Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932646AbbFPIqX (ORCPT ); Tue, 16 Jun 2015 04:46:23 -0400 Received: from mail.kernel.org ([198.145.29.136]:55891 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756483AbbFPIpm (ORCPT ); Tue, 16 Jun 2015 04:45:42 -0400 From: lizf@kernel.org To: stable@vger.kernel.org Cc: linux-kernel@vger.kernel.org, "Darrick J. Wong" , Mikulas Patocka , Mike Snitzer , Zefan Li Subject: [PATCH 3.4 096/172] dm io: deal with wandering queue limits when handling REQ_DISCARD and REQ_WRITE_SAME Date: Tue, 16 Jun 2015 16:35:50 +0800 Message-Id: <1434443826-4929-96-git-send-email-lizf@kernel.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1434443587-4599-1-git-send-email-lizf@kernel.org> References: <1434443587-4599-1-git-send-email-lizf@kernel.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2456 Lines: 69 From: "Darrick J. Wong" 3.4.108-rc1 review patch. If anyone has any objections, please let me know. ------------------ 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 [lizf: Backported to 3.4: - adjust context - 3.4 doesn't support REQ_WRITE_SAME] Signed-off-by: Zefan Li --- drivers/md/dm-io.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/drivers/md/dm-io.c b/drivers/md/dm-io.c index d3b1b54..489d7fb 100644 --- a/drivers/md/dm-io.c +++ b/drivers/md/dm-io.c @@ -298,11 +298,17 @@ 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; + /* + * Reject unsupported discard and write same requests. + */ + 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; + } } /* @@ -327,7 +333,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) { -- 1.9.1 -- 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/