nvmet: Introduce nvmet_dsm_len() helper
authorChristoph Hellwig <hch@lst.de>
Wed, 23 Oct 2019 16:35:43 +0000 (10:35 -0600)
committerJens Axboe <axboe@kernel.dk>
Mon, 4 Nov 2019 17:56:42 +0000 (10:56 -0700)
Similar to the nvmet_rw_len helper.

Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
[split patch, update changelog]
Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
Signed-off-by: Keith Busch <kbusch@kernel.org>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/nvme/target/io-cmd-file.c
drivers/nvme/target/nvmet.h

index 05453f5d1448621b4eb262a7717833bf6f4729ee..7481556da6e6761adb80546efa4596f379662b2f 100644 (file)
@@ -379,8 +379,7 @@ u16 nvmet_file_parse_io_cmd(struct nvmet_req *req)
                return 0;
        case nvme_cmd_dsm:
                req->execute = nvmet_file_execute_dsm;
-               req->data_len = (le32_to_cpu(cmd->dsm.nr) + 1) *
-                       sizeof(struct nvme_dsm_range);
+               req->data_len = nvmet_dsm_len(req);
                return 0;
        case nvme_cmd_write_zeroes:
                req->execute = nvmet_file_execute_write_zeroes;
index c51f8dd01dc487a1395e3a3ff5350cf260046118..6ccf2d098d9fe89c1b27cf4f7e05f2cdba5c3b10 100644 (file)
@@ -495,6 +495,12 @@ static inline u32 nvmet_rw_len(struct nvmet_req *req)
                        req->ns->blksize_shift;
 }
 
+static inline u32 nvmet_dsm_len(struct nvmet_req *req)
+{
+       return (le32_to_cpu(req->cmd->dsm.nr) + 1) *
+               sizeof(struct nvme_dsm_range);
+}
+
 u16 errno_to_nvme_status(struct nvmet_req *req, int errno);
 
 /* Convert a 32-bit number to a 16-bit 0's based number */