[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200430214450.10662-7-guoqing.jiang@cloud.ionos.com>
Date: Thu, 30 Apr 2020 23:44:47 +0200
From: Guoqing Jiang <guoqing.jiang@...ud.ionos.com>
To: linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org
Cc: hch@...radead.org, david@...morbit.com, willy@...radead.org,
Guoqing Jiang <guoqing.jiang@...ud.ionos.com>,
"Darrick J. Wong" <darrick.wong@...cle.com>,
linux-xfs@...r.kernel.org
Subject: [RFC PATCH V2 6/9] iomap: use attach/clear_page_private
Since the new pair function is introduced, we can call them to clean the
code in iomap.
Cc: Christoph Hellwig <hch@...radead.org>
Cc: "Darrick J. Wong" <darrick.wong@...cle.com>
Cc: linux-xfs@...r.kernel.org
Signed-off-by: Guoqing Jiang <guoqing.jiang@...ud.ionos.com>
---
RFC -> RFC V2
1. change the name of new functions to attach/clear_page_private.
2. call attach_page_private(newpage, clear_page_private(page)) to
cleanup code further as suggested by Matthew Wilcox.
3. don't return attach_page_private in iomap_page_create per the
comment from Christoph Hellwig.
fs/iomap/buffered-io.c | 19 ++++---------------
1 file changed, 4 insertions(+), 15 deletions(-)
diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c
index 89e21961d1ad..cf4c1b02a9d8 100644
--- a/fs/iomap/buffered-io.c
+++ b/fs/iomap/buffered-io.c
@@ -59,24 +59,19 @@ 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);
+ attach_page_private(page, iop);
return iop;
}
static void
iomap_page_release(struct page *page)
{
- struct iomap_page *iop = to_iomap_page(page);
+ struct iomap_page *iop = clear_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);
}
@@ -554,14 +549,8 @@ iomap_migrate_page(struct address_space *mapping, struct page *newpage,
if (ret != MIGRATEPAGE_SUCCESS)
return ret;
- if (page_has_private(page)) {
- ClearPagePrivate(page);
- get_page(newpage);
- set_page_private(newpage, page_private(page));
- set_page_private(page, 0);
- put_page(page);
- SetPagePrivate(newpage);
- }
+ if (page_has_private(page))
+ attach_page_private(newpage, clear_page_private(page));
if (mode != MIGRATE_SYNC_NO_COPY)
migrate_page_copy(newpage, page);
--
2.17.1
Powered by blists - more mailing lists