Skip to content

Commit c6c56ff

Browse files
Long Licmaiolino
authored andcommitted
xfs: remove redundant validation in xlog_recover_attri_commit_pass2
Remove the redundant post-parse validation switch. By the time that block is reached, xfs_attri_validate() has already guaranteed all name lengths are non-zero via xfs_attri_validate_namelen(), and xfs_attri_validate_name_iovec() has already returned -EFSCORRUPTED for NULL names. For the REMOVE case, attr_value and value_len are structurally guaranteed to be NULL/zero because the parsing loop only populates them when value_len != 0. All checks in that switch are therefore dead code. Reviewed-by: Darrick J. Wong <[email protected]> Signed-off-by: Long Li <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Signed-off-by: Carlos Maiolino <[email protected]>
1 parent d72f208 commit c6c56ff

1 file changed

Lines changed: 0 additions & 46 deletions

File tree

fs/xfs/xfs_attr_item.c

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1132,52 +1132,6 @@ xlog_recover_attri_commit_pass2(
11321132
return -EFSCORRUPTED;
11331133
}
11341134

1135-
switch (op) {
1136-
case XFS_ATTRI_OP_FLAGS_REMOVE:
1137-
/* Regular remove operations operate only on names. */
1138-
if (attr_value != NULL || value_len != 0) {
1139-
XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp,
1140-
attri_formatp, len);
1141-
return -EFSCORRUPTED;
1142-
}
1143-
fallthrough;
1144-
case XFS_ATTRI_OP_FLAGS_PPTR_REMOVE:
1145-
case XFS_ATTRI_OP_FLAGS_PPTR_SET:
1146-
case XFS_ATTRI_OP_FLAGS_SET:
1147-
case XFS_ATTRI_OP_FLAGS_REPLACE:
1148-
/*
1149-
* Regular xattr set/remove/replace operations require a name
1150-
* and do not take a newname. Values are optional for set and
1151-
* replace.
1152-
*
1153-
* Name-value set/remove operations must have a name, do not
1154-
* take a newname, and can take a value.
1155-
*/
1156-
if (attr_name == NULL || name_len == 0) {
1157-
XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp,
1158-
attri_formatp, len);
1159-
return -EFSCORRUPTED;
1160-
}
1161-
break;
1162-
case XFS_ATTRI_OP_FLAGS_PPTR_REPLACE:
1163-
/*
1164-
* Name-value replace operations require the caller to
1165-
* specify the old and new names and values explicitly.
1166-
* Values are optional.
1167-
*/
1168-
if (attr_name == NULL || name_len == 0) {
1169-
XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp,
1170-
attri_formatp, len);
1171-
return -EFSCORRUPTED;
1172-
}
1173-
if (attr_new_name == NULL || new_name_len == 0) {
1174-
XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp,
1175-
attri_formatp, len);
1176-
return -EFSCORRUPTED;
1177-
}
1178-
break;
1179-
}
1180-
11811135
/*
11821136
* Memory alloc failure will cause replay to abort. We attach the
11831137
* name/value buffer to the recovered incore log item and drop our

0 commit comments

Comments
 (0)