All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: axboe@kernel.dk, keith.busch@intel.com
Cc: linux-nvme@lists.infradead.org, linux-block@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH 07/10] nvme: factor out a add nvme_is_write helper
Date: Mon,  6 Jun 2016 23:20:49 +0200	[thread overview]
Message-ID: <1465248052-17811-8-git-send-email-hch@lst.de> (raw)
In-Reply-To: <1465248052-17811-1-git-send-email-hch@lst.de>

Centralize the check if a given NVMe command reads or writes data.

Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Reviewed-by: Jay Freyensee <james.p.freyensee@intel.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/nvme/host/core.c | 5 ++---
 include/linux/nvme.h     | 5 +++++
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index b582c11..ffd9910 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -176,10 +176,9 @@ EXPORT_SYMBOL_GPL(nvme_requeue_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;
 
@@ -344,7 +343,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;
diff --git a/include/linux/nvme.h b/include/linux/nvme.h
index 2b82f05..dc815cc 100644
--- a/include/linux/nvme.h
+++ b/include/linux/nvme.h
@@ -590,6 +590,11 @@ struct nvme_command {
 	};
 };
 
+static inline bool nvme_is_write(struct nvme_command *cmd)
+{
+	return cmd->common.opcode & 1;
+}
+
 enum {
 	NVME_SC_SUCCESS			= 0x0,
 	NVME_SC_INVALID_OPCODE		= 0x1,
-- 
2.1.4

WARNING: multiple messages have this Message-ID (diff)
From: hch@lst.de (Christoph Hellwig)
Subject: [PATCH 07/10] nvme: factor out a add nvme_is_write helper
Date: Mon,  6 Jun 2016 23:20:49 +0200	[thread overview]
Message-ID: <1465248052-17811-8-git-send-email-hch@lst.de> (raw)
In-Reply-To: <1465248052-17811-1-git-send-email-hch@lst.de>

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>
---
 drivers/nvme/host/core.c | 5 ++---
 include/linux/nvme.h     | 5 +++++
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index b582c11..ffd9910 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -176,10 +176,9 @@ EXPORT_SYMBOL_GPL(nvme_requeue_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;
 
@@ -344,7 +343,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;
diff --git a/include/linux/nvme.h b/include/linux/nvme.h
index 2b82f05..dc815cc 100644
--- a/include/linux/nvme.h
+++ b/include/linux/nvme.h
@@ -590,6 +590,11 @@ struct nvme_command {
 	};
 };
 
+static inline bool nvme_is_write(struct nvme_command *cmd)
+{
+	return cmd->common.opcode & 1;
+}
+
 enum {
 	NVME_SC_SUCCESS			= 0x0,
 	NVME_SC_INVALID_OPCODE		= 0x1,
-- 
2.1.4

  parent reply	other threads:[~2016-06-06 21:20 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-06 21:20 general preparation for NVMe over Fabrics support Christoph Hellwig
2016-06-06 21:20 ` Christoph Hellwig
2016-06-06 21:20 ` [PATCH 01/10] nvme.h: add RTD3R, RTD3E and OAES fields Christoph Hellwig
2016-06-06 21:20   ` Christoph Hellwig
2016-06-07  8:10   ` Johannes Thumshirn
2016-06-07  8:10     ` Johannes Thumshirn
2016-06-07  8:10     ` Johannes Thumshirn
2016-06-07  8:38     ` Johannes Thumshirn
2016-06-07  8:38       ` Johannes Thumshirn
2016-06-07  8:38       ` Johannes Thumshirn
2016-06-07 10:49     ` Christoph Hellwig
2016-06-07 10:49       ` Christoph Hellwig
2016-06-06 21:20 ` [PATCH 02/10] nvme.h: Add get_log_page command strucure Christoph Hellwig
2016-06-06 21:20   ` Christoph Hellwig
2016-06-06 21:20 ` [PATCH 03/10] nvme.h: add NVM command set SQE/CQE size defines Christoph Hellwig
2016-06-06 21:20   ` Christoph Hellwig
2016-06-06 21:20 ` [PATCH 04/10] nvme.h: add AER constants Christoph Hellwig
2016-06-06 21:20   ` Christoph Hellwig
2016-06-06 21:20 ` [PATCH 05/10] nvme.h: add constants for PSDT and FUSE values Christoph Hellwig
2016-06-06 21:20   ` Christoph Hellwig
2016-06-06 21:20 ` [PATCH 06/10] nvme: allow for size limitations from transport drivers Christoph Hellwig
2016-06-06 21:20   ` Christoph Hellwig
2016-06-06 21:20 ` Christoph Hellwig [this message]
2016-06-06 21:20   ` [PATCH 07/10] nvme: factor out a add nvme_is_write helper Christoph Hellwig
2016-06-06 21:20 ` [PATCH 08/10] nvme: move the workaround for I/O queue-less controllers from PCIe to core Christoph Hellwig
2016-06-06 21:20   ` Christoph Hellwig
2016-06-06 21:20 ` [PATCH 09/10] nvme: update nvme_cancel_io() a bit Christoph Hellwig
2016-06-06 21:20   ` Christoph Hellwig
2016-06-06 21:20 ` [PATCH 10/10] nvme: move nvme_cancel_request() to core.c Christoph Hellwig
2016-06-06 21:20   ` Christoph Hellwig
2016-06-09 16:38 ` general preparation for NVMe over Fabrics support Keith Busch
2016-06-09 16:38   ` Keith Busch
2016-06-09 17:12   ` Christoph Hellwig
2016-06-09 17:12     ` Christoph Hellwig
2016-06-12 13:33   ` Jens Axboe
2016-06-12 13:33     ` Jens Axboe
2016-06-13  8:03     ` Christoph Hellwig
2016-06-13  8:03       ` Christoph Hellwig

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=1465248052-17811-8-git-send-email-hch@lst.de \
    --to=hch@lst.de \
    --cc=axboe@kernel.dk \
    --cc=keith.busch@intel.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    /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 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.