From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Morton Subject: + include-linux-pagemaph-introduce-attach-detach_page_private.patch added to -mm tree Date: Mon, 18 May 2020 14:46:06 -0700 Message-ID: <20200518214606.BXX-TBZqv%akpm@linux-foundation.org> References: <20200513175005.1f4839360c18c0238df292d1@linux-foundation.org> Reply-To: linux-kernel@vger.kernel.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from mail.kernel.org ([198.145.29.99]:49618 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726250AbgERVqJ (ORCPT ); Mon, 18 May 2020 17:46:09 -0400 In-Reply-To: <20200513175005.1f4839360c18c0238df292d1@linux-foundation.org> Sender: mm-commits-owner@vger.kernel.org List-Id: mm-commits@vger.kernel.org To: adilger@dilger.ca, agruenba@redhat.com, anton@tuxera.com, bigeasy@linutronix.de, chao@kernel.org, clm@fb.com, darrick.wong@oracle.com, david@fromorbit.com, dsterba@suse.com, guoqing.jiang@cloud.ionos.com, guro@fb.com, hch@infradead.org, hubcap@omnibond.com, jaegeuk@kernel.org, josef@toxicpanda.com, kirill.shutemov@linux.intel.com, laoar.shao@gmail.com, martin@omnibond.com, mm-commits@vger.kernel.org, song@kernel.org, tglx@linutronix.de, viro@zeniv.linux.org.uk, william.kucharski@oracle.com, willy@infradead.org, yang.shi@linux.alibaba.com, yuchao0@huawei.com The patch titled Subject: include/linux/pagemap.h: introduce attach/detach_page_private has been added to the -mm tree. Its filename is include-linux-pagemaph-introduce-attach-detach_page_private.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/include-linux-pagemaph-introdu= ce-attach-detach_page_private.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/include-linux-pagemaph-introdu= ce-attach-detach_page_private.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing= your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ =46rom: Guoqing Jiang Subject: include/linux/pagemap.h: introduce attach/detach_page_private Patch series "Introduce attach/detach_page_private to cleanup code". This patch (of 10): The logic in attach_page_buffers and __clear_page_buffers are quite paired, but 1. they are located in different files. 2. attach_page_buffers is implemented in buffer_head.h, so it could be used by other files. But __clear_page_buffers is static function in buffer.c and other potential users can't call the function, md-bitmap even copied the function. So, introduce the new attach/detach_page_private to replace them. With the new pair of function, we will remove the usage of attach_page_buffers and __clear_page_buffers in next patches. Thanks for suggestions about the function name from Alexander Viro, Andreas Gr=C3=BCnbacher, Christoph Hellwig and Matthew Wilcox. Link: http://lkml.kernel.org/r/20200517214718.468-1-guoqing.jiang@cloud.ion= os.com Link: http://lkml.kernel.org/r/20200517214718.468-2-guoqing.jiang@cloud.ion= os.com Signed-off-by: Guoqing Jiang Suggested-by: Matthew Wilcox Cc: "Darrick J. Wong" Cc: William Kucharski Cc: "Kirill A. Shutemov" Cc: Andreas Gruenbacher Cc: Yang Shi Cc: Yafang Shao Cc: Song Liu Cc: Chris Mason Cc: Josef Bacik Cc: David Sterba Cc: Alexander Viro Cc: Jaegeuk Kim Cc: Chao Yu Cc: Christoph Hellwig Cc: Anton Altaparmakov Cc: Mike Marshall Cc: Martin Brandenburg Cc: Thomas Gleixner Cc: Sebastian Andrzej Siewior Cc: Roman Gushchin Cc: Andreas Dilger Cc: Chao Yu Cc: Dave Chinner Signed-off-by: Andrew Morton --- include/linux/pagemap.h | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) --- a/include/linux/pagemap.h~include-linux-pagemaph-introduce-attach-detac= h_page_private +++ a/include/linux/pagemap.h @@ -208,6 +208,43 @@ static inline int page_cache_add_specula return __page_cache_add_speculative(page, count); } =20 +/** + * attach_page_private - Attach private data to a page. + * @page: Page to attach data to. + * @data: Data to attach to page. + * + * Attaching private data to a page increments the page's reference count. + * The data must be detached before the page will be freed. + */ +static inline void attach_page_private(struct page *page, void *data) +{ + get_page(page); + set_page_private(page, (unsigned long)data); + SetPagePrivate(page); +} + +/** + * detach_page_private - Detach private data from a page. + * @page: Page to detach data from. + * + * Removes the data that was previously attached to the page and decrements + * the refcount on the page. + * + * Return: Data that was attached to the page. + */ +static inline void *detach_page_private(struct page *page) +{ + void *data =3D (void *)page_private(page); + + if (!PagePrivate(page)) + return NULL; + ClearPagePrivate(page); + set_page_private(page, 0); + put_page(page); + + return data; +} + #ifdef CONFIG_NUMA extern struct page *__page_cache_alloc(gfp_t gfp); #else _ Patches currently in -mm which might be from guoqing.jiang@cloud.ionos.com = are include-linux-pagemaph-introduce-attach-detach_page_private.patch md-remove-__clear_page_buffers-and-use-attach-detach_page_private.patch btrfs-use-attach-detach_page_private.patch fs-bufferc-use-attach-detach_page_private.patch f2fs-use-attach-detach_page_private.patch iomap-use-attach-detach_page_private.patch ntfs-replace-attach_page_buffers-with-attach_page_private.patch orangefs-use-attach-detach_page_private.patch buffer_headh-remove-attach_page_buffers.patch mm-migratec-call-detach_page_private-to-cleanup-code.patch