On Fri, May 10, 2024 at 05:34:26PM -0700, Wengang Wang wrote: You might want to lead off with the origins of this fixpatch: "A user with a completely full filesystem experienced an unexpected shutdown when the filesystem tried to write the superblock during runtime:" <dmesg dump here> "When xfs_log_sb writes a superblock to disk, sb_fdblocks is fetched..." (or so I'm guessing from the other replies in this thread?) ((What was it doing? Adding the ATTR/ATTR2 feature to the filesystem?)) > when writting super block to disk (in xfs_log_sb), sb_fdblocks is fetched from > m_fdblocks without any lock. As m_fdblocks can experience a positive -> negativ "negative" > -> positive changing when the FS reaches fullness (see xfs_mod_fdblocks) > So there is a chance that sb_fdblocks is negative, and because sb_fdblocks is > type of unsigned long long, it reads super big. And sb_fdblocks being bigger > than sb_dblocks is a problem during log recovery, xfs_validate_sb_write() > complains. > > Fix: > As sb_fdblocks will be re-calculated during mount when lazysbcount is enabled, > We just need to make xfs_validate_sb_write() happy -- make sure sb_fdblocks is > not genative. "negative". This otherwise looks good to me. --D > Signed-off-by: Wengang Wang <wen.gang.wang@xxxxxxxxxx> > --- > fs/xfs/libxfs/xfs_sb.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/fs/xfs/libxfs/xfs_sb.c b/fs/xfs/libxfs/xfs_sb.c > index 73a4b895de67..199756970383 100644 > --- a/fs/xfs/libxfs/xfs_sb.c > +++ b/fs/xfs/libxfs/xfs_sb.c > @@ -1037,7 +1037,7 @@ xfs_log_sb( > mp->m_sb.sb_ifree = min_t(uint64_t, > percpu_counter_sum(&mp->m_ifree), > mp->m_sb.sb_icount); > - mp->m_sb.sb_fdblocks = percpu_counter_sum(&mp->m_fdblocks); > + mp->m_sb.sb_fdblocks = percpu_counter_sum_positive(&mp->m_fdblocks); > } > > xfs_sb_to_disk(bp->b_addr, &mp->m_sb); > -- > 2.39.3 (Apple Git-146) > >