@@ -952,6 +952,33 @@ _("wrong FS UUID, inode %" PRIu64 " attr block %" PRIu64 "\n"),
return 0;
}
+/*
+ * Zap the forw/back links in an attribute block. Be careful, because the
+ * root block could be an attr leaf block or a da node block.
+ */
+static inline void
+clear_attr_forw_back(
+ struct xfs_buf *bp,
+ struct xfs_attr3_icleaf_hdr *leafhdr)
+{
+ struct xfs_mount *mp = bp->b_mount;
+
+ if (leafhdr->magic == XFS_DA_NODE_MAGIC ||
+ leafhdr->magic == XFS_DA3_NODE_MAGIC) {
+ struct xfs_da3_icnode_hdr da3_hdr;
+
+ xfs_da3_node_hdr_from_disk(mp, &da3_hdr, bp->b_addr);
+ da3_hdr.forw = 0;
+ da3_hdr.back = 0;
+ xfs_da3_node_hdr_to_disk(mp, bp->b_addr, &da3_hdr);
+ return;
+ }
+
+ leafhdr->forw = 0;
+ leafhdr->back = 0;
+ xfs_attr3_leaf_hdr_to_disk(mp->m_attr_geo, bp->b_addr, leafhdr);
+}
+
/*
* Start processing for a leaf or fuller btree.
* A leaf directory is one where the attribute fork is too big for
@@ -1028,10 +1055,7 @@ process_longform_attr(
_("clearing forw/back pointers in block 0 for attributes in inode %" PRIu64 "\n"),
ino);
repairlinks = 1;
- leafhdr.forw = 0;
- leafhdr.back = 0;
- xfs_attr3_leaf_hdr_to_disk(mp->m_attr_geo,
- leaf, &leafhdr);
+ clear_attr_forw_back(bp, &leafhdr);
} else {
do_warn(
_("would clear forw/back pointers in block 0 for attributes in inode %" PRIu64 "\n"), ino);