Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp947166pxb; Wed, 6 Apr 2022 05:04:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzD+vDUT/vwAA3AIAe4zKu21Oqr5qgfQcwpdO7Bq4kDyBHqvPd/ogCwx9I8e80X6rRzn8EP X-Received: by 2002:a05:6a00:18a5:b0:4fa:e6f0:d410 with SMTP id x37-20020a056a0018a500b004fae6f0d410mr8634058pfh.28.1649246660047; Wed, 06 Apr 2022 05:04:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649246660; cv=none; d=google.com; s=arc-20160816; b=Lf5MDZ6LiJTxI0dupd70b6fd1KDIytJexvTeVtrA7uATgfQfRQfWqKZMzeOhDptlcG kSAcJehy2dQ9Hw7ZsnRv2MIEmolVtZh3LHc8EvZwaipQ4U0E1CUc7F+eXUD7TwU5jBu9 v3Qevf3PxITJgA+XYqjJRZLK2f79YtDLZrVLzRQM4GuTZCUEh5QfKd3Vsx+eOdyoorrh ccxACSN6qCnp03tVxW5NFtZaxxMmoWV0izcqi0JC6kilBI8zXb/bwHlBgqka/hZoSwqV AByKw8AnvkfVql9S11uHGQXcG9Zq9FHZDjEnPVul8Kpk/z/3YD/ACMeBfnamRfvBXUJ7 i5ow== 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=mczYAUOnAZ35azPtHJjilu5PDQ0zaVRqIdK+4wfEz2E=; b=VRvma30JMg5WwtjYpEIIUKFlviLuVCtUyvT1F16wmZ59H/MhaZiPSicKdJOwCd1pt9 czOrQ0lxwRIO9lixsCr/rCH40rdNdhWEBQxsl2TkG/HpkUTGoJsgEKRD1NMDUvoH9G1I 1WwF/PGLJvyWMkA7wXCeHlsxifHyFbiQfQsQrKnh1GQPsJ0WCxGrQ6ccO+Z7tfEHUx17 7HB49cTe4kWGv1Q5bS9Vhxc2vNMSBQHhY7vB0w1wcG3CMx+anJ5TNzriJ0QDYbAta0c+ zGRDhQNVn/SfGj+F5a6Su2QuZVXvLqo4uhRXrzbMqPt1ScL3Yr0KJXSiAsPxJcQ5d6zK Y0Yw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=04Seav4L; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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. [23.128.96.19]) by mx.google.com with ESMTPS id b8-20020a170902d50800b00153b2d16524si5314441plg.300.2022.04.06.05.04.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 05:04:20 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=04Seav4L; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 8E5771A54D0; Wed, 6 Apr 2022 03:31:41 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356668AbiDEVO6 (ORCPT + 99 others); Tue, 5 Apr 2022 17:14:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51208 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350555AbiDEJ6w (ORCPT ); Tue, 5 Apr 2022 05:58:52 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4565765434; Tue, 5 Apr 2022 02:51:13 -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 A66F561673; Tue, 5 Apr 2022 09:51:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AF372C385A1; Tue, 5 Apr 2022 09:51:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649152272; bh=/I26JbtONVAeteWoFQTGjczew1GeyEqS2guztUZ+bYY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=04Seav4LI5W6Ivb0OG+LK5bKQZs3UaQ+MiQJnx/bon1MI00y/bNZjYmzZ8Ov/KAbb hksyjgnHMgbZPFAcgXk+VpmGg/44Kg7H4gUfCND/nKX+zpEUrKGauMWvEjzdJmYjo7 59x1eCfLWO2kACSmlDqpM82bgkF2BbErmrMJk+UY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Chao Yu , Jaegeuk Kim , Sasha Levin Subject: [PATCH 5.15 718/913] f2fs: dont get FREEZE lock in f2fs_evict_inode in frozen fs Date: Tue, 5 Apr 2022 09:29:40 +0200 Message-Id: <20220405070401.355238370@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: Jaegeuk Kim [ Upstream commit ba900534f807f0b327c92d5141c85d2313e2d55c ] Let's purge inode cache in order to avoid the below deadlock. [freeze test] shrinkder freeze_super - pwercpu_down_write(SB_FREEZE_FS) - super_cache_scan - down_read(&sb->s_umount) - prune_icache_sb - dispose_list - evict - f2fs_evict_inode thaw_super - down_write(&sb->s_umount); - __percpu_down_read(SB_FREEZE_FS) Reviewed-by: Chao Yu Signed-off-by: Jaegeuk Kim Signed-off-by: Sasha Levin --- Documentation/ABI/testing/sysfs-fs-f2fs | 1 + fs/f2fs/debug.c | 1 + fs/f2fs/f2fs.h | 1 + fs/f2fs/inode.c | 6 ++++-- fs/f2fs/super.c | 4 ++++ 5 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Documentation/ABI/testing/sysfs-fs-f2fs b/Documentation/ABI/testing/sysfs-fs-f2fs index f627e705e663..48d41b669627 100644 --- a/Documentation/ABI/testing/sysfs-fs-f2fs +++ b/Documentation/ABI/testing/sysfs-fs-f2fs @@ -425,6 +425,7 @@ Description: Show status of f2fs superblock in real time. 0x800 SBI_QUOTA_SKIP_FLUSH skip flushing quota in current CP 0x1000 SBI_QUOTA_NEED_REPAIR quota file may be corrupted 0x2000 SBI_IS_RESIZEFS resizefs is in process + 0x4000 SBI_IS_FREEZING freefs is in process ====== ===================== ================================= What: /sys/fs/f2fs//ckpt_thread_ioprio diff --git a/fs/f2fs/debug.c b/fs/f2fs/debug.c index 8c50518475a9..07ad0d81f0c5 100644 --- a/fs/f2fs/debug.c +++ b/fs/f2fs/debug.c @@ -338,6 +338,7 @@ static char *s_flag[] = { [SBI_QUOTA_SKIP_FLUSH] = " quota_skip_flush", [SBI_QUOTA_NEED_REPAIR] = " quota_need_repair", [SBI_IS_RESIZEFS] = " resizefs", + [SBI_IS_FREEZING] = " freezefs", }; static int stat_show(struct seq_file *s, void *v) diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index c68817d83a53..0a0fa1a64d06 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -1253,6 +1253,7 @@ enum { SBI_QUOTA_SKIP_FLUSH, /* skip flushing quota in current CP */ SBI_QUOTA_NEED_REPAIR, /* quota file may be corrupted */ SBI_IS_RESIZEFS, /* resizefs is in process */ + SBI_IS_FREEZING, /* freezefs is in process */ }; enum { diff --git a/fs/f2fs/inode.c b/fs/f2fs/inode.c index 6488f5ff250c..2272000fb10b 100644 --- a/fs/f2fs/inode.c +++ b/fs/f2fs/inode.c @@ -769,7 +769,8 @@ void f2fs_evict_inode(struct inode *inode) f2fs_remove_ino_entry(sbi, inode->i_ino, UPDATE_INO); f2fs_remove_ino_entry(sbi, inode->i_ino, FLUSH_INO); - sb_start_intwrite(inode->i_sb); + if (!is_sbi_flag_set(sbi, SBI_IS_FREEZING)) + sb_start_intwrite(inode->i_sb); set_inode_flag(inode, FI_NO_ALLOC); i_size_write(inode, 0); retry: @@ -800,7 +801,8 @@ void f2fs_evict_inode(struct inode *inode) if (dquot_initialize_needed(inode)) set_sbi_flag(sbi, SBI_QUOTA_NEED_REPAIR); } - sb_end_intwrite(inode->i_sb); + if (!is_sbi_flag_set(sbi, SBI_IS_FREEZING)) + sb_end_intwrite(inode->i_sb); no_delete: dquot_drop(inode); diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index 7b744ceb17a5..6dc66b7bc1f5 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -1663,11 +1663,15 @@ static int f2fs_freeze(struct super_block *sb) /* ensure no checkpoint required */ if (!llist_empty(&F2FS_SB(sb)->cprc_info.issue_list)) return -EINVAL; + + /* to avoid deadlock on f2fs_evict_inode->SB_FREEZE_FS */ + set_sbi_flag(F2FS_SB(sb), SBI_IS_FREEZING); return 0; } static int f2fs_unfreeze(struct super_block *sb) { + clear_sbi_flag(F2FS_SB(sb), SBI_IS_FREEZING); return 0; } -- 2.34.1