Messages in this thread |  | | | Subject | Re: [patch rfc] towards supporting O_NONBLOCK on regular files | | From | "Stephen C. Tweedie" <> | | Date | 15 Oct 2004 17:19:37 +0100 |
| |
Hi,
On Fri, 2004-10-15 at 16:44, Jeff Moyer wrote:
> I got the partial read case wrong in the last patch. In fact, it looks > like this code path would perform infinite retries before. This should > address that by returning upon the first partial read. Attached is a new > version of the patch.
...
> --- linux-2.6.9-rc4-mm1/mm/filemap.c.orig 2004-10-15 10:33:24.986209880 -0400 > +++ linux-2.6.9-rc4-mm1/mm/filemap.c 2004-10-15 11:38:50.869384920 -0400 > @@ -976,10 +987,10 @@ __generic_file_aio_read(struct kiocb *io > desc.error = 0; > do_generic_file_read(filp,ppos,&desc,file_read_actor); > retval += desc.written; > - if (!retval) { > + if (!retval) > retval = desc.error; > + if (desc.written != iov[seg].iov_len) > break; > - } > }
Yep; this chunk used to break out only on !retval, so at worst it's a data corrupter for multi-segment iovecs. If one do_generic_file_read() returned a short read we'd update retval but then move on to the next segment of the iovec; if the next one succeeded we'd be reading into the next segment but ppos wouldn't be correctly advanced.
The fix looks correct --- we still only return an error if no data at all has been returned, but we break out of the IO completely at the first short read.
--Stephen
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
|  |