]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs_db: don't allow label/uuid setting if the needsrepair flag is set
authorDarrick J. Wong <djwong@kernel.org>
Wed, 24 Feb 2021 00:09:28 +0000 (19:09 -0500)
committerEric Sandeen <sandeen@sandeen.net>
Wed, 24 Feb 2021 00:09:28 +0000 (19:09 -0500)
The NEEDSREPAIR flag can be set on filesystems where we /know/ that
there's something wrong with the metadata and want to force the sysadmin
to run xfs_repair before the next mount.  The goal here is to prevent
non-repair changes to a filesystem when we are confident of its
instability.  Normally we wouldn't bother with such safety checks for
the debugger, but the label and uuid functions can be called from
xfs_admin, so we should prevent these administrative tasks until the
filesystem can be repaired.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Allison Henderson <allison.henderson@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
db/sb.c

diff --git a/db/sb.c b/db/sb.c
index d7111e92a11a8f6fbdad4937de070918b58eac8c..cec7dce94bd4147d91625924d5a0e4636deac68e 100644 (file)
--- a/db/sb.c
+++ b/db/sb.c
@@ -379,6 +379,11 @@ uuid_f(
                                progname);
                        return 0;
                }
+               if (xfs_sb_version_needsrepair(&mp->m_sb)) {
+                       dbprintf(_("%s: filesystem needs xfs_repair\n"),
+                               progname);
+                       return 0;
+               }
 
                if (!strcasecmp(argv[1], "generate")) {
                        platform_uuid_generate(&uu);
@@ -543,6 +548,12 @@ label_f(
                        return 0;
                }
 
+               if (xfs_sb_version_needsrepair(&mp->m_sb)) {
+                       dbprintf(_("%s: filesystem needs xfs_repair\n"),
+                               progname);
+                       return 0;
+               }
+
                dbprintf(_("writing all SBs\n"));
                for (ag = 0; ag < mp->m_sb.sb_agcount; ag++)
                        if ((p = do_label(ag, argv[1])) == NULL) {