On Tue, Jan 04, 2022 at 03:42:16PM -0800, Darrick J. Wong wrote: > From: Darrick J. Wong <djwong@xxxxxxxxxx> > > Online fsck depends on callers holding ILOCK_EXCL from the time they > decide to update a block mapping until after they've updated the reverse > mapping records to guarantee the stability of both mapping records. > Unfortunately, the quota code drops ILOCK_EXCL at the first transaction > roll in the dquot allocation process, which breaks that assertion. This > leads to sporadic failures in the online rmap repair code if the repair > code grabs the AGF after bmapi_write maps a new block into the quota > file's data fork but before it can finish the deferred rmap update. > > Fix this by rewriting the function to hold the ILOCK until after the > transaction commit like all other bmap updates do, and get rid of the > dqread wrapper that does nothing but complicate the codebase. > > Signed-off-by: Darrick J. Wong <djwong@xxxxxxxxxx> > --- > fs/xfs/xfs_dquot.c | 79 ++++++++++++++++++---------------------------------- > 1 file changed, 28 insertions(+), 51 deletions(-) Yup, much nicer. I was just pondering if I should clean up the weird transaction stuff when looking at the xfs_bmapi_write() call in this function, but now I don't have to :) Reviewed-by: Dave Chinner <dchinner@xxxxxxxxxx> -- Dave Chinner david@xxxxxxxxxxxxx