]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: check unused nlink fields in the ondisk inode
authorDarrick J. Wong <djwong@kernel.org>
Mon, 29 Jul 2024 23:22:40 +0000 (16:22 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Tue, 30 Jul 2024 00:01:00 +0000 (17:01 -0700)
Source kernel commit: 40cb8613d6122ca80a9e42e4cecc4d308c3b80fb

v2/v3 inodes use di_nlink and not di_onlink; and v1 inodes use di_onlink
and not di_nlink.  Whichever field is not in use, make sure its contents
are zero, and teach xfs_scrub to fix that if it is.

This clears a bunch of missing scrub failure errors in xfs/385 for
core.onlink.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
libxfs/xfs_inode_buf.c

index 82cf64db938cf0125d7facc03a17fed0fd154fe6..aee581d53c83a8a96a3ce222c739d08aeb7f8748 100644 (file)
@@ -488,6 +488,14 @@ xfs_dinode_verify(
                        return __this_address;
        }
 
+       if (dip->di_version > 1) {
+               if (dip->di_onlink)
+                       return __this_address;
+       } else {
+               if (dip->di_nlink)
+                       return __this_address;
+       }
+
        /* don't allow invalid i_size */
        di_size = be64_to_cpu(dip->di_size);
        if (di_size & (1ULL << 63))