lkml.org 
[lkml]   [2022]   [Sep]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH v2 01/23] pagemap: Add filemap_grab_folio()
    Date
    Add function filemap_grab_folio() to grab a folio from the page cache.
    This function is meant to serve as a folio replacement for
    grab_cache_page, and is used to facilitate the removal of
    find_get_pages_range_tag().

    Signed-off-by: Vishal Moola (Oracle) <vishal.moola@gmail.com>
    ---
    include/linux/pagemap.h | 20 ++++++++++++++++++++
    1 file changed, 20 insertions(+)

    diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
    index 0178b2040ea3..4d3092d6b2c0 100644
    --- a/include/linux/pagemap.h
    +++ b/include/linux/pagemap.h
    @@ -547,6 +547,26 @@ static inline struct folio *filemap_lock_folio(struct address_space *mapping,
    return __filemap_get_folio(mapping, index, FGP_LOCK, 0);
    }

    +/**
    + * filemap_grab_folio - grab a folio from the page cache
    + * @mapping: The address space to search
    + * @index: The page index
    + *
    + * Looks up the page cache entry at @mapping & @index. If no folio is found,
    + * a new folio is created. The folio is locked, marked as accessed, and
    + * returned.
    + *
    + * Return: A found or created folio. NULL if no folio is found and failed to
    + * create a folio.
    + */
    +static inline struct folio *filemap_grab_folio(struct address_space *mapping,
    + pgoff_t index)
    +{
    + return __filemap_get_folio(mapping, index,
    + FGP_LOCK | FGP_ACCESSED | FGP_CREAT,
    + mapping_gfp_mask(mapping));
    +}
    +
    /**
    * find_get_page - find and get a page reference
    * @mapping: the address_space to search
    --
    2.36.1
    \
     
     \ /
      Last update: 2022-09-12 20:26    [W:4.291 / U:0.152 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site