[PATCH 03/10] nvme: factor out a add nvme_is_write helper
Kai-Heng Feng
kai.heng.feng at canonical.com
Fri Apr 28 04:20:15 UTC 2017
From: Christoph Hellwig <hch at lst.de>
BugLink: https://bugs.launchpad.net/bugs/1664602
Centralize the check if a given NVMe command reads or writes data.
Reviewed-by: Sagi Grimberg <sagi at grimberg.me>
Reviewed-by: Jay Freyensee <james.p.freyensee at intel.com>
Signed-off-by: Christoph Hellwig <hch at lst.de>
Reviewed-by: Keith Busch <keith.busch at intel.com>
Signed-off-by: Jens Axboe <axboe at fb.com>
(backported from commit 7a5abb4b48570c3552e33ff4c72ae1e8dac3ba15)
Signed-off-by: Kai-Heng Feng <kai.heng.feng at canonical.com>
---
drivers/nvme/host/core.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index b9c6f98fd109..455b1c91fd3e 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -92,10 +92,9 @@ void nvme_requeue_req(struct request *req)
struct request *nvme_alloc_request(struct request_queue *q,
struct nvme_command *cmd, unsigned int flags)
{
- bool write = cmd->common.opcode & 1;
struct request *req;
- req = blk_mq_alloc_request(q, write, flags);
+ req = blk_mq_alloc_request(q, nvme_is_write(cmd), flags);
if (IS_ERR(req))
return req;
@@ -153,7 +152,7 @@ int __nvme_submit_user_cmd(struct request_queue *q, struct nvme_command *cmd,
void __user *meta_buffer, unsigned meta_len, u32 meta_seed,
u32 *result, unsigned timeout)
{
- bool write = cmd->common.opcode & 1;
+ bool write = nvme_is_write(cmd);
struct nvme_completion cqe;
struct nvme_ns *ns = q->queuedata;
struct gendisk *disk = ns ? ns->disk : NULL;
--
2.12.2
More information about the kernel-team
mailing list