All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] nvmet: Change error code of discard command if not supported
@ 2018-01-29 14:00 Israel Rukshin
  2018-01-29 18:30 ` Sagi Grimberg
  0 siblings, 1 reply; 4+ messages in thread
From: Israel Rukshin @ 2018-01-29 14:00 UTC (permalink / raw)


Execute discard command on block device that doesn't support it
should return not supported error.
Returning internal error while using multi-path fails the path.

Reviewed-by: Max Gurtovoy <maxg at mellanox.com>
Signed-off-by: Israel Rukshin <israelr at mellanox.com>
---
 drivers/nvme/target/io-cmd.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/nvme/target/io-cmd.c b/drivers/nvme/target/io-cmd.c
index 0a4372a..00d4607a 100644
--- a/drivers/nvme/target/io-cmd.c
+++ b/drivers/nvme/target/io-cmd.c
@@ -105,10 +105,15 @@ static void nvmet_execute_flush(struct nvmet_req *req)
 static u16 nvmet_discard_range(struct nvmet_ns *ns,
 		struct nvme_dsm_range *range, struct bio **bio)
 {
-	if (__blkdev_issue_discard(ns->bdev,
+	int ret;
+
+	ret = __blkdev_issue_discard(ns->bdev,
 			le64_to_cpu(range->slba) << (ns->blksize_shift - 9),
 			le32_to_cpu(range->nlb) << (ns->blksize_shift - 9),
-			GFP_KERNEL, 0, bio))
+			GFP_KERNEL, 0, bio);
+	if (ret == -EOPNOTSUPP)
+		return NVME_SC_INVALID_OPCODE | NVME_SC_DNR;
+	else if (ret)
 		return NVME_SC_INTERNAL | NVME_SC_DNR;
 	return 0;
 }
-- 
1.8.3.1

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

* [PATCH] nvmet: Change error code of discard command if not supported
  2018-01-29 14:00 [PATCH] nvmet: Change error code of discard command if not supported Israel Rukshin
@ 2018-01-29 18:30 ` Sagi Grimberg
  2018-01-29 23:56   ` Max Gurtovoy
  2018-01-30  7:05   ` Christoph Hellwig
  0 siblings, 2 replies; 4+ messages in thread
From: Sagi Grimberg @ 2018-01-29 18:30 UTC (permalink / raw)



> Execute discard command on block device that doesn't support it
> should return not supported error.
> Returning internal error while using multi-path fails the path.
> 
> Reviewed-by: Max Gurtovoy <maxg at mellanox.com>
> Signed-off-by: Israel Rukshin <israelr at mellanox.com>
> ---
>   drivers/nvme/target/io-cmd.c | 9 +++++++--
>   1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/nvme/target/io-cmd.c b/drivers/nvme/target/io-cmd.c
> index 0a4372a..00d4607a 100644
> --- a/drivers/nvme/target/io-cmd.c
> +++ b/drivers/nvme/target/io-cmd.c
> @@ -105,10 +105,15 @@ static void nvmet_execute_flush(struct nvmet_req *req)
>   static u16 nvmet_discard_range(struct nvmet_ns *ns,
>   		struct nvme_dsm_range *range, struct bio **bio)
>   {
> -	if (__blkdev_issue_discard(ns->bdev,
> +	int ret;
> +
> +	ret = __blkdev_issue_discard(ns->bdev,
>   			le64_to_cpu(range->slba) << (ns->blksize_shift - 9),
>   			le32_to_cpu(range->nlb) << (ns->blksize_shift - 9),
> -			GFP_KERNEL, 0, bio))
> +			GFP_KERNEL, 0, bio);
> +	if (ret == -EOPNOTSUPP)
> +		return NVME_SC_INVALID_OPCODE | NVME_SC_DNR;

Actually I don't think we are allowed to fail with this status. We claim
we support dsm regardless of the underlying backend device (because we
can expose different devices in the same subsystem), so we can't fail
a valid dsm command on invalid opcode. Either we keep the existing
behavior or we simply return success as dsm is a hint anyways...

> +	else if (ret)
>   		return NVME_SC_INTERNAL | NVME_SC_DNR;
>   	return 0;
>   }
> 

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

* [PATCH] nvmet: Change error code of discard command if not supported
  2018-01-29 18:30 ` Sagi Grimberg
@ 2018-01-29 23:56   ` Max Gurtovoy
  2018-01-30  7:05   ` Christoph Hellwig
  1 sibling, 0 replies; 4+ messages in thread
From: Max Gurtovoy @ 2018-01-29 23:56 UTC (permalink / raw)




On 1/29/2018 8:30 PM, Sagi Grimberg wrote:
> 
>> Execute discard command on block device that doesn't support it
>> should return not supported error.
>> Returning internal error while using multi-path fails the path.
>>
>> Reviewed-by: Max Gurtovoy <maxg at mellanox.com>
>> Signed-off-by: Israel Rukshin <israelr at mellanox.com>
>> ---
>> ? drivers/nvme/target/io-cmd.c | 9 +++++++--
>> ? 1 file changed, 7 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/nvme/target/io-cmd.c b/drivers/nvme/target/io-cmd.c
>> index 0a4372a..00d4607a 100644
>> --- a/drivers/nvme/target/io-cmd.c
>> +++ b/drivers/nvme/target/io-cmd.c
>> @@ -105,10 +105,15 @@ static void nvmet_execute_flush(struct nvmet_req 
>> *req)
>> ? static u16 nvmet_discard_range(struct nvmet_ns *ns,
>> ????????? struct nvme_dsm_range *range, struct bio **bio)
>> ? {
>> -??? if (__blkdev_issue_discard(ns->bdev,
>> +??? int ret;
>> +
>> +??? ret = __blkdev_issue_discard(ns->bdev,
>> ????????????? le64_to_cpu(range->slba) << (ns->blksize_shift - 9),
>> ????????????? le32_to_cpu(range->nlb) << (ns->blksize_shift - 9),
>> -??????????? GFP_KERNEL, 0, bio))
>> +??????????? GFP_KERNEL, 0, bio);
>> +??? if (ret == -EOPNOTSUPP)
>> +??????? return NVME_SC_INVALID_OPCODE | NVME_SC_DNR;
> 
> Actually I don't think we are allowed to fail with this status. We claim
> we support dsm regardless of the underlying backend device (because we
> can expose different devices in the same subsystem), so we can't fail
> a valid dsm command on invalid opcode. Either we keep the existing
> behavior or we simply return success as dsm is a hint anyways...

we can't fail a path in case the backend device doesn't support dsm. The 
avarage user that will try to create a fs using mkfs.ext4, for example, 
on top of a multipath device, without the appropriate flags will fail.
I'm fine with returning successful value, we'll test it and send a V2.

> 
>> +??? else if (ret)
>> ????????? return NVME_SC_INTERNAL | NVME_SC_DNR;
>> ????? return 0;
>> ? }
>>

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

* [PATCH] nvmet: Change error code of discard command if not supported
  2018-01-29 18:30 ` Sagi Grimberg
  2018-01-29 23:56   ` Max Gurtovoy
@ 2018-01-30  7:05   ` Christoph Hellwig
  1 sibling, 0 replies; 4+ messages in thread
From: Christoph Hellwig @ 2018-01-30  7:05 UTC (permalink / raw)


On Mon, Jan 29, 2018@08:30:45PM +0200, Sagi Grimberg wrote:
> Actually I don't think we are allowed to fail with this status. We claim
> we support dsm regardless of the underlying backend device (because we
> can expose different devices in the same subsystem), so we can't fail
> a valid dsm command on invalid opcode. Either we keep the existing
> behavior or we simply return success as dsm is a hint anyways...

Yes, we should return success here.

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

end of thread, other threads:[~2018-01-30  7:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-29 14:00 [PATCH] nvmet: Change error code of discard command if not supported Israel Rukshin
2018-01-29 18:30 ` Sagi Grimberg
2018-01-29 23:56   ` Max Gurtovoy
2018-01-30  7:05   ` Christoph Hellwig

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.