mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2 0/4] exfat: fix VDL tracking bugs
@ 2026-10-04 10:19 Chi Zhiling
  2026-10-04 10:19 ` [PATCH v2 1/4] exfat: advance valid_size to EOF for append writes Chi Zhiling
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Chi Zhiling @ 2026-10-04 10:19 UTC (permalink / raw)
  To: exfat, linux-kernel
  Cc: Yuezhang.Mo, dxdt, linkinjeon, sj1557.seo, Chi Zhiling

From: Chi Zhiling <chizhiling@kylinos.cn>

exFAT tracks a valid data length (VDL) as exfat_inode_info.valid_size:
below it is valid data, at or above it is a hole that the read paths
zero-fill.  It is read without the inode lock (->iomap_begin and the
buffered-read bio completion) and updated from the write, mmap and
truncate paths, so it must only move forward, and only once the data has
actually been copied and the folio dirtied.  This series fixes the bugs
around that invariant:

 - An O_APPEND write uses the caller's offset instead of the position
   recalculated by generic_write_checks(), so valid_size may not be
   advanced to EOF.

 - Truncate does not hold mapping->invalidate_lock, so it can race with
   an mmap write faulting a page back in for the same range.

 - exfat_zero_new_range() does not dirty non-uptodate pages, so some of
   the zeroed blocks are never written back.

Patch 4 converts valid_size and zeroed_size to monotonic atomic counters
as a prerequisite for updating valid_size from contexts that do not hold
i_rwsem.

This series was split from:
https://lore.kernel.org/exfat/20261003033032.1775311-1-chizhiling@163.com/T/#t
The other patches still need some improvement.

Changes in v2:
Rebase onto the latest dev branch.

Chi Zhiling (4):
  exfat: advance valid_size to EOF for append writes
  exfat: hold the invalidate lock while truncating
  exfat: dirty all new pages when extending valid_size
  exfat: make valid_size and zeroed_size atomic

 fs/exfat/exfat_fs.h |  60 +++++++++++++++++-
 fs/exfat/file.c     | 144 ++++++++++++++------------------------------
 fs/exfat/inode.c    |  16 ++---
 fs/exfat/iomap.c    |  27 ++++-----
 fs/exfat/namei.c    |   4 +-
 5 files changed, 127 insertions(+), 124 deletions(-)

-- 
2.53.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-10-04 10:20 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-04 10:19 [PATCH v2 0/4] exfat: fix VDL tracking bugs Chi Zhiling
2026-10-04 10:19 ` [PATCH v2 1/4] exfat: advance valid_size to EOF for append writes Chi Zhiling
2026-10-04 10:19 ` [PATCH v2 2/4] exfat: hold the invalidate lock while truncating Chi Zhiling
2026-10-04 10:19 ` [PATCH v2 3/4] exfat: dirty all new pages when extending valid_size Chi Zhiling
2026-10-04 10:19 ` [PATCH v2 4/4] exfat: make valid_size and zeroed_size atomic Chi Zhiling

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®