From patchwork Sat Jan 24 22:10:48 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Busch X-Patchwork-Id: 5700401 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: X-Original-To: patchwork-dm-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id E02A3C058D for ; Sat, 24 Jan 2015 22:15:49 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DFBE4201B4 for ; Sat, 24 Jan 2015 22:15:48 +0000 (UTC) Received: from mx6-phx2.redhat.com (mx6-phx2.redhat.com [209.132.183.39]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C6F7C2018E for ; Sat, 24 Jan 2015 22:15:47 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx6-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t0OMB1Mc009329; Sat, 24 Jan 2015 17:11:02 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id t0OMB0cB002312 for ; Sat, 24 Jan 2015 17:11:00 -0500 Received: from mx1.redhat.com (ext-mx12.extmail.prod.ext.phx2.redhat.com [10.5.110.17]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t0OMB0aj032400; Sat, 24 Jan 2015 17:11:00 -0500 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t0OMAxPG016871; Sat, 24 Jan 2015 17:10:59 -0500 Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga103.jf.intel.com with ESMTP; 24 Jan 2015 14:06:49 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.09,461,1418112000"; d="scan'208";a="517125155" Received: from dcgshare.lm.intel.com ([10.232.118.254]) by orsmga003.jf.intel.com with ESMTP; 24 Jan 2015 14:04:03 -0800 Received: by dcgshare.lm.intel.com (Postfix, from userid 1017) id 3AB5CE00F2; Sat, 24 Jan 2015 15:10:57 -0700 (MST) From: Keith Busch To: dm-devel@redhat.com, Mike Snitzer , Jens Axboe Date: Sat, 24 Jan 2015 15:10:48 -0700 Message-Id: <1422137448-14747-1-git-send-email-keith.busch@intel.com> X-RedHat-Spam-Score: -7.31 (BAYES_00, DCC_REPUT_00_12, RCVD_IN_DNSWL_HI, SPF_PASS, T_RP_MATCHES_RCVD, URIBL_BLOCKED) 134.134.136.65 mga03.intel.com 134.134.136.65 mga03.intel.com X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Scanned-By: MIMEDefang 2.68 on 10.5.110.17 X-loop: dm-devel@redhat.com Cc: Keith Busch Subject: [dm-devel] [PATCH] dm: Respect request queue page gaps flag X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk Reply-To: device-mapper development List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This has request based dm inherit the QUEUE_FLAG_SG_GAPS flags from its underlying block devices' request queues, and does not merge two requests with sg gaps when required. This fixes problems when submitting cloned requests to multipathed devices requiring virtually contiguous buffers. Signed-off-by: Keith Busch --- block/blk-merge.c | 12 ++++++++++++ drivers/md/dm-table.c | 13 +++++++++++++ 2 files changed, 25 insertions(+) diff --git a/block/blk-merge.c b/block/blk-merge.c index 89b97b5..f021a11 100644 --- a/block/blk-merge.c +++ b/block/blk-merge.c @@ -385,6 +385,14 @@ static bool req_no_special_merge(struct request *req) return !q->mq_ops && req->special; } +static int req_gap_to_prev(struct request *req, struct request *next) +{ + struct bio *prev = req->biotail; + + return bvec_gap_to_prev(&prev->bi_io_vec[prev->bi_vcnt - 1], + next->bio->bi_io_vec[0].bv_offset); +} + static int ll_merge_requests_fn(struct request_queue *q, struct request *req, struct request *next) { @@ -399,6 +407,10 @@ static int ll_merge_requests_fn(struct request_queue *q, struct request *req, if (req_no_special_merge(req) || req_no_special_merge(next)) return 0; + if ((q->queue_flags & (1 << QUEUE_FLAG_SG_GAPS)) && + req_gap_to_prev(req, next)) + return 0; + /* * Will it become too large? */ diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c index 14954d8..d7eee6d 100644 --- a/drivers/md/dm-table.c +++ b/drivers/md/dm-table.c @@ -1389,6 +1389,14 @@ static int queue_supports_sg_merge(struct dm_target *ti, struct dm_dev *dev, return q && !test_bit(QUEUE_FLAG_NO_SG_MERGE, &q->queue_flags); } +static int queue_contiguous_sg(struct dm_target *ti, struct dm_dev *dev, + sector_t start, sector_t len, void *data) +{ + struct request_queue *q = bdev_get_queue(dev->bdev); + + return q && !test_bit(QUEUE_FLAG_SG_GAPS, &q->queue_flags); +} + static bool dm_table_all_devices_attribute(struct dm_table *t, iterate_devices_callout_fn func) { @@ -1509,6 +1517,11 @@ void dm_table_set_restrictions(struct dm_table *t, struct request_queue *q, else queue_flag_set_unlocked(QUEUE_FLAG_NO_SG_MERGE, q); + if (dm_table_all_devices_attribute(t, queue_contiguous_sg)) + queue_flag_clear_unlocked(QUEUE_FLAG_SG_GAPS, q); + else + queue_flag_set_unlocked(QUEUE_FLAG_SG_GAPS, q); + dm_table_set_integrity(t); /*