From: Darrick J. Wong Date: Mon, 9 Sep 2019 19:37:08 +0000 (-0400) Subject: xfs_repair: reduce the amount of "clearing reflink flag" messages X-Git-Tag: v5.3.0-rc2~120 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=904a5020dbcb15281c8bdc229cde83da65161984;p=thirdparty%2Fxfsprogs-dev.git xfs_repair: reduce the amount of "clearing reflink flag" messages Clearing the reflink flag on files that don't share blocks is an optimization, not a repair, so it's not critical to log a message every single time we clear a flag. Only log one message that we're clearing these flags unless verbose mode is enabled. Signed-off-by: Darrick J. Wong Reviewed-by: Dave Chinner Signed-off-by: Eric Sandeen --- diff --git a/repair/rmap.c b/repair/rmap.c index 5dd6557a0..b907383e7 100644 --- a/repair/rmap.c +++ b/repair/rmap.c @@ -1170,6 +1170,36 @@ record_inode_reflink_flag( (unsigned long long)lino, (unsigned long long)irec->ino_was_rl); } +/* + * Inform the user that we're clearing the reflink flag on an inode that + * doesn't actually share any blocks. This is an optimization (the kernel + * skips refcount checks for non-reflink files) and not a corruption repair, + * so we don't need to log every time we clear a flag unless verbose mode is + * enabled. + */ +static void +warn_clearing_reflink( + xfs_ino_t ino) +{ + static bool warned = false; + static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER; + + if (verbose) { + do_warn(_("clearing reflink flag on inode %"PRIu64"\n"), ino); + return; + } + + if (warned) + return; + + pthread_mutex_lock(&lock); + if (!warned) { + do_warn(_("clearing reflink flag on inodes when possible\n")); + warned = true; + } + pthread_mutex_unlock(&lock); +} + /* * Fix an inode's reflink flag. */ @@ -1188,9 +1218,7 @@ fix_inode_reflink_flag( _("setting reflink flag on inode %"PRIu64"\n"), XFS_AGINO_TO_INO(mp, agno, agino)); else if (!no_modify) /* && !set */ - do_warn( -_("clearing reflink flag on inode %"PRIu64"\n"), - XFS_AGINO_TO_INO(mp, agno, agino)); + warn_clearing_reflink(XFS_AGINO_TO_INO(mp, agno, agino)); if (no_modify) return 0;