From patchwork Wed Apr 27 15:06:23 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 736541 Received: from mx4-phx2.redhat.com (mx4-phx2.redhat.com [209.132.183.25]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p3RF99FJ027279 for ; Wed, 27 Apr 2011 15:09:30 GMT 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 p3RF6cQK002794; Wed, 27 Apr 2011 11:06:39 -0400 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p3RF6boD029032 for ; Wed, 27 Apr 2011 11:06:37 -0400 Received: from mx1.redhat.com (ext-mx11.extmail.prod.ext.phx2.redhat.com [10.5.110.16]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p3RF6W3s016449; Wed, 27 Apr 2011 11:06:32 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [18.85.46.34]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p3RF6OPa029967; Wed, 27 Apr 2011 11:06:24 -0400 Received: from hch by bombadil.infradead.org with local (Exim 4.72 #1 (Red Hat Linux)) id 1QF6Jr-0005Ze-TI; Wed, 27 Apr 2011 15:06:23 +0000 Date: Wed, 27 Apr 2011 11:06:23 -0400 From: Christoph Hellwig To: dm-devel@redhat.com Message-ID: <20110427150623.GC13487@infradead.org> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org See http://www.infradead.org/rpr.html X-RedHat-Spam-Score: -5.01 (RCVD_IN_DNSWL_HI,T_RP_MATCHES_RCVD) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 X-Scanned-By: MIMEDefang 2.68 on 10.5.110.16 X-loop: dm-devel@redhat.com Cc: snitzer@redhat.com Subject: [dm-devel] [PATCH, RFC] dm: relax discard restrictions 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: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Wed, 27 Apr 2011 15:09:30 +0000 (UTC) With targets like dm-thinp we might want to allow discard even if the underlying devices don't support them natively. This patch is the extreme variant of not restricting discard support at all, but maybe there are other options. Or maybe we should keep the old dm_table_supports_discards function as a helper for targets that want simple discard passthrough? Signed-off-by: Christoph Hellwig --- dm-devel mailing list dm-devel@redhat.com https://www.redhat.com/mailman/listinfo/dm-devel Index: linux-2.6/drivers/md/dm-table.c =================================================================== --- linux-2.6.orig/drivers/md/dm-table.c 2011-04-27 16:44:09.231032143 +0200 +++ linux-2.6/drivers/md/dm-table.c 2011-04-27 16:51:39.415259952 +0200 @@ -1136,10 +1136,10 @@ void dm_table_set_restrictions(struct dm */ q->limits = *limits; - if (!dm_table_supports_discards(t)) - queue_flag_clear_unlocked(QUEUE_FLAG_DISCARD, q); - else + if (t->discards_supported) queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, q); + else + queue_flag_clear_unlocked(QUEUE_FLAG_DISCARD, q); dm_table_set_integrity(t); @@ -1303,39 +1303,6 @@ struct mapped_device *dm_table_get_md(st return t->md; } -static int device_discard_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 && blk_queue_discard(q); -} - -bool dm_table_supports_discards(struct dm_table *t) -{ - struct dm_target *ti; - unsigned i = 0; - - if (!t->discards_supported) - return 0; - - /* - * Ensure that at least one underlying device supports discards. - * t->devices includes internal dm devices such as mirror logs - * so we need to use iterate_devices here, which targets - * supporting discard must provide. - */ - while (i < dm_table_get_num_targets(t)) { - ti = dm_table_get_target(t, i++); - - if (ti->type->iterate_devices && - ti->type->iterate_devices(ti, device_discard_capable, NULL)) - return 1; - } - - return 0; -} - EXPORT_SYMBOL(dm_vcalloc); EXPORT_SYMBOL(dm_get_device); EXPORT_SYMBOL(dm_put_device); Index: linux-2.6/drivers/md/dm.h =================================================================== --- linux-2.6.orig/drivers/md/dm.h 2011-04-27 16:50:32.992286464 +0200 +++ linux-2.6/drivers/md/dm.h 2011-04-27 16:50:34.898942802 +0200 @@ -61,7 +61,6 @@ int dm_table_any_congested(struct dm_tab int dm_table_any_busy_target(struct dm_table *t); unsigned dm_table_get_type(struct dm_table *t); bool dm_table_request_based(struct dm_table *t); -bool dm_table_supports_discards(struct dm_table *t); int dm_table_alloc_md_mempools(struct dm_table *t); void dm_table_free_md_mempools(struct dm_table *t); struct dm_md_mempools *dm_table_get_md_mempools(struct dm_table *t);