writeback: account per-bdi accumulated written pages
[linux-2.6-block.git] / include / linux / writeback.h
CommitLineData
1da177e4 1/*
f30c2269 2 * include/linux/writeback.h
1da177e4
LT
3 */
4#ifndef WRITEBACK_H
5#define WRITEBACK_H
6
e8edc6e0 7#include <linux/sched.h>
f5ff8422 8#include <linux/fs.h>
e8edc6e0 9
1da177e4
LT
10struct backing_dev_info;
11
1da177e4
LT
12/*
13 * fs/fs-writeback.c
14 */
15enum writeback_sync_modes {
16 WB_SYNC_NONE, /* Don't wait on anything */
17 WB_SYNC_ALL, /* Wait on every mapping */
1da177e4
LT
18};
19
20/*
21 * A control structure which tells the writeback code what to do. These are
22 * always on the stack, and hence need no locking. They are always initialised
23 * in a manner such that unspecified fields are set to zero.
24 */
25struct writeback_control {
1da177e4 26 enum writeback_sync_modes sync_mode;
1da177e4
LT
27 long nr_to_write; /* Write this many pages, and decrement
28 this for each page written */
29 long pages_skipped; /* Pages which were not written */
30
31 /*
32 * For a_ops->writepages(): is start or end are non-zero then this is
33 * a hint that the filesystem need only write out the pages inside that
34 * byterange. The byte at `end' is included in the writeout request.
35 */
111ebb6e
OH
36 loff_t range_start;
37 loff_t range_end;
1da177e4 38
22905f77 39 unsigned for_kupdate:1; /* A kupdate writeback */
b17621fe 40 unsigned for_background:1; /* A background writeback */
6e6938b6 41 unsigned tagged_writepages:1; /* tag-and-write to avoid livelock */
22905f77 42 unsigned for_reclaim:1; /* Invoked from the page allocator */
111ebb6e 43 unsigned range_cyclic:1; /* range_start is cyclic */
1da177e4
LT
44};
45
1da177e4
LT
46/*
47 * fs/fs-writeback.c
48 */
03ba3782 49struct bdi_writeback;
1da177e4 50int inode_wait(void *);
b6e51316 51void writeback_inodes_sb(struct super_block *);
3259f8be 52void writeback_inodes_sb_nr(struct super_block *, unsigned long nr);
17bd55d0 53int writeback_inodes_sb_if_idle(struct super_block *);
3259f8be 54int writeback_inodes_sb_nr_if_idle(struct super_block *, unsigned long nr);
b6e51316 55void sync_inodes_sb(struct super_block *);
d46db3d5 56long writeback_inodes_wb(struct bdi_writeback *wb, long nr_pages);
03ba3782
JA
57long wb_do_writeback(struct bdi_writeback *wb, int force_wait);
58void wakeup_flusher_threads(long nr_pages);
1da177e4
LT
59
60/* writeback.h requires fs.h; it, too, is not included from here. */
61static inline void wait_on_inode(struct inode *inode)
62{
63 might_sleep();
eaff8079 64 wait_on_bit(&inode->i_state, __I_NEW, inode_wait, TASK_UNINTERRUPTIBLE);
1da177e4 65}
1c0eeaf5
JE
66static inline void inode_sync_wait(struct inode *inode)
67{
68 might_sleep();
69 wait_on_bit(&inode->i_state, __I_SYNC, inode_wait,
70 TASK_UNINTERRUPTIBLE);
71}
72
1da177e4
LT
73
74/*
75 * mm/page-writeback.c
76 */
c2c4986e 77#ifdef CONFIG_BLOCK
31373d09 78void laptop_io_completion(struct backing_dev_info *info);
1da177e4 79void laptop_sync_completion(void);
31373d09
MG
80void laptop_mode_sync(struct work_struct *work);
81void laptop_mode_timer_fn(unsigned long data);
c2c4986e
JA
82#else
83static inline void laptop_sync_completion(void) { }
84#endif
232ea4d6 85void throttle_vm_writeout(gfp_t gfp_mask);
1da177e4
LT
86
87/* These are exported to sysctl. */
88extern int dirty_background_ratio;
2da02997 89extern unsigned long dirty_background_bytes;
1da177e4 90extern int vm_dirty_ratio;
2da02997 91extern unsigned long vm_dirty_bytes;
704503d8
AD
92extern unsigned int dirty_writeback_interval;
93extern unsigned int dirty_expire_interval;
195cf453 94extern int vm_highmem_is_dirtyable;
1da177e4
LT
95extern int block_dump;
96extern int laptop_mode;
97
3eefae99
SR
98extern unsigned long determine_dirtyable_memory(void);
99
2da02997 100extern int dirty_background_ratio_handler(struct ctl_table *table, int write,
8d65af78 101 void __user *buffer, size_t *lenp,
2da02997
DR
102 loff_t *ppos);
103extern int dirty_background_bytes_handler(struct ctl_table *table, int write,
8d65af78 104 void __user *buffer, size_t *lenp,
2da02997 105 loff_t *ppos);
04fbfdc1 106extern int dirty_ratio_handler(struct ctl_table *table, int write,
8d65af78 107 void __user *buffer, size_t *lenp,
04fbfdc1 108 loff_t *ppos);
2da02997 109extern int dirty_bytes_handler(struct ctl_table *table, int write,
8d65af78 110 void __user *buffer, size_t *lenp,
2da02997 111 loff_t *ppos);
04fbfdc1 112
1da177e4 113struct ctl_table;
8d65af78 114int dirty_writeback_centisecs_handler(struct ctl_table *, int,
1da177e4
LT
115 void __user *, size_t *, loff_t *);
116
16c4042f
WF
117void global_dirty_limits(unsigned long *pbackground, unsigned long *pdirty);
118unsigned long bdi_dirty_limit(struct backing_dev_info *bdi,
119 unsigned long dirty);
cf0ca9fe 120
1da177e4 121void page_writeback_init(void);
fa5a734e
AM
122void balance_dirty_pages_ratelimited_nr(struct address_space *mapping,
123 unsigned long nr_pages_dirtied);
124
125static inline void
126balance_dirty_pages_ratelimited(struct address_space *mapping)
127{
128 balance_dirty_pages_ratelimited_nr(mapping, 1);
129}
130
0ea97180
MS
131typedef int (*writepage_t)(struct page *page, struct writeback_control *wbc,
132 void *data);
133
0ea97180
MS
134int generic_writepages(struct address_space *mapping,
135 struct writeback_control *wbc);
5b41d924
ES
136void tag_pages_for_writeback(struct address_space *mapping,
137 pgoff_t start, pgoff_t end);
0ea97180
MS
138int write_cache_pages(struct address_space *mapping,
139 struct writeback_control *wbc, writepage_t writepage,
140 void *data);
1da177e4 141int do_writepages(struct address_space *mapping, struct writeback_control *wbc);
a200ee18 142void set_page_dirty_balance(struct page *page, int page_mkwrite);
2d1d43f6 143void writeback_set_ratelimit(void);
92c09c04
NK
144void tag_pages_for_writeback(struct address_space *mapping,
145 pgoff_t start, pgoff_t end);
1da177e4
LT
146
147/* pdflush.c */
148extern int nr_pdflush_threads; /* Global so it can be exported to sysctl
149 read-only. */
150
151
152#endif /* WRITEBACK_H */