diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2015-02-12 16:50:21 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-02-12 16:50:21 -0500 |
commit | 6bec0035286119eefc32a5b1102127e6a4032cb2 (patch) | |
tree | 440fab001b4c877b0b0c9fd62d8392e956e387e3 /mm | |
parent | 5d8e7fb6916556e9b476de33404e8c9e2c9aee61 (diff) | |
parent | 15d0f5ea348b9c4e6d41df294dde38a56a39c7bf (diff) |
Merge branch 'for-3.20/bdi' of git://git.kernel.dk/linux-block
Pull backing device changes from Jens Axboe:
"This contains a cleanup of how the backing device is handled, in
preparation for a rework of the life time rules. In this part, the
most important change is to split the unrelated nommu mmap flags from
it, but also removing a backing_dev_info pointer from the
address_space (and inode), and a cleanup of other various minor bits.
Christoph did all the work here, I just fixed an oops with pages that
have a swap backing. Arnd fixed a missing export, and Oleg killed the
lustre backing_dev_info from staging. Last patch was from Al,
unexporting parts that are now no longer needed outside"
* 'for-3.20/bdi' of git://git.kernel.dk/linux-block:
Make super_blocks and sb_lock static
mtd: export new mtd_mmap_capabilities
fs: make inode_to_bdi() handle NULL inode
staging/lustre/llite: get rid of backing_dev_info
fs: remove default_backing_dev_info
fs: don't reassign dirty inodes to default_backing_dev_info
nfs: don't call bdi_unregister
ceph: remove call to bdi_unregister
fs: remove mapping->backing_dev_info
fs: export inode_to_bdi and use it in favor of mapping->backing_dev_info
nilfs2: set up s_bdi like the generic mount_bdev code
block_dev: get bdev inode bdi directly from the block device
block_dev: only write bdev inode on close
fs: introduce f_op->mmap_capabilities for nommu mmap support
fs: kill BDI_CAP_SWAP_BACKED
fs: deduplicate noop_backing_dev_info
Diffstat (limited to 'mm')
-rw-r--r-- | mm/backing-dev.c | 107 | ||||
-rw-r--r-- | mm/fadvise.c | 4 | ||||
-rw-r--r-- | mm/filemap.c | 4 | ||||
-rw-r--r-- | mm/filemap_xip.c | 3 | ||||
-rw-r--r-- | mm/madvise.c | 17 | ||||
-rw-r--r-- | mm/nommu.c | 69 | ||||
-rw-r--r-- | mm/page-writeback.c | 29 | ||||
-rw-r--r-- | mm/readahead.c | 4 | ||||
-rw-r--r-- | mm/shmem.c | 24 | ||||
-rw-r--r-- | mm/swap.c | 2 | ||||
-rw-r--r-- | mm/swap_state.c | 6 | ||||
-rw-r--r-- | mm/truncate.c | 2 | ||||
-rw-r--r-- | mm/vmscan.c | 4 |
13 files changed, 95 insertions, 180 deletions
diff --git a/mm/backing-dev.c b/mm/backing-dev.c index 0ae0df55000b..7690ec77c722 100644 --- a/mm/backing-dev.c +++ b/mm/backing-dev.c | |||
@@ -14,19 +14,10 @@ | |||
14 | 14 | ||
15 | static atomic_long_t bdi_seq = ATOMIC_LONG_INIT(0); | 15 | static atomic_long_t bdi_seq = ATOMIC_LONG_INIT(0); |
16 | 16 | ||
17 | struct backing_dev_info default_backing_dev_info = { | ||
18 | .name = "default", | ||
19 | .ra_pages = VM_MAX_READAHEAD * 1024 / PAGE_CACHE_SIZE, | ||
20 | .state = 0, | ||
21 | .capabilities = BDI_CAP_MAP_COPY, | ||
22 | }; | ||
23 | EXPORT_SYMBOL_GPL(default_backing_dev_info); | ||
24 | |||
25 | struct backing_dev_info noop_backing_dev_info = { | 17 | struct backing_dev_info noop_backing_dev_info = { |
26 | .name = "noop", | 18 | .name = "noop", |
27 | .capabilities = BDI_CAP_NO_ACCT_AND_WRITEBACK, | 19 | .capabilities = BDI_CAP_NO_ACCT_AND_WRITEBACK, |
28 | }; | 20 | }; |
29 | EXPORT_SYMBOL_GPL(noop_backing_dev_info); | ||
30 | 21 | ||
31 | static struct class *bdi_class; | 22 | static struct class *bdi_class; |
32 | 23 | ||
@@ -40,17 +31,6 @@ LIST_HEAD(bdi_list); | |||
40 | /* bdi_wq serves all asynchronous writeback tasks */ | 31 | /* bdi_wq serves all asynchronous writeback tasks */ |
41 | struct workqueue_struct *bdi_wq; | 32 | struct workqueue_struct *bdi_wq; |
42 | 33 | ||
43 | static void bdi_lock_two(struct bdi_writeback *wb1, struct bdi_writeback *wb2) | ||
44 | { | ||
45 | if (wb1 < wb2) { | ||
46 | spin_lock(&wb1->list_lock); | ||
47 | spin_lock_nested(&wb2->list_lock, 1); | ||
48 | } else { | ||
49 | spin_lock(&wb2->list_lock); | ||
50 | spin_lock_nested(&wb1->list_lock, 1); | ||
51 | } | ||
52 | } | ||
53 | |||
54 | #ifdef CONFIG_DEBUG_FS | 34 | #ifdef CONFIG_DEBUG_FS |
55 | #include <linux/debugfs.h> | 35 | #include <linux/debugfs.h> |
56 | #include <linux/seq_file.h> | 36 | #include <linux/seq_file.h> |
@@ -264,9 +244,6 @@ static int __init default_bdi_init(void) | |||
264 | if (!bdi_wq) | 244 | if (!bdi_wq) |
265 | return -ENOMEM; | 245 | return -ENOMEM; |
266 | 246 | ||
267 | err = bdi_init(&default_backing_dev_info); | ||
268 | if (!err) | ||
269 | bdi_register(&default_backing_dev_info, NULL, "default"); | ||
270 | err = bdi_init(&noop_backing_dev_info); | 247 | err = bdi_init(&noop_backing_dev_info); |
271 | 248 | ||
272 | return err; | 249 | return err; |
@@ -355,19 +332,19 @@ EXPORT_SYMBOL(bdi_register_dev); | |||
355 | */ | 332 | */ |
356 | static void bdi_wb_shutdown(struct backing_dev_info *bdi) | 333 | static void bdi_wb_shutdown(struct backing_dev_info *bdi) |
357 | { | 334 | { |
358 | if (!bdi_cap_writeback_dirty(bdi)) | 335 | /* Make sure nobody queues further work */ |
336 | spin_lock_bh(&bdi->wb_lock); | ||
337 | if (!test_and_clear_bit(BDI_registered, &bdi->state)) { | ||
338 | spin_unlock_bh(&bdi->wb_lock); | ||
359 | return; | 339 | return; |
340 | } | ||
341 | spin_unlock_bh(&bdi->wb_lock); | ||
360 | 342 | ||
361 | /* | 343 | /* |
362 | * Make sure nobody finds us on the bdi_list anymore | 344 | * Make sure nobody finds us on the bdi_list anymore |
363 | */ | 345 | */ |
364 | bdi_remove_from_list(bdi); | 346 | bdi_remove_from_list(bdi); |
365 | 347 | ||
366 | /* Make sure nobody queues further work */ | ||
367 | spin_lock_bh(&bdi->wb_lock); | ||
368 | clear_bit(BDI_registered, &bdi->state); | ||
369 | spin_unlock_bh(&bdi->wb_lock); | ||
370 | |||
371 | /* | 348 | /* |
372 | * Drain work list and shutdown the delayed_work. At this point, | 349 | * Drain work list and shutdown the delayed_work. At this point, |
373 | * @bdi->bdi_list is empty telling bdi_Writeback_workfn() that @bdi | 350 | * @bdi->bdi_list is empty telling bdi_Writeback_workfn() that @bdi |
@@ -375,37 +352,22 @@ static void bdi_wb_shutdown(struct backing_dev_info *bdi) | |||
375 | */ | 352 | */ |
376 | mod_delayed_work(bdi_wq, &bdi->wb.dwork, 0); | 353 | mod_delayed_work(bdi_wq, &bdi->wb.dwork, 0); |
377 | flush_delayed_work(&bdi->wb.dwork); | 354 | flush_delayed_work(&bdi->wb.dwork); |
378 | WARN_ON(!list_empty(&bdi->work_list)); | ||
379 | WARN_ON(delayed_work_pending(&bdi->wb.dwork)); | ||
380 | } | 355 | } |
381 | 356 | ||
382 | /* | 357 | /* |
383 | * This bdi is going away now, make sure that no super_blocks point to it | 358 | * Called when the device behind @bdi has been removed or ejected. |
359 | * | ||
360 | * We can't really do much here except for reducing the dirty ratio at | ||
361 | * the moment. In the future we should be able to set a flag so that | ||
362 | * the filesystem can handle errors at mark_inode_dirty time instead | ||
363 | * of only at writeback time. | ||
384 | */ | 364 | */ |
385 | static void bdi_prune_sb(struct backing_dev_info *bdi) | ||
386 | { | ||
387 | struct super_block *sb; | ||
388 | |||
389 | spin_lock(&sb_lock); | ||
390 | list_for_each_entry(sb, &super_blocks, s_list) { | ||
391 | if (sb->s_bdi == bdi) | ||
392 | sb->s_bdi = &default_backing_dev_info; | ||
393 | } | ||
394 | spin_unlock(&sb_lock); | ||
395 | } | ||
396 | |||
397 | void bdi_unregister(struct backing_dev_info *bdi) | 365 | void bdi_unregister(struct backing_dev_info *bdi) |
398 | { | 366 | { |
399 | if (bdi->dev) { | 367 | if (WARN_ON_ONCE(!bdi->dev)) |
400 | bdi_set_min_ratio(bdi, 0); | 368 | return; |
401 | trace_writeback_bdi_unregister(bdi); | ||
402 | bdi_prune_sb(bdi); | ||
403 | 369 | ||
404 | bdi_wb_shutdown(bdi); | 370 | bdi_set_min_ratio(bdi, 0); |
405 | bdi_debug_unregister(bdi); | ||
406 | device_unregister(bdi->dev); | ||
407 | bdi->dev = NULL; | ||
408 | } | ||
409 | } | 371 | } |
410 | EXPORT_SYMBOL(bdi_unregister); | 372 | EXPORT_SYMBOL(bdi_unregister); |
411 | 373 | ||
@@ -474,37 +436,19 @@ void bdi_destroy(struct backing_dev_info *bdi) | |||
474 | { | 436 | { |
475 | int i; | 437 | int i; |
476 | 438 | ||
477 | /* | 439 | bdi_wb_shutdown(bdi); |
478 | * Splice our entries to the default_backing_dev_info. This | ||
479 | * condition shouldn't happen. @wb must be empty at this point and | ||
480 | * dirty inodes on it might cause other issues. This workaround is | ||
481 | * added by ce5f8e779519 ("writeback: splice dirty inode entries to | ||
482 | * default bdi on bdi_destroy()") without root-causing the issue. | ||
483 | * | ||
484 | * http://lkml.kernel.org/g/1253038617-30204-11-git-send-email-jens.axboe@oracle.com | ||
485 | * http://thread.gmane.org/gmane.linux.file-systems/35341/focus=35350 | ||
486 | * | ||
487 | * We should probably add WARN_ON() to find out whether it still | ||
488 | * happens and track it down if so. | ||
489 | */ | ||
490 | if (bdi_has_dirty_io(bdi)) { | ||
491 | struct bdi_writeback *dst = &default_backing_dev_info.wb; | ||
492 | |||
493 | bdi_lock_two(&bdi->wb, dst); | ||
494 | list_splice(&bdi->wb.b_dirty, &dst->b_dirty); | ||
495 | list_splice(&bdi->wb.b_io, &dst->b_io); | ||
496 | list_splice(&bdi->wb.b_more_io, &dst->b_more_io); | ||
497 | spin_unlock(&bdi->wb.list_lock); | ||
498 | spin_unlock(&dst->list_lock); | ||
499 | } | ||
500 | |||
501 | bdi_unregister(bdi); | ||
502 | 440 | ||
441 | WARN_ON(!list_empty(&bdi->work_list)); | ||
503 | WARN_ON(delayed_work_pending(&bdi->wb.dwork)); | 442 | WARN_ON(delayed_work_pending(&bdi->wb.dwork)); |
504 | 443 | ||
444 | if (bdi->dev) { | ||
445 | bdi_debug_unregister(bdi); | ||
446 | device_unregister(bdi->dev); | ||
447 | bdi->dev = NULL; | ||
448 | } | ||
449 | |||
505 | for (i = 0; i < NR_BDI_STAT_ITEMS; i++) | 450 | for (i = 0; i < NR_BDI_STAT_ITEMS; i++) |
506 | percpu_counter_destroy(&bdi->bdi_stat[i]); | 451 | percpu_counter_destroy(&bdi->bdi_stat[i]); |
507 | |||
508 | fprop_local_destroy_percpu(&bdi->completions); | 452 | fprop_local_destroy_percpu(&bdi->completions); |
509 | } | 453 | } |
510 | EXPORT_SYMBOL(bdi_destroy); | 454 | EXPORT_SYMBOL(bdi_destroy); |
@@ -513,13 +457,12 @@ EXPORT_SYMBOL(bdi_destroy); | |||
513 | * For use from filesystems to quickly init and register a bdi associated | 457 | * For use from filesystems to quickly init and register a bdi associated |
514 | * with dirty writeback | 458 | * with dirty writeback |
515 | */ | 459 | */ |
516 | int bdi_setup_and_register(struct backing_dev_info *bdi, char *name, | 460 | int bdi_setup_and_register(struct backing_dev_info *bdi, char *name) |
517 | unsigned int cap) | ||
518 | { | 461 | { |
519 | int err; | 462 | int err; |
520 | 463 | ||
521 | bdi->name = name; | 464 | bdi->name = name; |
522 | bdi->capabilities = cap; | 465 | bdi->capabilities = 0; |
523 | err = bdi_init(bdi); | 466 | err = bdi_init(bdi); |
524 | if (err) | 467 | if (err) |
525 | return err; | 468 | return err; |
diff --git a/mm/fadvise.c b/mm/fadvise.c index 2ad7adf4f0a4..fac23ecf8d72 100644 --- a/mm/fadvise.c +++ b/mm/fadvise.c | |||
@@ -73,7 +73,7 @@ SYSCALL_DEFINE4(fadvise64_64, int, fd, loff_t, offset, loff_t, len, int, advice) | |||
73 | else | 73 | else |
74 | endbyte--; /* inclusive */ | 74 | endbyte--; /* inclusive */ |
75 | 75 | ||
76 | bdi = mapping->backing_dev_info; | 76 | bdi = inode_to_bdi(mapping->host); |
77 | 77 | ||
78 | switch (advice) { | 78 | switch (advice) { |
79 | case POSIX_FADV_NORMAL: | 79 | case POSIX_FADV_NORMAL: |
@@ -113,7 +113,7 @@ SYSCALL_DEFINE4(fadvise64_64, int, fd, loff_t, offset, loff_t, len, int, advice) | |||
113 | case POSIX_FADV_NOREUSE: | 113 | case POSIX_FADV_NOREUSE: |
114 | break; | 114 | break; |
115 | case POSIX_FADV_DONTNEED: | 115 | case POSIX_FADV_DONTNEED: |
116 | if (!bdi_write_congested(mapping->backing_dev_info)) | 116 | if (!bdi_write_congested(bdi)) |
117 | __filemap_fdatawrite_range(mapping, offset, endbyte, | 117 | __filemap_fdatawrite_range(mapping, offset, endbyte, |
118 | WB_SYNC_NONE); | 118 | WB_SYNC_NONE); |
119 | 119 | ||
diff --git a/mm/filemap.c b/mm/filemap.c index bf7a27142704..d9f5336552d7 100644 --- a/mm/filemap.c +++ b/mm/filemap.c | |||
@@ -211,7 +211,7 @@ void __delete_from_page_cache(struct page *page, void *shadow) | |||
211 | */ | 211 | */ |
212 | if (PageDirty(page) && mapping_cap_account_dirty(mapping)) { | 212 | if (PageDirty(page) && mapping_cap_account_dirty(mapping)) { |
213 | dec_zone_page_state(page, NR_FILE_DIRTY); | 213 | dec_zone_page_state(page, NR_FILE_DIRTY); |
214 | dec_bdi_stat(mapping->backing_dev_info, BDI_RECLAIMABLE); | 214 | dec_bdi_stat(inode_to_bdi(mapping->host), BDI_RECLAIMABLE); |
215 | } | 215 | } |
216 | } | 216 | } |
217 | 217 | ||
@@ -2564,7 +2564,7 @@ ssize_t __generic_file_write_iter(struct kiocb *iocb, struct iov_iter *from) | |||
2564 | size_t count = iov_iter_count(from); | 2564 | size_t count = iov_iter_count(from); |
2565 | 2565 | ||
2566 | /* We can write back this queue in page reclaim */ | 2566 | /* We can write back this queue in page reclaim */ |
2567 | current->backing_dev_info = mapping->backing_dev_info; | 2567 | current->backing_dev_info = inode_to_bdi(inode); |
2568 | err = generic_write_checks(file, &pos, &count, S_ISBLK(inode->i_mode)); | 2568 | err = generic_write_checks(file, &pos, &count, S_ISBLK(inode->i_mode)); |
2569 | if (err) | 2569 | if (err) |
2570 | goto out; | 2570 | goto out; |
diff --git a/mm/filemap_xip.c b/mm/filemap_xip.c index 70c09da1a419..c175f9f25210 100644 --- a/mm/filemap_xip.c +++ b/mm/filemap_xip.c | |||
@@ -9,6 +9,7 @@ | |||
9 | */ | 9 | */ |
10 | 10 | ||
11 | #include <linux/fs.h> | 11 | #include <linux/fs.h> |
12 | #include <linux/backing-dev.h> | ||
12 | #include <linux/pagemap.h> | 13 | #include <linux/pagemap.h> |
13 | #include <linux/export.h> | 14 | #include <linux/export.h> |
14 | #include <linux/uio.h> | 15 | #include <linux/uio.h> |
@@ -409,7 +410,7 @@ xip_file_write(struct file *filp, const char __user *buf, size_t len, | |||
409 | count = len; | 410 | count = len; |
410 | 411 | ||
411 | /* We can write back this queue in page reclaim */ | 412 | /* We can write back this queue in page reclaim */ |
412 | current->backing_dev_info = mapping->backing_dev_info; | 413 | current->backing_dev_info = inode_to_bdi(inode); |
413 | 414 | ||
414 | ret = generic_write_checks(filp, &pos, &count, S_ISBLK(inode->i_mode)); | 415 | ret = generic_write_checks(filp, &pos, &count, S_ISBLK(inode->i_mode)); |
415 | if (ret) | 416 | if (ret) |
diff --git a/mm/madvise.c b/mm/madvise.c index d79fb5e8f80a..1077cbdc8b52 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/nommu.c b/mm/nommu.c index 1a19fb3b0463..7296360fc057 100644 --- a/mm/nommu.c +++ b/mm/nommu.c | |||
@@ -980,9 +980,6 @@ static int validate_mmap_request(struct file *file, | |||
980 | return -EOVERFLOW; | 980 | return -EOVERFLOW; |
981 | 981 | ||
982 | if (file) { | 982 | if (file) { |
983 | /* validate file mapping requests */ | ||
984 | struct address_space *mapping; | ||
985 | |||
986 | /* files must support mmap */ | 983 | /* files must support mmap */ |
987 | if (!file->f_op->mmap) | 984 | if (!file->f_op->mmap) |
988 | return -ENODEV; | 985 | return -ENODEV; |
@@ -991,28 +988,22 @@ static int validate_mmap_request(struct file *file, | |||
991 | * - we support chardevs that provide their own "memory" | 988 | * - we support chardevs that provide their own "memory" |
992 | * - we support files/blockdevs that are memory backed | 989 | * - we support files/blockdevs that are memory backed |
993 | */ | 990 | */ |
994 | mapping = file->f_mapping; | 991 | if (file->f_op->mmap_capabilities) { |
995 | if (!mapping) | 992 | capabilities = file->f_op->mmap_capabilities(file); |
996 | mapping = file_inode(file)->i_mapping; | 993 | } else { |
997 | |||
998 | capabilities = 0; | ||
999 | if (mapping && mapping->backing_dev_info) | ||
1000 | capabilities = mapping->backing_dev_info->capabilities; | ||
1001 | |||
1002 | if (!capabilities) { | ||
1003 | /* no explicit capabilities set, so assume some | 994 | /* no explicit capabilities set, so assume some |
1004 | * defaults */ | 995 | * defaults */ |
1005 | switch (file_inode(file)->i_mode & S_IFMT) { | 996 | switch (file_inode(file)->i_mode & S_IFMT) { |
1006 | case S_IFREG: | 997 | case S_IFREG: |
1007 | case S_IFBLK: | 998 | case S_IFBLK: |
1008 | capabilities = BDI_CAP_MAP_COPY; | 999 | capabilities = NOMMU_MAP_COPY; |
1009 | break; | 1000 | break; |
1010 | 1001 | ||
1011 | case S_IFCHR: | 1002 | case S_IFCHR: |
1012 | capabilities = | 1003 | capabilities = |
1013 | BDI_CAP_MAP_DIRECT | | 1004 | NOMMU_MAP_DIRECT | |
1014 | BDI_CAP_READ_MAP | | 1005 | NOMMU_MAP_READ | |
1015 | BDI_CAP_WRITE_MAP; | 1006 | NOMMU_MAP_WRITE; |
1016 | break; | 1007 | break; |
1017 | 1008 | ||
1018 | default: | 1009 | default: |
@@ -1023,9 +1014,9 @@ static int validate_mmap_request(struct file *file, | |||
1023 | /* eliminate any capabilities that we can't support on this | 1014 | /* eliminate any capabilities that we can't support on this |
1024 | * device */ | 1015 | * device */ |
1025 | if (!file->f_op->get_unmapped_area) | 1016 | if (!file->f_op->get_unmapped_area) |
1026 | capabilities &= ~BDI_CAP_MAP_DIRECT; | 1017 | capabilities &= ~NOMMU_MAP_DIRECT; |
1027 | if (!file->f_op->read) | 1018 | if (!file->f_op->read) |
1028 | capabilities &= ~BDI_CAP_MAP_COPY; | 1019 | capabilities &= ~NOMMU_MAP_COPY; |
1029 | 1020 | ||
1030 | /* The file shall have been opened with read permission. */ | 1021 | /* The file shall have been opened with read permission. */ |
1031 | if (!(file->f_mode & FMODE_READ)) | 1022 | if (!(file->f_mode & FMODE_READ)) |
@@ -1044,29 +1035,29 @@ static int validate_mmap_request(struct file *file, | |||
1044 | if (locks_verify_locked(file)) | 1035 | if (locks_verify_locked(file)) |
1045 | return -EAGAIN; | 1036 | return -EAGAIN; |
1046 | 1037 | ||
1047 | if (!(capabilities & BDI_CAP_MAP_DIRECT)) | 1038 | if (!(capabilities & NOMMU_MAP_DIRECT)) |
1048 | return -ENODEV; | 1039 | return -ENODEV; |
1049 | 1040 | ||
1050 | /* we mustn't privatise shared mappings */ | 1041 | /* we mustn't privatise shared mappings */ |
1051 | capabilities &= ~BDI_CAP_MAP_COPY; | 1042 | capabilities &= ~NOMMU_MAP_COPY; |
1052 | } else { | 1043 | } else { |
1053 | /* we're going to read the file into private memory we | 1044 | /* we're going to read the file into private memory we |
1054 | * allocate */ | 1045 | * allocate */ |
1055 | if (!(capabilities & BDI_CAP_MAP_COPY)) | 1046 | if (!(capabilities & NOMMU_MAP_COPY)) |
1056 | return -ENODEV; | 1047 | return -ENODEV; |
1057 | 1048 | ||
1058 | /* we don't permit a private writable mapping to be | 1049 | /* we don't permit a private writable mapping to be |
1059 | * shared with the backing device */ | 1050 | * shared with the backing device */ |
1060 | if (prot & PROT_WRITE) | 1051 | if (prot & PROT_WRITE) |
1061 | capabilities &= ~BDI_CAP_MAP_DIRECT; | 1052 | capabilities &= ~NOMMU_MAP_DIRECT; |
1062 | } | 1053 | } |
1063 | 1054 | ||
1064 | if (capabilities & BDI_CAP_MAP_DIRECT) { | 1055 | if (capabilities & NOMMU_MAP_DIRECT) { |
1065 | if (((prot & PROT_READ) && !(capabilities & BDI_CAP_READ_MAP)) || | 1056 | if (((prot & PROT_READ) && !(capabilities & NOMMU_MAP_READ)) || |
1066 | ((prot & PROT_WRITE) && !(capabilities & BDI_CAP_WRITE_MAP)) || | 1057 | ((prot & PROT_WRITE) && !(capabilities & NOMMU_MAP_WRITE)) || |
1067 | ((prot & PROT_EXEC) && !(capabilities & BDI_CAP_EXEC_MAP)) | 1058 | ((prot & PROT_EXEC) && !(capabilities & NOMMU_MAP_EXEC)) |
1068 | ) { | 1059 | ) { |
1069 | capabilities &= ~BDI_CAP_MAP_DIRECT; | 1060 | capabilities &= ~NOMMU_MAP_DIRECT; |
1070 | if (flags & MAP_SHARED) { | 1061 | if (flags & MAP_SHARED) { |
1071 | printk(KERN_WARNING | 1062 | printk(KERN_WARNING |
1072 | "MAP_SHARED not completely supported on !MMU\n"); | 1063 | "MAP_SHARED not completely supported on !MMU\n"); |
@@ -1083,21 +1074,21 @@ static int validate_mmap_request(struct file *file, | |||
1083 | } else if ((prot & PROT_READ) && !(prot & PROT_EXEC)) { | 1074 | } else if ((prot & PROT_READ) && !(prot & PROT_EXEC)) { |
1084 | /* handle implication of PROT_EXEC by PROT_READ */ | 1075 | /* handle implication of PROT_EXEC by PROT_READ */ |
1085 | if (current->personality & READ_IMPLIES_EXEC) { | 1076 | if (current->personality & READ_IMPLIES_EXEC) { |
1086 | if (capabilities & BDI_CAP_EXEC_MAP) | 1077 | if (capabilities & NOMMU_MAP_EXEC) |
1087 | prot |= PROT_EXEC; | 1078 | prot |= PROT_EXEC; |
1088 | } | 1079 | } |
1089 | } else if ((prot & PROT_READ) && | 1080 | } else if ((prot & PROT_READ) && |
1090 | (prot & PROT_EXEC) && | 1081 | (prot & PROT_EXEC) && |
1091 | !(capabilities & BDI_CAP_EXEC_MAP) | 1082 | !(capabilities & NOMMU_MAP_EXEC) |
1092 | ) { | 1083 | ) { |
1093 | /* backing file is not executable, try to copy */ | 1084 | /* backing file is not executable, try to copy */ |
1094 | capabilities &= ~BDI_CAP_MAP_DIRECT; | 1085 | capabilities &= ~NOMMU_MAP_DIRECT; |
1095 | } | 1086 | } |
1096 | } else { | 1087 | } else { |
1097 | /* anonymous mappings are always memory backed and can be | 1088 | /* anonymous mappings are always memory backed and can be |
1098 | * privately mapped | 1089 | * privately mapped |
1099 | */ | 1090 | */ |
1100 | capabilities = BDI_CAP_MAP_COPY; | 1091 | capabilities = NOMMU_MAP_COPY; |
1101 | 1092 | ||
1102 | /* handle PROT_EXEC implication by PROT_READ */ | 1093 | /* handle PROT_EXEC implication by PROT_READ */ |
1103 | if ((prot & PROT_READ) && | 1094 | if ((prot & PROT_READ) && |
@@ -1129,7 +1120,7 @@ static unsigned long determine_vm_flags(struct file *file, | |||
1129 | vm_flags = calc_vm_prot_bits(prot) | calc_vm_flag_bits(flags); | 1120 | vm_flags = calc_vm_prot_bits(prot) | calc_vm_flag_bits(flags); |
1130 | /* vm_flags |= mm->def_flags; */ | 1121 | /* vm_flags |= mm->def_flags; */ |
1131 | 1122 | ||
1132 | if (!(capabilities & BDI_CAP_MAP_DIRECT)) { | 1123 | if (!(capabilities & NOMMU_MAP_DIRECT)) { |
1133 | /* attempt to share read-only copies of mapped file chunks */ | 1124 | /* attempt to share read-only copies of mapped file chunks */ |
1134 | vm_flags |= VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC; | 1125 | vm_flags |= VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC; |
1135 | if (file && !(prot & PROT_WRITE)) | 1126 | if (file && !(prot & PROT_WRITE)) |
@@ -1138,7 +1129,7 @@ static unsigned long determine_vm_flags(struct file *file, | |||
1138 | /* overlay a shareable mapping on the backing device or inode | 1129 | /* overlay a shareable mapping on the backing device or inode |
1139 | * if possible - used for chardevs, ramfs/tmpfs/shmfs and | 1130 | * if possible - used for chardevs, ramfs/tmpfs/shmfs and |
1140 | * romfs/cramfs */ | 1131 | * romfs/cramfs */ |
1141 | vm_flags |= VM_MAYSHARE | (capabilities & BDI_CAP_VMFLAGS); | 1132 | vm_flags |= VM_MAYSHARE | (capabilities & NOMMU_VMFLAGS); |
1142 | if (flags & MAP_SHARED) | 1133 | if (flags & MAP_SHARED) |
1143 | vm_flags |= VM_SHARED; | 1134 | vm_flags |= VM_SHARED; |
1144 | } | 1135 | } |
@@ -1191,7 +1182,7 @@ static int do_mmap_private(struct vm_area_struct *vma, | |||
1191 | * shared mappings on devices or memory | 1182 | * shared mappings on devices or memory |
1192 | * - VM_MAYSHARE will be set if it may attempt to share | 1183 | * - VM_MAYSHARE will be set if it may attempt to share |
1193 | */ | 1184 | */ |
1194 | if (capabilities & BDI_CAP_MAP_DIRECT) { | 1185 | if (capabilities & NOMMU_MAP_DIRECT) { |
1195 | ret = vma->vm_file->f_op->mmap(vma->vm_file, vma); | 1186 | ret = vma->vm_file->f_op->mmap(vma->vm_file, vma); |
1196 | if (ret == 0) { | 1187 | if (ret == 0) { |
1197 | /* shouldn't return success if we're not sharing */ | 1188 | /* shouldn't return success if we're not sharing */ |
@@ -1380,7 +1371,7 @@ unsigned long do_mmap_pgoff(struct file *file, | |||
1380 | if ((pregion->vm_pgoff != pgoff || rpglen != pglen) && | 1371 | if ((pregion->vm_pgoff != pgoff || rpglen != pglen) && |
1381 | !(pgoff >= pregion->vm_pgoff && pgend <= rpgend)) { | 1372 | !(pgoff >= pregion->vm_pgoff && pgend <= rpgend)) { |
1382 | /* new mapping is not a subset of the region */ | 1373 | /* new mapping is not a subset of the region */ |
1383 | if (!(capabilities & BDI_CAP_MAP_DIRECT)) | 1374 | if (!(capabilities & NOMMU_MAP_DIRECT)) |
1384 | goto sharing_violation; | 1375 | goto sharing_violation; |
1385 | continue; | 1376 | continue; |
1386 | } | 1377 | } |
@@ -1419,7 +1410,7 @@ unsigned long do_mmap_pgoff(struct file *file, | |||
1419 | * - this is the hook for quasi-memory character devices to | 1410 | * - this is the hook for quasi-memory character devices to |
1420 | * tell us the location of a shared mapping | 1411 | * tell us the location of a shared mapping |
1421 | */ | 1412 | */ |
1422 | if (capabilities & BDI_CAP_MAP_DIRECT) { | 1413 | if (capabilities & NOMMU_MAP_DIRECT) { |
1423 | addr = file->f_op->get_unmapped_area(file, addr, len, | 1414 | addr = file->f_op->get_unmapped_area(file, addr, len, |
1424 | pgoff, flags); | 1415 | pgoff, flags); |
1425 | if (IS_ERR_VALUE(addr)) { | 1416 | if (IS_ERR_VALUE(addr)) { |
@@ -1431,10 +1422,10 @@ unsigned long do_mmap_pgoff(struct file *file, | |||
1431 | * the mapping so we'll have to attempt to copy | 1422 | * the mapping so we'll have to attempt to copy |
1432 | * it */ | 1423 | * it */ |
1433 | ret = -ENODEV; | 1424 | ret = -ENODEV; |
1434 | if (!(capabilities & BDI_CAP_MAP_COPY)) | 1425 | if (!(capabilities & NOMMU_MAP_COPY)) |
1435 | goto error_just_free; | 1426 | goto error_just_free; |
1436 | 1427 | ||
1437 | capabilities &= ~BDI_CAP_MAP_DIRECT; | 1428 | capabilities &= ~NOMMU_MAP_DIRECT; |
1438 | } else { | 1429 | } else { |
1439 | vma->vm_start = region->vm_start = addr; | 1430 | vma->vm_start = region->vm_start = addr; |
1440 | vma->vm_end = region->vm_end = addr + len; | 1431 | vma->vm_end = region->vm_end = addr + len; |
@@ -1445,7 +1436,7 @@ unsigned long do_mmap_pgoff(struct file *file, | |||
1445 | vma->vm_region = region; | 1436 | vma->vm_region = region; |
1446 | 1437 | ||
1447 | /* set up the mapping | 1438 | /* set up the mapping |
1448 | * - the region is filled in if BDI_CAP_MAP_DIRECT is still set | 1439 | * - the region is filled in if NOMMU_MAP_DIRECT is still set |
1449 | */ | 1440 | */ |
1450 | if (file && vma->vm_flags & VM_SHARED) | 1441 | if (file && vma->vm_flags & VM_SHARED) |
1451 | ret = do_mmap_shared_file(vma); | 1442 | ret = do_mmap_shared_file(vma); |
diff --git a/mm/page-writeback.c b/mm/page-writeback.c index 6a73e47e81c6..45e187b2d971 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c | |||
@@ -1351,7 +1351,7 @@ static void balance_dirty_pages(struct address_space *mapping, | |||
1351 | unsigned long task_ratelimit; | 1351 | unsigned long task_ratelimit; |
1352 | unsigned long dirty_ratelimit; | 1352 | unsigned long dirty_ratelimit; |
1353 | unsigned long pos_ratio; | 1353 | unsigned long pos_ratio; |
1354 | struct backing_dev_info *bdi = mapping->backing_dev_info; | 1354 | struct backing_dev_info *bdi = inode_to_bdi(mapping->host); |
1355 | bool strictlimit = bdi->capabilities & BDI_CAP_STRICTLIMIT; | 1355 | bool strictlimit = bdi->capabilities & BDI_CAP_STRICTLIMIT; |
1356 | unsigned long start_time = jiffies; | 1356 | unsigned long start_time = jiffies; |
1357 | 1357 | ||
@@ -1574,7 +1574,7 @@ DEFINE_PER_CPU(int, dirty_throttle_leaks) = 0; | |||
1574 | */ | 1574 | */ |
1575 | void balance_dirty_pages_ratelimited(struct address_space *mapping) | 1575 | void balance_dirty_pages_ratelimited(struct address_space *mapping) |
1576 | { | 1576 | { |
1577 | struct backing_dev_info *bdi = mapping->backing_dev_info; | 1577 | struct backing_dev_info *bdi = inode_to_bdi(mapping->host); |
1578 | int ratelimit; | 1578 | int ratelimit; |
1579 | int *p; | 1579 | int *p; |
1580 | 1580 | ||
@@ -1929,7 +1929,7 @@ continue_unlock: | |||
1929 | if (!clear_page_dirty_for_io(page)) | 1929 | if (!clear_page_dirty_for_io(page)) |
1930 | goto continue_unlock; | 1930 | goto continue_unlock; |
1931 | 1931 | ||
1932 | trace_wbc_writepage(wbc, mapping->backing_dev_info); | 1932 | trace_wbc_writepage(wbc, inode_to_bdi(mapping->host)); |
1933 | ret = (*writepage)(page, wbc, data); | 1933 | ret = (*writepage)(page, wbc, data); |
1934 | if (unlikely(ret)) { | 1934 | if (unlikely(ret)) { |
1935 | if (ret == AOP_WRITEPAGE_ACTIVATE) { | 1935 | if (ret == AOP_WRITEPAGE_ACTIVATE) { |
@@ -2094,10 +2094,12 @@ void account_page_dirtied(struct page *page, struct address_space *mapping) | |||
2094 | trace_writeback_dirty_page(page, mapping); | 2094 | trace_writeback_dirty_page(page, mapping); |
2095 | 2095 | ||
2096 | if (mapping_cap_account_dirty(mapping)) { | 2096 | if (mapping_cap_account_dirty(mapping)) { |
2097 | struct backing_dev_info *bdi = inode_to_bdi(mapping->host); | ||
2098 | |||
2097 | __inc_zone_page_state(page, NR_FILE_DIRTY); | 2099 | __inc_zone_page_state(page, NR_FILE_DIRTY); |
2098 | __inc_zone_page_state(page, NR_DIRTIED); | 2100 | __inc_zone_page_state(page, NR_DIRTIED); |
2099 | __inc_bdi_stat(mapping->backing_dev_info, BDI_RECLAIMABLE); | 2101 | __inc_bdi_stat(bdi, BDI_RECLAIMABLE); |
2100 | __inc_bdi_stat(mapping->backing_dev_info, BDI_DIRTIED); | 2102 | __inc_bdi_stat(bdi, BDI_DIRTIED); |
2101 | task_io_account_write(PAGE_CACHE_SIZE); | 2103 | task_io_account_write(PAGE_CACHE_SIZE); |
2102 | current->nr_dirtied++; | 2104 | current->nr_dirtied++; |
2103 | this_cpu_inc(bdp_ratelimits); | 2105 | this_cpu_inc(bdp_ratelimits); |
@@ -2156,7 +2158,7 @@ void account_page_redirty(struct page *page) | |||
2156 | if (mapping && mapping_cap_account_dirty(mapping)) { | 2158 | if (mapping && mapping_cap_account_dirty(mapping)) { |
2157 | current->nr_dirtied--; | 2159 | current->nr_dirtied--; |
2158 | dec_zone_page_state(page, NR_DIRTIED); | 2160 | dec_zone_page_state(page, NR_DIRTIED); |
2159 | dec_bdi_stat(mapping->backing_dev_info, BDI_DIRTIED); | 2161 | dec_bdi_stat(inode_to_bdi(mapping->host), BDI_DIRTIED); |
2160 | } | 2162 | } |
2161 | } | 2163 | } |
2162 | EXPORT_SYMBOL(account_page_redirty); | 2164 | EXPORT_SYMBOL(account_page_redirty); |
@@ -2298,7 +2300,7 @@ int clear_page_dirty_for_io(struct page *page) | |||
2298 | */ | 2300 | */ |
2299 | if (TestClearPageDirty(page)) { | 2301 | if (TestClearPageDirty(page)) { |
2300 | dec_zone_page_state(page, NR_FILE_DIRTY); | 2302 | dec_zone_page_state(page, NR_FILE_DIRTY); |
2301 | dec_bdi_stat(mapping->backing_dev_info, | 2303 | dec_bdi_stat(inode_to_bdi(mapping->host), |
2302 | BDI_RECLAIMABLE); | 2304 | BDI_RECLAIMABLE); |
2303 | return 1; | 2305 | return 1; |
2304 | } | 2306 | } |
@@ -2316,7 +2318,7 @@ int test_clear_page_writeback(struct page *page) | |||
2316 | 2318 | ||
2317 | memcg = mem_cgroup_begin_page_stat(page); | 2319 | memcg = mem_cgroup_begin_page_stat(page); |
2318 | if (mapping) { | 2320 | if (mapping) { |
2319 | struct backing_dev_info *bdi = mapping->backing_dev_info; | 2321 | struct backing_dev_info *bdi = inode_to_bdi(mapping->host); |
2320 | unsigned long flags; | 2322 | unsigned long flags; |
2321 | 2323 | ||
2322 | spin_lock_irqsave(&mapping->tree_lock, flags); | 2324 | spin_lock_irqsave(&mapping->tree_lock, flags); |
@@ -2351,7 +2353,7 @@ int __test_set_page_writeback(struct page *page, bool keep_write) | |||
2351 | 2353 | ||
2352 | memcg = mem_cgroup_begin_page_stat(page); | 2354 | memcg = mem_cgroup_begin_page_stat(page); |
2353 | if (mapping) { | 2355 | if (mapping) { |
2354 | struct backing_dev_info *bdi = mapping->backing_dev_info; | 2356 | struct backing_dev_info *bdi = inode_to_bdi(mapping->host); |
2355 | unsigned long flags; | 2357 | unsigned long flags; |
2356 | 2358 | ||
2357 | spin_lock_irqsave(&mapping->tree_lock, flags); | 2359 | spin_lock_irqsave(&mapping->tree_lock, flags); |
@@ -2405,12 +2407,7 @@ EXPORT_SYMBOL(mapping_tagged); | |||
2405 | */ | 2407 | */ |
2406 | void wait_for_stable_page(struct page *page) | 2408 | void wait_for_stable_page(struct page *page) |
2407 | { | 2409 | { |
2408 | struct address_space *mapping = page_mapping(page); | 2410 | if (bdi_cap_stable_pages_required(inode_to_bdi(page->mapping->host))) |
2409 | struct backing_dev_info *bdi = mapping->backing_dev_info; | 2411 | wait_on_page_writeback(page); |
2410 | |||
2411 | if (!bdi_cap_stable_pages_required(bdi)) | ||
2412 | return; | ||
2413 | |||
2414 | wait_on_page_writeback(page); | ||
2415 | } | 2412 | } |
2416 | EXPORT_SYMBOL_GPL(wait_for_stable_page); | 2413 | EXPORT_SYMBOL_GPL(wait_for_stable_page); |
diff --git a/mm/readahead.c b/mm/readahead.c index 17b9172ec37f..935675844b2e 100644 --- a/mm/readahead.c +++ b/mm/readahead.c | |||
@@ -27,7 +27,7 @@ | |||
27 | void | 27 | void |
28 | file_ra_state_init(struct file_ra_state *ra, struct address_space *mapping) | 28 | file_ra_state_init(struct file_ra_state *ra, struct address_space *mapping) |
29 | { | 29 | { |
30 | ra->ra_pages = mapping->backing_dev_info->ra_pages; | 30 | ra->ra_pages = inode_to_bdi(mapping->host)->ra_pages; |
31 | ra->prev_pos = -1; | 31 | ra->prev_pos = -1; |
32 | } | 32 | } |
33 | EXPORT_SYMBOL_GPL(file_ra_state_init); | 33 | EXPORT_SYMBOL_GPL(file_ra_state_init); |
@@ -541,7 +541,7 @@ page_cache_async_readahead(struct address_space *mapping, | |||
541 | /* | 541 | /* |
542 | * Defer asynchronous read-ahead on IO congestion. | 542 | * Defer asynchronous read-ahead on IO congestion. |
543 | */ | 543 | */ |
544 | if (bdi_read_congested(mapping->backing_dev_info)) | 544 | if (bdi_read_congested(inode_to_bdi(mapping->host))) |
545 | return; | 545 | return; |
546 | 546 | ||
547 | /* do read-ahead */ | 547 | /* do read-ahead */ |
diff --git a/mm/shmem.c b/mm/shmem.c index 864c878401e6..a63031fa3e0c 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,6 @@ 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; | ||
1419 | inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; | 1413 | inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; |
1420 | inode->i_generation = get_seconds(); | 1414 | inode->i_generation = get_seconds(); |
1421 | info = SHMEM_I(inode); | 1415 | info = SHMEM_I(inode); |
@@ -1461,7 +1455,7 @@ static struct inode *shmem_get_inode(struct super_block *sb, const struct inode | |||
1461 | 1455 | ||
1462 | bool shmem_mapping(struct address_space *mapping) | 1456 | bool shmem_mapping(struct address_space *mapping) |
1463 | { | 1457 | { |
1464 | return mapping->backing_dev_info == &shmem_backing_dev_info; | 1458 | return mapping->host->i_sb->s_op == &shmem_ops; |
1465 | } | 1459 | } |
1466 | 1460 | ||
1467 | #ifdef CONFIG_TMPFS | 1461 | #ifdef CONFIG_TMPFS |
@@ -3225,10 +3219,6 @@ int __init shmem_init(void) | |||
3225 | if (shmem_inode_cachep) | 3219 | if (shmem_inode_cachep) |
3226 | return 0; | 3220 | return 0; |
3227 | 3221 | ||
3228 | error = bdi_init(&shmem_backing_dev_info); | ||
3229 | if (error) | ||
3230 | goto out4; | ||
3231 | |||
3232 | error = shmem_init_inodecache(); | 3222 | error = shmem_init_inodecache(); |
3233 | if (error) | 3223 | if (error) |
3234 | goto out3; | 3224 | goto out3; |
@@ -3252,8 +3242,6 @@ out1: | |||
3252 | out2: | 3242 | out2: |
3253 | shmem_destroy_inodecache(); | 3243 | shmem_destroy_inodecache(); |
3254 | out3: | 3244 | out3: |
3255 | bdi_destroy(&shmem_backing_dev_info); | ||
3256 | out4: | ||
3257 | shm_mnt = ERR_PTR(error); | 3245 | shm_mnt = ERR_PTR(error); |
3258 | return error; | 3246 | return error; |
3259 | } | 3247 | } |
@@ -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 | #endif | 1143 | #endif |
diff --git a/mm/swap_state.c b/mm/swap_state.c index 9711342987a0..405923f77334 100644 --- a/mm/swap_state.c +++ b/mm/swap_state.c | |||
@@ -32,17 +32,11 @@ 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, | ||
46 | } | 40 | } |
47 | }; | 41 | }; |
48 | 42 | ||
diff --git a/mm/truncate.c b/mm/truncate.c index f1e4d6052369..ddec5a5966d7 100644 --- a/mm/truncate.c +++ b/mm/truncate.c | |||
@@ -112,7 +112,7 @@ void cancel_dirty_page(struct page *page, unsigned int account_size) | |||
112 | struct address_space *mapping = page->mapping; | 112 | struct address_space *mapping = page->mapping; |
113 | if (mapping && mapping_cap_account_dirty(mapping)) { | 113 | if (mapping && mapping_cap_account_dirty(mapping)) { |
114 | dec_zone_page_state(page, NR_FILE_DIRTY); | 114 | dec_zone_page_state(page, NR_FILE_DIRTY); |
115 | dec_bdi_stat(mapping->backing_dev_info, | 115 | dec_bdi_stat(inode_to_bdi(mapping->host), |
116 | BDI_RECLAIMABLE); | 116 | BDI_RECLAIMABLE); |
117 | if (account_size) | 117 | if (account_size) |
118 | task_io_account_cancelled_write(account_size); | 118 | task_io_account_cancelled_write(account_size); |
diff --git a/mm/vmscan.c b/mm/vmscan.c index 8e645ee52045..224dd298fdcd 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c | |||
@@ -500,7 +500,7 @@ static pageout_t pageout(struct page *page, struct address_space *mapping, | |||
500 | } | 500 | } |
501 | if (mapping->a_ops->writepage == NULL) | 501 | if (mapping->a_ops->writepage == NULL) |
502 | return PAGE_ACTIVATE; | 502 | return PAGE_ACTIVATE; |
503 | if (!may_write_to_queue(mapping->backing_dev_info, sc)) | 503 | if (!may_write_to_queue(inode_to_bdi(mapping->host), sc)) |
504 | return PAGE_KEEP; | 504 | return PAGE_KEEP; |
505 | 505 | ||
506 | if (clear_page_dirty_for_io(page)) { | 506 | if (clear_page_dirty_for_io(page)) { |
@@ -879,7 +879,7 @@ static unsigned long shrink_page_list(struct list_head *page_list, | |||
879 | */ | 879 | */ |
880 | mapping = page_mapping(page); | 880 | mapping = page_mapping(page); |
881 | if (((dirty || writeback) && mapping && | 881 | if (((dirty || writeback) && mapping && |
882 | bdi_write_congested(mapping->backing_dev_info)) || | 882 | bdi_write_congested(inode_to_bdi(mapping->host))) || |
883 | (writeback && PageReclaim(page))) | 883 | (writeback && PageReclaim(page))) |
884 | nr_congested++; | 884 | nr_congested++; |
885 | 885 | ||