提交 7f8a058f 编写于 作者: D Dave Chinner

Merge branch 'xfs-libxfs-restructure' into for-next

...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
# #
ccflags-y += -I$(src) # needed for trace events ccflags-y += -I$(src) # needed for trace events
ccflags-y += -I$(src)/libxfs
ccflags-$(CONFIG_XFS_DEBUG) += -g ccflags-$(CONFIG_XFS_DEBUG) += -g
...@@ -25,6 +26,39 @@ obj-$(CONFIG_XFS_FS) += xfs.o ...@@ -25,6 +26,39 @@ obj-$(CONFIG_XFS_FS) += xfs.o
# this one should be compiled first, as the tracing macros can easily blow up # this one should be compiled first, as the tracing macros can easily blow up
xfs-y += xfs_trace.o xfs-y += xfs_trace.o
# build the libxfs code first
xfs-y += $(addprefix libxfs/, \
xfs_alloc.o \
xfs_alloc_btree.o \
xfs_attr.o \
xfs_attr_leaf.o \
xfs_attr_remote.o \
xfs_bmap.o \
xfs_bmap_btree.o \
xfs_btree.o \
xfs_da_btree.o \
xfs_da_format.o \
xfs_dir2.o \
xfs_dir2_block.o \
xfs_dir2_data.o \
xfs_dir2_leaf.o \
xfs_dir2_node.o \
xfs_dir2_sf.o \
xfs_dquot_buf.o \
xfs_ialloc.o \
xfs_ialloc_btree.o \
xfs_inode_fork.o \
xfs_inode_buf.o \
xfs_log_rlimit.o \
xfs_sb.o \
xfs_symlink_remote.o \
xfs_trans_resv.o \
)
# xfs_rtbitmap is shared with libxfs
xfs-$(CONFIG_XFS_RT) += $(addprefix libxfs/, \
xfs_rtbitmap.o \
)
# highlevel code # highlevel code
xfs-y += xfs_aops.o \ xfs-y += xfs_aops.o \
xfs_attr_inactive.o \ xfs_attr_inactive.o \
...@@ -45,6 +79,7 @@ xfs-y += xfs_aops.o \ ...@@ -45,6 +79,7 @@ xfs-y += xfs_aops.o \
xfs_ioctl.o \ xfs_ioctl.o \
xfs_iomap.o \ xfs_iomap.o \
xfs_iops.o \ xfs_iops.o \
xfs_inode.o \
xfs_itable.o \ xfs_itable.o \
xfs_message.o \ xfs_message.o \
xfs_mount.o \ xfs_mount.o \
...@@ -56,42 +91,14 @@ xfs-y += xfs_aops.o \ ...@@ -56,42 +91,14 @@ xfs-y += xfs_aops.o \
kmem.o \ kmem.o \
uuid.o uuid.o
# code shared with libxfs
xfs-y += xfs_alloc.o \
xfs_alloc_btree.o \
xfs_attr.o \
xfs_attr_leaf.o \
xfs_attr_remote.o \
xfs_bmap.o \
xfs_bmap_btree.o \
xfs_btree.o \
xfs_da_btree.o \
xfs_da_format.o \
xfs_dir2.o \
xfs_dir2_block.o \
xfs_dir2_data.o \
xfs_dir2_leaf.o \
xfs_dir2_node.o \
xfs_dir2_sf.o \
xfs_dquot_buf.o \
xfs_ialloc.o \
xfs_ialloc_btree.o \
xfs_icreate_item.o \
xfs_inode.o \
xfs_inode_fork.o \
xfs_inode_buf.o \
xfs_log_recover.o \
xfs_log_rlimit.o \
xfs_sb.o \
xfs_symlink_remote.o \
xfs_trans_resv.o
# low-level transaction/log code # low-level transaction/log code
xfs-y += xfs_log.o \ xfs-y += xfs_log.o \
xfs_log_cil.o \ xfs_log_cil.o \
xfs_buf_item.o \ xfs_buf_item.o \
xfs_extfree_item.o \ xfs_extfree_item.o \
xfs_icreate_item.o \
xfs_inode_item.o \ xfs_inode_item.o \
xfs_log_recover.o \
xfs_trans_ail.o \ xfs_trans_ail.o \
xfs_trans_buf.o \ xfs_trans_buf.o \
xfs_trans_extfree.o \ xfs_trans_extfree.o \
...@@ -107,8 +114,7 @@ xfs-$(CONFIG_XFS_QUOTA) += xfs_dquot.o \ ...@@ -107,8 +114,7 @@ xfs-$(CONFIG_XFS_QUOTA) += xfs_dquot.o \
xfs_quotaops.o xfs_quotaops.o
# xfs_rtbitmap is shared with libxfs # xfs_rtbitmap is shared with libxfs
xfs-$(CONFIG_XFS_RT) += xfs_rtalloc.o \ xfs-$(CONFIG_XFS_RT) += xfs_rtalloc.o
xfs_rtbitmap.o
xfs-$(CONFIG_XFS_POSIX_ACL) += xfs_acl.o xfs-$(CONFIG_XFS_POSIX_ACL) += xfs_acl.o
xfs-$(CONFIG_PROC_FS) += xfs_stats.o xfs-$(CONFIG_PROC_FS) += xfs_stats.o
......
...@@ -483,9 +483,9 @@ xfs_agfl_read_verify( ...@@ -483,9 +483,9 @@ xfs_agfl_read_verify(
return; return;
if (!xfs_buf_verify_cksum(bp, XFS_AGFL_CRC_OFF)) if (!xfs_buf_verify_cksum(bp, XFS_AGFL_CRC_OFF))
xfs_buf_ioerror(bp, EFSBADCRC); xfs_buf_ioerror(bp, -EFSBADCRC);
else if (!xfs_agfl_verify(bp)) else if (!xfs_agfl_verify(bp))
xfs_buf_ioerror(bp, EFSCORRUPTED); xfs_buf_ioerror(bp, -EFSCORRUPTED);
if (bp->b_error) if (bp->b_error)
xfs_verifier_error(bp); xfs_verifier_error(bp);
...@@ -503,7 +503,7 @@ xfs_agfl_write_verify( ...@@ -503,7 +503,7 @@ xfs_agfl_write_verify(
return; return;
if (!xfs_agfl_verify(bp)) { if (!xfs_agfl_verify(bp)) {
xfs_buf_ioerror(bp, EFSCORRUPTED); xfs_buf_ioerror(bp, -EFSCORRUPTED);
xfs_verifier_error(bp); xfs_verifier_error(bp);
return; return;
} }
...@@ -559,7 +559,7 @@ xfs_alloc_update_counters( ...@@ -559,7 +559,7 @@ xfs_alloc_update_counters(
xfs_trans_agblocks_delta(tp, len); xfs_trans_agblocks_delta(tp, len);
if (unlikely(be32_to_cpu(agf->agf_freeblks) > if (unlikely(be32_to_cpu(agf->agf_freeblks) >
be32_to_cpu(agf->agf_length))) be32_to_cpu(agf->agf_length)))
return EFSCORRUPTED; return -EFSCORRUPTED;
xfs_alloc_log_agf(tp, agbp, XFS_AGF_FREEBLKS); xfs_alloc_log_agf(tp, agbp, XFS_AGF_FREEBLKS);
return 0; return 0;
...@@ -2234,11 +2234,11 @@ xfs_agf_read_verify( ...@@ -2234,11 +2234,11 @@ xfs_agf_read_verify(
if (xfs_sb_version_hascrc(&mp->m_sb) && if (xfs_sb_version_hascrc(&mp->m_sb) &&
!xfs_buf_verify_cksum(bp, XFS_AGF_CRC_OFF)) !xfs_buf_verify_cksum(bp, XFS_AGF_CRC_OFF))
xfs_buf_ioerror(bp, EFSBADCRC); xfs_buf_ioerror(bp, -EFSBADCRC);
else if (XFS_TEST_ERROR(!xfs_agf_verify(mp, bp), mp, else if (XFS_TEST_ERROR(!xfs_agf_verify(mp, bp), mp,
XFS_ERRTAG_ALLOC_READ_AGF, XFS_ERRTAG_ALLOC_READ_AGF,
XFS_RANDOM_ALLOC_READ_AGF)) XFS_RANDOM_ALLOC_READ_AGF))
xfs_buf_ioerror(bp, EFSCORRUPTED); xfs_buf_ioerror(bp, -EFSCORRUPTED);
if (bp->b_error) if (bp->b_error)
xfs_verifier_error(bp); xfs_verifier_error(bp);
...@@ -2252,7 +2252,7 @@ xfs_agf_write_verify( ...@@ -2252,7 +2252,7 @@ xfs_agf_write_verify(
struct xfs_buf_log_item *bip = bp->b_fspriv; struct xfs_buf_log_item *bip = bp->b_fspriv;
if (!xfs_agf_verify(mp, bp)) { if (!xfs_agf_verify(mp, bp)) {
xfs_buf_ioerror(bp, EFSCORRUPTED); xfs_buf_ioerror(bp, -EFSCORRUPTED);
xfs_verifier_error(bp); xfs_verifier_error(bp);
return; return;
} }
...@@ -2601,11 +2601,11 @@ xfs_free_extent( ...@@ -2601,11 +2601,11 @@ xfs_free_extent(
*/ */
args.agno = XFS_FSB_TO_AGNO(args.mp, bno); args.agno = XFS_FSB_TO_AGNO(args.mp, bno);
if (args.agno >= args.mp->m_sb.sb_agcount) if (args.agno >= args.mp->m_sb.sb_agcount)
return EFSCORRUPTED; return -EFSCORRUPTED;
args.agbno = XFS_FSB_TO_AGBNO(args.mp, bno); args.agbno = XFS_FSB_TO_AGBNO(args.mp, bno);
if (args.agbno >= args.mp->m_sb.sb_agblocks) if (args.agbno >= args.mp->m_sb.sb_agblocks)
return EFSCORRUPTED; return -EFSCORRUPTED;
args.pag = xfs_perag_get(args.mp, args.agno); args.pag = xfs_perag_get(args.mp, args.agno);
ASSERT(args.pag); ASSERT(args.pag);
...@@ -2617,7 +2617,7 @@ xfs_free_extent( ...@@ -2617,7 +2617,7 @@ xfs_free_extent(
/* validate the extent size is legal now we have the agf locked */ /* validate the extent size is legal now we have the agf locked */
if (args.agbno + len > if (args.agbno + len >
be32_to_cpu(XFS_BUF_TO_AGF(args.agbp)->agf_length)) { be32_to_cpu(XFS_BUF_TO_AGF(args.agbp)->agf_length)) {
error = EFSCORRUPTED; error = -EFSCORRUPTED;
goto error0; goto error0;
} }
......
...@@ -355,9 +355,9 @@ xfs_allocbt_read_verify( ...@@ -355,9 +355,9 @@ xfs_allocbt_read_verify(
struct xfs_buf *bp) struct xfs_buf *bp)
{ {
if (!xfs_btree_sblock_verify_crc(bp)) if (!xfs_btree_sblock_verify_crc(bp))
xfs_buf_ioerror(bp, EFSBADCRC); xfs_buf_ioerror(bp, -EFSBADCRC);
else if (!xfs_allocbt_verify(bp)) else if (!xfs_allocbt_verify(bp))
xfs_buf_ioerror(bp, EFSCORRUPTED); xfs_buf_ioerror(bp, -EFSCORRUPTED);
if (bp->b_error) { if (bp->b_error) {
trace_xfs_btree_corrupt(bp, _RET_IP_); trace_xfs_btree_corrupt(bp, _RET_IP_);
...@@ -371,7 +371,7 @@ xfs_allocbt_write_verify( ...@@ -371,7 +371,7 @@ xfs_allocbt_write_verify(
{ {
if (!xfs_allocbt_verify(bp)) { if (!xfs_allocbt_verify(bp)) {
trace_xfs_btree_corrupt(bp, _RET_IP_); trace_xfs_btree_corrupt(bp, _RET_IP_);
xfs_buf_ioerror(bp, EFSCORRUPTED); xfs_buf_ioerror(bp, -EFSCORRUPTED);
xfs_verifier_error(bp); xfs_verifier_error(bp);
return; return;
} }
......
...@@ -85,7 +85,7 @@ xfs_attr_args_init( ...@@ -85,7 +85,7 @@ xfs_attr_args_init(
{ {
if (!name) if (!name)
return EINVAL; return -EINVAL;
memset(args, 0, sizeof(*args)); memset(args, 0, sizeof(*args));
args->geo = dp->i_mount->m_attr_geo; args->geo = dp->i_mount->m_attr_geo;
...@@ -95,7 +95,7 @@ xfs_attr_args_init( ...@@ -95,7 +95,7 @@ xfs_attr_args_init(
args->name = name; args->name = name;
args->namelen = strlen((const char *)name); args->namelen = strlen((const char *)name);
if (args->namelen >= MAXNAMELEN) if (args->namelen >= MAXNAMELEN)
return EFAULT; /* match IRIX behaviour */ return -EFAULT; /* match IRIX behaviour */
args->hashval = xfs_da_hashname(args->name, args->namelen); args->hashval = xfs_da_hashname(args->name, args->namelen);
return 0; return 0;
...@@ -131,10 +131,10 @@ xfs_attr_get( ...@@ -131,10 +131,10 @@ xfs_attr_get(
XFS_STATS_INC(xs_attr_get); XFS_STATS_INC(xs_attr_get);
if (XFS_FORCED_SHUTDOWN(ip->i_mount)) if (XFS_FORCED_SHUTDOWN(ip->i_mount))
return EIO; return -EIO;
if (!xfs_inode_hasattr(ip)) if (!xfs_inode_hasattr(ip))
return ENOATTR; return -ENOATTR;
error = xfs_attr_args_init(&args, ip, name, flags); error = xfs_attr_args_init(&args, ip, name, flags);
if (error) if (error)
...@@ -145,7 +145,7 @@ xfs_attr_get( ...@@ -145,7 +145,7 @@ xfs_attr_get(
lock_mode = xfs_ilock_attr_map_shared(ip); lock_mode = xfs_ilock_attr_map_shared(ip);
if (!xfs_inode_hasattr(ip)) if (!xfs_inode_hasattr(ip))
error = ENOATTR; error = -ENOATTR;
else if (ip->i_d.di_aformat == XFS_DINODE_FMT_LOCAL) else if (ip->i_d.di_aformat == XFS_DINODE_FMT_LOCAL)
error = xfs_attr_shortform_getvalue(&args); error = xfs_attr_shortform_getvalue(&args);
else if (xfs_bmap_one_block(ip, XFS_ATTR_FORK)) else if (xfs_bmap_one_block(ip, XFS_ATTR_FORK))
...@@ -155,7 +155,7 @@ xfs_attr_get( ...@@ -155,7 +155,7 @@ xfs_attr_get(
xfs_iunlock(ip, lock_mode); xfs_iunlock(ip, lock_mode);
*valuelenp = args.valuelen; *valuelenp = args.valuelen;
return error == EEXIST ? 0 : error; return error == -EEXIST ? 0 : error;
} }
/* /*
...@@ -213,7 +213,7 @@ xfs_attr_set( ...@@ -213,7 +213,7 @@ xfs_attr_set(
XFS_STATS_INC(xs_attr_set); XFS_STATS_INC(xs_attr_set);
if (XFS_FORCED_SHUTDOWN(dp->i_mount)) if (XFS_FORCED_SHUTDOWN(dp->i_mount))
return EIO; return -EIO;
error = xfs_attr_args_init(&args, dp, name, flags); error = xfs_attr_args_init(&args, dp, name, flags);
if (error) if (error)
...@@ -304,7 +304,7 @@ xfs_attr_set( ...@@ -304,7 +304,7 @@ xfs_attr_set(
* the inode. * the inode.
*/ */
error = xfs_attr_shortform_addname(&args); error = xfs_attr_shortform_addname(&args);
if (error != ENOSPC) { if (error != -ENOSPC) {
/* /*
* Commit the shortform mods, and we're done. * Commit the shortform mods, and we're done.
* NOTE: this is also the error path (EEXIST, etc). * NOTE: this is also the error path (EEXIST, etc).
...@@ -419,10 +419,10 @@ xfs_attr_remove( ...@@ -419,10 +419,10 @@ xfs_attr_remove(
XFS_STATS_INC(xs_attr_remove); XFS_STATS_INC(xs_attr_remove);
if (XFS_FORCED_SHUTDOWN(dp->i_mount)) if (XFS_FORCED_SHUTDOWN(dp->i_mount))
return EIO; return -EIO;
if (!xfs_inode_hasattr(dp)) if (!xfs_inode_hasattr(dp))
return ENOATTR; return -ENOATTR;
error = xfs_attr_args_init(&args, dp, name, flags); error = xfs_attr_args_init(&args, dp, name, flags);
if (error) if (error)
...@@ -477,7 +477,7 @@ xfs_attr_remove( ...@@ -477,7 +477,7 @@ xfs_attr_remove(
xfs_trans_ijoin(args.trans, dp, 0); xfs_trans_ijoin(args.trans, dp, 0);
if (!xfs_inode_hasattr(dp)) { if (!xfs_inode_hasattr(dp)) {
error = XFS_ERROR(ENOATTR); error = -ENOATTR;
} else if (dp->i_d.di_aformat == XFS_DINODE_FMT_LOCAL) { } else if (dp->i_d.di_aformat == XFS_DINODE_FMT_LOCAL) {
ASSERT(dp->i_afp->if_flags & XFS_IFINLINE); ASSERT(dp->i_afp->if_flags & XFS_IFINLINE);
error = xfs_attr_shortform_remove(&args); error = xfs_attr_shortform_remove(&args);
...@@ -534,28 +534,28 @@ xfs_attr_shortform_addname(xfs_da_args_t *args) ...@@ -534,28 +534,28 @@ xfs_attr_shortform_addname(xfs_da_args_t *args)
trace_xfs_attr_sf_addname(args); trace_xfs_attr_sf_addname(args);
retval = xfs_attr_shortform_lookup(args); retval = xfs_attr_shortform_lookup(args);
if ((args->flags & ATTR_REPLACE) && (retval == ENOATTR)) { if ((args->flags & ATTR_REPLACE) && (retval == -ENOATTR)) {
return(retval); return retval;
} else if (retval == EEXIST) { } else if (retval == -EEXIST) {
if (args->flags & ATTR_CREATE) if (args->flags & ATTR_CREATE)
return(retval); return retval;
retval = xfs_attr_shortform_remove(args); retval = xfs_attr_shortform_remove(args);
ASSERT(retval == 0); ASSERT(retval == 0);
} }
if (args->namelen >= XFS_ATTR_SF_ENTSIZE_MAX || if (args->namelen >= XFS_ATTR_SF_ENTSIZE_MAX ||
args->valuelen >= 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_TOTSIZE(args->dp);
newsize += XFS_ATTR_SF_ENTSIZE_BYNAME(args->namelen, args->valuelen); newsize += XFS_ATTR_SF_ENTSIZE_BYNAME(args->namelen, args->valuelen);
forkoff = xfs_attr_shortform_bytesfit(args->dp, newsize); forkoff = xfs_attr_shortform_bytesfit(args->dp, newsize);
if (!forkoff) if (!forkoff)
return(XFS_ERROR(ENOSPC)); return -ENOSPC;
xfs_attr_shortform_add(args, forkoff); xfs_attr_shortform_add(args, forkoff);
return(0); return 0;
} }
...@@ -592,10 +592,10 @@ xfs_attr_leaf_addname(xfs_da_args_t *args) ...@@ -592,10 +592,10 @@ xfs_attr_leaf_addname(xfs_da_args_t *args)
* the given flags produce an error or call for an atomic rename. * the given flags produce an error or call for an atomic rename.
*/ */
retval = xfs_attr3_leaf_lookup_int(bp, args); retval = xfs_attr3_leaf_lookup_int(bp, args);
if ((args->flags & ATTR_REPLACE) && (retval == ENOATTR)) { if ((args->flags & ATTR_REPLACE) && (retval == -ENOATTR)) {
xfs_trans_brelse(args->trans, bp); xfs_trans_brelse(args->trans, bp);
return retval; return retval;
} else if (retval == EEXIST) { } else if (retval == -EEXIST) {
if (args->flags & ATTR_CREATE) { /* pure create op */ if (args->flags & ATTR_CREATE) { /* pure create op */
xfs_trans_brelse(args->trans, bp); xfs_trans_brelse(args->trans, bp);
return retval; return retval;
...@@ -626,7 +626,7 @@ xfs_attr_leaf_addname(xfs_da_args_t *args) ...@@ -626,7 +626,7 @@ xfs_attr_leaf_addname(xfs_da_args_t *args)
* if required. * if required.
*/ */
retval = xfs_attr3_leaf_add(bp, args); retval = xfs_attr3_leaf_add(bp, args);
if (retval == ENOSPC) { if (retval == -ENOSPC) {
/* /*
* Promote the attribute list to the Btree format, then * Promote the attribute list to the Btree format, then
* Commit that transaction so that the node_addname() call * Commit that transaction so that the node_addname() call
...@@ -642,7 +642,7 @@ xfs_attr_leaf_addname(xfs_da_args_t *args) ...@@ -642,7 +642,7 @@ xfs_attr_leaf_addname(xfs_da_args_t *args)
ASSERT(committed); ASSERT(committed);
args->trans = NULL; args->trans = NULL;
xfs_bmap_cancel(args->flist); xfs_bmap_cancel(args->flist);
return(error); return error;
} }
/* /*
...@@ -658,13 +658,13 @@ xfs_attr_leaf_addname(xfs_da_args_t *args) ...@@ -658,13 +658,13 @@ xfs_attr_leaf_addname(xfs_da_args_t *args)
*/ */
error = xfs_trans_roll(&args->trans, dp); error = xfs_trans_roll(&args->trans, dp);
if (error) if (error)
return (error); return error;
/* /*
* Fob the whole rest of the problem off on the Btree code. * Fob the whole rest of the problem off on the Btree code.
*/ */
error = xfs_attr_node_addname(args); error = xfs_attr_node_addname(args);
return(error); return error;
} }
/* /*
...@@ -673,7 +673,7 @@ xfs_attr_leaf_addname(xfs_da_args_t *args) ...@@ -673,7 +673,7 @@ xfs_attr_leaf_addname(xfs_da_args_t *args)
*/ */
error = xfs_trans_roll(&args->trans, dp); error = xfs_trans_roll(&args->trans, dp);
if (error) if (error)
return (error); return error;
/* /*
* If there was an out-of-line value, allocate the blocks we * If there was an out-of-line value, allocate the blocks we
...@@ -684,7 +684,7 @@ xfs_attr_leaf_addname(xfs_da_args_t *args) ...@@ -684,7 +684,7 @@ xfs_attr_leaf_addname(xfs_da_args_t *args)
if (args->rmtblkno > 0) { if (args->rmtblkno > 0) {
error = xfs_attr_rmtval_set(args); error = xfs_attr_rmtval_set(args);
if (error) if (error)
return(error); return error;
} }
/* /*
...@@ -700,7 +700,7 @@ xfs_attr_leaf_addname(xfs_da_args_t *args) ...@@ -700,7 +700,7 @@ xfs_attr_leaf_addname(xfs_da_args_t *args)
*/ */
error = xfs_attr3_leaf_flipflags(args); error = xfs_attr3_leaf_flipflags(args);
if (error) if (error)
return(error); return error;
/* /*
* Dismantle the "old" attribute/value pair by removing * Dismantle the "old" attribute/value pair by removing
...@@ -714,7 +714,7 @@ xfs_attr_leaf_addname(xfs_da_args_t *args) ...@@ -714,7 +714,7 @@ xfs_attr_leaf_addname(xfs_da_args_t *args)
if (args->rmtblkno) { if (args->rmtblkno) {
error = xfs_attr_rmtval_remove(args); error = xfs_attr_rmtval_remove(args);
if (error) if (error)
return(error); return error;
} }
/* /*
...@@ -744,7 +744,7 @@ xfs_attr_leaf_addname(xfs_da_args_t *args) ...@@ -744,7 +744,7 @@ xfs_attr_leaf_addname(xfs_da_args_t *args)
ASSERT(committed); ASSERT(committed);
args->trans = NULL; args->trans = NULL;
xfs_bmap_cancel(args->flist); xfs_bmap_cancel(args->flist);
return(error); return error;
} }
/* /*
...@@ -795,7 +795,7 @@ xfs_attr_leaf_removename(xfs_da_args_t *args) ...@@ -795,7 +795,7 @@ xfs_attr_leaf_removename(xfs_da_args_t *args)
return error; return error;
error = xfs_attr3_leaf_lookup_int(bp, args); error = xfs_attr3_leaf_lookup_int(bp, args);
if (error == ENOATTR) { if (error == -ENOATTR) {
xfs_trans_brelse(args->trans, bp); xfs_trans_brelse(args->trans, bp);
return error; return error;
} }
...@@ -850,7 +850,7 @@ xfs_attr_leaf_get(xfs_da_args_t *args) ...@@ -850,7 +850,7 @@ xfs_attr_leaf_get(xfs_da_args_t *args)
return error; return error;
error = xfs_attr3_leaf_lookup_int(bp, args); error = xfs_attr3_leaf_lookup_int(bp, args);
if (error != EEXIST) { if (error != -EEXIST) {
xfs_trans_brelse(args->trans, bp); xfs_trans_brelse(args->trans, bp);
return error; return error;
} }
...@@ -906,9 +906,9 @@ xfs_attr_node_addname(xfs_da_args_t *args) ...@@ -906,9 +906,9 @@ xfs_attr_node_addname(xfs_da_args_t *args)
goto out; goto out;
blk = &state->path.blk[ state->path.active-1 ]; blk = &state->path.blk[ state->path.active-1 ];
ASSERT(blk->magic == XFS_ATTR_LEAF_MAGIC); ASSERT(blk->magic == XFS_ATTR_LEAF_MAGIC);
if ((args->flags & ATTR_REPLACE) && (retval == ENOATTR)) { if ((args->flags & ATTR_REPLACE) && (retval == -ENOATTR)) {
goto out; goto out;
} else if (retval == EEXIST) { } else if (retval == -EEXIST) {
if (args->flags & ATTR_CREATE) if (args->flags & ATTR_CREATE)
goto out; goto out;
...@@ -933,7 +933,7 @@ xfs_attr_node_addname(xfs_da_args_t *args) ...@@ -933,7 +933,7 @@ xfs_attr_node_addname(xfs_da_args_t *args)
} }
retval = xfs_attr3_leaf_add(blk->bp, state->args); retval = xfs_attr3_leaf_add(blk->bp, state->args);
if (retval == ENOSPC) { if (retval == -ENOSPC) {
if (state->path.active == 1) { if (state->path.active == 1) {
/* /*
* Its really a single leaf node, but it had * Its really a single leaf node, but it had
...@@ -1031,7 +1031,7 @@ xfs_attr_node_addname(xfs_da_args_t *args) ...@@ -1031,7 +1031,7 @@ xfs_attr_node_addname(xfs_da_args_t *args)
if (args->rmtblkno > 0) { if (args->rmtblkno > 0) {
error = xfs_attr_rmtval_set(args); error = xfs_attr_rmtval_set(args);
if (error) if (error)
return(error); return error;
} }
/* /*
...@@ -1061,7 +1061,7 @@ xfs_attr_node_addname(xfs_da_args_t *args) ...@@ -1061,7 +1061,7 @@ xfs_attr_node_addname(xfs_da_args_t *args)
if (args->rmtblkno) { if (args->rmtblkno) {
error = xfs_attr_rmtval_remove(args); error = xfs_attr_rmtval_remove(args);
if (error) if (error)
return(error); return error;
} }
/* /*
...@@ -1134,8 +1134,8 @@ xfs_attr_node_addname(xfs_da_args_t *args) ...@@ -1134,8 +1134,8 @@ xfs_attr_node_addname(xfs_da_args_t *args)
if (state) if (state)
xfs_da_state_free(state); xfs_da_state_free(state);
if (error) if (error)
return(error); return error;
return(retval); return retval;
} }
/* /*
...@@ -1168,7 +1168,7 @@ xfs_attr_node_removename(xfs_da_args_t *args) ...@@ -1168,7 +1168,7 @@ xfs_attr_node_removename(xfs_da_args_t *args)
* Search to see if name exists, and get back a pointer to it. * Search to see if name exists, and get back a pointer to it.
*/ */
error = xfs_da3_node_lookup_int(state, &retval); error = xfs_da3_node_lookup_int(state, &retval);
if (error || (retval != EEXIST)) { if (error || (retval != -EEXIST)) {
if (error == 0) if (error == 0)
error = retval; error = retval;
goto out; goto out;
...@@ -1297,7 +1297,7 @@ xfs_attr_node_removename(xfs_da_args_t *args) ...@@ -1297,7 +1297,7 @@ xfs_attr_node_removename(xfs_da_args_t *args)
out: out:
xfs_da_state_free(state); xfs_da_state_free(state);
return(error); return error;
} }
/* /*
...@@ -1345,7 +1345,7 @@ xfs_attr_fillstate(xfs_da_state_t *state) ...@@ -1345,7 +1345,7 @@ xfs_attr_fillstate(xfs_da_state_t *state)
} }
} }
return(0); return 0;
} }
/* /*
...@@ -1376,7 +1376,7 @@ xfs_attr_refillstate(xfs_da_state_t *state) ...@@ -1376,7 +1376,7 @@ xfs_attr_refillstate(xfs_da_state_t *state)
blk->blkno, blk->disk_blkno, blk->blkno, blk->disk_blkno,
&blk->bp, XFS_ATTR_FORK); &blk->bp, XFS_ATTR_FORK);
if (error) if (error)
return(error); return error;
} else { } else {
blk->bp = NULL; blk->bp = NULL;
} }
...@@ -1395,13 +1395,13 @@ xfs_attr_refillstate(xfs_da_state_t *state) ...@@ -1395,13 +1395,13 @@ xfs_attr_refillstate(xfs_da_state_t *state)
blk->blkno, blk->disk_blkno, blk->blkno, blk->disk_blkno,
&blk->bp, XFS_ATTR_FORK); &blk->bp, XFS_ATTR_FORK);
if (error) if (error)
return(error); return error;
} else { } else {
blk->bp = NULL; blk->bp = NULL;
} }
} }
return(0); return 0;
} }
/* /*
...@@ -1431,7 +1431,7 @@ xfs_attr_node_get(xfs_da_args_t *args) ...@@ -1431,7 +1431,7 @@ xfs_attr_node_get(xfs_da_args_t *args)
error = xfs_da3_node_lookup_int(state, &retval); error = xfs_da3_node_lookup_int(state, &retval);
if (error) { if (error) {
retval = error; retval = error;
} else if (retval == EEXIST) { } else if (retval == -EEXIST) {
blk = &state->path.blk[ state->path.active-1 ]; blk = &state->path.blk[ state->path.active-1 ];
ASSERT(blk->bp != NULL); ASSERT(blk->bp != NULL);
ASSERT(blk->magic == XFS_ATTR_LEAF_MAGIC); ASSERT(blk->magic == XFS_ATTR_LEAF_MAGIC);
...@@ -1455,5 +1455,5 @@ xfs_attr_node_get(xfs_da_args_t *args) ...@@ -1455,5 +1455,5 @@ xfs_attr_node_get(xfs_da_args_t *args)
} }
xfs_da_state_free(state); xfs_da_state_free(state);
return(retval); return retval;
} }
...@@ -214,7 +214,7 @@ xfs_attr3_leaf_write_verify( ...@@ -214,7 +214,7 @@ xfs_attr3_leaf_write_verify(
struct xfs_attr3_leaf_hdr *hdr3 = bp->b_addr; struct xfs_attr3_leaf_hdr *hdr3 = bp->b_addr;
if (!xfs_attr3_leaf_verify(bp)) { if (!xfs_attr3_leaf_verify(bp)) {
xfs_buf_ioerror(bp, EFSCORRUPTED); xfs_buf_ioerror(bp, -EFSCORRUPTED);
xfs_verifier_error(bp); xfs_verifier_error(bp);
return; return;
} }
...@@ -242,9 +242,9 @@ xfs_attr3_leaf_read_verify( ...@@ -242,9 +242,9 @@ xfs_attr3_leaf_read_verify(
if (xfs_sb_version_hascrc(&mp->m_sb) && if (xfs_sb_version_hascrc(&mp->m_sb) &&
!xfs_buf_verify_cksum(bp, XFS_ATTR3_LEAF_CRC_OFF)) !xfs_buf_verify_cksum(bp, XFS_ATTR3_LEAF_CRC_OFF))
xfs_buf_ioerror(bp, EFSBADCRC); xfs_buf_ioerror(bp, -EFSBADCRC);
else if (!xfs_attr3_leaf_verify(bp)) else if (!xfs_attr3_leaf_verify(bp))
xfs_buf_ioerror(bp, EFSCORRUPTED); xfs_buf_ioerror(bp, -EFSCORRUPTED);
if (bp->b_error) if (bp->b_error)
xfs_verifier_error(bp); xfs_verifier_error(bp);
...@@ -547,7 +547,7 @@ xfs_attr_shortform_remove(xfs_da_args_t *args) ...@@ -547,7 +547,7 @@ xfs_attr_shortform_remove(xfs_da_args_t *args)
break; break;
} }
if (i == end) if (i == end)
return(XFS_ERROR(ENOATTR)); return -ENOATTR;
/* /*
* Fix up the attribute fork data, covering the hole * Fix up the attribute fork data, covering the hole
...@@ -582,7 +582,7 @@ xfs_attr_shortform_remove(xfs_da_args_t *args) ...@@ -582,7 +582,7 @@ xfs_attr_shortform_remove(xfs_da_args_t *args)
xfs_sbversion_add_attr2(mp, args->trans); xfs_sbversion_add_attr2(mp, args->trans);
return(0); return 0;
} }
/* /*
...@@ -611,9 +611,9 @@ xfs_attr_shortform_lookup(xfs_da_args_t *args) ...@@ -611,9 +611,9 @@ xfs_attr_shortform_lookup(xfs_da_args_t *args)
continue; continue;
if (!xfs_attr_namesp_match(args->flags, sfe->flags)) if (!xfs_attr_namesp_match(args->flags, sfe->flags))
continue; continue;
return(XFS_ERROR(EEXIST)); return -EEXIST;
} }
return(XFS_ERROR(ENOATTR)); return -ENOATTR;
} }
/* /*
...@@ -640,18 +640,18 @@ xfs_attr_shortform_getvalue(xfs_da_args_t *args) ...@@ -640,18 +640,18 @@ xfs_attr_shortform_getvalue(xfs_da_args_t *args)
continue; continue;
if (args->flags & ATTR_KERNOVAL) { if (args->flags & ATTR_KERNOVAL) {
args->valuelen = sfe->valuelen; args->valuelen = sfe->valuelen;
return(XFS_ERROR(EEXIST)); return -EEXIST;
} }
if (args->valuelen < sfe->valuelen) { if (args->valuelen < sfe->valuelen) {
args->valuelen = sfe->valuelen; args->valuelen = sfe->valuelen;
return(XFS_ERROR(ERANGE)); return -ERANGE;
} }
args->valuelen = sfe->valuelen; args->valuelen = sfe->valuelen;
memcpy(args->value, &sfe->nameval[args->namelen], memcpy(args->value, &sfe->nameval[args->namelen],
args->valuelen); args->valuelen);
return(XFS_ERROR(EEXIST)); return -EEXIST;
} }
return(XFS_ERROR(ENOATTR)); return -ENOATTR;
} }
/* /*
...@@ -691,7 +691,7 @@ xfs_attr_shortform_to_leaf(xfs_da_args_t *args) ...@@ -691,7 +691,7 @@ xfs_attr_shortform_to_leaf(xfs_da_args_t *args)
* If we hit an IO error middle of the transaction inside * If we hit an IO error middle of the transaction inside
* grow_inode(), we may have inconsistent data. Bail out. * grow_inode(), we may have inconsistent data. Bail out.
*/ */
if (error == EIO) if (error == -EIO)
goto out; goto out;
xfs_idata_realloc(dp, size, XFS_ATTR_FORK); /* try to put */ xfs_idata_realloc(dp, size, XFS_ATTR_FORK); /* try to put */
memcpy(ifp->if_u1.if_data, tmpbuffer, size); /* it back */ memcpy(ifp->if_u1.if_data, tmpbuffer, size); /* it back */
...@@ -730,9 +730,9 @@ xfs_attr_shortform_to_leaf(xfs_da_args_t *args) ...@@ -730,9 +730,9 @@ xfs_attr_shortform_to_leaf(xfs_da_args_t *args)
sfe->namelen); sfe->namelen);
nargs.flags = XFS_ATTR_NSP_ONDISK_TO_ARGS(sfe->flags); nargs.flags = XFS_ATTR_NSP_ONDISK_TO_ARGS(sfe->flags);
error = xfs_attr3_leaf_lookup_int(bp, &nargs); /* set a->index */ error = xfs_attr3_leaf_lookup_int(bp, &nargs); /* set a->index */
ASSERT(error == ENOATTR); ASSERT(error == -ENOATTR);
error = xfs_attr3_leaf_add(bp, &nargs); error = xfs_attr3_leaf_add(bp, &nargs);
ASSERT(error != ENOSPC); ASSERT(error != -ENOSPC);
if (error) if (error)
goto out; goto out;
sfe = XFS_ATTR_SF_NEXTENTRY(sfe); sfe = XFS_ATTR_SF_NEXTENTRY(sfe);
...@@ -741,7 +741,7 @@ xfs_attr_shortform_to_leaf(xfs_da_args_t *args) ...@@ -741,7 +741,7 @@ xfs_attr_shortform_to_leaf(xfs_da_args_t *args)
out: out:
kmem_free(tmpbuffer); kmem_free(tmpbuffer);
return(error); return error;
} }
/* /*
...@@ -769,12 +769,12 @@ xfs_attr_shortform_allfit( ...@@ -769,12 +769,12 @@ xfs_attr_shortform_allfit(
if (entry->flags & XFS_ATTR_INCOMPLETE) if (entry->flags & XFS_ATTR_INCOMPLETE)
continue; /* don't copy partial entries */ continue; /* don't copy partial entries */
if (!(entry->flags & XFS_ATTR_LOCAL)) if (!(entry->flags & XFS_ATTR_LOCAL))
return(0); return 0;
name_loc = xfs_attr3_leaf_name_local(leaf, i); name_loc = xfs_attr3_leaf_name_local(leaf, i);
if (name_loc->namelen >= XFS_ATTR_SF_ENTSIZE_MAX) if (name_loc->namelen >= XFS_ATTR_SF_ENTSIZE_MAX)
return(0); return 0;
if (be16_to_cpu(name_loc->valuelen) >= XFS_ATTR_SF_ENTSIZE_MAX) if (be16_to_cpu(name_loc->valuelen) >= XFS_ATTR_SF_ENTSIZE_MAX)
return(0); return 0;
bytes += sizeof(struct xfs_attr_sf_entry) - 1 bytes += sizeof(struct xfs_attr_sf_entry) - 1
+ name_loc->namelen + name_loc->namelen
+ be16_to_cpu(name_loc->valuelen); + be16_to_cpu(name_loc->valuelen);
...@@ -809,7 +809,7 @@ xfs_attr3_leaf_to_shortform( ...@@ -809,7 +809,7 @@ xfs_attr3_leaf_to_shortform(
tmpbuffer = kmem_alloc(args->geo->blksize, KM_SLEEP); tmpbuffer = kmem_alloc(args->geo->blksize, KM_SLEEP);
if (!tmpbuffer) if (!tmpbuffer)
return ENOMEM; return -ENOMEM;
memcpy(tmpbuffer, bp->b_addr, args->geo->blksize); memcpy(tmpbuffer, bp->b_addr, args->geo->blksize);
...@@ -1017,10 +1017,10 @@ xfs_attr3_leaf_split( ...@@ -1017,10 +1017,10 @@ xfs_attr3_leaf_split(
ASSERT(oldblk->magic == XFS_ATTR_LEAF_MAGIC); ASSERT(oldblk->magic == XFS_ATTR_LEAF_MAGIC);
error = xfs_da_grow_inode(state->args, &blkno); error = xfs_da_grow_inode(state->args, &blkno);
if (error) if (error)
return(error); return error;
error = xfs_attr3_leaf_create(state->args, blkno, &newblk->bp); error = xfs_attr3_leaf_create(state->args, blkno, &newblk->bp);
if (error) if (error)
return(error); return error;
newblk->blkno = blkno; newblk->blkno = blkno;
newblk->magic = XFS_ATTR_LEAF_MAGIC; newblk->magic = XFS_ATTR_LEAF_MAGIC;
...@@ -1031,7 +1031,7 @@ xfs_attr3_leaf_split( ...@@ -1031,7 +1031,7 @@ xfs_attr3_leaf_split(
xfs_attr3_leaf_rebalance(state, oldblk, newblk); xfs_attr3_leaf_rebalance(state, oldblk, newblk);
error = xfs_da3_blk_link(state, oldblk, newblk); error = xfs_da3_blk_link(state, oldblk, newblk);
if (error) if (error)
return(error); return error;
/* /*
* Save info on "old" attribute for "atomic rename" ops, leaf_add() * Save info on "old" attribute for "atomic rename" ops, leaf_add()
...@@ -1053,7 +1053,7 @@ xfs_attr3_leaf_split( ...@@ -1053,7 +1053,7 @@ xfs_attr3_leaf_split(
*/ */
oldblk->hashval = xfs_attr_leaf_lasthash(oldblk->bp, NULL); oldblk->hashval = xfs_attr_leaf_lasthash(oldblk->bp, NULL);
newblk->hashval = xfs_attr_leaf_lasthash(newblk->bp, NULL); newblk->hashval = xfs_attr_leaf_lasthash(newblk->bp, NULL);
return(error); return error;
} }
/* /*
...@@ -1108,7 +1108,7 @@ xfs_attr3_leaf_add( ...@@ -1108,7 +1108,7 @@ xfs_attr3_leaf_add(
* no good and we should just give up. * no good and we should just give up.
*/ */
if (!ichdr.holes && sum < entsize) if (!ichdr.holes && sum < entsize)
return XFS_ERROR(ENOSPC); return -ENOSPC;
/* /*
* Compact the entries to coalesce free space. * Compact the entries to coalesce free space.
...@@ -1121,7 +1121,7 @@ xfs_attr3_leaf_add( ...@@ -1121,7 +1121,7 @@ xfs_attr3_leaf_add(
* free region, in freemap[0]. If it is not big enough, give up. * free region, in freemap[0]. If it is not big enough, give up.
*/ */
if (ichdr.freemap[0].size < (entsize + sizeof(xfs_attr_leaf_entry_t))) { if (ichdr.freemap[0].size < (entsize + sizeof(xfs_attr_leaf_entry_t))) {
tmp = ENOSPC; tmp = -ENOSPC;
goto out_log_hdr; goto out_log_hdr;
} }
...@@ -1692,7 +1692,7 @@ xfs_attr3_leaf_toosmall( ...@@ -1692,7 +1692,7 @@ xfs_attr3_leaf_toosmall(
ichdr.usedbytes; ichdr.usedbytes;
if (bytes > (state->args->geo->blksize >> 1)) { if (bytes > (state->args->geo->blksize >> 1)) {
*action = 0; /* blk over 50%, don't try to join */ *action = 0; /* blk over 50%, don't try to join */
return(0); return 0;
} }
/* /*
...@@ -1711,7 +1711,7 @@ xfs_attr3_leaf_toosmall( ...@@ -1711,7 +1711,7 @@ xfs_attr3_leaf_toosmall(
error = xfs_da3_path_shift(state, &state->altpath, forward, error = xfs_da3_path_shift(state, &state->altpath, forward,
0, &retval); 0, &retval);
if (error) if (error)
return(error); return error;
if (retval) { if (retval) {
*action = 0; *action = 0;
} else { } else {
...@@ -1740,7 +1740,7 @@ xfs_attr3_leaf_toosmall( ...@@ -1740,7 +1740,7 @@ xfs_attr3_leaf_toosmall(
error = xfs_attr3_leaf_read(state->args->trans, state->args->dp, error = xfs_attr3_leaf_read(state->args->trans, state->args->dp,
blkno, -1, &bp); blkno, -1, &bp);
if (error) if (error)
return(error); return error;
xfs_attr3_leaf_hdr_from_disk(&ichdr2, bp->b_addr); xfs_attr3_leaf_hdr_from_disk(&ichdr2, bp->b_addr);
...@@ -1757,7 +1757,7 @@ xfs_attr3_leaf_toosmall( ...@@ -1757,7 +1757,7 @@ xfs_attr3_leaf_toosmall(
} }
if (i >= 2) { if (i >= 2) {
*action = 0; *action = 0;
return(0); return 0;
} }
/* /*
...@@ -1773,13 +1773,13 @@ xfs_attr3_leaf_toosmall( ...@@ -1773,13 +1773,13 @@ xfs_attr3_leaf_toosmall(
0, &retval); 0, &retval);
} }
if (error) if (error)
return(error); return error;
if (retval) { if (retval) {
*action = 0; *action = 0;
} else { } else {
*action = 1; *action = 1;
} }
return(0); return 0;
} }
/* /*
...@@ -2123,7 +2123,7 @@ xfs_attr3_leaf_lookup_int( ...@@ -2123,7 +2123,7 @@ xfs_attr3_leaf_lookup_int(
} }
if (probe == ichdr.count || be32_to_cpu(entry->hashval) != hashval) { if (probe == ichdr.count || be32_to_cpu(entry->hashval) != hashval) {
args->index = probe; args->index = probe;
return XFS_ERROR(ENOATTR); return -ENOATTR;
} }
/* /*
...@@ -2152,7 +2152,7 @@ xfs_attr3_leaf_lookup_int( ...@@ -2152,7 +2152,7 @@ xfs_attr3_leaf_lookup_int(
if (!xfs_attr_namesp_match(args->flags, entry->flags)) if (!xfs_attr_namesp_match(args->flags, entry->flags))
continue; continue;
args->index = probe; args->index = probe;
return XFS_ERROR(EEXIST); return -EEXIST;
} else { } else {
name_rmt = xfs_attr3_leaf_name_remote(leaf, probe); name_rmt = xfs_attr3_leaf_name_remote(leaf, probe);
if (name_rmt->namelen != args->namelen) if (name_rmt->namelen != args->namelen)
...@@ -2168,11 +2168,11 @@ xfs_attr3_leaf_lookup_int( ...@@ -2168,11 +2168,11 @@ xfs_attr3_leaf_lookup_int(
args->rmtblkcnt = xfs_attr3_rmt_blocks( args->rmtblkcnt = xfs_attr3_rmt_blocks(
args->dp->i_mount, args->dp->i_mount,
args->rmtvaluelen); args->rmtvaluelen);
return XFS_ERROR(EEXIST); return -EEXIST;
} }
} }
args->index = probe; args->index = probe;
return XFS_ERROR(ENOATTR); return -ENOATTR;
} }
/* /*
...@@ -2208,7 +2208,7 @@ xfs_attr3_leaf_getvalue( ...@@ -2208,7 +2208,7 @@ xfs_attr3_leaf_getvalue(
} }
if (args->valuelen < valuelen) { if (args->valuelen < valuelen) {
args->valuelen = valuelen; args->valuelen = valuelen;
return XFS_ERROR(ERANGE); return -ERANGE;
} }
args->valuelen = valuelen; args->valuelen = valuelen;
memcpy(args->value, &name_loc->nameval[args->namelen], valuelen); memcpy(args->value, &name_loc->nameval[args->namelen], valuelen);
...@@ -2226,7 +2226,7 @@ xfs_attr3_leaf_getvalue( ...@@ -2226,7 +2226,7 @@ xfs_attr3_leaf_getvalue(
} }
if (args->valuelen < args->rmtvaluelen) { if (args->valuelen < args->rmtvaluelen) {
args->valuelen = args->rmtvaluelen; args->valuelen = args->rmtvaluelen;
return XFS_ERROR(ERANGE); return -ERANGE;
} }
args->valuelen = args->rmtvaluelen; args->valuelen = args->rmtvaluelen;
} }
...@@ -2481,7 +2481,7 @@ xfs_attr3_leaf_clearflag( ...@@ -2481,7 +2481,7 @@ xfs_attr3_leaf_clearflag(
*/ */
error = xfs_attr3_leaf_read(args->trans, args->dp, args->blkno, -1, &bp); error = xfs_attr3_leaf_read(args->trans, args->dp, args->blkno, -1, &bp);
if (error) if (error)
return(error); return error;
leaf = bp->b_addr; leaf = bp->b_addr;
entry = &xfs_attr3_leaf_entryp(leaf)[args->index]; entry = &xfs_attr3_leaf_entryp(leaf)[args->index];
...@@ -2548,7 +2548,7 @@ xfs_attr3_leaf_setflag( ...@@ -2548,7 +2548,7 @@ xfs_attr3_leaf_setflag(
*/ */
error = xfs_attr3_leaf_read(args->trans, args->dp, args->blkno, -1, &bp); error = xfs_attr3_leaf_read(args->trans, args->dp, args->blkno, -1, &bp);
if (error) if (error)
return(error); return error;
leaf = bp->b_addr; leaf = bp->b_addr;
#ifdef DEBUG #ifdef DEBUG
......
...@@ -138,11 +138,11 @@ xfs_attr3_rmt_read_verify( ...@@ -138,11 +138,11 @@ xfs_attr3_rmt_read_verify(
while (len > 0) { while (len > 0) {
if (!xfs_verify_cksum(ptr, blksize, XFS_ATTR3_RMT_CRC_OFF)) { if (!xfs_verify_cksum(ptr, blksize, XFS_ATTR3_RMT_CRC_OFF)) {
xfs_buf_ioerror(bp, EFSBADCRC); xfs_buf_ioerror(bp, -EFSBADCRC);
break; break;
} }
if (!xfs_attr3_rmt_verify(mp, ptr, blksize, bno)) { if (!xfs_attr3_rmt_verify(mp, ptr, blksize, bno)) {
xfs_buf_ioerror(bp, EFSCORRUPTED); xfs_buf_ioerror(bp, -EFSCORRUPTED);
break; break;
} }
len -= blksize; len -= blksize;
...@@ -178,7 +178,7 @@ xfs_attr3_rmt_write_verify( ...@@ -178,7 +178,7 @@ xfs_attr3_rmt_write_verify(
while (len > 0) { while (len > 0) {
if (!xfs_attr3_rmt_verify(mp, ptr, blksize, bno)) { if (!xfs_attr3_rmt_verify(mp, ptr, blksize, bno)) {
xfs_buf_ioerror(bp, EFSCORRUPTED); xfs_buf_ioerror(bp, -EFSCORRUPTED);
xfs_verifier_error(bp); xfs_verifier_error(bp);
return; return;
} }
...@@ -257,7 +257,7 @@ xfs_attr_rmtval_copyout( ...@@ -257,7 +257,7 @@ xfs_attr_rmtval_copyout(
xfs_alert(mp, xfs_alert(mp,
"remote attribute header mismatch bno/off/len/owner (0x%llx/0x%x/Ox%x/0x%llx)", "remote attribute header mismatch bno/off/len/owner (0x%llx/0x%x/Ox%x/0x%llx)",
bno, *offset, byte_cnt, ino); bno, *offset, byte_cnt, ino);
return EFSCORRUPTED; return -EFSCORRUPTED;
} }
hdr_size = sizeof(struct xfs_attr3_rmt_hdr); hdr_size = sizeof(struct xfs_attr3_rmt_hdr);
} }
...@@ -452,7 +452,7 @@ xfs_attr_rmtval_set( ...@@ -452,7 +452,7 @@ xfs_attr_rmtval_set(
ASSERT(committed); ASSERT(committed);
args->trans = NULL; args->trans = NULL;
xfs_bmap_cancel(args->flist); xfs_bmap_cancel(args->flist);
return(error); return error;
} }
/* /*
...@@ -473,7 +473,7 @@ xfs_attr_rmtval_set( ...@@ -473,7 +473,7 @@ xfs_attr_rmtval_set(
*/ */
error = xfs_trans_roll(&args->trans, dp); error = xfs_trans_roll(&args->trans, dp);
if (error) if (error)
return (error); return error;
} }
/* /*
...@@ -498,7 +498,7 @@ xfs_attr_rmtval_set( ...@@ -498,7 +498,7 @@ xfs_attr_rmtval_set(
blkcnt, &map, &nmap, blkcnt, &map, &nmap,
XFS_BMAPI_ATTRFORK); XFS_BMAPI_ATTRFORK);
if (error) if (error)
return(error); return error;
ASSERT(nmap == 1); ASSERT(nmap == 1);
ASSERT((map.br_startblock != DELAYSTARTBLOCK) && ASSERT((map.br_startblock != DELAYSTARTBLOCK) &&
(map.br_startblock != HOLESTARTBLOCK)); (map.br_startblock != HOLESTARTBLOCK));
...@@ -508,7 +508,7 @@ xfs_attr_rmtval_set( ...@@ -508,7 +508,7 @@ xfs_attr_rmtval_set(
bp = xfs_buf_get(mp->m_ddev_targp, dblkno, dblkcnt, 0); bp = xfs_buf_get(mp->m_ddev_targp, dblkno, dblkcnt, 0);
if (!bp) if (!bp)
return ENOMEM; return -ENOMEM;
bp->b_ops = &xfs_attr3_rmt_buf_ops; bp->b_ops = &xfs_attr3_rmt_buf_ops;
xfs_attr_rmtval_copyin(mp, bp, args->dp->i_ino, &offset, xfs_attr_rmtval_copyin(mp, bp, args->dp->i_ino, &offset,
...@@ -563,7 +563,7 @@ xfs_attr_rmtval_remove( ...@@ -563,7 +563,7 @@ xfs_attr_rmtval_remove(
error = xfs_bmapi_read(args->dp, (xfs_fileoff_t)lblkno, error = xfs_bmapi_read(args->dp, (xfs_fileoff_t)lblkno,
blkcnt, &map, &nmap, XFS_BMAPI_ATTRFORK); blkcnt, &map, &nmap, XFS_BMAPI_ATTRFORK);
if (error) if (error)
return(error); return error;
ASSERT(nmap == 1); ASSERT(nmap == 1);
ASSERT((map.br_startblock != DELAYSTARTBLOCK) && ASSERT((map.br_startblock != DELAYSTARTBLOCK) &&
(map.br_startblock != HOLESTARTBLOCK)); (map.br_startblock != HOLESTARTBLOCK));
...@@ -622,7 +622,7 @@ xfs_attr_rmtval_remove( ...@@ -622,7 +622,7 @@ xfs_attr_rmtval_remove(
*/ */
error = xfs_trans_roll(&args->trans, args->dp); error = xfs_trans_roll(&args->trans, args->dp);
if (error) if (error)
return (error); return error;
} }
return(0); return 0;
} }
...@@ -1033,7 +1033,7 @@ xfs_bmap_add_attrfork_btree( ...@@ -1033,7 +1033,7 @@ xfs_bmap_add_attrfork_btree(
goto error0; goto error0;
if (stat == 0) { if (stat == 0) {
xfs_btree_del_cursor(cur, XFS_BTREE_NOERROR); xfs_btree_del_cursor(cur, XFS_BTREE_NOERROR);
return XFS_ERROR(ENOSPC); return -ENOSPC;
} }
*firstblock = cur->bc_private.b.firstblock; *firstblock = cur->bc_private.b.firstblock;
cur->bc_private.b.allocated = 0; cur->bc_private.b.allocated = 0;
...@@ -1115,7 +1115,7 @@ xfs_bmap_add_attrfork_local( ...@@ -1115,7 +1115,7 @@ xfs_bmap_add_attrfork_local(
/* should only be called for types that support local format data */ /* should only be called for types that support local format data */
ASSERT(0); ASSERT(0);
return EFSCORRUPTED; return -EFSCORRUPTED;
} }
/* /*
...@@ -1192,7 +1192,7 @@ xfs_bmap_add_attrfork( ...@@ -1192,7 +1192,7 @@ xfs_bmap_add_attrfork(
break; break;
default: default:
ASSERT(0); ASSERT(0);
error = XFS_ERROR(EINVAL); error = -EINVAL;
goto trans_cancel; goto trans_cancel;
} }
...@@ -1399,7 +1399,7 @@ xfs_bmap_read_extents( ...@@ -1399,7 +1399,7 @@ xfs_bmap_read_extents(
return 0; return 0;
error0: error0:
xfs_trans_brelse(tp, bp); xfs_trans_brelse(tp, bp);
return XFS_ERROR(EFSCORRUPTED); return -EFSCORRUPTED;
} }
...@@ -1576,7 +1576,7 @@ xfs_bmap_last_before( ...@@ -1576,7 +1576,7 @@ xfs_bmap_last_before(
if (XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_BTREE && if (XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_BTREE &&
XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_EXTENTS && XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_EXTENTS &&
XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_LOCAL) XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_LOCAL)
return XFS_ERROR(EIO); return -EIO;
if (XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_LOCAL) { if (XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_LOCAL) {
*last_block = 0; *last_block = 0;
return 0; return 0;
...@@ -1690,7 +1690,7 @@ xfs_bmap_last_offset( ...@@ -1690,7 +1690,7 @@ xfs_bmap_last_offset(
if (XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_BTREE && if (XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_BTREE &&
XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_EXTENTS) XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_EXTENTS)
return XFS_ERROR(EIO); return -EIO;
error = xfs_bmap_last_extent(NULL, ip, whichfork, &rec, &is_empty); error = xfs_bmap_last_extent(NULL, ip, whichfork, &rec, &is_empty);
if (error || is_empty) if (error || is_empty)
...@@ -3323,7 +3323,7 @@ xfs_bmap_extsize_align( ...@@ -3323,7 +3323,7 @@ xfs_bmap_extsize_align(
if (orig_off < align_off || if (orig_off < align_off ||
orig_end > align_off + align_alen || orig_end > align_off + align_alen ||
align_alen - temp < orig_alen) align_alen - temp < orig_alen)
return XFS_ERROR(EINVAL); return -EINVAL;
/* /*
* Try to fix it by moving the start up. * Try to fix it by moving the start up.
*/ */
...@@ -3348,7 +3348,7 @@ xfs_bmap_extsize_align( ...@@ -3348,7 +3348,7 @@ xfs_bmap_extsize_align(
* Result doesn't cover the request, fail it. * Result doesn't cover the request, fail it.
*/ */
if (orig_off < align_off || orig_end > align_off + align_alen) if (orig_off < align_off || orig_end > align_off + align_alen)
return XFS_ERROR(EINVAL); return -EINVAL;
} else { } else {
ASSERT(orig_off >= align_off); ASSERT(orig_off >= align_off);
ASSERT(orig_end <= align_off + align_alen); ASSERT(orig_end <= align_off + align_alen);
...@@ -4051,11 +4051,11 @@ xfs_bmapi_read( ...@@ -4051,11 +4051,11 @@ xfs_bmapi_read(
XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_BTREE), XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_BTREE),
mp, XFS_ERRTAG_BMAPIFORMAT, XFS_RANDOM_BMAPIFORMAT))) { mp, XFS_ERRTAG_BMAPIFORMAT, XFS_RANDOM_BMAPIFORMAT))) {
XFS_ERROR_REPORT("xfs_bmapi_read", XFS_ERRLEVEL_LOW, mp); XFS_ERROR_REPORT("xfs_bmapi_read", XFS_ERRLEVEL_LOW, mp);
return XFS_ERROR(EFSCORRUPTED); return -EFSCORRUPTED;
} }
if (XFS_FORCED_SHUTDOWN(mp)) if (XFS_FORCED_SHUTDOWN(mp))
return XFS_ERROR(EIO); return -EIO;
XFS_STATS_INC(xs_blk_mapr); XFS_STATS_INC(xs_blk_mapr);
...@@ -4246,11 +4246,11 @@ xfs_bmapi_delay( ...@@ -4246,11 +4246,11 @@ xfs_bmapi_delay(
XFS_IFORK_FORMAT(ip, XFS_DATA_FORK) != XFS_DINODE_FMT_BTREE), XFS_IFORK_FORMAT(ip, XFS_DATA_FORK) != XFS_DINODE_FMT_BTREE),
mp, XFS_ERRTAG_BMAPIFORMAT, XFS_RANDOM_BMAPIFORMAT))) { mp, XFS_ERRTAG_BMAPIFORMAT, XFS_RANDOM_BMAPIFORMAT))) {
XFS_ERROR_REPORT("xfs_bmapi_delay", XFS_ERRLEVEL_LOW, mp); XFS_ERROR_REPORT("xfs_bmapi_delay", XFS_ERRLEVEL_LOW, mp);
return XFS_ERROR(EFSCORRUPTED); return -EFSCORRUPTED;
} }
if (XFS_FORCED_SHUTDOWN(mp)) if (XFS_FORCED_SHUTDOWN(mp))
return XFS_ERROR(EIO); return -EIO;
XFS_STATS_INC(xs_blk_mapw); XFS_STATS_INC(xs_blk_mapw);
...@@ -4469,7 +4469,7 @@ xfs_bmapi_convert_unwritten( ...@@ -4469,7 +4469,7 @@ xfs_bmapi_convert_unwritten(
* so generate another request. * so generate another request.
*/ */
if (mval->br_blockcount < len) if (mval->br_blockcount < len)
return EAGAIN; return -EAGAIN;
return 0; return 0;
} }
...@@ -4540,11 +4540,11 @@ xfs_bmapi_write( ...@@ -4540,11 +4540,11 @@ xfs_bmapi_write(
XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_BTREE), XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_BTREE),
mp, XFS_ERRTAG_BMAPIFORMAT, XFS_RANDOM_BMAPIFORMAT))) { mp, XFS_ERRTAG_BMAPIFORMAT, XFS_RANDOM_BMAPIFORMAT))) {
XFS_ERROR_REPORT("xfs_bmapi_write", XFS_ERRLEVEL_LOW, mp); XFS_ERROR_REPORT("xfs_bmapi_write", XFS_ERRLEVEL_LOW, mp);
return XFS_ERROR(EFSCORRUPTED); return -EFSCORRUPTED;
} }
if (XFS_FORCED_SHUTDOWN(mp)) if (XFS_FORCED_SHUTDOWN(mp))
return XFS_ERROR(EIO); return -EIO;
ifp = XFS_IFORK_PTR(ip, whichfork); ifp = XFS_IFORK_PTR(ip, whichfork);
...@@ -4620,7 +4620,7 @@ xfs_bmapi_write( ...@@ -4620,7 +4620,7 @@ xfs_bmapi_write(
/* Execute unwritten extent conversion if necessary */ /* Execute unwritten extent conversion if necessary */
error = xfs_bmapi_convert_unwritten(&bma, mval, len, flags); error = xfs_bmapi_convert_unwritten(&bma, mval, len, flags);
if (error == EAGAIN) if (error == -EAGAIN)
continue; continue;
if (error) if (error)
goto error0; goto error0;
...@@ -4922,7 +4922,7 @@ xfs_bmap_del_extent( ...@@ -4922,7 +4922,7 @@ xfs_bmap_del_extent(
goto done; goto done;
cur->bc_rec.b = new; cur->bc_rec.b = new;
error = xfs_btree_insert(cur, &i); error = xfs_btree_insert(cur, &i);
if (error && error != ENOSPC) if (error && error != -ENOSPC)
goto done; goto done;
/* /*
* If get no-space back from btree insert, * If get no-space back from btree insert,
...@@ -4930,7 +4930,7 @@ xfs_bmap_del_extent( ...@@ -4930,7 +4930,7 @@ xfs_bmap_del_extent(
* block reservation. * block reservation.
* Fix up our state and return the error. * Fix up our state and return the error.
*/ */
if (error == ENOSPC) { if (error == -ENOSPC) {
/* /*
* Reset the cursor, don't trust * Reset the cursor, don't trust
* it after any insert operation. * it after any insert operation.
...@@ -4958,7 +4958,7 @@ xfs_bmap_del_extent( ...@@ -4958,7 +4958,7 @@ xfs_bmap_del_extent(
xfs_bmbt_set_blockcount(ep, xfs_bmbt_set_blockcount(ep,
got.br_blockcount); got.br_blockcount);
flags = 0; flags = 0;
error = XFS_ERROR(ENOSPC); error = -ENOSPC;
goto done; goto done;
} }
XFS_WANT_CORRUPTED_GOTO(i == 1, done); XFS_WANT_CORRUPTED_GOTO(i == 1, done);
...@@ -5076,11 +5076,11 @@ xfs_bunmapi( ...@@ -5076,11 +5076,11 @@ xfs_bunmapi(
XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_BTREE)) { XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_BTREE)) {
XFS_ERROR_REPORT("xfs_bunmapi", XFS_ERRLEVEL_LOW, XFS_ERROR_REPORT("xfs_bunmapi", XFS_ERRLEVEL_LOW,
ip->i_mount); ip->i_mount);
return XFS_ERROR(EFSCORRUPTED); return -EFSCORRUPTED;
} }
mp = ip->i_mount; mp = ip->i_mount;
if (XFS_FORCED_SHUTDOWN(mp)) if (XFS_FORCED_SHUTDOWN(mp))
return XFS_ERROR(EIO); return -EIO;
ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL));
ASSERT(len > 0); ASSERT(len > 0);
...@@ -5325,7 +5325,7 @@ xfs_bunmapi( ...@@ -5325,7 +5325,7 @@ xfs_bunmapi(
del.br_startoff > got.br_startoff && del.br_startoff > got.br_startoff &&
del.br_startoff + del.br_blockcount < del.br_startoff + del.br_blockcount <
got.br_startoff + got.br_blockcount) { got.br_startoff + got.br_blockcount) {
error = XFS_ERROR(ENOSPC); error = -ENOSPC;
goto error0; goto error0;
} }
error = xfs_bmap_del_extent(ip, tp, &lastx, flist, cur, &del, error = xfs_bmap_del_extent(ip, tp, &lastx, flist, cur, &del,
...@@ -5449,11 +5449,11 @@ xfs_bmap_shift_extents( ...@@ -5449,11 +5449,11 @@ xfs_bmap_shift_extents(
mp, XFS_ERRTAG_BMAPIFORMAT, XFS_RANDOM_BMAPIFORMAT))) { mp, XFS_ERRTAG_BMAPIFORMAT, XFS_RANDOM_BMAPIFORMAT))) {
XFS_ERROR_REPORT("xfs_bmap_shift_extents", XFS_ERROR_REPORT("xfs_bmap_shift_extents",
XFS_ERRLEVEL_LOW, mp); XFS_ERRLEVEL_LOW, mp);
return XFS_ERROR(EFSCORRUPTED); return -EFSCORRUPTED;
} }
if (XFS_FORCED_SHUTDOWN(mp)) if (XFS_FORCED_SHUTDOWN(mp))
return XFS_ERROR(EIO); return -EIO;
ASSERT(current_ext != NULL); ASSERT(current_ext != NULL);
...@@ -5516,14 +5516,14 @@ xfs_bmap_shift_extents( ...@@ -5516,14 +5516,14 @@ xfs_bmap_shift_extents(
*current_ext - 1), &left); *current_ext - 1), &left);
if (startoff < left.br_startoff + left.br_blockcount) if (startoff < left.br_startoff + left.br_blockcount)
error = XFS_ERROR(EINVAL); error = -EINVAL;
} else if (offset_shift_fsb > got.br_startoff) { } else if (offset_shift_fsb > got.br_startoff) {
/* /*
* When first extent is shifted, offset_shift_fsb * When first extent is shifted, offset_shift_fsb
* should be less than the stating offset of * should be less than the stating offset of
* the first extent. * the first extent.
*/ */
error = XFS_ERROR(EINVAL); error = -EINVAL;
} }
if (error) if (error)
......
...@@ -554,7 +554,7 @@ xfs_bmbt_alloc_block( ...@@ -554,7 +554,7 @@ xfs_bmbt_alloc_block(
args.minlen = args.maxlen = args.prod = 1; args.minlen = args.maxlen = args.prod = 1;
args.wasdel = cur->bc_private.b.flags & XFS_BTCUR_BPRV_WASDEL; args.wasdel = cur->bc_private.b.flags & XFS_BTCUR_BPRV_WASDEL;
if (!args.wasdel && xfs_trans_get_block_res(args.tp) == 0) { if (!args.wasdel && xfs_trans_get_block_res(args.tp) == 0) {
error = XFS_ERROR(ENOSPC); error = -ENOSPC;
goto error0; goto error0;
} }
error = xfs_alloc_vextent(&args); error = xfs_alloc_vextent(&args);
...@@ -779,9 +779,9 @@ xfs_bmbt_read_verify( ...@@ -779,9 +779,9 @@ xfs_bmbt_read_verify(
struct xfs_buf *bp) struct xfs_buf *bp)
{ {
if (!xfs_btree_lblock_verify_crc(bp)) if (!xfs_btree_lblock_verify_crc(bp))
xfs_buf_ioerror(bp, EFSBADCRC); xfs_buf_ioerror(bp, -EFSBADCRC);
else if (!xfs_bmbt_verify(bp)) else if (!xfs_bmbt_verify(bp))
xfs_buf_ioerror(bp, EFSCORRUPTED); xfs_buf_ioerror(bp, -EFSCORRUPTED);
if (bp->b_error) { if (bp->b_error) {
trace_xfs_btree_corrupt(bp, _RET_IP_); trace_xfs_btree_corrupt(bp, _RET_IP_);
...@@ -795,7 +795,7 @@ xfs_bmbt_write_verify( ...@@ -795,7 +795,7 @@ xfs_bmbt_write_verify(
{ {
if (!xfs_bmbt_verify(bp)) { if (!xfs_bmbt_verify(bp)) {
trace_xfs_btree_corrupt(bp, _RET_IP_); trace_xfs_btree_corrupt(bp, _RET_IP_);
xfs_buf_ioerror(bp, EFSCORRUPTED); xfs_buf_ioerror(bp, -EFSCORRUPTED);
xfs_verifier_error(bp); xfs_verifier_error(bp);
return; return;
} }
...@@ -959,7 +959,7 @@ xfs_bmbt_change_owner( ...@@ -959,7 +959,7 @@ xfs_bmbt_change_owner(
cur = xfs_bmbt_init_cursor(ip->i_mount, tp, ip, whichfork); cur = xfs_bmbt_init_cursor(ip->i_mount, tp, ip, whichfork);
if (!cur) if (!cur)
return ENOMEM; return -ENOMEM;
error = xfs_btree_change_owner(cur, new_owner, buffer_list); error = xfs_btree_change_owner(cur, new_owner, buffer_list);
xfs_btree_del_cursor(cur, error ? XFS_BTREE_ERROR : XFS_BTREE_NOERROR); xfs_btree_del_cursor(cur, error ? XFS_BTREE_ERROR : XFS_BTREE_NOERROR);
......
...@@ -92,7 +92,7 @@ xfs_btree_check_lblock( ...@@ -92,7 +92,7 @@ xfs_btree_check_lblock(
if (bp) if (bp)
trace_xfs_btree_corrupt(bp, _RET_IP_); trace_xfs_btree_corrupt(bp, _RET_IP_);
XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_LOW, mp); XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_LOW, mp);
return XFS_ERROR(EFSCORRUPTED); return -EFSCORRUPTED;
} }
return 0; return 0;
} }
...@@ -140,7 +140,7 @@ xfs_btree_check_sblock( ...@@ -140,7 +140,7 @@ xfs_btree_check_sblock(
if (bp) if (bp)
trace_xfs_btree_corrupt(bp, _RET_IP_); trace_xfs_btree_corrupt(bp, _RET_IP_);
XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_LOW, mp); XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_LOW, mp);
return XFS_ERROR(EFSCORRUPTED); return -EFSCORRUPTED;
} }
return 0; return 0;
} }
...@@ -1140,7 +1140,7 @@ xfs_btree_get_buf_block( ...@@ -1140,7 +1140,7 @@ xfs_btree_get_buf_block(
mp->m_bsize, flags); mp->m_bsize, flags);
if (!*bpp) if (!*bpp)
return ENOMEM; return -ENOMEM;
(*bpp)->b_ops = cur->bc_ops->buf_ops; (*bpp)->b_ops = cur->bc_ops->buf_ops;
*block = XFS_BUF_TO_BLOCK(*bpp); *block = XFS_BUF_TO_BLOCK(*bpp);
...@@ -1498,7 +1498,7 @@ xfs_btree_increment( ...@@ -1498,7 +1498,7 @@ xfs_btree_increment(
if (cur->bc_flags & XFS_BTREE_ROOT_IN_INODE) if (cur->bc_flags & XFS_BTREE_ROOT_IN_INODE)
goto out0; goto out0;
ASSERT(0); ASSERT(0);
error = EFSCORRUPTED; error = -EFSCORRUPTED;
goto error0; goto error0;
} }
ASSERT(lev < cur->bc_nlevels); ASSERT(lev < cur->bc_nlevels);
...@@ -1597,7 +1597,7 @@ xfs_btree_decrement( ...@@ -1597,7 +1597,7 @@ xfs_btree_decrement(
if (cur->bc_flags & XFS_BTREE_ROOT_IN_INODE) if (cur->bc_flags & XFS_BTREE_ROOT_IN_INODE)
goto out0; goto out0;
ASSERT(0); ASSERT(0);
error = EFSCORRUPTED; error = -EFSCORRUPTED;
goto error0; goto error0;
} }
ASSERT(lev < cur->bc_nlevels); ASSERT(lev < cur->bc_nlevels);
...@@ -4018,7 +4018,7 @@ xfs_btree_block_change_owner( ...@@ -4018,7 +4018,7 @@ xfs_btree_block_change_owner(
/* now read rh sibling block for next iteration */ /* now read rh sibling block for next iteration */
xfs_btree_get_sibling(cur, block, &rptr, XFS_BB_RIGHTSIB); xfs_btree_get_sibling(cur, block, &rptr, XFS_BB_RIGHTSIB);
if (xfs_btree_ptr_is_null(cur, &rptr)) if (xfs_btree_ptr_is_null(cur, &rptr))
return ENOENT; return -ENOENT;
return xfs_btree_lookup_get_block(cur, level, &rptr, &block); return xfs_btree_lookup_get_block(cur, level, &rptr, &block);
} }
...@@ -4061,7 +4061,7 @@ xfs_btree_change_owner( ...@@ -4061,7 +4061,7 @@ xfs_btree_change_owner(
buffer_list); buffer_list);
} while (!error); } while (!error);
if (error != ENOENT) if (error != -ENOENT)
return error; return error;
} }
......
...@@ -185,7 +185,7 @@ xfs_da3_node_write_verify( ...@@ -185,7 +185,7 @@ xfs_da3_node_write_verify(
struct xfs_da3_node_hdr *hdr3 = bp->b_addr; struct xfs_da3_node_hdr *hdr3 = bp->b_addr;
if (!xfs_da3_node_verify(bp)) { if (!xfs_da3_node_verify(bp)) {
xfs_buf_ioerror(bp, EFSCORRUPTED); xfs_buf_ioerror(bp, -EFSCORRUPTED);
xfs_verifier_error(bp); xfs_verifier_error(bp);
return; return;
} }
...@@ -214,13 +214,13 @@ xfs_da3_node_read_verify( ...@@ -214,13 +214,13 @@ xfs_da3_node_read_verify(
switch (be16_to_cpu(info->magic)) { switch (be16_to_cpu(info->magic)) {
case XFS_DA3_NODE_MAGIC: case XFS_DA3_NODE_MAGIC:
if (!xfs_buf_verify_cksum(bp, XFS_DA3_NODE_CRC_OFF)) { if (!xfs_buf_verify_cksum(bp, XFS_DA3_NODE_CRC_OFF)) {
xfs_buf_ioerror(bp, EFSBADCRC); xfs_buf_ioerror(bp, -EFSBADCRC);
break; break;
} }
/* fall through */ /* fall through */
case XFS_DA_NODE_MAGIC: case XFS_DA_NODE_MAGIC:
if (!xfs_da3_node_verify(bp)) { if (!xfs_da3_node_verify(bp)) {
xfs_buf_ioerror(bp, EFSCORRUPTED); xfs_buf_ioerror(bp, -EFSCORRUPTED);
break; break;
} }
return; return;
...@@ -315,7 +315,7 @@ xfs_da3_node_create( ...@@ -315,7 +315,7 @@ xfs_da3_node_create(
error = xfs_da_get_buf(tp, dp, blkno, -1, &bp, whichfork); error = xfs_da_get_buf(tp, dp, blkno, -1, &bp, whichfork);
if (error) if (error)
return(error); return error;
bp->b_ops = &xfs_da3_node_buf_ops; bp->b_ops = &xfs_da3_node_buf_ops;
xfs_trans_buf_set_type(tp, bp, XFS_BLFT_DA_NODE_BUF); xfs_trans_buf_set_type(tp, bp, XFS_BLFT_DA_NODE_BUF);
node = bp->b_addr; node = bp->b_addr;
...@@ -337,7 +337,7 @@ xfs_da3_node_create( ...@@ -337,7 +337,7 @@ xfs_da3_node_create(
XFS_DA_LOGRANGE(node, &node->hdr, dp->d_ops->node_hdr_size)); XFS_DA_LOGRANGE(node, &node->hdr, dp->d_ops->node_hdr_size));
*bpp = bp; *bpp = bp;
return(0); return 0;
} }
/* /*
...@@ -385,8 +385,8 @@ xfs_da3_split( ...@@ -385,8 +385,8 @@ xfs_da3_split(
switch (oldblk->magic) { switch (oldblk->magic) {
case XFS_ATTR_LEAF_MAGIC: case XFS_ATTR_LEAF_MAGIC:
error = xfs_attr3_leaf_split(state, oldblk, newblk); error = xfs_attr3_leaf_split(state, oldblk, newblk);
if ((error != 0) && (error != ENOSPC)) { if ((error != 0) && (error != -ENOSPC)) {
return(error); /* GROT: attr is inconsistent */ return error; /* GROT: attr is inconsistent */
} }
if (!error) { if (!error) {
addblk = newblk; addblk = newblk;
...@@ -408,7 +408,7 @@ xfs_da3_split( ...@@ -408,7 +408,7 @@ xfs_da3_split(
&state->extrablk); &state->extrablk);
} }
if (error) if (error)
return(error); /* GROT: attr inconsistent */ return error; /* GROT: attr inconsistent */
addblk = newblk; addblk = newblk;
break; break;
case XFS_DIR2_LEAFN_MAGIC: case XFS_DIR2_LEAFN_MAGIC:
...@@ -422,7 +422,7 @@ xfs_da3_split( ...@@ -422,7 +422,7 @@ xfs_da3_split(
max - i, &action); max - i, &action);
addblk->bp = NULL; addblk->bp = NULL;
if (error) if (error)
return(error); /* GROT: dir is inconsistent */ return error; /* GROT: dir is inconsistent */
/* /*
* Record the newly split block for the next time thru? * Record the newly split block for the next time thru?
*/ */
...@@ -439,7 +439,7 @@ xfs_da3_split( ...@@ -439,7 +439,7 @@ xfs_da3_split(
xfs_da3_fixhashpath(state, &state->path); xfs_da3_fixhashpath(state, &state->path);
} }
if (!addblk) if (!addblk)
return(0); return 0;
/* /*
* Split the root node. * Split the root node.
...@@ -449,7 +449,7 @@ xfs_da3_split( ...@@ -449,7 +449,7 @@ xfs_da3_split(
error = xfs_da3_root_split(state, oldblk, addblk); error = xfs_da3_root_split(state, oldblk, addblk);
if (error) { if (error) {
addblk->bp = NULL; addblk->bp = NULL;
return(error); /* GROT: dir is inconsistent */ return error; /* GROT: dir is inconsistent */
} }
/* /*
...@@ -492,7 +492,7 @@ xfs_da3_split( ...@@ -492,7 +492,7 @@ xfs_da3_split(
sizeof(node->hdr.info))); sizeof(node->hdr.info)));
} }
addblk->bp = NULL; addblk->bp = NULL;
return(0); return 0;
} }
/* /*
...@@ -670,18 +670,18 @@ xfs_da3_node_split( ...@@ -670,18 +670,18 @@ xfs_da3_node_split(
*/ */
error = xfs_da_grow_inode(state->args, &blkno); error = xfs_da_grow_inode(state->args, &blkno);
if (error) if (error)
return(error); /* GROT: dir is inconsistent */ return error; /* GROT: dir is inconsistent */
error = xfs_da3_node_create(state->args, blkno, treelevel, error = xfs_da3_node_create(state->args, blkno, treelevel,
&newblk->bp, state->args->whichfork); &newblk->bp, state->args->whichfork);
if (error) if (error)
return(error); /* GROT: dir is inconsistent */ return error; /* GROT: dir is inconsistent */
newblk->blkno = blkno; newblk->blkno = blkno;
newblk->magic = XFS_DA_NODE_MAGIC; newblk->magic = XFS_DA_NODE_MAGIC;
xfs_da3_node_rebalance(state, oldblk, newblk); xfs_da3_node_rebalance(state, oldblk, newblk);
error = xfs_da3_blk_link(state, oldblk, newblk); error = xfs_da3_blk_link(state, oldblk, newblk);
if (error) if (error)
return(error); return error;
*result = 1; *result = 1;
} else { } else {
*result = 0; *result = 0;
...@@ -721,7 +721,7 @@ xfs_da3_node_split( ...@@ -721,7 +721,7 @@ xfs_da3_node_split(
} }
} }
return(0); return 0;
} }
/* /*
...@@ -963,9 +963,9 @@ xfs_da3_join( ...@@ -963,9 +963,9 @@ xfs_da3_join(
case XFS_ATTR_LEAF_MAGIC: case XFS_ATTR_LEAF_MAGIC:
error = xfs_attr3_leaf_toosmall(state, &action); error = xfs_attr3_leaf_toosmall(state, &action);
if (error) if (error)
return(error); return error;
if (action == 0) if (action == 0)
return(0); return 0;
xfs_attr3_leaf_unbalance(state, drop_blk, save_blk); xfs_attr3_leaf_unbalance(state, drop_blk, save_blk);
break; break;
case XFS_DIR2_LEAFN_MAGIC: case XFS_DIR2_LEAFN_MAGIC:
...@@ -985,7 +985,7 @@ xfs_da3_join( ...@@ -985,7 +985,7 @@ xfs_da3_join(
xfs_da3_fixhashpath(state, &state->path); xfs_da3_fixhashpath(state, &state->path);
error = xfs_da3_node_toosmall(state, &action); error = xfs_da3_node_toosmall(state, &action);
if (error) if (error)
return(error); return error;
if (action == 0) if (action == 0)
return 0; return 0;
xfs_da3_node_unbalance(state, drop_blk, save_blk); xfs_da3_node_unbalance(state, drop_blk, save_blk);
...@@ -995,12 +995,12 @@ xfs_da3_join( ...@@ -995,12 +995,12 @@ xfs_da3_join(
error = xfs_da3_blk_unlink(state, drop_blk, save_blk); error = xfs_da3_blk_unlink(state, drop_blk, save_blk);
xfs_da_state_kill_altpath(state); xfs_da_state_kill_altpath(state);
if (error) if (error)
return(error); return error;
error = xfs_da_shrink_inode(state->args, drop_blk->blkno, error = xfs_da_shrink_inode(state->args, drop_blk->blkno,
drop_blk->bp); drop_blk->bp);
drop_blk->bp = NULL; drop_blk->bp = NULL;
if (error) if (error)
return(error); return error;
} }
/* /*
* We joined all the way to the top. If it turns out that * We joined all the way to the top. If it turns out that
...@@ -1010,7 +1010,7 @@ xfs_da3_join( ...@@ -1010,7 +1010,7 @@ xfs_da3_join(
xfs_da3_node_remove(state, drop_blk); xfs_da3_node_remove(state, drop_blk);
xfs_da3_fixhashpath(state, &state->path); xfs_da3_fixhashpath(state, &state->path);
error = xfs_da3_root_join(state, &state->path.blk[0]); error = xfs_da3_root_join(state, &state->path.blk[0]);
return(error); return error;
} }
#ifdef DEBUG #ifdef DEBUG
...@@ -1099,7 +1099,7 @@ xfs_da3_root_join( ...@@ -1099,7 +1099,7 @@ xfs_da3_root_join(
xfs_trans_log_buf(args->trans, root_blk->bp, 0, xfs_trans_log_buf(args->trans, root_blk->bp, 0,
args->geo->blksize - 1); args->geo->blksize - 1);
error = xfs_da_shrink_inode(args, child, bp); error = xfs_da_shrink_inode(args, child, bp);
return(error); return error;
} }
/* /*
...@@ -1142,7 +1142,7 @@ xfs_da3_node_toosmall( ...@@ -1142,7 +1142,7 @@ xfs_da3_node_toosmall(
dp->d_ops->node_hdr_from_disk(&nodehdr, node); dp->d_ops->node_hdr_from_disk(&nodehdr, node);
if (nodehdr.count > (state->args->geo->node_ents >> 1)) { if (nodehdr.count > (state->args->geo->node_ents >> 1)) {
*action = 0; /* blk over 50%, don't try to join */ *action = 0; /* blk over 50%, don't try to join */
return(0); /* blk over 50%, don't try to join */ return 0; /* blk over 50%, don't try to join */
} }
/* /*
...@@ -1161,13 +1161,13 @@ xfs_da3_node_toosmall( ...@@ -1161,13 +1161,13 @@ xfs_da3_node_toosmall(
error = xfs_da3_path_shift(state, &state->altpath, forward, error = xfs_da3_path_shift(state, &state->altpath, forward,
0, &retval); 0, &retval);
if (error) if (error)
return(error); return error;
if (retval) { if (retval) {
*action = 0; *action = 0;
} else { } else {
*action = 2; *action = 2;
} }
return(0); return 0;
} }
/* /*
...@@ -1194,7 +1194,7 @@ xfs_da3_node_toosmall( ...@@ -1194,7 +1194,7 @@ xfs_da3_node_toosmall(
error = xfs_da3_node_read(state->args->trans, dp, error = xfs_da3_node_read(state->args->trans, dp,
blkno, -1, &bp, state->args->whichfork); blkno, -1, &bp, state->args->whichfork);
if (error) if (error)
return(error); return error;
node = bp->b_addr; node = bp->b_addr;
dp->d_ops->node_hdr_from_disk(&thdr, node); dp->d_ops->node_hdr_from_disk(&thdr, node);
...@@ -1486,7 +1486,7 @@ xfs_da3_node_lookup_int( ...@@ -1486,7 +1486,7 @@ xfs_da3_node_lookup_int(
if (error) { if (error) {
blk->blkno = 0; blk->blkno = 0;
state->path.active--; state->path.active--;
return(error); return error;
} }
curr = blk->bp->b_addr; curr = blk->bp->b_addr;
blk->magic = be16_to_cpu(curr->magic); blk->magic = be16_to_cpu(curr->magic);
...@@ -1579,25 +1579,25 @@ xfs_da3_node_lookup_int( ...@@ -1579,25 +1579,25 @@ xfs_da3_node_lookup_int(
args->blkno = blk->blkno; args->blkno = blk->blkno;
} else { } else {
ASSERT(0); ASSERT(0);
return XFS_ERROR(EFSCORRUPTED); return -EFSCORRUPTED;
} }
if (((retval == ENOENT) || (retval == ENOATTR)) && if (((retval == -ENOENT) || (retval == -ENOATTR)) &&
(blk->hashval == args->hashval)) { (blk->hashval == args->hashval)) {
error = xfs_da3_path_shift(state, &state->path, 1, 1, error = xfs_da3_path_shift(state, &state->path, 1, 1,
&retval); &retval);
if (error) if (error)
return(error); return error;
if (retval == 0) { if (retval == 0) {
continue; continue;
} else if (blk->magic == XFS_ATTR_LEAF_MAGIC) { } else if (blk->magic == XFS_ATTR_LEAF_MAGIC) {
/* path_shift() gives ENOENT */ /* path_shift() gives ENOENT */
retval = XFS_ERROR(ENOATTR); retval = -ENOATTR;
} }
} }
break; break;
} }
*result = retval; *result = retval;
return(0); return 0;
} }
/*======================================================================== /*========================================================================
...@@ -1692,7 +1692,7 @@ xfs_da3_blk_link( ...@@ -1692,7 +1692,7 @@ xfs_da3_blk_link(
be32_to_cpu(old_info->back), be32_to_cpu(old_info->back),
-1, &bp, args->whichfork); -1, &bp, args->whichfork);
if (error) if (error)
return(error); return error;
ASSERT(bp != NULL); ASSERT(bp != NULL);
tmp_info = bp->b_addr; tmp_info = bp->b_addr;
ASSERT(tmp_info->magic == old_info->magic); ASSERT(tmp_info->magic == old_info->magic);
...@@ -1713,7 +1713,7 @@ xfs_da3_blk_link( ...@@ -1713,7 +1713,7 @@ xfs_da3_blk_link(
be32_to_cpu(old_info->forw), be32_to_cpu(old_info->forw),
-1, &bp, args->whichfork); -1, &bp, args->whichfork);
if (error) if (error)
return(error); return error;
ASSERT(bp != NULL); ASSERT(bp != NULL);
tmp_info = bp->b_addr; tmp_info = bp->b_addr;
ASSERT(tmp_info->magic == old_info->magic); ASSERT(tmp_info->magic == old_info->magic);
...@@ -1726,7 +1726,7 @@ xfs_da3_blk_link( ...@@ -1726,7 +1726,7 @@ xfs_da3_blk_link(
xfs_trans_log_buf(args->trans, old_blk->bp, 0, sizeof(*tmp_info) - 1); xfs_trans_log_buf(args->trans, old_blk->bp, 0, sizeof(*tmp_info) - 1);
xfs_trans_log_buf(args->trans, new_blk->bp, 0, sizeof(*tmp_info) - 1); xfs_trans_log_buf(args->trans, new_blk->bp, 0, sizeof(*tmp_info) - 1);
return(0); return 0;
} }
/* /*
...@@ -1772,7 +1772,7 @@ xfs_da3_blk_unlink( ...@@ -1772,7 +1772,7 @@ xfs_da3_blk_unlink(
be32_to_cpu(drop_info->back), be32_to_cpu(drop_info->back),
-1, &bp, args->whichfork); -1, &bp, args->whichfork);
if (error) if (error)
return(error); return error;
ASSERT(bp != NULL); ASSERT(bp != NULL);
tmp_info = bp->b_addr; tmp_info = bp->b_addr;
ASSERT(tmp_info->magic == save_info->magic); ASSERT(tmp_info->magic == save_info->magic);
...@@ -1789,7 +1789,7 @@ xfs_da3_blk_unlink( ...@@ -1789,7 +1789,7 @@ xfs_da3_blk_unlink(
be32_to_cpu(drop_info->forw), be32_to_cpu(drop_info->forw),
-1, &bp, args->whichfork); -1, &bp, args->whichfork);
if (error) if (error)
return(error); return error;
ASSERT(bp != NULL); ASSERT(bp != NULL);
tmp_info = bp->b_addr; tmp_info = bp->b_addr;
ASSERT(tmp_info->magic == save_info->magic); ASSERT(tmp_info->magic == save_info->magic);
...@@ -1801,7 +1801,7 @@ xfs_da3_blk_unlink( ...@@ -1801,7 +1801,7 @@ xfs_da3_blk_unlink(
} }
xfs_trans_log_buf(args->trans, save_blk->bp, 0, sizeof(*save_info) - 1); xfs_trans_log_buf(args->trans, save_blk->bp, 0, sizeof(*save_info) - 1);
return(0); return 0;
} }
/* /*
...@@ -1859,9 +1859,9 @@ xfs_da3_path_shift( ...@@ -1859,9 +1859,9 @@ xfs_da3_path_shift(
} }
} }
if (level < 0) { if (level < 0) {
*result = XFS_ERROR(ENOENT); /* we're out of our tree */ *result = -ENOENT; /* we're out of our tree */
ASSERT(args->op_flags & XFS_DA_OP_OKNOENT); ASSERT(args->op_flags & XFS_DA_OP_OKNOENT);
return(0); return 0;
} }
/* /*
...@@ -1883,7 +1883,7 @@ xfs_da3_path_shift( ...@@ -1883,7 +1883,7 @@ xfs_da3_path_shift(
error = xfs_da3_node_read(args->trans, dp, blkno, -1, error = xfs_da3_node_read(args->trans, dp, blkno, -1,
&blk->bp, args->whichfork); &blk->bp, args->whichfork);
if (error) if (error)
return(error); return error;
info = blk->bp->b_addr; info = blk->bp->b_addr;
ASSERT(info->magic == cpu_to_be16(XFS_DA_NODE_MAGIC) || ASSERT(info->magic == cpu_to_be16(XFS_DA_NODE_MAGIC) ||
info->magic == cpu_to_be16(XFS_DA3_NODE_MAGIC) || info->magic == cpu_to_be16(XFS_DA3_NODE_MAGIC) ||
...@@ -2068,7 +2068,7 @@ xfs_da_grow_inode_int( ...@@ -2068,7 +2068,7 @@ xfs_da_grow_inode_int(
if (got != count || mapp[0].br_startoff != *bno || if (got != count || mapp[0].br_startoff != *bno ||
mapp[mapi - 1].br_startoff + mapp[mapi - 1].br_blockcount != mapp[mapi - 1].br_startoff + mapp[mapi - 1].br_blockcount !=
*bno + count) { *bno + count) {
error = XFS_ERROR(ENOSPC); error = -ENOSPC;
goto out_free_map; goto out_free_map;
} }
...@@ -2158,7 +2158,7 @@ xfs_da3_swap_lastblock( ...@@ -2158,7 +2158,7 @@ xfs_da3_swap_lastblock(
if (unlikely(lastoff == 0)) { if (unlikely(lastoff == 0)) {
XFS_ERROR_REPORT("xfs_da_swap_lastblock(1)", XFS_ERRLEVEL_LOW, XFS_ERROR_REPORT("xfs_da_swap_lastblock(1)", XFS_ERRLEVEL_LOW,
mp); mp);
return XFS_ERROR(EFSCORRUPTED); return -EFSCORRUPTED;
} }
/* /*
* Read the last block in the btree space. * Read the last block in the btree space.
...@@ -2209,7 +2209,7 @@ xfs_da3_swap_lastblock( ...@@ -2209,7 +2209,7 @@ xfs_da3_swap_lastblock(
sib_info->magic != dead_info->magic)) { sib_info->magic != dead_info->magic)) {
XFS_ERROR_REPORT("xfs_da_swap_lastblock(2)", XFS_ERROR_REPORT("xfs_da_swap_lastblock(2)",
XFS_ERRLEVEL_LOW, mp); XFS_ERRLEVEL_LOW, mp);
error = XFS_ERROR(EFSCORRUPTED); error = -EFSCORRUPTED;
goto done; goto done;
} }
sib_info->forw = cpu_to_be32(dead_blkno); sib_info->forw = cpu_to_be32(dead_blkno);
...@@ -2231,7 +2231,7 @@ xfs_da3_swap_lastblock( ...@@ -2231,7 +2231,7 @@ xfs_da3_swap_lastblock(
sib_info->magic != dead_info->magic)) { sib_info->magic != dead_info->magic)) {
XFS_ERROR_REPORT("xfs_da_swap_lastblock(3)", XFS_ERROR_REPORT("xfs_da_swap_lastblock(3)",
XFS_ERRLEVEL_LOW, mp); XFS_ERRLEVEL_LOW, mp);
error = XFS_ERROR(EFSCORRUPTED); error = -EFSCORRUPTED;
goto done; goto done;
} }
sib_info->back = cpu_to_be32(dead_blkno); sib_info->back = cpu_to_be32(dead_blkno);
...@@ -2254,7 +2254,7 @@ xfs_da3_swap_lastblock( ...@@ -2254,7 +2254,7 @@ xfs_da3_swap_lastblock(
if (level >= 0 && level != par_hdr.level + 1) { if (level >= 0 && level != par_hdr.level + 1) {
XFS_ERROR_REPORT("xfs_da_swap_lastblock(4)", XFS_ERROR_REPORT("xfs_da_swap_lastblock(4)",
XFS_ERRLEVEL_LOW, mp); XFS_ERRLEVEL_LOW, mp);
error = XFS_ERROR(EFSCORRUPTED); error = -EFSCORRUPTED;
goto done; goto done;
} }
level = par_hdr.level; level = par_hdr.level;
...@@ -2267,7 +2267,7 @@ xfs_da3_swap_lastblock( ...@@ -2267,7 +2267,7 @@ xfs_da3_swap_lastblock(
if (entno == par_hdr.count) { if (entno == par_hdr.count) {
XFS_ERROR_REPORT("xfs_da_swap_lastblock(5)", XFS_ERROR_REPORT("xfs_da_swap_lastblock(5)",
XFS_ERRLEVEL_LOW, mp); XFS_ERRLEVEL_LOW, mp);
error = XFS_ERROR(EFSCORRUPTED); error = -EFSCORRUPTED;
goto done; goto done;
} }
par_blkno = be32_to_cpu(btree[entno].before); par_blkno = be32_to_cpu(btree[entno].before);
...@@ -2294,7 +2294,7 @@ xfs_da3_swap_lastblock( ...@@ -2294,7 +2294,7 @@ xfs_da3_swap_lastblock(
if (unlikely(par_blkno == 0)) { if (unlikely(par_blkno == 0)) {
XFS_ERROR_REPORT("xfs_da_swap_lastblock(6)", XFS_ERROR_REPORT("xfs_da_swap_lastblock(6)",
XFS_ERRLEVEL_LOW, mp); XFS_ERRLEVEL_LOW, mp);
error = XFS_ERROR(EFSCORRUPTED); error = -EFSCORRUPTED;
goto done; goto done;
} }
error = xfs_da3_node_read(tp, dp, par_blkno, -1, &par_buf, w); error = xfs_da3_node_read(tp, dp, par_blkno, -1, &par_buf, w);
...@@ -2305,7 +2305,7 @@ xfs_da3_swap_lastblock( ...@@ -2305,7 +2305,7 @@ xfs_da3_swap_lastblock(
if (par_hdr.level != level) { if (par_hdr.level != level) {
XFS_ERROR_REPORT("xfs_da_swap_lastblock(7)", XFS_ERROR_REPORT("xfs_da_swap_lastblock(7)",
XFS_ERRLEVEL_LOW, mp); XFS_ERRLEVEL_LOW, mp);
error = XFS_ERROR(EFSCORRUPTED); error = -EFSCORRUPTED;
goto done; goto done;
} }
btree = dp->d_ops->node_tree_p(par_node); btree = dp->d_ops->node_tree_p(par_node);
...@@ -2359,7 +2359,7 @@ xfs_da_shrink_inode( ...@@ -2359,7 +2359,7 @@ xfs_da_shrink_inode(
error = xfs_bunmapi(tp, dp, dead_blkno, count, error = xfs_bunmapi(tp, dp, dead_blkno, count,
xfs_bmapi_aflag(w)|XFS_BMAPI_METADATA, xfs_bmapi_aflag(w)|XFS_BMAPI_METADATA,
0, args->firstblock, args->flist, &done); 0, args->firstblock, args->flist, &done);
if (error == ENOSPC) { if (error == -ENOSPC) {
if (w != XFS_DATA_FORK) if (w != XFS_DATA_FORK)
break; break;
error = xfs_da3_swap_lastblock(args, &dead_blkno, error = xfs_da3_swap_lastblock(args, &dead_blkno,
...@@ -2427,7 +2427,7 @@ xfs_buf_map_from_irec( ...@@ -2427,7 +2427,7 @@ xfs_buf_map_from_irec(
map = kmem_zalloc(nirecs * sizeof(struct xfs_buf_map), map = kmem_zalloc(nirecs * sizeof(struct xfs_buf_map),
KM_SLEEP | KM_NOFS); KM_SLEEP | KM_NOFS);
if (!map) if (!map)
return ENOMEM; return -ENOMEM;
*mapp = map; *mapp = map;
} }
...@@ -2500,8 +2500,8 @@ xfs_dabuf_map( ...@@ -2500,8 +2500,8 @@ xfs_dabuf_map(
} }
if (!xfs_da_map_covers_blocks(nirecs, irecs, bno, nfsb)) { if (!xfs_da_map_covers_blocks(nirecs, irecs, bno, nfsb)) {
error = mappedbno == -2 ? -1 : XFS_ERROR(EFSCORRUPTED); error = mappedbno == -2 ? -1 : -EFSCORRUPTED;
if (unlikely(error == EFSCORRUPTED)) { if (unlikely(error == -EFSCORRUPTED)) {
if (xfs_error_level >= XFS_ERRLEVEL_LOW) { if (xfs_error_level >= XFS_ERRLEVEL_LOW) {
int i; int i;
xfs_alert(mp, "%s: bno %lld dir: inode %lld", xfs_alert(mp, "%s: bno %lld dir: inode %lld",
...@@ -2561,7 +2561,7 @@ xfs_da_get_buf( ...@@ -2561,7 +2561,7 @@ xfs_da_get_buf(
bp = xfs_trans_get_buf_map(trans, dp->i_mount->m_ddev_targp, bp = xfs_trans_get_buf_map(trans, dp->i_mount->m_ddev_targp,
mapp, nmap, 0); mapp, nmap, 0);
error = bp ? bp->b_error : XFS_ERROR(EIO); error = bp ? bp->b_error : -EIO;
if (error) { if (error) {
xfs_trans_brelse(trans, bp); xfs_trans_brelse(trans, bp);
goto out_free; goto out_free;
......
...@@ -108,7 +108,7 @@ xfs_da_mount( ...@@ -108,7 +108,7 @@ xfs_da_mount(
if (!mp->m_dir_geo || !mp->m_attr_geo) { if (!mp->m_dir_geo || !mp->m_attr_geo) {
kmem_free(mp->m_dir_geo); kmem_free(mp->m_dir_geo);
kmem_free(mp->m_attr_geo); kmem_free(mp->m_attr_geo);
return ENOMEM; return -ENOMEM;
} }
/* set up directory geometry */ /* set up directory geometry */
...@@ -202,7 +202,7 @@ xfs_dir_ino_validate( ...@@ -202,7 +202,7 @@ xfs_dir_ino_validate(
xfs_warn(mp, "Invalid inode number 0x%Lx", xfs_warn(mp, "Invalid inode number 0x%Lx",
(unsigned long long) ino); (unsigned long long) ino);
XFS_ERROR_REPORT("xfs_dir_ino_validate", XFS_ERRLEVEL_LOW, mp); XFS_ERROR_REPORT("xfs_dir_ino_validate", XFS_ERRLEVEL_LOW, mp);
return XFS_ERROR(EFSCORRUPTED); return -EFSCORRUPTED;
} }
return 0; return 0;
} }
...@@ -226,7 +226,7 @@ xfs_dir_init( ...@@ -226,7 +226,7 @@ xfs_dir_init(
args = kmem_zalloc(sizeof(*args), KM_SLEEP | KM_NOFS); args = kmem_zalloc(sizeof(*args), KM_SLEEP | KM_NOFS);
if (!args) if (!args)
return ENOMEM; return -ENOMEM;
args->geo = dp->i_mount->m_dir_geo; args->geo = dp->i_mount->m_dir_geo;
args->dp = dp; args->dp = dp;
...@@ -261,7 +261,7 @@ xfs_dir_createname( ...@@ -261,7 +261,7 @@ xfs_dir_createname(
args = kmem_zalloc(sizeof(*args), KM_SLEEP | KM_NOFS); args = kmem_zalloc(sizeof(*args), KM_SLEEP | KM_NOFS);
if (!args) if (!args)
return ENOMEM; return -ENOMEM;
args->geo = dp->i_mount->m_dir_geo; args->geo = dp->i_mount->m_dir_geo;
args->name = name->name; args->name = name->name;
...@@ -314,18 +314,18 @@ xfs_dir_cilookup_result( ...@@ -314,18 +314,18 @@ xfs_dir_cilookup_result(
int len) int len)
{ {
if (args->cmpresult == XFS_CMP_DIFFERENT) if (args->cmpresult == XFS_CMP_DIFFERENT)
return ENOENT; return -ENOENT;
if (args->cmpresult != XFS_CMP_CASE || if (args->cmpresult != XFS_CMP_CASE ||
!(args->op_flags & XFS_DA_OP_CILOOKUP)) !(args->op_flags & XFS_DA_OP_CILOOKUP))
return EEXIST; return -EEXIST;
args->value = kmem_alloc(len, KM_NOFS | KM_MAYFAIL); args->value = kmem_alloc(len, KM_NOFS | KM_MAYFAIL);
if (!args->value) if (!args->value)
return ENOMEM; return -ENOMEM;
memcpy(args->value, name, len); memcpy(args->value, name, len);
args->valuelen = len; args->valuelen = len;
return EEXIST; return -EEXIST;
} }
/* /*
...@@ -392,7 +392,7 @@ xfs_dir_lookup( ...@@ -392,7 +392,7 @@ xfs_dir_lookup(
rval = xfs_dir2_node_lookup(args); rval = xfs_dir2_node_lookup(args);
out_check_rval: out_check_rval:
if (rval == EEXIST) if (rval == -EEXIST)
rval = 0; rval = 0;
if (!rval) { if (!rval) {
*inum = args->inumber; *inum = args->inumber;
...@@ -428,7 +428,7 @@ xfs_dir_removename( ...@@ -428,7 +428,7 @@ xfs_dir_removename(
args = kmem_zalloc(sizeof(*args), KM_SLEEP | KM_NOFS); args = kmem_zalloc(sizeof(*args), KM_SLEEP | KM_NOFS);
if (!args) if (!args)
return ENOMEM; return -ENOMEM;
args->geo = dp->i_mount->m_dir_geo; args->geo = dp->i_mount->m_dir_geo;
args->name = name->name; args->name = name->name;
...@@ -493,7 +493,7 @@ xfs_dir_replace( ...@@ -493,7 +493,7 @@ xfs_dir_replace(
args = kmem_zalloc(sizeof(*args), KM_SLEEP | KM_NOFS); args = kmem_zalloc(sizeof(*args), KM_SLEEP | KM_NOFS);
if (!args) if (!args)
return ENOMEM; return -ENOMEM;
args->geo = dp->i_mount->m_dir_geo; args->geo = dp->i_mount->m_dir_geo;
args->name = name->name; args->name = name->name;
...@@ -555,7 +555,7 @@ xfs_dir_canenter( ...@@ -555,7 +555,7 @@ xfs_dir_canenter(
args = kmem_zalloc(sizeof(*args), KM_SLEEP | KM_NOFS); args = kmem_zalloc(sizeof(*args), KM_SLEEP | KM_NOFS);
if (!args) if (!args)
return ENOMEM; return -ENOMEM;
args->geo = dp->i_mount->m_dir_geo; args->geo = dp->i_mount->m_dir_geo;
args->name = name->name; args->name = name->name;
......
...@@ -91,9 +91,9 @@ xfs_dir3_block_read_verify( ...@@ -91,9 +91,9 @@ xfs_dir3_block_read_verify(
if (xfs_sb_version_hascrc(&mp->m_sb) && if (xfs_sb_version_hascrc(&mp->m_sb) &&
!xfs_buf_verify_cksum(bp, XFS_DIR3_DATA_CRC_OFF)) !xfs_buf_verify_cksum(bp, XFS_DIR3_DATA_CRC_OFF))
xfs_buf_ioerror(bp, EFSBADCRC); xfs_buf_ioerror(bp, -EFSBADCRC);
else if (!xfs_dir3_block_verify(bp)) else if (!xfs_dir3_block_verify(bp))
xfs_buf_ioerror(bp, EFSCORRUPTED); xfs_buf_ioerror(bp, -EFSCORRUPTED);
if (bp->b_error) if (bp->b_error)
xfs_verifier_error(bp); xfs_verifier_error(bp);
...@@ -108,7 +108,7 @@ xfs_dir3_block_write_verify( ...@@ -108,7 +108,7 @@ xfs_dir3_block_write_verify(
struct xfs_dir3_blk_hdr *hdr3 = bp->b_addr; struct xfs_dir3_blk_hdr *hdr3 = bp->b_addr;
if (!xfs_dir3_block_verify(bp)) { if (!xfs_dir3_block_verify(bp)) {
xfs_buf_ioerror(bp, EFSCORRUPTED); xfs_buf_ioerror(bp, -EFSCORRUPTED);
xfs_verifier_error(bp); xfs_verifier_error(bp);
return; return;
} }
...@@ -392,7 +392,7 @@ xfs_dir2_block_addname( ...@@ -392,7 +392,7 @@ xfs_dir2_block_addname(
if (args->op_flags & XFS_DA_OP_JUSTCHECK) { if (args->op_flags & XFS_DA_OP_JUSTCHECK) {
xfs_trans_brelse(tp, bp); xfs_trans_brelse(tp, bp);
if (!dup) if (!dup)
return XFS_ERROR(ENOSPC); return -ENOSPC;
return 0; return 0;
} }
...@@ -402,7 +402,7 @@ xfs_dir2_block_addname( ...@@ -402,7 +402,7 @@ xfs_dir2_block_addname(
if (!dup) { if (!dup) {
/* Don't have a space reservation: return no-space. */ /* Don't have a space reservation: return no-space. */
if (args->total == 0) if (args->total == 0)
return XFS_ERROR(ENOSPC); return -ENOSPC;
/* /*
* Convert to the next larger format. * Convert to the next larger format.
* Then add the new entry in that format. * Then add the new entry in that format.
...@@ -647,7 +647,7 @@ xfs_dir2_block_lookup( ...@@ -647,7 +647,7 @@ xfs_dir2_block_lookup(
args->filetype = dp->d_ops->data_get_ftype(dep); args->filetype = dp->d_ops->data_get_ftype(dep);
error = xfs_dir_cilookup_result(args, dep->name, dep->namelen); error = xfs_dir_cilookup_result(args, dep->name, dep->namelen);
xfs_trans_brelse(args->trans, bp); xfs_trans_brelse(args->trans, bp);
return XFS_ERROR(error); return error;
} }
/* /*
...@@ -703,7 +703,7 @@ xfs_dir2_block_lookup_int( ...@@ -703,7 +703,7 @@ xfs_dir2_block_lookup_int(
if (low > high) { if (low > high) {
ASSERT(args->op_flags & XFS_DA_OP_OKNOENT); ASSERT(args->op_flags & XFS_DA_OP_OKNOENT);
xfs_trans_brelse(tp, bp); xfs_trans_brelse(tp, bp);
return XFS_ERROR(ENOENT); return -ENOENT;
} }
} }
/* /*
...@@ -751,7 +751,7 @@ xfs_dir2_block_lookup_int( ...@@ -751,7 +751,7 @@ xfs_dir2_block_lookup_int(
* No match, release the buffer and return ENOENT. * No match, release the buffer and return ENOENT.
*/ */
xfs_trans_brelse(tp, bp); xfs_trans_brelse(tp, bp);
return XFS_ERROR(ENOENT); return -ENOENT;
} }
/* /*
...@@ -1091,7 +1091,7 @@ xfs_dir2_sf_to_block( ...@@ -1091,7 +1091,7 @@ xfs_dir2_sf_to_block(
*/ */
if (dp->i_d.di_size < offsetof(xfs_dir2_sf_hdr_t, parent)) { if (dp->i_d.di_size < offsetof(xfs_dir2_sf_hdr_t, parent)) {
ASSERT(XFS_FORCED_SHUTDOWN(mp)); ASSERT(XFS_FORCED_SHUTDOWN(mp));
return XFS_ERROR(EIO); return -EIO;
} }
oldsfp = (xfs_dir2_sf_hdr_t *)ifp->if_u1.if_data; oldsfp = (xfs_dir2_sf_hdr_t *)ifp->if_u1.if_data;
......
...@@ -100,7 +100,7 @@ __xfs_dir3_data_check( ...@@ -100,7 +100,7 @@ __xfs_dir3_data_check(
break; break;
default: default:
XFS_ERROR_REPORT("Bad Magic", XFS_ERRLEVEL_LOW, mp); XFS_ERROR_REPORT("Bad Magic", XFS_ERRLEVEL_LOW, mp);
return EFSCORRUPTED; return -EFSCORRUPTED;
} }
/* /*
...@@ -256,7 +256,7 @@ xfs_dir3_data_reada_verify( ...@@ -256,7 +256,7 @@ xfs_dir3_data_reada_verify(
xfs_dir3_data_verify(bp); xfs_dir3_data_verify(bp);
return; return;
default: default:
xfs_buf_ioerror(bp, EFSCORRUPTED); xfs_buf_ioerror(bp, -EFSCORRUPTED);
xfs_verifier_error(bp); xfs_verifier_error(bp);
break; break;
} }
...@@ -270,9 +270,9 @@ xfs_dir3_data_read_verify( ...@@ -270,9 +270,9 @@ xfs_dir3_data_read_verify(
if (xfs_sb_version_hascrc(&mp->m_sb) && if (xfs_sb_version_hascrc(&mp->m_sb) &&
!xfs_buf_verify_cksum(bp, XFS_DIR3_DATA_CRC_OFF)) !xfs_buf_verify_cksum(bp, XFS_DIR3_DATA_CRC_OFF))
xfs_buf_ioerror(bp, EFSBADCRC); xfs_buf_ioerror(bp, -EFSBADCRC);
else if (!xfs_dir3_data_verify(bp)) else if (!xfs_dir3_data_verify(bp))
xfs_buf_ioerror(bp, EFSCORRUPTED); xfs_buf_ioerror(bp, -EFSCORRUPTED);
if (bp->b_error) if (bp->b_error)
xfs_verifier_error(bp); xfs_verifier_error(bp);
...@@ -287,7 +287,7 @@ xfs_dir3_data_write_verify( ...@@ -287,7 +287,7 @@ xfs_dir3_data_write_verify(
struct xfs_dir3_blk_hdr *hdr3 = bp->b_addr; struct xfs_dir3_blk_hdr *hdr3 = bp->b_addr;
if (!xfs_dir3_data_verify(bp)) { if (!xfs_dir3_data_verify(bp)) {
xfs_buf_ioerror(bp, EFSCORRUPTED); xfs_buf_ioerror(bp, -EFSCORRUPTED);
xfs_verifier_error(bp); xfs_verifier_error(bp);
return; return;
} }
......
...@@ -183,9 +183,9 @@ __read_verify( ...@@ -183,9 +183,9 @@ __read_verify(
if (xfs_sb_version_hascrc(&mp->m_sb) && if (xfs_sb_version_hascrc(&mp->m_sb) &&
!xfs_buf_verify_cksum(bp, XFS_DIR3_LEAF_CRC_OFF)) !xfs_buf_verify_cksum(bp, XFS_DIR3_LEAF_CRC_OFF))
xfs_buf_ioerror(bp, EFSBADCRC); xfs_buf_ioerror(bp, -EFSBADCRC);
else if (!xfs_dir3_leaf_verify(bp, magic)) else if (!xfs_dir3_leaf_verify(bp, magic))
xfs_buf_ioerror(bp, EFSCORRUPTED); xfs_buf_ioerror(bp, -EFSCORRUPTED);
if (bp->b_error) if (bp->b_error)
xfs_verifier_error(bp); xfs_verifier_error(bp);
...@@ -201,7 +201,7 @@ __write_verify( ...@@ -201,7 +201,7 @@ __write_verify(
struct xfs_dir3_leaf_hdr *hdr3 = bp->b_addr; struct xfs_dir3_leaf_hdr *hdr3 = bp->b_addr;
if (!xfs_dir3_leaf_verify(bp, magic)) { if (!xfs_dir3_leaf_verify(bp, magic)) {
xfs_buf_ioerror(bp, EFSCORRUPTED); xfs_buf_ioerror(bp, -EFSCORRUPTED);
xfs_verifier_error(bp); xfs_verifier_error(bp);
return; return;
} }
...@@ -731,7 +731,7 @@ xfs_dir2_leaf_addname( ...@@ -731,7 +731,7 @@ xfs_dir2_leaf_addname(
if ((args->op_flags & XFS_DA_OP_JUSTCHECK) || if ((args->op_flags & XFS_DA_OP_JUSTCHECK) ||
args->total == 0) { args->total == 0) {
xfs_trans_brelse(tp, lbp); xfs_trans_brelse(tp, lbp);
return XFS_ERROR(ENOSPC); return -ENOSPC;
} }
/* /*
* Convert to node form. * Convert to node form.
...@@ -755,7 +755,7 @@ xfs_dir2_leaf_addname( ...@@ -755,7 +755,7 @@ xfs_dir2_leaf_addname(
*/ */
if (args->op_flags & XFS_DA_OP_JUSTCHECK) { if (args->op_flags & XFS_DA_OP_JUSTCHECK) {
xfs_trans_brelse(tp, lbp); xfs_trans_brelse(tp, lbp);
return use_block == -1 ? XFS_ERROR(ENOSPC) : 0; return use_block == -1 ? -ENOSPC : 0;
} }
/* /*
* If no allocations are allowed, return now before we've * If no allocations are allowed, return now before we've
...@@ -763,7 +763,7 @@ xfs_dir2_leaf_addname( ...@@ -763,7 +763,7 @@ xfs_dir2_leaf_addname(
*/ */
if (args->total == 0 && use_block == -1) { if (args->total == 0 && use_block == -1) {
xfs_trans_brelse(tp, lbp); xfs_trans_brelse(tp, lbp);
return XFS_ERROR(ENOSPC); return -ENOSPC;
} }
/* /*
* Need to compact the leaf entries, removing stale ones. * Need to compact the leaf entries, removing stale ones.
...@@ -1198,7 +1198,7 @@ xfs_dir2_leaf_lookup( ...@@ -1198,7 +1198,7 @@ xfs_dir2_leaf_lookup(
error = xfs_dir_cilookup_result(args, dep->name, dep->namelen); error = xfs_dir_cilookup_result(args, dep->name, dep->namelen);
xfs_trans_brelse(tp, dbp); xfs_trans_brelse(tp, dbp);
xfs_trans_brelse(tp, lbp); xfs_trans_brelse(tp, lbp);
return XFS_ERROR(error); return error;
} }
/* /*
...@@ -1327,13 +1327,13 @@ xfs_dir2_leaf_lookup_int( ...@@ -1327,13 +1327,13 @@ xfs_dir2_leaf_lookup_int(
return 0; return 0;
} }
/* /*
* No match found, return ENOENT. * No match found, return -ENOENT.
*/ */
ASSERT(cidb == -1); ASSERT(cidb == -1);
if (dbp) if (dbp)
xfs_trans_brelse(tp, dbp); xfs_trans_brelse(tp, dbp);
xfs_trans_brelse(tp, lbp); xfs_trans_brelse(tp, lbp);
return XFS_ERROR(ENOENT); return -ENOENT;
} }
/* /*
...@@ -1440,7 +1440,7 @@ xfs_dir2_leaf_removename( ...@@ -1440,7 +1440,7 @@ xfs_dir2_leaf_removename(
* Just go on, returning success, leaving the * Just go on, returning success, leaving the
* empty block in place. * empty block in place.
*/ */
if (error == ENOSPC && args->total == 0) if (error == -ENOSPC && args->total == 0)
error = 0; error = 0;
xfs_dir3_leaf_check(dp, lbp); xfs_dir3_leaf_check(dp, lbp);
return error; return error;
...@@ -1641,7 +1641,7 @@ xfs_dir2_leaf_trim_data( ...@@ -1641,7 +1641,7 @@ xfs_dir2_leaf_trim_data(
* Get rid of the data block. * Get rid of the data block.
*/ */
if ((error = xfs_dir2_shrink_inode(args, db, dbp))) { if ((error = xfs_dir2_shrink_inode(args, db, dbp))) {
ASSERT(error != ENOSPC); ASSERT(error != -ENOSPC);
xfs_trans_brelse(tp, dbp); xfs_trans_brelse(tp, dbp);
return error; return error;
} }
...@@ -1815,7 +1815,7 @@ xfs_dir2_node_to_leaf( ...@@ -1815,7 +1815,7 @@ xfs_dir2_node_to_leaf(
* punching out the middle of an extent, and this is an * punching out the middle of an extent, and this is an
* isolated block. * isolated block.
*/ */
ASSERT(error != ENOSPC); ASSERT(error != -ENOSPC);
return error; return error;
} }
fbp = NULL; fbp = NULL;
......
...@@ -117,9 +117,9 @@ xfs_dir3_free_read_verify( ...@@ -117,9 +117,9 @@ xfs_dir3_free_read_verify(
if (xfs_sb_version_hascrc(&mp->m_sb) && if (xfs_sb_version_hascrc(&mp->m_sb) &&
!xfs_buf_verify_cksum(bp, XFS_DIR3_FREE_CRC_OFF)) !xfs_buf_verify_cksum(bp, XFS_DIR3_FREE_CRC_OFF))
xfs_buf_ioerror(bp, EFSBADCRC); xfs_buf_ioerror(bp, -EFSBADCRC);
else if (!xfs_dir3_free_verify(bp)) else if (!xfs_dir3_free_verify(bp))
xfs_buf_ioerror(bp, EFSCORRUPTED); xfs_buf_ioerror(bp, -EFSCORRUPTED);
if (bp->b_error) if (bp->b_error)
xfs_verifier_error(bp); xfs_verifier_error(bp);
...@@ -134,7 +134,7 @@ xfs_dir3_free_write_verify( ...@@ -134,7 +134,7 @@ xfs_dir3_free_write_verify(
struct xfs_dir3_blk_hdr *hdr3 = bp->b_addr; struct xfs_dir3_blk_hdr *hdr3 = bp->b_addr;
if (!xfs_dir3_free_verify(bp)) { if (!xfs_dir3_free_verify(bp)) {
xfs_buf_ioerror(bp, EFSCORRUPTED); xfs_buf_ioerror(bp, -EFSCORRUPTED);
xfs_verifier_error(bp); xfs_verifier_error(bp);
return; return;
} }
...@@ -406,7 +406,7 @@ xfs_dir2_leafn_add( ...@@ -406,7 +406,7 @@ xfs_dir2_leafn_add(
* into other peoples memory * into other peoples memory
*/ */
if (index < 0) if (index < 0)
return XFS_ERROR(EFSCORRUPTED); return -EFSCORRUPTED;
/* /*
* If there are already the maximum number of leaf entries in * If there are already the maximum number of leaf entries in
...@@ -417,7 +417,7 @@ xfs_dir2_leafn_add( ...@@ -417,7 +417,7 @@ xfs_dir2_leafn_add(
if (leafhdr.count == dp->d_ops->leaf_max_ents(args->geo)) { if (leafhdr.count == dp->d_ops->leaf_max_ents(args->geo)) {
if (!leafhdr.stale) if (!leafhdr.stale)
return XFS_ERROR(ENOSPC); return -ENOSPC;
compact = leafhdr.stale > 1; compact = leafhdr.stale > 1;
} else } else
compact = 0; compact = 0;
...@@ -629,7 +629,7 @@ xfs_dir2_leafn_lookup_for_addname( ...@@ -629,7 +629,7 @@ xfs_dir2_leafn_lookup_for_addname(
XFS_ERRLEVEL_LOW, mp); XFS_ERRLEVEL_LOW, mp);
if (curfdb != newfdb) if (curfdb != newfdb)
xfs_trans_brelse(tp, curbp); xfs_trans_brelse(tp, curbp);
return XFS_ERROR(EFSCORRUPTED); return -EFSCORRUPTED;
} }
curfdb = newfdb; curfdb = newfdb;
if (be16_to_cpu(bests[fi]) >= length) if (be16_to_cpu(bests[fi]) >= length)
...@@ -660,7 +660,7 @@ xfs_dir2_leafn_lookup_for_addname( ...@@ -660,7 +660,7 @@ xfs_dir2_leafn_lookup_for_addname(
* Return the index, that will be the insertion point. * Return the index, that will be the insertion point.
*/ */
*indexp = index; *indexp = index;
return XFS_ERROR(ENOENT); return -ENOENT;
} }
/* /*
...@@ -789,7 +789,7 @@ xfs_dir2_leafn_lookup_for_entry( ...@@ -789,7 +789,7 @@ xfs_dir2_leafn_lookup_for_entry(
curbp->b_ops = &xfs_dir3_data_buf_ops; curbp->b_ops = &xfs_dir3_data_buf_ops;
xfs_trans_buf_set_type(tp, curbp, XFS_BLFT_DIR_DATA_BUF); xfs_trans_buf_set_type(tp, curbp, XFS_BLFT_DIR_DATA_BUF);
if (cmp == XFS_CMP_EXACT) if (cmp == XFS_CMP_EXACT)
return XFS_ERROR(EEXIST); return -EEXIST;
} }
} }
ASSERT(index == leafhdr.count || (args->op_flags & XFS_DA_OP_OKNOENT)); ASSERT(index == leafhdr.count || (args->op_flags & XFS_DA_OP_OKNOENT));
...@@ -812,7 +812,7 @@ xfs_dir2_leafn_lookup_for_entry( ...@@ -812,7 +812,7 @@ xfs_dir2_leafn_lookup_for_entry(
state->extravalid = 0; state->extravalid = 0;
} }
*indexp = index; *indexp = index;
return XFS_ERROR(ENOENT); return -ENOENT;
} }
/* /*
...@@ -1133,7 +1133,7 @@ xfs_dir3_data_block_free( ...@@ -1133,7 +1133,7 @@ xfs_dir3_data_block_free(
if (error == 0) { if (error == 0) {
fbp = NULL; fbp = NULL;
logfree = 0; logfree = 0;
} else if (error != ENOSPC || args->total != 0) } else if (error != -ENOSPC || args->total != 0)
return error; return error;
/* /*
* It's possible to get ENOSPC if there is no * It's possible to get ENOSPC if there is no
...@@ -1287,7 +1287,7 @@ xfs_dir2_leafn_remove( ...@@ -1287,7 +1287,7 @@ xfs_dir2_leafn_remove(
* In this case just drop the buffer and some one else * In this case just drop the buffer and some one else
* will eventually get rid of the empty block. * will eventually get rid of the empty block.
*/ */
else if (!(error == ENOSPC && args->total == 0)) else if (!(error == -ENOSPC && args->total == 0))
return error; return error;
} }
/* /*
...@@ -1599,7 +1599,7 @@ xfs_dir2_node_addname( ...@@ -1599,7 +1599,7 @@ xfs_dir2_node_addname(
error = xfs_da3_node_lookup_int(state, &rval); error = xfs_da3_node_lookup_int(state, &rval);
if (error) if (error)
rval = error; rval = error;
if (rval != ENOENT) { if (rval != -ENOENT) {
goto done; goto done;
} }
/* /*
...@@ -1628,7 +1628,7 @@ xfs_dir2_node_addname( ...@@ -1628,7 +1628,7 @@ xfs_dir2_node_addname(
* It didn't work, we need to split the leaf block. * It didn't work, we need to split the leaf block.
*/ */
if (args->total == 0) { if (args->total == 0) {
ASSERT(rval == ENOSPC); ASSERT(rval == -ENOSPC);
goto done; goto done;
} }
/* /*
...@@ -1815,7 +1815,7 @@ xfs_dir2_node_addname_int( ...@@ -1815,7 +1815,7 @@ xfs_dir2_node_addname_int(
* Not allowed to allocate, return failure. * Not allowed to allocate, return failure.
*/ */
if ((args->op_flags & XFS_DA_OP_JUSTCHECK) || args->total == 0) if ((args->op_flags & XFS_DA_OP_JUSTCHECK) || args->total == 0)
return XFS_ERROR(ENOSPC); return -ENOSPC;
/* /*
* Allocate and initialize the new data block. * Allocate and initialize the new data block.
...@@ -1876,7 +1876,7 @@ xfs_dir2_node_addname_int( ...@@ -1876,7 +1876,7 @@ xfs_dir2_node_addname_int(
} }
XFS_ERROR_REPORT("xfs_dir2_node_addname_int", XFS_ERROR_REPORT("xfs_dir2_node_addname_int",
XFS_ERRLEVEL_LOW, mp); XFS_ERRLEVEL_LOW, mp);
return XFS_ERROR(EFSCORRUPTED); return -EFSCORRUPTED;
} }
/* /*
...@@ -2042,8 +2042,8 @@ xfs_dir2_node_lookup( ...@@ -2042,8 +2042,8 @@ xfs_dir2_node_lookup(
error = xfs_da3_node_lookup_int(state, &rval); error = xfs_da3_node_lookup_int(state, &rval);
if (error) if (error)
rval = error; rval = error;
else if (rval == ENOENT && args->cmpresult == XFS_CMP_CASE) { else if (rval == -ENOENT && args->cmpresult == XFS_CMP_CASE) {
/* If a CI match, dup the actual name and return EEXIST */ /* If a CI match, dup the actual name and return -EEXIST */
xfs_dir2_data_entry_t *dep; xfs_dir2_data_entry_t *dep;
dep = (xfs_dir2_data_entry_t *) dep = (xfs_dir2_data_entry_t *)
...@@ -2096,7 +2096,7 @@ xfs_dir2_node_removename( ...@@ -2096,7 +2096,7 @@ xfs_dir2_node_removename(
goto out_free; goto out_free;
/* Didn't find it, upper layer screwed up. */ /* Didn't find it, upper layer screwed up. */
if (rval != EEXIST) { if (rval != -EEXIST) {
error = rval; error = rval;
goto out_free; goto out_free;
} }
...@@ -2169,7 +2169,7 @@ xfs_dir2_node_replace( ...@@ -2169,7 +2169,7 @@ xfs_dir2_node_replace(
* It should be found, since the vnodeops layer has looked it up * It should be found, since the vnodeops layer has looked it up
* and locked it. But paranoia is good. * and locked it. But paranoia is good.
*/ */
if (rval == EEXIST) { if (rval == -EEXIST) {
struct xfs_dir2_leaf_entry *ents; struct xfs_dir2_leaf_entry *ents;
/* /*
* Find the leaf entry. * Find the leaf entry.
...@@ -2272,7 +2272,7 @@ xfs_dir2_node_trim_free( ...@@ -2272,7 +2272,7 @@ xfs_dir2_node_trim_free(
* space reservation, when breaking up an extent into two * space reservation, when breaking up an extent into two
* pieces. This is the last block of an extent. * pieces. This is the last block of an extent.
*/ */
ASSERT(error != ENOSPC); ASSERT(error != -ENOSPC);
xfs_trans_brelse(tp, bp); xfs_trans_brelse(tp, bp);
return error; return error;
} }
......
...@@ -251,7 +251,7 @@ xfs_dir2_block_to_sf( ...@@ -251,7 +251,7 @@ xfs_dir2_block_to_sf(
logflags = XFS_ILOG_CORE; logflags = XFS_ILOG_CORE;
error = xfs_dir2_shrink_inode(args, args->geo->datablk, bp); error = xfs_dir2_shrink_inode(args, args->geo->datablk, bp);
if (error) { if (error) {
ASSERT(error != ENOSPC); ASSERT(error != -ENOSPC);
goto out; goto out;
} }
...@@ -299,7 +299,7 @@ xfs_dir2_sf_addname( ...@@ -299,7 +299,7 @@ xfs_dir2_sf_addname(
trace_xfs_dir2_sf_addname(args); trace_xfs_dir2_sf_addname(args);
ASSERT(xfs_dir2_sf_lookup(args) == ENOENT); ASSERT(xfs_dir2_sf_lookup(args) == -ENOENT);
dp = args->dp; dp = args->dp;
ASSERT(dp->i_df.if_flags & XFS_IFINLINE); ASSERT(dp->i_df.if_flags & XFS_IFINLINE);
/* /*
...@@ -307,7 +307,7 @@ xfs_dir2_sf_addname( ...@@ -307,7 +307,7 @@ xfs_dir2_sf_addname(
*/ */
if (dp->i_d.di_size < offsetof(xfs_dir2_sf_hdr_t, parent)) { if (dp->i_d.di_size < offsetof(xfs_dir2_sf_hdr_t, parent)) {
ASSERT(XFS_FORCED_SHUTDOWN(dp->i_mount)); ASSERT(XFS_FORCED_SHUTDOWN(dp->i_mount));
return XFS_ERROR(EIO); return -EIO;
} }
ASSERT(dp->i_df.if_bytes == dp->i_d.di_size); ASSERT(dp->i_df.if_bytes == dp->i_d.di_size);
ASSERT(dp->i_df.if_u1.if_data != NULL); ASSERT(dp->i_df.if_u1.if_data != NULL);
...@@ -345,7 +345,7 @@ xfs_dir2_sf_addname( ...@@ -345,7 +345,7 @@ xfs_dir2_sf_addname(
* Just checking or no space reservation, it doesn't fit. * Just checking or no space reservation, it doesn't fit.
*/ */
if ((args->op_flags & XFS_DA_OP_JUSTCHECK) || args->total == 0) if ((args->op_flags & XFS_DA_OP_JUSTCHECK) || args->total == 0)
return XFS_ERROR(ENOSPC); return -ENOSPC;
/* /*
* Convert to block form then add the name. * Convert to block form then add the name.
*/ */
...@@ -738,7 +738,7 @@ xfs_dir2_sf_lookup( ...@@ -738,7 +738,7 @@ xfs_dir2_sf_lookup(
*/ */
if (dp->i_d.di_size < offsetof(xfs_dir2_sf_hdr_t, parent)) { if (dp->i_d.di_size < offsetof(xfs_dir2_sf_hdr_t, parent)) {
ASSERT(XFS_FORCED_SHUTDOWN(dp->i_mount)); ASSERT(XFS_FORCED_SHUTDOWN(dp->i_mount));
return XFS_ERROR(EIO); return -EIO;
} }
ASSERT(dp->i_df.if_bytes == dp->i_d.di_size); ASSERT(dp->i_df.if_bytes == dp->i_d.di_size);
ASSERT(dp->i_df.if_u1.if_data != NULL); ASSERT(dp->i_df.if_u1.if_data != NULL);
...@@ -751,7 +751,7 @@ xfs_dir2_sf_lookup( ...@@ -751,7 +751,7 @@ xfs_dir2_sf_lookup(
args->inumber = dp->i_ino; args->inumber = dp->i_ino;
args->cmpresult = XFS_CMP_EXACT; args->cmpresult = XFS_CMP_EXACT;
args->filetype = XFS_DIR3_FT_DIR; args->filetype = XFS_DIR3_FT_DIR;
return XFS_ERROR(EEXIST); return -EEXIST;
} }
/* /*
* Special case for .. * Special case for ..
...@@ -761,7 +761,7 @@ xfs_dir2_sf_lookup( ...@@ -761,7 +761,7 @@ xfs_dir2_sf_lookup(
args->inumber = dp->d_ops->sf_get_parent_ino(sfp); args->inumber = dp->d_ops->sf_get_parent_ino(sfp);
args->cmpresult = XFS_CMP_EXACT; args->cmpresult = XFS_CMP_EXACT;
args->filetype = XFS_DIR3_FT_DIR; args->filetype = XFS_DIR3_FT_DIR;
return XFS_ERROR(EEXIST); return -EEXIST;
} }
/* /*
* Loop over all the entries trying to match ours. * Loop over all the entries trying to match ours.
...@@ -781,20 +781,20 @@ xfs_dir2_sf_lookup( ...@@ -781,20 +781,20 @@ xfs_dir2_sf_lookup(
args->inumber = dp->d_ops->sf_get_ino(sfp, sfep); args->inumber = dp->d_ops->sf_get_ino(sfp, sfep);
args->filetype = dp->d_ops->sf_get_ftype(sfep); args->filetype = dp->d_ops->sf_get_ftype(sfep);
if (cmp == XFS_CMP_EXACT) if (cmp == XFS_CMP_EXACT)
return XFS_ERROR(EEXIST); return -EEXIST;
ci_sfep = sfep; ci_sfep = sfep;
} }
} }
ASSERT(args->op_flags & XFS_DA_OP_OKNOENT); ASSERT(args->op_flags & XFS_DA_OP_OKNOENT);
/* /*
* Here, we can only be doing a lookup (not a rename or replace). * Here, we can only be doing a lookup (not a rename or replace).
* If a case-insensitive match was not found, return ENOENT. * If a case-insensitive match was not found, return -ENOENT.
*/ */
if (!ci_sfep) if (!ci_sfep)
return XFS_ERROR(ENOENT); return -ENOENT;
/* otherwise process the CI match as required by the caller */ /* otherwise process the CI match as required by the caller */
error = xfs_dir_cilookup_result(args, ci_sfep->name, ci_sfep->namelen); error = xfs_dir_cilookup_result(args, ci_sfep->name, ci_sfep->namelen);
return XFS_ERROR(error); return error;
} }
/* /*
...@@ -824,7 +824,7 @@ xfs_dir2_sf_removename( ...@@ -824,7 +824,7 @@ xfs_dir2_sf_removename(
*/ */
if (oldsize < offsetof(xfs_dir2_sf_hdr_t, parent)) { if (oldsize < offsetof(xfs_dir2_sf_hdr_t, parent)) {
ASSERT(XFS_FORCED_SHUTDOWN(dp->i_mount)); ASSERT(XFS_FORCED_SHUTDOWN(dp->i_mount));
return XFS_ERROR(EIO); return -EIO;
} }
ASSERT(dp->i_df.if_bytes == oldsize); ASSERT(dp->i_df.if_bytes == oldsize);
ASSERT(dp->i_df.if_u1.if_data != NULL); ASSERT(dp->i_df.if_u1.if_data != NULL);
...@@ -847,7 +847,7 @@ xfs_dir2_sf_removename( ...@@ -847,7 +847,7 @@ xfs_dir2_sf_removename(
* Didn't find it. * Didn't find it.
*/ */
if (i == sfp->count) if (i == sfp->count)
return XFS_ERROR(ENOENT); return -ENOENT;
/* /*
* Calculate sizes. * Calculate sizes.
*/ */
...@@ -914,7 +914,7 @@ xfs_dir2_sf_replace( ...@@ -914,7 +914,7 @@ xfs_dir2_sf_replace(
*/ */
if (dp->i_d.di_size < offsetof(xfs_dir2_sf_hdr_t, parent)) { if (dp->i_d.di_size < offsetof(xfs_dir2_sf_hdr_t, parent)) {
ASSERT(XFS_FORCED_SHUTDOWN(dp->i_mount)); ASSERT(XFS_FORCED_SHUTDOWN(dp->i_mount));
return XFS_ERROR(EIO); return -EIO;
} }
ASSERT(dp->i_df.if_bytes == dp->i_d.di_size); ASSERT(dp->i_df.if_bytes == dp->i_d.di_size);
ASSERT(dp->i_df.if_u1.if_data != NULL); ASSERT(dp->i_df.if_u1.if_data != NULL);
...@@ -990,7 +990,7 @@ xfs_dir2_sf_replace( ...@@ -990,7 +990,7 @@ xfs_dir2_sf_replace(
if (i8elevated) if (i8elevated)
xfs_dir2_sf_toino4(args); xfs_dir2_sf_toino4(args);
#endif #endif
return XFS_ERROR(ENOENT); return -ENOENT;
} }
} }
#if XFS_BIG_INUMS #if XFS_BIG_INUMS
......
...@@ -257,9 +257,9 @@ xfs_dquot_buf_read_verify( ...@@ -257,9 +257,9 @@ xfs_dquot_buf_read_verify(
struct xfs_mount *mp = bp->b_target->bt_mount; struct xfs_mount *mp = bp->b_target->bt_mount;
if (!xfs_dquot_buf_verify_crc(mp, bp)) if (!xfs_dquot_buf_verify_crc(mp, bp))
xfs_buf_ioerror(bp, EFSBADCRC); xfs_buf_ioerror(bp, -EFSBADCRC);
else if (!xfs_dquot_buf_verify(mp, bp)) else if (!xfs_dquot_buf_verify(mp, bp))
xfs_buf_ioerror(bp, EFSCORRUPTED); xfs_buf_ioerror(bp, -EFSCORRUPTED);
if (bp->b_error) if (bp->b_error)
xfs_verifier_error(bp); xfs_verifier_error(bp);
...@@ -277,7 +277,7 @@ xfs_dquot_buf_write_verify( ...@@ -277,7 +277,7 @@ xfs_dquot_buf_write_verify(
struct xfs_mount *mp = bp->b_target->bt_mount; struct xfs_mount *mp = bp->b_target->bt_mount;
if (!xfs_dquot_buf_verify(mp, bp)) { if (!xfs_dquot_buf_verify(mp, bp)) {
xfs_buf_ioerror(bp, EFSCORRUPTED); xfs_buf_ioerror(bp, -EFSCORRUPTED);
xfs_verifier_error(bp); xfs_verifier_error(bp);
return; return;
} }
......
...@@ -292,7 +292,7 @@ xfs_ialloc_inode_init( ...@@ -292,7 +292,7 @@ xfs_ialloc_inode_init(
mp->m_bsize * blks_per_cluster, mp->m_bsize * blks_per_cluster,
XBF_UNMAPPED); XBF_UNMAPPED);
if (!fbuf) if (!fbuf)
return ENOMEM; return -ENOMEM;
/* Initialize the inode buffers and log them appropriately. */ /* Initialize the inode buffers and log them appropriately. */
fbuf->b_ops = &xfs_inode_buf_ops; fbuf->b_ops = &xfs_inode_buf_ops;
...@@ -380,7 +380,7 @@ xfs_ialloc_ag_alloc( ...@@ -380,7 +380,7 @@ xfs_ialloc_ag_alloc(
newlen = args.mp->m_ialloc_inos; newlen = args.mp->m_ialloc_inos;
if (args.mp->m_maxicount && if (args.mp->m_maxicount &&
args.mp->m_sb.sb_icount + newlen > args.mp->m_maxicount) args.mp->m_sb.sb_icount + newlen > args.mp->m_maxicount)
return XFS_ERROR(ENOSPC); return -ENOSPC;
args.minlen = args.maxlen = args.mp->m_ialloc_blks; args.minlen = args.maxlen = args.mp->m_ialloc_blks;
/* /*
* First try to allocate inodes contiguous with the last-allocated * First try to allocate inodes contiguous with the last-allocated
...@@ -1385,7 +1385,7 @@ xfs_dialloc( ...@@ -1385,7 +1385,7 @@ xfs_dialloc(
if (error) { if (error) {
xfs_trans_brelse(tp, agbp); xfs_trans_brelse(tp, agbp);
if (error != ENOSPC) if (error != -ENOSPC)
goto out_error; goto out_error;
xfs_perag_put(pag); xfs_perag_put(pag);
...@@ -1416,7 +1416,7 @@ xfs_dialloc( ...@@ -1416,7 +1416,7 @@ xfs_dialloc(
agno = 0; agno = 0;
if (agno == start_agno) { if (agno == start_agno) {
*inop = NULLFSINO; *inop = NULLFSINO;
return noroom ? ENOSPC : 0; return noroom ? -ENOSPC : 0;
} }
} }
...@@ -1425,7 +1425,7 @@ xfs_dialloc( ...@@ -1425,7 +1425,7 @@ xfs_dialloc(
return xfs_dialloc_ag(tp, agbp, parent, inop); return xfs_dialloc_ag(tp, agbp, parent, inop);
out_error: out_error:
xfs_perag_put(pag); xfs_perag_put(pag);
return XFS_ERROR(error); return error;
} }
STATIC int STATIC int
...@@ -1682,7 +1682,7 @@ xfs_difree( ...@@ -1682,7 +1682,7 @@ xfs_difree(
xfs_warn(mp, "%s: agno >= mp->m_sb.sb_agcount (%d >= %d).", xfs_warn(mp, "%s: agno >= mp->m_sb.sb_agcount (%d >= %d).",
__func__, agno, mp->m_sb.sb_agcount); __func__, agno, mp->m_sb.sb_agcount);
ASSERT(0); ASSERT(0);
return XFS_ERROR(EINVAL); return -EINVAL;
} }
agino = XFS_INO_TO_AGINO(mp, inode); agino = XFS_INO_TO_AGINO(mp, inode);
if (inode != XFS_AGINO_TO_INO(mp, agno, agino)) { if (inode != XFS_AGINO_TO_INO(mp, agno, agino)) {
...@@ -1690,14 +1690,14 @@ xfs_difree( ...@@ -1690,14 +1690,14 @@ xfs_difree(
__func__, (unsigned long long)inode, __func__, (unsigned long long)inode,
(unsigned long long)XFS_AGINO_TO_INO(mp, agno, agino)); (unsigned long long)XFS_AGINO_TO_INO(mp, agno, agino));
ASSERT(0); ASSERT(0);
return XFS_ERROR(EINVAL); return -EINVAL;
} }
agbno = XFS_AGINO_TO_AGBNO(mp, agino); agbno = XFS_AGINO_TO_AGBNO(mp, agino);
if (agbno >= mp->m_sb.sb_agblocks) { if (agbno >= mp->m_sb.sb_agblocks) {
xfs_warn(mp, "%s: agbno >= mp->m_sb.sb_agblocks (%d >= %d).", xfs_warn(mp, "%s: agbno >= mp->m_sb.sb_agblocks (%d >= %d).",
__func__, agbno, mp->m_sb.sb_agblocks); __func__, agbno, mp->m_sb.sb_agblocks);
ASSERT(0); ASSERT(0);
return XFS_ERROR(EINVAL); return -EINVAL;
} }
/* /*
* Get the allocation group header. * Get the allocation group header.
...@@ -1769,7 +1769,7 @@ xfs_imap_lookup( ...@@ -1769,7 +1769,7 @@ xfs_imap_lookup(
if (i) if (i)
error = xfs_inobt_get_rec(cur, &rec, &i); error = xfs_inobt_get_rec(cur, &rec, &i);
if (!error && i == 0) if (!error && i == 0)
error = EINVAL; error = -EINVAL;
} }
xfs_trans_brelse(tp, agbp); xfs_trans_brelse(tp, agbp);
...@@ -1780,12 +1780,12 @@ xfs_imap_lookup( ...@@ -1780,12 +1780,12 @@ xfs_imap_lookup(
/* check that the returned record contains the required inode */ /* check that the returned record contains the required inode */
if (rec.ir_startino > agino || if (rec.ir_startino > agino ||
rec.ir_startino + mp->m_ialloc_inos <= agino) rec.ir_startino + mp->m_ialloc_inos <= agino)
return EINVAL; return -EINVAL;
/* for untrusted inodes check it is allocated first */ /* for untrusted inodes check it is allocated first */
if ((flags & XFS_IGET_UNTRUSTED) && if ((flags & XFS_IGET_UNTRUSTED) &&
(rec.ir_free & XFS_INOBT_MASK(agino - rec.ir_startino))) (rec.ir_free & XFS_INOBT_MASK(agino - rec.ir_startino)))
return EINVAL; return -EINVAL;
*chunk_agbno = XFS_AGINO_TO_AGBNO(mp, rec.ir_startino); *chunk_agbno = XFS_AGINO_TO_AGBNO(mp, rec.ir_startino);
*offset_agbno = agbno - *chunk_agbno; *offset_agbno = agbno - *chunk_agbno;
...@@ -1829,7 +1829,7 @@ xfs_imap( ...@@ -1829,7 +1829,7 @@ xfs_imap(
* as they can be invalid without implying corruption. * as they can be invalid without implying corruption.
*/ */
if (flags & XFS_IGET_UNTRUSTED) if (flags & XFS_IGET_UNTRUSTED)
return XFS_ERROR(EINVAL); return -EINVAL;
if (agno >= mp->m_sb.sb_agcount) { if (agno >= mp->m_sb.sb_agcount) {
xfs_alert(mp, xfs_alert(mp,
"%s: agno (%d) >= mp->m_sb.sb_agcount (%d)", "%s: agno (%d) >= mp->m_sb.sb_agcount (%d)",
...@@ -1849,7 +1849,7 @@ xfs_imap( ...@@ -1849,7 +1849,7 @@ xfs_imap(
} }
xfs_stack_trace(); xfs_stack_trace();
#endif /* DEBUG */ #endif /* DEBUG */
return XFS_ERROR(EINVAL); return -EINVAL;
} }
blks_per_cluster = xfs_icluster_size_fsb(mp); blks_per_cluster = xfs_icluster_size_fsb(mp);
...@@ -1922,7 +1922,7 @@ xfs_imap( ...@@ -1922,7 +1922,7 @@ xfs_imap(
__func__, (unsigned long long) imap->im_blkno, __func__, (unsigned long long) imap->im_blkno,
(unsigned long long) imap->im_len, (unsigned long long) imap->im_len,
XFS_FSB_TO_BB(mp, mp->m_sb.sb_dblocks)); XFS_FSB_TO_BB(mp, mp->m_sb.sb_dblocks));
return XFS_ERROR(EINVAL); return -EINVAL;
} }
return 0; return 0;
} }
...@@ -2072,11 +2072,11 @@ xfs_agi_read_verify( ...@@ -2072,11 +2072,11 @@ xfs_agi_read_verify(
if (xfs_sb_version_hascrc(&mp->m_sb) && if (xfs_sb_version_hascrc(&mp->m_sb) &&
!xfs_buf_verify_cksum(bp, XFS_AGI_CRC_OFF)) !xfs_buf_verify_cksum(bp, XFS_AGI_CRC_OFF))
xfs_buf_ioerror(bp, EFSBADCRC); xfs_buf_ioerror(bp, -EFSBADCRC);
else if (XFS_TEST_ERROR(!xfs_agi_verify(bp), mp, else if (XFS_TEST_ERROR(!xfs_agi_verify(bp), mp,
XFS_ERRTAG_IALLOC_READ_AGI, XFS_ERRTAG_IALLOC_READ_AGI,
XFS_RANDOM_IALLOC_READ_AGI)) XFS_RANDOM_IALLOC_READ_AGI))
xfs_buf_ioerror(bp, EFSCORRUPTED); xfs_buf_ioerror(bp, -EFSCORRUPTED);
if (bp->b_error) if (bp->b_error)
xfs_verifier_error(bp); xfs_verifier_error(bp);
...@@ -2090,7 +2090,7 @@ xfs_agi_write_verify( ...@@ -2090,7 +2090,7 @@ xfs_agi_write_verify(
struct xfs_buf_log_item *bip = bp->b_fspriv; struct xfs_buf_log_item *bip = bp->b_fspriv;
if (!xfs_agi_verify(bp)) { if (!xfs_agi_verify(bp)) {
xfs_buf_ioerror(bp, EFSCORRUPTED); xfs_buf_ioerror(bp, -EFSCORRUPTED);
xfs_verifier_error(bp); xfs_verifier_error(bp);
return; return;
} }
......
...@@ -272,9 +272,9 @@ xfs_inobt_read_verify( ...@@ -272,9 +272,9 @@ xfs_inobt_read_verify(
struct xfs_buf *bp) struct xfs_buf *bp)
{ {
if (!xfs_btree_sblock_verify_crc(bp)) if (!xfs_btree_sblock_verify_crc(bp))
xfs_buf_ioerror(bp, EFSBADCRC); xfs_buf_ioerror(bp, -EFSBADCRC);
else if (!xfs_inobt_verify(bp)) else if (!xfs_inobt_verify(bp))
xfs_buf_ioerror(bp, EFSCORRUPTED); xfs_buf_ioerror(bp, -EFSCORRUPTED);
if (bp->b_error) { if (bp->b_error) {
trace_xfs_btree_corrupt(bp, _RET_IP_); trace_xfs_btree_corrupt(bp, _RET_IP_);
...@@ -288,7 +288,7 @@ xfs_inobt_write_verify( ...@@ -288,7 +288,7 @@ xfs_inobt_write_verify(
{ {
if (!xfs_inobt_verify(bp)) { if (!xfs_inobt_verify(bp)) {
trace_xfs_btree_corrupt(bp, _RET_IP_); trace_xfs_btree_corrupt(bp, _RET_IP_);
xfs_buf_ioerror(bp, EFSCORRUPTED); xfs_buf_ioerror(bp, -EFSCORRUPTED);
xfs_verifier_error(bp); xfs_verifier_error(bp);
return; return;
} }
......
...@@ -101,7 +101,7 @@ xfs_inode_buf_verify( ...@@ -101,7 +101,7 @@ xfs_inode_buf_verify(
return; return;
} }
xfs_buf_ioerror(bp, EFSCORRUPTED); xfs_buf_ioerror(bp, -EFSCORRUPTED);
xfs_verifier_error(bp); xfs_verifier_error(bp);
#ifdef DEBUG #ifdef DEBUG
xfs_alert(mp, xfs_alert(mp,
...@@ -174,14 +174,14 @@ xfs_imap_to_bp( ...@@ -174,14 +174,14 @@ xfs_imap_to_bp(
(int)imap->im_len, buf_flags, &bp, (int)imap->im_len, buf_flags, &bp,
&xfs_inode_buf_ops); &xfs_inode_buf_ops);
if (error) { if (error) {
if (error == EAGAIN) { if (error == -EAGAIN) {
ASSERT(buf_flags & XBF_TRYLOCK); ASSERT(buf_flags & XBF_TRYLOCK);
return error; return error;
} }
if (error == EFSCORRUPTED && if (error == -EFSCORRUPTED &&
(iget_flags & XFS_IGET_UNTRUSTED)) (iget_flags & XFS_IGET_UNTRUSTED))
return XFS_ERROR(EINVAL); return -EINVAL;
xfs_warn(mp, "%s: xfs_trans_read_buf() returned error %d.", xfs_warn(mp, "%s: xfs_trans_read_buf() returned error %d.",
__func__, error); __func__, error);
...@@ -390,7 +390,7 @@ xfs_iread( ...@@ -390,7 +390,7 @@ xfs_iread(
__func__, ip->i_ino); __func__, ip->i_ino);
XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, dip); XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, dip);
error = XFS_ERROR(EFSCORRUPTED); error = -EFSCORRUPTED;
goto out_brelse; goto out_brelse;
} }
......
...@@ -102,7 +102,7 @@ xfs_iformat_fork( ...@@ -102,7 +102,7 @@ xfs_iformat_fork(
be64_to_cpu(dip->di_nblocks)); be64_to_cpu(dip->di_nblocks));
XFS_CORRUPTION_ERROR("xfs_iformat(1)", XFS_ERRLEVEL_LOW, XFS_CORRUPTION_ERROR("xfs_iformat(1)", XFS_ERRLEVEL_LOW,
ip->i_mount, dip); ip->i_mount, dip);
return XFS_ERROR(EFSCORRUPTED); return -EFSCORRUPTED;
} }
if (unlikely(dip->di_forkoff > ip->i_mount->m_sb.sb_inodesize)) { if (unlikely(dip->di_forkoff > ip->i_mount->m_sb.sb_inodesize)) {
...@@ -111,7 +111,7 @@ xfs_iformat_fork( ...@@ -111,7 +111,7 @@ xfs_iformat_fork(
dip->di_forkoff); dip->di_forkoff);
XFS_CORRUPTION_ERROR("xfs_iformat(2)", XFS_ERRLEVEL_LOW, XFS_CORRUPTION_ERROR("xfs_iformat(2)", XFS_ERRLEVEL_LOW,
ip->i_mount, dip); ip->i_mount, dip);
return XFS_ERROR(EFSCORRUPTED); return -EFSCORRUPTED;
} }
if (unlikely((ip->i_d.di_flags & XFS_DIFLAG_REALTIME) && if (unlikely((ip->i_d.di_flags & XFS_DIFLAG_REALTIME) &&
...@@ -121,7 +121,7 @@ xfs_iformat_fork( ...@@ -121,7 +121,7 @@ xfs_iformat_fork(
ip->i_ino); ip->i_ino);
XFS_CORRUPTION_ERROR("xfs_iformat(realtime)", XFS_CORRUPTION_ERROR("xfs_iformat(realtime)",
XFS_ERRLEVEL_LOW, ip->i_mount, dip); XFS_ERRLEVEL_LOW, ip->i_mount, dip);
return XFS_ERROR(EFSCORRUPTED); return -EFSCORRUPTED;
} }
switch (ip->i_d.di_mode & S_IFMT) { switch (ip->i_d.di_mode & S_IFMT) {
...@@ -132,7 +132,7 @@ xfs_iformat_fork( ...@@ -132,7 +132,7 @@ xfs_iformat_fork(
if (unlikely(dip->di_format != XFS_DINODE_FMT_DEV)) { if (unlikely(dip->di_format != XFS_DINODE_FMT_DEV)) {
XFS_CORRUPTION_ERROR("xfs_iformat(3)", XFS_ERRLEVEL_LOW, XFS_CORRUPTION_ERROR("xfs_iformat(3)", XFS_ERRLEVEL_LOW,
ip->i_mount, dip); ip->i_mount, dip);
return XFS_ERROR(EFSCORRUPTED); return -EFSCORRUPTED;
} }
ip->i_d.di_size = 0; ip->i_d.di_size = 0;
ip->i_df.if_u2.if_rdev = xfs_dinode_get_rdev(dip); ip->i_df.if_u2.if_rdev = xfs_dinode_get_rdev(dip);
...@@ -153,7 +153,7 @@ xfs_iformat_fork( ...@@ -153,7 +153,7 @@ xfs_iformat_fork(
XFS_CORRUPTION_ERROR("xfs_iformat(4)", XFS_CORRUPTION_ERROR("xfs_iformat(4)",
XFS_ERRLEVEL_LOW, XFS_ERRLEVEL_LOW,
ip->i_mount, dip); ip->i_mount, dip);
return XFS_ERROR(EFSCORRUPTED); return -EFSCORRUPTED;
} }
di_size = be64_to_cpu(dip->di_size); di_size = be64_to_cpu(dip->di_size);
...@@ -166,7 +166,7 @@ xfs_iformat_fork( ...@@ -166,7 +166,7 @@ xfs_iformat_fork(
XFS_CORRUPTION_ERROR("xfs_iformat(5)", XFS_CORRUPTION_ERROR("xfs_iformat(5)",
XFS_ERRLEVEL_LOW, XFS_ERRLEVEL_LOW,
ip->i_mount, dip); ip->i_mount, dip);
return XFS_ERROR(EFSCORRUPTED); return -EFSCORRUPTED;
} }
size = (int)di_size; size = (int)di_size;
...@@ -181,13 +181,13 @@ xfs_iformat_fork( ...@@ -181,13 +181,13 @@ xfs_iformat_fork(
default: default:
XFS_ERROR_REPORT("xfs_iformat(6)", XFS_ERRLEVEL_LOW, XFS_ERROR_REPORT("xfs_iformat(6)", XFS_ERRLEVEL_LOW,
ip->i_mount); ip->i_mount);
return XFS_ERROR(EFSCORRUPTED); return -EFSCORRUPTED;
} }
break; break;
default: default:
XFS_ERROR_REPORT("xfs_iformat(7)", XFS_ERRLEVEL_LOW, ip->i_mount); XFS_ERROR_REPORT("xfs_iformat(7)", XFS_ERRLEVEL_LOW, ip->i_mount);
return XFS_ERROR(EFSCORRUPTED); return -EFSCORRUPTED;
} }
if (error) { if (error) {
return error; return error;
...@@ -211,7 +211,7 @@ xfs_iformat_fork( ...@@ -211,7 +211,7 @@ xfs_iformat_fork(
XFS_CORRUPTION_ERROR("xfs_iformat(8)", XFS_CORRUPTION_ERROR("xfs_iformat(8)",
XFS_ERRLEVEL_LOW, XFS_ERRLEVEL_LOW,
ip->i_mount, dip); ip->i_mount, dip);
return XFS_ERROR(EFSCORRUPTED); return -EFSCORRUPTED;
} }
error = xfs_iformat_local(ip, dip, XFS_ATTR_FORK, size); error = xfs_iformat_local(ip, dip, XFS_ATTR_FORK, size);
...@@ -223,7 +223,7 @@ xfs_iformat_fork( ...@@ -223,7 +223,7 @@ xfs_iformat_fork(
error = xfs_iformat_btree(ip, dip, XFS_ATTR_FORK); error = xfs_iformat_btree(ip, dip, XFS_ATTR_FORK);
break; break;
default: default:
error = XFS_ERROR(EFSCORRUPTED); error = -EFSCORRUPTED;
break; break;
} }
if (error) { if (error) {
...@@ -266,7 +266,7 @@ xfs_iformat_local( ...@@ -266,7 +266,7 @@ xfs_iformat_local(
XFS_DFORK_SIZE(dip, ip->i_mount, whichfork)); XFS_DFORK_SIZE(dip, ip->i_mount, whichfork));
XFS_CORRUPTION_ERROR("xfs_iformat_local", XFS_ERRLEVEL_LOW, XFS_CORRUPTION_ERROR("xfs_iformat_local", XFS_ERRLEVEL_LOW,
ip->i_mount, dip); ip->i_mount, dip);
return XFS_ERROR(EFSCORRUPTED); return -EFSCORRUPTED;
} }
ifp = XFS_IFORK_PTR(ip, whichfork); ifp = XFS_IFORK_PTR(ip, whichfork);
real_size = 0; real_size = 0;
...@@ -322,7 +322,7 @@ xfs_iformat_extents( ...@@ -322,7 +322,7 @@ xfs_iformat_extents(
(unsigned long long) ip->i_ino, nex); (unsigned long long) ip->i_ino, nex);
XFS_CORRUPTION_ERROR("xfs_iformat_extents(1)", XFS_ERRLEVEL_LOW, XFS_CORRUPTION_ERROR("xfs_iformat_extents(1)", XFS_ERRLEVEL_LOW,
ip->i_mount, dip); ip->i_mount, dip);
return XFS_ERROR(EFSCORRUPTED); return -EFSCORRUPTED;
} }
ifp->if_real_bytes = 0; ifp->if_real_bytes = 0;
...@@ -350,7 +350,7 @@ xfs_iformat_extents( ...@@ -350,7 +350,7 @@ xfs_iformat_extents(
XFS_ERROR_REPORT("xfs_iformat_extents(2)", XFS_ERROR_REPORT("xfs_iformat_extents(2)",
XFS_ERRLEVEL_LOW, XFS_ERRLEVEL_LOW,
ip->i_mount); ip->i_mount);
return XFS_ERROR(EFSCORRUPTED); return -EFSCORRUPTED;
} }
} }
ifp->if_flags |= XFS_IFEXTENTS; ifp->if_flags |= XFS_IFEXTENTS;
...@@ -399,7 +399,7 @@ xfs_iformat_btree( ...@@ -399,7 +399,7 @@ xfs_iformat_btree(
(unsigned long long) ip->i_ino); (unsigned long long) ip->i_ino);
XFS_CORRUPTION_ERROR("xfs_iformat_btree", XFS_ERRLEVEL_LOW, XFS_CORRUPTION_ERROR("xfs_iformat_btree", XFS_ERRLEVEL_LOW,
mp, dip); mp, dip);
return XFS_ERROR(EFSCORRUPTED); return -EFSCORRUPTED;
} }
ifp->if_broot_bytes = size; ifp->if_broot_bytes = size;
...@@ -436,7 +436,7 @@ xfs_iread_extents( ...@@ -436,7 +436,7 @@ xfs_iread_extents(
if (unlikely(XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_BTREE)) { if (unlikely(XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_BTREE)) {
XFS_ERROR_REPORT("xfs_iread_extents", XFS_ERRLEVEL_LOW, XFS_ERROR_REPORT("xfs_iread_extents", XFS_ERRLEVEL_LOW,
ip->i_mount); ip->i_mount);
return XFS_ERROR(EFSCORRUPTED); return -EFSCORRUPTED;
} }
nextents = XFS_IFORK_NEXTENTS(ip, whichfork); nextents = XFS_IFORK_NEXTENTS(ip, whichfork);
ifp = XFS_IFORK_PTR(ip, whichfork); ifp = XFS_IFORK_PTR(ip, whichfork);
...@@ -1692,7 +1692,7 @@ xfs_iext_idx_to_irec( ...@@ -1692,7 +1692,7 @@ xfs_iext_idx_to_irec(
} }
*idxp = page_idx; *idxp = page_idx;
*erp_idxp = erp_idx; *erp_idxp = erp_idx;
return(erp); return erp;
} }
/* /*
......
...@@ -186,13 +186,13 @@ xfs_mount_validate_sb( ...@@ -186,13 +186,13 @@ xfs_mount_validate_sb(
*/ */
if (sbp->sb_magicnum != XFS_SB_MAGIC) { if (sbp->sb_magicnum != XFS_SB_MAGIC) {
xfs_warn(mp, "bad magic number"); xfs_warn(mp, "bad magic number");
return XFS_ERROR(EWRONGFS); return -EWRONGFS;
} }
if (!xfs_sb_good_version(sbp)) { if (!xfs_sb_good_version(sbp)) {
xfs_warn(mp, "bad version"); xfs_warn(mp, "bad version");
return XFS_ERROR(EWRONGFS); return -EWRONGFS;
} }
/* /*
...@@ -220,7 +220,7 @@ xfs_mount_validate_sb( ...@@ -220,7 +220,7 @@ xfs_mount_validate_sb(
xfs_warn(mp, xfs_warn(mp,
"Attempted to mount read-only compatible filesystem read-write.\n" "Attempted to mount read-only compatible filesystem read-write.\n"
"Filesystem can only be safely mounted read only."); "Filesystem can only be safely mounted read only.");
return XFS_ERROR(EINVAL); return -EINVAL;
} }
} }
if (xfs_sb_has_incompat_feature(sbp, if (xfs_sb_has_incompat_feature(sbp,
...@@ -230,7 +230,7 @@ xfs_mount_validate_sb( ...@@ -230,7 +230,7 @@ xfs_mount_validate_sb(
"Filesystem can not be safely mounted by this kernel.", "Filesystem can not be safely mounted by this kernel.",
(sbp->sb_features_incompat & (sbp->sb_features_incompat &
XFS_SB_FEAT_INCOMPAT_UNKNOWN)); XFS_SB_FEAT_INCOMPAT_UNKNOWN));
return XFS_ERROR(EINVAL); return -EINVAL;
} }
} }
...@@ -238,13 +238,13 @@ xfs_mount_validate_sb( ...@@ -238,13 +238,13 @@ xfs_mount_validate_sb(
if (sbp->sb_qflags & (XFS_OQUOTA_ENFD | XFS_OQUOTA_CHKD)) { if (sbp->sb_qflags & (XFS_OQUOTA_ENFD | XFS_OQUOTA_CHKD)) {
xfs_notice(mp, xfs_notice(mp,
"Version 5 of Super block has XFS_OQUOTA bits."); "Version 5 of Super block has XFS_OQUOTA bits.");
return XFS_ERROR(EFSCORRUPTED); return -EFSCORRUPTED;
} }
} else if (sbp->sb_qflags & (XFS_PQUOTA_ENFD | XFS_GQUOTA_ENFD | } else if (sbp->sb_qflags & (XFS_PQUOTA_ENFD | XFS_GQUOTA_ENFD |
XFS_PQUOTA_CHKD | XFS_GQUOTA_CHKD)) { XFS_PQUOTA_CHKD | XFS_GQUOTA_CHKD)) {
xfs_notice(mp, xfs_notice(mp,
"Superblock earlier than Version 5 has XFS_[PQ]UOTA_{ENFD|CHKD} bits."); "Superblock earlier than Version 5 has XFS_[PQ]UOTA_{ENFD|CHKD} bits.");
return XFS_ERROR(EFSCORRUPTED); return -EFSCORRUPTED;
} }
if (unlikely( if (unlikely(
...@@ -252,7 +252,7 @@ xfs_mount_validate_sb( ...@@ -252,7 +252,7 @@ xfs_mount_validate_sb(
xfs_warn(mp, xfs_warn(mp,
"filesystem is marked as having an external log; " "filesystem is marked as having an external log; "
"specify logdev on the mount command line."); "specify logdev on the mount command line.");
return XFS_ERROR(EINVAL); return -EINVAL;
} }
if (unlikely( if (unlikely(
...@@ -260,7 +260,7 @@ xfs_mount_validate_sb( ...@@ -260,7 +260,7 @@ xfs_mount_validate_sb(
xfs_warn(mp, xfs_warn(mp,
"filesystem is marked as having an internal log; " "filesystem is marked as having an internal log; "
"do not specify logdev on the mount command line."); "do not specify logdev on the mount command line.");
return XFS_ERROR(EINVAL); return -EINVAL;
} }
/* /*
...@@ -294,7 +294,7 @@ xfs_mount_validate_sb( ...@@ -294,7 +294,7 @@ xfs_mount_validate_sb(
sbp->sb_dblocks < XFS_MIN_DBLOCKS(sbp) || sbp->sb_dblocks < XFS_MIN_DBLOCKS(sbp) ||
sbp->sb_shared_vn != 0)) { sbp->sb_shared_vn != 0)) {
xfs_notice(mp, "SB sanity check failed"); xfs_notice(mp, "SB sanity check failed");
return XFS_ERROR(EFSCORRUPTED); return -EFSCORRUPTED;
} }
/* /*
...@@ -305,7 +305,7 @@ xfs_mount_validate_sb( ...@@ -305,7 +305,7 @@ xfs_mount_validate_sb(
"File system with blocksize %d bytes. " "File system with blocksize %d bytes. "
"Only pagesize (%ld) or less will currently work.", "Only pagesize (%ld) or less will currently work.",
sbp->sb_blocksize, PAGE_SIZE); sbp->sb_blocksize, PAGE_SIZE);
return XFS_ERROR(ENOSYS); return -ENOSYS;
} }
/* /*
...@@ -320,19 +320,19 @@ xfs_mount_validate_sb( ...@@ -320,19 +320,19 @@ xfs_mount_validate_sb(
default: default:
xfs_warn(mp, "inode size of %d bytes not supported", xfs_warn(mp, "inode size of %d bytes not supported",
sbp->sb_inodesize); sbp->sb_inodesize);
return XFS_ERROR(ENOSYS); return -ENOSYS;
} }
if (xfs_sb_validate_fsb_count(sbp, sbp->sb_dblocks) || if (xfs_sb_validate_fsb_count(sbp, sbp->sb_dblocks) ||
xfs_sb_validate_fsb_count(sbp, sbp->sb_rblocks)) { xfs_sb_validate_fsb_count(sbp, sbp->sb_rblocks)) {
xfs_warn(mp, xfs_warn(mp,
"file system too large to be mounted on this system."); "file system too large to be mounted on this system.");
return XFS_ERROR(EFBIG); return -EFBIG;
} }
if (check_inprogress && sbp->sb_inprogress) { if (check_inprogress && sbp->sb_inprogress) {
xfs_warn(mp, "Offline file system operation in progress!"); xfs_warn(mp, "Offline file system operation in progress!");
return XFS_ERROR(EFSCORRUPTED); return -EFSCORRUPTED;
} }
return 0; return 0;
} }
...@@ -620,7 +620,7 @@ xfs_sb_read_verify( ...@@ -620,7 +620,7 @@ xfs_sb_read_verify(
/* Only fail bad secondaries on a known V5 filesystem */ /* Only fail bad secondaries on a known V5 filesystem */
if (bp->b_bn == XFS_SB_DADDR || if (bp->b_bn == XFS_SB_DADDR ||
xfs_sb_version_hascrc(&mp->m_sb)) { xfs_sb_version_hascrc(&mp->m_sb)) {
error = EFSBADCRC; error = -EFSBADCRC;
goto out_error; goto out_error;
} }
} }
...@@ -630,7 +630,7 @@ xfs_sb_read_verify( ...@@ -630,7 +630,7 @@ xfs_sb_read_verify(
out_error: out_error:
if (error) { if (error) {
xfs_buf_ioerror(bp, error); xfs_buf_ioerror(bp, error);
if (error == EFSCORRUPTED || error == EFSBADCRC) if (error == -EFSCORRUPTED || error == -EFSBADCRC)
xfs_verifier_error(bp); xfs_verifier_error(bp);
} }
} }
...@@ -653,7 +653,7 @@ xfs_sb_quiet_read_verify( ...@@ -653,7 +653,7 @@ xfs_sb_quiet_read_verify(
return; return;
} }
/* quietly fail */ /* quietly fail */
xfs_buf_ioerror(bp, EWRONGFS); xfs_buf_ioerror(bp, -EWRONGFS);
} }
static void static void
......
...@@ -133,9 +133,9 @@ xfs_symlink_read_verify( ...@@ -133,9 +133,9 @@ xfs_symlink_read_verify(
return; return;
if (!xfs_buf_verify_cksum(bp, XFS_SYMLINK_CRC_OFF)) if (!xfs_buf_verify_cksum(bp, XFS_SYMLINK_CRC_OFF))
xfs_buf_ioerror(bp, EFSBADCRC); xfs_buf_ioerror(bp, -EFSBADCRC);
else if (!xfs_symlink_verify(bp)) else if (!xfs_symlink_verify(bp))
xfs_buf_ioerror(bp, EFSCORRUPTED); xfs_buf_ioerror(bp, -EFSCORRUPTED);
if (bp->b_error) if (bp->b_error)
xfs_verifier_error(bp); xfs_verifier_error(bp);
...@@ -153,7 +153,7 @@ xfs_symlink_write_verify( ...@@ -153,7 +153,7 @@ xfs_symlink_write_verify(
return; return;
if (!xfs_symlink_verify(bp)) { if (!xfs_symlink_verify(bp)) {
xfs_buf_ioerror(bp, EFSCORRUPTED); xfs_buf_ioerror(bp, -EFSCORRUPTED);
xfs_verifier_error(bp); xfs_verifier_error(bp);
return; return;
} }
......
...@@ -152,7 +152,7 @@ xfs_get_acl(struct inode *inode, int type) ...@@ -152,7 +152,7 @@ xfs_get_acl(struct inode *inode, int type)
if (!xfs_acl) if (!xfs_acl)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
error = -xfs_attr_get(ip, ea_name, (unsigned char *)xfs_acl, error = xfs_attr_get(ip, ea_name, (unsigned char *)xfs_acl,
&len, ATTR_ROOT); &len, ATTR_ROOT);
if (error) { if (error) {
/* /*
...@@ -210,7 +210,7 @@ __xfs_set_acl(struct inode *inode, int type, struct posix_acl *acl) ...@@ -210,7 +210,7 @@ __xfs_set_acl(struct inode *inode, int type, struct posix_acl *acl)
len -= sizeof(struct xfs_acl_entry) * len -= sizeof(struct xfs_acl_entry) *
(XFS_ACL_MAX_ENTRIES(ip->i_mount) - acl->a_count); (XFS_ACL_MAX_ENTRIES(ip->i_mount) - acl->a_count);
error = -xfs_attr_set(ip, ea_name, (unsigned char *)xfs_acl, error = xfs_attr_set(ip, ea_name, (unsigned char *)xfs_acl,
len, ATTR_ROOT); len, ATTR_ROOT);
kmem_free(xfs_acl); kmem_free(xfs_acl);
...@@ -218,7 +218,7 @@ __xfs_set_acl(struct inode *inode, int type, struct posix_acl *acl) ...@@ -218,7 +218,7 @@ __xfs_set_acl(struct inode *inode, int type, struct posix_acl *acl)
/* /*
* A NULL ACL argument means we want to remove the ACL. * A NULL ACL argument means we want to remove the ACL.
*/ */
error = -xfs_attr_remove(ip, ea_name, ATTR_ROOT); error = xfs_attr_remove(ip, ea_name, ATTR_ROOT);
/* /*
* If the attribute didn't exist to start with that's fine. * If the attribute didn't exist to start with that's fine.
...@@ -244,7 +244,7 @@ xfs_set_mode(struct inode *inode, umode_t mode) ...@@ -244,7 +244,7 @@ xfs_set_mode(struct inode *inode, umode_t mode)
iattr.ia_mode = mode; iattr.ia_mode = mode;
iattr.ia_ctime = current_fs_time(inode->i_sb); iattr.ia_ctime = current_fs_time(inode->i_sb);
error = -xfs_setattr_nonsize(XFS_I(inode), &iattr, XFS_ATTR_NOACL); error = xfs_setattr_nonsize(XFS_I(inode), &iattr, XFS_ATTR_NOACL);
} }
return error; return error;
......
...@@ -240,7 +240,7 @@ xfs_end_io( ...@@ -240,7 +240,7 @@ xfs_end_io(
done: done:
if (error) if (error)
ioend->io_error = -error; ioend->io_error = error;
xfs_destroy_ioend(ioend); xfs_destroy_ioend(ioend);
} }
...@@ -308,14 +308,14 @@ xfs_map_blocks( ...@@ -308,14 +308,14 @@ xfs_map_blocks(
int nimaps = 1; int nimaps = 1;
if (XFS_FORCED_SHUTDOWN(mp)) if (XFS_FORCED_SHUTDOWN(mp))
return -XFS_ERROR(EIO); return -EIO;
if (type == XFS_IO_UNWRITTEN) if (type == XFS_IO_UNWRITTEN)
bmapi_flags |= XFS_BMAPI_IGSTATE; bmapi_flags |= XFS_BMAPI_IGSTATE;
if (!xfs_ilock_nowait(ip, XFS_ILOCK_SHARED)) { if (!xfs_ilock_nowait(ip, XFS_ILOCK_SHARED)) {
if (nonblocking) if (nonblocking)
return -XFS_ERROR(EAGAIN); return -EAGAIN;
xfs_ilock(ip, XFS_ILOCK_SHARED); xfs_ilock(ip, XFS_ILOCK_SHARED);
} }
...@@ -332,14 +332,14 @@ xfs_map_blocks( ...@@ -332,14 +332,14 @@ xfs_map_blocks(
xfs_iunlock(ip, XFS_ILOCK_SHARED); xfs_iunlock(ip, XFS_ILOCK_SHARED);
if (error) if (error)
return -XFS_ERROR(error); return error;
if (type == XFS_IO_DELALLOC && if (type == XFS_IO_DELALLOC &&
(!nimaps || isnullstartblock(imap->br_startblock))) { (!nimaps || isnullstartblock(imap->br_startblock))) {
error = xfs_iomap_write_allocate(ip, offset, imap); error = xfs_iomap_write_allocate(ip, offset, imap);
if (!error) if (!error)
trace_xfs_map_blocks_alloc(ip, offset, count, type, imap); trace_xfs_map_blocks_alloc(ip, offset, count, type, imap);
return -XFS_ERROR(error); return error;
} }
#ifdef DEBUG #ifdef DEBUG
...@@ -502,7 +502,7 @@ xfs_submit_ioend( ...@@ -502,7 +502,7 @@ xfs_submit_ioend(
* time. * time.
*/ */
if (fail) { if (fail) {
ioend->io_error = -fail; ioend->io_error = fail;
xfs_finish_ioend(ioend); xfs_finish_ioend(ioend);
continue; continue;
} }
...@@ -1253,7 +1253,7 @@ __xfs_get_blocks( ...@@ -1253,7 +1253,7 @@ __xfs_get_blocks(
int new = 0; int new = 0;
if (XFS_FORCED_SHUTDOWN(mp)) if (XFS_FORCED_SHUTDOWN(mp))
return -XFS_ERROR(EIO); return -EIO;
offset = (xfs_off_t)iblock << inode->i_blkbits; offset = (xfs_off_t)iblock << inode->i_blkbits;
ASSERT(bh_result->b_size >= (1 << inode->i_blkbits)); ASSERT(bh_result->b_size >= (1 << inode->i_blkbits));
...@@ -1302,7 +1302,7 @@ __xfs_get_blocks( ...@@ -1302,7 +1302,7 @@ __xfs_get_blocks(
error = xfs_iomap_write_direct(ip, offset, size, error = xfs_iomap_write_direct(ip, offset, size,
&imap, nimaps); &imap, nimaps);
if (error) if (error)
return -error; return error;
new = 1; new = 1;
} else { } else {
/* /*
...@@ -1415,7 +1415,7 @@ __xfs_get_blocks( ...@@ -1415,7 +1415,7 @@ __xfs_get_blocks(
out_unlock: out_unlock:
xfs_iunlock(ip, lockmode); xfs_iunlock(ip, lockmode);
return -error; return error;
} }
int int
......
...@@ -76,7 +76,7 @@ xfs_attr3_leaf_freextent( ...@@ -76,7 +76,7 @@ xfs_attr3_leaf_freextent(
error = xfs_bmapi_read(dp, (xfs_fileoff_t)tblkno, tblkcnt, error = xfs_bmapi_read(dp, (xfs_fileoff_t)tblkno, tblkcnt,
&map, &nmap, XFS_BMAPI_ATTRFORK); &map, &nmap, XFS_BMAPI_ATTRFORK);
if (error) { if (error) {
return(error); return error;
} }
ASSERT(nmap == 1); ASSERT(nmap == 1);
ASSERT(map.br_startblock != DELAYSTARTBLOCK); ASSERT(map.br_startblock != DELAYSTARTBLOCK);
...@@ -95,21 +95,21 @@ xfs_attr3_leaf_freextent( ...@@ -95,21 +95,21 @@ xfs_attr3_leaf_freextent(
dp->i_mount->m_ddev_targp, dp->i_mount->m_ddev_targp,
dblkno, dblkcnt, 0); dblkno, dblkcnt, 0);
if (!bp) if (!bp)
return ENOMEM; return -ENOMEM;
xfs_trans_binval(*trans, bp); xfs_trans_binval(*trans, bp);
/* /*
* Roll to next transaction. * Roll to next transaction.
*/ */
error = xfs_trans_roll(trans, dp); error = xfs_trans_roll(trans, dp);
if (error) if (error)
return (error); return error;
} }
tblkno += map.br_blockcount; tblkno += map.br_blockcount;
tblkcnt -= map.br_blockcount; tblkcnt -= map.br_blockcount;
} }
return(0); return 0;
} }
/* /*
...@@ -227,7 +227,7 @@ xfs_attr3_node_inactive( ...@@ -227,7 +227,7 @@ xfs_attr3_node_inactive(
*/ */
if (level > XFS_DA_NODE_MAXDEPTH) { if (level > XFS_DA_NODE_MAXDEPTH) {
xfs_trans_brelse(*trans, bp); /* no locks for later trans */ xfs_trans_brelse(*trans, bp); /* no locks for later trans */
return XFS_ERROR(EIO); return -EIO;
} }
node = bp->b_addr; node = bp->b_addr;
...@@ -256,7 +256,7 @@ xfs_attr3_node_inactive( ...@@ -256,7 +256,7 @@ xfs_attr3_node_inactive(
error = xfs_da3_node_read(*trans, dp, child_fsb, -2, &child_bp, error = xfs_da3_node_read(*trans, dp, child_fsb, -2, &child_bp,
XFS_ATTR_FORK); XFS_ATTR_FORK);
if (error) if (error)
return(error); return error;
if (child_bp) { if (child_bp) {
/* save for re-read later */ /* save for re-read later */
child_blkno = XFS_BUF_ADDR(child_bp); child_blkno = XFS_BUF_ADDR(child_bp);
...@@ -277,7 +277,7 @@ xfs_attr3_node_inactive( ...@@ -277,7 +277,7 @@ xfs_attr3_node_inactive(
child_bp); child_bp);
break; break;
default: default:
error = XFS_ERROR(EIO); error = -EIO;
xfs_trans_brelse(*trans, child_bp); xfs_trans_brelse(*trans, child_bp);
break; break;
} }
...@@ -360,7 +360,7 @@ xfs_attr3_root_inactive( ...@@ -360,7 +360,7 @@ xfs_attr3_root_inactive(
error = xfs_attr3_leaf_inactive(trans, dp, bp); error = xfs_attr3_leaf_inactive(trans, dp, bp);
break; break;
default: default:
error = XFS_ERROR(EIO); error = -EIO;
xfs_trans_brelse(*trans, bp); xfs_trans_brelse(*trans, bp);
break; break;
} }
...@@ -414,7 +414,7 @@ xfs_attr_inactive(xfs_inode_t *dp) ...@@ -414,7 +414,7 @@ xfs_attr_inactive(xfs_inode_t *dp)
error = xfs_trans_reserve(trans, &M_RES(mp)->tr_attrinval, 0, 0); error = xfs_trans_reserve(trans, &M_RES(mp)->tr_attrinval, 0, 0);
if (error) { if (error) {
xfs_trans_cancel(trans, 0); xfs_trans_cancel(trans, 0);
return(error); return error;
} }
xfs_ilock(dp, XFS_ILOCK_EXCL); xfs_ilock(dp, XFS_ILOCK_EXCL);
...@@ -443,10 +443,10 @@ xfs_attr_inactive(xfs_inode_t *dp) ...@@ -443,10 +443,10 @@ xfs_attr_inactive(xfs_inode_t *dp)
error = xfs_trans_commit(trans, XFS_TRANS_RELEASE_LOG_RES); error = xfs_trans_commit(trans, XFS_TRANS_RELEASE_LOG_RES);
xfs_iunlock(dp, XFS_ILOCK_EXCL); xfs_iunlock(dp, XFS_ILOCK_EXCL);
return(error); return error;
out: out:
xfs_trans_cancel(trans, XFS_TRANS_RELEASE_LOG_RES|XFS_TRANS_ABORT); xfs_trans_cancel(trans, XFS_TRANS_RELEASE_LOG_RES|XFS_TRANS_ABORT);
xfs_iunlock(dp, XFS_ILOCK_EXCL); xfs_iunlock(dp, XFS_ILOCK_EXCL);
return(error); return error;
} }
...@@ -50,11 +50,11 @@ xfs_attr_shortform_compare(const void *a, const void *b) ...@@ -50,11 +50,11 @@ xfs_attr_shortform_compare(const void *a, const void *b)
sa = (xfs_attr_sf_sort_t *)a; sa = (xfs_attr_sf_sort_t *)a;
sb = (xfs_attr_sf_sort_t *)b; sb = (xfs_attr_sf_sort_t *)b;
if (sa->hash < sb->hash) { if (sa->hash < sb->hash) {
return(-1); return -1;
} else if (sa->hash > sb->hash) { } else if (sa->hash > sb->hash) {
return(1); return 1;
} else { } else {
return(sa->entno - sb->entno); return sa->entno - sb->entno;
} }
} }
...@@ -86,7 +86,7 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context) ...@@ -86,7 +86,7 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context)
sf = (xfs_attr_shortform_t *)dp->i_afp->if_u1.if_data; sf = (xfs_attr_shortform_t *)dp->i_afp->if_u1.if_data;
ASSERT(sf != NULL); ASSERT(sf != NULL);
if (!sf->hdr.count) if (!sf->hdr.count)
return(0); return 0;
cursor = context->cursor; cursor = context->cursor;
ASSERT(cursor != NULL); ASSERT(cursor != NULL);
...@@ -124,7 +124,7 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context) ...@@ -124,7 +124,7 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context)
sfe = XFS_ATTR_SF_NEXTENTRY(sfe); sfe = XFS_ATTR_SF_NEXTENTRY(sfe);
} }
trace_xfs_attr_list_sf_all(context); trace_xfs_attr_list_sf_all(context);
return(0); return 0;
} }
/* do no more for a search callback */ /* do no more for a search callback */
...@@ -150,7 +150,7 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context) ...@@ -150,7 +150,7 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context)
XFS_ERRLEVEL_LOW, XFS_ERRLEVEL_LOW,
context->dp->i_mount, sfe); context->dp->i_mount, sfe);
kmem_free(sbuf); kmem_free(sbuf);
return XFS_ERROR(EFSCORRUPTED); return -EFSCORRUPTED;
} }
sbp->entno = i; sbp->entno = i;
...@@ -188,7 +188,7 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context) ...@@ -188,7 +188,7 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context)
} }
if (i == nsbuf) { if (i == nsbuf) {
kmem_free(sbuf); kmem_free(sbuf);
return(0); return 0;
} }
/* /*
...@@ -213,7 +213,7 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context) ...@@ -213,7 +213,7 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context)
} }
kmem_free(sbuf); kmem_free(sbuf);
return(0); return 0;
} }
STATIC int STATIC int
...@@ -243,8 +243,8 @@ xfs_attr_node_list(xfs_attr_list_context_t *context) ...@@ -243,8 +243,8 @@ xfs_attr_node_list(xfs_attr_list_context_t *context)
if (cursor->blkno > 0) { if (cursor->blkno > 0) {
error = xfs_da3_node_read(NULL, dp, cursor->blkno, -1, error = xfs_da3_node_read(NULL, dp, cursor->blkno, -1,
&bp, XFS_ATTR_FORK); &bp, XFS_ATTR_FORK);
if ((error != 0) && (error != EFSCORRUPTED)) if ((error != 0) && (error != -EFSCORRUPTED))
return(error); return error;
if (bp) { if (bp) {
struct xfs_attr_leaf_entry *entries; struct xfs_attr_leaf_entry *entries;
...@@ -295,7 +295,7 @@ xfs_attr_node_list(xfs_attr_list_context_t *context) ...@@ -295,7 +295,7 @@ xfs_attr_node_list(xfs_attr_list_context_t *context)
cursor->blkno, -1, &bp, cursor->blkno, -1, &bp,
XFS_ATTR_FORK); XFS_ATTR_FORK);
if (error) if (error)
return(error); return error;
node = bp->b_addr; node = bp->b_addr;
magic = be16_to_cpu(node->hdr.info.magic); magic = be16_to_cpu(node->hdr.info.magic);
if (magic == XFS_ATTR_LEAF_MAGIC || if (magic == XFS_ATTR_LEAF_MAGIC ||
...@@ -308,7 +308,7 @@ xfs_attr_node_list(xfs_attr_list_context_t *context) ...@@ -308,7 +308,7 @@ xfs_attr_node_list(xfs_attr_list_context_t *context)
context->dp->i_mount, context->dp->i_mount,
node); node);
xfs_trans_brelse(NULL, bp); xfs_trans_brelse(NULL, bp);
return XFS_ERROR(EFSCORRUPTED); return -EFSCORRUPTED;
} }
dp->d_ops->node_hdr_from_disk(&nodehdr, node); dp->d_ops->node_hdr_from_disk(&nodehdr, node);
...@@ -496,11 +496,11 @@ xfs_attr_leaf_list(xfs_attr_list_context_t *context) ...@@ -496,11 +496,11 @@ xfs_attr_leaf_list(xfs_attr_list_context_t *context)
context->cursor->blkno = 0; context->cursor->blkno = 0;
error = xfs_attr3_leaf_read(NULL, context->dp, 0, -1, &bp); error = xfs_attr3_leaf_read(NULL, context->dp, 0, -1, &bp);
if (error) if (error)
return XFS_ERROR(error); return error;
error = xfs_attr3_leaf_list_int(bp, context); error = xfs_attr3_leaf_list_int(bp, context);
xfs_trans_brelse(NULL, bp); xfs_trans_brelse(NULL, bp);
return XFS_ERROR(error); return error;
} }
int int
...@@ -514,7 +514,7 @@ xfs_attr_list_int( ...@@ -514,7 +514,7 @@ xfs_attr_list_int(
XFS_STATS_INC(xs_attr_list); XFS_STATS_INC(xs_attr_list);
if (XFS_FORCED_SHUTDOWN(dp->i_mount)) if (XFS_FORCED_SHUTDOWN(dp->i_mount))
return EIO; return -EIO;
/* /*
* Decide on what work routines to call based on the inode size. * Decide on what work routines to call based on the inode size.
...@@ -616,16 +616,16 @@ xfs_attr_list( ...@@ -616,16 +616,16 @@ xfs_attr_list(
* Validate the cursor. * Validate the cursor.
*/ */
if (cursor->pad1 || cursor->pad2) if (cursor->pad1 || cursor->pad2)
return(XFS_ERROR(EINVAL)); return -EINVAL;
if ((cursor->initted == 0) && if ((cursor->initted == 0) &&
(cursor->hashval || cursor->blkno || cursor->offset)) (cursor->hashval || cursor->blkno || cursor->offset))
return XFS_ERROR(EINVAL); return -EINVAL;
/* /*
* Check for a properly aligned buffer. * Check for a properly aligned buffer.
*/ */
if (((long)buffer) & (sizeof(int)-1)) if (((long)buffer) & (sizeof(int)-1))
return XFS_ERROR(EFAULT); return -EFAULT;
if (flags & ATTR_KERNOVAL) if (flags & ATTR_KERNOVAL)
bufsize = 0; bufsize = 0;
...@@ -648,6 +648,6 @@ xfs_attr_list( ...@@ -648,6 +648,6 @@ xfs_attr_list(
alist->al_offset[0] = context.bufsize; alist->al_offset[0] = context.bufsize;
error = xfs_attr_list_int(&context); error = xfs_attr_list_int(&context);
ASSERT(error >= 0); ASSERT(error <= 0);
return error; return error;
} }
...@@ -133,7 +133,7 @@ xfs_bmap_finish( ...@@ -133,7 +133,7 @@ xfs_bmap_finish(
mp = ntp->t_mountp; mp = ntp->t_mountp;
if (!XFS_FORCED_SHUTDOWN(mp)) if (!XFS_FORCED_SHUTDOWN(mp))
xfs_force_shutdown(mp, xfs_force_shutdown(mp,
(error == EFSCORRUPTED) ? (error == -EFSCORRUPTED) ?
SHUTDOWN_CORRUPT_INCORE : SHUTDOWN_CORRUPT_INCORE :
SHUTDOWN_META_IO_ERROR); SHUTDOWN_META_IO_ERROR);
return error; return error;
...@@ -365,7 +365,7 @@ xfs_bmap_count_tree( ...@@ -365,7 +365,7 @@ xfs_bmap_count_tree(
xfs_trans_brelse(tp, bp); xfs_trans_brelse(tp, bp);
XFS_ERROR_REPORT("xfs_bmap_count_tree(1)", XFS_ERROR_REPORT("xfs_bmap_count_tree(1)",
XFS_ERRLEVEL_LOW, mp); XFS_ERRLEVEL_LOW, mp);
return XFS_ERROR(EFSCORRUPTED); return -EFSCORRUPTED;
} }
xfs_trans_brelse(tp, bp); xfs_trans_brelse(tp, bp);
} else { } else {
...@@ -432,7 +432,7 @@ xfs_bmap_count_blocks( ...@@ -432,7 +432,7 @@ xfs_bmap_count_blocks(
if (unlikely(xfs_bmap_count_tree(mp, tp, ifp, bno, level, count) < 0)) { if (unlikely(xfs_bmap_count_tree(mp, tp, ifp, bno, level, count) < 0)) {
XFS_ERROR_REPORT("xfs_bmap_count_blocks(2)", XFS_ERRLEVEL_LOW, XFS_ERROR_REPORT("xfs_bmap_count_blocks(2)", XFS_ERRLEVEL_LOW,
mp); mp);
return XFS_ERROR(EFSCORRUPTED); return -EFSCORRUPTED;
} }
return 0; return 0;
...@@ -524,13 +524,13 @@ xfs_getbmap( ...@@ -524,13 +524,13 @@ xfs_getbmap(
if (ip->i_d.di_aformat != XFS_DINODE_FMT_EXTENTS && if (ip->i_d.di_aformat != XFS_DINODE_FMT_EXTENTS &&
ip->i_d.di_aformat != XFS_DINODE_FMT_BTREE && ip->i_d.di_aformat != XFS_DINODE_FMT_BTREE &&
ip->i_d.di_aformat != XFS_DINODE_FMT_LOCAL) ip->i_d.di_aformat != XFS_DINODE_FMT_LOCAL)
return XFS_ERROR(EINVAL); return -EINVAL;
} else if (unlikely( } else if (unlikely(
ip->i_d.di_aformat != 0 && ip->i_d.di_aformat != 0 &&
ip->i_d.di_aformat != XFS_DINODE_FMT_EXTENTS)) { ip->i_d.di_aformat != XFS_DINODE_FMT_EXTENTS)) {
XFS_ERROR_REPORT("xfs_getbmap", XFS_ERRLEVEL_LOW, XFS_ERROR_REPORT("xfs_getbmap", XFS_ERRLEVEL_LOW,
ip->i_mount); ip->i_mount);
return XFS_ERROR(EFSCORRUPTED); return -EFSCORRUPTED;
} }
prealloced = 0; prealloced = 0;
...@@ -539,7 +539,7 @@ xfs_getbmap( ...@@ -539,7 +539,7 @@ xfs_getbmap(
if (ip->i_d.di_format != XFS_DINODE_FMT_EXTENTS && if (ip->i_d.di_format != XFS_DINODE_FMT_EXTENTS &&
ip->i_d.di_format != XFS_DINODE_FMT_BTREE && ip->i_d.di_format != XFS_DINODE_FMT_BTREE &&
ip->i_d.di_format != XFS_DINODE_FMT_LOCAL) ip->i_d.di_format != XFS_DINODE_FMT_LOCAL)
return XFS_ERROR(EINVAL); return -EINVAL;
if (xfs_get_extsz_hint(ip) || if (xfs_get_extsz_hint(ip) ||
ip->i_d.di_flags & (XFS_DIFLAG_PREALLOC|XFS_DIFLAG_APPEND)){ ip->i_d.di_flags & (XFS_DIFLAG_PREALLOC|XFS_DIFLAG_APPEND)){
...@@ -559,26 +559,26 @@ xfs_getbmap( ...@@ -559,26 +559,26 @@ xfs_getbmap(
bmv->bmv_entries = 0; bmv->bmv_entries = 0;
return 0; return 0;
} else if (bmv->bmv_length < 0) { } else if (bmv->bmv_length < 0) {
return XFS_ERROR(EINVAL); return -EINVAL;
} }
nex = bmv->bmv_count - 1; nex = bmv->bmv_count - 1;
if (nex <= 0) if (nex <= 0)
return XFS_ERROR(EINVAL); return -EINVAL;
bmvend = bmv->bmv_offset + bmv->bmv_length; bmvend = bmv->bmv_offset + bmv->bmv_length;
if (bmv->bmv_count > ULONG_MAX / sizeof(struct getbmapx)) if (bmv->bmv_count > ULONG_MAX / sizeof(struct getbmapx))
return XFS_ERROR(ENOMEM); return -ENOMEM;
out = kmem_zalloc_large(bmv->bmv_count * sizeof(struct getbmapx), 0); out = kmem_zalloc_large(bmv->bmv_count * sizeof(struct getbmapx), 0);
if (!out) if (!out)
return XFS_ERROR(ENOMEM); return -ENOMEM;
xfs_ilock(ip, XFS_IOLOCK_SHARED); xfs_ilock(ip, XFS_IOLOCK_SHARED);
if (whichfork == XFS_DATA_FORK) { if (whichfork == XFS_DATA_FORK) {
if (!(iflags & BMV_IF_DELALLOC) && if (!(iflags & BMV_IF_DELALLOC) &&
(ip->i_delayed_blks || XFS_ISIZE(ip) > ip->i_d.di_size)) { (ip->i_delayed_blks || XFS_ISIZE(ip) > ip->i_d.di_size)) {
error = -filemap_write_and_wait(VFS_I(ip)->i_mapping); error = filemap_write_and_wait(VFS_I(ip)->i_mapping);
if (error) if (error)
goto out_unlock_iolock; goto out_unlock_iolock;
...@@ -611,7 +611,7 @@ xfs_getbmap( ...@@ -611,7 +611,7 @@ xfs_getbmap(
/* /*
* Allocate enough space to handle "subnex" maps at a time. * Allocate enough space to handle "subnex" maps at a time.
*/ */
error = ENOMEM; error = -ENOMEM;
subnex = 16; subnex = 16;
map = kmem_alloc(subnex * sizeof(*map), KM_MAYFAIL | KM_NOFS); map = kmem_alloc(subnex * sizeof(*map), KM_MAYFAIL | KM_NOFS);
if (!map) if (!map)
...@@ -882,7 +882,7 @@ xfs_free_eofblocks( ...@@ -882,7 +882,7 @@ xfs_free_eofblocks(
if (need_iolock) { if (need_iolock) {
if (!xfs_ilock_nowait(ip, XFS_IOLOCK_EXCL)) { if (!xfs_ilock_nowait(ip, XFS_IOLOCK_EXCL)) {
xfs_trans_cancel(tp, 0); xfs_trans_cancel(tp, 0);
return EAGAIN; return -EAGAIN;
} }
} }
...@@ -955,14 +955,14 @@ xfs_alloc_file_space( ...@@ -955,14 +955,14 @@ xfs_alloc_file_space(
trace_xfs_alloc_file_space(ip); trace_xfs_alloc_file_space(ip);
if (XFS_FORCED_SHUTDOWN(mp)) if (XFS_FORCED_SHUTDOWN(mp))
return XFS_ERROR(EIO); return -EIO;
error = xfs_qm_dqattach(ip, 0); error = xfs_qm_dqattach(ip, 0);
if (error) if (error)
return error; return error;
if (len <= 0) if (len <= 0)
return XFS_ERROR(EINVAL); return -EINVAL;
rt = XFS_IS_REALTIME_INODE(ip); rt = XFS_IS_REALTIME_INODE(ip);
extsz = xfs_get_extsz_hint(ip); extsz = xfs_get_extsz_hint(ip);
...@@ -1028,7 +1028,7 @@ xfs_alloc_file_space( ...@@ -1028,7 +1028,7 @@ xfs_alloc_file_space(
/* /*
* Free the transaction structure. * Free the transaction structure.
*/ */
ASSERT(error == ENOSPC || XFS_FORCED_SHUTDOWN(mp)); ASSERT(error == -ENOSPC || XFS_FORCED_SHUTDOWN(mp));
xfs_trans_cancel(tp, 0); xfs_trans_cancel(tp, 0);
break; break;
} }
...@@ -1065,7 +1065,7 @@ xfs_alloc_file_space( ...@@ -1065,7 +1065,7 @@ xfs_alloc_file_space(
allocated_fsb = imapp->br_blockcount; allocated_fsb = imapp->br_blockcount;
if (nimaps == 0) { if (nimaps == 0) {
error = XFS_ERROR(ENOSPC); error = -ENOSPC;
break; break;
} }
...@@ -1126,7 +1126,7 @@ xfs_zero_remaining_bytes( ...@@ -1126,7 +1126,7 @@ xfs_zero_remaining_bytes(
mp->m_rtdev_targp : mp->m_ddev_targp, mp->m_rtdev_targp : mp->m_ddev_targp,
BTOBB(mp->m_sb.sb_blocksize), 0); BTOBB(mp->m_sb.sb_blocksize), 0);
if (!bp) if (!bp)
return XFS_ERROR(ENOMEM); return -ENOMEM;
xfs_buf_unlock(bp); xfs_buf_unlock(bp);
...@@ -1158,7 +1158,7 @@ xfs_zero_remaining_bytes( ...@@ -1158,7 +1158,7 @@ xfs_zero_remaining_bytes(
XFS_BUF_SET_ADDR(bp, xfs_fsb_to_db(ip, imap.br_startblock)); XFS_BUF_SET_ADDR(bp, xfs_fsb_to_db(ip, imap.br_startblock));
if (XFS_FORCED_SHUTDOWN(mp)) { if (XFS_FORCED_SHUTDOWN(mp)) {
error = XFS_ERROR(EIO); error = -EIO;
break; break;
} }
xfs_buf_iorequest(bp); xfs_buf_iorequest(bp);
...@@ -1176,7 +1176,7 @@ xfs_zero_remaining_bytes( ...@@ -1176,7 +1176,7 @@ xfs_zero_remaining_bytes(
XFS_BUF_WRITE(bp); XFS_BUF_WRITE(bp);
if (XFS_FORCED_SHUTDOWN(mp)) { if (XFS_FORCED_SHUTDOWN(mp)) {
error = XFS_ERROR(EIO); error = -EIO;
break; break;
} }
xfs_buf_iorequest(bp); xfs_buf_iorequest(bp);
...@@ -1234,7 +1234,7 @@ xfs_free_file_space( ...@@ -1234,7 +1234,7 @@ xfs_free_file_space(
rounding = max_t(xfs_off_t, 1 << mp->m_sb.sb_blocklog, PAGE_CACHE_SIZE); rounding = max_t(xfs_off_t, 1 << mp->m_sb.sb_blocklog, PAGE_CACHE_SIZE);
ioffset = offset & ~(rounding - 1); ioffset = offset & ~(rounding - 1);
error = -filemap_write_and_wait_range(VFS_I(ip)->i_mapping, error = filemap_write_and_wait_range(VFS_I(ip)->i_mapping,
ioffset, -1); ioffset, -1);
if (error) if (error)
goto out; goto out;
...@@ -1315,7 +1315,7 @@ xfs_free_file_space( ...@@ -1315,7 +1315,7 @@ xfs_free_file_space(
/* /*
* Free the transaction structure. * Free the transaction structure.
*/ */
ASSERT(error == ENOSPC || XFS_FORCED_SHUTDOWN(mp)); ASSERT(error == -ENOSPC || XFS_FORCED_SHUTDOWN(mp));
xfs_trans_cancel(tp, 0); xfs_trans_cancel(tp, 0);
break; break;
} }
...@@ -1557,14 +1557,14 @@ xfs_swap_extents_check_format( ...@@ -1557,14 +1557,14 @@ xfs_swap_extents_check_format(
/* Should never get a local format */ /* Should never get a local format */
if (ip->i_d.di_format == XFS_DINODE_FMT_LOCAL || if (ip->i_d.di_format == XFS_DINODE_FMT_LOCAL ||
tip->i_d.di_format == XFS_DINODE_FMT_LOCAL) tip->i_d.di_format == XFS_DINODE_FMT_LOCAL)
return EINVAL; return -EINVAL;
/* /*
* if the target inode has less extents that then temporary inode then * if the target inode has less extents that then temporary inode then
* why did userspace call us? * why did userspace call us?
*/ */
if (ip->i_d.di_nextents < tip->i_d.di_nextents) if (ip->i_d.di_nextents < tip->i_d.di_nextents)
return EINVAL; return -EINVAL;
/* /*
* if the target inode is in extent form and the temp inode is in btree * if the target inode is in extent form and the temp inode is in btree
...@@ -1573,19 +1573,19 @@ xfs_swap_extents_check_format( ...@@ -1573,19 +1573,19 @@ xfs_swap_extents_check_format(
*/ */
if (ip->i_d.di_format == XFS_DINODE_FMT_EXTENTS && if (ip->i_d.di_format == XFS_DINODE_FMT_EXTENTS &&
tip->i_d.di_format == XFS_DINODE_FMT_BTREE) tip->i_d.di_format == XFS_DINODE_FMT_BTREE)
return EINVAL; return -EINVAL;
/* Check temp in extent form to max in target */ /* Check temp in extent form to max in target */
if (tip->i_d.di_format == XFS_DINODE_FMT_EXTENTS && if (tip->i_d.di_format == XFS_DINODE_FMT_EXTENTS &&
XFS_IFORK_NEXTENTS(tip, XFS_DATA_FORK) > XFS_IFORK_NEXTENTS(tip, XFS_DATA_FORK) >
XFS_IFORK_MAXEXT(ip, XFS_DATA_FORK)) XFS_IFORK_MAXEXT(ip, XFS_DATA_FORK))
return EINVAL; return -EINVAL;
/* Check target in extent form to max in temp */ /* Check target in extent form to max in temp */
if (ip->i_d.di_format == XFS_DINODE_FMT_EXTENTS && if (ip->i_d.di_format == XFS_DINODE_FMT_EXTENTS &&
XFS_IFORK_NEXTENTS(ip, XFS_DATA_FORK) > XFS_IFORK_NEXTENTS(ip, XFS_DATA_FORK) >
XFS_IFORK_MAXEXT(tip, XFS_DATA_FORK)) XFS_IFORK_MAXEXT(tip, XFS_DATA_FORK))
return EINVAL; return -EINVAL;
/* /*
* If we are in a btree format, check that the temp root block will fit * If we are in a btree format, check that the temp root block will fit
...@@ -1599,20 +1599,20 @@ xfs_swap_extents_check_format( ...@@ -1599,20 +1599,20 @@ xfs_swap_extents_check_format(
if (tip->i_d.di_format == XFS_DINODE_FMT_BTREE) { if (tip->i_d.di_format == XFS_DINODE_FMT_BTREE) {
if (XFS_IFORK_BOFF(ip) && if (XFS_IFORK_BOFF(ip) &&
XFS_BMAP_BMDR_SPACE(tip->i_df.if_broot) > XFS_IFORK_BOFF(ip)) XFS_BMAP_BMDR_SPACE(tip->i_df.if_broot) > XFS_IFORK_BOFF(ip))
return EINVAL; return -EINVAL;
if (XFS_IFORK_NEXTENTS(tip, XFS_DATA_FORK) <= if (XFS_IFORK_NEXTENTS(tip, XFS_DATA_FORK) <=
XFS_IFORK_MAXEXT(ip, XFS_DATA_FORK)) XFS_IFORK_MAXEXT(ip, XFS_DATA_FORK))
return EINVAL; return -EINVAL;
} }
/* Reciprocal target->temp btree format checks */ /* Reciprocal target->temp btree format checks */
if (ip->i_d.di_format == XFS_DINODE_FMT_BTREE) { if (ip->i_d.di_format == XFS_DINODE_FMT_BTREE) {
if (XFS_IFORK_BOFF(tip) && if (XFS_IFORK_BOFF(tip) &&
XFS_BMAP_BMDR_SPACE(ip->i_df.if_broot) > XFS_IFORK_BOFF(tip)) XFS_BMAP_BMDR_SPACE(ip->i_df.if_broot) > XFS_IFORK_BOFF(tip))
return EINVAL; return -EINVAL;
if (XFS_IFORK_NEXTENTS(ip, XFS_DATA_FORK) <= if (XFS_IFORK_NEXTENTS(ip, XFS_DATA_FORK) <=
XFS_IFORK_MAXEXT(tip, XFS_DATA_FORK)) XFS_IFORK_MAXEXT(tip, XFS_DATA_FORK))
return EINVAL; return -EINVAL;
} }
return 0; return 0;
...@@ -1636,7 +1636,7 @@ xfs_swap_extents( ...@@ -1636,7 +1636,7 @@ xfs_swap_extents(
tempifp = kmem_alloc(sizeof(xfs_ifork_t), KM_MAYFAIL); tempifp = kmem_alloc(sizeof(xfs_ifork_t), KM_MAYFAIL);
if (!tempifp) { if (!tempifp) {
error = XFS_ERROR(ENOMEM); error = -ENOMEM;
goto out; goto out;
} }
...@@ -1651,24 +1651,24 @@ xfs_swap_extents( ...@@ -1651,24 +1651,24 @@ xfs_swap_extents(
/* Verify that both files have the same format */ /* Verify that both files have the same format */
if ((ip->i_d.di_mode & S_IFMT) != (tip->i_d.di_mode & S_IFMT)) { if ((ip->i_d.di_mode & S_IFMT) != (tip->i_d.di_mode & S_IFMT)) {
error = XFS_ERROR(EINVAL); error = -EINVAL;
goto out_unlock; goto out_unlock;
} }
/* Verify both files are either real-time or non-realtime */ /* Verify both files are either real-time or non-realtime */
if (XFS_IS_REALTIME_INODE(ip) != XFS_IS_REALTIME_INODE(tip)) { if (XFS_IS_REALTIME_INODE(ip) != XFS_IS_REALTIME_INODE(tip)) {
error = XFS_ERROR(EINVAL); error = -EINVAL;
goto out_unlock; goto out_unlock;
} }
error = -filemap_write_and_wait(VFS_I(tip)->i_mapping); error = filemap_write_and_wait(VFS_I(tip)->i_mapping);
if (error) if (error)
goto out_unlock; goto out_unlock;
truncate_pagecache_range(VFS_I(tip), 0, -1); truncate_pagecache_range(VFS_I(tip), 0, -1);
/* Verify O_DIRECT for ftmp */ /* Verify O_DIRECT for ftmp */
if (VN_CACHED(VFS_I(tip)) != 0) { if (VN_CACHED(VFS_I(tip)) != 0) {
error = XFS_ERROR(EINVAL); error = -EINVAL;
goto out_unlock; goto out_unlock;
} }
...@@ -1676,7 +1676,7 @@ xfs_swap_extents( ...@@ -1676,7 +1676,7 @@ xfs_swap_extents(
if (sxp->sx_offset != 0 || if (sxp->sx_offset != 0 ||
sxp->sx_length != ip->i_d.di_size || sxp->sx_length != ip->i_d.di_size ||
sxp->sx_length != tip->i_d.di_size) { sxp->sx_length != tip->i_d.di_size) {
error = XFS_ERROR(EFAULT); error = -EFAULT;
goto out_unlock; goto out_unlock;
} }
...@@ -1703,7 +1703,7 @@ xfs_swap_extents( ...@@ -1703,7 +1703,7 @@ xfs_swap_extents(
(sbp->bs_ctime.tv_nsec != VFS_I(ip)->i_ctime.tv_nsec) || (sbp->bs_ctime.tv_nsec != VFS_I(ip)->i_ctime.tv_nsec) ||
(sbp->bs_mtime.tv_sec != VFS_I(ip)->i_mtime.tv_sec) || (sbp->bs_mtime.tv_sec != VFS_I(ip)->i_mtime.tv_sec) ||
(sbp->bs_mtime.tv_nsec != VFS_I(ip)->i_mtime.tv_nsec)) { (sbp->bs_mtime.tv_nsec != VFS_I(ip)->i_mtime.tv_nsec)) {
error = XFS_ERROR(EBUSY); error = -EBUSY;
goto out_unlock; goto out_unlock;
} }
...@@ -1714,7 +1714,7 @@ xfs_swap_extents( ...@@ -1714,7 +1714,7 @@ xfs_swap_extents(
* until we have switched the extents. * until we have switched the extents.
*/ */
if (VN_MAPPED(VFS_I(ip))) { if (VN_MAPPED(VFS_I(ip))) {
error = XFS_ERROR(EBUSY); error = -EBUSY;
goto out_unlock; goto out_unlock;
} }
......
...@@ -130,7 +130,7 @@ xfs_buf_get_maps( ...@@ -130,7 +130,7 @@ xfs_buf_get_maps(
bp->b_maps = kmem_zalloc(map_count * sizeof(struct xfs_buf_map), bp->b_maps = kmem_zalloc(map_count * sizeof(struct xfs_buf_map),
KM_NOFS); KM_NOFS);
if (!bp->b_maps) if (!bp->b_maps)
return ENOMEM; return -ENOMEM;
return 0; return 0;
} }
...@@ -344,7 +344,7 @@ xfs_buf_allocate_memory( ...@@ -344,7 +344,7 @@ xfs_buf_allocate_memory(
if (unlikely(page == NULL)) { if (unlikely(page == NULL)) {
if (flags & XBF_READ_AHEAD) { if (flags & XBF_READ_AHEAD) {
bp->b_page_count = i; bp->b_page_count = i;
error = ENOMEM; error = -ENOMEM;
goto out_free_pages; goto out_free_pages;
} }
...@@ -465,7 +465,7 @@ _xfs_buf_find( ...@@ -465,7 +465,7 @@ _xfs_buf_find(
eofs = XFS_FSB_TO_BB(btp->bt_mount, btp->bt_mount->m_sb.sb_dblocks); eofs = XFS_FSB_TO_BB(btp->bt_mount, btp->bt_mount->m_sb.sb_dblocks);
if (blkno >= eofs) { if (blkno >= eofs) {
/* /*
* XXX (dgc): we should really be returning EFSCORRUPTED here, * XXX (dgc): we should really be returning -EFSCORRUPTED here,
* but none of the higher level infrastructure supports * but none of the higher level infrastructure supports
* returning a specific error on buffer lookup failures. * returning a specific error on buffer lookup failures.
*/ */
...@@ -1052,8 +1052,8 @@ xfs_buf_ioerror( ...@@ -1052,8 +1052,8 @@ xfs_buf_ioerror(
xfs_buf_t *bp, xfs_buf_t *bp,
int error) int error)
{ {
ASSERT(error >= 0 && error <= 0xffff); ASSERT(error <= 0 && error >= -1000);
bp->b_error = (unsigned short)error; bp->b_error = error;
trace_xfs_buf_ioerror(bp, error, _RET_IP_); trace_xfs_buf_ioerror(bp, error, _RET_IP_);
} }
...@@ -1064,7 +1064,7 @@ xfs_buf_ioerror_alert( ...@@ -1064,7 +1064,7 @@ xfs_buf_ioerror_alert(
{ {
xfs_alert(bp->b_target->bt_mount, xfs_alert(bp->b_target->bt_mount,
"metadata I/O error: block 0x%llx (\"%s\") error %d numblks %d", "metadata I/O error: block 0x%llx (\"%s\") error %d numblks %d",
(__uint64_t)XFS_BUF_ADDR(bp), func, bp->b_error, bp->b_length); (__uint64_t)XFS_BUF_ADDR(bp), func, -bp->b_error, bp->b_length);
} }
/* /*
...@@ -1083,7 +1083,7 @@ xfs_bioerror( ...@@ -1083,7 +1083,7 @@ xfs_bioerror(
/* /*
* No need to wait until the buffer is unpinned, we aren't flushing it. * No need to wait until the buffer is unpinned, we aren't flushing it.
*/ */
xfs_buf_ioerror(bp, EIO); xfs_buf_ioerror(bp, -EIO);
/* /*
* We're calling xfs_buf_ioend, so delete XBF_DONE flag. * We're calling xfs_buf_ioend, so delete XBF_DONE flag.
...@@ -1094,7 +1094,7 @@ xfs_bioerror( ...@@ -1094,7 +1094,7 @@ xfs_bioerror(
xfs_buf_ioend(bp, 0); xfs_buf_ioend(bp, 0);
return EIO; return -EIO;
} }
/* /*
...@@ -1127,13 +1127,13 @@ xfs_bioerror_relse( ...@@ -1127,13 +1127,13 @@ xfs_bioerror_relse(
* There's no reason to mark error for * There's no reason to mark error for
* ASYNC buffers. * ASYNC buffers.
*/ */
xfs_buf_ioerror(bp, EIO); xfs_buf_ioerror(bp, -EIO);
complete(&bp->b_iowait); complete(&bp->b_iowait);
} else { } else {
xfs_buf_relse(bp); xfs_buf_relse(bp);
} }
return EIO; return -EIO;
} }
STATIC int STATIC int
...@@ -1199,7 +1199,7 @@ xfs_buf_bio_end_io( ...@@ -1199,7 +1199,7 @@ xfs_buf_bio_end_io(
* buffers that require multiple bios to complete. * buffers that require multiple bios to complete.
*/ */
if (!bp->b_error) if (!bp->b_error)
xfs_buf_ioerror(bp, -error); xfs_buf_ioerror(bp, error);
if (!bp->b_error && xfs_buf_is_vmapped(bp) && (bp->b_flags & XBF_READ)) if (!bp->b_error && xfs_buf_is_vmapped(bp) && (bp->b_flags & XBF_READ))
invalidate_kernel_vmap_range(bp->b_addr, xfs_buf_vmap_len(bp)); invalidate_kernel_vmap_range(bp->b_addr, xfs_buf_vmap_len(bp));
...@@ -1286,7 +1286,7 @@ xfs_buf_ioapply_map( ...@@ -1286,7 +1286,7 @@ xfs_buf_ioapply_map(
* because the caller (xfs_buf_iorequest) holds a count itself. * because the caller (xfs_buf_iorequest) holds a count itself.
*/ */
atomic_dec(&bp->b_io_remaining); atomic_dec(&bp->b_io_remaining);
xfs_buf_ioerror(bp, EIO); xfs_buf_ioerror(bp, -EIO);
bio_put(bio); bio_put(bio);
} }
...@@ -1628,7 +1628,7 @@ xfs_setsize_buftarg( ...@@ -1628,7 +1628,7 @@ xfs_setsize_buftarg(
xfs_warn(btp->bt_mount, xfs_warn(btp->bt_mount,
"Cannot set_blocksize to %u on device %s", "Cannot set_blocksize to %u on device %s",
sectorsize, name); sectorsize, name);
return EINVAL; return -EINVAL;
} }
/* Set up device logical sector size mask */ /* Set up device logical sector size mask */
......
...@@ -178,7 +178,7 @@ typedef struct xfs_buf { ...@@ -178,7 +178,7 @@ typedef struct xfs_buf {
atomic_t b_io_remaining; /* #outstanding I/O requests */ atomic_t b_io_remaining; /* #outstanding I/O requests */
unsigned int b_page_count; /* size of page array */ unsigned int b_page_count; /* size of page array */
unsigned int b_offset; /* page offset in first page */ unsigned int b_offset; /* page offset in first page */
unsigned short b_error; /* error code on I/O */ int b_error; /* error code on I/O */
const struct xfs_buf_ops *b_ops; const struct xfs_buf_ops *b_ops;
#ifdef XFS_BUF_LOCK_TRACKING #ifdef XFS_BUF_LOCK_TRACKING
......
...@@ -488,7 +488,7 @@ xfs_buf_item_unpin( ...@@ -488,7 +488,7 @@ xfs_buf_item_unpin(
xfs_buf_lock(bp); xfs_buf_lock(bp);
xfs_buf_hold(bp); xfs_buf_hold(bp);
bp->b_flags |= XBF_ASYNC; bp->b_flags |= XBF_ASYNC;
xfs_buf_ioerror(bp, EIO); xfs_buf_ioerror(bp, -EIO);
XFS_BUF_UNDONE(bp); XFS_BUF_UNDONE(bp);
xfs_buf_stale(bp); xfs_buf_stale(bp);
xfs_buf_ioend(bp, 0); xfs_buf_ioend(bp, 0);
...@@ -725,7 +725,7 @@ xfs_buf_item_get_format( ...@@ -725,7 +725,7 @@ xfs_buf_item_get_format(
bip->bli_formats = kmem_zalloc(count * sizeof(struct xfs_buf_log_format), bip->bli_formats = kmem_zalloc(count * sizeof(struct xfs_buf_log_format),
KM_SLEEP); KM_SLEEP);
if (!bip->bli_formats) if (!bip->bli_formats)
return ENOMEM; return -ENOMEM;
return 0; return 0;
} }
......
...@@ -95,7 +95,7 @@ xfs_dir2_sf_getdents( ...@@ -95,7 +95,7 @@ xfs_dir2_sf_getdents(
*/ */
if (dp->i_d.di_size < offsetof(xfs_dir2_sf_hdr_t, parent)) { if (dp->i_d.di_size < offsetof(xfs_dir2_sf_hdr_t, parent)) {
ASSERT(XFS_FORCED_SHUTDOWN(dp->i_mount)); ASSERT(XFS_FORCED_SHUTDOWN(dp->i_mount));
return XFS_ERROR(EIO); return -EIO;
} }
ASSERT(dp->i_df.if_bytes == dp->i_d.di_size); ASSERT(dp->i_df.if_bytes == dp->i_d.di_size);
...@@ -677,7 +677,7 @@ xfs_readdir( ...@@ -677,7 +677,7 @@ xfs_readdir(
trace_xfs_readdir(dp); trace_xfs_readdir(dp);
if (XFS_FORCED_SHUTDOWN(dp->i_mount)) if (XFS_FORCED_SHUTDOWN(dp->i_mount))
return XFS_ERROR(EIO); return -EIO;
ASSERT(S_ISDIR(dp->i_d.di_mode)); ASSERT(S_ISDIR(dp->i_d.di_mode));
XFS_STATS_INC(xs_dir_getdents); XFS_STATS_INC(xs_dir_getdents);
......
...@@ -124,7 +124,7 @@ xfs_trim_extents( ...@@ -124,7 +124,7 @@ xfs_trim_extents(
} }
trace_xfs_discard_extent(mp, agno, fbno, flen); trace_xfs_discard_extent(mp, agno, fbno, flen);
error = -blkdev_issue_discard(bdev, dbno, dlen, GFP_NOFS, 0); error = blkdev_issue_discard(bdev, dbno, dlen, GFP_NOFS, 0);
if (error) if (error)
goto out_del_cursor; goto out_del_cursor;
*blocks_trimmed += flen; *blocks_trimmed += flen;
...@@ -166,11 +166,11 @@ xfs_ioc_trim( ...@@ -166,11 +166,11 @@ xfs_ioc_trim(
int error, last_error = 0; int error, last_error = 0;
if (!capable(CAP_SYS_ADMIN)) if (!capable(CAP_SYS_ADMIN))
return -XFS_ERROR(EPERM); return -EPERM;
if (!blk_queue_discard(q)) if (!blk_queue_discard(q))
return -XFS_ERROR(EOPNOTSUPP); return -EOPNOTSUPP;
if (copy_from_user(&range, urange, sizeof(range))) if (copy_from_user(&range, urange, sizeof(range)))
return -XFS_ERROR(EFAULT); return -EFAULT;
/* /*
* Truncating down the len isn't actually quite correct, but using * Truncating down the len isn't actually quite correct, but using
...@@ -182,7 +182,7 @@ xfs_ioc_trim( ...@@ -182,7 +182,7 @@ xfs_ioc_trim(
if (range.start >= XFS_FSB_TO_B(mp, mp->m_sb.sb_dblocks) || if (range.start >= XFS_FSB_TO_B(mp, mp->m_sb.sb_dblocks) ||
range.minlen > XFS_FSB_TO_B(mp, XFS_ALLOC_AG_MAX_USABLE(mp)) || range.minlen > XFS_FSB_TO_B(mp, XFS_ALLOC_AG_MAX_USABLE(mp)) ||
range.len < mp->m_sb.sb_blocksize) range.len < mp->m_sb.sb_blocksize)
return -XFS_ERROR(EINVAL); return -EINVAL;
start = BTOBB(range.start); start = BTOBB(range.start);
end = start + BTOBBT(range.len) - 1; end = start + BTOBBT(range.len) - 1;
...@@ -195,7 +195,7 @@ xfs_ioc_trim( ...@@ -195,7 +195,7 @@ xfs_ioc_trim(
end_agno = xfs_daddr_to_agno(mp, end); end_agno = xfs_daddr_to_agno(mp, end);
for (agno = start_agno; agno <= end_agno; agno++) { for (agno = start_agno; agno <= end_agno; agno++) {
error = -xfs_trim_extents(mp, agno, start, end, minlen, error = xfs_trim_extents(mp, agno, start, end, minlen,
&blocks_trimmed); &blocks_trimmed);
if (error) if (error)
last_error = error; last_error = error;
...@@ -206,7 +206,7 @@ xfs_ioc_trim( ...@@ -206,7 +206,7 @@ xfs_ioc_trim(
range.len = XFS_FSB_TO_B(mp, blocks_trimmed); range.len = XFS_FSB_TO_B(mp, blocks_trimmed);
if (copy_to_user(urange, &range, sizeof(range))) if (copy_to_user(urange, &range, sizeof(range)))
return -XFS_ERROR(EFAULT); return -EFAULT;
return 0; return 0;
} }
...@@ -222,11 +222,11 @@ xfs_discard_extents( ...@@ -222,11 +222,11 @@ xfs_discard_extents(
trace_xfs_discard_extent(mp, busyp->agno, busyp->bno, trace_xfs_discard_extent(mp, busyp->agno, busyp->bno,
busyp->length); busyp->length);
error = -blkdev_issue_discard(mp->m_ddev_targp->bt_bdev, error = blkdev_issue_discard(mp->m_ddev_targp->bt_bdev,
XFS_AGB_TO_DADDR(mp, busyp->agno, busyp->bno), XFS_AGB_TO_DADDR(mp, busyp->agno, busyp->bno),
XFS_FSB_TO_BB(mp, busyp->length), XFS_FSB_TO_BB(mp, busyp->length),
GFP_NOFS, 0); GFP_NOFS, 0);
if (error && error != EOPNOTSUPP) { if (error && error != -EOPNOTSUPP) {
xfs_info(mp, xfs_info(mp,
"discard failed for extent [0x%llu,%u], error %d", "discard failed for extent [0x%llu,%u], error %d",
(unsigned long long)busyp->bno, (unsigned long long)busyp->bno,
......
...@@ -327,7 +327,7 @@ xfs_qm_dqalloc( ...@@ -327,7 +327,7 @@ xfs_qm_dqalloc(
*/ */
if (!xfs_this_quota_on(dqp->q_mount, dqp->dq_flags)) { if (!xfs_this_quota_on(dqp->q_mount, dqp->dq_flags)) {
xfs_iunlock(quotip, XFS_ILOCK_EXCL); xfs_iunlock(quotip, XFS_ILOCK_EXCL);
return (ESRCH); return -ESRCH;
} }
xfs_trans_ijoin(tp, quotip, XFS_ILOCK_EXCL); xfs_trans_ijoin(tp, quotip, XFS_ILOCK_EXCL);
...@@ -354,7 +354,7 @@ xfs_qm_dqalloc( ...@@ -354,7 +354,7 @@ xfs_qm_dqalloc(
mp->m_quotainfo->qi_dqchunklen, mp->m_quotainfo->qi_dqchunklen,
0); 0);
if (!bp) { if (!bp) {
error = ENOMEM; error = -ENOMEM;
goto error1; goto error1;
} }
bp->b_ops = &xfs_dquot_buf_ops; bp->b_ops = &xfs_dquot_buf_ops;
...@@ -400,7 +400,7 @@ xfs_qm_dqalloc( ...@@ -400,7 +400,7 @@ xfs_qm_dqalloc(
error0: error0:
xfs_iunlock(quotip, XFS_ILOCK_EXCL); xfs_iunlock(quotip, XFS_ILOCK_EXCL);
return (error); return error;
} }
STATIC int STATIC int
...@@ -426,7 +426,7 @@ xfs_qm_dqrepair( ...@@ -426,7 +426,7 @@ xfs_qm_dqrepair(
if (error) { if (error) {
ASSERT(*bpp == NULL); ASSERT(*bpp == NULL);
return XFS_ERROR(error); return error;
} }
(*bpp)->b_ops = &xfs_dquot_buf_ops; (*bpp)->b_ops = &xfs_dquot_buf_ops;
...@@ -442,7 +442,7 @@ xfs_qm_dqrepair( ...@@ -442,7 +442,7 @@ xfs_qm_dqrepair(
if (error) { if (error) {
/* repair failed, we're screwed */ /* repair failed, we're screwed */
xfs_trans_brelse(tp, *bpp); xfs_trans_brelse(tp, *bpp);
return XFS_ERROR(EIO); return -EIO;
} }
} }
...@@ -480,7 +480,7 @@ xfs_qm_dqtobp( ...@@ -480,7 +480,7 @@ xfs_qm_dqtobp(
* didn't have the quota inode lock. * didn't have the quota inode lock.
*/ */
xfs_iunlock(quotip, lock_mode); xfs_iunlock(quotip, lock_mode);
return ESRCH; return -ESRCH;
} }
/* /*
...@@ -508,7 +508,7 @@ xfs_qm_dqtobp( ...@@ -508,7 +508,7 @@ xfs_qm_dqtobp(
* We don't allocate unless we're asked to * We don't allocate unless we're asked to
*/ */
if (!(flags & XFS_QMOPT_DQALLOC)) if (!(flags & XFS_QMOPT_DQALLOC))
return ENOENT; return -ENOENT;
ASSERT(tp); ASSERT(tp);
error = xfs_qm_dqalloc(tpp, mp, dqp, quotip, error = xfs_qm_dqalloc(tpp, mp, dqp, quotip,
...@@ -530,7 +530,7 @@ xfs_qm_dqtobp( ...@@ -530,7 +530,7 @@ xfs_qm_dqtobp(
mp->m_quotainfo->qi_dqchunklen, mp->m_quotainfo->qi_dqchunklen,
0, &bp, &xfs_dquot_buf_ops); 0, &bp, &xfs_dquot_buf_ops);
if (error == EFSCORRUPTED && (flags & XFS_QMOPT_DQREPAIR)) { if (error == -EFSCORRUPTED && (flags & XFS_QMOPT_DQREPAIR)) {
xfs_dqid_t firstid = (xfs_dqid_t)map.br_startoff * xfs_dqid_t firstid = (xfs_dqid_t)map.br_startoff *
mp->m_quotainfo->qi_dqperchunk; mp->m_quotainfo->qi_dqperchunk;
ASSERT(bp == NULL); ASSERT(bp == NULL);
...@@ -539,7 +539,7 @@ xfs_qm_dqtobp( ...@@ -539,7 +539,7 @@ xfs_qm_dqtobp(
if (error) { if (error) {
ASSERT(bp == NULL); ASSERT(bp == NULL);
return XFS_ERROR(error); return error;
} }
} }
...@@ -547,7 +547,7 @@ xfs_qm_dqtobp( ...@@ -547,7 +547,7 @@ xfs_qm_dqtobp(
*O_bpp = bp; *O_bpp = bp;
*O_ddpp = bp->b_addr + dqp->q_bufoffset; *O_ddpp = bp->b_addr + dqp->q_bufoffset;
return (0); return 0;
} }
...@@ -715,7 +715,7 @@ xfs_qm_dqget( ...@@ -715,7 +715,7 @@ xfs_qm_dqget(
if ((! XFS_IS_UQUOTA_ON(mp) && type == XFS_DQ_USER) || if ((! XFS_IS_UQUOTA_ON(mp) && type == XFS_DQ_USER) ||
(! XFS_IS_PQUOTA_ON(mp) && type == XFS_DQ_PROJ) || (! XFS_IS_PQUOTA_ON(mp) && type == XFS_DQ_PROJ) ||
(! XFS_IS_GQUOTA_ON(mp) && type == XFS_DQ_GROUP)) { (! XFS_IS_GQUOTA_ON(mp) && type == XFS_DQ_GROUP)) {
return (ESRCH); return -ESRCH;
} }
#ifdef DEBUG #ifdef DEBUG
...@@ -723,7 +723,7 @@ xfs_qm_dqget( ...@@ -723,7 +723,7 @@ xfs_qm_dqget(
if ((xfs_dqerror_target == mp->m_ddev_targp) && if ((xfs_dqerror_target == mp->m_ddev_targp) &&
(xfs_dqreq_num++ % xfs_dqerror_mod) == 0) { (xfs_dqreq_num++ % xfs_dqerror_mod) == 0) {
xfs_debug(mp, "Returning error in dqget"); xfs_debug(mp, "Returning error in dqget");
return (EIO); return -EIO;
} }
} }
...@@ -796,14 +796,14 @@ xfs_qm_dqget( ...@@ -796,14 +796,14 @@ xfs_qm_dqget(
} else { } else {
/* inode stays locked on return */ /* inode stays locked on return */
xfs_qm_dqdestroy(dqp); xfs_qm_dqdestroy(dqp);
return XFS_ERROR(ESRCH); return -ESRCH;
} }
} }
mutex_lock(&qi->qi_tree_lock); mutex_lock(&qi->qi_tree_lock);
error = -radix_tree_insert(tree, id, dqp); error = radix_tree_insert(tree, id, dqp);
if (unlikely(error)) { if (unlikely(error)) {
WARN_ON(error != EEXIST); WARN_ON(error != -EEXIST);
/* /*
* Duplicate found. Just throw away the new dquot and start * Duplicate found. Just throw away the new dquot and start
...@@ -829,7 +829,7 @@ xfs_qm_dqget( ...@@ -829,7 +829,7 @@ xfs_qm_dqget(
ASSERT((ip == NULL) || xfs_isilocked(ip, XFS_ILOCK_EXCL)); ASSERT((ip == NULL) || xfs_isilocked(ip, XFS_ILOCK_EXCL));
trace_xfs_dqget_miss(dqp); trace_xfs_dqget_miss(dqp);
*O_dqpp = dqp; *O_dqpp = dqp;
return (0); return 0;
} }
/* /*
...@@ -966,7 +966,7 @@ xfs_qm_dqflush( ...@@ -966,7 +966,7 @@ xfs_qm_dqflush(
SHUTDOWN_CORRUPT_INCORE); SHUTDOWN_CORRUPT_INCORE);
else else
spin_unlock(&mp->m_ail->xa_lock); spin_unlock(&mp->m_ail->xa_lock);
error = XFS_ERROR(EIO); error = -EIO;
goto out_unlock; goto out_unlock;
} }
...@@ -992,7 +992,7 @@ xfs_qm_dqflush( ...@@ -992,7 +992,7 @@ xfs_qm_dqflush(
xfs_buf_relse(bp); xfs_buf_relse(bp);
xfs_dqfunlock(dqp); xfs_dqfunlock(dqp);
xfs_force_shutdown(mp, SHUTDOWN_CORRUPT_INCORE); xfs_force_shutdown(mp, SHUTDOWN_CORRUPT_INCORE);
return XFS_ERROR(EIO); return -EIO;
} }
/* This is the only portion of data that needs to persist */ /* This is the only portion of data that needs to persist */
...@@ -1045,7 +1045,7 @@ xfs_qm_dqflush( ...@@ -1045,7 +1045,7 @@ xfs_qm_dqflush(
out_unlock: out_unlock:
xfs_dqfunlock(dqp); xfs_dqfunlock(dqp);
return XFS_ERROR(EIO); return -EIO;
} }
/* /*
......
...@@ -27,29 +27,6 @@ ...@@ -27,29 +27,6 @@
#ifdef DEBUG #ifdef DEBUG
int xfs_etrap[XFS_ERROR_NTRAP] = {
0,
};
int
xfs_error_trap(int e)
{
int i;
if (!e)
return 0;
for (i = 0; i < XFS_ERROR_NTRAP; i++) {
if (xfs_etrap[i] == 0)
break;
if (e != xfs_etrap[i])
continue;
xfs_notice(NULL, "%s: error %d", __func__, e);
BUG();
break;
}
return e;
}
int xfs_etest[XFS_NUM_INJECT_ERROR]; int xfs_etest[XFS_NUM_INJECT_ERROR];
int64_t xfs_etest_fsid[XFS_NUM_INJECT_ERROR]; int64_t xfs_etest_fsid[XFS_NUM_INJECT_ERROR];
char * xfs_etest_fsname[XFS_NUM_INJECT_ERROR]; char * xfs_etest_fsname[XFS_NUM_INJECT_ERROR];
...@@ -190,7 +167,7 @@ xfs_verifier_error( ...@@ -190,7 +167,7 @@ xfs_verifier_error(
struct xfs_mount *mp = bp->b_target->bt_mount; struct xfs_mount *mp = bp->b_target->bt_mount;
xfs_alert(mp, "Metadata %s detected at %pF, block 0x%llx", xfs_alert(mp, "Metadata %s detected at %pF, block 0x%llx",
bp->b_error == EFSBADCRC ? "CRC error" : "corruption", bp->b_error == -EFSBADCRC ? "CRC error" : "corruption",
__return_address, bp->b_bn); __return_address, bp->b_bn);
xfs_alert(mp, "Unmount and run xfs_repair"); xfs_alert(mp, "Unmount and run xfs_repair");
......
...@@ -18,15 +18,6 @@ ...@@ -18,15 +18,6 @@
#ifndef __XFS_ERROR_H__ #ifndef __XFS_ERROR_H__
#define __XFS_ERROR_H__ #define __XFS_ERROR_H__
#ifdef DEBUG
#define XFS_ERROR_NTRAP 10
extern int xfs_etrap[XFS_ERROR_NTRAP];
extern int xfs_error_trap(int);
#define XFS_ERROR(e) xfs_error_trap(e)
#else
#define XFS_ERROR(e) (e)
#endif
struct xfs_mount; struct xfs_mount;
extern void xfs_error_report(const char *tag, int level, struct xfs_mount *mp, extern void xfs_error_report(const char *tag, int level, struct xfs_mount *mp,
...@@ -56,7 +47,7 @@ extern void xfs_verifier_error(struct xfs_buf *bp); ...@@ -56,7 +47,7 @@ extern void xfs_verifier_error(struct xfs_buf *bp);
if (unlikely(!fs_is_ok)) { \ if (unlikely(!fs_is_ok)) { \
XFS_ERROR_REPORT("XFS_WANT_CORRUPTED_GOTO", \ XFS_ERROR_REPORT("XFS_WANT_CORRUPTED_GOTO", \
XFS_ERRLEVEL_LOW, NULL); \ XFS_ERRLEVEL_LOW, NULL); \
error = XFS_ERROR(EFSCORRUPTED); \ error = -EFSCORRUPTED; \
goto l; \ goto l; \
} \ } \
} }
...@@ -68,7 +59,7 @@ extern void xfs_verifier_error(struct xfs_buf *bp); ...@@ -68,7 +59,7 @@ extern void xfs_verifier_error(struct xfs_buf *bp);
if (unlikely(!fs_is_ok)) { \ if (unlikely(!fs_is_ok)) { \
XFS_ERROR_REPORT("XFS_WANT_CORRUPTED_RETURN", \ XFS_ERROR_REPORT("XFS_WANT_CORRUPTED_RETURN", \
XFS_ERRLEVEL_LOW, NULL); \ XFS_ERRLEVEL_LOW, NULL); \
return XFS_ERROR(EFSCORRUPTED); \ return -EFSCORRUPTED; \
} \ } \
} }
......
...@@ -147,9 +147,9 @@ xfs_nfs_get_inode( ...@@ -147,9 +147,9 @@ xfs_nfs_get_inode(
* We don't use ESTALE directly down the chain to not * We don't use ESTALE directly down the chain to not
* confuse applications using bulkstat that expect EINVAL. * confuse applications using bulkstat that expect EINVAL.
*/ */
if (error == EINVAL || error == ENOENT) if (error == -EINVAL || error == -ENOENT)
error = ESTALE; error = -ESTALE;
return ERR_PTR(-error); return ERR_PTR(error);
} }
if (ip->i_d.di_gen != generation) { if (ip->i_d.di_gen != generation) {
...@@ -217,7 +217,7 @@ xfs_fs_get_parent( ...@@ -217,7 +217,7 @@ xfs_fs_get_parent(
error = xfs_lookup(XFS_I(child->d_inode), &xfs_name_dotdot, &cip, NULL); error = xfs_lookup(XFS_I(child->d_inode), &xfs_name_dotdot, &cip, NULL);
if (unlikely(error)) if (unlikely(error))
return ERR_PTR(-error); return ERR_PTR(error);
return d_obtain_alias(VFS_I(cip)); return d_obtain_alias(VFS_I(cip));
} }
...@@ -237,7 +237,7 @@ xfs_fs_nfs_commit_metadata( ...@@ -237,7 +237,7 @@ xfs_fs_nfs_commit_metadata(
if (!lsn) if (!lsn)
return 0; return 0;
return -_xfs_log_force_lsn(mp, lsn, XFS_LOG_SYNC, NULL); return _xfs_log_force_lsn(mp, lsn, XFS_LOG_SYNC, NULL);
} }
const struct export_operations xfs_export_operations = { const struct export_operations xfs_export_operations = {
......
...@@ -298,7 +298,7 @@ xfs_efi_copy_format(xfs_log_iovec_t *buf, xfs_efi_log_format_t *dst_efi_fmt) ...@@ -298,7 +298,7 @@ xfs_efi_copy_format(xfs_log_iovec_t *buf, xfs_efi_log_format_t *dst_efi_fmt)
} }
return 0; return 0;
} }
return EFSCORRUPTED; return -EFSCORRUPTED;
} }
/* /*
......
...@@ -155,7 +155,7 @@ xfs_dir_fsync( ...@@ -155,7 +155,7 @@ xfs_dir_fsync(
if (!lsn) if (!lsn)
return 0; return 0;
return -_xfs_log_force_lsn(mp, lsn, XFS_LOG_SYNC, NULL); return _xfs_log_force_lsn(mp, lsn, XFS_LOG_SYNC, NULL);
} }
STATIC int STATIC int
...@@ -179,7 +179,7 @@ xfs_file_fsync( ...@@ -179,7 +179,7 @@ xfs_file_fsync(
return error; return error;
if (XFS_FORCED_SHUTDOWN(mp)) if (XFS_FORCED_SHUTDOWN(mp))
return -XFS_ERROR(EIO); return -EIO;
xfs_iflags_clear(ip, XFS_ITRUNCATED); xfs_iflags_clear(ip, XFS_ITRUNCATED);
...@@ -225,7 +225,7 @@ xfs_file_fsync( ...@@ -225,7 +225,7 @@ xfs_file_fsync(
!log_flushed) !log_flushed)
xfs_blkdev_issue_flush(mp->m_ddev_targp); xfs_blkdev_issue_flush(mp->m_ddev_targp);
return -error; return error;
} }
STATIC ssize_t STATIC ssize_t
...@@ -258,7 +258,7 @@ xfs_file_read_iter( ...@@ -258,7 +258,7 @@ xfs_file_read_iter(
if ((pos | size) & target->bt_logical_sectormask) { if ((pos | size) & target->bt_logical_sectormask) {
if (pos == i_size_read(inode)) if (pos == i_size_read(inode))
return 0; return 0;
return -XFS_ERROR(EINVAL); return -EINVAL;
} }
} }
...@@ -524,7 +524,7 @@ xfs_file_aio_write_checks( ...@@ -524,7 +524,7 @@ xfs_file_aio_write_checks(
xfs_rw_ilock(ip, *iolock); xfs_rw_ilock(ip, *iolock);
goto restart; goto restart;
} }
error = -xfs_zero_eof(ip, *pos, i_size_read(inode)); error = xfs_zero_eof(ip, *pos, i_size_read(inode));
if (error) if (error)
return error; return error;
} }
...@@ -594,7 +594,7 @@ xfs_file_dio_aio_write( ...@@ -594,7 +594,7 @@ xfs_file_dio_aio_write(
/* DIO must be aligned to device logical sector size */ /* DIO must be aligned to device logical sector size */
if ((pos | count) & target->bt_logical_sectormask) if ((pos | count) & target->bt_logical_sectormask)
return -XFS_ERROR(EINVAL); return -EINVAL;
/* "unaligned" here means not aligned to a filesystem block */ /* "unaligned" here means not aligned to a filesystem block */
if ((pos & mp->m_blockmask) || ((pos + count) & mp->m_blockmask)) if ((pos & mp->m_blockmask) || ((pos + count) & mp->m_blockmask))
...@@ -772,7 +772,7 @@ xfs_file_fallocate( ...@@ -772,7 +772,7 @@ xfs_file_fallocate(
unsigned blksize_mask = (1 << inode->i_blkbits) - 1; unsigned blksize_mask = (1 << inode->i_blkbits) - 1;
if (offset & blksize_mask || len & blksize_mask) { if (offset & blksize_mask || len & blksize_mask) {
error = EINVAL; error = -EINVAL;
goto out_unlock; goto out_unlock;
} }
...@@ -781,7 +781,7 @@ xfs_file_fallocate( ...@@ -781,7 +781,7 @@ xfs_file_fallocate(
* in which case it is effectively a truncate operation * in which case it is effectively a truncate operation
*/ */
if (offset + len >= i_size_read(inode)) { if (offset + len >= i_size_read(inode)) {
error = EINVAL; error = -EINVAL;
goto out_unlock; goto out_unlock;
} }
...@@ -794,7 +794,7 @@ xfs_file_fallocate( ...@@ -794,7 +794,7 @@ xfs_file_fallocate(
if (!(mode & FALLOC_FL_KEEP_SIZE) && if (!(mode & FALLOC_FL_KEEP_SIZE) &&
offset + len > i_size_read(inode)) { offset + len > i_size_read(inode)) {
new_size = offset + len; new_size = offset + len;
error = -inode_newsize_ok(inode, new_size); error = inode_newsize_ok(inode, new_size);
if (error) if (error)
goto out_unlock; goto out_unlock;
} }
...@@ -844,7 +844,7 @@ xfs_file_fallocate( ...@@ -844,7 +844,7 @@ xfs_file_fallocate(
out_unlock: out_unlock:
xfs_iunlock(ip, XFS_IOLOCK_EXCL); xfs_iunlock(ip, XFS_IOLOCK_EXCL);
return -error; return error;
} }
...@@ -889,7 +889,7 @@ xfs_file_release( ...@@ -889,7 +889,7 @@ xfs_file_release(
struct inode *inode, struct inode *inode,
struct file *filp) struct file *filp)
{ {
return -xfs_release(XFS_I(inode)); return xfs_release(XFS_I(inode));
} }
STATIC int STATIC int
...@@ -918,7 +918,7 @@ xfs_file_readdir( ...@@ -918,7 +918,7 @@ xfs_file_readdir(
error = xfs_readdir(ip, ctx, bufsize); error = xfs_readdir(ip, ctx, bufsize);
if (error) if (error)
return -error; return error;
return 0; return 0;
} }
...@@ -1184,7 +1184,7 @@ xfs_seek_data( ...@@ -1184,7 +1184,7 @@ xfs_seek_data(
isize = i_size_read(inode); isize = i_size_read(inode);
if (start >= isize) { if (start >= isize) {
error = ENXIO; error = -ENXIO;
goto out_unlock; goto out_unlock;
} }
...@@ -1206,7 +1206,7 @@ xfs_seek_data( ...@@ -1206,7 +1206,7 @@ xfs_seek_data(
/* No extents at given offset, must be beyond EOF */ /* No extents at given offset, must be beyond EOF */
if (nmap == 0) { if (nmap == 0) {
error = ENXIO; error = -ENXIO;
goto out_unlock; goto out_unlock;
} }
...@@ -1237,7 +1237,7 @@ xfs_seek_data( ...@@ -1237,7 +1237,7 @@ xfs_seek_data(
* we are reading after EOF if nothing in map[1]. * we are reading after EOF if nothing in map[1].
*/ */
if (nmap == 1) { if (nmap == 1) {
error = ENXIO; error = -ENXIO;
goto out_unlock; goto out_unlock;
} }
...@@ -1250,7 +1250,7 @@ xfs_seek_data( ...@@ -1250,7 +1250,7 @@ xfs_seek_data(
fsbno = map[i - 1].br_startoff + map[i - 1].br_blockcount; fsbno = map[i - 1].br_startoff + map[i - 1].br_blockcount;
start = XFS_FSB_TO_B(mp, fsbno); start = XFS_FSB_TO_B(mp, fsbno);
if (start >= isize) { if (start >= isize) {
error = ENXIO; error = -ENXIO;
goto out_unlock; goto out_unlock;
} }
} }
...@@ -1262,7 +1262,7 @@ xfs_seek_data( ...@@ -1262,7 +1262,7 @@ xfs_seek_data(
xfs_iunlock(ip, lock); xfs_iunlock(ip, lock);
if (error) if (error)
return -error; return error;
return offset; return offset;
} }
...@@ -1282,13 +1282,13 @@ xfs_seek_hole( ...@@ -1282,13 +1282,13 @@ xfs_seek_hole(
int error; int error;
if (XFS_FORCED_SHUTDOWN(mp)) if (XFS_FORCED_SHUTDOWN(mp))
return -XFS_ERROR(EIO); return -EIO;
lock = xfs_ilock_data_map_shared(ip); lock = xfs_ilock_data_map_shared(ip);
isize = i_size_read(inode); isize = i_size_read(inode);
if (start >= isize) { if (start >= isize) {
error = ENXIO; error = -ENXIO;
goto out_unlock; goto out_unlock;
} }
...@@ -1307,7 +1307,7 @@ xfs_seek_hole( ...@@ -1307,7 +1307,7 @@ xfs_seek_hole(
/* No extents at given offset, must be beyond EOF */ /* No extents at given offset, must be beyond EOF */
if (nmap == 0) { if (nmap == 0) {
error = ENXIO; error = -ENXIO;
goto out_unlock; goto out_unlock;
} }
...@@ -1370,7 +1370,7 @@ xfs_seek_hole( ...@@ -1370,7 +1370,7 @@ xfs_seek_hole(
xfs_iunlock(ip, lock); xfs_iunlock(ip, lock);
if (error) if (error)
return -error; return error;
return offset; return offset;
} }
......
...@@ -258,7 +258,7 @@ xfs_filestream_pick_ag( ...@@ -258,7 +258,7 @@ xfs_filestream_pick_ag(
if (*agp == NULLAGNUMBER) if (*agp == NULLAGNUMBER)
return 0; return 0;
err = ENOMEM; err = -ENOMEM;
item = kmem_alloc(sizeof(*item), KM_MAYFAIL); item = kmem_alloc(sizeof(*item), KM_MAYFAIL);
if (!item) if (!item)
goto out_put_ag; goto out_put_ag;
...@@ -268,7 +268,7 @@ xfs_filestream_pick_ag( ...@@ -268,7 +268,7 @@ xfs_filestream_pick_ag(
err = xfs_mru_cache_insert(mp->m_filestream, ip->i_ino, &item->mru); err = xfs_mru_cache_insert(mp->m_filestream, ip->i_ino, &item->mru);
if (err) { if (err) {
if (err == EEXIST) if (err == -EEXIST)
err = 0; err = 0;
goto out_free_item; goto out_free_item;
} }
......
...@@ -168,7 +168,7 @@ xfs_growfs_data_private( ...@@ -168,7 +168,7 @@ xfs_growfs_data_private(
nb = in->newblocks; nb = in->newblocks;
pct = in->imaxpct; pct = in->imaxpct;
if (nb < mp->m_sb.sb_dblocks || pct < 0 || pct > 100) if (nb < mp->m_sb.sb_dblocks || pct < 0 || pct > 100)
return XFS_ERROR(EINVAL); return -EINVAL;
if ((error = xfs_sb_validate_fsb_count(&mp->m_sb, nb))) if ((error = xfs_sb_validate_fsb_count(&mp->m_sb, nb)))
return error; return error;
dpct = pct - mp->m_sb.sb_imax_pct; dpct = pct - mp->m_sb.sb_imax_pct;
...@@ -176,7 +176,7 @@ xfs_growfs_data_private( ...@@ -176,7 +176,7 @@ xfs_growfs_data_private(
XFS_FSB_TO_BB(mp, nb) - XFS_FSS_TO_BB(mp, 1), XFS_FSB_TO_BB(mp, nb) - XFS_FSS_TO_BB(mp, 1),
XFS_FSS_TO_BB(mp, 1), 0, NULL); XFS_FSS_TO_BB(mp, 1), 0, NULL);
if (!bp) if (!bp)
return EIO; return -EIO;
if (bp->b_error) { if (bp->b_error) {
error = bp->b_error; error = bp->b_error;
xfs_buf_relse(bp); xfs_buf_relse(bp);
...@@ -191,7 +191,7 @@ xfs_growfs_data_private( ...@@ -191,7 +191,7 @@ xfs_growfs_data_private(
nagcount--; nagcount--;
nb = (xfs_rfsblock_t)nagcount * mp->m_sb.sb_agblocks; nb = (xfs_rfsblock_t)nagcount * mp->m_sb.sb_agblocks;
if (nb < mp->m_sb.sb_dblocks) if (nb < mp->m_sb.sb_dblocks)
return XFS_ERROR(EINVAL); return -EINVAL;
} }
new = nb - mp->m_sb.sb_dblocks; new = nb - mp->m_sb.sb_dblocks;
oagcount = mp->m_sb.sb_agcount; oagcount = mp->m_sb.sb_agcount;
...@@ -229,7 +229,7 @@ xfs_growfs_data_private( ...@@ -229,7 +229,7 @@ xfs_growfs_data_private(
XFS_FSS_TO_BB(mp, 1), 0, XFS_FSS_TO_BB(mp, 1), 0,
&xfs_agf_buf_ops); &xfs_agf_buf_ops);
if (!bp) { if (!bp) {
error = ENOMEM; error = -ENOMEM;
goto error0; goto error0;
} }
...@@ -270,7 +270,7 @@ xfs_growfs_data_private( ...@@ -270,7 +270,7 @@ xfs_growfs_data_private(
XFS_FSS_TO_BB(mp, 1), 0, XFS_FSS_TO_BB(mp, 1), 0,
&xfs_agfl_buf_ops); &xfs_agfl_buf_ops);
if (!bp) { if (!bp) {
error = ENOMEM; error = -ENOMEM;
goto error0; goto error0;
} }
...@@ -298,7 +298,7 @@ xfs_growfs_data_private( ...@@ -298,7 +298,7 @@ xfs_growfs_data_private(
XFS_FSS_TO_BB(mp, 1), 0, XFS_FSS_TO_BB(mp, 1), 0,
&xfs_agi_buf_ops); &xfs_agi_buf_ops);
if (!bp) { if (!bp) {
error = ENOMEM; error = -ENOMEM;
goto error0; goto error0;
} }
...@@ -336,7 +336,7 @@ xfs_growfs_data_private( ...@@ -336,7 +336,7 @@ xfs_growfs_data_private(
&xfs_allocbt_buf_ops); &xfs_allocbt_buf_ops);
if (!bp) { if (!bp) {
error = ENOMEM; error = -ENOMEM;
goto error0; goto error0;
} }
...@@ -365,7 +365,7 @@ xfs_growfs_data_private( ...@@ -365,7 +365,7 @@ xfs_growfs_data_private(
BTOBB(mp->m_sb.sb_blocksize), 0, BTOBB(mp->m_sb.sb_blocksize), 0,
&xfs_allocbt_buf_ops); &xfs_allocbt_buf_ops);
if (!bp) { if (!bp) {
error = ENOMEM; error = -ENOMEM;
goto error0; goto error0;
} }
...@@ -395,7 +395,7 @@ xfs_growfs_data_private( ...@@ -395,7 +395,7 @@ xfs_growfs_data_private(
BTOBB(mp->m_sb.sb_blocksize), 0, BTOBB(mp->m_sb.sb_blocksize), 0,
&xfs_inobt_buf_ops); &xfs_inobt_buf_ops);
if (!bp) { if (!bp) {
error = ENOMEM; error = -ENOMEM;
goto error0; goto error0;
} }
...@@ -420,7 +420,7 @@ xfs_growfs_data_private( ...@@ -420,7 +420,7 @@ xfs_growfs_data_private(
BTOBB(mp->m_sb.sb_blocksize), 0, BTOBB(mp->m_sb.sb_blocksize), 0,
&xfs_inobt_buf_ops); &xfs_inobt_buf_ops);
if (!bp) { if (!bp) {
error = ENOMEM; error = -ENOMEM;
goto error0; goto error0;
} }
...@@ -531,7 +531,7 @@ xfs_growfs_data_private( ...@@ -531,7 +531,7 @@ xfs_growfs_data_private(
bp->b_ops = &xfs_sb_buf_ops; bp->b_ops = &xfs_sb_buf_ops;
xfs_buf_zero(bp, 0, BBTOB(bp->b_length)); xfs_buf_zero(bp, 0, BBTOB(bp->b_length));
} else } else
error = ENOMEM; error = -ENOMEM;
} }
/* /*
...@@ -576,17 +576,17 @@ xfs_growfs_log_private( ...@@ -576,17 +576,17 @@ xfs_growfs_log_private(
nb = in->newblocks; nb = in->newblocks;
if (nb < XFS_MIN_LOG_BLOCKS || nb < XFS_B_TO_FSB(mp, XFS_MIN_LOG_BYTES)) if (nb < XFS_MIN_LOG_BLOCKS || nb < XFS_B_TO_FSB(mp, XFS_MIN_LOG_BYTES))
return XFS_ERROR(EINVAL); return -EINVAL;
if (nb == mp->m_sb.sb_logblocks && if (nb == mp->m_sb.sb_logblocks &&
in->isint == (mp->m_sb.sb_logstart != 0)) in->isint == (mp->m_sb.sb_logstart != 0))
return XFS_ERROR(EINVAL); return -EINVAL;
/* /*
* Moving the log is hard, need new interfaces to sync * Moving the log is hard, need new interfaces to sync
* the log first, hold off all activity while moving it. * the log first, hold off all activity while moving it.
* Can have shorter or longer log in the same space, * Can have shorter or longer log in the same space,
* or transform internal to external log or vice versa. * or transform internal to external log or vice versa.
*/ */
return XFS_ERROR(ENOSYS); return -ENOSYS;
} }
/* /*
...@@ -604,9 +604,9 @@ xfs_growfs_data( ...@@ -604,9 +604,9 @@ xfs_growfs_data(
int error; int error;
if (!capable(CAP_SYS_ADMIN)) if (!capable(CAP_SYS_ADMIN))
return XFS_ERROR(EPERM); return -EPERM;
if (!mutex_trylock(&mp->m_growlock)) if (!mutex_trylock(&mp->m_growlock))
return XFS_ERROR(EWOULDBLOCK); return -EWOULDBLOCK;
error = xfs_growfs_data_private(mp, in); error = xfs_growfs_data_private(mp, in);
mutex_unlock(&mp->m_growlock); mutex_unlock(&mp->m_growlock);
return error; return error;
...@@ -620,9 +620,9 @@ xfs_growfs_log( ...@@ -620,9 +620,9 @@ xfs_growfs_log(
int error; int error;
if (!capable(CAP_SYS_ADMIN)) if (!capable(CAP_SYS_ADMIN))
return XFS_ERROR(EPERM); return -EPERM;
if (!mutex_trylock(&mp->m_growlock)) if (!mutex_trylock(&mp->m_growlock))
return XFS_ERROR(EWOULDBLOCK); return -EWOULDBLOCK;
error = xfs_growfs_log_private(mp, in); error = xfs_growfs_log_private(mp, in);
mutex_unlock(&mp->m_growlock); mutex_unlock(&mp->m_growlock);
return error; return error;
...@@ -674,7 +674,7 @@ xfs_reserve_blocks( ...@@ -674,7 +674,7 @@ xfs_reserve_blocks(
/* If inval is null, report current values and return */ /* If inval is null, report current values and return */
if (inval == (__uint64_t *)NULL) { if (inval == (__uint64_t *)NULL) {
if (!outval) if (!outval)
return EINVAL; return -EINVAL;
outval->resblks = mp->m_resblks; outval->resblks = mp->m_resblks;
outval->resblks_avail = mp->m_resblks_avail; outval->resblks_avail = mp->m_resblks_avail;
return 0; return 0;
...@@ -757,7 +757,7 @@ xfs_reserve_blocks( ...@@ -757,7 +757,7 @@ xfs_reserve_blocks(
int error; int error;
error = xfs_icsb_modify_counters(mp, XFS_SBS_FDBLOCKS, error = xfs_icsb_modify_counters(mp, XFS_SBS_FDBLOCKS,
fdblks_delta, 0); fdblks_delta, 0);
if (error == ENOSPC) if (error == -ENOSPC)
goto retry; goto retry;
} }
return 0; return 0;
...@@ -818,7 +818,7 @@ xfs_fs_goingdown( ...@@ -818,7 +818,7 @@ xfs_fs_goingdown(
SHUTDOWN_FORCE_UMOUNT | SHUTDOWN_LOG_IO_ERROR); SHUTDOWN_FORCE_UMOUNT | SHUTDOWN_LOG_IO_ERROR);
break; break;
default: default:
return XFS_ERROR(EINVAL); return -EINVAL;
} }
return 0; return 0;
......
...@@ -158,7 +158,7 @@ xfs_iget_cache_hit( ...@@ -158,7 +158,7 @@ xfs_iget_cache_hit(
if (ip->i_ino != ino) { if (ip->i_ino != ino) {
trace_xfs_iget_skip(ip); trace_xfs_iget_skip(ip);
XFS_STATS_INC(xs_ig_frecycle); XFS_STATS_INC(xs_ig_frecycle);
error = EAGAIN; error = -EAGAIN;
goto out_error; goto out_error;
} }
...@@ -176,7 +176,7 @@ xfs_iget_cache_hit( ...@@ -176,7 +176,7 @@ xfs_iget_cache_hit(
if (ip->i_flags & (XFS_INEW|XFS_IRECLAIM)) { if (ip->i_flags & (XFS_INEW|XFS_IRECLAIM)) {
trace_xfs_iget_skip(ip); trace_xfs_iget_skip(ip);
XFS_STATS_INC(xs_ig_frecycle); XFS_STATS_INC(xs_ig_frecycle);
error = EAGAIN; error = -EAGAIN;
goto out_error; goto out_error;
} }
...@@ -184,7 +184,7 @@ xfs_iget_cache_hit( ...@@ -184,7 +184,7 @@ xfs_iget_cache_hit(
* If lookup is racing with unlink return an error immediately. * If lookup is racing with unlink return an error immediately.
*/ */
if (ip->i_d.di_mode == 0 && !(flags & XFS_IGET_CREATE)) { if (ip->i_d.di_mode == 0 && !(flags & XFS_IGET_CREATE)) {
error = ENOENT; error = -ENOENT;
goto out_error; goto out_error;
} }
...@@ -206,7 +206,7 @@ xfs_iget_cache_hit( ...@@ -206,7 +206,7 @@ xfs_iget_cache_hit(
spin_unlock(&ip->i_flags_lock); spin_unlock(&ip->i_flags_lock);
rcu_read_unlock(); rcu_read_unlock();
error = -inode_init_always(mp->m_super, inode); error = inode_init_always(mp->m_super, inode);
if (error) { if (error) {
/* /*
* Re-initializing the inode failed, and we are in deep * Re-initializing the inode failed, and we are in deep
...@@ -243,7 +243,7 @@ xfs_iget_cache_hit( ...@@ -243,7 +243,7 @@ xfs_iget_cache_hit(
/* If the VFS inode is being torn down, pause and try again. */ /* If the VFS inode is being torn down, pause and try again. */
if (!igrab(inode)) { if (!igrab(inode)) {
trace_xfs_iget_skip(ip); trace_xfs_iget_skip(ip);
error = EAGAIN; error = -EAGAIN;
goto out_error; goto out_error;
} }
...@@ -285,7 +285,7 @@ xfs_iget_cache_miss( ...@@ -285,7 +285,7 @@ xfs_iget_cache_miss(
ip = xfs_inode_alloc(mp, ino); ip = xfs_inode_alloc(mp, ino);
if (!ip) if (!ip)
return ENOMEM; return -ENOMEM;
error = xfs_iread(mp, tp, ip, flags); error = xfs_iread(mp, tp, ip, flags);
if (error) if (error)
...@@ -294,7 +294,7 @@ xfs_iget_cache_miss( ...@@ -294,7 +294,7 @@ xfs_iget_cache_miss(
trace_xfs_iget_miss(ip); trace_xfs_iget_miss(ip);
if ((ip->i_d.di_mode == 0) && !(flags & XFS_IGET_CREATE)) { if ((ip->i_d.di_mode == 0) && !(flags & XFS_IGET_CREATE)) {
error = ENOENT; error = -ENOENT;
goto out_destroy; goto out_destroy;
} }
...@@ -305,7 +305,7 @@ xfs_iget_cache_miss( ...@@ -305,7 +305,7 @@ xfs_iget_cache_miss(
* recurse into the file system. * recurse into the file system.
*/ */
if (radix_tree_preload(GFP_NOFS)) { if (radix_tree_preload(GFP_NOFS)) {
error = EAGAIN; error = -EAGAIN;
goto out_destroy; goto out_destroy;
} }
...@@ -341,7 +341,7 @@ xfs_iget_cache_miss( ...@@ -341,7 +341,7 @@ xfs_iget_cache_miss(
if (unlikely(error)) { if (unlikely(error)) {
WARN_ON(error != -EEXIST); WARN_ON(error != -EEXIST);
XFS_STATS_INC(xs_ig_dup); XFS_STATS_INC(xs_ig_dup);
error = EAGAIN; error = -EAGAIN;
goto out_preload_end; goto out_preload_end;
} }
spin_unlock(&pag->pag_ici_lock); spin_unlock(&pag->pag_ici_lock);
...@@ -408,7 +408,7 @@ xfs_iget( ...@@ -408,7 +408,7 @@ xfs_iget(
/* reject inode numbers outside existing AGs */ /* reject inode numbers outside existing AGs */
if (!ino || XFS_INO_TO_AGNO(mp, ino) >= mp->m_sb.sb_agcount) if (!ino || XFS_INO_TO_AGNO(mp, ino) >= mp->m_sb.sb_agcount)
return EINVAL; return -EINVAL;
/* get the perag structure and ensure that it's inode capable */ /* get the perag structure and ensure that it's inode capable */
pag = xfs_perag_get(mp, XFS_INO_TO_AGNO(mp, ino)); pag = xfs_perag_get(mp, XFS_INO_TO_AGNO(mp, ino));
...@@ -445,7 +445,7 @@ xfs_iget( ...@@ -445,7 +445,7 @@ xfs_iget(
return 0; return 0;
out_error_or_again: out_error_or_again:
if (error == EAGAIN) { if (error == -EAGAIN) {
delay(1); delay(1);
goto again; goto again;
} }
...@@ -489,18 +489,18 @@ xfs_inode_ag_walk_grab( ...@@ -489,18 +489,18 @@ xfs_inode_ag_walk_grab(
/* nothing to sync during shutdown */ /* nothing to sync during shutdown */
if (XFS_FORCED_SHUTDOWN(ip->i_mount)) if (XFS_FORCED_SHUTDOWN(ip->i_mount))
return EFSCORRUPTED; return -EFSCORRUPTED;
/* If we can't grab the inode, it must on it's way to reclaim. */ /* If we can't grab the inode, it must on it's way to reclaim. */
if (!igrab(inode)) if (!igrab(inode))
return ENOENT; return -ENOENT;
/* inode is valid */ /* inode is valid */
return 0; return 0;
out_unlock_noent: out_unlock_noent:
spin_unlock(&ip->i_flags_lock); spin_unlock(&ip->i_flags_lock);
return ENOENT; return -ENOENT;
} }
STATIC int STATIC int
...@@ -583,16 +583,16 @@ xfs_inode_ag_walk( ...@@ -583,16 +583,16 @@ xfs_inode_ag_walk(
continue; continue;
error = execute(batch[i], flags, args); error = execute(batch[i], flags, args);
IRELE(batch[i]); IRELE(batch[i]);
if (error == EAGAIN) { if (error == -EAGAIN) {
skipped++; skipped++;
continue; continue;
} }
if (error && last_error != EFSCORRUPTED) if (error && last_error != -EFSCORRUPTED)
last_error = error; last_error = error;
} }
/* bail out if the filesystem is corrupted. */ /* bail out if the filesystem is corrupted. */
if (error == EFSCORRUPTED) if (error == -EFSCORRUPTED)
break; break;
cond_resched(); cond_resched();
...@@ -652,11 +652,11 @@ xfs_inode_ag_iterator( ...@@ -652,11 +652,11 @@ xfs_inode_ag_iterator(
xfs_perag_put(pag); xfs_perag_put(pag);
if (error) { if (error) {
last_error = error; last_error = error;
if (error == EFSCORRUPTED) if (error == -EFSCORRUPTED)
break; break;
} }
} }
return XFS_ERROR(last_error); return last_error;
} }
int int
...@@ -680,11 +680,11 @@ xfs_inode_ag_iterator_tag( ...@@ -680,11 +680,11 @@ xfs_inode_ag_iterator_tag(
xfs_perag_put(pag); xfs_perag_put(pag);
if (error) { if (error) {
last_error = error; last_error = error;
if (error == EFSCORRUPTED) if (error == -EFSCORRUPTED)
break; break;
} }
} }
return XFS_ERROR(last_error); return last_error;
} }
/* /*
...@@ -944,7 +944,7 @@ xfs_reclaim_inode( ...@@ -944,7 +944,7 @@ xfs_reclaim_inode(
* see the stale flag set on the inode. * see the stale flag set on the inode.
*/ */
error = xfs_iflush(ip, &bp); error = xfs_iflush(ip, &bp);
if (error == EAGAIN) { if (error == -EAGAIN) {
xfs_iunlock(ip, XFS_ILOCK_EXCL); xfs_iunlock(ip, XFS_ILOCK_EXCL);
/* backoff longer than in xfs_ifree_cluster */ /* backoff longer than in xfs_ifree_cluster */
delay(2); delay(2);
...@@ -997,7 +997,7 @@ xfs_reclaim_inode( ...@@ -997,7 +997,7 @@ xfs_reclaim_inode(
xfs_iflags_clear(ip, XFS_IRECLAIM); xfs_iflags_clear(ip, XFS_IRECLAIM);
xfs_iunlock(ip, XFS_ILOCK_EXCL); xfs_iunlock(ip, XFS_ILOCK_EXCL);
/* /*
* We could return EAGAIN here to make reclaim rescan the inode tree in * We could return -EAGAIN here to make reclaim rescan the inode tree in
* a short while. However, this just burns CPU time scanning the tree * a short while. However, this just burns CPU time scanning the tree
* waiting for IO to complete and the reclaim work never goes back to * waiting for IO to complete and the reclaim work never goes back to
* the idle state. Instead, return 0 to let the next scheduled * the idle state. Instead, return 0 to let the next scheduled
...@@ -1100,7 +1100,7 @@ xfs_reclaim_inodes_ag( ...@@ -1100,7 +1100,7 @@ xfs_reclaim_inodes_ag(
if (!batch[i]) if (!batch[i])
continue; continue;
error = xfs_reclaim_inode(batch[i], pag, flags); error = xfs_reclaim_inode(batch[i], pag, flags);
if (error && last_error != EFSCORRUPTED) if (error && last_error != -EFSCORRUPTED)
last_error = error; last_error = error;
} }
...@@ -1129,7 +1129,7 @@ xfs_reclaim_inodes_ag( ...@@ -1129,7 +1129,7 @@ xfs_reclaim_inodes_ag(
trylock = 0; trylock = 0;
goto restart; goto restart;
} }
return XFS_ERROR(last_error); return last_error;
} }
int int
...@@ -1240,7 +1240,7 @@ xfs_inode_free_eofblocks( ...@@ -1240,7 +1240,7 @@ xfs_inode_free_eofblocks(
ret = xfs_free_eofblocks(ip->i_mount, ip, true); ret = xfs_free_eofblocks(ip->i_mount, ip, true);
/* don't revisit the inode if we're not waiting */ /* don't revisit the inode if we're not waiting */
if (ret == EAGAIN && !(flags & SYNC_WAIT)) if (ret == -EAGAIN && !(flags & SYNC_WAIT))
ret = 0; ret = 0;
return ret; return ret;
......
...@@ -72,14 +72,14 @@ xfs_fs_eofblocks_from_user( ...@@ -72,14 +72,14 @@ xfs_fs_eofblocks_from_user(
struct xfs_eofblocks *dst) struct xfs_eofblocks *dst)
{ {
if (src->eof_version != XFS_EOFBLOCKS_VERSION) if (src->eof_version != XFS_EOFBLOCKS_VERSION)
return EINVAL; return -EINVAL;
if (src->eof_flags & ~XFS_EOF_FLAGS_VALID) if (src->eof_flags & ~XFS_EOF_FLAGS_VALID)
return EINVAL; return -EINVAL;
if (memchr_inv(&src->pad32, 0, sizeof(src->pad32)) || if (memchr_inv(&src->pad32, 0, sizeof(src->pad32)) ||
memchr_inv(src->pad64, 0, sizeof(src->pad64))) memchr_inv(src->pad64, 0, sizeof(src->pad64)))
return EINVAL; return -EINVAL;
dst->eof_flags = src->eof_flags; dst->eof_flags = src->eof_flags;
dst->eof_prid = src->eof_prid; dst->eof_prid = src->eof_prid;
...@@ -89,14 +89,14 @@ xfs_fs_eofblocks_from_user( ...@@ -89,14 +89,14 @@ xfs_fs_eofblocks_from_user(
if (src->eof_flags & XFS_EOF_FLAGS_UID) { if (src->eof_flags & XFS_EOF_FLAGS_UID) {
dst->eof_uid = make_kuid(current_user_ns(), src->eof_uid); dst->eof_uid = make_kuid(current_user_ns(), src->eof_uid);
if (!uid_valid(dst->eof_uid)) if (!uid_valid(dst->eof_uid))
return EINVAL; return -EINVAL;
} }
dst->eof_gid = INVALID_GID; dst->eof_gid = INVALID_GID;
if (src->eof_flags & XFS_EOF_FLAGS_GID) { if (src->eof_flags & XFS_EOF_FLAGS_GID) {
dst->eof_gid = make_kgid(current_user_ns(), src->eof_gid); dst->eof_gid = make_kgid(current_user_ns(), src->eof_gid);
if (!gid_valid(dst->eof_gid)) if (!gid_valid(dst->eof_gid))
return EINVAL; return -EINVAL;
} }
return 0; return 0;
} }
......
...@@ -583,7 +583,7 @@ xfs_lookup( ...@@ -583,7 +583,7 @@ xfs_lookup(
trace_xfs_lookup(dp, name); trace_xfs_lookup(dp, name);
if (XFS_FORCED_SHUTDOWN(dp->i_mount)) if (XFS_FORCED_SHUTDOWN(dp->i_mount))
return XFS_ERROR(EIO); return -EIO;
lock_mode = xfs_ilock_data_map_shared(dp); lock_mode = xfs_ilock_data_map_shared(dp);
error = xfs_dir_lookup(NULL, dp, name, &inum, ci_name); error = xfs_dir_lookup(NULL, dp, name, &inum, ci_name);
...@@ -893,7 +893,7 @@ xfs_dir_ialloc( ...@@ -893,7 +893,7 @@ xfs_dir_ialloc(
} }
if (!ialloc_context && !ip) { if (!ialloc_context && !ip) {
*ipp = NULL; *ipp = NULL;
return XFS_ERROR(ENOSPC); return -ENOSPC;
} }
/* /*
...@@ -1088,7 +1088,7 @@ xfs_create( ...@@ -1088,7 +1088,7 @@ xfs_create(
trace_xfs_create(dp, name); trace_xfs_create(dp, name);
if (XFS_FORCED_SHUTDOWN(mp)) if (XFS_FORCED_SHUTDOWN(mp))
return XFS_ERROR(EIO); return -EIO;
prid = xfs_get_initial_prid(dp); prid = xfs_get_initial_prid(dp);
...@@ -1125,12 +1125,12 @@ xfs_create( ...@@ -1125,12 +1125,12 @@ xfs_create(
*/ */
tres.tr_logflags = XFS_TRANS_PERM_LOG_RES; tres.tr_logflags = XFS_TRANS_PERM_LOG_RES;
error = xfs_trans_reserve(tp, &tres, resblks, 0); error = xfs_trans_reserve(tp, &tres, resblks, 0);
if (error == ENOSPC) { if (error == -ENOSPC) {
/* flush outstanding delalloc blocks and retry */ /* flush outstanding delalloc blocks and retry */
xfs_flush_inodes(mp); xfs_flush_inodes(mp);
error = xfs_trans_reserve(tp, &tres, resblks, 0); error = xfs_trans_reserve(tp, &tres, resblks, 0);
} }
if (error == ENOSPC) { if (error == -ENOSPC) {
/* No space at all so try a "no-allocation" reservation */ /* No space at all so try a "no-allocation" reservation */
resblks = 0; resblks = 0;
error = xfs_trans_reserve(tp, &tres, 0, 0); error = xfs_trans_reserve(tp, &tres, 0, 0);
...@@ -1165,7 +1165,7 @@ xfs_create( ...@@ -1165,7 +1165,7 @@ xfs_create(
error = xfs_dir_ialloc(&tp, dp, mode, is_dir ? 2 : 1, rdev, error = xfs_dir_ialloc(&tp, dp, mode, is_dir ? 2 : 1, rdev,
prid, resblks > 0, &ip, &committed); prid, resblks > 0, &ip, &committed);
if (error) { if (error) {
if (error == ENOSPC) if (error == -ENOSPC)
goto out_trans_cancel; goto out_trans_cancel;
goto out_trans_abort; goto out_trans_abort;
} }
...@@ -1184,7 +1184,7 @@ xfs_create( ...@@ -1184,7 +1184,7 @@ xfs_create(
&first_block, &free_list, resblks ? &first_block, &free_list, resblks ?
resblks - XFS_IALLOC_SPACE_RES(mp) : 0); resblks - XFS_IALLOC_SPACE_RES(mp) : 0);
if (error) { if (error) {
ASSERT(error != ENOSPC); ASSERT(error != -ENOSPC);
goto out_trans_abort; goto out_trans_abort;
} }
xfs_trans_ichgtime(tp, dp, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG); xfs_trans_ichgtime(tp, dp, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG);
...@@ -1274,7 +1274,7 @@ xfs_create_tmpfile( ...@@ -1274,7 +1274,7 @@ xfs_create_tmpfile(
uint resblks; uint resblks;
if (XFS_FORCED_SHUTDOWN(mp)) if (XFS_FORCED_SHUTDOWN(mp))
return XFS_ERROR(EIO); return -EIO;
prid = xfs_get_initial_prid(dp); prid = xfs_get_initial_prid(dp);
...@@ -1293,7 +1293,7 @@ xfs_create_tmpfile( ...@@ -1293,7 +1293,7 @@ xfs_create_tmpfile(
tres = &M_RES(mp)->tr_create_tmpfile; tres = &M_RES(mp)->tr_create_tmpfile;
error = xfs_trans_reserve(tp, tres, resblks, 0); error = xfs_trans_reserve(tp, tres, resblks, 0);
if (error == ENOSPC) { if (error == -ENOSPC) {
/* No space at all so try a "no-allocation" reservation */ /* No space at all so try a "no-allocation" reservation */
resblks = 0; resblks = 0;
error = xfs_trans_reserve(tp, tres, 0, 0); error = xfs_trans_reserve(tp, tres, 0, 0);
...@@ -1311,7 +1311,7 @@ xfs_create_tmpfile( ...@@ -1311,7 +1311,7 @@ xfs_create_tmpfile(
error = xfs_dir_ialloc(&tp, dp, mode, 1, 0, error = xfs_dir_ialloc(&tp, dp, mode, 1, 0,
prid, resblks > 0, &ip, NULL); prid, resblks > 0, &ip, NULL);
if (error) { if (error) {
if (error == ENOSPC) if (error == -ENOSPC)
goto out_trans_cancel; goto out_trans_cancel;
goto out_trans_abort; goto out_trans_abort;
} }
...@@ -1382,7 +1382,7 @@ xfs_link( ...@@ -1382,7 +1382,7 @@ xfs_link(
ASSERT(!S_ISDIR(sip->i_d.di_mode)); ASSERT(!S_ISDIR(sip->i_d.di_mode));
if (XFS_FORCED_SHUTDOWN(mp)) if (XFS_FORCED_SHUTDOWN(mp))
return XFS_ERROR(EIO); return -EIO;
error = xfs_qm_dqattach(sip, 0); error = xfs_qm_dqattach(sip, 0);
if (error) if (error)
...@@ -1396,7 +1396,7 @@ xfs_link( ...@@ -1396,7 +1396,7 @@ xfs_link(
cancel_flags = XFS_TRANS_RELEASE_LOG_RES; cancel_flags = XFS_TRANS_RELEASE_LOG_RES;
resblks = XFS_LINK_SPACE_RES(mp, target_name->len); resblks = XFS_LINK_SPACE_RES(mp, target_name->len);
error = xfs_trans_reserve(tp, &M_RES(mp)->tr_link, resblks, 0); error = xfs_trans_reserve(tp, &M_RES(mp)->tr_link, resblks, 0);
if (error == ENOSPC) { if (error == -ENOSPC) {
resblks = 0; resblks = 0;
error = xfs_trans_reserve(tp, &M_RES(mp)->tr_link, 0, 0); error = xfs_trans_reserve(tp, &M_RES(mp)->tr_link, 0, 0);
} }
...@@ -1417,7 +1417,7 @@ xfs_link( ...@@ -1417,7 +1417,7 @@ xfs_link(
*/ */
if (unlikely((tdp->i_d.di_flags & XFS_DIFLAG_PROJINHERIT) && if (unlikely((tdp->i_d.di_flags & XFS_DIFLAG_PROJINHERIT) &&
(xfs_get_projid(tdp) != xfs_get_projid(sip)))) { (xfs_get_projid(tdp) != xfs_get_projid(sip)))) {
error = XFS_ERROR(EXDEV); error = -EXDEV;
goto error_return; goto error_return;
} }
...@@ -1636,7 +1636,7 @@ xfs_release( ...@@ -1636,7 +1636,7 @@ xfs_release(
if (truncated) { if (truncated) {
xfs_iflags_clear(ip, XFS_IDIRTY_RELEASE); xfs_iflags_clear(ip, XFS_IDIRTY_RELEASE);
if (VN_DIRTY(VFS_I(ip)) && ip->i_delayed_blks > 0) { if (VN_DIRTY(VFS_I(ip)) && ip->i_delayed_blks > 0) {
error = -filemap_flush(VFS_I(ip)->i_mapping); error = filemap_flush(VFS_I(ip)->i_mapping);
if (error) if (error)
return error; return error;
} }
...@@ -1673,7 +1673,7 @@ xfs_release( ...@@ -1673,7 +1673,7 @@ xfs_release(
return 0; return 0;
error = xfs_free_eofblocks(mp, ip, true); error = xfs_free_eofblocks(mp, ip, true);
if (error && error != EAGAIN) if (error && error != -EAGAIN)
return error; return error;
/* delalloc blocks after truncation means it really is dirty */ /* delalloc blocks after truncation means it really is dirty */
...@@ -1772,7 +1772,7 @@ xfs_inactive_ifree( ...@@ -1772,7 +1772,7 @@ xfs_inactive_ifree(
error = xfs_trans_reserve(tp, &M_RES(mp)->tr_ifree, error = xfs_trans_reserve(tp, &M_RES(mp)->tr_ifree,
XFS_IFREE_SPACE_RES(mp), 0); XFS_IFREE_SPACE_RES(mp), 0);
if (error) { if (error) {
if (error == ENOSPC) { if (error == -ENOSPC) {
xfs_warn_ratelimited(mp, xfs_warn_ratelimited(mp,
"Failed to remove inode(s) from unlinked list. " "Failed to remove inode(s) from unlinked list. "
"Please free space, unmount and run xfs_repair."); "Please free space, unmount and run xfs_repair.");
...@@ -2219,7 +2219,7 @@ xfs_ifree_cluster( ...@@ -2219,7 +2219,7 @@ xfs_ifree_cluster(
XBF_UNMAPPED); XBF_UNMAPPED);
if (!bp) if (!bp)
return ENOMEM; return -ENOMEM;
/* /*
* This buffer may not have been correctly initialised as we * This buffer may not have been correctly initialised as we
...@@ -2491,7 +2491,7 @@ xfs_remove( ...@@ -2491,7 +2491,7 @@ xfs_remove(
trace_xfs_remove(dp, name); trace_xfs_remove(dp, name);
if (XFS_FORCED_SHUTDOWN(mp)) if (XFS_FORCED_SHUTDOWN(mp))
return XFS_ERROR(EIO); return -EIO;
error = xfs_qm_dqattach(dp, 0); error = xfs_qm_dqattach(dp, 0);
if (error) if (error)
...@@ -2521,12 +2521,12 @@ xfs_remove( ...@@ -2521,12 +2521,12 @@ xfs_remove(
*/ */
resblks = XFS_REMOVE_SPACE_RES(mp); resblks = XFS_REMOVE_SPACE_RES(mp);
error = xfs_trans_reserve(tp, &M_RES(mp)->tr_remove, resblks, 0); error = xfs_trans_reserve(tp, &M_RES(mp)->tr_remove, resblks, 0);
if (error == ENOSPC) { if (error == -ENOSPC) {
resblks = 0; resblks = 0;
error = xfs_trans_reserve(tp, &M_RES(mp)->tr_remove, 0, 0); error = xfs_trans_reserve(tp, &M_RES(mp)->tr_remove, 0, 0);
} }
if (error) { if (error) {
ASSERT(error != ENOSPC); ASSERT(error != -ENOSPC);
cancel_flags = 0; cancel_flags = 0;
goto out_trans_cancel; goto out_trans_cancel;
} }
...@@ -2543,11 +2543,11 @@ xfs_remove( ...@@ -2543,11 +2543,11 @@ xfs_remove(
if (is_dir) { if (is_dir) {
ASSERT(ip->i_d.di_nlink >= 2); ASSERT(ip->i_d.di_nlink >= 2);
if (ip->i_d.di_nlink != 2) { if (ip->i_d.di_nlink != 2) {
error = XFS_ERROR(ENOTEMPTY); error = -ENOTEMPTY;
goto out_trans_cancel; goto out_trans_cancel;
} }
if (!xfs_dir_isempty(ip)) { if (!xfs_dir_isempty(ip)) {
error = XFS_ERROR(ENOTEMPTY); error = -ENOTEMPTY;
goto out_trans_cancel; goto out_trans_cancel;
} }
...@@ -2582,7 +2582,7 @@ xfs_remove( ...@@ -2582,7 +2582,7 @@ xfs_remove(
error = xfs_dir_removename(tp, dp, name, ip->i_ino, error = xfs_dir_removename(tp, dp, name, ip->i_ino,
&first_block, &free_list, resblks); &first_block, &free_list, resblks);
if (error) { if (error) {
ASSERT(error != ENOENT); ASSERT(error != -ENOENT);
goto out_bmap_cancel; goto out_bmap_cancel;
} }
...@@ -2702,7 +2702,7 @@ xfs_rename( ...@@ -2702,7 +2702,7 @@ xfs_rename(
cancel_flags = XFS_TRANS_RELEASE_LOG_RES; cancel_flags = XFS_TRANS_RELEASE_LOG_RES;
spaceres = XFS_RENAME_SPACE_RES(mp, target_name->len); spaceres = XFS_RENAME_SPACE_RES(mp, target_name->len);
error = xfs_trans_reserve(tp, &M_RES(mp)->tr_rename, spaceres, 0); error = xfs_trans_reserve(tp, &M_RES(mp)->tr_rename, spaceres, 0);
if (error == ENOSPC) { if (error == -ENOSPC) {
spaceres = 0; spaceres = 0;
error = xfs_trans_reserve(tp, &M_RES(mp)->tr_rename, 0, 0); error = xfs_trans_reserve(tp, &M_RES(mp)->tr_rename, 0, 0);
} }
...@@ -2747,7 +2747,7 @@ xfs_rename( ...@@ -2747,7 +2747,7 @@ xfs_rename(
*/ */
if (unlikely((target_dp->i_d.di_flags & XFS_DIFLAG_PROJINHERIT) && if (unlikely((target_dp->i_d.di_flags & XFS_DIFLAG_PROJINHERIT) &&
(xfs_get_projid(target_dp) != xfs_get_projid(src_ip)))) { (xfs_get_projid(target_dp) != xfs_get_projid(src_ip)))) {
error = XFS_ERROR(EXDEV); error = -EXDEV;
goto error_return; goto error_return;
} }
...@@ -2770,7 +2770,7 @@ xfs_rename( ...@@ -2770,7 +2770,7 @@ xfs_rename(
error = xfs_dir_createname(tp, target_dp, target_name, error = xfs_dir_createname(tp, target_dp, target_name,
src_ip->i_ino, &first_block, src_ip->i_ino, &first_block,
&free_list, spaceres); &free_list, spaceres);
if (error == ENOSPC) if (error == -ENOSPC)
goto error_return; goto error_return;
if (error) if (error)
goto abort_return; goto abort_return;
...@@ -2795,7 +2795,7 @@ xfs_rename( ...@@ -2795,7 +2795,7 @@ xfs_rename(
*/ */
if (!(xfs_dir_isempty(target_ip)) || if (!(xfs_dir_isempty(target_ip)) ||
(target_ip->i_d.di_nlink > 2)) { (target_ip->i_d.di_nlink > 2)) {
error = XFS_ERROR(EEXIST); error = -EEXIST;
goto error_return; goto error_return;
} }
} }
...@@ -2847,7 +2847,7 @@ xfs_rename( ...@@ -2847,7 +2847,7 @@ xfs_rename(
error = xfs_dir_replace(tp, src_ip, &xfs_name_dotdot, error = xfs_dir_replace(tp, src_ip, &xfs_name_dotdot,
target_dp->i_ino, target_dp->i_ino,
&first_block, &free_list, spaceres); &first_block, &free_list, spaceres);
ASSERT(error != EEXIST); ASSERT(error != -EEXIST);
if (error) if (error)
goto abort_return; goto abort_return;
} }
...@@ -3055,7 +3055,7 @@ xfs_iflush_cluster( ...@@ -3055,7 +3055,7 @@ xfs_iflush_cluster(
if (bp->b_iodone) { if (bp->b_iodone) {
XFS_BUF_UNDONE(bp); XFS_BUF_UNDONE(bp);
xfs_buf_stale(bp); xfs_buf_stale(bp);
xfs_buf_ioerror(bp, EIO); xfs_buf_ioerror(bp, -EIO);
xfs_buf_ioend(bp, 0); xfs_buf_ioend(bp, 0);
} else { } else {
xfs_buf_stale(bp); xfs_buf_stale(bp);
...@@ -3069,7 +3069,7 @@ xfs_iflush_cluster( ...@@ -3069,7 +3069,7 @@ xfs_iflush_cluster(
xfs_iflush_abort(iq, false); xfs_iflush_abort(iq, false);
kmem_free(ilist); kmem_free(ilist);
xfs_perag_put(pag); xfs_perag_put(pag);
return XFS_ERROR(EFSCORRUPTED); return -EFSCORRUPTED;
} }
/* /*
...@@ -3124,7 +3124,7 @@ xfs_iflush( ...@@ -3124,7 +3124,7 @@ xfs_iflush(
* as we wait for an empty AIL as part of the unmount process. * as we wait for an empty AIL as part of the unmount process.
*/ */
if (XFS_FORCED_SHUTDOWN(mp)) { if (XFS_FORCED_SHUTDOWN(mp)) {
error = XFS_ERROR(EIO); error = -EIO;
goto abort_out; goto abort_out;
} }
...@@ -3167,7 +3167,7 @@ xfs_iflush( ...@@ -3167,7 +3167,7 @@ xfs_iflush(
xfs_buf_relse(bp); xfs_buf_relse(bp);
xfs_force_shutdown(mp, SHUTDOWN_CORRUPT_INCORE); xfs_force_shutdown(mp, SHUTDOWN_CORRUPT_INCORE);
cluster_corrupt_out: cluster_corrupt_out:
error = XFS_ERROR(EFSCORRUPTED); error = -EFSCORRUPTED;
abort_out: abort_out:
/* /*
* Unlocks the flush lock * Unlocks the flush lock
...@@ -3331,5 +3331,5 @@ xfs_iflush_int( ...@@ -3331,5 +3331,5 @@ xfs_iflush_int(
return 0; return 0;
corrupt_out: corrupt_out:
return XFS_ERROR(EFSCORRUPTED); return -EFSCORRUPTED;
} }
...@@ -788,5 +788,5 @@ xfs_inode_item_format_convert( ...@@ -788,5 +788,5 @@ xfs_inode_item_format_convert(
in_f->ilf_boffset = in_f64->ilf_boffset; in_f->ilf_boffset = in_f64->ilf_boffset;
return 0; return 0;
} }
return EFSCORRUPTED; return -EFSCORRUPTED;
} }
此差异已折叠。
...@@ -56,7 +56,7 @@ xfs_compat_flock64_copyin( ...@@ -56,7 +56,7 @@ xfs_compat_flock64_copyin(
get_user(bf->l_sysid, &arg32->l_sysid) || get_user(bf->l_sysid, &arg32->l_sysid) ||
get_user(bf->l_pid, &arg32->l_pid) || get_user(bf->l_pid, &arg32->l_pid) ||
copy_from_user(bf->l_pad, &arg32->l_pad, 4*sizeof(u32))) copy_from_user(bf->l_pad, &arg32->l_pad, 4*sizeof(u32)))
return -XFS_ERROR(EFAULT); return -EFAULT;
return 0; return 0;
} }
...@@ -70,10 +70,10 @@ xfs_compat_ioc_fsgeometry_v1( ...@@ -70,10 +70,10 @@ xfs_compat_ioc_fsgeometry_v1(
error = xfs_fs_geometry(mp, &fsgeo, 3); error = xfs_fs_geometry(mp, &fsgeo, 3);
if (error) if (error)
return -error; return error;
/* The 32-bit variant simply has some padding at the end */ /* The 32-bit variant simply has some padding at the end */
if (copy_to_user(arg32, &fsgeo, sizeof(struct compat_xfs_fsop_geom_v1))) if (copy_to_user(arg32, &fsgeo, sizeof(struct compat_xfs_fsop_geom_v1)))
return -XFS_ERROR(EFAULT); return -EFAULT;
return 0; return 0;
} }
...@@ -84,7 +84,7 @@ xfs_compat_growfs_data_copyin( ...@@ -84,7 +84,7 @@ xfs_compat_growfs_data_copyin(
{ {
if (get_user(in->newblocks, &arg32->newblocks) || if (get_user(in->newblocks, &arg32->newblocks) ||
get_user(in->imaxpct, &arg32->imaxpct)) get_user(in->imaxpct, &arg32->imaxpct))
return -XFS_ERROR(EFAULT); return -EFAULT;
return 0; return 0;
} }
...@@ -95,7 +95,7 @@ xfs_compat_growfs_rt_copyin( ...@@ -95,7 +95,7 @@ xfs_compat_growfs_rt_copyin(
{ {
if (get_user(in->newblocks, &arg32->newblocks) || if (get_user(in->newblocks, &arg32->newblocks) ||
get_user(in->extsize, &arg32->extsize)) get_user(in->extsize, &arg32->extsize))
return -XFS_ERROR(EFAULT); return -EFAULT;
return 0; return 0;
} }
...@@ -113,7 +113,7 @@ xfs_inumbers_fmt_compat( ...@@ -113,7 +113,7 @@ xfs_inumbers_fmt_compat(
if (put_user(buffer[i].xi_startino, &p32[i].xi_startino) || if (put_user(buffer[i].xi_startino, &p32[i].xi_startino) ||
put_user(buffer[i].xi_alloccount, &p32[i].xi_alloccount) || put_user(buffer[i].xi_alloccount, &p32[i].xi_alloccount) ||
put_user(buffer[i].xi_allocmask, &p32[i].xi_allocmask)) put_user(buffer[i].xi_allocmask, &p32[i].xi_allocmask))
return -XFS_ERROR(EFAULT); return -EFAULT;
} }
*written = count * sizeof(*p32); *written = count * sizeof(*p32);
return 0; return 0;
...@@ -132,7 +132,7 @@ xfs_ioctl32_bstime_copyin( ...@@ -132,7 +132,7 @@ xfs_ioctl32_bstime_copyin(
if (get_user(sec32, &bstime32->tv_sec) || if (get_user(sec32, &bstime32->tv_sec) ||
get_user(bstime->tv_nsec, &bstime32->tv_nsec)) get_user(bstime->tv_nsec, &bstime32->tv_nsec))
return -XFS_ERROR(EFAULT); return -EFAULT;
bstime->tv_sec = sec32; bstime->tv_sec = sec32;
return 0; return 0;
} }
...@@ -164,7 +164,7 @@ xfs_ioctl32_bstat_copyin( ...@@ -164,7 +164,7 @@ xfs_ioctl32_bstat_copyin(
get_user(bstat->bs_dmevmask, &bstat32->bs_dmevmask) || get_user(bstat->bs_dmevmask, &bstat32->bs_dmevmask) ||
get_user(bstat->bs_dmstate, &bstat32->bs_dmstate) || get_user(bstat->bs_dmstate, &bstat32->bs_dmstate) ||
get_user(bstat->bs_aextents, &bstat32->bs_aextents)) get_user(bstat->bs_aextents, &bstat32->bs_aextents))
return -XFS_ERROR(EFAULT); return -EFAULT;
return 0; return 0;
} }
...@@ -180,7 +180,7 @@ xfs_bstime_store_compat( ...@@ -180,7 +180,7 @@ xfs_bstime_store_compat(
sec32 = p->tv_sec; sec32 = p->tv_sec;
if (put_user(sec32, &p32->tv_sec) || if (put_user(sec32, &p32->tv_sec) ||
put_user(p->tv_nsec, &p32->tv_nsec)) put_user(p->tv_nsec, &p32->tv_nsec))
return -XFS_ERROR(EFAULT); return -EFAULT;
return 0; return 0;
} }
...@@ -195,7 +195,7 @@ xfs_bulkstat_one_fmt_compat( ...@@ -195,7 +195,7 @@ xfs_bulkstat_one_fmt_compat(
compat_xfs_bstat_t __user *p32 = ubuffer; compat_xfs_bstat_t __user *p32 = ubuffer;
if (ubsize < sizeof(*p32)) if (ubsize < sizeof(*p32))
return XFS_ERROR(ENOMEM); return -ENOMEM;
if (put_user(buffer->bs_ino, &p32->bs_ino) || if (put_user(buffer->bs_ino, &p32->bs_ino) ||
put_user(buffer->bs_mode, &p32->bs_mode) || put_user(buffer->bs_mode, &p32->bs_mode) ||
...@@ -218,7 +218,7 @@ xfs_bulkstat_one_fmt_compat( ...@@ -218,7 +218,7 @@ xfs_bulkstat_one_fmt_compat(
put_user(buffer->bs_dmevmask, &p32->bs_dmevmask) || put_user(buffer->bs_dmevmask, &p32->bs_dmevmask) ||
put_user(buffer->bs_dmstate, &p32->bs_dmstate) || put_user(buffer->bs_dmstate, &p32->bs_dmstate) ||
put_user(buffer->bs_aextents, &p32->bs_aextents)) put_user(buffer->bs_aextents, &p32->bs_aextents))
return XFS_ERROR(EFAULT); return -EFAULT;
if (ubused) if (ubused)
*ubused = sizeof(*p32); *ubused = sizeof(*p32);
return 0; return 0;
...@@ -256,30 +256,30 @@ xfs_compat_ioc_bulkstat( ...@@ -256,30 +256,30 @@ xfs_compat_ioc_bulkstat(
/* should be called again (unused here, but used in dmapi) */ /* should be called again (unused here, but used in dmapi) */
if (!capable(CAP_SYS_ADMIN)) if (!capable(CAP_SYS_ADMIN))
return -XFS_ERROR(EPERM); return -EPERM;
if (XFS_FORCED_SHUTDOWN(mp)) if (XFS_FORCED_SHUTDOWN(mp))
return -XFS_ERROR(EIO); return -EIO;
if (get_user(addr, &p32->lastip)) if (get_user(addr, &p32->lastip))
return -XFS_ERROR(EFAULT); return -EFAULT;
bulkreq.lastip = compat_ptr(addr); bulkreq.lastip = compat_ptr(addr);
if (get_user(bulkreq.icount, &p32->icount) || if (get_user(bulkreq.icount, &p32->icount) ||
get_user(addr, &p32->ubuffer)) get_user(addr, &p32->ubuffer))
return -XFS_ERROR(EFAULT); return -EFAULT;
bulkreq.ubuffer = compat_ptr(addr); bulkreq.ubuffer = compat_ptr(addr);
if (get_user(addr, &p32->ocount)) if (get_user(addr, &p32->ocount))
return -XFS_ERROR(EFAULT); return -EFAULT;
bulkreq.ocount = compat_ptr(addr); bulkreq.ocount = compat_ptr(addr);
if (copy_from_user(&inlast, bulkreq.lastip, sizeof(__s64))) if (copy_from_user(&inlast, bulkreq.lastip, sizeof(__s64)))
return -XFS_ERROR(EFAULT); return -EFAULT;
if ((count = bulkreq.icount) <= 0) if ((count = bulkreq.icount) <= 0)
return -XFS_ERROR(EINVAL); return -EINVAL;
if (bulkreq.ubuffer == NULL) if (bulkreq.ubuffer == NULL)
return -XFS_ERROR(EINVAL); return -EINVAL;
if (cmd == XFS_IOC_FSINUMBERS_32) { if (cmd == XFS_IOC_FSINUMBERS_32) {
error = xfs_inumbers(mp, &inlast, &count, error = xfs_inumbers(mp, &inlast, &count,
...@@ -294,17 +294,17 @@ xfs_compat_ioc_bulkstat( ...@@ -294,17 +294,17 @@ xfs_compat_ioc_bulkstat(
xfs_bulkstat_one_compat, sizeof(compat_xfs_bstat_t), xfs_bulkstat_one_compat, sizeof(compat_xfs_bstat_t),
bulkreq.ubuffer, &done); bulkreq.ubuffer, &done);
} else } else
error = XFS_ERROR(EINVAL); error = -EINVAL;
if (error) if (error)
return -error; return error;
if (bulkreq.ocount != NULL) { if (bulkreq.ocount != NULL) {
if (copy_to_user(bulkreq.lastip, &inlast, if (copy_to_user(bulkreq.lastip, &inlast,
sizeof(xfs_ino_t))) sizeof(xfs_ino_t)))
return -XFS_ERROR(EFAULT); return -EFAULT;
if (copy_to_user(bulkreq.ocount, &count, sizeof(count))) if (copy_to_user(bulkreq.ocount, &count, sizeof(count)))
return -XFS_ERROR(EFAULT); return -EFAULT;
} }
return 0; return 0;
...@@ -318,7 +318,7 @@ xfs_compat_handlereq_copyin( ...@@ -318,7 +318,7 @@ xfs_compat_handlereq_copyin(
compat_xfs_fsop_handlereq_t hreq32; compat_xfs_fsop_handlereq_t hreq32;
if (copy_from_user(&hreq32, arg32, sizeof(compat_xfs_fsop_handlereq_t))) if (copy_from_user(&hreq32, arg32, sizeof(compat_xfs_fsop_handlereq_t)))
return -XFS_ERROR(EFAULT); return -EFAULT;
hreq->fd = hreq32.fd; hreq->fd = hreq32.fd;
hreq->path = compat_ptr(hreq32.path); hreq->path = compat_ptr(hreq32.path);
...@@ -352,19 +352,19 @@ xfs_compat_attrlist_by_handle( ...@@ -352,19 +352,19 @@ xfs_compat_attrlist_by_handle(
char *kbuf; char *kbuf;
if (!capable(CAP_SYS_ADMIN)) if (!capable(CAP_SYS_ADMIN))
return -XFS_ERROR(EPERM); return -EPERM;
if (copy_from_user(&al_hreq, arg, if (copy_from_user(&al_hreq, arg,
sizeof(compat_xfs_fsop_attrlist_handlereq_t))) sizeof(compat_xfs_fsop_attrlist_handlereq_t)))
return -XFS_ERROR(EFAULT); return -EFAULT;
if (al_hreq.buflen < sizeof(struct attrlist) || if (al_hreq.buflen < sizeof(struct attrlist) ||
al_hreq.buflen > XATTR_LIST_MAX) al_hreq.buflen > XATTR_LIST_MAX)
return -XFS_ERROR(EINVAL); return -EINVAL;
/* /*
* Reject flags, only allow namespaces. * Reject flags, only allow namespaces.
*/ */
if (al_hreq.flags & ~(ATTR_ROOT | ATTR_SECURE)) if (al_hreq.flags & ~(ATTR_ROOT | ATTR_SECURE))
return -XFS_ERROR(EINVAL); return -EINVAL;
dentry = xfs_compat_handlereq_to_dentry(parfilp, &al_hreq.hreq); dentry = xfs_compat_handlereq_to_dentry(parfilp, &al_hreq.hreq);
if (IS_ERR(dentry)) if (IS_ERR(dentry))
...@@ -376,7 +376,7 @@ xfs_compat_attrlist_by_handle( ...@@ -376,7 +376,7 @@ xfs_compat_attrlist_by_handle(
goto out_dput; goto out_dput;
cursor = (attrlist_cursor_kern_t *)&al_hreq.pos; cursor = (attrlist_cursor_kern_t *)&al_hreq.pos;
error = -xfs_attr_list(XFS_I(dentry->d_inode), kbuf, al_hreq.buflen, error = xfs_attr_list(XFS_I(dentry->d_inode), kbuf, al_hreq.buflen,
al_hreq.flags, cursor); al_hreq.flags, cursor);
if (error) if (error)
goto out_kfree; goto out_kfree;
...@@ -404,10 +404,10 @@ xfs_compat_attrmulti_by_handle( ...@@ -404,10 +404,10 @@ xfs_compat_attrmulti_by_handle(
unsigned char *attr_name; unsigned char *attr_name;
if (!capable(CAP_SYS_ADMIN)) if (!capable(CAP_SYS_ADMIN))
return -XFS_ERROR(EPERM); return -EPERM;
if (copy_from_user(&am_hreq, arg, if (copy_from_user(&am_hreq, arg,
sizeof(compat_xfs_fsop_attrmulti_handlereq_t))) sizeof(compat_xfs_fsop_attrmulti_handlereq_t)))
return -XFS_ERROR(EFAULT); return -EFAULT;
/* overflow check */ /* overflow check */
if (am_hreq.opcount >= INT_MAX / sizeof(compat_xfs_attr_multiop_t)) if (am_hreq.opcount >= INT_MAX / sizeof(compat_xfs_attr_multiop_t))
...@@ -417,7 +417,7 @@ xfs_compat_attrmulti_by_handle( ...@@ -417,7 +417,7 @@ xfs_compat_attrmulti_by_handle(
if (IS_ERR(dentry)) if (IS_ERR(dentry))
return PTR_ERR(dentry); return PTR_ERR(dentry);
error = E2BIG; error = -E2BIG;
size = am_hreq.opcount * sizeof(compat_xfs_attr_multiop_t); size = am_hreq.opcount * sizeof(compat_xfs_attr_multiop_t);
if (!size || size > 16 * PAGE_SIZE) if (!size || size > 16 * PAGE_SIZE)
goto out_dput; goto out_dput;
...@@ -428,7 +428,7 @@ xfs_compat_attrmulti_by_handle( ...@@ -428,7 +428,7 @@ xfs_compat_attrmulti_by_handle(
goto out_dput; goto out_dput;
} }
error = ENOMEM; error = -ENOMEM;
attr_name = kmalloc(MAXNAMELEN, GFP_KERNEL); attr_name = kmalloc(MAXNAMELEN, GFP_KERNEL);
if (!attr_name) if (!attr_name)
goto out_kfree_ops; goto out_kfree_ops;
...@@ -439,7 +439,7 @@ xfs_compat_attrmulti_by_handle( ...@@ -439,7 +439,7 @@ xfs_compat_attrmulti_by_handle(
compat_ptr(ops[i].am_attrname), compat_ptr(ops[i].am_attrname),
MAXNAMELEN); MAXNAMELEN);
if (ops[i].am_error == 0 || ops[i].am_error == MAXNAMELEN) if (ops[i].am_error == 0 || ops[i].am_error == MAXNAMELEN)
error = ERANGE; error = -ERANGE;
if (ops[i].am_error < 0) if (ops[i].am_error < 0)
break; break;
...@@ -470,19 +470,19 @@ xfs_compat_attrmulti_by_handle( ...@@ -470,19 +470,19 @@ xfs_compat_attrmulti_by_handle(
mnt_drop_write_file(parfilp); mnt_drop_write_file(parfilp);
break; break;
default: default:
ops[i].am_error = EINVAL; ops[i].am_error = -EINVAL;
} }
} }
if (copy_to_user(compat_ptr(am_hreq.ops), ops, size)) if (copy_to_user(compat_ptr(am_hreq.ops), ops, size))
error = XFS_ERROR(EFAULT); error = -EFAULT;
kfree(attr_name); kfree(attr_name);
out_kfree_ops: out_kfree_ops:
kfree(ops); kfree(ops);
out_dput: out_dput:
dput(dentry); dput(dentry);
return -error; return error;
} }
STATIC int STATIC int
...@@ -496,26 +496,26 @@ xfs_compat_fssetdm_by_handle( ...@@ -496,26 +496,26 @@ xfs_compat_fssetdm_by_handle(
struct dentry *dentry; struct dentry *dentry;
if (!capable(CAP_MKNOD)) if (!capable(CAP_MKNOD))
return -XFS_ERROR(EPERM); return -EPERM;
if (copy_from_user(&dmhreq, arg, if (copy_from_user(&dmhreq, arg,
sizeof(compat_xfs_fsop_setdm_handlereq_t))) sizeof(compat_xfs_fsop_setdm_handlereq_t)))
return -XFS_ERROR(EFAULT); return -EFAULT;
dentry = xfs_compat_handlereq_to_dentry(parfilp, &dmhreq.hreq); dentry = xfs_compat_handlereq_to_dentry(parfilp, &dmhreq.hreq);
if (IS_ERR(dentry)) if (IS_ERR(dentry))
return PTR_ERR(dentry); return PTR_ERR(dentry);
if (IS_IMMUTABLE(dentry->d_inode) || IS_APPEND(dentry->d_inode)) { if (IS_IMMUTABLE(dentry->d_inode) || IS_APPEND(dentry->d_inode)) {
error = -XFS_ERROR(EPERM); error = -EPERM;
goto out; goto out;
} }
if (copy_from_user(&fsd, compat_ptr(dmhreq.data), sizeof(fsd))) { if (copy_from_user(&fsd, compat_ptr(dmhreq.data), sizeof(fsd))) {
error = -XFS_ERROR(EFAULT); error = -EFAULT;
goto out; goto out;
} }
error = -xfs_set_dmattrs(XFS_I(dentry->d_inode), fsd.fsd_dmevmask, error = xfs_set_dmattrs(XFS_I(dentry->d_inode), fsd.fsd_dmevmask,
fsd.fsd_dmstate); fsd.fsd_dmstate);
out: out:
...@@ -588,7 +588,7 @@ xfs_file_compat_ioctl( ...@@ -588,7 +588,7 @@ xfs_file_compat_ioctl(
struct xfs_flock64 bf; struct xfs_flock64 bf;
if (xfs_compat_flock64_copyin(&bf, arg)) if (xfs_compat_flock64_copyin(&bf, arg))
return -XFS_ERROR(EFAULT); return -EFAULT;
cmd = _NATIVE_IOC(cmd, struct xfs_flock64); cmd = _NATIVE_IOC(cmd, struct xfs_flock64);
return xfs_ioc_space(ip, inode, filp, ioflags, cmd, &bf); return xfs_ioc_space(ip, inode, filp, ioflags, cmd, &bf);
} }
...@@ -598,25 +598,25 @@ xfs_file_compat_ioctl( ...@@ -598,25 +598,25 @@ xfs_file_compat_ioctl(
struct xfs_growfs_data in; struct xfs_growfs_data in;
if (xfs_compat_growfs_data_copyin(&in, arg)) if (xfs_compat_growfs_data_copyin(&in, arg))
return -XFS_ERROR(EFAULT); return -EFAULT;
error = mnt_want_write_file(filp); error = mnt_want_write_file(filp);
if (error) if (error)
return error; return error;
error = xfs_growfs_data(mp, &in); error = xfs_growfs_data(mp, &in);
mnt_drop_write_file(filp); mnt_drop_write_file(filp);
return -error; return error;
} }
case XFS_IOC_FSGROWFSRT_32: { case XFS_IOC_FSGROWFSRT_32: {
struct xfs_growfs_rt in; struct xfs_growfs_rt in;
if (xfs_compat_growfs_rt_copyin(&in, arg)) if (xfs_compat_growfs_rt_copyin(&in, arg))
return -XFS_ERROR(EFAULT); return -EFAULT;
error = mnt_want_write_file(filp); error = mnt_want_write_file(filp);
if (error) if (error)
return error; return error;
error = xfs_growfs_rt(mp, &in); error = xfs_growfs_rt(mp, &in);
mnt_drop_write_file(filp); mnt_drop_write_file(filp);
return -error; return error;
} }
#endif #endif
/* long changes size, but xfs only copiese out 32 bits */ /* long changes size, but xfs only copiese out 32 bits */
...@@ -633,13 +633,13 @@ xfs_file_compat_ioctl( ...@@ -633,13 +633,13 @@ xfs_file_compat_ioctl(
if (copy_from_user(&sxp, sxu, if (copy_from_user(&sxp, sxu,
offsetof(struct xfs_swapext, sx_stat)) || offsetof(struct xfs_swapext, sx_stat)) ||
xfs_ioctl32_bstat_copyin(&sxp.sx_stat, &sxu->sx_stat)) xfs_ioctl32_bstat_copyin(&sxp.sx_stat, &sxu->sx_stat))
return -XFS_ERROR(EFAULT); return -EFAULT;
error = mnt_want_write_file(filp); error = mnt_want_write_file(filp);
if (error) if (error)
return error; return error;
error = xfs_ioc_swapext(&sxp); error = xfs_ioc_swapext(&sxp);
mnt_drop_write_file(filp); mnt_drop_write_file(filp);
return -error; return error;
} }
case XFS_IOC_FSBULKSTAT_32: case XFS_IOC_FSBULKSTAT_32:
case XFS_IOC_FSBULKSTAT_SINGLE_32: case XFS_IOC_FSBULKSTAT_SINGLE_32:
...@@ -651,7 +651,7 @@ xfs_file_compat_ioctl( ...@@ -651,7 +651,7 @@ xfs_file_compat_ioctl(
struct xfs_fsop_handlereq hreq; struct xfs_fsop_handlereq hreq;
if (xfs_compat_handlereq_copyin(&hreq, arg)) if (xfs_compat_handlereq_copyin(&hreq, arg))
return -XFS_ERROR(EFAULT); return -EFAULT;
cmd = _NATIVE_IOC(cmd, struct xfs_fsop_handlereq); cmd = _NATIVE_IOC(cmd, struct xfs_fsop_handlereq);
return xfs_find_handle(cmd, &hreq); return xfs_find_handle(cmd, &hreq);
} }
...@@ -659,14 +659,14 @@ xfs_file_compat_ioctl( ...@@ -659,14 +659,14 @@ xfs_file_compat_ioctl(
struct xfs_fsop_handlereq hreq; struct xfs_fsop_handlereq hreq;
if (xfs_compat_handlereq_copyin(&hreq, arg)) if (xfs_compat_handlereq_copyin(&hreq, arg))
return -XFS_ERROR(EFAULT); return -EFAULT;
return xfs_open_by_handle(filp, &hreq); return xfs_open_by_handle(filp, &hreq);
} }
case XFS_IOC_READLINK_BY_HANDLE_32: { case XFS_IOC_READLINK_BY_HANDLE_32: {
struct xfs_fsop_handlereq hreq; struct xfs_fsop_handlereq hreq;
if (xfs_compat_handlereq_copyin(&hreq, arg)) if (xfs_compat_handlereq_copyin(&hreq, arg))
return -XFS_ERROR(EFAULT); return -EFAULT;
return xfs_readlink_by_handle(filp, &hreq); return xfs_readlink_by_handle(filp, &hreq);
} }
case XFS_IOC_ATTRLIST_BY_HANDLE_32: case XFS_IOC_ATTRLIST_BY_HANDLE_32:
...@@ -676,6 +676,6 @@ xfs_file_compat_ioctl( ...@@ -676,6 +676,6 @@ xfs_file_compat_ioctl(
case XFS_IOC_FSSETDM_BY_HANDLE_32: case XFS_IOC_FSSETDM_BY_HANDLE_32:
return xfs_compat_fssetdm_by_handle(filp, arg); return xfs_compat_fssetdm_by_handle(filp, arg);
default: default:
return -XFS_ERROR(ENOIOCTLCMD); return -ENOIOCTLCMD;
} }
} }
...@@ -110,7 +110,7 @@ xfs_alert_fsblock_zero( ...@@ -110,7 +110,7 @@ xfs_alert_fsblock_zero(
(unsigned long long)imap->br_startoff, (unsigned long long)imap->br_startoff,
(unsigned long long)imap->br_blockcount, (unsigned long long)imap->br_blockcount,
imap->br_state); imap->br_state);
return EFSCORRUPTED; return -EFSCORRUPTED;
} }
int int
...@@ -138,7 +138,7 @@ xfs_iomap_write_direct( ...@@ -138,7 +138,7 @@ xfs_iomap_write_direct(
error = xfs_qm_dqattach(ip, 0); error = xfs_qm_dqattach(ip, 0);
if (error) if (error)
return XFS_ERROR(error); return error;
rt = XFS_IS_REALTIME_INODE(ip); rt = XFS_IS_REALTIME_INODE(ip);
extsz = xfs_get_extsz_hint(ip); extsz = xfs_get_extsz_hint(ip);
...@@ -148,7 +148,7 @@ xfs_iomap_write_direct( ...@@ -148,7 +148,7 @@ xfs_iomap_write_direct(
if ((offset + count) > XFS_ISIZE(ip)) { if ((offset + count) > XFS_ISIZE(ip)) {
error = xfs_iomap_eof_align_last_fsb(mp, ip, extsz, &last_fsb); error = xfs_iomap_eof_align_last_fsb(mp, ip, extsz, &last_fsb);
if (error) if (error)
return XFS_ERROR(error); return error;
} else { } else {
if (nmaps && (imap->br_startblock == HOLESTARTBLOCK)) if (nmaps && (imap->br_startblock == HOLESTARTBLOCK))
last_fsb = MIN(last_fsb, (xfs_fileoff_t) last_fsb = MIN(last_fsb, (xfs_fileoff_t)
...@@ -188,7 +188,7 @@ xfs_iomap_write_direct( ...@@ -188,7 +188,7 @@ xfs_iomap_write_direct(
*/ */
if (error) { if (error) {
xfs_trans_cancel(tp, 0); xfs_trans_cancel(tp, 0);
return XFS_ERROR(error); return error;
} }
xfs_ilock(ip, XFS_ILOCK_EXCL); xfs_ilock(ip, XFS_ILOCK_EXCL);
...@@ -225,7 +225,7 @@ xfs_iomap_write_direct( ...@@ -225,7 +225,7 @@ xfs_iomap_write_direct(
* Copy any maps to caller's array and return any error. * Copy any maps to caller's array and return any error.
*/ */
if (nimaps == 0) { if (nimaps == 0) {
error = XFS_ERROR(ENOSPC); error = -ENOSPC;
goto out_unlock; goto out_unlock;
} }
...@@ -552,7 +552,7 @@ xfs_iomap_write_delay( ...@@ -552,7 +552,7 @@ xfs_iomap_write_delay(
*/ */
error = xfs_qm_dqattach_locked(ip, 0); error = xfs_qm_dqattach_locked(ip, 0);
if (error) if (error)
return XFS_ERROR(error); return error;
extsz = xfs_get_extsz_hint(ip); extsz = xfs_get_extsz_hint(ip);
offset_fsb = XFS_B_TO_FSBT(mp, offset); offset_fsb = XFS_B_TO_FSBT(mp, offset);
...@@ -596,11 +596,11 @@ xfs_iomap_write_delay( ...@@ -596,11 +596,11 @@ xfs_iomap_write_delay(
imap, &nimaps, XFS_BMAPI_ENTIRE); imap, &nimaps, XFS_BMAPI_ENTIRE);
switch (error) { switch (error) {
case 0: case 0:
case ENOSPC: case -ENOSPC:
case EDQUOT: case -EDQUOT:
break; break;
default: default:
return XFS_ERROR(error); return error;
} }
/* /*
...@@ -614,7 +614,7 @@ xfs_iomap_write_delay( ...@@ -614,7 +614,7 @@ xfs_iomap_write_delay(
error = 0; error = 0;
goto retry; goto retry;
} }
return XFS_ERROR(error ? error : ENOSPC); return error ? error : -ENOSPC;
} }
if (!(imap[0].br_startblock || XFS_IS_REALTIME_INODE(ip))) if (!(imap[0].br_startblock || XFS_IS_REALTIME_INODE(ip)))
...@@ -663,7 +663,7 @@ xfs_iomap_write_allocate( ...@@ -663,7 +663,7 @@ xfs_iomap_write_allocate(
*/ */
error = xfs_qm_dqattach(ip, 0); error = xfs_qm_dqattach(ip, 0);
if (error) if (error)
return XFS_ERROR(error); return error;
offset_fsb = XFS_B_TO_FSBT(mp, offset); offset_fsb = XFS_B_TO_FSBT(mp, offset);
count_fsb = imap->br_blockcount; count_fsb = imap->br_blockcount;
...@@ -690,7 +690,7 @@ xfs_iomap_write_allocate( ...@@ -690,7 +690,7 @@ xfs_iomap_write_allocate(
nres, 0); nres, 0);
if (error) { if (error) {
xfs_trans_cancel(tp, 0); xfs_trans_cancel(tp, 0);
return XFS_ERROR(error); return error;
} }
xfs_ilock(ip, XFS_ILOCK_EXCL); xfs_ilock(ip, XFS_ILOCK_EXCL);
xfs_trans_ijoin(tp, ip, 0); xfs_trans_ijoin(tp, ip, 0);
...@@ -739,7 +739,7 @@ xfs_iomap_write_allocate( ...@@ -739,7 +739,7 @@ xfs_iomap_write_allocate(
if ((map_start_fsb + count_fsb) > last_block) { if ((map_start_fsb + count_fsb) > last_block) {
count_fsb = last_block - map_start_fsb; count_fsb = last_block - map_start_fsb;
if (count_fsb == 0) { if (count_fsb == 0) {
error = EAGAIN; error = -EAGAIN;
goto trans_cancel; goto trans_cancel;
} }
} }
...@@ -793,7 +793,7 @@ xfs_iomap_write_allocate( ...@@ -793,7 +793,7 @@ xfs_iomap_write_allocate(
xfs_trans_cancel(tp, XFS_TRANS_RELEASE_LOG_RES | XFS_TRANS_ABORT); xfs_trans_cancel(tp, XFS_TRANS_RELEASE_LOG_RES | XFS_TRANS_ABORT);
error0: error0:
xfs_iunlock(ip, XFS_ILOCK_EXCL); xfs_iunlock(ip, XFS_ILOCK_EXCL);
return XFS_ERROR(error); return error;
} }
int int
...@@ -853,7 +853,7 @@ xfs_iomap_write_unwritten( ...@@ -853,7 +853,7 @@ xfs_iomap_write_unwritten(
resblks, 0); resblks, 0);
if (error) { if (error) {
xfs_trans_cancel(tp, 0); xfs_trans_cancel(tp, 0);
return XFS_ERROR(error); return error;
} }
xfs_ilock(ip, XFS_ILOCK_EXCL); xfs_ilock(ip, XFS_ILOCK_EXCL);
...@@ -892,7 +892,7 @@ xfs_iomap_write_unwritten( ...@@ -892,7 +892,7 @@ xfs_iomap_write_unwritten(
error = xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES); error = xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES);
xfs_iunlock(ip, XFS_ILOCK_EXCL); xfs_iunlock(ip, XFS_ILOCK_EXCL);
if (error) if (error)
return XFS_ERROR(error); return error;
if (!(imap.br_startblock || XFS_IS_REALTIME_INODE(ip))) if (!(imap.br_startblock || XFS_IS_REALTIME_INODE(ip)))
return xfs_alert_fsblock_zero(ip, &imap); return xfs_alert_fsblock_zero(ip, &imap);
...@@ -915,5 +915,5 @@ xfs_iomap_write_unwritten( ...@@ -915,5 +915,5 @@ xfs_iomap_write_unwritten(
xfs_bmap_cancel(&free_list); xfs_bmap_cancel(&free_list);
xfs_trans_cancel(tp, (XFS_TRANS_RELEASE_LOG_RES | XFS_TRANS_ABORT)); xfs_trans_cancel(tp, (XFS_TRANS_RELEASE_LOG_RES | XFS_TRANS_ABORT));
xfs_iunlock(ip, XFS_ILOCK_EXCL); xfs_iunlock(ip, XFS_ILOCK_EXCL);
return XFS_ERROR(error); return error;
} }
此差异已折叠。
...@@ -67,11 +67,11 @@ xfs_bulkstat_one_int( ...@@ -67,11 +67,11 @@ xfs_bulkstat_one_int(
*stat = BULKSTAT_RV_NOTHING; *stat = BULKSTAT_RV_NOTHING;
if (!buffer || xfs_internal_inum(mp, ino)) if (!buffer || xfs_internal_inum(mp, ino))
return XFS_ERROR(EINVAL); return -EINVAL;
buf = kmem_alloc(sizeof(*buf), KM_SLEEP | KM_MAYFAIL); buf = kmem_alloc(sizeof(*buf), KM_SLEEP | KM_MAYFAIL);
if (!buf) if (!buf)
return XFS_ERROR(ENOMEM); return -ENOMEM;
error = xfs_iget(mp, NULL, ino, error = xfs_iget(mp, NULL, ino,
(XFS_IGET_DONTCACHE | XFS_IGET_UNTRUSTED), (XFS_IGET_DONTCACHE | XFS_IGET_UNTRUSTED),
...@@ -154,9 +154,9 @@ xfs_bulkstat_one_fmt( ...@@ -154,9 +154,9 @@ xfs_bulkstat_one_fmt(
const xfs_bstat_t *buffer) const xfs_bstat_t *buffer)
{ {
if (ubsize < sizeof(*buffer)) if (ubsize < sizeof(*buffer))
return XFS_ERROR(ENOMEM); return -ENOMEM;
if (copy_to_user(ubuffer, buffer, sizeof(*buffer))) if (copy_to_user(ubuffer, buffer, sizeof(*buffer)))
return XFS_ERROR(EFAULT); return -EFAULT;
if (ubused) if (ubused)
*ubused = sizeof(*buffer); *ubused = sizeof(*buffer);
return 0; return 0;
...@@ -234,7 +234,7 @@ xfs_bulkstat( ...@@ -234,7 +234,7 @@ xfs_bulkstat(
return 0; return 0;
} }
if (!ubcountp || *ubcountp <= 0) { if (!ubcountp || *ubcountp <= 0) {
return EINVAL; return -EINVAL;
} }
ubcount = *ubcountp; /* statstruct's */ ubcount = *ubcountp; /* statstruct's */
ubleft = ubcount * statstruct_size; /* bytes */ ubleft = ubcount * statstruct_size; /* bytes */
...@@ -246,7 +246,7 @@ xfs_bulkstat( ...@@ -246,7 +246,7 @@ xfs_bulkstat(
inodes_per_cluster = blks_per_cluster << mp->m_sb.sb_inopblog; inodes_per_cluster = blks_per_cluster << mp->m_sb.sb_inopblog;
irbuf = kmem_zalloc_greedy(&irbsize, PAGE_SIZE, PAGE_SIZE * 4); irbuf = kmem_zalloc_greedy(&irbsize, PAGE_SIZE, PAGE_SIZE * 4);
if (!irbuf) if (!irbuf)
return ENOMEM; return -ENOMEM;
nirbuf = irbsize / sizeof(*irbuf); nirbuf = irbsize / sizeof(*irbuf);
...@@ -452,8 +452,8 @@ xfs_bulkstat( ...@@ -452,8 +452,8 @@ xfs_bulkstat(
error = formatter(mp, ino, ubufp, ubleft, error = formatter(mp, ino, ubufp, ubleft,
&ubused, &fmterror); &ubused, &fmterror);
if (fmterror == BULKSTAT_RV_NOTHING) { if (fmterror == BULKSTAT_RV_NOTHING) {
if (error && error != ENOENT && if (error && error != -ENOENT &&
error != EINVAL) { error != -EINVAL) {
ubleft = 0; ubleft = 0;
rval = error; rval = error;
break; break;
...@@ -551,8 +551,8 @@ xfs_bulkstat_single( ...@@ -551,8 +551,8 @@ xfs_bulkstat_single(
sizeof(xfs_bstat_t), buffer, done)) sizeof(xfs_bstat_t), buffer, done))
return error; return error;
if (count == 0 || (xfs_ino_t)*lastinop != ino) if (count == 0 || (xfs_ino_t)*lastinop != ino)
return error == EFSCORRUPTED ? return error == -EFSCORRUPTED ?
XFS_ERROR(EINVAL) : error; EINVAL : error;
else else
return 0; return 0;
} }
...@@ -661,7 +661,7 @@ xfs_inumbers( ...@@ -661,7 +661,7 @@ xfs_inumbers(
if (bufidx == bcount) { if (bufidx == bcount) {
long written; long written;
if (formatter(ubuffer, buffer, bufidx, &written)) { if (formatter(ubuffer, buffer, bufidx, &written)) {
error = XFS_ERROR(EFAULT); error = -EFAULT;
break; break;
} }
ubuffer += written; ubuffer += written;
...@@ -688,7 +688,7 @@ xfs_inumbers( ...@@ -688,7 +688,7 @@ xfs_inumbers(
if (bufidx) { if (bufidx) {
long written; long written;
if (formatter(ubuffer, buffer, bufidx, &written)) if (formatter(ubuffer, buffer, bufidx, &written))
error = XFS_ERROR(EFAULT); error = -EFAULT;
else else
*count += bufidx; *count += bufidx;
} }
......
...@@ -331,7 +331,7 @@ static inline __uint64_t roundup_64(__uint64_t x, __uint32_t y) ...@@ -331,7 +331,7 @@ static inline __uint64_t roundup_64(__uint64_t x, __uint32_t y)
{ {
x += y - 1; x += y - 1;
do_div(x, y); do_div(x, y);
return(x * y); return x * y;
} }
static inline __uint64_t howmany_64(__uint64_t x, __uint32_t y) static inline __uint64_t howmany_64(__uint64_t x, __uint32_t y)
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册