Re: [PATCH v3 10/11] xfs: Implement ->corrupted_range() for XFS

From: Christoph Hellwig
Date: Wed Feb 10 2021 - 08:45:08 EST



> + if (XFS_RMAP_NON_INODE_OWNER(rec->rm_owner) ||
> + (rec->rm_flags & (XFS_RMAP_ATTR_FORK | XFS_RMAP_BMBT_BLOCK))) {
> + // TODO check and try to fix metadata
> + rc = -EFSCORRUPTED;
> + xfs_force_shutdown(cur->bc_mp, SHUTDOWN_CORRUPT_META);

Just return early here so that we can avoid the else later.

> + /*
> + * Get files that incore, filter out others that are not in use.
> + */
> + rc = xfs_iget(cur->bc_mp, cur->bc_tp, rec->rm_owner,
> + XFS_IGET_INCORE, 0, &ip);

Can we rename rc to error?

> + if (rc || !ip)
> + return rc;

No need to check for ip here.

> + if (!VFS_I(ip)->i_mapping)
> + goto out;

This can't happen either.

> +
> + mapping = VFS_I(ip)->i_mapping;
> + if (IS_DAX(VFS_I(ip)))
> + rc = mf_dax_mapping_kill_procs(mapping, rec->rm_offset,
> + *flags);
> + else {
> + rc = -EIO;
> + mapping_set_error(mapping, rc);
> + }

By passing the method directly to the DAX device we should never get
this called for the non-DAX case.