iomap: use attach/detach_page_private
Since the new pair function is introduced, we can call them to clean the code in iomap. Signed-off-by: Guoqing Jiang <guoqing.jiang@cloud.ionos.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Reviewed-by: Andrew Morton <akpm@linux-foundation.org> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Cc: Christoph Hellwig <hch@infradead.org> Cc: Dave Chinner <david@fromorbit.com> Link: http://lkml.kernel.org/r/20200517214718.468-7-guoqing.jiang@cloud.ionos.com Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
7128cf9a25
commit
58aeb73196
@ -59,24 +59,19 @@ iomap_page_create(struct inode *inode, struct page *page)
|
|||||||
* migrate_page_move_mapping() assumes that pages with private data have
|
* migrate_page_move_mapping() assumes that pages with private data have
|
||||||
* their count elevated by 1.
|
* their count elevated by 1.
|
||||||
*/
|
*/
|
||||||
get_page(page);
|
attach_page_private(page, iop);
|
||||||
set_page_private(page, (unsigned long)iop);
|
|
||||||
SetPagePrivate(page);
|
|
||||||
return iop;
|
return iop;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
iomap_page_release(struct page *page)
|
iomap_page_release(struct page *page)
|
||||||
{
|
{
|
||||||
struct iomap_page *iop = to_iomap_page(page);
|
struct iomap_page *iop = detach_page_private(page);
|
||||||
|
|
||||||
if (!iop)
|
if (!iop)
|
||||||
return;
|
return;
|
||||||
WARN_ON_ONCE(atomic_read(&iop->read_count));
|
WARN_ON_ONCE(atomic_read(&iop->read_count));
|
||||||
WARN_ON_ONCE(atomic_read(&iop->write_count));
|
WARN_ON_ONCE(atomic_read(&iop->write_count));
|
||||||
ClearPagePrivate(page);
|
|
||||||
set_page_private(page, 0);
|
|
||||||
put_page(page);
|
|
||||||
kfree(iop);
|
kfree(iop);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -526,14 +521,8 @@ iomap_migrate_page(struct address_space *mapping, struct page *newpage,
|
|||||||
if (ret != MIGRATEPAGE_SUCCESS)
|
if (ret != MIGRATEPAGE_SUCCESS)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
if (page_has_private(page)) {
|
if (page_has_private(page))
|
||||||
ClearPagePrivate(page);
|
attach_page_private(newpage, detach_page_private(page));
|
||||||
get_page(newpage);
|
|
||||||
set_page_private(newpage, page_private(page));
|
|
||||||
set_page_private(page, 0);
|
|
||||||
put_page(page);
|
|
||||||
SetPagePrivate(newpage);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mode != MIGRATE_SYNC_NO_COPY)
|
if (mode != MIGRATE_SYNC_NO_COPY)
|
||||||
migrate_page_copy(newpage, page);
|
migrate_page_copy(newpage, page);
|
||||||
|
Loading…
Reference in New Issue
Block a user