From: Chao Leng <lengchao@huawei.com>
To: <linux-nvme@lists.infradead.org>
Cc: <linux-block@vger.kernel.org>, <kbusch@kernel.org>,
<axboe@fb.com>, <hch@lst.de>, <sagi@grimberg.me>,
<lengchao@huawei.com>
Subject: [PATCH 1/3] nvme-core: improve avoiding false remove namespace
Date: Thu, 20 Aug 2020 11:53:57 +0800 [thread overview]
Message-ID: <20200820035357.1634-1-lengchao@huawei.com> (raw)
nvme_revalidate_disk translate return error to 0 if it is not a fatal
error, thus avoid false remove namespace. If return error less than 0,
now only ENOMEM be translated to 0, but other error except ENODEV,
such as EAGAIN or EBUSY etc, also need translate to 0.
Another reason for improving the error translation: If request timeout
when connect, __nvme_submit_sync_cmd will return
NVME_SC_HOST_ABORTED_CMD(>0). At this time, should terminate the
connect process, but falsely continue the connect process,
this may cause deadlock. Many functions which call
__nvme_submit_sync_cmd treat error code(> 0) as target not support and
continue, but NVME_SC_HOST_ABORTED_CMD and NVME_SC_HOST_PATH_ERROR both
are cancled io by host, to fix this bug, we need set the flag:
NVME_REQ_CANCELLED, thus __nvme_submit_sync_cmd will translate return
error to INTR. This is conflict with error translation of
nvme_revalidate_disk, may cause false remove namespace.
Signed-off-by: Chao Leng <lengchao@huawei.com>
---
drivers/nvme/host/core.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 88cff309d8e4..43ac8a1ad65d 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -2130,10 +2130,10 @@ static int _nvme_revalidate_disk(struct gendisk *disk)
* Only fail the function if we got a fatal error back from the
* device, otherwise ignore the error and just move on.
*/
- if (ret == -ENOMEM || (ret > 0 && !(ret & NVME_SC_DNR)))
- ret = 0;
- else if (ret > 0)
+ if (ret > 0 && (ret & NVME_SC_DNR))
ret = blk_status_to_errno(nvme_error_status(ret));
+ else if (ret != -ENODEV)
+ ret = 0;
return ret;
}
--
2.16.4
next reply other threads:[~2020-08-20 3:54 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-20 3:53 Chao Leng [this message]
2020-08-20 4:33 ` [PATCH 1/3] nvme-core: improve avoiding false remove namespace Sagi Grimberg
2020-08-20 6:22 ` Chao Leng
2020-08-20 8:29 ` Christoph Hellwig
2020-08-20 15:44 ` Sagi Grimberg
2020-08-21 1:36 ` Chao Leng
2020-08-21 6:25 ` Christoph Hellwig
2020-08-21 20:23 ` Sagi Grimberg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200820035357.1634-1-lengchao@huawei.com \
--to=lengchao@huawei.com \
--cc=axboe@fb.com \
--cc=hch@lst.de \
--cc=kbusch@kernel.org \
--cc=linux-block@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=sagi@grimberg.me \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox