Description of problem: When 'dmsetup remove_all' is executed in an environment that many maps exist, some /sys/block/dm-* remain even though those devices aren't used and all maps are removed. Version-Release number of selected component: device-mapper-1.02.12-2.el5 kernel-2.6.18-1.2745.el5 How reproducible: Almost always in many maps environment on a specific system. But very rare on other systems. Steps to Reproduce: 1. Run attached script. # ./dmsetup-remove-all-fail.sh The attached script do the following: o Create a file and setup a loop-back device by using the file o Run 100 linear maps creation with using the loop-back device, 'sleep 3' and 'dmsetup remove_all' repeatedly. o The test stops when the problem occurs or after 1000 trials. Actual results: The script stops with 'Exit test.' message below. At the time, /sys/block/dm-* remain. -------------------------------------------------------------------- [root@nec-em4 ~]# ./dmsetup-remove-all-fail.sh INFO: Creating a file for loop setup. file=tmpfile 100+0 records in 100+0 records out 51200 bytes (51 kB) copied, 0.000862744 seconds, 59.3 MB/s INFO: Setting up loop device. dev=/dev/loop0 file=tmpfile INFO: Start map create/remove testing. INFO: Test stops when a problem occurs or after 1000 trials. INFO: Start TRIAL 0 INFO: Creating linear maps. nr_map=100 INFO: Removing all maps. INFO: Start TRIAL 1 INFO: Creating linear maps. nr_map=100 INFO: Removing all maps. ERROR: The problem occurs. Exit test. INFO: Manual clean-up is needed. [root@nec-em4 ~]# dmsetup ls No devices found [root@nec-em4 ~]# ls /sys/block/ dm-21 hda loop2 loop5 md0 ram10 ram13 ram2 ram5 ram8 sdb dm-60 loop0 loop3 loop6 ram0 ram11 ram14 ram3 ram6 ram9 sdc fd0 loop1 loop4 loop7 ram1 ram12 ram15 ram4 ram7 sda sdd [root@nec-em4 ~]# ls /sys/block/dm-*/holders /sys/block/dm-21/holders: /sys/block/dm-60/holders: [root@nec-em4 ~]# -------------------------------------------------------------------- Expected results: The script finishes with 'INFO: Test finished with no problem.' message. Additional info: This problem doesn't occur in RHEL4 U4. This problem seems to be prone not to occur in a few maps environment. This problem often occurs on the NEC Express5800 110Ej in Westford, but very rare on other systems.
Created attachment 140846 [details] Test script
This request was evaluated by Red Hat Product Management for inclusion in a Red Hat Enterprise Linux major release. Product Management has requested further review of this request by Red Hat Engineering, for potential inclusion in a Red Hat Enterprise Linux Major release. This request is not yet committed for inclusion.
Created attachment 140935 [details] FIx find_device race Original header: There is a race between dev_create() and find_device(). If the mdptr has not yet been stored against a device, find_device() needs to behave as though no device was found. It already returns NULL, but there is a dm_put() missing: it must drop the reference dm_get_md() took. The bug was introduced by dm-fix-mapped-device-ref-counting.patch. It manifests itself if another dm ioctl attempts to reference a newly-created device while the device creation ioctl is still running. The consequence is that the device cannot be removed until the machine is rebooted. Certain udev configurations can lead to this happening. Signed-off-by: Alasdair G Kergon <agk> Cc: dm-devel
in 2.6.18-1.2767.el5
A package has been built which should help the problem described in this bug report. This report is therefore being closed with a resolution of CURRENTRELEASE. You may reopen this bug report if the solution does not work for you.