aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorMiklos Szeredi <mszeredi@suse.cz>2008-04-30 03:54:37 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-04-30 11:29:50 -0400
commite4ad08fe64afca4ef79ecc4c624e6e871688da0d (patch)
tree5b8b390b874700041dc0c095e8ba9ac3ed42ea77 /include
parent76f1418b485da2707531178e517bbb5cf06b3c76 (diff)
mm: bdi: add separate writeback accounting capability
Add a new BDI capability flag: BDI_CAP_NO_ACCT_WB. If this flag is set, then don't update the per-bdi writeback stats from test_set_page_writeback() and test_clear_page_writeback(). Misc cleanups: - convert bdi_cap_writeback_dirty() and friends to static inline functions - create a flag that includes all three dirty/writeback related flags, since almst all users will want to have them toghether Signed-off-by: Miklos Szeredi <mszeredi@suse.cz> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include')
-rw-r--r--include/linux/backing-dev.h77
1 files changed, 57 insertions, 20 deletions
diff --git a/include/linux/backing-dev.h b/include/linux/backing-dev.h
index c49a2d045e11..13ab79d99268 100644
--- a/include/linux/backing-dev.h
+++ b/include/linux/backing-dev.h
@@ -12,6 +12,7 @@
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> 14#include <linux/kernel.h>
15#include <linux/fs.h>
15#include <asm/atomic.h> 16#include <asm/atomic.h>
16 17
17struct page; 18struct page;
@@ -151,22 +152,43 @@ int bdi_set_max_ratio(struct backing_dev_info *bdi, unsigned int max_ratio);
151 152
152/* 153/*
153 * Flags in backing_dev_info::capability 154 * Flags in backing_dev_info::capability
154 * - The first two flags control whether dirty pages will contribute to the 155 *
155 * VM's accounting and whether writepages() should be called for dirty pages 156 * The first three flags control whether dirty pages will contribute to the
156 * (something that would not, for example, be appropriate for ramfs) 157 * VM's accounting and whether writepages() should be called for dirty pages
157 * - These flags let !MMU mmap() govern direct device mapping vs immediate 158 * (something that would not, for example, be appropriate for ramfs)
158 * copying more easily for MAP_PRIVATE, especially for ROM filesystems 159 *
160 * WARNING: these flags are closely related and should not normally be
161 * used separately. The BDI_CAP_NO_ACCT_AND_WRITEBACK combines these
162 * three flags into a single convenience macro.
163 *
164 * BDI_CAP_NO_ACCT_DIRTY: Dirty pages shouldn't contribute to accounting
165 * BDI_CAP_NO_WRITEBACK: Don't write pages back
166 * BDI_CAP_NO_ACCT_WB: Don't automatically account writeback pages
167 *
168 * These flags let !MMU mmap() govern direct device mapping vs immediate
169 * copying more easily for MAP_PRIVATE, especially for ROM filesystems.
170 *
171 * BDI_CAP_MAP_COPY: Copy can be mapped (MAP_PRIVATE)
172 * BDI_CAP_MAP_DIRECT: Can be mapped directly (MAP_SHARED)
173 * BDI_CAP_READ_MAP: Can be mapped for reading
174 * BDI_CAP_WRITE_MAP: Can be mapped for writing
175 * BDI_CAP_EXEC_MAP: Can be mapped for execution
159 */ 176 */
160#define BDI_CAP_NO_ACCT_DIRTY 0x00000001 /* Dirty pages shouldn't contribute to accounting */ 177#define BDI_CAP_NO_ACCT_DIRTY 0x00000001
161#define BDI_CAP_NO_WRITEBACK 0x00000002 /* Don't write pages back */ 178#define BDI_CAP_NO_WRITEBACK 0x00000002
162#define BDI_CAP_MAP_COPY 0x00000004 /* Copy can be mapped (MAP_PRIVATE) */ 179#define BDI_CAP_MAP_COPY 0x00000004
163#define BDI_CAP_MAP_DIRECT 0x00000008 /* Can be mapped directly (MAP_SHARED) */ 180#define BDI_CAP_MAP_DIRECT 0x00000008
164#define BDI_CAP_READ_MAP 0x00000010 /* Can be mapped for reading */ 181#define BDI_CAP_READ_MAP 0x00000010
165#define BDI_CAP_WRITE_MAP 0x00000020 /* Can be mapped for writing */ 182#define BDI_CAP_WRITE_MAP 0x00000020
166#define BDI_CAP_EXEC_MAP 0x00000040 /* Can be mapped for execution */ 183#define BDI_CAP_EXEC_MAP 0x00000040
184#define BDI_CAP_NO_ACCT_WB 0x00000080
185
167#define BDI_CAP_VMFLAGS \ 186#define BDI_CAP_VMFLAGS \
168 (BDI_CAP_READ_MAP | BDI_CAP_WRITE_MAP | BDI_CAP_EXEC_MAP) 187 (BDI_CAP_READ_MAP | BDI_CAP_WRITE_MAP | BDI_CAP_EXEC_MAP)
169 188
189#define BDI_CAP_NO_ACCT_AND_WRITEBACK \
190 (BDI_CAP_NO_WRITEBACK | BDI_CAP_NO_ACCT_DIRTY | BDI_CAP_NO_ACCT_WB)
191
170#if defined(VM_MAYREAD) && \ 192#if defined(VM_MAYREAD) && \
171 (BDI_CAP_READ_MAP != VM_MAYREAD || \ 193 (BDI_CAP_READ_MAP != VM_MAYREAD || \
172 BDI_CAP_WRITE_MAP != VM_MAYWRITE || \ 194 BDI_CAP_WRITE_MAP != VM_MAYWRITE || \
@@ -206,17 +228,32 @@ void clear_bdi_congested(struct backing_dev_info *bdi, int rw);
206void set_bdi_congested(struct backing_dev_info *bdi, int rw); 228void set_bdi_congested(struct backing_dev_info *bdi, int rw);
207long congestion_wait(int rw, long timeout); 229long congestion_wait(int rw, long timeout);
208 230
209#define bdi_cap_writeback_dirty(bdi) \
210 (!((bdi)->capabilities & BDI_CAP_NO_WRITEBACK))
211 231
212#define bdi_cap_account_dirty(bdi) \ 232static inline bool bdi_cap_writeback_dirty(struct backing_dev_info *bdi)
213 (!((bdi)->capabilities & BDI_CAP_NO_ACCT_DIRTY)) 233{
234 return !(bdi->capabilities & BDI_CAP_NO_WRITEBACK);
235}
236
237static inline bool bdi_cap_account_dirty(struct backing_dev_info *bdi)
238{
239 return !(bdi->capabilities & BDI_CAP_NO_ACCT_DIRTY);
240}
214 241
215#define mapping_cap_writeback_dirty(mapping) \ 242static inline bool bdi_cap_account_writeback(struct backing_dev_info *bdi)
216 bdi_cap_writeback_dirty((mapping)->backing_dev_info) 243{
244 /* Paranoia: BDI_CAP_NO_WRITEBACK implies BDI_CAP_NO_ACCT_WB */
245 return !(bdi->capabilities & (BDI_CAP_NO_ACCT_WB |
246 BDI_CAP_NO_WRITEBACK));
247}
217 248
218#define mapping_cap_account_dirty(mapping) \ 249static inline bool mapping_cap_writeback_dirty(struct address_space *mapping)
219 bdi_cap_account_dirty((mapping)->backing_dev_info) 250{
251 return bdi_cap_writeback_dirty(mapping->backing_dev_info);
252}
220 253
254static inline bool mapping_cap_account_dirty(struct address_space *mapping)
255{
256 return bdi_cap_account_dirty(mapping->backing_dev_info);
257}
221 258
222#endif /* _LINUX_BACKING_DEV_H */ 259#endif /* _LINUX_BACKING_DEV_H */