diff mbox series

[1/2] block: export blk_validate_limits

Message ID 20241113084541.34315-2-hch@lst.de (mailing list archive)
State New
Headers show
Series [1/2] block: export blk_validate_limits | expand

Commit Message

Christoph Hellwig Nov. 13, 2024, 8:45 a.m. UTC
While block drivers do the validation as part of committing them to the
queue, users that use the limit outside of a block device context have
to validate the limits and fill in the calculated values as well.

So far btrfs is the only user of queue limits without a block device,
and it has gotten away with that more or less by accident.  But with
commit 559218d43ec9 ("block: pre-calculate max_zone_append_sectors")
this became fatal for setups that have small max zone append size,
as it won't be limited now.

Export blk_validate_limits so that it can be called directly from btrfs.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 block/blk-settings.c   | 3 ++-
 include/linux/blkdev.h | 1 +
 2 files changed, 3 insertions(+), 1 deletion(-)

Comments

Johannes Thumshirn Nov. 13, 2024, 10:10 a.m. UTC | #1
Looks good,
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Jens Axboe Nov. 13, 2024, 6:46 p.m. UTC | #2
On Wed, 13 Nov 2024 09:45:35 +0100, Christoph Hellwig wrote:
> While block drivers do the validation as part of committing them to the
> queue, users that use the limit outside of a block device context have
> to validate the limits and fill in the calculated values as well.
> 
> So far btrfs is the only user of queue limits without a block device,
> and it has gotten away with that more or less by accident.  But with
> commit 559218d43ec9 ("block: pre-calculate max_zone_append_sectors")
> this became fatal for setups that have small max zone append size,
> as it won't be limited now.
> 
> [...]

Applied, thanks!

[1/2] block: export blk_validate_limits
      commit: 470d2bc3a0bc19a849cc7478c02d3f5ecaa1233e
[2/2] btrfs: validate queue limits
      commit: e559ee022658c70bdc07c4846bf279f5a5abc494

Best regards,
diff mbox series

Patch

diff --git a/block/blk-settings.c b/block/blk-settings.c
index 7d6b296997c2..f1d4dfdc37a7 100644
--- a/block/blk-settings.c
+++ b/block/blk-settings.c
@@ -222,7 +222,7 @@  static void blk_validate_atomic_write_limits(struct queue_limits *lim)
  * Check that the limits in lim are valid, initialize defaults for unset
  * values, and cap values based on others where needed.
  */
-static int blk_validate_limits(struct queue_limits *lim)
+int blk_validate_limits(struct queue_limits *lim)
 {
 	unsigned int max_hw_sectors;
 	unsigned int logical_block_sectors;
@@ -365,6 +365,7 @@  static int blk_validate_limits(struct queue_limits *lim)
 		return err;
 	return blk_validate_zoned_limits(lim);
 }
+EXPORT_SYMBOL_GPL(blk_validate_limits);
 
 /*
  * Set the default limits for a newly allocated queue.  @lim contains the
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 65f37ae70712..cd905afaf51a 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -948,6 +948,7 @@  queue_limits_start_update(struct request_queue *q)
 int queue_limits_commit_update(struct request_queue *q,
 		struct queue_limits *lim);
 int queue_limits_set(struct request_queue *q, struct queue_limits *lim);
+int blk_validate_limits(struct queue_limits *lim);
 
 /**
  * queue_limits_cancel_update - cancel an atomic update of queue limits