From 8f92bde008f2197631a337225e731e46a064eeff Mon Sep 17 00:00:00 2001 From: "Darrick J. Wong" Date: Fri, 11 Oct 2019 16:05:17 -0700 Subject: xfs: convert open coded corruption check to use XFS_CORRUPT_ON Convert the last of the open coded corruption check and report idioms to use the XFS_CORRUPT_ON macro. In a subsequent patch we are going to add health reporting to the code block under each corruption check, so we don't bother to clean out "{ return -EFSCORRUPTED; }". Signed-off-by: Darrick J. Wong --- fs/xfs/xfs_dir2_readdir.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'fs/xfs/xfs_dir2_readdir.c') diff --git a/fs/xfs/xfs_dir2_readdir.c b/fs/xfs/xfs_dir2_readdir.c index a0bec0931f3b..a516d83158d1 100644 --- a/fs/xfs/xfs_dir2_readdir.c +++ b/fs/xfs/xfs_dir2_readdir.c @@ -116,11 +116,9 @@ xfs_dir2_sf_getdents( ino = dp->d_ops->sf_get_ino(sfp, sfep); filetype = dp->d_ops->sf_get_ftype(sfep); ctx->pos = off & 0x7fffffff; - if (!xfs_dir2_namecheck(sfep->name, sfep->namelen)) { - XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_LOW, - dp->i_mount); + if (XFS_CORRUPT_ON(dp->i_mount, + !xfs_dir2_namecheck(sfep->name, sfep->namelen))) return -EFSCORRUPTED; - } if (!dir_emit(ctx, (char *)sfep->name, sfep->namelen, ino, xfs_dir3_get_dtype(dp->i_mount, filetype))) return 0; @@ -214,9 +212,8 @@ xfs_dir2_block_getdents( /* * If it didn't fit, set the final offset to here & return. */ - if (!xfs_dir2_namecheck(dep->name, dep->namelen)) { - XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_LOW, - dp->i_mount); + if (XFS_CORRUPT_ON(dp->i_mount, + !xfs_dir2_namecheck(dep->name, dep->namelen))) { error = -EFSCORRUPTED; goto out_rele; } @@ -467,9 +464,8 @@ xfs_dir2_leaf_getdents( filetype = dp->d_ops->data_get_ftype(dep); ctx->pos = xfs_dir2_byte_to_dataptr(curoff) & 0x7fffffff; - if (!xfs_dir2_namecheck(dep->name, dep->namelen)) { - XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_LOW, - dp->i_mount); + if (XFS_CORRUPT_ON(dp->i_mount, + !xfs_dir2_namecheck(dep->name, dep->namelen))) { error = -EFSCORRUPTED; break; } -- cgit v1.2.3