[PATCH 12/14] xfs: parse both remote attr name on-disk formats

Andrey Albershteyn
2024-12-29T13:39:11Z

The new format has ->crc[2] field. This field is overlapped with
anything what is before this remote attr name, for filesystems
without dxattr.

Signed-off-by: Andrey Albershteyn <aalbersh@kernel.org>
---
fs/xfs/libxfs/xfs_da_format.h | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/fs/xfs/libxfs/xfs_da_format.h b/fs/xfs/libxfs/xfs_da_format.h
index bf0f73624446..4034530ad023 100644
--- a/fs/xfs/libxfs/xfs_da_format.h
+++ b/fs/xfs/libxfs/xfs_da_format.h
@@ -781,7 +781,13 @@ xfs_attr3_leaf_name_remote(
xfs_attr_leafblock_t *leafp,
int idx)
{
- return (xfs_attr_leaf_name_remote_t *)xfs_attr3_leaf_name(leafp, idx);
+ char *leaf = xfs_attr3_leaf_name(leafp, idx);
+ /* Overlap xfs_attr_leaf_name_remote_t with anything which is before.
+ * The overlap is created by ->crc[2] and is not used for filesystem
+ * without DXATTR. */
+ if (!xfs_sb_has_incompat_feature(sb, XFS_SB_FEAT_INCOMPAT_DXATTR))
+ return (xfs_attr_leaf_name_remote_t *)(leaf - 2*sizeof(__be32));
+ return (xfs_attr_leaf_name_remote_t *)leaf;
}

static inline xfs_attr_leaf_name_local_t *
--
2.47.0