Re: [PATCH v2] exfat: hold s_lock for cluster-chain updates in __exfat_cont_expand()
From: Namjae Jeon
Date: Wed Nov 18 2026 - 04:56:32 EST
On Wed, Nov 18, 2026 at 12:22 PM Chi Zhiling <chizhiling@xxxxxxx> wrote:
>
> On 11/18/26 09:58, Youling Tang wrote:
> > From: Youling Tang <tangyouling@xxxxxxxxxx>
> >
> > __exfat_cont_expand() allocates clusters, appends them to the FAT chain
> > and updates ei->start_clu, ei->flags and i_blocks without holding
> > sbi->s_lock. Readers such as writeback call exfat_map_cluster() with
> > s_lock held but without inode_lock, so they are not serialized against
> > the expansion and can observe the chain metadata mid-update.
> >
> > Hold s_lock around the cluster allocation, chain append and i_blocks
> > update. This nests inside the invalidate_lock held by
> > exfat_cont_expand(), matching the order used by exfat_truncate(). i_size
> > is published via exfat_pagecache_isize_extended(), which takes the
> > straddling folio lock; since writeback takes folio lock -> s_lock, this
> > must happen after s_lock is released to avoid inverting the lock order.
> > i_blocks is therefore updated first, under s_lock, which also ensures a
> > reader never sees i_size beyond the allocated chain.
> >
> > Signed-off-by: Youling Tang <tangyouling@xxxxxxxxxx>
>
> Looks good to me:
>
> Reviewed-by: Chi Zhiling <chizhiling@xxxxxxxxxx>
Applied it to #dev.
Thanks!