diff mbox series

[8/9] pmem: pass queue_limits to blk_mq_alloc_disk

Message ID 20240215071055.2201424-9-hch@lst.de (mailing list archive)
State New, archived
Headers show
Series [1/9] block: pass a queue_limits argument to blk_alloc_disk | expand

Commit Message

Christoph Hellwig Feb. 15, 2024, 7:10 a.m. UTC
Pass the queue limits directly to blk_alloc_disk instead of setting them
one at a time.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/nvdimm/pmem.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

Comments

Dave Jiang Feb. 15, 2024, 6:15 p.m. UTC | #1
On 2/15/24 12:10 AM, Christoph Hellwig wrote:
> Pass the queue limits directly to blk_alloc_disk instead of setting them
> one at a time.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>

Reviewed-by: Dave Jiang <dave.jiang@intel.com>
> ---
>  drivers/nvdimm/pmem.c | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c
> index 3a5df8d467c507..8dcc10b6db5b12 100644
> --- a/drivers/nvdimm/pmem.c
> +++ b/drivers/nvdimm/pmem.c
> @@ -451,6 +451,11 @@ static int pmem_attach_disk(struct device *dev,
>  {
>  	struct nd_namespace_io *nsio = to_nd_namespace_io(&ndns->dev);
>  	struct nd_region *nd_region = to_nd_region(dev->parent);
> +	struct queue_limits lim = {
> +		.logical_block_size	= pmem_sector_size(ndns),
> +		.physical_block_size	= PAGE_SIZE,
> +		.max_hw_sectors		= UINT_MAX,
> +	};
>  	int nid = dev_to_node(dev), fua;
>  	struct resource *res = &nsio->res;
>  	struct range bb_range;
> @@ -497,7 +502,7 @@ static int pmem_attach_disk(struct device *dev,
>  		return -EBUSY;
>  	}
>  
> -	disk = blk_alloc_disk(NULL, nid);
> +	disk = blk_alloc_disk(&lim, nid);
>  	if (IS_ERR(disk))
>  		return PTR_ERR(disk);
>  	q = disk->queue;
> @@ -539,9 +544,6 @@ static int pmem_attach_disk(struct device *dev,
>  	pmem->virt_addr = addr;
>  
>  	blk_queue_write_cache(q, true, fua);
> -	blk_queue_physical_block_size(q, PAGE_SIZE);
> -	blk_queue_logical_block_size(q, pmem_sector_size(ndns));
> -	blk_queue_max_hw_sectors(q, UINT_MAX);
>  	blk_queue_flag_set(QUEUE_FLAG_NONROT, q);
>  	blk_queue_flag_set(QUEUE_FLAG_SYNCHRONOUS, q);
>  	if (pmem->pfn_flags & PFN_MAP)
Chaitanya Kulkarni Feb. 17, 2024, 12:45 a.m. UTC | #2
On 2/14/24 23:10, Christoph Hellwig wrote:
> Pass the queue limits directly to blk_alloc_disk instead of setting them
> one at a time.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>

Looks good.

Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>

-ck
diff mbox series

Patch

diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c
index 3a5df8d467c507..8dcc10b6db5b12 100644
--- a/drivers/nvdimm/pmem.c
+++ b/drivers/nvdimm/pmem.c
@@ -451,6 +451,11 @@  static int pmem_attach_disk(struct device *dev,
 {
 	struct nd_namespace_io *nsio = to_nd_namespace_io(&ndns->dev);
 	struct nd_region *nd_region = to_nd_region(dev->parent);
+	struct queue_limits lim = {
+		.logical_block_size	= pmem_sector_size(ndns),
+		.physical_block_size	= PAGE_SIZE,
+		.max_hw_sectors		= UINT_MAX,
+	};
 	int nid = dev_to_node(dev), fua;
 	struct resource *res = &nsio->res;
 	struct range bb_range;
@@ -497,7 +502,7 @@  static int pmem_attach_disk(struct device *dev,
 		return -EBUSY;
 	}
 
-	disk = blk_alloc_disk(NULL, nid);
+	disk = blk_alloc_disk(&lim, nid);
 	if (IS_ERR(disk))
 		return PTR_ERR(disk);
 	q = disk->queue;
@@ -539,9 +544,6 @@  static int pmem_attach_disk(struct device *dev,
 	pmem->virt_addr = addr;
 
 	blk_queue_write_cache(q, true, fua);
-	blk_queue_physical_block_size(q, PAGE_SIZE);
-	blk_queue_logical_block_size(q, pmem_sector_size(ndns));
-	blk_queue_max_hw_sectors(q, UINT_MAX);
 	blk_queue_flag_set(QUEUE_FLAG_NONROT, q);
 	blk_queue_flag_set(QUEUE_FLAG_SYNCHRONOUS, q);
 	if (pmem->pfn_flags & PFN_MAP)