From patchwork Mon Mar 28 06:29:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naohiro Aota X-Patchwork-Id: 12793239 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CCB38C433F5 for ; Mon, 28 Mar 2022 06:29:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238453AbiC1GbM (ORCPT ); Mon, 28 Mar 2022 02:31:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238461AbiC1GbL (ORCPT ); Mon, 28 Mar 2022 02:31:11 -0400 Received: from esa2.hgst.iphmx.com (esa2.hgst.iphmx.com [68.232.143.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DF8891164 for ; Sun, 27 Mar 2022 23:29:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1648448971; x=1679984971; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=QKH/8wm+bXeq4ciczY4GMtSIhBOzRDlob2ZdPvhqb18=; b=TKRNIf/HV5XrKAUuGiqJ8W6xCi5kJyDgfFTaUDdqF1xkTqixUl7hJimk dqkgywsVFnmYQHJw3SVPNQyMZTooQ508ZpBg/svM1g7bGb0XrDHQkPhrz IbnugyQlj4DYOx665y2MviFYK4u+KXjI39Wfnm1rt/bqFMxNHogG4vYon YzPLNYBqTO/38oi5CMy1WYTVFtu+yGuVID5CfREFoEKmn/nFjPSpHt8Vt RkzgdUoCPy/3Hzqbcc4EIU6tDLqCDcLPUaQKc96UtJbqCkPmU3NZVaElb GseTICVi+Hk9CIUIKauVTk2Tj47LXP8UlCC/MTzJYrbIcsYY6VsVUc6u6 Q==; X-IronPort-AV: E=Sophos;i="5.90,216,1643644800"; d="scan'208";a="300566280" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 28 Mar 2022 14:29:31 +0800 IronPort-SDR: CgVUWher0AU0tcFxvA0XFeeAzNF2mMz/27O/KRcgB0Wm/gE4CnCAiaXelYqrYp9DwxLRqQLilf yX5HaIR0Q1QaiuEaKcxrOlok0+891O/jYGIztg875YrcT6ELYMFs41yE0tN6jIbVekQ8y8K/fi RuLITgRQJY69AE+WqEEZFwLbnCSLMV+Mi3m3sFQxYA58e5DlRkSDvDpOaGely5h2D/TMHcInpL 7a9IzCQvd818QLV6cotiOffWlFR4G8vSc6g4tOB/pkgDNZxIZTzLUaVGsNYMe2uhkheH6Y9Ehm KXv9y0aO9axmrSpZnrOFXr/P Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 27 Mar 2022 23:00:24 -0700 IronPort-SDR: gJJYoAUZYGnILQOJo4ovUSNu7eS5zPNyxicwdizEAUKpRSeXY7rD/SJw8Ap2psWE692o4dcug1 cBxCLNmooojHuNzKKxOnqGTVGepUM22eWCVdVk+J/RJiNHUUtf7nFuvm9aH5+vK50ljvuxnRUl mPTon85ovn4xCh4r15kVzR1UCs0YnSoM5uGhPLPXUT91CRSOkAK1c2BYeO8Gq0impl7v17bmVg WFioj6oVjMb35sTZdN3xqd7n6uKnmf7IDPctMI4UzHxkggS5u80gzoYa/P/YFltVC0Bj0ESGk/ ATs= WDCIronportException: Internal Received: from phd006511.ad.shared (HELO naota-xeon.wdc.com) ([10.225.52.242]) by uls-op-cesaip01.wdc.com with ESMTP; 27 Mar 2022 23:29:31 -0700 From: Naohiro Aota To: linux-btrfs@vger.kernel.org Cc: johannes.thumshirn@wdc.com, Naohiro Aota , Filipe Manana Subject: [PATCH v3 1/3] btrfs: mark resumed async balance as writing Date: Mon, 28 Mar 2022 15:29:20 +0900 Message-Id: <72503baa4f47792e9f7b6c3b5dc858e02e778fbf.1648448228.git.naohiro.aota@wdc.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org When btrfs balance is interrupted with umount, the background balance resumes on the next mount. There is a potential deadlock with FS freezing here like as described in commit 26559780b953 ("btrfs: zoned: mark relocation as writing"). Mark the process as sb_writing to avoid it. Reviewed-by: Filipe Manana Cc: stable@vger.kernel.org # 4.9+ Signed-off-by: Naohiro Aota --- fs/btrfs/volumes.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 3fd17e87815a..3471698fd831 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -4430,10 +4430,12 @@ static int balance_kthread(void *data) struct btrfs_fs_info *fs_info = data; int ret = 0; + sb_start_write(fs_info->sb); mutex_lock(&fs_info->balance_mutex); if (fs_info->balance_ctl) ret = btrfs_balance(fs_info, fs_info->balance_ctl, NULL); mutex_unlock(&fs_info->balance_mutex); + sb_end_write(fs_info->sb); return ret; }