Re: [PATCH] f2fs: fix to cover allocate_segment() with lock
From: Jaegeuk Kim
Date: Mon Apr 19 2021 - 12:57:24 EST
On 04/14, Chao Yu wrote:
> As we did for other cases, in fix_curseg_write_pointer(), let's
> change as below:
> - use callback function s_ops->allocate_segment() instead of
> raw function allocate_segment_by_default();
> - cover allocate_segment() with curseg_lock and sentry_lock.
>
> Signed-off-by: Chao Yu <yuchao0@xxxxxxxxxx>
> ---
> fs/f2fs/segment.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
> index b2ee6b7791b0..daf9531ec58f 100644
> --- a/fs/f2fs/segment.c
> +++ b/fs/f2fs/segment.c
> @@ -4848,7 +4848,12 @@ static int fix_curseg_write_pointer(struct f2fs_sb_info *sbi, int type)
>
> f2fs_notice(sbi, "Assign new section to curseg[%d]: "
> "curseg[0x%x,0x%x]", type, cs->segno, cs->next_blkoff);
> - allocate_segment_by_default(sbi, type, true);
> +
> + down_read(&SM_I(sbi)->curseg_lock);
> + down_write(&SIT_I(sbi)->sentry_lock);
> + SIT_I(sbi)->s_ops->allocate_segment(sbi, type, true);
> + up_write(&SIT_I(sbi)->sentry_lock);
> + up_read(&SM_I(sbi)->curseg_lock);
Seems f2fs_allocate_new_section()?
>
> /* check consistency of the zone curseg pointed to */
> if (check_zone_write_pointer(sbi, zbd, &zone))
> --
> 2.29.2