2 * include/linux/writeback.h
7 #include <linux/sched.h>
11 * The 1/4 region under the global dirty thresh is for smooth dirty throttling:
13 * (thresh - thresh/DIRTY_FULL_SCOPE, thresh)
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.
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.
24 #define DIRTY_FULL_SCOPE (DIRTY_SCOPE / 2)
27 * 4MB minimal write chunk size
29 #define MIN_WRITEBACK_PAGES (4096UL >> (PAGE_CACHE_SHIFT - 10))
31 struct backing_dev_info;
36 enum writeback_sync_modes {
37 WB_SYNC_NONE, /* Don't wait on anything */
38 WB_SYNC_ALL, /* Wait on every mapping */
42 * why some writeback work was initiated
46 WB_REASON_TRY_TO_FREE_PAGES,
49 WB_REASON_LAPTOP_TIMER,
50 WB_REASON_FREE_MORE_MEM,
51 WB_REASON_FS_FREE_SPACE,
52 WB_REASON_FORKER_THREAD,
56 extern const char *wb_reason_name[];
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.
63 struct writeback_control {
64 enum writeback_sync_modes sync_mode;
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 */
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.
77 unsigned for_kupdate:1; /* A kupdate writeback */
78 unsigned for_background:1; /* A background writeback */
79 unsigned tagged_writepages:1; /* tag-and-write to avoid livelock */
80 unsigned for_reclaim:1; /* Invoked from the page allocator */
81 unsigned range_cyclic:1; /* range_start is cyclic */
88 int inode_wait(void *);
89 void writeback_inodes_sb(struct super_block *, enum wb_reason reason);
90 void writeback_inodes_sb_nr(struct super_block *, unsigned long nr,
91 enum wb_reason reason);
92 int writeback_inodes_sb_if_idle(struct super_block *, enum wb_reason reason);
93 int writeback_inodes_sb_nr_if_idle(struct super_block *, unsigned long nr,
94 enum wb_reason reason);
95 void sync_inodes_sb(struct super_block *);
96 long writeback_inodes_wb(struct bdi_writeback *wb, long nr_pages,
97 enum wb_reason reason);
98 long wb_do_writeback(struct bdi_writeback *wb, int force_wait);
99 void wakeup_flusher_threads(long nr_pages, enum wb_reason reason);
101 /* writeback.h requires fs.h; it, too, is not included from here. */
102 static inline void wait_on_inode(struct inode *inode)
105 wait_on_bit(&inode->i_state, __I_NEW, inode_wait, TASK_UNINTERRUPTIBLE);
107 static inline void inode_sync_wait(struct inode *inode)
110 wait_on_bit(&inode->i_state, __I_SYNC, inode_wait,
111 TASK_UNINTERRUPTIBLE);
116 * mm/page-writeback.c
119 void laptop_io_completion(struct backing_dev_info *info);
120 void laptop_sync_completion(void);
121 void laptop_mode_sync(struct work_struct *work);
122 void laptop_mode_timer_fn(unsigned long data);
124 static inline void laptop_sync_completion(void) { }
126 void throttle_vm_writeout(gfp_t gfp_mask);
128 extern unsigned long global_dirty_limit;
130 /* These are exported to sysctl. */
131 extern int dirty_background_ratio;
132 extern unsigned long dirty_background_bytes;
133 extern int vm_dirty_ratio;
134 extern unsigned long vm_dirty_bytes;
135 extern unsigned int dirty_writeback_interval;
136 extern unsigned int dirty_expire_interval;
137 extern int vm_highmem_is_dirtyable;
138 extern int block_dump;
139 extern int laptop_mode;
141 extern unsigned long determine_dirtyable_memory(void);
143 extern int dirty_background_ratio_handler(struct ctl_table *table, int write,
144 void __user *buffer, size_t *lenp,
146 extern int dirty_background_bytes_handler(struct ctl_table *table, int write,
147 void __user *buffer, size_t *lenp,
149 extern int dirty_ratio_handler(struct ctl_table *table, int write,
150 void __user *buffer, size_t *lenp,
152 extern int dirty_bytes_handler(struct ctl_table *table, int write,
153 void __user *buffer, size_t *lenp,
157 int dirty_writeback_centisecs_handler(struct ctl_table *, int,
158 void __user *, size_t *, loff_t *);
160 void global_dirty_limits(unsigned long *pbackground, unsigned long *pdirty);
161 unsigned long bdi_dirty_limit(struct backing_dev_info *bdi,
162 unsigned long dirty);
164 void __bdi_update_bandwidth(struct backing_dev_info *bdi,
165 unsigned long thresh,
166 unsigned long bg_thresh,
168 unsigned long bdi_thresh,
169 unsigned long bdi_dirty,
170 unsigned long start_time);
172 void page_writeback_init(void);
173 void balance_dirty_pages_ratelimited_nr(struct address_space *mapping,
174 unsigned long nr_pages_dirtied);
177 balance_dirty_pages_ratelimited(struct address_space *mapping)
179 balance_dirty_pages_ratelimited_nr(mapping, 1);
182 typedef int (*writepage_t)(struct page *page, struct writeback_control *wbc,
185 int generic_writepages(struct address_space *mapping,
186 struct writeback_control *wbc);
187 void tag_pages_for_writeback(struct address_space *mapping,
188 pgoff_t start, pgoff_t end);
189 int write_cache_pages(struct address_space *mapping,
190 struct writeback_control *wbc, writepage_t writepage,
192 int do_writepages(struct address_space *mapping, struct writeback_control *wbc);
193 void set_page_dirty_balance(struct page *page, int page_mkwrite);
194 void writeback_set_ratelimit(void);
195 void tag_pages_for_writeback(struct address_space *mapping,
196 pgoff_t start, pgoff_t end);
199 extern int nr_pdflush_threads; /* Global so it can be exported to sysctl
203 #endif /* WRITEBACK_H */