Re: [PATCH 2/3] afs: Fix afs_write_end() to handle short writes
From: David Howells
Date: Mon Jun 14 2021 - 09:37:29 EST
Matthew Wilcox <willy@xxxxxxxxxxxxx> wrote:
> > (1) If the page is not up to date, then we should just return 0
> > (ie. indicating a zero-length copy). The loop in
> > generic_perform_write() will go around again, possibly breaking up the
> > iterator into discrete chunks.
>
> Does this actually work? What about the situation where you're reading
> the last page of a file and thus (almost) always reading fewer bytes
> than a PAGE_SIZE?
Al Viro made such a change for Ceph - and we're writing, not reading.
I was thinking that it would break if reading from a pipe, but Jeff pointed
out that the iov_iter_advance() in generic_perform_write() uses the return
value of ->write_end() to advance the iterator. So it might loop endlessly,
but it doesn't appear it will corrupt your data.
David