Message ID | 20240222121851.883141-2-chao@kernel.org (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | [f2fs-dev,1/4] f2fs: delete f2fs_get_new_segment() declaration | expand |
On 02/22, Chao Yu wrote: > f2fs_stop_checkpoint(, false) is complex and it may sleep, so we should > move it outside segmap_lock spinlock coverage in get_new_segment(). Chao, I merged this patch into https://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs.git/commit/?h=dev-test&id=f3b576d209983b5d6e1cb130bfc8ca1f0bbcad6d > > Signed-off-by: Chao Yu <chao@kernel.org> > --- > fs/f2fs/segment.c | 12 +++++++++--- > 1 file changed, 9 insertions(+), 3 deletions(-) > > diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c > index d0209ea77dd2..8edc42071e6f 100644 > --- a/fs/f2fs/segment.c > +++ b/fs/f2fs/segment.c > @@ -2646,6 +2646,7 @@ static void get_new_segment(struct f2fs_sb_info *sbi, > unsigned int old_zoneno = GET_ZONE_FROM_SEG(sbi, *newseg); > bool init = true; > int i; > + int ret = 0; > > spin_lock(&free_i->segmap_lock); > > @@ -2671,9 +2672,8 @@ static void get_new_segment(struct f2fs_sb_info *sbi, > secno = find_first_zero_bit(free_i->free_secmap, > MAIN_SECS(sbi)); > if (secno >= MAIN_SECS(sbi)) { > - f2fs_stop_checkpoint(sbi, false, > - STOP_CP_REASON_NO_SEGMENT); > - f2fs_bug_on(sbi, 1); > + ret = -ENOSPC; > + goto out_unlock; > } > } > segno = GET_SEG_FROM_SEC(sbi, secno); > @@ -2704,7 +2704,13 @@ static void get_new_segment(struct f2fs_sb_info *sbi, > f2fs_bug_on(sbi, test_bit(segno, free_i->free_segmap)); > __set_inuse(sbi, segno); > *newseg = segno; > +out_unlock: > spin_unlock(&free_i->segmap_lock); > + > + if (ret) { > + f2fs_stop_checkpoint(sbi, false, STOP_CP_REASON_NO_SEGMENT); > + f2fs_bug_on(sbi, 1); > + } > } > > static void reset_curseg(struct f2fs_sb_info *sbi, int type, int modified) > -- > 2.40.1
On 2024/2/28 1:50, Jaegeuk Kim wrote: > On 02/22, Chao Yu wrote: >> f2fs_stop_checkpoint(, false) is complex and it may sleep, so we should >> move it outside segmap_lock spinlock coverage in get_new_segment(). > > Chao, I merged this patch into > > https://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs.git/commit/?h=dev-test&id=f3b576d209983b5d6e1cb130bfc8ca1f0bbcad6d It's fine to me. Thanks, > >> >> Signed-off-by: Chao Yu <chao@kernel.org> >> --- >> fs/f2fs/segment.c | 12 +++++++++--- >> 1 file changed, 9 insertions(+), 3 deletions(-) >> >> diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c >> index d0209ea77dd2..8edc42071e6f 100644 >> --- a/fs/f2fs/segment.c >> +++ b/fs/f2fs/segment.c >> @@ -2646,6 +2646,7 @@ static void get_new_segment(struct f2fs_sb_info *sbi, >> unsigned int old_zoneno = GET_ZONE_FROM_SEG(sbi, *newseg); >> bool init = true; >> int i; >> + int ret = 0; >> >> spin_lock(&free_i->segmap_lock); >> >> @@ -2671,9 +2672,8 @@ static void get_new_segment(struct f2fs_sb_info *sbi, >> secno = find_first_zero_bit(free_i->free_secmap, >> MAIN_SECS(sbi)); >> if (secno >= MAIN_SECS(sbi)) { >> - f2fs_stop_checkpoint(sbi, false, >> - STOP_CP_REASON_NO_SEGMENT); >> - f2fs_bug_on(sbi, 1); >> + ret = -ENOSPC; >> + goto out_unlock; >> } >> } >> segno = GET_SEG_FROM_SEC(sbi, secno); >> @@ -2704,7 +2704,13 @@ static void get_new_segment(struct f2fs_sb_info *sbi, >> f2fs_bug_on(sbi, test_bit(segno, free_i->free_segmap)); >> __set_inuse(sbi, segno); >> *newseg = segno; >> +out_unlock: >> spin_unlock(&free_i->segmap_lock); >> + >> + if (ret) { >> + f2fs_stop_checkpoint(sbi, false, STOP_CP_REASON_NO_SEGMENT); >> + f2fs_bug_on(sbi, 1); >> + } >> } >> >> static void reset_curseg(struct f2fs_sb_info *sbi, int type, int modified) >> -- >> 2.40.1
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c index d0209ea77dd2..8edc42071e6f 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c @@ -2646,6 +2646,7 @@ static void get_new_segment(struct f2fs_sb_info *sbi, unsigned int old_zoneno = GET_ZONE_FROM_SEG(sbi, *newseg); bool init = true; int i; + int ret = 0; spin_lock(&free_i->segmap_lock); @@ -2671,9 +2672,8 @@ static void get_new_segment(struct f2fs_sb_info *sbi, secno = find_first_zero_bit(free_i->free_secmap, MAIN_SECS(sbi)); if (secno >= MAIN_SECS(sbi)) { - f2fs_stop_checkpoint(sbi, false, - STOP_CP_REASON_NO_SEGMENT); - f2fs_bug_on(sbi, 1); + ret = -ENOSPC; + goto out_unlock; } } segno = GET_SEG_FROM_SEC(sbi, secno); @@ -2704,7 +2704,13 @@ static void get_new_segment(struct f2fs_sb_info *sbi, f2fs_bug_on(sbi, test_bit(segno, free_i->free_segmap)); __set_inuse(sbi, segno); *newseg = segno; +out_unlock: spin_unlock(&free_i->segmap_lock); + + if (ret) { + f2fs_stop_checkpoint(sbi, false, STOP_CP_REASON_NO_SEGMENT); + f2fs_bug_on(sbi, 1); + } } static void reset_curseg(struct f2fs_sb_info *sbi, int type, int modified)
f2fs_stop_checkpoint(, false) is complex and it may sleep, so we should move it outside segmap_lock spinlock coverage in get_new_segment(). Signed-off-by: Chao Yu <chao@kernel.org> --- fs/f2fs/segment.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)