linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] f2fs: protect new segment allocation in expand_inode_data
@ 2020-06-01  3:03 Daeho Jeong
  2020-06-03  6:58 ` Chao Yu
  0 siblings, 1 reply; 4+ messages in thread
From: Daeho Jeong @ 2020-06-01  3:03 UTC (permalink / raw)
  To: linux-kernel, linux-f2fs-devel, kernel-team; +Cc: Daeho Jeong, Chao Yu

From: Daeho Jeong <daehojeong@google.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@google.com>
Reviewed-by: Chao Yu <yuchao0@huawei.com>
---
 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);
 
-- 
2.27.0.rc0.183.gde8f92d652-goog


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] f2fs: protect new segment allocation in expand_inode_data
  2020-06-01  3:03 [PATCH] f2fs: protect new segment allocation in expand_inode_data Daeho Jeong
@ 2020-06-03  6:58 ` Chao Yu
  2020-06-03  7:06   ` Daeho Jeong
  0 siblings, 1 reply; 4+ messages in thread
From: Chao Yu @ 2020-06-03  6:58 UTC (permalink / raw)
  To: Daeho Jeong, linux-kernel, linux-f2fs-devel, kernel-team; +Cc: Daeho Jeong

On 2020/6/1 11:03, Daeho Jeong wrote:
> From: Daeho Jeong <daehojeong@google.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@google.com>
> Reviewed-by: Chao Yu <yuchao0@huawei.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);
>  
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] f2fs: protect new segment allocation in expand_inode_data
  2020-06-03  6:58 ` Chao Yu
@ 2020-06-03  7:06   ` Daeho Jeong
  0 siblings, 0 replies; 4+ messages in thread
From: Daeho Jeong @ 2020-06-03  7:06 UTC (permalink / raw)
  To: Chao Yu; +Cc: linux-kernel, linux-f2fs-devel, kernel-team, Daeho Jeong

Oh, thanks for notification!

2020년 6월 3일 (수) 오후 3:59, Chao Yu <yuchao0@huawei.com>님이 작성:
>
> On 2020/6/1 11:03, Daeho Jeong wrote:
> > From: Daeho Jeong <daehojeong@google.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@google.com>
> > Reviewed-by: Chao Yu <yuchao0@huawei.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);
> >
> >

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] f2fs: protect new segment allocation in expand_inode_data
@ 2020-05-27  4:02 Daeho Jeong
  0 siblings, 0 replies; 4+ messages in thread
From: Daeho Jeong @ 2020-05-27  4:02 UTC (permalink / raw)
  To: linux-kernel, linux-f2fs-devel, kernel-team; +Cc: Daeho Jeong

From: Daeho Jeong <daehojeong@google.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@google.com>
---
 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);
 
-- 
2.27.0.rc0.183.gde8f92d652-goog


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-06-03  7:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-01  3:03 [PATCH] f2fs: protect new segment allocation in expand_inode_data Daeho Jeong
2020-06-03  6:58 ` Chao Yu
2020-06-03  7:06   ` Daeho Jeong
  -- strict thread matches above, loose matches on Subject: below --
2020-05-27  4:02 Daeho Jeong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).