From: Ernest Borowski <ernest.borowski.git@proton.me>
To: Hyunchul Lee <hyc.lee@gmail.com>
Cc: ernest.borowski.git@proton.me,
Namjae Jeon <linkinjeon@kernel.org>,
Baolin Liu <liubaolin12138@163.com>,
ntfs@lists.linux.dev, linux-kernel@vger.kernel.org,
Zhan Xusheng <zhanxusheng1024@gmail.com>,
stable@vger.kernel.org
Subject: Re: [PATCH 5/7] ntfs: punch out the delalloc reservation of a failed buffered write
Date: Tue, 24 Nov 2026 12:40:14 +0000 [thread overview]
Message-ID: <179552401127.2437814.5296523363339090299.b4-reply@b4> (raw)
In-Reply-To: <awPTjheQrp6sxB5W@hyunchul-PC02>
On Mon, Nov 23, 2026 at 02:47:58PM +0900, Hyunchul Lee wrote:
> Could this leave clean dealloc clusters reserved?
>
> For example, with 1 KiB clusters and 512-byte blocks,
> iomap_write_dealloc_ifs_punch() calls this callback seperately for each
> clean block in a dirty folio. For a cluster covering [1024, 2048),
> the callback receives [1024, 1536) and [1536, 2048) separately. Rounding
> each range produces an empty punch range, so neither call removes
> the reservation, even if the entire cluster is clean.
Yes, thanks. The test only used 512-byte, 4 KiB, 16 KiB and 64 KiB
clusters (either one block or at least 4 KiB), so it missed this.
Triggering it requires a folio with clean, uptodate blocks behind dirty
ones after a short write. That takes a hole below the initialized size
already read into the page cache (a write past the initialized size
drops the cache first) and a copy ending on a cluster boundary. If the
copy ends inside a cluster, patch 7 calls folio_mark_dirty() to cover
the rest of that cluster, which dirties every block, so nothing is
punched; that makes writeback write the whole page, and I will look at
narrowing it in v2.
For example, with 1 KiB clusters on a file initialized to its end:
pread() 32 KiB at 0, then pwrite() 32 KiB at 0 from a source that
faults after 1 KiB. With v1 the three clean clusters of the first folio
keep their reservation, and writeback allocates them but writes only the
dirty blocks, so [1024, 4096) reads back the old disk contents after a
remount. A failed write at a lower offset than a dirty cluster in the
same folio keeps the reservation until the inode is evicted.
v1 v2
short copy, 1 KiB clusters 4 clusters, 3072 B 1 cluster, 0 B
short copy, 2 KiB clusters 2 clusters, 2048 B 1 cluster, 0 B
failed write, 1 KiB clusters 4 clusters 1 cluster
failed write, 2 KiB clusters 2 clusters 1 cluster
(clusters allocated or reserved, of which 1 is the written cluster;
bytes of old data read back after a remount. Same results on Ubuntu
26.04 and Arch Linux.)
v2 adds an iomap patch before this one that passes each run of clean
blocks to ->punch() in one call. A cluster no larger than a folio then
reaches ->punch() whole when all its blocks are clean. A larger cluster
overlapping a dirty folio has dirty data and must stay. XFS and ext4
punch whatever range they get, so for them it only means fewer calls.
The iomap patch alone fixes both the short copy and the failed write.
CI runs:
ntfs-next + v1: https://github.com/xerrni/linux-ntfs/actions/runs/45386115143
ntfs-next + v1 + v2 fixes: https://github.com/xerrni/linux-ntfs/actions/runs/45386121459
The cases are in tests/delalloc_partial_fail.sh in
https://github.com/xerrni/linux-ntfs.
Thanks,
Ernest
next prev parent reply other threads:[~2026-11-24 12:40 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-22 18:19 [PATCH 0/7] ntfs: delayed allocation accounting and stale data fixes, part 1 Ernest Borowski via B4 Relay
2026-11-22 18:19 ` [PATCH 1/7] ntfs: release delalloc reservations cut off by truncate Ernest Borowski via B4 Relay
2026-11-23 2:16 ` Hyunchul Lee
2026-11-24 12:38 ` Ernest Borowski
2026-11-22 18:19 ` [PATCH 2/7] ntfs: do not consume delalloc reservations when filling holes Ernest Borowski via B4 Relay
2026-11-22 18:19 ` [PATCH 3/7] ntfs: release the delalloc reservations of an evicted inode Ernest Borowski via B4 Relay
2026-11-22 18:19 ` [PATCH 4/7] ntfs: do not shift the cluster number of a delalloc run on split Ernest Borowski via B4 Relay
2026-11-22 18:19 ` [PATCH 5/7] ntfs: punch out the delalloc reservation of a failed buffered write Ernest Borowski via B4 Relay
2026-11-23 5:47 ` Hyunchul Lee
2026-11-24 12:40 ` Ernest Borowski [this message]
2026-11-22 18:19 ` [PATCH 6/7] ntfs: zero new delalloc clusters even when writeback allocates them Ernest Borowski via B4 Relay
2026-11-23 5:50 ` Hyunchul Lee
2026-11-24 12:41 ` Ernest Borowski
2026-11-22 18:19 ` [PATCH 7/7] ntfs: zero the rest of a new cluster after a short buffered write Ernest Borowski via B4 Relay
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=179552401127.2437814.5296523363339090299.b4-reply@b4 \
--to=ernest.borowski.git@proton.me \
--cc=hyc.lee@gmail.com \
--cc=linkinjeon@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=liubaolin12138@163.com \
--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®