[PATCH 09/14] nvmet: based on passthru req control use REQ_FUA

Chaitanya Kulkarni chaitanya.kulkarni at wdc.com
Mon Aug 10 14:54:51 EDT 2020


The write request for passthru driver currently does not consider
nvme control field which could be set in the nvme_rw_command from host
side.

Update op_flags with REQ_FUA when control field flag is set to
NVME_RW_FUA.

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni at wdc.com>
---
 drivers/nvme/target/passthru.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/nvme/target/passthru.c b/drivers/nvme/target/passthru.c
index 5f06f4290c52..a703f3f14b35 100644
--- a/drivers/nvme/target/passthru.c
+++ b/drivers/nvme/target/passthru.c
@@ -207,11 +207,15 @@ static int nvmet_passthru_map_sg(struct nvmet_req *req, struct request *rq)
 	struct bio *bio;
 	int i, ret;
 
-	if (nvme_is_write(req->cmd))
+	if (nvme_is_write(req->cmd)) {
 		op_flags = REQ_SYNC | REQ_IDLE;
-	else if (unlikely(nvmet_write_cmd_group(req->cmd->common.opcode)))
+		if (req->cmd->rw.control & cpu_to_le16(NVME_RW_FUA))
+			op_flags |= REQ_FUA;
+	} else if (unlikely(nvmet_write_cmd_group(req->cmd->common.opcode))) {
 		op_flags = REQ_SYNC;
-	else if (unlikely(req->cmd->common.opcode == nvme_cmd_flush))
+		if (req->cmd->rw.control & cpu_to_le16(NVME_RW_FUA))
+			op_flags |= REQ_FUA;
+	} else if (unlikely(req->cmd->common.opcode == nvme_cmd_flush))
 		op_flags = REQ_FUA;
 
 	bio = bio_alloc(GFP_KERNEL, min(sg_cnt, BIO_MAX_PAGES));
-- 
2.22.1




More information about the Linux-nvme mailing list