Re: [PATCH] mm/filemap: do not allocate cache pages beyond end of file at read
From: Linus Torvalds
Date: Mon Nov 25 2019 - 12:05:52 EST
On Mon, Nov 25, 2019 at 2:53 AM Steven Whitehouse <swhiteho@xxxxxxxxxx> wrote:
>
> Linus, is that roughly what you were thinking of?
So the concept looks ok, but I don't really like the new flags as they
seem to be gfs2-specific rather than generic.
That said, I don't _gate_ them either, since they aren't in any
critical code sequence, and it's not like they do anything really odd.
I still think the whole gfs2 approach is broken. You're magically ok
with using stale data from the cache just because it's cached, even if
another client might have truncated the file or something.
So you're ok with saying "the file used to be X bytes in size, so
we'll just give you this data because we trust that the X is correct".
But you're not ok to say "oh, the file used to be X bytes in size, but
we don't want to give you a short read because it might not be correct
any more".
See the disconnect? You trust the size in one situation, but not in another one.
I also don't really see that you *need* the new flag at all. Since
you're doing to do a speculative read and then a real read anyway, and
since the only thing that you seem to care about is the file size
(because the *data* you will trust if it is cached), then why don't
you just use the *existing* generic read, and *IFF* you get a
truncated return value, then you go and double-check that the file
hasn't changed in size?
See what I'm saying? I think gfs2 is being very inconsistent in when
it trusts the file size, and I don't see that you even need the new
behavior that patch gives, because you might as well just use the
existing code (just move the i_size check earlier, and then teach gfs2
to double-check the "I didn't get as much as I expected" case).
Linus