2020-08-10 17:17:52

by Lennart Poettering

[permalink] [raw]
Subject: [PATCH v2] loop: unset GENHD_FL_NO_PART_SCAN on LOOP_CONFIGURE

When LOOP_CONFIGURE is used with LO_FLAGS_PARTSCAN we need to propagate
this into the GENHD_FL_NO_PART_SCAN. LOOP_SETSTATUS does this,
LOOP_CONFIGURE doesn't so far. Effect is that setting up a loopback
device with partition scanning doesn't actually work when LOOP_CONFIGURE
is issued, though it works fine with LOOP_SETSTATUS.

Let's correct that and propagate the flag in LOOP_CONFIGURE too.

Fixes: 3448914e8cc5("loop: Add LOOP_CONFIGURE ioctl")

Signed-off-by: Lennart Poettering <[email protected]>
Acked-by: Martijn Coenen <[email protected]>
---
drivers/block/loop.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index d18160146226..2f137d6ce169 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -1171,6 +1171,8 @@ static int loop_configure(struct loop_device *lo, fmode_t mode,
if (part_shift)
lo->lo_flags |= LO_FLAGS_PARTSCAN;
partscan = lo->lo_flags & LO_FLAGS_PARTSCAN;
+ if (partscan)
+ lo->lo_disk->flags &= ~GENHD_FL_NO_PART_SCAN;

/* Grab the block_device to prevent its destruction after we
* put /dev/loopXX inode. Later in __loop_clr_fd() we bdput(bdev).
--
2.26.2


2020-08-11 06:50:14

by Martijn Coenen

[permalink] [raw]
Subject: Re: [PATCH v2] loop: unset GENHD_FL_NO_PART_SCAN on LOOP_CONFIGURE

On Mon, Aug 10, 2020 at 7:16 PM Lennart Poettering <[email protected]> wrote:
>
> When LOOP_CONFIGURE is used with LO_FLAGS_PARTSCAN we need to propagate
> this into the GENHD_FL_NO_PART_SCAN. LOOP_SETSTATUS does this,
> LOOP_CONFIGURE doesn't so far. Effect is that setting up a loopback
> device with partition scanning doesn't actually work when LOOP_CONFIGURE
> is issued, though it works fine with LOOP_SETSTATUS.
>
> Let's correct that and propagate the flag in LOOP_CONFIGURE too.
>
> Fixes: 3448914e8cc5("loop: Add LOOP_CONFIGURE ioctl")
>
> Signed-off-by: Lennart Poettering <[email protected]>
> Acked-by: Martijn Coenen <[email protected]>

Thanks, still looks good to me.

> ---
> drivers/block/loop.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/block/loop.c b/drivers/block/loop.c
> index d18160146226..2f137d6ce169 100644
> --- a/drivers/block/loop.c
> +++ b/drivers/block/loop.c
> @@ -1171,6 +1171,8 @@ static int loop_configure(struct loop_device *lo, fmode_t mode,
> if (part_shift)
> lo->lo_flags |= LO_FLAGS_PARTSCAN;
> partscan = lo->lo_flags & LO_FLAGS_PARTSCAN;
> + if (partscan)
> + lo->lo_disk->flags &= ~GENHD_FL_NO_PART_SCAN;
>
> /* Grab the block_device to prevent its destruction after we
> * put /dev/loopXX inode. Later in __loop_clr_fd() we bdput(bdev).
> --
> 2.26.2

2020-08-11 13:15:14

by Jens Axboe

[permalink] [raw]
Subject: Re: [PATCH v2] loop: unset GENHD_FL_NO_PART_SCAN on LOOP_CONFIGURE

On 8/11/20 12:49 AM, Martijn Coenen wrote:
> On Mon, Aug 10, 2020 at 7:16 PM Lennart Poettering <[email protected]> wrote:
>>
>> When LOOP_CONFIGURE is used with LO_FLAGS_PARTSCAN we need to propagate
>> this into the GENHD_FL_NO_PART_SCAN. LOOP_SETSTATUS does this,
>> LOOP_CONFIGURE doesn't so far. Effect is that setting up a loopback
>> device with partition scanning doesn't actually work when LOOP_CONFIGURE
>> is issued, though it works fine with LOOP_SETSTATUS.
>>
>> Let's correct that and propagate the flag in LOOP_CONFIGURE too.
>>
>> Fixes: 3448914e8cc5("loop: Add LOOP_CONFIGURE ioctl")
>>
>> Signed-off-by: Lennart Poettering <[email protected]>
>> Acked-by: Martijn Coenen <[email protected]>
>
> Thanks, still looks good to me.

Applied.

--
Jens Axboe