summaryrefslogtreecommitdiffstats
path: root/fs/direct-io.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@infradead.org>2011-06-24 14:29:42 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2011-07-20 20:47:45 -0400
commitf9b5570d7fdedff32a2e78102bfb54cd1b12b289 (patch)
tree0bbe650c809d96b25d746c400e316c3ad71b4097 /fs/direct-io.c
parent9ea7df534ed2a18157434a496a12cf073ca00c52 (diff)
downloadop-kernel-dev-f9b5570d7fdedff32a2e78102bfb54cd1b12b289.zip
op-kernel-dev-f9b5570d7fdedff32a2e78102bfb54cd1b12b289.tar.gz
fs: simplify handling of zero sized reads in __blockdev_direct_IO
Reject zero sized reads as soon as we know our I/O length, and don't borther with locks or allocations that might have to be cleaned up otherwise. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/direct-io.c')
-rw-r--r--fs/direct-io.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/fs/direct-io.c b/fs/direct-io.c
index ac5f164..98ce3ac 100644
--- a/fs/direct-io.c
+++ b/fs/direct-io.c
@@ -1200,6 +1200,10 @@ __blockdev_direct_IO(int rw, struct kiocb *iocb, struct inode *inode,
}
}
+ /* watch out for a 0 len io from a tricksy fs */
+ if (rw == READ && end == offset)
+ return 0;
+
dio = kmalloc(sizeof(*dio), GFP_KERNEL);
retval = -ENOMEM;
if (!dio)
@@ -1213,8 +1217,7 @@ __blockdev_direct_IO(int rw, struct kiocb *iocb, struct inode *inode,
dio->flags = flags;
if (dio->flags & DIO_LOCKING) {
- /* watch out for a 0 len io from a tricksy fs */
- if (rw == READ && end > offset) {
+ if (rw == READ) {
struct address_space *mapping =
iocb->ki_filp->f_mapping;
OpenPOWER on IntegriCloud