Bugzilla – Bug 1173239
command 'losetup -P' does not work in 15.2
Last modified: 2020-06-24 15:26:23 UTC
I have a usb disk image on file with several partitions on it.
Normally I would run:
losetup -P -f --show usb.img
and such command would attach the file usb.img to a loop device (/dev/loop0)
and it would create also the devices /dev/loop0p1, /dev/loop0p<n> for each partition in the image file.
Such command works in 15.1 but fails in 15.2. dmesg shows:
loop_reread_partitions: partition scan of loop0 (usb.img) failed (rc=-16)
Instead with the latest kernelstable installed losetup -P works as expected.
I have found this 5.6.11 commit:
I have applied such modification to the kernel 5.3.18-lp152.19 of 15.2 and I can confirm that such commit fixes the problem.
It looks like the commit was blacklisted.
Daniel, could you check it again?
Yes, this is the commit which reverts two previously 'faulty' commits:
> 3ef5536274faf89e626276b833be122a16bdb81 # reverted by 10c70d95c0f2 ("block: remove the bd_openers checks in blk_drop_partitions")
> cb6b771b05c3026a85ed4817c1b87c5e6f41d136 # reverted by 10c70d95c0f2 ("block: remove the bd_openers checks in blk_drop_partitions")
> 10c70d95c0f2f9a6f52d0e33243d2877370cef51 # reverts previous commits: d3ef5536274f ("block: fix busy device checking in blk_drop_partitions") and cb6b771b05c3 ("block: fix busy device checking in blk_drop_partitions again")
That means 17d02cdd39c9 is not needed if 3ef5536274f and cb6b771b05c30
So, with the current 15.2 kernel "losetup -P" does not work, and the commit that fix the issue is is not needed. What's next?
For the record here is the unneeded fix that I'm using.
diff -Nraub linux.ori/block/partition-generic.c linux/block/partition-generic.c
--- linux.ori/block/partition-generic.c 2020-06-09 16:59:24.000000000 -0400
+++ linux/block/partition-generic.c 2020-06-22 10:20:22.432854702 -0400
@@ -463,7 +463,7 @@
struct hd_struct *part;
- if (bdev->bd_part_count || bdev->bd_openers > 1)
+ if (bdev->bd_part_count)
res = invalidate_partition(disk, 0);
(In reply to Giacomo Comes from comment #3)
> So, with the current 15.2 kernel "losetup -P" does not work, and the commit
> that fix the issue is is not needed. What's next?
> For the record here is the unneeded fix that I'm using.
Sorry for the confusion. We initially back ported the two patches which
are invalid. Instead back porting the third patch to revert the first two,
we just dropped the first two patches. The result should be same.
That said, I don't know why the dropping of the two initial patches
haven't made it yet to Leap 15.2.
The fix is expected to make it into first Leap 15.2 MU, and should appear in the KOTD tomorrow https://build.opensuse.org/project/show/Kernel:openSUSE-15.2