All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <djwong@kernel.org>
To: Christoph Hellwig <hch@lst.de>
Cc: Christian Brauner <brauner@kernel.org>,
	Alexander Viro <viro@zeniv.linux.org.uk>,
	Chandan Babu R <chandan.babu@oracle.com>,
	Brian Foster <bfoster@redhat.com>, Jens Axboe <axboe@kernel.dk>,
	Jan Kara <jack@suse.cz>, Theodore Ts'o <tytso@mit.edu>,
	linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	linux-xfs@vger.kernel.org, linux-ext4@vger.kernel.org
Subject: Re: [PATCH 4/6] xfs: call xfs_flush_unmap_range from xfs_free_file_space
Date: Tue, 27 Aug 2024 09:03:23 -0700	[thread overview]
Message-ID: <20240827160323.GS865349@frogsfrogsfrogs> (raw)
In-Reply-To: <20240827065123.1762168-5-hch@lst.de>

On Tue, Aug 27, 2024 at 08:50:48AM +0200, Christoph Hellwig wrote:
> Call xfs_flush_unmap_range from xfs_free_file_space so that
> xfs_file_fallocate doesn't have to predict which mode will call it.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>

Hmm.  I /think/ it's ok to shift the xfs_flush_unmap_range after the
file_modified and some of the other EINVAL bailouts that can happen
before xfs_free_file_space gets called.  Effectively that means that we
can fail faster now? :)

Later on this means that the cow-around code that the rtreflink patchset
introduces will also get flushed to disk before we start
collapsing/zeroing/punching.  AFAICT that should be fine.

Reviewed-by: Darrick J. Wong <djwong@kernel.org>

--D

> ---
>  fs/xfs/xfs_bmap_util.c |  8 ++++++++
>  fs/xfs/xfs_file.c      | 21 ---------------------
>  2 files changed, 8 insertions(+), 21 deletions(-)
> 
> diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c
> index fe2e2c93097550..187a0dbda24fc4 100644
> --- a/fs/xfs/xfs_bmap_util.c
> +++ b/fs/xfs/xfs_bmap_util.c
> @@ -848,6 +848,14 @@ xfs_free_file_space(
>  	if (len <= 0)	/* if nothing being freed */
>  		return 0;
>  
> +	/*
> +	 * Now AIO and DIO has drained we flush and (if necessary) invalidate
> +	 * the cached range over the first operation we are about to run.
> +	 */
> +	error = xfs_flush_unmap_range(ip, offset, len);
> +	if (error)
> +		return error;
> +
>  	startoffset_fsb = XFS_B_TO_FSB(mp, offset);
>  	endoffset_fsb = XFS_B_TO_FSBT(mp, offset + len);
>  
> diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c
> index 4cdc54dc96862e..5b9e49da06013c 100644
> --- a/fs/xfs/xfs_file.c
> +++ b/fs/xfs/xfs_file.c
> @@ -890,27 +890,6 @@ xfs_file_fallocate(
>  	 */
>  	inode_dio_wait(inode);
>  
> -	/*
> -	 * Now AIO and DIO has drained we flush and (if necessary) invalidate
> -	 * the cached range over the first operation we are about to run.
> -	 *
> -	 * We care about zero and collapse here because they both run a hole
> -	 * punch over the range first. Because that can zero data, and the range
> -	 * of invalidation for the shift operations is much larger, we still do
> -	 * the required flush for collapse in xfs_prepare_shift().
> -	 *
> -	 * Insert has the same range requirements as collapse, and we extend the
> -	 * file first which can zero data. Hence insert has the same
> -	 * flush/invalidate requirements as collapse and so they are both
> -	 * handled at the right time by xfs_prepare_shift().
> -	 */
> -	if (mode & (FALLOC_FL_PUNCH_HOLE | FALLOC_FL_ZERO_RANGE |
> -		    FALLOC_FL_COLLAPSE_RANGE)) {
> -		error = xfs_flush_unmap_range(ip, offset, len);
> -		if (error)
> -			goto out_unlock;
> -	}
> -
>  	error = file_modified(file);
>  	if (error)
>  		goto out_unlock;
> -- 
> 2.43.0
> 
> 

  reply	other threads:[~2024-08-27 16:03 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-27  6:50 sort out the fallocate mode mess v2 Christoph Hellwig
2024-08-27  6:50 ` [PATCH 1/6] block: remove checks for FALLOC_FL_NO_HIDE_STALE Christoph Hellwig
2024-08-27 14:55   ` Darrick J. Wong
2024-08-28 14:58   ` Christian Brauner
2024-08-28 15:31   ` Jan Kara
2024-08-27  6:50 ` [PATCH 2/6] ext4: remove tracing " Christoph Hellwig
2024-08-27 14:56   ` Darrick J. Wong
2024-08-28  4:04     ` Christoph Hellwig
2024-08-28 15:31   ` Jan Kara
2024-08-27  6:50 ` [PATCH 3/6] fs: sort out the fallocate mode vs flag mess Christoph Hellwig
2024-08-27 14:55   ` Darrick J. Wong
2024-08-28  4:05     ` Christoph Hellwig
2024-08-28 15:34   ` Jan Kara
2024-08-27  6:50 ` [PATCH 4/6] xfs: call xfs_flush_unmap_range from xfs_free_file_space Christoph Hellwig
2024-08-27 16:03   ` Darrick J. Wong [this message]
2024-08-28  4:06     ` Christoph Hellwig
2024-08-29  3:03   ` Dave Chinner
2024-08-29  3:54     ` Christoph Hellwig
2024-08-27  6:50 ` [PATCH 5/6] xfs: move the xfs_is_always_cow_inode check into xfs_alloc_file_space Christoph Hellwig
2024-08-27 16:03   ` Darrick J. Wong
2024-08-27  6:50 ` [PATCH 6/6] xfs: refactor xfs_file_fallocate Christoph Hellwig
2024-08-27 16:07   ` Darrick J. Wong
2024-08-28  4:07     ` Christoph Hellwig
2024-08-29  3:11   ` Dave Chinner
2024-08-29  3:56     ` Christoph Hellwig
  -- strict thread matches above, loose matches on Subject: below --
2024-08-21  6:30 sort out the fallocate mode mess Christoph Hellwig
2024-08-21  6:30 ` [PATCH 4/6] xfs: call xfs_flush_unmap_range from xfs_free_file_space 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=20240827160323.GS865349@frogsfrogsfrogs \
    --to=djwong@kernel.org \
    --cc=axboe@kernel.dk \
    --cc=bfoster@redhat.com \
    --cc=brauner@kernel.org \
    --cc=chandan.babu@oracle.com \
    --cc=hch@lst.de \
    --cc=jack@suse.cz \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    --cc=tytso@mit.edu \
    --cc=viro@zeniv.linux.org.uk \
    /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.