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.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/fs/block_dev.c b/fs/block_dev.c
index 575076c018f4..742899240872 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -22,6 +22,7 @@
22#include <linux/mount.h> 22#include <linux/mount.h>
23#include <linux/uio.h> 23#include <linux/uio.h>
24#include <linux/namei.h> 24#include <linux/namei.h>
25#include <linux/log2.h>
25#include <asm/uaccess.h> 26#include <asm/uaccess.h>
26#include "internal.h" 27#include "internal.h"
27 28
@@ -55,17 +56,19 @@ static sector_t max_block(struct block_device *bdev)
55 return retval; 56 return retval;
56} 57}
57 58
58/* Kill _all_ buffers, dirty or not.. */ 59/* Kill _all_ buffers and pagecache , dirty or not.. */
59static void kill_bdev(struct block_device *bdev) 60static void kill_bdev(struct block_device *bdev)
60{ 61{
61 invalidate_bdev(bdev, 1); 62 if (bdev->bd_inode->i_mapping->nrpages == 0)
63 return;
64 invalidate_bh_lrus();
62 truncate_inode_pages(bdev->bd_inode->i_mapping, 0); 65 truncate_inode_pages(bdev->bd_inode->i_mapping, 0);
63} 66}
64 67
65int set_blocksize(struct block_device *bdev, int size) 68int set_blocksize(struct block_device *bdev, int size)
66{ 69{
67 /* Size must be a power of two, and between 512 and PAGE_SIZE */ 70 /* Size must be a power of two, and between 512 and PAGE_SIZE */
68 if (size > PAGE_SIZE || size < 512 || (size & (size-1))) 71 if (size > PAGE_SIZE || size < 512 || !is_power_of_2(size))
69 return -EINVAL; 72 return -EINVAL;
70 73
71 /* Size cannot be smaller than the size supported by the device */ 74 /* Size cannot be smaller than the size supported by the device */
@@ -455,9 +458,7 @@ static void init_once(void * foo, struct kmem_cache * cachep, unsigned long flag
455 struct bdev_inode *ei = (struct bdev_inode *) foo; 458 struct bdev_inode *ei = (struct bdev_inode *) foo;
456 struct block_device *bdev = &ei->bdev; 459 struct block_device *bdev = &ei->bdev;
457 460
458 if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) == 461 if (flags & SLAB_CTOR_CONSTRUCTOR) {
459 SLAB_CTOR_CONSTRUCTOR)
460 {
461 memset(bdev, 0, sizeof(*bdev)); 462 memset(bdev, 0, sizeof(*bdev));
462 mutex_init(&bdev->bd_mutex); 463 mutex_init(&bdev->bd_mutex);
463 sema_init(&bdev->bd_mount_sem, 1); 464 sema_init(&bdev->bd_mount_sem, 1);
@@ -1478,7 +1479,7 @@ int __invalidate_device(struct block_device *bdev)
1478 res = invalidate_inodes(sb); 1479 res = invalidate_inodes(sb);
1479 drop_super(sb); 1480 drop_super(sb);
1480 } 1481 }
1481 invalidate_bdev(bdev, 0); 1482 invalidate_bdev(bdev);
1482 return res; 1483 return res;
1483} 1484}
1484EXPORT_SYMBOL(__invalidate_device); 1485EXPORT_SYMBOL(__invalidate_device);