Bug 1173239 - command 'losetup -P' does not work in 15.2
command 'losetup -P' does not work in 15.2
Status: RESOLVED FIXED
Classification: openSUSE
Product: openSUSE Distribution
Classification: openSUSE
Component: Kernel
Leap 15.2
Other Other
: P5 - None : Normal (vote)
: Leap 15.2
Assigned To: Daniel Wagner
E-mail List
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2020-06-22 19:21 UTC by Giacomo Comes
Modified: 2020-06-24 15:26 UTC (History)
2 users (show)

See Also:
Found By: ---
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Giacomo Comes 2020-06-22 19:21:14 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:
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=linux-5.6.y&id=17d02cdd39c9c58d890214f92b9899d600ecc087
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.
Comment 1 Takashi Iwai 2020-06-24 10:12:05 UTC
It looks like the commit was blacklisted.
Daniel, could you check it again?
Comment 2 Daniel Wagner 2020-06-24 12:01:54 UTC
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
are missing.
Comment 3 Giacomo Comes 2020-06-24 14:48:08 UTC
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;
        int res;
 
-       if (bdev->bd_part_count || bdev->bd_openers > 1)
+       if (bdev->bd_part_count)
                return -EBUSY;
        res = invalidate_partition(disk, 0);
        if (res)
Comment 4 Daniel Wagner 2020-06-24 15:08:05 UTC
(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.
Comment 5 Michal Suchanek 2020-06-24 15:26:23 UTC
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

Thanks