aboutsummaryrefslogtreecommitdiffstats
path: root/fs/block_dev.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/block_dev.c')
-rw-r--r--fs/block_dev.c38
1 files changed, 33 insertions, 5 deletions
diff --git a/fs/block_dev.c b/fs/block_dev.c
index b07f1da1de4e..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.. */
85static void kill_bdev(struct block_device *bdev) 87void 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}
97EXPORT_SYMBOL(kill_bdev);
98
99/* Invalidate clean unused buffers and pagecache. */
100void 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}
115EXPORT_SYMBOL(invalidate_bdev);
92 116
93int set_blocksize(struct block_device *bdev, int size) 117int set_blocksize(struct block_device *bdev, int size)
94{ 118{
@@ -425,7 +449,6 @@ static void bdev_i_callback(struct rcu_head *head)
425 struct inode *inode = container_of(head, struct inode, i_rcu); 449 struct inode *inode = container_of(head, struct inode, i_rcu);
426 struct bdev_inode *bdi = BDEV_I(inode); 450 struct bdev_inode *bdi = BDEV_I(inode);
427 451
428 INIT_LIST_HEAD(&inode->i_dentry);
429 kmem_cache_free(bdev_cachep, bdi); 452 kmem_cache_free(bdev_cachep, bdi);
430} 453}
431 454
@@ -493,7 +516,7 @@ static struct file_system_type bd_type = {
493 .kill_sb = kill_anon_super, 516 .kill_sb = kill_anon_super,
494}; 517};
495 518
496struct super_block *blockdev_superblock __read_mostly; 519static struct super_block *blockdev_superblock __read_mostly;
497 520
498void __init bdev_cache_init(void) 521void __init bdev_cache_init(void)
499{ 522{
@@ -639,6 +662,11 @@ static struct block_device *bd_acquire(struct inode *inode)
639 return bdev; 662 return bdev;
640} 663}
641 664
665static inline int sb_is_blkdev_sb(struct super_block *sb)
666{
667 return sb == blockdev_superblock;
668}
669
642/* Call when you free inode */ 670/* Call when you free inode */
643 671
644void bd_forget(struct inode *inode) 672void bd_forget(struct inode *inode)