aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/backing-dev.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/backing-dev.h')
-rw-r--r--include/linux/backing-dev.h55
1 files changed, 48 insertions, 7 deletions
diff --git a/include/linux/backing-dev.h b/include/linux/backing-dev.h
index 928cd5484f4d..d045f5f615c7 100644
--- a/include/linux/backing-dev.h
+++ b/include/linux/backing-dev.h
@@ -13,6 +13,8 @@
13#include <linux/proportions.h> 13#include <linux/proportions.h>
14#include <linux/kernel.h> 14#include <linux/kernel.h>
15#include <linux/fs.h> 15#include <linux/fs.h>
16#include <linux/sched.h>
17#include <linux/writeback.h>
16#include <asm/atomic.h> 18#include <asm/atomic.h>
17 19
18struct page; 20struct page;
@@ -23,7 +25,8 @@ struct dentry;
23 * Bits in backing_dev_info.state 25 * Bits in backing_dev_info.state
24 */ 26 */
25enum bdi_state { 27enum bdi_state {
26 BDI_pdflush, /* A pdflush thread is working this device */ 28 BDI_pending, /* On its way to being activated */
29 BDI_wb_alloc, /* Default embedded wb allocated */
27 BDI_async_congested, /* The async (write) queue is getting full */ 30 BDI_async_congested, /* The async (write) queue is getting full */
28 BDI_sync_congested, /* The sync queue is getting full */ 31 BDI_sync_congested, /* The sync queue is getting full */
29 BDI_unused, /* Available bits start here */ 32 BDI_unused, /* Available bits start here */
@@ -39,9 +42,22 @@ enum bdi_stat_item {
39 42
40#define BDI_STAT_BATCH (8*(1+ilog2(nr_cpu_ids))) 43#define BDI_STAT_BATCH (8*(1+ilog2(nr_cpu_ids)))
41 44
45struct bdi_writeback {
46 struct list_head list; /* hangs off the bdi */
47
48 struct backing_dev_info *bdi; /* our parent bdi */
49 unsigned int nr;
50
51 unsigned long last_old_flush; /* last old data flush */
52
53 struct task_struct *task; /* writeback task */
54 struct list_head b_dirty; /* dirty inodes */
55 struct list_head b_io; /* parked for writeback */
56 struct list_head b_more_io; /* parked for more writeback */
57};
58
42struct backing_dev_info { 59struct backing_dev_info {
43 struct list_head bdi_list; 60 struct list_head bdi_list;
44
45 unsigned long ra_pages; /* max readahead in PAGE_CACHE_SIZE units */ 61 unsigned long ra_pages; /* max readahead in PAGE_CACHE_SIZE units */
46 unsigned long state; /* Always use atomic bitops on this */ 62 unsigned long state; /* Always use atomic bitops on this */
47 unsigned int capabilities; /* Device capabilities */ 63 unsigned int capabilities; /* Device capabilities */
@@ -58,11 +74,15 @@ struct backing_dev_info {
58 unsigned int min_ratio; 74 unsigned int min_ratio;
59 unsigned int max_ratio, max_prop_frac; 75 unsigned int max_ratio, max_prop_frac;
60 76
61 struct device *dev; 77 struct bdi_writeback wb; /* default writeback info for this bdi */
78 spinlock_t wb_lock; /* protects update side of wb_list */
79 struct list_head wb_list; /* the flusher threads hanging off this bdi */
80 unsigned long wb_mask; /* bitmask of registered tasks */
81 unsigned int wb_cnt; /* number of registered tasks */
62 82
63 struct list_head b_dirty; /* dirty inodes */ 83 struct list_head work_list;
64 struct list_head b_io; /* parked for writeback */ 84
65 struct list_head b_more_io; /* parked for more writeback */ 85 struct device *dev;
66 86
67#ifdef CONFIG_DEBUG_FS 87#ifdef CONFIG_DEBUG_FS
68 struct dentry *debug_dir; 88 struct dentry *debug_dir;
@@ -77,10 +97,20 @@ int bdi_register(struct backing_dev_info *bdi, struct device *parent,
77 const char *fmt, ...); 97 const char *fmt, ...);
78int bdi_register_dev(struct backing_dev_info *bdi, dev_t dev); 98int bdi_register_dev(struct backing_dev_info *bdi, dev_t dev);
79void bdi_unregister(struct backing_dev_info *bdi); 99void bdi_unregister(struct backing_dev_info *bdi);
100void bdi_start_writeback(struct writeback_control *wbc);
101int bdi_writeback_task(struct bdi_writeback *wb);
102int bdi_has_dirty_io(struct backing_dev_info *bdi);
80 103
81extern struct mutex bdi_lock; 104extern spinlock_t bdi_lock;
82extern struct list_head bdi_list; 105extern struct list_head bdi_list;
83 106
107static inline int wb_has_dirty_io(struct bdi_writeback *wb)
108{
109 return !list_empty(&wb->b_dirty) ||
110 !list_empty(&wb->b_io) ||
111 !list_empty(&wb->b_more_io);
112}
113
84static inline void __add_bdi_stat(struct backing_dev_info *bdi, 114static inline void __add_bdi_stat(struct backing_dev_info *bdi,
85 enum bdi_stat_item item, s64 amount) 115 enum bdi_stat_item item, s64 amount)
86{ 116{
@@ -270,6 +300,11 @@ static inline bool bdi_cap_swap_backed(struct backing_dev_info *bdi)
270 return bdi->capabilities & BDI_CAP_SWAP_BACKED; 300 return bdi->capabilities & BDI_CAP_SWAP_BACKED;
271} 301}
272 302
303static inline bool bdi_cap_flush_forker(struct backing_dev_info *bdi)
304{
305 return bdi == &default_backing_dev_info;
306}
307
273static inline bool mapping_cap_writeback_dirty(struct address_space *mapping) 308static inline bool mapping_cap_writeback_dirty(struct address_space *mapping)
274{ 309{
275 return bdi_cap_writeback_dirty(mapping->backing_dev_info); 310 return bdi_cap_writeback_dirty(mapping->backing_dev_info);
@@ -285,4 +320,10 @@ static inline bool mapping_cap_swap_backed(struct address_space *mapping)
285 return bdi_cap_swap_backed(mapping->backing_dev_info); 320 return bdi_cap_swap_backed(mapping->backing_dev_info);
286} 321}
287 322
323static inline int bdi_sched_wait(void *word)
324{
325 schedule();
326 return 0;
327}
328
288#endif /* _LINUX_BACKING_DEV_H */ 329#endif /* _LINUX_BACKING_DEV_H */