]> www.infradead.org Git - users/hch/xfs.git/commitdiff
xfs: metadata files can have xattrs if metadir is enabled
authorDarrick J. Wong <djwong@kernel.org>
Wed, 7 Aug 2024 22:54:21 +0000 (15:54 -0700)
committerChristoph Hellwig <hch@lst.de>
Sun, 22 Sep 2024 06:07:20 +0000 (08:07 +0200)
If parent pointers are enabled, then metadata files will store parent
pointers in xattrs, just like files in the user visible directory tree.
Therefore, scrub and repair need to handle attr forks for metadata files
on metadir filesystems.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
fs/xfs/scrub/common.c
fs/xfs/scrub/repair.c

index a1e67b0f745f358b9a3bf43a9f2b3858c3adc0a8..671aca616f11ea68e80b1baa16d00da08c426b70 100644 (file)
@@ -1245,12 +1245,6 @@ xchk_metadata_inode_forks(
                return 0;
        }
 
-       /* They also should never have extended attributes. */
-       if (xfs_inode_hasattr(sc->ip)) {
-               xchk_ino_set_corrupt(sc, sc->ip->i_ino);
-               return 0;
-       }
-
        /* Invoke the data fork scrubber. */
        error = xchk_metadata_inode_subtype(sc, XFS_SCRUB_TYPE_BMBTD);
        if (error || (sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT))
@@ -1267,6 +1261,21 @@ xchk_metadata_inode_forks(
                        xchk_ino_set_corrupt(sc, sc->ip->i_ino);
        }
 
+       /*
+        * Metadata files can only have extended attributes on metadir
+        * filesystems, either for parent pointers or for actual xattr data.
+        */
+       if (xfs_inode_hasattr(sc->ip)) {
+               if (!xfs_has_metadir(sc->mp)) {
+                       xchk_ino_set_corrupt(sc, sc->ip->i_ino);
+                       return 0;
+               }
+
+               error = xchk_metadata_inode_subtype(sc, XFS_SCRUB_TYPE_BMBTA);
+               if (error || (sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT))
+                       return error;
+       }
+
        return 0;
 }
 
index 646ac8ade88d0b60a9124131655bc71862109b86..f80000d775524294de87524e4740a2754470c5af 100644 (file)
@@ -1082,7 +1082,12 @@ xrep_metadata_inode_forks(
        if (error)
                return error;
 
-       /* Make sure the attr fork looks ok before we delete it. */
+       /*
+        * Metadata files can only have extended attributes on metadir
+        * filesystems, either for parent pointers or for actual xattr data.
+        * For a non-metadir filesystem, make sure the attr fork looks ok
+        * before we delete it.
+        */
        if (xfs_inode_hasattr(sc->ip)) {
                error = xrep_metadata_inode_subtype(sc, XFS_SCRUB_TYPE_BMBTA);
                if (error)
@@ -1098,8 +1103,11 @@ xrep_metadata_inode_forks(
                        return error;
        }
 
-       /* Clear the attr forks since metadata shouldn't have that. */
-       if (xfs_inode_hasattr(sc->ip)) {
+       /*
+        * Metadata files on non-metadir filesystems cannot have attr forks,
+        * so clear them now.
+        */
+       if (xfs_inode_hasattr(sc->ip) && !xfs_has_metadir(sc->mp)) {
                if (!dirty) {
                        dirty = true;
                        xfs_trans_ijoin(sc->tp, sc->ip, 0);