xfs: do not use logged xattr updates on V4 filesystems
authorDarrick J. Wong <djwong@kernel.org>
Sun, 22 May 2022 22:41:03 +0000 (08:41 +1000)
committerDave Chinner <david@fromorbit.com>
Sun, 22 May 2022 22:41:03 +0000 (08:41 +1000)
V4 superblocks do not contain the log_incompat feature bit, which means
that we cannot protect xattr log items against kernels that are too old
to know how to recover them.  Turn off the log items for such
filesystems and adjust the "delayed" name to reflect what it's really
controlling.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
fs/xfs/libxfs/xfs_attr.c
fs/xfs/libxfs/xfs_attr.h

index 79615727f8c2ca745d4f173120af681cff2e6db0..9f14aca29ec40921e30f1c93dad3edcd5e285201 100644 (file)
@@ -982,7 +982,7 @@ xfs_attr_set(
        int                     error, local;
        int                     rmt_blks = 0;
        unsigned int            total;
-       int                     delayed = xfs_has_larp(mp);
+       bool                    use_logging = xfs_has_larp(mp);
 
        if (xfs_is_shutdown(dp->i_mount))
                return -EIO;
@@ -1027,7 +1027,7 @@ xfs_attr_set(
                rmt_blks = xfs_attr3_rmt_blocks(mp, XFS_XATTR_SIZE_MAX);
        }
 
-       if (delayed) {
+       if (use_logging) {
                error = xfs_attr_use_log_assist(mp);
                if (error)
                        return error;
@@ -1101,7 +1101,7 @@ xfs_attr_set(
 out_unlock:
        xfs_iunlock(dp, XFS_ILOCK_EXCL);
 drop_incompat:
-       if (delayed)
+       if (use_logging)
                xlog_drop_incompat_feat(mp->m_log);
        return error;
 
index b88b6d74e4fc922c6bddf03b12efce7999657fec..3cd9cbb68b0f42551eb68a932b0abfb9d542f320 100644 (file)
@@ -31,7 +31,8 @@ struct xfs_attr_list_context;
 static inline bool xfs_has_larp(struct xfs_mount *mp)
 {
 #ifdef DEBUG
-       return xfs_globals.larp;
+       /* Logged xattrs require a V5 super for log_incompat */
+       return xfs_has_crc(mp) && xfs_globals.larp;
 #else
        return false;
 #endif