From patchwork Wed Dec 18 10:52:44 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miao Xie X-Patchwork-Id: 3369591 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 91AD0C0D4A for ; Wed, 18 Dec 2013 10:52:05 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6C40A20457 for ; Wed, 18 Dec 2013 10:52:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B91E92044C for ; Wed, 18 Dec 2013 10:51:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751405Ab3LRKv4 (ORCPT ); Wed, 18 Dec 2013 05:51:56 -0500 Received: from cn.fujitsu.com ([222.73.24.84]:8691 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1751320Ab3LRKvz (ORCPT ); Wed, 18 Dec 2013 05:51:55 -0500 X-IronPort-AV: E=Sophos;i="4.95,507,1384272000"; d="scan'208";a="9283586" Received: from unknown (HELO tang.cn.fujitsu.com) ([10.167.250.3]) by song.cn.fujitsu.com with ESMTP; 18 Dec 2013 18:47:59 +0800 Received: from fnstmail02.fnst.cn.fujitsu.com (tang.cn.fujitsu.com [127.0.0.1]) by tang.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id rBIApVEA019488 for ; Wed, 18 Dec 2013 18:51:31 +0800 Received: from miao.fnst.cn.fujitsu.com ([10.167.226.106]) by fnstmail02.fnst.cn.fujitsu.com (Lotus Domino Release 8.5.3) with ESMTP id 2013121818510212-540952 ; Wed, 18 Dec 2013 18:51:02 +0800 From: Miao Xie To: linux-btrfs@vger.kernel.org Subject: [PATCH] Btrfs: improve the performance fluctuating of the fsync Date: Wed, 18 Dec 2013 18:52:44 +0800 Message-Id: <1387363964-20316-1-git-send-email-miaox@cn.fujitsu.com> X-Mailer: git-send-email 1.8.3.1 X-MIMETrack: Itemize by SMTP Server on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2013/12/18 18:51:02, Serialize by Router on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2013/12/18 18:51:02, Serialize complete at 2013/12/18 18:51:02 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 In order to improve the performance of fsync, we use the outstanding ordered extents to avoid looking up the checksum from the csum tree. But we didn't filter out the ordered extents whose csum is still being calculated, when we got those ordered extents, we had to wait for the csum calculation. It made the performance dropped down suddenly. (On my box, it drop down from 56MB/s to 4-10MB/s) But actually, the csum calculation of the ordered extents which were introduced by the current fsync had already completed. Those ordered extents whose csum was being calculated didn't belong to the current fsync, we can ignore them. By this patch, the performance fluctuating doesn't happen, and the average performance grows up by ~2%. Test Environment: CPU: 2CPU * 2Cores Memory: 4GB Partition: 20GB(HDD) Test Command: # sysbench --num-threads=8 --test=fileio --file-num=1 \ > --file-total-size=8G --file-block-size=32768 \ > --file-io-mode=sync --file-fsync-freq=100 \ > --file-fsync-end=no --max-requests=10000 \ > --file-test-mode=rndwr run Signed-off-by: Miao Xie --- fs/btrfs/ordered-data.c | 3 +++ fs/btrfs/tree-log.c | 2 -- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/fs/btrfs/ordered-data.c b/fs/btrfs/ordered-data.c index b8c2ded..df87ed5 100644 --- a/fs/btrfs/ordered-data.c +++ b/fs/btrfs/ordered-data.c @@ -433,6 +433,9 @@ void btrfs_get_logged_extents(struct btrfs_root *log, struct inode *inode) spin_lock_irq(&tree->lock); for (n = rb_first(&tree->tree); n; n = rb_next(n)) { ordered = rb_entry(n, struct btrfs_ordered_extent, rb_node); + if (ordered->csum_bytes_left) + continue; + spin_lock(&log->log_extents_lock[index]); if (list_empty(&ordered->log_list)) { list_add_tail(&ordered->log_list, &log->logged_list[index]); diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c index ba2f151..3eae2eb 100644 --- a/fs/btrfs/tree-log.c +++ b/fs/btrfs/tree-log.c @@ -3631,8 +3631,6 @@ again: * start over after this. */ - wait_event(ordered->wait, ordered->csum_bytes_left == 0); - list_for_each_entry(sum, &ordered->list, list) { ret = btrfs_csum_file_blocks(trans, log, sum); if (ret) {