[PATCH 3/7] nvmet: file: add support of Compare command
Dmitry Bogdanov
d.bogdanov at yadro.com
Wed Sep 11 23:42:55 PDT 2024
Add handling of Compare command in file backend.
Signed-off-by: Dmitry Bogdanov <d.bogdanov at yadro.com>
---
drivers/nvme/target/io-cmd-file.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/drivers/nvme/target/io-cmd-file.c b/drivers/nvme/target/io-cmd-file.c
index 2d068439b129..27ceb1120d6a 100644
--- a/drivers/nvme/target/io-cmd-file.c
+++ b/drivers/nvme/target/io-cmd-file.c
@@ -114,6 +114,15 @@ static void nvmet_file_io_done(struct kiocb *iocb, long ret)
if (unlikely(ret != req->transfer_len))
status = errno_to_nvme_status(req, ret);
+
+ if (req->cmd->rw.opcode == nvme_cmd_compare) {
+ if (likely(!status))
+ status = nvmet_compare_sg(req);
+
+ sgl_free(req->sg);
+ req->sg = req->cmp_sg;
+ }
+
nvmet_req_complete(req, status);
}
@@ -227,6 +236,17 @@ static void nvmet_file_execute_rw(struct nvmet_req *req)
return;
}
+ if (req->cmd->rw.opcode == nvme_cmd_compare) {
+ req->cmp_sg = req->sg;
+ req->sg = sgl_alloc(nvmet_rw_data_len(req), GFP_KERNEL,
+ &req->sg_cnt);
+
+ if (unlikely(!req->sg || WARN_ON(nr_bvec != req->sg_cnt))) {
+ nvmet_req_complete(req, NVME_SC_INTERNAL);
+ return;
+ }
+ }
+
if (nr_bvec > NVMET_MAX_INLINE_BIOVEC)
req->f.bvec = kmalloc_array(nr_bvec, sizeof(struct bio_vec),
GFP_KERNEL);
@@ -365,6 +385,7 @@ u16 nvmet_file_parse_io_cmd(struct nvmet_req *req)
switch (req->cmd->common.opcode) {
case nvme_cmd_read:
case nvme_cmd_write:
+ case nvme_cmd_compare:
req->execute = nvmet_file_execute_rw;
return 0;
case nvme_cmd_flush:
--
2.25.1
More information about the Linux-nvme
mailing list