diff options
author | Hugh Dickins <hugh@veritas.com> | 2008-07-24 00:27:34 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-07-24 13:47:16 -0400 |
commit | 11fa977ecde652ab324dd79c179deb52e82a8df1 (patch) | |
tree | 5842dab40a3754f3f34223b50f9dcfa5dd67dfa0 /mm | |
parent | a858f7b2e9bb4eb665176dde5cf32eeaaf90f153 (diff) |
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: Hugh Dickins <hugh@veritas.com>
Tested-by: Lawrence 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: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm')
-rw-r--r-- | mm/filemap.c | 42 |
1 files changed, 19 insertions, 23 deletions
diff --git a/mm/filemap.c b/mm/filemap.c index 6343f3c841b7..7675b91f4f63 100644 --- a/mm/filemap.c +++ b/mm/filemap.c | |||
@@ -1197,7 +1197,6 @@ generic_file_aio_read(struct kiocb *iocb, const struct iovec *iov, | |||
1197 | 1197 | ||
1198 | mapping = filp->f_mapping; | 1198 | mapping = filp->f_mapping; |
1199 | inode = mapping->host; | 1199 | inode = mapping->host; |
1200 | retval = 0; | ||
1201 | if (!count) | 1200 | if (!count) |
1202 | goto out; /* skip atime */ | 1201 | goto out; /* skip atime */ |
1203 | size = i_size_read(inode); | 1202 | size = i_size_read(inode); |
@@ -1209,33 +1208,30 @@ generic_file_aio_read(struct kiocb *iocb, const struct iovec *iov, | |||
1209 | } | 1208 | } |
1210 | if (retval > 0) | 1209 | if (retval > 0) |
1211 | *ppos = pos + retval; | 1210 | *ppos = pos + retval; |
1212 | } | 1211 | if (retval) { |
1213 | if (likely(retval != 0)) { | 1212 | file_accessed(filp); |
1214 | file_accessed(filp); | 1213 | goto out; |
1215 | goto out; | 1214 | } |
1216 | } | 1215 | } |
1217 | } | 1216 | } |
1218 | 1217 | ||
1219 | retval = 0; | 1218 | for (seg = 0; seg < nr_segs; seg++) { |
1220 | if (count) { | 1219 | read_descriptor_t desc; |
1221 | for (seg = 0; seg < nr_segs; seg++) { | ||
1222 | read_descriptor_t desc; | ||
1223 | 1220 | ||
1224 | desc.written = 0; | 1221 | desc.written = 0; |
1225 | desc.arg.buf = iov[seg].iov_base; | 1222 | desc.arg.buf = iov[seg].iov_base; |
1226 | desc.count = iov[seg].iov_len; | 1223 | desc.count = iov[seg].iov_len; |
1227 | if (desc.count == 0) | 1224 | if (desc.count == 0) |
1228 | continue; | 1225 | continue; |
1229 | desc.error = 0; | 1226 | desc.error = 0; |
1230 | do_generic_file_read(filp,ppos,&desc,file_read_actor); | 1227 | do_generic_file_read(filp, ppos, &desc, file_read_actor); |
1231 | retval += desc.written; | 1228 | retval += desc.written; |
1232 | if (desc.error) { | 1229 | if (desc.error) { |
1233 | retval = retval ?: desc.error; | 1230 | retval = retval ?: desc.error; |
1234 | break; | 1231 | break; |
1235 | } | ||
1236 | if (desc.count > 0) | ||
1237 | break; | ||
1238 | } | 1232 | } |
1233 | if (desc.count > 0) | ||
1234 | break; | ||
1239 | } | 1235 | } |
1240 | out: | 1236 | out: |
1241 | return retval; | 1237 | return retval; |