All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <djwong@kernel.org>
To: Lukas Herbolt <lukas@herbolt.com>
Cc: "Pankaj Raghav (Samsung)" <pankaj.raghav@linux.dev>,
	linux-xfs@vger.kernel.org, cem@kernel.org, hch@infradead.org,
	p.raghav@samsung.com
Subject: Re: [PATCH v11 2/2] xfs: add FALLOC_FL_WRITE_ZEROES to XFS code base
Date: Tue, 10 Mar 2026 08:02:54 -0700	[thread overview]
Message-ID: <20260310150254.GP1105363@frogsfrogsfrogs> (raw)
In-Reply-To: <db573faa5330e7cc8ad31ca86333227f@herbolt.com>

On Tue, Mar 10, 2026 at 12:22:54PM +0100, Lukas Herbolt wrote:
> On 2026-03-10 11:10, Pankaj Raghav (Samsung) wrote:
> > > 	if (xfs_is_always_cow_inode(ip) ||
> > 
> > Why should we check for this here but we don't do this check in
> > xfs_falloc_zero_range()?
> > 
> > There is a comment in xfs_falloc_allocate_range():
> > 
> > 	/*
> > 	 * If always_cow mode we can't use preallocations and thus should not
> > 	 * create them.
> > 	 */
> > 	if (xfs_is_always_cow_inode(XFS_I(inode)))
> > 		return -EOPNOTSUPP;
> > 
> > Don't we also use preallocations in xfs_falloc_zero_range()?
> > 
> 
> For the xfs_falloc_zero_range we return 0 on COW from xfs_alloc_file_space
> and that
> results in creating a hole in the file instead of having preallocated
> extents as shown
> bellow.
> 
> But for the xfs_falloc_write_zero_range(), we want fail as soon as possible
> as possible.
> 
> Feel free to correct me if I am wrong.

You're correct, write-zero-range wants to actually write zeroes to
storage to avoid remapping overhead during a write.  However, zoned /
alwayscow files always remap so this mode is not supported for them.

--D

> int
> xfs_alloc_file_space(
>         struct xfs_inode        *ip,
>         xfs_off_t               offset,
>         xfs_off_t               len)
> {
>         xfs_mount_t             *mp = ip->i_mount;
>         xfs_off_t               count;
>         xfs_filblks_t           allocatesize_fsb;
>         xfs_extlen_t            extsz, temp;
>         xfs_fileoff_t           startoffset_fsb;
>         xfs_fileoff_t           endoffset_fsb;
>         int                     rt;
>         xfs_trans_t             *tp;
>         xfs_bmbt_irec_t         imaps[1], *imapp;
>         int                     error;
> 
>         if (xfs_is_always_cow_inode(ip))
>                 return 0;
> 
> 
> root@build-00:/mnt# dd if=/dev/urandom of=/mnt/test.bin bs=10M oflag=direct
> count=1
> 1+0 records in
> 1+0 records out
> 10485760 bytes (10 MB, 10 MiB) copied, 0.167452 s, 62.6 MB/s
> root@build-00:/mnt# xfs_bmap -vp  test.bin
> test.bin:
>  EXT: FILE-OFFSET      BLOCK-RANGE      AG AG-OFFSET        TOTAL FLAGS
>    0: [0..20479]:      192..20671        0 (192..20671)     20480 000000
> root@build-00:/mnt# strace -e fallocate fallocate -zl 2M  test.bin
> fallocate(3, FALLOC_FL_ZERO_RANGE, 0, 2097152) = 0
> +++ exited with 0 +++
> root@build-00:/mnt# xfs_bmap -vp  test.bin
> test.bin:
>  EXT: FILE-OFFSET      BLOCK-RANGE      AG AG-OFFSET        TOTAL FLAGS
>    0: [0..4095]:       hole                                  4096
>    1: [4096..20479]:   4288..20671       0 (4288..20671)    16384 000000
> root@build-00:/mnt# dd if=/dev/urandom of=/mnt/test.bin bs=1M oflag=direct
> count=1 conv=notrunc
> 1+0 records in
> 1+0 records out
> 1048576 bytes (1.0 MB, 1.0 MiB) copied, 0.0172151 s, 60.9 MB/s
> root@build-00:/mnt# xfs_bmap -vp  test.bin
> test.bin:
>  EXT: FILE-OFFSET      BLOCK-RANGE      AG AG-OFFSET        TOTAL FLAGS
>    0: [0..2047]:       192..2239         0 (192..2239)       2048 000000
>    1: [2048..4095]:    hole                                  2048
>    2: [4096..20479]:   4288..20671       0 (4288..20671)    16384 000000
> root@build-00:/mnt# cat /sys/fs/xfs/debug/
> always_cow          bload_node_slack    larp                mount_delay
> bload_leaf_slack    bug_on_assert       log_recovery_delay  pwork_threads
> root@build-00:/mnt# cat /sys/fs/xfs/debug/always_cow
> 1
> 
> 
> -- 
> -lhe
> 

  reply	other threads:[~2026-03-10 15:02 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-09 18:12 [PATCH v11 2/2] xfs: add FALLOC_FL_WRITE_ZEROES to XFS code base Lukas Herbolt
2026-03-10  0:44 ` Darrick J. Wong
2026-03-10 10:10   ` Pankaj Raghav (Samsung)
2026-03-10 11:22     ` Lukas Herbolt
2026-03-10 15:02       ` Darrick J. Wong [this message]
2026-03-10 10:20   ` Lukas Herbolt
2026-03-10 14:57     ` Darrick J. Wong
2026-03-11  0:12 ` Dave Chinner
2026-03-12 21:36   ` Pankaj Raghav (Samsung)
2026-03-15 23:49     ` Dave Chinner
2026-03-16  7:23       ` Pankaj Raghav
2026-03-16  5:03   ` Lukas Herbolt
2026-03-17 12:20     ` Pankaj Raghav (Samsung)

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=20260310150254.GP1105363@frogsfrogsfrogs \
    --to=djwong@kernel.org \
    --cc=cem@kernel.org \
    --cc=hch@infradead.org \
    --cc=linux-xfs@vger.kernel.org \
    --cc=lukas@herbolt.com \
    --cc=p.raghav@samsung.com \
    --cc=pankaj.raghav@linux.dev \
    /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.