]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs_repair: notify user if free inodes contain errors
authorEric Sandeen <sandeen@redhat.com>
Wed, 1 Aug 2018 22:06:44 +0000 (17:06 -0500)
committerEric Sandeen <sandeen@redhat.com>
Wed, 1 Aug 2018 22:06:44 +0000 (17:06 -0500)
xfs_repair checks allocated but unused (free) inodes in on-disk clusters,
and up until now silently repairs any errors, and as a result does not
alter exit status if errors are found.

The in-kernel verifiers will be noisy about these errors and instruct
the user to run repair, so it's best if repair is explicit about any
fixes it makes.

This shamelessly re-uses xfs_dinode_verify for this purpose.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
libxfs/libxfs_api_defs.h
repair/dinode.c

index a1a95a4839babde2f42ae9435631a01838261b57..d368eab3e36131386f21b228863e4d4a39f7a8d9 100644 (file)
 #define xfs_symlink_hdr_ok             libxfs_symlink_hdr_ok
 
 #define xfs_verify_cksum               libxfs_verify_cksum
+#define xfs_dinode_verify              libxfs_dinode_verify
 
 #define xfs_alloc_ag_max_usable                libxfs_alloc_ag_max_usable
 #define xfs_allocbt_maxrecs            libxfs_allocbt_maxrecs
index e3b0cdc9c9016ed60e7c869f6703fa52331a70e2..dc912cbd8493ac4afaf82669b3c4fa3e247b46ab 100644 (file)
@@ -2548,12 +2548,20 @@ _("bad (negative) size %" PRId64 " on inode %" PRIu64 "\n"),
                 */
                if (was_free) {
                        /*
-                        * easy case, inode free -- inode and map agree, clear
+                        * easy case, inode free -- inode and map agree, check
                         * it just in case to ensure that format, etc. are
                         * set correctly
                         */
-                       if (!no_modify)
-                               *dirty += clear_dinode(mp, dino, lino);
+                       if (libxfs_dinode_verify(mp, lino, dino) != NULL) {
+                               do_warn(
+ _("free inode %" PRIu64 " contains errors, "), lino);
+                               if (!no_modify) {
+                                       *dirty += clear_dinode(mp, dino, lino);
+                                       do_warn(_("corrected\n"));
+                               } else {
+                                       do_warn(_("would correct\n"));
+                               }
+                       }
                        *used = is_free;
                        return 0;
                }