|
|
Log in / Subscribe / Register

add FALLOC_FL_WRITE_ZEROES support to xfs

From:  Pankaj Raghav <p.raghav-AT-samsung.com>
To:  linux-xfs-AT-vger.kernel.org
Subject:  [PATCH v8 0/2] add FALLOC_FL_WRITE_ZEROES support to xfs
Date:  Thu, 25 Jun 2026 13:45:48 +0200
Message-ID:  <20260625114550.4109104-1-p.raghav@samsung.com>
Cc:  bfoster-AT-redhat.com, lukas-AT-herbolt.com, "Darrick J . Wong" <djwong-AT-kernel.org>, p.raghav-AT-samsung.com, dgc-AT-kernel.org, gost.dev-AT-samsung.com, Zhang Yi <yi.zhang-AT-huaweicloud.com>, pankaj.raghav-AT-linux.dev, andres-AT-anarazel.de, kundan.kumar-AT-samsung.com, hch-AT-lst.de, cem-AT-kernel.org, hch-AT-infradead.org
Archive-link:  Article

The benefits of FALLOC_FL_WRITE_ZEROES was already discussed as a part
of Zhang Yi's initial patches[1]. Postgres developer Andres also
mentioned they would like to use this feature in Postgres [2].

I tested the changes with fsstress and fsx based on the xfstests patch I
sent recently to test this flag[4]. generic/363 helped me debug the
crash I noticed when I did the initial implementation[3].

Dave initially suggested to create a common helper based on
xfs_iomap_convert_unwritten() but as it can be seen in the previous
version, a lot of the code had to be rewritten. The changes had more in
common with xfs_alloc_file_space(). This version reuses
xfs_alloc_file_space() for write zeroes.

Thanks to Christoph for all the review comments and design suggestions
that were made both offline and online for this series.

Stress test generic/363 generic/127 xfs/131 are passing. I have started
the full xfstest suite for this series.

I will be sending a new generic test case for testing boundary block
corner case handling.

Changes since v7:
- Pass offset and len to xfs_alloc_file_space (Based on Sashiko's feedback).
- Add a lot of comments to prove correctness based on Zhang's feedback.
- Add Darrick's comment about xfs_alloc_file_space description.

Changes since v6:
- Pass only offset that needs to be zeroed to alloc_file_space (Christoph).
- Add RVB from Christoph.
- Change the call order. Call xfs_falloc_setsize() and then call
  xfs_alloc_file_space().
- Remove the prep patch to allow xfs_set_filesize to take 64-bit len.

Changes since v5:
- Add a prep patch to allow xfs_set_filesize to take 64-bit len
  (Sashiko)

Changes since v4:
- Introduce an enum for allocation mode in xfs_alloc_file_space (Christoph)
- Use xfs_set_filesize instead of updating the on-disk size in the
  function.

Changes since v3:
- Introduce xfs_bmap_alloc_or_convert_range() in xfs_iomap.c for easy
  review experience (christoph)
- Add extsz hint and rt support in xfs_bmap_alloc_or_convert_range()

Changes since v2:
- Add allow_write_zeroes to xfs_global so that we can enable this
  feature independent of the HW underneath.

Changes since v1 [5.1 5.2]:
- Added a new function xfs_bmap_alloc_or_convert_range() based on Dave's
  feedback.
- Changed the xfs_falloc_write_zeroes to use
  xfs_bmap_alloc_or_convert_range() instead of doing prealloc and
  convert approach.

[1] https://lore.kernel.org/linux-fsdevel/20250619111806.3546...
[2] https://lore.kernel.org/linux-fsdevel/20260217055103.GA61...
[3] https://lore.kernel.org/linux-xfs/6i2jvzn3lyugjlbgmjzpped...
[4] https://lore.kernel.org/linux-xfs/20260312195308.738189-1...
[5.1] https://lore.kernel.org/linux-xfs/20260309180708.427553-2...
[5.2] https://lore.kernel.org/linux-xfs/abC1LvRElctaHPe5@dread/

Pankaj Raghav (2):
  xfs: add an allocation mode to xfs_alloc_file_space()
  xfs: add support for FALLOC_FL_WRITE_ZEROES

 fs/xfs/xfs_bmap_util.c | 42 +++++++++++++++++---
 fs/xfs/xfs_bmap_util.h |  7 +++-
 fs/xfs/xfs_file.c      | 87 ++++++++++++++++++++++++++++++++++++++++--
 3 files changed, 125 insertions(+), 11 deletions(-)


base-commit: 6e24acc45ab58d39a0162b4d5f3fd001d07d868e
-- 
2.51.2




Copyright © 2026, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds