From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=117.135.210.2 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796192387; b=vKKBzjyAb8jQBMGS8sWZmD6D2N+ACdUoy8lE1FtdoCVRJR79zW86kFzo5kPWtijRd5TR QNKW8ZG9kTumdEyS0bkP/wIpVA8SwpVb241JgedpxnLClQ8vxR509DyVwKGEDAg8c0wu8 lzjVCYWJzyQ9GcYItL9LspQzR8C5wR1D57QxOI2NFLid9gRw7/mFdgXiJ2DWi+Q7xWeGK yYnwFtLiDKSLW/AMuQSsaaYcAem2JP40Eg0V5JSemgj4kBmLODGf6U48q1K9IO2IpJaJb myiHHmKpR1pxQPJv5o6MgQXXjAKwNq2/G95JQHGLO569utXGeBTQyohpQqkxsd5Ilog== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796192387; h=DMARC-Filter:DKIM-Signature:Received:Message-ID:Date:MIME-Version: User-Agent:Subject:To:Cc:References:Content-Language:From:In-Reply-To: Content-Type:Content-Transfer-Encoding:X-CM-TRANSID: X-Coremail-Antispam:X-Originating-IP:X-CM-SenderInfo; bh=zxauBBAshA9oDMdAc2uuvXc8ulnxVOJQ7qgXPkQ/D4k=; b=U5klDv4VMKQzwzn3EC8uxgP7Yq6CESlJgtXlJd+u5HF925QVXAEr9kNqEiELVfJY3xOz Wjsj2MItAsFjhEX5JYSn6Lyat18BQ5t6qGqS5siNppYJxUhyu1uvMAfZCAPO/2FB6iUiQ pBEAbqc02XNSAK9ivM35IVIt2wgjwDINRP3NbOtGWzWKXCA+6YH1bT+9cv4dt+fDaTPxc k/4umMy7Dlv112sY3b8LX8ndp6LIRGL9J4zspRwmOiHDDI7OBnNZaGoPsg6w3HiX3zc0Z CRlJ47V3g/u2WXAzGUtE05JAgBR5rWgE7hubEf8sXiz5Z4GtU5SMLZy4ZiVesOZgGTA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=163.com; spf=pass smtp.mailfrom=163.com; dkim=pass header.d=163.com header.i=@163.com header.a=rsa-sha256 header.s=s110527 header.b=SPf82+05; arc=none smtp.remote-ip=117.135.210.2 Received: from m16.mail.163.com (m16.mail.163.com [117.135.210.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 814E3606A31A; Wed, 2 Dec 2026 06:19:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 814E3606A31A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=163.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.a=rsa-sha256 header.s=s110527 header.b=SPf82+05 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=Message-ID:Date:MIME-Version:Subject:To:From: Content-Type; bh=zxauBBAshA9oDMdAc2uuvXc8ulnxVOJQ7qgXPkQ/D4k=; b=SPf82+05joGtDBcylaKJ1zCPs0EV3aqx92Dy6hn7PfoWtndKMgN/Lz3fxMqePE 9akM22nc2QbckYOUw7M8Zk2+I6OHAtrhKkC/unie6fT14CPyZlAKTTQHox05gAAu Yf6Cx1Aawr/C1YhhJ7eac7Rhj5/qQ3C/zjyU1ZSa1YqOM= Received: from [IPV6:2409:8900:1eca:984c:5a33:8f8e:f516:436c] (unknown []) by gzga-smtp-mtada-g0-3 (Coremail) with SMTP id _____wD3v0RUuA9rUUPqLw--.19757S2; Wed, 02 Dec 2026 14:19:02 +0800 (CST) Message-ID: Date: Wed, 2 Dec 2026 14:19:00 +0800 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v4 00/11] ntfs: delayed allocation accounting and stale data fixes, part 1 To: ernest.borowski.git@proton.me, Namjae Jeon , Hyunchul Lee Cc: Christian Brauner , Christoph Hellwig , "Darrick J. Wong" , ntfs@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org, Zhan Xusheng , stable@vger.kernel.org References: <20261201-b4-ntfs-delalloc-fixes-v4-0-e5dd6f77016a@proton.me> Content-Language: en-US From: liubaolin In-Reply-To: <20261201-b4-ntfs-delalloc-fixes-v4-0-e5dd6f77016a@proton.me> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-CM-TRANSID:_____wD3v0RUuA9rUUPqLw--.19757S2 X-Coremail-Antispam: 1Uf129KBjvJXoWxKF4UtrW5Ww1rAryfZr1fJFb_yoW3tw48pr W3Kr15JrsrAr9rJrsakw10qF1Fka1rJ34UJF4xX3sF9wn8Zr4IgF4vg3Z0vr9IkrWSqay2 qF4UZ34xur90y3DanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07U5nYwUUUUU= X-CM-SenderInfo: xolxutxrol0iasrtmqqrwthudrp/xtbC6hfhrGsPuFe2XgAA3T 在 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 The series looks good to me. Reviewed-by: Baolin Liu