diff options
-rw-r--r-- | include/linux/backing-dev.h | 13 | ||||
-rw-r--r-- | mm/madvise.c | 17 | ||||
-rw-r--r-- | mm/shmem.c | 25 | ||||
-rw-r--r-- | mm/swap.c | 2 | ||||
-rw-r--r-- | mm/swap_state.c | 7 |
5 files changed, 18 insertions, 46 deletions
diff --git a/include/linux/backing-dev.h b/include/linux/backing-dev.h index 5da6012b7a14..e936cea856dc 100644 --- a/include/linux/backing-dev.h +++ b/include/linux/backing-dev.h | |||
@@ -238,8 +238,6 @@ int bdi_set_max_ratio(struct backing_dev_info *bdi, unsigned int max_ratio); | |||
238 | * BDI_CAP_WRITE_MAP: Can be mapped for writing | 238 | * BDI_CAP_WRITE_MAP: Can be mapped for writing |
239 | * BDI_CAP_EXEC_MAP: Can be mapped for execution | 239 | * BDI_CAP_EXEC_MAP: Can be mapped for execution |
240 | * | 240 | * |
241 | * BDI_CAP_SWAP_BACKED: Count shmem/tmpfs objects as swap-backed. | ||
242 | * | ||
243 | * BDI_CAP_STRICTLIMIT: Keep number of dirty pages below bdi threshold. | 241 | * BDI_CAP_STRICTLIMIT: Keep number of dirty pages below bdi threshold. |
244 | */ | 242 | */ |
245 | #define BDI_CAP_NO_ACCT_DIRTY 0x00000001 | 243 | #define BDI_CAP_NO_ACCT_DIRTY 0x00000001 |
@@ -250,7 +248,6 @@ int bdi_set_max_ratio(struct backing_dev_info *bdi, unsigned int max_ratio); | |||
250 | #define BDI_CAP_WRITE_MAP 0x00000020 | 248 | #define BDI_CAP_WRITE_MAP 0x00000020 |
251 | #define BDI_CAP_EXEC_MAP 0x00000040 | 249 | #define BDI_CAP_EXEC_MAP 0x00000040 |
252 | #define BDI_CAP_NO_ACCT_WB 0x00000080 | 250 | #define BDI_CAP_NO_ACCT_WB 0x00000080 |
253 | #define BDI_CAP_SWAP_BACKED 0x00000100 | ||
254 | #define BDI_CAP_STABLE_WRITES 0x00000200 | 251 | #define BDI_CAP_STABLE_WRITES 0x00000200 |
255 | #define BDI_CAP_STRICTLIMIT 0x00000400 | 252 | #define BDI_CAP_STRICTLIMIT 0x00000400 |
256 | 253 | ||
@@ -329,11 +326,6 @@ static inline bool bdi_cap_account_writeback(struct backing_dev_info *bdi) | |||
329 | BDI_CAP_NO_WRITEBACK)); | 326 | BDI_CAP_NO_WRITEBACK)); |
330 | } | 327 | } |
331 | 328 | ||
332 | static inline bool bdi_cap_swap_backed(struct backing_dev_info *bdi) | ||
333 | { | ||
334 | return bdi->capabilities & BDI_CAP_SWAP_BACKED; | ||
335 | } | ||
336 | |||
337 | static inline bool mapping_cap_writeback_dirty(struct address_space *mapping) | 329 | static inline bool mapping_cap_writeback_dirty(struct address_space *mapping) |
338 | { | 330 | { |
339 | return bdi_cap_writeback_dirty(mapping->backing_dev_info); | 331 | return bdi_cap_writeback_dirty(mapping->backing_dev_info); |
@@ -344,11 +336,6 @@ static inline bool mapping_cap_account_dirty(struct address_space *mapping) | |||
344 | return bdi_cap_account_dirty(mapping->backing_dev_info); | 336 | return bdi_cap_account_dirty(mapping->backing_dev_info); |
345 | } | 337 | } |
346 | 338 | ||
347 | static inline bool mapping_cap_swap_backed(struct address_space *mapping) | ||
348 | { | ||
349 | return bdi_cap_swap_backed(mapping->backing_dev_info); | ||
350 | } | ||
351 | |||
352 | static inline int bdi_sched_wait(void *word) | 339 | static inline int bdi_sched_wait(void *word) |
353 | { | 340 | { |
354 | schedule(); | 341 | schedule(); |
diff --git a/mm/madvise.c b/mm/madvise.c index a271adc93289..1383a8916bc3 100644 --- a/mm/madvise.c +++ b/mm/madvise.c | |||
@@ -222,19 +222,22 @@ static long madvise_willneed(struct vm_area_struct *vma, | |||
222 | struct file *file = vma->vm_file; | 222 | struct file *file = vma->vm_file; |
223 | 223 | ||
224 | #ifdef CONFIG_SWAP | 224 | #ifdef CONFIG_SWAP |
225 | if (!file || mapping_cap_swap_backed(file->f_mapping)) { | 225 | if (!file) { |
226 | *prev = vma; | 226 | *prev = vma; |
227 | if (!file) | 227 | force_swapin_readahead(vma, start, end); |
228 | force_swapin_readahead(vma, start, end); | ||
229 | else | ||
230 | force_shm_swapin_readahead(vma, start, end, | ||
231 | file->f_mapping); | ||
232 | return 0; | 228 | return 0; |
233 | } | 229 | } |
234 | #endif | ||
235 | 230 | ||
231 | if (shmem_mapping(file->f_mapping)) { | ||
232 | *prev = vma; | ||
233 | force_shm_swapin_readahead(vma, start, end, | ||
234 | file->f_mapping); | ||
235 | return 0; | ||
236 | } | ||
237 | #else | ||
236 | if (!file) | 238 | if (!file) |
237 | return -EBADF; | 239 | return -EBADF; |
240 | #endif | ||
238 | 241 | ||
239 | if (file->f_mapping->a_ops->get_xip_mem) { | 242 | if (file->f_mapping->a_ops->get_xip_mem) { |
240 | /* no bad return value, but ignore advice */ | 243 | /* no bad return value, but ignore advice */ |
diff --git a/mm/shmem.c b/mm/shmem.c index 73ba1df7c8ba..1b77eaf589fd 100644 --- a/mm/shmem.c +++ b/mm/shmem.c | |||
@@ -191,11 +191,6 @@ static const struct inode_operations shmem_dir_inode_operations; | |||
191 | static const struct inode_operations shmem_special_inode_operations; | 191 | static const struct inode_operations shmem_special_inode_operations; |
192 | static const struct vm_operations_struct shmem_vm_ops; | 192 | static const struct vm_operations_struct shmem_vm_ops; |
193 | 193 | ||
194 | static struct backing_dev_info shmem_backing_dev_info __read_mostly = { | ||
195 | .ra_pages = 0, /* No readahead */ | ||
196 | .capabilities = BDI_CAP_NO_ACCT_AND_WRITEBACK | BDI_CAP_SWAP_BACKED, | ||
197 | }; | ||
198 | |||
199 | static LIST_HEAD(shmem_swaplist); | 194 | static LIST_HEAD(shmem_swaplist); |
200 | static DEFINE_MUTEX(shmem_swaplist_mutex); | 195 | static DEFINE_MUTEX(shmem_swaplist_mutex); |
201 | 196 | ||
@@ -765,11 +760,11 @@ static int shmem_writepage(struct page *page, struct writeback_control *wbc) | |||
765 | goto redirty; | 760 | goto redirty; |
766 | 761 | ||
767 | /* | 762 | /* |
768 | * shmem_backing_dev_info's capabilities prevent regular writeback or | 763 | * Our capabilities prevent regular writeback or sync from ever calling |
769 | * sync from ever calling shmem_writepage; but a stacking filesystem | 764 | * shmem_writepage; but a stacking filesystem might use ->writepage of |
770 | * might use ->writepage of its underlying filesystem, in which case | 765 | * its underlying filesystem, in which case tmpfs should write out to |
771 | * tmpfs should write out to swap only in response to memory pressure, | 766 | * swap only in response to memory pressure, and not for the writeback |
772 | * and not for the writeback threads or sync. | 767 | * threads or sync. |
773 | */ | 768 | */ |
774 | if (!wbc->for_reclaim) { | 769 | if (!wbc->for_reclaim) { |
775 | WARN_ON_ONCE(1); /* Still happens? Tell us about it! */ | 770 | WARN_ON_ONCE(1); /* Still happens? Tell us about it! */ |
@@ -1415,7 +1410,7 @@ static struct inode *shmem_get_inode(struct super_block *sb, const struct inode | |||
1415 | inode->i_ino = get_next_ino(); | 1410 | inode->i_ino = get_next_ino(); |
1416 | inode_init_owner(inode, dir, mode); | 1411 | inode_init_owner(inode, dir, mode); |
1417 | inode->i_blocks = 0; | 1412 | inode->i_blocks = 0; |
1418 | inode->i_mapping->backing_dev_info = &shmem_backing_dev_info; | 1413 | inode->i_mapping->backing_dev_info = &noop_backing_dev_info; |
1419 | inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; | 1414 | inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; |
1420 | inode->i_generation = get_seconds(); | 1415 | inode->i_generation = get_seconds(); |
1421 | info = SHMEM_I(inode); | 1416 | info = SHMEM_I(inode); |
@@ -1461,7 +1456,7 @@ static struct inode *shmem_get_inode(struct super_block *sb, const struct inode | |||
1461 | 1456 | ||
1462 | bool shmem_mapping(struct address_space *mapping) | 1457 | bool shmem_mapping(struct address_space *mapping) |
1463 | { | 1458 | { |
1464 | return mapping->backing_dev_info == &shmem_backing_dev_info; | 1459 | return mapping->host->i_sb->s_op == &shmem_ops; |
1465 | } | 1460 | } |
1466 | 1461 | ||
1467 | #ifdef CONFIG_TMPFS | 1462 | #ifdef CONFIG_TMPFS |
@@ -3226,10 +3221,6 @@ int __init shmem_init(void) | |||
3226 | if (shmem_inode_cachep) | 3221 | if (shmem_inode_cachep) |
3227 | return 0; | 3222 | return 0; |
3228 | 3223 | ||
3229 | error = bdi_init(&shmem_backing_dev_info); | ||
3230 | if (error) | ||
3231 | goto out4; | ||
3232 | |||
3233 | error = shmem_init_inodecache(); | 3224 | error = shmem_init_inodecache(); |
3234 | if (error) | 3225 | if (error) |
3235 | goto out3; | 3226 | goto out3; |
@@ -3253,8 +3244,6 @@ out1: | |||
3253 | out2: | 3244 | out2: |
3254 | shmem_destroy_inodecache(); | 3245 | shmem_destroy_inodecache(); |
3255 | out3: | 3246 | out3: |
3256 | bdi_destroy(&shmem_backing_dev_info); | ||
3257 | out4: | ||
3258 | shm_mnt = ERR_PTR(error); | 3247 | shm_mnt = ERR_PTR(error); |
3259 | return error; | 3248 | return error; |
3260 | } | 3249 | } |
@@ -1138,8 +1138,6 @@ void __init swap_setup(void) | |||
1138 | #ifdef CONFIG_SWAP | 1138 | #ifdef CONFIG_SWAP |
1139 | int i; | 1139 | int i; |
1140 | 1140 | ||
1141 | if (bdi_init(swapper_spaces[0].backing_dev_info)) | ||
1142 | panic("Failed to init swap bdi"); | ||
1143 | for (i = 0; i < MAX_SWAPFILES; i++) { | 1141 | for (i = 0; i < MAX_SWAPFILES; i++) { |
1144 | spin_lock_init(&swapper_spaces[i].tree_lock); | 1142 | spin_lock_init(&swapper_spaces[i].tree_lock); |
1145 | INIT_LIST_HEAD(&swapper_spaces[i].i_mmap_nonlinear); | 1143 | INIT_LIST_HEAD(&swapper_spaces[i].i_mmap_nonlinear); |
diff --git a/mm/swap_state.c b/mm/swap_state.c index 9711342987a0..1c137b69ecde 100644 --- a/mm/swap_state.c +++ b/mm/swap_state.c | |||
@@ -32,17 +32,12 @@ static const struct address_space_operations swap_aops = { | |||
32 | #endif | 32 | #endif |
33 | }; | 33 | }; |
34 | 34 | ||
35 | static struct backing_dev_info swap_backing_dev_info = { | ||
36 | .name = "swap", | ||
37 | .capabilities = BDI_CAP_NO_ACCT_AND_WRITEBACK | BDI_CAP_SWAP_BACKED, | ||
38 | }; | ||
39 | |||
40 | struct address_space swapper_spaces[MAX_SWAPFILES] = { | 35 | struct address_space swapper_spaces[MAX_SWAPFILES] = { |
41 | [0 ... MAX_SWAPFILES - 1] = { | 36 | [0 ... MAX_SWAPFILES - 1] = { |
42 | .page_tree = RADIX_TREE_INIT(GFP_ATOMIC|__GFP_NOWARN), | 37 | .page_tree = RADIX_TREE_INIT(GFP_ATOMIC|__GFP_NOWARN), |
43 | .i_mmap_writable = ATOMIC_INIT(0), | 38 | .i_mmap_writable = ATOMIC_INIT(0), |
44 | .a_ops = &swap_aops, | 39 | .a_ops = &swap_aops, |
45 | .backing_dev_info = &swap_backing_dev_info, | 40 | .backing_dev_info = &noop_backing_dev_info, |
46 | } | 41 | } |
47 | }; | 42 | }; |
48 | 43 | ||