From: Chao Yu <chao@kernel.org> To: Jaegeuk Kim <jaegeuk@kernel.org> Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Subject: Re: [PATCH] f2fs: fix to trigger a checkpoint in the end of foreground garbage collection Date: Tue, 4 Apr 2023 18:46:59 +0800 [thread overview] Message-ID: <08259184-d3c1-cb46-9751-e32e1bc6eb87@kernel.org> (raw) In-Reply-To: <ZCsXRin7symPxIrn@google.com> On 2023/4/4 2:13, Jaegeuk Kim wrote: > On 03/24, Chao Yu wrote: >> In order to reclaim free blocks in prefree sections before latter use. > > We were supposed to do checkpoint as is? It seems commit 6f8d4455060d ("f2fs: avoid fi->i_gc_rwsem[WRITE] lock in f2fs_gc") changed that logic? It caused that if has_not_enough_free_secs() returns false, it missed to call f2fs_write_checkpoint() before exit f2fs_gc()? @@ -1110,15 +1116,23 @@ gc_more: if (gc_type == FG_GC) sbi->cur_victim_sec = NULL_SEGNO; - if (!sync) { - if (has_not_enough_free_secs(sbi, sec_freed, 0)) { - if (skipped_round > MAX_SKIP_ATOMIC_COUNT && - skipped_round * 2 >= round) - f2fs_drop_inmem_pages_all(sbi, true); + if (sync) + goto stop; + + if (has_not_enough_free_secs(sbi, sec_freed, 0)) { + if (skipped_round <= MAX_SKIP_GC_COUNT || + skipped_round * 2 < round) { segno = NULL_SEGNO; goto gc_more; } + if (first_skipped < last_skipped && + (last_skipped - first_skipped) > + sbi->skipped_gc_rwsem) { + f2fs_drop_inmem_pages_all(sbi, true); + segno = NULL_SEGNO; + goto gc_more; + } if (gc_type == FG_GC) ret = f2fs_write_checkpoint(sbi, &cpc); } > >> >> Fixes: 6f8d4455060d ("f2fs: avoid fi->i_gc_rwsem[WRITE] lock in f2fs_gc") >> Signed-off-by: Chao Yu <chao@kernel.org> >> --- >> fs/f2fs/f2fs.h | 1 + >> fs/f2fs/gc.c | 8 ++++++++ >> fs/f2fs/segment.c | 1 + >> 3 files changed, 10 insertions(+) >> >> diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h >> index 53a005b420cf..b1515375cb4c 100644 >> --- a/fs/f2fs/f2fs.h >> +++ b/fs/f2fs/f2fs.h >> @@ -1269,6 +1269,7 @@ struct f2fs_gc_control { >> unsigned int victim_segno; /* target victim segment number */ >> int init_gc_type; /* FG_GC or BG_GC */ >> bool no_bg_gc; /* check the space and stop bg_gc */ >> + bool reclaim_space; /* trigger checkpoint to reclaim space */ >> bool should_migrate_blocks; /* should migrate blocks */ >> bool err_gc_skipped; /* return EAGAIN if GC skipped */ >> unsigned int nr_free_secs; /* # of free sections to do GC */ >> diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c >> index 2996d38aa89c..5a451d3d512d 100644 >> --- a/fs/f2fs/gc.c >> +++ b/fs/f2fs/gc.c >> @@ -132,6 +132,7 @@ static int gc_thread_func(void *data) >> >> gc_control.init_gc_type = sync_mode ? FG_GC : BG_GC; >> gc_control.no_bg_gc = foreground; >> + gc_control.reclaim_space = foreground; >> gc_control.nr_free_secs = foreground ? 1 : 0; >> >> /* if return value is not zero, no victim was selected */ >> @@ -1880,6 +1881,13 @@ int f2fs_gc(struct f2fs_sb_info *sbi, struct f2fs_gc_control *gc_control) >> (gc_type == FG_GC) ? sec_freed : 0, 0)) { >> if (gc_type == FG_GC && sec_freed < gc_control->nr_free_secs) >> goto go_gc_more; >> + >> + /* >> + * trigger a checkpoint in the end of foreground garbage >> + * collection. >> + */ >> + if (gc_control->reclaim_space) >> + ret = f2fs_write_checkpoint(sbi, &cpc); >> goto stop; >> } >> >> diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c >> index 6c11789da884..b62af2ae1685 100644 >> --- a/fs/f2fs/segment.c >> +++ b/fs/f2fs/segment.c >> @@ -421,6 +421,7 @@ void f2fs_balance_fs(struct f2fs_sb_info *sbi, bool need) >> .victim_segno = NULL_SEGNO, >> .init_gc_type = BG_GC, >> .no_bg_gc = true, >> + .reclaim_space = true, >> .should_migrate_blocks = false, >> .err_gc_skipped = false, >> .nr_free_secs = 1 }; >> -- >> 2.25.1
WARNING: multiple messages have this Message-ID (diff)
From: Chao Yu <chao@kernel.org> To: Jaegeuk Kim <jaegeuk@kernel.org> Cc: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Subject: Re: [f2fs-dev] [PATCH] f2fs: fix to trigger a checkpoint in the end of foreground garbage collection Date: Tue, 4 Apr 2023 18:46:59 +0800 [thread overview] Message-ID: <08259184-d3c1-cb46-9751-e32e1bc6eb87@kernel.org> (raw) In-Reply-To: <ZCsXRin7symPxIrn@google.com> On 2023/4/4 2:13, Jaegeuk Kim wrote: > On 03/24, Chao Yu wrote: >> In order to reclaim free blocks in prefree sections before latter use. > > We were supposed to do checkpoint as is? It seems commit 6f8d4455060d ("f2fs: avoid fi->i_gc_rwsem[WRITE] lock in f2fs_gc") changed that logic? It caused that if has_not_enough_free_secs() returns false, it missed to call f2fs_write_checkpoint() before exit f2fs_gc()? @@ -1110,15 +1116,23 @@ gc_more: if (gc_type == FG_GC) sbi->cur_victim_sec = NULL_SEGNO; - if (!sync) { - if (has_not_enough_free_secs(sbi, sec_freed, 0)) { - if (skipped_round > MAX_SKIP_ATOMIC_COUNT && - skipped_round * 2 >= round) - f2fs_drop_inmem_pages_all(sbi, true); + if (sync) + goto stop; + + if (has_not_enough_free_secs(sbi, sec_freed, 0)) { + if (skipped_round <= MAX_SKIP_GC_COUNT || + skipped_round * 2 < round) { segno = NULL_SEGNO; goto gc_more; } + if (first_skipped < last_skipped && + (last_skipped - first_skipped) > + sbi->skipped_gc_rwsem) { + f2fs_drop_inmem_pages_all(sbi, true); + segno = NULL_SEGNO; + goto gc_more; + } if (gc_type == FG_GC) ret = f2fs_write_checkpoint(sbi, &cpc); } > >> >> Fixes: 6f8d4455060d ("f2fs: avoid fi->i_gc_rwsem[WRITE] lock in f2fs_gc") >> Signed-off-by: Chao Yu <chao@kernel.org> >> --- >> fs/f2fs/f2fs.h | 1 + >> fs/f2fs/gc.c | 8 ++++++++ >> fs/f2fs/segment.c | 1 + >> 3 files changed, 10 insertions(+) >> >> diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h >> index 53a005b420cf..b1515375cb4c 100644 >> --- a/fs/f2fs/f2fs.h >> +++ b/fs/f2fs/f2fs.h >> @@ -1269,6 +1269,7 @@ struct f2fs_gc_control { >> unsigned int victim_segno; /* target victim segment number */ >> int init_gc_type; /* FG_GC or BG_GC */ >> bool no_bg_gc; /* check the space and stop bg_gc */ >> + bool reclaim_space; /* trigger checkpoint to reclaim space */ >> bool should_migrate_blocks; /* should migrate blocks */ >> bool err_gc_skipped; /* return EAGAIN if GC skipped */ >> unsigned int nr_free_secs; /* # of free sections to do GC */ >> diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c >> index 2996d38aa89c..5a451d3d512d 100644 >> --- a/fs/f2fs/gc.c >> +++ b/fs/f2fs/gc.c >> @@ -132,6 +132,7 @@ static int gc_thread_func(void *data) >> >> gc_control.init_gc_type = sync_mode ? FG_GC : BG_GC; >> gc_control.no_bg_gc = foreground; >> + gc_control.reclaim_space = foreground; >> gc_control.nr_free_secs = foreground ? 1 : 0; >> >> /* if return value is not zero, no victim was selected */ >> @@ -1880,6 +1881,13 @@ int f2fs_gc(struct f2fs_sb_info *sbi, struct f2fs_gc_control *gc_control) >> (gc_type == FG_GC) ? sec_freed : 0, 0)) { >> if (gc_type == FG_GC && sec_freed < gc_control->nr_free_secs) >> goto go_gc_more; >> + >> + /* >> + * trigger a checkpoint in the end of foreground garbage >> + * collection. >> + */ >> + if (gc_control->reclaim_space) >> + ret = f2fs_write_checkpoint(sbi, &cpc); >> goto stop; >> } >> >> diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c >> index 6c11789da884..b62af2ae1685 100644 >> --- a/fs/f2fs/segment.c >> +++ b/fs/f2fs/segment.c >> @@ -421,6 +421,7 @@ void f2fs_balance_fs(struct f2fs_sb_info *sbi, bool need) >> .victim_segno = NULL_SEGNO, >> .init_gc_type = BG_GC, >> .no_bg_gc = true, >> + .reclaim_space = true, >> .should_migrate_blocks = false, >> .err_gc_skipped = false, >> .nr_free_secs = 1 }; >> -- >> 2.25.1 _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
next prev parent reply other threads:[~2023-04-04 10:47 UTC|newest] Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-03-24 7:10 [PATCH] f2fs: fix to trigger a checkpoint in the end of foreground garbage collection Chao Yu 2023-03-24 7:10 ` [f2fs-dev] " Chao Yu 2023-04-03 18:13 ` Jaegeuk Kim 2023-04-03 18:13 ` [f2fs-dev] " Jaegeuk Kim 2023-04-04 10:46 ` Chao Yu [this message] 2023-04-04 10:46 ` Chao Yu 2023-04-04 21:39 ` Jaegeuk Kim 2023-04-04 21:39 ` [f2fs-dev] " Jaegeuk Kim 2023-04-05 2:02 ` Chao Yu 2023-04-05 2:02 ` [f2fs-dev] " Chao Yu 2023-04-05 15:55 ` Jaegeuk Kim 2023-04-05 15:55 ` [f2fs-dev] " Jaegeuk Kim 2023-04-10 13:52 ` Chao Yu 2023-04-10 13:52 ` [f2fs-dev] " Chao Yu 2023-04-10 23:21 ` Jaegeuk Kim 2023-04-10 23:21 ` [f2fs-dev] " Jaegeuk Kim 2023-04-13 9:15 ` Chao Yu 2023-04-13 9:15 ` [f2fs-dev] " Chao Yu 2023-04-13 15:56 ` Jaegeuk Kim 2023-04-13 15:56 ` [f2fs-dev] " Jaegeuk Kim 2023-04-13 15:58 ` Jaegeuk Kim 2023-04-13 15:58 ` Jaegeuk Kim 2023-04-13 19:25 ` Jaegeuk Kim 2023-04-13 19:25 ` Jaegeuk Kim 2023-04-18 15:51 ` Chao Yu 2023-04-18 15:51 ` Chao Yu
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=08259184-d3c1-cb46-9751-e32e1bc6eb87@kernel.org \ --to=chao@kernel.org \ --cc=jaegeuk@kernel.org \ --cc=linux-f2fs-devel@lists.sourceforge.net \ --cc=linux-kernel@vger.kernel.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.