Skip to contentSkip to conversation

iomap: get/put the page in iomap_page_create/release()

PATCH Superseded [email protected] 3 participants 3 messages Nov 15, 2018

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iomap: get/put the page in iomap_page_create/release()

From: Piotr Jaroszynski <[email protected]>

migrate_page_move_mapping() expects pages with private data set to have a page_count elevated by 1. This is what used to happen for xfs through the buffer_heads code before the switch to iomap in 82cb14175e7d ("xfs:
add support for sub-pagesize writeback without buffer_heads"). Not having the count elevated causes move_pages() to fail on memory mapped files coming from xfs.

Make iomap compatible with the migrate_page_move_mapping() assumption by elevating the page count as part of iomap_page_create() and lowering it in iomap_page_release().

Fixes 82cb14175e7d ("xfs: add support for sub-pagesize writeback

without buffer_heads")

---
 fs/iomap.c | 7 +++++++
 1 file changed, 7 insertions(+)
fs/iomap.c +7 -0
index 90c2febc93ac..23977f9f23a2 100644
@@ -117,6 +117,12 @@ iomap_page_create(struct inode *inode, struct page *page)
 	atomic_set(&iop->read_count, 0);
 	atomic_set(&iop->write_count, 0);
 	bitmap_zero(iop->uptodate, PAGE_SIZE / SECTOR_SIZE);
+
+	/*
+	 * At least 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;
@@ -133,6 +139,7 @@ iomap_page_release(struct page *page)
 	WARN_ON_ONCE(atomic_read(&iop->write_count));
 	ClearPagePrivate(page);
 	set_page_private(page, 0);
+	put_page(page);
 	kfree(iop);
 }
 
Signature · 1 line
2.11.0.262.g4b0a5b2.dirty
Reviewed-by on v1 1/1
#1 lore raw
Quoted 2 lines
Fixes 82cb14175e7d ("xfs: add support for sub-pagesize writeback

without buffer_heads")

I've never seen line breaks in Fixes tags, is this really a valid format?

fs/iomap.c iomap_page_create(struct inode *inode, struct page *page) · line 124

Quoted 4 lines
fs/iomap.c +4 -0
+	/*
+	 * At least migrate_page_move_mapping() assumes that pages with private
+	 * data have their count elevated by 1.
+	 */

I'd drop the "At least".

Otherwise this looks fine to me:

#2 lore raw
Quoted 4 lines · Christoph Hellwig
Quoted 2 lines
Fixes 82cb14175e7d ("xfs: add support for sub-pagesize writeback

without buffer_heads")

I've never seen line breaks in Fixes tags, is this really a valid format?

Probably not, fixed in v2.

Quoted 7 lines

fs/iomap.c iomap_page_create(struct inode *inode, struct page *page) · line 124

Quoted 5 lines
fs/iomap.c +4 -0
+	/*
+	 * At least migrate_page_move_mapping() assumes that pages with private
+	 * data have their count elevated by 1.
+	 */

I'd drop the "At least".

Fixed in v2.

Quoted 5 lines

Otherwise this looks fine to me:

Thanks!

Thanks,
Piotr