All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <djwong@kernel.org>
To: Andreas Gruenbacher <agruenba@redhat.com>
Cc: Christoph Hellwig <hch@infradead.org>,
	linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH] iomap: Move page_done callback under the folio lock
Date: Tue, 13 Dec 2022 12:03:41 -0800	[thread overview]
Message-ID: <Y5janUs2/29XZRbc@magnolia> (raw)
In-Reply-To: <20221213194833.1636649-1-agruenba@redhat.com>

On Tue, Dec 13, 2022 at 08:48:33PM +0100, Andreas Gruenbacher wrote:
> Hi Darrick,
> 
> I'd like to get the following iomap change into this merge window.  This
> only affects gfs2, so I can push it as part of the gfs2 updates if you
> don't mind, provided that I'll get your Reviewed-by confirmation.
> Otherwise, if you'd prefer to pass this through the xfs tree, could you
> please take it?

I don't mind you pushing changes to ->page_done through the gfs2 tree,
but don't you need to move the other callsite at the bottom of
iomap_write_begin?

--D

> Thanks,
> Andreas
> 
> --
> 
> Move the ->page_done() call in iomap_write_end() under the folio lock.
> This closes a race between journaled data writes and the shrinker in
> gfs2.  What's happening is that gfs2_iomap_page_done() is called after
> the page has been unlocked, so try_to_free_buffers() can come in and
> free the buffers while gfs2_iomap_page_done() is trying to add them to
> the current transaction.  The folio lock prevents that from happening.
> 
> The only user of ->page_done() is gfs2, so other filesystems are not
> affected.
> 
> Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
> ---
>  fs/iomap/buffered-io.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c
> index 91ee0b308e13..476c9ed1b333 100644
> --- a/fs/iomap/buffered-io.c
> +++ b/fs/iomap/buffered-io.c
> @@ -714,12 +714,12 @@ static size_t iomap_write_end(struct iomap_iter *iter, loff_t pos, size_t len,
>  		i_size_write(iter->inode, pos + ret);
>  		iter->iomap.flags |= IOMAP_F_SIZE_CHANGED;
>  	}
> +	if (page_ops && page_ops->page_done)
> +		page_ops->page_done(iter->inode, pos, ret, &folio->page);
>  	folio_unlock(folio);
>  
>  	if (old_size < pos)
>  		pagecache_isize_extended(iter->inode, old_size, pos);
> -	if (page_ops && page_ops->page_done)
> -		page_ops->page_done(iter->inode, pos, ret, &folio->page);
>  	folio_put(folio);
>  
>  	if (ret < len)
> -- 
> 2.38.1
> 

  reply	other threads:[~2022-12-13 20:03 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-13 19:48 [PATCH] iomap: Move page_done callback under the folio lock Andreas Gruenbacher
2022-12-13 20:03 ` Darrick J. Wong [this message]
2022-12-13 20:15   ` Andreas Gruenbacher
2022-12-14  7:39   ` Christoph Hellwig
2022-12-14 10:23     ` Andreas Gruenbacher
2022-12-14 10:24     ` [PATCH v2] " Andreas Gruenbacher
2022-12-15 20:13       ` Andreas Gruenbacher
2022-12-16  8:22         ` Christoph Hellwig

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=Y5janUs2/29XZRbc@magnolia \
    --to=djwong@kernel.org \
    --cc=agruenba@redhat.com \
    --cc=hch@infradead.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-xfs@vger.kernel.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.