From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796117676; b=auMNK4CR2sROJF28ZDLgz+NXFLegeZ9dgLPWEb+a7myo781qSUHKQBcSpH7a3aNp9tfb 2nqcUVTXkCsLM+on0eUJcD/rok/I/9BFmRVczaG42aSsnIqblznZzBfu+qUAS00cRMXcz xWOn3/DbV5o7dZKHLBgC2Bz9gwlXfcP6dLS/J6DN+sbuyEHlI5ce0jvL9yGqvNbcvFP89 svRZ/rcUauewfmywdAJowPdNqHleTLAd5qIdJiBpK/0bgdG8vUakBrl4jO2aWr1R3vitD seUDCWoSSA8JJ2Nga27oal2ID4ahN9TGuqR9N2LFKYUAB/MqjM5PwAMQGEOPb3TxNBA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796117676; h=Received:DKIM-Signature:Received:X-Forwarded-Encrypted: X-Gm-Message-State:X-Received:MIME-Version:References:In-Reply-To: From:Date:X-Gmail-Original-Message-ID:X-Gm-Features:Message-ID: Subject:To:Cc:Content-Type:Content-Transfer-Encoding; bh=5njv+gAXZJPlyVieki68FhQDKYjUg4vKVuYnRt7Yzxs=; b=yE5mFAZdpjE3Lf5i04IMaQPOnC4QzVLSCmyF0Xpp4PYyalp0jCnjfSPB5NKnkh51lhlu BdecCgTxCT89gVPYtju3d8LcSWUP+oxYCQMsV6x4tEkIcT+YaM7/BR+sMMi+RoYLOsd5L /YOpCYlG2NkJsVy3X/FDkHCc/tzUbKyIBDoDkHqgyJ0SAZJnZwFIKttiCgi7c87p204LS kGT3GsE+yJatfUC8UFLYEXgjri6oT4DLS29W6tW76Uavvo1In5TSGTkF+l743C4BibKbP aXx1LXclWIkq279F3aS3roX03cMQI7vnZWJs2tkzFrQRN0zNGPce1z9dcfzeOfXbSBQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Y89sxbv+; arc=none 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 4A43B606A33F for ; Tue, 1 Dec 2026 09:34:36 +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=Y89sxbv+ Received: by smtp.kernel.org (Postfix) with ESMTPSA id B03C91F00925 for ; Tue, 1 Dec 2026 09:34:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796117675; bh=5njv+gAXZJPlyVieki68FhQDKYjUg4vKVuYnRt7Yzxs=; h=References:In-Reply-To:From:Date:Subject:To:Cc; b=Y89sxbv+vKm5shpCeO5fk61lE3/5JNWtWJIKkmcFR2/4Op/wClU2hsTWi+jw39Aop HHL6a360WR2GPQRwjyiKlmeYsOg6Mxv/Ssup34UUKLFsaRlPBcn5BsOlF5SYLy0akq t96iFlrGdhnvgMZIgSGR3tj89kGDAEzX4idPKtZ5Vv11MWYQOgjTQ+8NtiGulpo8lJ PQixyaf5Ru+SWoo9q7RnC1WgVfbkor0EZJK9k5xJb0VWA0PBoeQKo9B/dv6F5hG60X xhrLOsUNkvJMstvMRpNl/LqYC0ozNulVbb8GJyWqCLEbVmBqBDedzUp3fSv4trhQSv 1/ynPbLD/tAgw== Received: by mail-ed1-f50.google.com with SMTP id 4fb4d7f45d1cf-6b4bd3d98bfso13984113a12.1 for ; Tue, 01 Dec 2026 01:34:35 -0800 (PST) X-Forwarded-Encrypted: i=1; AL+hErEYeK4FbyoxFB+1KpOJEpybcgFTCRVQz9yBNUREG9HTLziPj9Gmj4sFnRcUG54Mc/QUxgMeoZu6F6S68jU=@vger.kernel.org X-Gm-Message-State: APuU4Z9lpZ7+l7mARA0BDq/s1cjfJtyVJnD0PV0PayByVAdYvskg97Wg ++pXPe7+3Ee4Qf/GmzL9HUJ3Fi9NYiXXZQFpPOrIvMpwaJ13ZBIF0J2h5mGhNNWektmp8XPLjbN LDFs9L87rtw+/K7LE6qB8kBW77d1GL4U= X-Received: by 2002:a17:906:c10f:b0:c51:b21d:72f4 with SMTP id a640c23a62f3a-c51b21d76b4mr1694866966b.36.1796117674266; Tue, 01 Dec 2026 01:34:34 -0800 (PST) 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 References: <20261127031053.3695758-1-zhanxusheng1024@gmail.com> In-Reply-To: <20261127031053.3695758-1-zhanxusheng1024@gmail.com> From: Namjae Jeon Date: Tue, 1 Dec 2026 18:34:22 +0900 X-Gmail-Original-Message-ID: X-Gm-Features: Aa3M54rIGzFIfad99PA83mdQKfYfQ1nd6yh8cSg62Teq2ZpOEUxAP75ooqzHfcY Message-ID: Subject: Re: [PATCH v12] ntfs: trim the sizes after a short write To: Zhan Xusheng Cc: hyc.lee@gmail.com, ernest.borowski.git@proton.me, liubaolin12138@163.com, ntfs@lists.linux.dev, linux-kernel@vger.kernel.org, zhanxusheng@xiaomi.com, stable@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, Nov 27, 2026 at 12:11=E2=80=AFPM Zhan Xusheng wrote: > > From: Zhan Xusheng > > ntfs_file_write_iter() moves the data size and, for a non-resident > uncompressed file, the initialized size to pos + count before the copy. > __ntfs_extend_initialized_size() only zeroes [old initialized size, pos), > so the range [pos, pos + count) is initialized only by the copy itself. > When iomap_file_buffered_write() copies less than count, it returns a > positive short count and the error rollback at out: does not run. The > file keeps the size pos + count, and [pos + ret, pos + count) reads back > whatever the freed clusters held before, also after a remount. A local > user can read the old contents of freed clusters this way. > > Run the existing rollback for a short write as well, and roll the data > size back to the end of what was written, keeping the clusters that were > allocated on disk before the write, such as space reserved with > FALLOC_FL_KEEP_SIZE. Keep the initialized size, as a page fault through > a shared mapping may rely on it while the write is stalled on its > source, and zero what the write did not reach, up to the end of the > block holding pos + count. Only if that fails, take the initialized > size back to where the zeroing started, if it is above that. A writer > killed during the copy also leaves a short write, but iomap_zero_range() > then fails with -EINTR, so zero from a worker when a fatal signal is > pending. > > An asynchronous direct write that fails after submitting bios returns > -EIOCBQUEUED, and the rollback does not run for it either. Wait for a > direct write that moves the initialized size, and fail a non-blocking > one with -EAGAIN so that it is retried blocking, as ext4 does. > > Fixes: b041ca562526 ("ntfs: update iomap and address space operations") > Cc: stable@vger.kernel.org > Co-developed-by: Ernest Borowski > Signed-off-by: Ernest Borowski > Signed-off-by: Zhan Xusheng Applied it to #ntfs-next. Thanks!