Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp5575968pxb; Mon, 28 Mar 2022 14:26:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwMq1w3iGYYaQzR83Bz2BnR3VfuCDbJzIaO9Ldb3tsOvoX0Toz+sQuJkn4wlo9h0EZy4191 X-Received: by 2002:a05:6808:b13:b0:2ec:a7d0:124b with SMTP id s19-20020a0568080b1300b002eca7d0124bmr599862oij.85.1648502813667; Mon, 28 Mar 2022 14:26:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648502813; cv=none; d=google.com; s=arc-20160816; b=LUk3vAbXHawumLhMWvM0s3qxj/XolcERIdjLoiCSNNbLObN4upjq8AYMd2C/zvZccP u9ejhPFZF3Yfnp7cn6In92R1/btPYOLOxcGUNUzHmnPFetkqHOcxHn166vm5eUb3V4TK +eqhI8JkRXYSWQvEHGhyWVKORfVVwjW6AU7fT2XfxliXnzx6CeMSnEBxBkqzmGqsM5nr rnlczXqja6VKUAclagv5uy5h6DSvxYHZId5e+SnRV7utELMaganiwbAKSc0wJHxoSpbJ EHrRoffqkjGqxjdsIJ47osTa7W0r9UiHagp5JMQAG6V+er6bpMdDLQ2sMch77aEeNxfu Z7UQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=cK/FazBFEfOw/f8rLn9ZCs9tw8HqAHS7xribQCIT6sA=; b=KJgq9Fs+LYEedgdM6WJlKUqYV5cpStLBmpBd0ioWz5vKHLSnnEVJAixvpYOyfO7WUT ++/yMA1J9NF7ZQaSg7reuKrou24w9sYRcdFzWor8YO4Z6GU31VhFYQ/Sj41pu4H6E6Lz +Kzs8HouhmOEAoFg8aKI4/W6Ri+3BQpqfT0EDKPLLZLQ0oVBK3LzYhHWVLq0VsuHuAUl lMDIuackJRuYJu+g38BXEd4ovO6J+ypJzukjnInI/MaWj+JocxyfF4JEmFPkuOWQ6NBM J77ZQ2HiMZImRADQgCTyta3SBS2ov7v3wgDhfLSAGzpaw7XmJm6vWFwJ5+QAPtoDAq/i hGEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ESbJdsys; 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=kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id r10-20020a05687032ca00b000ddd8d4aa1csi10623872oac.232.2022.03.28.14.26.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Mar 2022 14:26:53 -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=@kernel.org header.s=k20201202 header.b=ESbJdsys; 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=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 056D540A1A; Mon, 28 Mar 2022 14:11:08 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343577AbiC1ToS (ORCPT + 99 others); Mon, 28 Mar 2022 15:44:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49550 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245753AbiC1ToA (ORCPT ); Mon, 28 Mar 2022 15:44:00 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 27F815EBE3; Mon, 28 Mar 2022 12:42:12 -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 B6641612AF; Mon, 28 Mar 2022 19:42:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5F4BAC34100; Mon, 28 Mar 2022 19:42:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1648496531; bh=EhX138gT4xw4XP//qPi7bg6ZwwdT6/mNNofgRsU8Cnw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ESbJdsysmyRjAysrUH/gqU48FtUBwsE2r8mSvsaNMPK0VFIz/Vsg5ifnWrRYkGgd3 +fU1G/u8niHnrerrzHyQHwbWR0FIrTS4UmrPV35/nuv7ZN1iX7OolHnEB6eOq0wURy k21b1uBXQ/FeSb9fuyYb9UcKGeC3CS/vAdg0/Cmf0Re+UkAiz1aFOf8sNkbugCc8yj rBxLXEOQh6M1i/OwKyWUsDuoolkQcAiVLra35zUP0uBKr3xjesAQ85xDSZO5J+HQIw DfuDdhDu67lwEYKF+BPwtvTvCjyv5m0ZHaLbG98CUciwvhO9xHxrR2IS5clnweiNUE 8dUoa17PFgiTA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Jaegeuk Kim , Chao Yu , Sasha Levin , yuchao0@huawei.com, linux-f2fs-devel@lists.sourceforge.net Subject: [PATCH AUTOSEL 5.17 10/21] f2fs: don't get FREEZE lock in f2fs_evict_inode in frozen fs Date: Mon, 28 Mar 2022 15:41:45 -0400 Message-Id: <20220328194157.1585642-10-sashal@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220328194157.1585642-1-sashal@kernel.org> References: <20220328194157.1585642-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE 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: 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 2416b03ff283..137f16feee08 100644 --- a/Documentation/ABI/testing/sysfs-fs-f2fs +++ b/Documentation/ABI/testing/sysfs-fs-f2fs @@ -430,6 +430,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 68b44015514f..2514597f5b26 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -1267,6 +1267,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 0ec8e32a00b4..026c2f79fd05 100644 --- a/fs/f2fs/inode.c +++ b/fs/f2fs/inode.c @@ -778,7 +778,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: @@ -809,7 +810,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 baefd398ec1a..e18726c5a564 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -1662,11 +1662,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