mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Baolin Liu <liubaolin12138@163.com>
To: linkinjeon@kernel.org, hyc.lee@gmail.com
Cc: ntfs@lists.linux.dev, linux-kernel@vger.kernel.org,
	Baolin Liu <liubaolin@kylinos.cn>
Subject: [PATCH v1 01/13] ntfs: limit writeback allocation to the dirty range
Date: Thu,  3 Dec 2026 12:03:40 +0800	[thread overview]
Message-ID: <20261203040352.1161120-2-liubaolin12138@163.com> (raw)
In-Reply-To: <20261203040352.1161120-1-liubaolin12138@163.com>

From: Baolin Liu <liubaolin@kylinos.cn>

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 <liubaolin@kylinos.cn>
---
 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)


  reply	other threads:[~2026-12-03  4:06 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-03  4:03 [PATCH v1 00/13] ntfs: add large folio support for ordinary files Baolin Liu
2026-12-03  4:03 ` Baolin Liu [this message]
2026-12-03  4:03 ` [PATCH v1 02/13] ntfs: read compression units without the block device page cache Baolin Liu
2026-12-03  4:03 ` [PATCH v1 03/13] ntfs: snapshot resident data for direct reads Baolin Liu
2026-12-03  4:03 ` [PATCH v1 04/13] ntfs: allow vmalloc for large runlist backups Baolin Liu
2026-12-03  4:03 ` [PATCH v1 05/13] ntfs: preserve delalloc reservations when allocating holes Baolin Liu
2026-12-03  4:03 ` [PATCH v1 06/13] ntfs: serialize delalloc reservations with cluster allocation Baolin Liu
2026-12-03  4:03 ` [PATCH v1 07/13] ntfs: respect space reservations when writing compressed data Baolin Liu
2026-12-03  4:03 ` [PATCH v1 08/13] ntfs: keep space for MFT growth during delayed allocation Baolin Liu
2026-12-03  4:03 ` [PATCH v1 09/13] ntfs: serialize compression changes with file access Baolin Liu
2026-12-03  4:03 ` [PATCH v1 10/13] ntfs: complete compressed reads at folio granularity Baolin Liu
2026-12-03  4:03 ` [PATCH v1 11/13] ntfs: stop compressed reads at EOF within a base page Baolin Liu
2026-12-03  4:03 ` [PATCH v1 12/13] ntfs: preserve large folios during compressed writes Baolin Liu
2026-12-03  4:03 ` [PATCH v1 13/13] ntfs: enable large folios for ordinary files Baolin Liu
2026-12-03  4:23 ` [PATCH v1 00/13] ntfs: add large folio support " liubaolin
2026-12-03  5:30   ` Namjae Jeon
2026-12-03 10:10     ` liubaolin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261203040352.1161120-2-liubaolin12138@163.com \
    --to=liubaolin12138@163.com \
    --cc=hyc.lee@gmail.com \
    --cc=linkinjeon@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=liubaolin@kylinos.cn \
    --cc=ntfs@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®