mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: liubaolin <liubaolin12138@163.com>
To: ernest.borowski.git@proton.me,
	Namjae Jeon <linkinjeon@kernel.org>,
	Hyunchul Lee <hyc.lee@gmail.com>
Cc: Christian Brauner <brauner@kernel.org>,
	Christoph Hellwig <hch@lst.de>,
	"Darrick J. Wong" <djwong@kernel.org>,
	ntfs@lists.linux.dev, linux-fsdevel@vger.kernel.org,
	linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org,
	Zhan Xusheng <zhanxusheng1024@gmail.com>,
	stable@vger.kernel.org
Subject: Re: [PATCH v4 00/11] ntfs: delayed allocation accounting and stale data fixes, part 1
Date: Wed, 2 Dec 2026 14:19:00 +0800	[thread overview]
Message-ID: <c8d7c2d8-3128-46de-8f98-0ed6331d0fef@163.com> (raw)
In-Reply-To: <20261201-b4-ntfs-delalloc-fixes-v4-0-e5dd6f77016a@proton.me>



在 2026/12/2 01:42, Ernest Borowski via B4 Relay 写道:
> A write/truncate/punch-hole stress test on a 128 MiB volume showed the
> free space reported by statfs() falling from 79 MB to zero within 80
> seconds, after which writes failed with ENOSPC or came back short, while
> $Bitmap stayed correct.  The delalloc reservations in
> vol->dirty_clusters were not given back on several paths.  The same
> paths also had buffered writes into holes that exposed old disk
> contents.
> 
> The series has four groups:
> 
> Patches 1-2 (iomap) are small prerequisites for patches 8 and 10.  ntfs
> reserves delalloc space in whole clusters, and a cluster can be smaller
> than a folio (1 KiB or 2 KiB clusters with 512-byte blocks).  Patch 1
> passes each run of clean blocks to ->punch() in one call, so that ntfs
> sees a whole clean cluster and can release it.  Patch 2 adds
> iomap_dirty_folio_range(), which patch 10 uses to dirty part of a folio.
> For XFS and ext4 the only effect of patch 1 is fewer ->punch() calls,
> and patch 2 changes nothing for them.
> 
> Patches 3-6 fix reservations that were lost or dropped: on truncate
> (3), when fallocate(), direct I/O or page_mkwrite() fill a hole (4),
> when a cluster allocation fails (5), and when a named stream is removed
> or an inode is evicted (6).
> 
> Patches 7-8 handle a buffered write that fails after ->iomap_begin()
> reserved its clusters, which left delalloc runs that no data covers.
> Patch 7 fixes the runlist split helpers, which turned such a run into
> real clusters when it was punched or collapsed, and so corrupted
> $Bitmap.  Patch 8 turns the clusters the write did not use back into
> holes, so that no such run is left.
> 
> Patches 9-11 fix buffered writes into holes that showed old disk
> contents or lost data written through a shared mapping:
> - patch 9: the zeroing of a new cluster's edges gave up as soon as
>    writeback allocated the cluster;
> - patch 10: a copy that stopped inside a new cluster left the rest of
>    the cluster unzeroed;
> - patch 11: when a write fault or writeback allocated the clusters
>    during the copy, the write zeroed blocks instead of reading them,
>    which overwrote data written through a shared mapping.
> 
> All patches are Cc stable.  Dependencies:
> - patches 1, 2, 3, 4 and 7 apply on their own;
> - 5 needs 4, 6 needs 3, and 8 needs 6;
> - 9 needs 8, 10 needs 9 and 2, and 11 needs 9;
> - 8 also needs 1 to release clusters smaller than a folio.
> 
>    3 --> 6 --> 8 --> 9 --> 10 <-- 2
>                ^     |
>                1     +--> 11
>    4 --> 5
>    7
> 
> The series is based on ntfs-next, which now has Zhan Xusheng's "ntfs:
> trim the sizes after a short write" [1].  Patch 10 uses the helper
> that [1] added, which zeroes from a worker when the writer has a fatal
> signal pending (iomap_zero_range() refuses to run then).  Part 2
> follows with five more patches: st_blocks of delalloc data, and the
> remaining stale data windows of write faults, writeback and direct I/O
> into holes.
> 
> Each bug fixed here has a reproducer that fails before and passes after
> its fix.  The reproducers run in QEMU on a kernel with KASAN, lockdep
> and UBSAN, at 512 B, 1 KiB, 2 KiB, 4 KiB, 16 KiB and 64 KiB clusters,
> with ntfsck -n after every case, on Ubuntu 26.04 and Arch Linux.  On
> ntfs-next 329758f9d73b the nine reproducers of these bugs
> (short_copy_stale, delalloc_accounting, delalloc_alloc_failure,
> delalloc_failed_write, delalloc_zero_race, stale_wb_race,
> delalloc_partial_fail, stale_write_mapping, delalloc_tail_zero_failure)
> pass with this series, except for the st_blocks check of
> delalloc_alloc_failure, which part 2 fixes.  Every test that passed
> before still passes.
> 
>    tests:                    https://github.com/xerrni/linux-ntfs
>    ntfs-next:                https://github.com/xerrni/linux-ntfs/actions/runs/46674620717
>    ntfs-next + this series:  https://github.com/xerrni/linux-ntfs/actions/runs/46674607930
> 
> [1] https://lore.kernel.org/all/20261127031053.3695758-1-zhanxusheng1024@gmail.com/
> 
> ---
> Changes in v4:
> - Patch 10: when zeroing the rest of the cluster fails, also record
>    the error with mapping_set_error(), so that fsync() reports it
>    (Baolin Liu).  New reproducer: delalloc_tail_zero_failure.
> - Patch 10: use ntfs_zero_range_unkillable() from [1] instead of a
>    second copy of it, with the lockdep check of the invalidate lock
>    that the copy had.
> - Rebased onto ntfs-next 329758f9d73b, which adds [1], with no
>    conflicts.
> - Link to v3: https://patch.msgid.link/20261130-b4-ntfs-delalloc-fixes-v3-0-874d34a6f1fe@proton.me
> 
> Changes in v3:
> - Patch 1: split an overlong line by storing the punch start in a local
>    variable (Christoph).
> - Patch 2: iomap_dirty_folio() now calls the same helper as
>    iomap_dirty_folio_range() instead of duplicating its code;
>    iomap_dirty_folio() still passes the mapping argument it receives,
>    since ->dirty_folio can run without the folio lock (Christoph).
> - Rebased onto ntfs-next 0d9dc4ba9089, which is based on v7.4-rc4, with
>    no conflicts.  The new base includes 6fe08320c3 ("iomap: don't punch
>    delalloc under a dirty EOF block"), which touches the same function
>    as patch 1; that commit does not affect ntfs, since ntfs's ->punch()
>    keeps every partly punched cluster.
> - The tests ran on ntfs-next 1975aab5bdb0, which differs from the new
>    base only by f11d0178f3 ("ntfs: avoid lock inversion when stream base
>    is the containing directory").
> - fstests on XFS and ext4 (buffered_iomap) with 1k and 4k blocks give
>    the same results with and without patches 1 and 2: XFS passes 156
>    (1k) and 158 (4k) tests, ext4 passes 97 (1k) and 99 (4k).  The only
>    failure is generic/223 on ext4 with both block sizes, which also
>    fails without the patches.
> - [1] now points to v12 of Zhan Xusheng's short write fix.
> - Link to v2: https://patch.msgid.link/20261124-b4-ntfs-delalloc-fixes-v2-0-f394c800ec03@proton.me
> 
> Changes in v2:
> - New patch 1 (iomap): one ->punch() call per run of clean blocks, so
>    that 1 KiB and 2 KiB clusters of a dirty folio are released after a
>    failed or short write (Hyunchul).
> - New patch 2 (iomap) and patch 10 (was 7): after a short copy, dirty
>    only the rest of the cluster, so the clusters the write did not reach
>    in the same folio are still released.
> - New patch 5, moved here from part 2: keep the reservations when a
>    cluster allocation fails, instead of resetting every file's
>    reservation or leaving a delalloc run with none (Hyunchul's question
>    on v1 patch 1).
> - New patch 11: revalidate the delalloc mapping when a write fault or
>    writeback allocated its clusters during the copy, instead of zeroing
>    data written through a shared mapping (Hyunchul).
> - Patches 3-4 and 6-9 are v1 patches 1-6, unchanged.
> - Cc the iomap maintainers and lists for patches 1 and 2.
> - Link to v1: https://patch.msgid.link/20261122-b4-ntfs-delalloc-fixes-v1-0-0726f0dce403@proton.me
> 
> ---
> Ernest Borowski (11):
>        iomap: punch out a run of clean blocks in one call
>        iomap: add a helper to mark a range of a folio dirty
>        ntfs: release delalloc reservations cut off by truncate
>        ntfs: do not consume delalloc reservations when filling holes
>        ntfs: keep delalloc reservations when a cluster allocation fails
>        ntfs: release the delalloc reservations of an evicted inode
>        ntfs: do not shift the cluster number of a delalloc run on split
>        ntfs: punch out the delalloc reservation of a failed buffered write
>        ntfs: zero new delalloc clusters even when writeback allocates them
>        ntfs: zero the rest of a new cluster after a short buffered write
>        ntfs: revalidate a buffered write's mapping after its clusters were allocated
> 
>   fs/iomap/buffered-io.c |  45 +++++--
>   fs/ntfs/attrib.c       | 130 +++++++++++++++++++-
>   fs/ntfs/attrib.h       |   2 +
>   fs/ntfs/file.c         |   5 +-
>   fs/ntfs/inode.c        |  13 +-
>   fs/ntfs/inode.h        |   3 +
>   fs/ntfs/iomap.c        | 321 +++++++++++++++++++++++++++++++++++++++----------
>   fs/ntfs/iomap.h        |   1 +
>   fs/ntfs/lcnalloc.c     |   1 -
>   fs/ntfs/runlist.c      |  13 +-
>   include/linux/iomap.h  |   1 +
>   11 files changed, 452 insertions(+), 83 deletions(-)
> ---
> base-commit: 329758f9d73b0ec537302c23c0507bbb2d495263
> change-id: 20261122-b4-ntfs-delalloc-fixes-5ba9d4e97353
> 
> Best regards,
> --
> Ernest Borowski <ernest.borowski.git@proton.me>

The series looks good to me.

Reviewed-by: Baolin Liu <liubaolin@kylinos.cn>


      parent reply	other threads:[~2026-12-02  6:19 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-01 17:42 Ernest Borowski via B4 Relay
2026-12-01 17:42 ` [PATCH v4 01/11] iomap: punch out a run of clean blocks in one call Ernest Borowski via B4 Relay
2026-12-01 17:42 ` [PATCH v4 02/11] iomap: add a helper to mark a range of a folio dirty Ernest Borowski via B4 Relay
2026-12-01 17:42 ` [PATCH v4 03/11] ntfs: release delalloc reservations cut off by truncate Ernest Borowski via B4 Relay
2026-12-01 17:42 ` [PATCH v4 04/11] ntfs: do not consume delalloc reservations when filling holes Ernest Borowski via B4 Relay
2026-12-01 17:42 ` [PATCH v4 05/11] ntfs: keep delalloc reservations when a cluster allocation fails Ernest Borowski via B4 Relay
2026-12-01 17:42 ` [PATCH v4 06/11] ntfs: release the delalloc reservations of an evicted inode Ernest Borowski via B4 Relay
2026-12-01 17:42 ` [PATCH v4 07/11] ntfs: do not shift the cluster number of a delalloc run on split Ernest Borowski via B4 Relay
2026-12-01 17:42 ` [PATCH v4 08/11] ntfs: punch out the delalloc reservation of a failed buffered write Ernest Borowski via B4 Relay
2026-12-01 17:42 ` [PATCH v4 09/11] ntfs: zero new delalloc clusters even when writeback allocates them Ernest Borowski via B4 Relay
2026-12-01 17:42 ` [PATCH v4 10/11] ntfs: zero the rest of a new cluster after a short buffered write Ernest Borowski via B4 Relay
2026-12-01 17:42 ` [PATCH v4 11/11] ntfs: revalidate a buffered write's mapping after its clusters were allocated Ernest Borowski via B4 Relay
2026-12-02  6:19 ` liubaolin [this message]

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=c8d7c2d8-3128-46de-8f98-0ed6331d0fef@163.com \
    --to=liubaolin12138@163.com \
    --cc=brauner@kernel.org \
    --cc=djwong@kernel.org \
    --cc=ernest.borowski.git@proton.me \
    --cc=hch@lst.de \
    --cc=hyc.lee@gmail.com \
    --cc=linkinjeon@kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    --cc=ntfs@lists.linux.dev \
    --cc=stable@vger.kernel.org \
    --cc=zhanxusheng1024@gmail.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®