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 4/5] exfat: serialize file expansion with mmap write faults
Date: Mon, 16 Nov 2026 16:57:51 +0800 [thread overview]
Message-ID: <20261116085752.3908082-5-chizhiling@163.com> (raw)
In-Reply-To: <20261116085752.3908082-1-chizhiling@163.com>
From: Namjae Jeon <linkinjeon@kernel.org>
File expansion changes allocation and i_size while mmap write faults
can initialize the invalid range. Cleaning only the old EOF folio does
not serialize the whole expansion with those faults.
Wait for direct I/O and hold invalidate_lock exclusively across cluster
allocation, EOF cleanup and the i_size update. Apply this to the common
expansion path used by ftruncate and fallocate.
Fixes: 98431d2cd1eb ("exfat: mark straddling folio RO and zero the post-EOF range")
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
---
fs/exfat/file.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/fs/exfat/file.c b/fs/exfat/file.c
index 47e95b14d570..0d1eeeeffa76 100644
--- a/fs/exfat/file.c
+++ b/fs/exfat/file.c
@@ -81,7 +81,7 @@ static void exfat_pagecache_isize_extended(struct inode *inode, loff_t from,
folio_put(folio);
}
-static int exfat_cont_expand(struct inode *inode, loff_t size)
+static int __exfat_cont_expand(struct inode *inode, loff_t size)
{
int ret;
unsigned int num_clusters, new_num_clusters, last_clu;
@@ -158,6 +158,17 @@ static int exfat_cont_expand(struct inode *inode, loff_t size)
return -EIO;
}
+static int exfat_cont_expand(struct inode *inode, loff_t size)
+{
+ int ret;
+
+ inode_dio_wait(inode);
+ filemap_invalidate_lock(inode->i_mapping);
+ ret = __exfat_cont_expand(inode, size);
+ filemap_invalidate_unlock(inode->i_mapping);
+ return ret;
+}
+
/*
* Preallocate space for a file. This implements exfat's fallocate file
* operation, which gets called from sys_fallocate system call. User space
--
2.53.0
next prev parent 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 [PATCH v4 0/5] exfat: fix valid_size update races Chi Zhiling
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 ` Chi Zhiling [this message]
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-5-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®