Advertisement
arter97

Untitled

Aug 10th, 2017
260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 2.19 KB | None | 0 0
  1. diff --git a/fs/f2fs/Kconfig b/fs/f2fs/Kconfig
  2. index 378c221d68a9..248e75aabcc8 100644
  3. --- a/fs/f2fs/Kconfig
  4. +++ b/fs/f2fs/Kconfig
  5. @@ -29,6 +29,19 @@ config F2FS_STAT_FS
  6.         - average SIT information about whole segments
  7.         - current memory footprint consumed by f2fs.
  8.  
  9. +config F2FS_POWER_AWARE
  10. +   bool "Power source awareness for F2FS background GC"
  11. +   depends on POWER_SUPPLY
  12. +   default n
  13. +   help
  14. +     Enable F2FS background GC only when external power source is
  15. +     connected for portable devices.
  16. +
  17. +     Enabling this won't cause any functional difference for systems
  18. +     without battery.
  19. +
  20. +     If unsure, say N.
  21. +
  22.  config F2FS_FS_XATTR
  23.     bool "F2FS extended attributes"
  24.     depends on F2FS_FS
  25. diff --git a/fs/f2fs/debug.c b/fs/f2fs/debug.c
  26. index 629c57024106..209c5afc59ce 100644
  27. --- a/fs/f2fs/debug.c
  28. +++ b/fs/f2fs/debug.c
  29. @@ -328,8 +328,13 @@ static int stat_show(struct seq_file *s, void *v)
  30.                si->prefree_count, si->free_segs, si->free_secs);
  31.         seq_printf(s, "CP calls: %d (BG: %d)\n",
  32.                 si->cp_count, si->bg_cp_count);
  33. -       seq_printf(s, "GC calls: %d (BG: %d)\n",
  34. +       seq_printf(s, "GC calls: %d (BG: %d)",
  35.                si->call_count, si->bg_gc);
  36. +#ifdef CONFIG_F2FS_POWER_AWARE
  37. +       if (power_supply_is_system_supplied() == 0)
  38. +           seq_puts(s, " (No external power source - BG disabled)");
  39. +#endif
  40. +       seq_puts(s, "\n");
  41.         seq_printf(s, "  - data segments : %d (%d)\n",
  42.                 si->data_segs, si->bg_data_segs);
  43.         seq_printf(s, "  - node segments : %d (%d)\n",
  44. diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
  45. index 8907042ea571..e0e0777e2afb 100644
  46. --- a/fs/f2fs/f2fs.h
  47. +++ b/fs/f2fs/f2fs.h
  48. @@ -30,6 +30,9 @@
  49.  #endif
  50.  #include <crypto/hash.h>
  51.  #include <linux/writeback.h>
  52. +#ifdef CONFIG_F2FS_POWER_AWARE
  53. +#include <linux/power_supply.h>
  54. +#endif
  55.  
  56.  #ifdef CONFIG_F2FS_CHECK_FS
  57.  #define f2fs_bug_on(sbi, condition)    BUG_ON(condition)
  58. @@ -1202,6 +1205,12 @@ static inline bool is_idle(struct f2fs_sb_info *sbi)
  59.     if (rl->count[BLK_RW_SYNC] || rl->count[BLK_RW_ASYNC])
  60.         return 0;
  61.  
  62. +#ifdef CONFIG_F2FS_POWER_AWARE
  63. +   /* >0 : AC; 0 : battery; <0 : error */
  64. +   if (power_supply_is_system_supplied() == 0)
  65. +       return 0;
  66. +#endif
  67. +
  68.     return f2fs_time_over(sbi, REQ_TIME);
  69.  }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement