Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
f2fs: implement rapid GC for Android
Android I/O workload is very different from traditional Linux distros and it barely gives f2fs enough chance to detect idle time. This behavior causes invalid segments to grow overtime, tanking write performance eventually. GC'ing all invalid blocks only takes a few minutes even under extreme scenario. Since we know exactly when the device goes idle(untouched) on Android, make use of it to rapidly GC all invalid blocks. Most Android devices are charged once a day or two, and majority of that time, it's left idle with the screen turned off. It's a great chance to trigger rapid GC as the user is not interacting with the device at all and the fact that we don't have to worry about the power consumption much during charging. This patch implements rapid GC by waiting until the screen goes off and detecting if an external power source is present. If it is, GC threads are fired up and follows the code logic from setting gc_urgent to 1. Since the device can go to sleep even with power source plugged in, an additional wakelock is catched. When no more GC victim block is found, GC thread sleeps for gc_no_gc_sleep_time, which is changed to 30m from this patch. Discard thread is also forcefully woken up upon rapid GC. Rapid GC also sets the discard policy to force, and sets 1ms interval to be inline with the GC policy. GC is expected to run only with rapid GC with this patch, so background GC is disabled and all GCs are forced to be flushed to allow maximum blocks to be discarded. To prevent triggering rapid GC excessively, it's triggered only when invalid blocks reach 3% of utilization. We use 3% from (total - written) to avoid GC not doing its job when the storage gets nearly full. Signed-off-by: Park Ju Hyung <qkrwngud825@gmail.com> (cherry picked from commit 34a4ea7309f551150628603f7ef71abc25e6b68e) (cherry picked from commit 0b16fac64c71823cc730ade1fce12146f1c60c76)
- Loading branch information
Showing
5 changed files
with
197 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters