aboutsummaryrefslogtreecommitdiffstats
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)
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 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,
1200 } 1200 }
1201 } 1201 }
1202 1202
1203 /* watch out for a 0 len io from a tricksy fs */
1204 if (rw == READ && end == offset)
1205 return 0;
1206
1203 dio = kmalloc(sizeof(*dio), GFP_KERNEL); 1207 dio = kmalloc(sizeof(*dio), GFP_KERNEL);
1204 retval = -ENOMEM; 1208 retval = -ENOMEM;
1205 if (!dio) 1209 if (!dio)
@@ -1213,8 +1217,7 @@ __blockdev_direct_IO(int rw, struct kiocb *iocb, struct inode *inode,
1213 1217
1214 dio->flags = flags; 1218 dio->flags = flags;
1215 if (dio->flags & DIO_LOCKING) { 1219 if (dio->flags & DIO_LOCKING) {
1216 /* watch out for a 0 len io from a tricksy fs */ 1220 if (rw == READ) {
1217 if (rw == READ && end > offset) {
1218 struct address_space *mapping = 1221 struct address_space *mapping =
1219 iocb->ki_filp->f_mapping; 1222 iocb->ki_filp->f_mapping;
1220 1223