Skip to content

Commit 91fb423

Browse files
author
Darrick J. Wong
committed
xfs: metadata files can have xattrs if metadir is enabled
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 <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]>
1 parent 13af229 commit 91fb423

File tree

2 files changed

+26
-9
lines changed

2 files changed

+26
-9
lines changed

fs/xfs/scrub/common.c

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1245,12 +1245,6 @@ xchk_metadata_inode_forks(
12451245
return 0;
12461246
}
12471247

1248-
/* They also should never have extended attributes. */
1249-
if (xfs_inode_hasattr(sc->ip)) {
1250-
xchk_ino_set_corrupt(sc, sc->ip->i_ino);
1251-
return 0;
1252-
}
1253-
12541248
/* Invoke the data fork scrubber. */
12551249
error = xchk_metadata_inode_subtype(sc, XFS_SCRUB_TYPE_BMBTD);
12561250
if (error || (sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT))
@@ -1267,6 +1261,21 @@ xchk_metadata_inode_forks(
12671261
xchk_ino_set_corrupt(sc, sc->ip->i_ino);
12681262
}
12691263

1264+
/*
1265+
* Metadata files can only have extended attributes on metadir
1266+
* filesystems, either for parent pointers or for actual xattr data.
1267+
*/
1268+
if (xfs_inode_hasattr(sc->ip)) {
1269+
if (!xfs_has_metadir(sc->mp)) {
1270+
xchk_ino_set_corrupt(sc, sc->ip->i_ino);
1271+
return 0;
1272+
}
1273+
1274+
error = xchk_metadata_inode_subtype(sc, XFS_SCRUB_TYPE_BMBTA);
1275+
if (error || (sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT))
1276+
return error;
1277+
}
1278+
12701279
return 0;
12711280
}
12721281

fs/xfs/scrub/repair.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,7 +1082,12 @@ xrep_metadata_inode_forks(
10821082
if (error)
10831083
return error;
10841084

1085-
/* Make sure the attr fork looks ok before we delete it. */
1085+
/*
1086+
* Metadata files can only have extended attributes on metadir
1087+
* filesystems, either for parent pointers or for actual xattr data.
1088+
* For a non-metadir filesystem, make sure the attr fork looks ok
1089+
* before we delete it.
1090+
*/
10861091
if (xfs_inode_hasattr(sc->ip)) {
10871092
error = xrep_metadata_inode_subtype(sc, XFS_SCRUB_TYPE_BMBTA);
10881093
if (error)
@@ -1098,8 +1103,11 @@ xrep_metadata_inode_forks(
10981103
return error;
10991104
}
11001105

1101-
/* Clear the attr forks since metadata shouldn't have that. */
1102-
if (xfs_inode_hasattr(sc->ip)) {
1106+
/*
1107+
* Metadata files on non-metadir filesystems cannot have attr forks,
1108+
* so clear them now.
1109+
*/
1110+
if (xfs_inode_hasattr(sc->ip) && !xfs_has_metadir(sc->mp)) {
11031111
if (!dirty) {
11041112
dirty = true;
11051113
xfs_trans_ijoin(sc->tp, sc->ip, 0);

0 commit comments

Comments
 (0)