diff options
Diffstat (limited to 'fs/block_dev.c')
-rw-r--r-- | fs/block_dev.c | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/fs/block_dev.c b/fs/block_dev.c index d11d0289f3d2..6dcee88c2e5d 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c | |||
@@ -404,20 +404,28 @@ static loff_t block_llseek(struct file *file, loff_t offset, int origin) | |||
404 | * NULL first argument is nfsd_sync_dir() and that's not a directory. | 404 | * NULL first argument is nfsd_sync_dir() and that's not a directory. |
405 | */ | 405 | */ |
406 | 406 | ||
407 | static int block_fsync(struct file *filp, struct dentry *dentry, int datasync) | 407 | int blkdev_fsync(struct file *filp, struct dentry *dentry, int datasync) |
408 | { | 408 | { |
409 | struct block_device *bdev = I_BDEV(filp->f_mapping->host); | 409 | struct inode *bd_inode = filp->f_mapping->host; |
410 | struct block_device *bdev = I_BDEV(bd_inode); | ||
410 | int error; | 411 | int error; |
411 | 412 | ||
412 | error = sync_blockdev(bdev); | 413 | /* |
413 | if (error) | 414 | * There is no need to serialise calls to blkdev_issue_flush with |
414 | return error; | 415 | * i_mutex and doing so causes performance issues with concurrent |
415 | 416 | * O_SYNC writers to a block device. | |
417 | */ | ||
418 | mutex_unlock(&bd_inode->i_mutex); | ||
419 | |||
416 | error = blkdev_issue_flush(bdev, NULL); | 420 | error = blkdev_issue_flush(bdev, NULL); |
417 | if (error == -EOPNOTSUPP) | 421 | if (error == -EOPNOTSUPP) |
418 | error = 0; | 422 | error = 0; |
423 | |||
424 | mutex_lock(&bd_inode->i_mutex); | ||
425 | |||
419 | return error; | 426 | return error; |
420 | } | 427 | } |
428 | EXPORT_SYMBOL(blkdev_fsync); | ||
421 | 429 | ||
422 | /* | 430 | /* |
423 | * pseudo-fs | 431 | * pseudo-fs |
@@ -1481,7 +1489,7 @@ const struct file_operations def_blk_fops = { | |||
1481 | .aio_read = generic_file_aio_read, | 1489 | .aio_read = generic_file_aio_read, |
1482 | .aio_write = blkdev_aio_write, | 1490 | .aio_write = blkdev_aio_write, |
1483 | .mmap = generic_file_mmap, | 1491 | .mmap = generic_file_mmap, |
1484 | .fsync = block_fsync, | 1492 | .fsync = blkdev_fsync, |
1485 | .unlocked_ioctl = block_ioctl, | 1493 | .unlocked_ioctl = block_ioctl, |
1486 | #ifdef CONFIG_COMPAT | 1494 | #ifdef CONFIG_COMPAT |
1487 | .compat_ioctl = compat_blkdev_ioctl, | 1495 | .compat_ioctl = compat_blkdev_ioctl, |