Re: [PATCH] exfat: hold s_lock for cluster-chain updates in exfat_cont_expand()

From: Chi Zhiling

Date: Tue Nov 17 2026 - 20:43:06 EST


On 11/17/26 14:00, 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
cont_expand() and can observe the chain metadata mid-update.

Hold s_lock around the cluster allocation, chain append and i_blocks
update. 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.

Please resubmit based on the latest exfat/dev code.

Thanks.