From: Christoph Hellwig Date: Mon, 19 Feb 2024 06:27:15 +0000 (+0100) Subject: shmem: document how to "persist" data when using shmem_*file_setup X-Git-Tag: v6.9-rc1~129^2~41 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9d8b36744935f83c5553e6f242b9961f676628ed;p=thirdparty%2Fkernel%2Flinux.git shmem: document how to "persist" data when using shmem_*file_setup 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 Reviewed-by: "Matthew Wilcox (Oracle)" Reviewed-by: "Darrick J. Wong" Signed-off-by: Chandan Babu R --- diff --git a/mm/shmem.c b/mm/shmem.c index 95e70e9ea060f..fb76da93d369c 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -2147,6 +2147,10 @@ unlock: * 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