diff options
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 | { |