gfs2.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] Remove uses of aops->writepage from gfs2
@ 2024-07-19 17:51 Matthew Wilcox (Oracle)
  2024-07-19 17:51 ` [PATCH 1/4] gfs2: Add gfs2_aspace_writepages() Matthew Wilcox (Oracle)
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Matthew Wilcox (Oracle) @ 2024-07-19 17:51 UTC (permalink / raw)
  To: Andreas Gruenbacher; +Cc: Matthew Wilcox (Oracle), gfs2, linux-fsdevel

Hi Andreas,

Here's my latest attempt to switch gfs2 from ->writepage to
->writepages.  I've been a bit more careful this time; I'm not sure
whether __gfs2_writepage() could call gfs2_aspace_writepage(), but
this order of patches shouldn't break any bisection.

Matthew Wilcox (Oracle) (4):
  gfs2: Add gfs2_aspace_writepages()
  gfs2: Remove __gfs2_writepage()
  gfs2: Remove gfs2_jdata_writepage()
  gfs2: Remove gfs2_aspace_writepage()

 fs/gfs2/aops.c    | 30 ------------------------------
 fs/gfs2/log.c     | 12 ++----------
 fs/gfs2/meta_io.c | 24 +++++++++++++++++-------
 3 files changed, 19 insertions(+), 47 deletions(-)

-- 
2.43.0


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

* [PATCH 1/4] gfs2: Add gfs2_aspace_writepages()
  2024-07-19 17:51 [PATCH 0/4] Remove uses of aops->writepage from gfs2 Matthew Wilcox (Oracle)
@ 2024-07-19 17:51 ` Matthew Wilcox (Oracle)
  2024-07-19 17:51 ` [PATCH 2/4] gfs2: Remove __gfs2_writepage() Matthew Wilcox (Oracle)
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Matthew Wilcox (Oracle) @ 2024-07-19 17:51 UTC (permalink / raw)
  To: Andreas Gruenbacher; +Cc: Matthew Wilcox (Oracle), gfs2, linux-fsdevel

This saves one indirect function call per folio and gets us closer to
removing aops->writepage.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 fs/gfs2/meta_io.c | 28 +++++++++++++++++++++++-----
 1 file changed, 23 insertions(+), 5 deletions(-)

diff --git a/fs/gfs2/meta_io.c b/fs/gfs2/meta_io.c
index 2b26e8d529aa..cfb204c9396c 100644
--- a/fs/gfs2/meta_io.c
+++ b/fs/gfs2/meta_io.c
@@ -30,9 +30,9 @@
 #include "util.h"
 #include "trace_gfs2.h"
 
-static int gfs2_aspace_writepage(struct page *page, struct writeback_control *wbc)
+static void gfs2_aspace_write_folio(struct folio *folio,
+		struct writeback_control *wbc)
 {
-	struct folio *folio = page_folio(page);
 	struct buffer_head *bh, *head;
 	int nr_underway = 0;
 	blk_opf_t write_flags = REQ_META | REQ_PRIO | wbc_to_write_flags(wbc);
@@ -66,8 +66,8 @@ static int gfs2_aspace_writepage(struct page *page, struct writeback_control *wb
 	} while ((bh = bh->b_this_page) != head);
 
 	/*
-	 * The page and its buffers are protected by PageWriteback(), so we can
-	 * drop the bh refcounts early.
+	 * The folio and its buffers are protected from truncation by
+	 * the writeback flag, so we can drop the bh refcounts early.
 	 */
 	BUG_ON(folio_test_writeback(folio));
 	folio_start_writeback(folio);
@@ -84,14 +84,31 @@ static int gfs2_aspace_writepage(struct page *page, struct writeback_control *wb
 
 	if (nr_underway == 0)
 		folio_end_writeback(folio);
+}
+
+static int gfs2_aspace_writepage(struct page *page, struct writeback_control *wbc)
+{
+	gfs2_aspace_write_folio(page_folio(page), wbc);
 
 	return 0;
 }
 
+static int gfs2_aspace_writepages(struct address_space *mapping,
+		struct writeback_control *wbc)
+{
+	struct folio *folio = NULL;
+	int error;
+
+	while ((folio = writeback_iter(mapping, wbc, folio, &error)))
+		gfs2_aspace_write_folio(folio, wbc);
+
+	return error;
+}
+
 const struct address_space_operations gfs2_meta_aops = {
 	.dirty_folio	= block_dirty_folio,
 	.invalidate_folio = block_invalidate_folio,
-	.writepage = gfs2_aspace_writepage,
+	.writepages = gfs2_aspace_writepages,
 	.release_folio = gfs2_release_folio,
 };
 
@@ -99,6 +116,7 @@ const struct address_space_operations gfs2_rgrp_aops = {
 	.dirty_folio	= block_dirty_folio,
 	.invalidate_folio = block_invalidate_folio,
 	.writepage = gfs2_aspace_writepage,
+	.writepages = gfs2_aspace_writepages,
 	.release_folio = gfs2_release_folio,
 };
 
-- 
2.43.0


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

* [PATCH 2/4] gfs2: Remove __gfs2_writepage()
  2024-07-19 17:51 [PATCH 0/4] Remove uses of aops->writepage from gfs2 Matthew Wilcox (Oracle)
  2024-07-19 17:51 ` [PATCH 1/4] gfs2: Add gfs2_aspace_writepages() Matthew Wilcox (Oracle)
@ 2024-07-19 17:51 ` Matthew Wilcox (Oracle)
  2024-07-19 17:51 ` [PATCH 3/4] gfs2: Remove gfs2_jdata_writepage() Matthew Wilcox (Oracle)
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Matthew Wilcox (Oracle) @ 2024-07-19 17:51 UTC (permalink / raw)
  To: Andreas Gruenbacher; +Cc: Matthew Wilcox (Oracle), gfs2, linux-fsdevel

Call aops->writepages() instead of using write_cache_pages() to call
aops->writepage.  Change the handling of -ENODATA to not set the
persistent error on the block device.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 fs/gfs2/log.c | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)

diff --git a/fs/gfs2/log.c b/fs/gfs2/log.c
index 6ee6013fb825..f9c5089783d2 100644
--- a/fs/gfs2/log.c
+++ b/fs/gfs2/log.c
@@ -80,15 +80,6 @@ void gfs2_remove_from_ail(struct gfs2_bufdata *bd)
 	brelse(bd->bd_bh);
 }
 
-static int __gfs2_writepage(struct folio *folio, struct writeback_control *wbc,
-		       void *data)
-{
-	struct address_space *mapping = data;
-	int ret = mapping->a_ops->writepage(&folio->page, wbc);
-	mapping_set_error(mapping, ret);
-	return ret;
-}
-
 /**
  * gfs2_ail1_start_one - Start I/O on a transaction
  * @sdp: The superblock
@@ -140,7 +131,7 @@ __acquires(&sdp->sd_ail_lock)
 		if (!mapping)
 			continue;
 		spin_unlock(&sdp->sd_ail_lock);
-		ret = write_cache_pages(mapping, wbc, __gfs2_writepage, mapping);
+		ret = mapping->a_ops->writepages(mapping, wbc);
 		if (need_resched()) {
 			blk_finish_plug(plug);
 			cond_resched();
@@ -149,6 +140,7 @@ __acquires(&sdp->sd_ail_lock)
 		spin_lock(&sdp->sd_ail_lock);
 		if (ret == -ENODATA) /* if a jdata write into a new hole */
 			ret = 0; /* ignore it */
+		mapping_set_error(mapping, ret);
 		if (ret || wbc->nr_to_write <= 0)
 			break;
 		return -EBUSY;
-- 
2.43.0


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

* [PATCH 3/4] gfs2: Remove gfs2_jdata_writepage()
  2024-07-19 17:51 [PATCH 0/4] Remove uses of aops->writepage from gfs2 Matthew Wilcox (Oracle)
  2024-07-19 17:51 ` [PATCH 1/4] gfs2: Add gfs2_aspace_writepages() Matthew Wilcox (Oracle)
  2024-07-19 17:51 ` [PATCH 2/4] gfs2: Remove __gfs2_writepage() Matthew Wilcox (Oracle)
@ 2024-07-19 17:51 ` Matthew Wilcox (Oracle)
  2024-07-19 17:51 ` [PATCH 4/4] gfs2: Remove gfs2_aspace_writepage() Matthew Wilcox (Oracle)
  2024-08-07 12:21 ` [PATCH 0/4] Remove uses of aops->writepage from gfs2 Matthew Wilcox
  4 siblings, 0 replies; 7+ messages in thread
From: Matthew Wilcox (Oracle) @ 2024-07-19 17:51 UTC (permalink / raw)
  To: Andreas Gruenbacher; +Cc: Matthew Wilcox (Oracle), gfs2, linux-fsdevel

There are no remaining callers of gfs2_jdata_writepage() other than
vmscan, which is known to do more harm than good.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 fs/gfs2/aops.c | 30 ------------------------------
 1 file changed, 30 deletions(-)

diff --git a/fs/gfs2/aops.c b/fs/gfs2/aops.c
index 10d5acd3f742..68fc8af14700 100644
--- a/fs/gfs2/aops.c
+++ b/fs/gfs2/aops.c
@@ -138,35 +138,6 @@ static int __gfs2_jdata_write_folio(struct folio *folio,
 	return gfs2_write_jdata_folio(folio, wbc);
 }
 
-/**
- * gfs2_jdata_writepage - Write complete page
- * @page: Page to write
- * @wbc: The writeback control
- *
- * Returns: errno
- *
- */
-
-static int gfs2_jdata_writepage(struct page *page, struct writeback_control *wbc)
-{
-	struct folio *folio = page_folio(page);
-	struct inode *inode = page->mapping->host;
-	struct gfs2_inode *ip = GFS2_I(inode);
-	struct gfs2_sbd *sdp = GFS2_SB(inode);
-
-	if (gfs2_assert_withdraw(sdp, ip->i_gl->gl_state == LM_ST_EXCLUSIVE))
-		goto out;
-	if (folio_test_checked(folio) || current->journal_info)
-		goto out_ignore;
-	return __gfs2_jdata_write_folio(folio, wbc);
-
-out_ignore:
-	folio_redirty_for_writepage(wbc, folio);
-out:
-	folio_unlock(folio);
-	return 0;
-}
-
 /**
  * gfs2_writepages - Write a bunch of dirty pages back to disk
  * @mapping: The mapping to write
@@ -748,7 +719,6 @@ static const struct address_space_operations gfs2_aops = {
 };
 
 static const struct address_space_operations gfs2_jdata_aops = {
-	.writepage = gfs2_jdata_writepage,
 	.writepages = gfs2_jdata_writepages,
 	.read_folio = gfs2_read_folio,
 	.readahead = gfs2_readahead,
-- 
2.43.0


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

* [PATCH 4/4] gfs2: Remove gfs2_aspace_writepage()
  2024-07-19 17:51 [PATCH 0/4] Remove uses of aops->writepage from gfs2 Matthew Wilcox (Oracle)
                   ` (2 preceding siblings ...)
  2024-07-19 17:51 ` [PATCH 3/4] gfs2: Remove gfs2_jdata_writepage() Matthew Wilcox (Oracle)
@ 2024-07-19 17:51 ` Matthew Wilcox (Oracle)
  2024-08-07 12:21 ` [PATCH 0/4] Remove uses of aops->writepage from gfs2 Matthew Wilcox
  4 siblings, 0 replies; 7+ messages in thread
From: Matthew Wilcox (Oracle) @ 2024-07-19 17:51 UTC (permalink / raw)
  To: Andreas Gruenbacher; +Cc: Matthew Wilcox (Oracle), gfs2, linux-fsdevel

There are no remaining callers of gfs2_aspace_writepage() other than
vmscan, which is known to do more harm than good.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 fs/gfs2/meta_io.c | 8 --------
 1 file changed, 8 deletions(-)

diff --git a/fs/gfs2/meta_io.c b/fs/gfs2/meta_io.c
index cfb204c9396c..fea3efcc2f93 100644
--- a/fs/gfs2/meta_io.c
+++ b/fs/gfs2/meta_io.c
@@ -86,13 +86,6 @@ static void gfs2_aspace_write_folio(struct folio *folio,
 		folio_end_writeback(folio);
 }
 
-static int gfs2_aspace_writepage(struct page *page, struct writeback_control *wbc)
-{
-	gfs2_aspace_write_folio(page_folio(page), wbc);
-
-	return 0;
-}
-
 static int gfs2_aspace_writepages(struct address_space *mapping,
 		struct writeback_control *wbc)
 {
@@ -115,7 +108,6 @@ const struct address_space_operations gfs2_meta_aops = {
 const struct address_space_operations gfs2_rgrp_aops = {
 	.dirty_folio	= block_dirty_folio,
 	.invalidate_folio = block_invalidate_folio,
-	.writepage = gfs2_aspace_writepage,
 	.writepages = gfs2_aspace_writepages,
 	.release_folio = gfs2_release_folio,
 };
-- 
2.43.0


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

* Re: [PATCH 0/4] Remove uses of aops->writepage from gfs2
  2024-07-19 17:51 [PATCH 0/4] Remove uses of aops->writepage from gfs2 Matthew Wilcox (Oracle)
                   ` (3 preceding siblings ...)
  2024-07-19 17:51 ` [PATCH 4/4] gfs2: Remove gfs2_aspace_writepage() Matthew Wilcox (Oracle)
@ 2024-08-07 12:21 ` Matthew Wilcox
  2024-08-07 16:24   ` Andreas Gruenbacher
  4 siblings, 1 reply; 7+ messages in thread
From: Matthew Wilcox @ 2024-08-07 12:21 UTC (permalink / raw)
  To: Andreas Gruenbacher; +Cc: gfs2, linux-fsdevel

On Fri, Jul 19, 2024 at 06:51:00PM +0100, Matthew Wilcox (Oracle) wrote:
> Hi Andreas,
> 
> Here's my latest attempt to switch gfs2 from ->writepage to
> ->writepages.  I've been a bit more careful this time; I'm not sure
> whether __gfs2_writepage() could call gfs2_aspace_writepage(), but
> this order of patches shouldn't break any bisection.

ping

> Matthew Wilcox (Oracle) (4):
>   gfs2: Add gfs2_aspace_writepages()
>   gfs2: Remove __gfs2_writepage()
>   gfs2: Remove gfs2_jdata_writepage()
>   gfs2: Remove gfs2_aspace_writepage()
> 
>  fs/gfs2/aops.c    | 30 ------------------------------
>  fs/gfs2/log.c     | 12 ++----------
>  fs/gfs2/meta_io.c | 24 +++++++++++++++++-------
>  3 files changed, 19 insertions(+), 47 deletions(-)
> 
> -- 
> 2.43.0
> 

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

* Re: [PATCH 0/4] Remove uses of aops->writepage from gfs2
  2024-08-07 12:21 ` [PATCH 0/4] Remove uses of aops->writepage from gfs2 Matthew Wilcox
@ 2024-08-07 16:24   ` Andreas Gruenbacher
  0 siblings, 0 replies; 7+ messages in thread
From: Andreas Gruenbacher @ 2024-08-07 16:24 UTC (permalink / raw)
  To: Matthew Wilcox; +Cc: gfs2, linux-fsdevel

Hi Willy,

On Wed, Aug 7, 2024 at 2:21 PM Matthew Wilcox <willy@infradead.org> wrote:
> On Fri, Jul 19, 2024 at 06:51:00PM +0100, Matthew Wilcox (Oracle) wrote:
> > Hi Andreas,
> >
> > Here's my latest attempt to switch gfs2 from ->writepage to
> > ->writepages.  I've been a bit more careful this time; I'm not sure
> > whether __gfs2_writepage() could call gfs2_aspace_writepage(), but
> > this order of patches shouldn't break any bisection.
>
> ping

Thank you very much for the patches. I've had a quick look, and it
looks like they should be working now. Testing still pending, though.

Andreas

> > Matthew Wilcox (Oracle) (4):
> >   gfs2: Add gfs2_aspace_writepages()
> >   gfs2: Remove __gfs2_writepage()
> >   gfs2: Remove gfs2_jdata_writepage()
> >   gfs2: Remove gfs2_aspace_writepage()
> >
> >  fs/gfs2/aops.c    | 30 ------------------------------
> >  fs/gfs2/log.c     | 12 ++----------
> >  fs/gfs2/meta_io.c | 24 +++++++++++++++++-------
> >  3 files changed, 19 insertions(+), 47 deletions(-)
> >
> > --
> > 2.43.0
> >
>


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

end of thread, other threads:[~2024-08-07 16:24 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-19 17:51 [PATCH 0/4] Remove uses of aops->writepage from gfs2 Matthew Wilcox (Oracle)
2024-07-19 17:51 ` [PATCH 1/4] gfs2: Add gfs2_aspace_writepages() Matthew Wilcox (Oracle)
2024-07-19 17:51 ` [PATCH 2/4] gfs2: Remove __gfs2_writepage() Matthew Wilcox (Oracle)
2024-07-19 17:51 ` [PATCH 3/4] gfs2: Remove gfs2_jdata_writepage() Matthew Wilcox (Oracle)
2024-07-19 17:51 ` [PATCH 4/4] gfs2: Remove gfs2_aspace_writepage() Matthew Wilcox (Oracle)
2024-08-07 12:21 ` [PATCH 0/4] Remove uses of aops->writepage from gfs2 Matthew Wilcox
2024-08-07 16:24   ` Andreas Gruenbacher

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 read-only IMAP folder(s) and NNTP newsgroup(s).