Message ID | 20240103084126.513354-4-hch@lst.de (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | [01/15] shmem: move the shmem_mapping assert into shmem_get_folio_gfp | expand |
On Wed, Jan 03, 2024 at 08:41:14AM +0000, Christoph Hellwig wrote: > 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> > --- > mm/shmem.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/mm/shmem.c b/mm/shmem.c > index 328eb3dbea9f1c..235fac6dc53a0b 100644 > --- a/mm/shmem.c > +++ b/mm/shmem.c > @@ -2129,6 +2129,11 @@ static int shmem_get_folio_gfp(struct inode *inode, pgoff_t index, > * > * Return: The found folio, %NULL if SGP_READ or SGP_NOALLOC was passed in @sgp > * and no folio was found at @index, or an ERR_PTR() otherwise. > + * > + * If the caller modifies data in the returned folio, it must call > + * folio_mark_dirty() on the locked folio before dropping the reference to > + * ensure the folio is not reclaimed. Unlike for normal file systems there is > + * no need to reserve space for users of shmem_*file_setup(). /me notes that this matches how /I/ think this is supposed to work, but I think someone more familiar with tmpfs should review this... --D > */ > int shmem_get_folio(struct inode *inode, pgoff_t index, struct folio **foliop, > enum sgp_type sgp) > -- > 2.39.2 > >
diff --git a/mm/shmem.c b/mm/shmem.c index 328eb3dbea9f1c..235fac6dc53a0b 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -2129,6 +2129,11 @@ static int shmem_get_folio_gfp(struct inode *inode, pgoff_t index, * * Return: The found folio, %NULL if SGP_READ or SGP_NOALLOC was passed in @sgp * and no folio was found at @index, or an ERR_PTR() otherwise. + * + * If the caller modifies data in the returned folio, it must call + * folio_mark_dirty() on the locked folio before dropping the reference to + * ensure the folio is not reclaimed. Unlike for normal file systems there is + * no need to reserve space for users of shmem_*file_setup(). */ int shmem_get_folio(struct inode *inode, pgoff_t index, struct folio **foliop, enum sgp_type sgp)
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> --- mm/shmem.c | 5 +++++ 1 file changed, 5 insertions(+)