linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* remove iomap_writepage
@ 2022-07-11  4:14 Christoph Hellwig
  2022-07-11  4:14 ` [PATCH 1/4] gfs2: stop using generic_writepages in gfs2_ail1_start_one Christoph Hellwig
                   ` (3 more replies)
  0 siblings, 4 replies; 15+ messages in thread
From: Christoph Hellwig @ 2022-07-11  4:14 UTC (permalink / raw)
  To: Bob Peterson, Andreas Gruenbacher, Darrick J. Wong,
	Damien Le Moal, Naohiro Aota
  Cc: Johannes Thumshirn, cluster-devel, linux-xfs, linux-fsdevel

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(-)

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 1/4] gfs2: stop using generic_writepages in gfs2_ail1_start_one
  2022-07-11  4:14 remove iomap_writepage Christoph Hellwig
@ 2022-07-11  4:14 ` Christoph Hellwig
  2022-07-11 10:27   ` Andreas Gruenbacher
  2022-07-11  4:14 ` [PATCH 2/4] gfs2: remove ->writepage Christoph Hellwig
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 15+ messages in thread
From: Christoph Hellwig @ 2022-07-11  4:14 UTC (permalink / raw)
  To: Bob Peterson, Andreas Gruenbacher, Darrick J. Wong,
	Damien Le Moal, Naohiro Aota
  Cc: Johannes Thumshirn, cluster-devel, linux-xfs, linux-fsdevel

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.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/gfs2/log.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/gfs2/log.c b/fs/gfs2/log.c
index f0ee3ff6f9a87..624dffc96136b 100644
--- a/fs/gfs2/log.c
+++ b/fs/gfs2/log.c
@@ -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();
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 2/4] gfs2: remove ->writepage
  2022-07-11  4:14 remove iomap_writepage Christoph Hellwig
  2022-07-11  4:14 ` [PATCH 1/4] gfs2: stop using generic_writepages in gfs2_ail1_start_one Christoph Hellwig
@ 2022-07-11  4:14 ` Christoph Hellwig
  2022-07-11 23:22   ` Andreas Grünbacher
  2022-07-11  4:14 ` [PATCH 3/4] zonefs: " Christoph Hellwig
  2022-07-11  4:14 ` [PATCH 4/4] iomap: remove iomap_writepage Christoph Hellwig
  3 siblings, 1 reply; 15+ messages in thread
From: Christoph Hellwig @ 2022-07-11  4:14 UTC (permalink / raw)
  To: Bob Peterson, Andreas Gruenbacher, Darrick J. Wong,
	Damien Le Moal, Naohiro Aota
  Cc: Johannes Thumshirn, cluster-devel, linux-xfs, linux-fsdevel

->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.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/gfs2/aops.c | 26 --------------------------
 1 file changed, 26 deletions(-)

diff --git a/fs/gfs2/aops.c b/fs/gfs2/aops.c
index 106e90a365838..0240a1a717f56 100644
--- a/fs/gfs2/aops.c
+++ b/fs/gfs2/aops.c
@@ -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,
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 3/4] zonefs: remove ->writepage
  2022-07-11  4:14 remove iomap_writepage Christoph Hellwig
  2022-07-11  4:14 ` [PATCH 1/4] gfs2: stop using generic_writepages in gfs2_ail1_start_one Christoph Hellwig
  2022-07-11  4:14 ` [PATCH 2/4] gfs2: remove ->writepage Christoph Hellwig
@ 2022-07-11  4:14 ` Christoph Hellwig
  2022-07-11  4:47   ` Damien Le Moal
  2022-07-11  9:12   ` Johannes Thumshirn
  2022-07-11  4:14 ` [PATCH 4/4] iomap: remove iomap_writepage Christoph Hellwig
  3 siblings, 2 replies; 15+ messages in thread
From: Christoph Hellwig @ 2022-07-11  4:14 UTC (permalink / raw)
  To: Bob Peterson, Andreas Gruenbacher, Darrick J. Wong,
	Damien Le Moal, Naohiro Aota
  Cc: Johannes Thumshirn, cluster-devel, linux-xfs, linux-fsdevel

->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.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/zonefs/super.c | 8 --------
 1 file changed, 8 deletions(-)

diff --git a/fs/zonefs/super.c b/fs/zonefs/super.c
index 053299758deb9..062c3f1da0327 100644
--- a/fs/zonefs/super.c
+++ b/fs/zonefs/super.c
@@ -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,
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 4/4] iomap: remove iomap_writepage
  2022-07-11  4:14 remove iomap_writepage Christoph Hellwig
                   ` (2 preceding siblings ...)
  2022-07-11  4:14 ` [PATCH 3/4] zonefs: " Christoph Hellwig
@ 2022-07-11  4:14 ` Christoph Hellwig
  2022-07-11  4:48   ` Damien Le Moal
  3 siblings, 1 reply; 15+ messages in thread
From: Christoph Hellwig @ 2022-07-11  4:14 UTC (permalink / raw)
  To: Bob Peterson, Andreas Gruenbacher, Darrick J. Wong,
	Damien Le Moal, Naohiro Aota
  Cc: Johannes Thumshirn, cluster-devel, linux-xfs, linux-fsdevel

Unused now.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/iomap/buffered-io.c | 15 ---------------
 include/linux/iomap.h  |  3 ---
 2 files changed, 18 deletions(-)

diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c
index d2a9f699e17ed..1bac8bda40d0c 100644
--- a/fs/iomap/buffered-io.c
+++ b/fs/iomap/buffered-io.c
@@ -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,
diff --git a/include/linux/iomap.h b/include/linux/iomap.h
index e552097c67e0b..911888560d3eb 100644
--- a/include/linux/iomap.h
+++ b/include/linux/iomap.h
@@ -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);
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [PATCH 3/4] zonefs: remove ->writepage
  2022-07-11  4:14 ` [PATCH 3/4] zonefs: " Christoph Hellwig
@ 2022-07-11  4:47   ` Damien Le Moal
  2022-07-11  9:12   ` Johannes Thumshirn
  1 sibling, 0 replies; 15+ messages in thread
From: Damien Le Moal @ 2022-07-11  4:47 UTC (permalink / raw)
  To: Christoph Hellwig, Bob Peterson, Andreas Gruenbacher,
	Darrick J. Wong, Naohiro Aota
  Cc: Johannes Thumshirn, cluster-devel, linux-xfs, linux-fsdevel

On 7/11/22 13:14, Christoph Hellwig wrote:
> ->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.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  fs/zonefs/super.c | 8 --------
>  1 file changed, 8 deletions(-)
> 
> diff --git a/fs/zonefs/super.c b/fs/zonefs/super.c
> index 053299758deb9..062c3f1da0327 100644
> --- a/fs/zonefs/super.c
> +++ b/fs/zonefs/super.c
> @@ -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,

Acked-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>

-- 
Damien Le Moal
Western Digital Research

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 4/4] iomap: remove iomap_writepage
  2022-07-11  4:14 ` [PATCH 4/4] iomap: remove iomap_writepage Christoph Hellwig
@ 2022-07-11  4:48   ` Damien Le Moal
  0 siblings, 0 replies; 15+ messages in thread
From: Damien Le Moal @ 2022-07-11  4:48 UTC (permalink / raw)
  To: Christoph Hellwig, Bob Peterson, Andreas Gruenbacher,
	Darrick J. Wong, Naohiro Aota
  Cc: Johannes Thumshirn, cluster-devel, linux-xfs, linux-fsdevel

On 7/11/22 13:14, Christoph Hellwig wrote:
> Unused now.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  fs/iomap/buffered-io.c | 15 ---------------
>  include/linux/iomap.h  |  3 ---
>  2 files changed, 18 deletions(-)
> 
> diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c
> index d2a9f699e17ed..1bac8bda40d0c 100644
> --- a/fs/iomap/buffered-io.c
> +++ b/fs/iomap/buffered-io.c
> @@ -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,
> diff --git a/include/linux/iomap.h b/include/linux/iomap.h
> index e552097c67e0b..911888560d3eb 100644
> --- a/include/linux/iomap.h
> +++ b/include/linux/iomap.h
> @@ -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);

Reviewed-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>

-- 
Damien Le Moal
Western Digital Research

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 3/4] zonefs: remove ->writepage
  2022-07-11  4:14 ` [PATCH 3/4] zonefs: " Christoph Hellwig
  2022-07-11  4:47   ` Damien Le Moal
@ 2022-07-11  9:12   ` Johannes Thumshirn
  1 sibling, 0 replies; 15+ messages in thread
From: Johannes Thumshirn @ 2022-07-11  9:12 UTC (permalink / raw)
  To: Christoph Hellwig, Bob Peterson, Andreas Gruenbacher,
	Darrick J. Wong, Damien Le Moal, Naohiro Aota
  Cc: Johannes Thumshirn, cluster-devel@redhat.com,
	linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org

Looks good,
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 1/4] gfs2: stop using generic_writepages in gfs2_ail1_start_one
  2022-07-11  4:14 ` [PATCH 1/4] gfs2: stop using generic_writepages in gfs2_ail1_start_one Christoph Hellwig
@ 2022-07-11 10:27   ` Andreas Gruenbacher
  2022-07-11 14:30     ` Christoph Hellwig
  0 siblings, 1 reply; 15+ messages in thread
From: Andreas Gruenbacher @ 2022-07-11 10:27 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Andreas Gruenbacher, Bob Peterson, Darrick J. Wong,
	Damien Le Moal, Naohiro Aota, Johannes Thumshirn, cluster-devel,
	linux-xfs, linux-fsdevel

Hello,

On Mon, Jul 11, 2022 at 7:27 AM Christoph Hellwig <hch@lst.de> wrote:
>
> 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.

Reviewed-by: Andreas Gruenbacher <agruenba@redhat.com>

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(-)

diff --git a/fs/gfs2/log.c b/fs/gfs2/log.c
index 624dffc96136..7fc6cb95dec8 100644
--- a/fs/gfs2/log.c
+++ b/fs/gfs2/log.c
@@ -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);
-- 
2.36.1


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [PATCH 1/4] gfs2: stop using generic_writepages in gfs2_ail1_start_one
  2022-07-11 10:27   ` Andreas Gruenbacher
@ 2022-07-11 14:30     ` Christoph Hellwig
  0 siblings, 0 replies; 15+ messages in thread
From: Christoph Hellwig @ 2022-07-11 14:30 UTC (permalink / raw)
  To: Andreas Gruenbacher
  Cc: Christoph Hellwig, Bob Peterson, Darrick J. Wong, Damien Le Moal,
	Naohiro Aota, Johannes Thumshirn, cluster-devel, linux-xfs,
	linux-fsdevel

On Mon, Jul 11, 2022 at 12:27:47PM +0200, Andreas Gruenbacher wrote:
> Can you add the below follow-up cleanup?

> -		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.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 2/4] gfs2: remove ->writepage
  2022-07-11  4:14 ` [PATCH 2/4] gfs2: remove ->writepage Christoph Hellwig
@ 2022-07-11 23:22   ` Andreas Grünbacher
  2022-07-12  4:57     ` Christoph Hellwig
  0 siblings, 1 reply; 15+ messages in thread
From: Andreas Grünbacher @ 2022-07-11 23:22 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Bob Peterson, Andreas Gruenbacher, Darrick J. Wong,
	Damien Le Moal, Naohiro Aota, Johannes Thumshirn, cluster-devel,
	linux-xfs, Linux FS-devel Mailing List

Am Mo., 11. Juli 2022 um 06:16 Uhr schrieb Christoph Hellwig <hch@lst.de>:
> ->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.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  fs/gfs2/aops.c | 26 --------------------------
>  1 file changed, 26 deletions(-)
>
> diff --git a/fs/gfs2/aops.c b/fs/gfs2/aops.c
> index 106e90a365838..0240a1a717f56 100644
> --- a/fs/gfs2/aops.c
> +++ b/fs/gfs2/aops.c
> @@ -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,
> --
> 2.30.2
>

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

Tested-by: Andreas Gruenbacher <agruenba@redhat.com>
Reviewed-by: Andreas Gruenbacher <agruenba@redhat.com>

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

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 2/4] gfs2: remove ->writepage
  2022-07-11 23:22   ` Andreas Grünbacher
@ 2022-07-12  4:57     ` Christoph Hellwig
  0 siblings, 0 replies; 15+ messages in thread
From: Christoph Hellwig @ 2022-07-12  4:57 UTC (permalink / raw)
  To: Andreas Grünbacher
  Cc: Christoph Hellwig, Bob Peterson, Andreas Gruenbacher,
	Darrick J. Wong, Damien Le Moal, Naohiro Aota, Johannes Thumshirn,
	cluster-devel, linux-xfs, Linux FS-devel Mailing List

On Tue, Jul 12, 2022 at 01:22:48AM +0200, Andreas Grünbacher wrote:
> 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.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 1/4] gfs2: stop using generic_writepages in gfs2_ail1_start_one
  2022-07-19  4:13 remove iomap_writepage v2 Christoph Hellwig
@ 2022-07-19  4:13 ` Christoph Hellwig
  2023-01-18 21:22   ` Andreas Gruenbacher
  0 siblings, 1 reply; 15+ messages in thread
From: Christoph Hellwig @ 2022-07-19  4:13 UTC (permalink / raw)
  To: Bob Peterson, Andreas Gruenbacher, Darrick J. Wong,
	Damien Le Moal, Naohiro Aota
  Cc: Johannes Thumshirn, cluster-devel, linux-xfs, linux-fsdevel

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.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Andreas Gruenbacher <agruenba@redhat.com>
---
 fs/gfs2/log.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/fs/gfs2/log.c b/fs/gfs2/log.c
index f0ee3ff6f9a87..a66e3b1f6d178 100644
--- a/fs/gfs2/log.c
+++ b/fs/gfs2/log.c
@@ -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();
@@ -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);
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [PATCH 1/4] gfs2: stop using generic_writepages in gfs2_ail1_start_one
  2022-07-19  4:13 ` [PATCH 1/4] gfs2: stop using generic_writepages in gfs2_ail1_start_one Christoph Hellwig
@ 2023-01-18 21:22   ` Andreas Gruenbacher
  2023-01-19  6:22     ` Christoph Hellwig
  0 siblings, 1 reply; 15+ messages in thread
From: Andreas Gruenbacher @ 2023-01-18 21:22 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Bob Peterson, Darrick J. Wong, Damien Le Moal, Naohiro Aota,
	Johannes Thumshirn, cluster-devel, linux-xfs, linux-fsdevel

Hi Christoph,

On Tue, Jul 19, 2022 at 7:07 AM Christoph Hellwig <hch@lst.de> wrote:
>
> 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.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> Reviewed-by: Andreas Gruenbacher <agruenba@redhat.com>
> ---
>  fs/gfs2/log.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/fs/gfs2/log.c b/fs/gfs2/log.c
> index f0ee3ff6f9a87..a66e3b1f6d178 100644
> --- a/fs/gfs2/log.c
> +++ b/fs/gfs2/log.c
> @@ -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);

this patch unfortunately breaks journaled data inodes.

We're in function gfs2_ail1_start_one() here, which is usually called
via gfs2_log_flush() -> empty_ail1_list() -> gfs2_ail1_start() ->
gfs2_ail1_flush() -> gfs2_ail1_start_one(), and we're going through
the list of buffer heads in the transaction to be flushed. We used to
submit each dirty buffer for I/O individually, but since commit
5ac048bb7ea6 ("GFS2: Use filemap_fdatawrite() to write back the AIL"),
we're submitting all the dirty pages in the metadata address space
this buffer head belongs to. That's slightly bizarre, but it happens
to catch exactly the same buffer heads that are in the transaction, so
we end up with the same result. From what I'm being told, this was
done as a performance optimization -- but nobody actually knows the
details anymore.

The above change means that instead of calling generic_writepages(),
we end up calling filemap_fdatawrite_wbc() -> do_writepages() ->
mapping->a_ops->writepages(). But that's something completely
different; the writepages address space operation operates is outward
facing, while we really only want to write out the dirty buffers /
pages in the underlying address space. In case of journaled data
inodes, gfs2_jdata_writepages() actually ends up trying to create a
filesystem transaction, which immediately hangs because we're in the
middle of a log flush.

So I'm tempted to revert the following two of your commits; luckily
that's independent from the iomap_writepage() removal:

  d3d71901b1ea ("gfs2: remove ->writepage")
  b2b0a5e97855 ("gfs2: stop using generic_writepages in gfs2_ail1_start_one")

I think we could go through iomap_writepages() instead of
generic_writepages() here as well,  but that's for another day.

As far as cgroup writeback goes, this is journal I/O and I don't have
the faintest idea how the accounting for that is even supposed to
work.

>                 if (need_resched()) {
>                         blk_finish_plug(plug);
>                         cond_resched();
> @@ -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);
> --
> 2.30.2
>

Thanks,
Andreas


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 1/4] gfs2: stop using generic_writepages in gfs2_ail1_start_one
  2023-01-18 21:22   ` Andreas Gruenbacher
@ 2023-01-19  6:22     ` Christoph Hellwig
  0 siblings, 0 replies; 15+ messages in thread
From: Christoph Hellwig @ 2023-01-19  6:22 UTC (permalink / raw)
  To: Andreas Gruenbacher
  Cc: Christoph Hellwig, Bob Peterson, Darrick J. Wong, Damien Le Moal,
	Naohiro Aota, Johannes Thumshirn, cluster-devel, linux-xfs,
	linux-fsdevel

On Wed, Jan 18, 2023 at 10:22:20PM +0100, Andreas Gruenbacher wrote:
> The above change means that instead of calling generic_writepages(),
> we end up calling filemap_fdatawrite_wbc() -> do_writepages() ->
> mapping->a_ops->writepages(). But that's something completely
> different; the writepages address space operation operates is outward
> facing, while we really only want to write out the dirty buffers /
> pages in the underlying address space. In case of journaled data
> inodes, gfs2_jdata_writepages() actually ends up trying to create a
> filesystem transaction, which immediately hangs because we're in the
> middle of a log flush.
> 
> So I'm tempted to revert the following two of your commits; luckily
> that's independent from the iomap_writepage() removal:
> 
>   d3d71901b1ea ("gfs2: remove ->writepage")
>   b2b0a5e97855 ("gfs2: stop using generic_writepages in gfs2_ail1_start_one")

generic_writepages is gone in linux-next, and I'd really like to keep
it that way.  So if you have to do this, please open code it
using write_cache_pages and a direct call to the writepage method of
choice.

> I think we could go through iomap_writepages() instead of
> generic_writepages() here as well,  but that's for another day.

Well, that would obviously be much better, and actually help with the
goal of removing ->writepage.

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2023-01-19  6:22 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-07-11  4:14 remove iomap_writepage Christoph Hellwig
2022-07-11  4:14 ` [PATCH 1/4] gfs2: stop using generic_writepages in gfs2_ail1_start_one Christoph Hellwig
2022-07-11 10:27   ` Andreas Gruenbacher
2022-07-11 14:30     ` Christoph Hellwig
2022-07-11  4:14 ` [PATCH 2/4] gfs2: remove ->writepage Christoph Hellwig
2022-07-11 23:22   ` Andreas Grünbacher
2022-07-12  4:57     ` Christoph Hellwig
2022-07-11  4:14 ` [PATCH 3/4] zonefs: " Christoph Hellwig
2022-07-11  4:47   ` Damien Le Moal
2022-07-11  9:12   ` Johannes Thumshirn
2022-07-11  4:14 ` [PATCH 4/4] iomap: remove iomap_writepage Christoph Hellwig
2022-07-11  4:48   ` Damien Le Moal
  -- strict thread matches above, loose matches on Subject: below --
2022-07-19  4:13 remove iomap_writepage v2 Christoph Hellwig
2022-07-19  4:13 ` [PATCH 1/4] gfs2: stop using generic_writepages in gfs2_ail1_start_one Christoph Hellwig
2023-01-18 21:22   ` Andreas Gruenbacher
2023-01-19  6:22     ` Christoph Hellwig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).