diff options
Diffstat (limited to 'include/linux/backing-dev.h')
-rw-r--r-- | include/linux/backing-dev.h | 102 |
1 files changed, 80 insertions, 22 deletions
diff --git a/include/linux/backing-dev.h b/include/linux/backing-dev.h index 48a62baace58..0a24d5550eb3 100644 --- a/include/linux/backing-dev.h +++ b/include/linux/backing-dev.h | |||
@@ -11,9 +11,13 @@ | |||
11 | #include <linux/percpu_counter.h> | 11 | #include <linux/percpu_counter.h> |
12 | #include <linux/log2.h> | 12 | #include <linux/log2.h> |
13 | #include <linux/proportions.h> | 13 | #include <linux/proportions.h> |
14 | #include <linux/kernel.h> | ||
15 | #include <linux/fs.h> | ||
14 | #include <asm/atomic.h> | 16 | #include <asm/atomic.h> |
15 | 17 | ||
16 | struct page; | 18 | struct page; |
19 | struct device; | ||
20 | struct dentry; | ||
17 | 21 | ||
18 | /* | 22 | /* |
19 | * Bits in backing_dev_info.state | 23 | * Bits in backing_dev_info.state |
@@ -48,11 +52,26 @@ struct backing_dev_info { | |||
48 | 52 | ||
49 | struct prop_local_percpu completions; | 53 | struct prop_local_percpu completions; |
50 | int dirty_exceeded; | 54 | int dirty_exceeded; |
55 | |||
56 | unsigned int min_ratio; | ||
57 | unsigned int max_ratio, max_prop_frac; | ||
58 | |||
59 | struct device *dev; | ||
60 | |||
61 | #ifdef CONFIG_DEBUG_FS | ||
62 | struct dentry *debug_dir; | ||
63 | struct dentry *debug_stats; | ||
64 | #endif | ||
51 | }; | 65 | }; |
52 | 66 | ||
53 | int bdi_init(struct backing_dev_info *bdi); | 67 | int bdi_init(struct backing_dev_info *bdi); |
54 | void bdi_destroy(struct backing_dev_info *bdi); | 68 | void bdi_destroy(struct backing_dev_info *bdi); |
55 | 69 | ||
70 | int bdi_register(struct backing_dev_info *bdi, struct device *parent, | ||
71 | const char *fmt, ...); | ||
72 | int bdi_register_dev(struct backing_dev_info *bdi, dev_t dev); | ||
73 | void bdi_unregister(struct backing_dev_info *bdi); | ||
74 | |||
56 | static inline void __add_bdi_stat(struct backing_dev_info *bdi, | 75 | static inline void __add_bdi_stat(struct backing_dev_info *bdi, |
57 | enum bdi_stat_item item, s64 amount) | 76 | enum bdi_stat_item item, s64 amount) |
58 | { | 77 | { |
@@ -116,6 +135,8 @@ static inline s64 bdi_stat_sum(struct backing_dev_info *bdi, | |||
116 | return sum; | 135 | return sum; |
117 | } | 136 | } |
118 | 137 | ||
138 | extern void bdi_writeout_inc(struct backing_dev_info *bdi); | ||
139 | |||
119 | /* | 140 | /* |
120 | * maximal error of a stat counter. | 141 | * maximal error of a stat counter. |
121 | */ | 142 | */ |
@@ -128,24 +149,48 @@ static inline unsigned long bdi_stat_error(struct backing_dev_info *bdi) | |||
128 | #endif | 149 | #endif |
129 | } | 150 | } |
130 | 151 | ||
152 | int bdi_set_min_ratio(struct backing_dev_info *bdi, unsigned int min_ratio); | ||
153 | int bdi_set_max_ratio(struct backing_dev_info *bdi, unsigned int max_ratio); | ||
154 | |||
131 | /* | 155 | /* |
132 | * Flags in backing_dev_info::capability | 156 | * Flags in backing_dev_info::capability |
133 | * - The first two flags control whether dirty pages will contribute to the | 157 | * |
134 | * VM's accounting and whether writepages() should be called for dirty pages | 158 | * The first three flags control whether dirty pages will contribute to the |
135 | * (something that would not, for example, be appropriate for ramfs) | 159 | * VM's accounting and whether writepages() should be called for dirty pages |
136 | * - These flags let !MMU mmap() govern direct device mapping vs immediate | 160 | * (something that would not, for example, be appropriate for ramfs) |
137 | * copying more easily for MAP_PRIVATE, especially for ROM filesystems | 161 | * |
162 | * WARNING: these flags are closely related and should not normally be | ||
163 | * used separately. The BDI_CAP_NO_ACCT_AND_WRITEBACK combines these | ||
164 | * three flags into a single convenience macro. | ||
165 | * | ||
166 | * BDI_CAP_NO_ACCT_DIRTY: Dirty pages shouldn't contribute to accounting | ||
167 | * BDI_CAP_NO_WRITEBACK: Don't write pages back | ||
168 | * BDI_CAP_NO_ACCT_WB: Don't automatically account writeback pages | ||
169 | * | ||
170 | * These flags let !MMU mmap() govern direct device mapping vs immediate | ||
171 | * copying more easily for MAP_PRIVATE, especially for ROM filesystems. | ||
172 | * | ||
173 | * BDI_CAP_MAP_COPY: Copy can be mapped (MAP_PRIVATE) | ||
174 | * BDI_CAP_MAP_DIRECT: Can be mapped directly (MAP_SHARED) | ||
175 | * BDI_CAP_READ_MAP: Can be mapped for reading | ||
176 | * BDI_CAP_WRITE_MAP: Can be mapped for writing | ||
177 | * BDI_CAP_EXEC_MAP: Can be mapped for execution | ||
138 | */ | 178 | */ |
139 | #define BDI_CAP_NO_ACCT_DIRTY 0x00000001 /* Dirty pages shouldn't contribute to accounting */ | 179 | #define BDI_CAP_NO_ACCT_DIRTY 0x00000001 |
140 | #define BDI_CAP_NO_WRITEBACK 0x00000002 /* Don't write pages back */ | 180 | #define BDI_CAP_NO_WRITEBACK 0x00000002 |
141 | #define BDI_CAP_MAP_COPY 0x00000004 /* Copy can be mapped (MAP_PRIVATE) */ | 181 | #define BDI_CAP_MAP_COPY 0x00000004 |
142 | #define BDI_CAP_MAP_DIRECT 0x00000008 /* Can be mapped directly (MAP_SHARED) */ | 182 | #define BDI_CAP_MAP_DIRECT 0x00000008 |
143 | #define BDI_CAP_READ_MAP 0x00000010 /* Can be mapped for reading */ | 183 | #define BDI_CAP_READ_MAP 0x00000010 |
144 | #define BDI_CAP_WRITE_MAP 0x00000020 /* Can be mapped for writing */ | 184 | #define BDI_CAP_WRITE_MAP 0x00000020 |
145 | #define BDI_CAP_EXEC_MAP 0x00000040 /* Can be mapped for execution */ | 185 | #define BDI_CAP_EXEC_MAP 0x00000040 |
186 | #define BDI_CAP_NO_ACCT_WB 0x00000080 | ||
187 | |||
146 | #define BDI_CAP_VMFLAGS \ | 188 | #define BDI_CAP_VMFLAGS \ |
147 | (BDI_CAP_READ_MAP | BDI_CAP_WRITE_MAP | BDI_CAP_EXEC_MAP) | 189 | (BDI_CAP_READ_MAP | BDI_CAP_WRITE_MAP | BDI_CAP_EXEC_MAP) |
148 | 190 | ||
191 | #define BDI_CAP_NO_ACCT_AND_WRITEBACK \ | ||
192 | (BDI_CAP_NO_WRITEBACK | BDI_CAP_NO_ACCT_DIRTY | BDI_CAP_NO_ACCT_WB) | ||
193 | |||
149 | #if defined(VM_MAYREAD) && \ | 194 | #if defined(VM_MAYREAD) && \ |
150 | (BDI_CAP_READ_MAP != VM_MAYREAD || \ | 195 | (BDI_CAP_READ_MAP != VM_MAYREAD || \ |
151 | BDI_CAP_WRITE_MAP != VM_MAYWRITE || \ | 196 | BDI_CAP_WRITE_MAP != VM_MAYWRITE || \ |
@@ -156,9 +201,7 @@ static inline unsigned long bdi_stat_error(struct backing_dev_info *bdi) | |||
156 | extern struct backing_dev_info default_backing_dev_info; | 201 | extern struct backing_dev_info default_backing_dev_info; |
157 | void default_unplug_io_fn(struct backing_dev_info *bdi, struct page *page); | 202 | void default_unplug_io_fn(struct backing_dev_info *bdi, struct page *page); |
158 | 203 | ||
159 | int writeback_acquire(struct backing_dev_info *bdi); | ||
160 | int writeback_in_progress(struct backing_dev_info *bdi); | 204 | int writeback_in_progress(struct backing_dev_info *bdi); |
161 | void writeback_release(struct backing_dev_info *bdi); | ||
162 | 205 | ||
163 | static inline int bdi_congested(struct backing_dev_info *bdi, int bdi_bits) | 206 | static inline int bdi_congested(struct backing_dev_info *bdi, int bdi_bits) |
164 | { | 207 | { |
@@ -187,17 +230,32 @@ void clear_bdi_congested(struct backing_dev_info *bdi, int rw); | |||
187 | void set_bdi_congested(struct backing_dev_info *bdi, int rw); | 230 | void set_bdi_congested(struct backing_dev_info *bdi, int rw); |
188 | long congestion_wait(int rw, long timeout); | 231 | long congestion_wait(int rw, long timeout); |
189 | 232 | ||
190 | #define bdi_cap_writeback_dirty(bdi) \ | ||
191 | (!((bdi)->capabilities & BDI_CAP_NO_WRITEBACK)) | ||
192 | 233 | ||
193 | #define bdi_cap_account_dirty(bdi) \ | 234 | static inline bool bdi_cap_writeback_dirty(struct backing_dev_info *bdi) |
194 | (!((bdi)->capabilities & BDI_CAP_NO_ACCT_DIRTY)) | 235 | { |
236 | return !(bdi->capabilities & BDI_CAP_NO_WRITEBACK); | ||
237 | } | ||
238 | |||
239 | static inline bool bdi_cap_account_dirty(struct backing_dev_info *bdi) | ||
240 | { | ||
241 | return !(bdi->capabilities & BDI_CAP_NO_ACCT_DIRTY); | ||
242 | } | ||
195 | 243 | ||
196 | #define mapping_cap_writeback_dirty(mapping) \ | 244 | static inline bool bdi_cap_account_writeback(struct backing_dev_info *bdi) |
197 | bdi_cap_writeback_dirty((mapping)->backing_dev_info) | 245 | { |
246 | /* Paranoia: BDI_CAP_NO_WRITEBACK implies BDI_CAP_NO_ACCT_WB */ | ||
247 | return !(bdi->capabilities & (BDI_CAP_NO_ACCT_WB | | ||
248 | BDI_CAP_NO_WRITEBACK)); | ||
249 | } | ||
198 | 250 | ||
199 | #define mapping_cap_account_dirty(mapping) \ | 251 | static inline bool mapping_cap_writeback_dirty(struct address_space *mapping) |
200 | bdi_cap_account_dirty((mapping)->backing_dev_info) | 252 | { |
253 | return bdi_cap_writeback_dirty(mapping->backing_dev_info); | ||
254 | } | ||
201 | 255 | ||
256 | static inline bool mapping_cap_account_dirty(struct address_space *mapping) | ||
257 | { | ||
258 | return bdi_cap_account_dirty(mapping->backing_dev_info); | ||
259 | } | ||
202 | 260 | ||
203 | #endif /* _LINUX_BACKING_DEV_H */ | 261 | #endif /* _LINUX_BACKING_DEV_H */ |