diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2011-09-16 02:31:11 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2012-01-03 22:54:07 -0500 |
commit | ff01bb4832651c6d25ac509a06a10fcbd75c461c (patch) | |
tree | bbfdebd317db97d346df78293566f36e883b1be9 /fs/block_dev.c | |
parent | 94ea4158f1733e3b10cef067d535f504866e0c41 (diff) |
fs: move code out of buffer.c
Move invalidate_bdev, block_sync_page into fs/block_dev.c. Export
kill_bdev as well, so brd doesn't have to open code it. Reduce
buffer_head.h requirement accordingly.
Removed a rather large comment from invalidate_bdev, as it looked a bit
obsolete to bother moving. The small comment replacing it says enough.
Signed-off-by: Nick Piggin <npiggin@suse.de>
Cc: Al Viro <viro@ZenIV.linux.org.uk>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/block_dev.c')
-rw-r--r-- | fs/block_dev.c | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/fs/block_dev.c b/fs/block_dev.c index 7866cdd9fe70..69a5b6fbee2b 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c | |||
@@ -17,6 +17,7 @@ | |||
17 | #include <linux/module.h> | 17 | #include <linux/module.h> |
18 | #include <linux/blkpg.h> | 18 | #include <linux/blkpg.h> |
19 | #include <linux/buffer_head.h> | 19 | #include <linux/buffer_head.h> |
20 | #include <linux/swap.h> | ||
20 | #include <linux/pagevec.h> | 21 | #include <linux/pagevec.h> |
21 | #include <linux/writeback.h> | 22 | #include <linux/writeback.h> |
22 | #include <linux/mpage.h> | 23 | #include <linux/mpage.h> |
@@ -25,6 +26,7 @@ | |||
25 | #include <linux/namei.h> | 26 | #include <linux/namei.h> |
26 | #include <linux/log2.h> | 27 | #include <linux/log2.h> |
27 | #include <linux/kmemleak.h> | 28 | #include <linux/kmemleak.h> |
29 | #include <linux/cleancache.h> | ||
28 | #include <asm/uaccess.h> | 30 | #include <asm/uaccess.h> |
29 | #include "internal.h" | 31 | #include "internal.h" |
30 | 32 | ||
@@ -82,13 +84,35 @@ static sector_t max_block(struct block_device *bdev) | |||
82 | } | 84 | } |
83 | 85 | ||
84 | /* Kill _all_ buffers and pagecache , dirty or not.. */ | 86 | /* Kill _all_ buffers and pagecache , dirty or not.. */ |
85 | static void kill_bdev(struct block_device *bdev) | 87 | void kill_bdev(struct block_device *bdev) |
86 | { | 88 | { |
87 | if (bdev->bd_inode->i_mapping->nrpages == 0) | 89 | struct address_space *mapping = bdev->bd_inode->i_mapping; |
90 | |||
91 | if (mapping->nrpages == 0) | ||
88 | return; | 92 | return; |
93 | |||
89 | invalidate_bh_lrus(); | 94 | invalidate_bh_lrus(); |
90 | truncate_inode_pages(bdev->bd_inode->i_mapping, 0); | 95 | truncate_inode_pages(mapping, 0); |
91 | } | 96 | } |
97 | EXPORT_SYMBOL(kill_bdev); | ||
98 | |||
99 | /* Invalidate clean unused buffers and pagecache. */ | ||
100 | void invalidate_bdev(struct block_device *bdev) | ||
101 | { | ||
102 | struct address_space *mapping = bdev->bd_inode->i_mapping; | ||
103 | |||
104 | if (mapping->nrpages == 0) | ||
105 | return; | ||
106 | |||
107 | invalidate_bh_lrus(); | ||
108 | lru_add_drain_all(); /* make sure all lru add caches are flushed */ | ||
109 | invalidate_mapping_pages(mapping, 0, -1); | ||
110 | /* 99% of the time, we don't need to flush the cleancache on the bdev. | ||
111 | * But, for the strange corners, lets be cautious | ||
112 | */ | ||
113 | cleancache_flush_inode(mapping); | ||
114 | } | ||
115 | EXPORT_SYMBOL(invalidate_bdev); | ||
92 | 116 | ||
93 | int set_blocksize(struct block_device *bdev, int size) | 117 | int set_blocksize(struct block_device *bdev, int size) |
94 | { | 118 | { |