On 2/14/22 3:32 PM, Matthew Wilcox wrote:
On Mon, Feb 14, 2022 at 03:09:09PM -0800, John Hubbard wrote:
@@ -309,7 +288,10 @@ int invalidate_inode_page(struct page *page)
It would be nice to retain some of the original comments. May I suggest
this (it has an additional paragraph) for an updated version of comments
above invalidate_inode_page():
/*
* Safely invalidate one page from its pagecache mapping.
* It only drops clean, unused pages. The page must be locked.
*
* This function can be called at any time, and is not supposed to throw away
* dirty pages. But pages can be marked dirty at any time too, so use
* remove_mapping(), which safely discards clean, unused pages.
*
* Returns 1 if the page is successfully invalidated, otherwise 0.
*/
By the end of this series, it becomes:
/**
* invalidate_inode_page() - Remove an unused page from the pagecache.
* @page: The page to remove.
*
* Safely invalidate one page from its pagecache mapping.
* It only drops clean, unused pages.
*
* Context: Page must be locked.
* Return: The number of pages successfully removed.
*/
OK.
Also, as long as you're there, a newline after the mapping declaration
would bring this routine into compliance with that convention.
Again, by the end, we're at:
struct folio *folio = page_folio(page);
struct address_space *mapping = folio_mapping(folio);
/* The page may have been truncated before it was locked */
if (!mapping)
return 0;
return mapping_shrink_folio(mapping, folio);
Also good.
hmmm, now I wonder why this isn't a boolean function. And I think the
reason is that it's quite old.
We could make this return a bool and have the one user that cares
call folio_nr_pages(). I don't have a strong preference.
Neither do I. No need to add churn for that.
thanks,
--
John Hubbard
NVIDIA