Commit d646a02a authored by Guo Chao's avatar Guo Chao Committed by Jens Axboe

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: default avatarGuo 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: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent a3cc86c2
...@@ -1032,7 +1032,9 @@ void bd_set_size(struct block_device *bdev, loff_t size) ...@@ -1032,7 +1032,9 @@ void bd_set_size(struct block_device *bdev, loff_t size)
{ {
unsigned bsize = bdev_logical_block_size(bdev); 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) { while (bsize < PAGE_CACHE_SIZE) {
if (size & bsize) if (size & bsize)
break; break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment