Commit e37c5cca authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Kleber Sacilotto de Souza

nvme: factor out a add nvme_is_write helper

BugLink: https://bugs.launchpad.net/bugs/1664602

Centralize the check if a given NVMe command reads or writes data.
Reviewed-by: default avatarSagi Grimberg <sagi@grimberg.me>
Reviewed-by: default avatarJay Freyensee <james.p.freyensee@intel.com>
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarKeith Busch <keith.busch@intel.com>
Signed-off-by: default avatarJens Axboe <axboe@fb.com>
(backported from commit 7a5abb4b)
Signed-off-by: default avatarKai-Heng Feng <kai.heng.feng@canonical.com>
Acked-By: default avatarAceLan Kao <acelan.kao@canonical.com>
Acked-By: default avatarShrirang Bagul <shrirang.bagul@canonical.com>
Signed-off-by: default avatarKhalid Elmously <khalid.elmously@canonical.com>
parent 0aa7cb3a
......@@ -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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment