* [PATCH] f2fs: continue to do fg_gc even if beyond max_victim_search
@ 2016-09-22 3:48 Yunlei He
2016-09-22 10:55 ` Chao Yu
0 siblings, 1 reply; 3+ messages in thread
From: Yunlei He @ 2016-09-22 3:48 UTC (permalink / raw)
To: linux-f2fs-devel, jaegeuk, yuchao0; +Cc: heyunlei
For forground gc, if can't find a victim in one max_victim_search,
try it again.
Signed-off-by: Yunlei He <heyunlei@huawei.com>
---
fs/f2fs/gc.c | 23 ++++++++++++-----------
1 file changed, 12 insertions(+), 11 deletions(-)
diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c
index 24acbbb..19e51a5 100644
--- a/fs/f2fs/gc.c
+++ b/fs/f2fs/gc.c
@@ -916,24 +916,25 @@ gc_more:
goto stop;
}
- if (gc_type == BG_GC && has_not_enough_free_secs(sbi, sec_freed, 0)) {
- gc_type = FG_GC;
+ if (gc_type == BG_GC && has_not_enough_free_secs(sbi, 0, 0)) {
/*
* If there is no victim and no prefree segment but still not
* enough free sections, we should flush dent/node blocks and do
* garbage collections.
*/
- if (__get_victim(sbi, &segno, gc_type) ||
- prefree_segments(sbi)) {
- write_checkpoint(sbi, &cpc);
- segno = NULL_SEGNO;
- } else if (has_not_enough_free_secs(sbi, 0, 0)) {
- write_checkpoint(sbi, &cpc);
- }
+ gc_type = FG_GC;
+ write_checkpoint(sbi, &cpc);
}
- if (segno == NULL_SEGNO && !__get_victim(sbi, &segno, gc_type))
- goto stop;
+ if (!__get_victim(sbi, &segno, gc_type)) {
+ if (sync)
+ goto stop;
+ else if (gc_type == FG_GC
+ && has_not_enough_free_secs(sbi, sec_freed, 0))
+ goto gc_more;
+ else
+ goto stop;
+ }
ret = 0;
if (do_garbage_collect(sbi, segno, &gc_list, gc_type) &&
--
1.9.1
------------------------------------------------------------------------------
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] f2fs: continue to do fg_gc even if beyond max_victim_search
2016-09-22 3:48 [PATCH] f2fs: continue to do fg_gc even if beyond max_victim_search Yunlei He
@ 2016-09-22 10:55 ` Chao Yu
2016-09-23 2:08 ` heyunlei
0 siblings, 1 reply; 3+ messages in thread
From: Chao Yu @ 2016-09-22 10:55 UTC (permalink / raw)
To: Yunlei He, linux-f2fs-devel, jaegeuk; +Cc: heyunlei
On 2016/9/22 11:48, Yunlei He wrote:
> For forground gc, if can't find a victim in one max_victim_search,
> try it again.
>
> Signed-off-by: Yunlei He <heyunlei@huawei.com>
> ---
> fs/f2fs/gc.c | 23 ++++++++++++-----------
> 1 file changed, 12 insertions(+), 11 deletions(-)
>
> diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c
> index 24acbbb..19e51a5 100644
> --- a/fs/f2fs/gc.c
> +++ b/fs/f2fs/gc.c
> @@ -916,24 +916,25 @@ gc_more:
> goto stop;
> }
>
> - if (gc_type == BG_GC && has_not_enough_free_secs(sbi, sec_freed, 0)) {
> - gc_type = FG_GC;
> + if (gc_type == BG_GC && has_not_enough_free_secs(sbi, 0, 0)) {
> /*
> * If there is no victim and no prefree segment but still not
> * enough free sections, we should flush dent/node blocks and do
> * garbage collections.
> */
> - if (__get_victim(sbi, &segno, gc_type) ||
> - prefree_segments(sbi)) {
> - write_checkpoint(sbi, &cpc);
> - segno = NULL_SEGNO;
> - } else if (has_not_enough_free_secs(sbi, 0, 0)) {
> - write_checkpoint(sbi, &cpc);
> - }
> + gc_type = FG_GC;
> + write_checkpoint(sbi, &cpc);
> }
>
> - if (segno == NULL_SEGNO && !__get_victim(sbi, &segno, gc_type))
> - goto stop;
> + if (!__get_victim(sbi, &segno, gc_type)) {
> + if (sync)
> + goto stop;
> + else if (gc_type == FG_GC
> + && has_not_enough_free_secs(sbi, sec_freed, 0))
> + goto gc_more;
Will we deadloop here?
Thanks,
> + else
> + goto stop;
> + }
> ret = 0;
>
> if (do_garbage_collect(sbi, segno, &gc_list, gc_type) &&
>
------------------------------------------------------------------------------
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] f2fs: continue to do fg_gc even if beyond max_victim_search
2016-09-22 10:55 ` Chao Yu
@ 2016-09-23 2:08 ` heyunlei
0 siblings, 0 replies; 3+ messages in thread
From: heyunlei @ 2016-09-23 2:08 UTC (permalink / raw)
To: Chao Yu, linux-f2fs-devel, jaegeuk; +Cc: heyunlei
On 2016/9/22 18:55, Chao Yu wrote:
> On 2016/9/22 11:48, Yunlei He wrote:
>> For forground gc, if can't find a victim in one max_victim_search,
>> try it again.
>>
>> Signed-off-by: Yunlei He <heyunlei@huawei.com>
>> ---
>> fs/f2fs/gc.c | 23 ++++++++++++-----------
>> 1 file changed, 12 insertions(+), 11 deletions(-)
>>
>> diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c
>> index 24acbbb..19e51a5 100644
>> --- a/fs/f2fs/gc.c
>> +++ b/fs/f2fs/gc.c
>> @@ -916,24 +916,25 @@ gc_more:
>> goto stop;
>> }
>>
>> - if (gc_type == BG_GC && has_not_enough_free_secs(sbi, sec_freed, 0)) {
>> - gc_type = FG_GC;
>> + if (gc_type == BG_GC && has_not_enough_free_secs(sbi, 0, 0)) {
>> /*
>> * If there is no victim and no prefree segment but still not
>> * enough free sections, we should flush dent/node blocks and do
>> * garbage collections.
>> */
>> - if (__get_victim(sbi, &segno, gc_type) ||
>> - prefree_segments(sbi)) {
>> - write_checkpoint(sbi, &cpc);
>> - segno = NULL_SEGNO;
>> - } else if (has_not_enough_free_secs(sbi, 0, 0)) {
>> - write_checkpoint(sbi, &cpc);
>> - }
>> + gc_type = FG_GC;
>> + write_checkpoint(sbi, &cpc);
>> }
>>
>> - if (segno == NULL_SEGNO && !__get_victim(sbi, &segno, gc_type))
>> - goto stop;
>> + if (!__get_victim(sbi, &segno, gc_type)) {
>> + if (sync)
>> + goto stop;
>> + else if (gc_type == FG_GC
>> + && has_not_enough_free_secs(sbi, sec_freed, 0))
>> + goto gc_more;
>
> Will we deadloop here?
>
Does no victim(whole partition) and has_not_enough_free_secs both satisfied at the same time?
If stop FG_GC here, it will come again soon, besides, sec_freed will not change to free segments,
for no checkpoint update.
Thanks,
> Thanks,
>
>> + else
>> + goto stop;
>> + }
>> ret = 0;
>>
>> if (do_garbage_collect(sbi, segno, &gc_list, gc_type) &&
>>
>
>
> .
>
------------------------------------------------------------------------------
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-09-23 2:08 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-22 3:48 [PATCH] f2fs: continue to do fg_gc even if beyond max_victim_search Yunlei He
2016-09-22 10:55 ` Chao Yu
2016-09-23 2:08 ` heyunlei
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.