|
12 | 12 | #include <linux/log2.h> |
13 | 13 | #include <linux/proportions.h> |
14 | 14 | #include <linux/kernel.h> |
| 15 | +#include <linux/fs.h> |
15 | 16 | #include <asm/atomic.h> |
16 | 17 |
|
17 | 18 | struct page; |
@@ -151,22 +152,43 @@ int bdi_set_max_ratio(struct backing_dev_info *bdi, unsigned int max_ratio); |
151 | 152 |
|
152 | 153 | /* |
153 | 154 | * Flags in backing_dev_info::capability |
154 | | - * - The first two flags control whether dirty pages will contribute to the |
155 | | - * VM's accounting and whether writepages() should be called for dirty pages |
156 | | - * (something that would not, for example, be appropriate for ramfs) |
157 | | - * - These flags let !MMU mmap() govern direct device mapping vs immediate |
158 | | - * copying more easily for MAP_PRIVATE, especially for ROM filesystems |
| 155 | + * |
| 156 | + * The first three flags control whether dirty pages will contribute to the |
| 157 | + * VM's accounting and whether writepages() should be called for dirty pages |
| 158 | + * (something that would not, for example, be appropriate for ramfs) |
| 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 */ |
161 | | -#define BDI_CAP_NO_WRITEBACK 0x00000002 /* Don't write pages back */ |
162 | | -#define BDI_CAP_MAP_COPY 0x00000004 /* Copy can be mapped (MAP_PRIVATE) */ |
163 | | -#define BDI_CAP_MAP_DIRECT 0x00000008 /* Can be mapped directly (MAP_SHARED) */ |
164 | | -#define BDI_CAP_READ_MAP 0x00000010 /* Can be mapped for reading */ |
165 | | -#define BDI_CAP_WRITE_MAP 0x00000020 /* Can be mapped for writing */ |
166 | | -#define BDI_CAP_EXEC_MAP 0x00000040 /* Can be mapped for execution */ |
| 177 | +#define BDI_CAP_NO_ACCT_DIRTY 0x00000001 |
| 178 | +#define BDI_CAP_NO_WRITEBACK 0x00000002 |
| 179 | +#define BDI_CAP_MAP_COPY 0x00000004 |
| 180 | +#define BDI_CAP_MAP_DIRECT 0x00000008 |
| 181 | +#define BDI_CAP_READ_MAP 0x00000010 |
| 182 | +#define BDI_CAP_WRITE_MAP 0x00000020 |
| 183 | +#define BDI_CAP_EXEC_MAP 0x00000040 |
| 184 | +#define BDI_CAP_NO_ACCT_WB 0x00000080 |
| 185 | + |
167 | 186 | #define BDI_CAP_VMFLAGS \ |
168 | 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 | 192 | #if defined(VM_MAYREAD) && \ |
171 | 193 | (BDI_CAP_READ_MAP != VM_MAYREAD || \ |
172 | 194 | BDI_CAP_WRITE_MAP != VM_MAYWRITE || \ |
@@ -206,17 +228,32 @@ void clear_bdi_congested(struct backing_dev_info *bdi, int rw); |
206 | 228 | void set_bdi_congested(struct backing_dev_info *bdi, int rw); |
207 | 229 | long 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) \ |
213 | | - (!((bdi)->capabilities & BDI_CAP_NO_ACCT_DIRTY)) |
| 232 | +static inline bool bdi_cap_writeback_dirty(struct backing_dev_info *bdi) |
| 233 | +{ |
| 234 | + return !(bdi->capabilities & BDI_CAP_NO_WRITEBACK); |
| 235 | +} |
| 236 | + |
| 237 | +static 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) \ |
216 | | - bdi_cap_writeback_dirty((mapping)->backing_dev_info) |
| 242 | +static inline bool bdi_cap_account_writeback(struct backing_dev_info *bdi) |
| 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) \ |
219 | | - bdi_cap_account_dirty((mapping)->backing_dev_info) |
| 249 | +static inline bool mapping_cap_writeback_dirty(struct address_space *mapping) |
| 250 | +{ |
| 251 | + return bdi_cap_writeback_dirty(mapping->backing_dev_info); |
| 252 | +} |
220 | 253 |
|
| 254 | +static 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 | 259 | #endif /* _LINUX_BACKING_DEV_H */ |
0 commit comments