Re: [PATCH] mm/filemap: do not allocate cache pages beyond end of file at read

From: Linus Torvalds
Date: Wed Oct 30 2019 - 06:54:58 EST


On Wed, Oct 30, 2019 at 11:35 AM Steven Whitehouse <swhiteho@xxxxxxxxxx> wrote:
>
> NFS may be ok here, but it will break GFS2. There may be others too...
> OCFS2 is likely one. Not sure about CIFS either. Does it really matter
> that we might occasionally allocate a page and then free it again?

Why are gfs2 and cifs doing things wrong?

"readpage()" is not for synchrionizing metadata. Never has been. You
shouldn't treat it that way, and you shouldn't then make excuses for
filesystems that treat it that way.

Look at mmap, for example. It will do the SIGBUS handling before
calling readpage(). Same goes for the copyfile code. A filesystem that
thinks "I will update size at readpage" is already fundamentally
buggy.

We do _recheck_ the inode size under the page lock, but that's to
handle the races with truncate etc.

Linus