diff options
Diffstat (limited to 'fs')
-rw-r--r-- | fs/block_dev.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/fs/block_dev.c b/fs/block_dev.c index a1e09b4fe1ba..ab3a456f6650 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c | |||
@@ -1544,6 +1544,22 @@ ssize_t blkdev_aio_write(struct kiocb *iocb, const struct iovec *iov, | |||
1544 | } | 1544 | } |
1545 | EXPORT_SYMBOL_GPL(blkdev_aio_write); | 1545 | EXPORT_SYMBOL_GPL(blkdev_aio_write); |
1546 | 1546 | ||
1547 | static ssize_t blkdev_aio_read(struct kiocb *iocb, const struct iovec *iov, | ||
1548 | unsigned long nr_segs, loff_t pos) | ||
1549 | { | ||
1550 | struct file *file = iocb->ki_filp; | ||
1551 | struct inode *bd_inode = file->f_mapping->host; | ||
1552 | loff_t size = i_size_read(bd_inode); | ||
1553 | |||
1554 | if (pos >= size) | ||
1555 | return 0; | ||
1556 | |||
1557 | size -= pos; | ||
1558 | if (size < INT_MAX) | ||
1559 | nr_segs = iov_shorten((struct iovec *)iov, nr_segs, size); | ||
1560 | return generic_file_aio_read(iocb, iov, nr_segs, pos); | ||
1561 | } | ||
1562 | |||
1547 | /* | 1563 | /* |
1548 | * Try to release a page associated with block device when the system | 1564 | * Try to release a page associated with block device when the system |
1549 | * is under memory pressure. | 1565 | * is under memory pressure. |
@@ -1574,7 +1590,7 @@ const struct file_operations def_blk_fops = { | |||
1574 | .llseek = block_llseek, | 1590 | .llseek = block_llseek, |
1575 | .read = do_sync_read, | 1591 | .read = do_sync_read, |
1576 | .write = do_sync_write, | 1592 | .write = do_sync_write, |
1577 | .aio_read = generic_file_aio_read, | 1593 | .aio_read = blkdev_aio_read, |
1578 | .aio_write = blkdev_aio_write, | 1594 | .aio_write = blkdev_aio_write, |
1579 | .mmap = generic_file_mmap, | 1595 | .mmap = generic_file_mmap, |
1580 | .fsync = blkdev_fsync, | 1596 | .fsync = blkdev_fsync, |