aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-10-19 12:51:07 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-10-19 12:51:07 -0400
commitb2a205ff49b9c55d4bdda1bdb10ad19ebd646221 (patch)
tree37e3821d811f74f67c84d7082b9ad8959c5b32a1
parent91b15613ce7fb3e724ca0d433eef8e6bf15322af (diff)
parent744889b7cbb56a64f957e65ade7cb65fe3f35714 (diff)
Merge tag 'for-linus-20181019' of git://git.kernel.dk/linux-block
Jens writes: "Block fixes for 4.19-final Two small fixes that should go into this release." * tag 'for-linus-20181019' of git://git.kernel.dk/linux-block: block: don't deal with discard limit in blkdev_issue_discard() nvme: remove ns sibling before clearing path
-rw-r--r--block/blk-lib.c28
-rw-r--r--drivers/nvme/host/core.c2
2 files changed, 3 insertions, 27 deletions
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,
29{ 29{
30 struct request_queue *q = bdev_get_queue(bdev); 30 struct request_queue *q = bdev_get_queue(bdev);
31 struct bio *bio = *biop; 31 struct bio *bio = *biop;
32 unsigned int granularity;
33 unsigned int op; 32 unsigned int op;
34 int alignment;
35 sector_t bs_mask; 33 sector_t bs_mask;
36 34
37 if (!q) 35 if (!q)
@@ -54,38 +52,16 @@ int __blkdev_issue_discard(struct block_device *bdev, sector_t sector,
54 if ((sector | nr_sects) & bs_mask) 52 if ((sector | nr_sects) & bs_mask)
55 return -EINVAL; 53 return -EINVAL;
56 54
57 /* Zero-sector (unknown) and one-sector granularities are the same. */
58 granularity = max(q->limits.discard_granularity >> 9, 1U);
59 alignment = (bdev_discard_alignment(bdev) >> 9) % granularity;
60
61 while (nr_sects) { 55 while (nr_sects) {
62 unsigned int req_sects; 56 unsigned int req_sects = nr_sects;
63 sector_t end_sect, tmp; 57 sector_t end_sect;
64 58
65 /*
66 * Issue in chunks of the user defined max discard setting,
67 * ensuring that bi_size doesn't overflow
68 */
69 req_sects = min_t(sector_t, nr_sects,
70 q->limits.max_discard_sectors);
71 if (!req_sects) 59 if (!req_sects)
72 goto fail; 60 goto fail;
73 if (req_sects > UINT_MAX >> 9) 61 if (req_sects > UINT_MAX >> 9)
74 req_sects = UINT_MAX >> 9; 62 req_sects = UINT_MAX >> 9;
75 63
76 /*
77 * If splitting a request, and the next starting sector would be
78 * misaligned, stop the discard at the previous aligned sector.
79 */
80 end_sect = sector + req_sects; 64 end_sect = sector + req_sects;
81 tmp = end_sect;
82 if (req_sects < nr_sects &&
83 sector_div(tmp, granularity) != alignment) {
84 end_sect = end_sect - alignment;
85 sector_div(end_sect, granularity);
86 end_sect = end_sect * granularity + alignment;
87 req_sects = end_sect - sector;
88 }
89 65
90 bio = next_bio(bio, 0, gfp_mask); 66 bio = next_bio(bio, 0, gfp_mask);
91 bio->bi_iter.bi_sector = sector; 67 bio->bi_iter.bi_sector = sector;
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index dd8ec1dd9219..6bb9908bf46f 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -3143,8 +3143,8 @@ static void nvme_ns_remove(struct nvme_ns *ns)
3143 } 3143 }
3144 3144
3145 mutex_lock(&ns->ctrl->subsys->lock); 3145 mutex_lock(&ns->ctrl->subsys->lock);
3146 nvme_mpath_clear_current_path(ns);
3147 list_del_rcu(&ns->siblings); 3146 list_del_rcu(&ns->siblings);
3147 nvme_mpath_clear_current_path(ns);
3148 mutex_unlock(&ns->ctrl->subsys->lock); 3148 mutex_unlock(&ns->ctrl->subsys->lock);
3149 3149
3150 down_write(&ns->ctrl->namespaces_rwsem); 3150 down_write(&ns->ctrl->namespaces_rwsem);