diff options
author | Pankaj Raghav <p.raghav@samsung.com> | 2023-01-10 15:36:35 +0100 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2023-01-29 15:18:34 -0700 |
commit | d67ea690ce0983dadf59cd06facc18f3acc89cea (patch) | |
tree | 5fbcbf0decc41e7b6c99e44bb290ce554c02ff81 /drivers | |
parent | e29b210021dcf8e03e0dcc035107afaeb55e6631 (diff) | |
download | linux-stable-d67ea690ce0983dadf59cd06facc18f3acc89cea.tar.gz linux-stable-d67ea690ce0983dadf59cd06facc18f3acc89cea.tar.bz2 linux-stable-d67ea690ce0983dadf59cd06facc18f3acc89cea.zip |
block: introduce bdev_zone_no helper
Add a generic bdev_zone_no() helper to calculate zone number for a
given sector in a block device. This helper internally uses disk_zone_no()
to find the zone number.
Use the helper bdev_zone_no() to calculate nr of zones. This lets us
make modifications to the math if needed in one place.
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
Signed-off-by: Pankaj Raghav <p.raghav@samsung.com>
Link: https://lore.kernel.org/r/20230110143635.77300-4-p.raghav@samsung.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/nvme/target/zns.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/drivers/nvme/target/zns.c b/drivers/nvme/target/zns.c index 1254cf57e008..7e4292d88016 100644 --- a/drivers/nvme/target/zns.c +++ b/drivers/nvme/target/zns.c @@ -254,8 +254,7 @@ static unsigned long nvmet_req_nr_zones_from_slba(struct nvmet_req *req) { unsigned int sect = nvmet_lba_to_sect(req->ns, req->cmd->zmr.slba); - return bdev_nr_zones(req->ns->bdev) - - (sect >> ilog2(bdev_zone_sectors(req->ns->bdev))); + return bdev_nr_zones(req->ns->bdev) - bdev_zone_no(req->ns->bdev, sect); } static unsigned long get_nr_zones_from_buf(struct nvmet_req *req, u32 bufsize) |