From patchwork Thu Nov 25 09:54:32 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miao Xie X-Patchwork-Id: 356472 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id oAP9uGS4025571 for ; Thu, 25 Nov 2010 09:56:18 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752035Ab0KYJzv (ORCPT ); Thu, 25 Nov 2010 04:55:51 -0500 Received: from cn.fujitsu.com ([222.73.24.84]:51436 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1751846Ab0KYJzq (ORCPT ); Thu, 25 Nov 2010 04:55:46 -0500 Received: from tang.cn.fujitsu.com (tang.cn.fujitsu.com [10.167.250.3]) by song.cn.fujitsu.com (Postfix) with ESMTP id 95E2E170E96; Thu, 25 Nov 2010 17:55:44 +0800 (CST) Received: from mailserver.fnst.cn.fujitus.com (tang.cn.fujitsu.com [127.0.0.1]) by tang.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id oAP9pBd2013793; Thu, 25 Nov 2010 17:51:11 +0800 Received: from [10.167.225.64] ([10.167.225.64]) by mailserver.fnst.cn.fujitus.com (Lotus Domino Release 8.5.1FP4) with ESMTP id 2010112517560063-101240 ; Thu, 25 Nov 2010 17:56:00 +0800 Message-ID: <4CEE3258.2090302@cn.fujitsu.com> Date: Thu, 25 Nov 2010 17:54:32 +0800 From: Miao Xie Reply-To: miaox@cn.fujitsu.com User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.9) Gecko/20100413 Fedora/3.0.4-2.fc13 Thunderbird/3.0.4 MIME-Version: 1.0 To: Chris Mason , Josef Bacik CC: Linux Btrfs , Liu Bo Subject: [RFC PATCH 2/4] Btrfs: add MS_RDONLY to avoid backgroud writeback X-MIMETrack: Itemize by SMTP Server on mailserver/fnst(Release 8.5.1FP4|July 25, 2010) at 2010-11-25 17:56:00, Serialize by Router on mailserver/fnst(Release 8.5.1FP4|July 25, 2010) at 2010-11-25 17:56:01, Serialize complete at 2010-11-25 17:56:01 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Thu, 25 Nov 2010 09:56:18 +0000 (UTC) diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c index 1fffbc0..45c76b9 100644 --- a/fs/btrfs/transaction.c +++ b/fs/btrfs/transaction.c @@ -1188,6 +1188,13 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans, unsigned long now = get_seconds(); int flush_on_commit = btrfs_test_opt(root, FLUSHONCOMMIT); + /* + * Since some error may force btrfs readonly, this can + * avoid backgroud writeback. + */ + if (root->fs_info->sb->s_flags & MS_RDONLY) + return 0; + btrfs_run_ordered_operations(root, 0); /* make a pass through all the delayed refs we have so far