On Sat, May 02, 2020 at 12:42:15AM +0200, Guoqing Jiang wrote:
On 5/2/20 12:16 AM, Matthew Wilcox wrote:I think you can do:
On Thu, Apr 30, 2020 at 11:44:41PM +0200, Guoqing Jiang wrote:Thanks for checking! Assume the below change is appropriate.
include/linux/pagemap.h: introduce attach/clear_page_privateI think mm/migrate.c could also use this:
md: remove __clear_page_buffers and use attach/clear_page_private
btrfs: use attach/clear_page_private
fs/buffer.c: use attach/clear_page_private
f2fs: use attach/clear_page_private
iomap: use attach/clear_page_private
ntfs: replace attach_page_buffers with attach_page_private
orangefs: use attach/clear_page_private
buffer_head.h: remove attach_page_buffers
ClearPagePrivate(page);
set_page_private(newpage, page_private(page));
set_page_private(page, 0);
put_page(page);
get_page(newpage);
diff --git a/mm/migrate.c b/mm/migrate.c
index 7160c1556f79..f214adfb3fa4 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -797,10 +797,7 @@ static int __buffer_migrate_page(struct address_space
*mapping,
ÂÂÂÂÂÂÂ if (rc != MIGRATEPAGE_SUCCESS)
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ goto unlock_buffers;
-ÂÂÂÂÂÂ ClearPagePrivate(page);
-ÂÂÂÂÂÂ set_page_private(newpage, page_private(page));
-ÂÂÂÂÂÂ set_page_private(page, 0);
-ÂÂÂÂÂÂ put_page(page);
+ÂÂÂÂÂÂ set_page_private(newpage, detach_page_private(page));
ÂÂÂÂÂÂÂ get_page(newpage);
@@ -797,11 +797,7 @@ static int __buffer_migrate_page(struct address_space *mapping,
if (rc != MIGRATEPAGE_SUCCESS)
goto unlock_buffers;
- ClearPagePrivate(page);
- set_page_private(newpage, page_private(page));
- set_page_private(page, 0);
- put_page(page);
- get_page(newpage);
+ attach_page_private(newpage, detach_page_private(page));
bh = head;
do {
@@ -810,8 +806,6 @@ static int __buffer_migrate_page(struct address_space *mapping,
} while (bh != head);
- SetPagePrivate(newpage);
-
if (mode != MIGRATE_SYNC_NO_COPY)
... but maybe there's a subtlety to the ordering of the setup of the bh
and setting PagePrivate that means what you have there is a better patch.