Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp855773pxb; Fri, 22 Apr 2022 12:43:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxMKKeYqtl4d9ejfqEWASN0YWHd6A2cB1DNmYjxs/iqlMdAT21dtdYNsz4XRGwlVBG3TQ3Q X-Received: by 2002:a63:6ac3:0:b0:3aa:f5a8:2e83 with SMTP id f186-20020a636ac3000000b003aaf5a82e83mr53773pgc.232.1650656601495; Fri, 22 Apr 2022 12:43:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650656601; cv=none; d=google.com; s=arc-20160816; b=ObZCvVI+hsOBZrP2LvOUKpxRHPag1LXUmVn3AM6vGhDITmFWQnWoaflu7GnO4MHnpq OHfu7lTAEyghGF+ifaI66lpoffo2xw5STU4++gHXPkKPgSU9MNcdhXyiZqx6MhCBgapO iy1GjCfopCzq8TQoCFlWVZtBdF4F5+54nMqlVF34WQEhP08wETYMWZr78WqsOTcAekuh O7A4dYMIdssZsu0o1dQIxDv5vvew1VYOr2nVqE+14HZDmUsnQWtsyYEEyApemud0Ib9w J+qZAUyEVT1XcMF/YHgAYGTwJYPQ5TXh9iCVZt6hnzcZ9J8Be1ZEOrAgYtS2wmRz11FC xqTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=N66B4Wwt38sPB6fHasjuuZXRjRqsjAsMNNEckDHGGY0=; b=0EILV67h1rCJy8ZwDfF2gXoC+a1yxaEWpwA4dlnNvkFnFukWaRcO7EPE0C6Mm/5LNV wO1Kcq7U7dxs8Wo5IijhOmXir7bFDg4k70zH1yhGMHGAY3FrQhch204O74DoT6e3/COL JEi63lw8HvdSfgKu6sYCLuvkpJm+2BnS9cSzRa1h8ZnmwPGJc7hbd63mDW85x1rln5b2 4AyUNi4FZOvqWb1ANcorPD7INL/W26H8G7WTKU5u58D4X/R7Eyvpt5faxDbw1uUYBNt8 WOrN7meNF6Nxpoqr4KxX73L+naQB6pQYGZQ1ul1hCEcGK8RwPq9CPgC24A7+Gg8esFdQ Dlrg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=T7oKNROo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id kb11-20020a17090ae7cb00b001cba0d1d3b4si9840344pjb.98.2022.04.22.12.43.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Apr 2022 12:43:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=T7oKNROo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id A796E205DAA; Fri, 22 Apr 2022 11:48:26 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239867AbiDRMiM (ORCPT + 99 others); Mon, 18 Apr 2022 08:38:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54196 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239484AbiDRMdG (ORCPT ); Mon, 18 Apr 2022 08:33:06 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CCA1427155; Mon, 18 Apr 2022 05:24:42 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 3A89AB80EDA; Mon, 18 Apr 2022 12:24:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 87886C385A7; Mon, 18 Apr 2022 12:24:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1650284679; bh=EqglRn5xcFl+tW4PtwzUZdnUb5d1rVO9ltXvhrXeKqw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=T7oKNROoD5P/XD7/cGChroTMJQFGimW8zzLD8VGo4OTR85+RDP0rjChlh1fXq6MsT eWqHTHgGoVyXTJFOKzVlOgHcIKTpRoYrEKkkUW7+OugHEsB4S6j1r02udb0BKMPdMQ BMqsU/c5V9fMiDXc0x11Pn4hQO6Y/qO4tRG6JMXI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Filipe Manana , Naohiro Aota , David Sterba Subject: [PATCH 5.17 193/219] btrfs: mark resumed async balance as writing Date: Mon, 18 Apr 2022 14:12:42 +0200 Message-Id: <20220418121212.277352250@linuxfoundation.org> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220418121203.462784814@linuxfoundation.org> References: <20220418121203.462784814@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Naohiro Aota commit a690e5f2db4d1dca742ce734aaff9f3112d63764 upstream. 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 Reviewed-by: David Sterba Signed-off-by: David Sterba Signed-off-by: Greg Kroah-Hartman --- fs/btrfs/volumes.c | 2 ++ 1 file changed, 2 insertions(+) --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -4467,10 +4467,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; }