Re: [PATCH v3 56/68] afs: Handle len being extending over page end in write_begin/write_end

From: David Howells
Date: Thu Dec 16 2021 - 11:47:52 EST


Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx> wrote:

> > With transparent huge pages, in the future, write_begin() and write_end()
> > may be passed a length parameter that, in combination with the offset into
> > the page, exceeds the length of that page. This allows
> > grab_cache_page_write_begin() to better choose the size of THP to allocate.
>
> I still think this is a fundamental bug in the caller. That
> "explanation" is weak, and the whole concept smells like week-old fish
> to me.

You really should ask Willy about this as it's multipage folio-related.

AIUI, because the page/folio may be allocated inside ->write_begin(),
generic_perform_write() tells the filesystem how much it has been asked to
write and then the folio allocation can be made to fit that.

However, at this time, ->write_begin() and ->write_end() have a page pointer
(or pointer-to-pointer), not a folio pointer, in their signature, so the
filesystem has to convert between them.

I'm working on write helpers for netfslib that absorb this out of the
filesystems that use it into its own take on generic_perform_write(), thereby
eliminating the need for ->write_begin and ->write_end. I have this kind of
working for afs and 9p at the moment and am looking at ceph, but there's a way
to go yet. I believe iomap does the same for block-based filesystems that use
it (such as xfs).

I think Willy's aim is to get rid of ->write_begin and ->write_end entirely.

David