summaryrefslogtreecommitdiffstats
path: root/fs/direct-io.c
diff options
context:
space:
mode:
authorIngo Molnar <mingo@kernel.org>2016-01-06 11:02:29 +0100
committerIngo Molnar <mingo@kernel.org>2016-01-06 11:02:29 +0100
commit567bee2803cb46caeb6011de5b738fde33dc3896 (patch)
tree05bab01377bffa356bfbe06c4b6193b23b7c24ca /fs/direct-io.c
parentaa0b7ae06387d40a988ce16a189082dee6e570bc (diff)
parent093e5840ae76f1082633503964d035f40ed0216d (diff)
downloadlinux-567bee2803cb46caeb6011de5b738fde33dc3896.tar.bz2
Merge branch 'sched/urgent' into sched/core, to pick up fixes before merging new patches
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'fs/direct-io.c')
-rw-r--r--fs/direct-io.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/fs/direct-io.c b/fs/direct-io.c
index cb5337d8c273..602e8441bc0f 100644
--- a/fs/direct-io.c
+++ b/fs/direct-io.c
@@ -1169,6 +1169,16 @@ do_blockdev_direct_IO(struct kiocb *iocb, struct inode *inode,
}
}
+ /* Once we sampled i_size check for reads beyond EOF */
+ dio->i_size = i_size_read(inode);
+ if (iov_iter_rw(iter) == READ && offset >= dio->i_size) {
+ if (dio->flags & DIO_LOCKING)
+ mutex_unlock(&inode->i_mutex);
+ kmem_cache_free(dio_cache, dio);
+ retval = 0;
+ goto out;
+ }
+
/*
* For file extending writes updating i_size before data writeouts
* complete can expose uninitialized blocks in dumb filesystems.
@@ -1222,7 +1232,6 @@ do_blockdev_direct_IO(struct kiocb *iocb, struct inode *inode,
sdio.next_block_for_io = -1;
dio->iocb = iocb;
- dio->i_size = i_size_read(inode);
spin_lock_init(&dio->bio_lock);
dio->refcount = 1;