All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dakshaja Uppalapati <dakshaja@chelsio.com>
To: eduard@hasenleithner.at, kbusch@kernel.org, sagi@grimberg.me,
	hch@lst.de, gregkh@linuxfoundation.org
Cc: nirranjan@chelsio.com, bharat@chelsio.com,
	Dakshaja Uppalapati <dakshaja@chelsio.com>,
	stable <stable@vger.kernel.org>
Subject: [PATCH nvme] nvme: Revert "nvme: Discard workaround for non-conformant devices"
Date: Wed,  3 Jun 2020 14:48:51 +0530	[thread overview]
Message-ID: <20200603091851.16957-1-dakshaja@chelsio.com> (raw)

This reverts upstream 'commit 530436c45ef2
("nvme: Discard workaround for non-conformant devices")'

Since commit `530436c45ef2` introduced a regression due to which
blk_update_request IO error is observed on formatting device, reverting it.

Fixes: 530436c45ef2 ("nvme: Discard workaround for non-conformant devices")
Cc: stable <stable@vger.kernel.org> # 4.19+
Signed-off-by: Dakshaja Uppalapati <dakshaja@chelsio.com>
---
 drivers/nvme/host/core.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index f3c037f5a9ba..ec598a86f88e 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -607,14 +607,8 @@ static blk_status_t nvme_setup_discard(struct nvme_ns *ns, struct request *req,
 	struct nvme_dsm_range *range;
 	struct bio *bio;
 
-	/*
-	 * Some devices do not consider the DSM 'Number of Ranges' field when
-	 * determining how much data to DMA. Always allocate memory for maximum
-	 * number of segments to prevent device reading beyond end of buffer.
-	 */
-	static const size_t alloc_size = sizeof(*range) * NVME_DSM_MAX_RANGES;
-
-	range = kzalloc(alloc_size, GFP_ATOMIC | __GFP_NOWARN);
+	range = kmalloc_array(segments, sizeof(*range),
+			      GFP_ATOMIC | __GFP_NOWARN);
 	if (!range) {
 		/*
 		 * If we fail allocation our range, fallback to the controller
@@ -654,7 +648,7 @@ static blk_status_t nvme_setup_discard(struct nvme_ns *ns, struct request *req,
 
 	req->special_vec.bv_page = virt_to_page(range);
 	req->special_vec.bv_offset = offset_in_page(range);
-	req->special_vec.bv_len = alloc_size;
+	req->special_vec.bv_len = sizeof(*range) * segments;
 	req->rq_flags |= RQF_SPECIAL_PAYLOAD;
 
 	return BLK_STS_OK;
-- 
2.18.0.232.gb7bd9486b.dirty


             reply	other threads:[~2020-06-03  9:21 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-03  9:18 Dakshaja Uppalapati [this message]
2020-06-03 13:07 ` [PATCH nvme] nvme: Revert "nvme: Discard workaround for non-conformant devices" Christoph Hellwig
2020-06-03 16:17   ` Dakshaja Uppalapati
2020-06-03 16:23     ` Christoph Hellwig
2020-06-03 21:20       ` Sagi Grimberg
2020-06-04  6:36         ` Dakshaja Uppalapati
2020-09-04 11:34           ` Greg KH
2020-06-05 13:43 ` Greg KH
2020-06-08  6:35   ` Dakshaja Uppalapati
2020-06-08 15:05     ` Keith Busch
2020-06-11 16:08       ` Dakshaja Uppalapati

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=20200603091851.16957-1-dakshaja@chelsio.com \
    --to=dakshaja@chelsio.com \
    --cc=bharat@chelsio.com \
    --cc=eduard@hasenleithner.at \
    --cc=gregkh@linuxfoundation.org \
    --cc=hch@lst.de \
    --cc=kbusch@kernel.org \
    --cc=nirranjan@chelsio.com \
    --cc=sagi@grimberg.me \
    --cc=stable@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.