From: Guoqing Jiang <guoqing.jiang@cloud.ionos.com>
To: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: hch@infradead.org, david@fromorbit.com, willy@infradead.org,
Guoqing Jiang <guoqing.jiang@cloud.ionos.com>,
Andrew Morton <akpm@linux-foundation.org>,
"Darrick J. Wong" <darrick.wong@oracle.com>,
William Kucharski <william.kucharski@oracle.com>,
"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
Andreas Gruenbacher <agruenba@redhat.com>,
Yang Shi <yang.shi@linux.alibaba.com>,
Yafang Shao <laoar.shao@gmail.com>
Subject: [RFC PATCH 1/9] include/linux/pagemap.h: introduce set/clear_fs_page_private
Date: Sun, 26 Apr 2020 23:49:17 +0200 [thread overview]
Message-ID: <20200426214925.10970-2-guoqing.jiang@cloud.ionos.com> (raw)
In-Reply-To: <20200426214925.10970-1-guoqing.jiang@cloud.ionos.com>
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 set/clear_fs_page_private to replace them since
they are mostly used in fs layer. With the new pair of function, we will
remove the usage of attach_page_buffers and __clear_page_buffers in
next patches.
Suggested-by: Matthew Wilcox <willy@infradead.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: "Darrick J. Wong" <darrick.wong@oracle.com>
Cc: William Kucharski <william.kucharski@oracle.com>
Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
Cc: Andreas Gruenbacher <agruenba@redhat.com>
Cc: Yang Shi <yang.shi@linux.alibaba.com>
Cc: Yafang Shao <laoar.shao@gmail.com>
Signed-off-by: Guoqing Jiang <guoqing.jiang@cloud.ionos.com>
---
include/linux/pagemap.h | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
index a8f7bd8ea1c6..2a165ea647fe 100644
--- a/include/linux/pagemap.h
+++ b/include/linux/pagemap.h
@@ -205,6 +205,28 @@ static inline int page_cache_add_speculative(struct page *page, int count)
return __page_cache_add_speculative(page, count);
}
+static inline void *set_fs_page_private(struct page *page, void *data)
+{
+ get_page(page);
+ set_page_private(page, (unsigned long)data);
+ SetPagePrivate(page);
+
+ return data;
+}
+
+static inline void *clear_fs_page_private(struct page *page)
+{
+ void *data = (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
--
2.17.1
next prev parent reply other threads:[~2020-04-26 21:50 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-26 21:49 [RFC PATCH 0/9] Introduce set/clear_fs_page_private to cleanup code Guoqing Jiang
2020-04-26 21:49 ` Guoqing Jiang [this message]
2020-04-27 5:52 ` [RFC PATCH 1/9] include/linux/pagemap.h: introduce set/clear_fs_page_private Christoph Hellwig
2020-04-27 8:10 ` Guoqing Jiang
2020-04-26 21:49 ` [RFC PATCH 2/9] md: remove __clear_page_buffers and use set/clear_fs_page_private Guoqing Jiang
2020-04-26 21:49 ` [RFC PATCH 3/9] btrfs: " Guoqing Jiang
2020-04-26 22:20 ` Dave Chinner
2020-04-27 5:54 ` Christoph Hellwig
2020-04-27 12:27 ` David Sterba
2020-04-27 8:14 ` Guoqing Jiang
2020-04-26 21:49 ` [RFC PATCH 4/9] fs/buffer.c: " Guoqing Jiang
2020-04-26 21:49 ` [RFC PATCH 5/9] f2fs: " Guoqing Jiang
2020-04-27 2:22 ` Chao Yu
2020-04-27 8:10 ` Guoqing Jiang
2020-04-26 21:49 ` [RFC PATCH 6/9] iomap: " Guoqing Jiang
2020-04-27 0:26 ` Matthew Wilcox
2020-04-27 5:55 ` Christoph Hellwig
2020-04-27 8:15 ` Guoqing Jiang
2020-04-27 8:15 ` Guoqing Jiang
2020-04-27 5:57 ` Christoph Hellwig
2020-04-27 8:12 ` Guoqing Jiang
2020-04-26 21:49 ` [RFC PATCH 7/9] ntfs: replace attach_page_buffers with set_fs_page_private Guoqing Jiang
2020-04-26 21:49 ` [RFC PATCH 8/9] orangefs: use set/clear_fs_page_private Guoqing Jiang
2020-04-26 22:24 ` Dave Chinner
2020-04-27 0:12 ` Matthew Wilcox
2020-04-27 2:27 ` Dave Chinner
2020-04-27 8:18 ` Guoqing Jiang
2020-04-27 2:58 ` Gao Xiang
2020-04-27 3:27 ` Gao Xiang
2020-04-26 21:49 ` [RFC PATCH 9/9] buffer_head.h: remove attach_page_buffers Guoqing Jiang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200426214925.10970-2-guoqing.jiang@cloud.ionos.com \
--to=guoqing.jiang@cloud.ionos.com \
--cc=agruenba@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=darrick.wong@oracle.com \
--cc=david@fromorbit.com \
--cc=hch@infradead.org \
--cc=kirill.shutemov@linux.intel.com \
--cc=laoar.shao@gmail.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=william.kucharski@oracle.com \
--cc=willy@infradead.org \
--cc=yang.shi@linux.alibaba.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).