summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuo Chao <yan@linux.vnet.ibm.com>2013-02-21 15:16:42 -0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-03-20 13:05:00 -0700
commitd72b4f90a2b042136f74a3de50b29d6ce76b5f12 (patch)
tree61006b7819cf5bf3eebe63702f0aa6a8eb095c15
parent969ff7dc5423e50938e7b42b59fe1163aced714c (diff)
block: use i_size_write() in bd_set_size()
commit d646a02a9d44d1421f273ae3923d97b47b918176 upstream. blkdev_ioctl(GETBLKSIZE) uses i_size_read() to read size of block device. If we update block size directly, reader may see intermediate result in some machines and configurations. Use i_size_write() instead. Signed-off-by: Guo Chao <yan@linux.vnet.ibm.com> Cc: Alexander Viro <viro@zeniv.linux.org.uk> Cc: Guo Chao <yan@linux.vnet.ibm.com> Cc: M. Hindess <hindessm@uk.ibm.com> Cc: Nikanth Karthikesan <knikanth@suse.de> Cc: Jens Axboe <axboe@kernel.dk> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Jens Axboe <axboe@kernel.dk> Acked-by: Jeff Mahoney <jeffm@suse.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--fs/block_dev.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/fs/block_dev.c b/fs/block_dev.c
index b3be92c980ee..a6e1e06e4bb8 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -1086,7 +1086,9 @@ void bd_set_size(struct block_device *bdev, loff_t size)
{
unsigned bsize = bdev_logical_block_size(bdev);
- bdev->bd_inode->i_size = size;
+ mutex_lock(&bdev->bd_inode->i_mutex);
+ i_size_write(bdev->bd_inode, size);
+ mutex_unlock(&bdev->bd_inode->i_mutex);
while (bsize < PAGE_CACHE_SIZE) {
if (size & bsize)
break;