From: "Darrick J. Wong" <djwong@kernel.org>
To: Christoph Hellwig <hch@lst.de>
Cc: Carlos Maiolino <cem@kernel.org>,
Christian Brauner <brauner@kernel.org>,
linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH 06/10] xfs: IOMAP_ZERO and IOMAP_UNSHARE already hold invalidate_lock
Date: Tue, 8 Oct 2024 10:39:43 -0700 [thread overview]
Message-ID: <20241008173943.GS21853@frogsfrogsfrogs> (raw)
In-Reply-To: <20241008085939.266014-7-hch@lst.de>
On Tue, Oct 08, 2024 at 10:59:17AM +0200, Christoph Hellwig wrote:
> All XFS callers of iomap_zero_range and iomap_file_unshare already hold
> invalidate_lock, so we can't take it again in
> iomap_file_buffered_write_punch_delalloc.
>
> Use the passed in flags argument to detect if we're called from a zero
> or unshare operation and don't take the lock again in this case.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
Thanks for fixing the bug I reported,
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
--D
> ---
> fs/xfs/xfs_iomap.c | 16 ++++++++++++----
> 1 file changed, 12 insertions(+), 4 deletions(-)
>
> diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c
> index 4fa4d66dc37761..17170d9b9ff78a 100644
> --- a/fs/xfs/xfs_iomap.c
> +++ b/fs/xfs/xfs_iomap.c
> @@ -1239,10 +1239,18 @@ xfs_buffered_write_iomap_end(
> if (start_byte >= end_byte)
> return 0;
>
> - filemap_invalidate_lock(inode->i_mapping);
> - iomap_write_delalloc_release(inode, start_byte, end_byte, flags, iomap,
> - xfs_buffered_write_delalloc_punch);
> - filemap_invalidate_unlock(inode->i_mapping);
> + /* For zeroing operations the callers already hold invalidate_lock. */
> + if (flags & (IOMAP_UNSHARE | IOMAP_ZERO)) {
> + rwsem_assert_held_write(&inode->i_mapping->invalidate_lock);
> + iomap_write_delalloc_release(inode, start_byte, end_byte, flags,
> + iomap, xfs_buffered_write_delalloc_punch);
> + } else {
> + filemap_invalidate_lock(inode->i_mapping);
> + iomap_write_delalloc_release(inode, start_byte, end_byte, flags,
> + iomap, xfs_buffered_write_delalloc_punch);
> + filemap_invalidate_unlock(inode->i_mapping);
> + }
> +
> return 0;
> }
>
> --
> 2.45.2
>
>
next prev parent reply other threads:[~2024-10-08 17:39 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-08 8:59 fix stale delalloc punching for COW I/O v5 Christoph Hellwig
2024-10-08 8:59 ` [PATCH 01/10] iomap: factor out a iomap_last_written_block helper Christoph Hellwig
2024-10-08 8:59 ` [PATCH 02/10] iomap: remove iomap_file_buffered_write_punch_delalloc Christoph Hellwig
2024-10-08 8:59 ` [PATCH 03/10] iomap: move locking out of iomap_write_delalloc_release Christoph Hellwig
2024-10-08 8:59 ` [PATCH 04/10] xfs: factor out a xfs_file_write_zero_eof helper Christoph Hellwig
2024-10-08 8:59 ` [PATCH 05/10] xfs: take XFS_MMAPLOCK_EXCL xfs_file_write_zero_eof Christoph Hellwig
2024-10-08 8:59 ` [PATCH 06/10] xfs: IOMAP_ZERO and IOMAP_UNSHARE already hold invalidate_lock Christoph Hellwig
2024-10-08 17:39 ` Darrick J. Wong [this message]
2024-10-08 8:59 ` [PATCH 07/10] xfs: support the COW fork in xfs_bmap_punch_delalloc_range Christoph Hellwig
2024-10-08 8:59 ` [PATCH 08/10] xfs: share more code in xfs_buffered_write_iomap_begin Christoph Hellwig
2024-10-08 8:59 ` [PATCH 09/10] xfs: set IOMAP_F_SHARED for all COW fork allocations Christoph Hellwig
2024-10-08 8:59 ` [PATCH 10/10] xfs: punch delalloc extents from the COW fork for COW writes Christoph Hellwig
2024-10-11 10:59 ` fix stale delalloc punching for COW I/O v5 Carlos Maiolino
2024-10-15 11:09 ` Carlos Maiolino
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=20241008173943.GS21853@frogsfrogsfrogs \
--to=djwong@kernel.org \
--cc=brauner@kernel.org \
--cc=cem@kernel.org \
--cc=hch@lst.de \
--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.