diff mbox series

[03/15] block: decouple blk_set_stacking_limits from blk_set_default_limits

Message ID 20240212064609.1327143-4-hch@lst.de (mailing list archive)
State New, archived
Headers show
Series [01/15] block: move max_{open,active}_zones to struct queue_limits | expand

Commit Message

Christoph Hellwig Feb. 12, 2024, 6:45 a.m. UTC
blk_set_stacking_limits uses very little from blk_set_default_limits.
Open code these initializations in preparation for rewriting
blk_set_default_limits.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 block/blk-settings.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

Comments

Damien Le Moal Feb. 12, 2024, 7:14 a.m. UTC | #1
On 2/12/24 15:45, Christoph Hellwig wrote:
> blk_set_stacking_limits uses very little from blk_set_default_limits.
> Open code these initializations in preparation for rewriting
> blk_set_default_limits.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  block/blk-settings.c | 11 +++++++----
>  1 file changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/block/blk-settings.c b/block/blk-settings.c
> index f16d3fec6658e5..1cae2db41490d2 100644
> --- a/block/blk-settings.c
> +++ b/block/blk-settings.c
> @@ -65,13 +65,16 @@ void blk_set_default_limits(struct queue_limits *lim)
>   * blk_set_stacking_limits - set default limits for stacking devices
>   * @lim:  the queue_limits structure to reset
>   *
> - * Description:
> - *   Returns a queue_limit struct to its default state. Should be used
> - *   by stacking drivers like DM that have no internal limits.
> + * Prepare queue limits for applying limits from underlying devices using
> + * blk_stack_limits().
>   */
>  void blk_set_stacking_limits(struct queue_limits *lim)
>  {
> -	blk_set_default_limits(lim);
> +	memset(lim, 0, sizeof(*lim));
> +	lim->logical_block_size = lim->physical_block_size = lim->io_min = 512;
> +	lim->discard_granularity = 512;

Super minor nit: SECTOR_SIZE would be nice here.

> +	lim->dma_alignment = 511;
> +	lim->seg_boundary_mask = BLK_SEG_BOUNDARY_MASK;
>  
>  	/* Inherit limits from component devices */
>  	lim->max_segments = USHRT_MAX;

Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Hannes Reinecke Feb. 12, 2024, 7:25 a.m. UTC | #2
On 2/12/24 14:45, Christoph Hellwig wrote:
> blk_set_stacking_limits uses very little from blk_set_default_limits.
> Open code these initializations in preparation for rewriting
> blk_set_default_limits.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>   block/blk-settings.c | 11 +++++++----
>   1 file changed, 7 insertions(+), 4 deletions(-)
> 

Reviewed-by: Hannes Reinecke <hare@suse.de>

Cheers,

Hannes
Christoph Hellwig Feb. 12, 2024, 7:28 a.m. UTC | #3
On Mon, Feb 12, 2024 at 04:14:48PM +0900, Damien Le Moal wrote:
> > -	blk_set_default_limits(lim);
> > +	memset(lim, 0, sizeof(*lim));
> > +	lim->logical_block_size = lim->physical_block_size = lim->io_min = 512;
> > +	lim->discard_granularity = 512;
> 
> Super minor nit: SECTOR_SIZE would be nice here.

Just a code movement / copy, but otherwise yes.  This code should go
away when updating the stacking to the new API, so I'm not going to
bother.
diff mbox series

Patch

diff --git a/block/blk-settings.c b/block/blk-settings.c
index f16d3fec6658e5..1cae2db41490d2 100644
--- a/block/blk-settings.c
+++ b/block/blk-settings.c
@@ -65,13 +65,16 @@  void blk_set_default_limits(struct queue_limits *lim)
  * blk_set_stacking_limits - set default limits for stacking devices
  * @lim:  the queue_limits structure to reset
  *
- * Description:
- *   Returns a queue_limit struct to its default state. Should be used
- *   by stacking drivers like DM that have no internal limits.
+ * Prepare queue limits for applying limits from underlying devices using
+ * blk_stack_limits().
  */
 void blk_set_stacking_limits(struct queue_limits *lim)
 {
-	blk_set_default_limits(lim);
+	memset(lim, 0, sizeof(*lim));
+	lim->logical_block_size = lim->physical_block_size = lim->io_min = 512;
+	lim->discard_granularity = 512;
+	lim->dma_alignment = 511;
+	lim->seg_boundary_mask = BLK_SEG_BOUNDARY_MASK;
 
 	/* Inherit limits from component devices */
 	lim->max_segments = USHRT_MAX;