Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp584599pxb; Tue, 5 Apr 2022 14:58:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzhxRB9//8FLVMzdlYt3Tjq/Y+MKMMRtwZTSU4Gd/qR//bbbxCYlUCBG7uw9IlsHmIccFuq X-Received: by 2002:a17:902:9b98:b0:156:52b1:b100 with SMTP id y24-20020a1709029b9800b0015652b1b100mr5566963plp.174.1649195903610; Tue, 05 Apr 2022 14:58:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649195903; cv=none; d=google.com; s=arc-20160816; b=WMohenztx/OTmvyTpRqs1U9lrDC/ic1mBm7KCCpE+/16N0lAzjyybDvGVcqHHnj+3o vpNSSBXfq+nSpL7oHlxqInfzYxK4nZCg6gymPVArtVg2ixN1yCUgtXusEVfBPkGJPdOP HnZD9tKh5og6bN1hq1ArU4N/gkPT7Y5FW2GrTaZ+Eau3vIIfyjRwv+4CgyQlklhFIaD6 7yZ/Dz8kv8jk/9NG3xsi223iTCwBMM/l68D6XkkUSUga9FiBpiNTChq7ZAvHr46Rb7jQ PEKfwj4iydJ3N3PMsR2wVRPtIF+owXU08orCNdxhD9vV588x9L52N0rfLAu19/VP5Nkz CHJg== 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=NgGLncfnUvjpqQh2T2o5uuHdR7llqfPcvERbgnEFEik=; b=a/X/1aLzNbPURau9NN8BHKRzNvZRhFZDOgBx3oXeqwVICH0GT8f5MUYzYUYwpzJ3nd fme/eVI66MzCHqaovVrOYnvYxXBBb39fPu0yPEUbMyUvXLG6ZU7OekTDbxaLyo0BhTIb R75sqZiZCnglC22o6JBGOtcgCz+EgmeY3nlyyYKctGR1Z6Byhzm7yplRyUhETSY0Dlsx s5NLNZDOmzf69pY2cXd8IRy3OE97nDzXrHXBH4TMBX13zpvRbr96AlzicWRs5joAAZu+ Kzo8bATsRlDiXwHpyej/ugUdHntbSeHsy8jRNK5c1YvjbOxW6p81A8VCpJD5RZbpSczc Dy0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=zyNZM+59; 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 17-20020a630e51000000b003993a5ec08bsi5029063pgo.187.2022.04.05.14.58.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Apr 2022 14:58:23 -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=zyNZM+59; 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 3159BF844F; Tue, 5 Apr 2022 14:44:11 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1389459AbiDEOo4 (ORCPT + 99 others); Tue, 5 Apr 2022 10:44:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50320 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244363AbiDEJlP (ORCPT ); Tue, 5 Apr 2022 05:41:15 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB6E79682D; Tue, 5 Apr 2022 02:26:15 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 8701361659; Tue, 5 Apr 2022 09:26:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8CE6BC385A2; Tue, 5 Apr 2022 09:26:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649150774; bh=LhUdYwK+yijx9j6jaivm7tHTIZ57ZeqRqUb+Y3YUgMg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zyNZM+597kgtBJgDXDmT+ZOmxysETN3Hp/6OtcVJydSgkOVxm1ctIpiq02kpFlR0F ipwoyOhbiZ6mlb2EKUJSb4GxjXWRvinKDkwfNZntkZYfyZCO9y/mrNJ6b2VTPzVq4I Keb70An6By722OnBrVxKLw7MIr/oMSAZMMhpvxcg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Johannes Thumshirn , Naohiro Aota , David Sterba Subject: [PATCH 5.15 169/913] btrfs: zoned: mark relocation as writing Date: Tue, 5 Apr 2022 09:20:31 +0200 Message-Id: <20220405070344.914093002@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070339.801210740@linuxfoundation.org> References: <20220405070339.801210740@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.0 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,T_SCC_BODY_TEXT_LINE autolearn=no 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 ca5e4ea0beaec8bc674121838bf8614c089effb9 upstream. There is a hung_task issue with running generic/068 on an SMR device. The hang occurs while a process is trying to thaw the filesystem. The process is trying to take sb->s_umount to thaw the FS. The lock is held by fsstress, which calls btrfs_sync_fs() and is waiting for an ordered extent to finish. However, as the FS is frozen, the ordered extents never finish. Having an ordered extent while the FS is frozen is the root cause of the hang. The ordered extent is initiated from btrfs_relocate_chunk() which is called from btrfs_reclaim_bgs_work(). This commit adds sb_*_write() around btrfs_relocate_chunk() call site. For the usual "btrfs balance" command, we already call it with mnt_want_file() in btrfs_ioctl_balance(). Fixes: 18bb8bbf13c1 ("btrfs: zoned: automatically reclaim zones") CC: stable@vger.kernel.org # 5.13+ Link: https://github.com/naota/linux/issues/56 Reviewed-by: Johannes Thumshirn Signed-off-by: Naohiro Aota Reviewed-by: David Sterba Signed-off-by: David Sterba Signed-off-by: Greg Kroah-Hartman --- fs/btrfs/block-group.c | 8 +++++++- fs/btrfs/volumes.c | 3 +++ 2 files changed, 10 insertions(+), 1 deletion(-) --- a/fs/btrfs/block-group.c +++ b/fs/btrfs/block-group.c @@ -1504,8 +1504,12 @@ void btrfs_reclaim_bgs_work(struct work_ if (!test_bit(BTRFS_FS_OPEN, &fs_info->flags)) return; - if (!btrfs_exclop_start(fs_info, BTRFS_EXCLOP_BALANCE)) + sb_start_write(fs_info->sb); + + if (!btrfs_exclop_start(fs_info, BTRFS_EXCLOP_BALANCE)) { + sb_end_write(fs_info->sb); return; + } /* * Long running balances can keep us blocked here for eternity, so @@ -1513,6 +1517,7 @@ void btrfs_reclaim_bgs_work(struct work_ */ if (!mutex_trylock(&fs_info->reclaim_bgs_lock)) { btrfs_exclop_finish(fs_info); + sb_end_write(fs_info->sb); return; } @@ -1581,6 +1586,7 @@ next: spin_unlock(&fs_info->unused_bgs_lock); mutex_unlock(&fs_info->reclaim_bgs_lock); btrfs_exclop_finish(fs_info); + sb_end_write(fs_info->sb); } void btrfs_reclaim_bgs(struct btrfs_fs_info *fs_info) --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -8185,10 +8185,12 @@ static int relocating_repair_kthread(voi target = cache->start; btrfs_put_block_group(cache); + sb_start_write(fs_info->sb); if (!btrfs_exclop_start(fs_info, BTRFS_EXCLOP_BALANCE)) { btrfs_info(fs_info, "zoned: skip relocating block group %llu to repair: EBUSY", target); + sb_end_write(fs_info->sb); return -EBUSY; } @@ -8216,6 +8218,7 @@ out: btrfs_put_block_group(cache); mutex_unlock(&fs_info->reclaim_bgs_lock); btrfs_exclop_finish(fs_info); + sb_end_write(fs_info->sb); return ret; }