Skip to content

Commit 823d13e

Browse files
chaseyuJaegeuk Kim
authored andcommitted
f2fs: fix to cover __allocate_new_section() with curseg_lock
In order to avoid race with f2fs_do_replace_block(). Fixes: f5a53ed ("f2fs: support aligned pinned file") Signed-off-by: Chao Yu <[email protected]> Signed-off-by: Jaegeuk Kim <[email protected]>
1 parent 753a8ed commit 823d13e

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

fs/f2fs/segment.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2945,19 +2945,23 @@ static void __allocate_new_section(struct f2fs_sb_info *sbi, int type)
29452945

29462946
void f2fs_allocate_new_section(struct f2fs_sb_info *sbi, int type)
29472947
{
2948+
down_read(&SM_I(sbi)->curseg_lock);
29482949
down_write(&SIT_I(sbi)->sentry_lock);
29492950
__allocate_new_section(sbi, type);
29502951
up_write(&SIT_I(sbi)->sentry_lock);
2952+
up_read(&SM_I(sbi)->curseg_lock);
29512953
}
29522954

29532955
void f2fs_allocate_new_segments(struct f2fs_sb_info *sbi)
29542956
{
29552957
int i;
29562958

2959+
down_read(&SM_I(sbi)->curseg_lock);
29572960
down_write(&SIT_I(sbi)->sentry_lock);
29582961
for (i = CURSEG_HOT_DATA; i <= CURSEG_COLD_DATA; i++)
29592962
__allocate_new_segment(sbi, i, false);
29602963
up_write(&SIT_I(sbi)->sentry_lock);
2964+
up_read(&SM_I(sbi)->curseg_lock);
29612965
}
29622966

29632967
static const struct segment_allocation default_salloc_ops = {

0 commit comments

Comments
 (0)