Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753442AbbEEBeY (ORCPT ); Mon, 4 May 2015 21:34:24 -0400 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:50956 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752565AbbEEBXG (ORCPT ); Mon, 4 May 2015 21:23:06 -0400 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Darrick J. Wong" , "Mike Snitzer" , "Mikulas Patocka" Date: Tue, 05 May 2015 02:16:39 +0100 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.2 101/221] dm io: deal with wandering queue limits when handling REQ_DISCARD and REQ_WRITE_SAME In-Reply-To: X-SA-Exim-Connect-IP: 192.168.4.249 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2218 Lines: 59 3.2.69-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: "Darrick J. Wong" 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 Signed-off-by: Mikulas Patocka Signed-off-by: Mike Snitzer [bwh: Backported to 3.2: adjust context; drop the write_same handling] Signed-off-by: Ben Hutchings --- drivers/md/dm-io.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) --- a/drivers/md/dm-io.c +++ b/drivers/md/dm-io.c @@ -299,11 +299,15 @@ static void do_region(int rw, unsigned r 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 r 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) { -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/