squeeze max-pause area and drop pass-good area
[linux-2.6.git] / include / linux / writeback.h
blob2b8963ff0f359b4c6dab919e2ccc3c2c0324b5bb
1 /*
2 * include/linux/writeback.h
3 */
4 #ifndef WRITEBACK_H
5 #define WRITEBACK_H
7 #include <linux/sched.h>
8 #include <linux/fs.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.
23 #define DIRTY_SCOPE 8
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;
34 * fs/fs-writeback.c
36 enum writeback_sync_modes {
37 WB_SYNC_NONE, /* Don't wait on anything */
38 WB_SYNC_ALL, /* Wait on every mapping */
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.
46 struct writeback_control {
47 enum writeback_sync_modes sync_mode;
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 */
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.
57 loff_t range_start;
58 loff_t range_end;
60 unsigned for_kupdate:1; /* A kupdate writeback */
61 unsigned for_background:1; /* A background writeback */
62 unsigned tagged_writepages:1; /* tag-and-write to avoid livelock */
63 unsigned for_reclaim:1; /* Invoked from the page allocator */
64 unsigned range_cyclic:1; /* range_start is cyclic */
68 * fs/fs-writeback.c
69 */
70 struct bdi_writeback;
71 int inode_wait(void *);
72 void writeback_inodes_sb(struct super_block *);
73 void writeback_inodes_sb_nr(struct super_block *, unsigned long nr);
74 int writeback_inodes_sb_if_idle(struct super_block *);
75 int writeback_inodes_sb_nr_if_idle(struct super_block *, unsigned long nr);
76 void sync_inodes_sb(struct super_block *);
77 long writeback_inodes_wb(struct bdi_writeback *wb, long nr_pages);
78 long wb_do_writeback(struct bdi_writeback *wb, int force_wait);
79 void wakeup_flusher_threads(long nr_pages);
81 /* writeback.h requires fs.h; it, too, is not included from here. */
82 static inline void wait_on_inode(struct inode *inode)
84 might_sleep();
85 wait_on_bit(&inode->i_state, __I_NEW, inode_wait, TASK_UNINTERRUPTIBLE);
87 static inline void inode_sync_wait(struct inode *inode)
89 might_sleep();
90 wait_on_bit(&inode->i_state, __I_SYNC, inode_wait,
91 TASK_UNINTERRUPTIBLE);
96 * mm/page-writeback.c
98 #ifdef CONFIG_BLOCK
99 void laptop_io_completion(struct backing_dev_info *info);
100 void laptop_sync_completion(void);
101 void laptop_mode_sync(struct work_struct *work);
102 void laptop_mode_timer_fn(unsigned long data);
103 #else
104 static inline void laptop_sync_completion(void) { }
105 #endif
106 void throttle_vm_writeout(gfp_t gfp_mask);
108 extern unsigned long global_dirty_limit;
110 /* These are exported to sysctl. */
111 extern int dirty_background_ratio;
112 extern unsigned long dirty_background_bytes;
113 extern int vm_dirty_ratio;
114 extern unsigned long vm_dirty_bytes;
115 extern unsigned int dirty_writeback_interval;
116 extern unsigned int dirty_expire_interval;
117 extern int vm_highmem_is_dirtyable;
118 extern int block_dump;
119 extern int laptop_mode;
121 extern unsigned long determine_dirtyable_memory(void);
123 extern int dirty_background_ratio_handler(struct ctl_table *table, int write,
124 void __user *buffer, size_t *lenp,
125 loff_t *ppos);
126 extern int dirty_background_bytes_handler(struct ctl_table *table, int write,
127 void __user *buffer, size_t *lenp,
128 loff_t *ppos);
129 extern int dirty_ratio_handler(struct ctl_table *table, int write,
130 void __user *buffer, size_t *lenp,
131 loff_t *ppos);
132 extern int dirty_bytes_handler(struct ctl_table *table, int write,
133 void __user *buffer, size_t *lenp,
134 loff_t *ppos);
136 struct ctl_table;
137 int dirty_writeback_centisecs_handler(struct ctl_table *, int,
138 void __user *, size_t *, loff_t *);
140 void global_dirty_limits(unsigned long *pbackground, unsigned long *pdirty);
141 unsigned long bdi_dirty_limit(struct backing_dev_info *bdi,
142 unsigned long dirty);
144 void __bdi_update_bandwidth(struct backing_dev_info *bdi,
145 unsigned long thresh,
146 unsigned long dirty,
147 unsigned long bdi_thresh,
148 unsigned long bdi_dirty,
149 unsigned long start_time);
151 void page_writeback_init(void);
152 void balance_dirty_pages_ratelimited_nr(struct address_space *mapping,
153 unsigned long nr_pages_dirtied);
155 static inline void
156 balance_dirty_pages_ratelimited(struct address_space *mapping)
158 balance_dirty_pages_ratelimited_nr(mapping, 1);
161 typedef int (*writepage_t)(struct page *page, struct writeback_control *wbc,
162 void *data);
164 int generic_writepages(struct address_space *mapping,
165 struct writeback_control *wbc);
166 void tag_pages_for_writeback(struct address_space *mapping,
167 pgoff_t start, pgoff_t end);
168 int write_cache_pages(struct address_space *mapping,
169 struct writeback_control *wbc, writepage_t writepage,
170 void *data);
171 int do_writepages(struct address_space *mapping, struct writeback_control *wbc);
172 void set_page_dirty_balance(struct page *page, int page_mkwrite);
173 void writeback_set_ratelimit(void);
174 void tag_pages_for_writeback(struct address_space *mapping,
175 pgoff_t start, pgoff_t end);
177 /* pdflush.c */
178 extern int nr_pdflush_threads; /* Global so it can be exported to sysctl
179 read-only. */
182 #endif /* WRITEBACK_H */