Linux-NVME Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] nvmet: fix nvmet_execute_write_zeroes function
@ 2018-04-02 14:49 Rodrigo R. Galvao
  2018-04-02 14:58 ` Keith Busch
  2018-04-05  1:34 ` Sasha Levin
  0 siblings, 2 replies; 5+ messages in thread
From: Rodrigo R. Galvao @ 2018-04-02 14:49 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 to within
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..5292bc3 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] 5+ messages in thread

* [PATCH v2] nvmet: fix nvmet_execute_write_zeroes function
  2018-04-02 14:49 [PATCH v2] nvmet: fix nvmet_execute_write_zeroes function Rodrigo R. Galvao
@ 2018-04-02 14:58 ` Keith Busch
  2018-04-02 16:31   ` Rodrigo Rosatti Galvao
  2018-04-05  1:34 ` Sasha Levin
  1 sibling, 1 reply; 5+ messages in thread
From: Keith Busch @ 2018-04-02 14:58 UTC (permalink / raw)


On Mon, Apr 02, 2018@11:49:41AM -0300, Rodrigo R. Galvao wrote:
> 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 to within
> 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..5292bc3 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));

I'm terribly sorry, but the +1 actually needs to be outside the
le16_to_cpu. The above will work on little-endian machines, but not big.

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

* [PATCH v2] nvmet: fix nvmet_execute_write_zeroes function
  2018-04-02 14:58 ` Keith Busch
@ 2018-04-02 16:31   ` Rodrigo Rosatti Galvao
  0 siblings, 0 replies; 5+ messages in thread
From: Rodrigo Rosatti Galvao @ 2018-04-02 16:31 UTC (permalink / raw)


> I'm terribly sorry, but the +1 actually needs to be outside the
> le16_to_cpu. The above will work on little-endian machines, but not big.

No problem at all. Thank you for helping on this.

I'm going to send a V3 with this change.

-- 
Rodrigo R. Galv?o
Intern - Linux Technology Center - IBM

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

* [PATCH v2] nvmet: fix nvmet_execute_write_zeroes function
  2018-04-02 14:49 [PATCH v2] nvmet: fix nvmet_execute_write_zeroes function Rodrigo R. Galvao
  2018-04-02 14:58 ` Keith Busch
@ 2018-04-05  1:34 ` Sasha Levin
  2018-04-05  1:48   ` Keith Busch
  1 sibling, 1 reply; 5+ messages in thread
From: Sasha Levin @ 2018-04-05  1:34 UTC (permalink / raw)


Hi "Rodrigo R. Galvao".

[This is an automated email]

This commit has been processed by the -stable helper bot and determined
to be a high probability candidate for -stable trees. (score: 6.9916)

The bot has tested the following trees: v4.15.15, v4.14.32, v4.9.92, v4.4.126, 

v4.15.15: Build OK!
v4.14.32: Build OK!
v4.9.92: Failed to apply! Possible dependencies:
    d262920998c8: ("nvmet: add support for the Write Zeroes command")
    78ce3daa7d70: ("nvmet: fix byte swap in nvmet_execute_write_zeroes")
    d262920998c8: ("nvmet: add support for the Write Zeroes command")

v4.4.126: Failed to apply! Possible dependencies:
    d262920998c8: ("nvmet: add support for the Write Zeroes command")
    a07b4970f464: ("nvmet: add a generic NVMe target")
    78ce3daa7d70: ("nvmet: fix byte swap in nvmet_execute_write_zeroes")
    d262920998c8: ("nvmet: add support for the Write Zeroes command")
    a07b4970f464: ("nvmet: add a generic NVMe target")


Please let us know if you'd like to have this patch included in a stable tree.

--
Thanks.
Sasha

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

* [PATCH v2] nvmet: fix nvmet_execute_write_zeroes function
  2018-04-05  1:34 ` Sasha Levin
@ 2018-04-05  1:48   ` Keith Busch
  0 siblings, 0 replies; 5+ messages in thread
From: Keith Busch @ 2018-04-05  1:48 UTC (permalink / raw)


On Thu, Apr 05, 2018@01:34:28AM +0000, Sasha Levin wrote:
> [This is an automated email]
> 
> This commit has been processed by the -stable helper bot and determined
> to be a high probability candidate for -stable trees. (score: 6.9916)
>
> The bot has tested the following trees: v4.15.15, v4.14.32, v4.9.92, v4.4.126, 

Nice! Good bot. :)
 
> v4.15.15: Build OK!
> v4.14.32: Build OK!
> v4.9.92: Failed to apply! Possible dependencies:
>     d262920998c8: ("nvmet: add support for the Write Zeroes command")
>     78ce3daa7d70: ("nvmet: fix byte swap in nvmet_execute_write_zeroes")
>     d262920998c8: ("nvmet: add support for the Write Zeroes command")
> 
> v4.4.126: Failed to apply! Possible dependencies:
>     d262920998c8: ("nvmet: add support for the Write Zeroes command")
>     a07b4970f464: ("nvmet: add a generic NVMe target")
>     78ce3daa7d70: ("nvmet: fix byte swap in nvmet_execute_write_zeroes")
>     d262920998c8: ("nvmet: add support for the Write Zeroes command")
>     a07b4970f464: ("nvmet: add a generic NVMe target")
> 
> 
> Please let us know if you'd like to have this patch included in a stable tree.

Yes, please! 4.14+ 

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

end of thread, other threads:[~2018-04-05  1:48 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-04-02 14:49 [PATCH v2] nvmet: fix nvmet_execute_write_zeroes function Rodrigo R. Galvao
2018-04-02 14:58 ` Keith Busch
2018-04-02 16:31   ` Rodrigo Rosatti Galvao
2018-04-05  1:34 ` Sasha Levin
2018-04-05  1:48   ` Keith Busch

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox