Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp756899pxp; Fri, 11 Mar 2022 14:18:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJxkl5Z1kBohw37wVvNhOlCGz6tUjgVL5elNnsJAAIaBeVoI4PDHvD5EQbYqn4Q5G8h+C0bS X-Received: by 2002:a17:90a:f186:b0:1bf:285a:2731 with SMTP id bv6-20020a17090af18600b001bf285a2731mr12833616pjb.22.1647037119574; Fri, 11 Mar 2022 14:18:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1647037119; cv=none; d=google.com; s=arc-20160816; b=dHAe9dsOsXQHhxiPcwxC+220gbH2vPeYQBrLyi+Z5bYafRWS95AGQkEzQpne8YHnhy eTp+cvzw9IWc8kAhSNAN8V1W85miwpltMjStKLWmDNKRAg8Afe7pLE16EuAKgl9qFZt/ bzCDoCZWTA9ODwSRRh16vh9TSejw4ytgdePd3I+jLTWpSrXBkjWPUSayBbHc3sZ58q+1 p15y/cD1+DwuP47xWHjaFWLv3rnRO1NLPAqMqCEkfsCFjAd7bF1mltG4vstIIIkT30At njgEhLKbPKzL/NboHNtGiOV6DXu1/nyDc8qVXZwFP//EAIDYjSreMaLeZx2mIb0mH0Lu 196g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:to:from:date:dkim-signature; bh=ouuTSbGM1o4XFTUR1JzVJoe9bj3AgROI4L4dglfoBEA=; b=T0OvFxDXlndTlHAOE7svMNhpnImeVzm4W3fQR2NTK48zADNQv12/377wkFUADKdOVr wnJn3pu1iGhKUuig9o0FpgRhFPPnYP5FqszUGjWr+jex76q8lbco5VNmfaVO7k8tmDqG eQz8NZGIa9IWe4NWcxhdFp4MbKTkPIjj1WpTWDv0BdQASYhoMT2p8PY9O+6JuQmUd1zh PL91ZtupRmZxPsPndp/HambvA4EP3nvlXs8ApiF7t3vKbvgsqUsghpM7+CpbeuBNMUw4 L39Sb9zEqlBpWlpUi0G/9EIiVxetVmWPVJ0u4sPlJMq612PROabT8VxT6H6odTIvj333 72lA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=inNNV5r+; 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=kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id f9-20020a17090a4a8900b001bd14e030c3si5934940pjh.155.2022.03.11.14.18.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Mar 2022 14:18:39 -0800 (PST) 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=@kernel.org header.s=k20201202 header.b=inNNV5r+; 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=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 921D823E94A; Fri, 11 Mar 2022 13:28:23 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343882AbiCKFXT (ORCPT + 99 others); Fri, 11 Mar 2022 00:23:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49210 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239861AbiCKFXS (ORCPT ); Fri, 11 Mar 2022 00:23:18 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 928571ACA36 for ; Thu, 10 Mar 2022 21:22:12 -0800 (PST) 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 0450B61ABC for ; Fri, 11 Mar 2022 05:22:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4C949C340EC; Fri, 11 Mar 2022 05:22:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1646976131; bh=8gqE6SNCXYrxBQ43gUi43oisXrMLQipGnGqrX9t1jAg=; h=Date:From:To:Subject:References:In-Reply-To:From; b=inNNV5r+0gxtvwo+9FvyS2LZxm1WpUr72oCgH87pOCQpqcSm5wZehU93QOG2Zfa0o TxHFZSqxo5HIg38GU+5pjWilylKLLgx0lDCAETphdnVFPRYAfZbPIBDSlqOJ3RVcEC NoRYTSkqf9aXephGUXBWSobaX+Tx23pyvwk6VvmhuTmGkef5AsfryR42WGPDuRS6vt mRKvS0GjvRi8En4Bvx6SUKA6Rh3wQSKtPKTpIGwTIJW8uWrcaILEvAIrQJMphCDSXt q0YsxCWHZ+HpwC3blY+kA5dPFHVgljXol5kGQ1LfGAg3uMaFRTnEnA4eTpVRLngih0 FsBI6Q0smfrIw== Date: Thu, 10 Mar 2022 21:22:09 -0800 From: Jaegeuk Kim To: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Subject: Re: [PATCH 1/2 v2] f2fs: don't get FREEZE lock in f2fs_evict_inode in frozen fs Message-ID: References: <20220309214834.3408741-1-jaegeuk@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220309214834.3408741-1-jaegeuk@kernel.org> X-Spam-Status: No, score=-2.8 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 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) Signed-off-by: Jaegeuk Kim --- Change log from v1: - add doc 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 58bf0dc83712..5a5f3c5445f6 100644 --- a/Documentation/ABI/testing/sysfs-fs-f2fs +++ b/Documentation/ABI/testing/sysfs-fs-f2fs @@ -458,6 +458,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 9a13902c7702..cba5eab24595 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 68d791ec8b27..da729f53daa8 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -1293,6 +1293,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 ab8e0c06c78c..71f232dcf3c2 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 8e3840973077..4b570b5c2674 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.35.1.723.g4982287a31-goog