From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: Eric Sandeen <sandeen@redhat.com>
Cc: matorola@gmail.com, xfs <linux-xfs@vger.kernel.org>
Subject: [PATCH] xfs_repair: take the ag_lock before recording rmap for a bmbt record
Date: Thu, 31 Aug 2017 13:12:55 -0700 [thread overview]
Message-ID: <20170831201255.GP3775@magnolia> (raw)
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>
---
repair/scan.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/repair/scan.c b/repair/scan.c
index 6c9f5e7..ccf60a6 100644
--- a/repair/scan.c
+++ b/repair/scan.c
@@ -386,7 +386,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."),
next reply other threads:[~2017-08-31 20:13 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-31 20:12 Darrick J. Wong [this message]
2017-09-01 11:40 ` [PATCH] xfs_repair: take the ag_lock before recording rmap for a bmbt record Carlos Maiolino
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170831201255.GP3775@magnolia \
--to=darrick.wong@oracle.com \
--cc=linux-xfs@vger.kernel.org \
--cc=matorola@gmail.com \
--cc=sandeen@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox