Skip to content

Commit

Permalink
iomap: use attach/detach_page_private
Browse files Browse the repository at this point in the history
Since the new pair function is introduced, we can call them to clean the
code in iomap.

Signed-off-by: Guoqing Jiang <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Reviewed-by: Andrew Morton <[email protected]>
Reviewed-by: Darrick J. Wong <[email protected]>
Cc: Christoph Hellwig <[email protected]>
Cc: Dave Chinner <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Guoqing Jiang authored and torvalds committed Jun 2, 2020
1 parent 7128cf9 commit 58aeb73
Showing 1 changed file with 4 additions and 15 deletions.
19 changes: 4 additions & 15 deletions fs/iomap/buffered-io.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 = detach_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);
}

Expand Down Expand Up @@ -526,14 +521,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, detach_page_private(page));

if (mode != MIGRATE_SYNC_NO_COPY)
migrate_page_copy(newpage, page);
Expand Down

0 comments on commit 58aeb73

Please sign in to comment.