All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3] nvmet: fix nvmet_execute_write_zeroes function
@ 2018-04-02 16:31 ` Rodrigo R. Galvao
  0 siblings, 0 replies; 8+ messages in thread
From: Rodrigo R. Galvao @ 2018-04-02 16:31 UTC (permalink / raw)
  Cc: hch, sagi, linux-nvme, linux-kernel, rosattig, rodrigorosattig

When trying to issue write_zeroes command against TARGET with a 4K block
size, it ends up hitting the following condition at __blkdev_issue_zeroout:

     if ((sector | nr_sects) & bs_mask)
                return -EINVAL;

Causing the command to always fail.
Considering we need to add 1 to get the correct block count, that addition
needs to be performed in the native format, so we moved the +1 right after
le16_to_cpu prior to converting to 512b.

Signed-off-by: Rodrigo R. Galvao <rosattig@linux.vnet.ibm.com>
---
 drivers/nvme/target/io-cmd.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/nvme/target/io-cmd.c b/drivers/nvme/target/io-cmd.c
index 28bbdff..cd23441 100644
--- a/drivers/nvme/target/io-cmd.c
+++ b/drivers/nvme/target/io-cmd.c
@@ -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))
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v3] nvmet: fix nvmet_execute_write_zeroes function
@ 2018-04-02 16:31 ` Rodrigo R. Galvao
  0 siblings, 0 replies; 8+ messages in thread
From: Rodrigo R. Galvao @ 2018-04-02 16:31 UTC (permalink / raw)


When trying to issue write_zeroes command against TARGET with a 4K block
size, it ends up hitting the following condition at __blkdev_issue_zeroout:

     if ((sector | nr_sects) & bs_mask)
                return -EINVAL;

Causing the command to always fail.
Considering we need to add 1 to get the correct block count, that addition
needs to be performed in the native format, so we moved the +1 right after
le16_to_cpu prior to converting to 512b.

Signed-off-by: Rodrigo R. Galvao <rosattig at linux.vnet.ibm.com>
---
 drivers/nvme/target/io-cmd.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/nvme/target/io-cmd.c b/drivers/nvme/target/io-cmd.c
index 28bbdff..cd23441 100644
--- a/drivers/nvme/target/io-cmd.c
+++ b/drivers/nvme/target/io-cmd.c
@@ -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))
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH v3] nvmet: fix nvmet_execute_write_zeroes function
  2018-04-02 16:31 ` Rodrigo R. Galvao
@ 2018-04-02 17:38   ` Keith Busch
  -1 siblings, 0 replies; 8+ messages in thread
From: Keith Busch @ 2018-04-02 17:38 UTC (permalink / raw)
  To: Rodrigo R. Galvao; +Cc: hch, sagi, linux-nvme, linux-kernel, rodrigorosattig

Thanks, I've applied the patch with a simpler changelog explaining
the bug.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v3] nvmet: fix nvmet_execute_write_zeroes function
@ 2018-04-02 17:38   ` Keith Busch
  0 siblings, 0 replies; 8+ messages in thread
From: Keith Busch @ 2018-04-02 17:38 UTC (permalink / raw)


Thanks, I've applied the patch with a simpler changelog explaining
the bug.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v3] nvmet: fix nvmet_execute_write_zeroes function
  2018-04-02 17:38   ` Keith Busch
@ 2018-04-03 15:11     ` Max Gurtovoy
  -1 siblings, 0 replies; 8+ messages in thread
From: Max Gurtovoy @ 2018-04-03 15:11 UTC (permalink / raw)
  To: Keith Busch, Rodrigo R. Galvao
  Cc: rodrigorosattig, linux-kernel, hch, linux-nvme, sagi



On 4/2/2018 8:38 PM, Keith Busch wrote:
> Thanks, I've applied the patch with a simpler changelog explaining
> the bug.

Thanks Rodrigo and Keith, I've tested with/w.o the patch and it works 
well (with the fix only).

-Max.

> 
> _______________________________________________
> Linux-nvme mailing list
> Linux-nvme@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-nvme
> 

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v3] nvmet: fix nvmet_execute_write_zeroes function
@ 2018-04-03 15:11     ` Max Gurtovoy
  0 siblings, 0 replies; 8+ messages in thread
From: Max Gurtovoy @ 2018-04-03 15:11 UTC (permalink / raw)




On 4/2/2018 8:38 PM, Keith Busch wrote:
> Thanks, I've applied the patch with a simpler changelog explaining
> the bug.

Thanks Rodrigo and Keith, I've tested with/w.o the patch and it works 
well (with the fix only).

-Max.

> 
> _______________________________________________
> Linux-nvme mailing list
> Linux-nvme at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-nvme
> 

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v3] nvmet: fix nvmet_execute_write_zeroes function
  2018-04-02 16:31 ` Rodrigo R. Galvao
@ 2018-04-04 10:00   ` Sagi Grimberg
  -1 siblings, 0 replies; 8+ messages in thread
From: Sagi Grimberg @ 2018-04-04 10:00 UTC (permalink / raw)
  To: Rodrigo R. Galvao; +Cc: hch, linux-nvme, linux-kernel, rodrigorosattig

Reviewed-by: Sagi Grimberg <sagi@grimberg.me>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v3] nvmet: fix nvmet_execute_write_zeroes function
@ 2018-04-04 10:00   ` Sagi Grimberg
  0 siblings, 0 replies; 8+ messages in thread
From: Sagi Grimberg @ 2018-04-04 10:00 UTC (permalink / raw)


Reviewed-by: Sagi Grimberg <sagi at grimberg.me>

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2018-04-04 10:00 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-02 16:31 [PATCH v3] nvmet: fix nvmet_execute_write_zeroes function Rodrigo R. Galvao
2018-04-02 16:31 ` Rodrigo R. Galvao
2018-04-02 17:38 ` Keith Busch
2018-04-02 17:38   ` Keith Busch
2018-04-03 15:11   ` Max Gurtovoy
2018-04-03 15:11     ` Max Gurtovoy
2018-04-04 10:00 ` Sagi Grimberg
2018-04-04 10:00   ` Sagi Grimberg

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.