Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754587Ab0K2WGm (ORCPT ); Mon, 29 Nov 2010 17:06:42 -0500 Received: from e7.ny.us.ibm.com ([32.97.182.137]:34859 "EHLO e7.ny.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754315Ab0K2WGK (ORCPT ); Mon, 29 Nov 2010 17:06:10 -0500 Subject: [PATCH 2/4] md: Compute average flush time from component devices To: Jens Axboe , "Theodore Ts'o" , Neil Brown , Andreas Dilger , Alasdair G Kergon , "Darrick J. Wong" From: "Darrick J. Wong" Cc: Jan Kara , Mike Snitzer , linux-kernel , linux-raid@vger.kernel.org, Keith Mannthey , dm-devel@redhat.com, Mingming Cao , Tejun Heo , linux-ext4@vger.kernel.org, Ric Wheeler , Christoph Hellwig , Josef Bacik Date: Mon, 29 Nov 2010 14:05:51 -0800 Message-ID: <20101129220551.12401.80601.stgit@elm3b57.beaverton.ibm.com> In-Reply-To: <20101129220536.12401.16581.stgit@elm3b57.beaverton.ibm.com> References: <20101129220536.12401.16581.stgit@elm3b57.beaverton.ibm.com> User-Agent: StGit/0.15 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Content-Scanned: Fidelis XPS MAILER Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1846 Lines: 57 For md devices which are composed of other block devices, a flush is spread out to those other block devices. Therefore, the average flush time can be computed as the average flush time of whichever device flushes most slowly. Signed-off-by: Darrick J. Wong --- drivers/md/md.c | 23 +++++++++++++++++++++++ 1 files changed, 23 insertions(+), 0 deletions(-) diff --git a/drivers/md/md.c b/drivers/md/md.c index 43243a4..af25c96 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -357,6 +357,28 @@ EXPORT_SYMBOL(mddev_congested); * Generic flush handling for md */ +static void measure_flushes(mddev_t *mddev) +{ + mdk_rdev_t *rdev; + u64 max = 0, samples = 0; + + rcu_read_lock(); + list_for_each_entry_rcu(rdev, &mddev->disks, same_set) + if (rdev->raid_disk >= 0 && + !test_bit(Faulty, &rdev->flags)) { + if (rdev->bdev->bd_disk->avg_flush_time_ns <= max) + continue; + max = rdev->bdev->bd_disk->avg_flush_time_ns; + samples = rdev->bdev->bd_disk->flush_samples; + } + rcu_read_unlock(); + + spin_lock(&mddev->gendisk->flush_time_lock); + mddev->gendisk->avg_flush_time_ns = max; + mddev->gendisk->flush_samples = samples; + spin_unlock(&mddev->gendisk->flush_time_lock); +} + static void md_end_flush(struct bio *bio, int err) { mdk_rdev_t *rdev = bio->bi_private; @@ -365,6 +387,7 @@ static void md_end_flush(struct bio *bio, int err) rdev_dec_pending(rdev, mddev); if (atomic_dec_and_test(&mddev->flush_pending)) { + measure_flushes(mddev); /* The pre-request flush has finished */ queue_work(md_wq, &mddev->flush_work); } -- 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/