From: Guo Chao Date: Wed, 20 Feb 2013 02:13:53 +0000 (+1100) Subject: block: use i_size_write() in bd_set_size() X-Git-Tag: next-20130220~1^2~610 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=e1b20bca11278c76a6d4a89576dcd39eef8e4a15;p=karo-tx-linux.git block: use i_size_write() in bd_set_size() 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 Cc: Alexander Viro Cc: Guo Chao Cc: M. Hindess Cc: Nikanth Karthikesan Cc: Jens Axboe Signed-off-by: Andrew Morton --- diff --git a/fs/block_dev.c b/fs/block_dev.c index 78333a37f49d..78edf767b5cc 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c @@ -1033,7 +1033,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;