From: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
To: Sasha Levin <sashal@kernel.org>
Cc: gregkh@linuxfoundation.org, ming.lei@redhat.com, axboe@kernel.dk,
hch@lst.de, mariusz.dabrowski@intel.com, ming.l@ssi.samsung.com,
snitzer@redhat.com, xni@redhat.com, stable@vger.kernel.org
Subject: Re: FAILED: patch "[PATCH] block: don't deal with discard limit in" failed to apply to 4.14-stable tree
Date: Sat, 22 Dec 2018 22:40:21 +0000 [thread overview]
Message-ID: <20181222224021.3kcomxgved2j4ace@debian> (raw)
In-Reply-To: <20181221232026.GF86645@sasha-vm>
[-- Attachment #1: Type: text/plain, Size: 1091 bytes --]
On Fri, Dec 21, 2018 at 06:20:26PM -0500, Sasha Levin wrote:
> On Thu, Dec 20, 2018 at 08:53:47PM +0000, Sudip Mukherjee wrote:
> > Hi Greg,
> >
> > On Thu, Nov 08, 2018 at 09:23:10AM -0800, gregkh@linuxfoundation.org wrote:
> > >
> > > The patch below does not apply to the 4.14-stable tree.
> > > If someone wants it applied there, or to any other stable or longterm
> > > tree, then please email the backport, including the original git commit
> > > id to <stable@vger.kernel.org>.
> >
> > Instead of backporting it was easier to add the commits it depends on.
> > 1) af097f5d199e ("block: break discard submissions into the user defined size")
> > It is not marked for stable but seems it can be in stable.
> >
> > 2) b88aef36b87c ("block: fix infinite loop if the device loses discard capability")
> > It is marked for stable but is not there in 4.14-stable.
> >
> > All are attached to this mail for you to apply.
>
> I've queued both for 4.14 and 4.9. It seems that 4.4 needs something
> more complex than that.
Backported patch attached for 4.4-stable tree.
--
Regards
Sudip
[-- Attachment #2: 0001-block-break-discard-submissions-into-the-user-define.patch --]
[-- Type: text/x-diff, Size: 1397 bytes --]
>From 2377ab657d423978108dfdaacd443adfa2613d2b Mon Sep 17 00:00:00 2001
From: Jens Axboe <axboe@kernel.dk>
Date: Tue, 8 May 2018 15:09:41 -0600
Subject: [PATCH 1/2] block: break discard submissions into the user defined size
commit af097f5d199e2aa3ab3ef777f0716e487b8f7b08 upstream
Don't build discards bigger than what the user asked for, if the
user decided to limit the size by writing to 'discard_max_bytes'.
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Omar Sandoval <osandov@fb.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
---
block/blk-lib.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/block/blk-lib.c b/block/blk-lib.c
index 9ebf65379556..73ca3ef8ca5a 100644
--- a/block/blk-lib.c
+++ b/block/blk-lib.c
@@ -81,8 +81,14 @@ int blkdev_issue_discard(struct block_device *bdev, sector_t sector,
break;
}
- /* Make sure bi_size doesn't overflow */
- req_sects = min_t(sector_t, nr_sects, UINT_MAX >> 9);
+ /*
+ * Issue in chunks of the user defined max discard setting,
+ * ensuring that bi_size doesn't overflow
+ */
+ req_sects = min_t(sector_t, nr_sects,
+ q->limits.max_discard_sectors);
+ if (req_sects > UINT_MAX >> 9)
+ req_sects = UINT_MAX >> 9;
/*
* If splitting a request, and the next starting sector would be
--
2.11.0
[-- Attachment #3: 0002-block-re-add-discard_granularity-and-alignment-check.patch --]
[-- Type: text/x-diff, Size: 3362 bytes --]
>From 2e507841428638b7fac3cea954e675b780a861a3 Mon Sep 17 00:00:00 2001
From: Ming Lin <ming.l@ssi.samsung.com>
Date: Thu, 22 Oct 2015 09:59:42 -0700
Subject: [PATCH 2/2] block: re-add discard_granularity and alignment checks
commit 744889b7cbb56a64f957e65ade7cb65fe3f35714 upstream
In commit b49a087("block: remove split code in
blkdev_issue_{discard,write_same}"), discard_granularity and alignment
checks were removed. Ideally, with bio late splitting, the upper layers
shouldn't need to depend on device's limits.
Christoph reported a discard regression on the HGST Ultrastar SN100 NVMe
device when mkfs.xfs. We have not found the root cause yet.
This patch re-adds discard_granularity and alignment checks by reverting
the related changes in commit b49a087. The good thing is now we can
remove the 2G discard size cap and just use UINT_MAX to avoid bi_size
overflow.
Reviewed-by: Christoph Hellwig <hch@lst.de>
Tested-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Ming Lin <ming.l@ssi.samsung.com>
Reviewed-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
Signed-off-by: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
---
block/blk-lib.c | 28 ++--------------------------
1 file changed, 2 insertions(+), 26 deletions(-)
diff --git a/block/blk-lib.c b/block/blk-lib.c
index 73ca3ef8ca5a..a42e680ef8f7 100644
--- a/block/blk-lib.c
+++ b/block/blk-lib.c
@@ -43,8 +43,6 @@ int blkdev_issue_discard(struct block_device *bdev, sector_t sector,
DECLARE_COMPLETION_ONSTACK(wait);
struct request_queue *q = bdev_get_queue(bdev);
int type = REQ_WRITE | REQ_DISCARD;
- unsigned int granularity;
- int alignment;
struct bio_batch bb;
struct bio *bio;
int ret = 0;
@@ -56,10 +54,6 @@ int blkdev_issue_discard(struct block_device *bdev, sector_t sector,
if (!blk_queue_discard(q))
return -EOPNOTSUPP;
- /* Zero-sector (unknown) and one-sector granularities are the same. */
- granularity = max(q->limits.discard_granularity >> 9, 1U);
- alignment = (bdev_discard_alignment(bdev) >> 9) % granularity;
-
if (flags & BLKDEV_DISCARD_SECURE) {
if (!blk_queue_secdiscard(q))
return -EOPNOTSUPP;
@@ -72,8 +66,8 @@ int blkdev_issue_discard(struct block_device *bdev, sector_t sector,
blk_start_plug(&plug);
while (nr_sects) {
- unsigned int req_sects;
- sector_t end_sect, tmp;
+ unsigned int req_sects = nr_sects;
+ sector_t end_sect;
bio = bio_alloc(gfp_mask, 1);
if (!bio) {
@@ -81,28 +75,10 @@ int blkdev_issue_discard(struct block_device *bdev, sector_t sector,
break;
}
- /*
- * Issue in chunks of the user defined max discard setting,
- * ensuring that bi_size doesn't overflow
- */
- req_sects = min_t(sector_t, nr_sects,
- q->limits.max_discard_sectors);
if (req_sects > UINT_MAX >> 9)
req_sects = UINT_MAX >> 9;
- /*
- * If splitting a request, and the next starting sector would be
- * misaligned, stop the discard at the previous aligned sector.
- */
end_sect = sector + req_sects;
- tmp = end_sect;
- if (req_sects < nr_sects &&
- sector_div(tmp, granularity) != alignment) {
- end_sect = end_sect - alignment;
- sector_div(end_sect, granularity);
- end_sect = end_sect * granularity + alignment;
- req_sects = end_sect - sector;
- }
bio->bi_iter.bi_sector = sector;
bio->bi_end_io = bio_batch_end_io;
--
2.11.0
next prev parent reply other threads:[~2018-12-22 22:40 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-08 17:23 FAILED: patch "[PATCH] block: don't deal with discard limit in" failed to apply to 4.14-stable tree gregkh
2018-12-20 20:53 ` Sudip Mukherjee
2018-12-21 23:20 ` Sasha Levin
2018-12-22 22:40 ` Sudip Mukherjee [this message]
2019-01-10 19:21 ` Greg KH
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=20181222224021.3kcomxgved2j4ace@debian \
--to=sudipm.mukherjee@gmail.com \
--cc=axboe@kernel.dk \
--cc=gregkh@linuxfoundation.org \
--cc=hch@lst.de \
--cc=mariusz.dabrowski@intel.com \
--cc=ming.l@ssi.samsung.com \
--cc=ming.lei@redhat.com \
--cc=sashal@kernel.org \
--cc=snitzer@redhat.com \
--cc=stable@vger.kernel.org \
--cc=xni@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 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.