From patchwork Thu Dec 20 05:57:10 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Snitzer X-Patchwork-Id: 1898441 Return-Path: X-Original-To: patchwork-dm-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from mx4-phx2.redhat.com (mx4-phx2.redhat.com [209.132.183.25]) by patchwork2.kernel.org (Postfix) with ESMTP id 9B628DF23A for ; Thu, 20 Dec 2012 06:02:16 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx4-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id qBK5vKxi015028; Thu, 20 Dec 2012 00:57:20 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id qBK5vJF3027790 for ; Thu, 20 Dec 2012 00:57:19 -0500 Received: from localhost (dhcp-185-13.bos.redhat.com [10.16.185.13]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id qBK5vDTO002144 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Thu, 20 Dec 2012 00:57:14 -0500 From: Mike Snitzer To: dm-devel@redhat.com Date: Thu, 20 Dec 2012 00:57:10 -0500 Message-Id: <1355983033-17863-1-git-send-email-snitzer@redhat.com> In-Reply-To: <20121220054725.GA17619@redhat.com> References: <20121220054725.GA17619@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-loop: dm-devel@redhat.com Cc: martin.petersen@oracle.com Subject: [dm-devel] [PATCH 1/4] dm: default to disabling WRITE SAME support for all targets 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 Best to disable WRITE SAME support for all targets and then require each target to opt-in by setting 'num_write_same_requests' in the dm_target structure. Signed-off-by: Mike Snitzer --- drivers/md/dm-table.c | 30 ++++++++++++++++++++++++++++++ include/linux/device-mapper.h | 6 ++++++ 2 files changed, 36 insertions(+), 0 deletions(-) diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c index 4c145fa..1ae337b 100644 --- a/drivers/md/dm-table.c +++ b/drivers/md/dm-table.c @@ -1423,6 +1423,33 @@ static bool dm_table_all_devices_attribute(struct dm_table *t, return 1; } +static int device_write_same_capable(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 && q->limits.max_write_same_sectors; +} + +static bool dm_table_supports_write_same(struct dm_table *t) +{ + struct dm_target *ti; + unsigned i = 0; + + while (i < dm_table_get_num_targets(t)) { + ti = dm_table_get_target(t, i++); + + if (!ti->num_write_same_requests) + continue; + + if (!ti->type->iterate_devices || + !ti->type->iterate_devices(ti, device_write_same_capable, NULL)) + return 1; + } + + return 0; +} + void dm_table_set_restrictions(struct dm_table *t, struct request_queue *q, struct queue_limits *limits) { @@ -1454,6 +1481,9 @@ void dm_table_set_restrictions(struct dm_table *t, struct request_queue *q, else queue_flag_clear_unlocked(QUEUE_FLAG_NONROT, q); + if (!dm_table_supports_write_same(t)) + q->limits.max_write_same_sectors = 0; + dm_table_set_integrity(t); /* diff --git a/include/linux/device-mapper.h b/include/linux/device-mapper.h index 2d65c70..072b72f 100644 --- a/include/linux/device-mapper.h +++ b/include/linux/device-mapper.h @@ -211,6 +211,12 @@ struct dm_target { unsigned num_discard_requests; /* + * The number of WRITE SAME requests that will be submitted to the target. + * The request number can be accessed with dm_bio_get_target_request_nr. + */ + unsigned num_write_same_requests; + + /* * The minimum number of extra bytes allocated in each bio for the * target to use. dm_per_bio_data returns the data location. */