mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Chi Zhiling <chizhiling@163.com>
To: exfat@lists.linux.dev, linux-kernel@vger.kernel.org
Cc: Yuezhang.Mo@sony.com, chenxiaosong@chenxiaosong.com,
	dxdt@dev.snart.me, hyc.lee@gmail.com, linkinjeon@kernel.org,
	liubaolin12138@163.com, sj1557.seo@samsung.com,
	Chi Zhiling <chizhiling@kylinos.cn>
Subject: [PATCH v2 6/7] exfat: advance valid_size while zeroing new ranges
Date: Sat,  3 Oct 2026 11:30:31 +0800	[thread overview]
Message-ID: <20261003033032.1775311-7-chizhiling@163.com> (raw)
In-Reply-To: <20261003033032.1775311-1-chizhiling@163.com>

From: Chi Zhiling <chizhiling@kylinos.cn>

valid_size is currently updated only after the range has been zeroed, so
it lags the folios that were just marked uptodate and dirty.

Advance it from exfat_zero_new_range() page by page, under the folio
lock and right after the folio is marked dirty.  exfat_extend_valid_size()
then only advances zeroed_size, and exfat_page_mkwrite() advances
valid_size once iomap_page_mkwrite() has returned the locked folio.

Signed-off-by: Chi Zhiling <chizhiling@kylinos.cn>
---
 fs/exfat/file.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/fs/exfat/file.c b/fs/exfat/file.c
index 6bd2b6d28a82..d92997dc8eec 100644
--- a/fs/exfat/file.c
+++ b/fs/exfat/file.c
@@ -666,6 +666,7 @@ int exfat_file_fsync(struct file *filp, loff_t start, loff_t end, int datasync)
 static int exfat_zero_new_range(struct inode *inode, loff_t start, loff_t end)
 {
 	struct address_space *mapping = inode->i_mapping;
+	struct exfat_inode_info *ei = EXFAT_I(inode);
 	loff_t next, pos = start;
 	struct folio *folio;
 	pgoff_t index;
@@ -683,6 +684,7 @@ static int exfat_zero_new_range(struct inode *inode, loff_t start, loff_t end)
 		folio_lock(folio);
 		if (folio->mapping == mapping) {
 			folio_mark_dirty(folio);
+			exfat_advance_valid_size(ei, next);
 			pos = next;
 		}
 		folio_unlock(folio);
@@ -732,7 +734,6 @@ static int exfat_extend_valid_size(struct inode *inode, loff_t new_valid_size)
 			return ret;
 		}
 
-		exfat_set_valid_size(ei, new_valid_size);
 		exfat_advance_zeroed_size(ei,
 				round_up(new_valid_size, i_blocksize(inode)));
 		mark_inode_dirty(inode);
@@ -925,7 +926,6 @@ static vm_fault_t exfat_page_mkwrite(struct vm_fault *vmf)
 		 */
 		exfat_advance_zeroed_size(ei,
 				round_up(new_valid_size, i_blocksize(inode)));
-		exfat_set_valid_size(ei, new_valid_size);
 		mark_inode_dirty(inode);
 	}
 
@@ -934,6 +934,9 @@ static vm_fault_t exfat_page_mkwrite(struct vm_fault *vmf)
 
 	filemap_invalidate_lock_shared(inode->i_mapping);
 	ret = iomap_page_mkwrite(vmf, &exfat_iomap_ops, NULL);
+	if (ret == VM_FAULT_LOCKED)
+		exfat_advance_valid_size(ei, new_valid_size);
+
 	filemap_invalidate_unlock_shared(inode->i_mapping);
 	sb_end_pagefault(inode->i_sb);
 	inode_unlock(inode);
-- 
2.53.0


  parent reply	other threads:[~2026-10-03  3:31 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-03  3:30 [PATCH v2 0/7] exfat: fix valid_size handling and locking Chi Zhiling
2026-10-03  3:30 ` [PATCH v2 1/7] exfat: advance valid_size to EOF for append writes Chi Zhiling
2026-10-03  3:30 ` [PATCH v2 2/7] exfat: hold the invalidate lock while truncating Chi Zhiling
2026-10-03  3:30 ` [PATCH v2 3/7] exfat: dirty all new pages when extending valid_size Chi Zhiling
2026-10-03  3:30 ` [PATCH v2 4/7] exfat: make valid_size and zeroed_size atomic Chi Zhiling
2026-10-03  3:30 ` [PATCH v2 5/7] exfat: publish valid_size under the folio lock for buffered writes Chi Zhiling
2026-10-03  3:30 ` Chi Zhiling [this message]
2026-10-03  3:30 ` [PATCH v2 7/7] exfat: drop i_rwsem from exfat_page_mkwrite 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=20261003033032.1775311-7-chizhiling@163.com \
    --to=chizhiling@163.com \
    --cc=Yuezhang.Mo@sony.com \
    --cc=chenxiaosong@chenxiaosong.com \
    --cc=chizhiling@kylinos.cn \
    --cc=dxdt@dev.snart.me \
    --cc=exfat@lists.linux.dev \
    --cc=hyc.lee@gmail.com \
    --cc=linkinjeon@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=liubaolin12138@163.com \
    --cc=sj1557.seo@samsung.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®