backing-dev-defs.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. #ifndef __LINUX_BACKING_DEV_DEFS_H
  2. #define __LINUX_BACKING_DEV_DEFS_H
  3. #include <linux/list.h>
  4. #include <linux/spinlock.h>
  5. #include <linux/percpu_counter.h>
  6. #include <linux/flex_proportions.h>
  7. #include <linux/timer.h>
  8. #include <linux/workqueue.h>
  9. struct page;
  10. struct device;
  11. struct dentry;
  12. /*
  13. * Bits in bdi_writeback.state
  14. */
  15. enum wb_state {
  16. WB_registered, /* bdi_register() was done */
  17. WB_writeback_running, /* Writeback is in progress */
  18. };
  19. enum wb_congested_state {
  20. WB_async_congested, /* The async (write) queue is getting full */
  21. WB_sync_congested, /* The sync queue is getting full */
  22. };
  23. typedef int (congested_fn)(void *, int);
  24. enum wb_stat_item {
  25. WB_RECLAIMABLE,
  26. WB_WRITEBACK,
  27. WB_DIRTIED,
  28. WB_WRITTEN,
  29. NR_WB_STAT_ITEMS
  30. };
  31. #define WB_STAT_BATCH (8*(1+ilog2(nr_cpu_ids)))
  32. struct bdi_writeback_congested {
  33. unsigned long state; /* WB_[a]sync_congested flags */
  34. };
  35. struct bdi_writeback {
  36. struct backing_dev_info *bdi; /* our parent bdi */
  37. unsigned long state; /* Always use atomic bitops on this */
  38. unsigned long last_old_flush; /* last old data flush */
  39. struct list_head b_dirty; /* dirty inodes */
  40. struct list_head b_io; /* parked for writeback */
  41. struct list_head b_more_io; /* parked for more writeback */
  42. struct list_head b_dirty_time; /* time stamps are dirty */
  43. spinlock_t list_lock; /* protects the b_* lists */
  44. struct percpu_counter stat[NR_WB_STAT_ITEMS];
  45. struct bdi_writeback_congested *congested;
  46. unsigned long bw_time_stamp; /* last time write bw is updated */
  47. unsigned long dirtied_stamp;
  48. unsigned long written_stamp; /* pages written at bw_time_stamp */
  49. unsigned long write_bandwidth; /* the estimated write bandwidth */
  50. unsigned long avg_write_bandwidth; /* further smoothed write bw */
  51. /*
  52. * The base dirty throttle rate, re-calculated on every 200ms.
  53. * All the bdi tasks' dirty rate will be curbed under it.
  54. * @dirty_ratelimit tracks the estimated @balanced_dirty_ratelimit
  55. * in small steps and is much more smooth/stable than the latter.
  56. */
  57. unsigned long dirty_ratelimit;
  58. unsigned long balanced_dirty_ratelimit;
  59. struct fprop_local_percpu completions;
  60. int dirty_exceeded;
  61. spinlock_t work_lock; /* protects work_list & dwork scheduling */
  62. struct list_head work_list;
  63. struct delayed_work dwork; /* work item used for writeback */
  64. };
  65. struct backing_dev_info {
  66. struct list_head bdi_list;
  67. unsigned long ra_pages; /* max readahead in PAGE_CACHE_SIZE units */
  68. unsigned int capabilities; /* Device capabilities */
  69. congested_fn *congested_fn; /* Function pointer if device is md/dm */
  70. void *congested_data; /* Pointer to aux data for congested func */
  71. char *name;
  72. unsigned int min_ratio;
  73. unsigned int max_ratio, max_prop_frac;
  74. struct bdi_writeback wb; /* default writeback info for this bdi */
  75. struct bdi_writeback_congested wb_congested;
  76. struct device *dev;
  77. struct timer_list laptop_mode_wb_timer;
  78. #ifdef CONFIG_DEBUG_FS
  79. struct dentry *debug_dir;
  80. struct dentry *debug_stats;
  81. #endif
  82. };
  83. enum {
  84. BLK_RW_ASYNC = 0,
  85. BLK_RW_SYNC = 1,
  86. };
  87. void clear_bdi_congested(struct backing_dev_info *bdi, int sync);
  88. void set_bdi_congested(struct backing_dev_info *bdi, int sync);
  89. #endif /* __LINUX_BACKING_DEV_DEFS_H */