public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Chao Yu <chao@kernel.org>
To: Jaegeuk Kim <jaegeuk@kernel.org>,
	linux-kernel@vger.kernel.org,
	linux-f2fs-devel@lists.sourceforge.net
Subject: Re: [f2fs-dev] [PATCH 1/2] f2fs: evict inode cache for frozen fs
Date: Thu, 10 Mar 2022 09:53:12 +0800	[thread overview]
Message-ID: <2a5564bb-463e-d163-0042-34fad42e2e46@kernel.org> (raw)
In-Reply-To: <20220309214834.3408741-1-jaegeuk@kernel.org>

On 2022/3/10 5:48, Jaegeuk Kim wrote:
> 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)

Ah, finally we catch this. :)

> 
> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
> ---
>   fs/f2fs/debug.c | 1 +
>   fs/f2fs/f2fs.h  | 1 +
>   fs/f2fs/inode.c | 6 ++++--
>   fs/f2fs/super.c | 4 ++++
>   4 files changed, 10 insertions(+), 2 deletions(-)
> 
> 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",

Could you please update description of "sb_status" entry in
Documentation/ABI/testing/sysfs-fs-f2fs as well?

Thanks,

>   };
>   
>   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;
>   }
>   

  parent reply	other threads:[~2022-03-10  1:53 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-09 21:48 [PATCH 1/2] f2fs: evict inode cache for frozen fs Jaegeuk Kim
2022-03-09 21:48 ` [PATCH 2/2] f2fs: use spin_lock to avoid hang Jaegeuk Kim
2022-03-10  2:23   ` [f2fs-dev] " Chao Yu
2022-03-10  2:51     ` Jaegeuk Kim
2022-03-16  2:33   ` Chao Yu
2022-03-10  1:53 ` Chao Yu [this message]
2022-03-11  3:10   ` [f2fs-dev] [PATCH 1/2] f2fs: evict inode cache for frozen fs Chao Yu
2022-03-11  5:22     ` Jaegeuk Kim
2022-03-10  2:52 ` [PATCH 1/2 v2] f2fs: do not expose unwritten blocks to user by DIO Jaegeuk Kim
2022-03-11  5:22 ` [PATCH 1/2 v2] f2fs: don't get FREEZE lock in f2fs_evict_inode in frozen fs Jaegeuk Kim
2022-03-11  7:25   ` [f2fs-dev] " Chao Yu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2a5564bb-463e-d163-0042-34fad42e2e46@kernel.org \
    --to=chao@kernel.org \
    --cc=jaegeuk@kernel.org \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox