Blame view
include/linux/writeback.h
5.79 KB
1da177e4c
|
1 |
/* |
f30c22695
|
2 |
* include/linux/writeback.h |
1da177e4c
|
3 4 5 |
*/ #ifndef WRITEBACK_H #define WRITEBACK_H |
e8edc6e03
|
6 |
#include <linux/sched.h> |
f5ff8422b
|
7 |
#include <linux/fs.h> |
e8edc6e03
|
8 |
|
ffd1f609a
|
9 |
/* |
1a12d8bd7
|
10 11 12 13 |
* The 1/4 region under the global dirty thresh is for smooth dirty throttling: * * (thresh - thresh/DIRTY_FULL_SCOPE, thresh) * |
ffd1f609a
|
14 15 16 17 18 19 20 21 |
* Further beyond, all dirtier tasks will enter a loop waiting (possibly long * time) for the dirty pages to drop, unless written enough pages. * * The global dirty threshold is normally equal to the global dirty limit, * except when the system suddenly allocates a lot of anonymous memory and * knocks down the global dirty threshold quickly, in which case the global * dirty limit will follow down slowly to prevent livelocking all dirtier tasks. */ |
1a12d8bd7
|
22 23 |
#define DIRTY_SCOPE 8 #define DIRTY_FULL_SCOPE (DIRTY_SCOPE / 2) |
ffd1f609a
|
24 |
|
1a12d8bd7
|
25 26 27 28 |
/* * 4MB minimal write chunk size */ #define MIN_WRITEBACK_PAGES (4096UL >> (PAGE_CACHE_SHIFT - 10)) |
1da177e4c
|
29 |
struct backing_dev_info; |
1da177e4c
|
30 |
/* |
1da177e4c
|
31 32 33 34 35 |
* fs/fs-writeback.c */ enum writeback_sync_modes { WB_SYNC_NONE, /* Don't wait on anything */ WB_SYNC_ALL, /* Wait on every mapping */ |
1da177e4c
|
36 37 38 39 40 41 42 43 |
}; /* * A control structure which tells the writeback code what to do. These are * always on the stack, and hence need no locking. They are always initialised * in a manner such that unspecified fields are set to zero. */ struct writeback_control { |
1da177e4c
|
44 |
enum writeback_sync_modes sync_mode; |
1da177e4c
|
45 46 47 48 49 50 51 52 53 |
long nr_to_write; /* Write this many pages, and decrement this for each page written */ long pages_skipped; /* Pages which were not written */ /* * For a_ops->writepages(): is start or end are non-zero then this is * a hint that the filesystem need only write out the pages inside that * byterange. The byte at `end' is included in the writeout request. */ |
111ebb6e6
|
54 55 |
loff_t range_start; loff_t range_end; |
1da177e4c
|
56 |
|
22905f775
|
57 |
unsigned for_kupdate:1; /* A kupdate writeback */ |
b17621fed
|
58 |
unsigned for_background:1; /* A background writeback */ |
6e6938b6d
|
59 |
unsigned tagged_writepages:1; /* tag-and-write to avoid livelock */ |
22905f775
|
60 |
unsigned for_reclaim:1; /* Invoked from the page allocator */ |
111ebb6e6
|
61 |
unsigned range_cyclic:1; /* range_start is cyclic */ |
1da177e4c
|
62 63 64 |
}; /* |
1da177e4c
|
65 66 |
* fs/fs-writeback.c */ |
03ba3782e
|
67 |
struct bdi_writeback; |
1da177e4c
|
68 |
int inode_wait(void *); |
b6e51316d
|
69 |
void writeback_inodes_sb(struct super_block *); |
3259f8bed
|
70 |
void writeback_inodes_sb_nr(struct super_block *, unsigned long nr); |
17bd55d03
|
71 |
int writeback_inodes_sb_if_idle(struct super_block *); |
3259f8bed
|
72 |
int writeback_inodes_sb_nr_if_idle(struct super_block *, unsigned long nr); |
b6e51316d
|
73 |
void sync_inodes_sb(struct super_block *); |
d46db3d58
|
74 |
long writeback_inodes_wb(struct bdi_writeback *wb, long nr_pages); |
03ba3782e
|
75 76 |
long wb_do_writeback(struct bdi_writeback *wb, int force_wait); void wakeup_flusher_threads(long nr_pages); |
1da177e4c
|
77 78 79 80 81 |
/* writeback.h requires fs.h; it, too, is not included from here. */ static inline void wait_on_inode(struct inode *inode) { might_sleep(); |
eaff8079d
|
82 |
wait_on_bit(&inode->i_state, __I_NEW, inode_wait, TASK_UNINTERRUPTIBLE); |
1da177e4c
|
83 |
} |
1c0eeaf56
|
84 85 86 87 88 89 |
static inline void inode_sync_wait(struct inode *inode) { might_sleep(); wait_on_bit(&inode->i_state, __I_SYNC, inode_wait, TASK_UNINTERRUPTIBLE); } |
1da177e4c
|
90 91 92 93 |
/* * mm/page-writeback.c */ |
c2c4986ed
|
94 |
#ifdef CONFIG_BLOCK |
31373d09d
|
95 |
void laptop_io_completion(struct backing_dev_info *info); |
1da177e4c
|
96 |
void laptop_sync_completion(void); |
31373d09d
|
97 98 |
void laptop_mode_sync(struct work_struct *work); void laptop_mode_timer_fn(unsigned long data); |
c2c4986ed
|
99 100 101 |
#else static inline void laptop_sync_completion(void) { } #endif |
232ea4d69
|
102 |
void throttle_vm_writeout(gfp_t gfp_mask); |
1da177e4c
|
103 |
|
c42843f2f
|
104 |
extern unsigned long global_dirty_limit; |
1da177e4c
|
105 106 |
/* These are exported to sysctl. */ extern int dirty_background_ratio; |
2da02997e
|
107 |
extern unsigned long dirty_background_bytes; |
1da177e4c
|
108 |
extern int vm_dirty_ratio; |
2da02997e
|
109 |
extern unsigned long vm_dirty_bytes; |
704503d83
|
110 111 |
extern unsigned int dirty_writeback_interval; extern unsigned int dirty_expire_interval; |
195cf453d
|
112 |
extern int vm_highmem_is_dirtyable; |
1da177e4c
|
113 114 |
extern int block_dump; extern int laptop_mode; |
3eefae994
|
115 |
extern unsigned long determine_dirtyable_memory(void); |
2da02997e
|
116 |
extern int dirty_background_ratio_handler(struct ctl_table *table, int write, |
8d65af789
|
117 |
void __user *buffer, size_t *lenp, |
2da02997e
|
118 119 |
loff_t *ppos); extern int dirty_background_bytes_handler(struct ctl_table *table, int write, |
8d65af789
|
120 |
void __user *buffer, size_t *lenp, |
2da02997e
|
121 |
loff_t *ppos); |
04fbfdc14
|
122 |
extern int dirty_ratio_handler(struct ctl_table *table, int write, |
8d65af789
|
123 |
void __user *buffer, size_t *lenp, |
04fbfdc14
|
124 |
loff_t *ppos); |
2da02997e
|
125 |
extern int dirty_bytes_handler(struct ctl_table *table, int write, |
8d65af789
|
126 |
void __user *buffer, size_t *lenp, |
2da02997e
|
127 |
loff_t *ppos); |
04fbfdc14
|
128 |
|
1da177e4c
|
129 |
struct ctl_table; |
8d65af789
|
130 |
int dirty_writeback_centisecs_handler(struct ctl_table *, int, |
1da177e4c
|
131 |
void __user *, size_t *, loff_t *); |
16c4042f0
|
132 133 134 |
void global_dirty_limits(unsigned long *pbackground, unsigned long *pdirty); unsigned long bdi_dirty_limit(struct backing_dev_info *bdi, unsigned long dirty); |
cf0ca9fe5
|
135 |
|
e98be2d59
|
136 |
void __bdi_update_bandwidth(struct backing_dev_info *bdi, |
c42843f2f
|
137 138 139 140 |
unsigned long thresh, unsigned long dirty, unsigned long bdi_thresh, unsigned long bdi_dirty, |
e98be2d59
|
141 |
unsigned long start_time); |
1da177e4c
|
142 |
void page_writeback_init(void); |
fa5a734e4
|
143 144 145 146 147 148 149 150 |
void balance_dirty_pages_ratelimited_nr(struct address_space *mapping, unsigned long nr_pages_dirtied); static inline void balance_dirty_pages_ratelimited(struct address_space *mapping) { balance_dirty_pages_ratelimited_nr(mapping, 1); } |
0ea971801
|
151 152 |
typedef int (*writepage_t)(struct page *page, struct writeback_control *wbc, void *data); |
0ea971801
|
153 154 |
int generic_writepages(struct address_space *mapping, struct writeback_control *wbc); |
5b41d9243
|
155 156 |
void tag_pages_for_writeback(struct address_space *mapping, pgoff_t start, pgoff_t end); |
0ea971801
|
157 158 159 |
int write_cache_pages(struct address_space *mapping, struct writeback_control *wbc, writepage_t writepage, void *data); |
1da177e4c
|
160 |
int do_writepages(struct address_space *mapping, struct writeback_control *wbc); |
a200ee182
|
161 |
void set_page_dirty_balance(struct page *page, int page_mkwrite); |
2d1d43f6a
|
162 |
void writeback_set_ratelimit(void); |
92c09c041
|
163 164 |
void tag_pages_for_writeback(struct address_space *mapping, pgoff_t start, pgoff_t end); |
1da177e4c
|
165 166 167 168 169 170 171 |
/* pdflush.c */ extern int nr_pdflush_threads; /* Global so it can be exported to sysctl read-only. */ #endif /* WRITEBACK_H */ |