stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ming Lei <ming.lei@redhat.com>
To: linux-nvme@lists.infradead.org, Christoph Hellwig <hch@lst.de>
Cc: Ming Lei <ming.lei@redhat.com>, Yi Zhang <yi.zhang@redhat.com>,
	Sagi Grimberg <sagi@grimberg.me>,
	Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>,
	stable@vger.kernel.org
Subject: [PATCH 2/4] nvmet: fix computation of io vector number
Date: Tue, 26 Mar 2019 11:19:26 +0800	[thread overview]
Message-ID: <20190326031928.9499-3-ming.lei@redhat.com> (raw)
In-Reply-To: <20190326031928.9499-1-ming.lei@redhat.com>

Current file backed ns code uses request data length to compute
number of io vector.

This way is actually wrong, the warning in nvmet_file_execute_io()
may be triggered because the sg->offset isn't considered.

Given the sg list is only single-page for nvme target, simply use
the req->sg_cnt as number of io vector.

Reported-by: Yi Zhang <yi.zhang@redhat.com>
Fixes: d5eff33ee6f8("nvmet: add simple file backed ns support")
Cc: Yi Zhang <yi.zhang@redhat.com>
Cc: Sagi Grimberg <sagi@grimberg.me>
Cc: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Ming Lei <ming.lei@redhat.com>
---
 drivers/nvme/target/io-cmd-file.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/nvme/target/io-cmd-file.c b/drivers/nvme/target/io-cmd-file.c
index 3e43212d3c1c..d67a43832cb1 100644
--- a/drivers/nvme/target/io-cmd-file.c
+++ b/drivers/nvme/target/io-cmd-file.c
@@ -128,7 +128,7 @@ 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);
+	ssize_t nr_bvec = req->sg_cnt;
 	struct sg_page_iter sg_pg_iter;
 	unsigned long bv_cnt = 0;
 	bool is_sync = false;
@@ -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);
-- 
2.9.5


  parent reply	other threads:[~2019-03-26  3:19 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20190326031928.9499-1-ming.lei@redhat.com>
2019-03-26  3:19 ` [PATCH 1/4] nvmet: set loop queue's segment boundary mask as PAGE_SIZE - 1 Ming Lei
2019-03-26  7:36   ` Christoph Hellwig
2019-03-26  7:37     ` Ming Lei
2019-03-26  7:39       ` Ming Lei
2019-03-27  8:15       ` Christoph Hellwig
2019-03-27  8:26         ` Ming Lei
2019-03-27  8:39           ` Christoph Hellwig
2019-03-26  3:19 ` Ming Lei [this message]
2019-03-26  7:38   ` [PATCH 2/4] nvmet: fix computation of io vector number Christoph Hellwig
2019-03-26  7:50     ` Ming Lei
2019-03-27  8:15       ` Christoph Hellwig
2019-03-26  3:19 ` [PATCH 3/4] nvmet: fix computation of bvec->bv_len Ming Lei

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190326031928.9499-3-ming.lei@redhat.com \
    --to=ming.lei@redhat.com \
    --cc=chaitanya.kulkarni@wdc.com \
    --cc=hch@lst.de \
    --cc=linux-nvme@lists.infradead.org \
    --cc=sagi@grimberg.me \
    --cc=stable@vger.kernel.org \
    --cc=yi.zhang@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).