From: Jianchao Wang <jianchao.w.wang@oracle.com>
To: keith.busch@intel.com, axboe@fb.com, hch@lst.de, sagi@grimberg.me
Cc: linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: [PATCH V4 1/5] nvme: do atomically bit operations on nvme_request.flags
Date: Thu, 8 Mar 2018 14:19:27 +0800 [thread overview]
Message-ID: <1520489971-31174-2-git-send-email-jianchao.w.wang@oracle.com> (raw)
In-Reply-To: <1520489971-31174-1-git-send-email-jianchao.w.wang@oracle.com>
Do atomically bit operations on nvme_request.flags instead of
regular read/write, then we could add other flags and set/clear
them safely.
Signed-off-by: Jianchao Wang <jianchao.w.wang@oracle.com>
---
drivers/nvme/host/core.c | 4 ++--
drivers/nvme/host/lightnvm.c | 4 ++--
drivers/nvme/host/nvme.h | 4 ++--
drivers/nvme/host/pci.c | 4 ++--
4 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 29ead91..7b8df47 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -674,7 +674,7 @@ int __nvme_submit_sync_cmd(struct request_queue *q, struct nvme_command *cmd,
blk_execute_rq(req->q, NULL, req, at_head);
if (result)
*result = nvme_req(req)->result;
- if (nvme_req(req)->flags & NVME_REQ_CANCELLED)
+ if (test_bit(NVME_REQ_CANCELLED, &nvme_req(req)->flags))
ret = -EINTR;
else
ret = nvme_req(req)->status;
@@ -763,7 +763,7 @@ static int nvme_submit_user_cmd(struct request_queue *q,
}
blk_execute_rq(req->q, disk, req, 0);
- if (nvme_req(req)->flags & NVME_REQ_CANCELLED)
+ if (test_bit(NVME_REQ_CANCELLED, &nvme_req(req)->flags))
ret = -EINTR;
else
ret = nvme_req(req)->status;
diff --git a/drivers/nvme/host/lightnvm.c b/drivers/nvme/host/lightnvm.c
index 50ef71ee..fd0c499 100644
--- a/drivers/nvme/host/lightnvm.c
+++ b/drivers/nvme/host/lightnvm.c
@@ -470,7 +470,7 @@ static int nvme_nvm_submit_io_sync(struct nvm_dev *dev, struct nvm_rq *rqd)
* handle the error accordingly.
*/
blk_execute_rq(q, NULL, rq, 0);
- if (nvme_req(rq)->flags & NVME_REQ_CANCELLED)
+ if (test_bit(NVME_REQ_CANCELLED, &nvme_req(rq)->flags))
ret = -EINTR;
rqd->ppa_status = le64_to_cpu(nvme_req(rq)->result.u64);
@@ -599,7 +599,7 @@ static int nvme_nvm_submit_user_cmd(struct request_queue *q,
blk_execute_rq(q, NULL, rq, 0);
- if (nvme_req(rq)->flags & NVME_REQ_CANCELLED)
+ if (test_bit(NVME_REQ_CANCELLED, &nvme_req(rq)->flags))
ret = -EINTR;
else if (nvme_req(rq)->status & 0x7ff)
ret = -EIO;
diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h
index e80fd74..02097e8 100644
--- a/drivers/nvme/host/nvme.h
+++ b/drivers/nvme/host/nvme.h
@@ -93,8 +93,8 @@ struct nvme_request {
struct nvme_command *cmd;
union nvme_result result;
u8 retries;
- u8 flags;
u16 status;
+ unsigned long flags;
};
/*
@@ -103,7 +103,7 @@ struct nvme_request {
#define REQ_NVME_MPATH REQ_DRV
enum {
- NVME_REQ_CANCELLED = (1 << 0),
+ NVME_REQ_CANCELLED = 0,
};
static inline struct nvme_request *nvme_req(struct request *req)
diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index 73036d2..e186158 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -1222,7 +1222,7 @@ static enum blk_eh_timer_return nvme_timeout(struct request *req, bool reserved)
"I/O %d QID %d timeout, disable controller\n",
req->tag, nvmeq->qid);
nvme_dev_disable(dev, false);
- nvme_req(req)->flags |= NVME_REQ_CANCELLED;
+ set_bit(NVME_REQ_CANCELLED, &nvme_req(req)->flags);
return BLK_EH_HANDLED;
default:
break;
@@ -1244,7 +1244,7 @@ static enum blk_eh_timer_return nvme_timeout(struct request *req, bool reserved)
* Mark the request as handled, since the inline shutdown
* forces all outstanding requests to complete.
*/
- nvme_req(req)->flags |= NVME_REQ_CANCELLED;
+ set_bit(NVME_REQ_CANCELLED, &nvme_req(req)->flags);
return BLK_EH_HANDLED;
}
--
2.7.4
next prev parent reply other threads:[~2018-03-08 6:22 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-08 6:19 PATCH V4 0/5 nvme-pci: fixes on nvme_timeout and nvme_dev_disable Jianchao Wang
2018-03-08 6:19 ` Jianchao Wang [this message]
2018-03-08 7:57 ` [PATCH V4 1/5] nvme: do atomically bit operations on nvme_request.flags Christoph Hellwig
2018-03-08 14:32 ` jianchao.wang
2018-03-08 6:19 ` [PATCH V4 2/5] nvme: add helper interface to flush in-flight requests Jianchao Wang
2018-03-08 13:11 ` Ming Lei
2018-03-08 14:44 ` jianchao.wang
2018-03-08 18:21 ` Sagi Grimberg
2018-03-09 1:59 ` jianchao.wang
2018-03-08 6:19 ` [PATCH V4 3/5] nvme-pci: avoid nvme_dev_disable to be invoked in nvme_timeout Jianchao Wang
2018-03-09 2:01 ` jianchao.wang
2018-03-13 13:29 ` jianchao.wang
2018-03-08 6:19 ` [PATCH V4 4/5] nvme-pci: discard wait timeout when delete cq/sq Jianchao Wang
2018-03-08 6:19 ` [PATCH V4 5/5] nvme-pci: add the timeout case for DELETEING state Jianchao Wang
2018-04-17 15:17 ` PATCH V4 0/5 nvme-pci: fixes on nvme_timeout and nvme_dev_disable Ming Lei
2018-04-18 14:24 ` jianchao.wang
2018-04-18 15:40 ` Ming Lei
2018-04-19 1:51 ` jianchao.wang
2018-04-19 2:27 ` Ming Lei
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=1520489971-31174-2-git-send-email-jianchao.w.wang@oracle.com \
--to=jianchao.w.wang@oracle.com \
--cc=axboe@fb.com \
--cc=hch@lst.de \
--cc=keith.busch@intel.com \
--cc=linux-kernel@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;
as well as URLs for NNTP newsgroup(s).