aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md
diff options
context:
space:
mode:
authorDarrick J. Wong <darrick.wong@oracle.com>2015-02-27 10:44:38 -0800
committerBen Hutchings <ben@decadent.org.uk>2015-05-09 23:16:25 +0100
commit23ca6642912d2ba7ffc332774490b54d1b831ed8 (patch)
tree57627cd35e6bcee3fbe9995a50cfb6b3dd5e7f38 /drivers/md
parent361a387fabc76ca346bbcc88ba9c99ef9e7e4691 (diff)
downloadkernel_samsung_smdk4412-23ca6642912d2ba7ffc332774490b54d1b831ed8.zip
kernel_samsung_smdk4412-23ca6642912d2ba7ffc332774490b54d1b831ed8.tar.gz
kernel_samsung_smdk4412-23ca6642912d2ba7ffc332774490b54d1b831ed8.tar.bz2
dm io: deal with wandering queue limits when handling REQ_DISCARD and REQ_WRITE_SAME
commit e5db29806b99ce2b2640d2e4d4fcb983cea115c5 upstream. Since it's possible for the discard and write same queue limits to change while the upper level command is being sliced and diced, fix up both of them (a) to reject IO if the special command is unsupported at the start of the function and (b) read the limits once and let the commands error out on their own if the status happens to change. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Mikulas Patocka <mpatocka@redhat.com> Signed-off-by: Mike Snitzer <snitzer@redhat.com> [bwh: Backported to 3.2: adjust context; drop the write_same handling] Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Diffstat (limited to 'drivers/md')
-rw-r--r--drivers/md/dm-io.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/drivers/md/dm-io.c b/drivers/md/dm-io.c
index 629083b..b8ed01b 100644
--- a/drivers/md/dm-io.c
+++ b/drivers/md/dm-io.c
@@ -299,11 +299,15 @@ static void do_region(int rw, unsigned region, struct dm_io_region *where,
sector_t remaining = where->count;
struct request_queue *q = bdev_get_queue(where->bdev);
sector_t discard_sectors;
+ unsigned int uninitialized_var(special_cmd_max_sectors);
/* Reject unsupported discard requests */
- if ((rw & REQ_DISCARD) && !blk_queue_discard(q)) {
- dec_count(io, region, -EOPNOTSUPP);
- return;
+ if (rw & REQ_DISCARD) {
+ special_cmd_max_sectors = q->limits.max_discard_sectors;
+ if (special_cmd_max_sectors == 0) {
+ dec_count(io, region, -EOPNOTSUPP);
+ return;
+ }
}
/*
@@ -328,7 +332,7 @@ static void do_region(int rw, unsigned region, struct dm_io_region *where,
store_io_and_region_in_bio(bio, io, region);
if (rw & REQ_DISCARD) {
- discard_sectors = min_t(sector_t, q->limits.max_discard_sectors, remaining);
+ discard_sectors = min_t(sector_t, special_cmd_max_sectors, remaining);
bio->bi_size = discard_sectors << SECTOR_SHIFT;
remaining -= discard_sectors;
} else while (remaining) {