]> git.neil.brown.name Git - linux.git/commitdiff
nvmet: add a new nvmet_zero_sgl helper
authorChristoph Hellwig <hch@lst.de>
Tue, 22 May 2018 09:10:02 +0000 (11:10 +0200)
committerChristoph Hellwig <hch@lst.de>
Fri, 1 Jun 2018 12:37:35 +0000 (14:37 +0200)
Zeroes the SGL in the payload.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
drivers/nvme/target/core.c
drivers/nvme/target/nvmet.h

index 800aaf96ddcd42f3094847bfb42207715567e35d..55c4bc693aa2ff6514bbf0e17fd74d456cb129e6 100644 (file)
@@ -57,6 +57,13 @@ u16 nvmet_copy_from_sgl(struct nvmet_req *req, off_t off, void *buf, size_t len)
        return 0;
 }
 
+u16 nvmet_zero_sgl(struct nvmet_req *req, off_t off, size_t len)
+{
+       if (sg_zero_buffer(req->sg, req->sg_cnt, len, off) != len)
+               return NVME_SC_SGL_INVALID_DATA | NVME_SC_DNR;
+       return 0;
+}
+
 static unsigned int nvmet_max_nsid(struct nvmet_subsys *subsys)
 {
        struct nvmet_ns *ns;
index 32ebffcf464ce0a9f6c1b66d418fc2083fd95593..768abe203298438ac1f983053f7bf660b1fd3059 100644 (file)
@@ -330,6 +330,7 @@ u16 nvmet_copy_to_sgl(struct nvmet_req *req, off_t off, const void *buf,
                size_t len);
 u16 nvmet_copy_from_sgl(struct nvmet_req *req, off_t off, void *buf,
                size_t len);
+u16 nvmet_zero_sgl(struct nvmet_req *req, off_t off, size_t len);
 
 u32 nvmet_get_log_page_len(struct nvme_command *cmd);