[RFC PATCH 6/9] iomap: use set/clear_fs_page_private

From: Guoqing Jiang
Date: Sun Apr 26 2020 - 17:50:10 EST


Since the new pair function is introduced, we can call them to clean the
code in iomap.

Cc: Christoph Hellwig <hch@xxxxxxxxxxxxx>
Cc: "Darrick J. Wong" <darrick.wong@xxxxxxxxxx>
Cc: linux-xfs@xxxxxxxxxxxxxxx
Signed-off-by: Guoqing Jiang <guoqing.jiang@xxxxxxxxxxxxxxx>
---
fs/iomap/buffered-io.c | 14 +++-----------
1 file changed, 3 insertions(+), 11 deletions(-)

diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c
index 89e21961d1ad..cc48bf4f1193 100644
--- a/fs/iomap/buffered-io.c
+++ b/fs/iomap/buffered-io.c
@@ -59,24 +59,18 @@ iomap_page_create(struct inode *inode, struct page *page)
* migrate_page_move_mapping() assumes that pages with private data have
* their count elevated by 1.
*/
- get_page(page);
- set_page_private(page, (unsigned long)iop);
- SetPagePrivate(page);
- return iop;
+ return (struct iomap_page *)set_fs_page_private(page, iop);
}

static void
iomap_page_release(struct page *page)
{
- struct iomap_page *iop = to_iomap_page(page);
+ struct iomap_page *iop = clear_fs_page_private(page);

if (!iop)
return;
WARN_ON_ONCE(atomic_read(&iop->read_count));
WARN_ON_ONCE(atomic_read(&iop->write_count));
- ClearPagePrivate(page);
- set_page_private(page, 0);
- put_page(page);
kfree(iop);
}

@@ -556,11 +550,9 @@ iomap_migrate_page(struct address_space *mapping, struct page *newpage,

if (page_has_private(page)) {
ClearPagePrivate(page);
- get_page(newpage);
- set_page_private(newpage, page_private(page));
+ set_fs_page_private(newpage, (void *)page_private(page));
set_page_private(page, 0);
put_page(page);
- SetPagePrivate(newpage);
}

if (mode != MIGRATE_SYNC_NO_COPY)
--
2.17.1