From patchwork Wed May 25 20:50:48 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mandeep Singh Baines X-Patchwork-Id: 821102 X-Patchwork-Delegate: snitzer@redhat.com Received: from mx4-phx2.redhat.com (mx4-phx2.redhat.com [209.132.183.25]) by demeter2.kernel.org (8.14.4/8.14.3) with ESMTP id p4QEtmQd028732 for ; Thu, 26 May 2011 14:56:09 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 p4QEqu2x018199; Thu, 26 May 2011 10:53:21 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p4PKpOET025859 for ; Wed, 25 May 2011 16:51:24 -0400 Received: from mx1.redhat.com (ext-mx11.extmail.prod.ext.phx2.redhat.com [10.5.110.16]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p4PKpIeG026666; Wed, 25 May 2011 16:51:18 -0400 Received: from smtp-out.google.com (smtp-out.google.com [74.125.121.67]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p4PKpHPN022418; Wed, 25 May 2011 16:51:18 -0400 Received: from wpaz33.hot.corp.google.com (wpaz33.hot.corp.google.com [172.24.198.97]) by smtp-out.google.com with ESMTP id p4PKp9Vw020643; Wed, 25 May 2011 13:51:10 -0700 Received: from msb.mtv.corp.google.com (msb.mtv.corp.google.com [172.22.72.160]) by wpaz33.hot.corp.google.com with ESMTP id p4PKovUZ026744; Wed, 25 May 2011 13:50:58 -0700 Received: by msb.mtv.corp.google.com (Postfix, from userid 55285) id 8DB5324610E; Wed, 25 May 2011 13:50:57 -0700 (PDT) From: Mandeep Singh Baines To: linux-kernel@vger.kernel.org, jrbarnette@chromium.org Date: Wed, 25 May 2011 13:50:48 -0700 Message-Id: <1306356648-30730-1-git-send-email-msb@chromium.org> X-System-Of-Record: true X-RedHat-Spam-Score: -2.31 (RCVD_IN_DNSWL_MED,T_RP_MATCHES_RCVD) X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-Scanned-By: MIMEDefang 2.68 on 10.5.110.16 X-loop: dm-devel@redhat.com X-Mailman-Approved-At: Thu, 26 May 2011 10:52:55 -0400 Cc: Mike Snitzer , "Martin K. Petersen" , Jens Axboe , Mandeep Singh Baines , dm-devel@redhat.com, Alasdair G Kergon Subject: [dm-devel] [PATCH] dm: pass up rotational 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-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Thu, 26 May 2011 14:56:09 +0000 (UTC) Allow the NONROT flag to be passed through to linear mappings if all underlying device are non-rotational. Tools like ureadahead will schedule IOs differently based on the rotational flag. With this patch, I see boot time go from 7.75 s to 7.46 s on my device. Suggested-by: J. Richard Barnette Signed-off-by: Mandeep Singh Baines Cc: Neil Brown Cc: Mike Snitzer Cc: Jens Axboe Cc: Martin K. Petersen Cc: Alasdair G Kergon Cc: dm-devel@redhat.com --- drivers/md/dm-table.c | 28 ++++++++++++++++++++++++++++ 1 files changed, 28 insertions(+), 0 deletions(-) diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c index cb8380c..40c6071 100644 --- a/drivers/md/dm-table.c +++ b/drivers/md/dm-table.c @@ -1177,6 +1177,30 @@ static void dm_table_set_integrity(struct dm_table *t) blk_get_integrity(template_disk)); } +static int device_nonrot(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_nonrot(q); +} + +static bool dm_table_all_nonrot(struct dm_table *t) +{ + unsigned i = 0; + + /* Ensure that all underlying device are non rotational. */ + while (i < dm_table_get_num_targets(t)) { + struct dm_target *ti = dm_table_get_target(t, i++); + + if (!ti->type->iterate_devices || + !ti->type->iterate_devices(ti, device_nonrot, NULL)) + return false; + } + + return true; +} + void dm_table_set_restrictions(struct dm_table *t, struct request_queue *q, struct queue_limits *limits) { @@ -1189,6 +1213,10 @@ void dm_table_set_restrictions(struct dm_table *t, struct request_queue *q, queue_flag_clear_unlocked(QUEUE_FLAG_DISCARD, q); else queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, q); + if (!dm_table_all_nonrot(t)) + queue_flag_clear_unlocked(QUEUE_FLAG_NONROT, q); + else + queue_flag_set_unlocked(QUEUE_FLAG_NONROT, q); dm_table_set_integrity(t);