Skip to contentSkip to conversation

f2fs: issue discard commands proactively in high fs utilization

PATCH In review Jaegeuk Kim 4 participants 4 messages May 29, 2018 – May 14, 2019 F2FS file system

lore
Share & tools
lore

Jaegeuk Kim

author maintainer
#0 lore raw

PATCH 1/1 f2fs: issue discard commands proactively in high fs utilization

In the high utilization like over 80%, we don't expect huge # of large discard commands, but do many small pending discards which affects FTL GCs a lot. Let's issue them in that case.

---
 fs/f2fs/f2fs.h    |  3 +-
 fs/f2fs/segment.c | 71 ++++++++++++++++++++++++++---------------------
 2 files changed, 40 insertions(+), 34 deletions(-)
fs/f2fs/f2fs.h +1 -2
index e852ac9472c6..27231fe8a6b2 100644
@@ -186,6 +186,7 @@ enum {
 #define DEF_MAX_DISCARD_LEN		512	/* Max. 2MB per discard */
 #define DEF_MIN_DISCARD_ISSUE_TIME	50	/* 50 ms, if exists */
 #define DEF_MAX_DISCARD_ISSUE_TIME	60000	/* 60 s, if no candidates */
+#define DEF_DISCARD_URGENT_UTIL		80	/* do more discard over 80% */
 #define DEF_CP_INTERVAL			60	/* 60 secs */
 #define DEF_IDLE_INTERVAL		5	/* 5 secs */
 
@@ -2777,8 +2778,6 @@ int f2fs_flush_device_cache(struct f2fs_sb_info *sbi);
 void destroy_flush_cmd_control(struct f2fs_sb_info *sbi, bool free);
 void invalidate_blocks(struct f2fs_sb_info *sbi, block_t addr);
 bool is_checkpointed_data(struct f2fs_sb_info *sbi, block_t blkaddr);
-void init_discard_policy(struct discard_policy *dpolicy, int discard_type,
-						unsigned int granularity);
 void drop_discard_cmd(struct f2fs_sb_info *sbi);
 void stop_discard_thread(struct f2fs_sb_info *sbi);
 bool f2fs_wait_discard_bios(struct f2fs_sb_info *sbi);
fs/f2fs/segment.c +39 -32

114 lines not on this page · raw message

Signature · 1 line
2.17.0.441.gb46fe60e1d-goog
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Jaegeuk Kim

In the high utilization like over 80%, we don't expect huge # of large discard commands, but do many small pending discards which affects FTL GCs a lot. Let's issue them in that case.

Thanks,

#2 lore raw
In reply to Jaegeuk Kim

fs/f2fs/segment.c static void __check_sit_bitmap(struct f2fs_sb_info *sbi, · line 915

Quoted 13 lines · Jaegeuk Kim

In the high utilization like over 80%, we don't expect huge # of large discard commands, but do many small pending discards which affects FTL GCs a lot. Let's issue them in that case.

---

fs/f2fs/segment.c +1 -0
index 6e40e536dae0..8c1f7a6bf178 100644
@@ -915,6 +915,38 @@ static void __check_sit_bitmap(struct f2fs_sb_info *sbi,
+                       dpolicy->max_interval = DEF_MIN_DISCARD_ISSUE_TIME;

Isn't this way too aggressive?

Discard thread will wake up on 50ms interval just because the user has used 80% of space.
60,000ms vs 50ms is too much of a stark difference.

I feel something like 10 seconds(10,000ms) could be a much more reasonable choice than this.

Thanks.

#3 lore raw
Quoted 17 lines · Ju Hyung Park

fs/f2fs/segment.c static void __check_sit_bitmap(struct f2fs_sb_info *sbi, · line 915

Quoted 13 lines · Jaegeuk Kim

In the high utilization like over 80%, we don't expect huge # of large discard commands, but do many small pending discards which affects FTL GCs a lot. Let's issue them in that case.

---

fs/f2fs/segment.c +1 -0
index 6e40e536dae0..8c1f7a6bf178 100644
@@ -915,6 +915,38 @@ static void __check_sit_bitmap(struct f2fs_sb_info *sbi,
+                       dpolicy->max_interval = DEF_MIN_DISCARD_ISSUE_TIME;

Isn't this way too aggressive?

Quoted 6 lines

Discard thread will wake up on 50ms interval just because the user has used 80% of space.
60,000ms vs 50ms is too much of a stark difference.

I feel something like 10 seconds(10,000ms) could be a much more reasonable choice than this.

Hmm.. I agree that current hard code method is not flexible enough, and I proposed below patch last year to adjust interval according to space usage, it looks Jaegeuk partially agreed with that, and pointed out we need to distinguish low/high-end storage to decide interval. And also you point out that btrfs introduces mount option "ssd" to let user give the device type, and we can distinguish with that. :P

https://git.kernel.org/pub/scm/linux/kernel/git/chao/linux.git/commit/?h=f2fs-dev&id=009f548e37ca5d9b4cad9e3c15c2164c53eff1df

But I pended below patch based on Jaegeuk's and your idea due to other work...

https://git.kernel.org/pub/scm/linux/kernel/git/chao/linux.git/commit/?h=f2fs-dev&id=47a992c12398c98e739e3eedc2743824459df943

Thanks,

Quoted 10 lines

Thanks.

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
.