[PATCH blktests 2/2] loop/001: verify all partitions are removed

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



loop/001 does not test whether all partitions are removed successfully
during loop device partition scanning. As a result, the regression
introduced by 0da03cab87e6 ("loop: Fix deadlock when calling
blkdev_reread_part()") can not be detected.

The regression will generate below message in dmesg:

[  464.414043] __loop_clr_fd: partition scan of loop0 failed (rc=-22)

and leave orphan partitions like below:

- /dev/loop0p1
- /sys/block/loop0/loop0p1

This patch verifies all partitions are removed by checking if there is
/sys/block/loopX/loopXpY left. The expected number of partitions left is 0.

Signed-off-by: Dongli Zhang <dongli.zhang@xxxxxxxxxx>
---
 tests/loop/001     | 5 +++++
 tests/loop/001.out | 1 +
 2 files changed, 6 insertions(+)

diff --git a/tests/loop/001 b/tests/loop/001
index 47f760a..a0326b7 100755
--- a/tests/loop/001
+++ b/tests/loop/001
@@ -4,6 +4,9 @@
 #
 # Test loop device partition scanning. Regression test for commit e02898b42380
 # ("loop: fix LO_FLAGS_PARTSCAN hang").
+#
+# Test loop device paritition scanning. Regression test for commit 758a58d0bc67
+# ("loop: set GENHD_FL_NO_PART_SCAN after blkdev_reread_part()").
 
 . tests/loop/rc
 
@@ -24,9 +27,11 @@ test() {
 		mkpart primary 50% 100%
 
 	loop_device="$(losetup -P -f --show "$TMPDIR/img")"
+	loop_name=${loop_device:5}
 	lsblk -ln "$loop_device" | wc -l
 
 	losetup -d "$loop_device"
+	ls /sys/block/$loop_name | grep loop | wc -l
 	rm "$TMPDIR/img"
 	echo "Test complete"
 }
diff --git a/tests/loop/001.out b/tests/loop/001.out
index 75979f0..8c4917f 100644
--- a/tests/loop/001.out
+++ b/tests/loop/001.out
@@ -1,3 +1,4 @@
 Running loop/001
 3
+0
 Test complete
-- 
2.7.4




[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux