Skip to content

Commit

Permalink
xfs: Nuke XFS_ERROR macro
Browse files Browse the repository at this point in the history
XFS_ERROR was designed long ago to trap return values, but it's not
runtime configurable, it's not consistently used, and we can do
similar error trapping with ftrace scripts and triggers from
userspace.

Just nuke XFS_ERROR and associated bits.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
  • Loading branch information
Eric Sandeen authored and Dave Chinner committed Jun 22, 2014
1 parent d99831f commit b474c7a
Show file tree
Hide file tree
Showing 45 changed files with 487 additions and 519 deletions.
10 changes: 5 additions & 5 deletions fs/xfs/xfs_aops.c
Original file line number Diff line number Diff line change
Expand Up @@ -308,14 +308,14 @@ xfs_map_blocks(
int nimaps = 1;

if (XFS_FORCED_SHUTDOWN(mp))
return -XFS_ERROR(EIO);
return -EIO;

if (type == XFS_IO_UNWRITTEN)
bmapi_flags |= XFS_BMAPI_IGSTATE;

if (!xfs_ilock_nowait(ip, XFS_ILOCK_SHARED)) {
if (nonblocking)
return -XFS_ERROR(EAGAIN);
return -EAGAIN;
xfs_ilock(ip, XFS_ILOCK_SHARED);
}

Expand All @@ -332,14 +332,14 @@ xfs_map_blocks(
xfs_iunlock(ip, XFS_ILOCK_SHARED);

if (error)
return -XFS_ERROR(error);
return -error;

if (type == XFS_IO_DELALLOC &&
(!nimaps || isnullstartblock(imap->br_startblock))) {
error = xfs_iomap_write_allocate(ip, offset, imap);
if (!error)
trace_xfs_map_blocks_alloc(ip, offset, count, type, imap);
return -XFS_ERROR(error);
return -error;
}

#ifdef DEBUG
Expand Down Expand Up @@ -1253,7 +1253,7 @@ __xfs_get_blocks(
int new = 0;

if (XFS_FORCED_SHUTDOWN(mp))
return -XFS_ERROR(EIO);
return -EIO;

offset = (xfs_off_t)iblock << inode->i_blkbits;
ASSERT(bh_result->b_size >= (1 << inode->i_blkbits));
Expand Down
6 changes: 3 additions & 3 deletions fs/xfs/xfs_attr.c
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ xfs_attr_remove(
xfs_trans_ijoin(args.trans, dp, 0);

if (!xfs_inode_hasattr(dp)) {
error = XFS_ERROR(ENOATTR);
error = ENOATTR;
} else if (dp->i_d.di_aformat == XFS_DINODE_FMT_LOCAL) {
ASSERT(dp->i_afp->if_flags & XFS_IFINLINE);
error = xfs_attr_shortform_remove(&args);
Expand Down Expand Up @@ -545,14 +545,14 @@ xfs_attr_shortform_addname(xfs_da_args_t *args)

if (args->namelen >= XFS_ATTR_SF_ENTSIZE_MAX ||
args->valuelen >= XFS_ATTR_SF_ENTSIZE_MAX)
return XFS_ERROR(ENOSPC);
return ENOSPC;

newsize = XFS_ATTR_SF_TOTSIZE(args->dp);
newsize += XFS_ATTR_SF_ENTSIZE_BYNAME(args->namelen, args->valuelen);

forkoff = xfs_attr_shortform_bytesfit(args->dp, newsize);
if (!forkoff)
return XFS_ERROR(ENOSPC);
return ENOSPC;

xfs_attr_shortform_add(args, forkoff);
return 0;
Expand Down
6 changes: 3 additions & 3 deletions fs/xfs/xfs_attr_inactive.c
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ xfs_attr3_node_inactive(
*/
if (level > XFS_DA_NODE_MAXDEPTH) {
xfs_trans_brelse(*trans, bp); /* no locks for later trans */
return XFS_ERROR(EIO);
return EIO;
}

node = bp->b_addr;
Expand Down Expand Up @@ -277,7 +277,7 @@ xfs_attr3_node_inactive(
child_bp);
break;
default:
error = XFS_ERROR(EIO);
error = EIO;
xfs_trans_brelse(*trans, child_bp);
break;
}
Expand Down Expand Up @@ -360,7 +360,7 @@ xfs_attr3_root_inactive(
error = xfs_attr3_leaf_inactive(trans, dp, bp);
break;
default:
error = XFS_ERROR(EIO);
error = EIO;
xfs_trans_brelse(*trans, bp);
break;
}
Expand Down
28 changes: 14 additions & 14 deletions fs/xfs/xfs_attr_leaf.c
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ xfs_attr_shortform_remove(xfs_da_args_t *args)
break;
}
if (i == end)
return XFS_ERROR(ENOATTR);
return ENOATTR;

/*
* Fix up the attribute fork data, covering the hole
Expand Down Expand Up @@ -611,9 +611,9 @@ xfs_attr_shortform_lookup(xfs_da_args_t *args)
continue;
if (!xfs_attr_namesp_match(args->flags, sfe->flags))
continue;
return XFS_ERROR(EEXIST);
return EEXIST;
}
return XFS_ERROR(ENOATTR);
return ENOATTR;
}

/*
Expand All @@ -640,18 +640,18 @@ xfs_attr_shortform_getvalue(xfs_da_args_t *args)
continue;
if (args->flags & ATTR_KERNOVAL) {
args->valuelen = sfe->valuelen;
return XFS_ERROR(EEXIST);
return EEXIST;
}
if (args->valuelen < sfe->valuelen) {
args->valuelen = sfe->valuelen;
return XFS_ERROR(ERANGE);
return ERANGE;
}
args->valuelen = sfe->valuelen;
memcpy(args->value, &sfe->nameval[args->namelen],
args->valuelen);
return XFS_ERROR(EEXIST);
return EEXIST;
}
return XFS_ERROR(ENOATTR);
return ENOATTR;
}

/*
Expand Down Expand Up @@ -1108,7 +1108,7 @@ xfs_attr3_leaf_add(
* no good and we should just give up.
*/
if (!ichdr.holes && sum < entsize)
return XFS_ERROR(ENOSPC);
return ENOSPC;

/*
* Compact the entries to coalesce free space.
Expand Down Expand Up @@ -2123,7 +2123,7 @@ xfs_attr3_leaf_lookup_int(
}
if (probe == ichdr.count || be32_to_cpu(entry->hashval) != hashval) {
args->index = probe;
return XFS_ERROR(ENOATTR);
return ENOATTR;
}

/*
Expand Down Expand Up @@ -2152,7 +2152,7 @@ xfs_attr3_leaf_lookup_int(
if (!xfs_attr_namesp_match(args->flags, entry->flags))
continue;
args->index = probe;
return XFS_ERROR(EEXIST);
return EEXIST;
} else {
name_rmt = xfs_attr3_leaf_name_remote(leaf, probe);
if (name_rmt->namelen != args->namelen)
Expand All @@ -2168,11 +2168,11 @@ xfs_attr3_leaf_lookup_int(
args->rmtblkcnt = xfs_attr3_rmt_blocks(
args->dp->i_mount,
args->rmtvaluelen);
return XFS_ERROR(EEXIST);
return EEXIST;
}
}
args->index = probe;
return XFS_ERROR(ENOATTR);
return ENOATTR;
}

/*
Expand Down Expand Up @@ -2208,7 +2208,7 @@ xfs_attr3_leaf_getvalue(
}
if (args->valuelen < valuelen) {
args->valuelen = valuelen;
return XFS_ERROR(ERANGE);
return ERANGE;
}
args->valuelen = valuelen;
memcpy(args->value, &name_loc->nameval[args->namelen], valuelen);
Expand All @@ -2226,7 +2226,7 @@ xfs_attr3_leaf_getvalue(
}
if (args->valuelen < args->rmtvaluelen) {
args->valuelen = args->rmtvaluelen;
return XFS_ERROR(ERANGE);
return ERANGE;
}
args->valuelen = args->rmtvaluelen;
}
Expand Down
14 changes: 7 additions & 7 deletions fs/xfs/xfs_attr_list.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context)
XFS_ERRLEVEL_LOW,
context->dp->i_mount, sfe);
kmem_free(sbuf);
return XFS_ERROR(EFSCORRUPTED);
return EFSCORRUPTED;
}

sbp->entno = i;
Expand Down Expand Up @@ -308,7 +308,7 @@ xfs_attr_node_list(xfs_attr_list_context_t *context)
context->dp->i_mount,
node);
xfs_trans_brelse(NULL, bp);
return XFS_ERROR(EFSCORRUPTED);
return EFSCORRUPTED;
}

dp->d_ops->node_hdr_from_disk(&nodehdr, node);
Expand Down Expand Up @@ -496,11 +496,11 @@ xfs_attr_leaf_list(xfs_attr_list_context_t *context)
context->cursor->blkno = 0;
error = xfs_attr3_leaf_read(NULL, context->dp, 0, -1, &bp);
if (error)
return XFS_ERROR(error);
return error;

error = xfs_attr3_leaf_list_int(bp, context);
xfs_trans_brelse(NULL, bp);
return XFS_ERROR(error);
return error;
}

int
Expand Down Expand Up @@ -616,16 +616,16 @@ xfs_attr_list(
* Validate the cursor.
*/
if (cursor->pad1 || cursor->pad2)
return XFS_ERROR(EINVAL);
return EINVAL;
if ((cursor->initted == 0) &&
(cursor->hashval || cursor->blkno || cursor->offset))
return XFS_ERROR(EINVAL);
return EINVAL;

/*
* Check for a properly aligned buffer.
*/
if (((long)buffer) & (sizeof(int)-1))
return XFS_ERROR(EFAULT);
return EFAULT;
if (flags & ATTR_KERNOVAL)
bufsize = 0;

Expand Down
Loading

0 comments on commit b474c7a

Please sign in to comment.