From: Hyunchul Lee <hyc.lee@gmail.com>
To: ernest.borowski.git@proton.me
Cc: Namjae Jeon <linkinjeon@kernel.org>,
Baolin Liu <liubaolin12138@163.com>,
Christian Brauner <brauner@kernel.org>,
Christoph Hellwig <hch@lst.de>,
"Darrick J. Wong" <djwong@kernel.org>,
ntfs@lists.linux.dev, linux-fsdevel@vger.kernel.org,
linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org,
Zhan Xusheng <zhanxusheng1024@gmail.com>,
stable@vger.kernel.org
Subject: Re: [PATCH v4 10/11] ntfs: zero the rest of a new cluster after a short buffered write
Date: Fri, 4 Dec 2026 10:05:55 +0900 [thread overview]
Message-ID: <axIR80g42pw0ZB7C@hyunchul-PC02> (raw)
In-Reply-To: <20261201-b4-ntfs-delalloc-fixes-v4-10-e5dd6f77016a@proton.me>
Hi Ernest,
> +/*
> + * Make writeback write all of [start, end), the rest of a cluster that was a
> + * hole and that a short buffered write filled only in part. Folios in the
> + * page cache keep their contents (the zeroes __iomap_write_begin() put
> + * there, or data an mmap write added meanwhile), and only their blocks in
> + * the range are dirtied: other clean blocks of the folio may be holes, or
> + * delalloc clusters the write did not reach, which the caller punches out.
> + * The rest of the range is zeroed only while the cluster is still delalloc:
> + * once a write fault or writeback has allocated it, what an mmap write put
> + * there since may be on the disk only, and zeroing the page cache would
> + * overwrite it. The caller holds the invalidate lock.
> + */
> +static int ntfs_dirty_cluster_tail(struct inode *inode, loff_t start,
> + loff_t end)
> +{
> + struct folio *folio;
> + loff_t next;
> + int err = 0;
> +
> + lockdep_assert_held_write(&inode->i_mapping->invalidate_lock);
> + while (!err && start < end) {
> + folio = filemap_lock_folio(inode->i_mapping,
> + start >> PAGE_SHIFT);
> + if (IS_ERR(folio)) {
> + next = min_t(loff_t, round_up(start + 1, PAGE_SIZE),
> + end);
> + if (ntfs_pos_is_delalloc(inode, start))
> + err = ntfs_zero_range_unkillable(inode, start,
> + next - start);
> + } else {
> + bool uptodate = folio_test_uptodate(folio);
> + size_t off = offset_in_folio(folio, start);
> +
> + next = min_t(loff_t, folio_pos(folio) +
> + folio_size(folio), end);
> + if (uptodate)
> + iomap_dirty_folio_range(folio, off,
> + next - start);
Instead of marking this range dirty directly, how about zeroing it with
iomap_zero_range()? __iomap_write_end() marks exactly the zeroed range
dirty.
if (ntfs_pos_is_delalloc(inode, start)) {
ntfs_zero_range_unkillable(...)
continue;
}
folio = filemap_lock_folio(...)
if (IS_ERR(folio))
continue;
if (folio_test_uptodate(folio))
folio_mark_dirty(folio);
...
> + folio_unlock(folio);
> + folio_put(folio);
> + if (!uptodate && ntfs_pos_is_delalloc(inode, start))
> + err = ntfs_zero_range_unkillable(inode, start,
> + next - start);
> + }
> + start = next;
> + }
> + return err;
> +}
> +
--
Thanks,
Hyunchul
next prev parent reply other threads:[~2026-12-04 1:05 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-01 17:42 [PATCH v4 00/11] ntfs: delayed allocation accounting and stale data fixes, part 1 Ernest Borowski
2026-12-01 17:42 ` Ernest Borowski via B4 Relay
2026-12-01 17:42 ` [PATCH v4 01/11] iomap: punch out a run of clean blocks in one call Ernest Borowski
2026-12-01 17:42 ` Ernest Borowski via B4 Relay
2026-12-01 17:42 ` [PATCH v4 02/11] iomap: add a helper to mark a range of a folio dirty Ernest Borowski
2026-12-01 17:42 ` Ernest Borowski via B4 Relay
2026-12-01 17:42 ` [PATCH v4 03/11] ntfs: release delalloc reservations cut off by truncate Ernest Borowski
2026-12-01 17:42 ` Ernest Borowski via B4 Relay
2026-12-01 17:42 ` [PATCH v4 04/11] ntfs: do not consume delalloc reservations when filling holes Ernest Borowski
2026-12-01 17:42 ` Ernest Borowski via B4 Relay
2026-12-01 17:42 ` [PATCH v4 05/11] ntfs: keep delalloc reservations when a cluster allocation fails Ernest Borowski
2026-12-01 17:42 ` Ernest Borowski via B4 Relay
2026-12-01 17:42 ` [PATCH v4 06/11] ntfs: release the delalloc reservations of an evicted inode Ernest Borowski
2026-12-01 17:42 ` Ernest Borowski via B4 Relay
2026-12-01 17:42 ` [PATCH v4 07/11] ntfs: do not shift the cluster number of a delalloc run on split Ernest Borowski
2026-12-01 17:42 ` Ernest Borowski via B4 Relay
2026-12-01 17:42 ` [PATCH v4 08/11] ntfs: punch out the delalloc reservation of a failed buffered write Ernest Borowski
2026-12-01 17:42 ` Ernest Borowski via B4 Relay
2026-12-01 17:42 ` [PATCH v4 09/11] ntfs: zero new delalloc clusters even when writeback allocates them Ernest Borowski
2026-12-01 17:42 ` Ernest Borowski via B4 Relay
2026-12-01 17:42 ` [PATCH v4 10/11] ntfs: zero the rest of a new cluster after a short buffered write Ernest Borowski
2026-12-01 17:42 ` Ernest Borowski via B4 Relay
2026-12-04 1:05 ` Hyunchul Lee [this message]
2026-12-04 18:45 ` Ernest Borowski
2026-12-01 17:42 ` [PATCH v4 11/11] ntfs: revalidate a buffered write's mapping after its clusters were allocated Ernest Borowski
2026-12-01 17:42 ` Ernest Borowski via B4 Relay
2026-12-02 6:19 ` [PATCH v4 00/11] ntfs: delayed allocation accounting and stale data fixes, part 1 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=axIR80g42pw0ZB7C@hyunchul-PC02 \
--to=hyc.lee@gmail.com \
--cc=brauner@kernel.org \
--cc=djwong@kernel.org \
--cc=ernest.borowski.git@proton.me \
--cc=hch@lst.de \
--cc=linkinjeon@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
--cc=liubaolin12138@163.com \
--cc=ntfs@lists.linux.dev \
--cc=stable@vger.kernel.org \
--cc=zhanxusheng1024@gmail.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.