Skip to content

Commit 3de6047

Browse files
Matthew Wilcox (Oracle)jankara
authored andcommitted
highmem: Add folio_release_kmap()
This is the folio equivalent of unmap_and_put_page(), which remains as a wrapper for it. Signed-off-by: Matthew Wilcox (Oracle) <[email protected]> Signed-off-by: Jan Kara <[email protected]> Message-Id: <[email protected]>
1 parent bceef32 commit 3de6047

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

include/linux/highmem.h

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -551,10 +551,24 @@ static inline void folio_zero_range(struct folio *folio,
551551
zero_user_segments(&folio->page, start, start + length, 0, 0);
552552
}
553553

554-
static inline void unmap_and_put_page(struct page *page, void *addr)
554+
/**
555+
* folio_release_kmap - Unmap a folio and drop a refcount.
556+
* @folio: The folio to release.
557+
* @addr: The address previously returned by a call to kmap_local_folio().
558+
*
559+
* It is common, eg in directory handling to kmap a folio. This function
560+
* unmaps the folio and drops the refcount that was being held to keep the
561+
* folio alive while we accessed it.
562+
*/
563+
static inline void folio_release_kmap(struct folio *folio, void *addr)
555564
{
556565
kunmap_local(addr);
557-
put_page(page);
566+
folio_put(folio);
567+
}
568+
569+
static inline void unmap_and_put_page(struct page *page, void *addr)
570+
{
571+
folio_release_kmap(page_folio(page), addr);
558572
}
559573

560574
#endif /* _LINUX_HIGHMEM_H */

0 commit comments

Comments
 (0)