diff options
-rw-r--r-- | fs/fuse/file.c | 3 | ||||
-rw-r--r-- | mm/filemap.c | 42 |
2 files changed, 23 insertions, 22 deletions
diff --git a/fs/fuse/file.c b/fs/fuse/file.c index 7e70506297bc..89fdfd1919af 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c | |||
@@ -2710,6 +2710,9 @@ fuse_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov, | |||
2710 | inode = file->f_mapping->host; | 2710 | inode = file->f_mapping->host; |
2711 | i_size = i_size_read(inode); | 2711 | i_size = i_size_read(inode); |
2712 | 2712 | ||
2713 | if ((rw == READ) && (offset > i_size)) | ||
2714 | return 0; | ||
2715 | |||
2713 | /* optimization for short read */ | 2716 | /* optimization for short read */ |
2714 | if (async_dio && rw != WRITE && offset + count > i_size) { | 2717 | if (async_dio && rw != WRITE && offset + count > i_size) { |
2715 | if (offset >= i_size) | 2718 | if (offset >= i_size) |
diff --git a/mm/filemap.c b/mm/filemap.c index b7749a92021c..01842867c9d2 100644 --- a/mm/filemap.c +++ b/mm/filemap.c | |||
@@ -1428,30 +1428,28 @@ generic_file_aio_read(struct kiocb *iocb, const struct iovec *iov, | |||
1428 | if (!count) | 1428 | if (!count) |
1429 | goto out; /* skip atime */ | 1429 | goto out; /* skip atime */ |
1430 | size = i_size_read(inode); | 1430 | size = i_size_read(inode); |
1431 | if (pos < size) { | 1431 | retval = filemap_write_and_wait_range(mapping, pos, |
1432 | retval = filemap_write_and_wait_range(mapping, pos, | ||
1433 | pos + iov_length(iov, nr_segs) - 1); | 1432 | pos + iov_length(iov, nr_segs) - 1); |
1434 | if (!retval) { | 1433 | if (!retval) { |
1435 | retval = mapping->a_ops->direct_IO(READ, iocb, | 1434 | retval = mapping->a_ops->direct_IO(READ, iocb, |
1436 | iov, pos, nr_segs); | 1435 | iov, pos, nr_segs); |
1437 | } | 1436 | } |
1438 | if (retval > 0) { | 1437 | if (retval > 0) { |
1439 | *ppos = pos + retval; | 1438 | *ppos = pos + retval; |
1440 | count -= retval; | 1439 | count -= retval; |
1441 | } | 1440 | } |
1442 | 1441 | ||
1443 | /* | 1442 | /* |
1444 | * Btrfs can have a short DIO read if we encounter | 1443 | * Btrfs can have a short DIO read if we encounter |
1445 | * compressed extents, so if there was an error, or if | 1444 | * compressed extents, so if there was an error, or if |
1446 | * we've already read everything we wanted to, or if | 1445 | * we've already read everything we wanted to, or if |
1447 | * there was a short read because we hit EOF, go ahead | 1446 | * there was a short read because we hit EOF, go ahead |
1448 | * and return. Otherwise fallthrough to buffered io for | 1447 | * and return. Otherwise fallthrough to buffered io for |
1449 | * the rest of the read. | 1448 | * the rest of the read. |
1450 | */ | 1449 | */ |
1451 | if (retval < 0 || !count || *ppos >= size) { | 1450 | if (retval < 0 || !count || *ppos >= size) { |
1452 | file_accessed(filp); | 1451 | file_accessed(filp); |
1453 | goto out; | 1452 | goto out; |
1454 | } | ||
1455 | } | 1453 | } |
1456 | } | 1454 | } |
1457 | 1455 | ||