From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=100.103.45.18 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796146971; b=Ijvcg8gej24EC1FZwILMSPvn+xYhWEJ8En7PDC1vqQGBYXjxvu+dqiKGY1w0WTh0YNia 9nmuRftMgjCkXdRdwpNheP3KigACGjjFNar4s8+wRAKMu1he5pR82cheLY4Ea+PKx7M0l snHqM2V56LBbUnsNi6/QShgfVlVJPJVZmRYVT1wdCFkBbAESCAmkbHKOCtHECix3RZ6RL hF3uAZDugPJe6BcnKPmGOntoF409i8gW6NY+NrhmDRy2HK/etFsv2XzCUo1vrdVVErcUV DNg+bwDhJbGPj53bQXy534LaesFfUV7nar/jqkZiF44oLT6NtatfXI/SKEcqj+5kY6Q== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796146971; h=Received:DKIM-Signature:Received:From:Date:Subject:MIME-Version: Content-Type:Message-Id:References:In-Reply-To:To:Cc:X-Mailer: X-Developer-Signature:X-Developer-Key:X-Endpoint-Received: X-Original-From:Reply-To:Content-Transfer-Encoding; bh=/aA9zX9BxdvGDLmCP50XVp9jjceKwjFMN8wthJHW6l4=; b=3LyRLkh1NwXSlUP7irwI4VzTQMWUym24aWCMPyTgDKFwXWhIOVMjJ5tu1gyHavcnE/Rk kc7OTgWIIoRE1NL0N35kHXK9r8DX+3kfTIGVbiqOUWulKTfBUE9WeiXiFoYYo9iOP9/u7 +Vg3gEFBnvUX2a5Avyxpu6JWxV4JI00Qx+/Ug4XyuqoPJyxojO66ejqi/U3QwtWtxZwW1 laaqY4ePj89LKZ4jj4PscSA2Xt0uY/ulAEqwSEkb7M1fmT+7s61yvC+9j7kqZ1UhpkI7t 204uokotcxyMqUJJUmzeqRbOMT+s3bEB9XNPVHr1Y4Poswz9I4OH6z6orxJAaKII5Cw== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=UrQZNV+M; arc=pass header.oldest-pass=0 smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ED341606A681; Tue, 1 Dec 2026 17:42:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=UrQZNV+M Authentication-Results: smtp.kernel.org; arc=none smtp.remote-ip=100.80.115.77 ARC-Seal: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; cv=none; t=1796146970; b=IwRX3FEC7RfFjJ4EnvV1ixQsAgFN58b3P2bs0r6h4IlhgY6jjdvl5ZBUq7lXtbUoKm3x q/jF0XkMGVJJGTtlHQimOdBqSsrjcLi+kR3heWw3gBuVPxSougt5ZSa0JF2L3y8pI7UZm lVr4r6Os4ZFICGhYfLX7VNBetm8n7IXMwzLXh9V4wIFsC5CA85C4u9I2lz8KhFMY7t4MH wn9UxZjIFv2r64gDoLKp7C+21bx2DFdDBmA9poO4GgV1TrMDQrvTpsY8lVa4NJDoyagk5 pMoeY1XPN6+RqOH5iJ+ihLnYqhx7oIdiiWfuKieaEIfM44/hTv57cIqYTZ/LPSCFvuA== ARC-Message-Signature: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; c=relaxed/relaxed; t=1796146970; h=DKIM-Signature:Received:From:Date:Subject:MIME-Version:Content-Type: Message-Id:References:In-Reply-To:To:Cc:X-Mailer: X-Developer-Signature:X-Developer-Key:X-Endpoint-Received: X-Original-From:Reply-To:Content-Transfer-Encoding; bh=/aA9zX9BxdvGDLmCP50XVp9jjceKwjFMN8wthJHW6l4=; b=wJqnNVyPC/CPdU8qoYUy/2UAr7WZWJmxqEQCvCowuhsy5v63nwUCaWwIvBUUwpR1T+W6 pV2QNjDSYZk90KoeRQb2g7ET99FxeUtSfmkPPq9+Q6JX9i+lg6KjAbSaM3X20KNsJdacS MCOVK/dOffqvPPNWCa2utynTim4kEECQTRnT4O1FiXmBQBOO1nIohuvq1gvITyaml1hwd zQpWxXKffFi4jbNXZuCj3Qq2pfEfuNOssFjmi17wK1CSHg8iqvJsKl2gx6X4Gwt6yEUPf sVPxJKk5zzERKYPtJU0iFGelZa6Qf8a2mm8bQNAPPyjng+GhtNGVzcjokgE0Ab9jZug== ARC-Authentication-Results: i=1; smtp.kernel.org; arc=none smtp.remote-ip=100.80.115.77 Received: from lkml.kernel.org (nexus.subspace.kernel.org [100.80.115.77]) (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.kernel.org (Postfix) with ESMTPS id 5F7AF1F00A16; Tue, 1 Dec 2026 17:42:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796146970; bh=/aA9zX9BxdvGDLmCP50XVp9jjceKwjFMN8wthJHW6l4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To; b=UrQZNV+MoGd71cKCqC3XLPdK0hvC4cH/d96IvJgkw2NdRAAuhQn0DQP3w5T/1sgTZ faGciS4jTjrg7wGHn1IQcMEz/0rQZxEL3QnDiGxwDCznnqX7sMUpaTIRZGPQTvEbjJ UX3mV3qZSWJ/rALhuQluNpJcj9qi9SXe98HD9lnEV1hMTilszqdk6yosuDbAYifNK5 Gzw8BqCrEMXEtV9sEOeN7ehMXdmkaELimAoEJxeOPZWm+vtKH4uI1qbTKy3hB6SgBu cCmHP0i1k0cRtS8PbwRmTjmpFIitbn04y/wVWl11zkJO7B/z5LRIUtFw2jQJBbcaqA CF3uEX7KLX9mQ== Received: from nexus.subspace.kernel.org (localhost [IPv6:::1]) by lkml.kernel.org (Postfix) with ESMTP id D3C5B4EF1B; Tue, 1 Dec 2026 17:42:38 +0000 (UTC) From: Ernest Borowski via B4 Relay Date: Tue, 01 Dec 2026 18:42:39 +0100 Subject: [PATCH v4 04/11] ntfs: do not consume delalloc reservations when filling holes 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 Content-Type: text/plain; charset="utf-8" Message-Id: <20261201-b4-ntfs-delalloc-fixes-v4-4-e5dd6f77016a@proton.me> References: <20261201-b4-ntfs-delalloc-fixes-v4-0-e5dd6f77016a@proton.me> In-Reply-To: <20261201-b4-ntfs-delalloc-fixes-v4-0-e5dd6f77016a@proton.me> To: Namjae Jeon , Hyunchul Lee , Baolin Liu 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, Ernest Borowski X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2158; i=ernest.borowski.git@proton.me; s=default; h=from:subject:message-id; bh=qlO31Tstqk/n+UBUPPN4WUoJKJzUHS/R43E4OsafLFI=; b=owGbwMvMwCVWzJ65uCpJ5D/jabUkhmx+dh4Lux+Hj6XM2Pq1Uf3oleNeSonXTilbrLPZ8LvTu K6gx6m6o5SFQYyLQVZMkaXj/40Qn5Bvn5bFafXBzGFlAhnCwMUpABNp3MDwP8hgyo/miLVNCbYn 750umVXupKf9WfDyzNfX/MIPnbmxZQ4jw9n8b0fWvNwkXnJx8zu3nX++zvvgtLLh8IJwhR9L//B M3MIAAA== X-Developer-Key: i=ernest.borowski.git@proton.me; a=openpgp; fpr=88FFD8544C54F6F2A65E2A8E730769A37A6214FF X-Endpoint-Received: by B4 Relay for ernest.borowski.git@proton.me/default with auth_id=1589 X-Original-From: Ernest Borowski Reply-To: ernest.borowski.git@proton.me Content-Transfer-Encoding: 7bit From: Ernest Borowski ntfs_attr_map_cluster() always calls ntfs_cluster_alloc() with is_dealloc set, which makes the allocator skip the dirty_clusters check and subtract the allocated clusters from vol->dirty_clusters. That is right for writeback converting an LCN_DELALLOC run, whose clusters were reserved by the buffered write, but ntfs_attr_map_cluster() also fills plain holes for fallocate(), direct I/O and page_mkwrite(), which never reserved anything. Those allocations release reservations that belong to dirty data of other files, and can use clusters that are promised to that data, so writeback of the delayed data can later run out of space although every earlier check succeeded. Reproducer: write 1 MiB to file A without syncing (statfs() free space drops by 256 clusters), then fallocate() 1 MiB on file B: free space does not drop at all. Only treat the allocation as consuming a reservation when the run being filled is a delalloc run. Filling a hole now fails with ENOSPC when the remaining free clusters are all reserved for delayed data, so a write fault into a hole of an mmap()ed file gets SIGBUS in that case, as on other filesystems with delayed allocation. Fixes: 495e90fa3348 ("ntfs: update attrib operations") Cc: stable@vger.kernel.org Signed-off-by: Ernest Borowski --- fs/ntfs/attrib.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/fs/ntfs/attrib.c b/fs/ntfs/attrib.c index 3f19fd2ec7..31ee811458 100644 --- a/fs/ntfs/attrib.c +++ b/fs/ntfs/attrib.c @@ -5557,8 +5557,14 @@ int ntfs_attr_map_cluster(struct ntfs_inode *ni, s64 vcn_start, s64 *lcn_start, } } + /* + * Only a delayed-allocation run holds a reservation in + * vol->dirty_clusters for the allocator to consume. Holes filled by + * fallocate(), direct I/O or page_mkwrite() have none and must leave + * the reservations of other writers alone. + */ rlc = ntfs_cluster_alloc(vol, vcn, clu_count, lcn_seek_from, DATA_ZONE, - false, true, true); + false, true, lcn == LCN_DELALLOC); if (IS_ERR(rlc)) { err = PTR_ERR(rlc); goto out; -- 2.56.1