Merge branch 'modsplit-Oct31_2011' of git://git.kernel.org/pub/scm/linux/kernel/git...
[deliverable/linux.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
ffd1f609 10/*
1a12d8bd
WF
11 * The 1/4 region under the global dirty thresh is for smooth dirty throttling:
12 *
13 * (thresh - thresh/DIRTY_FULL_SCOPE, thresh)
14 *
ffd1f609
WF
15 * Further beyond, all dirtier tasks will enter a loop waiting (possibly long
16 * time) for the dirty pages to drop, unless written enough pages.
17 *
18 * The global dirty threshold is normally equal to the global dirty limit,
19 * except when the system suddenly allocates a lot of anonymous memory and
20 * knocks down the global dirty threshold quickly, in which case the global
21 * dirty limit will follow down slowly to prevent livelocking all dirtier tasks.
22 */
1a12d8bd
WF
23#define DIRTY_SCOPE 8
24#define DIRTY_FULL_SCOPE (DIRTY_SCOPE / 2)
ffd1f609 25
1a12d8bd
WF
26/*
27 * 4MB minimal write chunk size
28 */
29#define MIN_WRITEBACK_PAGES (4096UL >> (PAGE_CACHE_SHIFT - 10))
30
1da177e4
LT
31struct backing_dev_info;
32
1da177e4
LT
33/*
34 * fs/fs-writeback.c
35 */
36enum writeback_sync_modes {
37 WB_SYNC_NONE, /* Don't wait on anything */
38 WB_SYNC_ALL, /* Wait on every mapping */
1da177e4
LT
39};
40
0e175a18
CW
41/*
42 * why some writeback work was initiated
43 */
44enum wb_reason {
45 WB_REASON_BACKGROUND,
46 WB_REASON_TRY_TO_FREE_PAGES,
47 WB_REASON_SYNC,
48 WB_REASON_PERIODIC,
49 WB_REASON_LAPTOP_TIMER,
50 WB_REASON_FREE_MORE_MEM,
51 WB_REASON_FS_FREE_SPACE,
52 WB_REASON_FORKER_THREAD,
53
54 WB_REASON_MAX,
55};
56extern const char *wb_reason_name[];
57
1da177e4
LT
58/*
59 * A control structure which tells the writeback code what to do. These are
60 * always on the stack, and hence need no locking. They are always initialised
61 * in a manner such that unspecified fields are set to zero.
62 */
63struct writeback_control {
1da177e4 64 enum writeback_sync_modes sync_mode;
1da177e4
LT
65 long nr_to_write; /* Write this many pages, and decrement
66 this for each page written */
67 long pages_skipped; /* Pages which were not written */
68
69 /*
70 * For a_ops->writepages(): is start or end are non-zero then this is
71 * a hint that the filesystem need only write out the pages inside that
72 * byterange. The byte at `end' is included in the writeout request.
73 */
111ebb6e
OH
74 loff_t range_start;
75 loff_t range_end;
1da177e4 76
22905f77 77 unsigned for_kupdate:1; /* A kupdate writeback */
b17621fe 78 unsigned for_background:1; /* A background writeback */
6e6938b6 79 unsigned tagged_writepages:1; /* tag-and-write to avoid livelock */
22905f77 80 unsigned for_reclaim:1; /* Invoked from the page allocator */
111ebb6e 81 unsigned range_cyclic:1; /* range_start is cyclic */
1da177e4
LT
82};
83
1da177e4
LT
84/*
85 * fs/fs-writeback.c
86 */
03ba3782 87struct bdi_writeback;
1da177e4 88int inode_wait(void *);
0e175a18
CW
89void writeback_inodes_sb(struct super_block *, enum wb_reason reason);
90void writeback_inodes_sb_nr(struct super_block *, unsigned long nr,
91 enum wb_reason reason);
92int writeback_inodes_sb_if_idle(struct super_block *, enum wb_reason reason);
93int writeback_inodes_sb_nr_if_idle(struct super_block *, unsigned long nr,
94 enum wb_reason reason);
b6e51316 95void sync_inodes_sb(struct super_block *);
0e175a18
CW
96long writeback_inodes_wb(struct bdi_writeback *wb, long nr_pages,
97 enum wb_reason reason);
03ba3782 98long wb_do_writeback(struct bdi_writeback *wb, int force_wait);
0e175a18 99void wakeup_flusher_threads(long nr_pages, enum wb_reason reason);
1da177e4
LT
100
101/* writeback.h requires fs.h; it, too, is not included from here. */
102static inline void wait_on_inode(struct inode *inode)
103{
104 might_sleep();
eaff8079 105 wait_on_bit(&inode->i_state, __I_NEW, inode_wait, TASK_UNINTERRUPTIBLE);
1da177e4 106}
1c0eeaf5
JE
107static inline void inode_sync_wait(struct inode *inode)
108{
109 might_sleep();
110 wait_on_bit(&inode->i_state, __I_SYNC, inode_wait,
111 TASK_UNINTERRUPTIBLE);
112}
113
1da177e4
LT
114
115/*
116 * mm/page-writeback.c
117 */
c2c4986e 118#ifdef CONFIG_BLOCK
31373d09 119void laptop_io_completion(struct backing_dev_info *info);
1da177e4 120void laptop_sync_completion(void);
31373d09
MG
121void laptop_mode_sync(struct work_struct *work);
122void laptop_mode_timer_fn(unsigned long data);
c2c4986e
JA
123#else
124static inline void laptop_sync_completion(void) { }
125#endif
232ea4d6 126void throttle_vm_writeout(gfp_t gfp_mask);
1da177e4 127
c42843f2
WF
128extern unsigned long global_dirty_limit;
129
1da177e4
LT
130/* These are exported to sysctl. */
131extern int dirty_background_ratio;
2da02997 132extern unsigned long dirty_background_bytes;
1da177e4 133extern int vm_dirty_ratio;
2da02997 134extern unsigned long vm_dirty_bytes;
704503d8
AD
135extern unsigned int dirty_writeback_interval;
136extern unsigned int dirty_expire_interval;
195cf453 137extern int vm_highmem_is_dirtyable;
1da177e4
LT
138extern int block_dump;
139extern int laptop_mode;
140
3eefae99
SR
141extern unsigned long determine_dirtyable_memory(void);
142
2da02997 143extern int dirty_background_ratio_handler(struct ctl_table *table, int write,
8d65af78 144 void __user *buffer, size_t *lenp,
2da02997
DR
145 loff_t *ppos);
146extern int dirty_background_bytes_handler(struct ctl_table *table, int write,
8d65af78 147 void __user *buffer, size_t *lenp,
2da02997 148 loff_t *ppos);
04fbfdc1 149extern int dirty_ratio_handler(struct ctl_table *table, int write,
8d65af78 150 void __user *buffer, size_t *lenp,
04fbfdc1 151 loff_t *ppos);
2da02997 152extern int dirty_bytes_handler(struct ctl_table *table, int write,
8d65af78 153 void __user *buffer, size_t *lenp,
2da02997 154 loff_t *ppos);
04fbfdc1 155
1da177e4 156struct ctl_table;
8d65af78 157int dirty_writeback_centisecs_handler(struct ctl_table *, int,
1da177e4
LT
158 void __user *, size_t *, loff_t *);
159
16c4042f
WF
160void global_dirty_limits(unsigned long *pbackground, unsigned long *pdirty);
161unsigned long bdi_dirty_limit(struct backing_dev_info *bdi,
162 unsigned long dirty);
cf0ca9fe 163
e98be2d5 164void __bdi_update_bandwidth(struct backing_dev_info *bdi,
c42843f2 165 unsigned long thresh,
af6a3113 166 unsigned long bg_thresh,
c42843f2
WF
167 unsigned long dirty,
168 unsigned long bdi_thresh,
169 unsigned long bdi_dirty,
e98be2d5
WF
170 unsigned long start_time);
171
1da177e4 172void page_writeback_init(void);
fa5a734e
AM
173void balance_dirty_pages_ratelimited_nr(struct address_space *mapping,
174 unsigned long nr_pages_dirtied);
175
176static inline void
177balance_dirty_pages_ratelimited(struct address_space *mapping)
178{
179 balance_dirty_pages_ratelimited_nr(mapping, 1);
180}
181
0ea97180
MS
182typedef int (*writepage_t)(struct page *page, struct writeback_control *wbc,
183 void *data);
184
0ea97180
MS
185int generic_writepages(struct address_space *mapping,
186 struct writeback_control *wbc);
5b41d924
ES
187void tag_pages_for_writeback(struct address_space *mapping,
188 pgoff_t start, pgoff_t end);
0ea97180
MS
189int write_cache_pages(struct address_space *mapping,
190 struct writeback_control *wbc, writepage_t writepage,
191 void *data);
1da177e4 192int do_writepages(struct address_space *mapping, struct writeback_control *wbc);
a200ee18 193void set_page_dirty_balance(struct page *page, int page_mkwrite);
2d1d43f6 194void writeback_set_ratelimit(void);
92c09c04
NK
195void tag_pages_for_writeback(struct address_space *mapping,
196 pgoff_t start, pgoff_t end);
1da177e4
LT
197
198/* pdflush.c */
199extern int nr_pdflush_threads; /* Global so it can be exported to sysctl
200 read-only. */
201
202
203#endif /* WRITEBACK_H */
This page took 1.475228 seconds and 5 git commands to generate.