From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=117.135.210.5 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796270783; b=KuEJKUOM5L3ibQomOpSabLPCf7EO7miRS3HpD0lyLCVh4wIz2pRdNuVn6fVkjijP2qfo H89XjW8SiJIg2X7vFd9HhGpsKWomNiak444p5DMqOXD6XrJB8a8iACPMr8JryPQlWCWSL HE9mBj9KM/d+jRPdkKXpWZ1ZbOswad776xOUJySQdhtcBZPV/dwpoOL7kU+nxXIbpMbQS Dr+SIOZpAnM38iKIYX+T+KDDOWQF6L/VXaNTSZI8+EZXoeEYxHLdnsuluDl303TD3GWTb mv2OF7chGGJ8GVTtLnCPRLc3zSCIcv2lJTEuyqNlt4ys5qtJCLLJSikYreCXnvRQuSA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796270783; h=DMARC-Filter:DKIM-Signature:Received:From:To:Cc:Subject:Date: Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding:X-CM-TRANSID:X-Coremail-Antispam: X-Originating-IP:X-CM-SenderInfo; bh=9C860GkpgHQWELZZmRkrEOy2yHYCtCc9w6nF9IozUFw=; b=HdBGEOAAV4JLW+Z70YtEakXBLvbptBTwhRiu+wQ5+9/A1v2uZv+kWDVsHrLqiz1mQjN5 rIoxOH5bD0lwOvyEAHDBpRZKJJjOG5ZRtm/4oGFSWmZ8WvKLHrC7m+i4ONafWYYCDa0pT 3Cx79E6ypfGjDXfK56mQP2y827H3nf95HiOP2ipkqbpGEbWbT0zBl90wU+OevSGfKsRwY +5eni7av81YtlZsRQju7BP7yYKvU57Abd22vGEQLcj+CU1qgNlfR9i9Vm2xDhtq1UGNGz 0wz7EUgKLOzNGYQNKOeY2Bx57+sFvLd1zK7OHFSVNM9WJJ34AsMKcGWCZYp1cYmpRuQ== 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="JcOGgv/r"; arc=none smtp.remote-ip=117.135.210.5 Received: from m16.mail.163.com (m16.mail.163.com [117.135.210.5]) (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 8D4C8606A336 for ; Thu, 3 Dec 2026 04:06:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 8D4C8606A336 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=JcOGgv/r DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=9C 860GkpgHQWELZZmRkrEOy2yHYCtCc9w6nF9IozUFw=; b=JcOGgv/rSIOYTnSI59 x+KnriCXJGiBuLLRN42WpZWFRNkEenNAvG51DN8xgt3ChyvUVFuQj133ef9tmbE5 eB5uHTPZm18EONXsik9nQUsPTAhL9SWY2oRUfxGc2d0Tg0hMDSb5f8YyKFFF9PZT 2rvUHN6dOojgvJPa4DyLUNq70= Received: from liubaolin-ROG-Strix-G713PV-G713PV (unknown []) by gzsmtp5 (Coremail) with SMTP id QCgvCgC3F7Cp6hBr4BFFJg--.15232S3; Thu, 03 Dec 2026 12:06:04 +0800 (CST) From: Baolin Liu To: linkinjeon@kernel.org, hyc.lee@gmail.com Cc: ntfs@lists.linux.dev, linux-kernel@vger.kernel.org, Baolin Liu Subject: [PATCH v1 01/13] ntfs: limit writeback allocation to the dirty range Date: Thu, 3 Dec 2026 12:03:40 +0800 Message-ID: <20261203040352.1161120-2-liubaolin12138@163.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261203040352.1161120-1-liubaolin12138@163.com> References: <20261203040352.1161120-1-liubaolin12138@163.com> 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-Transfer-Encoding: 8bit X-CM-TRANSID:QCgvCgC3F7Cp6hBr4BFFJg--.15232S3 X-Coremail-Antispam: 1Uf129KBjvJXoW7tFW3ZF17Xw1UXrW8XF4xJFb_yoW8tryfpr Z2kF98Ga1rJF13Wws2g345XFy093Z5tr1UJr4UX3yavwn0vr1Ikas5K3WF9FWFyF93AryU XrW8u3yxWr9xZF7anT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07j718kUUUUU= X-CM-SenderInfo: xolxutxrol0iasrtmqqrwthudrp/xtbC6QzEj2sQ6qxAagAA35 From: Baolin Liu A buffered write into a hole reserves space before copying user data. If the copy faults partway through, writeback can allocate the clean remainder of the reservation because it maps up to allocated_size. After fsync and cache eviction, reads can expose old disk contents instead of zeros. A pwritev with an inaccessible second buffer reproduces this with order-0 folios. Limit writeback mappings to the dirty range supplied by iomap. Zero unwritten edges of newly allocated clusters for writeback as for direct writes and page_mkwrite, and keep reservation accounting independent of that zeroing. Fixes: b041ca562526 ("ntfs: update iomap and address space operations") Signed-off-by: Baolin Liu --- fs/ntfs/iomap.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/fs/ntfs/iomap.c b/fs/ntfs/iomap.c index ce916707f69b..8970cadcd31e 100644 --- a/fs/ntfs/iomap.c +++ b/fs/ntfs/iomap.c @@ -620,7 +620,8 @@ static int ntfs_write_da_iomap_begin_non_resident(struct inode *inode, if (balloc == true) { if (flags & IOMAP_DIRECT || - ntfs_iomap_flags & NTFS_IOMAP_FLAGS_MKWRITE) { + ntfs_iomap_flags & (NTFS_IOMAP_FLAGS_MKWRITE | + NTFS_IOMAP_FLAGS_WRITEBACK)) { loff_t end = offset + length; if (vcn_ofs || ((vol->cluster_size > iomap->length) && @@ -636,7 +637,8 @@ static int ntfs_write_da_iomap_begin_non_resident(struct inode *inode, (start_lcn + lcn_count - 1) << vol->cluster_size_bits, vol->cluster_size); - } else { + } + if (ntfs_iomap_flags & NTFS_IOMAP_FLAGS_WRITEBACK) { if (lcn_count > ni->i_dealloc_clusters) ni->i_dealloc_clusters = 0; else @@ -804,8 +806,8 @@ static ssize_t ntfs_writeback_range(struct iomap_writepage_ctx *wpc, offset >= wpc->iomap.offset + wpc->iomap.length) { int error; - error = __ntfs_write_iomap_begin(wpc->inode, offset, - NTFS_I(wpc->inode)->allocated_size - offset, + /* A short write may leave clean delalloc blocks after this range. */ + error = __ntfs_write_iomap_begin(wpc->inode, offset, len, IOMAP_WRITE, &wpc->iomap, NTFS_IOMAP_FLAGS_WRITEBACK); if (error)