writeback: send work item to queue_io, move_expired_inodes
[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
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
41/*
42 * A control structure which tells the writeback code what to do. These are
43 * always on the stack, and hence need no locking. They are always initialised
44 * in a manner such that unspecified fields are set to zero.
45 */
46struct writeback_control {
1da177e4 47 enum writeback_sync_modes sync_mode;
1da177e4
LT
48 long nr_to_write; /* Write this many pages, and decrement
49 this for each page written */
50 long pages_skipped; /* Pages which were not written */
51
52 /*
53 * For a_ops->writepages(): is start or end are non-zero then this is
54 * a hint that the filesystem need only write out the pages inside that
55 * byterange. The byte at `end' is included in the writeout request.
56 */
111ebb6e
OH
57 loff_t range_start;
58 loff_t range_end;
1da177e4 59
22905f77 60 unsigned for_kupdate:1; /* A kupdate writeback */
b17621fe 61 unsigned for_background:1; /* A background writeback */
6e6938b6 62 unsigned tagged_writepages:1; /* tag-and-write to avoid livelock */
22905f77 63 unsigned for_reclaim:1; /* Invoked from the page allocator */
111ebb6e 64 unsigned range_cyclic:1; /* range_start is cyclic */
1da177e4
LT
65};
66
1da177e4
LT
67/*
68 * fs/fs-writeback.c
69 */
03ba3782 70struct bdi_writeback;
1da177e4 71int inode_wait(void *);
b6e51316 72void writeback_inodes_sb(struct super_block *);
3259f8be 73void writeback_inodes_sb_nr(struct super_block *, unsigned long nr);
17bd55d0 74int writeback_inodes_sb_if_idle(struct super_block *);
3259f8be 75int writeback_inodes_sb_nr_if_idle(struct super_block *, unsigned long nr);
b6e51316 76void sync_inodes_sb(struct super_block *);
d46db3d5 77long writeback_inodes_wb(struct bdi_writeback *wb, long nr_pages);
03ba3782
JA
78long wb_do_writeback(struct bdi_writeback *wb, int force_wait);
79void wakeup_flusher_threads(long nr_pages);
1da177e4
LT
80
81/* writeback.h requires fs.h; it, too, is not included from here. */
82static inline void wait_on_inode(struct inode *inode)
83{
84 might_sleep();
eaff8079 85 wait_on_bit(&inode->i_state, __I_NEW, inode_wait, TASK_UNINTERRUPTIBLE);
1da177e4 86}
1c0eeaf5
JE
87static inline void inode_sync_wait(struct inode *inode)
88{
89 might_sleep();
90 wait_on_bit(&inode->i_state, __I_SYNC, inode_wait,
91 TASK_UNINTERRUPTIBLE);
92}
93
1da177e4
LT
94
95/*
96 * mm/page-writeback.c
97 */
c2c4986e 98#ifdef CONFIG_BLOCK
31373d09 99void laptop_io_completion(struct backing_dev_info *info);
1da177e4 100void laptop_sync_completion(void);
31373d09
MG
101void laptop_mode_sync(struct work_struct *work);
102void laptop_mode_timer_fn(unsigned long data);
c2c4986e
JA
103#else
104static inline void laptop_sync_completion(void) { }
105#endif
232ea4d6 106void throttle_vm_writeout(gfp_t gfp_mask);
1da177e4 107
c42843f2
WF
108extern unsigned long global_dirty_limit;
109
1da177e4
LT
110/* These are exported to sysctl. */
111extern int dirty_background_ratio;
2da02997 112extern unsigned long dirty_background_bytes;
1da177e4 113extern int vm_dirty_ratio;
2da02997 114extern unsigned long vm_dirty_bytes;
704503d8
AD
115extern unsigned int dirty_writeback_interval;
116extern unsigned int dirty_expire_interval;
195cf453 117extern int vm_highmem_is_dirtyable;
1da177e4
LT
118extern int block_dump;
119extern int laptop_mode;
120
3eefae99
SR
121extern unsigned long determine_dirtyable_memory(void);
122
2da02997 123extern int dirty_background_ratio_handler(struct ctl_table *table, int write,
8d65af78 124 void __user *buffer, size_t *lenp,
2da02997
DR
125 loff_t *ppos);
126extern int dirty_background_bytes_handler(struct ctl_table *table, int write,
8d65af78 127 void __user *buffer, size_t *lenp,
2da02997 128 loff_t *ppos);
04fbfdc1 129extern int dirty_ratio_handler(struct ctl_table *table, int write,
8d65af78 130 void __user *buffer, size_t *lenp,
04fbfdc1 131 loff_t *ppos);
2da02997 132extern int dirty_bytes_handler(struct ctl_table *table, int write,
8d65af78 133 void __user *buffer, size_t *lenp,
2da02997 134 loff_t *ppos);
04fbfdc1 135
1da177e4 136struct ctl_table;
8d65af78 137int dirty_writeback_centisecs_handler(struct ctl_table *, int,
1da177e4
LT
138 void __user *, size_t *, loff_t *);
139
16c4042f
WF
140void global_dirty_limits(unsigned long *pbackground, unsigned long *pdirty);
141unsigned long bdi_dirty_limit(struct backing_dev_info *bdi,
142 unsigned long dirty);
cf0ca9fe 143
e98be2d5 144void __bdi_update_bandwidth(struct backing_dev_info *bdi,
c42843f2 145 unsigned long thresh,
af6a3113 146 unsigned long bg_thresh,
c42843f2
WF
147 unsigned long dirty,
148 unsigned long bdi_thresh,
149 unsigned long bdi_dirty,
e98be2d5
WF
150 unsigned long start_time);
151
1da177e4 152void page_writeback_init(void);
fa5a734e
AM
153void balance_dirty_pages_ratelimited_nr(struct address_space *mapping,
154 unsigned long nr_pages_dirtied);
155
156static inline void
157balance_dirty_pages_ratelimited(struct address_space *mapping)
158{
159 balance_dirty_pages_ratelimited_nr(mapping, 1);
160}
161
0ea97180
MS
162typedef int (*writepage_t)(struct page *page, struct writeback_control *wbc,
163 void *data);
164
0ea97180
MS
165int generic_writepages(struct address_space *mapping,
166 struct writeback_control *wbc);
5b41d924
ES
167void tag_pages_for_writeback(struct address_space *mapping,
168 pgoff_t start, pgoff_t end);
0ea97180
MS
169int write_cache_pages(struct address_space *mapping,
170 struct writeback_control *wbc, writepage_t writepage,
171 void *data);
1da177e4 172int do_writepages(struct address_space *mapping, struct writeback_control *wbc);
a200ee18 173void set_page_dirty_balance(struct page *page, int page_mkwrite);
2d1d43f6 174void writeback_set_ratelimit(void);
92c09c04
NK
175void tag_pages_for_writeback(struct address_space *mapping,
176 pgoff_t start, pgoff_t end);
1da177e4
LT
177
178/* pdflush.c */
179extern int nr_pdflush_threads; /* Global so it can be exported to sysctl
180 read-only. */
181
182
183#endif /* WRITEBACK_H */