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=1796409637; b=BiIzsxsrYP8pgnvTKPv/NidSn7FfB/ZAUrnQOTQCh2LWIdjRQ2mn2nk8mKX78vLnhkts eR0sBQIIeDJDAM/rjCZDeXCvDbHnFLaE8Dz3jX2G+ghbWQMUa+PUy42Bf3eoSO+kGHNKr ag8Pg7qBHyxxsSbPKx+H5egIisB9uZoAX0OkbbKwz8DEMdfKGH4XJPavrS+TRc5CN1qq5 t07lbrp3S5loO6wkdxywLmVTQYlJ6/lWBYV7Rzj8Ukro05gLSfW8McdL/shuwUbYPBlCX rkB15YT+m3i31lJwGKQhGTYbtFxUTj8SUPmFQinyRoyGD4cWd6hQNQ96Mh3A/gyhAkw== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796409637; 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=OAKfNpDRNbXUCxJjwP7a4yyfNRhEXq93kWGUWac8J8c=; b=F9hs027kxNlAKauYacuCTGm4zAFOKYGT/7B700EH0+fKRuO2RrNXN1lcLrffxamgFNuR 2NJ+ydDPsLpeHimwe+6JeUJ9H1rPfYZcVb6m5uWgL77ephTGPKIELBUq5ZYnD5YVUGpMx VolXck14Z6bDVjsXbD+L8MX6zDyo0F8tVv+QX8Zm5DrOI0nWPDD1TCt4LjsrrCnTD2V5M ul1lSgAa04OFYHQfbAywETgn4/JOBtNhrPi7Phiuizesb/+7b1uUF1RiO1HmreAXNvFqd lAUt3NHVxXQwVRcm0YnqBeIEs2OtimOIPmAJ5diPcKnXP6qLwm0UfogQT/zX8Uqsg9w== 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=CqmFaSWu; 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 A6869606A330; Fri, 4 Dec 2026 18:40:37 +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=CqmFaSWu 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=1796409637; b=bticVrJUBHBHIlRQuwagTvttxlW/6i9YkGE2bKSJ9RWPMv+kIdvQiKhSddQfNNgUWoIm NNC5i15DLAO34HZkxhXEzmTCNtaaJBOd44vC6FuHmmVfU9PJUH1Fuc0T5lJhzPaRPSHqu T4yeMDK8fw1JtNZ4H1k00CUAnC2MPK/ey+9CuDwhvTtD6NO/+lPdMAOCotBs7Wivl5Fzr z19IQ8qEkVpYazkQxZvqUpR7accZkdkb+tM6CE+2qiTkgX+PeSewjRSPyuHk1s1Qg4CJk Uof3pM4EBPcMfQ/aZNkfH+23ae1uJBF1KvCgX1o9zPaThq1nwgU2IynZwu3u+Ttk6fA== ARC-Message-Signature: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; c=relaxed/relaxed; t=1796409637; 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=OAKfNpDRNbXUCxJjwP7a4yyfNRhEXq93kWGUWac8J8c=; b=aSlasQWANjB2DzDb0IL5zN91SMsix7eF2mZT8Ufk9d3tRKrNGsOEryxEuNThu2oYnH9I ksWtipbZKTFW09JP5fTnZla1Mi6pTW/PkItnoivIEt9pARaXumSvaOPPMb5/zunf8VupJ S7sOoSTXDuIZ/SlGmEuR4KeutLVubM5BRqePi3jHT5jJDQERHi3naerahwoCUlXfrx4c1 o4SJIZLVZYgsY3p7lk1AalpFkHfxV99D/OppujsdnWmRCO5uxXMKxrgWIar7bJk7M+ds0 eghKh8O2T0KSwLBO8Ci/50ZFRlomCXtuT/YH4BlHrCdpMbhlHiqOsKGNPUqnveBRDQg== 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 DF4421F00A12; Fri, 4 Dec 2026 18:40:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796409637; bh=OAKfNpDRNbXUCxJjwP7a4yyfNRhEXq93kWGUWac8J8c=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To; b=CqmFaSWueJlbfPYKJmJJGAX2B3ACqUc+uJd5Q6twVfH9z8OtAkKfr8JedTI9Y8LUu NsoK8WtlBvKGoDEX2V7MVbNS5IjF/3jGQzPYUuPtea5yxdKDM3XyJ8QgZJNiFKvqJW Q/HOuUL4NLjMyPMUHCDDhCXjEnKBeh1Cf3E2TKOy3GwgPavNs/5RPtL05nAvX8usVK pV2wrylHGC0H6rsJgDQuOtUCgZzY4pwsERsrvw8NWI5ybaEWdVWPuoBmaRVMhTlycz QQ6/eY9On/StuPP7AdqrUFcbW1jc5Py2qaNozfqRZl343sSUtv4aHM26A9kJXDIgi3 QZ5jts93Xq3jg== Received: from nexus.subspace.kernel.org (localhost [IPv6:::1]) by lkml.kernel.org (Postfix) with ESMTP id 6B0414DC3A; Fri, 4 Dec 2026 18:40:35 +0000 (UTC) From: Ernest Borowski via B4 Relay Date: Fri, 04 Dec 2026 19:40:35 +0100 Subject: [PATCH v5 04/13] 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: <20261204-b4-ntfs-delalloc-fixes-v5-4-1cd0267df2cd@proton.me> References: <20261204-b4-ntfs-delalloc-fixes-v5-0-1cd0267df2cd@proton.me> In-Reply-To: <20261204-b4-ntfs-delalloc-fixes-v5-0-1cd0267df2cd@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, Baolin Liu , Ernest Borowski X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2206; i=ernest.borowski.git@proton.me; s=default; h=from:subject:message-id; bh=VOdT+R589IiPbkCNPimXh8aVfQlflJWTd9p3BMnw9xw=; b=owGbwMvMwCVWzJ65uCpJ5D/jabUkhmxhToUbX7f+lHk5uXPJ3E8FXgceLdH96CkSXMLjHXA// 6Wol1ZDRykLgxgXg6yYIkvH/xshPiHfPi2L0+qDmcPKBDKEgYtTACby7hAjw+3ZrxL+fLIue1Iv ddl/iqD5bsme+hnm1S93XGCV5QpuP8/wV+LmnutplqKzU5xXnzje9mDFn9oTukIcy7/cXmi06qT DPn4A 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 Reviewed-by: Baolin Liu 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