f2fs: do not use CURSEG_ALL_DATA_ATGC in foreground or urgent GC
RFC PATCH 1/1 f2fs: do not use CURSEG_ALL_DATA_ATGC in foreground or urgent GC
CURSEG_ALL_DATA_ATGC is introduced by age threshold based GC for better hot/cold data seperation and avoiding free segment cost. However, LFS write mode is preferred in the scenario of foreground or urgent GC, which should be finished ASAP. So, let's only use CURSEG_ALL_DATA_ATGC when not urgent in background GC.
--- fs/f2fs/gc.c | 3 ++- fs/f2fs/segment.c | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-)
fs/f2fs/gc.c +2 -1
@@ -1120,7 +1120,8 @@ static int move_data_block(struct inode *inode, block_t bidx,block_t newaddr;int err =0 ;bool lfs_mode =f2fs_lfs_mode (fio.sbi); -int type = fio.sbi->am.atgc_enabled ? +int type = fio.sbi->am.atgc_enabled && gc_type ==BG_GC && + fio.sbi->gc_mode <GC_URGENT_HIGH ?CURSEG_ALL_DATA_ATGC :CURSEG_COLD_DATA ;/* do not read out */
fs/f2fs/segment.c +3 -1
@@ -3264,7 +3264,9 @@ static int __get_segment_type_6(struct f2fs_io_info *fio)struct inode *inode = fio->page->mapping->host;if (is_cold_data (fio->page)) { -if (fio->sbi->am.atgc_enabled) +if (fio->sbi->am.atgc_enabled && + fio->io_type ==FS_DATA_IO && + fio->sbi->gc_mode <GC_URGENT_HIGH )return CURSEG_ALL_DATA_ATGC ;else return CURSEG_COLD_DATA ;
Signature · 8 lines
2.7.4 _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Quoted 5 lines · On 2021/3/16 21:15, Weichao Guo via Linux-f2fs-devel wrote:
CURSEG_ALL_DATA_ATGCis introduced by age threshold based GC for better hot/cold data seperation and avoiding free segment cost. However, LFS write mode is preferred in the scenario of foreground or urgent GC, which should be finished ASAP. So, let's only useCURSEG_ALL_DATA_ATGCwhen not urgent in background GC.
Weichao,
select_gc_type()
case GC_URGENT_HIGH: gc_mode = GC_GREEDY;
We have selected 'greedy' algorithm rather than 'atgc' algorithm for high urgent gc, did you mean we should use 'greedy' for low urgent gc as well?
Thanks,
Quoted 28 lines
Signed-off-by Weichao Guo <[email protected]>Signed-off-by Huang Jianan <[email protected]>--- fs/f2fs/gc.c | 3 ++- fs/f2fs/segment.c | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-)fs/f2fs/gc.c +2
-1@@ -1120,7 +1120,8 @@ static int move_data_block(struct inode *inode, block_t bidx,block_t newaddr;int err =0 ;bool lfs_mode =f2fs_lfs_mode (fio.sbi); -int type = fio.sbi->am.atgc_enabled ? +int type = fio.sbi->am.atgc_enabled && gc_type ==BG_GC && + fio.sbi->gc_mode <GC_URGENT_HIGH ?CURSEG_ALL_DATA_ATGC :CURSEG_COLD_DATA ;/* do not read out */ fs/f2fs/segment.c +0
-0
fs/f2fs/segment.c static int __get_segment_type_6(struct f2fs_io_info *fio) · line 3272
Quoted 10 lines
fs/f2fs/segment.c +3
-1@@ -3264,7 +3264,9 @@ static int __get_segment_type_6(struct f2fs_io_info *fio)struct inode *inode = fio->page->mapping->host;if (is_cold_data (fio->page)) { -if (fio->sbi->am.atgc_enabled) +if (fio->sbi->am.atgc_enabled && + fio->io_type ==FS_DATA_IO && + fio->sbi->gc_mode <GC_URGENT_HIGH )return CURSEG_ALL_DATA_ATGC ;else return CURSEG_COLD_DATA ;
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Quoted 9 lines · Chao Yu
Quoted 5 lines · On 2021/3/16 21:15, Weichao Guo via Linux-f2fs-devel wrote:
CURSEG_ALL_DATA_ATGCis introduced by age threshold based GC for better hot/cold data seperation and avoiding free segment cost. However, LFS write mode is preferred in the scenario of foreground or urgent GC, which should be finished ASAP. So, let's only useCURSEG_ALL_DATA_ATGCwhen not urgent in background GC.Weichao,
Quoted 7 lines
select_gc_type()case
GC_URGENT_HIGH:
gc_mode=GC_GREEDY;We have selected 'greedy' algorithm rather than 'atgc' algorithm for high urgent gc, did you mean we should use 'greedy' for low urgent gc as well?
Hi Chao,
I mean in the target victim selection, we use AT_SSR mode if only atgc_enabled
regardless of the gc mode. My point is:
1. AT_SSR is good, but LFS mode is perferred in the scenario of foreground GC (at least)
& high urgent background GC, which should be finished ASAP.
2. For other GC scenarios using 'greedy' algorithm, I think either AT_SSR or LFS mode is OK.
Because the source victim has few valid blocks & may be not cold.
3. And for GC scenarios using CB/ATGC algorithm, I think AT_SSR mode is better.
Thanks,
Weichao
Quoted 33 lines
Thanks,
Quoted 30 lines
Signed-off-by Weichao Guo <[email protected]>Signed-off-by Huang Jianan <[email protected]>---
fs/f2fs/gc.c | 3 ++-
fs/f2fs/segment.c| 4 +++-2 files changed, 5 insertions(+), 2 deletions(-)fs/f2fs/gc.c +2
-1@@ -1120,7 +1120,8 @@ static int move_data_block(struct inode *inode,block_t bidx, block_t newaddr; int err = 0; bool lfs_mode = f2fs_lfs_mode(fio.sbi); - int type = fio.sbi->am.atgc_enabled ? + int type = fio.sbi->am.atgc_enabled && gc_type == BG_GC && + fio.sbi->gc_mode < GC_URGENT_HIGH ? CURSEG_ALL_DATA_ATGC : CURSEG_COLD_DATA; /* do not read out */fs/f2fs/segment.c +0
-0@@ -3264,7 +3264,9 @@ static int __get_segment_type_6(struct f2fs_io_info *fio) struct inode *inode = fio->page->mapping->host; if (is_cold_data(fio->page)) {
Quoted 8 lines
Quoted 8 lines
fs/f2fs/segment.c +3
-1- if (fio->sbi->am.atgc_enabled) + if (fio->sbi->am.atgc_enabled && + fio->io_type == FS_DATA_IO && + fio->sbi->gc_mode < GC_URGENT_HIGH) return CURSEG_ALL_DATA_ATGC;else
returnCURSEG_COLD_DATA;
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Quoted 21 lines · Weichao Guo
Quoted 11 lines · Chao Yu
Quoted 7 lines · On 2021/3/16 21:15, Weichao Guo via Linux-f2fs-devel wrote:
CURSEG_ALL_DATA_ATGCis introduced by age threshold based GC for better hot/cold data seperation and avoiding free segment cost. However, LFS write mode is preferred in the scenario of foreground or urgent GC, which
should be finished ASAP. So, let's only useCURSEG_ALL_DATA_ATGCwhen not
urgent in background GC.Weichao,
Quoted 7 lines
select_gc_type()case
GC_URGENT_HIGH:
gc_mode=GC_GREEDY;We have selected 'greedy' algorithm rather than 'atgc' algorithm for high urgent gc, did you mean we should use 'greedy' for low urgent gc as well?
Quoted 6 lines
Hi Chao,
I mean in the target victim selection, we use
AT_SSRmode if onlyatgc_enabledregardless of the gc mode. My point is:
Yup,
Quoted 6 lines
1.
AT_SSRis good, but LFS mode is perferred in the scenario of foreground GC (at least)& high urgent background GC, which should be finished ASAP.
Quoted 7 lines
2. For other GC scenarios using 'greedy' algorithm, I think either
AT_SSRor LFS mode is OK.Because the source victim has few valid blocks & may be not cold.
3. And for GC scenarios using CB/ATGC algorithm, I think
AT_SSRmode is better.
Alright, it's fine to me to change policy like this.
One more concern is, if user trigger GC_URGENT_LOW, we don't need to force GC to use non-AT_SSR allocation, right? as now GC_URGENT_LOW only controls IO awareness of discard/GC thread.
+ if (sbi->gc_mode == GC_URGENT_LOW &&
+ (type == DISCARD_TIME || type == GC_TIME))
+ return true;
Thanks,
Quoted 39 lines
Thanks,
Weichao
Quoted 34 lines
Thanks,
Quoted 31 lines
Signed-off-by Weichao Guo <[email protected]>Signed-off-by Huang Jianan <[email protected]>--- fs/f2fs/gc.c | 3 ++- fs/f2fs/segment.c | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-)fs/f2fs/gc.c +2
-1@@ -1120,7 +1120,8 @@ static int move_data_block(struct inode *inode,block_t bidx, block_t newaddr; int err = 0; bool lfs_mode = f2fs_lfs_mode(fio.sbi); - int type = fio.sbi->am.atgc_enabled ? + int type = fio.sbi->am.atgc_enabled && gc_type == BG_GC && + fio.sbi->gc_mode < GC_URGENT_HIGH ? CURSEG_ALL_DATA_ATGC : CURSEG_COLD_DATA; /* do not read out */fs/f2fs/segment.c +0
-1@@ -3264,7 +3264,9 @@ static int __get_segment_type_6(struct f2fs_io_info *fio) struct inode *inode = fio->page->mapping->host; if (is_cold_data(fio->page)) { - if (fio->sbi->am.atgc_enabled)
Quoted 9 lines
Quoted 7 lines
fs/f2fs/segment.c static int __get_segment_type_6(struct f2fs_io_info *fio) · line 3272
Quoted 7 lines
fs/f2fs/segment.c +3
-0+ if (fio->sbi->am.atgc_enabled && + fio->io_type == FS_DATA_IO && + fio->sbi->gc_mode < GC_URGENT_HIGH) return CURSEG_ALL_DATA_ATGC; else return CURSEG_COLD_DATA;.
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Quoted 42 lines · Chao Yu
Quoted 21 lines · Weichao Guo
Quoted 11 lines · Chao Yu
Quoted 7 lines · On 2021/3/16 21:15, Weichao Guo via Linux-f2fs-devel wrote:
CURSEG_ALL_DATA_ATGCis introduced by age threshold based GC for better hot/cold data seperation and avoiding free segment cost. However, LFS write mode is preferred in the scenario of foreground or urgent GC, which
should be finished ASAP. So, let's only useCURSEG_ALL_DATA_ATGCwhen not
urgent in background GC.Weichao,
Quoted 7 lines
select_gc_type()case
GC_URGENT_HIGH:
gc_mode=GC_GREEDY;We have selected 'greedy' algorithm rather than 'atgc' algorithm for high urgent gc, did you mean we should use 'greedy' for low urgent gc as well?
Quoted 6 lines
Hi Chao,
I mean in the target victim selection, we use
AT_SSRmode if onlyatgc_enabledregardless of the gc mode. My point is:
Yup,
Quoted 11 lines
1.
AT_SSRis good, but LFS mode is perferred in the scenario of foreground GC (at least)& high urgent background GC, which should be finished ASAP.
2. For other GC scenarios using 'greedy' algorithm, I think either
AT_SSRor LFS mode is OK.Because the source victim has few valid blocks & may be not cold.
Quoted 7 lines
Quoted 2 lines
3. And for GC scenarios using CB/ATGC algorithm, I think
AT_SSRmode is better.Alright, it's fine to me to change policy like this.
One more concern is, if user trigger
GC_URGENT_LOW, we don't need to force GC to use non-AT_SSR allocation, right? as nowGC_URGENT_LOWonly
Chao,
I agree with you, so using non-AT_SSR in foreground GC & high urgent background GC?
I will send a new version of this patch later.
Thanks,
Weichao
Quoted 56 lines
controls IO awareness of discard/GC thread.
+ if (
sbi->gc_mode==GC_URGENT_LOW&&
+ (type ==DISCARD_TIME|| type ==GC_TIME)) + return true;Thanks,
Quoted 48 lines
Thanks,
Weichao
Quoted 33 lines
Thanks,
Quoted 30 lines
Signed-off-by Weichao Guo <[email protected]>Signed-off-by Huang Jianan <[email protected]>---
fs/f2fs/gc.c | 3 ++-
fs/f2fs/segment.c| 4 +++-2 files changed, 5 insertions(+), 2 deletions(-)fs/f2fs/gc.c +2
-1@@ -1120,7 +1120,8 @@ static int move_data_block(struct inode *inode,block_t bidx, block_t newaddr; int err = 0; bool lfs_mode = f2fs_lfs_mode(fio.sbi); - int type = fio.sbi->am.atgc_enabled ? + int type = fio.sbi->am.atgc_enabled && gc_type == BG_GC && + fio.sbi->gc_mode < GC_URGENT_HIGH ? CURSEG_ALL_DATA_ATGC : CURSEG_COLD_DATA; /* do not read out */fs/f2fs/segment.c +0
-0@@ -3264,7 +3264,9 @@ static int __get_segment_type_6(struct f2fs_io_info *fio) struct inode *inode = fio->page->mapping->host; if (is_cold_data(fio->page)) {Quoted 8 lines
Quoted 8 lines
fs/f2fs/segment.c +3
-1- if (fio->sbi->am.atgc_enabled) + if (fio->sbi->am.atgc_enabled && + fio->io_type == FS_DATA_IO && + fio->sbi->gc_mode < GC_URGENT_HIGH) return CURSEG_ALL_DATA_ATGC;else
returnCURSEG_COLD_DATA;.
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Quoted 50 lines · Weichao Guo
Quoted 48 lines · Chao Yu
Quoted 24 lines · Weichao Guo
Quoted 14 lines · Chao Yu
Quoted 8 lines · On 2021/3/16 21:15, Weichao Guo via Linux-f2fs-devel wrote:
CURSEG_ALL_DATA_ATGCis introduced by age threshold based GC for better
hot/cold data seperation and avoiding free segment cost. However, LFS write mode is preferred in the scenario of foreground or urgent GC, which
should be finished ASAP. So, let's only useCURSEG_ALL_DATA_ATGCwhen not
urgent in background GC.Weichao,
select_gc_type()Quoted 7 lines
case
GC_URGENT_HIGH:
gc_mode=GC_GREEDY;We have selected 'greedy' algorithm rather than 'atgc' algorithm for high
urgent gc, did you mean we should use 'greedy' for low urgent gc as well?Quoted 6 lines
Hi Chao,
I mean in the target victim selection, we use
AT_SSRmode if onlyatgc_enabledregardless of the gc mode. My point is:
Yup,
Quoted 13 lines
1.
AT_SSRis good, but LFS mode is perferred in the scenario of foreground GC (at least)& high urgent background GC, which should be finished ASAP.
2. For other GC scenarios using 'greedy' algorithm, I think either
AT_SSRor LFS mode is OK.Because the source victim has few valid blocks & may be not cold.
3. And for GC scenarios using CB/ATGC algorithm, I think
AT_SSRmode is better.
Quoted 6 lines
Quoted 4 lines
Alright, it's fine to me to change policy like this.
One more concern is, if user trigger
GC_URGENT_LOW, we don't need to force GC to use non-AT_SSR allocation, right? as nowGC_URGENT_LOWonlyChao,
Weichao,
Quoted 3 lines
I agree with you, so using non-AT_SSR in foreground GC & high urgent background GC?
Yeah,
Thanks,
Quoted 63 lines
I will send a new version of this patch later.
Thanks,
Weichao
Quoted 56 lines
controls IO awareness of discard/GC thread.
+ if (
sbi->gc_mode==GC_URGENT_LOW&&
+ (type ==DISCARD_TIME|| type ==GC_TIME)) + return true;Thanks,
Quoted 48 lines
Thanks,
Weichao
Quoted 33 lines
Thanks,
Quoted 30 lines
Signed-off-by Weichao Guo <[email protected]>Signed-off-by Huang Jianan <[email protected]>--- fs/f2fs/gc.c | 3 ++- fs/f2fs/segment.c | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-)fs/f2fs/gc.c +2
-1@@ -1120,7 +1120,8 @@ static int move_data_block(struct inode *inode,block_t bidx, block_t newaddr; int err = 0; bool lfs_mode = f2fs_lfs_mode(fio.sbi); - int type = fio.sbi->am.atgc_enabled ? + int type = fio.sbi->am.atgc_enabled && gc_type == BG_GC && + fio.sbi->gc_mode < GC_URGENT_HIGH ? CURSEG_ALL_DATA_ATGC : CURSEG_COLD_DATA; /* do not read out */fs/f2fs/segment.c +0
-0@@ -3264,7 +3264,9 @@ static int __get_segment_type_6(struct f2fs_io_info *fio) struct inode *inode = fio->page->mapping->host; if (is_cold_data(fio->page)) {Quoted 8 lines
fs/f2fs/segment.c static int __get_segment_type_6(struct f2fs_io_info *fio) · line 3272
Quoted 8 lines
fs/f2fs/segment.c +3
-1- if (fio->sbi->am.atgc_enabled) + if (fio->sbi->am.atgc_enabled && + fio->io_type == FS_DATA_IO && + fio->sbi->gc_mode < GC_URGENT_HIGH) return CURSEG_ALL_DATA_ATGC; else return CURSEG_COLD_DATA;.
Quoted 2 lines
.
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel