]>
Commit | Line | Data |
---|---|---|
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 |
10 | struct backing_dev_info; |
11 | ||
1da177e4 LT |
12 | /* |
13 | * fs/fs-writeback.c | |
14 | */ | |
15 | enum 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 | */ | |
25 | struct 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 | 49 | struct bdi_writeback; |
1da177e4 | 50 | int inode_wait(void *); |
b6e51316 | 51 | void writeback_inodes_sb(struct super_block *); |
3259f8be | 52 | void writeback_inodes_sb_nr(struct super_block *, unsigned long nr); |
17bd55d0 | 53 | int writeback_inodes_sb_if_idle(struct super_block *); |
3259f8be | 54 | int writeback_inodes_sb_nr_if_idle(struct super_block *, unsigned long nr); |
b6e51316 | 55 | void sync_inodes_sb(struct super_block *); |
d46db3d5 | 56 | long writeback_inodes_wb(struct bdi_writeback *wb, long nr_pages); |
03ba3782 JA |
57 | long wb_do_writeback(struct bdi_writeback *wb, int force_wait); |
58 | void wakeup_flusher_threads(long nr_pages); | |
1da177e4 LT |
59 | |
60 | /* writeback.h requires fs.h; it, too, is not included from here. */ | |
61 | static 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 |
66 | static 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 | 78 | void laptop_io_completion(struct backing_dev_info *info); |
1da177e4 | 79 | void laptop_sync_completion(void); |
31373d09 MG |
80 | void laptop_mode_sync(struct work_struct *work); |
81 | void laptop_mode_timer_fn(unsigned long data); | |
c2c4986e JA |
82 | #else |
83 | static inline void laptop_sync_completion(void) { } | |
84 | #endif | |
232ea4d6 | 85 | void throttle_vm_writeout(gfp_t gfp_mask); |
1da177e4 LT |
86 | |
87 | /* These are exported to sysctl. */ | |
88 | extern int dirty_background_ratio; | |
2da02997 | 89 | extern unsigned long dirty_background_bytes; |
1da177e4 | 90 | extern int vm_dirty_ratio; |
2da02997 | 91 | extern unsigned long vm_dirty_bytes; |
704503d8 AD |
92 | extern unsigned int dirty_writeback_interval; |
93 | extern unsigned int dirty_expire_interval; | |
195cf453 | 94 | extern int vm_highmem_is_dirtyable; |
1da177e4 LT |
95 | extern int block_dump; |
96 | extern int laptop_mode; | |
97 | ||
3eefae99 SR |
98 | extern unsigned long determine_dirtyable_memory(void); |
99 | ||
2da02997 | 100 | extern 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); |
103 | extern 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 | 106 | extern int dirty_ratio_handler(struct ctl_table *table, int write, |
8d65af78 | 107 | void __user *buffer, size_t *lenp, |
04fbfdc1 | 108 | loff_t *ppos); |
2da02997 | 109 | extern 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 | 113 | struct ctl_table; |
8d65af78 | 114 | int dirty_writeback_centisecs_handler(struct ctl_table *, int, |
1da177e4 LT |
115 | void __user *, size_t *, loff_t *); |
116 | ||
16c4042f WF |
117 | void global_dirty_limits(unsigned long *pbackground, unsigned long *pdirty); |
118 | unsigned long bdi_dirty_limit(struct backing_dev_info *bdi, | |
119 | unsigned long dirty); | |
cf0ca9fe | 120 | |
e98be2d5 WF |
121 | void __bdi_update_bandwidth(struct backing_dev_info *bdi, |
122 | unsigned long start_time); | |
123 | ||
1da177e4 | 124 | void page_writeback_init(void); |
fa5a734e AM |
125 | void balance_dirty_pages_ratelimited_nr(struct address_space *mapping, |
126 | unsigned long nr_pages_dirtied); | |
127 | ||
128 | static inline void | |
129 | balance_dirty_pages_ratelimited(struct address_space *mapping) | |
130 | { | |
131 | balance_dirty_pages_ratelimited_nr(mapping, 1); | |
132 | } | |
133 | ||
0ea97180 MS |
134 | typedef int (*writepage_t)(struct page *page, struct writeback_control *wbc, |
135 | void *data); | |
136 | ||
0ea97180 MS |
137 | int generic_writepages(struct address_space *mapping, |
138 | struct writeback_control *wbc); | |
5b41d924 ES |
139 | void tag_pages_for_writeback(struct address_space *mapping, |
140 | pgoff_t start, pgoff_t end); | |
0ea97180 MS |
141 | int write_cache_pages(struct address_space *mapping, |
142 | struct writeback_control *wbc, writepage_t writepage, | |
143 | void *data); | |
1da177e4 | 144 | int do_writepages(struct address_space *mapping, struct writeback_control *wbc); |
a200ee18 | 145 | void set_page_dirty_balance(struct page *page, int page_mkwrite); |
2d1d43f6 | 146 | void writeback_set_ratelimit(void); |
92c09c04 NK |
147 | void tag_pages_for_writeback(struct address_space *mapping, |
148 | pgoff_t start, pgoff_t end); | |
1da177e4 LT |
149 | |
150 | /* pdflush.c */ | |
151 | extern int nr_pdflush_threads; /* Global so it can be exported to sysctl | |
152 | read-only. */ | |
153 | ||
154 | ||
155 | #endif /* WRITEBACK_H */ |