Re: [PATCH v1] exfat: mark straddling folio RO for 4K block size
From: Yuezhang.Mo@xxxxxxxx
Date: Thu Oct 08 2026 - 22:47:19 EST
> > #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?
>
> 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.