From patchwork Tue Jan 20 09:05:37 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qu Wenruo X-Patchwork-Id: 5666461 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 E6EF99F2ED for ; Tue, 20 Jan 2015 09:12:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 21999203AE for ; Tue, 20 Jan 2015 09:12:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3A094203A9 for ; Tue, 20 Jan 2015 09:12:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751374AbbATJJO (ORCPT ); Tue, 20 Jan 2015 04:09:14 -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 S1752087AbbATJHs (ORCPT ); Tue, 20 Jan 2015 04:07:48 -0500 X-IronPort-AV: E=Sophos;i="5.04,848,1406563200"; d="scan'208";a="56324397" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 20 Jan 2015 17:04:18 +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 t0K979Es014157; Tue, 20 Jan 2015 17:07:09 +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:50 +0800 From: Qu Wenruo To: CC: Subject: [PATCH RFC v2 5/5] Revert "btrfs: move commit out of sysfs when changing features" Date: Tue, 20 Jan 2015 17:05:37 +0800 Message-ID: <1421744737-16586-6-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 This reverts commit 0eae2747ec1dd ("btrfs: move commit out of sysfs when changing features"). Unlike most btrfs file operations, sysfs don't go through the normal open/read/write routine which will initiate a sb_start_*write/read. This is very dangerous on frozen btrfs, if using the pending changes method, sysfs change can make fs_info->pending_changes to 1, and later sync_fs() call will cause deadlock. So revert the patch to deal the deadlock caused by the following workload: freeze() -> change features -> sync() -> unfreeze() Signed-off-by: Qu Wenruo --- fs/btrfs/sysfs.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c index 226f726..b2e7bb4 100644 --- a/fs/btrfs/sysfs.c +++ b/fs/btrfs/sysfs.c @@ -111,6 +111,7 @@ static ssize_t btrfs_feature_attr_store(struct kobject *kobj, { struct btrfs_fs_info *fs_info; struct btrfs_feature_attr *fa = to_btrfs_feature_attr(a); + struct btrfs_trans_handle *trans; u64 features, set, clear; unsigned long val; int ret; @@ -152,6 +153,10 @@ static ssize_t btrfs_feature_attr_store(struct kobject *kobj, btrfs_info(fs_info, "%s %s feature flag", val ? "Setting" : "Clearing", fa->kobj_attr.attr.name); + trans = btrfs_start_transaction(fs_info->fs_root, 0); + if (IS_ERR(trans)) + return PTR_ERR(trans); + spin_lock(&fs_info->super_lock); features = get_features(fs_info, fa->feature_set); if (val) @@ -161,11 +166,9 @@ static ssize_t btrfs_feature_attr_store(struct kobject *kobj, set_features(fs_info, fa->feature_set, features); spin_unlock(&fs_info->super_lock); - /* - * We don't want to do full transaction commit from inside sysfs - */ - btrfs_set_pending(fs_info, COMMIT); - wake_up_process(fs_info->transaction_kthread); + ret = btrfs_commit_transaction(trans, fs_info->fs_root); + if (ret) + return ret; return count; }