lightnvm: create cmd before allocating request
authorJavier González <jg@lightnvm.io>
Wed, 3 May 2017 09:19:04 +0000 (11:19 +0200)
committerJens Axboe <axboe@fb.com>
Thu, 4 May 2017 13:53:04 +0000 (07:53 -0600)
Create nvme command before allocating a request using
nvme_alloc_request, which uses the command direction. Up until now, the
command has been zeroized, so all commands have been allocated as a
read operation.

Signed-off-by: Javier González <javier@cnexlabs.com>
Reviewed-by: Matias Bjørling <matias@cnexlabs.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@fb.com>
drivers/nvme/host/lightnvm.c

index e4e4e60b1224f770ab89d0a4f0cde4e86d6eea42..8c4adac6fafcc56dfe37d05a51f45798e5194652 100644 (file)
@@ -503,6 +503,8 @@ static int nvme_nvm_submit_io(struct nvm_dev *dev, struct nvm_rq *rqd)
        if (!cmd)
                return -ENOMEM;
 
+       nvme_nvm_rqtocmd(rq, rqd, ns, cmd);
+
        rq = nvme_alloc_request(q, (struct nvme_command *)cmd, 0, NVME_QID_ANY);
        if (IS_ERR(rq)) {
                kfree(cmd);
@@ -517,8 +519,6 @@ static int nvme_nvm_submit_io(struct nvm_dev *dev, struct nvm_rq *rqd)
                rq->__data_len = 0;
        }
 
-       nvme_nvm_rqtocmd(rq, rqd, ns, cmd);
-
        rq->end_io_data = rqd;
 
        blk_execute_rq_nowait(q, NULL, rq, 0, nvme_nvm_end_io);