Skip to contentSkip to conversation

remove iomap_writepage

PATCH In review Christoph Hellwig 5 participants 12 messages Jul 11, 2022 – Jul 12, 2022

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

Hi all,

this series removes iomap_writepage and it's callers, following what xfs has been doing for a long time.

Diffstat:

 fs/gfs2/aops.c         |   26 --------------------------
 fs/gfs2/log.c          |    2 +-
 fs/iomap/buffered-io.c |   15 ---------------
 fs/zonefs/super.c      |    8 --------
 include/linux/iomap.h  |    3 ---
 5 files changed, 1 insertion(+), 53 deletions(-)
#1 lore raw

PATCH 1/4 gfs2: stop using generic_writepages in gfs2_ail1_start_one

Use filemap_fdatawrite_wbc instead of generic_writepages in gfs2_ail1_start_one so that the functin can also cope with address_space operations that only implement ->writepages and to properly account for cgroup writeback.

---
 fs/gfs2/log.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/gfs2/log.c +1 -1
index f0ee3ff6f9a87..624dffc96136b 100644
@@ -131,7 +131,7 @@ __acquires(&sdp->sd_ail_lock)
 		if (!mapping)
 			continue;
 		spin_unlock(&sdp->sd_ail_lock);
-		ret = generic_writepages(mapping, wbc);
+		ret = filemap_fdatawrite_wbc(mapping, wbc);
 		if (need_resched()) {
 			blk_finish_plug(plug);
 			cond_resched();
Signature · 1 line
2.30.2
maintainer Reviewed-by on v1 1/4
#2 lore raw

Re: [PATCH 1/4] gfs2: stop using generic_writepages in gfs2_ail1_start_one

Hello,

Quoted 5 lines · Christoph Hellwig

Use filemap_fdatawrite_wbc instead of generic_writepages in gfs2_ail1_start_one so that the functin can also cope with address_space operations that only implement ->writepages and to properly account for cgroup writeback.

I assume you want to push this through the xfs tree.

Can you add the below follow-up cleanup?

Thanks,
Andreas

---
 fs/gfs2/log.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
fs/gfs2/log.c +1 -2
index 624dffc96136..7fc6cb95dec8 100644
@@ -222,8 +222,7 @@ void gfs2_ail1_flush(struct gfs2_sbd *sdp, struct writeback_control *wbc)
 	spin_unlock(&sdp->sd_ail_lock);
 	blk_finish_plug(&plug);
 	if (ret) {
-		gfs2_lm(sdp, "gfs2_ail1_start_one (generic_writepages) "
-			"returned: %d\n", ret);
+		gfs2_lm(sdp, "gfs2_ail1_start_one returned %d\n", ret);
 		gfs2_withdraw(sdp);
 	}
 	trace_gfs2_ail_flush(sdp, wbc, 0);
Signature · 1 line
2.36.1
#3 lore raw

Re: [PATCH 1/4] gfs2: stop using generic_writepages in gfs2_ail1_start_one

fs/gfs2/log.c void gfs2_ail1_flush(struct gfs2_sbd *sdp, struct writeback_control *wbc) · line 225

Quoted 5 lines · Andreas Gruenbacher

Can you add the below follow-up cleanup?

fs/gfs2/log.c +1 -2
-		gfs2_lm(sdp, "gfs2_ail1_start_one (generic_writepages) "
-			"returned: %d\n", ret);
+		gfs2_lm(sdp, "gfs2_ail1_start_one returned %d\n", ret);

The cleanup looks fine to me, yes.

#4 lore raw

PATCH 2/4 gfs2: remove ->writepage

In reply to Christoph Hellwig

->writepage is only used for single page writeback from memory reclaim, and not called at all for cgroup writeback. Follow the lead of XFS and remove ->writepage and rely entirely on ->writepages.

---
 fs/gfs2/aops.c | 26 --------------------------
 1 file changed, 26 deletions(-)
fs/gfs2/aops.c +0 -26
index 106e90a365838..0240a1a717f56 100644
@@ -81,31 +81,6 @@ static int gfs2_get_block_noalloc(struct inode *inode, sector_t lblock,
 	return 0;
 }
 
-/**
- * gfs2_writepage - Write page for writeback mappings
- * @page: The page
- * @wbc: The writeback control
- */
-static int gfs2_writepage(struct page *page, struct writeback_control *wbc)
-{
-	struct inode *inode = page->mapping->host;
-	struct gfs2_inode *ip = GFS2_I(inode);
-	struct gfs2_sbd *sdp = GFS2_SB(inode);
-	struct iomap_writepage_ctx wpc = { };
-
-	if (gfs2_assert_withdraw(sdp, gfs2_glock_is_held_excl(ip->i_gl)))
-		goto out;
-	if (current->journal_info)
-		goto redirty;
-	return iomap_writepage(page, wbc, &wpc, &gfs2_writeback_ops);
-
-redirty:
-	redirty_page_for_writepage(wbc, page);
-out:
-	unlock_page(page);
-	return 0;
-}
-
 /**
  * gfs2_write_jdata_page - gfs2 jdata-specific version of block_write_full_page
  * @page: The page to write
@@ -765,7 +740,6 @@ bool gfs2_release_folio(struct folio *folio, gfp_t gfp_mask)
 }
 
 static const struct address_space_operations gfs2_aops = {
-	.writepage = gfs2_writepage,
 	.writepages = gfs2_writepages,
 	.read_folio = gfs2_read_folio,
 	.readahead = gfs2_readahead,
Signature · 1 line
2.30.2
Tested-by Andreas Gruenbacher Reviewed-by Andreas Gruenbacher on v1 2/4
#5 lore raw

Re: [PATCH 2/4] gfs2: remove ->writepage

Am Mo., 11. Juli 2022 um 06:16 Uhr schrieb Christoph Hellwig <[email protected]>:

Quoted 54 lines

->writepage is only used for single page writeback from memory reclaim, and not called at all for cgroup writeback. Follow the lead of XFS and remove ->writepage and rely entirely on ->writepages.

---
 fs/gfs2/aops.c | 26 --------------------------
 1 file changed, 26 deletions(-)
fs/gfs2/aops.c +0 -27
index 106e90a365838..0240a1a717f56 100644
@@ -81,31 +81,6 @@ static int gfs2_get_block_noalloc(struct inode *inode, sector_t lblock,
        return 0;
 }
 
-/**
- * gfs2_writepage - Write page for writeback mappings
- * @page: The page
- * @wbc: The writeback control
- */
-static int gfs2_writepage(struct page *page, struct writeback_control *wbc)
-{
-       struct inode *inode = page->mapping->host;
-       struct gfs2_inode *ip = GFS2_I(inode);
-       struct gfs2_sbd *sdp = GFS2_SB(inode);
-       struct iomap_writepage_ctx wpc = { };
-
-       if (gfs2_assert_withdraw(sdp, gfs2_glock_is_held_excl(ip->i_gl)))
-               goto out;
-       if (current->journal_info)
-               goto redirty;
-       return iomap_writepage(page, wbc, &wpc, &gfs2_writeback_ops);
-
-redirty:
-       redirty_page_for_writepage(wbc, page);
-out:
-       unlock_page(page);
-       return 0;
-}
-
 /**
  * gfs2_write_jdata_page - gfs2 jdata-specific version of block_write_full_page
  * @page: The page to write
@@ -765,7 +740,6 @@ bool gfs2_release_folio(struct folio *folio, gfp_t gfp_mask)
 }
 
 static const struct address_space_operations gfs2_aops = {
-       .writepage = gfs2_writepage,
        .writepages = gfs2_writepages,
        .read_folio = gfs2_read_folio,
        .readahead = gfs2_readahead,
--
Quoted 2 lines

2.30.2

This is looking fine, and it has survived a moderate amount of testing already.

It should be possible to remove the .writepage operation in gfs2_jdata_aops as well, but I must be overlooking something because that actually breaks things.

Thanks,
Andreas

#6 lore raw

Re: [PATCH 2/4] gfs2: remove ->writepage

Quoted 3 lines · Andreas Gr?nbacher

It should be possible to remove the .writepage operation in gfs2_jdata_aops as well, but I must be overlooking something because that actually breaks things.

We'll need to wire up ->migratepage for it first to not lose any memory migration functinality. But yes, the plan is to eventually kill off ->writepage. If I can get you to look into gfs2_jdata_aops, gfs2_meta_aops and gfs2_rgrp_aops, that would be awesome.

#7 lore raw

PATCH 3/4 zonefs: remove ->writepage

In reply to Christoph Hellwig

->writepage is only used for single page writeback from memory reclaim, and not called at all for cgroup writeback. Follow the lead of XFS and remove ->writepage and rely entirely on ->writepages.

---
 fs/zonefs/super.c | 8 --------
 1 file changed, 8 deletions(-)
fs/zonefs/super.c +0 -8
index 053299758deb9..062c3f1da0327 100644
@@ -232,13 +232,6 @@ static const struct iomap_writeback_ops zonefs_writeback_ops = {
 	.map_blocks		= zonefs_write_map_blocks,
 };
 
-static int zonefs_writepage(struct page *page, struct writeback_control *wbc)
-{
-	struct iomap_writepage_ctx wpc = { };
-
-	return iomap_writepage(page, wbc, &wpc, &zonefs_writeback_ops);
-}
-
 static int zonefs_writepages(struct address_space *mapping,
 			     struct writeback_control *wbc)
 {
@@ -266,7 +259,6 @@ static int zonefs_swap_activate(struct swap_info_struct *sis,
 static const struct address_space_operations zonefs_file_aops = {
 	.read_folio		= zonefs_read_folio,
 	.readahead		= zonefs_readahead,
-	.writepage		= zonefs_writepage,
 	.writepages		= zonefs_writepages,
 	.dirty_folio		= filemap_dirty_folio,
 	.release_folio		= iomap_release_folio,
Signature · 1 line
2.30.2
Acked-by on v1 3/4
#8 lore raw

Re: [PATCH 3/4] zonefs: remove ->writepage

Quoted 28 lines · Christoph Hellwig

->writepage is only used for single page writeback from memory reclaim, and not called at all for cgroup writeback. Follow the lead of XFS and remove ->writepage and rely entirely on ->writepages.

---
 fs/zonefs/super.c | 8 --------
 1 file changed, 8 deletions(-)
fs/zonefs/super.c +0 -7
index 053299758deb9..062c3f1da0327 100644
@@ -232,13 +232,6 @@ static const struct iomap_writeback_ops zonefs_writeback_ops = {
 	.map_blocks		= zonefs_write_map_blocks,
 };
 
-static int zonefs_writepage(struct page *page, struct writeback_control *wbc)
-{
-	struct iomap_writepage_ctx wpc = { };
-
-	return iomap_writepage(page, wbc, &wpc, &zonefs_writeback_ops);
-}
-
 static int zonefs_writepages(struct address_space *mapping,
 			     struct writeback_control *wbc)
 {

fs/zonefs/super.c static int zonefs_swap_activate(struct swap_info_struct *sis, · line 264

Quoted 7 lines
fs/zonefs/super.c +0 -1
@@ -266,7 +259,6 @@ static int zonefs_swap_activate(struct swap_info_struct *sis,
 static const struct address_space_operations zonefs_file_aops = {
 	.read_folio		= zonefs_read_folio,
 	.readahead		= zonefs_readahead,
-	.writepage		= zonefs_writepage,
 	.writepages		= zonefs_writepages,
 	.dirty_folio		= filemap_dirty_folio,
 	.release_folio		= iomap_release_folio,
Signature · 2 lines
Damien Le Moal
Western Digital Research
#10 lore raw

PATCH 4/4 iomap: remove iomap_writepage

In reply to Christoph Hellwig

Unused now.

---
 fs/iomap/buffered-io.c | 15 ---------------
 include/linux/iomap.h  |  3 ---
 2 files changed, 18 deletions(-)
fs/iomap/buffered-io.c +0 -15
index d2a9f699e17ed..1bac8bda40d0c 100644
@@ -1518,21 +1518,6 @@ iomap_do_writepage(struct page *page, struct writeback_control *wbc, void *data)
 	return 0;
 }
 
-int
-iomap_writepage(struct page *page, struct writeback_control *wbc,
-		struct iomap_writepage_ctx *wpc,
-		const struct iomap_writeback_ops *ops)
-{
-	int ret;
-
-	wpc->ops = ops;
-	ret = iomap_do_writepage(page, wbc, wpc);
-	if (!wpc->ioend)
-		return ret;
-	return iomap_submit_ioend(wpc, wpc->ioend, ret);
-}
-EXPORT_SYMBOL_GPL(iomap_writepage);
-
 int
 iomap_writepages(struct address_space *mapping, struct writeback_control *wbc,
 		struct iomap_writepage_ctx *wpc,
include/linux/iomap.h +0 -3
index e552097c67e0b..911888560d3eb 100644
@@ -303,9 +303,6 @@ void iomap_finish_ioends(struct iomap_ioend *ioend, int error);
 void iomap_ioend_try_merge(struct iomap_ioend *ioend,
 		struct list_head *more_ioends);
 void iomap_sort_ioends(struct list_head *ioend_list);
-int iomap_writepage(struct page *page, struct writeback_control *wbc,
-		struct iomap_writepage_ctx *wpc,
-		const struct iomap_writeback_ops *ops);
 int iomap_writepages(struct address_space *mapping,
 		struct writeback_control *wbc, struct iomap_writepage_ctx *wpc,
 		const struct iomap_writeback_ops *ops);
Signature · 1 line
2.30.2
Reviewed-by on v1 4/4
#11 lore raw

Re: [PATCH 4/4] iomap: remove iomap_writepage

Quoted 39 lines · Christoph Hellwig

Unused now.

---
 fs/iomap/buffered-io.c | 15 ---------------
 include/linux/iomap.h  |  3 ---
 2 files changed, 18 deletions(-)
fs/iomap/buffered-io.c +0 -15
index d2a9f699e17ed..1bac8bda40d0c 100644
@@ -1518,21 +1518,6 @@ iomap_do_writepage(struct page *page, struct writeback_control *wbc, void *data)
 	return 0;
 }
 
-int
-iomap_writepage(struct page *page, struct writeback_control *wbc,
-		struct iomap_writepage_ctx *wpc,
-		const struct iomap_writeback_ops *ops)
-{
-	int ret;
-
-	wpc->ops = ops;
-	ret = iomap_do_writepage(page, wbc, wpc);
-	if (!wpc->ioend)
-		return ret;
-	return iomap_submit_ioend(wpc, wpc->ioend, ret);
-}
-EXPORT_SYMBOL_GPL(iomap_writepage);
-
 int
 iomap_writepages(struct address_space *mapping, struct writeback_control *wbc,
 		struct iomap_writepage_ctx *wpc,
include/linux/iomap.h +0 -0
index e552097c67e0b..911888560d3eb 100644

include/linux/iomap.h void iomap_finish_ioends(struct iomap_ioend *ioend, int error); · line 308

Quoted 9 lines
include/linux/iomap.h +0 -3
@@ -303,9 +303,6 @@ void iomap_finish_ioends(struct iomap_ioend *ioend, int error);
 void iomap_ioend_try_merge(struct iomap_ioend *ioend,
 		struct list_head *more_ioends);
 void iomap_sort_ioends(struct list_head *ioend_list);
-int iomap_writepage(struct page *page, struct writeback_control *wbc,
-		struct iomap_writepage_ctx *wpc,
-		const struct iomap_writeback_ops *ops);
 int iomap_writepages(struct address_space *mapping,
 		struct writeback_control *wbc, struct iomap_writepage_ctx *wpc,
 		const struct iomap_writeback_ops *ops);
Signature · 2 lines
Damien Le Moal
Western Digital Research