Skip to content

exfat: fix VDL tracking bugs

Chi Zhiling exfat lkml 2 versions In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest4 patches 6 repliesIn review
  2. v14 patches 0 repliesSuperseded

Changes in v2 from the cover letter

Rebase onto the latest dev branch.

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4exfat: advance valid_size to EOF for append writesfs/exfat/file.c+8 -100 replies
2/4exfat: hold the invalidate lock while truncatingfs/exfat/file.c+4 -00 replies
3/4exfat: dirty all new pages when extending valid_sizefs/exfat/file.c+16 -766 replies
4/4exfat: make valid_size and zeroed_size atomicfs/exfat/exfat_fs.h fs/exfat/file.c fs/exfat/inode.c +2 more+100 -390 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [PATCH v2 0/4] exfat: fix VDL tracking bugs

From: Chi Zhiling <[email protected]>

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/[email protected]/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(-)
Signature · 1 line
2.53.0