aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/writeback.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/writeback.h')
-rw-r--r--include/linux/writeback.h70
1 files changed, 34 insertions, 36 deletions
diff --git a/include/linux/writeback.h b/include/linux/writeback.h
index b82a83aba31..2b8963ff0f3 100644
--- a/include/linux/writeback.h
+++ b/include/linux/writeback.h
@@ -7,8 +7,6 @@
7#include <linux/sched.h> 7#include <linux/sched.h>
8#include <linux/fs.h> 8#include <linux/fs.h>
9 9
10DECLARE_PER_CPU(int, dirty_throttle_leaks);
11
12/* 10/*
13 * The 1/4 region under the global dirty thresh is for smooth dirty throttling: 11 * The 1/4 region under the global dirty thresh is for smooth dirty throttling:
14 * 12 *
@@ -25,6 +23,11 @@ DECLARE_PER_CPU(int, dirty_throttle_leaks);
25#define DIRTY_SCOPE 8 23#define DIRTY_SCOPE 8
26#define DIRTY_FULL_SCOPE (DIRTY_SCOPE / 2) 24#define DIRTY_FULL_SCOPE (DIRTY_SCOPE / 2)
27 25
26/*
27 * 4MB minimal write chunk size
28 */
29#define MIN_WRITEBACK_PAGES (4096UL >> (PAGE_CACHE_SHIFT - 10))
30
28struct backing_dev_info; 31struct backing_dev_info;
29 32
30/* 33/*
@@ -36,42 +39,24 @@ enum writeback_sync_modes {
36}; 39};
37 40
38/* 41/*
39 * why some writeback work was initiated
40 */
41enum wb_reason {
42 WB_REASON_BACKGROUND,
43 WB_REASON_TRY_TO_FREE_PAGES,
44 WB_REASON_SYNC,
45 WB_REASON_PERIODIC,
46 WB_REASON_LAPTOP_TIMER,
47 WB_REASON_FREE_MORE_MEM,
48 WB_REASON_FS_FREE_SPACE,
49 WB_REASON_FORKER_THREAD,
50
51 WB_REASON_MAX,
52};
53extern const char *wb_reason_name[];
54
55/*
56 * A control structure which tells the writeback code what to do. These are 42 * A control structure which tells the writeback code what to do. These are
57 * always on the stack, and hence need no locking. They are always initialised 43 * always on the stack, and hence need no locking. They are always initialised
58 * in a manner such that unspecified fields are set to zero. 44 * in a manner such that unspecified fields are set to zero.
59 */ 45 */
60struct writeback_control { 46struct writeback_control {
47 enum writeback_sync_modes sync_mode;
61 long nr_to_write; /* Write this many pages, and decrement 48 long nr_to_write; /* Write this many pages, and decrement
62 this for each page written */ 49 this for each page written */
63 long pages_skipped; /* Pages which were not written */ 50 long pages_skipped; /* Pages which were not written */
64 51
65 /* 52 /*
66 * For a_ops->writepages(): if start or end are non-zero then this is 53 * For a_ops->writepages(): is start or end are non-zero then this is
67 * a hint that the filesystem need only write out the pages inside that 54 * a hint that the filesystem need only write out the pages inside that
68 * byterange. The byte at `end' is included in the writeout request. 55 * byterange. The byte at `end' is included in the writeout request.
69 */ 56 */
70 loff_t range_start; 57 loff_t range_start;
71 loff_t range_end; 58 loff_t range_end;
72 59
73 enum writeback_sync_modes sync_mode;
74
75 unsigned for_kupdate:1; /* A kupdate writeback */ 60 unsigned for_kupdate:1; /* A kupdate writeback */
76 unsigned for_background:1; /* A background writeback */ 61 unsigned for_background:1; /* A background writeback */
77 unsigned tagged_writepages:1; /* tag-and-write to avoid livelock */ 62 unsigned tagged_writepages:1; /* tag-and-write to avoid livelock */
@@ -84,18 +69,14 @@ struct writeback_control {
84 */ 69 */
85struct bdi_writeback; 70struct bdi_writeback;
86int inode_wait(void *); 71int inode_wait(void *);
87void writeback_inodes_sb(struct super_block *, enum wb_reason reason); 72void writeback_inodes_sb(struct super_block *);
88void writeback_inodes_sb_nr(struct super_block *, unsigned long nr, 73void writeback_inodes_sb_nr(struct super_block *, unsigned long nr);
89 enum wb_reason reason); 74int writeback_inodes_sb_if_idle(struct super_block *);
90int writeback_inodes_sb_if_idle(struct super_block *, enum wb_reason reason); 75int writeback_inodes_sb_nr_if_idle(struct super_block *, unsigned long nr);
91int writeback_inodes_sb_nr_if_idle(struct super_block *, unsigned long nr,
92 enum wb_reason reason);
93void sync_inodes_sb(struct super_block *); 76void sync_inodes_sb(struct super_block *);
94long writeback_inodes_wb(struct bdi_writeback *wb, long nr_pages, 77long writeback_inodes_wb(struct bdi_writeback *wb, long nr_pages);
95 enum wb_reason reason);
96long wb_do_writeback(struct bdi_writeback *wb, int force_wait); 78long wb_do_writeback(struct bdi_writeback *wb, int force_wait);
97void wakeup_flusher_threads(long nr_pages, enum wb_reason reason); 79void wakeup_flusher_threads(long nr_pages);
98void inode_wait_for_writeback(struct inode *inode);
99 80
100/* writeback.h requires fs.h; it, too, is not included from here. */ 81/* writeback.h requires fs.h; it, too, is not included from here. */
101static inline void wait_on_inode(struct inode *inode) 82static inline void wait_on_inode(struct inode *inode)
@@ -103,6 +84,13 @@ static inline void wait_on_inode(struct inode *inode)
103 might_sleep(); 84 might_sleep();
104 wait_on_bit(&inode->i_state, __I_NEW, inode_wait, TASK_UNINTERRUPTIBLE); 85 wait_on_bit(&inode->i_state, __I_NEW, inode_wait, TASK_UNINTERRUPTIBLE);
105} 86}
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
106 94
107/* 95/*
108 * mm/page-writeback.c 96 * mm/page-writeback.c
@@ -116,7 +104,6 @@ void laptop_mode_timer_fn(unsigned long data);
116static inline void laptop_sync_completion(void) { } 104static inline void laptop_sync_completion(void) { }
117#endif 105#endif
118void throttle_vm_writeout(gfp_t gfp_mask); 106void throttle_vm_writeout(gfp_t gfp_mask);
119bool zone_dirty_ok(struct zone *zone);
120 107
121extern unsigned long global_dirty_limit; 108extern unsigned long global_dirty_limit;
122 109
@@ -131,6 +118,8 @@ extern int vm_highmem_is_dirtyable;
131extern int block_dump; 118extern int block_dump;
132extern int laptop_mode; 119extern int laptop_mode;
133 120
121extern unsigned long determine_dirtyable_memory(void);
122
134extern int dirty_background_ratio_handler(struct ctl_table *table, int write, 123extern int dirty_background_ratio_handler(struct ctl_table *table, int write,
135 void __user *buffer, size_t *lenp, 124 void __user *buffer, size_t *lenp,
136 loff_t *ppos); 125 loff_t *ppos);
@@ -154,14 +143,20 @@ unsigned long bdi_dirty_limit(struct backing_dev_info *bdi,
154 143
155void __bdi_update_bandwidth(struct backing_dev_info *bdi, 144void __bdi_update_bandwidth(struct backing_dev_info *bdi,
156 unsigned long thresh, 145 unsigned long thresh,
157 unsigned long bg_thresh,
158 unsigned long dirty, 146 unsigned long dirty,
159 unsigned long bdi_thresh, 147 unsigned long bdi_thresh,
160 unsigned long bdi_dirty, 148 unsigned long bdi_dirty,
161 unsigned long start_time); 149 unsigned long start_time);
162 150
163void page_writeback_init(void); 151void page_writeback_init(void);
164void balance_dirty_pages_ratelimited(struct address_space *mapping); 152void balance_dirty_pages_ratelimited_nr(struct address_space *mapping,
153 unsigned long nr_pages_dirtied);
154
155static inline void
156balance_dirty_pages_ratelimited(struct address_space *mapping)
157{
158 balance_dirty_pages_ratelimited_nr(mapping, 1);
159}
165 160
166typedef int (*writepage_t)(struct page *page, struct writeback_control *wbc, 161typedef int (*writepage_t)(struct page *page, struct writeback_control *wbc,
167 void *data); 162 void *data);
@@ -179,6 +174,9 @@ void writeback_set_ratelimit(void);
179void tag_pages_for_writeback(struct address_space *mapping, 174void tag_pages_for_writeback(struct address_space *mapping,
180 pgoff_t start, pgoff_t end); 175 pgoff_t start, pgoff_t end);
181 176
182void account_page_redirty(struct page *page); 177/* pdflush.c */
178extern int nr_pdflush_threads; /* Global so it can be exported to sysctl
179 read-only. */
180
183 181
184#endif /* WRITEBACK_H */ 182#endif /* WRITEBACK_H */