Home Home > GIT Browse
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Thumshirn <jthumshirn@suse.de>2019-04-08 13:44:39 +0200
committerJohannes Thumshirn <jthumshirn@suse.de>2019-04-08 13:44:39 +0200
commit70dafbdb5ac3a56e78d24a85d06d686a657aa776 (patch)
treee9ad5f93136ee68f7cb112d24556a52fbcc94023
parentee31e753a4c25ce45428d30206941d060fb84b15 (diff)
nvmet: fix building bvec from sg list (bsc#1131837).
-rw-r--r--patches.fixes/nvmet-fix-building-bvec-from-sg-list.patch88
-rw-r--r--series.conf1
2 files changed, 89 insertions, 0 deletions
diff --git a/patches.fixes/nvmet-fix-building-bvec-from-sg-list.patch b/patches.fixes/nvmet-fix-building-bvec-from-sg-list.patch
new file mode 100644
index 0000000000..06923f5d25
--- /dev/null
+++ b/patches.fixes/nvmet-fix-building-bvec-from-sg-list.patch
@@ -0,0 +1,88 @@
+From: Ming Lei <ming.lei@redhat.com>
+Date: Wed, 27 Mar 2019 17:07:22 +0800
+Subject: nvmet: fix building bvec from sg list
+Git-commit: 02db99548d3608a625cf481cff2bb7b626829b3f
+Patch-mainline: v5.1-rc3
+References: bsc#1131837
+
+There are two mistakes for building bvec from sg list for file
+backed ns:
+
+- use request data length to compute number of io vector, this way
+doesn't consider sg->offset, and the result may be smaller than required
+io vectors
+
+- bvec->bv_len isn't capped by sg->length
+
+This patch fixes this issue by building bvec from sg directly, given
+the whole IO stack is ready for multi-page bvec.
+
+Reported-by: Yi Zhang <yi.zhang@redhat.com>
+Fixes: 3a85a5de29ea ("nvme-loop: add a NVMe loopback host driver")
+
+Signed-off-by: Ming Lei <ming.lei@redhat.com>
+Signed-off-by: Christoph Hellwig <hch@lst.de>
+Acked-by: Johannes Thumshirn <jthumshirn@suse.de>
+---
+ drivers/nvme/target/io-cmd-file.c | 20 ++++++++++----------
+ 1 file changed, 10 insertions(+), 10 deletions(-)
+
+diff --git a/drivers/nvme/target/io-cmd-file.c b/drivers/nvme/target/io-cmd-file.c
+index 3e43212d3c1c..bc6ebb51b0bf 100644
+--- a/drivers/nvme/target/io-cmd-file.c
++++ b/drivers/nvme/target/io-cmd-file.c
+@@ -75,11 +75,11 @@ int nvmet_file_ns_enable(struct nvmet_ns *ns)
+ return ret;
+ }
+
+-static void nvmet_file_init_bvec(struct bio_vec *bv, struct sg_page_iter *iter)
++static void nvmet_file_init_bvec(struct bio_vec *bv, struct scatterlist *sg)
+ {
+- bv->bv_page = sg_page_iter_page(iter);
+- bv->bv_offset = iter->sg->offset;
+- bv->bv_len = PAGE_SIZE - iter->sg->offset;
++ bv->bv_page = sg_page(sg);
++ bv->bv_offset = sg->offset;
++ bv->bv_len = sg->length;
+ }
+
+ static ssize_t nvmet_file_submit_bvec(struct nvmet_req *req, loff_t pos,
+@@ -128,14 +128,14 @@ static void nvmet_file_io_done(struct kiocb *iocb, long ret, long ret2)
+
+ static bool nvmet_file_execute_io(struct nvmet_req *req, int ki_flags)
+ {
+- ssize_t nr_bvec = DIV_ROUND_UP(req->data_len, PAGE_SIZE);
+- struct sg_page_iter sg_pg_iter;
++ ssize_t nr_bvec = req->sg_cnt;
+ unsigned long bv_cnt = 0;
+ bool is_sync = false;
+ size_t len = 0, total_len = 0;
+ ssize_t ret = 0;
+ loff_t pos;
+-
++ int i;
++ struct scatterlist *sg;
+
+ if (req->f.mpool_alloc && nr_bvec > NVMET_MAX_MPOOL_BVEC)
+ is_sync = true;
+@@ -147,8 +147,8 @@ static bool nvmet_file_execute_io(struct nvmet_req *req, int ki_flags)
+ }
+
+ memset(&req->f.iocb, 0, sizeof(struct kiocb));
+- for_each_sg_page(req->sg, &sg_pg_iter, req->sg_cnt, 0) {
+- nvmet_file_init_bvec(&req->f.bvec[bv_cnt], &sg_pg_iter);
++ for_each_sg(req->sg, sg, req->sg_cnt, i) {
++ nvmet_file_init_bvec(&req->f.bvec[bv_cnt], sg);
+ len += req->f.bvec[bv_cnt].bv_len;
+ total_len += req->f.bvec[bv_cnt].bv_len;
+ bv_cnt++;
+@@ -225,7 +225,7 @@ static void nvmet_file_submit_buffered_io(struct nvmet_req *req)
+
+ static void nvmet_file_execute_rw(struct nvmet_req *req)
+ {
+- ssize_t nr_bvec = DIV_ROUND_UP(req->data_len, PAGE_SIZE);
++ ssize_t nr_bvec = req->sg_cnt;
+
+ if (!req->sg_cnt || !nr_bvec) {
+ nvmet_req_complete(req, 0);
+
diff --git a/series.conf b/series.conf
index 656cf2401d..b071ca7ea6 100644
--- a/series.conf
+++ b/series.conf
@@ -44873,6 +44873,7 @@
patches.drm/0001-drm-i915-gvt-Don-t-submit-request-for-error-workload.patch
patches.drm/drm-i915-selftests-Fix-an-IS_ERR-vs-NULL-check.patch
patches.drm/drm-i915-icl-Fix-VEBOX-mismatch-BUG_ON.patch
+ patches.fixes/nvmet-fix-building-bvec-from-sg-list.patch
patches.suse/kbuild-modversions-Fix-relative-CRC-byte-order-inter.patch
patches.drivers/ALSA-rawmidi-Fix-potential-Spectre-v1-vulnerability.patch
patches.drivers/ALSA-seq-oss-Fix-Spectre-v1-vulnerability.patch