Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/fs/f2fs/Kconfig b/fs/f2fs/Kconfig
- index 378c221d68a9..248e75aabcc8 100644
- --- a/fs/f2fs/Kconfig
- +++ b/fs/f2fs/Kconfig
- @@ -29,6 +29,19 @@ config F2FS_STAT_FS
- - average SIT information about whole segments
- - current memory footprint consumed by f2fs.
- +config F2FS_POWER_AWARE
- + bool "Power source awareness for F2FS background GC"
- + depends on POWER_SUPPLY
- + default n
- + help
- + Enable F2FS background GC only when external power source is
- + connected for portable devices.
- +
- + Enabling this won't cause any functional difference for systems
- + without battery.
- +
- + If unsure, say N.
- +
- config F2FS_FS_XATTR
- bool "F2FS extended attributes"
- depends on F2FS_FS
- diff --git a/fs/f2fs/debug.c b/fs/f2fs/debug.c
- index 629c57024106..209c5afc59ce 100644
- --- a/fs/f2fs/debug.c
- +++ b/fs/f2fs/debug.c
- @@ -328,8 +328,13 @@ static int stat_show(struct seq_file *s, void *v)
- si->prefree_count, si->free_segs, si->free_secs);
- seq_printf(s, "CP calls: %d (BG: %d)\n",
- si->cp_count, si->bg_cp_count);
- - seq_printf(s, "GC calls: %d (BG: %d)\n",
- + seq_printf(s, "GC calls: %d (BG: %d)",
- si->call_count, si->bg_gc);
- +#ifdef CONFIG_F2FS_POWER_AWARE
- + if (power_supply_is_system_supplied() == 0)
- + seq_puts(s, " (No external power source - BG disabled)");
- +#endif
- + seq_puts(s, "\n");
- seq_printf(s, " - data segments : %d (%d)\n",
- si->data_segs, si->bg_data_segs);
- seq_printf(s, " - node segments : %d (%d)\n",
- diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
- index 8907042ea571..e0e0777e2afb 100644
- --- a/fs/f2fs/f2fs.h
- +++ b/fs/f2fs/f2fs.h
- @@ -30,6 +30,9 @@
- #endif
- #include <crypto/hash.h>
- #include <linux/writeback.h>
- +#ifdef CONFIG_F2FS_POWER_AWARE
- +#include <linux/power_supply.h>
- +#endif
- #ifdef CONFIG_F2FS_CHECK_FS
- #define f2fs_bug_on(sbi, condition) BUG_ON(condition)
- @@ -1202,6 +1205,12 @@ static inline bool is_idle(struct f2fs_sb_info *sbi)
- if (rl->count[BLK_RW_SYNC] || rl->count[BLK_RW_ASYNC])
- return 0;
- +#ifdef CONFIG_F2FS_POWER_AWARE
- + /* >0 : AC; 0 : battery; <0 : error */
- + if (power_supply_is_system_supplied() == 0)
- + return 0;
- +#endif
- +
- return f2fs_time_over(sbi, REQ_TIME);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement