[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <daed6176-fb7d-bd4d-9662-735cc3cda2e0@huawei.com>
Date: Wed, 3 Jun 2020 14:58:46 +0800
From: Chao Yu <yuchao0@...wei.com>
To: Daeho Jeong <daeho43@...il.com>, <linux-kernel@...r.kernel.org>,
<linux-f2fs-devel@...ts.sourceforge.net>, <kernel-team@...roid.com>
CC: Daeho Jeong <daehojeong@...gle.com>
Subject: Re: [PATCH] f2fs: protect new segment allocation in expand_inode_data
On 2020/6/1 11:03, Daeho Jeong wrote:
> From: Daeho Jeong <daehojeong@...gle.com>
>
> Found a new segemnt allocation without f2fs_lock_op() in
> expand_inode_data(). So, when we do fallocate() for a pinned file
> and trigger checkpoint very frequently and simultaneously. F2FS gets
> stuck in the below code of do_checkpoint() forever.
>
> f2fs_sync_meta_pages(sbi, META, LONG_MAX, FS_CP_META_IO);
> /* Wait for all dirty meta pages to be submitted for IO */
> <= if fallocate() here,
> f2fs_wait_on_all_pages(sbi, F2FS_DIRTY_META); <= it'll wait forever.
>
> Signed-off-by: Daeho Jeong <daehojeong@...gle.com>
> Reviewed-by: Chao Yu <yuchao0@...wei.com>
Daeho,
I guess Jaegeuk could add the tag when merging this patch, we don't have
to resend the patch if there is no updates on code and message.
Thanks,
> ---
> fs/f2fs/file.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
> index f7de2a1da528..14ace885baa9 100644
> --- a/fs/f2fs/file.c
> +++ b/fs/f2fs/file.c
> @@ -1660,7 +1660,11 @@ static int expand_inode_data(struct inode *inode, loff_t offset,
>
> down_write(&sbi->pin_sem);
> map.m_seg_type = CURSEG_COLD_DATA_PINNED;
> +
> + f2fs_lock_op(sbi);
> f2fs_allocate_new_segments(sbi, CURSEG_COLD_DATA);
> + f2fs_unlock_op(sbi);
> +
> err = f2fs_map_blocks(inode, &map, 1, F2FS_GET_BLOCK_PRE_DIO);
> up_write(&sbi->pin_sem);
>
>
Powered by blists - more mailing lists