Commit 11fa977e authored by Hugh Dickins's avatar Hugh Dickins Committed by Linus Torvalds

generic_file_aio_read() cleanups

As akpm points out, there's really no need for generic_file_aio_read to
make a special case of count 0: just loop through nr_segs doing nothing.
And as Harvey Harrison points out, there's no need to reset retval to 0
where it's already 0.

Setting count (or ocount) to 0 before calling generic_segment_checks is
unnecessary too; but reluctantly I'll leave that removal to someone with a
wider range of gcc versions to hand - 4.1.2 and 4.2.1 don't warn about it,
but perhaps others do - I forget which are the warniest versions.
Signed-off-by: default avatarHugh Dickins <hugh@veritas.com>
Tested-by: default avatarLawrence Greenfield <leg@google.com>
Cc: Christoph Rohland <hans-christoph.rohland@sap.com>
Cc: Badari Pulavarty <pbadari@us.ibm.com>
Cc: Zach Brown <zach.brown@oracle.com>
Cc: Nick Piggin <nickpiggin@yahoo.com.au>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent a858f7b2
...@@ -1197,7 +1197,6 @@ generic_file_aio_read(struct kiocb *iocb, const struct iovec *iov, ...@@ -1197,7 +1197,6 @@ generic_file_aio_read(struct kiocb *iocb, const struct iovec *iov,
mapping = filp->f_mapping; mapping = filp->f_mapping;
inode = mapping->host; inode = mapping->host;
retval = 0;
if (!count) if (!count)
goto out; /* skip atime */ goto out; /* skip atime */
size = i_size_read(inode); size = i_size_read(inode);
...@@ -1209,15 +1208,13 @@ generic_file_aio_read(struct kiocb *iocb, const struct iovec *iov, ...@@ -1209,15 +1208,13 @@ generic_file_aio_read(struct kiocb *iocb, const struct iovec *iov,
} }
if (retval > 0) if (retval > 0)
*ppos = pos + retval; *ppos = pos + retval;
} if (retval) {
if (likely(retval != 0)) {
file_accessed(filp); file_accessed(filp);
goto out; goto out;
} }
} }
}
retval = 0;
if (count) {
for (seg = 0; seg < nr_segs; seg++) { for (seg = 0; seg < nr_segs; seg++) {
read_descriptor_t desc; read_descriptor_t desc;
...@@ -1227,7 +1224,7 @@ generic_file_aio_read(struct kiocb *iocb, const struct iovec *iov, ...@@ -1227,7 +1224,7 @@ generic_file_aio_read(struct kiocb *iocb, const struct iovec *iov,
if (desc.count == 0) if (desc.count == 0)
continue; continue;
desc.error = 0; desc.error = 0;
do_generic_file_read(filp,ppos,&desc,file_read_actor); do_generic_file_read(filp, ppos, &desc, file_read_actor);
retval += desc.written; retval += desc.written;
if (desc.error) { if (desc.error) {
retval = retval ?: desc.error; retval = retval ?: desc.error;
...@@ -1236,7 +1233,6 @@ generic_file_aio_read(struct kiocb *iocb, const struct iovec *iov, ...@@ -1236,7 +1233,6 @@ generic_file_aio_read(struct kiocb *iocb, const struct iovec *iov,
if (desc.count > 0) if (desc.count > 0)
break; break;
} }
}
out: out:
return retval; return retval;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment