Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp694234pxb; Tue, 5 Apr 2022 19:04:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwo1FJRB5J8rWwx+4ElZ1DM/pZ9N2SrpPxVcUM6anVoDLXETShkXr4GDng+bC0RNE9H8cX6 X-Received: by 2002:a17:90b:4acc:b0:1c7:f18:1141 with SMTP id mh12-20020a17090b4acc00b001c70f181141mr7331766pjb.31.1649210590419; Tue, 05 Apr 2022 19:03:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649210590; cv=none; d=google.com; s=arc-20160816; b=Sm7XMEqCnnzwkVJaE+F8c4zCBWyxd6wU2/MCOIguwtLeRv8TRLHFNfTr6mgf2cllIM Mu3v6wPi2hXvHq78yrv/2A9jngOx/NVmzvcX/aelyeKGJymdKpGBvZR27HGLUk20m+Bf ZFj4iZA7y0rtUgjrP1oVBYTl0LAZ32acbKdWowavNx5misBrv3dbIyPym6664UkLcBSD CHSxV36o5sM3h812FHmIAj//OCcTBCtLiEgWVnXXqjwFehKWAixownnNUfCvzvtc5wQx JebdmyHR18WRd/NfJfDre8ix8bucjU1u9JXJOImUam3x0Xdi5uXgolk/HZqCOq0hwWCl Md5g== 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=tzTID0G7/bpsavEEBnokihf6n1w88s8P822ojaOoXdc=; b=POE/FCdFWfdQH5eEaiAR9mgIQkBHJixrudedd9JducffDst35H1msbsdoFPsVp/2T8 X5mjLnwX+1lyj/q8c5piKTYz5DRnOt4ehEx1xJrdrQ1icYtOThcY6Ew1uOh3atXxif8P SEzJQ/WxQOIRCa5FgTmB9gH0jWxEcUPDTCO32miGxqzZ+xKDRZXRSojPU3c2pA3JZpXf N6B+KdN2HOicVYYTh34543z/iRgmhF6BuUQPDVjykOTHqorSW3AwY9tkdLGKgfuAuiOG xdmSb92oO6pfyqmFZBIAnQZHI7V6UisnwXEQJ3jiLBHHrK+WlBVnlUCXNtCvDTR0UrMy JJDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=sd2ywaUz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lb8-20020a17090b4a4800b001bf1cbbcb9fsi4352286pjb.131.2022.04.05.19.02.52; Tue, 05 Apr 2022 19:03:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=sd2ywaUz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235845AbiDEIAb (ORCPT + 99 others); Tue, 5 Apr 2022 04:00:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54820 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232165AbiDEHtD (ORCPT ); Tue, 5 Apr 2022 03:49:03 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 218B4BFE; Tue, 5 Apr 2022 00:46:46 -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 C0E73616DE; Tue, 5 Apr 2022 07:46:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D403DC34110; Tue, 5 Apr 2022 07:46:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649144805; bh=ghfsdy2FY18wxZNczTzKE0jexByHGmomgL6U6fHsJZc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sd2ywaUzezpew0oe0jTNQA36NjkyvJ9N5AO6LGrwo38xtdLKo3eG3K6PLZNpl2KYf b67vRq3qeY/gdsMOjecqzp57K/t+NvnsCkc9i4J/OS6UJWCw2GHpYrSpX6qyPDV1fT iDLYEhvoMYIeEtr8EABBtaqYl1Rqw5fycro8FhAw= 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.17 0176/1126] btrfs: zoned: mark relocation as writing Date: Tue, 5 Apr 2022 09:15:23 +0200 Message-Id: <20220405070412.768251580@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070407.513532867@linuxfoundation.org> References: <20220405070407.513532867@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=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 @@ -1522,8 +1522,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 @@ -1531,6 +1535,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; } @@ -1605,6 +1610,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 @@ -8299,10 +8299,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; } @@ -8330,6 +8332,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; }