Re: [PATCH v7 0/5] vfs: Non-blockling buffered fs read (page cache only)

From: Andrew Morton
Date: Fri Mar 27 2015 - 12:38:36 EST


On Fri, 27 Mar 2015 09:30:46 -0700 Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> wrote:

> I expect that this situation (first part in cache, latter part not in
> cache) is rare - for reasonably small requests the common cases will be
> "all cached" and "nothing cached". So perhaps the best approach here
> is for samba to add special handling for the short read, to work out
> the reason for its occurrence.
>
> Alternatively we could add another flag to pread2() to select this
> "throw away my data and return -EAGAIN" behaviour. Presumably
> implemented with an i_size check, but it's gonna be racy.

Here's a better way:

nr_read = pread2(buf, len);
if (nr_read < len)
nr_read += pread(buf + nr_read, len - nr_read);
if (nr_read < len)
we_hit_eof();
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/