nvmet: Fix nvmet_execute_write_zeroes sector count
authorRodrigo R. Galvao <rosattig@linux.vnet.ibm.com>
Thu, 12 Apr 2018 15:16:11 +0000 (09:16 -0600)
committerJens Axboe <axboe@kernel.dk>
Thu, 12 Apr 2018 15:58:27 +0000 (09:58 -0600)
We have to increment the number of logical blocks to a 1's based value
in the native format prior to converting to 512b units.

Signed-off-by: Rodrigo R. Galvao <rosattig@linux.vnet.ibm.com>
[changelog]
Signed-off-by: Keith Busch <keith.busch@intel.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/nvme/target/io-cmd.c

index 28bbdff4a88baa27cb2398597cc02529c49e19f4..cd23441796731960e76b9d3b07b48f18572aa20b 100644 (file)
@@ -173,8 +173,8 @@ static void nvmet_execute_write_zeroes(struct nvmet_req *req)
 
        sector = le64_to_cpu(write_zeroes->slba) <<
                (req->ns->blksize_shift - 9);
-       nr_sector = (((sector_t)le16_to_cpu(write_zeroes->length)) <<
-               (req->ns->blksize_shift - 9)) + 1;
+       nr_sector = (((sector_t)le16_to_cpu(write_zeroes->length) + 1) <<
+               (req->ns->blksize_shift - 9));
 
        if (__blkdev_issue_zeroout(req->ns->bdev, sector, nr_sector,
                                GFP_KERNEL, &bio, 0))