@@ -968,6 +968,22 @@ fsr_setup_attr_fork(
if (!(bstatp->bs_xflags & FS_XFLAG_HASATTR))
return 0;
+ /*
+ * If the filesystem has the ability to perform atomic extent swaps or
+ * has the reverse mapping btree enabled, the file extent swap
+ * implementation uses a higher level algorithm that calls into the
+ * bmap code instead of playing games with swapping the extent forks.
+ *
+ * The newer bmap implementation does not require specific values of
+ * bs_forkoff, unlike the old fork swap code. Therefore, leave the
+ * extended attributes alone if we know we're not using the old fork
+ * swap strategy. This eliminates a major source of runtime errors
+ * in fsr.
+ */
+ if (fsgeom.flags & (XFS_FSOP_GEOM_FLAGS_ATOMIC_SWAP |
+ XFS_FSOP_GEOM_FLAGS_RMAPBT))
+ return 0;
+
/*
* use the old method if we have attr1 or the kernel does not yet
* support passing the fork offset in the bulkstat data.