Skip to content

Commit

Permalink
fs: simplify handling of zero sized reads in __blockdev_direct_IO
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Al Viro <[email protected]>
  • Loading branch information
Christoph Hellwig authored and Al Viro committed Jul 21, 2011
1 parent 9ea7df5 commit f9b5570
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions fs/direct-io.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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;

Expand Down

0 comments on commit f9b5570

Please sign in to comment.