Re: [PATCH 07/21] shmem: document how to "persist" data when using shmem_*file_setup

Christoph Hellwig
2024-01-28T16:54:44Z

On Fri, Jan 26, 2024 at 03:49:30PM +0000, Matthew Wilcox wrote:
> This doesn't quite make sense to me. Do you mean:
>
> * If the caller modifies data in the folio, it must call folio_mark_dirty()
> * before unlocking the folio to ensure that the folio is not reclaimed.
> * There is no equivalent to write_begin/write_end for shmem.
>
> (also this should go before the Return: section; the return section
> should be the last thing in the kernel-doc)

So the first sentence and moving the section makes total sense.
The second sentence I don't think is very useful. write_begin/write_end
are relaly just a way for generic_perform_write to do the space
reservation and extending i_size and not really methods in the classic
sense. They should go away from a_ops and certainly don't end up
being mentioned in shmem.c.

What I have now is this:

If the caller modifies data in the folio, it must call folio_mark_dirty()
before unlocking the folio to ensure that the folio is not reclaimed.
These is no need to reserve space before calling folio_mark_dirty().

but I'm open to further improvements.