Re: [PATCH 05/20] shmem: export shmem_get_folio

Matthew Wilcox
2024-02-16T13:53:14Z

On Mon, Jan 29, 2024 at 03:34:47PM +0100, Christoph Hellwig wrote:
> +/**
> + * shmem_get_folio - find and get a reference to a shmem folio.
> + * @inode: inode to search
> + * @index: the page index.
> + * @foliop: pointer to the found folio if one was found
> + * @sgp: SGP_* flags to control behavior
> + *
> + * Looks up the page cache entry at @inode & @index.
> + *
> + * If this function returns a folio, it is returned with an increased refcount.
> + *
> + * 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.

I know I gave an R-b on this earlier, but Hugh made me look again, and
this comment clearly does not reflect what the function does.
Presumably it returns an errno and sets foliop if it returns 0?

Also, should this function be called shmem_lock_folio() to mirror
filemap_lock_folio()?

> + */
> int shmem_get_folio(struct inode *inode, pgoff_t index, struct folio **foliop,
> enum sgp_type sgp)
> {
> return shmem_get_folio_gfp(inode, index, foliop, sgp,
> mapping_gfp_mask(inode->i_mapping), NULL, NULL);
> }
> +EXPORT_SYMBOL_GPL(shmem_get_folio);