]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs_repair: reduce the amount of "clearing reflink flag" messages
authorDarrick J. Wong <darrick.wong@oracle.com>
Mon, 9 Sep 2019 19:37:08 +0000 (15:37 -0400)
committerEric Sandeen <sandeen@redhat.com>
Mon, 9 Sep 2019 19:37:08 +0000 (15:37 -0400)
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 <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
repair/rmap.c

index 5dd6557a01dcae2eb4df1479097dd538260a2e41..b907383e7222e65876f98e42a886bc9c73c7ae39 100644 (file)
@@ -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;