From patchwork Thu Jan 29 02:24:36 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qu Wenruo X-Patchwork-Id: 5734861 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 7C5F8BF440 for ; Thu, 29 Jan 2015 02:26:08 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id ABA4A201F2 for ; Thu, 29 Jan 2015 02:26:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D436E201ED for ; Thu, 29 Jan 2015 02:26:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932901AbbA2C0A (ORCPT ); Wed, 28 Jan 2015 21:26:00 -0500 Received: from cn.fujitsu.com ([59.151.112.132]:26041 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S932830AbbA2CZ6 (ORCPT ); Wed, 28 Jan 2015 21:25:58 -0500 X-IronPort-AV: E=Sophos;i="5.04,848,1406563200"; d="scan'208";a="56792901" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 29 Jan 2015 10:22:25 +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 t0T2PEBm026234 for ; Thu, 29 Jan 2015 10:25:15 +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 10:25:55 +0800 From: Qu Wenruo To: Subject: [PATCH RESEND v4 3/8] btrfs: Introduce per-transaction mount_opt to keep mount option consistent during transaction. Date: Thu, 29 Jan 2015 10:24:36 +0800 Message-ID: <1422498281-20493-4-git-send-email-quwenruo@cn.fujitsu.com> X-Mailer: git-send-email 2.2.2 In-Reply-To: <1422498281-20493-1-git-send-email-quwenruo@cn.fujitsu.com> References: <1422498281-20493-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) {