From: Darrick J. Wong <darrick.wong@xxxxxxxxxx> Actually take the rt lock before updating the bitmap from multiple threads. This fixes an infrequent corruption problem when running generic/013 and rtinherit=1 is set on the root dir. Signed-off-by: Darrick J. Wong <darrick.wong@xxxxxxxxxx> --- repair/dinode.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/repair/dinode.c b/repair/dinode.c index 57013bf149b2..07f3f83aef8c 100644 --- a/repair/dinode.c +++ b/repair/dinode.c @@ -184,6 +184,7 @@ process_rt_rec( xfs_rfsblock_t *tot, int check_dups) { + struct aglock *lock = &ag_locks[(signed)NULLAGNUMBER]; xfs_fsblock_t b, lastb; xfs_rtblock_t ext; int state; @@ -245,6 +246,7 @@ _("data fork in rt ino %" PRIu64 " claims dup rt extent," continue; } + pthread_mutex_lock(&lock->lock); state = get_rtbmap(ext); switch (state) { case XR_E_FREE: @@ -270,6 +272,7 @@ _("data fork in rt inode %" PRIu64 " found metadata block %" PRIu64 " in rt bmap do_warn( _("data fork in rt inode %" PRIu64 " claims used rt block %" PRIu64 "\n"), ino, ext); + pthread_mutex_unlock(&lock->lock); return 1; case XR_E_FREE1: default: @@ -277,6 +280,7 @@ _("data fork in rt inode %" PRIu64 " claims used rt block %" PRIu64 "\n"), _("illegal state %d in rt block map %" PRIu64 "\n"), state, b); } + pthread_mutex_unlock(&lock->lock); } /*