aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorDave Chinner <dchinner@redhat.com>2014-06-25 00:58:08 -0400
committerDave Chinner <david@fromorbit.com>2014-06-25 00:58:08 -0400
commit2451337dd043901b5270b7586942abe564443e3d (patch)
tree5f2a59b2c829dbb942c18315ffc0edfed0d3790a /fs
parent30f712c9dd69348aa51351d5cb6d366bf4fae31d (diff)
xfs: global error sign conversion
Convert all the errors the core XFs code to negative error signs like the rest of the kernel and remove all the sign conversion we do in the interface layers. Errors for conversion (and comparison) found via searches like: $ git grep " E" fs/xfs $ git grep "return E" fs/xfs $ git grep " E[A-Z].*;$" fs/xfs Negation points found via searches like: $ git grep "= -[a-z,A-Z]" fs/xfs $ git grep "return -[a-z,A-D,F-Z]" fs/xfs $ git grep " -[a-z].*;" fs/xfs [ with some bits I missed from Brian Foster ] Signed-off-by: Dave Chinner <dchinner@redhat.com> Reviewed-by: Brian Foster <bfoster@redhat.com> Signed-off-by: Dave Chinner <david@fromorbit.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/xfs/libxfs/xfs_alloc.c20
-rw-r--r--fs/xfs/libxfs/xfs_alloc_btree.c6
-rw-r--r--fs/xfs/libxfs/xfs_attr.c50
-rw-r--r--fs/xfs/libxfs/xfs_attr_leaf.c44
-rw-r--r--fs/xfs/libxfs/xfs_attr_remote.c10
-rw-r--r--fs/xfs/libxfs/xfs_bmap.c52
-rw-r--r--fs/xfs/libxfs/xfs_bmap_btree.c10
-rw-r--r--fs/xfs/libxfs/xfs_btree.c14
-rw-r--r--fs/xfs/libxfs/xfs_da_btree.c42
-rw-r--r--fs/xfs/libxfs/xfs_dir2.c24
-rw-r--r--fs/xfs/libxfs/xfs_dir2_block.c16
-rw-r--r--fs/xfs/libxfs/xfs_dir2_data.c10
-rw-r--r--fs/xfs/libxfs/xfs_dir2_leaf.c22
-rw-r--r--fs/xfs/libxfs/xfs_dir2_node.c40
-rw-r--r--fs/xfs/libxfs/xfs_dir2_sf.c28
-rw-r--r--fs/xfs/libxfs/xfs_dquot_buf.c6
-rw-r--r--fs/xfs/libxfs/xfs_ialloc.c32
-rw-r--r--fs/xfs/libxfs/xfs_ialloc_btree.c6
-rw-r--r--fs/xfs/libxfs/xfs_inode_buf.c10
-rw-r--r--fs/xfs/libxfs/xfs_inode_fork.c30
-rw-r--r--fs/xfs/libxfs/xfs_sb.c32
-rw-r--r--fs/xfs/libxfs/xfs_symlink_remote.c6
-rw-r--r--fs/xfs/xfs_acl.c8
-rw-r--r--fs/xfs/xfs_aops.c12
-rw-r--r--fs/xfs/xfs_attr_inactive.c8
-rw-r--r--fs/xfs/xfs_attr_list.c16
-rw-r--r--fs/xfs/xfs_bmap_util.c78
-rw-r--r--fs/xfs/xfs_buf.c26
-rw-r--r--fs/xfs/xfs_buf.h2
-rw-r--r--fs/xfs/xfs_buf_item.c4
-rw-r--r--fs/xfs/xfs_dir2_readdir.c4
-rw-r--r--fs/xfs/xfs_discard.c8
-rw-r--r--fs/xfs/xfs_dquot.c28
-rw-r--r--fs/xfs/xfs_error.c2
-rw-r--r--fs/xfs/xfs_error.h4
-rw-r--r--fs/xfs/xfs_export.c10
-rw-r--r--fs/xfs/xfs_extfree_item.c2
-rw-r--r--fs/xfs/xfs_file.c34
-rw-r--r--fs/xfs/xfs_filestream.c4
-rw-r--r--fs/xfs/xfs_fsops.c42
-rw-r--r--fs/xfs/xfs_icache.c46
-rw-r--r--fs/xfs/xfs_icache.h10
-rw-r--r--fs/xfs/xfs_inode.c66
-rw-r--r--fs/xfs/xfs_inode_item.c2
-rw-r--r--fs/xfs/xfs_ioctl.c140
-rw-r--r--fs/xfs/xfs_ioctl32.c32
-rw-r--r--fs/xfs/xfs_iomap.c12
-rw-r--r--fs/xfs/xfs_iops.c58
-rw-r--r--fs/xfs/xfs_itable.c22
-rw-r--r--fs/xfs/xfs_log.c52
-rw-r--r--fs/xfs/xfs_log_cil.c6
-rw-r--r--fs/xfs/xfs_log_recover.c183
-rw-r--r--fs/xfs/xfs_mount.c70
-rw-r--r--fs/xfs/xfs_mru_cache.c14
-rw-r--r--fs/xfs/xfs_qm.c24
-rw-r--r--fs/xfs/xfs_qm_bhv.c2
-rw-r--r--fs/xfs/xfs_qm_syscalls.c24
-rw-r--r--fs/xfs/xfs_quotaops.c18
-rw-r--r--fs/xfs/xfs_rtalloc.c20
-rw-r--r--fs/xfs/xfs_rtalloc.h2
-rw-r--r--fs/xfs/xfs_super.c88
-rw-r--r--fs/xfs/xfs_symlink.c30
-rw-r--r--fs/xfs/xfs_trans.c8
-rw-r--r--fs/xfs/xfs_trans_ail.c4
-rw-r--r--fs/xfs/xfs_trans_buf.c24
-rw-r--r--fs/xfs/xfs_trans_dquot.c4
-rw-r--r--fs/xfs/xfs_xattr.c6
67 files changed, 882 insertions, 887 deletions
diff --git a/fs/xfs/libxfs/xfs_alloc.c b/fs/xfs/libxfs/xfs_alloc.c
index d43813267a80..4bffffe038a1 100644
--- a/fs/xfs/libxfs/xfs_alloc.c
+++ b/fs/xfs/libxfs/xfs_alloc.c
@@ -483,9 +483,9 @@ xfs_agfl_read_verify(
483 return; 483 return;
484 484
485 if (!xfs_buf_verify_cksum(bp, XFS_AGFL_CRC_OFF)) 485 if (!xfs_buf_verify_cksum(bp, XFS_AGFL_CRC_OFF))
486 xfs_buf_ioerror(bp, EFSBADCRC); 486 xfs_buf_ioerror(bp, -EFSBADCRC);
487 else if (!xfs_agfl_verify(bp)) 487 else if (!xfs_agfl_verify(bp))
488 xfs_buf_ioerror(bp, EFSCORRUPTED); 488 xfs_buf_ioerror(bp, -EFSCORRUPTED);
489 489
490 if (bp->b_error) 490 if (bp->b_error)
491 xfs_verifier_error(bp); 491 xfs_verifier_error(bp);
@@ -503,7 +503,7 @@ xfs_agfl_write_verify(
503 return; 503 return;
504 504
505 if (!xfs_agfl_verify(bp)) { 505 if (!xfs_agfl_verify(bp)) {
506 xfs_buf_ioerror(bp, EFSCORRUPTED); 506 xfs_buf_ioerror(bp, -EFSCORRUPTED);
507 xfs_verifier_error(bp); 507 xfs_verifier_error(bp);
508 return; 508 return;
509 } 509 }
@@ -559,7 +559,7 @@ xfs_alloc_update_counters(
559 xfs_trans_agblocks_delta(tp, len); 559 xfs_trans_agblocks_delta(tp, len);
560 if (unlikely(be32_to_cpu(agf->agf_freeblks) > 560 if (unlikely(be32_to_cpu(agf->agf_freeblks) >
561 be32_to_cpu(agf->agf_length))) 561 be32_to_cpu(agf->agf_length)))
562 return EFSCORRUPTED; 562 return -EFSCORRUPTED;
563 563
564 xfs_alloc_log_agf(tp, agbp, XFS_AGF_FREEBLKS); 564 xfs_alloc_log_agf(tp, agbp, XFS_AGF_FREEBLKS);
565 return 0; 565 return 0;
@@ -2234,11 +2234,11 @@ xfs_agf_read_verify(
2234 2234
2235 if (xfs_sb_version_hascrc(&mp->m_sb) && 2235 if (xfs_sb_version_hascrc(&mp->m_sb) &&
2236 !xfs_buf_verify_cksum(bp, XFS_AGF_CRC_OFF)) 2236 !xfs_buf_verify_cksum(bp, XFS_AGF_CRC_OFF))
2237 xfs_buf_ioerror(bp, EFSBADCRC); 2237 xfs_buf_ioerror(bp, -EFSBADCRC);
2238 else if (XFS_TEST_ERROR(!xfs_agf_verify(mp, bp), mp, 2238 else if (XFS_TEST_ERROR(!xfs_agf_verify(mp, bp), mp,
2239 XFS_ERRTAG_ALLOC_READ_AGF, 2239 XFS_ERRTAG_ALLOC_READ_AGF,
2240 XFS_RANDOM_ALLOC_READ_AGF)) 2240 XFS_RANDOM_ALLOC_READ_AGF))
2241 xfs_buf_ioerror(bp, EFSCORRUPTED); 2241 xfs_buf_ioerror(bp, -EFSCORRUPTED);
2242 2242
2243 if (bp->b_error) 2243 if (bp->b_error)
2244 xfs_verifier_error(bp); 2244 xfs_verifier_error(bp);
@@ -2252,7 +2252,7 @@ xfs_agf_write_verify(
2252 struct xfs_buf_log_item *bip = bp->b_fspriv; 2252 struct xfs_buf_log_item *bip = bp->b_fspriv;
2253 2253
2254 if (!xfs_agf_verify(mp, bp)) { 2254 if (!xfs_agf_verify(mp, bp)) {
2255 xfs_buf_ioerror(bp, EFSCORRUPTED); 2255 xfs_buf_ioerror(bp, -EFSCORRUPTED);
2256 xfs_verifier_error(bp); 2256 xfs_verifier_error(bp);
2257 return; 2257 return;
2258 } 2258 }
@@ -2601,11 +2601,11 @@ xfs_free_extent(
2601 */ 2601 */
2602 args.agno = XFS_FSB_TO_AGNO(args.mp, bno); 2602 args.agno = XFS_FSB_TO_AGNO(args.mp, bno);
2603 if (args.agno >= args.mp->m_sb.sb_agcount) 2603 if (args.agno >= args.mp->m_sb.sb_agcount)
2604 return EFSCORRUPTED; 2604 return -EFSCORRUPTED;
2605 2605
2606 args.agbno = XFS_FSB_TO_AGBNO(args.mp, bno); 2606 args.agbno = XFS_FSB_TO_AGBNO(args.mp, bno);
2607 if (args.agbno >= args.mp->m_sb.sb_agblocks) 2607 if (args.agbno >= args.mp->m_sb.sb_agblocks)
2608 return EFSCORRUPTED; 2608 return -EFSCORRUPTED;
2609 2609
2610 args.pag = xfs_perag_get(args.mp, args.agno); 2610 args.pag = xfs_perag_get(args.mp, args.agno);
2611 ASSERT(args.pag); 2611 ASSERT(args.pag);
@@ -2617,7 +2617,7 @@ xfs_free_extent(
2617 /* validate the extent size is legal now we have the agf locked */ 2617 /* validate the extent size is legal now we have the agf locked */
2618 if (args.agbno + len > 2618 if (args.agbno + len >
2619 be32_to_cpu(XFS_BUF_TO_AGF(args.agbp)->agf_length)) { 2619 be32_to_cpu(XFS_BUF_TO_AGF(args.agbp)->agf_length)) {
2620 error = EFSCORRUPTED; 2620 error = -EFSCORRUPTED;
2621 goto error0; 2621 goto error0;
2622 } 2622 }
2623 2623
diff --git a/fs/xfs/libxfs/xfs_alloc_btree.c b/fs/xfs/libxfs/xfs_alloc_btree.c
index 8358f1ded94d..e0e83e24d3ef 100644
--- a/fs/xfs/libxfs/xfs_alloc_btree.c
+++ b/fs/xfs/libxfs/xfs_alloc_btree.c
@@ -355,9 +355,9 @@ xfs_allocbt_read_verify(
355 struct xfs_buf *bp) 355 struct xfs_buf *bp)
356{ 356{
357 if (!xfs_btree_sblock_verify_crc(bp)) 357 if (!xfs_btree_sblock_verify_crc(bp))
358 xfs_buf_ioerror(bp, EFSBADCRC); 358 xfs_buf_ioerror(bp, -EFSBADCRC);
359 else if (!xfs_allocbt_verify(bp)) 359 else if (!xfs_allocbt_verify(bp))
360 xfs_buf_ioerror(bp, EFSCORRUPTED); 360 xfs_buf_ioerror(bp, -EFSCORRUPTED);
361 361
362 if (bp->b_error) { 362 if (bp->b_error) {
363 trace_xfs_btree_corrupt(bp, _RET_IP_); 363 trace_xfs_btree_corrupt(bp, _RET_IP_);
@@ -371,7 +371,7 @@ xfs_allocbt_write_verify(
371{ 371{
372 if (!xfs_allocbt_verify(bp)) { 372 if (!xfs_allocbt_verify(bp)) {
373 trace_xfs_btree_corrupt(bp, _RET_IP_); 373 trace_xfs_btree_corrupt(bp, _RET_IP_);
374 xfs_buf_ioerror(bp, EFSCORRUPTED); 374 xfs_buf_ioerror(bp, -EFSCORRUPTED);
375 xfs_verifier_error(bp); 375 xfs_verifier_error(bp);
376 return; 376 return;
377 } 377 }
diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c
index 7d95b16f0919..353fb425faef 100644
--- a/fs/xfs/libxfs/xfs_attr.c
+++ b/fs/xfs/libxfs/xfs_attr.c
@@ -85,7 +85,7 @@ xfs_attr_args_init(
85{ 85{
86 86
87 if (!name) 87 if (!name)
88 return EINVAL; 88 return -EINVAL;
89 89
90 memset(args, 0, sizeof(*args)); 90 memset(args, 0, sizeof(*args));
91 args->geo = dp->i_mount->m_attr_geo; 91 args->geo = dp->i_mount->m_attr_geo;
@@ -95,7 +95,7 @@ xfs_attr_args_init(
95 args->name = name; 95 args->name = name;
96 args->namelen = strlen((const char *)name); 96 args->namelen = strlen((const char *)name);
97 if (args->namelen >= MAXNAMELEN) 97 if (args->namelen >= MAXNAMELEN)
98 return EFAULT; /* match IRIX behaviour */ 98 return -EFAULT; /* match IRIX behaviour */
99 99
100 args->hashval = xfs_da_hashname(args->name, args->namelen); 100 args->hashval = xfs_da_hashname(args->name, args->namelen);
101 return 0; 101 return 0;
@@ -131,10 +131,10 @@ xfs_attr_get(
131 XFS_STATS_INC(xs_attr_get); 131 XFS_STATS_INC(xs_attr_get);
132 132
133 if (XFS_FORCED_SHUTDOWN(ip->i_mount)) 133 if (XFS_FORCED_SHUTDOWN(ip->i_mount))
134 return EIO; 134 return -EIO;
135 135
136 if (!xfs_inode_hasattr(ip)) 136 if (!xfs_inode_hasattr(ip))
137 return ENOATTR; 137 return -ENOATTR;
138 138
139 error = xfs_attr_args_init(&args, ip, name, flags); 139 error = xfs_attr_args_init(&args, ip, name, flags);
140 if (error) 140 if (error)
@@ -145,7 +145,7 @@ xfs_attr_get(
145 145
146 lock_mode = xfs_ilock_attr_map_shared(ip); 146 lock_mode = xfs_ilock_attr_map_shared(ip);
147 if (!xfs_inode_hasattr(ip)) 147 if (!xfs_inode_hasattr(ip))
148 error = ENOATTR; 148 error = -ENOATTR;
149 else if (ip->i_d.di_aformat == XFS_DINODE_FMT_LOCAL) 149 else if (ip->i_d.di_aformat == XFS_DINODE_FMT_LOCAL)
150 error = xfs_attr_shortform_getvalue(&args); 150 error = xfs_attr_shortform_getvalue(&args);
151 else if (xfs_bmap_one_block(ip, XFS_ATTR_FORK)) 151 else if (xfs_bmap_one_block(ip, XFS_ATTR_FORK))
@@ -155,7 +155,7 @@ xfs_attr_get(
155 xfs_iunlock(ip, lock_mode); 155 xfs_iunlock(ip, lock_mode);
156 156
157 *valuelenp = args.valuelen; 157 *valuelenp = args.valuelen;
158 return error == EEXIST ? 0 : error; 158 return error == -EEXIST ? 0 : error;
159} 159}
160 160
161/* 161/*
@@ -213,7 +213,7 @@ xfs_attr_set(
213 XFS_STATS_INC(xs_attr_set); 213 XFS_STATS_INC(xs_attr_set);
214 214
215 if (XFS_FORCED_SHUTDOWN(dp->i_mount)) 215 if (XFS_FORCED_SHUTDOWN(dp->i_mount))
216 return EIO; 216 return -EIO;
217 217
218 error = xfs_attr_args_init(&args, dp, name, flags); 218 error = xfs_attr_args_init(&args, dp, name, flags);
219 if (error) 219 if (error)
@@ -304,7 +304,7 @@ xfs_attr_set(
304 * the inode. 304 * the inode.
305 */ 305 */
306 error = xfs_attr_shortform_addname(&args); 306 error = xfs_attr_shortform_addname(&args);
307 if (error != ENOSPC) { 307 if (error != -ENOSPC) {
308 /* 308 /*
309 * Commit the shortform mods, and we're done. 309 * Commit the shortform mods, and we're done.
310 * NOTE: this is also the error path (EEXIST, etc). 310 * NOTE: this is also the error path (EEXIST, etc).
@@ -419,10 +419,10 @@ xfs_attr_remove(
419 XFS_STATS_INC(xs_attr_remove); 419 XFS_STATS_INC(xs_attr_remove);
420 420
421 if (XFS_FORCED_SHUTDOWN(dp->i_mount)) 421 if (XFS_FORCED_SHUTDOWN(dp->i_mount))
422 return EIO; 422 return -EIO;
423 423
424 if (!xfs_inode_hasattr(dp)) 424 if (!xfs_inode_hasattr(dp))
425 return ENOATTR; 425 return -ENOATTR;
426 426
427 error = xfs_attr_args_init(&args, dp, name, flags); 427 error = xfs_attr_args_init(&args, dp, name, flags);
428 if (error) 428 if (error)
@@ -477,7 +477,7 @@ xfs_attr_remove(
477 xfs_trans_ijoin(args.trans, dp, 0); 477 xfs_trans_ijoin(args.trans, dp, 0);
478 478
479 if (!xfs_inode_hasattr(dp)) { 479 if (!xfs_inode_hasattr(dp)) {
480 error = ENOATTR; 480 error = -ENOATTR;
481 } else if (dp->i_d.di_aformat == XFS_DINODE_FMT_LOCAL) { 481 } else if (dp->i_d.di_aformat == XFS_DINODE_FMT_LOCAL) {
482 ASSERT(dp->i_afp->if_flags & XFS_IFINLINE); 482 ASSERT(dp->i_afp->if_flags & XFS_IFINLINE);
483 error = xfs_attr_shortform_remove(&args); 483 error = xfs_attr_shortform_remove(&args);
@@ -534,9 +534,9 @@ xfs_attr_shortform_addname(xfs_da_args_t *args)
534 trace_xfs_attr_sf_addname(args); 534 trace_xfs_attr_sf_addname(args);
535 535
536 retval = xfs_attr_shortform_lookup(args); 536 retval = xfs_attr_shortform_lookup(args);
537 if ((args->flags & ATTR_REPLACE) && (retval == ENOATTR)) { 537 if ((args->flags & ATTR_REPLACE) && (retval == -ENOATTR)) {
538 return retval; 538 return retval;
539 } else if (retval == EEXIST) { 539 } else if (retval == -EEXIST) {
540 if (args->flags & ATTR_CREATE) 540 if (args->flags & ATTR_CREATE)
541 return retval; 541 return retval;
542 retval = xfs_attr_shortform_remove(args); 542 retval = xfs_attr_shortform_remove(args);
@@ -545,14 +545,14 @@ xfs_attr_shortform_addname(xfs_da_args_t *args)
545 545
546 if (args->namelen >= XFS_ATTR_SF_ENTSIZE_MAX || 546 if (args->namelen >= XFS_ATTR_SF_ENTSIZE_MAX ||
547 args->valuelen >= XFS_ATTR_SF_ENTSIZE_MAX) 547 args->valuelen >= XFS_ATTR_SF_ENTSIZE_MAX)
548 return ENOSPC; 548 return -ENOSPC;
549 549
550 newsize = XFS_ATTR_SF_TOTSIZE(args->dp); 550 newsize = XFS_ATTR_SF_TOTSIZE(args->dp);
551 newsize += XFS_ATTR_SF_ENTSIZE_BYNAME(args->namelen, args->valuelen); 551 newsize += XFS_ATTR_SF_ENTSIZE_BYNAME(args->namelen, args->valuelen);
552 552
553 forkoff = xfs_attr_shortform_bytesfit(args->dp, newsize); 553 forkoff = xfs_attr_shortform_bytesfit(args->dp, newsize);
554 if (!forkoff) 554 if (!forkoff)
555 return ENOSPC; 555 return -ENOSPC;
556 556
557 xfs_attr_shortform_add(args, forkoff); 557 xfs_attr_shortform_add(args, forkoff);
558 return 0; 558 return 0;
@@ -592,10 +592,10 @@ xfs_attr_leaf_addname(xfs_da_args_t *args)
592 * the given flags produce an error or call for an atomic rename. 592 * the given flags produce an error or call for an atomic rename.
593 */ 593 */
594 retval = xfs_attr3_leaf_lookup_int(bp, args); 594 retval = xfs_attr3_leaf_lookup_int(bp, args);
595 if ((args->flags & ATTR_REPLACE) && (retval == ENOATTR)) { 595 if ((args->flags & ATTR_REPLACE) && (retval == -ENOATTR)) {
596 xfs_trans_brelse(args->trans, bp); 596 xfs_trans_brelse(args->trans, bp);
597 return retval; 597 return retval;
598 } else if (retval == EEXIST) { 598 } else if (retval == -EEXIST) {
599 if (args->flags & ATTR_CREATE) { /* pure create op */ 599 if (args->flags & ATTR_CREATE) { /* pure create op */
600 xfs_trans_brelse(args->trans, bp); 600 xfs_trans_brelse(args->trans, bp);
601 return retval; 601 return retval;
@@ -626,7 +626,7 @@ xfs_attr_leaf_addname(xfs_da_args_t *args)
626 * if required. 626 * if required.
627 */ 627 */
628 retval = xfs_attr3_leaf_add(bp, args); 628 retval = xfs_attr3_leaf_add(bp, args);
629 if (retval == ENOSPC) { 629 if (retval == -ENOSPC) {
630 /* 630 /*
631 * Promote the attribute list to the Btree format, then 631 * Promote the attribute list to the Btree format, then
632 * Commit that transaction so that the node_addname() call 632 * Commit that transaction so that the node_addname() call
@@ -795,7 +795,7 @@ xfs_attr_leaf_removename(xfs_da_args_t *args)
795 return error; 795 return error;
796 796
797 error = xfs_attr3_leaf_lookup_int(bp, args); 797 error = xfs_attr3_leaf_lookup_int(bp, args);
798 if (error == ENOATTR) { 798 if (error == -ENOATTR) {
799 xfs_trans_brelse(args->trans, bp); 799 xfs_trans_brelse(args->trans, bp);
800 return error; 800 return error;
801 } 801 }
@@ -850,7 +850,7 @@ xfs_attr_leaf_get(xfs_da_args_t *args)
850 return error; 850 return error;
851 851
852 error = xfs_attr3_leaf_lookup_int(bp, args); 852 error = xfs_attr3_leaf_lookup_int(bp, args);
853 if (error != EEXIST) { 853 if (error != -EEXIST) {
854 xfs_trans_brelse(args->trans, bp); 854 xfs_trans_brelse(args->trans, bp);
855 return error; 855 return error;
856 } 856 }
@@ -906,9 +906,9 @@ restart:
906 goto out; 906 goto out;
907 blk = &state->path.blk[ state->path.active-1 ]; 907 blk = &state->path.blk[ state->path.active-1 ];
908 ASSERT(blk->magic == XFS_ATTR_LEAF_MAGIC); 908 ASSERT(blk->magic == XFS_ATTR_LEAF_MAGIC);
909 if ((args->flags & ATTR_REPLACE) && (retval == ENOATTR)) { 909 if ((args->flags & ATTR_REPLACE) && (retval == -ENOATTR)) {
910 goto out; 910 goto out;
911 } else if (retval == EEXIST) { 911 } else if (retval == -EEXIST) {
912 if (args->flags & ATTR_CREATE) 912 if (args->flags & ATTR_CREATE)
913 goto out; 913 goto out;
914 914
@@ -933,7 +933,7 @@ restart:
933 } 933 }
934 934
935 retval = xfs_attr3_leaf_add(blk->bp, state->args); 935 retval = xfs_attr3_leaf_add(blk->bp, state->args);
936 if (retval == ENOSPC) { 936 if (retval == -ENOSPC) {
937 if (state->path.active == 1) { 937 if (state->path.active == 1) {
938 /* 938 /*
939 * Its really a single leaf node, but it had 939 * Its really a single leaf node, but it had
@@ -1168,7 +1168,7 @@ xfs_attr_node_removename(xfs_da_args_t *args)
1168 * Search to see if name exists, and get back a pointer to it. 1168 * Search to see if name exists, and get back a pointer to it.
1169 */ 1169 */
1170 error = xfs_da3_node_lookup_int(state, &retval); 1170 error = xfs_da3_node_lookup_int(state, &retval);
1171 if (error || (retval != EEXIST)) { 1171 if (error || (retval != -EEXIST)) {
1172 if (error == 0) 1172 if (error == 0)
1173 error = retval; 1173 error = retval;
1174 goto out; 1174 goto out;
@@ -1431,7 +1431,7 @@ xfs_attr_node_get(xfs_da_args_t *args)
1431 error = xfs_da3_node_lookup_int(state, &retval); 1431 error = xfs_da3_node_lookup_int(state, &retval);
1432 if (error) { 1432 if (error) {
1433 retval = error; 1433 retval = error;
1434 } else if (retval == EEXIST) { 1434 } else if (retval == -EEXIST) {
1435 blk = &state->path.blk[ state->path.active-1 ]; 1435 blk = &state->path.blk[ state->path.active-1 ];
1436 ASSERT(blk->bp != NULL); 1436 ASSERT(blk->bp != NULL);
1437 ASSERT(blk->magic == XFS_ATTR_LEAF_MAGIC); 1437 ASSERT(blk->magic == XFS_ATTR_LEAF_MAGIC);
diff --git a/fs/xfs/libxfs/xfs_attr_leaf.c b/fs/xfs/libxfs/xfs_attr_leaf.c
index 127d96aba845..b1f73dbbf3d8 100644
--- a/fs/xfs/libxfs/xfs_attr_leaf.c
+++ b/fs/xfs/libxfs/xfs_attr_leaf.c
@@ -214,7 +214,7 @@ xfs_attr3_leaf_write_verify(
214 struct xfs_attr3_leaf_hdr *hdr3 = bp->b_addr; 214 struct xfs_attr3_leaf_hdr *hdr3 = bp->b_addr;
215 215
216 if (!xfs_attr3_leaf_verify(bp)) { 216 if (!xfs_attr3_leaf_verify(bp)) {
217 xfs_buf_ioerror(bp, EFSCORRUPTED); 217 xfs_buf_ioerror(bp, -EFSCORRUPTED);
218 xfs_verifier_error(bp); 218 xfs_verifier_error(bp);
219 return; 219 return;
220 } 220 }
@@ -242,9 +242,9 @@ xfs_attr3_leaf_read_verify(
242 242
243 if (xfs_sb_version_hascrc(&mp->m_sb) && 243 if (xfs_sb_version_hascrc(&mp->m_sb) &&
244 !xfs_buf_verify_cksum(bp, XFS_ATTR3_LEAF_CRC_OFF)) 244 !xfs_buf_verify_cksum(bp, XFS_ATTR3_LEAF_CRC_OFF))
245 xfs_buf_ioerror(bp, EFSBADCRC); 245 xfs_buf_ioerror(bp, -EFSBADCRC);
246 else if (!xfs_attr3_leaf_verify(bp)) 246 else if (!xfs_attr3_leaf_verify(bp))
247 xfs_buf_ioerror(bp, EFSCORRUPTED); 247 xfs_buf_ioerror(bp, -EFSCORRUPTED);
248 248
249 if (bp->b_error) 249 if (bp->b_error)
250 xfs_verifier_error(bp); 250 xfs_verifier_error(bp);
@@ -547,7 +547,7 @@ xfs_attr_shortform_remove(xfs_da_args_t *args)
547 break; 547 break;
548 } 548 }
549 if (i == end) 549 if (i == end)
550 return ENOATTR; 550 return -ENOATTR;
551 551
552 /* 552 /*
553 * Fix up the attribute fork data, covering the hole 553 * Fix up the attribute fork data, covering the hole
@@ -611,9 +611,9 @@ xfs_attr_shortform_lookup(xfs_da_args_t *args)
611 continue; 611 continue;
612 if (!xfs_attr_namesp_match(args->flags, sfe->flags)) 612 if (!xfs_attr_namesp_match(args->flags, sfe->flags))
613 continue; 613 continue;
614 return EEXIST; 614 return -EEXIST;
615 } 615 }
616 return ENOATTR; 616 return -ENOATTR;
617} 617}
618 618
619/* 619/*
@@ -640,18 +640,18 @@ xfs_attr_shortform_getvalue(xfs_da_args_t *args)
640 continue; 640 continue;
641 if (args->flags & ATTR_KERNOVAL) { 641 if (args->flags & ATTR_KERNOVAL) {
642 args->valuelen = sfe->valuelen; 642 args->valuelen = sfe->valuelen;
643 return EEXIST; 643 return -EEXIST;
644 } 644 }
645 if (args->valuelen < sfe->valuelen) { 645 if (args->valuelen < sfe->valuelen) {
646 args->valuelen = sfe->valuelen; 646 args->valuelen = sfe->valuelen;
647 return ERANGE; 647 return -ERANGE;
648 } 648 }
649 args->valuelen = sfe->valuelen; 649 args->valuelen = sfe->valuelen;
650 memcpy(args->value, &sfe->nameval[args->namelen], 650 memcpy(args->value, &sfe->nameval[args->namelen],
651 args->valuelen); 651 args->valuelen);
652 return EEXIST; 652 return -EEXIST;
653 } 653 }
654 return ENOATTR; 654 return -ENOATTR;
655} 655}
656 656
657/* 657/*
@@ -691,7 +691,7 @@ xfs_attr_shortform_to_leaf(xfs_da_args_t *args)
691 * If we hit an IO error middle of the transaction inside 691 * If we hit an IO error middle of the transaction inside
692 * grow_inode(), we may have inconsistent data. Bail out. 692 * grow_inode(), we may have inconsistent data. Bail out.
693 */ 693 */
694 if (error == EIO) 694 if (error == -EIO)
695 goto out; 695 goto out;
696 xfs_idata_realloc(dp, size, XFS_ATTR_FORK); /* try to put */ 696 xfs_idata_realloc(dp, size, XFS_ATTR_FORK); /* try to put */
697 memcpy(ifp->if_u1.if_data, tmpbuffer, size); /* it back */ 697 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 sfe->namelen); 730 sfe->namelen);
731 nargs.flags = XFS_ATTR_NSP_ONDISK_TO_ARGS(sfe->flags); 731 nargs.flags = XFS_ATTR_NSP_ONDISK_TO_ARGS(sfe->flags);
732 error = xfs_attr3_leaf_lookup_int(bp, &nargs); /* set a->index */ 732 error = xfs_attr3_leaf_lookup_int(bp, &nargs); /* set a->index */
733 ASSERT(error == ENOATTR); 733 ASSERT(error == -ENOATTR);
734 error = xfs_attr3_leaf_add(bp, &nargs); 734 error = xfs_attr3_leaf_add(bp, &nargs);
735 ASSERT(error != ENOSPC); 735 ASSERT(error != -ENOSPC);
736 if (error) 736 if (error)
737 goto out; 737 goto out;
738 sfe = XFS_ATTR_SF_NEXTENTRY(sfe); 738 sfe = XFS_ATTR_SF_NEXTENTRY(sfe);
@@ -809,7 +809,7 @@ xfs_attr3_leaf_to_shortform(
809 809
810 tmpbuffer = kmem_alloc(args->geo->blksize, KM_SLEEP); 810 tmpbuffer = kmem_alloc(args->geo->blksize, KM_SLEEP);
811 if (!tmpbuffer) 811 if (!tmpbuffer)
812 return ENOMEM; 812 return -ENOMEM;
813 813
814 memcpy(tmpbuffer, bp->b_addr, args->geo->blksize); 814 memcpy(tmpbuffer, bp->b_addr, args->geo->blksize);
815 815
@@ -1108,7 +1108,7 @@ xfs_attr3_leaf_add(
1108 * no good and we should just give up. 1108 * no good and we should just give up.
1109 */ 1109 */
1110 if (!ichdr.holes && sum < entsize) 1110 if (!ichdr.holes && sum < entsize)
1111 return ENOSPC; 1111 return -ENOSPC;
1112 1112
1113 /* 1113 /*
1114 * Compact the entries to coalesce free space. 1114 * Compact the entries to coalesce free space.
@@ -1121,7 +1121,7 @@ xfs_attr3_leaf_add(
1121 * free region, in freemap[0]. If it is not big enough, give up. 1121 * free region, in freemap[0]. If it is not big enough, give up.
1122 */ 1122 */
1123 if (ichdr.freemap[0].size < (entsize + sizeof(xfs_attr_leaf_entry_t))) { 1123 if (ichdr.freemap[0].size < (entsize + sizeof(xfs_attr_leaf_entry_t))) {
1124 tmp = ENOSPC; 1124 tmp = -ENOSPC;
1125 goto out_log_hdr; 1125 goto out_log_hdr;
1126 } 1126 }
1127 1127
@@ -2123,7 +2123,7 @@ xfs_attr3_leaf_lookup_int(
2123 } 2123 }
2124 if (probe == ichdr.count || be32_to_cpu(entry->hashval) != hashval) { 2124 if (probe == ichdr.count || be32_to_cpu(entry->hashval) != hashval) {
2125 args->index = probe; 2125 args->index = probe;
2126 return ENOATTR; 2126 return -ENOATTR;
2127 } 2127 }
2128 2128
2129 /* 2129 /*
@@ -2152,7 +2152,7 @@ xfs_attr3_leaf_lookup_int(
2152 if (!xfs_attr_namesp_match(args->flags, entry->flags)) 2152 if (!xfs_attr_namesp_match(args->flags, entry->flags))
2153 continue; 2153 continue;
2154 args->index = probe; 2154 args->index = probe;
2155 return EEXIST; 2155 return -EEXIST;
2156 } else { 2156 } else {
2157 name_rmt = xfs_attr3_leaf_name_remote(leaf, probe); 2157 name_rmt = xfs_attr3_leaf_name_remote(leaf, probe);
2158 if (name_rmt->namelen != args->namelen) 2158 if (name_rmt->namelen != args->namelen)
@@ -2168,11 +2168,11 @@ xfs_attr3_leaf_lookup_int(
2168 args->rmtblkcnt = xfs_attr3_rmt_blocks( 2168 args->rmtblkcnt = xfs_attr3_rmt_blocks(
2169 args->dp->i_mount, 2169 args->dp->i_mount,
2170 args->rmtvaluelen); 2170 args->rmtvaluelen);
2171 return EEXIST; 2171 return -EEXIST;
2172 } 2172 }
2173 } 2173 }
2174 args->index = probe; 2174 args->index = probe;
2175 return ENOATTR; 2175 return -ENOATTR;
2176} 2176}
2177 2177
2178/* 2178/*
@@ -2208,7 +2208,7 @@ xfs_attr3_leaf_getvalue(
2208 } 2208 }
2209 if (args->valuelen < valuelen) { 2209 if (args->valuelen < valuelen) {
2210 args->valuelen = valuelen; 2210 args->valuelen = valuelen;
2211 return ERANGE; 2211 return -ERANGE;
2212 } 2212 }
2213 args->valuelen = valuelen; 2213 args->valuelen = valuelen;
2214 memcpy(args->value, &name_loc->nameval[args->namelen], valuelen); 2214 memcpy(args->value, &name_loc->nameval[args->namelen], valuelen);
@@ -2226,7 +2226,7 @@ xfs_attr3_leaf_getvalue(
2226 } 2226 }
2227 if (args->valuelen < args->rmtvaluelen) { 2227 if (args->valuelen < args->rmtvaluelen) {
2228 args->valuelen = args->rmtvaluelen; 2228 args->valuelen = args->rmtvaluelen;
2229 return ERANGE; 2229 return -ERANGE;
2230 } 2230 }
2231 args->valuelen = args->rmtvaluelen; 2231 args->valuelen = args->rmtvaluelen;
2232 } 2232 }
diff --git a/fs/xfs/libxfs/xfs_attr_remote.c b/fs/xfs/libxfs/xfs_attr_remote.c
index a8bbc562ff35..7510ab8058a4 100644
--- a/fs/xfs/libxfs/xfs_attr_remote.c
+++ b/fs/xfs/libxfs/xfs_attr_remote.c
@@ -138,11 +138,11 @@ xfs_attr3_rmt_read_verify(
138 138
139 while (len > 0) { 139 while (len > 0) {
140 if (!xfs_verify_cksum(ptr, blksize, XFS_ATTR3_RMT_CRC_OFF)) { 140 if (!xfs_verify_cksum(ptr, blksize, XFS_ATTR3_RMT_CRC_OFF)) {
141 xfs_buf_ioerror(bp, EFSBADCRC); 141 xfs_buf_ioerror(bp, -EFSBADCRC);
142 break; 142 break;
143 } 143 }
144 if (!xfs_attr3_rmt_verify(mp, ptr, blksize, bno)) { 144 if (!xfs_attr3_rmt_verify(mp, ptr, blksize, bno)) {
145 xfs_buf_ioerror(bp, EFSCORRUPTED); 145 xfs_buf_ioerror(bp, -EFSCORRUPTED);
146 break; 146 break;
147 } 147 }
148 len -= blksize; 148 len -= blksize;
@@ -178,7 +178,7 @@ xfs_attr3_rmt_write_verify(
178 178
179 while (len > 0) { 179 while (len > 0) {
180 if (!xfs_attr3_rmt_verify(mp, ptr, blksize, bno)) { 180 if (!xfs_attr3_rmt_verify(mp, ptr, blksize, bno)) {
181 xfs_buf_ioerror(bp, EFSCORRUPTED); 181 xfs_buf_ioerror(bp, -EFSCORRUPTED);
182 xfs_verifier_error(bp); 182 xfs_verifier_error(bp);
183 return; 183 return;
184 } 184 }
@@ -257,7 +257,7 @@ xfs_attr_rmtval_copyout(
257 xfs_alert(mp, 257 xfs_alert(mp,
258"remote attribute header mismatch bno/off/len/owner (0x%llx/0x%x/Ox%x/0x%llx)", 258"remote attribute header mismatch bno/off/len/owner (0x%llx/0x%x/Ox%x/0x%llx)",
259 bno, *offset, byte_cnt, ino); 259 bno, *offset, byte_cnt, ino);
260 return EFSCORRUPTED; 260 return -EFSCORRUPTED;
261 } 261 }
262 hdr_size = sizeof(struct xfs_attr3_rmt_hdr); 262 hdr_size = sizeof(struct xfs_attr3_rmt_hdr);
263 } 263 }
@@ -508,7 +508,7 @@ xfs_attr_rmtval_set(
508 508
509 bp = xfs_buf_get(mp->m_ddev_targp, dblkno, dblkcnt, 0); 509 bp = xfs_buf_get(mp->m_ddev_targp, dblkno, dblkcnt, 0);
510 if (!bp) 510 if (!bp)
511 return ENOMEM; 511 return -ENOMEM;
512 bp->b_ops = &xfs_attr3_rmt_buf_ops; 512 bp->b_ops = &xfs_attr3_rmt_buf_ops;
513 513
514 xfs_attr_rmtval_copyin(mp, bp, args->dp->i_ino, &offset, 514 xfs_attr_rmtval_copyin(mp, bp, args->dp->i_ino, &offset,
diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
index b44d63189dab..72a110eb1dda 100644
--- a/fs/xfs/libxfs/xfs_bmap.c
+++ b/fs/xfs/libxfs/xfs_bmap.c
@@ -1033,7 +1033,7 @@ xfs_bmap_add_attrfork_btree(
1033 goto error0; 1033 goto error0;
1034 if (stat == 0) { 1034 if (stat == 0) {
1035 xfs_btree_del_cursor(cur, XFS_BTREE_NOERROR); 1035 xfs_btree_del_cursor(cur, XFS_BTREE_NOERROR);
1036 return ENOSPC; 1036 return -ENOSPC;
1037 } 1037 }
1038 *firstblock = cur->bc_private.b.firstblock; 1038 *firstblock = cur->bc_private.b.firstblock;
1039 cur->bc_private.b.allocated = 0; 1039 cur->bc_private.b.allocated = 0;
@@ -1115,7 +1115,7 @@ xfs_bmap_add_attrfork_local(
1115 1115
1116 /* should only be called for types that support local format data */ 1116 /* should only be called for types that support local format data */
1117 ASSERT(0); 1117 ASSERT(0);
1118 return EFSCORRUPTED; 1118 return -EFSCORRUPTED;
1119} 1119}
1120 1120
1121/* 1121/*
@@ -1192,7 +1192,7 @@ xfs_bmap_add_attrfork(
1192 break; 1192 break;
1193 default: 1193 default:
1194 ASSERT(0); 1194 ASSERT(0);
1195 error = EINVAL; 1195 error = -EINVAL;
1196 goto trans_cancel; 1196 goto trans_cancel;
1197 } 1197 }
1198 1198
@@ -1399,7 +1399,7 @@ xfs_bmap_read_extents(
1399 return 0; 1399 return 0;
1400error0: 1400error0:
1401 xfs_trans_brelse(tp, bp); 1401 xfs_trans_brelse(tp, bp);
1402 return EFSCORRUPTED; 1402 return -EFSCORRUPTED;
1403} 1403}
1404 1404
1405 1405
@@ -1576,7 +1576,7 @@ xfs_bmap_last_before(
1576 if (XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_BTREE && 1576 if (XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_BTREE &&
1577 XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_EXTENTS && 1577 XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_EXTENTS &&
1578 XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_LOCAL) 1578 XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_LOCAL)
1579 return EIO; 1579 return -EIO;
1580 if (XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_LOCAL) { 1580 if (XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_LOCAL) {
1581 *last_block = 0; 1581 *last_block = 0;
1582 return 0; 1582 return 0;
@@ -1690,7 +1690,7 @@ xfs_bmap_last_offset(
1690 1690
1691 if (XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_BTREE && 1691 if (XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_BTREE &&
1692 XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_EXTENTS) 1692 XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_EXTENTS)
1693 return EIO; 1693 return -EIO;
1694 1694
1695 error = xfs_bmap_last_extent(NULL, ip, whichfork, &rec, &is_empty); 1695 error = xfs_bmap_last_extent(NULL, ip, whichfork, &rec, &is_empty);
1696 if (error || is_empty) 1696 if (error || is_empty)
@@ -3323,7 +3323,7 @@ xfs_bmap_extsize_align(
3323 if (orig_off < align_off || 3323 if (orig_off < align_off ||
3324 orig_end > align_off + align_alen || 3324 orig_end > align_off + align_alen ||
3325 align_alen - temp < orig_alen) 3325 align_alen - temp < orig_alen)
3326 return EINVAL; 3326 return -EINVAL;
3327 /* 3327 /*
3328 * Try to fix it by moving the start up. 3328 * Try to fix it by moving the start up.
3329 */ 3329 */
@@ -3348,7 +3348,7 @@ xfs_bmap_extsize_align(
3348 * Result doesn't cover the request, fail it. 3348 * Result doesn't cover the request, fail it.
3349 */ 3349 */
3350 if (orig_off < align_off || orig_end > align_off + align_alen) 3350 if (orig_off < align_off || orig_end > align_off + align_alen)
3351 return EINVAL; 3351 return -EINVAL;
3352 } else { 3352 } else {
3353 ASSERT(orig_off >= align_off); 3353 ASSERT(orig_off >= align_off);
3354 ASSERT(orig_end <= align_off + align_alen); 3354 ASSERT(orig_end <= align_off + align_alen);
@@ -4051,11 +4051,11 @@ xfs_bmapi_read(
4051 XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_BTREE), 4051 XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_BTREE),
4052 mp, XFS_ERRTAG_BMAPIFORMAT, XFS_RANDOM_BMAPIFORMAT))) { 4052 mp, XFS_ERRTAG_BMAPIFORMAT, XFS_RANDOM_BMAPIFORMAT))) {
4053 XFS_ERROR_REPORT("xfs_bmapi_read", XFS_ERRLEVEL_LOW, mp); 4053 XFS_ERROR_REPORT("xfs_bmapi_read", XFS_ERRLEVEL_LOW, mp);
4054 return EFSCORRUPTED; 4054 return -EFSCORRUPTED;
4055 } 4055 }
4056 4056
4057 if (XFS_FORCED_SHUTDOWN(mp)) 4057 if (XFS_FORCED_SHUTDOWN(mp))
4058 return EIO; 4058 return -EIO;
4059 4059
4060 XFS_STATS_INC(xs_blk_mapr); 4060 XFS_STATS_INC(xs_blk_mapr);
4061 4061
@@ -4246,11 +4246,11 @@ xfs_bmapi_delay(
4246 XFS_IFORK_FORMAT(ip, XFS_DATA_FORK) != XFS_DINODE_FMT_BTREE), 4246 XFS_IFORK_FORMAT(ip, XFS_DATA_FORK) != XFS_DINODE_FMT_BTREE),
4247 mp, XFS_ERRTAG_BMAPIFORMAT, XFS_RANDOM_BMAPIFORMAT))) { 4247 mp, XFS_ERRTAG_BMAPIFORMAT, XFS_RANDOM_BMAPIFORMAT))) {
4248 XFS_ERROR_REPORT("xfs_bmapi_delay", XFS_ERRLEVEL_LOW, mp); 4248 XFS_ERROR_REPORT("xfs_bmapi_delay", XFS_ERRLEVEL_LOW, mp);
4249 return EFSCORRUPTED; 4249 return -EFSCORRUPTED;
4250 } 4250 }
4251 4251
4252 if (XFS_FORCED_SHUTDOWN(mp)) 4252 if (XFS_FORCED_SHUTDOWN(mp))
4253 return EIO; 4253 return -EIO;
4254 4254
4255 XFS_STATS_INC(xs_blk_mapw); 4255 XFS_STATS_INC(xs_blk_mapw);
4256 4256
@@ -4469,7 +4469,7 @@ xfs_bmapi_convert_unwritten(
4469 * so generate another request. 4469 * so generate another request.
4470 */ 4470 */
4471 if (mval->br_blockcount < len) 4471 if (mval->br_blockcount < len)
4472 return EAGAIN; 4472 return -EAGAIN;
4473 return 0; 4473 return 0;
4474} 4474}
4475 4475
@@ -4540,11 +4540,11 @@ xfs_bmapi_write(
4540 XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_BTREE), 4540 XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_BTREE),
4541 mp, XFS_ERRTAG_BMAPIFORMAT, XFS_RANDOM_BMAPIFORMAT))) { 4541 mp, XFS_ERRTAG_BMAPIFORMAT, XFS_RANDOM_BMAPIFORMAT))) {
4542 XFS_ERROR_REPORT("xfs_bmapi_write", XFS_ERRLEVEL_LOW, mp); 4542 XFS_ERROR_REPORT("xfs_bmapi_write", XFS_ERRLEVEL_LOW, mp);
4543 return EFSCORRUPTED; 4543 return -EFSCORRUPTED;
4544 } 4544 }
4545 4545
4546 if (XFS_FORCED_SHUTDOWN(mp)) 4546 if (XFS_FORCED_SHUTDOWN(mp))
4547 return EIO; 4547 return -EIO;
4548 4548
4549 ifp = XFS_IFORK_PTR(ip, whichfork); 4549 ifp = XFS_IFORK_PTR(ip, whichfork);
4550 4550
@@ -4623,7 +4623,7 @@ xfs_bmapi_write(
4623 4623
4624 /* Execute unwritten extent conversion if necessary */ 4624 /* Execute unwritten extent conversion if necessary */
4625 error = xfs_bmapi_convert_unwritten(&bma, mval, len, flags); 4625 error = xfs_bmapi_convert_unwritten(&bma, mval, len, flags);
4626 if (error == EAGAIN) 4626 if (error == -EAGAIN)
4627 continue; 4627 continue;
4628 if (error) 4628 if (error)
4629 goto error0; 4629 goto error0;
@@ -4925,7 +4925,7 @@ xfs_bmap_del_extent(
4925 goto done; 4925 goto done;
4926 cur->bc_rec.b = new; 4926 cur->bc_rec.b = new;
4927 error = xfs_btree_insert(cur, &i); 4927 error = xfs_btree_insert(cur, &i);
4928 if (error && error != ENOSPC) 4928 if (error && error != -ENOSPC)
4929 goto done; 4929 goto done;
4930 /* 4930 /*
4931 * If get no-space back from btree insert, 4931 * If get no-space back from btree insert,
@@ -4933,7 +4933,7 @@ xfs_bmap_del_extent(
4933 * block reservation. 4933 * block reservation.
4934 * Fix up our state and return the error. 4934 * Fix up our state and return the error.
4935 */ 4935 */
4936 if (error == ENOSPC) { 4936 if (error == -ENOSPC) {
4937 /* 4937 /*
4938 * Reset the cursor, don't trust 4938 * Reset the cursor, don't trust
4939 * it after any insert operation. 4939 * it after any insert operation.
@@ -4961,7 +4961,7 @@ xfs_bmap_del_extent(
4961 xfs_bmbt_set_blockcount(ep, 4961 xfs_bmbt_set_blockcount(ep,
4962 got.br_blockcount); 4962 got.br_blockcount);
4963 flags = 0; 4963 flags = 0;
4964 error = ENOSPC; 4964 error = -ENOSPC;
4965 goto done; 4965 goto done;
4966 } 4966 }
4967 XFS_WANT_CORRUPTED_GOTO(i == 1, done); 4967 XFS_WANT_CORRUPTED_GOTO(i == 1, done);
@@ -5079,11 +5079,11 @@ xfs_bunmapi(
5079 XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_BTREE)) { 5079 XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_BTREE)) {
5080 XFS_ERROR_REPORT("xfs_bunmapi", XFS_ERRLEVEL_LOW, 5080 XFS_ERROR_REPORT("xfs_bunmapi", XFS_ERRLEVEL_LOW,
5081 ip->i_mount); 5081 ip->i_mount);
5082 return EFSCORRUPTED; 5082 return -EFSCORRUPTED;
5083 } 5083 }
5084 mp = ip->i_mount; 5084 mp = ip->i_mount;
5085 if (XFS_FORCED_SHUTDOWN(mp)) 5085 if (XFS_FORCED_SHUTDOWN(mp))
5086 return EIO; 5086 return -EIO;
5087 5087
5088 ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); 5088 ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL));
5089 ASSERT(len > 0); 5089 ASSERT(len > 0);
@@ -5328,7 +5328,7 @@ xfs_bunmapi(
5328 del.br_startoff > got.br_startoff && 5328 del.br_startoff > got.br_startoff &&
5329 del.br_startoff + del.br_blockcount < 5329 del.br_startoff + del.br_blockcount <
5330 got.br_startoff + got.br_blockcount) { 5330 got.br_startoff + got.br_blockcount) {
5331 error = ENOSPC; 5331 error = -ENOSPC;
5332 goto error0; 5332 goto error0;
5333 } 5333 }
5334 error = xfs_bmap_del_extent(ip, tp, &lastx, flist, cur, &del, 5334 error = xfs_bmap_del_extent(ip, tp, &lastx, flist, cur, &del,
@@ -5452,11 +5452,11 @@ xfs_bmap_shift_extents(
5452 mp, XFS_ERRTAG_BMAPIFORMAT, XFS_RANDOM_BMAPIFORMAT))) { 5452 mp, XFS_ERRTAG_BMAPIFORMAT, XFS_RANDOM_BMAPIFORMAT))) {
5453 XFS_ERROR_REPORT("xfs_bmap_shift_extents", 5453 XFS_ERROR_REPORT("xfs_bmap_shift_extents",
5454 XFS_ERRLEVEL_LOW, mp); 5454 XFS_ERRLEVEL_LOW, mp);
5455 return EFSCORRUPTED; 5455 return -EFSCORRUPTED;
5456 } 5456 }
5457 5457
5458 if (XFS_FORCED_SHUTDOWN(mp)) 5458 if (XFS_FORCED_SHUTDOWN(mp))
5459 return EIO; 5459 return -EIO;
5460 5460
5461 ASSERT(current_ext != NULL); 5461 ASSERT(current_ext != NULL);
5462 5462
@@ -5519,14 +5519,14 @@ xfs_bmap_shift_extents(
5519 *current_ext - 1), &left); 5519 *current_ext - 1), &left);
5520 5520
5521 if (startoff < left.br_startoff + left.br_blockcount) 5521 if (startoff < left.br_startoff + left.br_blockcount)
5522 error = EINVAL; 5522 error = -EINVAL;
5523 } else if (offset_shift_fsb > got.br_startoff) { 5523 } else if (offset_shift_fsb > got.br_startoff) {
5524 /* 5524 /*
5525 * When first extent is shifted, offset_shift_fsb 5525 * When first extent is shifted, offset_shift_fsb
5526 * should be less than the stating offset of 5526 * should be less than the stating offset of
5527 * the first extent. 5527 * the first extent.
5528 */ 5528 */
5529 error = EINVAL; 5529 error = -EINVAL;
5530 } 5530 }
5531 5531
5532 if (error) 5532 if (error)
diff --git a/fs/xfs/libxfs/xfs_bmap_btree.c b/fs/xfs/libxfs/xfs_bmap_btree.c
index de65bb8bab04..a388de4ceaa1 100644
--- a/fs/xfs/libxfs/xfs_bmap_btree.c
+++ b/fs/xfs/libxfs/xfs_bmap_btree.c
@@ -554,7 +554,7 @@ xfs_bmbt_alloc_block(
554 args.minlen = args.maxlen = args.prod = 1; 554 args.minlen = args.maxlen = args.prod = 1;
555 args.wasdel = cur->bc_private.b.flags & XFS_BTCUR_BPRV_WASDEL; 555 args.wasdel = cur->bc_private.b.flags & XFS_BTCUR_BPRV_WASDEL;
556 if (!args.wasdel && xfs_trans_get_block_res(args.tp) == 0) { 556 if (!args.wasdel && xfs_trans_get_block_res(args.tp) == 0) {
557 error = ENOSPC; 557 error = -ENOSPC;
558 goto error0; 558 goto error0;
559 } 559 }
560 error = xfs_alloc_vextent(&args); 560 error = xfs_alloc_vextent(&args);
@@ -779,9 +779,9 @@ xfs_bmbt_read_verify(
779 struct xfs_buf *bp) 779 struct xfs_buf *bp)
780{ 780{
781 if (!xfs_btree_lblock_verify_crc(bp)) 781 if (!xfs_btree_lblock_verify_crc(bp))
782 xfs_buf_ioerror(bp, EFSBADCRC); 782 xfs_buf_ioerror(bp, -EFSBADCRC);
783 else if (!xfs_bmbt_verify(bp)) 783 else if (!xfs_bmbt_verify(bp))
784 xfs_buf_ioerror(bp, EFSCORRUPTED); 784 xfs_buf_ioerror(bp, -EFSCORRUPTED);
785 785
786 if (bp->b_error) { 786 if (bp->b_error) {
787 trace_xfs_btree_corrupt(bp, _RET_IP_); 787 trace_xfs_btree_corrupt(bp, _RET_IP_);
@@ -795,7 +795,7 @@ xfs_bmbt_write_verify(
795{ 795{
796 if (!xfs_bmbt_verify(bp)) { 796 if (!xfs_bmbt_verify(bp)) {
797 trace_xfs_btree_corrupt(bp, _RET_IP_); 797 trace_xfs_btree_corrupt(bp, _RET_IP_);
798 xfs_buf_ioerror(bp, EFSCORRUPTED); 798 xfs_buf_ioerror(bp, -EFSCORRUPTED);
799 xfs_verifier_error(bp); 799 xfs_verifier_error(bp);
800 return; 800 return;
801 } 801 }
@@ -959,7 +959,7 @@ xfs_bmbt_change_owner(
959 959
960 cur = xfs_bmbt_init_cursor(ip->i_mount, tp, ip, whichfork); 960 cur = xfs_bmbt_init_cursor(ip->i_mount, tp, ip, whichfork);
961 if (!cur) 961 if (!cur)
962 return ENOMEM; 962 return -ENOMEM;
963 963
964 error = xfs_btree_change_owner(cur, new_owner, buffer_list); 964 error = xfs_btree_change_owner(cur, new_owner, buffer_list);
965 xfs_btree_del_cursor(cur, error ? XFS_BTREE_ERROR : XFS_BTREE_NOERROR); 965 xfs_btree_del_cursor(cur, error ? XFS_BTREE_ERROR : XFS_BTREE_NOERROR);
diff --git a/fs/xfs/libxfs/xfs_btree.c b/fs/xfs/libxfs/xfs_btree.c
index 036b4fd34bf7..0097c42f1f10 100644
--- a/fs/xfs/libxfs/xfs_btree.c
+++ b/fs/xfs/libxfs/xfs_btree.c
@@ -91,7 +91,7 @@ xfs_btree_check_lblock(
91 if (bp) 91 if (bp)
92 trace_xfs_btree_corrupt(bp, _RET_IP_); 92 trace_xfs_btree_corrupt(bp, _RET_IP_);
93 XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_LOW, mp); 93 XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_LOW, mp);
94 return EFSCORRUPTED; 94 return -EFSCORRUPTED;
95 } 95 }
96 return 0; 96 return 0;
97} 97}
@@ -139,7 +139,7 @@ xfs_btree_check_sblock(
139 if (bp) 139 if (bp)
140 trace_xfs_btree_corrupt(bp, _RET_IP_); 140 trace_xfs_btree_corrupt(bp, _RET_IP_);
141 XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_LOW, mp); 141 XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_LOW, mp);
142 return EFSCORRUPTED; 142 return -EFSCORRUPTED;
143 } 143 }
144 return 0; 144 return 0;
145} 145}
@@ -1139,7 +1139,7 @@ xfs_btree_get_buf_block(
1139 mp->m_bsize, flags); 1139 mp->m_bsize, flags);
1140 1140
1141 if (!*bpp) 1141 if (!*bpp)
1142 return ENOMEM; 1142 return -ENOMEM;
1143 1143
1144 (*bpp)->b_ops = cur->bc_ops->buf_ops; 1144 (*bpp)->b_ops = cur->bc_ops->buf_ops;
1145 *block = XFS_BUF_TO_BLOCK(*bpp); 1145 *block = XFS_BUF_TO_BLOCK(*bpp);
@@ -1497,7 +1497,7 @@ xfs_btree_increment(
1497 if (cur->bc_flags & XFS_BTREE_ROOT_IN_INODE) 1497 if (cur->bc_flags & XFS_BTREE_ROOT_IN_INODE)
1498 goto out0; 1498 goto out0;
1499 ASSERT(0); 1499 ASSERT(0);
1500 error = EFSCORRUPTED; 1500 error = -EFSCORRUPTED;
1501 goto error0; 1501 goto error0;
1502 } 1502 }
1503 ASSERT(lev < cur->bc_nlevels); 1503 ASSERT(lev < cur->bc_nlevels);
@@ -1596,7 +1596,7 @@ xfs_btree_decrement(
1596 if (cur->bc_flags & XFS_BTREE_ROOT_IN_INODE) 1596 if (cur->bc_flags & XFS_BTREE_ROOT_IN_INODE)
1597 goto out0; 1597 goto out0;
1598 ASSERT(0); 1598 ASSERT(0);
1599 error = EFSCORRUPTED; 1599 error = -EFSCORRUPTED;
1600 goto error0; 1600 goto error0;
1601 } 1601 }
1602 ASSERT(lev < cur->bc_nlevels); 1602 ASSERT(lev < cur->bc_nlevels);
@@ -3938,7 +3938,7 @@ xfs_btree_block_change_owner(
3938 /* now read rh sibling block for next iteration */ 3938 /* now read rh sibling block for next iteration */
3939 xfs_btree_get_sibling(cur, block, &rptr, XFS_BB_RIGHTSIB); 3939 xfs_btree_get_sibling(cur, block, &rptr, XFS_BB_RIGHTSIB);
3940 if (xfs_btree_ptr_is_null(cur, &rptr)) 3940 if (xfs_btree_ptr_is_null(cur, &rptr))
3941 return ENOENT; 3941 return -ENOENT;
3942 3942
3943 return xfs_btree_lookup_get_block(cur, level, &rptr, &block); 3943 return xfs_btree_lookup_get_block(cur, level, &rptr, &block);
3944} 3944}
@@ -3981,7 +3981,7 @@ xfs_btree_change_owner(
3981 buffer_list); 3981 buffer_list);
3982 } while (!error); 3982 } while (!error);
3983 3983
3984 if (error != ENOENT) 3984 if (error != -ENOENT)
3985 return error; 3985 return error;
3986 } 3986 }
3987 3987
diff --git a/fs/xfs/libxfs/xfs_da_btree.c b/fs/xfs/libxfs/xfs_da_btree.c
index a1a4e3e47a1e..8d809873525b 100644
--- a/fs/xfs/libxfs/xfs_da_btree.c
+++ b/fs/xfs/libxfs/xfs_da_btree.c
@@ -185,7 +185,7 @@ xfs_da3_node_write_verify(
185 struct xfs_da3_node_hdr *hdr3 = bp->b_addr; 185 struct xfs_da3_node_hdr *hdr3 = bp->b_addr;
186 186
187 if (!xfs_da3_node_verify(bp)) { 187 if (!xfs_da3_node_verify(bp)) {
188 xfs_buf_ioerror(bp, EFSCORRUPTED); 188 xfs_buf_ioerror(bp, -EFSCORRUPTED);
189 xfs_verifier_error(bp); 189 xfs_verifier_error(bp);
190 return; 190 return;
191 } 191 }
@@ -214,13 +214,13 @@ xfs_da3_node_read_verify(
214 switch (be16_to_cpu(info->magic)) { 214 switch (be16_to_cpu(info->magic)) {
215 case XFS_DA3_NODE_MAGIC: 215 case XFS_DA3_NODE_MAGIC:
216 if (!xfs_buf_verify_cksum(bp, XFS_DA3_NODE_CRC_OFF)) { 216 if (!xfs_buf_verify_cksum(bp, XFS_DA3_NODE_CRC_OFF)) {
217 xfs_buf_ioerror(bp, EFSBADCRC); 217 xfs_buf_ioerror(bp, -EFSBADCRC);
218 break; 218 break;
219 } 219 }
220 /* fall through */ 220 /* fall through */
221 case XFS_DA_NODE_MAGIC: 221 case XFS_DA_NODE_MAGIC:
222 if (!xfs_da3_node_verify(bp)) { 222 if (!xfs_da3_node_verify(bp)) {
223 xfs_buf_ioerror(bp, EFSCORRUPTED); 223 xfs_buf_ioerror(bp, -EFSCORRUPTED);
224 break; 224 break;
225 } 225 }
226 return; 226 return;
@@ -385,7 +385,7 @@ xfs_da3_split(
385 switch (oldblk->magic) { 385 switch (oldblk->magic) {
386 case XFS_ATTR_LEAF_MAGIC: 386 case XFS_ATTR_LEAF_MAGIC:
387 error = xfs_attr3_leaf_split(state, oldblk, newblk); 387 error = xfs_attr3_leaf_split(state, oldblk, newblk);
388 if ((error != 0) && (error != ENOSPC)) { 388 if ((error != 0) && (error != -ENOSPC)) {
389 return error; /* GROT: attr is inconsistent */ 389 return error; /* GROT: attr is inconsistent */
390 } 390 }
391 if (!error) { 391 if (!error) {
@@ -1579,9 +1579,9 @@ xfs_da3_node_lookup_int(
1579 args->blkno = blk->blkno; 1579 args->blkno = blk->blkno;
1580 } else { 1580 } else {
1581 ASSERT(0); 1581 ASSERT(0);
1582 return EFSCORRUPTED; 1582 return -EFSCORRUPTED;
1583 } 1583 }
1584 if (((retval == ENOENT) || (retval == ENOATTR)) && 1584 if (((retval == -ENOENT) || (retval == -ENOATTR)) &&
1585 (blk->hashval == args->hashval)) { 1585 (blk->hashval == args->hashval)) {
1586 error = xfs_da3_path_shift(state, &state->path, 1, 1, 1586 error = xfs_da3_path_shift(state, &state->path, 1, 1,
1587 &retval); 1587 &retval);
@@ -1591,7 +1591,7 @@ xfs_da3_node_lookup_int(
1591 continue; 1591 continue;
1592 } else if (blk->magic == XFS_ATTR_LEAF_MAGIC) { 1592 } else if (blk->magic == XFS_ATTR_LEAF_MAGIC) {
1593 /* path_shift() gives ENOENT */ 1593 /* path_shift() gives ENOENT */
1594 retval = ENOATTR; 1594 retval = -ENOATTR;
1595 } 1595 }
1596 } 1596 }
1597 break; 1597 break;
@@ -1859,7 +1859,7 @@ xfs_da3_path_shift(
1859 } 1859 }
1860 } 1860 }
1861 if (level < 0) { 1861 if (level < 0) {
1862 *result = ENOENT; /* we're out of our tree */ 1862 *result = -ENOENT; /* we're out of our tree */
1863 ASSERT(args->op_flags & XFS_DA_OP_OKNOENT); 1863 ASSERT(args->op_flags & XFS_DA_OP_OKNOENT);
1864 return 0; 1864 return 0;
1865 } 1865 }
@@ -2068,7 +2068,7 @@ xfs_da_grow_inode_int(
2068 if (got != count || mapp[0].br_startoff != *bno || 2068 if (got != count || mapp[0].br_startoff != *bno ||
2069 mapp[mapi - 1].br_startoff + mapp[mapi - 1].br_blockcount != 2069 mapp[mapi - 1].br_startoff + mapp[mapi - 1].br_blockcount !=
2070 *bno + count) { 2070 *bno + count) {
2071 error = ENOSPC; 2071 error = -ENOSPC;
2072 goto out_free_map; 2072 goto out_free_map;
2073 } 2073 }
2074 2074
@@ -2158,7 +2158,7 @@ xfs_da3_swap_lastblock(
2158 if (unlikely(lastoff == 0)) { 2158 if (unlikely(lastoff == 0)) {
2159 XFS_ERROR_REPORT("xfs_da_swap_lastblock(1)", XFS_ERRLEVEL_LOW, 2159 XFS_ERROR_REPORT("xfs_da_swap_lastblock(1)", XFS_ERRLEVEL_LOW,
2160 mp); 2160 mp);
2161 return EFSCORRUPTED; 2161 return -EFSCORRUPTED;
2162 } 2162 }
2163 /* 2163 /*
2164 * Read the last block in the btree space. 2164 * Read the last block in the btree space.
@@ -2209,7 +2209,7 @@ xfs_da3_swap_lastblock(
2209 sib_info->magic != dead_info->magic)) { 2209 sib_info->magic != dead_info->magic)) {
2210 XFS_ERROR_REPORT("xfs_da_swap_lastblock(2)", 2210 XFS_ERROR_REPORT("xfs_da_swap_lastblock(2)",
2211 XFS_ERRLEVEL_LOW, mp); 2211 XFS_ERRLEVEL_LOW, mp);
2212 error = EFSCORRUPTED; 2212 error = -EFSCORRUPTED;
2213 goto done; 2213 goto done;
2214 } 2214 }
2215 sib_info->forw = cpu_to_be32(dead_blkno); 2215 sib_info->forw = cpu_to_be32(dead_blkno);
@@ -2231,7 +2231,7 @@ xfs_da3_swap_lastblock(
2231 sib_info->magic != dead_info->magic)) { 2231 sib_info->magic != dead_info->magic)) {
2232 XFS_ERROR_REPORT("xfs_da_swap_lastblock(3)", 2232 XFS_ERROR_REPORT("xfs_da_swap_lastblock(3)",
2233 XFS_ERRLEVEL_LOW, mp); 2233 XFS_ERRLEVEL_LOW, mp);
2234 error = EFSCORRUPTED; 2234 error = -EFSCORRUPTED;
2235 goto done; 2235 goto done;
2236 } 2236 }
2237 sib_info->back = cpu_to_be32(dead_blkno); 2237 sib_info->back = cpu_to_be32(dead_blkno);
@@ -2254,7 +2254,7 @@ xfs_da3_swap_lastblock(
2254 if (level >= 0 && level != par_hdr.level + 1) { 2254 if (level >= 0 && level != par_hdr.level + 1) {
2255 XFS_ERROR_REPORT("xfs_da_swap_lastblock(4)", 2255 XFS_ERROR_REPORT("xfs_da_swap_lastblock(4)",
2256 XFS_ERRLEVEL_LOW, mp); 2256 XFS_ERRLEVEL_LOW, mp);
2257 error = EFSCORRUPTED; 2257 error = -EFSCORRUPTED;
2258 goto done; 2258 goto done;
2259 } 2259 }
2260 level = par_hdr.level; 2260 level = par_hdr.level;
@@ -2267,7 +2267,7 @@ xfs_da3_swap_lastblock(
2267 if (entno == par_hdr.count) { 2267 if (entno == par_hdr.count) {
2268 XFS_ERROR_REPORT("xfs_da_swap_lastblock(5)", 2268 XFS_ERROR_REPORT("xfs_da_swap_lastblock(5)",
2269 XFS_ERRLEVEL_LOW, mp); 2269 XFS_ERRLEVEL_LOW, mp);
2270 error = EFSCORRUPTED; 2270 error = -EFSCORRUPTED;
2271 goto done; 2271 goto done;
2272 } 2272 }
2273 par_blkno = be32_to_cpu(btree[entno].before); 2273 par_blkno = be32_to_cpu(btree[entno].before);
@@ -2294,7 +2294,7 @@ xfs_da3_swap_lastblock(
2294 if (unlikely(par_blkno == 0)) { 2294 if (unlikely(par_blkno == 0)) {
2295 XFS_ERROR_REPORT("xfs_da_swap_lastblock(6)", 2295 XFS_ERROR_REPORT("xfs_da_swap_lastblock(6)",
2296 XFS_ERRLEVEL_LOW, mp); 2296 XFS_ERRLEVEL_LOW, mp);
2297 error = EFSCORRUPTED; 2297 error = -EFSCORRUPTED;
2298 goto done; 2298 goto done;
2299 } 2299 }
2300 error = xfs_da3_node_read(tp, dp, par_blkno, -1, &par_buf, w); 2300 error = xfs_da3_node_read(tp, dp, par_blkno, -1, &par_buf, w);
@@ -2305,7 +2305,7 @@ xfs_da3_swap_lastblock(
2305 if (par_hdr.level != level) { 2305 if (par_hdr.level != level) {
2306 XFS_ERROR_REPORT("xfs_da_swap_lastblock(7)", 2306 XFS_ERROR_REPORT("xfs_da_swap_lastblock(7)",
2307 XFS_ERRLEVEL_LOW, mp); 2307 XFS_ERRLEVEL_LOW, mp);
2308 error = EFSCORRUPTED; 2308 error = -EFSCORRUPTED;
2309 goto done; 2309 goto done;
2310 } 2310 }
2311 btree = dp->d_ops->node_tree_p(par_node); 2311 btree = dp->d_ops->node_tree_p(par_node);
@@ -2359,7 +2359,7 @@ xfs_da_shrink_inode(
2359 error = xfs_bunmapi(tp, dp, dead_blkno, count, 2359 error = xfs_bunmapi(tp, dp, dead_blkno, count,
2360 xfs_bmapi_aflag(w)|XFS_BMAPI_METADATA, 2360 xfs_bmapi_aflag(w)|XFS_BMAPI_METADATA,
2361 0, args->firstblock, args->flist, &done); 2361 0, args->firstblock, args->flist, &done);
2362 if (error == ENOSPC) { 2362 if (error == -ENOSPC) {
2363 if (w != XFS_DATA_FORK) 2363 if (w != XFS_DATA_FORK)
2364 break; 2364 break;
2365 error = xfs_da3_swap_lastblock(args, &dead_blkno, 2365 error = xfs_da3_swap_lastblock(args, &dead_blkno,
@@ -2427,7 +2427,7 @@ xfs_buf_map_from_irec(
2427 map = kmem_zalloc(nirecs * sizeof(struct xfs_buf_map), 2427 map = kmem_zalloc(nirecs * sizeof(struct xfs_buf_map),
2428 KM_SLEEP | KM_NOFS); 2428 KM_SLEEP | KM_NOFS);
2429 if (!map) 2429 if (!map)
2430 return ENOMEM; 2430 return -ENOMEM;
2431 *mapp = map; 2431 *mapp = map;
2432 } 2432 }
2433 2433
@@ -2500,8 +2500,8 @@ xfs_dabuf_map(
2500 } 2500 }
2501 2501
2502 if (!xfs_da_map_covers_blocks(nirecs, irecs, bno, nfsb)) { 2502 if (!xfs_da_map_covers_blocks(nirecs, irecs, bno, nfsb)) {
2503 error = mappedbno == -2 ? -1 : EFSCORRUPTED; 2503 error = mappedbno == -2 ? -1 : -EFSCORRUPTED;
2504 if (unlikely(error == EFSCORRUPTED)) { 2504 if (unlikely(error == -EFSCORRUPTED)) {
2505 if (xfs_error_level >= XFS_ERRLEVEL_LOW) { 2505 if (xfs_error_level >= XFS_ERRLEVEL_LOW) {
2506 int i; 2506 int i;
2507 xfs_alert(mp, "%s: bno %lld dir: inode %lld", 2507 xfs_alert(mp, "%s: bno %lld dir: inode %lld",
@@ -2561,7 +2561,7 @@ xfs_da_get_buf(
2561 2561
2562 bp = xfs_trans_get_buf_map(trans, dp->i_mount->m_ddev_targp, 2562 bp = xfs_trans_get_buf_map(trans, dp->i_mount->m_ddev_targp,
2563 mapp, nmap, 0); 2563 mapp, nmap, 0);
2564 error = bp ? bp->b_error : EIO; 2564 error = bp ? bp->b_error : -EIO;
2565 if (error) { 2565 if (error) {
2566 xfs_trans_brelse(trans, bp); 2566 xfs_trans_brelse(trans, bp);
2567 goto out_free; 2567 goto out_free;
diff --git a/fs/xfs/libxfs/xfs_dir2.c b/fs/xfs/libxfs/xfs_dir2.c
index a0aca734199b..6cef22152fd6 100644
--- a/fs/xfs/libxfs/xfs_dir2.c
+++ b/fs/xfs/libxfs/xfs_dir2.c
@@ -108,7 +108,7 @@ xfs_da_mount(
108 if (!mp->m_dir_geo || !mp->m_attr_geo) { 108 if (!mp->m_dir_geo || !mp->m_attr_geo) {
109 kmem_free(mp->m_dir_geo); 109 kmem_free(mp->m_dir_geo);
110 kmem_free(mp->m_attr_geo); 110 kmem_free(mp->m_attr_geo);
111 return ENOMEM; 111 return -ENOMEM;
112 } 112 }
113 113
114 /* set up directory geometry */ 114 /* set up directory geometry */
@@ -202,7 +202,7 @@ xfs_dir_ino_validate(
202 xfs_warn(mp, "Invalid inode number 0x%Lx", 202 xfs_warn(mp, "Invalid inode number 0x%Lx",
203 (unsigned long long) ino); 203 (unsigned long long) ino);
204 XFS_ERROR_REPORT("xfs_dir_ino_validate", XFS_ERRLEVEL_LOW, mp); 204 XFS_ERROR_REPORT("xfs_dir_ino_validate", XFS_ERRLEVEL_LOW, mp);
205 return EFSCORRUPTED; 205 return -EFSCORRUPTED;
206 } 206 }
207 return 0; 207 return 0;
208} 208}
@@ -226,7 +226,7 @@ xfs_dir_init(
226 226
227 args = kmem_zalloc(sizeof(*args), KM_SLEEP | KM_NOFS); 227 args = kmem_zalloc(sizeof(*args), KM_SLEEP | KM_NOFS);
228 if (!args) 228 if (!args)
229 return ENOMEM; 229 return -ENOMEM;
230 230
231 args->geo = dp->i_mount->m_dir_geo; 231 args->geo = dp->i_mount->m_dir_geo;
232 args->dp = dp; 232 args->dp = dp;
@@ -261,7 +261,7 @@ xfs_dir_createname(
261 261
262 args = kmem_zalloc(sizeof(*args), KM_SLEEP | KM_NOFS); 262 args = kmem_zalloc(sizeof(*args), KM_SLEEP | KM_NOFS);
263 if (!args) 263 if (!args)
264 return ENOMEM; 264 return -ENOMEM;
265 265
266 args->geo = dp->i_mount->m_dir_geo; 266 args->geo = dp->i_mount->m_dir_geo;
267 args->name = name->name; 267 args->name = name->name;
@@ -314,18 +314,18 @@ xfs_dir_cilookup_result(
314 int len) 314 int len)
315{ 315{
316 if (args->cmpresult == XFS_CMP_DIFFERENT) 316 if (args->cmpresult == XFS_CMP_DIFFERENT)
317 return ENOENT; 317 return -ENOENT;
318 if (args->cmpresult != XFS_CMP_CASE || 318 if (args->cmpresult != XFS_CMP_CASE ||
319 !(args->op_flags & XFS_DA_OP_CILOOKUP)) 319 !(args->op_flags & XFS_DA_OP_CILOOKUP))
320 return EEXIST; 320 return -EEXIST;
321 321
322 args->value = kmem_alloc(len, KM_NOFS | KM_MAYFAIL); 322 args->value = kmem_alloc(len, KM_NOFS | KM_MAYFAIL);
323 if (!args->value) 323 if (!args->value)
324 return ENOMEM; 324 return -ENOMEM;
325 325
326 memcpy(args->value, name, len); 326 memcpy(args->value, name, len);
327 args->valuelen = len; 327 args->valuelen = len;
328 return EEXIST; 328 return -EEXIST;
329} 329}
330 330
331/* 331/*
@@ -392,7 +392,7 @@ xfs_dir_lookup(
392 rval = xfs_dir2_node_lookup(args); 392 rval = xfs_dir2_node_lookup(args);
393 393
394out_check_rval: 394out_check_rval:
395 if (rval == EEXIST) 395 if (rval == -EEXIST)
396 rval = 0; 396 rval = 0;
397 if (!rval) { 397 if (!rval) {
398 *inum = args->inumber; 398 *inum = args->inumber;
@@ -428,7 +428,7 @@ xfs_dir_removename(
428 428
429 args = kmem_zalloc(sizeof(*args), KM_SLEEP | KM_NOFS); 429 args = kmem_zalloc(sizeof(*args), KM_SLEEP | KM_NOFS);
430 if (!args) 430 if (!args)
431 return ENOMEM; 431 return -ENOMEM;
432 432
433 args->geo = dp->i_mount->m_dir_geo; 433 args->geo = dp->i_mount->m_dir_geo;
434 args->name = name->name; 434 args->name = name->name;
@@ -493,7 +493,7 @@ xfs_dir_replace(
493 493
494 args = kmem_zalloc(sizeof(*args), KM_SLEEP | KM_NOFS); 494 args = kmem_zalloc(sizeof(*args), KM_SLEEP | KM_NOFS);
495 if (!args) 495 if (!args)
496 return ENOMEM; 496 return -ENOMEM;
497 497
498 args->geo = dp->i_mount->m_dir_geo; 498 args->geo = dp->i_mount->m_dir_geo;
499 args->name = name->name; 499 args->name = name->name;
@@ -555,7 +555,7 @@ xfs_dir_canenter(
555 555
556 args = kmem_zalloc(sizeof(*args), KM_SLEEP | KM_NOFS); 556 args = kmem_zalloc(sizeof(*args), KM_SLEEP | KM_NOFS);
557 if (!args) 557 if (!args)
558 return ENOMEM; 558 return -ENOMEM;
559 559
560 args->geo = dp->i_mount->m_dir_geo; 560 args->geo = dp->i_mount->m_dir_geo;
561 args->name = name->name; 561 args->name = name->name;
diff --git a/fs/xfs/libxfs/xfs_dir2_block.c b/fs/xfs/libxfs/xfs_dir2_block.c
index ab0bffccf5c3..9628ceccfa02 100644
--- a/fs/xfs/libxfs/xfs_dir2_block.c
+++ b/fs/xfs/libxfs/xfs_dir2_block.c
@@ -91,9 +91,9 @@ xfs_dir3_block_read_verify(
91 91
92 if (xfs_sb_version_hascrc(&mp->m_sb) && 92 if (xfs_sb_version_hascrc(&mp->m_sb) &&
93 !xfs_buf_verify_cksum(bp, XFS_DIR3_DATA_CRC_OFF)) 93 !xfs_buf_verify_cksum(bp, XFS_DIR3_DATA_CRC_OFF))
94 xfs_buf_ioerror(bp, EFSBADCRC); 94 xfs_buf_ioerror(bp, -EFSBADCRC);
95 else if (!xfs_dir3_block_verify(bp)) 95 else if (!xfs_dir3_block_verify(bp))
96 xfs_buf_ioerror(bp, EFSCORRUPTED); 96 xfs_buf_ioerror(bp, -EFSCORRUPTED);
97 97
98 if (bp->b_error) 98 if (bp->b_error)
99 xfs_verifier_error(bp); 99 xfs_verifier_error(bp);
@@ -108,7 +108,7 @@ xfs_dir3_block_write_verify(
108 struct xfs_dir3_blk_hdr *hdr3 = bp->b_addr; 108 struct xfs_dir3_blk_hdr *hdr3 = bp->b_addr;
109 109
110 if (!xfs_dir3_block_verify(bp)) { 110 if (!xfs_dir3_block_verify(bp)) {
111 xfs_buf_ioerror(bp, EFSCORRUPTED); 111 xfs_buf_ioerror(bp, -EFSCORRUPTED);
112 xfs_verifier_error(bp); 112 xfs_verifier_error(bp);
113 return; 113 return;
114 } 114 }
@@ -392,7 +392,7 @@ xfs_dir2_block_addname(
392 if (args->op_flags & XFS_DA_OP_JUSTCHECK) { 392 if (args->op_flags & XFS_DA_OP_JUSTCHECK) {
393 xfs_trans_brelse(tp, bp); 393 xfs_trans_brelse(tp, bp);
394 if (!dup) 394 if (!dup)
395 return ENOSPC; 395 return -ENOSPC;
396 return 0; 396 return 0;
397 } 397 }
398 398
@@ -402,7 +402,7 @@ xfs_dir2_block_addname(
402 if (!dup) { 402 if (!dup) {
403 /* Don't have a space reservation: return no-space. */ 403 /* Don't have a space reservation: return no-space. */
404 if (args->total == 0) 404 if (args->total == 0)
405 return ENOSPC; 405 return -ENOSPC;
406 /* 406 /*
407 * Convert to the next larger format. 407 * Convert to the next larger format.
408 * Then add the new entry in that format. 408 * Then add the new entry in that format.
@@ -703,7 +703,7 @@ xfs_dir2_block_lookup_int(
703 if (low > high) { 703 if (low > high) {
704 ASSERT(args->op_flags & XFS_DA_OP_OKNOENT); 704 ASSERT(args->op_flags & XFS_DA_OP_OKNOENT);
705 xfs_trans_brelse(tp, bp); 705 xfs_trans_brelse(tp, bp);
706 return ENOENT; 706 return -ENOENT;
707 } 707 }
708 } 708 }
709 /* 709 /*
@@ -751,7 +751,7 @@ xfs_dir2_block_lookup_int(
751 * No match, release the buffer and return ENOENT. 751 * No match, release the buffer and return ENOENT.
752 */ 752 */
753 xfs_trans_brelse(tp, bp); 753 xfs_trans_brelse(tp, bp);
754 return ENOENT; 754 return -ENOENT;
755} 755}
756 756
757/* 757/*
@@ -1091,7 +1091,7 @@ xfs_dir2_sf_to_block(
1091 */ 1091 */
1092 if (dp->i_d.di_size < offsetof(xfs_dir2_sf_hdr_t, parent)) { 1092 if (dp->i_d.di_size < offsetof(xfs_dir2_sf_hdr_t, parent)) {
1093 ASSERT(XFS_FORCED_SHUTDOWN(mp)); 1093 ASSERT(XFS_FORCED_SHUTDOWN(mp));
1094 return EIO; 1094 return -EIO;
1095 } 1095 }
1096 1096
1097 oldsfp = (xfs_dir2_sf_hdr_t *)ifp->if_u1.if_data; 1097 oldsfp = (xfs_dir2_sf_hdr_t *)ifp->if_u1.if_data;
diff --git a/fs/xfs/libxfs/xfs_dir2_data.c b/fs/xfs/libxfs/xfs_dir2_data.c
index 8c2f6422648e..fdd803fecb8e 100644
--- a/fs/xfs/libxfs/xfs_dir2_data.c
+++ b/fs/xfs/libxfs/xfs_dir2_data.c
@@ -100,7 +100,7 @@ __xfs_dir3_data_check(
100 break; 100 break;
101 default: 101 default:
102 XFS_ERROR_REPORT("Bad Magic", XFS_ERRLEVEL_LOW, mp); 102 XFS_ERROR_REPORT("Bad Magic", XFS_ERRLEVEL_LOW, mp);
103 return EFSCORRUPTED; 103 return -EFSCORRUPTED;
104 } 104 }
105 105
106 /* 106 /*
@@ -256,7 +256,7 @@ xfs_dir3_data_reada_verify(
256 xfs_dir3_data_verify(bp); 256 xfs_dir3_data_verify(bp);
257 return; 257 return;
258 default: 258 default:
259 xfs_buf_ioerror(bp, EFSCORRUPTED); 259 xfs_buf_ioerror(bp, -EFSCORRUPTED);
260 xfs_verifier_error(bp); 260 xfs_verifier_error(bp);
261 break; 261 break;
262 } 262 }
@@ -270,9 +270,9 @@ xfs_dir3_data_read_verify(
270 270
271 if (xfs_sb_version_hascrc(&mp->m_sb) && 271 if (xfs_sb_version_hascrc(&mp->m_sb) &&
272 !xfs_buf_verify_cksum(bp, XFS_DIR3_DATA_CRC_OFF)) 272 !xfs_buf_verify_cksum(bp, XFS_DIR3_DATA_CRC_OFF))
273 xfs_buf_ioerror(bp, EFSBADCRC); 273 xfs_buf_ioerror(bp, -EFSBADCRC);
274 else if (!xfs_dir3_data_verify(bp)) 274 else if (!xfs_dir3_data_verify(bp))
275 xfs_buf_ioerror(bp, EFSCORRUPTED); 275 xfs_buf_ioerror(bp, -EFSCORRUPTED);
276 276
277 if (bp->b_error) 277 if (bp->b_error)
278 xfs_verifier_error(bp); 278 xfs_verifier_error(bp);
@@ -287,7 +287,7 @@ xfs_dir3_data_write_verify(
287 struct xfs_dir3_blk_hdr *hdr3 = bp->b_addr; 287 struct xfs_dir3_blk_hdr *hdr3 = bp->b_addr;
288 288
289 if (!xfs_dir3_data_verify(bp)) { 289 if (!xfs_dir3_data_verify(bp)) {
290 xfs_buf_ioerror(bp, EFSCORRUPTED); 290 xfs_buf_ioerror(bp, -EFSCORRUPTED);
291 xfs_verifier_error(bp); 291 xfs_verifier_error(bp);
292 return; 292 return;
293 } 293 }
diff --git a/fs/xfs/libxfs/xfs_dir2_leaf.c b/fs/xfs/libxfs/xfs_dir2_leaf.c
index 78b411bfc543..a19174eb3cb2 100644
--- a/fs/xfs/libxfs/xfs_dir2_leaf.c
+++ b/fs/xfs/libxfs/xfs_dir2_leaf.c
@@ -183,9 +183,9 @@ __read_verify(
183 183
184 if (xfs_sb_version_hascrc(&mp->m_sb) && 184 if (xfs_sb_version_hascrc(&mp->m_sb) &&
185 !xfs_buf_verify_cksum(bp, XFS_DIR3_LEAF_CRC_OFF)) 185 !xfs_buf_verify_cksum(bp, XFS_DIR3_LEAF_CRC_OFF))
186 xfs_buf_ioerror(bp, EFSBADCRC); 186 xfs_buf_ioerror(bp, -EFSBADCRC);
187 else if (!xfs_dir3_leaf_verify(bp, magic)) 187 else if (!xfs_dir3_leaf_verify(bp, magic))
188 xfs_buf_ioerror(bp, EFSCORRUPTED); 188 xfs_buf_ioerror(bp, -EFSCORRUPTED);
189 189
190 if (bp->b_error) 190 if (bp->b_error)
191 xfs_verifier_error(bp); 191 xfs_verifier_error(bp);
@@ -201,7 +201,7 @@ __write_verify(
201 struct xfs_dir3_leaf_hdr *hdr3 = bp->b_addr; 201 struct xfs_dir3_leaf_hdr *hdr3 = bp->b_addr;
202 202
203 if (!xfs_dir3_leaf_verify(bp, magic)) { 203 if (!xfs_dir3_leaf_verify(bp, magic)) {
204 xfs_buf_ioerror(bp, EFSCORRUPTED); 204 xfs_buf_ioerror(bp, -EFSCORRUPTED);
205 xfs_verifier_error(bp); 205 xfs_verifier_error(bp);
206 return; 206 return;
207 } 207 }
@@ -731,7 +731,7 @@ xfs_dir2_leaf_addname(
731 if ((args->op_flags & XFS_DA_OP_JUSTCHECK) || 731 if ((args->op_flags & XFS_DA_OP_JUSTCHECK) ||
732 args->total == 0) { 732 args->total == 0) {
733 xfs_trans_brelse(tp, lbp); 733 xfs_trans_brelse(tp, lbp);
734 return ENOSPC; 734 return -ENOSPC;
735 } 735 }
736 /* 736 /*
737 * Convert to node form. 737 * Convert to node form.
@@ -755,7 +755,7 @@ xfs_dir2_leaf_addname(
755 */ 755 */
756 if (args->op_flags & XFS_DA_OP_JUSTCHECK) { 756 if (args->op_flags & XFS_DA_OP_JUSTCHECK) {
757 xfs_trans_brelse(tp, lbp); 757 xfs_trans_brelse(tp, lbp);
758 return use_block == -1 ? ENOSPC : 0; 758 return use_block == -1 ? -ENOSPC : 0;
759 } 759 }
760 /* 760 /*
761 * If no allocations are allowed, return now before we've 761 * If no allocations are allowed, return now before we've
@@ -763,7 +763,7 @@ xfs_dir2_leaf_addname(
763 */ 763 */
764 if (args->total == 0 && use_block == -1) { 764 if (args->total == 0 && use_block == -1) {
765 xfs_trans_brelse(tp, lbp); 765 xfs_trans_brelse(tp, lbp);
766 return ENOSPC; 766 return -ENOSPC;
767 } 767 }
768 /* 768 /*
769 * Need to compact the leaf entries, removing stale ones. 769 * Need to compact the leaf entries, removing stale ones.
@@ -1327,13 +1327,13 @@ xfs_dir2_leaf_lookup_int(
1327 return 0; 1327 return 0;
1328 } 1328 }
1329 /* 1329 /*
1330 * No match found, return ENOENT. 1330 * No match found, return -ENOENT.
1331 */ 1331 */
1332 ASSERT(cidb == -1); 1332 ASSERT(cidb == -1);
1333 if (dbp) 1333 if (dbp)
1334 xfs_trans_brelse(tp, dbp); 1334 xfs_trans_brelse(tp, dbp);
1335 xfs_trans_brelse(tp, lbp); 1335 xfs_trans_brelse(tp, lbp);
1336 return ENOENT; 1336 return -ENOENT;
1337} 1337}
1338 1338
1339/* 1339/*
@@ -1440,7 +1440,7 @@ xfs_dir2_leaf_removename(
1440 * Just go on, returning success, leaving the 1440 * Just go on, returning success, leaving the
1441 * empty block in place. 1441 * empty block in place.
1442 */ 1442 */
1443 if (error == ENOSPC && args->total == 0) 1443 if (error == -ENOSPC && args->total == 0)
1444 error = 0; 1444 error = 0;
1445 xfs_dir3_leaf_check(dp, lbp); 1445 xfs_dir3_leaf_check(dp, lbp);
1446 return error; 1446 return error;
@@ -1641,7 +1641,7 @@ xfs_dir2_leaf_trim_data(
1641 * Get rid of the data block. 1641 * Get rid of the data block.
1642 */ 1642 */
1643 if ((error = xfs_dir2_shrink_inode(args, db, dbp))) { 1643 if ((error = xfs_dir2_shrink_inode(args, db, dbp))) {
1644 ASSERT(error != ENOSPC); 1644 ASSERT(error != -ENOSPC);
1645 xfs_trans_brelse(tp, dbp); 1645 xfs_trans_brelse(tp, dbp);
1646 return error; 1646 return error;
1647 } 1647 }
@@ -1815,7 +1815,7 @@ xfs_dir2_node_to_leaf(
1815 * punching out the middle of an extent, and this is an 1815 * punching out the middle of an extent, and this is an
1816 * isolated block. 1816 * isolated block.
1817 */ 1817 */
1818 ASSERT(error != ENOSPC); 1818 ASSERT(error != -ENOSPC);
1819 return error; 1819 return error;
1820 } 1820 }
1821 fbp = NULL; 1821 fbp = NULL;
diff --git a/fs/xfs/libxfs/xfs_dir2_node.c b/fs/xfs/libxfs/xfs_dir2_node.c
index 4cf8b99d09a4..2ae6ac2c11ae 100644
--- a/fs/xfs/libxfs/xfs_dir2_node.c
+++ b/fs/xfs/libxfs/xfs_dir2_node.c
@@ -117,9 +117,9 @@ xfs_dir3_free_read_verify(
117 117
118 if (xfs_sb_version_hascrc(&mp->m_sb) && 118 if (xfs_sb_version_hascrc(&mp->m_sb) &&
119 !xfs_buf_verify_cksum(bp, XFS_DIR3_FREE_CRC_OFF)) 119 !xfs_buf_verify_cksum(bp, XFS_DIR3_FREE_CRC_OFF))
120 xfs_buf_ioerror(bp, EFSBADCRC); 120 xfs_buf_ioerror(bp, -EFSBADCRC);
121 else if (!xfs_dir3_free_verify(bp)) 121 else if (!xfs_dir3_free_verify(bp))
122 xfs_buf_ioerror(bp, EFSCORRUPTED); 122 xfs_buf_ioerror(bp, -EFSCORRUPTED);
123 123
124 if (bp->b_error) 124 if (bp->b_error)
125 xfs_verifier_error(bp); 125 xfs_verifier_error(bp);
@@ -134,7 +134,7 @@ xfs_dir3_free_write_verify(
134 struct xfs_dir3_blk_hdr *hdr3 = bp->b_addr; 134 struct xfs_dir3_blk_hdr *hdr3 = bp->b_addr;
135 135
136 if (!xfs_dir3_free_verify(bp)) { 136 if (!xfs_dir3_free_verify(bp)) {
137 xfs_buf_ioerror(bp, EFSCORRUPTED); 137 xfs_buf_ioerror(bp, -EFSCORRUPTED);
138 xfs_verifier_error(bp); 138 xfs_verifier_error(bp);
139 return; 139 return;
140 } 140 }
@@ -406,7 +406,7 @@ xfs_dir2_leafn_add(
406 * into other peoples memory 406 * into other peoples memory
407 */ 407 */
408 if (index < 0) 408 if (index < 0)
409 return EFSCORRUPTED; 409 return -EFSCORRUPTED;
410 410
411 /* 411 /*
412 * If there are already the maximum number of leaf entries in 412 * If there are already the maximum number of leaf entries in
@@ -417,7 +417,7 @@ xfs_dir2_leafn_add(
417 417
418 if (leafhdr.count == dp->d_ops->leaf_max_ents(args->geo)) { 418 if (leafhdr.count == dp->d_ops->leaf_max_ents(args->geo)) {
419 if (!leafhdr.stale) 419 if (!leafhdr.stale)
420 return ENOSPC; 420 return -ENOSPC;
421 compact = leafhdr.stale > 1; 421 compact = leafhdr.stale > 1;
422 } else 422 } else
423 compact = 0; 423 compact = 0;
@@ -629,7 +629,7 @@ xfs_dir2_leafn_lookup_for_addname(
629 XFS_ERRLEVEL_LOW, mp); 629 XFS_ERRLEVEL_LOW, mp);
630 if (curfdb != newfdb) 630 if (curfdb != newfdb)
631 xfs_trans_brelse(tp, curbp); 631 xfs_trans_brelse(tp, curbp);
632 return EFSCORRUPTED; 632 return -EFSCORRUPTED;
633 } 633 }
634 curfdb = newfdb; 634 curfdb = newfdb;
635 if (be16_to_cpu(bests[fi]) >= length) 635 if (be16_to_cpu(bests[fi]) >= length)
@@ -660,7 +660,7 @@ out:
660 * Return the index, that will be the insertion point. 660 * Return the index, that will be the insertion point.
661 */ 661 */
662 *indexp = index; 662 *indexp = index;
663 return ENOENT; 663 return -ENOENT;
664} 664}
665 665
666/* 666/*
@@ -789,7 +789,7 @@ xfs_dir2_leafn_lookup_for_entry(
789 curbp->b_ops = &xfs_dir3_data_buf_ops; 789 curbp->b_ops = &xfs_dir3_data_buf_ops;
790 xfs_trans_buf_set_type(tp, curbp, XFS_BLFT_DIR_DATA_BUF); 790 xfs_trans_buf_set_type(tp, curbp, XFS_BLFT_DIR_DATA_BUF);
791 if (cmp == XFS_CMP_EXACT) 791 if (cmp == XFS_CMP_EXACT)
792 return EEXIST; 792 return -EEXIST;
793 } 793 }
794 } 794 }
795 ASSERT(index == leafhdr.count || (args->op_flags & XFS_DA_OP_OKNOENT)); 795 ASSERT(index == leafhdr.count || (args->op_flags & XFS_DA_OP_OKNOENT));
@@ -812,7 +812,7 @@ xfs_dir2_leafn_lookup_for_entry(
812 state->extravalid = 0; 812 state->extravalid = 0;
813 } 813 }
814 *indexp = index; 814 *indexp = index;
815 return ENOENT; 815 return -ENOENT;
816} 816}
817 817
818/* 818/*
@@ -1133,7 +1133,7 @@ xfs_dir3_data_block_free(
1133 if (error == 0) { 1133 if (error == 0) {
1134 fbp = NULL; 1134 fbp = NULL;
1135 logfree = 0; 1135 logfree = 0;
1136 } else if (error != ENOSPC || args->total != 0) 1136 } else if (error != -ENOSPC || args->total != 0)
1137 return error; 1137 return error;
1138 /* 1138 /*
1139 * It's possible to get ENOSPC if there is no 1139 * It's possible to get ENOSPC if there is no
@@ -1287,7 +1287,7 @@ xfs_dir2_leafn_remove(
1287 * In this case just drop the buffer and some one else 1287 * In this case just drop the buffer and some one else
1288 * will eventually get rid of the empty block. 1288 * will eventually get rid of the empty block.
1289 */ 1289 */
1290 else if (!(error == ENOSPC && args->total == 0)) 1290 else if (!(error == -ENOSPC && args->total == 0))
1291 return error; 1291 return error;
1292 } 1292 }
1293 /* 1293 /*
@@ -1599,7 +1599,7 @@ xfs_dir2_node_addname(
1599 error = xfs_da3_node_lookup_int(state, &rval); 1599 error = xfs_da3_node_lookup_int(state, &rval);
1600 if (error) 1600 if (error)
1601 rval = error; 1601 rval = error;
1602 if (rval != ENOENT) { 1602 if (rval != -ENOENT) {
1603 goto done; 1603 goto done;
1604 } 1604 }
1605 /* 1605 /*
@@ -1628,7 +1628,7 @@ xfs_dir2_node_addname(
1628 * It didn't work, we need to split the leaf block. 1628 * It didn't work, we need to split the leaf block.
1629 */ 1629 */
1630 if (args->total == 0) { 1630 if (args->total == 0) {
1631 ASSERT(rval == ENOSPC); 1631 ASSERT(rval == -ENOSPC);
1632 goto done; 1632 goto done;
1633 } 1633 }
1634 /* 1634 /*
@@ -1815,7 +1815,7 @@ xfs_dir2_node_addname_int(
1815 * Not allowed to allocate, return failure. 1815 * Not allowed to allocate, return failure.
1816 */ 1816 */
1817 if ((args->op_flags & XFS_DA_OP_JUSTCHECK) || args->total == 0) 1817 if ((args->op_flags & XFS_DA_OP_JUSTCHECK) || args->total == 0)
1818 return ENOSPC; 1818 return -ENOSPC;
1819 1819
1820 /* 1820 /*
1821 * Allocate and initialize the new data block. 1821 * Allocate and initialize the new data block.
@@ -1876,7 +1876,7 @@ xfs_dir2_node_addname_int(
1876 } 1876 }
1877 XFS_ERROR_REPORT("xfs_dir2_node_addname_int", 1877 XFS_ERROR_REPORT("xfs_dir2_node_addname_int",
1878 XFS_ERRLEVEL_LOW, mp); 1878 XFS_ERRLEVEL_LOW, mp);
1879 return EFSCORRUPTED; 1879 return -EFSCORRUPTED;
1880 } 1880 }
1881 1881
1882 /* 1882 /*
@@ -2042,8 +2042,8 @@ xfs_dir2_node_lookup(
2042 error = xfs_da3_node_lookup_int(state, &rval); 2042 error = xfs_da3_node_lookup_int(state, &rval);
2043 if (error) 2043 if (error)
2044 rval = error; 2044 rval = error;
2045 else if (rval == ENOENT && args->cmpresult == XFS_CMP_CASE) { 2045 else if (rval == -ENOENT && args->cmpresult == XFS_CMP_CASE) {
2046 /* If a CI match, dup the actual name and return EEXIST */ 2046 /* If a CI match, dup the actual name and return -EEXIST */
2047 xfs_dir2_data_entry_t *dep; 2047 xfs_dir2_data_entry_t *dep;
2048 2048
2049 dep = (xfs_dir2_data_entry_t *) 2049 dep = (xfs_dir2_data_entry_t *)
@@ -2096,7 +2096,7 @@ xfs_dir2_node_removename(
2096 goto out_free; 2096 goto out_free;
2097 2097
2098 /* Didn't find it, upper layer screwed up. */ 2098 /* Didn't find it, upper layer screwed up. */
2099 if (rval != EEXIST) { 2099 if (rval != -EEXIST) {
2100 error = rval; 2100 error = rval;
2101 goto out_free; 2101 goto out_free;
2102 } 2102 }
@@ -2169,7 +2169,7 @@ xfs_dir2_node_replace(
2169 * It should be found, since the vnodeops layer has looked it up 2169 * It should be found, since the vnodeops layer has looked it up
2170 * and locked it. But paranoia is good. 2170 * and locked it. But paranoia is good.
2171 */ 2171 */
2172 if (rval == EEXIST) { 2172 if (rval == -EEXIST) {
2173 struct xfs_dir2_leaf_entry *ents; 2173 struct xfs_dir2_leaf_entry *ents;
2174 /* 2174 /*
2175 * Find the leaf entry. 2175 * Find the leaf entry.
@@ -2272,7 +2272,7 @@ xfs_dir2_node_trim_free(
2272 * space reservation, when breaking up an extent into two 2272 * space reservation, when breaking up an extent into two
2273 * pieces. This is the last block of an extent. 2273 * pieces. This is the last block of an extent.
2274 */ 2274 */
2275 ASSERT(error != ENOSPC); 2275 ASSERT(error != -ENOSPC);
2276 xfs_trans_brelse(tp, bp); 2276 xfs_trans_brelse(tp, bp);
2277 return error; 2277 return error;
2278 } 2278 }
diff --git a/fs/xfs/libxfs/xfs_dir2_sf.c b/fs/xfs/libxfs/xfs_dir2_sf.c
index ab3563b87995..8f4f26af35e1 100644
--- a/fs/xfs/libxfs/xfs_dir2_sf.c
+++ b/fs/xfs/libxfs/xfs_dir2_sf.c
@@ -251,7 +251,7 @@ xfs_dir2_block_to_sf(
251 logflags = XFS_ILOG_CORE; 251 logflags = XFS_ILOG_CORE;
252 error = xfs_dir2_shrink_inode(args, args->geo->datablk, bp); 252 error = xfs_dir2_shrink_inode(args, args->geo->datablk, bp);
253 if (error) { 253 if (error) {
254 ASSERT(error != ENOSPC); 254 ASSERT(error != -ENOSPC);
255 goto out; 255 goto out;
256 } 256 }
257 257
@@ -299,7 +299,7 @@ xfs_dir2_sf_addname(
299 299
300 trace_xfs_dir2_sf_addname(args); 300 trace_xfs_dir2_sf_addname(args);
301 301
302 ASSERT(xfs_dir2_sf_lookup(args) == ENOENT); 302 ASSERT(xfs_dir2_sf_lookup(args) == -ENOENT);
303 dp = args->dp; 303 dp = args->dp;
304 ASSERT(dp->i_df.if_flags & XFS_IFINLINE); 304 ASSERT(dp->i_df.if_flags & XFS_IFINLINE);
305 /* 305 /*
@@ -307,7 +307,7 @@ xfs_dir2_sf_addname(
307 */ 307 */
308 if (dp->i_d.di_size < offsetof(xfs_dir2_sf_hdr_t, parent)) { 308 if (dp->i_d.di_size < offsetof(xfs_dir2_sf_hdr_t, parent)) {
309 ASSERT(XFS_FORCED_SHUTDOWN(dp->i_mount)); 309 ASSERT(XFS_FORCED_SHUTDOWN(dp->i_mount));
310 return EIO; 310 return -EIO;
311 } 311 }
312 ASSERT(dp->i_df.if_bytes == dp->i_d.di_size); 312 ASSERT(dp->i_df.if_bytes == dp->i_d.di_size);
313 ASSERT(dp->i_df.if_u1.if_data != NULL); 313 ASSERT(dp->i_df.if_u1.if_data != NULL);
@@ -345,7 +345,7 @@ xfs_dir2_sf_addname(
345 * Just checking or no space reservation, it doesn't fit. 345 * Just checking or no space reservation, it doesn't fit.
346 */ 346 */
347 if ((args->op_flags & XFS_DA_OP_JUSTCHECK) || args->total == 0) 347 if ((args->op_flags & XFS_DA_OP_JUSTCHECK) || args->total == 0)
348 return ENOSPC; 348 return -ENOSPC;
349 /* 349 /*
350 * Convert to block form then add the name. 350 * Convert to block form then add the name.
351 */ 351 */
@@ -738,7 +738,7 @@ xfs_dir2_sf_lookup(
738 */ 738 */
739 if (dp->i_d.di_size < offsetof(xfs_dir2_sf_hdr_t, parent)) { 739 if (dp->i_d.di_size < offsetof(xfs_dir2_sf_hdr_t, parent)) {
740 ASSERT(XFS_FORCED_SHUTDOWN(dp->i_mount)); 740 ASSERT(XFS_FORCED_SHUTDOWN(dp->i_mount));
741 return EIO; 741 return -EIO;
742 } 742 }
743 ASSERT(dp->i_df.if_bytes == dp->i_d.di_size); 743 ASSERT(dp->i_df.if_bytes == dp->i_d.di_size);
744 ASSERT(dp->i_df.if_u1.if_data != NULL); 744 ASSERT(dp->i_df.if_u1.if_data != NULL);
@@ -751,7 +751,7 @@ xfs_dir2_sf_lookup(
751 args->inumber = dp->i_ino; 751 args->inumber = dp->i_ino;
752 args->cmpresult = XFS_CMP_EXACT; 752 args->cmpresult = XFS_CMP_EXACT;
753 args->filetype = XFS_DIR3_FT_DIR; 753 args->filetype = XFS_DIR3_FT_DIR;
754 return EEXIST; 754 return -EEXIST;
755 } 755 }
756 /* 756 /*
757 * Special case for .. 757 * Special case for ..
@@ -761,7 +761,7 @@ xfs_dir2_sf_lookup(
761 args->inumber = dp->d_ops->sf_get_parent_ino(sfp); 761 args->inumber = dp->d_ops->sf_get_parent_ino(sfp);
762 args->cmpresult = XFS_CMP_EXACT; 762 args->cmpresult = XFS_CMP_EXACT;
763 args->filetype = XFS_DIR3_FT_DIR; 763 args->filetype = XFS_DIR3_FT_DIR;
764 return EEXIST; 764 return -EEXIST;
765 } 765 }
766 /* 766 /*
767 * Loop over all the entries trying to match ours. 767 * Loop over all the entries trying to match ours.
@@ -781,17 +781,17 @@ xfs_dir2_sf_lookup(
781 args->inumber = dp->d_ops->sf_get_ino(sfp, sfep); 781 args->inumber = dp->d_ops->sf_get_ino(sfp, sfep);
782 args->filetype = dp->d_ops->sf_get_ftype(sfep); 782 args->filetype = dp->d_ops->sf_get_ftype(sfep);
783 if (cmp == XFS_CMP_EXACT) 783 if (cmp == XFS_CMP_EXACT)
784 return EEXIST; 784 return -EEXIST;
785 ci_sfep = sfep; 785 ci_sfep = sfep;
786 } 786 }
787 } 787 }
788 ASSERT(args->op_flags & XFS_DA_OP_OKNOENT); 788 ASSERT(args->op_flags & XFS_DA_OP_OKNOENT);
789 /* 789 /*
790 * Here, we can only be doing a lookup (not a rename or replace). 790 * Here, we can only be doing a lookup (not a rename or replace).
791 * If a case-insensitive match was not found, return ENOENT. 791 * If a case-insensitive match was not found, return -ENOENT.
792 */ 792 */
793 if (!ci_sfep) 793 if (!ci_sfep)
794 return ENOENT; 794 return -ENOENT;
795 /* otherwise process the CI match as required by the caller */ 795 /* otherwise process the CI match as required by the caller */
796 error = xfs_dir_cilookup_result(args, ci_sfep->name, ci_sfep->namelen); 796 error = xfs_dir_cilookup_result(args, ci_sfep->name, ci_sfep->namelen);
797 return error; 797 return error;
@@ -824,7 +824,7 @@ xfs_dir2_sf_removename(
824 */ 824 */
825 if (oldsize < offsetof(xfs_dir2_sf_hdr_t, parent)) { 825 if (oldsize < offsetof(xfs_dir2_sf_hdr_t, parent)) {
826 ASSERT(XFS_FORCED_SHUTDOWN(dp->i_mount)); 826 ASSERT(XFS_FORCED_SHUTDOWN(dp->i_mount));
827 return EIO; 827 return -EIO;
828 } 828 }
829 ASSERT(dp->i_df.if_bytes == oldsize); 829 ASSERT(dp->i_df.if_bytes == oldsize);
830 ASSERT(dp->i_df.if_u1.if_data != NULL); 830 ASSERT(dp->i_df.if_u1.if_data != NULL);
@@ -847,7 +847,7 @@ xfs_dir2_sf_removename(
847 * Didn't find it. 847 * Didn't find it.
848 */ 848 */
849 if (i == sfp->count) 849 if (i == sfp->count)
850 return ENOENT; 850 return -ENOENT;
851 /* 851 /*
852 * Calculate sizes. 852 * Calculate sizes.
853 */ 853 */
@@ -914,7 +914,7 @@ xfs_dir2_sf_replace(
914 */ 914 */
915 if (dp->i_d.di_size < offsetof(xfs_dir2_sf_hdr_t, parent)) { 915 if (dp->i_d.di_size < offsetof(xfs_dir2_sf_hdr_t, parent)) {
916 ASSERT(XFS_FORCED_SHUTDOWN(dp->i_mount)); 916 ASSERT(XFS_FORCED_SHUTDOWN(dp->i_mount));
917 return EIO; 917 return -EIO;
918 } 918 }
919 ASSERT(dp->i_df.if_bytes == dp->i_d.di_size); 919 ASSERT(dp->i_df.if_bytes == dp->i_d.di_size);
920 ASSERT(dp->i_df.if_u1.if_data != NULL); 920 ASSERT(dp->i_df.if_u1.if_data != NULL);
@@ -990,7 +990,7 @@ xfs_dir2_sf_replace(
990 if (i8elevated) 990 if (i8elevated)
991 xfs_dir2_sf_toino4(args); 991 xfs_dir2_sf_toino4(args);
992#endif 992#endif
993 return ENOENT; 993 return -ENOENT;
994 } 994 }
995 } 995 }
996#if XFS_BIG_INUMS 996#if XFS_BIG_INUMS
diff --git a/fs/xfs/libxfs/xfs_dquot_buf.c b/fs/xfs/libxfs/xfs_dquot_buf.c
index c2ac0c611ad8..bb969337efc8 100644
--- a/fs/xfs/libxfs/xfs_dquot_buf.c
+++ b/fs/xfs/libxfs/xfs_dquot_buf.c
@@ -257,9 +257,9 @@ xfs_dquot_buf_read_verify(
257 struct xfs_mount *mp = bp->b_target->bt_mount; 257 struct xfs_mount *mp = bp->b_target->bt_mount;
258 258
259 if (!xfs_dquot_buf_verify_crc(mp, bp)) 259 if (!xfs_dquot_buf_verify_crc(mp, bp))
260 xfs_buf_ioerror(bp, EFSBADCRC); 260 xfs_buf_ioerror(bp, -EFSBADCRC);
261 else if (!xfs_dquot_buf_verify(mp, bp)) 261 else if (!xfs_dquot_buf_verify(mp, bp))
262 xfs_buf_ioerror(bp, EFSCORRUPTED); 262 xfs_buf_ioerror(bp, -EFSCORRUPTED);
263 263
264 if (bp->b_error) 264 if (bp->b_error)
265 xfs_verifier_error(bp); 265 xfs_verifier_error(bp);
@@ -277,7 +277,7 @@ xfs_dquot_buf_write_verify(
277 struct xfs_mount *mp = bp->b_target->bt_mount; 277 struct xfs_mount *mp = bp->b_target->bt_mount;
278 278
279 if (!xfs_dquot_buf_verify(mp, bp)) { 279 if (!xfs_dquot_buf_verify(mp, bp)) {
280 xfs_buf_ioerror(bp, EFSCORRUPTED); 280 xfs_buf_ioerror(bp, -EFSCORRUPTED);
281 xfs_verifier_error(bp); 281 xfs_verifier_error(bp);
282 return; 282 return;
283 } 283 }
diff --git a/fs/xfs/libxfs/xfs_ialloc.c b/fs/xfs/libxfs/xfs_ialloc.c
index 16fb63a9bc5e..b62771f1f4b5 100644
--- a/fs/xfs/libxfs/xfs_ialloc.c
+++ b/fs/xfs/libxfs/xfs_ialloc.c
@@ -292,7 +292,7 @@ xfs_ialloc_inode_init(
292 mp->m_bsize * blks_per_cluster, 292 mp->m_bsize * blks_per_cluster,
293 XBF_UNMAPPED); 293 XBF_UNMAPPED);
294 if (!fbuf) 294 if (!fbuf)
295 return ENOMEM; 295 return -ENOMEM;
296 296
297 /* Initialize the inode buffers and log them appropriately. */ 297 /* Initialize the inode buffers and log them appropriately. */
298 fbuf->b_ops = &xfs_inode_buf_ops; 298 fbuf->b_ops = &xfs_inode_buf_ops;
@@ -380,7 +380,7 @@ xfs_ialloc_ag_alloc(
380 newlen = args.mp->m_ialloc_inos; 380 newlen = args.mp->m_ialloc_inos;
381 if (args.mp->m_maxicount && 381 if (args.mp->m_maxicount &&
382 args.mp->m_sb.sb_icount + newlen > args.mp->m_maxicount) 382 args.mp->m_sb.sb_icount + newlen > args.mp->m_maxicount)
383 return ENOSPC; 383 return -ENOSPC;
384 args.minlen = args.maxlen = args.mp->m_ialloc_blks; 384 args.minlen = args.maxlen = args.mp->m_ialloc_blks;
385 /* 385 /*
386 * First try to allocate inodes contiguous with the last-allocated 386 * First try to allocate inodes contiguous with the last-allocated
@@ -1385,7 +1385,7 @@ xfs_dialloc(
1385 if (error) { 1385 if (error) {
1386 xfs_trans_brelse(tp, agbp); 1386 xfs_trans_brelse(tp, agbp);
1387 1387
1388 if (error != ENOSPC) 1388 if (error != -ENOSPC)
1389 goto out_error; 1389 goto out_error;
1390 1390
1391 xfs_perag_put(pag); 1391 xfs_perag_put(pag);
@@ -1416,7 +1416,7 @@ nextag:
1416 agno = 0; 1416 agno = 0;
1417 if (agno == start_agno) { 1417 if (agno == start_agno) {
1418 *inop = NULLFSINO; 1418 *inop = NULLFSINO;
1419 return noroom ? ENOSPC : 0; 1419 return noroom ? -ENOSPC : 0;
1420 } 1420 }
1421 } 1421 }
1422 1422
@@ -1682,7 +1682,7 @@ xfs_difree(
1682 xfs_warn(mp, "%s: agno >= mp->m_sb.sb_agcount (%d >= %d).", 1682 xfs_warn(mp, "%s: agno >= mp->m_sb.sb_agcount (%d >= %d).",
1683 __func__, agno, mp->m_sb.sb_agcount); 1683 __func__, agno, mp->m_sb.sb_agcount);
1684 ASSERT(0); 1684 ASSERT(0);
1685 return EINVAL; 1685 return -EINVAL;
1686 } 1686 }
1687 agino = XFS_INO_TO_AGINO(mp, inode); 1687 agino = XFS_INO_TO_AGINO(mp, inode);
1688 if (inode != XFS_AGINO_TO_INO(mp, agno, agino)) { 1688 if (inode != XFS_AGINO_TO_INO(mp, agno, agino)) {
@@ -1690,14 +1690,14 @@ xfs_difree(
1690 __func__, (unsigned long long)inode, 1690 __func__, (unsigned long long)inode,
1691 (unsigned long long)XFS_AGINO_TO_INO(mp, agno, agino)); 1691 (unsigned long long)XFS_AGINO_TO_INO(mp, agno, agino));
1692 ASSERT(0); 1692 ASSERT(0);
1693 return EINVAL; 1693 return -EINVAL;
1694 } 1694 }
1695 agbno = XFS_AGINO_TO_AGBNO(mp, agino); 1695 agbno = XFS_AGINO_TO_AGBNO(mp, agino);
1696 if (agbno >= mp->m_sb.sb_agblocks) { 1696 if (agbno >= mp->m_sb.sb_agblocks) {
1697 xfs_warn(mp, "%s: agbno >= mp->m_sb.sb_agblocks (%d >= %d).", 1697 xfs_warn(mp, "%s: agbno >= mp->m_sb.sb_agblocks (%d >= %d).",
1698 __func__, agbno, mp->m_sb.sb_agblocks); 1698 __func__, agbno, mp->m_sb.sb_agblocks);
1699 ASSERT(0); 1699 ASSERT(0);
1700 return EINVAL; 1700 return -EINVAL;
1701 } 1701 }
1702 /* 1702 /*
1703 * Get the allocation group header. 1703 * Get the allocation group header.
@@ -1769,7 +1769,7 @@ xfs_imap_lookup(
1769 if (i) 1769 if (i)
1770 error = xfs_inobt_get_rec(cur, &rec, &i); 1770 error = xfs_inobt_get_rec(cur, &rec, &i);
1771 if (!error && i == 0) 1771 if (!error && i == 0)
1772 error = EINVAL; 1772 error = -EINVAL;
1773 } 1773 }
1774 1774
1775 xfs_trans_brelse(tp, agbp); 1775 xfs_trans_brelse(tp, agbp);
@@ -1780,12 +1780,12 @@ xfs_imap_lookup(
1780 /* check that the returned record contains the required inode */ 1780 /* check that the returned record contains the required inode */
1781 if (rec.ir_startino > agino || 1781 if (rec.ir_startino > agino ||
1782 rec.ir_startino + mp->m_ialloc_inos <= agino) 1782 rec.ir_startino + mp->m_ialloc_inos <= agino)
1783 return EINVAL; 1783 return -EINVAL;
1784 1784
1785 /* for untrusted inodes check it is allocated first */ 1785 /* for untrusted inodes check it is allocated first */
1786 if ((flags & XFS_IGET_UNTRUSTED) && 1786 if ((flags & XFS_IGET_UNTRUSTED) &&
1787 (rec.ir_free & XFS_INOBT_MASK(agino - rec.ir_startino))) 1787 (rec.ir_free & XFS_INOBT_MASK(agino - rec.ir_startino)))
1788 return EINVAL; 1788 return -EINVAL;
1789 1789
1790 *chunk_agbno = XFS_AGINO_TO_AGBNO(mp, rec.ir_startino); 1790 *chunk_agbno = XFS_AGINO_TO_AGBNO(mp, rec.ir_startino);
1791 *offset_agbno = agbno - *chunk_agbno; 1791 *offset_agbno = agbno - *chunk_agbno;
@@ -1829,7 +1829,7 @@ xfs_imap(
1829 * as they can be invalid without implying corruption. 1829 * as they can be invalid without implying corruption.
1830 */ 1830 */
1831 if (flags & XFS_IGET_UNTRUSTED) 1831 if (flags & XFS_IGET_UNTRUSTED)
1832 return EINVAL; 1832 return -EINVAL;
1833 if (agno >= mp->m_sb.sb_agcount) { 1833 if (agno >= mp->m_sb.sb_agcount) {
1834 xfs_alert(mp, 1834 xfs_alert(mp,
1835 "%s: agno (%d) >= mp->m_sb.sb_agcount (%d)", 1835 "%s: agno (%d) >= mp->m_sb.sb_agcount (%d)",
@@ -1849,7 +1849,7 @@ xfs_imap(
1849 } 1849 }
1850 xfs_stack_trace(); 1850 xfs_stack_trace();
1851#endif /* DEBUG */ 1851#endif /* DEBUG */
1852 return EINVAL; 1852 return -EINVAL;
1853 } 1853 }
1854 1854
1855 blks_per_cluster = xfs_icluster_size_fsb(mp); 1855 blks_per_cluster = xfs_icluster_size_fsb(mp);
@@ -1922,7 +1922,7 @@ out_map:
1922 __func__, (unsigned long long) imap->im_blkno, 1922 __func__, (unsigned long long) imap->im_blkno,
1923 (unsigned long long) imap->im_len, 1923 (unsigned long long) imap->im_len,
1924 XFS_FSB_TO_BB(mp, mp->m_sb.sb_dblocks)); 1924 XFS_FSB_TO_BB(mp, mp->m_sb.sb_dblocks));
1925 return EINVAL; 1925 return -EINVAL;
1926 } 1926 }
1927 return 0; 1927 return 0;
1928} 1928}
@@ -2072,11 +2072,11 @@ xfs_agi_read_verify(
2072 2072
2073 if (xfs_sb_version_hascrc(&mp->m_sb) && 2073 if (xfs_sb_version_hascrc(&mp->m_sb) &&
2074 !xfs_buf_verify_cksum(bp, XFS_AGI_CRC_OFF)) 2074 !xfs_buf_verify_cksum(bp, XFS_AGI_CRC_OFF))
2075 xfs_buf_ioerror(bp, EFSBADCRC); 2075 xfs_buf_ioerror(bp, -EFSBADCRC);
2076 else if (XFS_TEST_ERROR(!xfs_agi_verify(bp), mp, 2076 else if (XFS_TEST_ERROR(!xfs_agi_verify(bp), mp,
2077 XFS_ERRTAG_IALLOC_READ_AGI, 2077 XFS_ERRTAG_IALLOC_READ_AGI,
2078 XFS_RANDOM_IALLOC_READ_AGI)) 2078 XFS_RANDOM_IALLOC_READ_AGI))
2079 xfs_buf_ioerror(bp, EFSCORRUPTED); 2079 xfs_buf_ioerror(bp, -EFSCORRUPTED);
2080 2080
2081 if (bp->b_error) 2081 if (bp->b_error)
2082 xfs_verifier_error(bp); 2082 xfs_verifier_error(bp);
@@ -2090,7 +2090,7 @@ xfs_agi_write_verify(
2090 struct xfs_buf_log_item *bip = bp->b_fspriv; 2090 struct xfs_buf_log_item *bip = bp->b_fspriv;
2091 2091
2092 if (!xfs_agi_verify(bp)) { 2092 if (!xfs_agi_verify(bp)) {
2093 xfs_buf_ioerror(bp, EFSCORRUPTED); 2093 xfs_buf_ioerror(bp, -EFSCORRUPTED);
2094 xfs_verifier_error(bp); 2094 xfs_verifier_error(bp);
2095 return; 2095 return;
2096 } 2096 }
diff --git a/fs/xfs/libxfs/xfs_ialloc_btree.c b/fs/xfs/libxfs/xfs_ialloc_btree.c
index 726f83a681a5..c9b06f30fe86 100644
--- a/fs/xfs/libxfs/xfs_ialloc_btree.c
+++ b/fs/xfs/libxfs/xfs_ialloc_btree.c
@@ -272,9 +272,9 @@ xfs_inobt_read_verify(
272 struct xfs_buf *bp) 272 struct xfs_buf *bp)
273{ 273{
274 if (!xfs_btree_sblock_verify_crc(bp)) 274 if (!xfs_btree_sblock_verify_crc(bp))
275 xfs_buf_ioerror(bp, EFSBADCRC); 275 xfs_buf_ioerror(bp, -EFSBADCRC);
276 else if (!xfs_inobt_verify(bp)) 276 else if (!xfs_inobt_verify(bp))
277 xfs_buf_ioerror(bp, EFSCORRUPTED); 277 xfs_buf_ioerror(bp, -EFSCORRUPTED);
278 278
279 if (bp->b_error) { 279 if (bp->b_error) {
280 trace_xfs_btree_corrupt(bp, _RET_IP_); 280 trace_xfs_btree_corrupt(bp, _RET_IP_);
@@ -288,7 +288,7 @@ xfs_inobt_write_verify(
288{ 288{
289 if (!xfs_inobt_verify(bp)) { 289 if (!xfs_inobt_verify(bp)) {
290 trace_xfs_btree_corrupt(bp, _RET_IP_); 290 trace_xfs_btree_corrupt(bp, _RET_IP_);
291 xfs_buf_ioerror(bp, EFSCORRUPTED); 291 xfs_buf_ioerror(bp, -EFSCORRUPTED);
292 xfs_verifier_error(bp); 292 xfs_verifier_error(bp);
293 return; 293 return;
294 } 294 }
diff --git a/fs/xfs/libxfs/xfs_inode_buf.c b/fs/xfs/libxfs/xfs_inode_buf.c
index 1e5366d7745e..f18fd2da49f7 100644
--- a/fs/xfs/libxfs/xfs_inode_buf.c
+++ b/fs/xfs/libxfs/xfs_inode_buf.c
@@ -101,7 +101,7 @@ xfs_inode_buf_verify(
101 return; 101 return;
102 } 102 }
103 103
104 xfs_buf_ioerror(bp, EFSCORRUPTED); 104 xfs_buf_ioerror(bp, -EFSCORRUPTED);
105 xfs_verifier_error(bp); 105 xfs_verifier_error(bp);
106#ifdef DEBUG 106#ifdef DEBUG
107 xfs_alert(mp, 107 xfs_alert(mp,
@@ -174,14 +174,14 @@ xfs_imap_to_bp(
174 (int)imap->im_len, buf_flags, &bp, 174 (int)imap->im_len, buf_flags, &bp,
175 &xfs_inode_buf_ops); 175 &xfs_inode_buf_ops);
176 if (error) { 176 if (error) {
177 if (error == EAGAIN) { 177 if (error == -EAGAIN) {
178 ASSERT(buf_flags & XBF_TRYLOCK); 178 ASSERT(buf_flags & XBF_TRYLOCK);
179 return error; 179 return error;
180 } 180 }
181 181
182 if (error == EFSCORRUPTED && 182 if (error == -EFSCORRUPTED &&
183 (iget_flags & XFS_IGET_UNTRUSTED)) 183 (iget_flags & XFS_IGET_UNTRUSTED))
184 return EINVAL; 184 return -EINVAL;
185 185
186 xfs_warn(mp, "%s: xfs_trans_read_buf() returned error %d.", 186 xfs_warn(mp, "%s: xfs_trans_read_buf() returned error %d.",
187 __func__, error); 187 __func__, error);
@@ -390,7 +390,7 @@ xfs_iread(
390 __func__, ip->i_ino); 390 __func__, ip->i_ino);
391 391
392 XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, dip); 392 XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, dip);
393 error = EFSCORRUPTED; 393 error = -EFSCORRUPTED;
394 goto out_brelse; 394 goto out_brelse;
395 } 395 }
396 396
diff --git a/fs/xfs/libxfs/xfs_inode_fork.c b/fs/xfs/libxfs/xfs_inode_fork.c
index 2a124e97f082..8ac9411bcf2a 100644
--- a/fs/xfs/libxfs/xfs_inode_fork.c
+++ b/fs/xfs/libxfs/xfs_inode_fork.c
@@ -102,7 +102,7 @@ xfs_iformat_fork(
102 be64_to_cpu(dip->di_nblocks)); 102 be64_to_cpu(dip->di_nblocks));
103 XFS_CORRUPTION_ERROR("xfs_iformat(1)", XFS_ERRLEVEL_LOW, 103 XFS_CORRUPTION_ERROR("xfs_iformat(1)", XFS_ERRLEVEL_LOW,
104 ip->i_mount, dip); 104 ip->i_mount, dip);
105 return EFSCORRUPTED; 105 return -EFSCORRUPTED;
106 } 106 }
107 107
108 if (unlikely(dip->di_forkoff > ip->i_mount->m_sb.sb_inodesize)) { 108 if (unlikely(dip->di_forkoff > ip->i_mount->m_sb.sb_inodesize)) {
@@ -111,7 +111,7 @@ xfs_iformat_fork(
111 dip->di_forkoff); 111 dip->di_forkoff);
112 XFS_CORRUPTION_ERROR("xfs_iformat(2)", XFS_ERRLEVEL_LOW, 112 XFS_CORRUPTION_ERROR("xfs_iformat(2)", XFS_ERRLEVEL_LOW,
113 ip->i_mount, dip); 113 ip->i_mount, dip);
114 return EFSCORRUPTED; 114 return -EFSCORRUPTED;
115 } 115 }
116 116
117 if (unlikely((ip->i_d.di_flags & XFS_DIFLAG_REALTIME) && 117 if (unlikely((ip->i_d.di_flags & XFS_DIFLAG_REALTIME) &&
@@ -121,7 +121,7 @@ xfs_iformat_fork(
121 ip->i_ino); 121 ip->i_ino);
122 XFS_CORRUPTION_ERROR("xfs_iformat(realtime)", 122 XFS_CORRUPTION_ERROR("xfs_iformat(realtime)",
123 XFS_ERRLEVEL_LOW, ip->i_mount, dip); 123 XFS_ERRLEVEL_LOW, ip->i_mount, dip);
124 return EFSCORRUPTED; 124 return -EFSCORRUPTED;
125 } 125 }
126 126
127 switch (ip->i_d.di_mode & S_IFMT) { 127 switch (ip->i_d.di_mode & S_IFMT) {
@@ -132,7 +132,7 @@ xfs_iformat_fork(
132 if (unlikely(dip->di_format != XFS_DINODE_FMT_DEV)) { 132 if (unlikely(dip->di_format != XFS_DINODE_FMT_DEV)) {
133 XFS_CORRUPTION_ERROR("xfs_iformat(3)", XFS_ERRLEVEL_LOW, 133 XFS_CORRUPTION_ERROR("xfs_iformat(3)", XFS_ERRLEVEL_LOW,
134 ip->i_mount, dip); 134 ip->i_mount, dip);
135 return EFSCORRUPTED; 135 return -EFSCORRUPTED;
136 } 136 }
137 ip->i_d.di_size = 0; 137 ip->i_d.di_size = 0;
138 ip->i_df.if_u2.if_rdev = xfs_dinode_get_rdev(dip); 138 ip->i_df.if_u2.if_rdev = xfs_dinode_get_rdev(dip);
@@ -153,7 +153,7 @@ xfs_iformat_fork(
153 XFS_CORRUPTION_ERROR("xfs_iformat(4)", 153 XFS_CORRUPTION_ERROR("xfs_iformat(4)",
154 XFS_ERRLEVEL_LOW, 154 XFS_ERRLEVEL_LOW,
155 ip->i_mount, dip); 155 ip->i_mount, dip);
156 return EFSCORRUPTED; 156 return -EFSCORRUPTED;
157 } 157 }
158 158
159 di_size = be64_to_cpu(dip->di_size); 159 di_size = be64_to_cpu(dip->di_size);
@@ -166,7 +166,7 @@ xfs_iformat_fork(
166 XFS_CORRUPTION_ERROR("xfs_iformat(5)", 166 XFS_CORRUPTION_ERROR("xfs_iformat(5)",
167 XFS_ERRLEVEL_LOW, 167 XFS_ERRLEVEL_LOW,
168 ip->i_mount, dip); 168 ip->i_mount, dip);
169 return EFSCORRUPTED; 169 return -EFSCORRUPTED;
170 } 170 }
171 171
172 size = (int)di_size; 172 size = (int)di_size;
@@ -181,13 +181,13 @@ xfs_iformat_fork(
181 default: 181 default:
182 XFS_ERROR_REPORT("xfs_iformat(6)", XFS_ERRLEVEL_LOW, 182 XFS_ERROR_REPORT("xfs_iformat(6)", XFS_ERRLEVEL_LOW,
183 ip->i_mount); 183 ip->i_mount);
184 return EFSCORRUPTED; 184 return -EFSCORRUPTED;
185 } 185 }
186 break; 186 break;
187 187
188 default: 188 default:
189 XFS_ERROR_REPORT("xfs_iformat(7)", XFS_ERRLEVEL_LOW, ip->i_mount); 189 XFS_ERROR_REPORT("xfs_iformat(7)", XFS_ERRLEVEL_LOW, ip->i_mount);
190 return EFSCORRUPTED; 190 return -EFSCORRUPTED;
191 } 191 }
192 if (error) { 192 if (error) {
193 return error; 193 return error;
@@ -211,7 +211,7 @@ xfs_iformat_fork(
211 XFS_CORRUPTION_ERROR("xfs_iformat(8)", 211 XFS_CORRUPTION_ERROR("xfs_iformat(8)",
212 XFS_ERRLEVEL_LOW, 212 XFS_ERRLEVEL_LOW,
213 ip->i_mount, dip); 213 ip->i_mount, dip);
214 return EFSCORRUPTED; 214 return -EFSCORRUPTED;
215 } 215 }
216 216
217 error = xfs_iformat_local(ip, dip, XFS_ATTR_FORK, size); 217 error = xfs_iformat_local(ip, dip, XFS_ATTR_FORK, size);
@@ -223,7 +223,7 @@ xfs_iformat_fork(
223 error = xfs_iformat_btree(ip, dip, XFS_ATTR_FORK); 223 error = xfs_iformat_btree(ip, dip, XFS_ATTR_FORK);
224 break; 224 break;
225 default: 225 default:
226 error = EFSCORRUPTED; 226 error = -EFSCORRUPTED;
227 break; 227 break;
228 } 228 }
229 if (error) { 229 if (error) {
@@ -266,7 +266,7 @@ xfs_iformat_local(
266 XFS_DFORK_SIZE(dip, ip->i_mount, whichfork)); 266 XFS_DFORK_SIZE(dip, ip->i_mount, whichfork));
267 XFS_CORRUPTION_ERROR("xfs_iformat_local", XFS_ERRLEVEL_LOW, 267 XFS_CORRUPTION_ERROR("xfs_iformat_local", XFS_ERRLEVEL_LOW,
268 ip->i_mount, dip); 268 ip->i_mount, dip);
269 return EFSCORRUPTED; 269 return -EFSCORRUPTED;
270 } 270 }
271 ifp = XFS_IFORK_PTR(ip, whichfork); 271 ifp = XFS_IFORK_PTR(ip, whichfork);
272 real_size = 0; 272 real_size = 0;
@@ -322,7 +322,7 @@ xfs_iformat_extents(
322 (unsigned long long) ip->i_ino, nex); 322 (unsigned long long) ip->i_ino, nex);
323 XFS_CORRUPTION_ERROR("xfs_iformat_extents(1)", XFS_ERRLEVEL_LOW, 323 XFS_CORRUPTION_ERROR("xfs_iformat_extents(1)", XFS_ERRLEVEL_LOW,
324 ip->i_mount, dip); 324 ip->i_mount, dip);
325 return EFSCORRUPTED; 325 return -EFSCORRUPTED;
326 } 326 }
327 327
328 ifp->if_real_bytes = 0; 328 ifp->if_real_bytes = 0;
@@ -350,7 +350,7 @@ xfs_iformat_extents(
350 XFS_ERROR_REPORT("xfs_iformat_extents(2)", 350 XFS_ERROR_REPORT("xfs_iformat_extents(2)",
351 XFS_ERRLEVEL_LOW, 351 XFS_ERRLEVEL_LOW,
352 ip->i_mount); 352 ip->i_mount);
353 return EFSCORRUPTED; 353 return -EFSCORRUPTED;
354 } 354 }
355 } 355 }
356 ifp->if_flags |= XFS_IFEXTENTS; 356 ifp->if_flags |= XFS_IFEXTENTS;
@@ -399,7 +399,7 @@ xfs_iformat_btree(
399 (unsigned long long) ip->i_ino); 399 (unsigned long long) ip->i_ino);
400 XFS_CORRUPTION_ERROR("xfs_iformat_btree", XFS_ERRLEVEL_LOW, 400 XFS_CORRUPTION_ERROR("xfs_iformat_btree", XFS_ERRLEVEL_LOW,
401 mp, dip); 401 mp, dip);
402 return EFSCORRUPTED; 402 return -EFSCORRUPTED;
403 } 403 }
404 404
405 ifp->if_broot_bytes = size; 405 ifp->if_broot_bytes = size;
@@ -436,7 +436,7 @@ xfs_iread_extents(
436 if (unlikely(XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_BTREE)) { 436 if (unlikely(XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_BTREE)) {
437 XFS_ERROR_REPORT("xfs_iread_extents", XFS_ERRLEVEL_LOW, 437 XFS_ERROR_REPORT("xfs_iread_extents", XFS_ERRLEVEL_LOW,
438 ip->i_mount); 438 ip->i_mount);
439 return EFSCORRUPTED; 439 return -EFSCORRUPTED;
440 } 440 }
441 nextents = XFS_IFORK_NEXTENTS(ip, whichfork); 441 nextents = XFS_IFORK_NEXTENTS(ip, whichfork);
442 ifp = XFS_IFORK_PTR(ip, whichfork); 442 ifp = XFS_IFORK_PTR(ip, whichfork);
diff --git a/fs/xfs/libxfs/xfs_sb.c b/fs/xfs/libxfs/xfs_sb.c
index 06ad60b4b9fd..f5ca0286a0af 100644
--- a/fs/xfs/libxfs/xfs_sb.c
+++ b/fs/xfs/libxfs/xfs_sb.c
@@ -186,13 +186,13 @@ xfs_mount_validate_sb(
186 */ 186 */
187 if (sbp->sb_magicnum != XFS_SB_MAGIC) { 187 if (sbp->sb_magicnum != XFS_SB_MAGIC) {
188 xfs_warn(mp, "bad magic number"); 188 xfs_warn(mp, "bad magic number");
189 return EWRONGFS; 189 return -EWRONGFS;
190 } 190 }
191 191
192 192
193 if (!xfs_sb_good_version(sbp)) { 193 if (!xfs_sb_good_version(sbp)) {
194 xfs_warn(mp, "bad version"); 194 xfs_warn(mp, "bad version");
195 return EWRONGFS; 195 return -EWRONGFS;
196 } 196 }
197 197
198 /* 198 /*
@@ -220,7 +220,7 @@ xfs_mount_validate_sb(
220 xfs_warn(mp, 220 xfs_warn(mp,
221"Attempted to mount read-only compatible filesystem read-write.\n" 221"Attempted to mount read-only compatible filesystem read-write.\n"
222"Filesystem can only be safely mounted read only."); 222"Filesystem can only be safely mounted read only.");
223 return EINVAL; 223 return -EINVAL;
224 } 224 }
225 } 225 }
226 if (xfs_sb_has_incompat_feature(sbp, 226 if (xfs_sb_has_incompat_feature(sbp,
@@ -230,7 +230,7 @@ xfs_mount_validate_sb(
230"Filesystem can not be safely mounted by this kernel.", 230"Filesystem can not be safely mounted by this kernel.",
231 (sbp->sb_features_incompat & 231 (sbp->sb_features_incompat &
232 XFS_SB_FEAT_INCOMPAT_UNKNOWN)); 232 XFS_SB_FEAT_INCOMPAT_UNKNOWN));
233 return EINVAL; 233 return -EINVAL;
234 } 234 }
235 } 235 }
236 236
@@ -238,13 +238,13 @@ xfs_mount_validate_sb(
238 if (sbp->sb_qflags & (XFS_OQUOTA_ENFD | XFS_OQUOTA_CHKD)) { 238 if (sbp->sb_qflags & (XFS_OQUOTA_ENFD | XFS_OQUOTA_CHKD)) {
239 xfs_notice(mp, 239 xfs_notice(mp,
240 "Version 5 of Super block has XFS_OQUOTA bits."); 240 "Version 5 of Super block has XFS_OQUOTA bits.");
241 return EFSCORRUPTED; 241 return -EFSCORRUPTED;
242 } 242 }
243 } else if (sbp->sb_qflags & (XFS_PQUOTA_ENFD | XFS_GQUOTA_ENFD | 243 } else if (sbp->sb_qflags & (XFS_PQUOTA_ENFD | XFS_GQUOTA_ENFD |
244 XFS_PQUOTA_CHKD | XFS_GQUOTA_CHKD)) { 244 XFS_PQUOTA_CHKD | XFS_GQUOTA_CHKD)) {
245 xfs_notice(mp, 245 xfs_notice(mp,
246"Superblock earlier than Version 5 has XFS_[PQ]UOTA_{ENFD|CHKD} bits."); 246"Superblock earlier than Version 5 has XFS_[PQ]UOTA_{ENFD|CHKD} bits.");
247 return EFSCORRUPTED; 247 return -EFSCORRUPTED;
248 } 248 }
249 249
250 if (unlikely( 250 if (unlikely(
@@ -252,7 +252,7 @@ xfs_mount_validate_sb(
252 xfs_warn(mp, 252 xfs_warn(mp,
253 "filesystem is marked as having an external log; " 253 "filesystem is marked as having an external log; "
254 "specify logdev on the mount command line."); 254 "specify logdev on the mount command line.");
255 return EINVAL; 255 return -EINVAL;
256 } 256 }
257 257
258 if (unlikely( 258 if (unlikely(
@@ -260,7 +260,7 @@ xfs_mount_validate_sb(
260 xfs_warn(mp, 260 xfs_warn(mp,
261 "filesystem is marked as having an internal log; " 261 "filesystem is marked as having an internal log; "
262 "do not specify logdev on the mount command line."); 262 "do not specify logdev on the mount command line.");
263 return EINVAL; 263 return -EINVAL;
264 } 264 }
265 265
266 /* 266 /*
@@ -294,7 +294,7 @@ xfs_mount_validate_sb(
294 sbp->sb_dblocks < XFS_MIN_DBLOCKS(sbp) || 294 sbp->sb_dblocks < XFS_MIN_DBLOCKS(sbp) ||
295 sbp->sb_shared_vn != 0)) { 295 sbp->sb_shared_vn != 0)) {
296 xfs_notice(mp, "SB sanity check failed"); 296 xfs_notice(mp, "SB sanity check failed");
297 return EFSCORRUPTED; 297 return -EFSCORRUPTED;
298 } 298 }
299 299
300 /* 300 /*
@@ -305,7 +305,7 @@ xfs_mount_validate_sb(
305 "File system with blocksize %d bytes. " 305 "File system with blocksize %d bytes. "
306 "Only pagesize (%ld) or less will currently work.", 306 "Only pagesize (%ld) or less will currently work.",
307 sbp->sb_blocksize, PAGE_SIZE); 307 sbp->sb_blocksize, PAGE_SIZE);
308 return ENOSYS; 308 return -ENOSYS;
309 } 309 }
310 310
311 /* 311 /*
@@ -320,19 +320,19 @@ xfs_mount_validate_sb(
320 default: 320 default:
321 xfs_warn(mp, "inode size of %d bytes not supported", 321 xfs_warn(mp, "inode size of %d bytes not supported",
322 sbp->sb_inodesize); 322 sbp->sb_inodesize);
323 return ENOSYS; 323 return -ENOSYS;
324 } 324 }
325 325
326 if (xfs_sb_validate_fsb_count(sbp, sbp->sb_dblocks) || 326 if (xfs_sb_validate_fsb_count(sbp, sbp->sb_dblocks) ||
327 xfs_sb_validate_fsb_count(sbp, sbp->sb_rblocks)) { 327 xfs_sb_validate_fsb_count(sbp, sbp->sb_rblocks)) {
328 xfs_warn(mp, 328 xfs_warn(mp,
329 "file system too large to be mounted on this system."); 329 "file system too large to be mounted on this system.");
330 return EFBIG; 330 return -EFBIG;
331 } 331 }
332 332
333 if (check_inprogress && sbp->sb_inprogress) { 333 if (check_inprogress && sbp->sb_inprogress) {
334 xfs_warn(mp, "Offline file system operation in progress!"); 334 xfs_warn(mp, "Offline file system operation in progress!");
335 return EFSCORRUPTED; 335 return -EFSCORRUPTED;
336 } 336 }
337 return 0; 337 return 0;
338} 338}
@@ -603,7 +603,7 @@ xfs_sb_read_verify(
603 /* Only fail bad secondaries on a known V5 filesystem */ 603 /* Only fail bad secondaries on a known V5 filesystem */
604 if (bp->b_bn == XFS_SB_DADDR || 604 if (bp->b_bn == XFS_SB_DADDR ||
605 xfs_sb_version_hascrc(&mp->m_sb)) { 605 xfs_sb_version_hascrc(&mp->m_sb)) {
606 error = EFSBADCRC; 606 error = -EFSBADCRC;
607 goto out_error; 607 goto out_error;
608 } 608 }
609 } 609 }
@@ -613,7 +613,7 @@ xfs_sb_read_verify(
613out_error: 613out_error:
614 if (error) { 614 if (error) {
615 xfs_buf_ioerror(bp, error); 615 xfs_buf_ioerror(bp, error);
616 if (error == EFSCORRUPTED || error == EFSBADCRC) 616 if (error == -EFSCORRUPTED || error == -EFSBADCRC)
617 xfs_verifier_error(bp); 617 xfs_verifier_error(bp);
618 } 618 }
619} 619}
@@ -636,7 +636,7 @@ xfs_sb_quiet_read_verify(
636 return; 636 return;
637 } 637 }
638 /* quietly fail */ 638 /* quietly fail */
639 xfs_buf_ioerror(bp, EWRONGFS); 639 xfs_buf_ioerror(bp, -EWRONGFS);
640} 640}
641 641
642static void 642static void
diff --git a/fs/xfs/libxfs/xfs_symlink_remote.c b/fs/xfs/libxfs/xfs_symlink_remote.c
index 23c2f2577c8d..5782f037eab4 100644
--- a/fs/xfs/libxfs/xfs_symlink_remote.c
+++ b/fs/xfs/libxfs/xfs_symlink_remote.c
@@ -133,9 +133,9 @@ xfs_symlink_read_verify(
133 return; 133 return;
134 134
135 if (!xfs_buf_verify_cksum(bp, XFS_SYMLINK_CRC_OFF)) 135 if (!xfs_buf_verify_cksum(bp, XFS_SYMLINK_CRC_OFF))
136 xfs_buf_ioerror(bp, EFSBADCRC); 136 xfs_buf_ioerror(bp, -EFSBADCRC);
137 else if (!xfs_symlink_verify(bp)) 137 else if (!xfs_symlink_verify(bp))
138 xfs_buf_ioerror(bp, EFSCORRUPTED); 138 xfs_buf_ioerror(bp, -EFSCORRUPTED);
139 139
140 if (bp->b_error) 140 if (bp->b_error)
141 xfs_verifier_error(bp); 141 xfs_verifier_error(bp);
@@ -153,7 +153,7 @@ xfs_symlink_write_verify(
153 return; 153 return;
154 154
155 if (!xfs_symlink_verify(bp)) { 155 if (!xfs_symlink_verify(bp)) {
156 xfs_buf_ioerror(bp, EFSCORRUPTED); 156 xfs_buf_ioerror(bp, -EFSCORRUPTED);
157 xfs_verifier_error(bp); 157 xfs_verifier_error(bp);
158 return; 158 return;
159 } 159 }
diff --git a/fs/xfs/xfs_acl.c b/fs/xfs/xfs_acl.c
index 6888ad886ff6..a65fa5dde6e9 100644
--- a/fs/xfs/xfs_acl.c
+++ b/fs/xfs/xfs_acl.c
@@ -152,7 +152,7 @@ xfs_get_acl(struct inode *inode, int type)
152 if (!xfs_acl) 152 if (!xfs_acl)
153 return ERR_PTR(-ENOMEM); 153 return ERR_PTR(-ENOMEM);
154 154
155 error = -xfs_attr_get(ip, ea_name, (unsigned char *)xfs_acl, 155 error = xfs_attr_get(ip, ea_name, (unsigned char *)xfs_acl,
156 &len, ATTR_ROOT); 156 &len, ATTR_ROOT);
157 if (error) { 157 if (error) {
158 /* 158 /*
@@ -210,7 +210,7 @@ __xfs_set_acl(struct inode *inode, int type, struct posix_acl *acl)
210 len -= sizeof(struct xfs_acl_entry) * 210 len -= sizeof(struct xfs_acl_entry) *
211 (XFS_ACL_MAX_ENTRIES(ip->i_mount) - acl->a_count); 211 (XFS_ACL_MAX_ENTRIES(ip->i_mount) - acl->a_count);
212 212
213 error = -xfs_attr_set(ip, ea_name, (unsigned char *)xfs_acl, 213 error = xfs_attr_set(ip, ea_name, (unsigned char *)xfs_acl,
214 len, ATTR_ROOT); 214 len, ATTR_ROOT);
215 215
216 kmem_free(xfs_acl); 216 kmem_free(xfs_acl);
@@ -218,7 +218,7 @@ __xfs_set_acl(struct inode *inode, int type, struct posix_acl *acl)
218 /* 218 /*
219 * A NULL ACL argument means we want to remove the ACL. 219 * A NULL ACL argument means we want to remove the ACL.
220 */ 220 */
221 error = -xfs_attr_remove(ip, ea_name, ATTR_ROOT); 221 error = xfs_attr_remove(ip, ea_name, ATTR_ROOT);
222 222
223 /* 223 /*
224 * If the attribute didn't exist to start with that's fine. 224 * 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 iattr.ia_mode = mode; 244 iattr.ia_mode = mode;
245 iattr.ia_ctime = current_fs_time(inode->i_sb); 245 iattr.ia_ctime = current_fs_time(inode->i_sb);
246 246
247 error = -xfs_setattr_nonsize(XFS_I(inode), &iattr, XFS_ATTR_NOACL); 247 error = xfs_setattr_nonsize(XFS_I(inode), &iattr, XFS_ATTR_NOACL);
248 } 248 }
249 249
250 return error; 250 return error;
diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c
index eb67f416b13a..11e9b4caa54f 100644
--- a/fs/xfs/xfs_aops.c
+++ b/fs/xfs/xfs_aops.c
@@ -240,7 +240,7 @@ xfs_end_io(
240 240
241done: 241done:
242 if (error) 242 if (error)
243 ioend->io_error = -error; 243 ioend->io_error = error;
244 xfs_destroy_ioend(ioend); 244 xfs_destroy_ioend(ioend);
245} 245}
246 246
@@ -332,14 +332,14 @@ xfs_map_blocks(
332 xfs_iunlock(ip, XFS_ILOCK_SHARED); 332 xfs_iunlock(ip, XFS_ILOCK_SHARED);
333 333
334 if (error) 334 if (error)
335 return -error; 335 return error;
336 336
337 if (type == XFS_IO_DELALLOC && 337 if (type == XFS_IO_DELALLOC &&
338 (!nimaps || isnullstartblock(imap->br_startblock))) { 338 (!nimaps || isnullstartblock(imap->br_startblock))) {
339 error = xfs_iomap_write_allocate(ip, offset, imap); 339 error = xfs_iomap_write_allocate(ip, offset, imap);
340 if (!error) 340 if (!error)
341 trace_xfs_map_blocks_alloc(ip, offset, count, type, imap); 341 trace_xfs_map_blocks_alloc(ip, offset, count, type, imap);
342 return -error; 342 return error;
343 } 343 }
344 344
345#ifdef DEBUG 345#ifdef DEBUG
@@ -502,7 +502,7 @@ xfs_submit_ioend(
502 * time. 502 * time.
503 */ 503 */
504 if (fail) { 504 if (fail) {
505 ioend->io_error = -fail; 505 ioend->io_error = fail;
506 xfs_finish_ioend(ioend); 506 xfs_finish_ioend(ioend);
507 continue; 507 continue;
508 } 508 }
@@ -1302,7 +1302,7 @@ __xfs_get_blocks(
1302 error = xfs_iomap_write_direct(ip, offset, size, 1302 error = xfs_iomap_write_direct(ip, offset, size,
1303 &imap, nimaps); 1303 &imap, nimaps);
1304 if (error) 1304 if (error)
1305 return -error; 1305 return error;
1306 new = 1; 1306 new = 1;
1307 } else { 1307 } else {
1308 /* 1308 /*
@@ -1415,7 +1415,7 @@ __xfs_get_blocks(
1415 1415
1416out_unlock: 1416out_unlock:
1417 xfs_iunlock(ip, lockmode); 1417 xfs_iunlock(ip, lockmode);
1418 return -error; 1418 return error;
1419} 1419}
1420 1420
1421int 1421int
diff --git a/fs/xfs/xfs_attr_inactive.c b/fs/xfs/xfs_attr_inactive.c
index f19d1ef1f84a..aa2a8b1838a2 100644
--- a/fs/xfs/xfs_attr_inactive.c
+++ b/fs/xfs/xfs_attr_inactive.c
@@ -95,7 +95,7 @@ xfs_attr3_leaf_freextent(
95 dp->i_mount->m_ddev_targp, 95 dp->i_mount->m_ddev_targp,
96 dblkno, dblkcnt, 0); 96 dblkno, dblkcnt, 0);
97 if (!bp) 97 if (!bp)
98 return ENOMEM; 98 return -ENOMEM;
99 xfs_trans_binval(*trans, bp); 99 xfs_trans_binval(*trans, bp);
100 /* 100 /*
101 * Roll to next transaction. 101 * Roll to next transaction.
@@ -227,7 +227,7 @@ xfs_attr3_node_inactive(
227 */ 227 */
228 if (level > XFS_DA_NODE_MAXDEPTH) { 228 if (level > XFS_DA_NODE_MAXDEPTH) {
229 xfs_trans_brelse(*trans, bp); /* no locks for later trans */ 229 xfs_trans_brelse(*trans, bp); /* no locks for later trans */
230 return EIO; 230 return -EIO;
231 } 231 }
232 232
233 node = bp->b_addr; 233 node = bp->b_addr;
@@ -277,7 +277,7 @@ xfs_attr3_node_inactive(
277 child_bp); 277 child_bp);
278 break; 278 break;
279 default: 279 default:
280 error = EIO; 280 error = -EIO;
281 xfs_trans_brelse(*trans, child_bp); 281 xfs_trans_brelse(*trans, child_bp);
282 break; 282 break;
283 } 283 }
@@ -360,7 +360,7 @@ xfs_attr3_root_inactive(
360 error = xfs_attr3_leaf_inactive(trans, dp, bp); 360 error = xfs_attr3_leaf_inactive(trans, dp, bp);
361 break; 361 break;
362 default: 362 default:
363 error = EIO; 363 error = -EIO;
364 xfs_trans_brelse(*trans, bp); 364 xfs_trans_brelse(*trans, bp);
365 break; 365 break;
366 } 366 }
diff --git a/fs/xfs/xfs_attr_list.c b/fs/xfs/xfs_attr_list.c
index 84ea231e0da4..62db83ab6cbc 100644
--- a/fs/xfs/xfs_attr_list.c
+++ b/fs/xfs/xfs_attr_list.c
@@ -150,7 +150,7 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context)
150 XFS_ERRLEVEL_LOW, 150 XFS_ERRLEVEL_LOW,
151 context->dp->i_mount, sfe); 151 context->dp->i_mount, sfe);
152 kmem_free(sbuf); 152 kmem_free(sbuf);
153 return EFSCORRUPTED; 153 return -EFSCORRUPTED;
154 } 154 }
155 155
156 sbp->entno = i; 156 sbp->entno = i;
@@ -243,7 +243,7 @@ xfs_attr_node_list(xfs_attr_list_context_t *context)
243 if (cursor->blkno > 0) { 243 if (cursor->blkno > 0) {
244 error = xfs_da3_node_read(NULL, dp, cursor->blkno, -1, 244 error = xfs_da3_node_read(NULL, dp, cursor->blkno, -1,
245 &bp, XFS_ATTR_FORK); 245 &bp, XFS_ATTR_FORK);
246 if ((error != 0) && (error != EFSCORRUPTED)) 246 if ((error != 0) && (error != -EFSCORRUPTED))
247 return error; 247 return error;
248 if (bp) { 248 if (bp) {
249 struct xfs_attr_leaf_entry *entries; 249 struct xfs_attr_leaf_entry *entries;
@@ -308,7 +308,7 @@ xfs_attr_node_list(xfs_attr_list_context_t *context)
308 context->dp->i_mount, 308 context->dp->i_mount,
309 node); 309 node);
310 xfs_trans_brelse(NULL, bp); 310 xfs_trans_brelse(NULL, bp);
311 return EFSCORRUPTED; 311 return -EFSCORRUPTED;
312 } 312 }
313 313
314 dp->d_ops->node_hdr_from_disk(&nodehdr, node); 314 dp->d_ops->node_hdr_from_disk(&nodehdr, node);
@@ -514,7 +514,7 @@ xfs_attr_list_int(
514 XFS_STATS_INC(xs_attr_list); 514 XFS_STATS_INC(xs_attr_list);
515 515
516 if (XFS_FORCED_SHUTDOWN(dp->i_mount)) 516 if (XFS_FORCED_SHUTDOWN(dp->i_mount))
517 return EIO; 517 return -EIO;
518 518
519 /* 519 /*
520 * Decide on what work routines to call based on the inode size. 520 * Decide on what work routines to call based on the inode size.
@@ -616,16 +616,16 @@ xfs_attr_list(
616 * Validate the cursor. 616 * Validate the cursor.
617 */ 617 */
618 if (cursor->pad1 || cursor->pad2) 618 if (cursor->pad1 || cursor->pad2)
619 return EINVAL; 619 return -EINVAL;
620 if ((cursor->initted == 0) && 620 if ((cursor->initted == 0) &&
621 (cursor->hashval || cursor->blkno || cursor->offset)) 621 (cursor->hashval || cursor->blkno || cursor->offset))
622 return EINVAL; 622 return -EINVAL;
623 623
624 /* 624 /*
625 * Check for a properly aligned buffer. 625 * Check for a properly aligned buffer.
626 */ 626 */
627 if (((long)buffer) & (sizeof(int)-1)) 627 if (((long)buffer) & (sizeof(int)-1))
628 return EFAULT; 628 return -EFAULT;
629 if (flags & ATTR_KERNOVAL) 629 if (flags & ATTR_KERNOVAL)
630 bufsize = 0; 630 bufsize = 0;
631 631
@@ -648,6 +648,6 @@ xfs_attr_list(
648 alist->al_offset[0] = context.bufsize; 648 alist->al_offset[0] = context.bufsize;
649 649
650 error = xfs_attr_list_int(&context); 650 error = xfs_attr_list_int(&context);
651 ASSERT(error >= 0); 651 ASSERT(error <= 0);
652 return error; 652 return error;
653} 653}
diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c
index ee48642c2802..56f050efcac8 100644
--- a/fs/xfs/xfs_bmap_util.c
+++ b/fs/xfs/xfs_bmap_util.c
@@ -133,7 +133,7 @@ xfs_bmap_finish(
133 mp = ntp->t_mountp; 133 mp = ntp->t_mountp;
134 if (!XFS_FORCED_SHUTDOWN(mp)) 134 if (!XFS_FORCED_SHUTDOWN(mp))
135 xfs_force_shutdown(mp, 135 xfs_force_shutdown(mp,
136 (error == EFSCORRUPTED) ? 136 (error == -EFSCORRUPTED) ?
137 SHUTDOWN_CORRUPT_INCORE : 137 SHUTDOWN_CORRUPT_INCORE :
138 SHUTDOWN_META_IO_ERROR); 138 SHUTDOWN_META_IO_ERROR);
139 return error; 139 return error;
@@ -418,7 +418,7 @@ xfs_bmap_count_tree(
418 xfs_trans_brelse(tp, bp); 418 xfs_trans_brelse(tp, bp);
419 XFS_ERROR_REPORT("xfs_bmap_count_tree(1)", 419 XFS_ERROR_REPORT("xfs_bmap_count_tree(1)",
420 XFS_ERRLEVEL_LOW, mp); 420 XFS_ERRLEVEL_LOW, mp);
421 return EFSCORRUPTED; 421 return -EFSCORRUPTED;
422 } 422 }
423 xfs_trans_brelse(tp, bp); 423 xfs_trans_brelse(tp, bp);
424 } else { 424 } else {
@@ -485,7 +485,7 @@ xfs_bmap_count_blocks(
485 if (unlikely(xfs_bmap_count_tree(mp, tp, ifp, bno, level, count) < 0)) { 485 if (unlikely(xfs_bmap_count_tree(mp, tp, ifp, bno, level, count) < 0)) {
486 XFS_ERROR_REPORT("xfs_bmap_count_blocks(2)", XFS_ERRLEVEL_LOW, 486 XFS_ERROR_REPORT("xfs_bmap_count_blocks(2)", XFS_ERRLEVEL_LOW,
487 mp); 487 mp);
488 return EFSCORRUPTED; 488 return -EFSCORRUPTED;
489 } 489 }
490 490
491 return 0; 491 return 0;
@@ -577,13 +577,13 @@ xfs_getbmap(
577 if (ip->i_d.di_aformat != XFS_DINODE_FMT_EXTENTS && 577 if (ip->i_d.di_aformat != XFS_DINODE_FMT_EXTENTS &&
578 ip->i_d.di_aformat != XFS_DINODE_FMT_BTREE && 578 ip->i_d.di_aformat != XFS_DINODE_FMT_BTREE &&
579 ip->i_d.di_aformat != XFS_DINODE_FMT_LOCAL) 579 ip->i_d.di_aformat != XFS_DINODE_FMT_LOCAL)
580 return EINVAL; 580 return -EINVAL;
581 } else if (unlikely( 581 } else if (unlikely(
582 ip->i_d.di_aformat != 0 && 582 ip->i_d.di_aformat != 0 &&
583 ip->i_d.di_aformat != XFS_DINODE_FMT_EXTENTS)) { 583 ip->i_d.di_aformat != XFS_DINODE_FMT_EXTENTS)) {
584 XFS_ERROR_REPORT("xfs_getbmap", XFS_ERRLEVEL_LOW, 584 XFS_ERROR_REPORT("xfs_getbmap", XFS_ERRLEVEL_LOW,
585 ip->i_mount); 585 ip->i_mount);
586 return EFSCORRUPTED; 586 return -EFSCORRUPTED;
587 } 587 }
588 588
589 prealloced = 0; 589 prealloced = 0;
@@ -592,7 +592,7 @@ xfs_getbmap(
592 if (ip->i_d.di_format != XFS_DINODE_FMT_EXTENTS && 592 if (ip->i_d.di_format != XFS_DINODE_FMT_EXTENTS &&
593 ip->i_d.di_format != XFS_DINODE_FMT_BTREE && 593 ip->i_d.di_format != XFS_DINODE_FMT_BTREE &&
594 ip->i_d.di_format != XFS_DINODE_FMT_LOCAL) 594 ip->i_d.di_format != XFS_DINODE_FMT_LOCAL)
595 return EINVAL; 595 return -EINVAL;
596 596
597 if (xfs_get_extsz_hint(ip) || 597 if (xfs_get_extsz_hint(ip) ||
598 ip->i_d.di_flags & (XFS_DIFLAG_PREALLOC|XFS_DIFLAG_APPEND)){ 598 ip->i_d.di_flags & (XFS_DIFLAG_PREALLOC|XFS_DIFLAG_APPEND)){
@@ -612,26 +612,26 @@ xfs_getbmap(
612 bmv->bmv_entries = 0; 612 bmv->bmv_entries = 0;
613 return 0; 613 return 0;
614 } else if (bmv->bmv_length < 0) { 614 } else if (bmv->bmv_length < 0) {
615 return EINVAL; 615 return -EINVAL;
616 } 616 }
617 617
618 nex = bmv->bmv_count - 1; 618 nex = bmv->bmv_count - 1;
619 if (nex <= 0) 619 if (nex <= 0)
620 return EINVAL; 620 return -EINVAL;
621 bmvend = bmv->bmv_offset + bmv->bmv_length; 621 bmvend = bmv->bmv_offset + bmv->bmv_length;
622 622
623 623
624 if (bmv->bmv_count > ULONG_MAX / sizeof(struct getbmapx)) 624 if (bmv->bmv_count > ULONG_MAX / sizeof(struct getbmapx))
625 return ENOMEM; 625 return -ENOMEM;
626 out = kmem_zalloc_large(bmv->bmv_count * sizeof(struct getbmapx), 0); 626 out = kmem_zalloc_large(bmv->bmv_count * sizeof(struct getbmapx), 0);
627 if (!out) 627 if (!out)
628 return ENOMEM; 628 return -ENOMEM;
629 629
630 xfs_ilock(ip, XFS_IOLOCK_SHARED); 630 xfs_ilock(ip, XFS_IOLOCK_SHARED);
631 if (whichfork == XFS_DATA_FORK) { 631 if (whichfork == XFS_DATA_FORK) {
632 if (!(iflags & BMV_IF_DELALLOC) && 632 if (!(iflags & BMV_IF_DELALLOC) &&
633 (ip->i_delayed_blks || XFS_ISIZE(ip) > ip->i_d.di_size)) { 633 (ip->i_delayed_blks || XFS_ISIZE(ip) > ip->i_d.di_size)) {
634 error = -filemap_write_and_wait(VFS_I(ip)->i_mapping); 634 error = filemap_write_and_wait(VFS_I(ip)->i_mapping);
635 if (error) 635 if (error)
636 goto out_unlock_iolock; 636 goto out_unlock_iolock;
637 637
@@ -664,7 +664,7 @@ xfs_getbmap(
664 /* 664 /*
665 * Allocate enough space to handle "subnex" maps at a time. 665 * Allocate enough space to handle "subnex" maps at a time.
666 */ 666 */
667 error = ENOMEM; 667 error = -ENOMEM;
668 subnex = 16; 668 subnex = 16;
669 map = kmem_alloc(subnex * sizeof(*map), KM_MAYFAIL | KM_NOFS); 669 map = kmem_alloc(subnex * sizeof(*map), KM_MAYFAIL | KM_NOFS);
670 if (!map) 670 if (!map)
@@ -935,7 +935,7 @@ xfs_free_eofblocks(
935 if (need_iolock) { 935 if (need_iolock) {
936 if (!xfs_ilock_nowait(ip, XFS_IOLOCK_EXCL)) { 936 if (!xfs_ilock_nowait(ip, XFS_IOLOCK_EXCL)) {
937 xfs_trans_cancel(tp, 0); 937 xfs_trans_cancel(tp, 0);
938 return EAGAIN; 938 return -EAGAIN;
939 } 939 }
940 } 940 }
941 941
@@ -1008,14 +1008,14 @@ xfs_alloc_file_space(
1008 trace_xfs_alloc_file_space(ip); 1008 trace_xfs_alloc_file_space(ip);
1009 1009
1010 if (XFS_FORCED_SHUTDOWN(mp)) 1010 if (XFS_FORCED_SHUTDOWN(mp))
1011 return EIO; 1011 return -EIO;
1012 1012
1013 error = xfs_qm_dqattach(ip, 0); 1013 error = xfs_qm_dqattach(ip, 0);
1014 if (error) 1014 if (error)
1015 return error; 1015 return error;
1016 1016
1017 if (len <= 0) 1017 if (len <= 0)
1018 return EINVAL; 1018 return -EINVAL;
1019 1019
1020 rt = XFS_IS_REALTIME_INODE(ip); 1020 rt = XFS_IS_REALTIME_INODE(ip);
1021 extsz = xfs_get_extsz_hint(ip); 1021 extsz = xfs_get_extsz_hint(ip);
@@ -1081,7 +1081,7 @@ xfs_alloc_file_space(
1081 /* 1081 /*
1082 * Free the transaction structure. 1082 * Free the transaction structure.
1083 */ 1083 */
1084 ASSERT(error == ENOSPC || XFS_FORCED_SHUTDOWN(mp)); 1084 ASSERT(error == -ENOSPC || XFS_FORCED_SHUTDOWN(mp));
1085 xfs_trans_cancel(tp, 0); 1085 xfs_trans_cancel(tp, 0);
1086 break; 1086 break;
1087 } 1087 }
@@ -1118,7 +1118,7 @@ xfs_alloc_file_space(
1118 allocated_fsb = imapp->br_blockcount; 1118 allocated_fsb = imapp->br_blockcount;
1119 1119
1120 if (nimaps == 0) { 1120 if (nimaps == 0) {
1121 error = ENOSPC; 1121 error = -ENOSPC;
1122 break; 1122 break;
1123 } 1123 }
1124 1124
@@ -1179,7 +1179,7 @@ xfs_zero_remaining_bytes(
1179 mp->m_rtdev_targp : mp->m_ddev_targp, 1179 mp->m_rtdev_targp : mp->m_ddev_targp,
1180 BTOBB(mp->m_sb.sb_blocksize), 0); 1180 BTOBB(mp->m_sb.sb_blocksize), 0);
1181 if (!bp) 1181 if (!bp)
1182 return ENOMEM; 1182 return -ENOMEM;
1183 1183
1184 xfs_buf_unlock(bp); 1184 xfs_buf_unlock(bp);
1185 1185
@@ -1211,7 +1211,7 @@ xfs_zero_remaining_bytes(
1211 XFS_BUF_SET_ADDR(bp, xfs_fsb_to_db(ip, imap.br_startblock)); 1211 XFS_BUF_SET_ADDR(bp, xfs_fsb_to_db(ip, imap.br_startblock));
1212 1212
1213 if (XFS_FORCED_SHUTDOWN(mp)) { 1213 if (XFS_FORCED_SHUTDOWN(mp)) {
1214 error = EIO; 1214 error = -EIO;
1215 break; 1215 break;
1216 } 1216 }
1217 xfs_buf_iorequest(bp); 1217 xfs_buf_iorequest(bp);
@@ -1229,7 +1229,7 @@ xfs_zero_remaining_bytes(
1229 XFS_BUF_WRITE(bp); 1229 XFS_BUF_WRITE(bp);
1230 1230
1231 if (XFS_FORCED_SHUTDOWN(mp)) { 1231 if (XFS_FORCED_SHUTDOWN(mp)) {
1232 error = EIO; 1232 error = -EIO;
1233 break; 1233 break;
1234 } 1234 }
1235 xfs_buf_iorequest(bp); 1235 xfs_buf_iorequest(bp);
@@ -1287,7 +1287,7 @@ xfs_free_file_space(
1287 1287
1288 rounding = max_t(xfs_off_t, 1 << mp->m_sb.sb_blocklog, PAGE_CACHE_SIZE); 1288 rounding = max_t(xfs_off_t, 1 << mp->m_sb.sb_blocklog, PAGE_CACHE_SIZE);
1289 ioffset = offset & ~(rounding - 1); 1289 ioffset = offset & ~(rounding - 1);
1290 error = -filemap_write_and_wait_range(VFS_I(ip)->i_mapping, 1290 error = filemap_write_and_wait_range(VFS_I(ip)->i_mapping,
1291 ioffset, -1); 1291 ioffset, -1);
1292 if (error) 1292 if (error)
1293 goto out; 1293 goto out;
@@ -1368,7 +1368,7 @@ xfs_free_file_space(
1368 /* 1368 /*
1369 * Free the transaction structure. 1369 * Free the transaction structure.
1370 */ 1370 */
1371 ASSERT(error == ENOSPC || XFS_FORCED_SHUTDOWN(mp)); 1371 ASSERT(error == -ENOSPC || XFS_FORCED_SHUTDOWN(mp));
1372 xfs_trans_cancel(tp, 0); 1372 xfs_trans_cancel(tp, 0);
1373 break; 1373 break;
1374 } 1374 }
@@ -1610,14 +1610,14 @@ xfs_swap_extents_check_format(
1610 /* Should never get a local format */ 1610 /* Should never get a local format */
1611 if (ip->i_d.di_format == XFS_DINODE_FMT_LOCAL || 1611 if (ip->i_d.di_format == XFS_DINODE_FMT_LOCAL ||
1612 tip->i_d.di_format == XFS_DINODE_FMT_LOCAL) 1612 tip->i_d.di_format == XFS_DINODE_FMT_LOCAL)
1613 return EINVAL; 1613 return -EINVAL;
1614 1614
1615 /* 1615 /*
1616 * if the target inode has less extents that then temporary inode then 1616 * if the target inode has less extents that then temporary inode then
1617 * why did userspace call us? 1617 * why did userspace call us?
1618 */ 1618 */
1619 if (ip->i_d.di_nextents < tip->i_d.di_nextents) 1619 if (ip->i_d.di_nextents < tip->i_d.di_nextents)
1620 return EINVAL; 1620 return -EINVAL;
1621 1621
1622 /* 1622 /*
1623 * if the target inode is in extent form and the temp inode is in btree 1623 * if the target inode is in extent form and the temp inode is in btree
@@ -1626,19 +1626,19 @@ xfs_swap_extents_check_format(
1626 */ 1626 */
1627 if (ip->i_d.di_format == XFS_DINODE_FMT_EXTENTS && 1627 if (ip->i_d.di_format == XFS_DINODE_FMT_EXTENTS &&
1628 tip->i_d.di_format == XFS_DINODE_FMT_BTREE) 1628 tip->i_d.di_format == XFS_DINODE_FMT_BTREE)
1629 return EINVAL; 1629 return -EINVAL;
1630 1630
1631 /* Check temp in extent form to max in target */ 1631 /* Check temp in extent form to max in target */
1632 if (tip->i_d.di_format == XFS_DINODE_FMT_EXTENTS && 1632 if (tip->i_d.di_format == XFS_DINODE_FMT_EXTENTS &&
1633 XFS_IFORK_NEXTENTS(tip, XFS_DATA_FORK) > 1633 XFS_IFORK_NEXTENTS(tip, XFS_DATA_FORK) >
1634 XFS_IFORK_MAXEXT(ip, XFS_DATA_FORK)) 1634 XFS_IFORK_MAXEXT(ip, XFS_DATA_FORK))
1635 return EINVAL; 1635 return -EINVAL;
1636 1636
1637 /* Check target in extent form to max in temp */ 1637 /* Check target in extent form to max in temp */
1638 if (ip->i_d.di_format == XFS_DINODE_FMT_EXTENTS && 1638 if (ip->i_d.di_format == XFS_DINODE_FMT_EXTENTS &&
1639 XFS_IFORK_NEXTENTS(ip, XFS_DATA_FORK) > 1639 XFS_IFORK_NEXTENTS(ip, XFS_DATA_FORK) >
1640 XFS_IFORK_MAXEXT(tip, XFS_DATA_FORK)) 1640 XFS_IFORK_MAXEXT(tip, XFS_DATA_FORK))
1641 return EINVAL; 1641 return -EINVAL;
1642 1642
1643 /* 1643 /*
1644 * If we are in a btree format, check that the temp root block will fit 1644 * If we are in a btree format, check that the temp root block will fit
@@ -1652,20 +1652,20 @@ xfs_swap_extents_check_format(
1652 if (tip->i_d.di_format == XFS_DINODE_FMT_BTREE) { 1652 if (tip->i_d.di_format == XFS_DINODE_FMT_BTREE) {
1653 if (XFS_IFORK_BOFF(ip) && 1653 if (XFS_IFORK_BOFF(ip) &&
1654 XFS_BMAP_BMDR_SPACE(tip->i_df.if_broot) > XFS_IFORK_BOFF(ip)) 1654 XFS_BMAP_BMDR_SPACE(tip->i_df.if_broot) > XFS_IFORK_BOFF(ip))
1655 return EINVAL; 1655 return -EINVAL;
1656 if (XFS_IFORK_NEXTENTS(tip, XFS_DATA_FORK) <= 1656 if (XFS_IFORK_NEXTENTS(tip, XFS_DATA_FORK) <=
1657 XFS_IFORK_MAXEXT(ip, XFS_DATA_FORK)) 1657 XFS_IFORK_MAXEXT(ip, XFS_DATA_FORK))
1658 return EINVAL; 1658 return -EINVAL;
1659 } 1659 }
1660 1660
1661 /* Reciprocal target->temp btree format checks */ 1661 /* Reciprocal target->temp btree format checks */
1662 if (ip->i_d.di_format == XFS_DINODE_FMT_BTREE) { 1662 if (ip->i_d.di_format == XFS_DINODE_FMT_BTREE) {
1663 if (XFS_IFORK_BOFF(tip) && 1663 if (XFS_IFORK_BOFF(tip) &&
1664 XFS_BMAP_BMDR_SPACE(ip->i_df.if_broot) > XFS_IFORK_BOFF(tip)) 1664 XFS_BMAP_BMDR_SPACE(ip->i_df.if_broot) > XFS_IFORK_BOFF(tip))
1665 return EINVAL; 1665 return -EINVAL;
1666 if (XFS_IFORK_NEXTENTS(ip, XFS_DATA_FORK) <= 1666 if (XFS_IFORK_NEXTENTS(ip, XFS_DATA_FORK) <=
1667 XFS_IFORK_MAXEXT(tip, XFS_DATA_FORK)) 1667 XFS_IFORK_MAXEXT(tip, XFS_DATA_FORK))
1668 return EINVAL; 1668 return -EINVAL;
1669 } 1669 }
1670 1670
1671 return 0; 1671 return 0;
@@ -1689,7 +1689,7 @@ xfs_swap_extents(
1689 1689
1690 tempifp = kmem_alloc(sizeof(xfs_ifork_t), KM_MAYFAIL); 1690 tempifp = kmem_alloc(sizeof(xfs_ifork_t), KM_MAYFAIL);
1691 if (!tempifp) { 1691 if (!tempifp) {
1692 error = ENOMEM; 1692 error = -ENOMEM;
1693 goto out; 1693 goto out;
1694 } 1694 }
1695 1695
@@ -1704,24 +1704,24 @@ xfs_swap_extents(
1704 1704
1705 /* Verify that both files have the same format */ 1705 /* Verify that both files have the same format */
1706 if ((ip->i_d.di_mode & S_IFMT) != (tip->i_d.di_mode & S_IFMT)) { 1706 if ((ip->i_d.di_mode & S_IFMT) != (tip->i_d.di_mode & S_IFMT)) {
1707 error = EINVAL; 1707 error = -EINVAL;
1708 goto out_unlock; 1708 goto out_unlock;
1709 } 1709 }
1710 1710
1711 /* Verify both files are either real-time or non-realtime */ 1711 /* Verify both files are either real-time or non-realtime */
1712 if (XFS_IS_REALTIME_INODE(ip) != XFS_IS_REALTIME_INODE(tip)) { 1712 if (XFS_IS_REALTIME_INODE(ip) != XFS_IS_REALTIME_INODE(tip)) {
1713 error = EINVAL; 1713 error = -EINVAL;
1714 goto out_unlock; 1714 goto out_unlock;
1715 } 1715 }
1716 1716
1717 error = -filemap_write_and_wait(VFS_I(tip)->i_mapping); 1717 error = filemap_write_and_wait(VFS_I(tip)->i_mapping);
1718 if (error) 1718 if (error)
1719 goto out_unlock; 1719 goto out_unlock;
1720 truncate_pagecache_range(VFS_I(tip), 0, -1); 1720 truncate_pagecache_range(VFS_I(tip), 0, -1);
1721 1721
1722 /* Verify O_DIRECT for ftmp */ 1722 /* Verify O_DIRECT for ftmp */
1723 if (VN_CACHED(VFS_I(tip)) != 0) { 1723 if (VN_CACHED(VFS_I(tip)) != 0) {
1724 error = EINVAL; 1724 error = -EINVAL;
1725 goto out_unlock; 1725 goto out_unlock;
1726 } 1726 }
1727 1727
@@ -1729,7 +1729,7 @@ xfs_swap_extents(
1729 if (sxp->sx_offset != 0 || 1729 if (sxp->sx_offset != 0 ||
1730 sxp->sx_length != ip->i_d.di_size || 1730 sxp->sx_length != ip->i_d.di_size ||
1731 sxp->sx_length != tip->i_d.di_size) { 1731 sxp->sx_length != tip->i_d.di_size) {
1732 error = EFAULT; 1732 error = -EFAULT;
1733 goto out_unlock; 1733 goto out_unlock;
1734 } 1734 }
1735 1735
@@ -1756,7 +1756,7 @@ xfs_swap_extents(
1756 (sbp->bs_ctime.tv_nsec != VFS_I(ip)->i_ctime.tv_nsec) || 1756 (sbp->bs_ctime.tv_nsec != VFS_I(ip)->i_ctime.tv_nsec) ||
1757 (sbp->bs_mtime.tv_sec != VFS_I(ip)->i_mtime.tv_sec) || 1757 (sbp->bs_mtime.tv_sec != VFS_I(ip)->i_mtime.tv_sec) ||
1758 (sbp->bs_mtime.tv_nsec != VFS_I(ip)->i_mtime.tv_nsec)) { 1758 (sbp->bs_mtime.tv_nsec != VFS_I(ip)->i_mtime.tv_nsec)) {
1759 error = EBUSY; 1759 error = -EBUSY;
1760 goto out_unlock; 1760 goto out_unlock;
1761 } 1761 }
1762 1762
@@ -1767,7 +1767,7 @@ xfs_swap_extents(
1767 * until we have switched the extents. 1767 * until we have switched the extents.
1768 */ 1768 */
1769 if (VN_MAPPED(VFS_I(ip))) { 1769 if (VN_MAPPED(VFS_I(ip))) {
1770 error = EBUSY; 1770 error = -EBUSY;
1771 goto out_unlock; 1771 goto out_unlock;
1772 } 1772 }
1773 1773
diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c
index 7a34a1ae6552..a6dc83e70ece 100644
--- a/fs/xfs/xfs_buf.c
+++ b/fs/xfs/xfs_buf.c
@@ -130,7 +130,7 @@ xfs_buf_get_maps(
130 bp->b_maps = kmem_zalloc(map_count * sizeof(struct xfs_buf_map), 130 bp->b_maps = kmem_zalloc(map_count * sizeof(struct xfs_buf_map),
131 KM_NOFS); 131 KM_NOFS);
132 if (!bp->b_maps) 132 if (!bp->b_maps)
133 return ENOMEM; 133 return -ENOMEM;
134 return 0; 134 return 0;
135} 135}
136 136
@@ -344,7 +344,7 @@ retry:
344 if (unlikely(page == NULL)) { 344 if (unlikely(page == NULL)) {
345 if (flags & XBF_READ_AHEAD) { 345 if (flags & XBF_READ_AHEAD) {
346 bp->b_page_count = i; 346 bp->b_page_count = i;
347 error = ENOMEM; 347 error = -ENOMEM;
348 goto out_free_pages; 348 goto out_free_pages;
349 } 349 }
350 350
@@ -465,7 +465,7 @@ _xfs_buf_find(
465 eofs = XFS_FSB_TO_BB(btp->bt_mount, btp->bt_mount->m_sb.sb_dblocks); 465 eofs = XFS_FSB_TO_BB(btp->bt_mount, btp->bt_mount->m_sb.sb_dblocks);
466 if (blkno >= eofs) { 466 if (blkno >= eofs) {
467 /* 467 /*
468 * XXX (dgc): we should really be returning EFSCORRUPTED here, 468 * XXX (dgc): we should really be returning -EFSCORRUPTED here,
469 * but none of the higher level infrastructure supports 469 * but none of the higher level infrastructure supports
470 * returning a specific error on buffer lookup failures. 470 * returning a specific error on buffer lookup failures.
471 */ 471 */
@@ -1052,8 +1052,8 @@ xfs_buf_ioerror(
1052 xfs_buf_t *bp, 1052 xfs_buf_t *bp,
1053 int error) 1053 int error)
1054{ 1054{
1055 ASSERT(error >= 0 && error <= 0xffff); 1055 ASSERT(error <= 0 && error >= -1000);
1056 bp->b_error = (unsigned short)error; 1056 bp->b_error = error;
1057 trace_xfs_buf_ioerror(bp, error, _RET_IP_); 1057 trace_xfs_buf_ioerror(bp, error, _RET_IP_);
1058} 1058}
1059 1059
@@ -1064,7 +1064,7 @@ xfs_buf_ioerror_alert(
1064{ 1064{
1065 xfs_alert(bp->b_target->bt_mount, 1065 xfs_alert(bp->b_target->bt_mount,
1066"metadata I/O error: block 0x%llx (\"%s\") error %d numblks %d", 1066"metadata I/O error: block 0x%llx (\"%s\") error %d numblks %d",
1067 (__uint64_t)XFS_BUF_ADDR(bp), func, bp->b_error, bp->b_length); 1067 (__uint64_t)XFS_BUF_ADDR(bp), func, -bp->b_error, bp->b_length);
1068} 1068}
1069 1069
1070/* 1070/*
@@ -1083,7 +1083,7 @@ xfs_bioerror(
1083 /* 1083 /*
1084 * No need to wait until the buffer is unpinned, we aren't flushing it. 1084 * No need to wait until the buffer is unpinned, we aren't flushing it.
1085 */ 1085 */
1086 xfs_buf_ioerror(bp, EIO); 1086 xfs_buf_ioerror(bp, -EIO);
1087 1087
1088 /* 1088 /*
1089 * We're calling xfs_buf_ioend, so delete XBF_DONE flag. 1089 * We're calling xfs_buf_ioend, so delete XBF_DONE flag.
@@ -1094,7 +1094,7 @@ xfs_bioerror(
1094 1094
1095 xfs_buf_ioend(bp, 0); 1095 xfs_buf_ioend(bp, 0);
1096 1096
1097 return EIO; 1097 return -EIO;
1098} 1098}
1099 1099
1100/* 1100/*
@@ -1127,13 +1127,13 @@ xfs_bioerror_relse(
1127 * There's no reason to mark error for 1127 * There's no reason to mark error for
1128 * ASYNC buffers. 1128 * ASYNC buffers.
1129 */ 1129 */
1130 xfs_buf_ioerror(bp, EIO); 1130 xfs_buf_ioerror(bp, -EIO);
1131 complete(&bp->b_iowait); 1131 complete(&bp->b_iowait);
1132 } else { 1132 } else {
1133 xfs_buf_relse(bp); 1133 xfs_buf_relse(bp);
1134 } 1134 }
1135 1135
1136 return EIO; 1136 return -EIO;
1137} 1137}
1138 1138
1139STATIC int 1139STATIC int
@@ -1199,7 +1199,7 @@ xfs_buf_bio_end_io(
1199 * buffers that require multiple bios to complete. 1199 * buffers that require multiple bios to complete.
1200 */ 1200 */
1201 if (!bp->b_error) 1201 if (!bp->b_error)
1202 xfs_buf_ioerror(bp, -error); 1202 xfs_buf_ioerror(bp, error);
1203 1203
1204 if (!bp->b_error && xfs_buf_is_vmapped(bp) && (bp->b_flags & XBF_READ)) 1204 if (!bp->b_error && xfs_buf_is_vmapped(bp) && (bp->b_flags & XBF_READ))
1205 invalidate_kernel_vmap_range(bp->b_addr, xfs_buf_vmap_len(bp)); 1205 invalidate_kernel_vmap_range(bp->b_addr, xfs_buf_vmap_len(bp));
@@ -1286,7 +1286,7 @@ next_chunk:
1286 * because the caller (xfs_buf_iorequest) holds a count itself. 1286 * because the caller (xfs_buf_iorequest) holds a count itself.
1287 */ 1287 */
1288 atomic_dec(&bp->b_io_remaining); 1288 atomic_dec(&bp->b_io_remaining);
1289 xfs_buf_ioerror(bp, EIO); 1289 xfs_buf_ioerror(bp, -EIO);
1290 bio_put(bio); 1290 bio_put(bio);
1291 } 1291 }
1292 1292
@@ -1628,7 +1628,7 @@ xfs_setsize_buftarg(
1628 xfs_warn(btp->bt_mount, 1628 xfs_warn(btp->bt_mount,
1629 "Cannot set_blocksize to %u on device %s", 1629 "Cannot set_blocksize to %u on device %s",
1630 sectorsize, name); 1630 sectorsize, name);
1631 return EINVAL; 1631 return -EINVAL;
1632 } 1632 }
1633 1633
1634 /* Set up device logical sector size mask */ 1634 /* Set up device logical sector size mask */
diff --git a/fs/xfs/xfs_buf.h b/fs/xfs/xfs_buf.h
index 3a7a5523d3dc..c753183900b3 100644
--- a/fs/xfs/xfs_buf.h
+++ b/fs/xfs/xfs_buf.h
@@ -178,7 +178,7 @@ typedef struct xfs_buf {
178 atomic_t b_io_remaining; /* #outstanding I/O requests */ 178 atomic_t b_io_remaining; /* #outstanding I/O requests */
179 unsigned int b_page_count; /* size of page array */ 179 unsigned int b_page_count; /* size of page array */
180 unsigned int b_offset; /* page offset in first page */ 180 unsigned int b_offset; /* page offset in first page */
181 unsigned short b_error; /* error code on I/O */ 181 int b_error; /* error code on I/O */
182 const struct xfs_buf_ops *b_ops; 182 const struct xfs_buf_ops *b_ops;
183 183
184#ifdef XFS_BUF_LOCK_TRACKING 184#ifdef XFS_BUF_LOCK_TRACKING
diff --git a/fs/xfs/xfs_buf_item.c b/fs/xfs/xfs_buf_item.c
index 4654338b03fc..76007deed31f 100644
--- a/fs/xfs/xfs_buf_item.c
+++ b/fs/xfs/xfs_buf_item.c
@@ -488,7 +488,7 @@ xfs_buf_item_unpin(
488 xfs_buf_lock(bp); 488 xfs_buf_lock(bp);
489 xfs_buf_hold(bp); 489 xfs_buf_hold(bp);
490 bp->b_flags |= XBF_ASYNC; 490 bp->b_flags |= XBF_ASYNC;
491 xfs_buf_ioerror(bp, EIO); 491 xfs_buf_ioerror(bp, -EIO);
492 XFS_BUF_UNDONE(bp); 492 XFS_BUF_UNDONE(bp);
493 xfs_buf_stale(bp); 493 xfs_buf_stale(bp);
494 xfs_buf_ioend(bp, 0); 494 xfs_buf_ioend(bp, 0);
@@ -725,7 +725,7 @@ xfs_buf_item_get_format(
725 bip->bli_formats = kmem_zalloc(count * sizeof(struct xfs_buf_log_format), 725 bip->bli_formats = kmem_zalloc(count * sizeof(struct xfs_buf_log_format),
726 KM_SLEEP); 726 KM_SLEEP);
727 if (!bip->bli_formats) 727 if (!bip->bli_formats)
728 return ENOMEM; 728 return -ENOMEM;
729 return 0; 729 return 0;
730} 730}
731 731
diff --git a/fs/xfs/xfs_dir2_readdir.c b/fs/xfs/xfs_dir2_readdir.c
index 02390739abf7..f1b69edcdf31 100644
--- a/fs/xfs/xfs_dir2_readdir.c
+++ b/fs/xfs/xfs_dir2_readdir.c
@@ -95,7 +95,7 @@ xfs_dir2_sf_getdents(
95 */ 95 */
96 if (dp->i_d.di_size < offsetof(xfs_dir2_sf_hdr_t, parent)) { 96 if (dp->i_d.di_size < offsetof(xfs_dir2_sf_hdr_t, parent)) {
97 ASSERT(XFS_FORCED_SHUTDOWN(dp->i_mount)); 97 ASSERT(XFS_FORCED_SHUTDOWN(dp->i_mount));
98 return EIO; 98 return -EIO;
99 } 99 }
100 100
101 ASSERT(dp->i_df.if_bytes == dp->i_d.di_size); 101 ASSERT(dp->i_df.if_bytes == dp->i_d.di_size);
@@ -677,7 +677,7 @@ xfs_readdir(
677 trace_xfs_readdir(dp); 677 trace_xfs_readdir(dp);
678 678
679 if (XFS_FORCED_SHUTDOWN(dp->i_mount)) 679 if (XFS_FORCED_SHUTDOWN(dp->i_mount))
680 return EIO; 680 return -EIO;
681 681
682 ASSERT(S_ISDIR(dp->i_d.di_mode)); 682 ASSERT(S_ISDIR(dp->i_d.di_mode));
683 XFS_STATS_INC(xs_dir_getdents); 683 XFS_STATS_INC(xs_dir_getdents);
diff --git a/fs/xfs/xfs_discard.c b/fs/xfs/xfs_discard.c
index 3fee16e63f3a..13d08a1b390e 100644
--- a/fs/xfs/xfs_discard.c
+++ b/fs/xfs/xfs_discard.c
@@ -124,7 +124,7 @@ xfs_trim_extents(
124 } 124 }
125 125
126 trace_xfs_discard_extent(mp, agno, fbno, flen); 126 trace_xfs_discard_extent(mp, agno, fbno, flen);
127 error = -blkdev_issue_discard(bdev, dbno, dlen, GFP_NOFS, 0); 127 error = blkdev_issue_discard(bdev, dbno, dlen, GFP_NOFS, 0);
128 if (error) 128 if (error)
129 goto out_del_cursor; 129 goto out_del_cursor;
130 *blocks_trimmed += flen; 130 *blocks_trimmed += flen;
@@ -195,7 +195,7 @@ xfs_ioc_trim(
195 end_agno = xfs_daddr_to_agno(mp, end); 195 end_agno = xfs_daddr_to_agno(mp, end);
196 196
197 for (agno = start_agno; agno <= end_agno; agno++) { 197 for (agno = start_agno; agno <= end_agno; agno++) {
198 error = -xfs_trim_extents(mp, agno, start, end, minlen, 198 error = xfs_trim_extents(mp, agno, start, end, minlen,
199 &blocks_trimmed); 199 &blocks_trimmed);
200 if (error) 200 if (error)
201 last_error = error; 201 last_error = error;
@@ -222,11 +222,11 @@ xfs_discard_extents(
222 trace_xfs_discard_extent(mp, busyp->agno, busyp->bno, 222 trace_xfs_discard_extent(mp, busyp->agno, busyp->bno,
223 busyp->length); 223 busyp->length);
224 224
225 error = -blkdev_issue_discard(mp->m_ddev_targp->bt_bdev, 225 error = blkdev_issue_discard(mp->m_ddev_targp->bt_bdev,
226 XFS_AGB_TO_DADDR(mp, busyp->agno, busyp->bno), 226 XFS_AGB_TO_DADDR(mp, busyp->agno, busyp->bno),
227 XFS_FSB_TO_BB(mp, busyp->length), 227 XFS_FSB_TO_BB(mp, busyp->length),
228 GFP_NOFS, 0); 228 GFP_NOFS, 0);
229 if (error && error != EOPNOTSUPP) { 229 if (error && error != -EOPNOTSUPP) {
230 xfs_info(mp, 230 xfs_info(mp,
231 "discard failed for extent [0x%llu,%u], error %d", 231 "discard failed for extent [0x%llu,%u], error %d",
232 (unsigned long long)busyp->bno, 232 (unsigned long long)busyp->bno,
diff --git a/fs/xfs/xfs_dquot.c b/fs/xfs/xfs_dquot.c
index 3ee242686181..8a44a79f49af 100644
--- a/fs/xfs/xfs_dquot.c
+++ b/fs/xfs/xfs_dquot.c
@@ -327,7 +327,7 @@ xfs_qm_dqalloc(
327 */ 327 */
328 if (!xfs_this_quota_on(dqp->q_mount, dqp->dq_flags)) { 328 if (!xfs_this_quota_on(dqp->q_mount, dqp->dq_flags)) {
329 xfs_iunlock(quotip, XFS_ILOCK_EXCL); 329 xfs_iunlock(quotip, XFS_ILOCK_EXCL);
330 return ESRCH; 330 return -ESRCH;
331 } 331 }
332 332
333 xfs_trans_ijoin(tp, quotip, XFS_ILOCK_EXCL); 333 xfs_trans_ijoin(tp, quotip, XFS_ILOCK_EXCL);
@@ -354,7 +354,7 @@ xfs_qm_dqalloc(
354 mp->m_quotainfo->qi_dqchunklen, 354 mp->m_quotainfo->qi_dqchunklen,
355 0); 355 0);
356 if (!bp) { 356 if (!bp) {
357 error = ENOMEM; 357 error = -ENOMEM;
358 goto error1; 358 goto error1;
359 } 359 }
360 bp->b_ops = &xfs_dquot_buf_ops; 360 bp->b_ops = &xfs_dquot_buf_ops;
@@ -442,7 +442,7 @@ xfs_qm_dqrepair(
442 if (error) { 442 if (error) {
443 /* repair failed, we're screwed */ 443 /* repair failed, we're screwed */
444 xfs_trans_brelse(tp, *bpp); 444 xfs_trans_brelse(tp, *bpp);
445 return EIO; 445 return -EIO;
446 } 446 }
447 } 447 }
448 448
@@ -480,7 +480,7 @@ xfs_qm_dqtobp(
480 * didn't have the quota inode lock. 480 * didn't have the quota inode lock.
481 */ 481 */
482 xfs_iunlock(quotip, lock_mode); 482 xfs_iunlock(quotip, lock_mode);
483 return ESRCH; 483 return -ESRCH;
484 } 484 }
485 485
486 /* 486 /*
@@ -508,7 +508,7 @@ xfs_qm_dqtobp(
508 * We don't allocate unless we're asked to 508 * We don't allocate unless we're asked to
509 */ 509 */
510 if (!(flags & XFS_QMOPT_DQALLOC)) 510 if (!(flags & XFS_QMOPT_DQALLOC))
511 return ENOENT; 511 return -ENOENT;
512 512
513 ASSERT(tp); 513 ASSERT(tp);
514 error = xfs_qm_dqalloc(tpp, mp, dqp, quotip, 514 error = xfs_qm_dqalloc(tpp, mp, dqp, quotip,
@@ -530,7 +530,7 @@ xfs_qm_dqtobp(
530 mp->m_quotainfo->qi_dqchunklen, 530 mp->m_quotainfo->qi_dqchunklen,
531 0, &bp, &xfs_dquot_buf_ops); 531 0, &bp, &xfs_dquot_buf_ops);
532 532
533 if (error == EFSCORRUPTED && (flags & XFS_QMOPT_DQREPAIR)) { 533 if (error == -EFSCORRUPTED && (flags & XFS_QMOPT_DQREPAIR)) {
534 xfs_dqid_t firstid = (xfs_dqid_t)map.br_startoff * 534 xfs_dqid_t firstid = (xfs_dqid_t)map.br_startoff *
535 mp->m_quotainfo->qi_dqperchunk; 535 mp->m_quotainfo->qi_dqperchunk;
536 ASSERT(bp == NULL); 536 ASSERT(bp == NULL);
@@ -715,7 +715,7 @@ xfs_qm_dqget(
715 if ((! XFS_IS_UQUOTA_ON(mp) && type == XFS_DQ_USER) || 715 if ((! XFS_IS_UQUOTA_ON(mp) && type == XFS_DQ_USER) ||
716 (! XFS_IS_PQUOTA_ON(mp) && type == XFS_DQ_PROJ) || 716 (! XFS_IS_PQUOTA_ON(mp) && type == XFS_DQ_PROJ) ||
717 (! XFS_IS_GQUOTA_ON(mp) && type == XFS_DQ_GROUP)) { 717 (! XFS_IS_GQUOTA_ON(mp) && type == XFS_DQ_GROUP)) {
718 return ESRCH; 718 return -ESRCH;
719 } 719 }
720 720
721#ifdef DEBUG 721#ifdef DEBUG
@@ -723,7 +723,7 @@ xfs_qm_dqget(
723 if ((xfs_dqerror_target == mp->m_ddev_targp) && 723 if ((xfs_dqerror_target == mp->m_ddev_targp) &&
724 (xfs_dqreq_num++ % xfs_dqerror_mod) == 0) { 724 (xfs_dqreq_num++ % xfs_dqerror_mod) == 0) {
725 xfs_debug(mp, "Returning error in dqget"); 725 xfs_debug(mp, "Returning error in dqget");
726 return EIO; 726 return -EIO;
727 } 727 }
728 } 728 }
729 729
@@ -796,14 +796,14 @@ restart:
796 } else { 796 } else {
797 /* inode stays locked on return */ 797 /* inode stays locked on return */
798 xfs_qm_dqdestroy(dqp); 798 xfs_qm_dqdestroy(dqp);
799 return ESRCH; 799 return -ESRCH;
800 } 800 }
801 } 801 }
802 802
803 mutex_lock(&qi->qi_tree_lock); 803 mutex_lock(&qi->qi_tree_lock);
804 error = -radix_tree_insert(tree, id, dqp); 804 error = radix_tree_insert(tree, id, dqp);
805 if (unlikely(error)) { 805 if (unlikely(error)) {
806 WARN_ON(error != EEXIST); 806 WARN_ON(error != -EEXIST);
807 807
808 /* 808 /*
809 * Duplicate found. Just throw away the new dquot and start 809 * Duplicate found. Just throw away the new dquot and start
@@ -966,7 +966,7 @@ xfs_qm_dqflush(
966 SHUTDOWN_CORRUPT_INCORE); 966 SHUTDOWN_CORRUPT_INCORE);
967 else 967 else
968 spin_unlock(&mp->m_ail->xa_lock); 968 spin_unlock(&mp->m_ail->xa_lock);
969 error = EIO; 969 error = -EIO;
970 goto out_unlock; 970 goto out_unlock;
971 } 971 }
972 972
@@ -992,7 +992,7 @@ xfs_qm_dqflush(
992 xfs_buf_relse(bp); 992 xfs_buf_relse(bp);
993 xfs_dqfunlock(dqp); 993 xfs_dqfunlock(dqp);
994 xfs_force_shutdown(mp, SHUTDOWN_CORRUPT_INCORE); 994 xfs_force_shutdown(mp, SHUTDOWN_CORRUPT_INCORE);
995 return EIO; 995 return -EIO;
996 } 996 }
997 997
998 /* This is the only portion of data that needs to persist */ 998 /* This is the only portion of data that needs to persist */
@@ -1045,7 +1045,7 @@ xfs_qm_dqflush(
1045 1045
1046out_unlock: 1046out_unlock:
1047 xfs_dqfunlock(dqp); 1047 xfs_dqfunlock(dqp);
1048 return EIO; 1048 return -EIO;
1049} 1049}
1050 1050
1051/* 1051/*
diff --git a/fs/xfs/xfs_error.c b/fs/xfs/xfs_error.c
index 14f98c2f0daf..b92fd7bc49e3 100644
--- a/fs/xfs/xfs_error.c
+++ b/fs/xfs/xfs_error.c
@@ -167,7 +167,7 @@ xfs_verifier_error(
167 struct xfs_mount *mp = bp->b_target->bt_mount; 167 struct xfs_mount *mp = bp->b_target->bt_mount;
168 168
169 xfs_alert(mp, "Metadata %s detected at %pF, block 0x%llx", 169 xfs_alert(mp, "Metadata %s detected at %pF, block 0x%llx",
170 bp->b_error == EFSBADCRC ? "CRC error" : "corruption", 170 bp->b_error == -EFSBADCRC ? "CRC error" : "corruption",
171 __return_address, bp->b_bn); 171 __return_address, bp->b_bn);
172 172
173 xfs_alert(mp, "Unmount and run xfs_repair"); 173 xfs_alert(mp, "Unmount and run xfs_repair");
diff --git a/fs/xfs/xfs_error.h b/fs/xfs/xfs_error.h
index a2b5b4cfd228..279a76e52791 100644
--- a/fs/xfs/xfs_error.h
+++ b/fs/xfs/xfs_error.h
@@ -47,7 +47,7 @@ extern void xfs_verifier_error(struct xfs_buf *bp);
47 if (unlikely(!fs_is_ok)) { \ 47 if (unlikely(!fs_is_ok)) { \
48 XFS_ERROR_REPORT("XFS_WANT_CORRUPTED_GOTO", \ 48 XFS_ERROR_REPORT("XFS_WANT_CORRUPTED_GOTO", \
49 XFS_ERRLEVEL_LOW, NULL); \ 49 XFS_ERRLEVEL_LOW, NULL); \
50 error = EFSCORRUPTED; \ 50 error = -EFSCORRUPTED; \
51 goto l; \ 51 goto l; \
52 } \ 52 } \
53 } 53 }
@@ -59,7 +59,7 @@ extern void xfs_verifier_error(struct xfs_buf *bp);
59 if (unlikely(!fs_is_ok)) { \ 59 if (unlikely(!fs_is_ok)) { \
60 XFS_ERROR_REPORT("XFS_WANT_CORRUPTED_RETURN", \ 60 XFS_ERROR_REPORT("XFS_WANT_CORRUPTED_RETURN", \
61 XFS_ERRLEVEL_LOW, NULL); \ 61 XFS_ERRLEVEL_LOW, NULL); \
62 return EFSCORRUPTED; \ 62 return -EFSCORRUPTED; \
63 } \ 63 } \
64 } 64 }
65 65
diff --git a/fs/xfs/xfs_export.c b/fs/xfs/xfs_export.c
index 753e467aa1a5..5a6bd5d8779a 100644
--- a/fs/xfs/xfs_export.c
+++ b/fs/xfs/xfs_export.c
@@ -147,9 +147,9 @@ xfs_nfs_get_inode(
147 * We don't use ESTALE directly down the chain to not 147 * We don't use ESTALE directly down the chain to not
148 * confuse applications using bulkstat that expect EINVAL. 148 * confuse applications using bulkstat that expect EINVAL.
149 */ 149 */
150 if (error == EINVAL || error == ENOENT) 150 if (error == -EINVAL || error == -ENOENT)
151 error = ESTALE; 151 error = -ESTALE;
152 return ERR_PTR(-error); 152 return ERR_PTR(error);
153 } 153 }
154 154
155 if (ip->i_d.di_gen != generation) { 155 if (ip->i_d.di_gen != generation) {
@@ -217,7 +217,7 @@ xfs_fs_get_parent(
217 217
218 error = xfs_lookup(XFS_I(child->d_inode), &xfs_name_dotdot, &cip, NULL); 218 error = xfs_lookup(XFS_I(child->d_inode), &xfs_name_dotdot, &cip, NULL);
219 if (unlikely(error)) 219 if (unlikely(error))
220 return ERR_PTR(-error); 220 return ERR_PTR(error);
221 221
222 return d_obtain_alias(VFS_I(cip)); 222 return d_obtain_alias(VFS_I(cip));
223} 223}
@@ -237,7 +237,7 @@ xfs_fs_nfs_commit_metadata(
237 237
238 if (!lsn) 238 if (!lsn)
239 return 0; 239 return 0;
240 return -_xfs_log_force_lsn(mp, lsn, XFS_LOG_SYNC, NULL); 240 return _xfs_log_force_lsn(mp, lsn, XFS_LOG_SYNC, NULL);
241} 241}
242 242
243const struct export_operations xfs_export_operations = { 243const struct export_operations xfs_export_operations = {
diff --git a/fs/xfs/xfs_extfree_item.c b/fs/xfs/xfs_extfree_item.c
index fb7a4c1ce1c5..c4327419dc5c 100644
--- a/fs/xfs/xfs_extfree_item.c
+++ b/fs/xfs/xfs_extfree_item.c
@@ -298,7 +298,7 @@ xfs_efi_copy_format(xfs_log_iovec_t *buf, xfs_efi_log_format_t *dst_efi_fmt)
298 } 298 }
299 return 0; 299 return 0;
300 } 300 }
301 return EFSCORRUPTED; 301 return -EFSCORRUPTED;
302} 302}
303 303
304/* 304/*
diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c
index 754caa0e8ef2..181605da08e4 100644
--- a/fs/xfs/xfs_file.c
+++ b/fs/xfs/xfs_file.c
@@ -155,7 +155,7 @@ xfs_dir_fsync(
155 155
156 if (!lsn) 156 if (!lsn)
157 return 0; 157 return 0;
158 return -_xfs_log_force_lsn(mp, lsn, XFS_LOG_SYNC, NULL); 158 return _xfs_log_force_lsn(mp, lsn, XFS_LOG_SYNC, NULL);
159} 159}
160 160
161STATIC int 161STATIC int
@@ -225,7 +225,7 @@ xfs_file_fsync(
225 !log_flushed) 225 !log_flushed)
226 xfs_blkdev_issue_flush(mp->m_ddev_targp); 226 xfs_blkdev_issue_flush(mp->m_ddev_targp);
227 227
228 return -error; 228 return error;
229} 229}
230 230
231STATIC ssize_t 231STATIC ssize_t
@@ -524,7 +524,7 @@ restart:
524 xfs_rw_ilock(ip, *iolock); 524 xfs_rw_ilock(ip, *iolock);
525 goto restart; 525 goto restart;
526 } 526 }
527 error = -xfs_zero_eof(ip, *pos, i_size_read(inode)); 527 error = xfs_zero_eof(ip, *pos, i_size_read(inode));
528 if (error) 528 if (error)
529 return error; 529 return error;
530 } 530 }
@@ -772,7 +772,7 @@ xfs_file_fallocate(
772 unsigned blksize_mask = (1 << inode->i_blkbits) - 1; 772 unsigned blksize_mask = (1 << inode->i_blkbits) - 1;
773 773
774 if (offset & blksize_mask || len & blksize_mask) { 774 if (offset & blksize_mask || len & blksize_mask) {
775 error = EINVAL; 775 error = -EINVAL;
776 goto out_unlock; 776 goto out_unlock;
777 } 777 }
778 778
@@ -781,7 +781,7 @@ xfs_file_fallocate(
781 * in which case it is effectively a truncate operation 781 * in which case it is effectively a truncate operation
782 */ 782 */
783 if (offset + len >= i_size_read(inode)) { 783 if (offset + len >= i_size_read(inode)) {
784 error = EINVAL; 784 error = -EINVAL;
785 goto out_unlock; 785 goto out_unlock;
786 } 786 }
787 787
@@ -794,7 +794,7 @@ xfs_file_fallocate(
794 if (!(mode & FALLOC_FL_KEEP_SIZE) && 794 if (!(mode & FALLOC_FL_KEEP_SIZE) &&
795 offset + len > i_size_read(inode)) { 795 offset + len > i_size_read(inode)) {
796 new_size = offset + len; 796 new_size = offset + len;
797 error = -inode_newsize_ok(inode, new_size); 797 error = inode_newsize_ok(inode, new_size);
798 if (error) 798 if (error)
799 goto out_unlock; 799 goto out_unlock;
800 } 800 }
@@ -844,7 +844,7 @@ xfs_file_fallocate(
844 844
845out_unlock: 845out_unlock:
846 xfs_iunlock(ip, XFS_IOLOCK_EXCL); 846 xfs_iunlock(ip, XFS_IOLOCK_EXCL);
847 return -error; 847 return error;
848} 848}
849 849
850 850
@@ -889,7 +889,7 @@ xfs_file_release(
889 struct inode *inode, 889 struct inode *inode,
890 struct file *filp) 890 struct file *filp)
891{ 891{
892 return -xfs_release(XFS_I(inode)); 892 return xfs_release(XFS_I(inode));
893} 893}
894 894
895STATIC int 895STATIC int
@@ -918,7 +918,7 @@ xfs_file_readdir(
918 918
919 error = xfs_readdir(ip, ctx, bufsize); 919 error = xfs_readdir(ip, ctx, bufsize);
920 if (error) 920 if (error)
921 return -error; 921 return error;
922 return 0; 922 return 0;
923} 923}
924 924
@@ -1184,7 +1184,7 @@ xfs_seek_data(
1184 1184
1185 isize = i_size_read(inode); 1185 isize = i_size_read(inode);
1186 if (start >= isize) { 1186 if (start >= isize) {
1187 error = ENXIO; 1187 error = -ENXIO;
1188 goto out_unlock; 1188 goto out_unlock;
1189 } 1189 }
1190 1190
@@ -1206,7 +1206,7 @@ xfs_seek_data(
1206 1206
1207 /* No extents at given offset, must be beyond EOF */ 1207 /* No extents at given offset, must be beyond EOF */
1208 if (nmap == 0) { 1208 if (nmap == 0) {
1209 error = ENXIO; 1209 error = -ENXIO;
1210 goto out_unlock; 1210 goto out_unlock;
1211 } 1211 }
1212 1212
@@ -1237,7 +1237,7 @@ xfs_seek_data(
1237 * we are reading after EOF if nothing in map[1]. 1237 * we are reading after EOF if nothing in map[1].
1238 */ 1238 */
1239 if (nmap == 1) { 1239 if (nmap == 1) {
1240 error = ENXIO; 1240 error = -ENXIO;
1241 goto out_unlock; 1241 goto out_unlock;
1242 } 1242 }
1243 1243
@@ -1250,7 +1250,7 @@ xfs_seek_data(
1250 fsbno = map[i - 1].br_startoff + map[i - 1].br_blockcount; 1250 fsbno = map[i - 1].br_startoff + map[i - 1].br_blockcount;
1251 start = XFS_FSB_TO_B(mp, fsbno); 1251 start = XFS_FSB_TO_B(mp, fsbno);
1252 if (start >= isize) { 1252 if (start >= isize) {
1253 error = ENXIO; 1253 error = -ENXIO;
1254 goto out_unlock; 1254 goto out_unlock;
1255 } 1255 }
1256 } 1256 }
@@ -1262,7 +1262,7 @@ out_unlock:
1262 xfs_iunlock(ip, lock); 1262 xfs_iunlock(ip, lock);
1263 1263
1264 if (error) 1264 if (error)
1265 return -error; 1265 return error;
1266 return offset; 1266 return offset;
1267} 1267}
1268 1268
@@ -1288,7 +1288,7 @@ xfs_seek_hole(
1288 1288
1289 isize = i_size_read(inode); 1289 isize = i_size_read(inode);
1290 if (start >= isize) { 1290 if (start >= isize) {
1291 error = ENXIO; 1291 error = -ENXIO;
1292 goto out_unlock; 1292 goto out_unlock;
1293 } 1293 }
1294 1294
@@ -1307,7 +1307,7 @@ xfs_seek_hole(
1307 1307
1308 /* No extents at given offset, must be beyond EOF */ 1308 /* No extents at given offset, must be beyond EOF */
1309 if (nmap == 0) { 1309 if (nmap == 0) {
1310 error = ENXIO; 1310 error = -ENXIO;
1311 goto out_unlock; 1311 goto out_unlock;
1312 } 1312 }
1313 1313
@@ -1370,7 +1370,7 @@ out_unlock:
1370 xfs_iunlock(ip, lock); 1370 xfs_iunlock(ip, lock);
1371 1371
1372 if (error) 1372 if (error)
1373 return -error; 1373 return error;
1374 return offset; 1374 return offset;
1375} 1375}
1376 1376
diff --git a/fs/xfs/xfs_filestream.c b/fs/xfs/xfs_filestream.c
index 8ec81bed7992..e92730c1d3ca 100644
--- a/fs/xfs/xfs_filestream.c
+++ b/fs/xfs/xfs_filestream.c
@@ -258,7 +258,7 @@ next_ag:
258 if (*agp == NULLAGNUMBER) 258 if (*agp == NULLAGNUMBER)
259 return 0; 259 return 0;
260 260
261 err = ENOMEM; 261 err = -ENOMEM;
262 item = kmem_alloc(sizeof(*item), KM_MAYFAIL); 262 item = kmem_alloc(sizeof(*item), KM_MAYFAIL);
263 if (!item) 263 if (!item)
264 goto out_put_ag; 264 goto out_put_ag;
@@ -268,7 +268,7 @@ next_ag:
268 268
269 err = xfs_mru_cache_insert(mp->m_filestream, ip->i_ino, &item->mru); 269 err = xfs_mru_cache_insert(mp->m_filestream, ip->i_ino, &item->mru);
270 if (err) { 270 if (err) {
271 if (err == EEXIST) 271 if (err == -EEXIST)
272 err = 0; 272 err = 0;
273 goto out_free_item; 273 goto out_free_item;
274 } 274 }
diff --git a/fs/xfs/xfs_fsops.c b/fs/xfs/xfs_fsops.c
index 4334638b7b83..f91de1ef05e1 100644
--- a/fs/xfs/xfs_fsops.c
+++ b/fs/xfs/xfs_fsops.c
@@ -168,7 +168,7 @@ xfs_growfs_data_private(
168 nb = in->newblocks; 168 nb = in->newblocks;
169 pct = in->imaxpct; 169 pct = in->imaxpct;
170 if (nb < mp->m_sb.sb_dblocks || pct < 0 || pct > 100) 170 if (nb < mp->m_sb.sb_dblocks || pct < 0 || pct > 100)
171 return EINVAL; 171 return -EINVAL;
172 if ((error = xfs_sb_validate_fsb_count(&mp->m_sb, nb))) 172 if ((error = xfs_sb_validate_fsb_count(&mp->m_sb, nb)))
173 return error; 173 return error;
174 dpct = pct - mp->m_sb.sb_imax_pct; 174 dpct = pct - mp->m_sb.sb_imax_pct;
@@ -176,7 +176,7 @@ xfs_growfs_data_private(
176 XFS_FSB_TO_BB(mp, nb) - XFS_FSS_TO_BB(mp, 1), 176 XFS_FSB_TO_BB(mp, nb) - XFS_FSS_TO_BB(mp, 1),
177 XFS_FSS_TO_BB(mp, 1), 0, NULL); 177 XFS_FSS_TO_BB(mp, 1), 0, NULL);
178 if (!bp) 178 if (!bp)
179 return EIO; 179 return -EIO;
180 if (bp->b_error) { 180 if (bp->b_error) {
181 error = bp->b_error; 181 error = bp->b_error;
182 xfs_buf_relse(bp); 182 xfs_buf_relse(bp);
@@ -191,7 +191,7 @@ xfs_growfs_data_private(
191 nagcount--; 191 nagcount--;
192 nb = (xfs_rfsblock_t)nagcount * mp->m_sb.sb_agblocks; 192 nb = (xfs_rfsblock_t)nagcount * mp->m_sb.sb_agblocks;
193 if (nb < mp->m_sb.sb_dblocks) 193 if (nb < mp->m_sb.sb_dblocks)
194 return EINVAL; 194 return -EINVAL;
195 } 195 }
196 new = nb - mp->m_sb.sb_dblocks; 196 new = nb - mp->m_sb.sb_dblocks;
197 oagcount = mp->m_sb.sb_agcount; 197 oagcount = mp->m_sb.sb_agcount;
@@ -229,7 +229,7 @@ xfs_growfs_data_private(
229 XFS_FSS_TO_BB(mp, 1), 0, 229 XFS_FSS_TO_BB(mp, 1), 0,
230 &xfs_agf_buf_ops); 230 &xfs_agf_buf_ops);
231 if (!bp) { 231 if (!bp) {
232 error = ENOMEM; 232 error = -ENOMEM;
233 goto error0; 233 goto error0;
234 } 234 }
235 235
@@ -270,7 +270,7 @@ xfs_growfs_data_private(
270 XFS_FSS_TO_BB(mp, 1), 0, 270 XFS_FSS_TO_BB(mp, 1), 0,
271 &xfs_agfl_buf_ops); 271 &xfs_agfl_buf_ops);
272 if (!bp) { 272 if (!bp) {
273 error = ENOMEM; 273 error = -ENOMEM;
274 goto error0; 274 goto error0;
275 } 275 }
276 276
@@ -298,7 +298,7 @@ xfs_growfs_data_private(
298 XFS_FSS_TO_BB(mp, 1), 0, 298 XFS_FSS_TO_BB(mp, 1), 0,
299 &xfs_agi_buf_ops); 299 &xfs_agi_buf_ops);
300 if (!bp) { 300 if (!bp) {
301 error = ENOMEM; 301 error = -ENOMEM;
302 goto error0; 302 goto error0;
303 } 303 }
304 304
@@ -336,7 +336,7 @@ xfs_growfs_data_private(
336 &xfs_allocbt_buf_ops); 336 &xfs_allocbt_buf_ops);
337 337
338 if (!bp) { 338 if (!bp) {
339 error = ENOMEM; 339 error = -ENOMEM;
340 goto error0; 340 goto error0;
341 } 341 }
342 342
@@ -365,7 +365,7 @@ xfs_growfs_data_private(
365 BTOBB(mp->m_sb.sb_blocksize), 0, 365 BTOBB(mp->m_sb.sb_blocksize), 0,
366 &xfs_allocbt_buf_ops); 366 &xfs_allocbt_buf_ops);
367 if (!bp) { 367 if (!bp) {
368 error = ENOMEM; 368 error = -ENOMEM;
369 goto error0; 369 goto error0;
370 } 370 }
371 371
@@ -395,7 +395,7 @@ xfs_growfs_data_private(
395 BTOBB(mp->m_sb.sb_blocksize), 0, 395 BTOBB(mp->m_sb.sb_blocksize), 0,
396 &xfs_inobt_buf_ops); 396 &xfs_inobt_buf_ops);
397 if (!bp) { 397 if (!bp) {
398 error = ENOMEM; 398 error = -ENOMEM;
399 goto error0; 399 goto error0;
400 } 400 }
401 401
@@ -420,7 +420,7 @@ xfs_growfs_data_private(
420 BTOBB(mp->m_sb.sb_blocksize), 0, 420 BTOBB(mp->m_sb.sb_blocksize), 0,
421 &xfs_inobt_buf_ops); 421 &xfs_inobt_buf_ops);
422 if (!bp) { 422 if (!bp) {
423 error = ENOMEM; 423 error = -ENOMEM;
424 goto error0; 424 goto error0;
425 } 425 }
426 426
@@ -531,7 +531,7 @@ xfs_growfs_data_private(
531 bp->b_ops = &xfs_sb_buf_ops; 531 bp->b_ops = &xfs_sb_buf_ops;
532 xfs_buf_zero(bp, 0, BBTOB(bp->b_length)); 532 xfs_buf_zero(bp, 0, BBTOB(bp->b_length));
533 } else 533 } else
534 error = ENOMEM; 534 error = -ENOMEM;
535 } 535 }
536 536
537 /* 537 /*
@@ -576,17 +576,17 @@ xfs_growfs_log_private(
576 576
577 nb = in->newblocks; 577 nb = in->newblocks;
578 if (nb < XFS_MIN_LOG_BLOCKS || nb < XFS_B_TO_FSB(mp, XFS_MIN_LOG_BYTES)) 578 if (nb < XFS_MIN_LOG_BLOCKS || nb < XFS_B_TO_FSB(mp, XFS_MIN_LOG_BYTES))
579 return EINVAL; 579 return -EINVAL;
580 if (nb == mp->m_sb.sb_logblocks && 580 if (nb == mp->m_sb.sb_logblocks &&
581 in->isint == (mp->m_sb.sb_logstart != 0)) 581 in->isint == (mp->m_sb.sb_logstart != 0))
582 return EINVAL; 582 return -EINVAL;
583 /* 583 /*
584 * Moving the log is hard, need new interfaces to sync 584 * Moving the log is hard, need new interfaces to sync
585 * the log first, hold off all activity while moving it. 585 * the log first, hold off all activity while moving it.
586 * Can have shorter or longer log in the same space, 586 * Can have shorter or longer log in the same space,
587 * or transform internal to external log or vice versa. 587 * or transform internal to external log or vice versa.
588 */ 588 */
589 return ENOSYS; 589 return -ENOSYS;
590} 590}
591 591
592/* 592/*
@@ -604,9 +604,9 @@ xfs_growfs_data(
604 int error; 604 int error;
605 605
606 if (!capable(CAP_SYS_ADMIN)) 606 if (!capable(CAP_SYS_ADMIN))
607 return EPERM; 607 return -EPERM;
608 if (!mutex_trylock(&mp->m_growlock)) 608 if (!mutex_trylock(&mp->m_growlock))
609 return EWOULDBLOCK; 609 return -EWOULDBLOCK;
610 error = xfs_growfs_data_private(mp, in); 610 error = xfs_growfs_data_private(mp, in);
611 mutex_unlock(&mp->m_growlock); 611 mutex_unlock(&mp->m_growlock);
612 return error; 612 return error;
@@ -620,9 +620,9 @@ xfs_growfs_log(
620 int error; 620 int error;
621 621
622 if (!capable(CAP_SYS_ADMIN)) 622 if (!capable(CAP_SYS_ADMIN))
623 return EPERM; 623 return -EPERM;
624 if (!mutex_trylock(&mp->m_growlock)) 624 if (!mutex_trylock(&mp->m_growlock))
625 return EWOULDBLOCK; 625 return -EWOULDBLOCK;
626 error = xfs_growfs_log_private(mp, in); 626 error = xfs_growfs_log_private(mp, in);
627 mutex_unlock(&mp->m_growlock); 627 mutex_unlock(&mp->m_growlock);
628 return error; 628 return error;
@@ -674,7 +674,7 @@ xfs_reserve_blocks(
674 /* If inval is null, report current values and return */ 674 /* If inval is null, report current values and return */
675 if (inval == (__uint64_t *)NULL) { 675 if (inval == (__uint64_t *)NULL) {
676 if (!outval) 676 if (!outval)
677 return EINVAL; 677 return -EINVAL;
678 outval->resblks = mp->m_resblks; 678 outval->resblks = mp->m_resblks;
679 outval->resblks_avail = mp->m_resblks_avail; 679 outval->resblks_avail = mp->m_resblks_avail;
680 return 0; 680 return 0;
@@ -757,7 +757,7 @@ out:
757 int error; 757 int error;
758 error = xfs_icsb_modify_counters(mp, XFS_SBS_FDBLOCKS, 758 error = xfs_icsb_modify_counters(mp, XFS_SBS_FDBLOCKS,
759 fdblks_delta, 0); 759 fdblks_delta, 0);
760 if (error == ENOSPC) 760 if (error == -ENOSPC)
761 goto retry; 761 goto retry;
762 } 762 }
763 return 0; 763 return 0;
@@ -818,7 +818,7 @@ xfs_fs_goingdown(
818 SHUTDOWN_FORCE_UMOUNT | SHUTDOWN_LOG_IO_ERROR); 818 SHUTDOWN_FORCE_UMOUNT | SHUTDOWN_LOG_IO_ERROR);
819 break; 819 break;
820 default: 820 default:
821 return EINVAL; 821 return -EINVAL;
822 } 822 }
823 823
824 return 0; 824 return 0;
diff --git a/fs/xfs/xfs_icache.c b/fs/xfs/xfs_icache.c
index f2cc936d713e..08ba4c6e1359 100644
--- a/fs/xfs/xfs_icache.c
+++ b/fs/xfs/xfs_icache.c
@@ -158,7 +158,7 @@ xfs_iget_cache_hit(
158 if (ip->i_ino != ino) { 158 if (ip->i_ino != ino) {
159 trace_xfs_iget_skip(ip); 159 trace_xfs_iget_skip(ip);
160 XFS_STATS_INC(xs_ig_frecycle); 160 XFS_STATS_INC(xs_ig_frecycle);
161 error = EAGAIN; 161 error = -EAGAIN;
162 goto out_error; 162 goto out_error;
163 } 163 }
164 164
@@ -176,7 +176,7 @@ xfs_iget_cache_hit(
176 if (ip->i_flags & (XFS_INEW|XFS_IRECLAIM)) { 176 if (ip->i_flags & (XFS_INEW|XFS_IRECLAIM)) {
177 trace_xfs_iget_skip(ip); 177 trace_xfs_iget_skip(ip);
178 XFS_STATS_INC(xs_ig_frecycle); 178 XFS_STATS_INC(xs_ig_frecycle);
179 error = EAGAIN; 179 error = -EAGAIN;
180 goto out_error; 180 goto out_error;
181 } 181 }
182 182
@@ -184,7 +184,7 @@ xfs_iget_cache_hit(
184 * If lookup is racing with unlink return an error immediately. 184 * If lookup is racing with unlink return an error immediately.
185 */ 185 */
186 if (ip->i_d.di_mode == 0 && !(flags & XFS_IGET_CREATE)) { 186 if (ip->i_d.di_mode == 0 && !(flags & XFS_IGET_CREATE)) {
187 error = ENOENT; 187 error = -ENOENT;
188 goto out_error; 188 goto out_error;
189 } 189 }
190 190
@@ -206,7 +206,7 @@ xfs_iget_cache_hit(
206 spin_unlock(&ip->i_flags_lock); 206 spin_unlock(&ip->i_flags_lock);
207 rcu_read_unlock(); 207 rcu_read_unlock();
208 208
209 error = -inode_init_always(mp->m_super, inode); 209 error = inode_init_always(mp->m_super, inode);
210 if (error) { 210 if (error) {
211 /* 211 /*
212 * Re-initializing the inode failed, and we are in deep 212 * Re-initializing the inode failed, and we are in deep
@@ -243,7 +243,7 @@ xfs_iget_cache_hit(
243 /* If the VFS inode is being torn down, pause and try again. */ 243 /* If the VFS inode is being torn down, pause and try again. */
244 if (!igrab(inode)) { 244 if (!igrab(inode)) {
245 trace_xfs_iget_skip(ip); 245 trace_xfs_iget_skip(ip);
246 error = EAGAIN; 246 error = -EAGAIN;
247 goto out_error; 247 goto out_error;
248 } 248 }
249 249
@@ -285,7 +285,7 @@ xfs_iget_cache_miss(
285 285
286 ip = xfs_inode_alloc(mp, ino); 286 ip = xfs_inode_alloc(mp, ino);
287 if (!ip) 287 if (!ip)
288 return ENOMEM; 288 return -ENOMEM;
289 289
290 error = xfs_iread(mp, tp, ip, flags); 290 error = xfs_iread(mp, tp, ip, flags);
291 if (error) 291 if (error)
@@ -294,7 +294,7 @@ xfs_iget_cache_miss(
294 trace_xfs_iget_miss(ip); 294 trace_xfs_iget_miss(ip);
295 295
296 if ((ip->i_d.di_mode == 0) && !(flags & XFS_IGET_CREATE)) { 296 if ((ip->i_d.di_mode == 0) && !(flags & XFS_IGET_CREATE)) {
297 error = ENOENT; 297 error = -ENOENT;
298 goto out_destroy; 298 goto out_destroy;
299 } 299 }
300 300
@@ -305,7 +305,7 @@ xfs_iget_cache_miss(
305 * recurse into the file system. 305 * recurse into the file system.
306 */ 306 */
307 if (radix_tree_preload(GFP_NOFS)) { 307 if (radix_tree_preload(GFP_NOFS)) {
308 error = EAGAIN; 308 error = -EAGAIN;
309 goto out_destroy; 309 goto out_destroy;
310 } 310 }
311 311
@@ -341,7 +341,7 @@ xfs_iget_cache_miss(
341 if (unlikely(error)) { 341 if (unlikely(error)) {
342 WARN_ON(error != -EEXIST); 342 WARN_ON(error != -EEXIST);
343 XFS_STATS_INC(xs_ig_dup); 343 XFS_STATS_INC(xs_ig_dup);
344 error = EAGAIN; 344 error = -EAGAIN;
345 goto out_preload_end; 345 goto out_preload_end;
346 } 346 }
347 spin_unlock(&pag->pag_ici_lock); 347 spin_unlock(&pag->pag_ici_lock);
@@ -408,7 +408,7 @@ xfs_iget(
408 408
409 /* reject inode numbers outside existing AGs */ 409 /* reject inode numbers outside existing AGs */
410 if (!ino || XFS_INO_TO_AGNO(mp, ino) >= mp->m_sb.sb_agcount) 410 if (!ino || XFS_INO_TO_AGNO(mp, ino) >= mp->m_sb.sb_agcount)
411 return EINVAL; 411 return -EINVAL;
412 412
413 /* get the perag structure and ensure that it's inode capable */ 413 /* get the perag structure and ensure that it's inode capable */
414 pag = xfs_perag_get(mp, XFS_INO_TO_AGNO(mp, ino)); 414 pag = xfs_perag_get(mp, XFS_INO_TO_AGNO(mp, ino));
@@ -445,7 +445,7 @@ again:
445 return 0; 445 return 0;
446 446
447out_error_or_again: 447out_error_or_again:
448 if (error == EAGAIN) { 448 if (error == -EAGAIN) {
449 delay(1); 449 delay(1);
450 goto again; 450 goto again;
451 } 451 }
@@ -489,18 +489,18 @@ xfs_inode_ag_walk_grab(
489 489
490 /* nothing to sync during shutdown */ 490 /* nothing to sync during shutdown */
491 if (XFS_FORCED_SHUTDOWN(ip->i_mount)) 491 if (XFS_FORCED_SHUTDOWN(ip->i_mount))
492 return EFSCORRUPTED; 492 return -EFSCORRUPTED;
493 493
494 /* If we can't grab the inode, it must on it's way to reclaim. */ 494 /* If we can't grab the inode, it must on it's way to reclaim. */
495 if (!igrab(inode)) 495 if (!igrab(inode))
496 return ENOENT; 496 return -ENOENT;
497 497
498 /* inode is valid */ 498 /* inode is valid */
499 return 0; 499 return 0;
500 500
501out_unlock_noent: 501out_unlock_noent:
502 spin_unlock(&ip->i_flags_lock); 502 spin_unlock(&ip->i_flags_lock);
503 return ENOENT; 503 return -ENOENT;
504} 504}
505 505
506STATIC int 506STATIC int
@@ -583,16 +583,16 @@ restart:
583 continue; 583 continue;
584 error = execute(batch[i], flags, args); 584 error = execute(batch[i], flags, args);
585 IRELE(batch[i]); 585 IRELE(batch[i]);
586 if (error == EAGAIN) { 586 if (error == -EAGAIN) {
587 skipped++; 587 skipped++;
588 continue; 588 continue;
589 } 589 }
590 if (error && last_error != EFSCORRUPTED) 590 if (error && last_error != -EFSCORRUPTED)
591 last_error = error; 591 last_error = error;
592 } 592 }
593 593
594 /* bail out if the filesystem is corrupted. */ 594 /* bail out if the filesystem is corrupted. */
595 if (error == EFSCORRUPTED) 595 if (error == -EFSCORRUPTED)
596 break; 596 break;
597 597
598 cond_resched(); 598 cond_resched();
@@ -652,7 +652,7 @@ xfs_inode_ag_iterator(
652 xfs_perag_put(pag); 652 xfs_perag_put(pag);
653 if (error) { 653 if (error) {
654 last_error = error; 654 last_error = error;
655 if (error == EFSCORRUPTED) 655 if (error == -EFSCORRUPTED)
656 break; 656 break;
657 } 657 }
658 } 658 }
@@ -680,7 +680,7 @@ xfs_inode_ag_iterator_tag(
680 xfs_perag_put(pag); 680 xfs_perag_put(pag);
681 if (error) { 681 if (error) {
682 last_error = error; 682 last_error = error;
683 if (error == EFSCORRUPTED) 683 if (error == -EFSCORRUPTED)
684 break; 684 break;
685 } 685 }
686 } 686 }
@@ -944,7 +944,7 @@ restart:
944 * see the stale flag set on the inode. 944 * see the stale flag set on the inode.
945 */ 945 */
946 error = xfs_iflush(ip, &bp); 946 error = xfs_iflush(ip, &bp);
947 if (error == EAGAIN) { 947 if (error == -EAGAIN) {
948 xfs_iunlock(ip, XFS_ILOCK_EXCL); 948 xfs_iunlock(ip, XFS_ILOCK_EXCL);
949 /* backoff longer than in xfs_ifree_cluster */ 949 /* backoff longer than in xfs_ifree_cluster */
950 delay(2); 950 delay(2);
@@ -997,7 +997,7 @@ out:
997 xfs_iflags_clear(ip, XFS_IRECLAIM); 997 xfs_iflags_clear(ip, XFS_IRECLAIM);
998 xfs_iunlock(ip, XFS_ILOCK_EXCL); 998 xfs_iunlock(ip, XFS_ILOCK_EXCL);
999 /* 999 /*
1000 * We could return EAGAIN here to make reclaim rescan the inode tree in 1000 * We could return -EAGAIN here to make reclaim rescan the inode tree in
1001 * a short while. However, this just burns CPU time scanning the tree 1001 * a short while. However, this just burns CPU time scanning the tree
1002 * waiting for IO to complete and the reclaim work never goes back to 1002 * waiting for IO to complete and the reclaim work never goes back to
1003 * the idle state. Instead, return 0 to let the next scheduled 1003 * the idle state. Instead, return 0 to let the next scheduled
@@ -1100,7 +1100,7 @@ restart:
1100 if (!batch[i]) 1100 if (!batch[i])
1101 continue; 1101 continue;
1102 error = xfs_reclaim_inode(batch[i], pag, flags); 1102 error = xfs_reclaim_inode(batch[i], pag, flags);
1103 if (error && last_error != EFSCORRUPTED) 1103 if (error && last_error != -EFSCORRUPTED)
1104 last_error = error; 1104 last_error = error;
1105 } 1105 }
1106 1106
@@ -1240,7 +1240,7 @@ xfs_inode_free_eofblocks(
1240 ret = xfs_free_eofblocks(ip->i_mount, ip, true); 1240 ret = xfs_free_eofblocks(ip->i_mount, ip, true);
1241 1241
1242 /* don't revisit the inode if we're not waiting */ 1242 /* don't revisit the inode if we're not waiting */
1243 if (ret == EAGAIN && !(flags & SYNC_WAIT)) 1243 if (ret == -EAGAIN && !(flags & SYNC_WAIT))
1244 ret = 0; 1244 ret = 0;
1245 1245
1246 return ret; 1246 return ret;
diff --git a/fs/xfs/xfs_icache.h b/fs/xfs/xfs_icache.h
index 9cf017b899be..6250430d609c 100644
--- a/fs/xfs/xfs_icache.h
+++ b/fs/xfs/xfs_icache.h
@@ -72,14 +72,14 @@ xfs_fs_eofblocks_from_user(
72 struct xfs_eofblocks *dst) 72 struct xfs_eofblocks *dst)
73{ 73{
74 if (src->eof_version != XFS_EOFBLOCKS_VERSION) 74 if (src->eof_version != XFS_EOFBLOCKS_VERSION)
75 return EINVAL; 75 return -EINVAL;
76 76
77 if (src->eof_flags & ~XFS_EOF_FLAGS_VALID) 77 if (src->eof_flags & ~XFS_EOF_FLAGS_VALID)
78 return EINVAL; 78 return -EINVAL;
79 79
80 if (memchr_inv(&src->pad32, 0, sizeof(src->pad32)) || 80 if (memchr_inv(&src->pad32, 0, sizeof(src->pad32)) ||
81 memchr_inv(src->pad64, 0, sizeof(src->pad64))) 81 memchr_inv(src->pad64, 0, sizeof(src->pad64)))
82 return EINVAL; 82 return -EINVAL;
83 83
84 dst->eof_flags = src->eof_flags; 84 dst->eof_flags = src->eof_flags;
85 dst->eof_prid = src->eof_prid; 85 dst->eof_prid = src->eof_prid;
@@ -89,14 +89,14 @@ xfs_fs_eofblocks_from_user(
89 if (src->eof_flags & XFS_EOF_FLAGS_UID) { 89 if (src->eof_flags & XFS_EOF_FLAGS_UID) {
90 dst->eof_uid = make_kuid(current_user_ns(), src->eof_uid); 90 dst->eof_uid = make_kuid(current_user_ns(), src->eof_uid);
91 if (!uid_valid(dst->eof_uid)) 91 if (!uid_valid(dst->eof_uid))
92 return EINVAL; 92 return -EINVAL;
93 } 93 }
94 94
95 dst->eof_gid = INVALID_GID; 95 dst->eof_gid = INVALID_GID;
96 if (src->eof_flags & XFS_EOF_FLAGS_GID) { 96 if (src->eof_flags & XFS_EOF_FLAGS_GID) {
97 dst->eof_gid = make_kgid(current_user_ns(), src->eof_gid); 97 dst->eof_gid = make_kgid(current_user_ns(), src->eof_gid);
98 if (!gid_valid(dst->eof_gid)) 98 if (!gid_valid(dst->eof_gid))
99 return EINVAL; 99 return -EINVAL;
100 } 100 }
101 return 0; 101 return 0;
102} 102}
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index 605e3e1dff28..1a5e068bc420 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -583,7 +583,7 @@ xfs_lookup(
583 trace_xfs_lookup(dp, name); 583 trace_xfs_lookup(dp, name);
584 584
585 if (XFS_FORCED_SHUTDOWN(dp->i_mount)) 585 if (XFS_FORCED_SHUTDOWN(dp->i_mount))
586 return EIO; 586 return -EIO;
587 587
588 lock_mode = xfs_ilock_data_map_shared(dp); 588 lock_mode = xfs_ilock_data_map_shared(dp);
589 error = xfs_dir_lookup(NULL, dp, name, &inum, ci_name); 589 error = xfs_dir_lookup(NULL, dp, name, &inum, ci_name);
@@ -893,7 +893,7 @@ xfs_dir_ialloc(
893 } 893 }
894 if (!ialloc_context && !ip) { 894 if (!ialloc_context && !ip) {
895 *ipp = NULL; 895 *ipp = NULL;
896 return ENOSPC; 896 return -ENOSPC;
897 } 897 }
898 898
899 /* 899 /*
@@ -1088,7 +1088,7 @@ xfs_create(
1088 trace_xfs_create(dp, name); 1088 trace_xfs_create(dp, name);
1089 1089
1090 if (XFS_FORCED_SHUTDOWN(mp)) 1090 if (XFS_FORCED_SHUTDOWN(mp))
1091 return EIO; 1091 return -EIO;
1092 1092
1093 prid = xfs_get_initial_prid(dp); 1093 prid = xfs_get_initial_prid(dp);
1094 1094
@@ -1125,12 +1125,12 @@ xfs_create(
1125 */ 1125 */
1126 tres.tr_logflags = XFS_TRANS_PERM_LOG_RES; 1126 tres.tr_logflags = XFS_TRANS_PERM_LOG_RES;
1127 error = xfs_trans_reserve(tp, &tres, resblks, 0); 1127 error = xfs_trans_reserve(tp, &tres, resblks, 0);
1128 if (error == ENOSPC) { 1128 if (error == -ENOSPC) {
1129 /* flush outstanding delalloc blocks and retry */ 1129 /* flush outstanding delalloc blocks and retry */
1130 xfs_flush_inodes(mp); 1130 xfs_flush_inodes(mp);
1131 error = xfs_trans_reserve(tp, &tres, resblks, 0); 1131 error = xfs_trans_reserve(tp, &tres, resblks, 0);
1132 } 1132 }
1133 if (error == ENOSPC) { 1133 if (error == -ENOSPC) {
1134 /* No space at all so try a "no-allocation" reservation */ 1134 /* No space at all so try a "no-allocation" reservation */
1135 resblks = 0; 1135 resblks = 0;
1136 error = xfs_trans_reserve(tp, &tres, 0, 0); 1136 error = xfs_trans_reserve(tp, &tres, 0, 0);
@@ -1165,7 +1165,7 @@ xfs_create(
1165 error = xfs_dir_ialloc(&tp, dp, mode, is_dir ? 2 : 1, rdev, 1165 error = xfs_dir_ialloc(&tp, dp, mode, is_dir ? 2 : 1, rdev,
1166 prid, resblks > 0, &ip, &committed); 1166 prid, resblks > 0, &ip, &committed);
1167 if (error) { 1167 if (error) {
1168 if (error == ENOSPC) 1168 if (error == -ENOSPC)
1169 goto out_trans_cancel; 1169 goto out_trans_cancel;
1170 goto out_trans_abort; 1170 goto out_trans_abort;
1171 } 1171 }
@@ -1184,7 +1184,7 @@ xfs_create(
1184 &first_block, &free_list, resblks ? 1184 &first_block, &free_list, resblks ?
1185 resblks - XFS_IALLOC_SPACE_RES(mp) : 0); 1185 resblks - XFS_IALLOC_SPACE_RES(mp) : 0);
1186 if (error) { 1186 if (error) {
1187 ASSERT(error != ENOSPC); 1187 ASSERT(error != -ENOSPC);
1188 goto out_trans_abort; 1188 goto out_trans_abort;
1189 } 1189 }
1190 xfs_trans_ichgtime(tp, dp, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG); 1190 xfs_trans_ichgtime(tp, dp, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG);
@@ -1274,7 +1274,7 @@ xfs_create_tmpfile(
1274 uint resblks; 1274 uint resblks;
1275 1275
1276 if (XFS_FORCED_SHUTDOWN(mp)) 1276 if (XFS_FORCED_SHUTDOWN(mp))
1277 return EIO; 1277 return -EIO;
1278 1278
1279 prid = xfs_get_initial_prid(dp); 1279 prid = xfs_get_initial_prid(dp);
1280 1280
@@ -1293,7 +1293,7 @@ xfs_create_tmpfile(
1293 1293
1294 tres = &M_RES(mp)->tr_create_tmpfile; 1294 tres = &M_RES(mp)->tr_create_tmpfile;
1295 error = xfs_trans_reserve(tp, tres, resblks, 0); 1295 error = xfs_trans_reserve(tp, tres, resblks, 0);
1296 if (error == ENOSPC) { 1296 if (error == -ENOSPC) {
1297 /* No space at all so try a "no-allocation" reservation */ 1297 /* No space at all so try a "no-allocation" reservation */
1298 resblks = 0; 1298 resblks = 0;
1299 error = xfs_trans_reserve(tp, tres, 0, 0); 1299 error = xfs_trans_reserve(tp, tres, 0, 0);
@@ -1311,7 +1311,7 @@ xfs_create_tmpfile(
1311 error = xfs_dir_ialloc(&tp, dp, mode, 1, 0, 1311 error = xfs_dir_ialloc(&tp, dp, mode, 1, 0,
1312 prid, resblks > 0, &ip, NULL); 1312 prid, resblks > 0, &ip, NULL);
1313 if (error) { 1313 if (error) {
1314 if (error == ENOSPC) 1314 if (error == -ENOSPC)
1315 goto out_trans_cancel; 1315 goto out_trans_cancel;
1316 goto out_trans_abort; 1316 goto out_trans_abort;
1317 } 1317 }
@@ -1382,7 +1382,7 @@ xfs_link(
1382 ASSERT(!S_ISDIR(sip->i_d.di_mode)); 1382 ASSERT(!S_ISDIR(sip->i_d.di_mode));
1383 1383
1384 if (XFS_FORCED_SHUTDOWN(mp)) 1384 if (XFS_FORCED_SHUTDOWN(mp))
1385 return EIO; 1385 return -EIO;
1386 1386
1387 error = xfs_qm_dqattach(sip, 0); 1387 error = xfs_qm_dqattach(sip, 0);
1388 if (error) 1388 if (error)
@@ -1396,7 +1396,7 @@ xfs_link(
1396 cancel_flags = XFS_TRANS_RELEASE_LOG_RES; 1396 cancel_flags = XFS_TRANS_RELEASE_LOG_RES;
1397 resblks = XFS_LINK_SPACE_RES(mp, target_name->len); 1397 resblks = XFS_LINK_SPACE_RES(mp, target_name->len);
1398 error = xfs_trans_reserve(tp, &M_RES(mp)->tr_link, resblks, 0); 1398 error = xfs_trans_reserve(tp, &M_RES(mp)->tr_link, resblks, 0);
1399 if (error == ENOSPC) { 1399 if (error == -ENOSPC) {
1400 resblks = 0; 1400 resblks = 0;
1401 error = xfs_trans_reserve(tp, &M_RES(mp)->tr_link, 0, 0); 1401 error = xfs_trans_reserve(tp, &M_RES(mp)->tr_link, 0, 0);
1402 } 1402 }
@@ -1417,7 +1417,7 @@ xfs_link(
1417 */ 1417 */
1418 if (unlikely((tdp->i_d.di_flags & XFS_DIFLAG_PROJINHERIT) && 1418 if (unlikely((tdp->i_d.di_flags & XFS_DIFLAG_PROJINHERIT) &&
1419 (xfs_get_projid(tdp) != xfs_get_projid(sip)))) { 1419 (xfs_get_projid(tdp) != xfs_get_projid(sip)))) {
1420 error = EXDEV; 1420 error = -EXDEV;
1421 goto error_return; 1421 goto error_return;
1422 } 1422 }
1423 1423
@@ -1636,7 +1636,7 @@ xfs_release(
1636 if (truncated) { 1636 if (truncated) {
1637 xfs_iflags_clear(ip, XFS_IDIRTY_RELEASE); 1637 xfs_iflags_clear(ip, XFS_IDIRTY_RELEASE);
1638 if (VN_DIRTY(VFS_I(ip)) && ip->i_delayed_blks > 0) { 1638 if (VN_DIRTY(VFS_I(ip)) && ip->i_delayed_blks > 0) {
1639 error = -filemap_flush(VFS_I(ip)->i_mapping); 1639 error = filemap_flush(VFS_I(ip)->i_mapping);
1640 if (error) 1640 if (error)
1641 return error; 1641 return error;
1642 } 1642 }
@@ -1673,7 +1673,7 @@ xfs_release(
1673 return 0; 1673 return 0;
1674 1674
1675 error = xfs_free_eofblocks(mp, ip, true); 1675 error = xfs_free_eofblocks(mp, ip, true);
1676 if (error && error != EAGAIN) 1676 if (error && error != -EAGAIN)
1677 return error; 1677 return error;
1678 1678
1679 /* delalloc blocks after truncation means it really is dirty */ 1679 /* delalloc blocks after truncation means it really is dirty */
@@ -1772,7 +1772,7 @@ xfs_inactive_ifree(
1772 error = xfs_trans_reserve(tp, &M_RES(mp)->tr_ifree, 1772 error = xfs_trans_reserve(tp, &M_RES(mp)->tr_ifree,
1773 XFS_IFREE_SPACE_RES(mp), 0); 1773 XFS_IFREE_SPACE_RES(mp), 0);
1774 if (error) { 1774 if (error) {
1775 if (error == ENOSPC) { 1775 if (error == -ENOSPC) {
1776 xfs_warn_ratelimited(mp, 1776 xfs_warn_ratelimited(mp,
1777 "Failed to remove inode(s) from unlinked list. " 1777 "Failed to remove inode(s) from unlinked list. "
1778 "Please free space, unmount and run xfs_repair."); 1778 "Please free space, unmount and run xfs_repair.");
@@ -2219,7 +2219,7 @@ xfs_ifree_cluster(
2219 XBF_UNMAPPED); 2219 XBF_UNMAPPED);
2220 2220
2221 if (!bp) 2221 if (!bp)
2222 return ENOMEM; 2222 return -ENOMEM;
2223 2223
2224 /* 2224 /*
2225 * This buffer may not have been correctly initialised as we 2225 * This buffer may not have been correctly initialised as we
@@ -2491,7 +2491,7 @@ xfs_remove(
2491 trace_xfs_remove(dp, name); 2491 trace_xfs_remove(dp, name);
2492 2492
2493 if (XFS_FORCED_SHUTDOWN(mp)) 2493 if (XFS_FORCED_SHUTDOWN(mp))
2494 return EIO; 2494 return -EIO;
2495 2495
2496 error = xfs_qm_dqattach(dp, 0); 2496 error = xfs_qm_dqattach(dp, 0);
2497 if (error) 2497 if (error)
@@ -2521,12 +2521,12 @@ xfs_remove(
2521 */ 2521 */
2522 resblks = XFS_REMOVE_SPACE_RES(mp); 2522 resblks = XFS_REMOVE_SPACE_RES(mp);
2523 error = xfs_trans_reserve(tp, &M_RES(mp)->tr_remove, resblks, 0); 2523 error = xfs_trans_reserve(tp, &M_RES(mp)->tr_remove, resblks, 0);
2524 if (error == ENOSPC) { 2524 if (error == -ENOSPC) {
2525 resblks = 0; 2525 resblks = 0;
2526 error = xfs_trans_reserve(tp, &M_RES(mp)->tr_remove, 0, 0); 2526 error = xfs_trans_reserve(tp, &M_RES(mp)->tr_remove, 0, 0);
2527 } 2527 }
2528 if (error) { 2528 if (error) {
2529 ASSERT(error != ENOSPC); 2529 ASSERT(error != -ENOSPC);
2530 cancel_flags = 0; 2530 cancel_flags = 0;
2531 goto out_trans_cancel; 2531 goto out_trans_cancel;
2532 } 2532 }
@@ -2543,11 +2543,11 @@ xfs_remove(
2543 if (is_dir) { 2543 if (is_dir) {
2544 ASSERT(ip->i_d.di_nlink >= 2); 2544 ASSERT(ip->i_d.di_nlink >= 2);
2545 if (ip->i_d.di_nlink != 2) { 2545 if (ip->i_d.di_nlink != 2) {
2546 error = ENOTEMPTY; 2546 error = -ENOTEMPTY;
2547 goto out_trans_cancel; 2547 goto out_trans_cancel;
2548 } 2548 }
2549 if (!xfs_dir_isempty(ip)) { 2549 if (!xfs_dir_isempty(ip)) {
2550 error = ENOTEMPTY; 2550 error = -ENOTEMPTY;
2551 goto out_trans_cancel; 2551 goto out_trans_cancel;
2552 } 2552 }
2553 2553
@@ -2582,7 +2582,7 @@ xfs_remove(
2582 error = xfs_dir_removename(tp, dp, name, ip->i_ino, 2582 error = xfs_dir_removename(tp, dp, name, ip->i_ino,
2583 &first_block, &free_list, resblks); 2583 &first_block, &free_list, resblks);
2584 if (error) { 2584 if (error) {
2585 ASSERT(error != ENOENT); 2585 ASSERT(error != -ENOENT);
2586 goto out_bmap_cancel; 2586 goto out_bmap_cancel;
2587 } 2587 }
2588 2588
@@ -2702,7 +2702,7 @@ xfs_rename(
2702 cancel_flags = XFS_TRANS_RELEASE_LOG_RES; 2702 cancel_flags = XFS_TRANS_RELEASE_LOG_RES;
2703 spaceres = XFS_RENAME_SPACE_RES(mp, target_name->len); 2703 spaceres = XFS_RENAME_SPACE_RES(mp, target_name->len);
2704 error = xfs_trans_reserve(tp, &M_RES(mp)->tr_rename, spaceres, 0); 2704 error = xfs_trans_reserve(tp, &M_RES(mp)->tr_rename, spaceres, 0);
2705 if (error == ENOSPC) { 2705 if (error == -ENOSPC) {
2706 spaceres = 0; 2706 spaceres = 0;
2707 error = xfs_trans_reserve(tp, &M_RES(mp)->tr_rename, 0, 0); 2707 error = xfs_trans_reserve(tp, &M_RES(mp)->tr_rename, 0, 0);
2708 } 2708 }
@@ -2747,7 +2747,7 @@ xfs_rename(
2747 */ 2747 */
2748 if (unlikely((target_dp->i_d.di_flags & XFS_DIFLAG_PROJINHERIT) && 2748 if (unlikely((target_dp->i_d.di_flags & XFS_DIFLAG_PROJINHERIT) &&
2749 (xfs_get_projid(target_dp) != xfs_get_projid(src_ip)))) { 2749 (xfs_get_projid(target_dp) != xfs_get_projid(src_ip)))) {
2750 error = EXDEV; 2750 error = -EXDEV;
2751 goto error_return; 2751 goto error_return;
2752 } 2752 }
2753 2753
@@ -2770,7 +2770,7 @@ xfs_rename(
2770 error = xfs_dir_createname(tp, target_dp, target_name, 2770 error = xfs_dir_createname(tp, target_dp, target_name,
2771 src_ip->i_ino, &first_block, 2771 src_ip->i_ino, &first_block,
2772 &free_list, spaceres); 2772 &free_list, spaceres);
2773 if (error == ENOSPC) 2773 if (error == -ENOSPC)
2774 goto error_return; 2774 goto error_return;
2775 if (error) 2775 if (error)
2776 goto abort_return; 2776 goto abort_return;
@@ -2795,7 +2795,7 @@ xfs_rename(
2795 */ 2795 */
2796 if (!(xfs_dir_isempty(target_ip)) || 2796 if (!(xfs_dir_isempty(target_ip)) ||
2797 (target_ip->i_d.di_nlink > 2)) { 2797 (target_ip->i_d.di_nlink > 2)) {
2798 error = EEXIST; 2798 error = -EEXIST;
2799 goto error_return; 2799 goto error_return;
2800 } 2800 }
2801 } 2801 }
@@ -2847,7 +2847,7 @@ xfs_rename(
2847 error = xfs_dir_replace(tp, src_ip, &xfs_name_dotdot, 2847 error = xfs_dir_replace(tp, src_ip, &xfs_name_dotdot,
2848 target_dp->i_ino, 2848 target_dp->i_ino,
2849 &first_block, &free_list, spaceres); 2849 &first_block, &free_list, spaceres);
2850 ASSERT(error != EEXIST); 2850 ASSERT(error != -EEXIST);
2851 if (error) 2851 if (error)
2852 goto abort_return; 2852 goto abort_return;
2853 } 2853 }
@@ -3055,7 +3055,7 @@ cluster_corrupt_out:
3055 if (bp->b_iodone) { 3055 if (bp->b_iodone) {
3056 XFS_BUF_UNDONE(bp); 3056 XFS_BUF_UNDONE(bp);
3057 xfs_buf_stale(bp); 3057 xfs_buf_stale(bp);
3058 xfs_buf_ioerror(bp, EIO); 3058 xfs_buf_ioerror(bp, -EIO);
3059 xfs_buf_ioend(bp, 0); 3059 xfs_buf_ioend(bp, 0);
3060 } else { 3060 } else {
3061 xfs_buf_stale(bp); 3061 xfs_buf_stale(bp);
@@ -3069,7 +3069,7 @@ cluster_corrupt_out:
3069 xfs_iflush_abort(iq, false); 3069 xfs_iflush_abort(iq, false);
3070 kmem_free(ilist); 3070 kmem_free(ilist);
3071 xfs_perag_put(pag); 3071 xfs_perag_put(pag);
3072 return EFSCORRUPTED; 3072 return -EFSCORRUPTED;
3073} 3073}
3074 3074
3075/* 3075/*
@@ -3124,7 +3124,7 @@ xfs_iflush(
3124 * as we wait for an empty AIL as part of the unmount process. 3124 * as we wait for an empty AIL as part of the unmount process.
3125 */ 3125 */
3126 if (XFS_FORCED_SHUTDOWN(mp)) { 3126 if (XFS_FORCED_SHUTDOWN(mp)) {
3127 error = EIO; 3127 error = -EIO;
3128 goto abort_out; 3128 goto abort_out;
3129 } 3129 }
3130 3130
@@ -3167,7 +3167,7 @@ corrupt_out:
3167 xfs_buf_relse(bp); 3167 xfs_buf_relse(bp);
3168 xfs_force_shutdown(mp, SHUTDOWN_CORRUPT_INCORE); 3168 xfs_force_shutdown(mp, SHUTDOWN_CORRUPT_INCORE);
3169cluster_corrupt_out: 3169cluster_corrupt_out:
3170 error = EFSCORRUPTED; 3170 error = -EFSCORRUPTED;
3171abort_out: 3171abort_out:
3172 /* 3172 /*
3173 * Unlocks the flush lock 3173 * Unlocks the flush lock
@@ -3331,5 +3331,5 @@ xfs_iflush_int(
3331 return 0; 3331 return 0;
3332 3332
3333corrupt_out: 3333corrupt_out:
3334 return EFSCORRUPTED; 3334 return -EFSCORRUPTED;
3335} 3335}
diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c
index a640137b3573..de5a7be36e60 100644
--- a/fs/xfs/xfs_inode_item.c
+++ b/fs/xfs/xfs_inode_item.c
@@ -788,5 +788,5 @@ xfs_inode_item_format_convert(
788 in_f->ilf_boffset = in_f64->ilf_boffset; 788 in_f->ilf_boffset = in_f64->ilf_boffset;
789 return 0; 789 return 0;
790 } 790 }
791 return EFSCORRUPTED; 791 return -EFSCORRUPTED;
792} 792}
diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
index 1a1648fbda1c..30983b8ceaa1 100644
--- a/fs/xfs/xfs_ioctl.c
+++ b/fs/xfs/xfs_ioctl.c
@@ -305,7 +305,7 @@ xfs_readlink_by_handle(
305 goto out_dput; 305 goto out_dput;
306 } 306 }
307 307
308 error = -xfs_readlink(XFS_I(dentry->d_inode), link); 308 error = xfs_readlink(XFS_I(dentry->d_inode), link);
309 if (error) 309 if (error)
310 goto out_kfree; 310 goto out_kfree;
311 error = readlink_copy(hreq->ohandle, olen, link); 311 error = readlink_copy(hreq->ohandle, olen, link);
@@ -330,10 +330,10 @@ xfs_set_dmattrs(
330 int error; 330 int error;
331 331
332 if (!capable(CAP_SYS_ADMIN)) 332 if (!capable(CAP_SYS_ADMIN))
333 return EPERM; 333 return -EPERM;
334 334
335 if (XFS_FORCED_SHUTDOWN(mp)) 335 if (XFS_FORCED_SHUTDOWN(mp))
336 return EIO; 336 return -EIO;
337 337
338 tp = xfs_trans_alloc(mp, XFS_TRANS_SET_DMATTRS); 338 tp = xfs_trans_alloc(mp, XFS_TRANS_SET_DMATTRS);
339 error = xfs_trans_reserve(tp, &M_RES(mp)->tr_ichange, 0, 0); 339 error = xfs_trans_reserve(tp, &M_RES(mp)->tr_ichange, 0, 0);
@@ -388,7 +388,7 @@ xfs_fssetdm_by_handle(
388 goto out; 388 goto out;
389 } 389 }
390 390
391 error = -xfs_set_dmattrs(XFS_I(dentry->d_inode), fsd.fsd_dmevmask, 391 error = xfs_set_dmattrs(XFS_I(dentry->d_inode), fsd.fsd_dmevmask,
392 fsd.fsd_dmstate); 392 fsd.fsd_dmstate);
393 393
394 out: 394 out:
@@ -431,7 +431,7 @@ xfs_attrlist_by_handle(
431 goto out_dput; 431 goto out_dput;
432 432
433 cursor = (attrlist_cursor_kern_t *)&al_hreq.pos; 433 cursor = (attrlist_cursor_kern_t *)&al_hreq.pos;
434 error = -xfs_attr_list(XFS_I(dentry->d_inode), kbuf, al_hreq.buflen, 434 error = xfs_attr_list(XFS_I(dentry->d_inode), kbuf, al_hreq.buflen,
435 al_hreq.flags, cursor); 435 al_hreq.flags, cursor);
436 if (error) 436 if (error)
437 goto out_kfree; 437 goto out_kfree;
@@ -455,20 +455,20 @@ xfs_attrmulti_attr_get(
455 __uint32_t flags) 455 __uint32_t flags)
456{ 456{
457 unsigned char *kbuf; 457 unsigned char *kbuf;
458 int error = EFAULT; 458 int error = -EFAULT;
459 459
460 if (*len > XATTR_SIZE_MAX) 460 if (*len > XATTR_SIZE_MAX)
461 return EINVAL; 461 return -EINVAL;
462 kbuf = kmem_zalloc_large(*len, KM_SLEEP); 462 kbuf = kmem_zalloc_large(*len, KM_SLEEP);
463 if (!kbuf) 463 if (!kbuf)
464 return ENOMEM; 464 return -ENOMEM;
465 465
466 error = xfs_attr_get(XFS_I(inode), name, kbuf, (int *)len, flags); 466 error = xfs_attr_get(XFS_I(inode), name, kbuf, (int *)len, flags);
467 if (error) 467 if (error)
468 goto out_kfree; 468 goto out_kfree;
469 469
470 if (copy_to_user(ubuf, kbuf, *len)) 470 if (copy_to_user(ubuf, kbuf, *len))
471 error = EFAULT; 471 error = -EFAULT;
472 472
473out_kfree: 473out_kfree:
474 kmem_free(kbuf); 474 kmem_free(kbuf);
@@ -484,20 +484,17 @@ xfs_attrmulti_attr_set(
484 __uint32_t flags) 484 __uint32_t flags)
485{ 485{
486 unsigned char *kbuf; 486 unsigned char *kbuf;
487 int error = EFAULT;
488 487
489 if (IS_IMMUTABLE(inode) || IS_APPEND(inode)) 488 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
490 return EPERM; 489 return -EPERM;
491 if (len > XATTR_SIZE_MAX) 490 if (len > XATTR_SIZE_MAX)
492 return EINVAL; 491 return -EINVAL;
493 492
494 kbuf = memdup_user(ubuf, len); 493 kbuf = memdup_user(ubuf, len);
495 if (IS_ERR(kbuf)) 494 if (IS_ERR(kbuf))
496 return PTR_ERR(kbuf); 495 return PTR_ERR(kbuf);
497 496
498 error = xfs_attr_set(XFS_I(inode), name, kbuf, len, flags); 497 return xfs_attr_set(XFS_I(inode), name, kbuf, len, flags);
499
500 return error;
501} 498}
502 499
503int 500int
@@ -507,7 +504,7 @@ xfs_attrmulti_attr_remove(
507 __uint32_t flags) 504 __uint32_t flags)
508{ 505{
509 if (IS_IMMUTABLE(inode) || IS_APPEND(inode)) 506 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
510 return EPERM; 507 return -EPERM;
511 return xfs_attr_remove(XFS_I(inode), name, flags); 508 return xfs_attr_remove(XFS_I(inode), name, flags);
512} 509}
513 510
@@ -536,18 +533,18 @@ xfs_attrmulti_by_handle(
536 if (IS_ERR(dentry)) 533 if (IS_ERR(dentry))
537 return PTR_ERR(dentry); 534 return PTR_ERR(dentry);
538 535
539 error = E2BIG; 536 error = -E2BIG;
540 size = am_hreq.opcount * sizeof(xfs_attr_multiop_t); 537 size = am_hreq.opcount * sizeof(xfs_attr_multiop_t);
541 if (!size || size > 16 * PAGE_SIZE) 538 if (!size || size > 16 * PAGE_SIZE)
542 goto out_dput; 539 goto out_dput;
543 540
544 ops = memdup_user(am_hreq.ops, size); 541 ops = memdup_user(am_hreq.ops, size);
545 if (IS_ERR(ops)) { 542 if (IS_ERR(ops)) {
546 error = -PTR_ERR(ops); 543 error = PTR_ERR(ops);
547 goto out_dput; 544 goto out_dput;
548 } 545 }
549 546
550 error = ENOMEM; 547 error = -ENOMEM;
551 attr_name = kmalloc(MAXNAMELEN, GFP_KERNEL); 548 attr_name = kmalloc(MAXNAMELEN, GFP_KERNEL);
552 if (!attr_name) 549 if (!attr_name)
553 goto out_kfree_ops; 550 goto out_kfree_ops;
@@ -557,7 +554,7 @@ xfs_attrmulti_by_handle(
557 ops[i].am_error = strncpy_from_user((char *)attr_name, 554 ops[i].am_error = strncpy_from_user((char *)attr_name,
558 ops[i].am_attrname, MAXNAMELEN); 555 ops[i].am_attrname, MAXNAMELEN);
559 if (ops[i].am_error == 0 || ops[i].am_error == MAXNAMELEN) 556 if (ops[i].am_error == 0 || ops[i].am_error == MAXNAMELEN)
560 error = ERANGE; 557 error = -ERANGE;
561 if (ops[i].am_error < 0) 558 if (ops[i].am_error < 0)
562 break; 559 break;
563 560
@@ -588,19 +585,19 @@ xfs_attrmulti_by_handle(
588 mnt_drop_write_file(parfilp); 585 mnt_drop_write_file(parfilp);
589 break; 586 break;
590 default: 587 default:
591 ops[i].am_error = EINVAL; 588 ops[i].am_error = -EINVAL;
592 } 589 }
593 } 590 }
594 591
595 if (copy_to_user(am_hreq.ops, ops, size)) 592 if (copy_to_user(am_hreq.ops, ops, size))
596 error = EFAULT; 593 error = -EFAULT;
597 594
598 kfree(attr_name); 595 kfree(attr_name);
599 out_kfree_ops: 596 out_kfree_ops:
600 kfree(ops); 597 kfree(ops);
601 out_dput: 598 out_dput:
602 dput(dentry); 599 dput(dentry);
603 return -error; 600 return error;
604} 601}
605 602
606int 603int
@@ -652,7 +649,7 @@ xfs_ioc_space(
652 bf->l_start += XFS_ISIZE(ip); 649 bf->l_start += XFS_ISIZE(ip);
653 break; 650 break;
654 default: 651 default:
655 error = EINVAL; 652 error = -EINVAL;
656 goto out_unlock; 653 goto out_unlock;
657 } 654 }
658 655
@@ -669,7 +666,7 @@ xfs_ioc_space(
669 case XFS_IOC_UNRESVSP: 666 case XFS_IOC_UNRESVSP:
670 case XFS_IOC_UNRESVSP64: 667 case XFS_IOC_UNRESVSP64:
671 if (bf->l_len <= 0) { 668 if (bf->l_len <= 0) {
672 error = EINVAL; 669 error = -EINVAL;
673 goto out_unlock; 670 goto out_unlock;
674 } 671 }
675 break; 672 break;
@@ -682,7 +679,7 @@ xfs_ioc_space(
682 bf->l_start > mp->m_super->s_maxbytes || 679 bf->l_start > mp->m_super->s_maxbytes ||
683 bf->l_start + bf->l_len < 0 || 680 bf->l_start + bf->l_len < 0 ||
684 bf->l_start + bf->l_len >= mp->m_super->s_maxbytes) { 681 bf->l_start + bf->l_len >= mp->m_super->s_maxbytes) {
685 error = EINVAL; 682 error = -EINVAL;
686 goto out_unlock; 683 goto out_unlock;
687 } 684 }
688 685
@@ -723,7 +720,7 @@ xfs_ioc_space(
723 break; 720 break;
724 default: 721 default:
725 ASSERT(0); 722 ASSERT(0);
726 error = EINVAL; 723 error = -EINVAL;
727 } 724 }
728 725
729 if (error) 726 if (error)
@@ -759,7 +756,7 @@ xfs_ioc_space(
759out_unlock: 756out_unlock:
760 xfs_iunlock(ip, XFS_IOLOCK_EXCL); 757 xfs_iunlock(ip, XFS_IOLOCK_EXCL);
761 mnt_drop_write_file(filp); 758 mnt_drop_write_file(filp);
762 return -error; 759 return error;
763} 760}
764 761
765STATIC int 762STATIC int
@@ -807,7 +804,7 @@ xfs_ioc_bulkstat(
807 &done); 804 &done);
808 805
809 if (error) 806 if (error)
810 return -error; 807 return error;
811 808
812 if (bulkreq.ocount != NULL) { 809 if (bulkreq.ocount != NULL) {
813 if (copy_to_user(bulkreq.lastip, &inlast, 810 if (copy_to_user(bulkreq.lastip, &inlast,
@@ -831,7 +828,7 @@ xfs_ioc_fsgeometry_v1(
831 828
832 error = xfs_fs_geometry(mp, &fsgeo, 3); 829 error = xfs_fs_geometry(mp, &fsgeo, 3);
833 if (error) 830 if (error)
834 return -error; 831 return error;
835 832
836 /* 833 /*
837 * Caller should have passed an argument of type 834 * Caller should have passed an argument of type
@@ -853,7 +850,7 @@ xfs_ioc_fsgeometry(
853 850
854 error = xfs_fs_geometry(mp, &fsgeo, 4); 851 error = xfs_fs_geometry(mp, &fsgeo, 4);
855 if (error) 852 if (error)
856 return -error; 853 return error;
857 854
858 if (copy_to_user(arg, &fsgeo, sizeof(fsgeo))) 855 if (copy_to_user(arg, &fsgeo, sizeof(fsgeo)))
859 return -EFAULT; 856 return -EFAULT;
@@ -1041,16 +1038,16 @@ xfs_ioctl_setattr(
1041 trace_xfs_ioctl_setattr(ip); 1038 trace_xfs_ioctl_setattr(ip);
1042 1039
1043 if (mp->m_flags & XFS_MOUNT_RDONLY) 1040 if (mp->m_flags & XFS_MOUNT_RDONLY)
1044 return EROFS; 1041 return -EROFS;
1045 if (XFS_FORCED_SHUTDOWN(mp)) 1042 if (XFS_FORCED_SHUTDOWN(mp))
1046 return EIO; 1043 return -EIO;
1047 1044
1048 /* 1045 /*
1049 * Disallow 32bit project ids when projid32bit feature is not enabled. 1046 * Disallow 32bit project ids when projid32bit feature is not enabled.
1050 */ 1047 */
1051 if ((mask & FSX_PROJID) && (fa->fsx_projid > (__uint16_t)-1) && 1048 if ((mask & FSX_PROJID) && (fa->fsx_projid > (__uint16_t)-1) &&
1052 !xfs_sb_version_hasprojid32bit(&ip->i_mount->m_sb)) 1049 !xfs_sb_version_hasprojid32bit(&ip->i_mount->m_sb))
1053 return EINVAL; 1050 return -EINVAL;
1054 1051
1055 /* 1052 /*
1056 * If disk quotas is on, we make sure that the dquots do exist on disk, 1053 * If disk quotas is on, we make sure that the dquots do exist on disk,
@@ -1088,7 +1085,7 @@ xfs_ioctl_setattr(
1088 * CAP_FSETID capability is applicable. 1085 * CAP_FSETID capability is applicable.
1089 */ 1086 */
1090 if (!inode_owner_or_capable(VFS_I(ip))) { 1087 if (!inode_owner_or_capable(VFS_I(ip))) {
1091 code = EPERM; 1088 code = -EPERM;
1092 goto error_return; 1089 goto error_return;
1093 } 1090 }
1094 1091
@@ -1099,7 +1096,7 @@ xfs_ioctl_setattr(
1099 */ 1096 */
1100 if (mask & FSX_PROJID) { 1097 if (mask & FSX_PROJID) {
1101 if (current_user_ns() != &init_user_ns) { 1098 if (current_user_ns() != &init_user_ns) {
1102 code = EINVAL; 1099 code = -EINVAL;
1103 goto error_return; 1100 goto error_return;
1104 } 1101 }
1105 1102
@@ -1122,7 +1119,7 @@ xfs_ioctl_setattr(
1122 if (ip->i_d.di_nextents && 1119 if (ip->i_d.di_nextents &&
1123 ((ip->i_d.di_extsize << mp->m_sb.sb_blocklog) != 1120 ((ip->i_d.di_extsize << mp->m_sb.sb_blocklog) !=
1124 fa->fsx_extsize)) { 1121 fa->fsx_extsize)) {
1125 code = EINVAL; /* EFBIG? */ 1122 code = -EINVAL; /* EFBIG? */
1126 goto error_return; 1123 goto error_return;
1127 } 1124 }
1128 1125
@@ -1141,7 +1138,7 @@ xfs_ioctl_setattr(
1141 1138
1142 extsize_fsb = XFS_B_TO_FSB(mp, fa->fsx_extsize); 1139 extsize_fsb = XFS_B_TO_FSB(mp, fa->fsx_extsize);
1143 if (extsize_fsb > MAXEXTLEN) { 1140 if (extsize_fsb > MAXEXTLEN) {
1144 code = EINVAL; 1141 code = -EINVAL;
1145 goto error_return; 1142 goto error_return;
1146 } 1143 }
1147 1144
@@ -1153,13 +1150,13 @@ xfs_ioctl_setattr(
1153 } else { 1150 } else {
1154 size = mp->m_sb.sb_blocksize; 1151 size = mp->m_sb.sb_blocksize;
1155 if (extsize_fsb > mp->m_sb.sb_agblocks / 2) { 1152 if (extsize_fsb > mp->m_sb.sb_agblocks / 2) {
1156 code = EINVAL; 1153 code = -EINVAL;
1157 goto error_return; 1154 goto error_return;
1158 } 1155 }
1159 } 1156 }
1160 1157
1161 if (fa->fsx_extsize % size) { 1158 if (fa->fsx_extsize % size) {
1162 code = EINVAL; 1159 code = -EINVAL;
1163 goto error_return; 1160 goto error_return;
1164 } 1161 }
1165 } 1162 }
@@ -1173,7 +1170,7 @@ xfs_ioctl_setattr(
1173 if ((ip->i_d.di_nextents || ip->i_delayed_blks) && 1170 if ((ip->i_d.di_nextents || ip->i_delayed_blks) &&
1174 (XFS_IS_REALTIME_INODE(ip)) != 1171 (XFS_IS_REALTIME_INODE(ip)) !=
1175 (fa->fsx_xflags & XFS_XFLAG_REALTIME)) { 1172 (fa->fsx_xflags & XFS_XFLAG_REALTIME)) {
1176 code = EINVAL; /* EFBIG? */ 1173 code = -EINVAL; /* EFBIG? */
1177 goto error_return; 1174 goto error_return;
1178 } 1175 }
1179 1176
@@ -1184,7 +1181,7 @@ xfs_ioctl_setattr(
1184 if ((mp->m_sb.sb_rblocks == 0) || 1181 if ((mp->m_sb.sb_rblocks == 0) ||
1185 (mp->m_sb.sb_rextsize == 0) || 1182 (mp->m_sb.sb_rextsize == 0) ||
1186 (ip->i_d.di_extsize % mp->m_sb.sb_rextsize)) { 1183 (ip->i_d.di_extsize % mp->m_sb.sb_rextsize)) {
1187 code = EINVAL; 1184 code = -EINVAL;
1188 goto error_return; 1185 goto error_return;
1189 } 1186 }
1190 } 1187 }
@@ -1198,7 +1195,7 @@ xfs_ioctl_setattr(
1198 (fa->fsx_xflags & 1195 (fa->fsx_xflags &
1199 (XFS_XFLAG_IMMUTABLE | XFS_XFLAG_APPEND))) && 1196 (XFS_XFLAG_IMMUTABLE | XFS_XFLAG_APPEND))) &&
1200 !capable(CAP_LINUX_IMMUTABLE)) { 1197 !capable(CAP_LINUX_IMMUTABLE)) {
1201 code = EPERM; 1198 code = -EPERM;
1202 goto error_return; 1199 goto error_return;
1203 } 1200 }
1204 } 1201 }
@@ -1301,7 +1298,7 @@ xfs_ioc_fssetxattr(
1301 return error; 1298 return error;
1302 error = xfs_ioctl_setattr(ip, &fa, mask); 1299 error = xfs_ioctl_setattr(ip, &fa, mask);
1303 mnt_drop_write_file(filp); 1300 mnt_drop_write_file(filp);
1304 return -error; 1301 return error;
1305} 1302}
1306 1303
1307STATIC int 1304STATIC int
@@ -1346,7 +1343,7 @@ xfs_ioc_setxflags(
1346 return error; 1343 return error;
1347 error = xfs_ioctl_setattr(ip, &fa, mask); 1344 error = xfs_ioctl_setattr(ip, &fa, mask);
1348 mnt_drop_write_file(filp); 1345 mnt_drop_write_file(filp);
1349 return -error; 1346 return error;
1350} 1347}
1351 1348
1352STATIC int 1349STATIC int
@@ -1356,7 +1353,7 @@ xfs_getbmap_format(void **ap, struct getbmapx *bmv, int *full)
1356 1353
1357 /* copy only getbmap portion (not getbmapx) */ 1354 /* copy only getbmap portion (not getbmapx) */
1358 if (copy_to_user(base, bmv, sizeof(struct getbmap))) 1355 if (copy_to_user(base, bmv, sizeof(struct getbmap)))
1359 return EFAULT; 1356 return -EFAULT;
1360 1357
1361 *ap += sizeof(struct getbmap); 1358 *ap += sizeof(struct getbmap);
1362 return 0; 1359 return 0;
@@ -1385,7 +1382,7 @@ xfs_ioc_getbmap(
1385 error = xfs_getbmap(ip, &bmx, xfs_getbmap_format, 1382 error = xfs_getbmap(ip, &bmx, xfs_getbmap_format,
1386 (struct getbmap *)arg+1); 1383 (struct getbmap *)arg+1);
1387 if (error) 1384 if (error)
1388 return -error; 1385 return error;
1389 1386
1390 /* copy back header - only size of getbmap */ 1387 /* copy back header - only size of getbmap */
1391 if (copy_to_user(arg, &bmx, sizeof(struct getbmap))) 1388 if (copy_to_user(arg, &bmx, sizeof(struct getbmap)))
@@ -1399,7 +1396,7 @@ xfs_getbmapx_format(void **ap, struct getbmapx *bmv, int *full)
1399 struct getbmapx __user *base = *ap; 1396 struct getbmapx __user *base = *ap;
1400 1397
1401 if (copy_to_user(base, bmv, sizeof(struct getbmapx))) 1398 if (copy_to_user(base, bmv, sizeof(struct getbmapx)))
1402 return EFAULT; 1399 return -EFAULT;
1403 1400
1404 *ap += sizeof(struct getbmapx); 1401 *ap += sizeof(struct getbmapx);
1405 return 0; 1402 return 0;
@@ -1425,7 +1422,7 @@ xfs_ioc_getbmapx(
1425 error = xfs_getbmap(ip, &bmx, xfs_getbmapx_format, 1422 error = xfs_getbmap(ip, &bmx, xfs_getbmapx_format,
1426 (struct getbmapx *)arg+1); 1423 (struct getbmapx *)arg+1);
1427 if (error) 1424 if (error)
1428 return -error; 1425 return error;
1429 1426
1430 /* copy back header */ 1427 /* copy back header */
1431 if (copy_to_user(arg, &bmx, sizeof(struct getbmapx))) 1428 if (copy_to_user(arg, &bmx, sizeof(struct getbmapx)))
@@ -1445,33 +1442,33 @@ xfs_ioc_swapext(
1445 /* Pull information for the target fd */ 1442 /* Pull information for the target fd */
1446 f = fdget((int)sxp->sx_fdtarget); 1443 f = fdget((int)sxp->sx_fdtarget);
1447 if (!f.file) { 1444 if (!f.file) {
1448 error = EINVAL; 1445 error = -EINVAL;
1449 goto out; 1446 goto out;
1450 } 1447 }
1451 1448
1452 if (!(f.file->f_mode & FMODE_WRITE) || 1449 if (!(f.file->f_mode & FMODE_WRITE) ||
1453 !(f.file->f_mode & FMODE_READ) || 1450 !(f.file->f_mode & FMODE_READ) ||
1454 (f.file->f_flags & O_APPEND)) { 1451 (f.file->f_flags & O_APPEND)) {
1455 error = EBADF; 1452 error = -EBADF;
1456 goto out_put_file; 1453 goto out_put_file;
1457 } 1454 }
1458 1455
1459 tmp = fdget((int)sxp->sx_fdtmp); 1456 tmp = fdget((int)sxp->sx_fdtmp);
1460 if (!tmp.file) { 1457 if (!tmp.file) {
1461 error = EINVAL; 1458 error = -EINVAL;
1462 goto out_put_file; 1459 goto out_put_file;
1463 } 1460 }
1464 1461
1465 if (!(tmp.file->f_mode & FMODE_WRITE) || 1462 if (!(tmp.file->f_mode & FMODE_WRITE) ||
1466 !(tmp.file->f_mode & FMODE_READ) || 1463 !(tmp.file->f_mode & FMODE_READ) ||
1467 (tmp.file->f_flags & O_APPEND)) { 1464 (tmp.file->f_flags & O_APPEND)) {
1468 error = EBADF; 1465 error = -EBADF;
1469 goto out_put_tmp_file; 1466 goto out_put_tmp_file;
1470 } 1467 }
1471 1468
1472 if (IS_SWAPFILE(file_inode(f.file)) || 1469 if (IS_SWAPFILE(file_inode(f.file)) ||
1473 IS_SWAPFILE(file_inode(tmp.file))) { 1470 IS_SWAPFILE(file_inode(tmp.file))) {
1474 error = EINVAL; 1471 error = -EINVAL;
1475 goto out_put_tmp_file; 1472 goto out_put_tmp_file;
1476 } 1473 }
1477 1474
@@ -1479,17 +1476,17 @@ xfs_ioc_swapext(
1479 tip = XFS_I(file_inode(tmp.file)); 1476 tip = XFS_I(file_inode(tmp.file));
1480 1477
1481 if (ip->i_mount != tip->i_mount) { 1478 if (ip->i_mount != tip->i_mount) {
1482 error = EINVAL; 1479 error = -EINVAL;
1483 goto out_put_tmp_file; 1480 goto out_put_tmp_file;
1484 } 1481 }
1485 1482
1486 if (ip->i_ino == tip->i_ino) { 1483 if (ip->i_ino == tip->i_ino) {
1487 error = EINVAL; 1484 error = -EINVAL;
1488 goto out_put_tmp_file; 1485 goto out_put_tmp_file;
1489 } 1486 }
1490 1487
1491 if (XFS_FORCED_SHUTDOWN(ip->i_mount)) { 1488 if (XFS_FORCED_SHUTDOWN(ip->i_mount)) {
1492 error = EIO; 1489 error = -EIO;
1493 goto out_put_tmp_file; 1490 goto out_put_tmp_file;
1494 } 1491 }
1495 1492
@@ -1597,7 +1594,7 @@ xfs_file_ioctl(
1597 error = xfs_set_dmattrs(ip, dmi.fsd_dmevmask, 1594 error = xfs_set_dmattrs(ip, dmi.fsd_dmevmask,
1598 dmi.fsd_dmstate); 1595 dmi.fsd_dmstate);
1599 mnt_drop_write_file(filp); 1596 mnt_drop_write_file(filp);
1600 return -error; 1597 return error;
1601 } 1598 }
1602 1599
1603 case XFS_IOC_GETBMAP: 1600 case XFS_IOC_GETBMAP:
@@ -1649,7 +1646,7 @@ xfs_file_ioctl(
1649 return error; 1646 return error;
1650 error = xfs_ioc_swapext(&sxp); 1647 error = xfs_ioc_swapext(&sxp);
1651 mnt_drop_write_file(filp); 1648 mnt_drop_write_file(filp);
1652 return -error; 1649 return error;
1653 } 1650 }
1654 1651
1655 case XFS_IOC_FSCOUNTS: { 1652 case XFS_IOC_FSCOUNTS: {
@@ -1657,7 +1654,7 @@ xfs_file_ioctl(
1657 1654
1658 error = xfs_fs_counts(mp, &out); 1655 error = xfs_fs_counts(mp, &out);
1659 if (error) 1656 if (error)
1660 return -error; 1657 return error;
1661 1658
1662 if (copy_to_user(arg, &out, sizeof(out))) 1659 if (copy_to_user(arg, &out, sizeof(out)))
1663 return -EFAULT; 1660 return -EFAULT;
@@ -1686,7 +1683,7 @@ xfs_file_ioctl(
1686 error = xfs_reserve_blocks(mp, &in, &inout); 1683 error = xfs_reserve_blocks(mp, &in, &inout);
1687 mnt_drop_write_file(filp); 1684 mnt_drop_write_file(filp);
1688 if (error) 1685 if (error)
1689 return -error; 1686 return error;
1690 1687
1691 if (copy_to_user(arg, &inout, sizeof(inout))) 1688 if (copy_to_user(arg, &inout, sizeof(inout)))
1692 return -EFAULT; 1689 return -EFAULT;
@@ -1701,7 +1698,7 @@ xfs_file_ioctl(
1701 1698
1702 error = xfs_reserve_blocks(mp, NULL, &out); 1699 error = xfs_reserve_blocks(mp, NULL, &out);
1703 if (error) 1700 if (error)
1704 return -error; 1701 return error;
1705 1702
1706 if (copy_to_user(arg, &out, sizeof(out))) 1703 if (copy_to_user(arg, &out, sizeof(out)))
1707 return -EFAULT; 1704 return -EFAULT;
@@ -1720,7 +1717,7 @@ xfs_file_ioctl(
1720 return error; 1717 return error;
1721 error = xfs_growfs_data(mp, &in); 1718 error = xfs_growfs_data(mp, &in);
1722 mnt_drop_write_file(filp); 1719 mnt_drop_write_file(filp);
1723 return -error; 1720 return error;
1724 } 1721 }
1725 1722
1726 case XFS_IOC_FSGROWFSLOG: { 1723 case XFS_IOC_FSGROWFSLOG: {
@@ -1734,7 +1731,7 @@ xfs_file_ioctl(
1734 return error; 1731 return error;
1735 error = xfs_growfs_log(mp, &in); 1732 error = xfs_growfs_log(mp, &in);
1736 mnt_drop_write_file(filp); 1733 mnt_drop_write_file(filp);
1737 return -error; 1734 return error;
1738 } 1735 }
1739 1736
1740 case XFS_IOC_FSGROWFSRT: { 1737 case XFS_IOC_FSGROWFSRT: {
@@ -1748,7 +1745,7 @@ xfs_file_ioctl(
1748 return error; 1745 return error;
1749 error = xfs_growfs_rt(mp, &in); 1746 error = xfs_growfs_rt(mp, &in);
1750 mnt_drop_write_file(filp); 1747 mnt_drop_write_file(filp);
1751 return -error; 1748 return error;
1752 } 1749 }
1753 1750
1754 case XFS_IOC_GOINGDOWN: { 1751 case XFS_IOC_GOINGDOWN: {
@@ -1760,8 +1757,7 @@ xfs_file_ioctl(
1760 if (get_user(in, (__uint32_t __user *)arg)) 1757 if (get_user(in, (__uint32_t __user *)arg))
1761 return -EFAULT; 1758 return -EFAULT;
1762 1759
1763 error = xfs_fs_goingdown(mp, in); 1760 return xfs_fs_goingdown(mp, in);
1764 return -error;
1765 } 1761 }
1766 1762
1767 case XFS_IOC_ERROR_INJECTION: { 1763 case XFS_IOC_ERROR_INJECTION: {
@@ -1773,16 +1769,14 @@ xfs_file_ioctl(
1773 if (copy_from_user(&in, arg, sizeof(in))) 1769 if (copy_from_user(&in, arg, sizeof(in)))
1774 return -EFAULT; 1770 return -EFAULT;
1775 1771
1776 error = xfs_errortag_add(in.errtag, mp); 1772 return xfs_errortag_add(in.errtag, mp);
1777 return -error;
1778 } 1773 }
1779 1774
1780 case XFS_IOC_ERROR_CLEARALL: 1775 case XFS_IOC_ERROR_CLEARALL:
1781 if (!capable(CAP_SYS_ADMIN)) 1776 if (!capable(CAP_SYS_ADMIN))
1782 return -EPERM; 1777 return -EPERM;
1783 1778
1784 error = xfs_errortag_clearall(mp, 1); 1779 return xfs_errortag_clearall(mp, 1);
1785 return -error;
1786 1780
1787 case XFS_IOC_FREE_EOFBLOCKS: { 1781 case XFS_IOC_FREE_EOFBLOCKS: {
1788 struct xfs_fs_eofblocks eofb; 1782 struct xfs_fs_eofblocks eofb;
@@ -1799,9 +1793,9 @@ xfs_file_ioctl(
1799 1793
1800 error = xfs_fs_eofblocks_from_user(&eofb, &keofb); 1794 error = xfs_fs_eofblocks_from_user(&eofb, &keofb);
1801 if (error) 1795 if (error)
1802 return -error; 1796 return error;
1803 1797
1804 return -xfs_icache_free_eofblocks(mp, &keofb); 1798 return xfs_icache_free_eofblocks(mp, &keofb);
1805 } 1799 }
1806 1800
1807 default: 1801 default:
diff --git a/fs/xfs/xfs_ioctl32.c b/fs/xfs/xfs_ioctl32.c
index 357963ec9ba6..e65ea67e3ae3 100644
--- a/fs/xfs/xfs_ioctl32.c
+++ b/fs/xfs/xfs_ioctl32.c
@@ -70,7 +70,7 @@ xfs_compat_ioc_fsgeometry_v1(
70 70
71 error = xfs_fs_geometry(mp, &fsgeo, 3); 71 error = xfs_fs_geometry(mp, &fsgeo, 3);
72 if (error) 72 if (error)
73 return -error; 73 return error;
74 /* The 32-bit variant simply has some padding at the end */ 74 /* The 32-bit variant simply has some padding at the end */
75 if (copy_to_user(arg32, &fsgeo, sizeof(struct compat_xfs_fsop_geom_v1))) 75 if (copy_to_user(arg32, &fsgeo, sizeof(struct compat_xfs_fsop_geom_v1)))
76 return -EFAULT; 76 return -EFAULT;
@@ -195,7 +195,7 @@ xfs_bulkstat_one_fmt_compat(
195 compat_xfs_bstat_t __user *p32 = ubuffer; 195 compat_xfs_bstat_t __user *p32 = ubuffer;
196 196
197 if (ubsize < sizeof(*p32)) 197 if (ubsize < sizeof(*p32))
198 return ENOMEM; 198 return -ENOMEM;
199 199
200 if (put_user(buffer->bs_ino, &p32->bs_ino) || 200 if (put_user(buffer->bs_ino, &p32->bs_ino) ||
201 put_user(buffer->bs_mode, &p32->bs_mode) || 201 put_user(buffer->bs_mode, &p32->bs_mode) ||
@@ -218,7 +218,7 @@ xfs_bulkstat_one_fmt_compat(
218 put_user(buffer->bs_dmevmask, &p32->bs_dmevmask) || 218 put_user(buffer->bs_dmevmask, &p32->bs_dmevmask) ||
219 put_user(buffer->bs_dmstate, &p32->bs_dmstate) || 219 put_user(buffer->bs_dmstate, &p32->bs_dmstate) ||
220 put_user(buffer->bs_aextents, &p32->bs_aextents)) 220 put_user(buffer->bs_aextents, &p32->bs_aextents))
221 return EFAULT; 221 return -EFAULT;
222 if (ubused) 222 if (ubused)
223 *ubused = sizeof(*p32); 223 *ubused = sizeof(*p32);
224 return 0; 224 return 0;
@@ -294,9 +294,9 @@ xfs_compat_ioc_bulkstat(
294 xfs_bulkstat_one_compat, sizeof(compat_xfs_bstat_t), 294 xfs_bulkstat_one_compat, sizeof(compat_xfs_bstat_t),
295 bulkreq.ubuffer, &done); 295 bulkreq.ubuffer, &done);
296 } else 296 } else
297 error = EINVAL; 297 error = -EINVAL;
298 if (error) 298 if (error)
299 return -error; 299 return error;
300 300
301 if (bulkreq.ocount != NULL) { 301 if (bulkreq.ocount != NULL) {
302 if (copy_to_user(bulkreq.lastip, &inlast, 302 if (copy_to_user(bulkreq.lastip, &inlast,
@@ -376,7 +376,7 @@ xfs_compat_attrlist_by_handle(
376 goto out_dput; 376 goto out_dput;
377 377
378 cursor = (attrlist_cursor_kern_t *)&al_hreq.pos; 378 cursor = (attrlist_cursor_kern_t *)&al_hreq.pos;
379 error = -xfs_attr_list(XFS_I(dentry->d_inode), kbuf, al_hreq.buflen, 379 error = xfs_attr_list(XFS_I(dentry->d_inode), kbuf, al_hreq.buflen,
380 al_hreq.flags, cursor); 380 al_hreq.flags, cursor);
381 if (error) 381 if (error)
382 goto out_kfree; 382 goto out_kfree;
@@ -417,7 +417,7 @@ xfs_compat_attrmulti_by_handle(
417 if (IS_ERR(dentry)) 417 if (IS_ERR(dentry))
418 return PTR_ERR(dentry); 418 return PTR_ERR(dentry);
419 419
420 error = E2BIG; 420 error = -E2BIG;
421 size = am_hreq.opcount * sizeof(compat_xfs_attr_multiop_t); 421 size = am_hreq.opcount * sizeof(compat_xfs_attr_multiop_t);
422 if (!size || size > 16 * PAGE_SIZE) 422 if (!size || size > 16 * PAGE_SIZE)
423 goto out_dput; 423 goto out_dput;
@@ -428,7 +428,7 @@ xfs_compat_attrmulti_by_handle(
428 goto out_dput; 428 goto out_dput;
429 } 429 }
430 430
431 error = ENOMEM; 431 error = -ENOMEM;
432 attr_name = kmalloc(MAXNAMELEN, GFP_KERNEL); 432 attr_name = kmalloc(MAXNAMELEN, GFP_KERNEL);
433 if (!attr_name) 433 if (!attr_name)
434 goto out_kfree_ops; 434 goto out_kfree_ops;
@@ -439,7 +439,7 @@ xfs_compat_attrmulti_by_handle(
439 compat_ptr(ops[i].am_attrname), 439 compat_ptr(ops[i].am_attrname),
440 MAXNAMELEN); 440 MAXNAMELEN);
441 if (ops[i].am_error == 0 || ops[i].am_error == MAXNAMELEN) 441 if (ops[i].am_error == 0 || ops[i].am_error == MAXNAMELEN)
442 error = ERANGE; 442 error = -ERANGE;
443 if (ops[i].am_error < 0) 443 if (ops[i].am_error < 0)
444 break; 444 break;
445 445
@@ -470,19 +470,19 @@ xfs_compat_attrmulti_by_handle(
470 mnt_drop_write_file(parfilp); 470 mnt_drop_write_file(parfilp);
471 break; 471 break;
472 default: 472 default:
473 ops[i].am_error = EINVAL; 473 ops[i].am_error = -EINVAL;
474 } 474 }
475 } 475 }
476 476
477 if (copy_to_user(compat_ptr(am_hreq.ops), ops, size)) 477 if (copy_to_user(compat_ptr(am_hreq.ops), ops, size))
478 error = EFAULT; 478 error = -EFAULT;
479 479
480 kfree(attr_name); 480 kfree(attr_name);
481 out_kfree_ops: 481 out_kfree_ops:
482 kfree(ops); 482 kfree(ops);
483 out_dput: 483 out_dput:
484 dput(dentry); 484 dput(dentry);
485 return -error; 485 return error;
486} 486}
487 487
488STATIC int 488STATIC int
@@ -515,7 +515,7 @@ xfs_compat_fssetdm_by_handle(
515 goto out; 515 goto out;
516 } 516 }
517 517
518 error = -xfs_set_dmattrs(XFS_I(dentry->d_inode), fsd.fsd_dmevmask, 518 error = xfs_set_dmattrs(XFS_I(dentry->d_inode), fsd.fsd_dmevmask,
519 fsd.fsd_dmstate); 519 fsd.fsd_dmstate);
520 520
521out: 521out:
@@ -604,7 +604,7 @@ xfs_file_compat_ioctl(
604 return error; 604 return error;
605 error = xfs_growfs_data(mp, &in); 605 error = xfs_growfs_data(mp, &in);
606 mnt_drop_write_file(filp); 606 mnt_drop_write_file(filp);
607 return -error; 607 return error;
608 } 608 }
609 case XFS_IOC_FSGROWFSRT_32: { 609 case XFS_IOC_FSGROWFSRT_32: {
610 struct xfs_growfs_rt in; 610 struct xfs_growfs_rt in;
@@ -616,7 +616,7 @@ xfs_file_compat_ioctl(
616 return error; 616 return error;
617 error = xfs_growfs_rt(mp, &in); 617 error = xfs_growfs_rt(mp, &in);
618 mnt_drop_write_file(filp); 618 mnt_drop_write_file(filp);
619 return -error; 619 return error;
620 } 620 }
621#endif 621#endif
622 /* long changes size, but xfs only copiese out 32 bits */ 622 /* long changes size, but xfs only copiese out 32 bits */
@@ -639,7 +639,7 @@ xfs_file_compat_ioctl(
639 return error; 639 return error;
640 error = xfs_ioc_swapext(&sxp); 640 error = xfs_ioc_swapext(&sxp);
641 mnt_drop_write_file(filp); 641 mnt_drop_write_file(filp);
642 return -error; 642 return error;
643 } 643 }
644 case XFS_IOC_FSBULKSTAT_32: 644 case XFS_IOC_FSBULKSTAT_32:
645 case XFS_IOC_FSBULKSTAT_SINGLE_32: 645 case XFS_IOC_FSBULKSTAT_SINGLE_32:
diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c
index c6d603080e5b..923c044bd26f 100644
--- a/fs/xfs/xfs_iomap.c
+++ b/fs/xfs/xfs_iomap.c
@@ -110,7 +110,7 @@ xfs_alert_fsblock_zero(
110 (unsigned long long)imap->br_startoff, 110 (unsigned long long)imap->br_startoff,
111 (unsigned long long)imap->br_blockcount, 111 (unsigned long long)imap->br_blockcount,
112 imap->br_state); 112 imap->br_state);
113 return EFSCORRUPTED; 113 return -EFSCORRUPTED;
114} 114}
115 115
116int 116int
@@ -225,7 +225,7 @@ xfs_iomap_write_direct(
225 * Copy any maps to caller's array and return any error. 225 * Copy any maps to caller's array and return any error.
226 */ 226 */
227 if (nimaps == 0) { 227 if (nimaps == 0) {
228 error = ENOSPC; 228 error = -ENOSPC;
229 goto out_unlock; 229 goto out_unlock;
230 } 230 }
231 231
@@ -596,8 +596,8 @@ retry:
596 imap, &nimaps, XFS_BMAPI_ENTIRE); 596 imap, &nimaps, XFS_BMAPI_ENTIRE);
597 switch (error) { 597 switch (error) {
598 case 0: 598 case 0:
599 case ENOSPC: 599 case -ENOSPC:
600 case EDQUOT: 600 case -EDQUOT:
601 break; 601 break;
602 default: 602 default:
603 return error; 603 return error;
@@ -614,7 +614,7 @@ retry:
614 error = 0; 614 error = 0;
615 goto retry; 615 goto retry;
616 } 616 }
617 return error ? error : ENOSPC; 617 return error ? error : -ENOSPC;
618 } 618 }
619 619
620 if (!(imap[0].br_startblock || XFS_IS_REALTIME_INODE(ip))) 620 if (!(imap[0].br_startblock || XFS_IS_REALTIME_INODE(ip)))
@@ -739,7 +739,7 @@ xfs_iomap_write_allocate(
739 if ((map_start_fsb + count_fsb) > last_block) { 739 if ((map_start_fsb + count_fsb) > last_block) {
740 count_fsb = last_block - map_start_fsb; 740 count_fsb = last_block - map_start_fsb;
741 if (count_fsb == 0) { 741 if (count_fsb == 0) {
742 error = EAGAIN; 742 error = -EAGAIN;
743 goto trans_cancel; 743 goto trans_cancel;
744 } 744 }
745 } 745 }
diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
index 6bdc1fc8f950..d75621ae3e36 100644
--- a/fs/xfs/xfs_iops.c
+++ b/fs/xfs/xfs_iops.c
@@ -72,7 +72,7 @@ xfs_initxattrs(
72 int error = 0; 72 int error = 0;
73 73
74 for (xattr = xattr_array; xattr->name != NULL; xattr++) { 74 for (xattr = xattr_array; xattr->name != NULL; xattr++) {
75 error = -xfs_attr_set(ip, xattr->name, xattr->value, 75 error = xfs_attr_set(ip, xattr->name, xattr->value,
76 xattr->value_len, ATTR_SECURE); 76 xattr->value_len, ATTR_SECURE);
77 if (error < 0) 77 if (error < 0)
78 break; 78 break;
@@ -93,7 +93,7 @@ xfs_init_security(
93 struct inode *dir, 93 struct inode *dir,
94 const struct qstr *qstr) 94 const struct qstr *qstr)
95{ 95{
96 return -security_inode_init_security(inode, dir, qstr, 96 return security_inode_init_security(inode, dir, qstr,
97 &xfs_initxattrs, NULL); 97 &xfs_initxattrs, NULL);
98} 98}
99 99
@@ -173,12 +173,12 @@ xfs_generic_create(
173 173
174#ifdef CONFIG_XFS_POSIX_ACL 174#ifdef CONFIG_XFS_POSIX_ACL
175 if (default_acl) { 175 if (default_acl) {
176 error = -xfs_set_acl(inode, default_acl, ACL_TYPE_DEFAULT); 176 error = xfs_set_acl(inode, default_acl, ACL_TYPE_DEFAULT);
177 if (error) 177 if (error)
178 goto out_cleanup_inode; 178 goto out_cleanup_inode;
179 } 179 }
180 if (acl) { 180 if (acl) {
181 error = -xfs_set_acl(inode, acl, ACL_TYPE_ACCESS); 181 error = xfs_set_acl(inode, acl, ACL_TYPE_ACCESS);
182 if (error) 182 if (error)
183 goto out_cleanup_inode; 183 goto out_cleanup_inode;
184 } 184 }
@@ -194,7 +194,7 @@ xfs_generic_create(
194 posix_acl_release(default_acl); 194 posix_acl_release(default_acl);
195 if (acl) 195 if (acl)
196 posix_acl_release(acl); 196 posix_acl_release(acl);
197 return -error; 197 return error;
198 198
199 out_cleanup_inode: 199 out_cleanup_inode:
200 if (!tmpfile) 200 if (!tmpfile)
@@ -248,8 +248,8 @@ xfs_vn_lookup(
248 xfs_dentry_to_name(&name, dentry, 0); 248 xfs_dentry_to_name(&name, dentry, 0);
249 error = xfs_lookup(XFS_I(dir), &name, &cip, NULL); 249 error = xfs_lookup(XFS_I(dir), &name, &cip, NULL);
250 if (unlikely(error)) { 250 if (unlikely(error)) {
251 if (unlikely(error != ENOENT)) 251 if (unlikely(error != -ENOENT))
252 return ERR_PTR(-error); 252 return ERR_PTR(error);
253 d_add(dentry, NULL); 253 d_add(dentry, NULL);
254 return NULL; 254 return NULL;
255 } 255 }
@@ -275,8 +275,8 @@ xfs_vn_ci_lookup(
275 xfs_dentry_to_name(&xname, dentry, 0); 275 xfs_dentry_to_name(&xname, dentry, 0);
276 error = xfs_lookup(XFS_I(dir), &xname, &ip, &ci_name); 276 error = xfs_lookup(XFS_I(dir), &xname, &ip, &ci_name);
277 if (unlikely(error)) { 277 if (unlikely(error)) {
278 if (unlikely(error != ENOENT)) 278 if (unlikely(error != -ENOENT))
279 return ERR_PTR(-error); 279 return ERR_PTR(error);
280 /* 280 /*
281 * call d_add(dentry, NULL) here when d_drop_negative_children 281 * call d_add(dentry, NULL) here when d_drop_negative_children
282 * is called in xfs_vn_mknod (ie. allow negative dentries 282 * is called in xfs_vn_mknod (ie. allow negative dentries
@@ -311,7 +311,7 @@ xfs_vn_link(
311 311
312 error = xfs_link(XFS_I(dir), XFS_I(inode), &name); 312 error = xfs_link(XFS_I(dir), XFS_I(inode), &name);
313 if (unlikely(error)) 313 if (unlikely(error))
314 return -error; 314 return error;
315 315
316 ihold(inode); 316 ihold(inode);
317 d_instantiate(dentry, inode); 317 d_instantiate(dentry, inode);
@@ -328,7 +328,7 @@ xfs_vn_unlink(
328 328
329 xfs_dentry_to_name(&name, dentry, 0); 329 xfs_dentry_to_name(&name, dentry, 0);
330 330
331 error = -xfs_remove(XFS_I(dir), &name, XFS_I(dentry->d_inode)); 331 error = xfs_remove(XFS_I(dir), &name, XFS_I(dentry->d_inode));
332 if (error) 332 if (error)
333 return error; 333 return error;
334 334
@@ -375,7 +375,7 @@ xfs_vn_symlink(
375 xfs_cleanup_inode(dir, inode, dentry); 375 xfs_cleanup_inode(dir, inode, dentry);
376 iput(inode); 376 iput(inode);
377 out: 377 out:
378 return -error; 378 return error;
379} 379}
380 380
381STATIC int 381STATIC int
@@ -392,8 +392,8 @@ xfs_vn_rename(
392 xfs_dentry_to_name(&oname, odentry, 0); 392 xfs_dentry_to_name(&oname, odentry, 0);
393 xfs_dentry_to_name(&nname, ndentry, odentry->d_inode->i_mode); 393 xfs_dentry_to_name(&nname, ndentry, odentry->d_inode->i_mode);
394 394
395 return -xfs_rename(XFS_I(odir), &oname, XFS_I(odentry->d_inode), 395 return xfs_rename(XFS_I(odir), &oname, XFS_I(odentry->d_inode),
396 XFS_I(ndir), &nname, new_inode ? 396 XFS_I(ndir), &nname, new_inode ?
397 XFS_I(new_inode) : NULL); 397 XFS_I(new_inode) : NULL);
398} 398}
399 399
@@ -414,7 +414,7 @@ xfs_vn_follow_link(
414 if (!link) 414 if (!link)
415 goto out_err; 415 goto out_err;
416 416
417 error = -xfs_readlink(XFS_I(dentry->d_inode), link); 417 error = xfs_readlink(XFS_I(dentry->d_inode), link);
418 if (unlikely(error)) 418 if (unlikely(error))
419 goto out_kfree; 419 goto out_kfree;
420 420
@@ -546,12 +546,12 @@ xfs_setattr_nonsize(
546 /* If acls are being inherited, we already have this checked */ 546 /* If acls are being inherited, we already have this checked */
547 if (!(flags & XFS_ATTR_NOACL)) { 547 if (!(flags & XFS_ATTR_NOACL)) {
548 if (mp->m_flags & XFS_MOUNT_RDONLY) 548 if (mp->m_flags & XFS_MOUNT_RDONLY)
549 return EROFS; 549 return -EROFS;
550 550
551 if (XFS_FORCED_SHUTDOWN(mp)) 551 if (XFS_FORCED_SHUTDOWN(mp))
552 return EIO; 552 return -EIO;
553 553
554 error = -inode_change_ok(inode, iattr); 554 error = inode_change_ok(inode, iattr);
555 if (error) 555 if (error)
556 return error; 556 return error;
557 } 557 }
@@ -713,7 +713,7 @@ xfs_setattr_nonsize(
713 * Posix ACL code seems to care about this issue either. 713 * Posix ACL code seems to care about this issue either.
714 */ 714 */
715 if ((mask & ATTR_MODE) && !(flags & XFS_ATTR_NOACL)) { 715 if ((mask & ATTR_MODE) && !(flags & XFS_ATTR_NOACL)) {
716 error = -posix_acl_chmod(inode, inode->i_mode); 716 error = posix_acl_chmod(inode, inode->i_mode);
717 if (error) 717 if (error)
718 return error; 718 return error;
719 } 719 }
@@ -748,12 +748,12 @@ xfs_setattr_size(
748 trace_xfs_setattr(ip); 748 trace_xfs_setattr(ip);
749 749
750 if (mp->m_flags & XFS_MOUNT_RDONLY) 750 if (mp->m_flags & XFS_MOUNT_RDONLY)
751 return EROFS; 751 return -EROFS;
752 752
753 if (XFS_FORCED_SHUTDOWN(mp)) 753 if (XFS_FORCED_SHUTDOWN(mp))
754 return EIO; 754 return -EIO;
755 755
756 error = -inode_change_ok(inode, iattr); 756 error = inode_change_ok(inode, iattr);
757 if (error) 757 if (error)
758 return error; 758 return error;
759 759
@@ -818,7 +818,7 @@ xfs_setattr_size(
818 * care about here. 818 * care about here.
819 */ 819 */
820 if (oldsize != ip->i_d.di_size && newsize > ip->i_d.di_size) { 820 if (oldsize != ip->i_d.di_size && newsize > ip->i_d.di_size) {
821 error = -filemap_write_and_wait_range(VFS_I(ip)->i_mapping, 821 error = filemap_write_and_wait_range(VFS_I(ip)->i_mapping,
822 ip->i_d.di_size, newsize); 822 ip->i_d.di_size, newsize);
823 if (error) 823 if (error)
824 return error; 824 return error;
@@ -844,7 +844,7 @@ xfs_setattr_size(
844 * much we can do about this, except to hope that the caller sees ENOMEM 844 * much we can do about this, except to hope that the caller sees ENOMEM
845 * and retries the truncate operation. 845 * and retries the truncate operation.
846 */ 846 */
847 error = -block_truncate_page(inode->i_mapping, newsize, xfs_get_blocks); 847 error = block_truncate_page(inode->i_mapping, newsize, xfs_get_blocks);
848 if (error) 848 if (error)
849 return error; 849 return error;
850 truncate_setsize(inode, newsize); 850 truncate_setsize(inode, newsize);
@@ -950,7 +950,7 @@ xfs_vn_setattr(
950 error = xfs_setattr_nonsize(ip, iattr, 0); 950 error = xfs_setattr_nonsize(ip, iattr, 0);
951 } 951 }
952 952
953 return -error; 953 return error;
954} 954}
955 955
956STATIC int 956STATIC int
@@ -970,7 +970,7 @@ xfs_vn_update_time(
970 error = xfs_trans_reserve(tp, &M_RES(mp)->tr_fsyncts, 0, 0); 970 error = xfs_trans_reserve(tp, &M_RES(mp)->tr_fsyncts, 0, 0);
971 if (error) { 971 if (error) {
972 xfs_trans_cancel(tp, 0); 972 xfs_trans_cancel(tp, 0);
973 return -error; 973 return error;
974 } 974 }
975 975
976 xfs_ilock(ip, XFS_ILOCK_EXCL); 976 xfs_ilock(ip, XFS_ILOCK_EXCL);
@@ -991,7 +991,7 @@ xfs_vn_update_time(
991 } 991 }
992 xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL); 992 xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);
993 xfs_trans_log_inode(tp, ip, XFS_ILOG_TIMESTAMP); 993 xfs_trans_log_inode(tp, ip, XFS_ILOG_TIMESTAMP);
994 return -xfs_trans_commit(tp, 0); 994 return xfs_trans_commit(tp, 0);
995} 995}
996 996
997#define XFS_FIEMAP_FLAGS (FIEMAP_FLAG_SYNC|FIEMAP_FLAG_XATTR) 997#define XFS_FIEMAP_FLAGS (FIEMAP_FLAG_SYNC|FIEMAP_FLAG_XATTR)
@@ -1036,7 +1036,7 @@ xfs_fiemap_format(
1036 *full = 1; /* user array now full */ 1036 *full = 1; /* user array now full */
1037 } 1037 }
1038 1038
1039 return -error; 1039 return error;
1040} 1040}
1041 1041
1042STATIC int 1042STATIC int
@@ -1075,7 +1075,7 @@ xfs_vn_fiemap(
1075 1075
1076 error = xfs_getbmap(ip, &bm, xfs_fiemap_format, fieinfo); 1076 error = xfs_getbmap(ip, &bm, xfs_fiemap_format, fieinfo);
1077 if (error) 1077 if (error)
1078 return -error; 1078 return error;
1079 1079
1080 return 0; 1080 return 0;
1081} 1081}
diff --git a/fs/xfs/xfs_itable.c b/fs/xfs/xfs_itable.c
index e4056a7495e5..7e54992bcae9 100644
--- a/fs/xfs/xfs_itable.c
+++ b/fs/xfs/xfs_itable.c
@@ -67,11 +67,11 @@ xfs_bulkstat_one_int(
67 *stat = BULKSTAT_RV_NOTHING; 67 *stat = BULKSTAT_RV_NOTHING;
68 68
69 if (!buffer || xfs_internal_inum(mp, ino)) 69 if (!buffer || xfs_internal_inum(mp, ino))
70 return EINVAL; 70 return -EINVAL;
71 71
72 buf = kmem_alloc(sizeof(*buf), KM_SLEEP | KM_MAYFAIL); 72 buf = kmem_alloc(sizeof(*buf), KM_SLEEP | KM_MAYFAIL);
73 if (!buf) 73 if (!buf)
74 return ENOMEM; 74 return -ENOMEM;
75 75
76 error = xfs_iget(mp, NULL, ino, 76 error = xfs_iget(mp, NULL, ino,
77 (XFS_IGET_DONTCACHE | XFS_IGET_UNTRUSTED), 77 (XFS_IGET_DONTCACHE | XFS_IGET_UNTRUSTED),
@@ -154,9 +154,9 @@ xfs_bulkstat_one_fmt(
154 const xfs_bstat_t *buffer) 154 const xfs_bstat_t *buffer)
155{ 155{
156 if (ubsize < sizeof(*buffer)) 156 if (ubsize < sizeof(*buffer))
157 return ENOMEM; 157 return -ENOMEM;
158 if (copy_to_user(ubuffer, buffer, sizeof(*buffer))) 158 if (copy_to_user(ubuffer, buffer, sizeof(*buffer)))
159 return EFAULT; 159 return -EFAULT;
160 if (ubused) 160 if (ubused)
161 *ubused = sizeof(*buffer); 161 *ubused = sizeof(*buffer);
162 return 0; 162 return 0;
@@ -234,7 +234,7 @@ xfs_bulkstat(
234 return 0; 234 return 0;
235 } 235 }
236 if (!ubcountp || *ubcountp <= 0) { 236 if (!ubcountp || *ubcountp <= 0) {
237 return EINVAL; 237 return -EINVAL;
238 } 238 }
239 ubcount = *ubcountp; /* statstruct's */ 239 ubcount = *ubcountp; /* statstruct's */
240 ubleft = ubcount * statstruct_size; /* bytes */ 240 ubleft = ubcount * statstruct_size; /* bytes */
@@ -246,7 +246,7 @@ xfs_bulkstat(
246 inodes_per_cluster = blks_per_cluster << mp->m_sb.sb_inopblog; 246 inodes_per_cluster = blks_per_cluster << mp->m_sb.sb_inopblog;
247 irbuf = kmem_zalloc_greedy(&irbsize, PAGE_SIZE, PAGE_SIZE * 4); 247 irbuf = kmem_zalloc_greedy(&irbsize, PAGE_SIZE, PAGE_SIZE * 4);
248 if (!irbuf) 248 if (!irbuf)
249 return ENOMEM; 249 return -ENOMEM;
250 250
251 nirbuf = irbsize / sizeof(*irbuf); 251 nirbuf = irbsize / sizeof(*irbuf);
252 252
@@ -452,8 +452,8 @@ xfs_bulkstat(
452 error = formatter(mp, ino, ubufp, ubleft, 452 error = formatter(mp, ino, ubufp, ubleft,
453 &ubused, &fmterror); 453 &ubused, &fmterror);
454 if (fmterror == BULKSTAT_RV_NOTHING) { 454 if (fmterror == BULKSTAT_RV_NOTHING) {
455 if (error && error != ENOENT && 455 if (error && error != -ENOENT &&
456 error != EINVAL) { 456 error != -EINVAL) {
457 ubleft = 0; 457 ubleft = 0;
458 rval = error; 458 rval = error;
459 break; 459 break;
@@ -551,7 +551,7 @@ xfs_bulkstat_single(
551 sizeof(xfs_bstat_t), buffer, done)) 551 sizeof(xfs_bstat_t), buffer, done))
552 return error; 552 return error;
553 if (count == 0 || (xfs_ino_t)*lastinop != ino) 553 if (count == 0 || (xfs_ino_t)*lastinop != ino)
554 return error == EFSCORRUPTED ? 554 return error == -EFSCORRUPTED ?
555 EINVAL : error; 555 EINVAL : error;
556 else 556 else
557 return 0; 557 return 0;
@@ -661,7 +661,7 @@ xfs_inumbers(
661 if (bufidx == bcount) { 661 if (bufidx == bcount) {
662 long written; 662 long written;
663 if (formatter(ubuffer, buffer, bufidx, &written)) { 663 if (formatter(ubuffer, buffer, bufidx, &written)) {
664 error = EFAULT; 664 error = -EFAULT;
665 break; 665 break;
666 } 666 }
667 ubuffer += written; 667 ubuffer += written;
@@ -688,7 +688,7 @@ xfs_inumbers(
688 if (bufidx) { 688 if (bufidx) {
689 long written; 689 long written;
690 if (formatter(ubuffer, buffer, bufidx, &written)) 690 if (formatter(ubuffer, buffer, bufidx, &written))
691 error = EFAULT; 691 error = -EFAULT;
692 else 692 else
693 *count += bufidx; 693 *count += bufidx;
694 } 694 }
diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c
index 01b715677596..7647818b8c8a 100644
--- a/fs/xfs/xfs_log.c
+++ b/fs/xfs/xfs_log.c
@@ -283,7 +283,7 @@ xlog_grant_head_wait(
283 return 0; 283 return 0;
284shutdown: 284shutdown:
285 list_del_init(&tic->t_queue); 285 list_del_init(&tic->t_queue);
286 return EIO; 286 return -EIO;
287} 287}
288 288
289/* 289/*
@@ -377,7 +377,7 @@ xfs_log_regrant(
377 int error = 0; 377 int error = 0;
378 378
379 if (XLOG_FORCED_SHUTDOWN(log)) 379 if (XLOG_FORCED_SHUTDOWN(log))
380 return EIO; 380 return -EIO;
381 381
382 XFS_STATS_INC(xs_try_logspace); 382 XFS_STATS_INC(xs_try_logspace);
383 383
@@ -446,7 +446,7 @@ xfs_log_reserve(
446 ASSERT(client == XFS_TRANSACTION || client == XFS_LOG); 446 ASSERT(client == XFS_TRANSACTION || client == XFS_LOG);
447 447
448 if (XLOG_FORCED_SHUTDOWN(log)) 448 if (XLOG_FORCED_SHUTDOWN(log))
449 return EIO; 449 return -EIO;
450 450
451 XFS_STATS_INC(xs_try_logspace); 451 XFS_STATS_INC(xs_try_logspace);
452 452
@@ -454,7 +454,7 @@ xfs_log_reserve(
454 tic = xlog_ticket_alloc(log, unit_bytes, cnt, client, permanent, 454 tic = xlog_ticket_alloc(log, unit_bytes, cnt, client, permanent,
455 KM_SLEEP | KM_MAYFAIL); 455 KM_SLEEP | KM_MAYFAIL);
456 if (!tic) 456 if (!tic)
457 return ENOMEM; 457 return -ENOMEM;
458 458
459 tic->t_trans_type = t_type; 459 tic->t_trans_type = t_type;
460 *ticp = tic; 460 *ticp = tic;
@@ -590,7 +590,7 @@ xfs_log_release_iclog(
590{ 590{
591 if (xlog_state_release_iclog(mp->m_log, iclog)) { 591 if (xlog_state_release_iclog(mp->m_log, iclog)) {
592 xfs_force_shutdown(mp, SHUTDOWN_LOG_IO_ERROR); 592 xfs_force_shutdown(mp, SHUTDOWN_LOG_IO_ERROR);
593 return EIO; 593 return -EIO;
594 } 594 }
595 595
596 return 0; 596 return 0;
@@ -628,7 +628,7 @@ xfs_log_mount(
628 628
629 mp->m_log = xlog_alloc_log(mp, log_target, blk_offset, num_bblks); 629 mp->m_log = xlog_alloc_log(mp, log_target, blk_offset, num_bblks);
630 if (IS_ERR(mp->m_log)) { 630 if (IS_ERR(mp->m_log)) {
631 error = -PTR_ERR(mp->m_log); 631 error = PTR_ERR(mp->m_log);
632 goto out; 632 goto out;
633 } 633 }
634 634
@@ -652,18 +652,18 @@ xfs_log_mount(
652 xfs_warn(mp, 652 xfs_warn(mp,
653 "Log size %d blocks too small, minimum size is %d blocks", 653 "Log size %d blocks too small, minimum size is %d blocks",
654 mp->m_sb.sb_logblocks, min_logfsbs); 654 mp->m_sb.sb_logblocks, min_logfsbs);
655 error = EINVAL; 655 error = -EINVAL;
656 } else if (mp->m_sb.sb_logblocks > XFS_MAX_LOG_BLOCKS) { 656 } else if (mp->m_sb.sb_logblocks > XFS_MAX_LOG_BLOCKS) {
657 xfs_warn(mp, 657 xfs_warn(mp,
658 "Log size %d blocks too large, maximum size is %lld blocks", 658 "Log size %d blocks too large, maximum size is %lld blocks",
659 mp->m_sb.sb_logblocks, XFS_MAX_LOG_BLOCKS); 659 mp->m_sb.sb_logblocks, XFS_MAX_LOG_BLOCKS);
660 error = EINVAL; 660 error = -EINVAL;
661 } else if (XFS_FSB_TO_B(mp, mp->m_sb.sb_logblocks) > XFS_MAX_LOG_BYTES) { 661 } else if (XFS_FSB_TO_B(mp, mp->m_sb.sb_logblocks) > XFS_MAX_LOG_BYTES) {
662 xfs_warn(mp, 662 xfs_warn(mp,
663 "log size %lld bytes too large, maximum size is %lld bytes", 663 "log size %lld bytes too large, maximum size is %lld bytes",
664 XFS_FSB_TO_B(mp, mp->m_sb.sb_logblocks), 664 XFS_FSB_TO_B(mp, mp->m_sb.sb_logblocks),
665 XFS_MAX_LOG_BYTES); 665 XFS_MAX_LOG_BYTES);
666 error = EINVAL; 666 error = -EINVAL;
667 } 667 }
668 if (error) { 668 if (error) {
669 if (xfs_sb_version_hascrc(&mp->m_sb)) { 669 if (xfs_sb_version_hascrc(&mp->m_sb)) {
@@ -1313,7 +1313,7 @@ xlog_alloc_log(
1313 xlog_in_core_t *iclog, *prev_iclog=NULL; 1313 xlog_in_core_t *iclog, *prev_iclog=NULL;
1314 xfs_buf_t *bp; 1314 xfs_buf_t *bp;
1315 int i; 1315 int i;
1316 int error = ENOMEM; 1316 int error = -ENOMEM;
1317 uint log2_size = 0; 1317 uint log2_size = 0;
1318 1318
1319 log = kmem_zalloc(sizeof(struct xlog), KM_MAYFAIL); 1319 log = kmem_zalloc(sizeof(struct xlog), KM_MAYFAIL);
@@ -1340,7 +1340,7 @@ xlog_alloc_log(
1340 xlog_grant_head_init(&log->l_reserve_head); 1340 xlog_grant_head_init(&log->l_reserve_head);
1341 xlog_grant_head_init(&log->l_write_head); 1341 xlog_grant_head_init(&log->l_write_head);
1342 1342
1343 error = EFSCORRUPTED; 1343 error = -EFSCORRUPTED;
1344 if (xfs_sb_version_hassector(&mp->m_sb)) { 1344 if (xfs_sb_version_hassector(&mp->m_sb)) {
1345 log2_size = mp->m_sb.sb_logsectlog; 1345 log2_size = mp->m_sb.sb_logsectlog;
1346 if (log2_size < BBSHIFT) { 1346 if (log2_size < BBSHIFT) {
@@ -1369,7 +1369,7 @@ xlog_alloc_log(
1369 1369
1370 xlog_get_iclog_buffer_size(mp, log); 1370 xlog_get_iclog_buffer_size(mp, log);
1371 1371
1372 error = ENOMEM; 1372 error = -ENOMEM;
1373 bp = xfs_buf_alloc(mp->m_logdev_targp, 0, BTOBB(log->l_iclog_size), 0); 1373 bp = xfs_buf_alloc(mp->m_logdev_targp, 0, BTOBB(log->l_iclog_size), 0);
1374 if (!bp) 1374 if (!bp)
1375 goto out_free_log; 1375 goto out_free_log;
@@ -1463,7 +1463,7 @@ out_free_iclog:
1463out_free_log: 1463out_free_log:
1464 kmem_free(log); 1464 kmem_free(log);
1465out: 1465out:
1466 return ERR_PTR(-error); 1466 return ERR_PTR(error);
1467} /* xlog_alloc_log */ 1467} /* xlog_alloc_log */
1468 1468
1469 1469
@@ -1661,7 +1661,7 @@ xlog_bdstrat(
1661 1661
1662 xfs_buf_lock(bp); 1662 xfs_buf_lock(bp);
1663 if (iclog->ic_state & XLOG_STATE_IOERROR) { 1663 if (iclog->ic_state & XLOG_STATE_IOERROR) {
1664 xfs_buf_ioerror(bp, EIO); 1664 xfs_buf_ioerror(bp, -EIO);
1665 xfs_buf_stale(bp); 1665 xfs_buf_stale(bp);
1666 xfs_buf_ioend(bp, 0); 1666 xfs_buf_ioend(bp, 0);
1667 /* 1667 /*
@@ -2360,7 +2360,7 @@ xlog_write(
2360 2360
2361 ophdr = xlog_write_setup_ophdr(log, ptr, ticket, flags); 2361 ophdr = xlog_write_setup_ophdr(log, ptr, ticket, flags);
2362 if (!ophdr) 2362 if (!ophdr)
2363 return EIO; 2363 return -EIO;
2364 2364
2365 xlog_write_adv_cnt(&ptr, &len, &log_offset, 2365 xlog_write_adv_cnt(&ptr, &len, &log_offset,
2366 sizeof(struct xlog_op_header)); 2366 sizeof(struct xlog_op_header));
@@ -2859,7 +2859,7 @@ restart:
2859 spin_lock(&log->l_icloglock); 2859 spin_lock(&log->l_icloglock);
2860 if (XLOG_FORCED_SHUTDOWN(log)) { 2860 if (XLOG_FORCED_SHUTDOWN(log)) {
2861 spin_unlock(&log->l_icloglock); 2861 spin_unlock(&log->l_icloglock);
2862 return EIO; 2862 return -EIO;
2863 } 2863 }
2864 2864
2865 iclog = log->l_iclog; 2865 iclog = log->l_iclog;
@@ -3047,7 +3047,7 @@ xlog_state_release_iclog(
3047 int sync = 0; /* do we sync? */ 3047 int sync = 0; /* do we sync? */
3048 3048
3049 if (iclog->ic_state & XLOG_STATE_IOERROR) 3049 if (iclog->ic_state & XLOG_STATE_IOERROR)
3050 return EIO; 3050 return -EIO;
3051 3051
3052 ASSERT(atomic_read(&iclog->ic_refcnt) > 0); 3052 ASSERT(atomic_read(&iclog->ic_refcnt) > 0);
3053 if (!atomic_dec_and_lock(&iclog->ic_refcnt, &log->l_icloglock)) 3053 if (!atomic_dec_and_lock(&iclog->ic_refcnt, &log->l_icloglock))
@@ -3055,7 +3055,7 @@ xlog_state_release_iclog(
3055 3055
3056 if (iclog->ic_state & XLOG_STATE_IOERROR) { 3056 if (iclog->ic_state & XLOG_STATE_IOERROR) {
3057 spin_unlock(&log->l_icloglock); 3057 spin_unlock(&log->l_icloglock);
3058 return EIO; 3058 return -EIO;
3059 } 3059 }
3060 ASSERT(iclog->ic_state == XLOG_STATE_ACTIVE || 3060 ASSERT(iclog->ic_state == XLOG_STATE_ACTIVE ||
3061 iclog->ic_state == XLOG_STATE_WANT_SYNC); 3061 iclog->ic_state == XLOG_STATE_WANT_SYNC);
@@ -3172,7 +3172,7 @@ _xfs_log_force(
3172 iclog = log->l_iclog; 3172 iclog = log->l_iclog;
3173 if (iclog->ic_state & XLOG_STATE_IOERROR) { 3173 if (iclog->ic_state & XLOG_STATE_IOERROR) {
3174 spin_unlock(&log->l_icloglock); 3174 spin_unlock(&log->l_icloglock);
3175 return EIO; 3175 return -EIO;
3176 } 3176 }
3177 3177
3178 /* If the head iclog is not active nor dirty, we just attach 3178 /* If the head iclog is not active nor dirty, we just attach
@@ -3210,7 +3210,7 @@ _xfs_log_force(
3210 spin_unlock(&log->l_icloglock); 3210 spin_unlock(&log->l_icloglock);
3211 3211
3212 if (xlog_state_release_iclog(log, iclog)) 3212 if (xlog_state_release_iclog(log, iclog))
3213 return EIO; 3213 return -EIO;
3214 3214
3215 if (log_flushed) 3215 if (log_flushed)
3216 *log_flushed = 1; 3216 *log_flushed = 1;
@@ -3246,7 +3246,7 @@ maybe_sleep:
3246 */ 3246 */
3247 if (iclog->ic_state & XLOG_STATE_IOERROR) { 3247 if (iclog->ic_state & XLOG_STATE_IOERROR) {
3248 spin_unlock(&log->l_icloglock); 3248 spin_unlock(&log->l_icloglock);
3249 return EIO; 3249 return -EIO;
3250 } 3250 }
3251 XFS_STATS_INC(xs_log_force_sleep); 3251 XFS_STATS_INC(xs_log_force_sleep);
3252 xlog_wait(&iclog->ic_force_wait, &log->l_icloglock); 3252 xlog_wait(&iclog->ic_force_wait, &log->l_icloglock);
@@ -3256,7 +3256,7 @@ maybe_sleep:
3256 * and the memory read should be atomic. 3256 * and the memory read should be atomic.
3257 */ 3257 */
3258 if (iclog->ic_state & XLOG_STATE_IOERROR) 3258 if (iclog->ic_state & XLOG_STATE_IOERROR)
3259 return EIO; 3259 return -EIO;
3260 if (log_flushed) 3260 if (log_flushed)
3261 *log_flushed = 1; 3261 *log_flushed = 1;
3262 } else { 3262 } else {
@@ -3324,7 +3324,7 @@ try_again:
3324 iclog = log->l_iclog; 3324 iclog = log->l_iclog;
3325 if (iclog->ic_state & XLOG_STATE_IOERROR) { 3325 if (iclog->ic_state & XLOG_STATE_IOERROR) {
3326 spin_unlock(&log->l_icloglock); 3326 spin_unlock(&log->l_icloglock);
3327 return EIO; 3327 return -EIO;
3328 } 3328 }
3329 3329
3330 do { 3330 do {
@@ -3375,7 +3375,7 @@ try_again:
3375 xlog_state_switch_iclogs(log, iclog, 0); 3375 xlog_state_switch_iclogs(log, iclog, 0);
3376 spin_unlock(&log->l_icloglock); 3376 spin_unlock(&log->l_icloglock);
3377 if (xlog_state_release_iclog(log, iclog)) 3377 if (xlog_state_release_iclog(log, iclog))
3378 return EIO; 3378 return -EIO;
3379 if (log_flushed) 3379 if (log_flushed)
3380 *log_flushed = 1; 3380 *log_flushed = 1;
3381 spin_lock(&log->l_icloglock); 3381 spin_lock(&log->l_icloglock);
@@ -3390,7 +3390,7 @@ try_again:
3390 */ 3390 */
3391 if (iclog->ic_state & XLOG_STATE_IOERROR) { 3391 if (iclog->ic_state & XLOG_STATE_IOERROR) {
3392 spin_unlock(&log->l_icloglock); 3392 spin_unlock(&log->l_icloglock);
3393 return EIO; 3393 return -EIO;
3394 } 3394 }
3395 XFS_STATS_INC(xs_log_force_sleep); 3395 XFS_STATS_INC(xs_log_force_sleep);
3396 xlog_wait(&iclog->ic_force_wait, &log->l_icloglock); 3396 xlog_wait(&iclog->ic_force_wait, &log->l_icloglock);
@@ -3400,7 +3400,7 @@ try_again:
3400 * and the memory read should be atomic. 3400 * and the memory read should be atomic.
3401 */ 3401 */
3402 if (iclog->ic_state & XLOG_STATE_IOERROR) 3402 if (iclog->ic_state & XLOG_STATE_IOERROR)
3403 return EIO; 3403 return -EIO;
3404 3404
3405 if (log_flushed) 3405 if (log_flushed)
3406 *log_flushed = 1; 3406 *log_flushed = 1;
diff --git a/fs/xfs/xfs_log_cil.c b/fs/xfs/xfs_log_cil.c
index 0d554f2cb4a8..2ee4388dc682 100644
--- a/fs/xfs/xfs_log_cil.c
+++ b/fs/xfs/xfs_log_cil.c
@@ -634,7 +634,7 @@ out_abort_free_ticket:
634 xfs_log_ticket_put(tic); 634 xfs_log_ticket_put(tic);
635out_abort: 635out_abort:
636 xlog_cil_committed(ctx, XFS_LI_ABORTED); 636 xlog_cil_committed(ctx, XFS_LI_ABORTED);
637 return EIO; 637 return -EIO;
638} 638}
639 639
640static void 640static void
@@ -928,12 +928,12 @@ xlog_cil_init(
928 928
929 cil = kmem_zalloc(sizeof(*cil), KM_SLEEP|KM_MAYFAIL); 929 cil = kmem_zalloc(sizeof(*cil), KM_SLEEP|KM_MAYFAIL);
930 if (!cil) 930 if (!cil)
931 return ENOMEM; 931 return -ENOMEM;
932 932
933 ctx = kmem_zalloc(sizeof(*ctx), KM_SLEEP|KM_MAYFAIL); 933 ctx = kmem_zalloc(sizeof(*ctx), KM_SLEEP|KM_MAYFAIL);
934 if (!ctx) { 934 if (!ctx) {
935 kmem_free(cil); 935 kmem_free(cil);
936 return ENOMEM; 936 return -ENOMEM;
937 } 937 }
938 938
939 INIT_WORK(&cil->xc_push_work, xlog_cil_push_work); 939 INIT_WORK(&cil->xc_push_work, xlog_cil_push_work);
diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c
index 845a92c9c241..fbc2362d13e3 100644
--- a/fs/xfs/xfs_log_recover.c
+++ b/fs/xfs/xfs_log_recover.c
@@ -179,7 +179,7 @@ xlog_bread_noalign(
179 xfs_warn(log->l_mp, "Invalid block length (0x%x) for buffer", 179 xfs_warn(log->l_mp, "Invalid block length (0x%x) for buffer",
180 nbblks); 180 nbblks);
181 XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_HIGH, log->l_mp); 181 XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_HIGH, log->l_mp);
182 return EFSCORRUPTED; 182 return -EFSCORRUPTED;
183 } 183 }
184 184
185 blk_no = round_down(blk_no, log->l_sectBBsize); 185 blk_no = round_down(blk_no, log->l_sectBBsize);
@@ -194,7 +194,7 @@ xlog_bread_noalign(
194 bp->b_error = 0; 194 bp->b_error = 0;
195 195
196 if (XFS_FORCED_SHUTDOWN(log->l_mp)) 196 if (XFS_FORCED_SHUTDOWN(log->l_mp))
197 return EIO; 197 return -EIO;
198 198
199 xfs_buf_iorequest(bp); 199 xfs_buf_iorequest(bp);
200 error = xfs_buf_iowait(bp); 200 error = xfs_buf_iowait(bp);
@@ -268,7 +268,7 @@ xlog_bwrite(
268 xfs_warn(log->l_mp, "Invalid block length (0x%x) for buffer", 268 xfs_warn(log->l_mp, "Invalid block length (0x%x) for buffer",
269 nbblks); 269 nbblks);
270 XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_HIGH, log->l_mp); 270 XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_HIGH, log->l_mp);
271 return EFSCORRUPTED; 271 return -EFSCORRUPTED;
272 } 272 }
273 273
274 blk_no = round_down(blk_no, log->l_sectBBsize); 274 blk_no = round_down(blk_no, log->l_sectBBsize);
@@ -330,14 +330,14 @@ xlog_header_check_recover(
330 xlog_header_check_dump(mp, head); 330 xlog_header_check_dump(mp, head);
331 XFS_ERROR_REPORT("xlog_header_check_recover(1)", 331 XFS_ERROR_REPORT("xlog_header_check_recover(1)",
332 XFS_ERRLEVEL_HIGH, mp); 332 XFS_ERRLEVEL_HIGH, mp);
333 return EFSCORRUPTED; 333 return -EFSCORRUPTED;
334 } else if (unlikely(!uuid_equal(&mp->m_sb.sb_uuid, &head->h_fs_uuid))) { 334 } else if (unlikely(!uuid_equal(&mp->m_sb.sb_uuid, &head->h_fs_uuid))) {
335 xfs_warn(mp, 335 xfs_warn(mp,
336 "dirty log entry has mismatched uuid - can't recover"); 336 "dirty log entry has mismatched uuid - can't recover");
337 xlog_header_check_dump(mp, head); 337 xlog_header_check_dump(mp, head);
338 XFS_ERROR_REPORT("xlog_header_check_recover(2)", 338 XFS_ERROR_REPORT("xlog_header_check_recover(2)",
339 XFS_ERRLEVEL_HIGH, mp); 339 XFS_ERRLEVEL_HIGH, mp);
340 return EFSCORRUPTED; 340 return -EFSCORRUPTED;
341 } 341 }
342 return 0; 342 return 0;
343} 343}
@@ -364,7 +364,7 @@ xlog_header_check_mount(
364 xlog_header_check_dump(mp, head); 364 xlog_header_check_dump(mp, head);
365 XFS_ERROR_REPORT("xlog_header_check_mount", 365 XFS_ERROR_REPORT("xlog_header_check_mount",
366 XFS_ERRLEVEL_HIGH, mp); 366 XFS_ERRLEVEL_HIGH, mp);
367 return EFSCORRUPTED; 367 return -EFSCORRUPTED;
368 } 368 }
369 return 0; 369 return 0;
370} 370}
@@ -462,7 +462,7 @@ xlog_find_verify_cycle(
462 while (!(bp = xlog_get_bp(log, bufblks))) { 462 while (!(bp = xlog_get_bp(log, bufblks))) {
463 bufblks >>= 1; 463 bufblks >>= 1;
464 if (bufblks < log->l_sectBBsize) 464 if (bufblks < log->l_sectBBsize)
465 return ENOMEM; 465 return -ENOMEM;
466 } 466 }
467 467
468 for (i = start_blk; i < start_blk + nbblks; i += bufblks) { 468 for (i = start_blk; i < start_blk + nbblks; i += bufblks) {
@@ -524,7 +524,7 @@ xlog_find_verify_log_record(
524 524
525 if (!(bp = xlog_get_bp(log, num_blks))) { 525 if (!(bp = xlog_get_bp(log, num_blks))) {
526 if (!(bp = xlog_get_bp(log, 1))) 526 if (!(bp = xlog_get_bp(log, 1)))
527 return ENOMEM; 527 return -ENOMEM;
528 smallmem = 1; 528 smallmem = 1;
529 } else { 529 } else {
530 error = xlog_bread(log, start_blk, num_blks, bp, &offset); 530 error = xlog_bread(log, start_blk, num_blks, bp, &offset);
@@ -539,7 +539,7 @@ xlog_find_verify_log_record(
539 xfs_warn(log->l_mp, 539 xfs_warn(log->l_mp,
540 "Log inconsistent (didn't find previous header)"); 540 "Log inconsistent (didn't find previous header)");
541 ASSERT(0); 541 ASSERT(0);
542 error = EIO; 542 error = -EIO;
543 goto out; 543 goto out;
544 } 544 }
545 545
@@ -564,7 +564,7 @@ xlog_find_verify_log_record(
564 * will be called again for the end of the physical log. 564 * will be called again for the end of the physical log.
565 */ 565 */
566 if (i == -1) { 566 if (i == -1) {
567 error = -1; 567 error = 1;
568 goto out; 568 goto out;
569 } 569 }
570 570
@@ -628,7 +628,12 @@ xlog_find_head(
628 int error, log_bbnum = log->l_logBBsize; 628 int error, log_bbnum = log->l_logBBsize;
629 629
630 /* Is the end of the log device zeroed? */ 630 /* Is the end of the log device zeroed? */
631 if ((error = xlog_find_zeroed(log, &first_blk)) == -1) { 631 error = xlog_find_zeroed(log, &first_blk);
632 if (error < 0) {
633 xfs_warn(log->l_mp, "empty log check failed");
634 return error;
635 }
636 if (error == 1) {
632 *return_head_blk = first_blk; 637 *return_head_blk = first_blk;
633 638
634 /* Is the whole lot zeroed? */ 639 /* Is the whole lot zeroed? */
@@ -641,15 +646,12 @@ xlog_find_head(
641 } 646 }
642 647
643 return 0; 648 return 0;
644 } else if (error) {
645 xfs_warn(log->l_mp, "empty log check failed");
646 return error;
647 } 649 }
648 650
649 first_blk = 0; /* get cycle # of 1st block */ 651 first_blk = 0; /* get cycle # of 1st block */
650 bp = xlog_get_bp(log, 1); 652 bp = xlog_get_bp(log, 1);
651 if (!bp) 653 if (!bp)
652 return ENOMEM; 654 return -ENOMEM;
653 655
654 error = xlog_bread(log, 0, 1, bp, &offset); 656 error = xlog_bread(log, 0, 1, bp, &offset);
655 if (error) 657 if (error)
@@ -818,29 +820,29 @@ validate_head:
818 start_blk = head_blk - num_scan_bblks; /* don't read head_blk */ 820 start_blk = head_blk - num_scan_bblks; /* don't read head_blk */
819 821
820 /* start ptr at last block ptr before head_blk */ 822 /* start ptr at last block ptr before head_blk */
821 if ((error = xlog_find_verify_log_record(log, start_blk, 823 error = xlog_find_verify_log_record(log, start_blk, &head_blk, 0);
822 &head_blk, 0)) == -1) { 824 if (error == 1)
823 error = EIO; 825 error = -EIO;
824 goto bp_err; 826 if (error)
825 } else if (error)
826 goto bp_err; 827 goto bp_err;
827 } else { 828 } else {
828 start_blk = 0; 829 start_blk = 0;
829 ASSERT(head_blk <= INT_MAX); 830 ASSERT(head_blk <= INT_MAX);
830 if ((error = xlog_find_verify_log_record(log, start_blk, 831 error = xlog_find_verify_log_record(log, start_blk, &head_blk, 0);
831 &head_blk, 0)) == -1) { 832 if (error < 0)
833 goto bp_err;
834 if (error == 1) {
832 /* We hit the beginning of the log during our search */ 835 /* We hit the beginning of the log during our search */
833 start_blk = log_bbnum - (num_scan_bblks - head_blk); 836 start_blk = log_bbnum - (num_scan_bblks - head_blk);
834 new_blk = log_bbnum; 837 new_blk = log_bbnum;
835 ASSERT(start_blk <= INT_MAX && 838 ASSERT(start_blk <= INT_MAX &&
836 (xfs_daddr_t) log_bbnum-start_blk >= 0); 839 (xfs_daddr_t) log_bbnum-start_blk >= 0);
837 ASSERT(head_blk <= INT_MAX); 840 ASSERT(head_blk <= INT_MAX);
838 if ((error = xlog_find_verify_log_record(log, 841 error = xlog_find_verify_log_record(log, start_blk,
839 start_blk, &new_blk, 842 &new_blk, (int)head_blk);
840 (int)head_blk)) == -1) { 843 if (error == 1)
841 error = EIO; 844 error = -EIO;
842 goto bp_err; 845 if (error)
843 } else if (error)
844 goto bp_err; 846 goto bp_err;
845 if (new_blk != log_bbnum) 847 if (new_blk != log_bbnum)
846 head_blk = new_blk; 848 head_blk = new_blk;
@@ -911,7 +913,7 @@ xlog_find_tail(
911 913
912 bp = xlog_get_bp(log, 1); 914 bp = xlog_get_bp(log, 1);
913 if (!bp) 915 if (!bp)
914 return ENOMEM; 916 return -ENOMEM;
915 if (*head_blk == 0) { /* special case */ 917 if (*head_blk == 0) { /* special case */
916 error = xlog_bread(log, 0, 1, bp, &offset); 918 error = xlog_bread(log, 0, 1, bp, &offset);
917 if (error) 919 if (error)
@@ -961,7 +963,7 @@ xlog_find_tail(
961 xfs_warn(log->l_mp, "%s: couldn't find sync record", __func__); 963 xfs_warn(log->l_mp, "%s: couldn't find sync record", __func__);
962 xlog_put_bp(bp); 964 xlog_put_bp(bp);
963 ASSERT(0); 965 ASSERT(0);
964 return EIO; 966 return -EIO;
965 } 967 }
966 968
967 /* find blk_no of tail of log */ 969 /* find blk_no of tail of log */
@@ -1092,8 +1094,8 @@ done:
1092 * 1094 *
1093 * Return: 1095 * Return:
1094 * 0 => the log is completely written to 1096 * 0 => the log is completely written to
1095 * -1 => use *blk_no as the first block of the log 1097 * 1 => use *blk_no as the first block of the log
1096 * >0 => error has occurred 1098 * <0 => error has occurred
1097 */ 1099 */
1098STATIC int 1100STATIC int
1099xlog_find_zeroed( 1101xlog_find_zeroed(
@@ -1112,7 +1114,7 @@ xlog_find_zeroed(
1112 /* check totally zeroed log */ 1114 /* check totally zeroed log */
1113 bp = xlog_get_bp(log, 1); 1115 bp = xlog_get_bp(log, 1);
1114 if (!bp) 1116 if (!bp)
1115 return ENOMEM; 1117 return -ENOMEM;
1116 error = xlog_bread(log, 0, 1, bp, &offset); 1118 error = xlog_bread(log, 0, 1, bp, &offset);
1117 if (error) 1119 if (error)
1118 goto bp_err; 1120 goto bp_err;
@@ -1121,7 +1123,7 @@ xlog_find_zeroed(
1121 if (first_cycle == 0) { /* completely zeroed log */ 1123 if (first_cycle == 0) { /* completely zeroed log */
1122 *blk_no = 0; 1124 *blk_no = 0;
1123 xlog_put_bp(bp); 1125 xlog_put_bp(bp);
1124 return -1; 1126 return 1;
1125 } 1127 }
1126 1128
1127 /* check partially zeroed log */ 1129 /* check partially zeroed log */
@@ -1141,7 +1143,7 @@ xlog_find_zeroed(
1141 */ 1143 */
1142 xfs_warn(log->l_mp, 1144 xfs_warn(log->l_mp,
1143 "Log inconsistent or not a log (last==0, first!=1)"); 1145 "Log inconsistent or not a log (last==0, first!=1)");
1144 error = EINVAL; 1146 error = -EINVAL;
1145 goto bp_err; 1147 goto bp_err;
1146 } 1148 }
1147 1149
@@ -1179,19 +1181,18 @@ xlog_find_zeroed(
1179 * Potentially backup over partial log record write. We don't need 1181 * Potentially backup over partial log record write. We don't need
1180 * to search the end of the log because we know it is zero. 1182 * to search the end of the log because we know it is zero.
1181 */ 1183 */
1182 if ((error = xlog_find_verify_log_record(log, start_blk, 1184 error = xlog_find_verify_log_record(log, start_blk, &last_blk, 0);
1183 &last_blk, 0)) == -1) { 1185 if (error == 1)
1184 error = EIO; 1186 error = -EIO;
1185 goto bp_err; 1187 if (error)
1186 } else if (error) 1188 goto bp_err;
1187 goto bp_err;
1188 1189
1189 *blk_no = last_blk; 1190 *blk_no = last_blk;
1190bp_err: 1191bp_err:
1191 xlog_put_bp(bp); 1192 xlog_put_bp(bp);
1192 if (error) 1193 if (error)
1193 return error; 1194 return error;
1194 return -1; 1195 return 1;
1195} 1196}
1196 1197
1197/* 1198/*
@@ -1251,7 +1252,7 @@ xlog_write_log_records(
1251 while (!(bp = xlog_get_bp(log, bufblks))) { 1252 while (!(bp = xlog_get_bp(log, bufblks))) {
1252 bufblks >>= 1; 1253 bufblks >>= 1;
1253 if (bufblks < sectbb) 1254 if (bufblks < sectbb)
1254 return ENOMEM; 1255 return -ENOMEM;
1255 } 1256 }
1256 1257
1257 /* We may need to do a read at the start to fill in part of 1258 /* We may need to do a read at the start to fill in part of
@@ -1354,7 +1355,7 @@ xlog_clear_stale_blocks(
1354 if (unlikely(head_block < tail_block || head_block >= log->l_logBBsize)) { 1355 if (unlikely(head_block < tail_block || head_block >= log->l_logBBsize)) {
1355 XFS_ERROR_REPORT("xlog_clear_stale_blocks(1)", 1356 XFS_ERROR_REPORT("xlog_clear_stale_blocks(1)",
1356 XFS_ERRLEVEL_LOW, log->l_mp); 1357 XFS_ERRLEVEL_LOW, log->l_mp);
1357 return EFSCORRUPTED; 1358 return -EFSCORRUPTED;
1358 } 1359 }
1359 tail_distance = tail_block + (log->l_logBBsize - head_block); 1360 tail_distance = tail_block + (log->l_logBBsize - head_block);
1360 } else { 1361 } else {
@@ -1366,7 +1367,7 @@ xlog_clear_stale_blocks(
1366 if (unlikely(head_block >= tail_block || head_cycle != (tail_cycle + 1))){ 1367 if (unlikely(head_block >= tail_block || head_cycle != (tail_cycle + 1))){
1367 XFS_ERROR_REPORT("xlog_clear_stale_blocks(2)", 1368 XFS_ERROR_REPORT("xlog_clear_stale_blocks(2)",
1368 XFS_ERRLEVEL_LOW, log->l_mp); 1369 XFS_ERRLEVEL_LOW, log->l_mp);
1369 return EFSCORRUPTED; 1370 return -EFSCORRUPTED;
1370 } 1371 }
1371 tail_distance = tail_block - head_block; 1372 tail_distance = tail_block - head_block;
1372 } 1373 }
@@ -1551,7 +1552,7 @@ xlog_recover_add_to_trans(
1551 xfs_warn(log->l_mp, "%s: bad header magic number", 1552 xfs_warn(log->l_mp, "%s: bad header magic number",
1552 __func__); 1553 __func__);
1553 ASSERT(0); 1554 ASSERT(0);
1554 return EIO; 1555 return -EIO;
1555 } 1556 }
1556 if (len == sizeof(xfs_trans_header_t)) 1557 if (len == sizeof(xfs_trans_header_t))
1557 xlog_recover_add_item(&trans->r_itemq); 1558 xlog_recover_add_item(&trans->r_itemq);
@@ -1581,7 +1582,7 @@ xlog_recover_add_to_trans(
1581 in_f->ilf_size); 1582 in_f->ilf_size);
1582 ASSERT(0); 1583 ASSERT(0);
1583 kmem_free(ptr); 1584 kmem_free(ptr);
1584 return EIO; 1585 return -EIO;
1585 } 1586 }
1586 1587
1587 item->ri_total = in_f->ilf_size; 1588 item->ri_total = in_f->ilf_size;
@@ -1702,7 +1703,7 @@ xlog_recover_reorder_trans(
1702 */ 1703 */
1703 if (!list_empty(&sort_list)) 1704 if (!list_empty(&sort_list))
1704 list_splice_init(&sort_list, &trans->r_itemq); 1705 list_splice_init(&sort_list, &trans->r_itemq);
1705 error = EIO; 1706 error = -EIO;
1706 goto out; 1707 goto out;
1707 } 1708 }
1708 } 1709 }
@@ -1943,7 +1944,7 @@ xlog_recover_do_inode_buffer(
1943 item, bp); 1944 item, bp);
1944 XFS_ERROR_REPORT("xlog_recover_do_inode_buf", 1945 XFS_ERROR_REPORT("xlog_recover_do_inode_buf",
1945 XFS_ERRLEVEL_LOW, mp); 1946 XFS_ERRLEVEL_LOW, mp);
1946 return EFSCORRUPTED; 1947 return -EFSCORRUPTED;
1947 } 1948 }
1948 1949
1949 buffer_nextp = (xfs_agino_t *)xfs_buf_offset(bp, 1950 buffer_nextp = (xfs_agino_t *)xfs_buf_offset(bp,
@@ -2496,7 +2497,7 @@ xlog_recover_buffer_pass2(
2496 bp = xfs_buf_read(mp->m_ddev_targp, buf_f->blf_blkno, buf_f->blf_len, 2497 bp = xfs_buf_read(mp->m_ddev_targp, buf_f->blf_blkno, buf_f->blf_len,
2497 buf_flags, NULL); 2498 buf_flags, NULL);
2498 if (!bp) 2499 if (!bp)
2499 return ENOMEM; 2500 return -ENOMEM;
2500 error = bp->b_error; 2501 error = bp->b_error;
2501 if (error) { 2502 if (error) {
2502 xfs_buf_ioerror_alert(bp, "xlog_recover_do..(read#1)"); 2503 xfs_buf_ioerror_alert(bp, "xlog_recover_do..(read#1)");
@@ -2598,7 +2599,7 @@ xfs_recover_inode_owner_change(
2598 2599
2599 ip = xfs_inode_alloc(mp, in_f->ilf_ino); 2600 ip = xfs_inode_alloc(mp, in_f->ilf_ino);
2600 if (!ip) 2601 if (!ip)
2601 return ENOMEM; 2602 return -ENOMEM;
2602 2603
2603 /* instantiate the inode */ 2604 /* instantiate the inode */
2604 xfs_dinode_from_disk(&ip->i_d, dip); 2605 xfs_dinode_from_disk(&ip->i_d, dip);
@@ -2676,7 +2677,7 @@ xlog_recover_inode_pass2(
2676 bp = xfs_buf_read(mp->m_ddev_targp, in_f->ilf_blkno, in_f->ilf_len, 0, 2677 bp = xfs_buf_read(mp->m_ddev_targp, in_f->ilf_blkno, in_f->ilf_len, 0,
2677 &xfs_inode_buf_ops); 2678 &xfs_inode_buf_ops);
2678 if (!bp) { 2679 if (!bp) {
2679 error = ENOMEM; 2680 error = -ENOMEM;
2680 goto error; 2681 goto error;
2681 } 2682 }
2682 error = bp->b_error; 2683 error = bp->b_error;
@@ -2697,7 +2698,7 @@ xlog_recover_inode_pass2(
2697 __func__, dip, bp, in_f->ilf_ino); 2698 __func__, dip, bp, in_f->ilf_ino);
2698 XFS_ERROR_REPORT("xlog_recover_inode_pass2(1)", 2699 XFS_ERROR_REPORT("xlog_recover_inode_pass2(1)",
2699 XFS_ERRLEVEL_LOW, mp); 2700 XFS_ERRLEVEL_LOW, mp);
2700 error = EFSCORRUPTED; 2701 error = -EFSCORRUPTED;
2701 goto out_release; 2702 goto out_release;
2702 } 2703 }
2703 dicp = item->ri_buf[1].i_addr; 2704 dicp = item->ri_buf[1].i_addr;
@@ -2707,7 +2708,7 @@ xlog_recover_inode_pass2(
2707 __func__, item, in_f->ilf_ino); 2708 __func__, item, in_f->ilf_ino);
2708 XFS_ERROR_REPORT("xlog_recover_inode_pass2(2)", 2709 XFS_ERROR_REPORT("xlog_recover_inode_pass2(2)",
2709 XFS_ERRLEVEL_LOW, mp); 2710 XFS_ERRLEVEL_LOW, mp);
2710 error = EFSCORRUPTED; 2711 error = -EFSCORRUPTED;
2711 goto out_release; 2712 goto out_release;
2712 } 2713 }
2713 2714
@@ -2764,7 +2765,7 @@ xlog_recover_inode_pass2(
2764 "%s: Bad regular inode log record, rec ptr 0x%p, " 2765 "%s: Bad regular inode log record, rec ptr 0x%p, "
2765 "ino ptr = 0x%p, ino bp = 0x%p, ino %Ld", 2766 "ino ptr = 0x%p, ino bp = 0x%p, ino %Ld",
2766 __func__, item, dip, bp, in_f->ilf_ino); 2767 __func__, item, dip, bp, in_f->ilf_ino);
2767 error = EFSCORRUPTED; 2768 error = -EFSCORRUPTED;
2768 goto out_release; 2769 goto out_release;
2769 } 2770 }
2770 } else if (unlikely(S_ISDIR(dicp->di_mode))) { 2771 } else if (unlikely(S_ISDIR(dicp->di_mode))) {
@@ -2777,7 +2778,7 @@ xlog_recover_inode_pass2(
2777 "%s: Bad dir inode log record, rec ptr 0x%p, " 2778 "%s: Bad dir inode log record, rec ptr 0x%p, "
2778 "ino ptr = 0x%p, ino bp = 0x%p, ino %Ld", 2779 "ino ptr = 0x%p, ino bp = 0x%p, ino %Ld",
2779 __func__, item, dip, bp, in_f->ilf_ino); 2780 __func__, item, dip, bp, in_f->ilf_ino);
2780 error = EFSCORRUPTED; 2781 error = -EFSCORRUPTED;
2781 goto out_release; 2782 goto out_release;
2782 } 2783 }
2783 } 2784 }
@@ -2790,7 +2791,7 @@ xlog_recover_inode_pass2(
2790 __func__, item, dip, bp, in_f->ilf_ino, 2791 __func__, item, dip, bp, in_f->ilf_ino,
2791 dicp->di_nextents + dicp->di_anextents, 2792 dicp->di_nextents + dicp->di_anextents,
2792 dicp->di_nblocks); 2793 dicp->di_nblocks);
2793 error = EFSCORRUPTED; 2794 error = -EFSCORRUPTED;
2794 goto out_release; 2795 goto out_release;
2795 } 2796 }
2796 if (unlikely(dicp->di_forkoff > mp->m_sb.sb_inodesize)) { 2797 if (unlikely(dicp->di_forkoff > mp->m_sb.sb_inodesize)) {
@@ -2800,7 +2801,7 @@ xlog_recover_inode_pass2(
2800 "%s: Bad inode log record, rec ptr 0x%p, dino ptr 0x%p, " 2801 "%s: Bad inode log record, rec ptr 0x%p, dino ptr 0x%p, "
2801 "dino bp 0x%p, ino %Ld, forkoff 0x%x", __func__, 2802 "dino bp 0x%p, ino %Ld, forkoff 0x%x", __func__,
2802 item, dip, bp, in_f->ilf_ino, dicp->di_forkoff); 2803 item, dip, bp, in_f->ilf_ino, dicp->di_forkoff);
2803 error = EFSCORRUPTED; 2804 error = -EFSCORRUPTED;
2804 goto out_release; 2805 goto out_release;
2805 } 2806 }
2806 isize = xfs_icdinode_size(dicp->di_version); 2807 isize = xfs_icdinode_size(dicp->di_version);
@@ -2810,7 +2811,7 @@ xlog_recover_inode_pass2(
2810 xfs_alert(mp, 2811 xfs_alert(mp,
2811 "%s: Bad inode log record length %d, rec ptr 0x%p", 2812 "%s: Bad inode log record length %d, rec ptr 0x%p",
2812 __func__, item->ri_buf[1].i_len, item); 2813 __func__, item->ri_buf[1].i_len, item);
2813 error = EFSCORRUPTED; 2814 error = -EFSCORRUPTED;
2814 goto out_release; 2815 goto out_release;
2815 } 2816 }
2816 2817
@@ -2898,7 +2899,7 @@ xlog_recover_inode_pass2(
2898 default: 2899 default:
2899 xfs_warn(log->l_mp, "%s: Invalid flag", __func__); 2900 xfs_warn(log->l_mp, "%s: Invalid flag", __func__);
2900 ASSERT(0); 2901 ASSERT(0);
2901 error = EIO; 2902 error = -EIO;
2902 goto out_release; 2903 goto out_release;
2903 } 2904 }
2904 } 2905 }
@@ -2976,12 +2977,12 @@ xlog_recover_dquot_pass2(
2976 recddq = item->ri_buf[1].i_addr; 2977 recddq = item->ri_buf[1].i_addr;
2977 if (recddq == NULL) { 2978 if (recddq == NULL) {
2978 xfs_alert(log->l_mp, "NULL dquot in %s.", __func__); 2979 xfs_alert(log->l_mp, "NULL dquot in %s.", __func__);
2979 return EIO; 2980 return -EIO;
2980 } 2981 }
2981 if (item->ri_buf[1].i_len < sizeof(xfs_disk_dquot_t)) { 2982 if (item->ri_buf[1].i_len < sizeof(xfs_disk_dquot_t)) {
2982 xfs_alert(log->l_mp, "dquot too small (%d) in %s.", 2983 xfs_alert(log->l_mp, "dquot too small (%d) in %s.",
2983 item->ri_buf[1].i_len, __func__); 2984 item->ri_buf[1].i_len, __func__);
2984 return EIO; 2985 return -EIO;
2985 } 2986 }
2986 2987
2987 /* 2988 /*
@@ -3007,7 +3008,7 @@ xlog_recover_dquot_pass2(
3007 error = xfs_dqcheck(mp, recddq, dq_f->qlf_id, 0, XFS_QMOPT_DOWARN, 3008 error = xfs_dqcheck(mp, recddq, dq_f->qlf_id, 0, XFS_QMOPT_DOWARN,
3008 "xlog_recover_dquot_pass2 (log copy)"); 3009 "xlog_recover_dquot_pass2 (log copy)");
3009 if (error) 3010 if (error)
3010 return EIO; 3011 return -EIO;
3011 ASSERT(dq_f->qlf_len == 1); 3012 ASSERT(dq_f->qlf_len == 1);
3012 3013
3013 error = xfs_trans_read_buf(mp, NULL, mp->m_ddev_targp, dq_f->qlf_blkno, 3014 error = xfs_trans_read_buf(mp, NULL, mp->m_ddev_targp, dq_f->qlf_blkno,
@@ -3028,7 +3029,7 @@ xlog_recover_dquot_pass2(
3028 "xlog_recover_dquot_pass2"); 3029 "xlog_recover_dquot_pass2");
3029 if (error) { 3030 if (error) {
3030 xfs_buf_relse(bp); 3031 xfs_buf_relse(bp);
3031 return EIO; 3032 return -EIO;
3032 } 3033 }
3033 3034
3034 /* 3035 /*
@@ -3178,38 +3179,38 @@ xlog_recover_do_icreate_pass2(
3178 icl = (struct xfs_icreate_log *)item->ri_buf[0].i_addr; 3179 icl = (struct xfs_icreate_log *)item->ri_buf[0].i_addr;
3179 if (icl->icl_type != XFS_LI_ICREATE) { 3180 if (icl->icl_type != XFS_LI_ICREATE) {
3180 xfs_warn(log->l_mp, "xlog_recover_do_icreate_trans: bad type"); 3181 xfs_warn(log->l_mp, "xlog_recover_do_icreate_trans: bad type");
3181 return EINVAL; 3182 return -EINVAL;
3182 } 3183 }
3183 3184
3184 if (icl->icl_size != 1) { 3185 if (icl->icl_size != 1) {
3185 xfs_warn(log->l_mp, "xlog_recover_do_icreate_trans: bad icl size"); 3186 xfs_warn(log->l_mp, "xlog_recover_do_icreate_trans: bad icl size");
3186 return EINVAL; 3187 return -EINVAL;
3187 } 3188 }
3188 3189
3189 agno = be32_to_cpu(icl->icl_ag); 3190 agno = be32_to_cpu(icl->icl_ag);
3190 if (agno >= mp->m_sb.sb_agcount) { 3191 if (agno >= mp->m_sb.sb_agcount) {
3191 xfs_warn(log->l_mp, "xlog_recover_do_icreate_trans: bad agno"); 3192 xfs_warn(log->l_mp, "xlog_recover_do_icreate_trans: bad agno");
3192 return EINVAL; 3193 return -EINVAL;
3193 } 3194 }
3194 agbno = be32_to_cpu(icl->icl_agbno); 3195 agbno = be32_to_cpu(icl->icl_agbno);
3195 if (!agbno || agbno == NULLAGBLOCK || agbno >= mp->m_sb.sb_agblocks) { 3196 if (!agbno || agbno == NULLAGBLOCK || agbno >= mp->m_sb.sb_agblocks) {
3196 xfs_warn(log->l_mp, "xlog_recover_do_icreate_trans: bad agbno"); 3197 xfs_warn(log->l_mp, "xlog_recover_do_icreate_trans: bad agbno");
3197 return EINVAL; 3198 return -EINVAL;
3198 } 3199 }
3199 isize = be32_to_cpu(icl->icl_isize); 3200 isize = be32_to_cpu(icl->icl_isize);
3200 if (isize != mp->m_sb.sb_inodesize) { 3201 if (isize != mp->m_sb.sb_inodesize) {
3201 xfs_warn(log->l_mp, "xlog_recover_do_icreate_trans: bad isize"); 3202 xfs_warn(log->l_mp, "xlog_recover_do_icreate_trans: bad isize");
3202 return EINVAL; 3203 return -EINVAL;
3203 } 3204 }
3204 count = be32_to_cpu(icl->icl_count); 3205 count = be32_to_cpu(icl->icl_count);
3205 if (!count) { 3206 if (!count) {
3206 xfs_warn(log->l_mp, "xlog_recover_do_icreate_trans: bad count"); 3207 xfs_warn(log->l_mp, "xlog_recover_do_icreate_trans: bad count");
3207 return EINVAL; 3208 return -EINVAL;
3208 } 3209 }
3209 length = be32_to_cpu(icl->icl_length); 3210 length = be32_to_cpu(icl->icl_length);
3210 if (!length || length >= mp->m_sb.sb_agblocks) { 3211 if (!length || length >= mp->m_sb.sb_agblocks) {
3211 xfs_warn(log->l_mp, "xlog_recover_do_icreate_trans: bad length"); 3212 xfs_warn(log->l_mp, "xlog_recover_do_icreate_trans: bad length");
3212 return EINVAL; 3213 return -EINVAL;
3213 } 3214 }
3214 3215
3215 /* existing allocation is fixed value */ 3216 /* existing allocation is fixed value */
@@ -3218,7 +3219,7 @@ xlog_recover_do_icreate_pass2(
3218 if (count != mp->m_ialloc_inos || 3219 if (count != mp->m_ialloc_inos ||
3219 length != mp->m_ialloc_blks) { 3220 length != mp->m_ialloc_blks) {
3220 xfs_warn(log->l_mp, "xlog_recover_do_icreate_trans: bad count 2"); 3221 xfs_warn(log->l_mp, "xlog_recover_do_icreate_trans: bad count 2");
3221 return EINVAL; 3222 return -EINVAL;
3222 } 3223 }
3223 3224
3224 /* 3225 /*
@@ -3389,7 +3390,7 @@ xlog_recover_commit_pass1(
3389 xfs_warn(log->l_mp, "%s: invalid item type (%d)", 3390 xfs_warn(log->l_mp, "%s: invalid item type (%d)",
3390 __func__, ITEM_TYPE(item)); 3391 __func__, ITEM_TYPE(item));
3391 ASSERT(0); 3392 ASSERT(0);
3392 return EIO; 3393 return -EIO;
3393 } 3394 }
3394} 3395}
3395 3396
@@ -3425,7 +3426,7 @@ xlog_recover_commit_pass2(
3425 xfs_warn(log->l_mp, "%s: invalid item type (%d)", 3426 xfs_warn(log->l_mp, "%s: invalid item type (%d)",
3426 __func__, ITEM_TYPE(item)); 3427 __func__, ITEM_TYPE(item));
3427 ASSERT(0); 3428 ASSERT(0);
3428 return EIO; 3429 return -EIO;
3429 } 3430 }
3430} 3431}
3431 3432
@@ -3560,7 +3561,7 @@ xlog_recover_process_data(
3560 3561
3561 /* check the log format matches our own - else we can't recover */ 3562 /* check the log format matches our own - else we can't recover */
3562 if (xlog_header_check_recover(log->l_mp, rhead)) 3563 if (xlog_header_check_recover(log->l_mp, rhead))
3563 return EIO; 3564 return -EIO;
3564 3565
3565 while ((dp < lp) && num_logops) { 3566 while ((dp < lp) && num_logops) {
3566 ASSERT(dp + sizeof(xlog_op_header_t) <= lp); 3567 ASSERT(dp + sizeof(xlog_op_header_t) <= lp);
@@ -3571,7 +3572,7 @@ xlog_recover_process_data(
3571 xfs_warn(log->l_mp, "%s: bad clientid 0x%x", 3572 xfs_warn(log->l_mp, "%s: bad clientid 0x%x",
3572 __func__, ohead->oh_clientid); 3573 __func__, ohead->oh_clientid);
3573 ASSERT(0); 3574 ASSERT(0);
3574 return EIO; 3575 return -EIO;
3575 } 3576 }
3576 tid = be32_to_cpu(ohead->oh_tid); 3577 tid = be32_to_cpu(ohead->oh_tid);
3577 hash = XLOG_RHASH(tid); 3578 hash = XLOG_RHASH(tid);
@@ -3585,7 +3586,7 @@ xlog_recover_process_data(
3585 xfs_warn(log->l_mp, "%s: bad length 0x%x", 3586 xfs_warn(log->l_mp, "%s: bad length 0x%x",
3586 __func__, be32_to_cpu(ohead->oh_len)); 3587 __func__, be32_to_cpu(ohead->oh_len));
3587 WARN_ON(1); 3588 WARN_ON(1);
3588 return EIO; 3589 return -EIO;
3589 } 3590 }
3590 flags = ohead->oh_flags & ~XLOG_END_TRANS; 3591 flags = ohead->oh_flags & ~XLOG_END_TRANS;
3591 if (flags & XLOG_WAS_CONT_TRANS) 3592 if (flags & XLOG_WAS_CONT_TRANS)
@@ -3607,7 +3608,7 @@ xlog_recover_process_data(
3607 xfs_warn(log->l_mp, "%s: bad transaction", 3608 xfs_warn(log->l_mp, "%s: bad transaction",
3608 __func__); 3609 __func__);
3609 ASSERT(0); 3610 ASSERT(0);
3610 error = EIO; 3611 error = -EIO;
3611 break; 3612 break;
3612 case 0: 3613 case 0:
3613 case XLOG_CONTINUE_TRANS: 3614 case XLOG_CONTINUE_TRANS:
@@ -3618,7 +3619,7 @@ xlog_recover_process_data(
3618 xfs_warn(log->l_mp, "%s: bad flag 0x%x", 3619 xfs_warn(log->l_mp, "%s: bad flag 0x%x",
3619 __func__, flags); 3620 __func__, flags);
3620 ASSERT(0); 3621 ASSERT(0);
3621 error = EIO; 3622 error = -EIO;
3622 break; 3623 break;
3623 } 3624 }
3624 if (error) { 3625 if (error) {
@@ -3669,7 +3670,7 @@ xlog_recover_process_efi(
3669 */ 3670 */
3670 set_bit(XFS_EFI_RECOVERED, &efip->efi_flags); 3671 set_bit(XFS_EFI_RECOVERED, &efip->efi_flags);
3671 xfs_efi_release(efip, efip->efi_format.efi_nextents); 3672 xfs_efi_release(efip, efip->efi_format.efi_nextents);
3672 return EIO; 3673 return -EIO;
3673 } 3674 }
3674 } 3675 }
3675 3676
@@ -3969,7 +3970,7 @@ xlog_unpack_data_crc(
3969 * CRC protection by punting an error back up the stack. 3970 * CRC protection by punting an error back up the stack.
3970 */ 3971 */
3971 if (xfs_sb_version_hascrc(&log->l_mp->m_sb)) 3972 if (xfs_sb_version_hascrc(&log->l_mp->m_sb))
3972 return EFSCORRUPTED; 3973 return -EFSCORRUPTED;
3973 } 3974 }
3974 3975
3975 return 0; 3976 return 0;
@@ -4018,14 +4019,14 @@ xlog_valid_rec_header(
4018 if (unlikely(rhead->h_magicno != cpu_to_be32(XLOG_HEADER_MAGIC_NUM))) { 4019 if (unlikely(rhead->h_magicno != cpu_to_be32(XLOG_HEADER_MAGIC_NUM))) {
4019 XFS_ERROR_REPORT("xlog_valid_rec_header(1)", 4020 XFS_ERROR_REPORT("xlog_valid_rec_header(1)",
4020 XFS_ERRLEVEL_LOW, log->l_mp); 4021 XFS_ERRLEVEL_LOW, log->l_mp);
4021 return EFSCORRUPTED; 4022 return -EFSCORRUPTED;
4022 } 4023 }
4023 if (unlikely( 4024 if (unlikely(
4024 (!rhead->h_version || 4025 (!rhead->h_version ||
4025 (be32_to_cpu(rhead->h_version) & (~XLOG_VERSION_OKBITS))))) { 4026 (be32_to_cpu(rhead->h_version) & (~XLOG_VERSION_OKBITS))))) {
4026 xfs_warn(log->l_mp, "%s: unrecognised log version (%d).", 4027 xfs_warn(log->l_mp, "%s: unrecognised log version (%d).",
4027 __func__, be32_to_cpu(rhead->h_version)); 4028 __func__, be32_to_cpu(rhead->h_version));
4028 return EIO; 4029 return -EIO;
4029 } 4030 }
4030 4031
4031 /* LR body must have data or it wouldn't have been written */ 4032 /* LR body must have data or it wouldn't have been written */
@@ -4033,12 +4034,12 @@ xlog_valid_rec_header(
4033 if (unlikely( hlen <= 0 || hlen > INT_MAX )) { 4034 if (unlikely( hlen <= 0 || hlen > INT_MAX )) {
4034 XFS_ERROR_REPORT("xlog_valid_rec_header(2)", 4035 XFS_ERROR_REPORT("xlog_valid_rec_header(2)",
4035 XFS_ERRLEVEL_LOW, log->l_mp); 4036 XFS_ERRLEVEL_LOW, log->l_mp);
4036 return EFSCORRUPTED; 4037 return -EFSCORRUPTED;
4037 } 4038 }
4038 if (unlikely( blkno > log->l_logBBsize || blkno > INT_MAX )) { 4039 if (unlikely( blkno > log->l_logBBsize || blkno > INT_MAX )) {
4039 XFS_ERROR_REPORT("xlog_valid_rec_header(3)", 4040 XFS_ERROR_REPORT("xlog_valid_rec_header(3)",
4040 XFS_ERRLEVEL_LOW, log->l_mp); 4041 XFS_ERRLEVEL_LOW, log->l_mp);
4041 return EFSCORRUPTED; 4042 return -EFSCORRUPTED;
4042 } 4043 }
4043 return 0; 4044 return 0;
4044} 4045}
@@ -4081,7 +4082,7 @@ xlog_do_recovery_pass(
4081 */ 4082 */
4082 hbp = xlog_get_bp(log, 1); 4083 hbp = xlog_get_bp(log, 1);
4083 if (!hbp) 4084 if (!hbp)
4084 return ENOMEM; 4085 return -ENOMEM;
4085 4086
4086 error = xlog_bread(log, tail_blk, 1, hbp, &offset); 4087 error = xlog_bread(log, tail_blk, 1, hbp, &offset);
4087 if (error) 4088 if (error)
@@ -4110,11 +4111,11 @@ xlog_do_recovery_pass(
4110 } 4111 }
4111 4112
4112 if (!hbp) 4113 if (!hbp)
4113 return ENOMEM; 4114 return -ENOMEM;
4114 dbp = xlog_get_bp(log, BTOBB(h_size)); 4115 dbp = xlog_get_bp(log, BTOBB(h_size));
4115 if (!dbp) { 4116 if (!dbp) {
4116 xlog_put_bp(hbp); 4117 xlog_put_bp(hbp);
4117 return ENOMEM; 4118 return -ENOMEM;
4118 } 4119 }
4119 4120
4120 memset(rhash, 0, sizeof(rhash)); 4121 memset(rhash, 0, sizeof(rhash));
@@ -4388,7 +4389,7 @@ xlog_do_recover(
4388 * If IO errors happened during recovery, bail out. 4389 * If IO errors happened during recovery, bail out.
4389 */ 4390 */
4390 if (XFS_FORCED_SHUTDOWN(log->l_mp)) { 4391 if (XFS_FORCED_SHUTDOWN(log->l_mp)) {
4391 return EIO; 4392 return -EIO;
4392 } 4393 }
4393 4394
4394 /* 4395 /*
@@ -4415,7 +4416,7 @@ xlog_do_recover(
4415 4416
4416 if (XFS_FORCED_SHUTDOWN(log->l_mp)) { 4417 if (XFS_FORCED_SHUTDOWN(log->l_mp)) {
4417 xfs_buf_relse(bp); 4418 xfs_buf_relse(bp);
4418 return EIO; 4419 return -EIO;
4419 } 4420 }
4420 4421
4421 xfs_buf_iorequest(bp); 4422 xfs_buf_iorequest(bp);
@@ -4492,7 +4493,7 @@ xlog_recover(
4492"Please recover the log on a kernel that supports the unknown features.", 4493"Please recover the log on a kernel that supports the unknown features.",
4493 (log->l_mp->m_sb.sb_features_log_incompat & 4494 (log->l_mp->m_sb.sb_features_log_incompat &
4494 XFS_SB_FEAT_INCOMPAT_LOG_UNKNOWN)); 4495 XFS_SB_FEAT_INCOMPAT_LOG_UNKNOWN));
4495 return EINVAL; 4496 return -EINVAL;
4496 } 4497 }
4497 4498
4498 xfs_notice(log->l_mp, "Starting recovery (logdev: %s)", 4499 xfs_notice(log->l_mp, "Starting recovery (logdev: %s)",
diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c
index b50ec92f9620..d5c44a6bdb5b 100644
--- a/fs/xfs/xfs_mount.c
+++ b/fs/xfs/xfs_mount.c
@@ -76,7 +76,7 @@ xfs_uuid_mount(
76 76
77 if (uuid_is_nil(uuid)) { 77 if (uuid_is_nil(uuid)) {
78 xfs_warn(mp, "Filesystem has nil UUID - can't mount"); 78 xfs_warn(mp, "Filesystem has nil UUID - can't mount");
79 return EINVAL; 79 return -EINVAL;
80 } 80 }
81 81
82 mutex_lock(&xfs_uuid_table_mutex); 82 mutex_lock(&xfs_uuid_table_mutex);
@@ -104,7 +104,7 @@ xfs_uuid_mount(
104 out_duplicate: 104 out_duplicate:
105 mutex_unlock(&xfs_uuid_table_mutex); 105 mutex_unlock(&xfs_uuid_table_mutex);
106 xfs_warn(mp, "Filesystem has duplicate UUID %pU - can't mount", uuid); 106 xfs_warn(mp, "Filesystem has duplicate UUID %pU - can't mount", uuid);
107 return EINVAL; 107 return -EINVAL;
108} 108}
109 109
110STATIC void 110STATIC void
@@ -175,10 +175,10 @@ xfs_sb_validate_fsb_count(
175 175
176#if XFS_BIG_BLKNOS /* Limited by ULONG_MAX of page cache index */ 176#if XFS_BIG_BLKNOS /* Limited by ULONG_MAX of page cache index */
177 if (nblocks >> (PAGE_CACHE_SHIFT - sbp->sb_blocklog) > ULONG_MAX) 177 if (nblocks >> (PAGE_CACHE_SHIFT - sbp->sb_blocklog) > ULONG_MAX)
178 return EFBIG; 178 return -EFBIG;
179#else /* Limited by UINT_MAX of sectors */ 179#else /* Limited by UINT_MAX of sectors */
180 if (nblocks << (sbp->sb_blocklog - BBSHIFT) > UINT_MAX) 180 if (nblocks << (sbp->sb_blocklog - BBSHIFT) > UINT_MAX)
181 return EFBIG; 181 return -EFBIG;
182#endif 182#endif
183 return 0; 183 return 0;
184} 184}
@@ -308,15 +308,15 @@ reread:
308 if (!bp) { 308 if (!bp) {
309 if (loud) 309 if (loud)
310 xfs_warn(mp, "SB buffer read failed"); 310 xfs_warn(mp, "SB buffer read failed");
311 return EIO; 311 return -EIO;
312 } 312 }
313 if (bp->b_error) { 313 if (bp->b_error) {
314 error = bp->b_error; 314 error = bp->b_error;
315 if (loud) 315 if (loud)
316 xfs_warn(mp, "SB validate failed with error %d.", error); 316 xfs_warn(mp, "SB validate failed with error %d.", error);
317 /* bad CRC means corrupted metadata */ 317 /* bad CRC means corrupted metadata */
318 if (error == EFSBADCRC) 318 if (error == -EFSBADCRC)
319 error = EFSCORRUPTED; 319 error = -EFSCORRUPTED;
320 goto release_buf; 320 goto release_buf;
321 } 321 }
322 322
@@ -333,7 +333,7 @@ reread:
333 if (sbp->sb_magicnum != XFS_SB_MAGIC) { 333 if (sbp->sb_magicnum != XFS_SB_MAGIC) {
334 if (loud) 334 if (loud)
335 xfs_warn(mp, "Invalid superblock magic number"); 335 xfs_warn(mp, "Invalid superblock magic number");
336 error = EINVAL; 336 error = -EINVAL;
337 goto release_buf; 337 goto release_buf;
338 } 338 }
339 339
@@ -344,7 +344,7 @@ reread:
344 if (loud) 344 if (loud)
345 xfs_warn(mp, "device supports %u byte sectors (not %u)", 345 xfs_warn(mp, "device supports %u byte sectors (not %u)",
346 sector_size, sbp->sb_sectsize); 346 sector_size, sbp->sb_sectsize);
347 error = ENOSYS; 347 error = -ENOSYS;
348 goto release_buf; 348 goto release_buf;
349 } 349 }
350 350
@@ -392,7 +392,7 @@ xfs_update_alignment(xfs_mount_t *mp)
392 xfs_warn(mp, 392 xfs_warn(mp,
393 "alignment check failed: sunit/swidth vs. blocksize(%d)", 393 "alignment check failed: sunit/swidth vs. blocksize(%d)",
394 sbp->sb_blocksize); 394 sbp->sb_blocksize);
395 return EINVAL; 395 return -EINVAL;
396 } else { 396 } else {
397 /* 397 /*
398 * Convert the stripe unit and width to FSBs. 398 * Convert the stripe unit and width to FSBs.
@@ -402,14 +402,14 @@ xfs_update_alignment(xfs_mount_t *mp)
402 xfs_warn(mp, 402 xfs_warn(mp,
403 "alignment check failed: sunit/swidth vs. agsize(%d)", 403 "alignment check failed: sunit/swidth vs. agsize(%d)",
404 sbp->sb_agblocks); 404 sbp->sb_agblocks);
405 return EINVAL; 405 return -EINVAL;
406 } else if (mp->m_dalign) { 406 } else if (mp->m_dalign) {
407 mp->m_swidth = XFS_BB_TO_FSBT(mp, mp->m_swidth); 407 mp->m_swidth = XFS_BB_TO_FSBT(mp, mp->m_swidth);
408 } else { 408 } else {
409 xfs_warn(mp, 409 xfs_warn(mp,
410 "alignment check failed: sunit(%d) less than bsize(%d)", 410 "alignment check failed: sunit(%d) less than bsize(%d)",
411 mp->m_dalign, sbp->sb_blocksize); 411 mp->m_dalign, sbp->sb_blocksize);
412 return EINVAL; 412 return -EINVAL;
413 } 413 }
414 } 414 }
415 415
@@ -429,7 +429,7 @@ xfs_update_alignment(xfs_mount_t *mp)
429 } else { 429 } else {
430 xfs_warn(mp, 430 xfs_warn(mp,
431 "cannot change alignment: superblock does not support data alignment"); 431 "cannot change alignment: superblock does not support data alignment");
432 return EINVAL; 432 return -EINVAL;
433 } 433 }
434 } else if ((mp->m_flags & XFS_MOUNT_NOALIGN) != XFS_MOUNT_NOALIGN && 434 } else if ((mp->m_flags & XFS_MOUNT_NOALIGN) != XFS_MOUNT_NOALIGN &&
435 xfs_sb_version_hasdalign(&mp->m_sb)) { 435 xfs_sb_version_hasdalign(&mp->m_sb)) {
@@ -556,14 +556,14 @@ xfs_check_sizes(xfs_mount_t *mp)
556 d = (xfs_daddr_t)XFS_FSB_TO_BB(mp, mp->m_sb.sb_dblocks); 556 d = (xfs_daddr_t)XFS_FSB_TO_BB(mp, mp->m_sb.sb_dblocks);
557 if (XFS_BB_TO_FSB(mp, d) != mp->m_sb.sb_dblocks) { 557 if (XFS_BB_TO_FSB(mp, d) != mp->m_sb.sb_dblocks) {
558 xfs_warn(mp, "filesystem size mismatch detected"); 558 xfs_warn(mp, "filesystem size mismatch detected");
559 return EFBIG; 559 return -EFBIG;
560 } 560 }
561 bp = xfs_buf_read_uncached(mp->m_ddev_targp, 561 bp = xfs_buf_read_uncached(mp->m_ddev_targp,
562 d - XFS_FSS_TO_BB(mp, 1), 562 d - XFS_FSS_TO_BB(mp, 1),
563 XFS_FSS_TO_BB(mp, 1), 0, NULL); 563 XFS_FSS_TO_BB(mp, 1), 0, NULL);
564 if (!bp) { 564 if (!bp) {
565 xfs_warn(mp, "last sector read failed"); 565 xfs_warn(mp, "last sector read failed");
566 return EIO; 566 return -EIO;
567 } 567 }
568 xfs_buf_relse(bp); 568 xfs_buf_relse(bp);
569 569
@@ -571,14 +571,14 @@ xfs_check_sizes(xfs_mount_t *mp)
571 d = (xfs_daddr_t)XFS_FSB_TO_BB(mp, mp->m_sb.sb_logblocks); 571 d = (xfs_daddr_t)XFS_FSB_TO_BB(mp, mp->m_sb.sb_logblocks);
572 if (XFS_BB_TO_FSB(mp, d) != mp->m_sb.sb_logblocks) { 572 if (XFS_BB_TO_FSB(mp, d) != mp->m_sb.sb_logblocks) {
573 xfs_warn(mp, "log size mismatch detected"); 573 xfs_warn(mp, "log size mismatch detected");
574 return EFBIG; 574 return -EFBIG;
575 } 575 }
576 bp = xfs_buf_read_uncached(mp->m_logdev_targp, 576 bp = xfs_buf_read_uncached(mp->m_logdev_targp,
577 d - XFS_FSB_TO_BB(mp, 1), 577 d - XFS_FSB_TO_BB(mp, 1),
578 XFS_FSB_TO_BB(mp, 1), 0, NULL); 578 XFS_FSB_TO_BB(mp, 1), 0, NULL);
579 if (!bp) { 579 if (!bp) {
580 xfs_warn(mp, "log device read failed"); 580 xfs_warn(mp, "log device read failed");
581 return EIO; 581 return -EIO;
582 } 582 }
583 xfs_buf_relse(bp); 583 xfs_buf_relse(bp);
584 } 584 }
@@ -816,7 +816,7 @@ xfs_mountfs(
816 if (!sbp->sb_logblocks) { 816 if (!sbp->sb_logblocks) {
817 xfs_warn(mp, "no log defined"); 817 xfs_warn(mp, "no log defined");
818 XFS_ERROR_REPORT("xfs_mountfs", XFS_ERRLEVEL_LOW, mp); 818 XFS_ERROR_REPORT("xfs_mountfs", XFS_ERRLEVEL_LOW, mp);
819 error = EFSCORRUPTED; 819 error = -EFSCORRUPTED;
820 goto out_free_perag; 820 goto out_free_perag;
821 } 821 }
822 822
@@ -876,7 +876,7 @@ xfs_mountfs(
876 xfs_iunlock(rip, XFS_ILOCK_EXCL); 876 xfs_iunlock(rip, XFS_ILOCK_EXCL);
877 XFS_ERROR_REPORT("xfs_mountfs_int(2)", XFS_ERRLEVEL_LOW, 877 XFS_ERROR_REPORT("xfs_mountfs_int(2)", XFS_ERRLEVEL_LOW,
878 mp); 878 mp);
879 error = EFSCORRUPTED; 879 error = -EFSCORRUPTED;
880 goto out_rele_rip; 880 goto out_rele_rip;
881 } 881 }
882 mp->m_rootip = rip; /* save it */ 882 mp->m_rootip = rip; /* save it */
@@ -1152,7 +1152,7 @@ xfs_mod_incore_sb_unlocked(
1152 lcounter += delta; 1152 lcounter += delta;
1153 if (lcounter < 0) { 1153 if (lcounter < 0) {
1154 ASSERT(0); 1154 ASSERT(0);
1155 return EINVAL; 1155 return -EINVAL;
1156 } 1156 }
1157 mp->m_sb.sb_icount = lcounter; 1157 mp->m_sb.sb_icount = lcounter;
1158 return 0; 1158 return 0;
@@ -1161,7 +1161,7 @@ xfs_mod_incore_sb_unlocked(
1161 lcounter += delta; 1161 lcounter += delta;
1162 if (lcounter < 0) { 1162 if (lcounter < 0) {
1163 ASSERT(0); 1163 ASSERT(0);
1164 return EINVAL; 1164 return -EINVAL;
1165 } 1165 }
1166 mp->m_sb.sb_ifree = lcounter; 1166 mp->m_sb.sb_ifree = lcounter;
1167 return 0; 1167 return 0;
@@ -1191,7 +1191,7 @@ xfs_mod_incore_sb_unlocked(
1191 * blocks if were allowed to. 1191 * blocks if were allowed to.
1192 */ 1192 */
1193 if (!rsvd) 1193 if (!rsvd)
1194 return ENOSPC; 1194 return -ENOSPC;
1195 1195
1196 lcounter = (long long)mp->m_resblks_avail + delta; 1196 lcounter = (long long)mp->m_resblks_avail + delta;
1197 if (lcounter >= 0) { 1197 if (lcounter >= 0) {
@@ -1202,7 +1202,7 @@ xfs_mod_incore_sb_unlocked(
1202 "Filesystem \"%s\": reserve blocks depleted! " 1202 "Filesystem \"%s\": reserve blocks depleted! "
1203 "Consider increasing reserve pool size.", 1203 "Consider increasing reserve pool size.",
1204 mp->m_fsname); 1204 mp->m_fsname);
1205 return ENOSPC; 1205 return -ENOSPC;
1206 } 1206 }
1207 1207
1208 mp->m_sb.sb_fdblocks = lcounter + XFS_ALLOC_SET_ASIDE(mp); 1208 mp->m_sb.sb_fdblocks = lcounter + XFS_ALLOC_SET_ASIDE(mp);
@@ -1211,7 +1211,7 @@ xfs_mod_incore_sb_unlocked(
1211 lcounter = (long long)mp->m_sb.sb_frextents; 1211 lcounter = (long long)mp->m_sb.sb_frextents;
1212 lcounter += delta; 1212 lcounter += delta;
1213 if (lcounter < 0) { 1213 if (lcounter < 0) {
1214 return ENOSPC; 1214 return -ENOSPC;
1215 } 1215 }
1216 mp->m_sb.sb_frextents = lcounter; 1216 mp->m_sb.sb_frextents = lcounter;
1217 return 0; 1217 return 0;
@@ -1220,7 +1220,7 @@ xfs_mod_incore_sb_unlocked(
1220 lcounter += delta; 1220 lcounter += delta;
1221 if (lcounter < 0) { 1221 if (lcounter < 0) {
1222 ASSERT(0); 1222 ASSERT(0);
1223 return EINVAL; 1223 return -EINVAL;
1224 } 1224 }
1225 mp->m_sb.sb_dblocks = lcounter; 1225 mp->m_sb.sb_dblocks = lcounter;
1226 return 0; 1226 return 0;
@@ -1229,7 +1229,7 @@ xfs_mod_incore_sb_unlocked(
1229 scounter += delta; 1229 scounter += delta;
1230 if (scounter < 0) { 1230 if (scounter < 0) {
1231 ASSERT(0); 1231 ASSERT(0);
1232 return EINVAL; 1232 return -EINVAL;
1233 } 1233 }
1234 mp->m_sb.sb_agcount = scounter; 1234 mp->m_sb.sb_agcount = scounter;
1235 return 0; 1235 return 0;
@@ -1238,7 +1238,7 @@ xfs_mod_incore_sb_unlocked(
1238 scounter += delta; 1238 scounter += delta;
1239 if (scounter < 0) { 1239 if (scounter < 0) {
1240 ASSERT(0); 1240 ASSERT(0);
1241 return EINVAL; 1241 return -EINVAL;
1242 } 1242 }
1243 mp->m_sb.sb_imax_pct = scounter; 1243 mp->m_sb.sb_imax_pct = scounter;
1244 return 0; 1244 return 0;
@@ -1247,7 +1247,7 @@ xfs_mod_incore_sb_unlocked(
1247 scounter += delta; 1247 scounter += delta;
1248 if (scounter < 0) { 1248 if (scounter < 0) {
1249 ASSERT(0); 1249 ASSERT(0);
1250 return EINVAL; 1250 return -EINVAL;
1251 } 1251 }
1252 mp->m_sb.sb_rextsize = scounter; 1252 mp->m_sb.sb_rextsize = scounter;
1253 return 0; 1253 return 0;
@@ -1256,7 +1256,7 @@ xfs_mod_incore_sb_unlocked(
1256 scounter += delta; 1256 scounter += delta;
1257 if (scounter < 0) { 1257 if (scounter < 0) {
1258 ASSERT(0); 1258 ASSERT(0);
1259 return EINVAL; 1259 return -EINVAL;
1260 } 1260 }
1261 mp->m_sb.sb_rbmblocks = scounter; 1261 mp->m_sb.sb_rbmblocks = scounter;
1262 return 0; 1262 return 0;
@@ -1265,7 +1265,7 @@ xfs_mod_incore_sb_unlocked(
1265 lcounter += delta; 1265 lcounter += delta;
1266 if (lcounter < 0) { 1266 if (lcounter < 0) {
1267 ASSERT(0); 1267 ASSERT(0);
1268 return EINVAL; 1268 return -EINVAL;
1269 } 1269 }
1270 mp->m_sb.sb_rblocks = lcounter; 1270 mp->m_sb.sb_rblocks = lcounter;
1271 return 0; 1271 return 0;
@@ -1274,7 +1274,7 @@ xfs_mod_incore_sb_unlocked(
1274 lcounter += delta; 1274 lcounter += delta;
1275 if (lcounter < 0) { 1275 if (lcounter < 0) {
1276 ASSERT(0); 1276 ASSERT(0);
1277 return EINVAL; 1277 return -EINVAL;
1278 } 1278 }
1279 mp->m_sb.sb_rextents = lcounter; 1279 mp->m_sb.sb_rextents = lcounter;
1280 return 0; 1280 return 0;
@@ -1283,13 +1283,13 @@ xfs_mod_incore_sb_unlocked(
1283 scounter += delta; 1283 scounter += delta;
1284 if (scounter < 0) { 1284 if (scounter < 0) {
1285 ASSERT(0); 1285 ASSERT(0);
1286 return EINVAL; 1286 return -EINVAL;
1287 } 1287 }
1288 mp->m_sb.sb_rextslog = scounter; 1288 mp->m_sb.sb_rextslog = scounter;
1289 return 0; 1289 return 0;
1290 default: 1290 default:
1291 ASSERT(0); 1291 ASSERT(0);
1292 return EINVAL; 1292 return -EINVAL;
1293 } 1293 }
1294} 1294}
1295 1295
@@ -1452,7 +1452,7 @@ xfs_dev_is_read_only(
1452 (mp->m_rtdev_targp && xfs_readonly_buftarg(mp->m_rtdev_targp))) { 1452 (mp->m_rtdev_targp && xfs_readonly_buftarg(mp->m_rtdev_targp))) {
1453 xfs_notice(mp, "%s required on read-only device.", message); 1453 xfs_notice(mp, "%s required on read-only device.", message);
1454 xfs_notice(mp, "write access unavailable, cannot proceed."); 1454 xfs_notice(mp, "write access unavailable, cannot proceed.");
1455 return EROFS; 1455 return -EROFS;
1456 } 1456 }
1457 return 0; 1457 return 0;
1458} 1458}
@@ -1995,7 +1995,7 @@ slow_path:
1995 * (e.g. lots of space just got freed). After that 1995 * (e.g. lots of space just got freed). After that
1996 * we are done. 1996 * we are done.
1997 */ 1997 */
1998 if (ret != ENOSPC) 1998 if (ret != -ENOSPC)
1999 xfs_icsb_balance_counter(mp, field, 0); 1999 xfs_icsb_balance_counter(mp, field, 0);
2000 xfs_icsb_unlock(mp); 2000 xfs_icsb_unlock(mp);
2001 return ret; 2001 return ret;
diff --git a/fs/xfs/xfs_mru_cache.c b/fs/xfs/xfs_mru_cache.c
index f99b4933dc22..1eb6f3df698c 100644
--- a/fs/xfs/xfs_mru_cache.c
+++ b/fs/xfs/xfs_mru_cache.c
@@ -337,20 +337,20 @@ xfs_mru_cache_create(
337 *mrup = NULL; 337 *mrup = NULL;
338 338
339 if (!mrup || !grp_count || !lifetime_ms || !free_func) 339 if (!mrup || !grp_count || !lifetime_ms || !free_func)
340 return EINVAL; 340 return -EINVAL;
341 341
342 if (!(grp_time = msecs_to_jiffies(lifetime_ms) / grp_count)) 342 if (!(grp_time = msecs_to_jiffies(lifetime_ms) / grp_count))
343 return EINVAL; 343 return -EINVAL;
344 344
345 if (!(mru = kmem_zalloc(sizeof(*mru), KM_SLEEP))) 345 if (!(mru = kmem_zalloc(sizeof(*mru), KM_SLEEP)))
346 return ENOMEM; 346 return -ENOMEM;
347 347
348 /* An extra list is needed to avoid reaping up to a grp_time early. */ 348 /* An extra list is needed to avoid reaping up to a grp_time early. */
349 mru->grp_count = grp_count + 1; 349 mru->grp_count = grp_count + 1;
350 mru->lists = kmem_zalloc(mru->grp_count * sizeof(*mru->lists), KM_SLEEP); 350 mru->lists = kmem_zalloc(mru->grp_count * sizeof(*mru->lists), KM_SLEEP);
351 351
352 if (!mru->lists) { 352 if (!mru->lists) {
353 err = ENOMEM; 353 err = -ENOMEM;
354 goto exit; 354 goto exit;
355 } 355 }
356 356
@@ -434,16 +434,16 @@ xfs_mru_cache_insert(
434 434
435 ASSERT(mru && mru->lists); 435 ASSERT(mru && mru->lists);
436 if (!mru || !mru->lists) 436 if (!mru || !mru->lists)
437 return EINVAL; 437 return -EINVAL;
438 438
439 if (radix_tree_preload(GFP_KERNEL)) 439 if (radix_tree_preload(GFP_KERNEL))
440 return ENOMEM; 440 return -ENOMEM;
441 441
442 INIT_LIST_HEAD(&elem->list_node); 442 INIT_LIST_HEAD(&elem->list_node);
443 elem->key = key; 443 elem->key = key;
444 444
445 spin_lock(&mru->lock); 445 spin_lock(&mru->lock);
446 error = -radix_tree_insert(&mru->store, key, elem); 446 error = radix_tree_insert(&mru->store, key, elem);
447 radix_tree_preload_end(); 447 radix_tree_preload_end();
448 if (!error) 448 if (!error)
449 _xfs_mru_cache_list_insert(mru, elem); 449 _xfs_mru_cache_list_insert(mru, elem);
diff --git a/fs/xfs/xfs_qm.c b/fs/xfs/xfs_qm.c
index a97d94d69a1e..ba284f6469db 100644
--- a/fs/xfs/xfs_qm.c
+++ b/fs/xfs/xfs_qm.c
@@ -98,18 +98,18 @@ restart:
98 next_index = be32_to_cpu(dqp->q_core.d_id) + 1; 98 next_index = be32_to_cpu(dqp->q_core.d_id) + 1;
99 99
100 error = execute(batch[i], data); 100 error = execute(batch[i], data);
101 if (error == EAGAIN) { 101 if (error == -EAGAIN) {
102 skipped++; 102 skipped++;
103 continue; 103 continue;
104 } 104 }
105 if (error && last_error != EFSCORRUPTED) 105 if (error && last_error != -EFSCORRUPTED)
106 last_error = error; 106 last_error = error;
107 } 107 }
108 108
109 mutex_unlock(&qi->qi_tree_lock); 109 mutex_unlock(&qi->qi_tree_lock);
110 110
111 /* bail out if the filesystem is corrupted. */ 111 /* bail out if the filesystem is corrupted. */
112 if (last_error == EFSCORRUPTED) { 112 if (last_error == -EFSCORRUPTED) {
113 skipped = 0; 113 skipped = 0;
114 break; 114 break;
115 } 115 }
@@ -138,7 +138,7 @@ xfs_qm_dqpurge(
138 xfs_dqlock(dqp); 138 xfs_dqlock(dqp);
139 if ((dqp->dq_flags & XFS_DQ_FREEING) || dqp->q_nrefs != 0) { 139 if ((dqp->dq_flags & XFS_DQ_FREEING) || dqp->q_nrefs != 0) {
140 xfs_dqunlock(dqp); 140 xfs_dqunlock(dqp);
141 return EAGAIN; 141 return -EAGAIN;
142 } 142 }
143 143
144 dqp->dq_flags |= XFS_DQ_FREEING; 144 dqp->dq_flags |= XFS_DQ_FREEING;
@@ -671,7 +671,7 @@ xfs_qm_init_quotainfo(
671 671
672 qinf = mp->m_quotainfo = kmem_zalloc(sizeof(xfs_quotainfo_t), KM_SLEEP); 672 qinf = mp->m_quotainfo = kmem_zalloc(sizeof(xfs_quotainfo_t), KM_SLEEP);
673 673
674 error = -list_lru_init(&qinf->qi_lru); 674 error = list_lru_init(&qinf->qi_lru);
675 if (error) 675 if (error)
676 goto out_free_qinf; 676 goto out_free_qinf;
677 677
@@ -995,7 +995,7 @@ xfs_qm_dqiter_bufs(
995 * will leave a trace in the log indicating corruption has 995 * will leave a trace in the log indicating corruption has
996 * been detected. 996 * been detected.
997 */ 997 */
998 if (error == EFSCORRUPTED) { 998 if (error == -EFSCORRUPTED) {
999 error = xfs_trans_read_buf(mp, NULL, mp->m_ddev_targp, 999 error = xfs_trans_read_buf(mp, NULL, mp->m_ddev_targp,
1000 XFS_FSB_TO_DADDR(mp, bno), 1000 XFS_FSB_TO_DADDR(mp, bno),
1001 mp->m_quotainfo->qi_dqchunklen, 0, &bp, 1001 mp->m_quotainfo->qi_dqchunklen, 0, &bp,
@@ -1138,8 +1138,8 @@ xfs_qm_quotacheck_dqadjust(
1138 /* 1138 /*
1139 * Shouldn't be able to turn off quotas here. 1139 * Shouldn't be able to turn off quotas here.
1140 */ 1140 */
1141 ASSERT(error != ESRCH); 1141 ASSERT(error != -ESRCH);
1142 ASSERT(error != ENOENT); 1142 ASSERT(error != -ENOENT);
1143 return error; 1143 return error;
1144 } 1144 }
1145 1145
@@ -1226,7 +1226,7 @@ xfs_qm_dqusage_adjust(
1226 */ 1226 */
1227 if (xfs_is_quota_inode(&mp->m_sb, ino)) { 1227 if (xfs_is_quota_inode(&mp->m_sb, ino)) {
1228 *res = BULKSTAT_RV_NOTHING; 1228 *res = BULKSTAT_RV_NOTHING;
1229 return EINVAL; 1229 return -EINVAL;
1230 } 1230 }
1231 1231
1232 /* 1232 /*
@@ -1679,7 +1679,7 @@ xfs_qm_vop_dqalloc(
1679 XFS_QMOPT_DOWARN, 1679 XFS_QMOPT_DOWARN,
1680 &uq); 1680 &uq);
1681 if (error) { 1681 if (error) {
1682 ASSERT(error != ENOENT); 1682 ASSERT(error != -ENOENT);
1683 return error; 1683 return error;
1684 } 1684 }
1685 /* 1685 /*
@@ -1706,7 +1706,7 @@ xfs_qm_vop_dqalloc(
1706 XFS_QMOPT_DOWARN, 1706 XFS_QMOPT_DOWARN,
1707 &gq); 1707 &gq);
1708 if (error) { 1708 if (error) {
1709 ASSERT(error != ENOENT); 1709 ASSERT(error != -ENOENT);
1710 goto error_rele; 1710 goto error_rele;
1711 } 1711 }
1712 xfs_dqunlock(gq); 1712 xfs_dqunlock(gq);
@@ -1726,7 +1726,7 @@ xfs_qm_vop_dqalloc(
1726 XFS_QMOPT_DOWARN, 1726 XFS_QMOPT_DOWARN,
1727 &pq); 1727 &pq);
1728 if (error) { 1728 if (error) {
1729 ASSERT(error != ENOENT); 1729 ASSERT(error != -ENOENT);
1730 goto error_rele; 1730 goto error_rele;
1731 } 1731 }
1732 xfs_dqunlock(pq); 1732 xfs_dqunlock(pq);
diff --git a/fs/xfs/xfs_qm_bhv.c b/fs/xfs/xfs_qm_bhv.c
index fa9797382d5b..2c61e61b0205 100644
--- a/fs/xfs/xfs_qm_bhv.c
+++ b/fs/xfs/xfs_qm_bhv.c
@@ -117,7 +117,7 @@ xfs_qm_newmount(
117 (uquotaondisk ? " usrquota" : ""), 117 (uquotaondisk ? " usrquota" : ""),
118 (gquotaondisk ? " grpquota" : ""), 118 (gquotaondisk ? " grpquota" : ""),
119 (pquotaondisk ? " prjquota" : "")); 119 (pquotaondisk ? " prjquota" : ""));
120 return EPERM; 120 return -EPERM;
121 } 121 }
122 122
123 if (XFS_IS_QUOTA_ON(mp) || quotaondisk) { 123 if (XFS_IS_QUOTA_ON(mp) || quotaondisk) {
diff --git a/fs/xfs/xfs_qm_syscalls.c b/fs/xfs/xfs_qm_syscalls.c
index f5167e837828..80f2d77d929a 100644
--- a/fs/xfs/xfs_qm_syscalls.c
+++ b/fs/xfs/xfs_qm_syscalls.c
@@ -64,10 +64,10 @@ xfs_qm_scall_quotaoff(
64 /* 64 /*
65 * No file system can have quotas enabled on disk but not in core. 65 * No file system can have quotas enabled on disk but not in core.
66 * Note that quota utilities (like quotaoff) _expect_ 66 * Note that quota utilities (like quotaoff) _expect_
67 * errno == EEXIST here. 67 * errno == -EEXIST here.
68 */ 68 */
69 if ((mp->m_qflags & flags) == 0) 69 if ((mp->m_qflags & flags) == 0)
70 return EEXIST; 70 return -EEXIST;
71 error = 0; 71 error = 0;
72 72
73 flags &= (XFS_ALL_QUOTA_ACCT | XFS_ALL_QUOTA_ENFD); 73 flags &= (XFS_ALL_QUOTA_ACCT | XFS_ALL_QUOTA_ENFD);
@@ -278,13 +278,13 @@ xfs_qm_scall_trunc_qfiles(
278 xfs_mount_t *mp, 278 xfs_mount_t *mp,
279 uint flags) 279 uint flags)
280{ 280{
281 int error = EINVAL; 281 int error = -EINVAL;
282 282
283 if (!xfs_sb_version_hasquota(&mp->m_sb) || flags == 0 || 283 if (!xfs_sb_version_hasquota(&mp->m_sb) || flags == 0 ||
284 (flags & ~XFS_DQ_ALLTYPES)) { 284 (flags & ~XFS_DQ_ALLTYPES)) {
285 xfs_debug(mp, "%s: flags=%x m_qflags=%x", 285 xfs_debug(mp, "%s: flags=%x m_qflags=%x",
286 __func__, flags, mp->m_qflags); 286 __func__, flags, mp->m_qflags);
287 return EINVAL; 287 return -EINVAL;
288 } 288 }
289 289
290 if (flags & XFS_DQ_USER) { 290 if (flags & XFS_DQ_USER) {
@@ -328,7 +328,7 @@ xfs_qm_scall_quotaon(
328 if (flags == 0) { 328 if (flags == 0) {
329 xfs_debug(mp, "%s: zero flags, m_qflags=%x", 329 xfs_debug(mp, "%s: zero flags, m_qflags=%x",
330 __func__, mp->m_qflags); 330 __func__, mp->m_qflags);
331 return EINVAL; 331 return -EINVAL;
332 } 332 }
333 333
334 /* No fs can turn on quotas with a delayed effect */ 334 /* No fs can turn on quotas with a delayed effect */
@@ -351,13 +351,13 @@ xfs_qm_scall_quotaon(
351 xfs_debug(mp, 351 xfs_debug(mp,
352 "%s: Can't enforce without acct, flags=%x sbflags=%x", 352 "%s: Can't enforce without acct, flags=%x sbflags=%x",
353 __func__, flags, mp->m_sb.sb_qflags); 353 __func__, flags, mp->m_sb.sb_qflags);
354 return EINVAL; 354 return -EINVAL;
355 } 355 }
356 /* 356 /*
357 * If everything's up to-date incore, then don't waste time. 357 * If everything's up to-date incore, then don't waste time.
358 */ 358 */
359 if ((mp->m_qflags & flags) == flags) 359 if ((mp->m_qflags & flags) == flags)
360 return EEXIST; 360 return -EEXIST;
361 361
362 /* 362 /*
363 * Change sb_qflags on disk but not incore mp->qflags 363 * Change sb_qflags on disk but not incore mp->qflags
@@ -372,7 +372,7 @@ xfs_qm_scall_quotaon(
372 * There's nothing to change if it's the same. 372 * There's nothing to change if it's the same.
373 */ 373 */
374 if ((qf & flags) == flags && sbflags == 0) 374 if ((qf & flags) == flags && sbflags == 0)
375 return EEXIST; 375 return -EEXIST;
376 sbflags |= XFS_SB_QFLAGS; 376 sbflags |= XFS_SB_QFLAGS;
377 377
378 if ((error = xfs_qm_write_sb_changes(mp, sbflags))) 378 if ((error = xfs_qm_write_sb_changes(mp, sbflags)))
@@ -390,7 +390,7 @@ xfs_qm_scall_quotaon(
390 return 0; 390 return 0;
391 391
392 if (! XFS_IS_QUOTA_RUNNING(mp)) 392 if (! XFS_IS_QUOTA_RUNNING(mp))
393 return ESRCH; 393 return -ESRCH;
394 394
395 /* 395 /*
396 * Switch on quota enforcement in core. 396 * Switch on quota enforcement in core.
@@ -595,7 +595,7 @@ xfs_qm_scall_setqlim(
595 xfs_qcnt_t hard, soft; 595 xfs_qcnt_t hard, soft;
596 596
597 if (newlim->d_fieldmask & ~XFS_DQ_MASK) 597 if (newlim->d_fieldmask & ~XFS_DQ_MASK)
598 return EINVAL; 598 return -EINVAL;
599 if ((newlim->d_fieldmask & XFS_DQ_MASK) == 0) 599 if ((newlim->d_fieldmask & XFS_DQ_MASK) == 0)
600 return 0; 600 return 0;
601 601
@@ -615,7 +615,7 @@ xfs_qm_scall_setqlim(
615 */ 615 */
616 error = xfs_qm_dqget(mp, NULL, id, type, XFS_QMOPT_DQALLOC, &dqp); 616 error = xfs_qm_dqget(mp, NULL, id, type, XFS_QMOPT_DQALLOC, &dqp);
617 if (error) { 617 if (error) {
618 ASSERT(error != ENOENT); 618 ASSERT(error != -ENOENT);
619 goto out_unlock; 619 goto out_unlock;
620 } 620 }
621 xfs_dqunlock(dqp); 621 xfs_dqunlock(dqp);
@@ -850,7 +850,7 @@ xfs_qm_scall_getquota(
850 * our utility programs are concerned. 850 * our utility programs are concerned.
851 */ 851 */
852 if (XFS_IS_DQUOT_UNINITIALIZED(dqp)) { 852 if (XFS_IS_DQUOT_UNINITIALIZED(dqp)) {
853 error = ENOENT; 853 error = -ENOENT;
854 goto out_put; 854 goto out_put;
855 } 855 }
856 856
diff --git a/fs/xfs/xfs_quotaops.c b/fs/xfs/xfs_quotaops.c
index 2ad1b9822e92..4f7aecbe61da 100644
--- a/fs/xfs/xfs_quotaops.c
+++ b/fs/xfs/xfs_quotaops.c
@@ -51,7 +51,7 @@ xfs_fs_get_xstate(
51 51
52 if (!XFS_IS_QUOTA_RUNNING(mp)) 52 if (!XFS_IS_QUOTA_RUNNING(mp))
53 return -ENOSYS; 53 return -ENOSYS;
54 return -xfs_qm_scall_getqstat(mp, fqs); 54 return xfs_qm_scall_getqstat(mp, fqs);
55} 55}
56 56
57STATIC int 57STATIC int
@@ -63,7 +63,7 @@ xfs_fs_get_xstatev(
63 63
64 if (!XFS_IS_QUOTA_RUNNING(mp)) 64 if (!XFS_IS_QUOTA_RUNNING(mp))
65 return -ENOSYS; 65 return -ENOSYS;
66 return -xfs_qm_scall_getqstatv(mp, fqs); 66 return xfs_qm_scall_getqstatv(mp, fqs);
67} 67}
68 68
69STATIC int 69STATIC int
@@ -95,11 +95,11 @@ xfs_fs_set_xstate(
95 95
96 switch (op) { 96 switch (op) {
97 case Q_XQUOTAON: 97 case Q_XQUOTAON:
98 return -xfs_qm_scall_quotaon(mp, flags); 98 return xfs_qm_scall_quotaon(mp, flags);
99 case Q_XQUOTAOFF: 99 case Q_XQUOTAOFF:
100 if (!XFS_IS_QUOTA_ON(mp)) 100 if (!XFS_IS_QUOTA_ON(mp))
101 return -EINVAL; 101 return -EINVAL;
102 return -xfs_qm_scall_quotaoff(mp, flags); 102 return xfs_qm_scall_quotaoff(mp, flags);
103 } 103 }
104 104
105 return -EINVAL; 105 return -EINVAL;
@@ -112,7 +112,7 @@ xfs_fs_rm_xquota(
112{ 112{
113 struct xfs_mount *mp = XFS_M(sb); 113 struct xfs_mount *mp = XFS_M(sb);
114 unsigned int flags = 0; 114 unsigned int flags = 0;
115 115
116 if (sb->s_flags & MS_RDONLY) 116 if (sb->s_flags & MS_RDONLY)
117 return -EROFS; 117 return -EROFS;
118 118
@@ -126,8 +126,8 @@ xfs_fs_rm_xquota(
126 if (uflags & FS_USER_QUOTA) 126 if (uflags & FS_USER_QUOTA)
127 flags |= XFS_DQ_PROJ; 127 flags |= XFS_DQ_PROJ;
128 128
129 return -xfs_qm_scall_trunc_qfiles(mp, flags); 129 return xfs_qm_scall_trunc_qfiles(mp, flags);
130} 130}
131 131
132STATIC int 132STATIC int
133xfs_fs_get_dqblk( 133xfs_fs_get_dqblk(
@@ -142,7 +142,7 @@ xfs_fs_get_dqblk(
142 if (!XFS_IS_QUOTA_ON(mp)) 142 if (!XFS_IS_QUOTA_ON(mp))
143 return -ESRCH; 143 return -ESRCH;
144 144
145 return -xfs_qm_scall_getquota(mp, from_kqid(&init_user_ns, qid), 145 return xfs_qm_scall_getquota(mp, from_kqid(&init_user_ns, qid),
146 xfs_quota_type(qid.type), fdq); 146 xfs_quota_type(qid.type), fdq);
147} 147}
148 148
@@ -161,7 +161,7 @@ xfs_fs_set_dqblk(
161 if (!XFS_IS_QUOTA_ON(mp)) 161 if (!XFS_IS_QUOTA_ON(mp))
162 return -ESRCH; 162 return -ESRCH;
163 163
164 return -xfs_qm_scall_setqlim(mp, from_kqid(&init_user_ns, qid), 164 return xfs_qm_scall_setqlim(mp, from_kqid(&init_user_ns, qid),
165 xfs_quota_type(qid.type), fdq); 165 xfs_quota_type(qid.type), fdq);
166} 166}
167 167
diff --git a/fs/xfs/xfs_rtalloc.c b/fs/xfs/xfs_rtalloc.c
index 1a98a783cf4b..b741d7286990 100644
--- a/fs/xfs/xfs_rtalloc.c
+++ b/fs/xfs/xfs_rtalloc.c
@@ -863,7 +863,7 @@ xfs_growfs_rt_alloc(
863 XFS_BMAPI_METADATA, &firstblock, 863 XFS_BMAPI_METADATA, &firstblock,
864 resblks, &map, &nmap, &flist); 864 resblks, &map, &nmap, &flist);
865 if (!error && nmap < 1) 865 if (!error && nmap < 1)
866 error = ENOSPC; 866 error = -ENOSPC;
867 if (error) 867 if (error)
868 goto error_cancel; 868 goto error_cancel;
869 /* 869 /*
@@ -903,7 +903,7 @@ xfs_growfs_rt_alloc(
903 bp = xfs_trans_get_buf(tp, mp->m_ddev_targp, d, 903 bp = xfs_trans_get_buf(tp, mp->m_ddev_targp, d,
904 mp->m_bsize, 0); 904 mp->m_bsize, 0);
905 if (bp == NULL) { 905 if (bp == NULL) {
906 error = EIO; 906 error = -EIO;
907error_cancel: 907error_cancel:
908 xfs_trans_cancel(tp, cancelflags); 908 xfs_trans_cancel(tp, cancelflags);
909 goto error; 909 goto error;
@@ -962,11 +962,11 @@ xfs_growfs_rt(
962 * Initial error checking. 962 * Initial error checking.
963 */ 963 */
964 if (!capable(CAP_SYS_ADMIN)) 964 if (!capable(CAP_SYS_ADMIN))
965 return EPERM; 965 return -EPERM;
966 if (mp->m_rtdev_targp == NULL || mp->m_rbmip == NULL || 966 if (mp->m_rtdev_targp == NULL || mp->m_rbmip == NULL ||
967 (nrblocks = in->newblocks) <= sbp->sb_rblocks || 967 (nrblocks = in->newblocks) <= sbp->sb_rblocks ||
968 (sbp->sb_rblocks && (in->extsize != sbp->sb_rextsize))) 968 (sbp->sb_rblocks && (in->extsize != sbp->sb_rextsize)))
969 return EINVAL; 969 return -EINVAL;
970 if ((error = xfs_sb_validate_fsb_count(sbp, nrblocks))) 970 if ((error = xfs_sb_validate_fsb_count(sbp, nrblocks)))
971 return error; 971 return error;
972 /* 972 /*
@@ -976,7 +976,7 @@ xfs_growfs_rt(
976 XFS_FSB_TO_BB(mp, nrblocks - 1), 976 XFS_FSB_TO_BB(mp, nrblocks - 1),
977 XFS_FSB_TO_BB(mp, 1), 0, NULL); 977 XFS_FSB_TO_BB(mp, 1), 0, NULL);
978 if (!bp) 978 if (!bp)
979 return EIO; 979 return -EIO;
980 if (bp->b_error) { 980 if (bp->b_error) {
981 error = bp->b_error; 981 error = bp->b_error;
982 xfs_buf_relse(bp); 982 xfs_buf_relse(bp);
@@ -1001,7 +1001,7 @@ xfs_growfs_rt(
1001 * since we'll log basically the whole summary file at once. 1001 * since we'll log basically the whole summary file at once.
1002 */ 1002 */
1003 if (nrsumblocks > (mp->m_sb.sb_logblocks >> 1)) 1003 if (nrsumblocks > (mp->m_sb.sb_logblocks >> 1))
1004 return EINVAL; 1004 return -EINVAL;
1005 /* 1005 /*
1006 * Get the old block counts for bitmap and summary inodes. 1006 * Get the old block counts for bitmap and summary inodes.
1007 * These can't change since other growfs callers are locked out. 1007 * These can't change since other growfs callers are locked out.
@@ -1208,7 +1208,7 @@ xfs_rtallocate_extent(
1208 len, &sumbp, &sb, prod, &r); 1208 len, &sumbp, &sb, prod, &r);
1209 break; 1209 break;
1210 default: 1210 default:
1211 error = EIO; 1211 error = -EIO;
1212 ASSERT(0); 1212 ASSERT(0);
1213 } 1213 }
1214 if (error) 1214 if (error)
@@ -1247,7 +1247,7 @@ xfs_rtmount_init(
1247 if (mp->m_rtdev_targp == NULL) { 1247 if (mp->m_rtdev_targp == NULL) {
1248 xfs_warn(mp, 1248 xfs_warn(mp,
1249 "Filesystem has a realtime volume, use rtdev=device option"); 1249 "Filesystem has a realtime volume, use rtdev=device option");
1250 return ENODEV; 1250 return -ENODEV;
1251 } 1251 }
1252 mp->m_rsumlevels = sbp->sb_rextslog + 1; 1252 mp->m_rsumlevels = sbp->sb_rextslog + 1;
1253 mp->m_rsumsize = 1253 mp->m_rsumsize =
@@ -1263,7 +1263,7 @@ xfs_rtmount_init(
1263 xfs_warn(mp, "realtime mount -- %llu != %llu", 1263 xfs_warn(mp, "realtime mount -- %llu != %llu",
1264 (unsigned long long) XFS_BB_TO_FSB(mp, d), 1264 (unsigned long long) XFS_BB_TO_FSB(mp, d),
1265 (unsigned long long) mp->m_sb.sb_rblocks); 1265 (unsigned long long) mp->m_sb.sb_rblocks);
1266 return EFBIG; 1266 return -EFBIG;
1267 } 1267 }
1268 bp = xfs_buf_read_uncached(mp->m_rtdev_targp, 1268 bp = xfs_buf_read_uncached(mp->m_rtdev_targp,
1269 d - XFS_FSB_TO_BB(mp, 1), 1269 d - XFS_FSB_TO_BB(mp, 1),
@@ -1272,7 +1272,7 @@ xfs_rtmount_init(
1272 xfs_warn(mp, "realtime device size check failed"); 1272 xfs_warn(mp, "realtime device size check failed");
1273 if (bp) 1273 if (bp)
1274 xfs_buf_relse(bp); 1274 xfs_buf_relse(bp);
1275 return EIO; 1275 return -EIO;
1276 } 1276 }
1277 xfs_buf_relse(bp); 1277 xfs_buf_relse(bp);
1278 return 0; 1278 return 0;
diff --git a/fs/xfs/xfs_rtalloc.h b/fs/xfs/xfs_rtalloc.h
index 752b63d10300..c642795324af 100644
--- a/fs/xfs/xfs_rtalloc.h
+++ b/fs/xfs/xfs_rtalloc.h
@@ -132,7 +132,7 @@ xfs_rtmount_init(
132 return 0; 132 return 0;
133 133
134 xfs_warn(mp, "Not built with CONFIG_XFS_RT"); 134 xfs_warn(mp, "Not built with CONFIG_XFS_RT");
135 return ENOSYS; 135 return -ENOSYS;
136} 136}
137# define xfs_rtmount_inodes(m) (((mp)->m_sb.sb_rblocks == 0)? 0 : (ENOSYS)) 137# define xfs_rtmount_inodes(m) (((mp)->m_sb.sb_rblocks == 0)? 0 : (ENOSYS))
138# define xfs_rtunmount_inodes(m) 138# define xfs_rtunmount_inodes(m)
diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
index 12d3ad3203ff..f2e5f8a503d2 100644
--- a/fs/xfs/xfs_super.c
+++ b/fs/xfs/xfs_super.c
@@ -185,7 +185,7 @@ xfs_parseargs(
185 */ 185 */
186 mp->m_fsname = kstrndup(sb->s_id, MAXNAMELEN, GFP_KERNEL); 186 mp->m_fsname = kstrndup(sb->s_id, MAXNAMELEN, GFP_KERNEL);
187 if (!mp->m_fsname) 187 if (!mp->m_fsname)
188 return ENOMEM; 188 return -ENOMEM;
189 mp->m_fsname_len = strlen(mp->m_fsname) + 1; 189 mp->m_fsname_len = strlen(mp->m_fsname) + 1;
190 190
191 /* 191 /*
@@ -227,57 +227,57 @@ xfs_parseargs(
227 if (!value || !*value) { 227 if (!value || !*value) {
228 xfs_warn(mp, "%s option requires an argument", 228 xfs_warn(mp, "%s option requires an argument",
229 this_char); 229 this_char);
230 return EINVAL; 230 return -EINVAL;
231 } 231 }
232 if (kstrtoint(value, 10, &mp->m_logbufs)) 232 if (kstrtoint(value, 10, &mp->m_logbufs))
233 return EINVAL; 233 return -EINVAL;
234 } else if (!strcmp(this_char, MNTOPT_LOGBSIZE)) { 234 } else if (!strcmp(this_char, MNTOPT_LOGBSIZE)) {
235 if (!value || !*value) { 235 if (!value || !*value) {
236 xfs_warn(mp, "%s option requires an argument", 236 xfs_warn(mp, "%s option requires an argument",
237 this_char); 237 this_char);
238 return EINVAL; 238 return -EINVAL;
239 } 239 }
240 if (suffix_kstrtoint(value, 10, &mp->m_logbsize)) 240 if (suffix_kstrtoint(value, 10, &mp->m_logbsize))
241 return EINVAL; 241 return -EINVAL;
242 } else if (!strcmp(this_char, MNTOPT_LOGDEV)) { 242 } else if (!strcmp(this_char, MNTOPT_LOGDEV)) {
243 if (!value || !*value) { 243 if (!value || !*value) {
244 xfs_warn(mp, "%s option requires an argument", 244 xfs_warn(mp, "%s option requires an argument",
245 this_char); 245 this_char);
246 return EINVAL; 246 return -EINVAL;
247 } 247 }
248 mp->m_logname = kstrndup(value, MAXNAMELEN, GFP_KERNEL); 248 mp->m_logname = kstrndup(value, MAXNAMELEN, GFP_KERNEL);
249 if (!mp->m_logname) 249 if (!mp->m_logname)
250 return ENOMEM; 250 return -ENOMEM;
251 } else if (!strcmp(this_char, MNTOPT_MTPT)) { 251 } else if (!strcmp(this_char, MNTOPT_MTPT)) {
252 xfs_warn(mp, "%s option not allowed on this system", 252 xfs_warn(mp, "%s option not allowed on this system",
253 this_char); 253 this_char);
254 return EINVAL; 254 return -EINVAL;
255 } else if (!strcmp(this_char, MNTOPT_RTDEV)) { 255 } else if (!strcmp(this_char, MNTOPT_RTDEV)) {
256 if (!value || !*value) { 256 if (!value || !*value) {
257 xfs_warn(mp, "%s option requires an argument", 257 xfs_warn(mp, "%s option requires an argument",
258 this_char); 258 this_char);
259 return EINVAL; 259 return -EINVAL;
260 } 260 }
261 mp->m_rtname = kstrndup(value, MAXNAMELEN, GFP_KERNEL); 261 mp->m_rtname = kstrndup(value, MAXNAMELEN, GFP_KERNEL);
262 if (!mp->m_rtname) 262 if (!mp->m_rtname)
263 return ENOMEM; 263 return -ENOMEM;
264 } else if (!strcmp(this_char, MNTOPT_BIOSIZE)) { 264 } else if (!strcmp(this_char, MNTOPT_BIOSIZE)) {
265 if (!value || !*value) { 265 if (!value || !*value) {
266 xfs_warn(mp, "%s option requires an argument", 266 xfs_warn(mp, "%s option requires an argument",
267 this_char); 267 this_char);
268 return EINVAL; 268 return -EINVAL;
269 } 269 }
270 if (kstrtoint(value, 10, &iosize)) 270 if (kstrtoint(value, 10, &iosize))
271 return EINVAL; 271 return -EINVAL;
272 iosizelog = ffs(iosize) - 1; 272 iosizelog = ffs(iosize) - 1;
273 } else if (!strcmp(this_char, MNTOPT_ALLOCSIZE)) { 273 } else if (!strcmp(this_char, MNTOPT_ALLOCSIZE)) {
274 if (!value || !*value) { 274 if (!value || !*value) {
275 xfs_warn(mp, "%s option requires an argument", 275 xfs_warn(mp, "%s option requires an argument",
276 this_char); 276 this_char);
277 return EINVAL; 277 return -EINVAL;
278 } 278 }
279 if (suffix_kstrtoint(value, 10, &iosize)) 279 if (suffix_kstrtoint(value, 10, &iosize))
280 return EINVAL; 280 return -EINVAL;
281 iosizelog = ffs(iosize) - 1; 281 iosizelog = ffs(iosize) - 1;
282 } else if (!strcmp(this_char, MNTOPT_GRPID) || 282 } else if (!strcmp(this_char, MNTOPT_GRPID) ||
283 !strcmp(this_char, MNTOPT_BSDGROUPS)) { 283 !strcmp(this_char, MNTOPT_BSDGROUPS)) {
@@ -297,18 +297,18 @@ xfs_parseargs(
297 if (!value || !*value) { 297 if (!value || !*value) {
298 xfs_warn(mp, "%s option requires an argument", 298 xfs_warn(mp, "%s option requires an argument",
299 this_char); 299 this_char);
300 return EINVAL; 300 return -EINVAL;
301 } 301 }
302 if (kstrtoint(value, 10, &dsunit)) 302 if (kstrtoint(value, 10, &dsunit))
303 return EINVAL; 303 return -EINVAL;
304 } else if (!strcmp(this_char, MNTOPT_SWIDTH)) { 304 } else if (!strcmp(this_char, MNTOPT_SWIDTH)) {
305 if (!value || !*value) { 305 if (!value || !*value) {
306 xfs_warn(mp, "%s option requires an argument", 306 xfs_warn(mp, "%s option requires an argument",
307 this_char); 307 this_char);
308 return EINVAL; 308 return -EINVAL;
309 } 309 }
310 if (kstrtoint(value, 10, &dswidth)) 310 if (kstrtoint(value, 10, &dswidth))
311 return EINVAL; 311 return -EINVAL;
312 } else if (!strcmp(this_char, MNTOPT_32BITINODE)) { 312 } else if (!strcmp(this_char, MNTOPT_32BITINODE)) {
313 mp->m_flags |= XFS_MOUNT_SMALL_INUMS; 313 mp->m_flags |= XFS_MOUNT_SMALL_INUMS;
314 } else if (!strcmp(this_char, MNTOPT_64BITINODE)) { 314 } else if (!strcmp(this_char, MNTOPT_64BITINODE)) {
@@ -316,7 +316,7 @@ xfs_parseargs(
316#if !XFS_BIG_INUMS 316#if !XFS_BIG_INUMS
317 xfs_warn(mp, "%s option not allowed on this system", 317 xfs_warn(mp, "%s option not allowed on this system",
318 this_char); 318 this_char);
319 return EINVAL; 319 return -EINVAL;
320#endif 320#endif
321 } else if (!strcmp(this_char, MNTOPT_NOUUID)) { 321 } else if (!strcmp(this_char, MNTOPT_NOUUID)) {
322 mp->m_flags |= XFS_MOUNT_NOUUID; 322 mp->m_flags |= XFS_MOUNT_NOUUID;
@@ -390,7 +390,7 @@ xfs_parseargs(
390 "irixsgid is now a sysctl(2) variable, option is deprecated."); 390 "irixsgid is now a sysctl(2) variable, option is deprecated.");
391 } else { 391 } else {
392 xfs_warn(mp, "unknown mount option [%s].", this_char); 392 xfs_warn(mp, "unknown mount option [%s].", this_char);
393 return EINVAL; 393 return -EINVAL;
394 } 394 }
395 } 395 }
396 396
@@ -400,32 +400,32 @@ xfs_parseargs(
400 if ((mp->m_flags & XFS_MOUNT_NORECOVERY) && 400 if ((mp->m_flags & XFS_MOUNT_NORECOVERY) &&
401 !(mp->m_flags & XFS_MOUNT_RDONLY)) { 401 !(mp->m_flags & XFS_MOUNT_RDONLY)) {
402 xfs_warn(mp, "no-recovery mounts must be read-only."); 402 xfs_warn(mp, "no-recovery mounts must be read-only.");
403 return EINVAL; 403 return -EINVAL;
404 } 404 }
405 405
406 if ((mp->m_flags & XFS_MOUNT_NOALIGN) && (dsunit || dswidth)) { 406 if ((mp->m_flags & XFS_MOUNT_NOALIGN) && (dsunit || dswidth)) {
407 xfs_warn(mp, 407 xfs_warn(mp,
408 "sunit and swidth options incompatible with the noalign option"); 408 "sunit and swidth options incompatible with the noalign option");
409 return EINVAL; 409 return -EINVAL;
410 } 410 }
411 411
412#ifndef CONFIG_XFS_QUOTA 412#ifndef CONFIG_XFS_QUOTA
413 if (XFS_IS_QUOTA_RUNNING(mp)) { 413 if (XFS_IS_QUOTA_RUNNING(mp)) {
414 xfs_warn(mp, "quota support not available in this kernel."); 414 xfs_warn(mp, "quota support not available in this kernel.");
415 return EINVAL; 415 return -EINVAL;
416 } 416 }
417#endif 417#endif
418 418
419 if ((dsunit && !dswidth) || (!dsunit && dswidth)) { 419 if ((dsunit && !dswidth) || (!dsunit && dswidth)) {
420 xfs_warn(mp, "sunit and swidth must be specified together"); 420 xfs_warn(mp, "sunit and swidth must be specified together");
421 return EINVAL; 421 return -EINVAL;
422 } 422 }
423 423
424 if (dsunit && (dswidth % dsunit != 0)) { 424 if (dsunit && (dswidth % dsunit != 0)) {
425 xfs_warn(mp, 425 xfs_warn(mp,
426 "stripe width (%d) must be a multiple of the stripe unit (%d)", 426 "stripe width (%d) must be a multiple of the stripe unit (%d)",
427 dswidth, dsunit); 427 dswidth, dsunit);
428 return EINVAL; 428 return -EINVAL;
429 } 429 }
430 430
431done: 431done:
@@ -446,7 +446,7 @@ done:
446 mp->m_logbufs > XLOG_MAX_ICLOGS)) { 446 mp->m_logbufs > XLOG_MAX_ICLOGS)) {
447 xfs_warn(mp, "invalid logbufs value: %d [not %d-%d]", 447 xfs_warn(mp, "invalid logbufs value: %d [not %d-%d]",
448 mp->m_logbufs, XLOG_MIN_ICLOGS, XLOG_MAX_ICLOGS); 448 mp->m_logbufs, XLOG_MIN_ICLOGS, XLOG_MAX_ICLOGS);
449 return EINVAL; 449 return -EINVAL;
450 } 450 }
451 if (mp->m_logbsize != -1 && 451 if (mp->m_logbsize != -1 &&
452 mp->m_logbsize != 0 && 452 mp->m_logbsize != 0 &&
@@ -456,7 +456,7 @@ done:
456 xfs_warn(mp, 456 xfs_warn(mp,
457 "invalid logbufsize: %d [not 16k,32k,64k,128k or 256k]", 457 "invalid logbufsize: %d [not 16k,32k,64k,128k or 256k]",
458 mp->m_logbsize); 458 mp->m_logbsize);
459 return EINVAL; 459 return -EINVAL;
460 } 460 }
461 461
462 if (iosizelog) { 462 if (iosizelog) {
@@ -465,7 +465,7 @@ done:
465 xfs_warn(mp, "invalid log iosize: %d [not %d-%d]", 465 xfs_warn(mp, "invalid log iosize: %d [not %d-%d]",
466 iosizelog, XFS_MIN_IO_LOG, 466 iosizelog, XFS_MIN_IO_LOG,
467 XFS_MAX_IO_LOG); 467 XFS_MAX_IO_LOG);
468 return EINVAL; 468 return -EINVAL;
469 } 469 }
470 470
471 mp->m_flags |= XFS_MOUNT_DFLT_IOSIZE; 471 mp->m_flags |= XFS_MOUNT_DFLT_IOSIZE;
@@ -686,7 +686,7 @@ xfs_blkdev_get(
686 xfs_warn(mp, "Invalid device [%s], error=%d\n", name, error); 686 xfs_warn(mp, "Invalid device [%s], error=%d\n", name, error);
687 } 687 }
688 688
689 return -error; 689 return error;
690} 690}
691 691
692STATIC void 692STATIC void
@@ -756,7 +756,7 @@ xfs_open_devices(
756 if (rtdev == ddev || rtdev == logdev) { 756 if (rtdev == ddev || rtdev == logdev) {
757 xfs_warn(mp, 757 xfs_warn(mp,
758 "Cannot mount filesystem with identical rtdev and ddev/logdev."); 758 "Cannot mount filesystem with identical rtdev and ddev/logdev.");
759 error = EINVAL; 759 error = -EINVAL;
760 goto out_close_rtdev; 760 goto out_close_rtdev;
761 } 761 }
762 } 762 }
@@ -764,7 +764,7 @@ xfs_open_devices(
764 /* 764 /*
765 * Setup xfs_mount buffer target pointers 765 * Setup xfs_mount buffer target pointers
766 */ 766 */
767 error = ENOMEM; 767 error = -ENOMEM;
768 mp->m_ddev_targp = xfs_alloc_buftarg(mp, ddev); 768 mp->m_ddev_targp = xfs_alloc_buftarg(mp, ddev);
769 if (!mp->m_ddev_targp) 769 if (!mp->m_ddev_targp)
770 goto out_close_rtdev; 770 goto out_close_rtdev;
@@ -1295,7 +1295,7 @@ xfs_fs_freeze(
1295 1295
1296 xfs_save_resvblks(mp); 1296 xfs_save_resvblks(mp);
1297 xfs_quiesce_attr(mp); 1297 xfs_quiesce_attr(mp);
1298 return -xfs_fs_log_dummy(mp); 1298 return xfs_fs_log_dummy(mp);
1299} 1299}
1300 1300
1301STATIC int 1301STATIC int
@@ -1314,7 +1314,7 @@ xfs_fs_show_options(
1314 struct seq_file *m, 1314 struct seq_file *m,
1315 struct dentry *root) 1315 struct dentry *root)
1316{ 1316{
1317 return -xfs_showargs(XFS_M(root->d_sb), m); 1317 return xfs_showargs(XFS_M(root->d_sb), m);
1318} 1318}
1319 1319
1320/* 1320/*
@@ -1336,14 +1336,14 @@ xfs_finish_flags(
1336 mp->m_logbsize < mp->m_sb.sb_logsunit) { 1336 mp->m_logbsize < mp->m_sb.sb_logsunit) {
1337 xfs_warn(mp, 1337 xfs_warn(mp,
1338 "logbuf size must be greater than or equal to log stripe size"); 1338 "logbuf size must be greater than or equal to log stripe size");
1339 return EINVAL; 1339 return -EINVAL;
1340 } 1340 }
1341 } else { 1341 } else {
1342 /* Fail a mount if the logbuf is larger than 32K */ 1342 /* Fail a mount if the logbuf is larger than 32K */
1343 if (mp->m_logbsize > XLOG_BIG_RECORD_BSIZE) { 1343 if (mp->m_logbsize > XLOG_BIG_RECORD_BSIZE) {
1344 xfs_warn(mp, 1344 xfs_warn(mp,
1345 "logbuf size for version 1 logs must be 16K or 32K"); 1345 "logbuf size for version 1 logs must be 16K or 32K");
1346 return EINVAL; 1346 return -EINVAL;
1347 } 1347 }
1348 } 1348 }
1349 1349
@@ -1355,7 +1355,7 @@ xfs_finish_flags(
1355 xfs_warn(mp, 1355 xfs_warn(mp,
1356"Cannot mount a V5 filesystem as %s. %s is always enabled for V5 filesystems.", 1356"Cannot mount a V5 filesystem as %s. %s is always enabled for V5 filesystems.",
1357 MNTOPT_NOATTR2, MNTOPT_ATTR2); 1357 MNTOPT_NOATTR2, MNTOPT_ATTR2);
1358 return EINVAL; 1358 return -EINVAL;
1359 } 1359 }
1360 1360
1361 /* 1361 /*
@@ -1372,7 +1372,7 @@ xfs_finish_flags(
1372 if ((mp->m_sb.sb_flags & XFS_SBF_READONLY) && !ronly) { 1372 if ((mp->m_sb.sb_flags & XFS_SBF_READONLY) && !ronly) {
1373 xfs_warn(mp, 1373 xfs_warn(mp,
1374 "cannot mount a read-only filesystem as read-write"); 1374 "cannot mount a read-only filesystem as read-write");
1375 return EROFS; 1375 return -EROFS;
1376 } 1376 }
1377 1377
1378 if ((mp->m_qflags & (XFS_GQUOTA_ACCT | XFS_GQUOTA_ACTIVE)) && 1378 if ((mp->m_qflags & (XFS_GQUOTA_ACCT | XFS_GQUOTA_ACTIVE)) &&
@@ -1380,7 +1380,7 @@ xfs_finish_flags(
1380 !xfs_sb_version_has_pquotino(&mp->m_sb)) { 1380 !xfs_sb_version_has_pquotino(&mp->m_sb)) {
1381 xfs_warn(mp, 1381 xfs_warn(mp,
1382 "Super block does not support project and group quota together"); 1382 "Super block does not support project and group quota together");
1383 return EINVAL; 1383 return -EINVAL;
1384 } 1384 }
1385 1385
1386 return 0; 1386 return 0;
@@ -1394,7 +1394,7 @@ xfs_fs_fill_super(
1394{ 1394{
1395 struct inode *root; 1395 struct inode *root;
1396 struct xfs_mount *mp = NULL; 1396 struct xfs_mount *mp = NULL;
1397 int flags = 0, error = ENOMEM; 1397 int flags = 0, error = -ENOMEM;
1398 1398
1399 mp = kzalloc(sizeof(struct xfs_mount), GFP_KERNEL); 1399 mp = kzalloc(sizeof(struct xfs_mount), GFP_KERNEL);
1400 if (!mp) 1400 if (!mp)
@@ -1428,11 +1428,11 @@ xfs_fs_fill_super(
1428 if (error) 1428 if (error)
1429 goto out_free_fsname; 1429 goto out_free_fsname;
1430 1430
1431 error = -xfs_init_mount_workqueues(mp); 1431 error = xfs_init_mount_workqueues(mp);
1432 if (error) 1432 if (error)
1433 goto out_close_devices; 1433 goto out_close_devices;
1434 1434
1435 error = -xfs_icsb_init_counters(mp); 1435 error = xfs_icsb_init_counters(mp);
1436 if (error) 1436 if (error)
1437 goto out_destroy_workqueues; 1437 goto out_destroy_workqueues;
1438 1438
@@ -1474,12 +1474,12 @@ xfs_fs_fill_super(
1474 1474
1475 root = igrab(VFS_I(mp->m_rootip)); 1475 root = igrab(VFS_I(mp->m_rootip));
1476 if (!root) { 1476 if (!root) {
1477 error = ENOENT; 1477 error = -ENOENT;
1478 goto out_unmount; 1478 goto out_unmount;
1479 } 1479 }
1480 sb->s_root = d_make_root(root); 1480 sb->s_root = d_make_root(root);
1481 if (!sb->s_root) { 1481 if (!sb->s_root) {
1482 error = ENOMEM; 1482 error = -ENOMEM;
1483 goto out_unmount; 1483 goto out_unmount;
1484 } 1484 }
1485 1485
@@ -1499,7 +1499,7 @@ out_destroy_workqueues:
1499 xfs_free_fsname(mp); 1499 xfs_free_fsname(mp);
1500 kfree(mp); 1500 kfree(mp);
1501 out: 1501 out:
1502 return -error; 1502 return error;
1503 1503
1504 out_unmount: 1504 out_unmount:
1505 xfs_filestream_unmount(mp); 1505 xfs_filestream_unmount(mp);
diff --git a/fs/xfs/xfs_symlink.c b/fs/xfs/xfs_symlink.c
index c2c8173d1634..6a944a2cd36f 100644
--- a/fs/xfs/xfs_symlink.c
+++ b/fs/xfs/xfs_symlink.c
@@ -76,15 +76,15 @@ xfs_readlink_bmap(
76 bp = xfs_buf_read(mp->m_ddev_targp, d, BTOBB(byte_cnt), 0, 76 bp = xfs_buf_read(mp->m_ddev_targp, d, BTOBB(byte_cnt), 0,
77 &xfs_symlink_buf_ops); 77 &xfs_symlink_buf_ops);
78 if (!bp) 78 if (!bp)
79 return ENOMEM; 79 return -ENOMEM;
80 error = bp->b_error; 80 error = bp->b_error;
81 if (error) { 81 if (error) {
82 xfs_buf_ioerror_alert(bp, __func__); 82 xfs_buf_ioerror_alert(bp, __func__);
83 xfs_buf_relse(bp); 83 xfs_buf_relse(bp);
84 84
85 /* bad CRC means corrupted metadata */ 85 /* bad CRC means corrupted metadata */
86 if (error == EFSBADCRC) 86 if (error == -EFSBADCRC)
87 error = EFSCORRUPTED; 87 error = -EFSCORRUPTED;
88 goto out; 88 goto out;
89 } 89 }
90 byte_cnt = XFS_SYMLINK_BUF_SPACE(mp, byte_cnt); 90 byte_cnt = XFS_SYMLINK_BUF_SPACE(mp, byte_cnt);
@@ -95,7 +95,7 @@ xfs_readlink_bmap(
95 if (xfs_sb_version_hascrc(&mp->m_sb)) { 95 if (xfs_sb_version_hascrc(&mp->m_sb)) {
96 if (!xfs_symlink_hdr_ok(ip->i_ino, offset, 96 if (!xfs_symlink_hdr_ok(ip->i_ino, offset,
97 byte_cnt, bp)) { 97 byte_cnt, bp)) {
98 error = EFSCORRUPTED; 98 error = -EFSCORRUPTED;
99 xfs_alert(mp, 99 xfs_alert(mp,
100"symlink header does not match required off/len/owner (0x%x/Ox%x,0x%llx)", 100"symlink header does not match required off/len/owner (0x%x/Ox%x,0x%llx)",
101 offset, byte_cnt, ip->i_ino); 101 offset, byte_cnt, ip->i_ino);
@@ -135,7 +135,7 @@ xfs_readlink(
135 trace_xfs_readlink(ip); 135 trace_xfs_readlink(ip);
136 136
137 if (XFS_FORCED_SHUTDOWN(mp)) 137 if (XFS_FORCED_SHUTDOWN(mp))
138 return EIO; 138 return -EIO;
139 139
140 xfs_ilock(ip, XFS_ILOCK_SHARED); 140 xfs_ilock(ip, XFS_ILOCK_SHARED);
141 141
@@ -148,7 +148,7 @@ xfs_readlink(
148 __func__, (unsigned long long) ip->i_ino, 148 __func__, (unsigned long long) ip->i_ino,
149 (long long) pathlen); 149 (long long) pathlen);
150 ASSERT(0); 150 ASSERT(0);
151 error = EFSCORRUPTED; 151 error = -EFSCORRUPTED;
152 goto out; 152 goto out;
153 } 153 }
154 154
@@ -203,14 +203,14 @@ xfs_symlink(
203 trace_xfs_symlink(dp, link_name); 203 trace_xfs_symlink(dp, link_name);
204 204
205 if (XFS_FORCED_SHUTDOWN(mp)) 205 if (XFS_FORCED_SHUTDOWN(mp))
206 return EIO; 206 return -EIO;
207 207
208 /* 208 /*
209 * Check component lengths of the target path name. 209 * Check component lengths of the target path name.
210 */ 210 */
211 pathlen = strlen(target_path); 211 pathlen = strlen(target_path);
212 if (pathlen >= MAXPATHLEN) /* total string too long */ 212 if (pathlen >= MAXPATHLEN) /* total string too long */
213 return ENAMETOOLONG; 213 return -ENAMETOOLONG;
214 214
215 udqp = gdqp = NULL; 215 udqp = gdqp = NULL;
216 prid = xfs_get_initial_prid(dp); 216 prid = xfs_get_initial_prid(dp);
@@ -238,7 +238,7 @@ xfs_symlink(
238 fs_blocks = xfs_symlink_blocks(mp, pathlen); 238 fs_blocks = xfs_symlink_blocks(mp, pathlen);
239 resblks = XFS_SYMLINK_SPACE_RES(mp, link_name->len, fs_blocks); 239 resblks = XFS_SYMLINK_SPACE_RES(mp, link_name->len, fs_blocks);
240 error = xfs_trans_reserve(tp, &M_RES(mp)->tr_symlink, resblks, 0); 240 error = xfs_trans_reserve(tp, &M_RES(mp)->tr_symlink, resblks, 0);
241 if (error == ENOSPC && fs_blocks == 0) { 241 if (error == -ENOSPC && fs_blocks == 0) {
242 resblks = 0; 242 resblks = 0;
243 error = xfs_trans_reserve(tp, &M_RES(mp)->tr_symlink, 0, 0); 243 error = xfs_trans_reserve(tp, &M_RES(mp)->tr_symlink, 0, 0);
244 } 244 }
@@ -254,7 +254,7 @@ xfs_symlink(
254 * Check whether the directory allows new symlinks or not. 254 * Check whether the directory allows new symlinks or not.
255 */ 255 */
256 if (dp->i_d.di_flags & XFS_DIFLAG_NOSYMLINKS) { 256 if (dp->i_d.di_flags & XFS_DIFLAG_NOSYMLINKS) {
257 error = EPERM; 257 error = -EPERM;
258 goto error_return; 258 goto error_return;
259 } 259 }
260 260
@@ -284,7 +284,7 @@ xfs_symlink(
284 error = xfs_dir_ialloc(&tp, dp, S_IFLNK | (mode & ~S_IFMT), 1, 0, 284 error = xfs_dir_ialloc(&tp, dp, S_IFLNK | (mode & ~S_IFMT), 1, 0,
285 prid, resblks > 0, &ip, NULL); 285 prid, resblks > 0, &ip, NULL);
286 if (error) { 286 if (error) {
287 if (error == ENOSPC) 287 if (error == -ENOSPC)
288 goto error_return; 288 goto error_return;
289 goto error1; 289 goto error1;
290 } 290 }
@@ -348,7 +348,7 @@ xfs_symlink(
348 bp = xfs_trans_get_buf(tp, mp->m_ddev_targp, d, 348 bp = xfs_trans_get_buf(tp, mp->m_ddev_targp, d,
349 BTOBB(byte_cnt), 0); 349 BTOBB(byte_cnt), 0);
350 if (!bp) { 350 if (!bp) {
351 error = ENOMEM; 351 error = -ENOMEM;
352 goto error2; 352 goto error2;
353 } 353 }
354 bp->b_ops = &xfs_symlink_buf_ops; 354 bp->b_ops = &xfs_symlink_buf_ops;
@@ -489,7 +489,7 @@ xfs_inactive_symlink_rmt(
489 XFS_FSB_TO_DADDR(mp, mval[i].br_startblock), 489 XFS_FSB_TO_DADDR(mp, mval[i].br_startblock),
490 XFS_FSB_TO_BB(mp, mval[i].br_blockcount), 0); 490 XFS_FSB_TO_BB(mp, mval[i].br_blockcount), 0);
491 if (!bp) { 491 if (!bp) {
492 error = ENOMEM; 492 error = -ENOMEM;
493 goto error_bmap_cancel; 493 goto error_bmap_cancel;
494 } 494 }
495 xfs_trans_binval(tp, bp); 495 xfs_trans_binval(tp, bp);
@@ -562,7 +562,7 @@ xfs_inactive_symlink(
562 trace_xfs_inactive_symlink(ip); 562 trace_xfs_inactive_symlink(ip);
563 563
564 if (XFS_FORCED_SHUTDOWN(mp)) 564 if (XFS_FORCED_SHUTDOWN(mp))
565 return EIO; 565 return -EIO;
566 566
567 xfs_ilock(ip, XFS_ILOCK_EXCL); 567 xfs_ilock(ip, XFS_ILOCK_EXCL);
568 568
@@ -580,7 +580,7 @@ xfs_inactive_symlink(
580 __func__, (unsigned long long)ip->i_ino, pathlen); 580 __func__, (unsigned long long)ip->i_ino, pathlen);
581 xfs_iunlock(ip, XFS_ILOCK_EXCL); 581 xfs_iunlock(ip, XFS_ILOCK_EXCL);
582 ASSERT(0); 582 ASSERT(0);
583 return EFSCORRUPTED; 583 return -EFSCORRUPTED;
584 } 584 }
585 585
586 if (ip->i_df.if_flags & XFS_IFINLINE) { 586 if (ip->i_df.if_flags & XFS_IFINLINE) {
diff --git a/fs/xfs/xfs_trans.c b/fs/xfs/xfs_trans.c
index 6b9b48dfddaa..30e8e3410955 100644
--- a/fs/xfs/xfs_trans.c
+++ b/fs/xfs/xfs_trans.c
@@ -190,7 +190,7 @@ xfs_trans_reserve(
190 -((int64_t)blocks), rsvd); 190 -((int64_t)blocks), rsvd);
191 if (error != 0) { 191 if (error != 0) {
192 current_restore_flags_nested(&tp->t_pflags, PF_FSTRANS); 192 current_restore_flags_nested(&tp->t_pflags, PF_FSTRANS);
193 return ENOSPC; 193 return -ENOSPC;
194 } 194 }
195 tp->t_blk_res += blocks; 195 tp->t_blk_res += blocks;
196 } 196 }
@@ -241,7 +241,7 @@ xfs_trans_reserve(
241 error = xfs_mod_incore_sb(tp->t_mountp, XFS_SBS_FREXTENTS, 241 error = xfs_mod_incore_sb(tp->t_mountp, XFS_SBS_FREXTENTS,
242 -((int64_t)rtextents), rsvd); 242 -((int64_t)rtextents), rsvd);
243 if (error) { 243 if (error) {
244 error = ENOSPC; 244 error = -ENOSPC;
245 goto undo_log; 245 goto undo_log;
246 } 246 }
247 tp->t_rtx_res += rtextents; 247 tp->t_rtx_res += rtextents;
@@ -874,7 +874,7 @@ xfs_trans_commit(
874 goto out_unreserve; 874 goto out_unreserve;
875 875
876 if (XFS_FORCED_SHUTDOWN(mp)) { 876 if (XFS_FORCED_SHUTDOWN(mp)) {
877 error = EIO; 877 error = -EIO;
878 goto out_unreserve; 878 goto out_unreserve;
879 } 879 }
880 880
@@ -917,7 +917,7 @@ out_unreserve:
917 if (tp->t_ticket) { 917 if (tp->t_ticket) {
918 commit_lsn = xfs_log_done(mp, tp->t_ticket, NULL, log_flags); 918 commit_lsn = xfs_log_done(mp, tp->t_ticket, NULL, log_flags);
919 if (commit_lsn == -1 && !error) 919 if (commit_lsn == -1 && !error)
920 error = EIO; 920 error = -EIO;
921 } 921 }
922 current_restore_flags_nested(&tp->t_pflags, PF_FSTRANS); 922 current_restore_flags_nested(&tp->t_pflags, PF_FSTRANS);
923 xfs_trans_free_items(tp, NULLCOMMITLSN, error ? XFS_TRANS_ABORT : 0); 923 xfs_trans_free_items(tp, NULLCOMMITLSN, error ? XFS_TRANS_ABORT : 0);
diff --git a/fs/xfs/xfs_trans_ail.c b/fs/xfs/xfs_trans_ail.c
index cb0f3a84cc68..859482f53b5a 100644
--- a/fs/xfs/xfs_trans_ail.c
+++ b/fs/xfs/xfs_trans_ail.c
@@ -762,7 +762,7 @@ xfs_trans_ail_init(
762 762
763 ailp = kmem_zalloc(sizeof(struct xfs_ail), KM_MAYFAIL); 763 ailp = kmem_zalloc(sizeof(struct xfs_ail), KM_MAYFAIL);
764 if (!ailp) 764 if (!ailp)
765 return ENOMEM; 765 return -ENOMEM;
766 766
767 ailp->xa_mount = mp; 767 ailp->xa_mount = mp;
768 INIT_LIST_HEAD(&ailp->xa_ail); 768 INIT_LIST_HEAD(&ailp->xa_ail);
@@ -781,7 +781,7 @@ xfs_trans_ail_init(
781 781
782out_free_ailp: 782out_free_ailp:
783 kmem_free(ailp); 783 kmem_free(ailp);
784 return ENOMEM; 784 return -ENOMEM;
785} 785}
786 786
787void 787void
diff --git a/fs/xfs/xfs_trans_buf.c b/fs/xfs/xfs_trans_buf.c
index 33bf55d7403a..96c898e7ac9a 100644
--- a/fs/xfs/xfs_trans_buf.c
+++ b/fs/xfs/xfs_trans_buf.c
@@ -266,7 +266,7 @@ xfs_trans_read_buf_map(
266 bp = xfs_buf_read_map(target, map, nmaps, flags, ops); 266 bp = xfs_buf_read_map(target, map, nmaps, flags, ops);
267 if (!bp) 267 if (!bp)
268 return (flags & XBF_TRYLOCK) ? 268 return (flags & XBF_TRYLOCK) ?
269 EAGAIN : ENOMEM; 269 -EAGAIN : -ENOMEM;
270 270
271 if (bp->b_error) { 271 if (bp->b_error) {
272 error = bp->b_error; 272 error = bp->b_error;
@@ -276,8 +276,8 @@ xfs_trans_read_buf_map(
276 xfs_buf_relse(bp); 276 xfs_buf_relse(bp);
277 277
278 /* bad CRC means corrupted metadata */ 278 /* bad CRC means corrupted metadata */
279 if (error == EFSBADCRC) 279 if (error == -EFSBADCRC)
280 error = EFSCORRUPTED; 280 error = -EFSCORRUPTED;
281 return error; 281 return error;
282 } 282 }
283#ifdef DEBUG 283#ifdef DEBUG
@@ -286,7 +286,7 @@ xfs_trans_read_buf_map(
286 if (((xfs_req_num++) % xfs_error_mod) == 0) { 286 if (((xfs_req_num++) % xfs_error_mod) == 0) {
287 xfs_buf_relse(bp); 287 xfs_buf_relse(bp);
288 xfs_debug(mp, "Returning error!"); 288 xfs_debug(mp, "Returning error!");
289 return EIO; 289 return -EIO;
290 } 290 }
291 } 291 }
292 } 292 }
@@ -342,8 +342,8 @@ xfs_trans_read_buf_map(
342 xfs_force_shutdown(tp->t_mountp, 342 xfs_force_shutdown(tp->t_mountp,
343 SHUTDOWN_META_IO_ERROR); 343 SHUTDOWN_META_IO_ERROR);
344 /* bad CRC means corrupted metadata */ 344 /* bad CRC means corrupted metadata */
345 if (error == EFSBADCRC) 345 if (error == -EFSBADCRC)
346 error = EFSCORRUPTED; 346 error = -EFSCORRUPTED;
347 return error; 347 return error;
348 } 348 }
349 } 349 }
@@ -354,7 +354,7 @@ xfs_trans_read_buf_map(
354 if (XFS_FORCED_SHUTDOWN(mp)) { 354 if (XFS_FORCED_SHUTDOWN(mp)) {
355 trace_xfs_trans_read_buf_shut(bp, _RET_IP_); 355 trace_xfs_trans_read_buf_shut(bp, _RET_IP_);
356 *bpp = NULL; 356 *bpp = NULL;
357 return EIO; 357 return -EIO;
358 } 358 }
359 359
360 360
@@ -371,7 +371,7 @@ xfs_trans_read_buf_map(
371 if (bp == NULL) { 371 if (bp == NULL) {
372 *bpp = NULL; 372 *bpp = NULL;
373 return (flags & XBF_TRYLOCK) ? 373 return (flags & XBF_TRYLOCK) ?
374 0 : ENOMEM; 374 0 : -ENOMEM;
375 } 375 }
376 if (bp->b_error) { 376 if (bp->b_error) {
377 error = bp->b_error; 377 error = bp->b_error;
@@ -383,8 +383,8 @@ xfs_trans_read_buf_map(
383 xfs_buf_relse(bp); 383 xfs_buf_relse(bp);
384 384
385 /* bad CRC means corrupted metadata */ 385 /* bad CRC means corrupted metadata */
386 if (error == EFSBADCRC) 386 if (error == -EFSBADCRC)
387 error = EFSCORRUPTED; 387 error = -EFSCORRUPTED;
388 return error; 388 return error;
389 } 389 }
390#ifdef DEBUG 390#ifdef DEBUG
@@ -395,7 +395,7 @@ xfs_trans_read_buf_map(
395 SHUTDOWN_META_IO_ERROR); 395 SHUTDOWN_META_IO_ERROR);
396 xfs_buf_relse(bp); 396 xfs_buf_relse(bp);
397 xfs_debug(mp, "Returning trans error!"); 397 xfs_debug(mp, "Returning trans error!");
398 return EIO; 398 return -EIO;
399 } 399 }
400 } 400 }
401 } 401 }
@@ -413,7 +413,7 @@ shutdown_abort:
413 trace_xfs_trans_read_buf_shut(bp, _RET_IP_); 413 trace_xfs_trans_read_buf_shut(bp, _RET_IP_);
414 xfs_buf_relse(bp); 414 xfs_buf_relse(bp);
415 *bpp = NULL; 415 *bpp = NULL;
416 return EIO; 416 return -EIO;
417} 417}
418 418
419/* 419/*
diff --git a/fs/xfs/xfs_trans_dquot.c b/fs/xfs/xfs_trans_dquot.c
index 41172861e857..846e061c2e98 100644
--- a/fs/xfs/xfs_trans_dquot.c
+++ b/fs/xfs/xfs_trans_dquot.c
@@ -722,8 +722,8 @@ xfs_trans_dqresv(
722error_return: 722error_return:
723 xfs_dqunlock(dqp); 723 xfs_dqunlock(dqp);
724 if (flags & XFS_QMOPT_ENOSPC) 724 if (flags & XFS_QMOPT_ENOSPC)
725 return ENOSPC; 725 return -ENOSPC;
726 return EDQUOT; 726 return -EDQUOT;
727} 727}
728 728
729 729
diff --git a/fs/xfs/xfs_xattr.c b/fs/xfs/xfs_xattr.c
index 78ed92a46fdd..93455b998041 100644
--- a/fs/xfs/xfs_xattr.c
+++ b/fs/xfs/xfs_xattr.c
@@ -49,7 +49,7 @@ xfs_xattr_get(struct dentry *dentry, const char *name,
49 value = NULL; 49 value = NULL;
50 } 50 }
51 51
52 error = -xfs_attr_get(ip, (unsigned char *)name, value, &asize, xflags); 52 error = xfs_attr_get(ip, (unsigned char *)name, value, &asize, xflags);
53 if (error) 53 if (error)
54 return error; 54 return error;
55 return asize; 55 return asize;
@@ -71,8 +71,8 @@ xfs_xattr_set(struct dentry *dentry, const char *name, const void *value,
71 xflags |= ATTR_REPLACE; 71 xflags |= ATTR_REPLACE;
72 72
73 if (!value) 73 if (!value)
74 return -xfs_attr_remove(ip, (unsigned char *)name, xflags); 74 return xfs_attr_remove(ip, (unsigned char *)name, xflags);
75 return -xfs_attr_set(ip, (unsigned char *)name, 75 return xfs_attr_set(ip, (unsigned char *)name,
76 (void *)value, size, xflags); 76 (void *)value, size, xflags);
77} 77}
78 78