Re: [PATCH v1] exfat: mark straddling folio RO for 4K block size
From: Chi Zhiling
Date: Fri Oct 09 2026 - 02:19:18 EST
On 10/9/26 10:46 AM, Yuezhang.Mo@xxxxxxxx wrote:
#include "exfat_raw.h"
#include "exfat_fs.h"
@@ -91,6 +92,20 @@ static int exfat_cont_expand(struct inode *inode, loff_t size)
*/
pagecache_isize_extended(inode, oldsize, inode->i_size);
+ if (i_blocksize(inode) >= PAGE_SIZE && (oldsize & (PAGE_SIZE - 1))) {
+ struct folio *folio;
+
+ folio = filemap_lock_folio(inode->i_mapping,
+ oldsize >> PAGE_SHIFT);
+ if (!IS_ERR(folio)) {
+ if (folio_mkclean(folio))
+ folio_mark_dirty(folio);
+
+ folio_unlock(folio);
+ folio_put(folio);
+ }
+ }
I think fixing this issue specifically for the block size = 4K case may
not be thorough enough, because pagecache_isize_extended() may also fail
to work when the block size is smaller than 4K.
What condition might pagecache_isize_extended() fail to work when the block
size is smaller than 4K?
I didn’t explain this clearly. What I meant is that the issue is not the block size, but the fact that VDL in exFAT is not block-aligned. pagecache_isize_extended is designed to work at block granularity, so it won’t work either if oldsize and newsize fall within the same block.
/* Page straddling @from will not have any hole block created? */
rounded_from = round_up(from, bsize);
if (to <= rounded_from || !(rounded_from & (PAGE_SIZE - 1)))
return;
We should set the folio containing valid_size to RO whenever valid_size
!= i_size and valid_size is not page-aligned, regardless of the block size.
We should set the folio containing oldsize to RO, rather than valid_size.
This is because, when the folio containing oldsize was first set to RW, oldsize
constrained valid_size, after the file size is subsequently expanded, that
constraint changes, necessitating a re-setting of valid_size.
Yes, using oldsize is better.