lkml.org 
[lkml]   [2021]   [Feb]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Subject[PATCH 02/33] mm: Add an unlock function for PG_private_2/PG_fscache
    From
    Date
    Add a function, unlock_page_private_2(), to unlock PG_private_2 analogous
    to that of PG_lock. Add a kerneldoc banner to that indicating the example
    usage case.

    A wrapper will need to be placed in the netfs header in the patch that adds
    that.

    [This implements a suggestion by Linus to not mix the terminology of
    PG_private_2 and PG_fscache in the mm core function]

    Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: David Howells <dhowells@redhat.com>
    cc: Linus Torvalds <torvalds@linux-foundation.org>
    cc: Matthew Wilcox (Oracle) <willy@infradead.org>
    cc: Alexander Viro <viro@zeniv.linux.org.uk>
    cc: Christoph Hellwig <hch@lst.de>
    cc: linux-mm@kvack.org
    cc: linux-cachefs@redhat.com
    cc: linux-afs@lists.infradead.org
    cc: linux-nfs@vger.kernel.org
    cc: linux-cifs@vger.kernel.org
    cc: ceph-devel@vger.kernel.org
    cc: v9fs-developer@lists.sourceforge.net
    cc: linux-fsdevel@vger.kernel.org
    Link: https://lore.kernel.org/linux-fsdevel/1330473.1612974547@warthog.procyon.org.uk/
    Link: https://lore.kernel.org/linux-fsdevel/CAHk-=wjgA-74ddehziVk=XAEMTKswPu1Yw4uaro1R3ibs27ztw@mail.gmail.com/
    ---

    include/linux/pagemap.h | 1 +
    mm/filemap.c | 20 ++++++++++++++++++++
    2 files changed, 21 insertions(+)

    diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
    index d5570deff400..365a28ece763 100644
    --- a/include/linux/pagemap.h
    +++ b/include/linux/pagemap.h
    @@ -591,6 +591,7 @@ extern int __lock_page_async(struct page *page, struct wait_page_queue *wait);
    extern int __lock_page_or_retry(struct page *page, struct mm_struct *mm,
    unsigned int flags);
    extern void unlock_page(struct page *page);
    +extern void unlock_page_private_2(struct page *page);

    /*
    * Return true if the page was successfully locked
    diff --git a/mm/filemap.c b/mm/filemap.c
    index 5c9d564317a5..7d321152d579 100644
    --- a/mm/filemap.c
    +++ b/mm/filemap.c
    @@ -1466,6 +1466,26 @@ void unlock_page(struct page *page)
    }
    EXPORT_SYMBOL(unlock_page);

    +/**
    + * unlock_page_private_2 - Unlock a page that's locked with PG_private_2
    + * @page: The page
    + *
    + * Unlocks a page that's locked with PG_private_2 and wakes up sleepers in
    + * wait_on_page_private_2().
    + *
    + * This is, for example, used when a netfs page is being written to a local
    + * disk cache, thereby allowing writes to the cache for the same page to be
    + * serialised.
    + */
    +void unlock_page_private_2(struct page *page)
    +{
    + page = compound_head(page);
    + VM_BUG_ON_PAGE(!PagePrivate2(page), page);
    + clear_bit_unlock(PG_private_2, &page->flags);
    + wake_up_page_bit(page, PG_private_2);
    +}
    +EXPORT_SYMBOL(unlock_page_private_2);
    +
    /**
    * end_page_writeback - end writeback against a page
    * @page: the page

    \
     
     \ /
      Last update: 2021-02-15 18:24    [W:3.125 / U:0.748 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site