diff options
author | Darrick J. Wong <darrick.wong@oracle.com> | 2017-09-15 08:33:45 -0500 |
---|---|---|
committer | Eric Sandeen <sandeen@redhat.com> | 2017-09-15 08:33:45 -0500 |
commit | 5d52e7a5799c9843aef325e926a794638c48ad43 (patch) | |
tree | 21feec0e6205954fac7d0a7dace3899ae9047581 | |
parent | 9a106b5fbb88342f0ee02891d1bbb0e3c5a93d03 (diff) | |
download | xfsprogs-dev-5d52e7a5799c9843aef325e926a794638c48ad43.tar.gz |
xfs_repair: take the ag_lock before recording rmap for a bmbt record
When the (threaded) inode scanner iterates the blocks of a bmbt tree and
wants to record the bmbt blocks in the in-core rmap database, we have to
take the ag_lock for the AG that the bmbt block is in, or else we can
accidentally corrupt the rmap slab by calling slab_add from two threads.
Reported-by: matorola@gmail.com
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
-rw-r--r-- | repair/scan.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/repair/scan.c b/repair/scan.c index 447611ac37..9c0f2d6a10 100644 --- a/repair/scan.c +++ b/repair/scan.c @@ -383,7 +383,10 @@ _("bad state %d, inode %" PRIu64 " bmap block 0x%" PRIx64 "\n"), /* Record BMBT blocks in the reverse-mapping data. */ if (check_dups && collect_rmaps) { + agno = XFS_FSB_TO_AGNO(mp, bno); + pthread_mutex_lock(&ag_locks[agno].lock); error = rmap_add_bmbt_rec(mp, ino, whichfork, bno); + pthread_mutex_unlock(&ag_locks[agno].lock); if (error) do_error( _("couldn't add inode %"PRIu64" bmbt block %"PRIu64" reverse-mapping data."), |