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.
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 744889b7cbb56a64f957e65ade7cb65fe3f35714 Mon Sep 17 00:00:00 2001
From: Ming Lei ming.lei@redhat.com Date: Fri, 12 Oct 2018 15:53:10 +0800 Subject: [PATCH] block: don't deal with discard limit in blkdev_issue_discard()
blk_queue_split() does respect this limit via bio splitting, so no need to do that in blkdev_issue_discard(), then we can align to normal bio submit(bio_add_page() & submit_bio()).
More importantly, this patch fixes one issue introduced in a22c4d7e34402cc ("block: re-add discard_granularity and alignment checks"), in which zero discard bio may be generated in case of zero alignment.
Fixes: a22c4d7e34402ccdf3 ("block: re-add discard_granularity and alignment checks") Cc: stable@vger.kernel.org Cc: Ming Lin ming.l@ssi.samsung.com Cc: Mike Snitzer snitzer@redhat.com Cc: Christoph Hellwig hch@lst.de Cc: Xiao Ni xni@redhat.com Tested-by: Mariusz Dabrowski mariusz.dabrowski@intel.com Signed-off-by: Ming Lei ming.lei@redhat.com Signed-off-by: Jens Axboe axboe@kernel.dk
diff --git a/block/blk-lib.c b/block/blk-lib.c index d1b9dd03da25..bbd44666f2b5 100644 --- a/block/blk-lib.c +++ b/block/blk-lib.c @@ -29,9 +29,7 @@ int __blkdev_issue_discard(struct block_device *bdev, sector_t sector, { struct request_queue *q = bdev_get_queue(bdev); struct bio *bio = *biop; - unsigned int granularity; unsigned int op; - int alignment; sector_t bs_mask;
if (!q) @@ -54,38 +52,16 @@ int __blkdev_issue_discard(struct block_device *bdev, sector_t sector, if ((sector | nr_sects) & bs_mask) return -EINVAL;
- /* 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; - while (nr_sects) { - unsigned int req_sects; - sector_t end_sect, tmp; + unsigned int req_sects = nr_sects; + sector_t end_sect;
- /* - * 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) goto fail; 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 = next_bio(bio, 0, gfp_mask); bio->bi_iter.bi_sector = sector;
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.
-- Regards Sudip
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.
- af097f5d199e ("block: break discard submissions into the user defined size")
It is not marked for stable but seems it can be in stable.
- 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.
-- Thanks, Sasha
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.
- af097f5d199e ("block: break discard submissions into the user defined size")
It is not marked for stable but seems it can be in stable.
- 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
On Sat, Dec 22, 2018 at 10:40:21PM +0000, Sudip Mukherjee wrote:
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.
- af097f5d199e ("block: break discard submissions into the user defined size")
It is not marked for stable but seems it can be in stable.
- 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.
Thanks for these, now queued up.
greg k-h
linux-stable-mirror@lists.linaro.org