From patchwork Fri Nov 14 10:33:14 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Sterba X-Patchwork-Id: 5304691 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 6C5B79F2ED for ; Fri, 14 Nov 2014 10:33:23 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A7FCC2015D for ; Fri, 14 Nov 2014 10:33:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D147720154 for ; Fri, 14 Nov 2014 10:33:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755116AbaKNKdR (ORCPT ); Fri, 14 Nov 2014 05:33:17 -0500 Received: from cantor2.suse.de ([195.135.220.15]:57146 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755091AbaKNKdP (ORCPT ); Fri, 14 Nov 2014 05:33:15 -0500 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id D452DAD35 for ; Fri, 14 Nov 2014 10:33:14 +0000 (UTC) Received: by ds.suse.cz (Postfix, from userid 10065) id ACB61DA8E7; Fri, 14 Nov 2014 11:33:14 +0100 (CET) From: David Sterba To: linux-btrfs@vger.kernel.org Cc: David Sterba Subject: [PATCH 4/6] btrfs: introduce pending action: commit Date: Fri, 14 Nov 2014 11:33:14 +0100 Message-Id: X-Mailer: git-send-email 2.1.3 In-Reply-To: References: 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=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 In some contexts, like in sysfs handlers, we don't want to trigger a transaction commit. It's a heavy operation, we don't know what external locks may be taken. Instead, make it possible to finish the operation through sync syscall or SYNC_FS ioctl. Signed-off-by: David Sterba --- fs/btrfs/ctree.h | 1 + fs/btrfs/transaction.c | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 1c9157e4ab0c..817fc19b8159 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -2132,6 +2132,7 @@ struct btrfs_ioctl_defrag_range_args { #define BTRFS_PENDING_SET_INODE_MAP_CACHE (0) #define BTRFS_PENDING_CLEAR_INODE_MAP_CACHE (1) +#define BTRFS_PENDING_COMMIT (2) #define btrfs_test_pending(info, opt) \ test_bit(BTRFS_PENDING_##opt, &(info)->pending_changes) diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c index 703238ed7337..9d8e2b8d12b4 100644 --- a/fs/btrfs/transaction.c +++ b/fs/btrfs/transaction.c @@ -2036,6 +2036,11 @@ void btrfs_apply_pending_changes(struct btrfs_fs_info *fs_info) btrfs_clear_opt(fs_info->mount_opt, INODE_MAP_CACHE); prev &= ~bit; + bit = 1 << BTRFS_PENDING_COMMIT; + if (prev & bit) + btrfs_debug(fs_info, "pending commit done"); + prev &= ~bit; + if (prev) btrfs_warn(fs_info, "unknown pending changes left 0x%lx, ignoring", prev);