diff options
author | Christoph Hellwig <hch@lst.de> | 2015-01-14 04:42:36 -0500 |
---|---|---|
committer | Jens Axboe <axboe@fb.com> | 2015-01-20 16:03:04 -0500 |
commit | de1414a654e66b81b5348dbc5259ecf2fb61655e (patch) | |
tree | 2b3d60d6c0dc87ba33caff3e326d5648831d6176 /mm | |
parent | 26ff13047e3dc6c0230a629867e8dbd4a15a7626 (diff) |
fs: export inode_to_bdi and use it in favor of mapping->backing_dev_info
Now that we got rid of the bdi abuse on character devices we can always use
sb->s_bdi to get at the backing_dev_info for a file, except for the block
device special case. Export inode_to_bdi and replace uses of
mapping->backing_dev_info with it to prepare for the removal of
mapping->backing_dev_info.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Tejun Heo <tj@kernel.org>
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'mm')
-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/page-writeback.c | 29 | ||||
-rw-r--r-- | mm/readahead.c | 4 | ||||
-rw-r--r-- | mm/truncate.c | 2 | ||||
-rw-r--r-- | mm/vmscan.c | 4 |
7 files changed, 24 insertions, 26 deletions
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 673e4581a2e5..5d7c23c26f81 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 | ||
@@ -2565,7 +2565,7 @@ ssize_t __generic_file_write_iter(struct kiocb *iocb, struct iov_iter *from) | |||
2565 | size_t count = iov_iter_count(from); | 2565 | size_t count = iov_iter_count(from); |
2566 | 2566 | ||
2567 | /* We can write back this queue in page reclaim */ | 2567 | /* We can write back this queue in page reclaim */ |
2568 | current->backing_dev_info = mapping->backing_dev_info; | 2568 | current->backing_dev_info = inode_to_bdi(inode); |
2569 | err = generic_write_checks(file, &pos, &count, S_ISBLK(inode->i_mode)); | 2569 | err = generic_write_checks(file, &pos, &count, S_ISBLK(inode->i_mode)); |
2570 | if (err) | 2570 | if (err) |
2571 | goto out; | 2571 | goto out; |
diff --git a/mm/filemap_xip.c b/mm/filemap_xip.c index 0d105aeff82f..26897fbfbe19 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> |
@@ -410,7 +411,7 @@ xip_file_write(struct file *filp, const char __user *buf, size_t len, | |||
410 | count = len; | 411 | count = len; |
411 | 412 | ||
412 | /* We can write back this queue in page reclaim */ | 413 | /* We can write back this queue in page reclaim */ |
413 | current->backing_dev_info = mapping->backing_dev_info; | 414 | current->backing_dev_info = inode_to_bdi(inode); |
414 | 415 | ||
415 | ret = generic_write_checks(filp, &pos, &count, S_ISBLK(inode->i_mode)); | 416 | ret = generic_write_checks(filp, &pos, &count, S_ISBLK(inode->i_mode)); |
416 | if (ret) | 417 | if (ret) |
diff --git a/mm/page-writeback.c b/mm/page-writeback.c index 6f4335238e33..d4cbb4bd7d1c 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); |
@@ -2295,7 +2297,7 @@ int clear_page_dirty_for_io(struct page *page) | |||
2295 | */ | 2297 | */ |
2296 | if (TestClearPageDirty(page)) { | 2298 | if (TestClearPageDirty(page)) { |
2297 | dec_zone_page_state(page, NR_FILE_DIRTY); | 2299 | dec_zone_page_state(page, NR_FILE_DIRTY); |
2298 | dec_bdi_stat(mapping->backing_dev_info, | 2300 | dec_bdi_stat(inode_to_bdi(mapping->host), |
2299 | BDI_RECLAIMABLE); | 2301 | BDI_RECLAIMABLE); |
2300 | return 1; | 2302 | return 1; |
2301 | } | 2303 | } |
@@ -2315,7 +2317,7 @@ int test_clear_page_writeback(struct page *page) | |||
2315 | 2317 | ||
2316 | memcg = mem_cgroup_begin_page_stat(page, &locked, &memcg_flags); | 2318 | memcg = mem_cgroup_begin_page_stat(page, &locked, &memcg_flags); |
2317 | if (mapping) { | 2319 | if (mapping) { |
2318 | struct backing_dev_info *bdi = mapping->backing_dev_info; | 2320 | struct backing_dev_info *bdi = inode_to_bdi(mapping->host); |
2319 | unsigned long flags; | 2321 | unsigned long flags; |
2320 | 2322 | ||
2321 | spin_lock_irqsave(&mapping->tree_lock, flags); | 2323 | spin_lock_irqsave(&mapping->tree_lock, flags); |
@@ -2352,7 +2354,7 @@ int __test_set_page_writeback(struct page *page, bool keep_write) | |||
2352 | 2354 | ||
2353 | memcg = mem_cgroup_begin_page_stat(page, &locked, &memcg_flags); | 2355 | memcg = mem_cgroup_begin_page_stat(page, &locked, &memcg_flags); |
2354 | if (mapping) { | 2356 | if (mapping) { |
2355 | struct backing_dev_info *bdi = mapping->backing_dev_info; | 2357 | struct backing_dev_info *bdi = inode_to_bdi(mapping->host); |
2356 | unsigned long flags; | 2358 | unsigned long flags; |
2357 | 2359 | ||
2358 | spin_lock_irqsave(&mapping->tree_lock, flags); | 2360 | spin_lock_irqsave(&mapping->tree_lock, flags); |
@@ -2406,12 +2408,7 @@ EXPORT_SYMBOL(mapping_tagged); | |||
2406 | */ | 2408 | */ |
2407 | void wait_for_stable_page(struct page *page) | 2409 | void wait_for_stable_page(struct page *page) |
2408 | { | 2410 | { |
2409 | struct address_space *mapping = page_mapping(page); | 2411 | if (bdi_cap_stable_pages_required(inode_to_bdi(page->mapping->host))) |
2410 | struct backing_dev_info *bdi = mapping->backing_dev_info; | 2412 | wait_on_page_writeback(page); |
2411 | |||
2412 | if (!bdi_cap_stable_pages_required(bdi)) | ||
2413 | return; | ||
2414 | |||
2415 | wait_on_page_writeback(page); | ||
2416 | } | 2413 | } |
2417 | EXPORT_SYMBOL_GPL(wait_for_stable_page); | 2414 | 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/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 ab2505c3ef54..e00a16393f21 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c | |||
@@ -497,7 +497,7 @@ static pageout_t pageout(struct page *page, struct address_space *mapping, | |||
497 | } | 497 | } |
498 | if (mapping->a_ops->writepage == NULL) | 498 | if (mapping->a_ops->writepage == NULL) |
499 | return PAGE_ACTIVATE; | 499 | return PAGE_ACTIVATE; |
500 | if (!may_write_to_queue(mapping->backing_dev_info, sc)) | 500 | if (!may_write_to_queue(inode_to_bdi(mapping->host), sc)) |
501 | return PAGE_KEEP; | 501 | return PAGE_KEEP; |
502 | 502 | ||
503 | if (clear_page_dirty_for_io(page)) { | 503 | if (clear_page_dirty_for_io(page)) { |
@@ -876,7 +876,7 @@ static unsigned long shrink_page_list(struct list_head *page_list, | |||
876 | */ | 876 | */ |
877 | mapping = page_mapping(page); | 877 | mapping = page_mapping(page); |
878 | if (((dirty || writeback) && mapping && | 878 | if (((dirty || writeback) && mapping && |
879 | bdi_write_congested(mapping->backing_dev_info)) || | 879 | bdi_write_congested(inode_to_bdi(mapping->host))) || |
880 | (writeback && PageReclaim(page))) | 880 | (writeback && PageReclaim(page))) |
881 | nr_congested++; | 881 | nr_congested++; |
882 | 882 | ||