* [PATCH] nbd: Respect max_part for all partition scans
@ 2020-12-17 8:58 Josh Triplett
2020-12-17 14:39 ` Josef Bacik
2020-12-17 14:55 ` Jens Axboe
0 siblings, 2 replies; 3+ messages in thread
From: Josh Triplett @ 2020-12-17 8:58 UTC (permalink / raw)
To: Josef Bacik, Jens Axboe; +Cc: linux-block, nbd, linux-kernel
The creation path of the NBD device respects max_part and only scans for
partitions if max_part is not 0. However, some other code paths ignore
max_part, and unconditionally scan for partitions. Add a check for
max_part on each partition scan.
Signed-off-by: Josh Triplett <josh@joshtriplett.org>
---
Caught this when reading recent NBD patches, which tweaked the
nbd_set_size path.
It doesn't seem worth factoring these two lines into a function,
especially since the callers obtain the disk structure in different
ways.
drivers/block/nbd.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index 92f84ed0ba9e..6727358e147d 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -318,7 +318,8 @@ static int nbd_set_size(struct nbd_device *nbd, loff_t bytesize,
blk_queue_logical_block_size(nbd->disk->queue, blksize);
blk_queue_physical_block_size(nbd->disk->queue, blksize);
- set_bit(GD_NEED_PART_SCAN, &nbd->disk->state);
+ if (max_part)
+ set_bit(GD_NEED_PART_SCAN, &nbd->disk->state);
if (!set_capacity_and_notify(nbd->disk, bytesize >> 9))
kobject_uevent(&nbd_to_dev(nbd)->kobj, KOBJ_CHANGE);
return 0;
@@ -1476,9 +1477,11 @@ static int nbd_open(struct block_device *bdev, fmode_t mode)
refcount_set(&nbd->config_refs, 1);
refcount_inc(&nbd->refs);
mutex_unlock(&nbd->config_lock);
- set_bit(GD_NEED_PART_SCAN, &bdev->bd_disk->state);
+ if (max_part)
+ set_bit(GD_NEED_PART_SCAN, &bdev->bd_disk->state);
} else if (nbd_disconnected(nbd->config)) {
- set_bit(GD_NEED_PART_SCAN, &bdev->bd_disk->state);
+ if (max_part)
+ set_bit(GD_NEED_PART_SCAN, &bdev->bd_disk->state);
}
out:
mutex_unlock(&nbd_index_mutex);
--
2.29.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] nbd: Respect max_part for all partition scans
2020-12-17 8:58 [PATCH] nbd: Respect max_part for all partition scans Josh Triplett
@ 2020-12-17 14:39 ` Josef Bacik
2020-12-17 14:55 ` Jens Axboe
1 sibling, 0 replies; 3+ messages in thread
From: Josef Bacik @ 2020-12-17 14:39 UTC (permalink / raw)
To: Josh Triplett, Jens Axboe; +Cc: linux-block, nbd, linux-kernel
On 12/17/20 3:58 AM, Josh Triplett wrote:
> The creation path of the NBD device respects max_part and only scans for
> partitions if max_part is not 0. However, some other code paths ignore
> max_part, and unconditionally scan for partitions. Add a check for
> max_part on each partition scan.
>
> Signed-off-by: Josh Triplett <josh@joshtriplett.org>
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Thanks,
Josef
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] nbd: Respect max_part for all partition scans
2020-12-17 8:58 [PATCH] nbd: Respect max_part for all partition scans Josh Triplett
2020-12-17 14:39 ` Josef Bacik
@ 2020-12-17 14:55 ` Jens Axboe
1 sibling, 0 replies; 3+ messages in thread
From: Jens Axboe @ 2020-12-17 14:55 UTC (permalink / raw)
To: Josh Triplett, Josef Bacik; +Cc: linux-block, nbd, linux-kernel
On 12/17/20 1:58 AM, Josh Triplett wrote:
> The creation path of the NBD device respects max_part and only scans for
> partitions if max_part is not 0. However, some other code paths ignore
> max_part, and unconditionally scan for partitions. Add a check for
> max_part on each partition scan.
Applied, thanks.
--
Jens Axboe
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-12-17 14:56 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-17 8:58 [PATCH] nbd: Respect max_part for all partition scans Josh Triplett
2020-12-17 14:39 ` Josef Bacik
2020-12-17 14:55 ` Jens Axboe
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.