diff options
author | Darrick J. Wong <darrick.wong@oracle.com> | 2019-10-11 16:05:17 -0700 |
---|---|---|
committer | Darrick J. Wong <darrick.wong@oracle.com> | 2019-11-22 21:35:05 -0800 |
commit | 8f92bde008f2197631a337225e731e46a064eeff (patch) | |
tree | c66005c21b496ee0e0815c49043c3d4b179a2d67 /fs/xfs/xfs_dir2_readdir.c | |
parent | 2e82c02cafbb8d14a50ee9c14f67d66f1b1e0b38 (diff) |
xfs: convert open coded corruption check to use XFS_CORRUPT_ONrefactor-corruption-checks_2019-11-22
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 <darrick.wong@oracle.com>
Diffstat (limited to 'fs/xfs/xfs_dir2_readdir.c')
-rw-r--r-- | fs/xfs/xfs_dir2_readdir.c | 16 |
1 files changed, 6 insertions, 10 deletions
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; } |