if (error)
                return error;
  
 +      /* attr2 -> noattr2 */
 +      if (xfs_has_noattr2(new_mp)) {
 +              if (xfs_has_crc(mp)) {
 +                      xfs_warn(mp,
 +                      "attr2 is always enabled for a V5 filesystem - can't be changed.");
 +                      return -EINVAL;
 +              }
 +              mp->m_features &= ~XFS_FEAT_ATTR2;
 +              mp->m_features |= XFS_FEAT_NOATTR2;
 +      } else if (xfs_has_attr2(new_mp)) {
 +              /* noattr2 -> attr2 */
 +              mp->m_features &= ~XFS_FEAT_NOATTR2;
 +              mp->m_features |= XFS_FEAT_ATTR2;
 +      }
 +
+       /* Validate new max_atomic_write option before making other changes */
+       if (mp->m_awu_max_bytes != new_mp->m_awu_max_bytes) {
+               error = xfs_set_max_atomic_write_opt(mp,
+                               new_mp->m_awu_max_bytes);
+               if (error)
+                       return error;
+       }
+ 
        /* inode32 -> inode64 */
        if (xfs_has_small_inums(mp) && !xfs_has_small_inums(new_mp)) {
                mp->m_features &= ~XFS_FEAT_SMALL_INUMS;