From patchwork Thu Jan 29 01:27:35 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qu Wenruo X-Patchwork-Id: 5733341 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.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 03BAABF440 for ; Thu, 29 Jan 2015 01:29:12 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3B04020123 for ; Thu, 29 Jan 2015 01:29:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 516F520149 for ; Thu, 29 Jan 2015 01:29:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752117AbbA2B3D (ORCPT ); Wed, 28 Jan 2015 20:29:03 -0500 Received: from cn.fujitsu.com ([59.151.112.132]:5504 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1752268AbbA2B3B (ORCPT ); Wed, 28 Jan 2015 20:29:01 -0500 X-IronPort-AV: E=Sophos;i="5.04,848,1406563200"; d="scan'208";a="56788752" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 29 Jan 2015 09:25:30 +0800 Received: from G08CNEXCHPEKD02.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t0T1SJu4020968; Thu, 29 Jan 2015 09:28:19 +0800 Received: from localhost.localdomain (10.167.226.33) by G08CNEXCHPEKD02.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.181.6; Thu, 29 Jan 2015 09:28:59 +0800 From: Qu Wenruo To: CC: Subject: [PATCH v4 3/8] btrfs: Introduce per-transaction mount_opt to keep mount option consistent during transaction. Date: Thu, 29 Jan 2015 09:27:35 +0800 Message-ID: <1422494863-15077-5-git-send-email-quwenruo@cn.fujitsu.com> X-Mailer: git-send-email 2.2.2 In-Reply-To: <1422494863-15077-1-git-send-email-quwenruo@cn.fujitsu.com> References: <1422494863-15077-1-git-send-email-quwenruo@cn.fujitsu.com> MIME-Version: 1.0 X-Originating-IP: [10.167.226.33] Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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 Before this patch, mount_opt is not consistent during a transaction. btrfs_parse_options() can race with transaction. Now each transaction will keep a copy of fs_info->mount_opt upon creation, and new btrfs_test_trans_opt() macro is introduced to get the mount_opt in the transaction. Signed-off-by: Qu Wenruo --- fs/btrfs/transaction.c | 1 + fs/btrfs/transaction.h | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c index 295a135..846e1b8 100644 --- a/fs/btrfs/transaction.c +++ b/fs/btrfs/transaction.c @@ -210,6 +210,7 @@ loop: return -EROFS; } + cur_trans->mount_opt = fs_info->mount_opt; atomic_set(&cur_trans->num_writers, 1); extwriter_counter_init(cur_trans, type); init_waitqueue_head(&cur_trans->writer_wait); diff --git a/fs/btrfs/transaction.h b/fs/btrfs/transaction.h index fd400a3..4052879 100644 --- a/fs/btrfs/transaction.h +++ b/fs/btrfs/transaction.h @@ -52,6 +52,7 @@ struct btrfs_transaction { struct list_head list; struct extent_io_tree dirty_pages; unsigned long start_time; + unsigned long mount_opt; wait_queue_head_t writer_wait; wait_queue_head_t commit_wait; struct list_head pending_snapshots; @@ -126,6 +127,9 @@ struct btrfs_pending_snapshot { struct list_head list; }; +#define btrfs_test_trans_opt(trans, opt) \ + (btrfs_raw_test_opt(trans->transaction->mount_opt, opt)) + static inline void btrfs_set_inode_last_trans(struct btrfs_trans_handle *trans, struct inode *inode) {