All of lore.kernel.org
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@infradead.org>
To: Su Yue <glass.su@suse.com>
Cc: gfs2@lists.linux.dev, l@damenly.org, agruenba@redhat.com
Subject: Re: [PATCH 2/2] gfs2: do not call gfs2_jdata_writepages for jdata
Date: Fri, 6 Jun 2025 13:27:40 +0100	[thread overview]
Message-ID: <aELevNcGGuS5lSSI@casper.infradead.org> (raw)
In-Reply-To: <20250606094756.95958-3-glass.su@suse.com>

On Fri, Jun 06, 2025 at 05:47:56PM +0800, Su Yue wrote:
> +++ b/fs/gfs2/aops.c
> @@ -138,6 +138,46 @@ static int __gfs2_jdata_write_folio(struct folio *folio,
>  	return gfs2_write_jdata_full_folio(folio, wbc);
>  }
>  
> +/**
> + * gfs2_write_jdata_folio - Write folio
> + * @folio: folio to write
> + * @wbc: The writeback control
> + *
> + * Returns: errno
> + *
> + */
> +
> +static int gfs2_write_jdata_folio(struct folio *folio, struct writeback_control *wbc)
> +{
> +	struct inode *inode = folio->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;
> +}
> +
> +int gfs2_write_jdata_folios(struct address_space *mapping, struct writeback_control *wbc)
> +{
> +	struct folio *folio = NULL;
> +	int error;
> +
> +	while ((folio = writeback_iter(mapping, wbc, folio, &error)))
> +		error = gfs2_write_jdata_folio(folio, wbc);
> +
> +	return error;
> +}

The great thing about using an iterator pattern rather than a callback
pattern is that we don't need this stupid extra function.  So you can
drop patch 1 and just do this:

+	struct inode *inode = 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))
+		return -Ewhatever;
+
+	while ((folio = writeback_iter(mapping, wbc, folio, &error))) {
+		if (folio_test_checked(folio) || current->journal_info)
+			goto ignore;
+		error = __gfs2_jdata_write_folio(folio, wbc);
+		continue;
+
+ignore:
+		folio_redirty_for_writepage(wbc, folio);
+		folio_unlock(folio);
+	}
+
+	return error;

  reply	other threads:[~2025-06-06 12:27 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-06  9:47 [PATCH 0/2] GFS2: Fix wrong call of new trans for jdata Su Yue
2025-06-06  9:47 ` [PATCH 1/2] gfs2: rename gfs2_write_jdata_folio to gfs2_write_jdata_full_folio Su Yue
2025-06-06  9:47 ` [PATCH 2/2] gfs2: do not call gfs2_jdata_writepages for jdata Su Yue
2025-06-06 12:27   ` Matthew Wilcox [this message]
2025-06-09  0:18     ` Su Yue
2025-06-09  0:20 ` [PATCH 0/2] GFS2: Fix wrong call of new trans " Su Yue

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aELevNcGGuS5lSSI@casper.infradead.org \
    --to=willy@infradead.org \
    --cc=agruenba@redhat.com \
    --cc=gfs2@lists.linux.dev \
    --cc=glass.su@suse.com \
    --cc=l@damenly.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.