diff mbox series

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

Message ID 20240219062730.3031391-8-hch@lst.de (mailing list archive)
State New
Headers show
Series [01/22] mm: move mapping_set_update out of <linux/swap.h> | expand

Commit Message

Christoph Hellwig Feb. 19, 2024, 6:27 a.m. UTC
Add a blurb that simply dirtying the folio will persist data for in-kernel
shmem files.  This is what most of the callers already do.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
---
 mm/shmem.c | 4 ++++
 1 file changed, 4 insertions(+)
diff mbox series

Patch

diff --git a/mm/shmem.c b/mm/shmem.c
index 95e70e9ea060f3..fb76da93d369cf 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -2147,6 +2147,10 @@  static int shmem_get_folio_gfp(struct inode *inode, pgoff_t index,
  * Looks up the page cache entry at @inode & @index.  If a folio is
  * present, it is returned locked with an increased refcount.
  *
+ * 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 need to reserve space before calling folio_mark_dirty().
+ *
  * When no folio is found, the behavior depends on @sgp:
  *  - for SGP_READ, *foliop is %NULL and 0 is returned
  *  - for SGP_NOALLOC, *foliop is %NULL and -ENOENT is returned