From patchwork Tue Jan 14 12:31:52 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miao Xie X-Patchwork-Id: 3485771 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 121EE9F381 for ; Tue, 14 Jan 2014 13:16:38 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8342020212 for ; Tue, 14 Jan 2014 13:16:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5EDF12020F for ; Tue, 14 Jan 2014 13:16:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751841AbaANNQ0 (ORCPT ); Tue, 14 Jan 2014 08:16:26 -0500 Received: from cn.fujitsu.com ([222.73.24.84]:30785 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1751826AbaANNQS (ORCPT ); Tue, 14 Jan 2014 08:16:18 -0500 X-IronPort-AV: E=Sophos;i="4.95,658,1384272000"; d="scan'208";a="9415311" Received: from unknown (HELO tang.cn.fujitsu.com) ([10.167.250.3]) by song.cn.fujitsu.com with ESMTP; 14 Jan 2014 21:12:19 +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 s0ECUOnC015721 for ; Tue, 14 Jan 2014 20:30:26 +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 2014011420291304-1067067 ; Tue, 14 Jan 2014 20:29:13 +0800 From: Miao Xie To: linux-btrfs@vger.kernel.org Subject: [PATCH V2 4/4] Btrfs: flush the dirty pages of the ordered extent aggressively during logging csum Date: Tue, 14 Jan 2014 20:31:52 +0800 Message-Id: <1389702712-26638-5-git-send-email-miaox@cn.fujitsu.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1389702712-26638-1-git-send-email-miaox@cn.fujitsu.com> References: <1389702712-26638-1-git-send-email-miaox@cn.fujitsu.com> X-MIMETrack: Itemize by SMTP Server on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2014/01/14 20:29:13, Serialize by Router on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2014/01/14 20:29:14, Serialize complete at 2014/01/14 20:29:14 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.0 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 The performance of fsync dropped down suddenly sometimes, the main reason of this problem was that we might only flush part dirty pages in a ordered extent, then got that ordered extent, wait for the csum calcucation. But if no task flushed the left part, we would wait until the flusher flushed them, sometimes we need wait for several seconds, it made the performance drop down suddenly. (On my box, it drop down from 56MB/s to 4-10MB/s) This patch improves the above problem by flushing left dirty pages aggressively. 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/tree-log.c | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-) diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c index 251e6f4..944701b 100644 --- a/fs/btrfs/tree-log.c +++ b/fs/btrfs/tree-log.c @@ -3470,7 +3470,11 @@ static int log_one_extent(struct btrfs_trans_handle *trans, &ordered->flags)) continue; - wait_event(ordered->wait, ordered->csum_bytes_left == 0); + if (ordered->csum_bytes_left) { + btrfs_start_ordered_extent(inode, ordered, 0); + 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);