Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f9b5570d authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Al Viro
Browse files

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: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 9ea7df53
Loading
Loading
Loading
Loading
+5 −2
Original line number Original line Diff line number Diff line
@@ -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);
	dio = kmalloc(sizeof(*dio), GFP_KERNEL);
	retval = -ENOMEM;
	retval = -ENOMEM;
	if (!dio)
	if (!dio)
@@ -1213,8 +1217,7 @@ __blockdev_direct_IO(int rw, struct kiocb *iocb, struct inode *inode,


	dio->flags = flags;
	dio->flags = flags;
	if (dio->flags & DIO_LOCKING) {
	if (dio->flags & DIO_LOCKING) {
		/* watch out for a 0 len io from a tricksy fs */
		if (rw == READ) {
		if (rw == READ && end > offset) {
			struct address_space *mapping =
			struct address_space *mapping =
					iocb->ki_filp->f_mapping;
					iocb->ki_filp->f_mapping;