* [PATCH] block: add a bdev_limits helper
@ 2024-10-29 14:19 Christoph Hellwig
2024-10-29 15:13 ` John Garry
2024-10-29 15:26 ` Jens Axboe
0 siblings, 2 replies; 4+ messages in thread
From: Christoph Hellwig @ 2024-10-29 14:19 UTC (permalink / raw)
To: axboe; +Cc: linux-block
Add a helper to get the queue_limits from the bdev without having to
poke into the request_queue.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
block/blk-merge.c | 3 +--
block/blk-settings.c | 2 +-
drivers/md/dm-cache-target.c | 4 ++--
drivers/md/dm-clone-target.c | 4 ++--
drivers/md/dm-thin.c | 2 +-
fs/btrfs/zoned.c | 7 ++-----
include/linux/blkdev.h | 15 ++++++++++-----
7 files changed, 19 insertions(+), 18 deletions(-)
diff --git a/block/blk-merge.c b/block/blk-merge.c
index 8b9a9646aed8..d813d799cee7 100644
--- a/block/blk-merge.c
+++ b/block/blk-merge.c
@@ -411,10 +411,9 @@ struct bio *bio_split_zone_append(struct bio *bio,
*/
struct bio *bio_split_to_limits(struct bio *bio)
{
- const struct queue_limits *lim = &bdev_get_queue(bio->bi_bdev)->limits;
unsigned int nr_segs;
- return __bio_split_to_limits(bio, lim, &nr_segs);
+ return __bio_split_to_limits(bio, bdev_limits(bio->bi_bdev), &nr_segs);
}
EXPORT_SYMBOL(bio_split_to_limits);
diff --git a/block/blk-settings.c b/block/blk-settings.c
index a446654ddee5..95fc39d09872 100644
--- a/block/blk-settings.c
+++ b/block/blk-settings.c
@@ -661,7 +661,7 @@ EXPORT_SYMBOL(blk_stack_limits);
void queue_limits_stack_bdev(struct queue_limits *t, struct block_device *bdev,
sector_t offset, const char *pfx)
{
- if (blk_stack_limits(t, &bdev_get_queue(bdev)->limits,
+ if (blk_stack_limits(t, bdev_limits(bdev),
get_start_sect(bdev) + offset))
pr_notice("%s: Warning: Device %pg is misaligned\n",
pfx, bdev);
diff --git a/drivers/md/dm-cache-target.c b/drivers/md/dm-cache-target.c
index 40709310e327..bc18255380b0 100644
--- a/drivers/md/dm-cache-target.c
+++ b/drivers/md/dm-cache-target.c
@@ -3361,7 +3361,7 @@ static int cache_iterate_devices(struct dm_target *ti,
static void disable_passdown_if_not_supported(struct cache *cache)
{
struct block_device *origin_bdev = cache->origin_dev->bdev;
- struct queue_limits *origin_limits = &bdev_get_queue(origin_bdev)->limits;
+ struct queue_limits *origin_limits = bdev_limits(origin_bdev);
const char *reason = NULL;
if (!cache->features.discard_passdown)
@@ -3383,7 +3383,7 @@ static void disable_passdown_if_not_supported(struct cache *cache)
static void set_discard_limits(struct cache *cache, struct queue_limits *limits)
{
struct block_device *origin_bdev = cache->origin_dev->bdev;
- struct queue_limits *origin_limits = &bdev_get_queue(origin_bdev)->limits;
+ struct queue_limits *origin_limits = bdev_limits(origin_bdev);
if (!cache->features.discard_passdown) {
/* No passdown is done so setting own virtual limits */
diff --git a/drivers/md/dm-clone-target.c b/drivers/md/dm-clone-target.c
index 12bbe487a4c8..e956d980672c 100644
--- a/drivers/md/dm-clone-target.c
+++ b/drivers/md/dm-clone-target.c
@@ -2020,7 +2020,7 @@ static void clone_resume(struct dm_target *ti)
static void disable_passdown_if_not_supported(struct clone *clone)
{
struct block_device *dest_dev = clone->dest_dev->bdev;
- struct queue_limits *dest_limits = &bdev_get_queue(dest_dev)->limits;
+ struct queue_limits *dest_limits = bdev_limits(dest_dev);
const char *reason = NULL;
if (!test_bit(DM_CLONE_DISCARD_PASSDOWN, &clone->flags))
@@ -2041,7 +2041,7 @@ static void disable_passdown_if_not_supported(struct clone *clone)
static void set_discard_limits(struct clone *clone, struct queue_limits *limits)
{
struct block_device *dest_bdev = clone->dest_dev->bdev;
- struct queue_limits *dest_limits = &bdev_get_queue(dest_bdev)->limits;
+ struct queue_limits *dest_limits = bdev_limits(dest_bdev);
if (!test_bit(DM_CLONE_DISCARD_PASSDOWN, &clone->flags)) {
/* No passdown is done so we set our own virtual limits */
diff --git a/drivers/md/dm-thin.c b/drivers/md/dm-thin.c
index 89632ce97760..9095f19a84f3 100644
--- a/drivers/md/dm-thin.c
+++ b/drivers/md/dm-thin.c
@@ -2842,7 +2842,7 @@ static void disable_discard_passdown_if_not_supported(struct pool_c *pt)
{
struct pool *pool = pt->pool;
struct block_device *data_bdev = pt->data_dev->bdev;
- struct queue_limits *data_limits = &bdev_get_queue(data_bdev)->limits;
+ struct queue_limits *data_limits = bdev_limits(data_bdev);
const char *reason = NULL;
if (!pt->adjusted_pf.discard_passdown)
diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c
index 826b128a6df0..32ce2edf582b 100644
--- a/fs/btrfs/zoned.c
+++ b/fs/btrfs/zoned.c
@@ -707,11 +707,8 @@ int btrfs_check_zoned_mode(struct btrfs_fs_info *fs_info)
* zoned mode. In this case, we don't have a valid max zone
* append size.
*/
- if (bdev_is_zoned(device->bdev)) {
- blk_stack_limits(lim,
- &bdev_get_queue(device->bdev)->limits,
- 0);
- }
+ if (bdev_is_zoned(device->bdev))
+ blk_stack_limits(lim, bdev_limits(device->bdev), 0);
}
/*
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index d0a52ed05e60..7bfc877e159e 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -1159,6 +1159,11 @@ enum blk_default_limits {
*/
#define BLK_DEF_MAX_SECTORS_CAP 2560u
+static inline struct queue_limits *bdev_limits(struct block_device *bdev)
+{
+ return &bdev_get_queue(bdev)->limits;
+}
+
static inline unsigned long queue_segment_boundary(const struct request_queue *q)
{
return q->limits.seg_boundary_mask;
@@ -1293,23 +1298,23 @@ unsigned int bdev_discard_alignment(struct block_device *bdev);
static inline unsigned int bdev_max_discard_sectors(struct block_device *bdev)
{
- return bdev_get_queue(bdev)->limits.max_discard_sectors;
+ return bdev_limits(bdev)->max_discard_sectors;
}
static inline unsigned int bdev_discard_granularity(struct block_device *bdev)
{
- return bdev_get_queue(bdev)->limits.discard_granularity;
+ return bdev_limits(bdev)->discard_granularity;
}
static inline unsigned int
bdev_max_secure_erase_sectors(struct block_device *bdev)
{
- return bdev_get_queue(bdev)->limits.max_secure_erase_sectors;
+ return bdev_limits(bdev)->max_secure_erase_sectors;
}
static inline unsigned int bdev_write_zeroes_sectors(struct block_device *bdev)
{
- return bdev_get_queue(bdev)->limits.max_write_zeroes_sectors;
+ return bdev_limits(bdev)->max_write_zeroes_sectors;
}
static inline bool bdev_nonrot(struct block_device *bdev)
@@ -1345,7 +1350,7 @@ static inline bool bdev_write_cache(struct block_device *bdev)
static inline bool bdev_fua(struct block_device *bdev)
{
- return bdev_get_queue(bdev)->limits.features & BLK_FEAT_FUA;
+ return bdev_limits(bdev)->features & BLK_FEAT_FUA;
}
static inline bool bdev_nowait(struct block_device *bdev)
--
2.45.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] block: add a bdev_limits helper
2024-10-29 14:19 [PATCH] block: add a bdev_limits helper Christoph Hellwig
@ 2024-10-29 15:13 ` John Garry
2024-10-29 15:16 ` Christoph Hellwig
2024-10-29 15:26 ` Jens Axboe
1 sibling, 1 reply; 4+ messages in thread
From: John Garry @ 2024-10-29 15:13 UTC (permalink / raw)
To: Christoph Hellwig, axboe; +Cc: linux-block
On 29/10/2024 14:19, Christoph Hellwig wrote:
> Add a helper to get the queue_limits from the bdev without having to
> poke into the request_queue.
>
> Signed-off-by: Christoph Hellwig<hch@lst.de>
> ---
This looks ok:
Reviewed-by: John Garry <john.g.garry@oracle.com>
I do note that there still seems to be patterns of calling
bdev_get_queue() and then examining the queue limits directly outside
block/, like do_region() in dm-io.c or lots of other drivers/md/ stuff
or loop_config_discard
I can try to help clean some up when I get a chance
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] block: add a bdev_limits helper
2024-10-29 15:13 ` John Garry
@ 2024-10-29 15:16 ` Christoph Hellwig
0 siblings, 0 replies; 4+ messages in thread
From: Christoph Hellwig @ 2024-10-29 15:16 UTC (permalink / raw)
To: John Garry; +Cc: Christoph Hellwig, axboe, linux-block
On Tue, Oct 29, 2024 at 03:13:10PM +0000, John Garry wrote:
> I do note that there still seems to be patterns of calling bdev_get_queue()
> and then examining the queue limits directly outside block/, like
> do_region() in dm-io.c or lots of other drivers/md/ stuff or
> loop_config_discard
>
> I can try to help clean some up when I get a chance
I'm slowly going through them. Have been a bit busy lately, but as
I have some pending code that can make use of bdev_limits() I expedited
them. If you want to take some on go for it, I have no immediate plans
as I'm pretty busy at the moment.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] block: add a bdev_limits helper
2024-10-29 14:19 [PATCH] block: add a bdev_limits helper Christoph Hellwig
2024-10-29 15:13 ` John Garry
@ 2024-10-29 15:26 ` Jens Axboe
1 sibling, 0 replies; 4+ messages in thread
From: Jens Axboe @ 2024-10-29 15:26 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: linux-block
On Tue, 29 Oct 2024 15:19:37 +0100, Christoph Hellwig wrote:
> Add a helper to get the queue_limits from the bdev without having to
> poke into the request_queue.
>
>
Applied, thanks!
[1/1] block: add a bdev_limits helper
(no commit info)
Best regards,
--
Jens Axboe
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-10-29 15:26 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-29 14:19 [PATCH] block: add a bdev_limits helper Christoph Hellwig
2024-10-29 15:13 ` John Garry
2024-10-29 15:16 ` Christoph Hellwig
2024-10-29 15:26 ` Jens Axboe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).