diff options
Diffstat (limited to 'include/linux/backing-dev.h')
| -rw-r--r-- | include/linux/backing-dev.h | 57 |
1 files changed, 56 insertions, 1 deletions
diff --git a/include/linux/backing-dev.h b/include/linux/backing-dev.h index 1d52425a6118..b449e738533a 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 | ||
| 18 | struct page; | 20 | struct page; |
| @@ -23,9 +25,11 @@ struct dentry; | |||
| 23 | * Bits in backing_dev_info.state | 25 | * Bits in backing_dev_info.state |
| 24 | */ | 26 | */ |
| 25 | enum bdi_state { | 27 | enum 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 */ |
| 32 | BDI_registered, /* bdi_register() was done */ | ||
| 29 | BDI_unused, /* Available bits start here */ | 33 | BDI_unused, /* Available bits start here */ |
| 30 | }; | 34 | }; |
| 31 | 35 | ||
| @@ -39,7 +43,23 @@ enum bdi_stat_item { | |||
| 39 | 43 | ||
| 40 | #define BDI_STAT_BATCH (8*(1+ilog2(nr_cpu_ids))) | 44 | #define BDI_STAT_BATCH (8*(1+ilog2(nr_cpu_ids))) |
| 41 | 45 | ||
| 46 | struct bdi_writeback { | ||
| 47 | struct list_head list; /* hangs off the bdi */ | ||
| 48 | |||
| 49 | struct backing_dev_info *bdi; /* our parent bdi */ | ||
| 50 | unsigned int nr; | ||
| 51 | |||
| 52 | unsigned long last_old_flush; /* last old data flush */ | ||
| 53 | |||
| 54 | struct task_struct *task; /* writeback task */ | ||
| 55 | struct list_head b_dirty; /* dirty inodes */ | ||
| 56 | struct list_head b_io; /* parked for writeback */ | ||
| 57 | struct list_head b_more_io; /* parked for more writeback */ | ||
| 58 | }; | ||
| 59 | |||
| 42 | struct backing_dev_info { | 60 | struct backing_dev_info { |
| 61 | struct list_head bdi_list; | ||
| 62 | struct rcu_head rcu_head; | ||
| 43 | unsigned long ra_pages; /* max readahead in PAGE_CACHE_SIZE units */ | 63 | unsigned long ra_pages; /* max readahead in PAGE_CACHE_SIZE units */ |
| 44 | unsigned long state; /* Always use atomic bitops on this */ | 64 | unsigned long state; /* Always use atomic bitops on this */ |
| 45 | unsigned int capabilities; /* Device capabilities */ | 65 | unsigned int capabilities; /* Device capabilities */ |
| @@ -48,6 +68,8 @@ struct backing_dev_info { | |||
| 48 | void (*unplug_io_fn)(struct backing_dev_info *, struct page *); | 68 | void (*unplug_io_fn)(struct backing_dev_info *, struct page *); |
| 49 | void *unplug_io_data; | 69 | void *unplug_io_data; |
| 50 | 70 | ||
| 71 | char *name; | ||
| 72 | |||
| 51 | struct percpu_counter bdi_stat[NR_BDI_STAT_ITEMS]; | 73 | struct percpu_counter bdi_stat[NR_BDI_STAT_ITEMS]; |
| 52 | 74 | ||
| 53 | struct prop_local_percpu completions; | 75 | struct prop_local_percpu completions; |
| @@ -56,6 +78,14 @@ struct backing_dev_info { | |||
| 56 | unsigned int min_ratio; | 78 | unsigned int min_ratio; |
| 57 | unsigned int max_ratio, max_prop_frac; | 79 | unsigned int max_ratio, max_prop_frac; |
| 58 | 80 | ||
| 81 | struct bdi_writeback wb; /* default writeback info for this bdi */ | ||
| 82 | spinlock_t wb_lock; /* protects update side of wb_list */ | ||
| 83 | struct list_head wb_list; /* the flusher threads hanging off this bdi */ | ||
| 84 | unsigned long wb_mask; /* bitmask of registered tasks */ | ||
| 85 | unsigned int wb_cnt; /* number of registered tasks */ | ||
| 86 | |||
| 87 | struct list_head work_list; | ||
| 88 | |||
| 59 | struct device *dev; | 89 | struct device *dev; |
| 60 | 90 | ||
| 61 | #ifdef CONFIG_DEBUG_FS | 91 | #ifdef CONFIG_DEBUG_FS |
| @@ -71,6 +101,20 @@ int bdi_register(struct backing_dev_info *bdi, struct device *parent, | |||
| 71 | const char *fmt, ...); | 101 | const char *fmt, ...); |
| 72 | int bdi_register_dev(struct backing_dev_info *bdi, dev_t dev); | 102 | int bdi_register_dev(struct backing_dev_info *bdi, dev_t dev); |
| 73 | void bdi_unregister(struct backing_dev_info *bdi); | 103 | void bdi_unregister(struct backing_dev_info *bdi); |
| 104 | void bdi_start_writeback(struct backing_dev_info *bdi, struct super_block *sb, | ||
| 105 | long nr_pages); | ||
| 106 | int bdi_writeback_task(struct bdi_writeback *wb); | ||
| 107 | int bdi_has_dirty_io(struct backing_dev_info *bdi); | ||
| 108 | |||
| 109 | extern spinlock_t bdi_lock; | ||
| 110 | extern struct list_head bdi_list; | ||
| 111 | |||
| 112 | static inline int wb_has_dirty_io(struct bdi_writeback *wb) | ||
| 113 | { | ||
| 114 | return !list_empty(&wb->b_dirty) || | ||
| 115 | !list_empty(&wb->b_io) || | ||
| 116 | !list_empty(&wb->b_more_io); | ||
| 117 | } | ||
| 74 | 118 | ||
| 75 | static inline void __add_bdi_stat(struct backing_dev_info *bdi, | 119 | static inline void __add_bdi_stat(struct backing_dev_info *bdi, |
| 76 | enum bdi_stat_item item, s64 amount) | 120 | enum bdi_stat_item item, s64 amount) |
| @@ -261,6 +305,11 @@ static inline bool bdi_cap_swap_backed(struct backing_dev_info *bdi) | |||
| 261 | return bdi->capabilities & BDI_CAP_SWAP_BACKED; | 305 | return bdi->capabilities & BDI_CAP_SWAP_BACKED; |
| 262 | } | 306 | } |
| 263 | 307 | ||
| 308 | static inline bool bdi_cap_flush_forker(struct backing_dev_info *bdi) | ||
| 309 | { | ||
| 310 | return bdi == &default_backing_dev_info; | ||
| 311 | } | ||
| 312 | |||
| 264 | static inline bool mapping_cap_writeback_dirty(struct address_space *mapping) | 313 | static inline bool mapping_cap_writeback_dirty(struct address_space *mapping) |
| 265 | { | 314 | { |
| 266 | return bdi_cap_writeback_dirty(mapping->backing_dev_info); | 315 | return bdi_cap_writeback_dirty(mapping->backing_dev_info); |
| @@ -276,4 +325,10 @@ static inline bool mapping_cap_swap_backed(struct address_space *mapping) | |||
| 276 | return bdi_cap_swap_backed(mapping->backing_dev_info); | 325 | return bdi_cap_swap_backed(mapping->backing_dev_info); |
| 277 | } | 326 | } |
| 278 | 327 | ||
| 328 | static inline int bdi_sched_wait(void *word) | ||
| 329 | { | ||
| 330 | schedule(); | ||
| 331 | return 0; | ||
| 332 | } | ||
| 333 | |||
| 279 | #endif /* _LINUX_BACKING_DEV_H */ | 334 | #endif /* _LINUX_BACKING_DEV_H */ |
