aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
Diffstat (limited to 'fs')
-rw-r--r--fs/block_dev.c29
1 files changed, 28 insertions, 1 deletions
diff --git a/fs/block_dev.c b/fs/block_dev.c
index 94dfda24c06e..3581a4e53942 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -1405,6 +1405,33 @@ static long block_ioctl(struct file *file, unsigned cmd, unsigned long arg)
1405} 1405}
1406 1406
1407/* 1407/*
1408 * Write data to the block device. Only intended for the block device itself
1409 * and the raw driver which basically is a fake block device.
1410 *
1411 * Does not take i_mutex for the write and thus is not for general purpose
1412 * use.
1413 */
1414ssize_t blkdev_aio_write(struct kiocb *iocb, const struct iovec *iov,
1415 unsigned long nr_segs, loff_t pos)
1416{
1417 struct file *file = iocb->ki_filp;
1418 ssize_t ret;
1419
1420 BUG_ON(iocb->ki_pos != pos);
1421
1422 ret = __generic_file_aio_write(iocb, iov, nr_segs, &iocb->ki_pos);
1423 if (ret > 0 || ret == -EIOCBQUEUED) {
1424 ssize_t err;
1425
1426 err = generic_write_sync(file, pos, ret);
1427 if (err < 0 && ret > 0)
1428 ret = err;
1429 }
1430 return ret;
1431}
1432EXPORT_SYMBOL_GPL(blkdev_aio_write);
1433
1434/*
1408 * Try to release a page associated with block device when the system 1435 * Try to release a page associated with block device when the system
1409 * is under memory pressure. 1436 * is under memory pressure.
1410 */ 1437 */
@@ -1436,7 +1463,7 @@ const struct file_operations def_blk_fops = {
1436 .read = do_sync_read, 1463 .read = do_sync_read,
1437 .write = do_sync_write, 1464 .write = do_sync_write,
1438 .aio_read = generic_file_aio_read, 1465 .aio_read = generic_file_aio_read,
1439 .aio_write = generic_file_aio_write_nolock, 1466 .aio_write = blkdev_aio_write,
1440 .mmap = generic_file_mmap, 1467 .mmap = generic_file_mmap,
1441 .fsync = block_fsync, 1468 .fsync = block_fsync,
1442 .unlocked_ioctl = block_ioctl, 1469 .unlocked_ioctl = block_ioctl,