]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
nvme: factor out a add nvme_is_write helper
authorChristoph Hellwig <hch@lst.de>
Mon, 6 Jun 2016 21:20:49 +0000 (23:20 +0200)
committerJens Axboe <axboe@fb.com>
Sun, 12 Jun 2016 13:29:43 +0000 (07:29 -0600)
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>
Reviewed-by: Keith Busch <keith.busch@intel.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
drivers/nvme/host/core.c
include/linux/nvme.h

index 7ded308fd67bbcfad8b55257cb20f5a99a1f1f27..45fd6cca4a27eb611dffdf247b4a58d30a409adb 100644 (file)
@@ -193,10 +193,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;
 
@@ -361,7 +360,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;
index 2b82f05fe4ecff25ceff54aa897ca74e311e8f02..dc815cc6718db546ef1c0ae80e1b7be7fd768bb3 100644 (file)
@@ -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,