From patchwork Tue Jan 20 09:05:34 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qu Wenruo X-Patchwork-Id: 5666421 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.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id A02B39F2ED for ; Tue, 20 Jan 2015 09:09:17 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C11E220353 for ; Tue, 20 Jan 2015 09:09:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E4BB0203A9 for ; Tue, 20 Jan 2015 09:09:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752544AbbATJHt (ORCPT ); Tue, 20 Jan 2015 04:07:49 -0500 Received: from cn.fujitsu.com ([59.151.112.132]:42399 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1752521AbbATJHr (ORCPT ); Tue, 20 Jan 2015 04:07:47 -0500 X-IronPort-AV: E=Sophos;i="5.04,848,1406563200"; d="scan'208";a="56324392" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 20 Jan 2015 17:04:15 +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 t0K9765T014143; Tue, 20 Jan 2015 17:07:06 +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; Tue, 20 Jan 2015 17:07:47 +0800 From: Qu Wenruo To: CC: Subject: [PATCH RFC v2 2/5] btrfs: Add btrfs_start_transaction_freeze() to start transaction in btrfs_freeze() Date: Tue, 20 Jan 2015 17:05:34 +0800 Message-ID: <1421744737-16586-3-git-send-email-quwenruo@cn.fujitsu.com> X-Mailer: git-send-email 2.2.2 In-Reply-To: <1421744737-16586-1-git-send-email-quwenruo@cn.fujitsu.com> References: <1421744737-16586-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 Add btrfs_start_transaction_freeze() function. This is needed for btrfs_freeze() to handle the pending changes. If there is no running transaction when btrfs_freeze() is called, btrfs_freeze() needs to start a transaction to handle the pending changes, and it can't initial a sb_start_intwrite() call. Signed-off-by: Qu Wenruo --- fs/btrfs/transaction.c | 8 ++++++++ fs/btrfs/transaction.h | 2 ++ 2 files changed, 10 insertions(+) diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c index e88b59d..13a2b67 100644 --- a/fs/btrfs/transaction.c +++ b/fs/btrfs/transaction.c @@ -570,6 +570,14 @@ struct btrfs_trans_handle *btrfs_start_transaction_lflush( BTRFS_RESERVE_FLUSH_LIMIT); } +/* Only used in btrfs_freeze() */ +struct btrfs_trans_handle *btrfs_start_transaction_freeze( + struct btrfs_root *root, int num_items) +{ + return start_transaction(root, num_items, __TRANS_START, + BTRFS_RESERVE_FLUSH_ALL); +} + struct btrfs_trans_handle *btrfs_join_transaction(struct btrfs_root *root) { return start_transaction(root, 0, TRANS_JOIN, 0); diff --git a/fs/btrfs/transaction.h b/fs/btrfs/transaction.h index 00ed29c..49bd7eb 100644 --- a/fs/btrfs/transaction.h +++ b/fs/btrfs/transaction.h @@ -140,6 +140,8 @@ struct btrfs_trans_handle *btrfs_start_transaction(struct btrfs_root *root, int num_items); struct btrfs_trans_handle *btrfs_start_transaction_lflush( struct btrfs_root *root, int num_items); +struct btrfs_trans_handle *btrfs_start_transaction_freeze( + struct btrfs_root *root, int num_items); struct btrfs_trans_handle *btrfs_join_transaction(struct btrfs_root *root); struct btrfs_trans_handle *btrfs_join_transaction_nolock(struct btrfs_root *root); struct btrfs_trans_handle *btrfs_attach_transaction(struct btrfs_root *root);