From: Christoph Hellwig Date: Fri, 24 Jun 2011 18:29:42 +0000 (-0400) Subject: fs: simplify handling of zero sized reads in __blockdev_direct_IO X-Git-Url: http://git.cdn.openwrt.org/?a=commitdiff_plain;h=f9b5570d7fdedff32a2e78102bfb54cd1b12b289;p=openwrt%2Fstaging%2Fblogic.git 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 Signed-off-by: Al Viro --- diff --git a/fs/direct-io.c b/fs/direct-io.c index ac5f164170e3..98ce3ac0d94b 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;