mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Chi Zhiling <chizhiling@163.com>
To: linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	exfat@lists.linux.dev, linux-kernel@vger.kernel.org
Cc: Namjae Jeon <linkinjeon@kernel.org>,
	Sungjong Seo <sj1557.seo@samsung.com>,
	Yuezhang Mo <yuezhang.mo@sony.com>,
	Christian Brauner <brauner@kernel.org>,
	"Darrick J. Wong" <djwong@kernel.org>,
	Chi Zhiling <chizhiling@kylinos.cn>
Subject: [PATCH v4 0/5] exfat: fix valid_size update races
Date: Mon, 16 Nov 2026 16:57:47 +0800	[thread overview]
Message-ID: <20261116085752.3908082-1-chizhiling@163.com> (raw)

From: Chi Zhiling <chizhiling@kylinos.cn>

exFAT uses valid_size (ValidDataLength) as the on-disk boundary of
initialised data, but the current code advances it too late and without
proper serialisation.  Buffered writes can silently lose data reclaimed
before valid_size covers it, file expansion and page faults can
initialise the same range concurrently, and a failed or short direct
write can still grow the file on disk.

This series advances valid_size under the folio lock, keeps zeroed_size
in sync with the block tails that were actually initialised, and
revalidates cached iomaps for buffered writes.  File expansion holds
invalidate_lock across allocation, EOF cleanup and the i_size update.
Direct writes are prepared and written back through their destination
boundary folio before submission, publish i_size and valid_size only
from ->end_io(), and hold invalidate_lock across completion, post-write
invalidation, gap initialisation and rollback so that mmap faults
cannot interfere.

V4:
- Fold the series into five patches and rebase onto current exfat/dev.
- Add a patch that serialises file expansion with mmap write faults.
- Rework direct writes: prepare and write back the invalid range through
  the destination boundary folio, initialise the gap after the post-write
  invalidation, and keep pure overwrites asynchronous.
- Track initialised block tails in zeroed_size instead of
  IOMAP_F_ZERO_TAIL, record the on-disk length in i_size, and finish
  short direct reads with filemap_read().
- Pick up the Reviewed-by on the iomap patch.

V3: https://lore.kernel.org/exfat/20261016033349.3104509-1-chizhiling@163.com/
V2: https://lore.kernel.org/exfat/20261013033837.2748258-1-chizhiling@163.com/
V1: https://lore.kernel.org/exfat/59056131-e3bd-4003-8c30-0a356cf0bd82@163.com/
Link: https://lore.kernel.org/exfat/10029d6f-13cc-4d17-a2f9-b093a8339dde/T/#t

Chi Zhiling (3):
  iomap: export iomap_bio_read_folio_range_sync()
  exfat: increase VDL before unlocking initialized folios
  exfat: zero invalid VDL tails in buffered and direct reads

Namjae Jeon (2):
  exfat: serialize file expansion with mmap write faults
  exfat: coordinate direct writes with mmap faults

 fs/exfat/exfat_fs.h   |   2 +-
 fs/exfat/fatent.c     |   6 +-
 fs/exfat/file.c       | 427 ++++++++++++++++++++++++++++++++----------
 fs/exfat/inode.c      |  19 +-
 fs/exfat/iomap.c      | 368 ++++++++++++++++++++++++------------
 fs/exfat/iomap.h      |  10 +-
 fs/iomap/bio.c        |   1 +
 fs/iomap/internal.h   |  12 --
 include/linux/iomap.h |   9 +
 9 files changed, 599 insertions(+), 255 deletions(-)

-- 
2.53.0


             reply	other threads:[~2026-11-16  8:59 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-16  8:57 Chi Zhiling [this message]
2026-11-16  8:57 ` [PATCH v4 1/5] iomap: export iomap_bio_read_folio_range_sync() Chi Zhiling
2026-11-16  8:57 ` [PATCH v4 2/5] exfat: increase VDL before unlocking initialized folios Chi Zhiling
2026-11-16  8:57 ` [PATCH v4 3/5] exfat: zero invalid VDL tails in buffered and direct reads Chi Zhiling
2026-11-16  8:57 ` [PATCH v4 4/5] exfat: serialize file expansion with mmap write faults Chi Zhiling
2026-11-16  8:57 ` [PATCH v4 5/5] exfat: coordinate direct writes with mmap faults Chi Zhiling

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=20261116085752.3908082-1-chizhiling@163.com \
    --to=chizhiling@163.com \
    --cc=brauner@kernel.org \
    --cc=chizhiling@kylinos.cn \
    --cc=djwong@kernel.org \
    --cc=exfat@lists.linux.dev \
    --cc=linkinjeon@kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    --cc=sj1557.seo@samsung.com \
    --cc=yuezhang.mo@sony.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 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®