aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorDave Chinner <david@fromorbit.com>2014-07-14 17:37:18 -0400
committerDave Chinner <david@fromorbit.com>2014-07-14 17:37:18 -0400
commit7f8a058f6dc52219117bc2469b1fb816f7fa1a4b (patch)
tree43ce8eed4d26beb6f2acff2279c43eae7f79f83a /fs
parent03e01349c654fbdea80d3d9b4ab599244eb55bb7 (diff)
parent2451337dd043901b5270b7586942abe564443e3d (diff)
Merge branch 'xfs-libxfs-restructure' into for-next
Diffstat (limited to 'fs')
-rw-r--r--fs/xfs/Makefile70
-rw-r--r--fs/xfs/libxfs/xfs_ag.h (renamed from fs/xfs/xfs_ag.h)0
-rw-r--r--fs/xfs/libxfs/xfs_alloc.c (renamed from fs/xfs/xfs_alloc.c)20
-rw-r--r--fs/xfs/libxfs/xfs_alloc.h (renamed from fs/xfs/xfs_alloc.h)0
-rw-r--r--fs/xfs/libxfs/xfs_alloc_btree.c (renamed from fs/xfs/xfs_alloc_btree.c)6
-rw-r--r--fs/xfs/libxfs/xfs_alloc_btree.h (renamed from fs/xfs/xfs_alloc_btree.h)0
-rw-r--r--fs/xfs/libxfs/xfs_attr.c (renamed from fs/xfs/xfs_attr.c)92
-rw-r--r--fs/xfs/libxfs/xfs_attr_leaf.c (renamed from fs/xfs/xfs_attr_leaf.c)78
-rw-r--r--fs/xfs/libxfs/xfs_attr_leaf.h (renamed from fs/xfs/xfs_attr_leaf.h)0
-rw-r--r--fs/xfs/libxfs/xfs_attr_remote.c (renamed from fs/xfs/xfs_attr_remote.c)22
-rw-r--r--fs/xfs/libxfs/xfs_attr_remote.h (renamed from fs/xfs/xfs_attr_remote.h)0
-rw-r--r--fs/xfs/libxfs/xfs_attr_sf.h (renamed from fs/xfs/xfs_attr_sf.h)0
-rw-r--r--fs/xfs/libxfs/xfs_bit.h (renamed from fs/xfs/xfs_bit.h)0
-rw-r--r--fs/xfs/libxfs/xfs_bmap.c (renamed from fs/xfs/xfs_bmap.c)52
-rw-r--r--fs/xfs/libxfs/xfs_bmap.h (renamed from fs/xfs/xfs_bmap.h)0
-rw-r--r--fs/xfs/libxfs/xfs_bmap_btree.c (renamed from fs/xfs/xfs_bmap_btree.c)10
-rw-r--r--fs/xfs/libxfs/xfs_bmap_btree.h (renamed from fs/xfs/xfs_bmap_btree.h)0
-rw-r--r--fs/xfs/libxfs/xfs_btree.c (renamed from fs/xfs/xfs_btree.c)14
-rw-r--r--fs/xfs/libxfs/xfs_btree.h (renamed from fs/xfs/xfs_btree.h)0
-rw-r--r--fs/xfs/libxfs/xfs_cksum.h (renamed from fs/xfs/xfs_cksum.h)0
-rw-r--r--fs/xfs/libxfs/xfs_da_btree.c (renamed from fs/xfs/xfs_da_btree.c)110
-rw-r--r--fs/xfs/libxfs/xfs_da_btree.h (renamed from fs/xfs/xfs_da_btree.h)0
-rw-r--r--fs/xfs/libxfs/xfs_da_format.c (renamed from fs/xfs/xfs_da_format.c)0
-rw-r--r--fs/xfs/libxfs/xfs_da_format.h (renamed from fs/xfs/xfs_da_format.h)0
-rw-r--r--fs/xfs/libxfs/xfs_dinode.h (renamed from fs/xfs/xfs_dinode.h)0
-rw-r--r--fs/xfs/libxfs/xfs_dir2.c (renamed from fs/xfs/xfs_dir2.c)24
-rw-r--r--fs/xfs/libxfs/xfs_dir2.h (renamed from fs/xfs/xfs_dir2.h)0
-rw-r--r--fs/xfs/libxfs/xfs_dir2_block.c (renamed from fs/xfs/xfs_dir2_block.c)18
-rw-r--r--fs/xfs/libxfs/xfs_dir2_data.c (renamed from fs/xfs/xfs_dir2_data.c)10
-rw-r--r--fs/xfs/libxfs/xfs_dir2_leaf.c (renamed from fs/xfs/xfs_dir2_leaf.c)24
-rw-r--r--fs/xfs/libxfs/xfs_dir2_node.c (renamed from fs/xfs/xfs_dir2_node.c)40
-rw-r--r--fs/xfs/libxfs/xfs_dir2_priv.h (renamed from fs/xfs/xfs_dir2_priv.h)0
-rw-r--r--fs/xfs/libxfs/xfs_dir2_sf.c (renamed from fs/xfs/xfs_dir2_sf.c)30
-rw-r--r--fs/xfs/libxfs/xfs_dquot_buf.c (renamed from fs/xfs/xfs_dquot_buf.c)6
-rw-r--r--fs/xfs/libxfs/xfs_format.h (renamed from fs/xfs/xfs_format.h)0
-rw-r--r--fs/xfs/libxfs/xfs_ialloc.c (renamed from fs/xfs/xfs_ialloc.c)34
-rw-r--r--fs/xfs/libxfs/xfs_ialloc.h (renamed from fs/xfs/xfs_ialloc.h)0
-rw-r--r--fs/xfs/libxfs/xfs_ialloc_btree.c (renamed from fs/xfs/xfs_ialloc_btree.c)6
-rw-r--r--fs/xfs/libxfs/xfs_ialloc_btree.h (renamed from fs/xfs/xfs_ialloc_btree.h)0
-rw-r--r--fs/xfs/libxfs/xfs_inode_buf.c (renamed from fs/xfs/xfs_inode_buf.c)10
-rw-r--r--fs/xfs/libxfs/xfs_inode_buf.h (renamed from fs/xfs/xfs_inode_buf.h)0
-rw-r--r--fs/xfs/libxfs/xfs_inode_fork.c (renamed from fs/xfs/xfs_inode_fork.c)32
-rw-r--r--fs/xfs/libxfs/xfs_inode_fork.h (renamed from fs/xfs/xfs_inode_fork.h)0
-rw-r--r--fs/xfs/libxfs/xfs_inum.h (renamed from fs/xfs/xfs_inum.h)0
-rw-r--r--fs/xfs/libxfs/xfs_log_format.h (renamed from fs/xfs/xfs_log_format.h)0
-rw-r--r--fs/xfs/libxfs/xfs_log_recover.h (renamed from fs/xfs/xfs_log_recover.h)0
-rw-r--r--fs/xfs/libxfs/xfs_log_rlimit.c (renamed from fs/xfs/xfs_log_rlimit.c)0
-rw-r--r--fs/xfs/libxfs/xfs_quota_defs.h (renamed from fs/xfs/xfs_quota_defs.h)0
-rw-r--r--fs/xfs/libxfs/xfs_rtbitmap.c (renamed from fs/xfs/xfs_rtbitmap.c)0
-rw-r--r--fs/xfs/libxfs/xfs_sb.c (renamed from fs/xfs/xfs_sb.c)32
-rw-r--r--fs/xfs/libxfs/xfs_sb.h (renamed from fs/xfs/xfs_sb.h)0
-rw-r--r--fs/xfs/libxfs/xfs_shared.h (renamed from fs/xfs/xfs_shared.h)0
-rw-r--r--fs/xfs/libxfs/xfs_symlink_remote.c (renamed from fs/xfs/xfs_symlink_remote.c)6
-rw-r--r--fs/xfs/libxfs/xfs_trans_resv.c (renamed from fs/xfs/xfs_trans_resv.c)0
-rw-r--r--fs/xfs/libxfs/xfs_trans_resv.h (renamed from fs/xfs/xfs_trans_resv.h)0
-rw-r--r--fs/xfs/libxfs/xfs_trans_space.h (renamed from fs/xfs/xfs_trans_space.h)0
-rw-r--r--fs/xfs/xfs_acl.c8
-rw-r--r--fs/xfs/xfs_aops.c18
-rw-r--r--fs/xfs/xfs_attr_inactive.c22
-rw-r--r--fs/xfs/xfs_attr_list.c38
-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.c18
-rw-r--r--fs/xfs/xfs_dquot.c38
-rw-r--r--fs/xfs/xfs_error.c25
-rw-r--r--fs/xfs/xfs_error.h13
-rw-r--r--fs/xfs/xfs_export.c10
-rw-r--r--fs/xfs/xfs_extfree_item.c2
-rw-r--r--fs/xfs/xfs_file.c42
-rw-r--r--fs/xfs/xfs_filestream.c4
-rw-r--r--fs/xfs/xfs_fsops.c42
-rw-r--r--fs/xfs/xfs_icache.c52
-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.c256
-rw-r--r--fs/xfs/xfs_ioctl32.c106
-rw-r--r--fs/xfs/xfs_iomap.c34
-rw-r--r--fs/xfs/xfs_iops.c68
-rw-r--r--fs/xfs/xfs_itable.c24
-rw-r--r--fs/xfs/xfs_linux.h2
-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.c191
-rw-r--r--fs/xfs/xfs_mount.c70
-rw-r--r--fs/xfs/xfs_mru_cache.c14
-rw-r--r--fs/xfs/xfs_qm.c32
-rw-r--r--fs/xfs/xfs_qm_bhv.c2
-rw-r--r--fs/xfs/xfs_qm_syscalls.c46
-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.c10
-rw-r--r--fs/xfs/xfs_trans_ail.c4
-rw-r--r--fs/xfs/xfs_trans_buf.c37
-rw-r--r--fs/xfs/xfs_trans_dquot.c4
-rw-r--r--fs/xfs/xfs_xattr.c6
102 files changed, 1180 insertions, 1212 deletions
diff --git a/fs/xfs/Makefile b/fs/xfs/Makefile
index c21f43506661..0dfa26d626f5 100644
--- a/fs/xfs/Makefile
+++ b/fs/xfs/Makefile
@@ -17,6 +17,7 @@
17# 17#
18 18
19ccflags-y += -I$(src) # needed for trace events 19ccflags-y += -I$(src) # needed for trace events
20ccflags-y += -I$(src)/libxfs
20 21
21ccflags-$(CONFIG_XFS_DEBUG) += -g 22ccflags-$(CONFIG_XFS_DEBUG) += -g
22 23
@@ -25,6 +26,39 @@ obj-$(CONFIG_XFS_FS) += xfs.o
25# this one should be compiled first, as the tracing macros can easily blow up 26# this one should be compiled first, as the tracing macros can easily blow up
26xfs-y += xfs_trace.o 27xfs-y += xfs_trace.o
27 28
29# build the libxfs code first
30xfs-y += $(addprefix libxfs/, \
31 xfs_alloc.o \
32 xfs_alloc_btree.o \
33 xfs_attr.o \
34 xfs_attr_leaf.o \
35 xfs_attr_remote.o \
36 xfs_bmap.o \
37 xfs_bmap_btree.o \
38 xfs_btree.o \
39 xfs_da_btree.o \
40 xfs_da_format.o \
41 xfs_dir2.o \
42 xfs_dir2_block.o \
43 xfs_dir2_data.o \
44 xfs_dir2_leaf.o \
45 xfs_dir2_node.o \
46 xfs_dir2_sf.o \
47 xfs_dquot_buf.o \
48 xfs_ialloc.o \
49 xfs_ialloc_btree.o \
50 xfs_inode_fork.o \
51 xfs_inode_buf.o \
52 xfs_log_rlimit.o \
53 xfs_sb.o \
54 xfs_symlink_remote.o \
55 xfs_trans_resv.o \
56 )
57# xfs_rtbitmap is shared with libxfs
58xfs-$(CONFIG_XFS_RT) += $(addprefix libxfs/, \
59 xfs_rtbitmap.o \
60 )
61
28# highlevel code 62# highlevel code
29xfs-y += xfs_aops.o \ 63xfs-y += xfs_aops.o \
30 xfs_attr_inactive.o \ 64 xfs_attr_inactive.o \
@@ -45,6 +79,7 @@ xfs-y += xfs_aops.o \
45 xfs_ioctl.o \ 79 xfs_ioctl.o \
46 xfs_iomap.o \ 80 xfs_iomap.o \
47 xfs_iops.o \ 81 xfs_iops.o \
82 xfs_inode.o \
48 xfs_itable.o \ 83 xfs_itable.o \
49 xfs_message.o \ 84 xfs_message.o \
50 xfs_mount.o \ 85 xfs_mount.o \
@@ -56,42 +91,14 @@ xfs-y += xfs_aops.o \
56 kmem.o \ 91 kmem.o \
57 uuid.o 92 uuid.o
58 93
59# code shared with libxfs
60xfs-y += xfs_alloc.o \
61 xfs_alloc_btree.o \
62 xfs_attr.o \
63 xfs_attr_leaf.o \
64 xfs_attr_remote.o \
65 xfs_bmap.o \
66 xfs_bmap_btree.o \
67 xfs_btree.o \
68 xfs_da_btree.o \
69 xfs_da_format.o \
70 xfs_dir2.o \
71 xfs_dir2_block.o \
72 xfs_dir2_data.o \
73 xfs_dir2_leaf.o \
74 xfs_dir2_node.o \
75 xfs_dir2_sf.o \
76 xfs_dquot_buf.o \
77 xfs_ialloc.o \
78 xfs_ialloc_btree.o \
79 xfs_icreate_item.o \
80 xfs_inode.o \
81 xfs_inode_fork.o \
82 xfs_inode_buf.o \
83 xfs_log_recover.o \
84 xfs_log_rlimit.o \
85 xfs_sb.o \
86 xfs_symlink_remote.o \
87 xfs_trans_resv.o
88
89# low-level transaction/log code 94# low-level transaction/log code
90xfs-y += xfs_log.o \ 95xfs-y += xfs_log.o \
91 xfs_log_cil.o \ 96 xfs_log_cil.o \
92 xfs_buf_item.o \ 97 xfs_buf_item.o \
93 xfs_extfree_item.o \ 98 xfs_extfree_item.o \
99 xfs_icreate_item.o \
94 xfs_inode_item.o \ 100 xfs_inode_item.o \
101 xfs_log_recover.o \
95 xfs_trans_ail.o \ 102 xfs_trans_ail.o \
96 xfs_trans_buf.o \ 103 xfs_trans_buf.o \
97 xfs_trans_extfree.o \ 104 xfs_trans_extfree.o \
@@ -107,8 +114,7 @@ xfs-$(CONFIG_XFS_QUOTA) += xfs_dquot.o \
107 xfs_quotaops.o 114 xfs_quotaops.o
108 115
109# xfs_rtbitmap is shared with libxfs 116# xfs_rtbitmap is shared with libxfs
110xfs-$(CONFIG_XFS_RT) += xfs_rtalloc.o \ 117xfs-$(CONFIG_XFS_RT) += xfs_rtalloc.o
111 xfs_rtbitmap.o
112 118
113xfs-$(CONFIG_XFS_POSIX_ACL) += xfs_acl.o 119xfs-$(CONFIG_XFS_POSIX_ACL) += xfs_acl.o
114xfs-$(CONFIG_PROC_FS) += xfs_stats.o 120xfs-$(CONFIG_PROC_FS) += xfs_stats.o
diff --git a/fs/xfs/xfs_ag.h b/fs/xfs/libxfs/xfs_ag.h
index 6e247a99f5db..6e247a99f5db 100644
--- a/fs/xfs/xfs_ag.h
+++ b/fs/xfs/libxfs/xfs_ag.h
diff --git a/fs/xfs/xfs_alloc.c b/fs/xfs/libxfs/xfs_alloc.c
index d43813267a80..4bffffe038a1 100644
--- a/fs/xfs/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/xfs_alloc.h b/fs/xfs/libxfs/xfs_alloc.h
index feacb061bab7..feacb061bab7 100644
--- a/fs/xfs/xfs_alloc.h
+++ b/fs/xfs/libxfs/xfs_alloc.h
diff --git a/fs/xfs/xfs_alloc_btree.c b/fs/xfs/libxfs/xfs_alloc_btree.c
index 8358f1ded94d..e0e83e24d3ef 100644
--- a/fs/xfs/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/xfs_alloc_btree.h b/fs/xfs/libxfs/xfs_alloc_btree.h
index 45e189e7e81c..45e189e7e81c 100644
--- a/fs/xfs/xfs_alloc_btree.h
+++ b/fs/xfs/libxfs/xfs_alloc_btree.h
diff --git a/fs/xfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c
index bfe36fc2cdc2..353fb425faef 100644
--- a/fs/xfs/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 = XFS_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,28 +534,28 @@ 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);
543 ASSERT(retval == 0); 543 ASSERT(retval == 0);
544 } 544 }
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(XFS_ERROR(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(XFS_ERROR(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;
559} 559}
560 560
561 561
@@ -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
@@ -642,7 +642,7 @@ xfs_attr_leaf_addname(xfs_da_args_t *args)
642 ASSERT(committed); 642 ASSERT(committed);
643 args->trans = NULL; 643 args->trans = NULL;
644 xfs_bmap_cancel(args->flist); 644 xfs_bmap_cancel(args->flist);
645 return(error); 645 return error;
646 } 646 }
647 647
648 /* 648 /*
@@ -658,13 +658,13 @@ xfs_attr_leaf_addname(xfs_da_args_t *args)
658 */ 658 */
659 error = xfs_trans_roll(&args->trans, dp); 659 error = xfs_trans_roll(&args->trans, dp);
660 if (error) 660 if (error)
661 return (error); 661 return error;
662 662
663 /* 663 /*
664 * Fob the whole rest of the problem off on the Btree code. 664 * Fob the whole rest of the problem off on the Btree code.
665 */ 665 */
666 error = xfs_attr_node_addname(args); 666 error = xfs_attr_node_addname(args);
667 return(error); 667 return error;
668 } 668 }
669 669
670 /* 670 /*
@@ -673,7 +673,7 @@ xfs_attr_leaf_addname(xfs_da_args_t *args)
673 */ 673 */
674 error = xfs_trans_roll(&args->trans, dp); 674 error = xfs_trans_roll(&args->trans, dp);
675 if (error) 675 if (error)
676 return (error); 676 return error;
677 677
678 /* 678 /*
679 * If there was an out-of-line value, allocate the blocks we 679 * If there was an out-of-line value, allocate the blocks we
@@ -684,7 +684,7 @@ xfs_attr_leaf_addname(xfs_da_args_t *args)
684 if (args->rmtblkno > 0) { 684 if (args->rmtblkno > 0) {
685 error = xfs_attr_rmtval_set(args); 685 error = xfs_attr_rmtval_set(args);
686 if (error) 686 if (error)
687 return(error); 687 return error;
688 } 688 }
689 689
690 /* 690 /*
@@ -700,7 +700,7 @@ xfs_attr_leaf_addname(xfs_da_args_t *args)
700 */ 700 */
701 error = xfs_attr3_leaf_flipflags(args); 701 error = xfs_attr3_leaf_flipflags(args);
702 if (error) 702 if (error)
703 return(error); 703 return error;
704 704
705 /* 705 /*
706 * Dismantle the "old" attribute/value pair by removing 706 * Dismantle the "old" attribute/value pair by removing
@@ -714,7 +714,7 @@ xfs_attr_leaf_addname(xfs_da_args_t *args)
714 if (args->rmtblkno) { 714 if (args->rmtblkno) {
715 error = xfs_attr_rmtval_remove(args); 715 error = xfs_attr_rmtval_remove(args);
716 if (error) 716 if (error)
717 return(error); 717 return error;
718 } 718 }
719 719
720 /* 720 /*
@@ -744,7 +744,7 @@ xfs_attr_leaf_addname(xfs_da_args_t *args)
744 ASSERT(committed); 744 ASSERT(committed);
745 args->trans = NULL; 745 args->trans = NULL;
746 xfs_bmap_cancel(args->flist); 746 xfs_bmap_cancel(args->flist);
747 return(error); 747 return error;
748 } 748 }
749 749
750 /* 750 /*
@@ -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
@@ -1031,7 +1031,7 @@ restart:
1031 if (args->rmtblkno > 0) { 1031 if (args->rmtblkno > 0) {
1032 error = xfs_attr_rmtval_set(args); 1032 error = xfs_attr_rmtval_set(args);
1033 if (error) 1033 if (error)
1034 return(error); 1034 return error;
1035 } 1035 }
1036 1036
1037 /* 1037 /*
@@ -1061,7 +1061,7 @@ restart:
1061 if (args->rmtblkno) { 1061 if (args->rmtblkno) {
1062 error = xfs_attr_rmtval_remove(args); 1062 error = xfs_attr_rmtval_remove(args);
1063 if (error) 1063 if (error)
1064 return(error); 1064 return error;
1065 } 1065 }
1066 1066
1067 /* 1067 /*
@@ -1134,8 +1134,8 @@ out:
1134 if (state) 1134 if (state)
1135 xfs_da_state_free(state); 1135 xfs_da_state_free(state);
1136 if (error) 1136 if (error)
1137 return(error); 1137 return error;
1138 return(retval); 1138 return retval;
1139} 1139}
1140 1140
1141/* 1141/*
@@ -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;
@@ -1297,7 +1297,7 @@ xfs_attr_node_removename(xfs_da_args_t *args)
1297 1297
1298out: 1298out:
1299 xfs_da_state_free(state); 1299 xfs_da_state_free(state);
1300 return(error); 1300 return error;
1301} 1301}
1302 1302
1303/* 1303/*
@@ -1345,7 +1345,7 @@ xfs_attr_fillstate(xfs_da_state_t *state)
1345 } 1345 }
1346 } 1346 }
1347 1347
1348 return(0); 1348 return 0;
1349} 1349}
1350 1350
1351/* 1351/*
@@ -1376,7 +1376,7 @@ xfs_attr_refillstate(xfs_da_state_t *state)
1376 blk->blkno, blk->disk_blkno, 1376 blk->blkno, blk->disk_blkno,
1377 &blk->bp, XFS_ATTR_FORK); 1377 &blk->bp, XFS_ATTR_FORK);
1378 if (error) 1378 if (error)
1379 return(error); 1379 return error;
1380 } else { 1380 } else {
1381 blk->bp = NULL; 1381 blk->bp = NULL;
1382 } 1382 }
@@ -1395,13 +1395,13 @@ xfs_attr_refillstate(xfs_da_state_t *state)
1395 blk->blkno, blk->disk_blkno, 1395 blk->blkno, blk->disk_blkno,
1396 &blk->bp, XFS_ATTR_FORK); 1396 &blk->bp, XFS_ATTR_FORK);
1397 if (error) 1397 if (error)
1398 return(error); 1398 return error;
1399 } else { 1399 } else {
1400 blk->bp = NULL; 1400 blk->bp = NULL;
1401 } 1401 }
1402 } 1402 }
1403 1403
1404 return(0); 1404 return 0;
1405} 1405}
1406 1406
1407/* 1407/*
@@ -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);
@@ -1455,5 +1455,5 @@ xfs_attr_node_get(xfs_da_args_t *args)
1455 } 1455 }
1456 1456
1457 xfs_da_state_free(state); 1457 xfs_da_state_free(state);
1458 return(retval); 1458 return retval;
1459} 1459}
diff --git a/fs/xfs/xfs_attr_leaf.c b/fs/xfs/libxfs/xfs_attr_leaf.c
index 28712d29e43c..b1f73dbbf3d8 100644
--- a/fs/xfs/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(XFS_ERROR(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
@@ -582,7 +582,7 @@ xfs_attr_shortform_remove(xfs_da_args_t *args)
582 582
583 xfs_sbversion_add_attr2(mp, args->trans); 583 xfs_sbversion_add_attr2(mp, args->trans);
584 584
585 return(0); 585 return 0;
586} 586}
587 587
588/* 588/*
@@ -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(XFS_ERROR(EEXIST)); 614 return -EEXIST;
615 } 615 }
616 return(XFS_ERROR(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(XFS_ERROR(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(XFS_ERROR(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(XFS_ERROR(EEXIST)); 652 return -EEXIST;
653 } 653 }
654 return(XFS_ERROR(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);
@@ -741,7 +741,7 @@ xfs_attr_shortform_to_leaf(xfs_da_args_t *args)
741 741
742out: 742out:
743 kmem_free(tmpbuffer); 743 kmem_free(tmpbuffer);
744 return(error); 744 return error;
745} 745}
746 746
747/* 747/*
@@ -769,12 +769,12 @@ xfs_attr_shortform_allfit(
769 if (entry->flags & XFS_ATTR_INCOMPLETE) 769 if (entry->flags & XFS_ATTR_INCOMPLETE)
770 continue; /* don't copy partial entries */ 770 continue; /* don't copy partial entries */
771 if (!(entry->flags & XFS_ATTR_LOCAL)) 771 if (!(entry->flags & XFS_ATTR_LOCAL))
772 return(0); 772 return 0;
773 name_loc = xfs_attr3_leaf_name_local(leaf, i); 773 name_loc = xfs_attr3_leaf_name_local(leaf, i);
774 if (name_loc->namelen >= XFS_ATTR_SF_ENTSIZE_MAX) 774 if (name_loc->namelen >= XFS_ATTR_SF_ENTSIZE_MAX)
775 return(0); 775 return 0;
776 if (be16_to_cpu(name_loc->valuelen) >= XFS_ATTR_SF_ENTSIZE_MAX) 776 if (be16_to_cpu(name_loc->valuelen) >= XFS_ATTR_SF_ENTSIZE_MAX)
777 return(0); 777 return 0;
778 bytes += sizeof(struct xfs_attr_sf_entry) - 1 778 bytes += sizeof(struct xfs_attr_sf_entry) - 1
779 + name_loc->namelen 779 + name_loc->namelen
780 + be16_to_cpu(name_loc->valuelen); 780 + be16_to_cpu(name_loc->valuelen);
@@ -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
@@ -1017,10 +1017,10 @@ xfs_attr3_leaf_split(
1017 ASSERT(oldblk->magic == XFS_ATTR_LEAF_MAGIC); 1017 ASSERT(oldblk->magic == XFS_ATTR_LEAF_MAGIC);
1018 error = xfs_da_grow_inode(state->args, &blkno); 1018 error = xfs_da_grow_inode(state->args, &blkno);
1019 if (error) 1019 if (error)
1020 return(error); 1020 return error;
1021 error = xfs_attr3_leaf_create(state->args, blkno, &newblk->bp); 1021 error = xfs_attr3_leaf_create(state->args, blkno, &newblk->bp);
1022 if (error) 1022 if (error)
1023 return(error); 1023 return error;
1024 newblk->blkno = blkno; 1024 newblk->blkno = blkno;
1025 newblk->magic = XFS_ATTR_LEAF_MAGIC; 1025 newblk->magic = XFS_ATTR_LEAF_MAGIC;
1026 1026
@@ -1031,7 +1031,7 @@ xfs_attr3_leaf_split(
1031 xfs_attr3_leaf_rebalance(state, oldblk, newblk); 1031 xfs_attr3_leaf_rebalance(state, oldblk, newblk);
1032 error = xfs_da3_blk_link(state, oldblk, newblk); 1032 error = xfs_da3_blk_link(state, oldblk, newblk);
1033 if (error) 1033 if (error)
1034 return(error); 1034 return error;
1035 1035
1036 /* 1036 /*
1037 * Save info on "old" attribute for "atomic rename" ops, leaf_add() 1037 * Save info on "old" attribute for "atomic rename" ops, leaf_add()
@@ -1053,7 +1053,7 @@ xfs_attr3_leaf_split(
1053 */ 1053 */
1054 oldblk->hashval = xfs_attr_leaf_lasthash(oldblk->bp, NULL); 1054 oldblk->hashval = xfs_attr_leaf_lasthash(oldblk->bp, NULL);
1055 newblk->hashval = xfs_attr_leaf_lasthash(newblk->bp, NULL); 1055 newblk->hashval = xfs_attr_leaf_lasthash(newblk->bp, NULL);
1056 return(error); 1056 return error;
1057} 1057}
1058 1058
1059/* 1059/*
@@ -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 XFS_ERROR(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
@@ -1692,7 +1692,7 @@ xfs_attr3_leaf_toosmall(
1692 ichdr.usedbytes; 1692 ichdr.usedbytes;
1693 if (bytes > (state->args->geo->blksize >> 1)) { 1693 if (bytes > (state->args->geo->blksize >> 1)) {
1694 *action = 0; /* blk over 50%, don't try to join */ 1694 *action = 0; /* blk over 50%, don't try to join */
1695 return(0); 1695 return 0;
1696 } 1696 }
1697 1697
1698 /* 1698 /*
@@ -1711,7 +1711,7 @@ xfs_attr3_leaf_toosmall(
1711 error = xfs_da3_path_shift(state, &state->altpath, forward, 1711 error = xfs_da3_path_shift(state, &state->altpath, forward,
1712 0, &retval); 1712 0, &retval);
1713 if (error) 1713 if (error)
1714 return(error); 1714 return error;
1715 if (retval) { 1715 if (retval) {
1716 *action = 0; 1716 *action = 0;
1717 } else { 1717 } else {
@@ -1740,7 +1740,7 @@ xfs_attr3_leaf_toosmall(
1740 error = xfs_attr3_leaf_read(state->args->trans, state->args->dp, 1740 error = xfs_attr3_leaf_read(state->args->trans, state->args->dp,
1741 blkno, -1, &bp); 1741 blkno, -1, &bp);
1742 if (error) 1742 if (error)
1743 return(error); 1743 return error;
1744 1744
1745 xfs_attr3_leaf_hdr_from_disk(&ichdr2, bp->b_addr); 1745 xfs_attr3_leaf_hdr_from_disk(&ichdr2, bp->b_addr);
1746 1746
@@ -1757,7 +1757,7 @@ xfs_attr3_leaf_toosmall(
1757 } 1757 }
1758 if (i >= 2) { 1758 if (i >= 2) {
1759 *action = 0; 1759 *action = 0;
1760 return(0); 1760 return 0;
1761 } 1761 }
1762 1762
1763 /* 1763 /*
@@ -1773,13 +1773,13 @@ xfs_attr3_leaf_toosmall(
1773 0, &retval); 1773 0, &retval);
1774 } 1774 }
1775 if (error) 1775 if (error)
1776 return(error); 1776 return error;
1777 if (retval) { 1777 if (retval) {
1778 *action = 0; 1778 *action = 0;
1779 } else { 1779 } else {
1780 *action = 1; 1780 *action = 1;
1781 } 1781 }
1782 return(0); 1782 return 0;
1783} 1783}
1784 1784
1785/* 1785/*
@@ -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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(EEXIST); 2171 return -EEXIST;
2172 } 2172 }
2173 } 2173 }
2174 args->index = probe; 2174 args->index = probe;
2175 return XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(ERANGE); 2229 return -ERANGE;
2230 } 2230 }
2231 args->valuelen = args->rmtvaluelen; 2231 args->valuelen = args->rmtvaluelen;
2232 } 2232 }
@@ -2481,7 +2481,7 @@ xfs_attr3_leaf_clearflag(
2481 */ 2481 */
2482 error = xfs_attr3_leaf_read(args->trans, args->dp, args->blkno, -1, &bp); 2482 error = xfs_attr3_leaf_read(args->trans, args->dp, args->blkno, -1, &bp);
2483 if (error) 2483 if (error)
2484 return(error); 2484 return error;
2485 2485
2486 leaf = bp->b_addr; 2486 leaf = bp->b_addr;
2487 entry = &xfs_attr3_leaf_entryp(leaf)[args->index]; 2487 entry = &xfs_attr3_leaf_entryp(leaf)[args->index];
@@ -2548,7 +2548,7 @@ xfs_attr3_leaf_setflag(
2548 */ 2548 */
2549 error = xfs_attr3_leaf_read(args->trans, args->dp, args->blkno, -1, &bp); 2549 error = xfs_attr3_leaf_read(args->trans, args->dp, args->blkno, -1, &bp);
2550 if (error) 2550 if (error)
2551 return(error); 2551 return error;
2552 2552
2553 leaf = bp->b_addr; 2553 leaf = bp->b_addr;
2554#ifdef DEBUG 2554#ifdef DEBUG
diff --git a/fs/xfs/xfs_attr_leaf.h b/fs/xfs/libxfs/xfs_attr_leaf.h
index e2929da7c3ba..e2929da7c3ba 100644
--- a/fs/xfs/xfs_attr_leaf.h
+++ b/fs/xfs/libxfs/xfs_attr_leaf.h
diff --git a/fs/xfs/xfs_attr_remote.c b/fs/xfs/libxfs/xfs_attr_remote.c
index b5adfecbb8ee..7510ab8058a4 100644
--- a/fs/xfs/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 }
@@ -452,7 +452,7 @@ xfs_attr_rmtval_set(
452 ASSERT(committed); 452 ASSERT(committed);
453 args->trans = NULL; 453 args->trans = NULL;
454 xfs_bmap_cancel(args->flist); 454 xfs_bmap_cancel(args->flist);
455 return(error); 455 return error;
456 } 456 }
457 457
458 /* 458 /*
@@ -473,7 +473,7 @@ xfs_attr_rmtval_set(
473 */ 473 */
474 error = xfs_trans_roll(&args->trans, dp); 474 error = xfs_trans_roll(&args->trans, dp);
475 if (error) 475 if (error)
476 return (error); 476 return error;
477 } 477 }
478 478
479 /* 479 /*
@@ -498,7 +498,7 @@ xfs_attr_rmtval_set(
498 blkcnt, &map, &nmap, 498 blkcnt, &map, &nmap,
499 XFS_BMAPI_ATTRFORK); 499 XFS_BMAPI_ATTRFORK);
500 if (error) 500 if (error)
501 return(error); 501 return error;
502 ASSERT(nmap == 1); 502 ASSERT(nmap == 1);
503 ASSERT((map.br_startblock != DELAYSTARTBLOCK) && 503 ASSERT((map.br_startblock != DELAYSTARTBLOCK) &&
504 (map.br_startblock != HOLESTARTBLOCK)); 504 (map.br_startblock != HOLESTARTBLOCK));
@@ -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,
@@ -563,7 +563,7 @@ xfs_attr_rmtval_remove(
563 error = xfs_bmapi_read(args->dp, (xfs_fileoff_t)lblkno, 563 error = xfs_bmapi_read(args->dp, (xfs_fileoff_t)lblkno,
564 blkcnt, &map, &nmap, XFS_BMAPI_ATTRFORK); 564 blkcnt, &map, &nmap, XFS_BMAPI_ATTRFORK);
565 if (error) 565 if (error)
566 return(error); 566 return error;
567 ASSERT(nmap == 1); 567 ASSERT(nmap == 1);
568 ASSERT((map.br_startblock != DELAYSTARTBLOCK) && 568 ASSERT((map.br_startblock != DELAYSTARTBLOCK) &&
569 (map.br_startblock != HOLESTARTBLOCK)); 569 (map.br_startblock != HOLESTARTBLOCK));
@@ -622,7 +622,7 @@ xfs_attr_rmtval_remove(
622 */ 622 */
623 error = xfs_trans_roll(&args->trans, args->dp); 623 error = xfs_trans_roll(&args->trans, args->dp);
624 if (error) 624 if (error)
625 return (error); 625 return error;
626 } 626 }
627 return(0); 627 return 0;
628} 628}
diff --git a/fs/xfs/xfs_attr_remote.h b/fs/xfs/libxfs/xfs_attr_remote.h
index 5a9acfa156d7..5a9acfa156d7 100644
--- a/fs/xfs/xfs_attr_remote.h
+++ b/fs/xfs/libxfs/xfs_attr_remote.h
diff --git a/fs/xfs/xfs_attr_sf.h b/fs/xfs/libxfs/xfs_attr_sf.h
index 919756e3ba53..919756e3ba53 100644
--- a/fs/xfs/xfs_attr_sf.h
+++ b/fs/xfs/libxfs/xfs_attr_sf.h
diff --git a/fs/xfs/xfs_bit.h b/fs/xfs/libxfs/xfs_bit.h
index e1649c0d3e02..e1649c0d3e02 100644
--- a/fs/xfs/xfs_bit.h
+++ b/fs/xfs/libxfs/xfs_bit.h
diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
index 75c3fe5f3d9d..94ac88306fa6 100644
--- a/fs/xfs/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 XFS_ERROR(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 = XFS_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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(EFSCORRUPTED); 4054 return -EFSCORRUPTED;
4055 } 4055 }
4056 4056
4057 if (XFS_FORCED_SHUTDOWN(mp)) 4057 if (XFS_FORCED_SHUTDOWN(mp))
4058 return XFS_ERROR(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 XFS_ERROR(EFSCORRUPTED); 4249 return -EFSCORRUPTED;
4250 } 4250 }
4251 4251
4252 if (XFS_FORCED_SHUTDOWN(mp)) 4252 if (XFS_FORCED_SHUTDOWN(mp))
4253 return XFS_ERROR(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 XFS_ERROR(EFSCORRUPTED); 4543 return -EFSCORRUPTED;
4544 } 4544 }
4545 4545
4546 if (XFS_FORCED_SHUTDOWN(mp)) 4546 if (XFS_FORCED_SHUTDOWN(mp))
4547 return XFS_ERROR(EIO); 4547 return -EIO;
4548 4548
4549 ifp = XFS_IFORK_PTR(ip, whichfork); 4549 ifp = XFS_IFORK_PTR(ip, whichfork);
4550 4550
@@ -4620,7 +4620,7 @@ xfs_bmapi_write(
4620 4620
4621 /* Execute unwritten extent conversion if necessary */ 4621 /* Execute unwritten extent conversion if necessary */
4622 error = xfs_bmapi_convert_unwritten(&bma, mval, len, flags); 4622 error = xfs_bmapi_convert_unwritten(&bma, mval, len, flags);
4623 if (error == EAGAIN) 4623 if (error == -EAGAIN)
4624 continue; 4624 continue;
4625 if (error) 4625 if (error)
4626 goto error0; 4626 goto error0;
@@ -4922,7 +4922,7 @@ xfs_bmap_del_extent(
4922 goto done; 4922 goto done;
4923 cur->bc_rec.b = new; 4923 cur->bc_rec.b = new;
4924 error = xfs_btree_insert(cur, &i); 4924 error = xfs_btree_insert(cur, &i);
4925 if (error && error != ENOSPC) 4925 if (error && error != -ENOSPC)
4926 goto done; 4926 goto done;
4927 /* 4927 /*
4928 * If get no-space back from btree insert, 4928 * If get no-space back from btree insert,
@@ -4930,7 +4930,7 @@ xfs_bmap_del_extent(
4930 * block reservation. 4930 * block reservation.
4931 * Fix up our state and return the error. 4931 * Fix up our state and return the error.
4932 */ 4932 */
4933 if (error == ENOSPC) { 4933 if (error == -ENOSPC) {
4934 /* 4934 /*
4935 * Reset the cursor, don't trust 4935 * Reset the cursor, don't trust
4936 * it after any insert operation. 4936 * it after any insert operation.
@@ -4958,7 +4958,7 @@ xfs_bmap_del_extent(
4958 xfs_bmbt_set_blockcount(ep, 4958 xfs_bmbt_set_blockcount(ep,
4959 got.br_blockcount); 4959 got.br_blockcount);
4960 flags = 0; 4960 flags = 0;
4961 error = XFS_ERROR(ENOSPC); 4961 error = -ENOSPC;
4962 goto done; 4962 goto done;
4963 } 4963 }
4964 XFS_WANT_CORRUPTED_GOTO(i == 1, done); 4964 XFS_WANT_CORRUPTED_GOTO(i == 1, done);
@@ -5076,11 +5076,11 @@ xfs_bunmapi(
5076 XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_BTREE)) { 5076 XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_BTREE)) {
5077 XFS_ERROR_REPORT("xfs_bunmapi", XFS_ERRLEVEL_LOW, 5077 XFS_ERROR_REPORT("xfs_bunmapi", XFS_ERRLEVEL_LOW,
5078 ip->i_mount); 5078 ip->i_mount);
5079 return XFS_ERROR(EFSCORRUPTED); 5079 return -EFSCORRUPTED;
5080 } 5080 }
5081 mp = ip->i_mount; 5081 mp = ip->i_mount;
5082 if (XFS_FORCED_SHUTDOWN(mp)) 5082 if (XFS_FORCED_SHUTDOWN(mp))
5083 return XFS_ERROR(EIO); 5083 return -EIO;
5084 5084
5085 ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); 5085 ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL));
5086 ASSERT(len > 0); 5086 ASSERT(len > 0);
@@ -5325,7 +5325,7 @@ xfs_bunmapi(
5325 del.br_startoff > got.br_startoff && 5325 del.br_startoff > got.br_startoff &&
5326 del.br_startoff + del.br_blockcount < 5326 del.br_startoff + del.br_blockcount <
5327 got.br_startoff + got.br_blockcount) { 5327 got.br_startoff + got.br_blockcount) {
5328 error = XFS_ERROR(ENOSPC); 5328 error = -ENOSPC;
5329 goto error0; 5329 goto error0;
5330 } 5330 }
5331 error = xfs_bmap_del_extent(ip, tp, &lastx, flist, cur, &del, 5331 error = xfs_bmap_del_extent(ip, tp, &lastx, flist, cur, &del,
@@ -5449,11 +5449,11 @@ xfs_bmap_shift_extents(
5449 mp, XFS_ERRTAG_BMAPIFORMAT, XFS_RANDOM_BMAPIFORMAT))) { 5449 mp, XFS_ERRTAG_BMAPIFORMAT, XFS_RANDOM_BMAPIFORMAT))) {
5450 XFS_ERROR_REPORT("xfs_bmap_shift_extents", 5450 XFS_ERROR_REPORT("xfs_bmap_shift_extents",
5451 XFS_ERRLEVEL_LOW, mp); 5451 XFS_ERRLEVEL_LOW, mp);
5452 return XFS_ERROR(EFSCORRUPTED); 5452 return -EFSCORRUPTED;
5453 } 5453 }
5454 5454
5455 if (XFS_FORCED_SHUTDOWN(mp)) 5455 if (XFS_FORCED_SHUTDOWN(mp))
5456 return XFS_ERROR(EIO); 5456 return -EIO;
5457 5457
5458 ASSERT(current_ext != NULL); 5458 ASSERT(current_ext != NULL);
5459 5459
@@ -5516,14 +5516,14 @@ xfs_bmap_shift_extents(
5516 *current_ext - 1), &left); 5516 *current_ext - 1), &left);
5517 5517
5518 if (startoff < left.br_startoff + left.br_blockcount) 5518 if (startoff < left.br_startoff + left.br_blockcount)
5519 error = XFS_ERROR(EINVAL); 5519 error = -EINVAL;
5520 } else if (offset_shift_fsb > got.br_startoff) { 5520 } else if (offset_shift_fsb > got.br_startoff) {
5521 /* 5521 /*
5522 * When first extent is shifted, offset_shift_fsb 5522 * When first extent is shifted, offset_shift_fsb
5523 * should be less than the stating offset of 5523 * should be less than the stating offset of
5524 * the first extent. 5524 * the first extent.
5525 */ 5525 */
5526 error = XFS_ERROR(EINVAL); 5526 error = -EINVAL;
5527 } 5527 }
5528 5528
5529 if (error) 5529 if (error)
diff --git a/fs/xfs/xfs_bmap.h b/fs/xfs/libxfs/xfs_bmap.h
index b879ca56a64c..b879ca56a64c 100644
--- a/fs/xfs/xfs_bmap.h
+++ b/fs/xfs/libxfs/xfs_bmap.h
diff --git a/fs/xfs/xfs_bmap_btree.c b/fs/xfs/libxfs/xfs_bmap_btree.c
index 948836c4fd90..a388de4ceaa1 100644
--- a/fs/xfs/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 = XFS_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/xfs_bmap_btree.h b/fs/xfs/libxfs/xfs_bmap_btree.h
index 819a8a4dee95..819a8a4dee95 100644
--- a/fs/xfs/xfs_bmap_btree.h
+++ b/fs/xfs/libxfs/xfs_bmap_btree.h
diff --git a/fs/xfs/xfs_btree.c b/fs/xfs/libxfs/xfs_btree.c
index cf893bc1e373..ba35c9ccb8f9 100644
--- a/fs/xfs/xfs_btree.c
+++ b/fs/xfs/libxfs/xfs_btree.c
@@ -92,7 +92,7 @@ xfs_btree_check_lblock(
92 if (bp) 92 if (bp)
93 trace_xfs_btree_corrupt(bp, _RET_IP_); 93 trace_xfs_btree_corrupt(bp, _RET_IP_);
94 XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_LOW, mp); 94 XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_LOW, mp);
95 return XFS_ERROR(EFSCORRUPTED); 95 return -EFSCORRUPTED;
96 } 96 }
97 return 0; 97 return 0;
98} 98}
@@ -140,7 +140,7 @@ xfs_btree_check_sblock(
140 if (bp) 140 if (bp)
141 trace_xfs_btree_corrupt(bp, _RET_IP_); 141 trace_xfs_btree_corrupt(bp, _RET_IP_);
142 XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_LOW, mp); 142 XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_LOW, mp);
143 return XFS_ERROR(EFSCORRUPTED); 143 return -EFSCORRUPTED;
144 } 144 }
145 return 0; 145 return 0;
146} 146}
@@ -1140,7 +1140,7 @@ xfs_btree_get_buf_block(
1140 mp->m_bsize, flags); 1140 mp->m_bsize, flags);
1141 1141
1142 if (!*bpp) 1142 if (!*bpp)
1143 return ENOMEM; 1143 return -ENOMEM;
1144 1144
1145 (*bpp)->b_ops = cur->bc_ops->buf_ops; 1145 (*bpp)->b_ops = cur->bc_ops->buf_ops;
1146 *block = XFS_BUF_TO_BLOCK(*bpp); 1146 *block = XFS_BUF_TO_BLOCK(*bpp);
@@ -1498,7 +1498,7 @@ xfs_btree_increment(
1498 if (cur->bc_flags & XFS_BTREE_ROOT_IN_INODE) 1498 if (cur->bc_flags & XFS_BTREE_ROOT_IN_INODE)
1499 goto out0; 1499 goto out0;
1500 ASSERT(0); 1500 ASSERT(0);
1501 error = EFSCORRUPTED; 1501 error = -EFSCORRUPTED;
1502 goto error0; 1502 goto error0;
1503 } 1503 }
1504 ASSERT(lev < cur->bc_nlevels); 1504 ASSERT(lev < cur->bc_nlevels);
@@ -1597,7 +1597,7 @@ xfs_btree_decrement(
1597 if (cur->bc_flags & XFS_BTREE_ROOT_IN_INODE) 1597 if (cur->bc_flags & XFS_BTREE_ROOT_IN_INODE)
1598 goto out0; 1598 goto out0;
1599 ASSERT(0); 1599 ASSERT(0);
1600 error = EFSCORRUPTED; 1600 error = -EFSCORRUPTED;
1601 goto error0; 1601 goto error0;
1602 } 1602 }
1603 ASSERT(lev < cur->bc_nlevels); 1603 ASSERT(lev < cur->bc_nlevels);
@@ -4018,7 +4018,7 @@ xfs_btree_block_change_owner(
4018 /* now read rh sibling block for next iteration */ 4018 /* now read rh sibling block for next iteration */
4019 xfs_btree_get_sibling(cur, block, &rptr, XFS_BB_RIGHTSIB); 4019 xfs_btree_get_sibling(cur, block, &rptr, XFS_BB_RIGHTSIB);
4020 if (xfs_btree_ptr_is_null(cur, &rptr)) 4020 if (xfs_btree_ptr_is_null(cur, &rptr))
4021 return ENOENT; 4021 return -ENOENT;
4022 4022
4023 return xfs_btree_lookup_get_block(cur, level, &rptr, &block); 4023 return xfs_btree_lookup_get_block(cur, level, &rptr, &block);
4024} 4024}
@@ -4061,7 +4061,7 @@ xfs_btree_change_owner(
4061 buffer_list); 4061 buffer_list);
4062 } while (!error); 4062 } while (!error);
4063 4063
4064 if (error != ENOENT) 4064 if (error != -ENOENT)
4065 return error; 4065 return error;
4066 } 4066 }
4067 4067
diff --git a/fs/xfs/xfs_btree.h b/fs/xfs/libxfs/xfs_btree.h
index a04b69422f67..a04b69422f67 100644
--- a/fs/xfs/xfs_btree.h
+++ b/fs/xfs/libxfs/xfs_btree.h
diff --git a/fs/xfs/xfs_cksum.h b/fs/xfs/libxfs/xfs_cksum.h
index fad1676ad8cd..fad1676ad8cd 100644
--- a/fs/xfs/xfs_cksum.h
+++ b/fs/xfs/libxfs/xfs_cksum.h
diff --git a/fs/xfs/xfs_da_btree.c b/fs/xfs/libxfs/xfs_da_btree.c
index a514ab616650..8d809873525b 100644
--- a/fs/xfs/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;
@@ -315,7 +315,7 @@ xfs_da3_node_create(
315 315
316 error = xfs_da_get_buf(tp, dp, blkno, -1, &bp, whichfork); 316 error = xfs_da_get_buf(tp, dp, blkno, -1, &bp, whichfork);
317 if (error) 317 if (error)
318 return(error); 318 return error;
319 bp->b_ops = &xfs_da3_node_buf_ops; 319 bp->b_ops = &xfs_da3_node_buf_ops;
320 xfs_trans_buf_set_type(tp, bp, XFS_BLFT_DA_NODE_BUF); 320 xfs_trans_buf_set_type(tp, bp, XFS_BLFT_DA_NODE_BUF);
321 node = bp->b_addr; 321 node = bp->b_addr;
@@ -337,7 +337,7 @@ xfs_da3_node_create(
337 XFS_DA_LOGRANGE(node, &node->hdr, dp->d_ops->node_hdr_size)); 337 XFS_DA_LOGRANGE(node, &node->hdr, dp->d_ops->node_hdr_size));
338 338
339 *bpp = bp; 339 *bpp = bp;
340 return(0); 340 return 0;
341} 341}
342 342
343/* 343/*
@@ -385,8 +385,8 @@ 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) {
392 addblk = newblk; 392 addblk = newblk;
@@ -408,7 +408,7 @@ xfs_da3_split(
408 &state->extrablk); 408 &state->extrablk);
409 } 409 }
410 if (error) 410 if (error)
411 return(error); /* GROT: attr inconsistent */ 411 return error; /* GROT: attr inconsistent */
412 addblk = newblk; 412 addblk = newblk;
413 break; 413 break;
414 case XFS_DIR2_LEAFN_MAGIC: 414 case XFS_DIR2_LEAFN_MAGIC:
@@ -422,7 +422,7 @@ xfs_da3_split(
422 max - i, &action); 422 max - i, &action);
423 addblk->bp = NULL; 423 addblk->bp = NULL;
424 if (error) 424 if (error)
425 return(error); /* GROT: dir is inconsistent */ 425 return error; /* GROT: dir is inconsistent */
426 /* 426 /*
427 * Record the newly split block for the next time thru? 427 * Record the newly split block for the next time thru?
428 */ 428 */
@@ -439,7 +439,7 @@ xfs_da3_split(
439 xfs_da3_fixhashpath(state, &state->path); 439 xfs_da3_fixhashpath(state, &state->path);
440 } 440 }
441 if (!addblk) 441 if (!addblk)
442 return(0); 442 return 0;
443 443
444 /* 444 /*
445 * Split the root node. 445 * Split the root node.
@@ -449,7 +449,7 @@ xfs_da3_split(
449 error = xfs_da3_root_split(state, oldblk, addblk); 449 error = xfs_da3_root_split(state, oldblk, addblk);
450 if (error) { 450 if (error) {
451 addblk->bp = NULL; 451 addblk->bp = NULL;
452 return(error); /* GROT: dir is inconsistent */ 452 return error; /* GROT: dir is inconsistent */
453 } 453 }
454 454
455 /* 455 /*
@@ -492,7 +492,7 @@ xfs_da3_split(
492 sizeof(node->hdr.info))); 492 sizeof(node->hdr.info)));
493 } 493 }
494 addblk->bp = NULL; 494 addblk->bp = NULL;
495 return(0); 495 return 0;
496} 496}
497 497
498/* 498/*
@@ -670,18 +670,18 @@ xfs_da3_node_split(
670 */ 670 */
671 error = xfs_da_grow_inode(state->args, &blkno); 671 error = xfs_da_grow_inode(state->args, &blkno);
672 if (error) 672 if (error)
673 return(error); /* GROT: dir is inconsistent */ 673 return error; /* GROT: dir is inconsistent */
674 674
675 error = xfs_da3_node_create(state->args, blkno, treelevel, 675 error = xfs_da3_node_create(state->args, blkno, treelevel,
676 &newblk->bp, state->args->whichfork); 676 &newblk->bp, state->args->whichfork);
677 if (error) 677 if (error)
678 return(error); /* GROT: dir is inconsistent */ 678 return error; /* GROT: dir is inconsistent */
679 newblk->blkno = blkno; 679 newblk->blkno = blkno;
680 newblk->magic = XFS_DA_NODE_MAGIC; 680 newblk->magic = XFS_DA_NODE_MAGIC;
681 xfs_da3_node_rebalance(state, oldblk, newblk); 681 xfs_da3_node_rebalance(state, oldblk, newblk);
682 error = xfs_da3_blk_link(state, oldblk, newblk); 682 error = xfs_da3_blk_link(state, oldblk, newblk);
683 if (error) 683 if (error)
684 return(error); 684 return error;
685 *result = 1; 685 *result = 1;
686 } else { 686 } else {
687 *result = 0; 687 *result = 0;
@@ -721,7 +721,7 @@ xfs_da3_node_split(
721 } 721 }
722 } 722 }
723 723
724 return(0); 724 return 0;
725} 725}
726 726
727/* 727/*
@@ -963,9 +963,9 @@ xfs_da3_join(
963 case XFS_ATTR_LEAF_MAGIC: 963 case XFS_ATTR_LEAF_MAGIC:
964 error = xfs_attr3_leaf_toosmall(state, &action); 964 error = xfs_attr3_leaf_toosmall(state, &action);
965 if (error) 965 if (error)
966 return(error); 966 return error;
967 if (action == 0) 967 if (action == 0)
968 return(0); 968 return 0;
969 xfs_attr3_leaf_unbalance(state, drop_blk, save_blk); 969 xfs_attr3_leaf_unbalance(state, drop_blk, save_blk);
970 break; 970 break;
971 case XFS_DIR2_LEAFN_MAGIC: 971 case XFS_DIR2_LEAFN_MAGIC:
@@ -985,7 +985,7 @@ xfs_da3_join(
985 xfs_da3_fixhashpath(state, &state->path); 985 xfs_da3_fixhashpath(state, &state->path);
986 error = xfs_da3_node_toosmall(state, &action); 986 error = xfs_da3_node_toosmall(state, &action);
987 if (error) 987 if (error)
988 return(error); 988 return error;
989 if (action == 0) 989 if (action == 0)
990 return 0; 990 return 0;
991 xfs_da3_node_unbalance(state, drop_blk, save_blk); 991 xfs_da3_node_unbalance(state, drop_blk, save_blk);
@@ -995,12 +995,12 @@ xfs_da3_join(
995 error = xfs_da3_blk_unlink(state, drop_blk, save_blk); 995 error = xfs_da3_blk_unlink(state, drop_blk, save_blk);
996 xfs_da_state_kill_altpath(state); 996 xfs_da_state_kill_altpath(state);
997 if (error) 997 if (error)
998 return(error); 998 return error;
999 error = xfs_da_shrink_inode(state->args, drop_blk->blkno, 999 error = xfs_da_shrink_inode(state->args, drop_blk->blkno,
1000 drop_blk->bp); 1000 drop_blk->bp);
1001 drop_blk->bp = NULL; 1001 drop_blk->bp = NULL;
1002 if (error) 1002 if (error)
1003 return(error); 1003 return error;
1004 } 1004 }
1005 /* 1005 /*
1006 * We joined all the way to the top. If it turns out that 1006 * We joined all the way to the top. If it turns out that
@@ -1010,7 +1010,7 @@ xfs_da3_join(
1010 xfs_da3_node_remove(state, drop_blk); 1010 xfs_da3_node_remove(state, drop_blk);
1011 xfs_da3_fixhashpath(state, &state->path); 1011 xfs_da3_fixhashpath(state, &state->path);
1012 error = xfs_da3_root_join(state, &state->path.blk[0]); 1012 error = xfs_da3_root_join(state, &state->path.blk[0]);
1013 return(error); 1013 return error;
1014} 1014}
1015 1015
1016#ifdef DEBUG 1016#ifdef DEBUG
@@ -1099,7 +1099,7 @@ xfs_da3_root_join(
1099 xfs_trans_log_buf(args->trans, root_blk->bp, 0, 1099 xfs_trans_log_buf(args->trans, root_blk->bp, 0,
1100 args->geo->blksize - 1); 1100 args->geo->blksize - 1);
1101 error = xfs_da_shrink_inode(args, child, bp); 1101 error = xfs_da_shrink_inode(args, child, bp);
1102 return(error); 1102 return error;
1103} 1103}
1104 1104
1105/* 1105/*
@@ -1142,7 +1142,7 @@ xfs_da3_node_toosmall(
1142 dp->d_ops->node_hdr_from_disk(&nodehdr, node); 1142 dp->d_ops->node_hdr_from_disk(&nodehdr, node);
1143 if (nodehdr.count > (state->args->geo->node_ents >> 1)) { 1143 if (nodehdr.count > (state->args->geo->node_ents >> 1)) {
1144 *action = 0; /* blk over 50%, don't try to join */ 1144 *action = 0; /* blk over 50%, don't try to join */
1145 return(0); /* blk over 50%, don't try to join */ 1145 return 0; /* blk over 50%, don't try to join */
1146 } 1146 }
1147 1147
1148 /* 1148 /*
@@ -1161,13 +1161,13 @@ xfs_da3_node_toosmall(
1161 error = xfs_da3_path_shift(state, &state->altpath, forward, 1161 error = xfs_da3_path_shift(state, &state->altpath, forward,
1162 0, &retval); 1162 0, &retval);
1163 if (error) 1163 if (error)
1164 return(error); 1164 return error;
1165 if (retval) { 1165 if (retval) {
1166 *action = 0; 1166 *action = 0;
1167 } else { 1167 } else {
1168 *action = 2; 1168 *action = 2;
1169 } 1169 }
1170 return(0); 1170 return 0;
1171 } 1171 }
1172 1172
1173 /* 1173 /*
@@ -1194,7 +1194,7 @@ xfs_da3_node_toosmall(
1194 error = xfs_da3_node_read(state->args->trans, dp, 1194 error = xfs_da3_node_read(state->args->trans, dp,
1195 blkno, -1, &bp, state->args->whichfork); 1195 blkno, -1, &bp, state->args->whichfork);
1196 if (error) 1196 if (error)
1197 return(error); 1197 return error;
1198 1198
1199 node = bp->b_addr; 1199 node = bp->b_addr;
1200 dp->d_ops->node_hdr_from_disk(&thdr, node); 1200 dp->d_ops->node_hdr_from_disk(&thdr, node);
@@ -1486,7 +1486,7 @@ xfs_da3_node_lookup_int(
1486 if (error) { 1486 if (error) {
1487 blk->blkno = 0; 1487 blk->blkno = 0;
1488 state->path.active--; 1488 state->path.active--;
1489 return(error); 1489 return error;
1490 } 1490 }
1491 curr = blk->bp->b_addr; 1491 curr = blk->bp->b_addr;
1492 blk->magic = be16_to_cpu(curr->magic); 1492 blk->magic = be16_to_cpu(curr->magic);
@@ -1579,25 +1579,25 @@ 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 XFS_ERROR(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);
1588 if (error) 1588 if (error)
1589 return(error); 1589 return error;
1590 if (retval == 0) { 1590 if (retval == 0) {
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 = XFS_ERROR(ENOATTR); 1594 retval = -ENOATTR;
1595 } 1595 }
1596 } 1596 }
1597 break; 1597 break;
1598 } 1598 }
1599 *result = retval; 1599 *result = retval;
1600 return(0); 1600 return 0;
1601} 1601}
1602 1602
1603/*======================================================================== 1603/*========================================================================
@@ -1692,7 +1692,7 @@ xfs_da3_blk_link(
1692 be32_to_cpu(old_info->back), 1692 be32_to_cpu(old_info->back),
1693 -1, &bp, args->whichfork); 1693 -1, &bp, args->whichfork);
1694 if (error) 1694 if (error)
1695 return(error); 1695 return error;
1696 ASSERT(bp != NULL); 1696 ASSERT(bp != NULL);
1697 tmp_info = bp->b_addr; 1697 tmp_info = bp->b_addr;
1698 ASSERT(tmp_info->magic == old_info->magic); 1698 ASSERT(tmp_info->magic == old_info->magic);
@@ -1713,7 +1713,7 @@ xfs_da3_blk_link(
1713 be32_to_cpu(old_info->forw), 1713 be32_to_cpu(old_info->forw),
1714 -1, &bp, args->whichfork); 1714 -1, &bp, args->whichfork);
1715 if (error) 1715 if (error)
1716 return(error); 1716 return error;
1717 ASSERT(bp != NULL); 1717 ASSERT(bp != NULL);
1718 tmp_info = bp->b_addr; 1718 tmp_info = bp->b_addr;
1719 ASSERT(tmp_info->magic == old_info->magic); 1719 ASSERT(tmp_info->magic == old_info->magic);
@@ -1726,7 +1726,7 @@ xfs_da3_blk_link(
1726 1726
1727 xfs_trans_log_buf(args->trans, old_blk->bp, 0, sizeof(*tmp_info) - 1); 1727 xfs_trans_log_buf(args->trans, old_blk->bp, 0, sizeof(*tmp_info) - 1);
1728 xfs_trans_log_buf(args->trans, new_blk->bp, 0, sizeof(*tmp_info) - 1); 1728 xfs_trans_log_buf(args->trans, new_blk->bp, 0, sizeof(*tmp_info) - 1);
1729 return(0); 1729 return 0;
1730} 1730}
1731 1731
1732/* 1732/*
@@ -1772,7 +1772,7 @@ xfs_da3_blk_unlink(
1772 be32_to_cpu(drop_info->back), 1772 be32_to_cpu(drop_info->back),
1773 -1, &bp, args->whichfork); 1773 -1, &bp, args->whichfork);
1774 if (error) 1774 if (error)
1775 return(error); 1775 return error;
1776 ASSERT(bp != NULL); 1776 ASSERT(bp != NULL);
1777 tmp_info = bp->b_addr; 1777 tmp_info = bp->b_addr;
1778 ASSERT(tmp_info->magic == save_info->magic); 1778 ASSERT(tmp_info->magic == save_info->magic);
@@ -1789,7 +1789,7 @@ xfs_da3_blk_unlink(
1789 be32_to_cpu(drop_info->forw), 1789 be32_to_cpu(drop_info->forw),
1790 -1, &bp, args->whichfork); 1790 -1, &bp, args->whichfork);
1791 if (error) 1791 if (error)
1792 return(error); 1792 return error;
1793 ASSERT(bp != NULL); 1793 ASSERT(bp != NULL);
1794 tmp_info = bp->b_addr; 1794 tmp_info = bp->b_addr;
1795 ASSERT(tmp_info->magic == save_info->magic); 1795 ASSERT(tmp_info->magic == save_info->magic);
@@ -1801,7 +1801,7 @@ xfs_da3_blk_unlink(
1801 } 1801 }
1802 1802
1803 xfs_trans_log_buf(args->trans, save_blk->bp, 0, sizeof(*save_info) - 1); 1803 xfs_trans_log_buf(args->trans, save_blk->bp, 0, sizeof(*save_info) - 1);
1804 return(0); 1804 return 0;
1805} 1805}
1806 1806
1807/* 1807/*
@@ -1859,9 +1859,9 @@ xfs_da3_path_shift(
1859 } 1859 }
1860 } 1860 }
1861 if (level < 0) { 1861 if (level < 0) {
1862 *result = XFS_ERROR(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 }
1866 1866
1867 /* 1867 /*
@@ -1883,7 +1883,7 @@ xfs_da3_path_shift(
1883 error = xfs_da3_node_read(args->trans, dp, blkno, -1, 1883 error = xfs_da3_node_read(args->trans, dp, blkno, -1,
1884 &blk->bp, args->whichfork); 1884 &blk->bp, args->whichfork);
1885 if (error) 1885 if (error)
1886 return(error); 1886 return error;
1887 info = blk->bp->b_addr; 1887 info = blk->bp->b_addr;
1888 ASSERT(info->magic == cpu_to_be16(XFS_DA_NODE_MAGIC) || 1888 ASSERT(info->magic == cpu_to_be16(XFS_DA_NODE_MAGIC) ||
1889 info->magic == cpu_to_be16(XFS_DA3_NODE_MAGIC) || 1889 info->magic == cpu_to_be16(XFS_DA3_NODE_MAGIC) ||
@@ -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 = XFS_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 XFS_ERROR(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 = XFS_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 = XFS_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 = XFS_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 = XFS_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 = XFS_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 = XFS_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 : XFS_ERROR(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 : XFS_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/xfs_da_btree.h b/fs/xfs/libxfs/xfs_da_btree.h
index 6e153e399a77..6e153e399a77 100644
--- a/fs/xfs/xfs_da_btree.h
+++ b/fs/xfs/libxfs/xfs_da_btree.h
diff --git a/fs/xfs/xfs_da_format.c b/fs/xfs/libxfs/xfs_da_format.c
index c9aee52a37e2..c9aee52a37e2 100644
--- a/fs/xfs/xfs_da_format.c
+++ b/fs/xfs/libxfs/xfs_da_format.c
diff --git a/fs/xfs/xfs_da_format.h b/fs/xfs/libxfs/xfs_da_format.h
index 0a49b0286372..0a49b0286372 100644
--- a/fs/xfs/xfs_da_format.h
+++ b/fs/xfs/libxfs/xfs_da_format.h
diff --git a/fs/xfs/xfs_dinode.h b/fs/xfs/libxfs/xfs_dinode.h
index 623bbe8fd921..623bbe8fd921 100644
--- a/fs/xfs/xfs_dinode.h
+++ b/fs/xfs/libxfs/xfs_dinode.h
diff --git a/fs/xfs/xfs_dir2.c b/fs/xfs/libxfs/xfs_dir2.c
index 79670cda48ae..6cef22152fd6 100644
--- a/fs/xfs/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 XFS_ERROR(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/xfs_dir2.h b/fs/xfs/libxfs/xfs_dir2.h
index c8e86b0b5e99..c8e86b0b5e99 100644
--- a/fs/xfs/xfs_dir2.h
+++ b/fs/xfs/libxfs/xfs_dir2.h
diff --git a/fs/xfs/xfs_dir2_block.c b/fs/xfs/libxfs/xfs_dir2_block.c
index c7cd3154026a..9628ceccfa02 100644
--- a/fs/xfs/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 XFS_ERROR(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 XFS_ERROR(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.
@@ -647,7 +647,7 @@ xfs_dir2_block_lookup(
647 args->filetype = dp->d_ops->data_get_ftype(dep); 647 args->filetype = dp->d_ops->data_get_ftype(dep);
648 error = xfs_dir_cilookup_result(args, dep->name, dep->namelen); 648 error = xfs_dir_cilookup_result(args, dep->name, dep->namelen);
649 xfs_trans_brelse(args->trans, bp); 649 xfs_trans_brelse(args->trans, bp);
650 return XFS_ERROR(error); 650 return error;
651} 651}
652 652
653/* 653/*
@@ -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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(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/xfs_dir2_data.c b/fs/xfs/libxfs/xfs_dir2_data.c
index 8c2f6422648e..fdd803fecb8e 100644
--- a/fs/xfs/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/xfs_dir2_leaf.c b/fs/xfs/libxfs/xfs_dir2_leaf.c
index fb0aad4440c1..a19174eb3cb2 100644
--- a/fs/xfs/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 XFS_ERROR(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 ? XFS_ERROR(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 XFS_ERROR(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.
@@ -1198,7 +1198,7 @@ xfs_dir2_leaf_lookup(
1198 error = xfs_dir_cilookup_result(args, dep->name, dep->namelen); 1198 error = xfs_dir_cilookup_result(args, dep->name, dep->namelen);
1199 xfs_trans_brelse(tp, dbp); 1199 xfs_trans_brelse(tp, dbp);
1200 xfs_trans_brelse(tp, lbp); 1200 xfs_trans_brelse(tp, lbp);
1201 return XFS_ERROR(error); 1201 return error;
1202} 1202}
1203 1203
1204/* 1204/*
@@ -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 XFS_ERROR(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/xfs_dir2_node.c b/fs/xfs/libxfs/xfs_dir2_node.c
index da43d304fca2..2ae6ac2c11ae 100644
--- a/fs/xfs/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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(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/xfs_dir2_priv.h b/fs/xfs/libxfs/xfs_dir2_priv.h
index 27ce0794d196..27ce0794d196 100644
--- a/fs/xfs/xfs_dir2_priv.h
+++ b/fs/xfs/libxfs/xfs_dir2_priv.h
diff --git a/fs/xfs/xfs_dir2_sf.c b/fs/xfs/libxfs/xfs_dir2_sf.c
index 53c3be619db5..8f4f26af35e1 100644
--- a/fs/xfs/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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(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,20 +781,20 @@ 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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(error); 797 return error;
798} 798}
799 799
800/* 800/*
@@ -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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(ENOENT); 993 return -ENOENT;
994 } 994 }
995 } 995 }
996#if XFS_BIG_INUMS 996#if XFS_BIG_INUMS
diff --git a/fs/xfs/xfs_dquot_buf.c b/fs/xfs/libxfs/xfs_dquot_buf.c
index c2ac0c611ad8..bb969337efc8 100644
--- a/fs/xfs/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/xfs_format.h b/fs/xfs/libxfs/xfs_format.h
index 34d85aca3058..34d85aca3058 100644
--- a/fs/xfs/xfs_format.h
+++ b/fs/xfs/libxfs/xfs_format.h
diff --git a/fs/xfs/xfs_ialloc.c b/fs/xfs/libxfs/xfs_ialloc.c
index 5960e5593fe0..b62771f1f4b5 100644
--- a/fs/xfs/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 XFS_ERROR(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
@@ -1425,7 +1425,7 @@ out_alloc:
1425 return xfs_dialloc_ag(tp, agbp, parent, inop); 1425 return xfs_dialloc_ag(tp, agbp, parent, inop);
1426out_error: 1426out_error:
1427 xfs_perag_put(pag); 1427 xfs_perag_put(pag);
1428 return XFS_ERROR(error); 1428 return error;
1429} 1429}
1430 1430
1431STATIC int 1431STATIC int
@@ -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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(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/xfs_ialloc.h b/fs/xfs/libxfs/xfs_ialloc.h
index 95ad1c002d60..95ad1c002d60 100644
--- a/fs/xfs/xfs_ialloc.h
+++ b/fs/xfs/libxfs/xfs_ialloc.h
diff --git a/fs/xfs/xfs_ialloc_btree.c b/fs/xfs/libxfs/xfs_ialloc_btree.c
index 726f83a681a5..c9b06f30fe86 100644
--- a/fs/xfs/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/xfs_ialloc_btree.h b/fs/xfs/libxfs/xfs_ialloc_btree.h
index d7ebea72c2d0..d7ebea72c2d0 100644
--- a/fs/xfs/xfs_ialloc_btree.h
+++ b/fs/xfs/libxfs/xfs_ialloc_btree.h
diff --git a/fs/xfs/xfs_inode_buf.c b/fs/xfs/libxfs/xfs_inode_buf.c
index cb35ae41d4a1..f18fd2da49f7 100644
--- a/fs/xfs/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 XFS_ERROR(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 = XFS_ERROR(EFSCORRUPTED); 393 error = -EFSCORRUPTED;
394 goto out_brelse; 394 goto out_brelse;
395 } 395 }
396 396
diff --git a/fs/xfs/xfs_inode_buf.h b/fs/xfs/libxfs/xfs_inode_buf.h
index 9308c47f2a52..9308c47f2a52 100644
--- a/fs/xfs/xfs_inode_buf.h
+++ b/fs/xfs/libxfs/xfs_inode_buf.h
diff --git a/fs/xfs/xfs_inode_fork.c b/fs/xfs/libxfs/xfs_inode_fork.c
index b031e8d0d928..8ac9411bcf2a 100644
--- a/fs/xfs/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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(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 = XFS_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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(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);
@@ -1692,7 +1692,7 @@ xfs_iext_idx_to_irec(
1692 } 1692 }
1693 *idxp = page_idx; 1693 *idxp = page_idx;
1694 *erp_idxp = erp_idx; 1694 *erp_idxp = erp_idx;
1695 return(erp); 1695 return erp;
1696} 1696}
1697 1697
1698/* 1698/*
diff --git a/fs/xfs/xfs_inode_fork.h b/fs/xfs/libxfs/xfs_inode_fork.h
index 7d3b1ed6dcbe..7d3b1ed6dcbe 100644
--- a/fs/xfs/xfs_inode_fork.h
+++ b/fs/xfs/libxfs/xfs_inode_fork.h
diff --git a/fs/xfs/xfs_inum.h b/fs/xfs/libxfs/xfs_inum.h
index 90efdaf1706f..90efdaf1706f 100644
--- a/fs/xfs/xfs_inum.h
+++ b/fs/xfs/libxfs/xfs_inum.h
diff --git a/fs/xfs/xfs_log_format.h b/fs/xfs/libxfs/xfs_log_format.h
index f0969c77bdbe..f0969c77bdbe 100644
--- a/fs/xfs/xfs_log_format.h
+++ b/fs/xfs/libxfs/xfs_log_format.h
diff --git a/fs/xfs/xfs_log_recover.h b/fs/xfs/libxfs/xfs_log_recover.h
index 1c55ccbb379d..1c55ccbb379d 100644
--- a/fs/xfs/xfs_log_recover.h
+++ b/fs/xfs/libxfs/xfs_log_recover.h
diff --git a/fs/xfs/xfs_log_rlimit.c b/fs/xfs/libxfs/xfs_log_rlimit.c
index ee7e0e80246b..ee7e0e80246b 100644
--- a/fs/xfs/xfs_log_rlimit.c
+++ b/fs/xfs/libxfs/xfs_log_rlimit.c
diff --git a/fs/xfs/xfs_quota_defs.h b/fs/xfs/libxfs/xfs_quota_defs.h
index 137e20937077..137e20937077 100644
--- a/fs/xfs/xfs_quota_defs.h
+++ b/fs/xfs/libxfs/xfs_quota_defs.h
diff --git a/fs/xfs/xfs_rtbitmap.c b/fs/xfs/libxfs/xfs_rtbitmap.c
index f4dd697cac08..f4dd697cac08 100644
--- a/fs/xfs/xfs_rtbitmap.c
+++ b/fs/xfs/libxfs/xfs_rtbitmap.c
diff --git a/fs/xfs/xfs_sb.c b/fs/xfs/libxfs/xfs_sb.c
index 7703fa6770ff..6e93b5ef0a6b 100644
--- a/fs/xfs/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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(EFSCORRUPTED); 335 return -EFSCORRUPTED;
336 } 336 }
337 return 0; 337 return 0;
338} 338}
@@ -620,7 +620,7 @@ xfs_sb_read_verify(
620 /* Only fail bad secondaries on a known V5 filesystem */ 620 /* Only fail bad secondaries on a known V5 filesystem */
621 if (bp->b_bn == XFS_SB_DADDR || 621 if (bp->b_bn == XFS_SB_DADDR ||
622 xfs_sb_version_hascrc(&mp->m_sb)) { 622 xfs_sb_version_hascrc(&mp->m_sb)) {
623 error = EFSBADCRC; 623 error = -EFSBADCRC;
624 goto out_error; 624 goto out_error;
625 } 625 }
626 } 626 }
@@ -630,7 +630,7 @@ xfs_sb_read_verify(
630out_error: 630out_error:
631 if (error) { 631 if (error) {
632 xfs_buf_ioerror(bp, error); 632 xfs_buf_ioerror(bp, error);
633 if (error == EFSCORRUPTED || error == EFSBADCRC) 633 if (error == -EFSCORRUPTED || error == -EFSBADCRC)
634 xfs_verifier_error(bp); 634 xfs_verifier_error(bp);
635 } 635 }
636} 636}
@@ -653,7 +653,7 @@ xfs_sb_quiet_read_verify(
653 return; 653 return;
654 } 654 }
655 /* quietly fail */ 655 /* quietly fail */
656 xfs_buf_ioerror(bp, EWRONGFS); 656 xfs_buf_ioerror(bp, -EWRONGFS);
657} 657}
658 658
659static void 659static void
diff --git a/fs/xfs/xfs_sb.h b/fs/xfs/libxfs/xfs_sb.h
index c43c2d609a24..c43c2d609a24 100644
--- a/fs/xfs/xfs_sb.h
+++ b/fs/xfs/libxfs/xfs_sb.h
diff --git a/fs/xfs/xfs_shared.h b/fs/xfs/libxfs/xfs_shared.h
index 82404da2ca67..82404da2ca67 100644
--- a/fs/xfs/xfs_shared.h
+++ b/fs/xfs/libxfs/xfs_shared.h
diff --git a/fs/xfs/xfs_symlink_remote.c b/fs/xfs/libxfs/xfs_symlink_remote.c
index 23c2f2577c8d..5782f037eab4 100644
--- a/fs/xfs/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_trans_resv.c b/fs/xfs/libxfs/xfs_trans_resv.c
index f2bda7c76b8a..f2bda7c76b8a 100644
--- a/fs/xfs/xfs_trans_resv.c
+++ b/fs/xfs/libxfs/xfs_trans_resv.c
diff --git a/fs/xfs/xfs_trans_resv.h b/fs/xfs/libxfs/xfs_trans_resv.h
index 1097d14cd583..1097d14cd583 100644
--- a/fs/xfs/xfs_trans_resv.h
+++ b/fs/xfs/libxfs/xfs_trans_resv.h
diff --git a/fs/xfs/xfs_trans_space.h b/fs/xfs/libxfs/xfs_trans_space.h
index bf9c4579334d..bf9c4579334d 100644
--- a/fs/xfs/xfs_trans_space.h
+++ b/fs/xfs/libxfs/xfs_trans_space.h
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 faaf716e2080..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
@@ -308,14 +308,14 @@ xfs_map_blocks(
308 int nimaps = 1; 308 int nimaps = 1;
309 309
310 if (XFS_FORCED_SHUTDOWN(mp)) 310 if (XFS_FORCED_SHUTDOWN(mp))
311 return -XFS_ERROR(EIO); 311 return -EIO;
312 312
313 if (type == XFS_IO_UNWRITTEN) 313 if (type == XFS_IO_UNWRITTEN)
314 bmapi_flags |= XFS_BMAPI_IGSTATE; 314 bmapi_flags |= XFS_BMAPI_IGSTATE;
315 315
316 if (!xfs_ilock_nowait(ip, XFS_ILOCK_SHARED)) { 316 if (!xfs_ilock_nowait(ip, XFS_ILOCK_SHARED)) {
317 if (nonblocking) 317 if (nonblocking)
318 return -XFS_ERROR(EAGAIN); 318 return -EAGAIN;
319 xfs_ilock(ip, XFS_ILOCK_SHARED); 319 xfs_ilock(ip, XFS_ILOCK_SHARED);
320 } 320 }
321 321
@@ -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 -XFS_ERROR(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 -XFS_ERROR(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 }
@@ -1253,7 +1253,7 @@ __xfs_get_blocks(
1253 int new = 0; 1253 int new = 0;
1254 1254
1255 if (XFS_FORCED_SHUTDOWN(mp)) 1255 if (XFS_FORCED_SHUTDOWN(mp))
1256 return -XFS_ERROR(EIO); 1256 return -EIO;
1257 1257
1258 offset = (xfs_off_t)iblock << inode->i_blkbits; 1258 offset = (xfs_off_t)iblock << inode->i_blkbits;
1259 ASSERT(bh_result->b_size >= (1 << inode->i_blkbits)); 1259 ASSERT(bh_result->b_size >= (1 << inode->i_blkbits));
@@ -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 09480c57f069..aa2a8b1838a2 100644
--- a/fs/xfs/xfs_attr_inactive.c
+++ b/fs/xfs/xfs_attr_inactive.c
@@ -76,7 +76,7 @@ xfs_attr3_leaf_freextent(
76 error = xfs_bmapi_read(dp, (xfs_fileoff_t)tblkno, tblkcnt, 76 error = xfs_bmapi_read(dp, (xfs_fileoff_t)tblkno, tblkcnt,
77 &map, &nmap, XFS_BMAPI_ATTRFORK); 77 &map, &nmap, XFS_BMAPI_ATTRFORK);
78 if (error) { 78 if (error) {
79 return(error); 79 return error;
80 } 80 }
81 ASSERT(nmap == 1); 81 ASSERT(nmap == 1);
82 ASSERT(map.br_startblock != DELAYSTARTBLOCK); 82 ASSERT(map.br_startblock != DELAYSTARTBLOCK);
@@ -95,21 +95,21 @@ 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.
102 */ 102 */
103 error = xfs_trans_roll(trans, dp); 103 error = xfs_trans_roll(trans, dp);
104 if (error) 104 if (error)
105 return (error); 105 return error;
106 } 106 }
107 107
108 tblkno += map.br_blockcount; 108 tblkno += map.br_blockcount;
109 tblkcnt -= map.br_blockcount; 109 tblkcnt -= map.br_blockcount;
110 } 110 }
111 111
112 return(0); 112 return 0;
113} 113}
114 114
115/* 115/*
@@ -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 XFS_ERROR(EIO); 230 return -EIO;
231 } 231 }
232 232
233 node = bp->b_addr; 233 node = bp->b_addr;
@@ -256,7 +256,7 @@ xfs_attr3_node_inactive(
256 error = xfs_da3_node_read(*trans, dp, child_fsb, -2, &child_bp, 256 error = xfs_da3_node_read(*trans, dp, child_fsb, -2, &child_bp,
257 XFS_ATTR_FORK); 257 XFS_ATTR_FORK);
258 if (error) 258 if (error)
259 return(error); 259 return error;
260 if (child_bp) { 260 if (child_bp) {
261 /* save for re-read later */ 261 /* save for re-read later */
262 child_blkno = XFS_BUF_ADDR(child_bp); 262 child_blkno = XFS_BUF_ADDR(child_bp);
@@ -277,7 +277,7 @@ xfs_attr3_node_inactive(
277 child_bp); 277 child_bp);
278 break; 278 break;
279 default: 279 default:
280 error = XFS_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 = XFS_ERROR(EIO); 363 error = -EIO;
364 xfs_trans_brelse(*trans, bp); 364 xfs_trans_brelse(*trans, bp);
365 break; 365 break;
366 } 366 }
@@ -414,7 +414,7 @@ xfs_attr_inactive(xfs_inode_t *dp)
414 error = xfs_trans_reserve(trans, &M_RES(mp)->tr_attrinval, 0, 0); 414 error = xfs_trans_reserve(trans, &M_RES(mp)->tr_attrinval, 0, 0);
415 if (error) { 415 if (error) {
416 xfs_trans_cancel(trans, 0); 416 xfs_trans_cancel(trans, 0);
417 return(error); 417 return error;
418 } 418 }
419 xfs_ilock(dp, XFS_ILOCK_EXCL); 419 xfs_ilock(dp, XFS_ILOCK_EXCL);
420 420
@@ -443,10 +443,10 @@ xfs_attr_inactive(xfs_inode_t *dp)
443 error = xfs_trans_commit(trans, XFS_TRANS_RELEASE_LOG_RES); 443 error = xfs_trans_commit(trans, XFS_TRANS_RELEASE_LOG_RES);
444 xfs_iunlock(dp, XFS_ILOCK_EXCL); 444 xfs_iunlock(dp, XFS_ILOCK_EXCL);
445 445
446 return(error); 446 return error;
447 447
448out: 448out:
449 xfs_trans_cancel(trans, XFS_TRANS_RELEASE_LOG_RES|XFS_TRANS_ABORT); 449 xfs_trans_cancel(trans, XFS_TRANS_RELEASE_LOG_RES|XFS_TRANS_ABORT);
450 xfs_iunlock(dp, XFS_ILOCK_EXCL); 450 xfs_iunlock(dp, XFS_ILOCK_EXCL);
451 return(error); 451 return error;
452} 452}
diff --git a/fs/xfs/xfs_attr_list.c b/fs/xfs/xfs_attr_list.c
index 90e2eeb21207..62db83ab6cbc 100644
--- a/fs/xfs/xfs_attr_list.c
+++ b/fs/xfs/xfs_attr_list.c
@@ -50,11 +50,11 @@ xfs_attr_shortform_compare(const void *a, const void *b)
50 sa = (xfs_attr_sf_sort_t *)a; 50 sa = (xfs_attr_sf_sort_t *)a;
51 sb = (xfs_attr_sf_sort_t *)b; 51 sb = (xfs_attr_sf_sort_t *)b;
52 if (sa->hash < sb->hash) { 52 if (sa->hash < sb->hash) {
53 return(-1); 53 return -1;
54 } else if (sa->hash > sb->hash) { 54 } else if (sa->hash > sb->hash) {
55 return(1); 55 return 1;
56 } else { 56 } else {
57 return(sa->entno - sb->entno); 57 return sa->entno - sb->entno;
58 } 58 }
59} 59}
60 60
@@ -86,7 +86,7 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context)
86 sf = (xfs_attr_shortform_t *)dp->i_afp->if_u1.if_data; 86 sf = (xfs_attr_shortform_t *)dp->i_afp->if_u1.if_data;
87 ASSERT(sf != NULL); 87 ASSERT(sf != NULL);
88 if (!sf->hdr.count) 88 if (!sf->hdr.count)
89 return(0); 89 return 0;
90 cursor = context->cursor; 90 cursor = context->cursor;
91 ASSERT(cursor != NULL); 91 ASSERT(cursor != NULL);
92 92
@@ -124,7 +124,7 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context)
124 sfe = XFS_ATTR_SF_NEXTENTRY(sfe); 124 sfe = XFS_ATTR_SF_NEXTENTRY(sfe);
125 } 125 }
126 trace_xfs_attr_list_sf_all(context); 126 trace_xfs_attr_list_sf_all(context);
127 return(0); 127 return 0;
128 } 128 }
129 129
130 /* do no more for a search callback */ 130 /* do no more for a search callback */
@@ -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 XFS_ERROR(EFSCORRUPTED); 153 return -EFSCORRUPTED;
154 } 154 }
155 155
156 sbp->entno = i; 156 sbp->entno = i;
@@ -188,7 +188,7 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context)
188 } 188 }
189 if (i == nsbuf) { 189 if (i == nsbuf) {
190 kmem_free(sbuf); 190 kmem_free(sbuf);
191 return(0); 191 return 0;
192 } 192 }
193 193
194 /* 194 /*
@@ -213,7 +213,7 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context)
213 } 213 }
214 214
215 kmem_free(sbuf); 215 kmem_free(sbuf);
216 return(0); 216 return 0;
217} 217}
218 218
219STATIC int 219STATIC int
@@ -243,8 +243,8 @@ 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;
250 250
@@ -295,7 +295,7 @@ xfs_attr_node_list(xfs_attr_list_context_t *context)
295 cursor->blkno, -1, &bp, 295 cursor->blkno, -1, &bp,
296 XFS_ATTR_FORK); 296 XFS_ATTR_FORK);
297 if (error) 297 if (error)
298 return(error); 298 return error;
299 node = bp->b_addr; 299 node = bp->b_addr;
300 magic = be16_to_cpu(node->hdr.info.magic); 300 magic = be16_to_cpu(node->hdr.info.magic);
301 if (magic == XFS_ATTR_LEAF_MAGIC || 301 if (magic == XFS_ATTR_LEAF_MAGIC ||
@@ -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 XFS_ERROR(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);
@@ -496,11 +496,11 @@ xfs_attr_leaf_list(xfs_attr_list_context_t *context)
496 context->cursor->blkno = 0; 496 context->cursor->blkno = 0;
497 error = xfs_attr3_leaf_read(NULL, context->dp, 0, -1, &bp); 497 error = xfs_attr3_leaf_read(NULL, context->dp, 0, -1, &bp);
498 if (error) 498 if (error)
499 return XFS_ERROR(error); 499 return error;
500 500
501 error = xfs_attr3_leaf_list_int(bp, context); 501 error = xfs_attr3_leaf_list_int(bp, context);
502 xfs_trans_brelse(NULL, bp); 502 xfs_trans_brelse(NULL, bp);
503 return XFS_ERROR(error); 503 return error;
504} 504}
505 505
506int 506int
@@ -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(XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(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 64731ef3324d..43a97442f28a 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;
@@ -365,7 +365,7 @@ xfs_bmap_count_tree(
365 xfs_trans_brelse(tp, bp); 365 xfs_trans_brelse(tp, bp);
366 XFS_ERROR_REPORT("xfs_bmap_count_tree(1)", 366 XFS_ERROR_REPORT("xfs_bmap_count_tree(1)",
367 XFS_ERRLEVEL_LOW, mp); 367 XFS_ERRLEVEL_LOW, mp);
368 return XFS_ERROR(EFSCORRUPTED); 368 return -EFSCORRUPTED;
369 } 369 }
370 xfs_trans_brelse(tp, bp); 370 xfs_trans_brelse(tp, bp);
371 } else { 371 } else {
@@ -432,7 +432,7 @@ xfs_bmap_count_blocks(
432 if (unlikely(xfs_bmap_count_tree(mp, tp, ifp, bno, level, count) < 0)) { 432 if (unlikely(xfs_bmap_count_tree(mp, tp, ifp, bno, level, count) < 0)) {
433 XFS_ERROR_REPORT("xfs_bmap_count_blocks(2)", XFS_ERRLEVEL_LOW, 433 XFS_ERROR_REPORT("xfs_bmap_count_blocks(2)", XFS_ERRLEVEL_LOW,
434 mp); 434 mp);
435 return XFS_ERROR(EFSCORRUPTED); 435 return -EFSCORRUPTED;
436 } 436 }
437 437
438 return 0; 438 return 0;
@@ -524,13 +524,13 @@ xfs_getbmap(
524 if (ip->i_d.di_aformat != XFS_DINODE_FMT_EXTENTS && 524 if (ip->i_d.di_aformat != XFS_DINODE_FMT_EXTENTS &&
525 ip->i_d.di_aformat != XFS_DINODE_FMT_BTREE && 525 ip->i_d.di_aformat != XFS_DINODE_FMT_BTREE &&
526 ip->i_d.di_aformat != XFS_DINODE_FMT_LOCAL) 526 ip->i_d.di_aformat != XFS_DINODE_FMT_LOCAL)
527 return XFS_ERROR(EINVAL); 527 return -EINVAL;
528 } else if (unlikely( 528 } else if (unlikely(
529 ip->i_d.di_aformat != 0 && 529 ip->i_d.di_aformat != 0 &&
530 ip->i_d.di_aformat != XFS_DINODE_FMT_EXTENTS)) { 530 ip->i_d.di_aformat != XFS_DINODE_FMT_EXTENTS)) {
531 XFS_ERROR_REPORT("xfs_getbmap", XFS_ERRLEVEL_LOW, 531 XFS_ERROR_REPORT("xfs_getbmap", XFS_ERRLEVEL_LOW,
532 ip->i_mount); 532 ip->i_mount);
533 return XFS_ERROR(EFSCORRUPTED); 533 return -EFSCORRUPTED;
534 } 534 }
535 535
536 prealloced = 0; 536 prealloced = 0;
@@ -539,7 +539,7 @@ xfs_getbmap(
539 if (ip->i_d.di_format != XFS_DINODE_FMT_EXTENTS && 539 if (ip->i_d.di_format != XFS_DINODE_FMT_EXTENTS &&
540 ip->i_d.di_format != XFS_DINODE_FMT_BTREE && 540 ip->i_d.di_format != XFS_DINODE_FMT_BTREE &&
541 ip->i_d.di_format != XFS_DINODE_FMT_LOCAL) 541 ip->i_d.di_format != XFS_DINODE_FMT_LOCAL)
542 return XFS_ERROR(EINVAL); 542 return -EINVAL;
543 543
544 if (xfs_get_extsz_hint(ip) || 544 if (xfs_get_extsz_hint(ip) ||
545 ip->i_d.di_flags & (XFS_DIFLAG_PREALLOC|XFS_DIFLAG_APPEND)){ 545 ip->i_d.di_flags & (XFS_DIFLAG_PREALLOC|XFS_DIFLAG_APPEND)){
@@ -559,26 +559,26 @@ xfs_getbmap(
559 bmv->bmv_entries = 0; 559 bmv->bmv_entries = 0;
560 return 0; 560 return 0;
561 } else if (bmv->bmv_length < 0) { 561 } else if (bmv->bmv_length < 0) {
562 return XFS_ERROR(EINVAL); 562 return -EINVAL;
563 } 563 }
564 564
565 nex = bmv->bmv_count - 1; 565 nex = bmv->bmv_count - 1;
566 if (nex <= 0) 566 if (nex <= 0)
567 return XFS_ERROR(EINVAL); 567 return -EINVAL;
568 bmvend = bmv->bmv_offset + bmv->bmv_length; 568 bmvend = bmv->bmv_offset + bmv->bmv_length;
569 569
570 570
571 if (bmv->bmv_count > ULONG_MAX / sizeof(struct getbmapx)) 571 if (bmv->bmv_count > ULONG_MAX / sizeof(struct getbmapx))
572 return XFS_ERROR(ENOMEM); 572 return -ENOMEM;
573 out = kmem_zalloc_large(bmv->bmv_count * sizeof(struct getbmapx), 0); 573 out = kmem_zalloc_large(bmv->bmv_count * sizeof(struct getbmapx), 0);
574 if (!out) 574 if (!out)
575 return XFS_ERROR(ENOMEM); 575 return -ENOMEM;
576 576
577 xfs_ilock(ip, XFS_IOLOCK_SHARED); 577 xfs_ilock(ip, XFS_IOLOCK_SHARED);
578 if (whichfork == XFS_DATA_FORK) { 578 if (whichfork == XFS_DATA_FORK) {
579 if (!(iflags & BMV_IF_DELALLOC) && 579 if (!(iflags & BMV_IF_DELALLOC) &&
580 (ip->i_delayed_blks || XFS_ISIZE(ip) > ip->i_d.di_size)) { 580 (ip->i_delayed_blks || XFS_ISIZE(ip) > ip->i_d.di_size)) {
581 error = -filemap_write_and_wait(VFS_I(ip)->i_mapping); 581 error = filemap_write_and_wait(VFS_I(ip)->i_mapping);
582 if (error) 582 if (error)
583 goto out_unlock_iolock; 583 goto out_unlock_iolock;
584 584
@@ -611,7 +611,7 @@ xfs_getbmap(
611 /* 611 /*
612 * Allocate enough space to handle "subnex" maps at a time. 612 * Allocate enough space to handle "subnex" maps at a time.
613 */ 613 */
614 error = ENOMEM; 614 error = -ENOMEM;
615 subnex = 16; 615 subnex = 16;
616 map = kmem_alloc(subnex * sizeof(*map), KM_MAYFAIL | KM_NOFS); 616 map = kmem_alloc(subnex * sizeof(*map), KM_MAYFAIL | KM_NOFS);
617 if (!map) 617 if (!map)
@@ -882,7 +882,7 @@ xfs_free_eofblocks(
882 if (need_iolock) { 882 if (need_iolock) {
883 if (!xfs_ilock_nowait(ip, XFS_IOLOCK_EXCL)) { 883 if (!xfs_ilock_nowait(ip, XFS_IOLOCK_EXCL)) {
884 xfs_trans_cancel(tp, 0); 884 xfs_trans_cancel(tp, 0);
885 return EAGAIN; 885 return -EAGAIN;
886 } 886 }
887 } 887 }
888 888
@@ -955,14 +955,14 @@ xfs_alloc_file_space(
955 trace_xfs_alloc_file_space(ip); 955 trace_xfs_alloc_file_space(ip);
956 956
957 if (XFS_FORCED_SHUTDOWN(mp)) 957 if (XFS_FORCED_SHUTDOWN(mp))
958 return XFS_ERROR(EIO); 958 return -EIO;
959 959
960 error = xfs_qm_dqattach(ip, 0); 960 error = xfs_qm_dqattach(ip, 0);
961 if (error) 961 if (error)
962 return error; 962 return error;
963 963
964 if (len <= 0) 964 if (len <= 0)
965 return XFS_ERROR(EINVAL); 965 return -EINVAL;
966 966
967 rt = XFS_IS_REALTIME_INODE(ip); 967 rt = XFS_IS_REALTIME_INODE(ip);
968 extsz = xfs_get_extsz_hint(ip); 968 extsz = xfs_get_extsz_hint(ip);
@@ -1028,7 +1028,7 @@ xfs_alloc_file_space(
1028 /* 1028 /*
1029 * Free the transaction structure. 1029 * Free the transaction structure.
1030 */ 1030 */
1031 ASSERT(error == ENOSPC || XFS_FORCED_SHUTDOWN(mp)); 1031 ASSERT(error == -ENOSPC || XFS_FORCED_SHUTDOWN(mp));
1032 xfs_trans_cancel(tp, 0); 1032 xfs_trans_cancel(tp, 0);
1033 break; 1033 break;
1034 } 1034 }
@@ -1065,7 +1065,7 @@ xfs_alloc_file_space(
1065 allocated_fsb = imapp->br_blockcount; 1065 allocated_fsb = imapp->br_blockcount;
1066 1066
1067 if (nimaps == 0) { 1067 if (nimaps == 0) {
1068 error = XFS_ERROR(ENOSPC); 1068 error = -ENOSPC;
1069 break; 1069 break;
1070 } 1070 }
1071 1071
@@ -1126,7 +1126,7 @@ xfs_zero_remaining_bytes(
1126 mp->m_rtdev_targp : mp->m_ddev_targp, 1126 mp->m_rtdev_targp : mp->m_ddev_targp,
1127 BTOBB(mp->m_sb.sb_blocksize), 0); 1127 BTOBB(mp->m_sb.sb_blocksize), 0);
1128 if (!bp) 1128 if (!bp)
1129 return XFS_ERROR(ENOMEM); 1129 return -ENOMEM;
1130 1130
1131 xfs_buf_unlock(bp); 1131 xfs_buf_unlock(bp);
1132 1132
@@ -1158,7 +1158,7 @@ xfs_zero_remaining_bytes(
1158 XFS_BUF_SET_ADDR(bp, xfs_fsb_to_db(ip, imap.br_startblock)); 1158 XFS_BUF_SET_ADDR(bp, xfs_fsb_to_db(ip, imap.br_startblock));
1159 1159
1160 if (XFS_FORCED_SHUTDOWN(mp)) { 1160 if (XFS_FORCED_SHUTDOWN(mp)) {
1161 error = XFS_ERROR(EIO); 1161 error = -EIO;
1162 break; 1162 break;
1163 } 1163 }
1164 xfs_buf_iorequest(bp); 1164 xfs_buf_iorequest(bp);
@@ -1176,7 +1176,7 @@ xfs_zero_remaining_bytes(
1176 XFS_BUF_WRITE(bp); 1176 XFS_BUF_WRITE(bp);
1177 1177
1178 if (XFS_FORCED_SHUTDOWN(mp)) { 1178 if (XFS_FORCED_SHUTDOWN(mp)) {
1179 error = XFS_ERROR(EIO); 1179 error = -EIO;
1180 break; 1180 break;
1181 } 1181 }
1182 xfs_buf_iorequest(bp); 1182 xfs_buf_iorequest(bp);
@@ -1234,7 +1234,7 @@ xfs_free_file_space(
1234 1234
1235 rounding = max_t(xfs_off_t, 1 << mp->m_sb.sb_blocklog, PAGE_CACHE_SIZE); 1235 rounding = max_t(xfs_off_t, 1 << mp->m_sb.sb_blocklog, PAGE_CACHE_SIZE);
1236 ioffset = offset & ~(rounding - 1); 1236 ioffset = offset & ~(rounding - 1);
1237 error = -filemap_write_and_wait_range(VFS_I(ip)->i_mapping, 1237 error = filemap_write_and_wait_range(VFS_I(ip)->i_mapping,
1238 ioffset, -1); 1238 ioffset, -1);
1239 if (error) 1239 if (error)
1240 goto out; 1240 goto out;
@@ -1315,7 +1315,7 @@ xfs_free_file_space(
1315 /* 1315 /*
1316 * Free the transaction structure. 1316 * Free the transaction structure.
1317 */ 1317 */
1318 ASSERT(error == ENOSPC || XFS_FORCED_SHUTDOWN(mp)); 1318 ASSERT(error == -ENOSPC || XFS_FORCED_SHUTDOWN(mp));
1319 xfs_trans_cancel(tp, 0); 1319 xfs_trans_cancel(tp, 0);
1320 break; 1320 break;
1321 } 1321 }
@@ -1557,14 +1557,14 @@ xfs_swap_extents_check_format(
1557 /* Should never get a local format */ 1557 /* Should never get a local format */
1558 if (ip->i_d.di_format == XFS_DINODE_FMT_LOCAL || 1558 if (ip->i_d.di_format == XFS_DINODE_FMT_LOCAL ||
1559 tip->i_d.di_format == XFS_DINODE_FMT_LOCAL) 1559 tip->i_d.di_format == XFS_DINODE_FMT_LOCAL)
1560 return EINVAL; 1560 return -EINVAL;
1561 1561
1562 /* 1562 /*
1563 * if the target inode has less extents that then temporary inode then 1563 * if the target inode has less extents that then temporary inode then
1564 * why did userspace call us? 1564 * why did userspace call us?
1565 */ 1565 */
1566 if (ip->i_d.di_nextents < tip->i_d.di_nextents) 1566 if (ip->i_d.di_nextents < tip->i_d.di_nextents)
1567 return EINVAL; 1567 return -EINVAL;
1568 1568
1569 /* 1569 /*
1570 * if the target inode is in extent form and the temp inode is in btree 1570 * if the target inode is in extent form and the temp inode is in btree
@@ -1573,19 +1573,19 @@ xfs_swap_extents_check_format(
1573 */ 1573 */
1574 if (ip->i_d.di_format == XFS_DINODE_FMT_EXTENTS && 1574 if (ip->i_d.di_format == XFS_DINODE_FMT_EXTENTS &&
1575 tip->i_d.di_format == XFS_DINODE_FMT_BTREE) 1575 tip->i_d.di_format == XFS_DINODE_FMT_BTREE)
1576 return EINVAL; 1576 return -EINVAL;
1577 1577
1578 /* Check temp in extent form to max in target */ 1578 /* Check temp in extent form to max in target */
1579 if (tip->i_d.di_format == XFS_DINODE_FMT_EXTENTS && 1579 if (tip->i_d.di_format == XFS_DINODE_FMT_EXTENTS &&
1580 XFS_IFORK_NEXTENTS(tip, XFS_DATA_FORK) > 1580 XFS_IFORK_NEXTENTS(tip, XFS_DATA_FORK) >
1581 XFS_IFORK_MAXEXT(ip, XFS_DATA_FORK)) 1581 XFS_IFORK_MAXEXT(ip, XFS_DATA_FORK))
1582 return EINVAL; 1582 return -EINVAL;
1583 1583
1584 /* Check target in extent form to max in temp */ 1584 /* Check target in extent form to max in temp */
1585 if (ip->i_d.di_format == XFS_DINODE_FMT_EXTENTS && 1585 if (ip->i_d.di_format == XFS_DINODE_FMT_EXTENTS &&
1586 XFS_IFORK_NEXTENTS(ip, XFS_DATA_FORK) > 1586 XFS_IFORK_NEXTENTS(ip, XFS_DATA_FORK) >
1587 XFS_IFORK_MAXEXT(tip, XFS_DATA_FORK)) 1587 XFS_IFORK_MAXEXT(tip, XFS_DATA_FORK))
1588 return EINVAL; 1588 return -EINVAL;
1589 1589
1590 /* 1590 /*
1591 * If we are in a btree format, check that the temp root block will fit 1591 * If we are in a btree format, check that the temp root block will fit
@@ -1599,20 +1599,20 @@ xfs_swap_extents_check_format(
1599 if (tip->i_d.di_format == XFS_DINODE_FMT_BTREE) { 1599 if (tip->i_d.di_format == XFS_DINODE_FMT_BTREE) {
1600 if (XFS_IFORK_BOFF(ip) && 1600 if (XFS_IFORK_BOFF(ip) &&
1601 XFS_BMAP_BMDR_SPACE(tip->i_df.if_broot) > XFS_IFORK_BOFF(ip)) 1601 XFS_BMAP_BMDR_SPACE(tip->i_df.if_broot) > XFS_IFORK_BOFF(ip))
1602 return EINVAL; 1602 return -EINVAL;
1603 if (XFS_IFORK_NEXTENTS(tip, XFS_DATA_FORK) <= 1603 if (XFS_IFORK_NEXTENTS(tip, XFS_DATA_FORK) <=
1604 XFS_IFORK_MAXEXT(ip, XFS_DATA_FORK)) 1604 XFS_IFORK_MAXEXT(ip, XFS_DATA_FORK))
1605 return EINVAL; 1605 return -EINVAL;
1606 } 1606 }
1607 1607
1608 /* Reciprocal target->temp btree format checks */ 1608 /* Reciprocal target->temp btree format checks */
1609 if (ip->i_d.di_format == XFS_DINODE_FMT_BTREE) { 1609 if (ip->i_d.di_format == XFS_DINODE_FMT_BTREE) {
1610 if (XFS_IFORK_BOFF(tip) && 1610 if (XFS_IFORK_BOFF(tip) &&
1611 XFS_BMAP_BMDR_SPACE(ip->i_df.if_broot) > XFS_IFORK_BOFF(tip)) 1611 XFS_BMAP_BMDR_SPACE(ip->i_df.if_broot) > XFS_IFORK_BOFF(tip))
1612 return EINVAL; 1612 return -EINVAL;
1613 if (XFS_IFORK_NEXTENTS(ip, XFS_DATA_FORK) <= 1613 if (XFS_IFORK_NEXTENTS(ip, XFS_DATA_FORK) <=
1614 XFS_IFORK_MAXEXT(tip, XFS_DATA_FORK)) 1614 XFS_IFORK_MAXEXT(tip, XFS_DATA_FORK))
1615 return EINVAL; 1615 return -EINVAL;
1616 } 1616 }
1617 1617
1618 return 0; 1618 return 0;
@@ -1636,7 +1636,7 @@ xfs_swap_extents(
1636 1636
1637 tempifp = kmem_alloc(sizeof(xfs_ifork_t), KM_MAYFAIL); 1637 tempifp = kmem_alloc(sizeof(xfs_ifork_t), KM_MAYFAIL);
1638 if (!tempifp) { 1638 if (!tempifp) {
1639 error = XFS_ERROR(ENOMEM); 1639 error = -ENOMEM;
1640 goto out; 1640 goto out;
1641 } 1641 }
1642 1642
@@ -1651,24 +1651,24 @@ xfs_swap_extents(
1651 1651
1652 /* Verify that both files have the same format */ 1652 /* Verify that both files have the same format */
1653 if ((ip->i_d.di_mode & S_IFMT) != (tip->i_d.di_mode & S_IFMT)) { 1653 if ((ip->i_d.di_mode & S_IFMT) != (tip->i_d.di_mode & S_IFMT)) {
1654 error = XFS_ERROR(EINVAL); 1654 error = -EINVAL;
1655 goto out_unlock; 1655 goto out_unlock;
1656 } 1656 }
1657 1657
1658 /* Verify both files are either real-time or non-realtime */ 1658 /* Verify both files are either real-time or non-realtime */
1659 if (XFS_IS_REALTIME_INODE(ip) != XFS_IS_REALTIME_INODE(tip)) { 1659 if (XFS_IS_REALTIME_INODE(ip) != XFS_IS_REALTIME_INODE(tip)) {
1660 error = XFS_ERROR(EINVAL); 1660 error = -EINVAL;
1661 goto out_unlock; 1661 goto out_unlock;
1662 } 1662 }
1663 1663
1664 error = -filemap_write_and_wait(VFS_I(tip)->i_mapping); 1664 error = filemap_write_and_wait(VFS_I(tip)->i_mapping);
1665 if (error) 1665 if (error)
1666 goto out_unlock; 1666 goto out_unlock;
1667 truncate_pagecache_range(VFS_I(tip), 0, -1); 1667 truncate_pagecache_range(VFS_I(tip), 0, -1);
1668 1668
1669 /* Verify O_DIRECT for ftmp */ 1669 /* Verify O_DIRECT for ftmp */
1670 if (VN_CACHED(VFS_I(tip)) != 0) { 1670 if (VN_CACHED(VFS_I(tip)) != 0) {
1671 error = XFS_ERROR(EINVAL); 1671 error = -EINVAL;
1672 goto out_unlock; 1672 goto out_unlock;
1673 } 1673 }
1674 1674
@@ -1676,7 +1676,7 @@ xfs_swap_extents(
1676 if (sxp->sx_offset != 0 || 1676 if (sxp->sx_offset != 0 ||
1677 sxp->sx_length != ip->i_d.di_size || 1677 sxp->sx_length != ip->i_d.di_size ||
1678 sxp->sx_length != tip->i_d.di_size) { 1678 sxp->sx_length != tip->i_d.di_size) {
1679 error = XFS_ERROR(EFAULT); 1679 error = -EFAULT;
1680 goto out_unlock; 1680 goto out_unlock;
1681 } 1681 }
1682 1682
@@ -1703,7 +1703,7 @@ xfs_swap_extents(
1703 (sbp->bs_ctime.tv_nsec != VFS_I(ip)->i_ctime.tv_nsec) || 1703 (sbp->bs_ctime.tv_nsec != VFS_I(ip)->i_ctime.tv_nsec) ||
1704 (sbp->bs_mtime.tv_sec != VFS_I(ip)->i_mtime.tv_sec) || 1704 (sbp->bs_mtime.tv_sec != VFS_I(ip)->i_mtime.tv_sec) ||
1705 (sbp->bs_mtime.tv_nsec != VFS_I(ip)->i_mtime.tv_nsec)) { 1705 (sbp->bs_mtime.tv_nsec != VFS_I(ip)->i_mtime.tv_nsec)) {
1706 error = XFS_ERROR(EBUSY); 1706 error = -EBUSY;
1707 goto out_unlock; 1707 goto out_unlock;
1708 } 1708 }
1709 1709
@@ -1714,7 +1714,7 @@ xfs_swap_extents(
1714 * until we have switched the extents. 1714 * until we have switched the extents.
1715 */ 1715 */
1716 if (VN_MAPPED(VFS_I(ip))) { 1716 if (VN_MAPPED(VFS_I(ip))) {
1717 error = XFS_ERROR(EBUSY); 1717 error = -EBUSY;
1718 goto out_unlock; 1718 goto out_unlock;
1719 } 1719 }
1720 1720
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 48e99afb9cb0..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 XFS_ERROR(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 XFS_ERROR(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 4f11ef011139..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;
@@ -166,11 +166,11 @@ xfs_ioc_trim(
166 int error, last_error = 0; 166 int error, last_error = 0;
167 167
168 if (!capable(CAP_SYS_ADMIN)) 168 if (!capable(CAP_SYS_ADMIN))
169 return -XFS_ERROR(EPERM); 169 return -EPERM;
170 if (!blk_queue_discard(q)) 170 if (!blk_queue_discard(q))
171 return -XFS_ERROR(EOPNOTSUPP); 171 return -EOPNOTSUPP;
172 if (copy_from_user(&range, urange, sizeof(range))) 172 if (copy_from_user(&range, urange, sizeof(range)))
173 return -XFS_ERROR(EFAULT); 173 return -EFAULT;
174 174
175 /* 175 /*
176 * Truncating down the len isn't actually quite correct, but using 176 * Truncating down the len isn't actually quite correct, but using
@@ -182,7 +182,7 @@ xfs_ioc_trim(
182 if (range.start >= XFS_FSB_TO_B(mp, mp->m_sb.sb_dblocks) || 182 if (range.start >= XFS_FSB_TO_B(mp, mp->m_sb.sb_dblocks) ||
183 range.minlen > XFS_FSB_TO_B(mp, XFS_ALLOC_AG_MAX_USABLE(mp)) || 183 range.minlen > XFS_FSB_TO_B(mp, XFS_ALLOC_AG_MAX_USABLE(mp)) ||
184 range.len < mp->m_sb.sb_blocksize) 184 range.len < mp->m_sb.sb_blocksize)
185 return -XFS_ERROR(EINVAL); 185 return -EINVAL;
186 186
187 start = BTOBB(range.start); 187 start = BTOBB(range.start);
188 end = start + BTOBBT(range.len) - 1; 188 end = start + BTOBBT(range.len) - 1;
@@ -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;
@@ -206,7 +206,7 @@ xfs_ioc_trim(
206 206
207 range.len = XFS_FSB_TO_B(mp, blocks_trimmed); 207 range.len = XFS_FSB_TO_B(mp, blocks_trimmed);
208 if (copy_to_user(urange, &range, sizeof(range))) 208 if (copy_to_user(urange, &range, sizeof(range)))
209 return -XFS_ERROR(EFAULT); 209 return -EFAULT;
210 return 0; 210 return 0;
211} 211}
212 212
@@ -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 3ee0cd43edc0..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;
@@ -400,7 +400,7 @@ xfs_qm_dqalloc(
400 error0: 400 error0:
401 xfs_iunlock(quotip, XFS_ILOCK_EXCL); 401 xfs_iunlock(quotip, XFS_ILOCK_EXCL);
402 402
403 return (error); 403 return error;
404} 404}
405 405
406STATIC int 406STATIC int
@@ -426,7 +426,7 @@ xfs_qm_dqrepair(
426 426
427 if (error) { 427 if (error) {
428 ASSERT(*bpp == NULL); 428 ASSERT(*bpp == NULL);
429 return XFS_ERROR(error); 429 return error;
430 } 430 }
431 (*bpp)->b_ops = &xfs_dquot_buf_ops; 431 (*bpp)->b_ops = &xfs_dquot_buf_ops;
432 432
@@ -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 XFS_ERROR(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);
@@ -539,7 +539,7 @@ xfs_qm_dqtobp(
539 539
540 if (error) { 540 if (error) {
541 ASSERT(bp == NULL); 541 ASSERT(bp == NULL);
542 return XFS_ERROR(error); 542 return error;
543 } 543 }
544 } 544 }
545 545
@@ -547,7 +547,7 @@ xfs_qm_dqtobp(
547 *O_bpp = bp; 547 *O_bpp = bp;
548 *O_ddpp = bp->b_addr + dqp->q_bufoffset; 548 *O_ddpp = bp->b_addr + dqp->q_bufoffset;
549 549
550 return (0); 550 return 0;
551} 551}
552 552
553 553
@@ -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 XFS_ERROR(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
@@ -829,7 +829,7 @@ restart:
829 ASSERT((ip == NULL) || xfs_isilocked(ip, XFS_ILOCK_EXCL)); 829 ASSERT((ip == NULL) || xfs_isilocked(ip, XFS_ILOCK_EXCL));
830 trace_xfs_dqget_miss(dqp); 830 trace_xfs_dqget_miss(dqp);
831 *O_dqpp = dqp; 831 *O_dqpp = dqp;
832 return (0); 832 return 0;
833} 833}
834 834
835/* 835/*
@@ -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 = XFS_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 XFS_ERROR(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 XFS_ERROR(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 edac5b057d28..b92fd7bc49e3 100644
--- a/fs/xfs/xfs_error.c
+++ b/fs/xfs/xfs_error.c
@@ -27,29 +27,6 @@
27 27
28#ifdef DEBUG 28#ifdef DEBUG
29 29
30int xfs_etrap[XFS_ERROR_NTRAP] = {
31 0,
32};
33
34int
35xfs_error_trap(int e)
36{
37 int i;
38
39 if (!e)
40 return 0;
41 for (i = 0; i < XFS_ERROR_NTRAP; i++) {
42 if (xfs_etrap[i] == 0)
43 break;
44 if (e != xfs_etrap[i])
45 continue;
46 xfs_notice(NULL, "%s: error %d", __func__, e);
47 BUG();
48 break;
49 }
50 return e;
51}
52
53int xfs_etest[XFS_NUM_INJECT_ERROR]; 30int xfs_etest[XFS_NUM_INJECT_ERROR];
54int64_t xfs_etest_fsid[XFS_NUM_INJECT_ERROR]; 31int64_t xfs_etest_fsid[XFS_NUM_INJECT_ERROR];
55char * xfs_etest_fsname[XFS_NUM_INJECT_ERROR]; 32char * xfs_etest_fsname[XFS_NUM_INJECT_ERROR];
@@ -190,7 +167,7 @@ xfs_verifier_error(
190 struct xfs_mount *mp = bp->b_target->bt_mount; 167 struct xfs_mount *mp = bp->b_target->bt_mount;
191 168
192 xfs_alert(mp, "Metadata %s detected at %pF, block 0x%llx", 169 xfs_alert(mp, "Metadata %s detected at %pF, block 0x%llx",
193 bp->b_error == EFSBADCRC ? "CRC error" : "corruption", 170 bp->b_error == -EFSBADCRC ? "CRC error" : "corruption",
194 __return_address, bp->b_bn); 171 __return_address, bp->b_bn);
195 172
196 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 c1c57d4a4b5d..279a76e52791 100644
--- a/fs/xfs/xfs_error.h
+++ b/fs/xfs/xfs_error.h
@@ -18,15 +18,6 @@
18#ifndef __XFS_ERROR_H__ 18#ifndef __XFS_ERROR_H__
19#define __XFS_ERROR_H__ 19#define __XFS_ERROR_H__
20 20
21#ifdef DEBUG
22#define XFS_ERROR_NTRAP 10
23extern int xfs_etrap[XFS_ERROR_NTRAP];
24extern int xfs_error_trap(int);
25#define XFS_ERROR(e) xfs_error_trap(e)
26#else
27#define XFS_ERROR(e) (e)
28#endif
29
30struct xfs_mount; 21struct xfs_mount;
31 22
32extern void xfs_error_report(const char *tag, int level, struct xfs_mount *mp, 23extern void xfs_error_report(const char *tag, int level, struct xfs_mount *mp,
@@ -56,7 +47,7 @@ extern void xfs_verifier_error(struct xfs_buf *bp);
56 if (unlikely(!fs_is_ok)) { \ 47 if (unlikely(!fs_is_ok)) { \
57 XFS_ERROR_REPORT("XFS_WANT_CORRUPTED_GOTO", \ 48 XFS_ERROR_REPORT("XFS_WANT_CORRUPTED_GOTO", \
58 XFS_ERRLEVEL_LOW, NULL); \ 49 XFS_ERRLEVEL_LOW, NULL); \
59 error = XFS_ERROR(EFSCORRUPTED); \ 50 error = -EFSCORRUPTED; \
60 goto l; \ 51 goto l; \
61 } \ 52 } \
62 } 53 }
@@ -68,7 +59,7 @@ extern void xfs_verifier_error(struct xfs_buf *bp);
68 if (unlikely(!fs_is_ok)) { \ 59 if (unlikely(!fs_is_ok)) { \
69 XFS_ERROR_REPORT("XFS_WANT_CORRUPTED_RETURN", \ 60 XFS_ERROR_REPORT("XFS_WANT_CORRUPTED_RETURN", \
70 XFS_ERRLEVEL_LOW, NULL); \ 61 XFS_ERRLEVEL_LOW, NULL); \
71 return XFS_ERROR(EFSCORRUPTED); \ 62 return -EFSCORRUPTED; \
72 } \ 63 } \
73 } 64 }
74 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 1f66779d7a46..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
@@ -179,7 +179,7 @@ xfs_file_fsync(
179 return error; 179 return error;
180 180
181 if (XFS_FORCED_SHUTDOWN(mp)) 181 if (XFS_FORCED_SHUTDOWN(mp))
182 return -XFS_ERROR(EIO); 182 return -EIO;
183 183
184 xfs_iflags_clear(ip, XFS_ITRUNCATED); 184 xfs_iflags_clear(ip, XFS_ITRUNCATED);
185 185
@@ -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
@@ -258,7 +258,7 @@ xfs_file_read_iter(
258 if ((pos | size) & target->bt_logical_sectormask) { 258 if ((pos | size) & target->bt_logical_sectormask) {
259 if (pos == i_size_read(inode)) 259 if (pos == i_size_read(inode))
260 return 0; 260 return 0;
261 return -XFS_ERROR(EINVAL); 261 return -EINVAL;
262 } 262 }
263 } 263 }
264 264
@@ -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 }
@@ -594,7 +594,7 @@ xfs_file_dio_aio_write(
594 594
595 /* DIO must be aligned to device logical sector size */ 595 /* DIO must be aligned to device logical sector size */
596 if ((pos | count) & target->bt_logical_sectormask) 596 if ((pos | count) & target->bt_logical_sectormask)
597 return -XFS_ERROR(EINVAL); 597 return -EINVAL;
598 598
599 /* "unaligned" here means not aligned to a filesystem block */ 599 /* "unaligned" here means not aligned to a filesystem block */
600 if ((pos & mp->m_blockmask) || ((pos + count) & mp->m_blockmask)) 600 if ((pos & mp->m_blockmask) || ((pos + count) & mp->m_blockmask))
@@ -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
@@ -1282,13 +1282,13 @@ xfs_seek_hole(
1282 int error; 1282 int error;
1283 1283
1284 if (XFS_FORCED_SHUTDOWN(mp)) 1284 if (XFS_FORCED_SHUTDOWN(mp))
1285 return -XFS_ERROR(EIO); 1285 return -EIO;
1286 1286
1287 lock = xfs_ilock_data_map_shared(ip); 1287 lock = xfs_ilock_data_map_shared(ip);
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 d2295561570a..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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(EPERM); 607 return -EPERM;
608 if (!mutex_trylock(&mp->m_growlock)) 608 if (!mutex_trylock(&mp->m_growlock))
609 return XFS_ERROR(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 XFS_ERROR(EPERM); 623 return -EPERM;
624 if (!mutex_trylock(&mp->m_growlock)) 624 if (!mutex_trylock(&mp->m_growlock))
625 return XFS_ERROR(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 XFS_ERROR(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 c48df5f25b9f..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,11 +652,11 @@ 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 }
659 return XFS_ERROR(last_error); 659 return last_error;
660} 660}
661 661
662int 662int
@@ -680,11 +680,11 @@ 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 }
687 return XFS_ERROR(last_error); 687 return last_error;
688} 688}
689 689
690/* 690/*
@@ -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
@@ -1129,7 +1129,7 @@ restart:
1129 trylock = 0; 1129 trylock = 0;
1130 goto restart; 1130 goto restart;
1131 } 1131 }
1132 return XFS_ERROR(last_error); 1132 return last_error;
1133} 1133}
1134 1134
1135int 1135int
@@ -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 a6115fe1ac94..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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(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 = XFS_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 XFS_ERROR(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 = XFS_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 = XFS_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 = XFS_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 = XFS_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 XFS_ERROR(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 = XFS_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 = XFS_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 XFS_ERROR(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 8bc1bbce7451..30983b8ceaa1 100644
--- a/fs/xfs/xfs_ioctl.c
+++ b/fs/xfs/xfs_ioctl.c
@@ -207,7 +207,7 @@ xfs_open_by_handle(
207 struct path path; 207 struct path path;
208 208
209 if (!capable(CAP_SYS_ADMIN)) 209 if (!capable(CAP_SYS_ADMIN))
210 return -XFS_ERROR(EPERM); 210 return -EPERM;
211 211
212 dentry = xfs_handlereq_to_dentry(parfilp, hreq); 212 dentry = xfs_handlereq_to_dentry(parfilp, hreq);
213 if (IS_ERR(dentry)) 213 if (IS_ERR(dentry))
@@ -216,7 +216,7 @@ xfs_open_by_handle(
216 216
217 /* Restrict xfs_open_by_handle to directories & regular files. */ 217 /* Restrict xfs_open_by_handle to directories & regular files. */
218 if (!(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode))) { 218 if (!(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode))) {
219 error = -XFS_ERROR(EPERM); 219 error = -EPERM;
220 goto out_dput; 220 goto out_dput;
221 } 221 }
222 222
@@ -228,18 +228,18 @@ xfs_open_by_handle(
228 fmode = OPEN_FMODE(permflag); 228 fmode = OPEN_FMODE(permflag);
229 if ((!(permflag & O_APPEND) || (permflag & O_TRUNC)) && 229 if ((!(permflag & O_APPEND) || (permflag & O_TRUNC)) &&
230 (fmode & FMODE_WRITE) && IS_APPEND(inode)) { 230 (fmode & FMODE_WRITE) && IS_APPEND(inode)) {
231 error = -XFS_ERROR(EPERM); 231 error = -EPERM;
232 goto out_dput; 232 goto out_dput;
233 } 233 }
234 234
235 if ((fmode & FMODE_WRITE) && IS_IMMUTABLE(inode)) { 235 if ((fmode & FMODE_WRITE) && IS_IMMUTABLE(inode)) {
236 error = -XFS_ERROR(EACCES); 236 error = -EACCES;
237 goto out_dput; 237 goto out_dput;
238 } 238 }
239 239
240 /* Can't write directories. */ 240 /* Can't write directories. */
241 if (S_ISDIR(inode->i_mode) && (fmode & FMODE_WRITE)) { 241 if (S_ISDIR(inode->i_mode) && (fmode & FMODE_WRITE)) {
242 error = -XFS_ERROR(EISDIR); 242 error = -EISDIR;
243 goto out_dput; 243 goto out_dput;
244 } 244 }
245 245
@@ -282,7 +282,7 @@ xfs_readlink_by_handle(
282 int error; 282 int error;
283 283
284 if (!capable(CAP_SYS_ADMIN)) 284 if (!capable(CAP_SYS_ADMIN))
285 return -XFS_ERROR(EPERM); 285 return -EPERM;
286 286
287 dentry = xfs_handlereq_to_dentry(parfilp, hreq); 287 dentry = xfs_handlereq_to_dentry(parfilp, hreq);
288 if (IS_ERR(dentry)) 288 if (IS_ERR(dentry))
@@ -290,22 +290,22 @@ xfs_readlink_by_handle(
290 290
291 /* Restrict this handle operation to symlinks only. */ 291 /* Restrict this handle operation to symlinks only. */
292 if (!S_ISLNK(dentry->d_inode->i_mode)) { 292 if (!S_ISLNK(dentry->d_inode->i_mode)) {
293 error = -XFS_ERROR(EINVAL); 293 error = -EINVAL;
294 goto out_dput; 294 goto out_dput;
295 } 295 }
296 296
297 if (copy_from_user(&olen, hreq->ohandlen, sizeof(__u32))) { 297 if (copy_from_user(&olen, hreq->ohandlen, sizeof(__u32))) {
298 error = -XFS_ERROR(EFAULT); 298 error = -EFAULT;
299 goto out_dput; 299 goto out_dput;
300 } 300 }
301 301
302 link = kmalloc(MAXPATHLEN+1, GFP_KERNEL); 302 link = kmalloc(MAXPATHLEN+1, GFP_KERNEL);
303 if (!link) { 303 if (!link) {
304 error = -XFS_ERROR(ENOMEM); 304 error = -ENOMEM;
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 XFS_ERROR(EPERM); 333 return -EPERM;
334 334
335 if (XFS_FORCED_SHUTDOWN(mp)) 335 if (XFS_FORCED_SHUTDOWN(mp))
336 return XFS_ERROR(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);
@@ -364,9 +364,9 @@ xfs_fssetdm_by_handle(
364 struct dentry *dentry; 364 struct dentry *dentry;
365 365
366 if (!capable(CAP_MKNOD)) 366 if (!capable(CAP_MKNOD))
367 return -XFS_ERROR(EPERM); 367 return -EPERM;
368 if (copy_from_user(&dmhreq, arg, sizeof(xfs_fsop_setdm_handlereq_t))) 368 if (copy_from_user(&dmhreq, arg, sizeof(xfs_fsop_setdm_handlereq_t)))
369 return -XFS_ERROR(EFAULT); 369 return -EFAULT;
370 370
371 error = mnt_want_write_file(parfilp); 371 error = mnt_want_write_file(parfilp);
372 if (error) 372 if (error)
@@ -379,16 +379,16 @@ xfs_fssetdm_by_handle(
379 } 379 }
380 380
381 if (IS_IMMUTABLE(dentry->d_inode) || IS_APPEND(dentry->d_inode)) { 381 if (IS_IMMUTABLE(dentry->d_inode) || IS_APPEND(dentry->d_inode)) {
382 error = -XFS_ERROR(EPERM); 382 error = -EPERM;
383 goto out; 383 goto out;
384 } 384 }
385 385
386 if (copy_from_user(&fsd, dmhreq.data, sizeof(fsd))) { 386 if (copy_from_user(&fsd, dmhreq.data, sizeof(fsd))) {
387 error = -XFS_ERROR(EFAULT); 387 error = -EFAULT;
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:
@@ -409,18 +409,18 @@ xfs_attrlist_by_handle(
409 char *kbuf; 409 char *kbuf;
410 410
411 if (!capable(CAP_SYS_ADMIN)) 411 if (!capable(CAP_SYS_ADMIN))
412 return -XFS_ERROR(EPERM); 412 return -EPERM;
413 if (copy_from_user(&al_hreq, arg, sizeof(xfs_fsop_attrlist_handlereq_t))) 413 if (copy_from_user(&al_hreq, arg, sizeof(xfs_fsop_attrlist_handlereq_t)))
414 return -XFS_ERROR(EFAULT); 414 return -EFAULT;
415 if (al_hreq.buflen < sizeof(struct attrlist) || 415 if (al_hreq.buflen < sizeof(struct attrlist) ||
416 al_hreq.buflen > XATTR_LIST_MAX) 416 al_hreq.buflen > XATTR_LIST_MAX)
417 return -XFS_ERROR(EINVAL); 417 return -EINVAL;
418 418
419 /* 419 /*
420 * Reject flags, only allow namespaces. 420 * Reject flags, only allow namespaces.
421 */ 421 */
422 if (al_hreq.flags & ~(ATTR_ROOT | ATTR_SECURE)) 422 if (al_hreq.flags & ~(ATTR_ROOT | ATTR_SECURE))
423 return -XFS_ERROR(EINVAL); 423 return -EINVAL;
424 424
425 dentry = xfs_handlereq_to_dentry(parfilp, &al_hreq.hreq); 425 dentry = xfs_handlereq_to_dentry(parfilp, &al_hreq.hreq);
426 if (IS_ERR(dentry)) 426 if (IS_ERR(dentry))
@@ -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
@@ -524,9 +521,9 @@ xfs_attrmulti_by_handle(
524 unsigned char *attr_name; 521 unsigned char *attr_name;
525 522
526 if (!capable(CAP_SYS_ADMIN)) 523 if (!capable(CAP_SYS_ADMIN))
527 return -XFS_ERROR(EPERM); 524 return -EPERM;
528 if (copy_from_user(&am_hreq, arg, sizeof(xfs_fsop_attrmulti_handlereq_t))) 525 if (copy_from_user(&am_hreq, arg, sizeof(xfs_fsop_attrmulti_handlereq_t)))
529 return -XFS_ERROR(EFAULT); 526 return -EFAULT;
530 527
531 /* overflow check */ 528 /* overflow check */
532 if (am_hreq.opcount >= INT_MAX / sizeof(xfs_attr_multiop_t)) 529 if (am_hreq.opcount >= INT_MAX / sizeof(xfs_attr_multiop_t))
@@ -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 = XFS_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
@@ -625,16 +622,16 @@ xfs_ioc_space(
625 */ 622 */
626 if (!xfs_sb_version_hasextflgbit(&ip->i_mount->m_sb) && 623 if (!xfs_sb_version_hasextflgbit(&ip->i_mount->m_sb) &&
627 !capable(CAP_SYS_ADMIN)) 624 !capable(CAP_SYS_ADMIN))
628 return -XFS_ERROR(EPERM); 625 return -EPERM;
629 626
630 if (inode->i_flags & (S_IMMUTABLE|S_APPEND)) 627 if (inode->i_flags & (S_IMMUTABLE|S_APPEND))
631 return -XFS_ERROR(EPERM); 628 return -EPERM;
632 629
633 if (!(filp->f_mode & FMODE_WRITE)) 630 if (!(filp->f_mode & FMODE_WRITE))
634 return -XFS_ERROR(EBADF); 631 return -EBADF;
635 632
636 if (!S_ISREG(inode->i_mode)) 633 if (!S_ISREG(inode->i_mode))
637 return -XFS_ERROR(EINVAL); 634 return -EINVAL;
638 635
639 error = mnt_want_write_file(filp); 636 error = mnt_want_write_file(filp);
640 if (error) 637 if (error)
@@ -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 = XFS_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 = XFS_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 = XFS_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 = XFS_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
@@ -781,19 +778,19 @@ xfs_ioc_bulkstat(
781 return -EPERM; 778 return -EPERM;
782 779
783 if (XFS_FORCED_SHUTDOWN(mp)) 780 if (XFS_FORCED_SHUTDOWN(mp))
784 return -XFS_ERROR(EIO); 781 return -EIO;
785 782
786 if (copy_from_user(&bulkreq, arg, sizeof(xfs_fsop_bulkreq_t))) 783 if (copy_from_user(&bulkreq, arg, sizeof(xfs_fsop_bulkreq_t)))
787 return -XFS_ERROR(EFAULT); 784 return -EFAULT;
788 785
789 if (copy_from_user(&inlast, bulkreq.lastip, sizeof(__s64))) 786 if (copy_from_user(&inlast, bulkreq.lastip, sizeof(__s64)))
790 return -XFS_ERROR(EFAULT); 787 return -EFAULT;
791 788
792 if ((count = bulkreq.icount) <= 0) 789 if ((count = bulkreq.icount) <= 0)
793 return -XFS_ERROR(EINVAL); 790 return -EINVAL;
794 791
795 if (bulkreq.ubuffer == NULL) 792 if (bulkreq.ubuffer == NULL)
796 return -XFS_ERROR(EINVAL); 793 return -EINVAL;
797 794
798 if (cmd == XFS_IOC_FSINUMBERS) 795 if (cmd == XFS_IOC_FSINUMBERS)
799 error = xfs_inumbers(mp, &inlast, &count, 796 error = xfs_inumbers(mp, &inlast, &count,
@@ -807,15 +804,15 @@ 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,
814 sizeof(xfs_ino_t))) 811 sizeof(xfs_ino_t)))
815 return -XFS_ERROR(EFAULT); 812 return -EFAULT;
816 813
817 if (copy_to_user(bulkreq.ocount, &count, sizeof(count))) 814 if (copy_to_user(bulkreq.ocount, &count, sizeof(count)))
818 return -XFS_ERROR(EFAULT); 815 return -EFAULT;
819 } 816 }
820 817
821 return 0; 818 return 0;
@@ -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
@@ -839,7 +836,7 @@ xfs_ioc_fsgeometry_v1(
839 * xfs_fsop_geom_t that xfs_fs_geometry() fills in. 836 * xfs_fsop_geom_t that xfs_fs_geometry() fills in.
840 */ 837 */
841 if (copy_to_user(arg, &fsgeo, sizeof(xfs_fsop_geom_v1_t))) 838 if (copy_to_user(arg, &fsgeo, sizeof(xfs_fsop_geom_v1_t)))
842 return -XFS_ERROR(EFAULT); 839 return -EFAULT;
843 return 0; 840 return 0;
844} 841}
845 842
@@ -853,10 +850,10 @@ 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 -XFS_ERROR(EFAULT); 856 return -EFAULT;
860 return 0; 857 return 0;
861} 858}
862 859
@@ -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 XFS_ERROR(EROFS); 1041 return -EROFS;
1045 if (XFS_FORCED_SHUTDOWN(mp)) 1042 if (XFS_FORCED_SHUTDOWN(mp))
1046 return XFS_ERROR(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 XFS_ERROR(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 = XFS_ERROR(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 = XFS_ERROR(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 = XFS_ERROR(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 = XFS_ERROR(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 = XFS_ERROR(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 = XFS_ERROR(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 = XFS_ERROR(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 = XFS_ERROR(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 = XFS_ERROR(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 XFS_ERROR(EFAULT); 1356 return -EFAULT;
1360 1357
1361 *ap += sizeof(struct getbmap); 1358 *ap += sizeof(struct getbmap);
1362 return 0; 1359 return 0;
@@ -1373,10 +1370,10 @@ xfs_ioc_getbmap(
1373 int error; 1370 int error;
1374 1371
1375 if (copy_from_user(&bmx, arg, sizeof(struct getbmapx))) 1372 if (copy_from_user(&bmx, arg, sizeof(struct getbmapx)))
1376 return -XFS_ERROR(EFAULT); 1373 return -EFAULT;
1377 1374
1378 if (bmx.bmv_count < 2) 1375 if (bmx.bmv_count < 2)
1379 return -XFS_ERROR(EINVAL); 1376 return -EINVAL;
1380 1377
1381 bmx.bmv_iflags = (cmd == XFS_IOC_GETBMAPA ? BMV_IF_ATTRFORK : 0); 1378 bmx.bmv_iflags = (cmd == XFS_IOC_GETBMAPA ? BMV_IF_ATTRFORK : 0);
1382 if (ioflags & IO_INVIS) 1379 if (ioflags & IO_INVIS)
@@ -1385,11 +1382,11 @@ 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)))
1392 return -XFS_ERROR(EFAULT); 1389 return -EFAULT;
1393 return 0; 1390 return 0;
1394} 1391}
1395 1392
@@ -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 XFS_ERROR(EFAULT); 1399 return -EFAULT;
1403 1400
1404 *ap += sizeof(struct getbmapx); 1401 *ap += sizeof(struct getbmapx);
1405 return 0; 1402 return 0;
@@ -1414,22 +1411,22 @@ xfs_ioc_getbmapx(
1414 int error; 1411 int error;
1415 1412
1416 if (copy_from_user(&bmx, arg, sizeof(bmx))) 1413 if (copy_from_user(&bmx, arg, sizeof(bmx)))
1417 return -XFS_ERROR(EFAULT); 1414 return -EFAULT;
1418 1415
1419 if (bmx.bmv_count < 2) 1416 if (bmx.bmv_count < 2)
1420 return -XFS_ERROR(EINVAL); 1417 return -EINVAL;
1421 1418
1422 if (bmx.bmv_iflags & (~BMV_IF_VALID)) 1419 if (bmx.bmv_iflags & (~BMV_IF_VALID))
1423 return -XFS_ERROR(EINVAL); 1420 return -EINVAL;
1424 1421
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)))
1432 return -XFS_ERROR(EFAULT); 1429 return -EFAULT;
1433 1430
1434 return 0; 1431 return 0;
1435} 1432}
@@ -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 = XFS_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 = XFS_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 = XFS_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 = XFS_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 = XFS_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 = XFS_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 = XFS_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 = XFS_ERROR(EIO); 1489 error = -EIO;
1493 goto out_put_tmp_file; 1490 goto out_put_tmp_file;
1494 } 1491 }
1495 1492
@@ -1542,7 +1539,7 @@ xfs_file_ioctl(
1542 xfs_flock64_t bf; 1539 xfs_flock64_t bf;
1543 1540
1544 if (copy_from_user(&bf, arg, sizeof(bf))) 1541 if (copy_from_user(&bf, arg, sizeof(bf)))
1545 return -XFS_ERROR(EFAULT); 1542 return -EFAULT;
1546 return xfs_ioc_space(ip, inode, filp, ioflags, cmd, &bf); 1543 return xfs_ioc_space(ip, inode, filp, ioflags, cmd, &bf);
1547 } 1544 }
1548 case XFS_IOC_DIOINFO: { 1545 case XFS_IOC_DIOINFO: {
@@ -1555,7 +1552,7 @@ xfs_file_ioctl(
1555 da.d_maxiosz = INT_MAX & ~(da.d_miniosz - 1); 1552 da.d_maxiosz = INT_MAX & ~(da.d_miniosz - 1);
1556 1553
1557 if (copy_to_user(arg, &da, sizeof(da))) 1554 if (copy_to_user(arg, &da, sizeof(da)))
1558 return -XFS_ERROR(EFAULT); 1555 return -EFAULT;
1559 return 0; 1556 return 0;
1560 } 1557 }
1561 1558
@@ -1588,7 +1585,7 @@ xfs_file_ioctl(
1588 struct fsdmidata dmi; 1585 struct fsdmidata dmi;
1589 1586
1590 if (copy_from_user(&dmi, arg, sizeof(dmi))) 1587 if (copy_from_user(&dmi, arg, sizeof(dmi)))
1591 return -XFS_ERROR(EFAULT); 1588 return -EFAULT;
1592 1589
1593 error = mnt_want_write_file(filp); 1590 error = mnt_want_write_file(filp);
1594 if (error) 1591 if (error)
@@ -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:
@@ -1613,14 +1610,14 @@ xfs_file_ioctl(
1613 xfs_fsop_handlereq_t hreq; 1610 xfs_fsop_handlereq_t hreq;
1614 1611
1615 if (copy_from_user(&hreq, arg, sizeof(hreq))) 1612 if (copy_from_user(&hreq, arg, sizeof(hreq)))
1616 return -XFS_ERROR(EFAULT); 1613 return -EFAULT;
1617 return xfs_find_handle(cmd, &hreq); 1614 return xfs_find_handle(cmd, &hreq);
1618 } 1615 }
1619 case XFS_IOC_OPEN_BY_HANDLE: { 1616 case XFS_IOC_OPEN_BY_HANDLE: {
1620 xfs_fsop_handlereq_t hreq; 1617 xfs_fsop_handlereq_t hreq;
1621 1618
1622 if (copy_from_user(&hreq, arg, sizeof(xfs_fsop_handlereq_t))) 1619 if (copy_from_user(&hreq, arg, sizeof(xfs_fsop_handlereq_t)))
1623 return -XFS_ERROR(EFAULT); 1620 return -EFAULT;
1624 return xfs_open_by_handle(filp, &hreq); 1621 return xfs_open_by_handle(filp, &hreq);
1625 } 1622 }
1626 case XFS_IOC_FSSETDM_BY_HANDLE: 1623 case XFS_IOC_FSSETDM_BY_HANDLE:
@@ -1630,7 +1627,7 @@ xfs_file_ioctl(
1630 xfs_fsop_handlereq_t hreq; 1627 xfs_fsop_handlereq_t hreq;
1631 1628
1632 if (copy_from_user(&hreq, arg, sizeof(xfs_fsop_handlereq_t))) 1629 if (copy_from_user(&hreq, arg, sizeof(xfs_fsop_handlereq_t)))
1633 return -XFS_ERROR(EFAULT); 1630 return -EFAULT;
1634 return xfs_readlink_by_handle(filp, &hreq); 1631 return xfs_readlink_by_handle(filp, &hreq);
1635 } 1632 }
1636 case XFS_IOC_ATTRLIST_BY_HANDLE: 1633 case XFS_IOC_ATTRLIST_BY_HANDLE:
@@ -1643,13 +1640,13 @@ xfs_file_ioctl(
1643 struct xfs_swapext sxp; 1640 struct xfs_swapext sxp;
1644 1641
1645 if (copy_from_user(&sxp, arg, sizeof(xfs_swapext_t))) 1642 if (copy_from_user(&sxp, arg, sizeof(xfs_swapext_t)))
1646 return -XFS_ERROR(EFAULT); 1643 return -EFAULT;
1647 error = mnt_want_write_file(filp); 1644 error = mnt_want_write_file(filp);
1648 if (error) 1645 if (error)
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,10 +1654,10 @@ 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 -XFS_ERROR(EFAULT); 1660 return -EFAULT;
1664 return 0; 1661 return 0;
1665 } 1662 }
1666 1663
@@ -1672,10 +1669,10 @@ xfs_file_ioctl(
1672 return -EPERM; 1669 return -EPERM;
1673 1670
1674 if (mp->m_flags & XFS_MOUNT_RDONLY) 1671 if (mp->m_flags & XFS_MOUNT_RDONLY)
1675 return -XFS_ERROR(EROFS); 1672 return -EROFS;
1676 1673
1677 if (copy_from_user(&inout, arg, sizeof(inout))) 1674 if (copy_from_user(&inout, arg, sizeof(inout)))
1678 return -XFS_ERROR(EFAULT); 1675 return -EFAULT;
1679 1676
1680 error = mnt_want_write_file(filp); 1677 error = mnt_want_write_file(filp);
1681 if (error) 1678 if (error)
@@ -1686,10 +1683,10 @@ 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 -XFS_ERROR(EFAULT); 1689 return -EFAULT;
1693 return 0; 1690 return 0;
1694 } 1691 }
1695 1692
@@ -1701,10 +1698,10 @@ 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 -XFS_ERROR(EFAULT); 1704 return -EFAULT;
1708 1705
1709 return 0; 1706 return 0;
1710 } 1707 }
@@ -1713,42 +1710,42 @@ xfs_file_ioctl(
1713 xfs_growfs_data_t in; 1710 xfs_growfs_data_t in;
1714 1711
1715 if (copy_from_user(&in, arg, sizeof(in))) 1712 if (copy_from_user(&in, arg, sizeof(in)))
1716 return -XFS_ERROR(EFAULT); 1713 return -EFAULT;
1717 1714
1718 error = mnt_want_write_file(filp); 1715 error = mnt_want_write_file(filp);
1719 if (error) 1716 if (error)
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: {
1727 xfs_growfs_log_t in; 1724 xfs_growfs_log_t in;
1728 1725
1729 if (copy_from_user(&in, arg, sizeof(in))) 1726 if (copy_from_user(&in, arg, sizeof(in)))
1730 return -XFS_ERROR(EFAULT); 1727 return -EFAULT;
1731 1728
1732 error = mnt_want_write_file(filp); 1729 error = mnt_want_write_file(filp);
1733 if (error) 1730 if (error)
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: {
1741 xfs_growfs_rt_t in; 1738 xfs_growfs_rt_t in;
1742 1739
1743 if (copy_from_user(&in, arg, sizeof(in))) 1740 if (copy_from_user(&in, arg, sizeof(in)))
1744 return -XFS_ERROR(EFAULT); 1741 return -EFAULT;
1745 1742
1746 error = mnt_want_write_file(filp); 1743 error = mnt_want_write_file(filp);
1747 if (error) 1744 if (error)
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: {
@@ -1758,10 +1755,9 @@ xfs_file_ioctl(
1758 return -EPERM; 1755 return -EPERM;
1759 1756
1760 if (get_user(in, (__uint32_t __user *)arg)) 1757 if (get_user(in, (__uint32_t __user *)arg))
1761 return -XFS_ERROR(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: {
@@ -1771,18 +1767,16 @@ xfs_file_ioctl(
1771 return -EPERM; 1767 return -EPERM;
1772 1768
1773 if (copy_from_user(&in, arg, sizeof(in))) 1769 if (copy_from_user(&in, arg, sizeof(in)))
1774 return -XFS_ERROR(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;
@@ -1792,16 +1786,16 @@ xfs_file_ioctl(
1792 return -EPERM; 1786 return -EPERM;
1793 1787
1794 if (mp->m_flags & XFS_MOUNT_RDONLY) 1788 if (mp->m_flags & XFS_MOUNT_RDONLY)
1795 return -XFS_ERROR(EROFS); 1789 return -EROFS;
1796 1790
1797 if (copy_from_user(&eofb, arg, sizeof(eofb))) 1791 if (copy_from_user(&eofb, arg, sizeof(eofb)))
1798 return -XFS_ERROR(EFAULT); 1792 return -EFAULT;
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 944d5baa710a..e65ea67e3ae3 100644
--- a/fs/xfs/xfs_ioctl32.c
+++ b/fs/xfs/xfs_ioctl32.c
@@ -56,7 +56,7 @@ xfs_compat_flock64_copyin(
56 get_user(bf->l_sysid, &arg32->l_sysid) || 56 get_user(bf->l_sysid, &arg32->l_sysid) ||
57 get_user(bf->l_pid, &arg32->l_pid) || 57 get_user(bf->l_pid, &arg32->l_pid) ||
58 copy_from_user(bf->l_pad, &arg32->l_pad, 4*sizeof(u32))) 58 copy_from_user(bf->l_pad, &arg32->l_pad, 4*sizeof(u32)))
59 return -XFS_ERROR(EFAULT); 59 return -EFAULT;
60 return 0; 60 return 0;
61} 61}
62 62
@@ -70,10 +70,10 @@ 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 -XFS_ERROR(EFAULT); 76 return -EFAULT;
77 return 0; 77 return 0;
78} 78}
79 79
@@ -84,7 +84,7 @@ xfs_compat_growfs_data_copyin(
84{ 84{
85 if (get_user(in->newblocks, &arg32->newblocks) || 85 if (get_user(in->newblocks, &arg32->newblocks) ||
86 get_user(in->imaxpct, &arg32->imaxpct)) 86 get_user(in->imaxpct, &arg32->imaxpct))
87 return -XFS_ERROR(EFAULT); 87 return -EFAULT;
88 return 0; 88 return 0;
89} 89}
90 90
@@ -95,7 +95,7 @@ xfs_compat_growfs_rt_copyin(
95{ 95{
96 if (get_user(in->newblocks, &arg32->newblocks) || 96 if (get_user(in->newblocks, &arg32->newblocks) ||
97 get_user(in->extsize, &arg32->extsize)) 97 get_user(in->extsize, &arg32->extsize))
98 return -XFS_ERROR(EFAULT); 98 return -EFAULT;
99 return 0; 99 return 0;
100} 100}
101 101
@@ -113,7 +113,7 @@ xfs_inumbers_fmt_compat(
113 if (put_user(buffer[i].xi_startino, &p32[i].xi_startino) || 113 if (put_user(buffer[i].xi_startino, &p32[i].xi_startino) ||
114 put_user(buffer[i].xi_alloccount, &p32[i].xi_alloccount) || 114 put_user(buffer[i].xi_alloccount, &p32[i].xi_alloccount) ||
115 put_user(buffer[i].xi_allocmask, &p32[i].xi_allocmask)) 115 put_user(buffer[i].xi_allocmask, &p32[i].xi_allocmask))
116 return -XFS_ERROR(EFAULT); 116 return -EFAULT;
117 } 117 }
118 *written = count * sizeof(*p32); 118 *written = count * sizeof(*p32);
119 return 0; 119 return 0;
@@ -132,7 +132,7 @@ xfs_ioctl32_bstime_copyin(
132 132
133 if (get_user(sec32, &bstime32->tv_sec) || 133 if (get_user(sec32, &bstime32->tv_sec) ||
134 get_user(bstime->tv_nsec, &bstime32->tv_nsec)) 134 get_user(bstime->tv_nsec, &bstime32->tv_nsec))
135 return -XFS_ERROR(EFAULT); 135 return -EFAULT;
136 bstime->tv_sec = sec32; 136 bstime->tv_sec = sec32;
137 return 0; 137 return 0;
138} 138}
@@ -164,7 +164,7 @@ xfs_ioctl32_bstat_copyin(
164 get_user(bstat->bs_dmevmask, &bstat32->bs_dmevmask) || 164 get_user(bstat->bs_dmevmask, &bstat32->bs_dmevmask) ||
165 get_user(bstat->bs_dmstate, &bstat32->bs_dmstate) || 165 get_user(bstat->bs_dmstate, &bstat32->bs_dmstate) ||
166 get_user(bstat->bs_aextents, &bstat32->bs_aextents)) 166 get_user(bstat->bs_aextents, &bstat32->bs_aextents))
167 return -XFS_ERROR(EFAULT); 167 return -EFAULT;
168 return 0; 168 return 0;
169} 169}
170 170
@@ -180,7 +180,7 @@ xfs_bstime_store_compat(
180 sec32 = p->tv_sec; 180 sec32 = p->tv_sec;
181 if (put_user(sec32, &p32->tv_sec) || 181 if (put_user(sec32, &p32->tv_sec) ||
182 put_user(p->tv_nsec, &p32->tv_nsec)) 182 put_user(p->tv_nsec, &p32->tv_nsec))
183 return -XFS_ERROR(EFAULT); 183 return -EFAULT;
184 return 0; 184 return 0;
185} 185}
186 186
@@ -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 XFS_ERROR(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 XFS_ERROR(EFAULT); 221 return -EFAULT;
222 if (ubused) 222 if (ubused)
223 *ubused = sizeof(*p32); 223 *ubused = sizeof(*p32);
224 return 0; 224 return 0;
@@ -256,30 +256,30 @@ xfs_compat_ioc_bulkstat(
256 /* should be called again (unused here, but used in dmapi) */ 256 /* should be called again (unused here, but used in dmapi) */
257 257
258 if (!capable(CAP_SYS_ADMIN)) 258 if (!capable(CAP_SYS_ADMIN))
259 return -XFS_ERROR(EPERM); 259 return -EPERM;
260 260
261 if (XFS_FORCED_SHUTDOWN(mp)) 261 if (XFS_FORCED_SHUTDOWN(mp))
262 return -XFS_ERROR(EIO); 262 return -EIO;
263 263
264 if (get_user(addr, &p32->lastip)) 264 if (get_user(addr, &p32->lastip))
265 return -XFS_ERROR(EFAULT); 265 return -EFAULT;
266 bulkreq.lastip = compat_ptr(addr); 266 bulkreq.lastip = compat_ptr(addr);
267 if (get_user(bulkreq.icount, &p32->icount) || 267 if (get_user(bulkreq.icount, &p32->icount) ||
268 get_user(addr, &p32->ubuffer)) 268 get_user(addr, &p32->ubuffer))
269 return -XFS_ERROR(EFAULT); 269 return -EFAULT;
270 bulkreq.ubuffer = compat_ptr(addr); 270 bulkreq.ubuffer = compat_ptr(addr);
271 if (get_user(addr, &p32->ocount)) 271 if (get_user(addr, &p32->ocount))
272 return -XFS_ERROR(EFAULT); 272 return -EFAULT;
273 bulkreq.ocount = compat_ptr(addr); 273 bulkreq.ocount = compat_ptr(addr);
274 274
275 if (copy_from_user(&inlast, bulkreq.lastip, sizeof(__s64))) 275 if (copy_from_user(&inlast, bulkreq.lastip, sizeof(__s64)))
276 return -XFS_ERROR(EFAULT); 276 return -EFAULT;
277 277
278 if ((count = bulkreq.icount) <= 0) 278 if ((count = bulkreq.icount) <= 0)
279 return -XFS_ERROR(EINVAL); 279 return -EINVAL;
280 280
281 if (bulkreq.ubuffer == NULL) 281 if (bulkreq.ubuffer == NULL)
282 return -XFS_ERROR(EINVAL); 282 return -EINVAL;
283 283
284 if (cmd == XFS_IOC_FSINUMBERS_32) { 284 if (cmd == XFS_IOC_FSINUMBERS_32) {
285 error = xfs_inumbers(mp, &inlast, &count, 285 error = xfs_inumbers(mp, &inlast, &count,
@@ -294,17 +294,17 @@ 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 = XFS_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,
303 sizeof(xfs_ino_t))) 303 sizeof(xfs_ino_t)))
304 return -XFS_ERROR(EFAULT); 304 return -EFAULT;
305 305
306 if (copy_to_user(bulkreq.ocount, &count, sizeof(count))) 306 if (copy_to_user(bulkreq.ocount, &count, sizeof(count)))
307 return -XFS_ERROR(EFAULT); 307 return -EFAULT;
308 } 308 }
309 309
310 return 0; 310 return 0;
@@ -318,7 +318,7 @@ xfs_compat_handlereq_copyin(
318 compat_xfs_fsop_handlereq_t hreq32; 318 compat_xfs_fsop_handlereq_t hreq32;
319 319
320 if (copy_from_user(&hreq32, arg32, sizeof(compat_xfs_fsop_handlereq_t))) 320 if (copy_from_user(&hreq32, arg32, sizeof(compat_xfs_fsop_handlereq_t)))
321 return -XFS_ERROR(EFAULT); 321 return -EFAULT;
322 322
323 hreq->fd = hreq32.fd; 323 hreq->fd = hreq32.fd;
324 hreq->path = compat_ptr(hreq32.path); 324 hreq->path = compat_ptr(hreq32.path);
@@ -352,19 +352,19 @@ xfs_compat_attrlist_by_handle(
352 char *kbuf; 352 char *kbuf;
353 353
354 if (!capable(CAP_SYS_ADMIN)) 354 if (!capable(CAP_SYS_ADMIN))
355 return -XFS_ERROR(EPERM); 355 return -EPERM;
356 if (copy_from_user(&al_hreq, arg, 356 if (copy_from_user(&al_hreq, arg,
357 sizeof(compat_xfs_fsop_attrlist_handlereq_t))) 357 sizeof(compat_xfs_fsop_attrlist_handlereq_t)))
358 return -XFS_ERROR(EFAULT); 358 return -EFAULT;
359 if (al_hreq.buflen < sizeof(struct attrlist) || 359 if (al_hreq.buflen < sizeof(struct attrlist) ||
360 al_hreq.buflen > XATTR_LIST_MAX) 360 al_hreq.buflen > XATTR_LIST_MAX)
361 return -XFS_ERROR(EINVAL); 361 return -EINVAL;
362 362
363 /* 363 /*
364 * Reject flags, only allow namespaces. 364 * Reject flags, only allow namespaces.
365 */ 365 */
366 if (al_hreq.flags & ~(ATTR_ROOT | ATTR_SECURE)) 366 if (al_hreq.flags & ~(ATTR_ROOT | ATTR_SECURE))
367 return -XFS_ERROR(EINVAL); 367 return -EINVAL;
368 368
369 dentry = xfs_compat_handlereq_to_dentry(parfilp, &al_hreq.hreq); 369 dentry = xfs_compat_handlereq_to_dentry(parfilp, &al_hreq.hreq);
370 if (IS_ERR(dentry)) 370 if (IS_ERR(dentry))
@@ -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;
@@ -404,10 +404,10 @@ xfs_compat_attrmulti_by_handle(
404 unsigned char *attr_name; 404 unsigned char *attr_name;
405 405
406 if (!capable(CAP_SYS_ADMIN)) 406 if (!capable(CAP_SYS_ADMIN))
407 return -XFS_ERROR(EPERM); 407 return -EPERM;
408 if (copy_from_user(&am_hreq, arg, 408 if (copy_from_user(&am_hreq, arg,
409 sizeof(compat_xfs_fsop_attrmulti_handlereq_t))) 409 sizeof(compat_xfs_fsop_attrmulti_handlereq_t)))
410 return -XFS_ERROR(EFAULT); 410 return -EFAULT;
411 411
412 /* overflow check */ 412 /* overflow check */
413 if (am_hreq.opcount >= INT_MAX / sizeof(compat_xfs_attr_multiop_t)) 413 if (am_hreq.opcount >= INT_MAX / sizeof(compat_xfs_attr_multiop_t))
@@ -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 = XFS_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
@@ -496,26 +496,26 @@ xfs_compat_fssetdm_by_handle(
496 struct dentry *dentry; 496 struct dentry *dentry;
497 497
498 if (!capable(CAP_MKNOD)) 498 if (!capable(CAP_MKNOD))
499 return -XFS_ERROR(EPERM); 499 return -EPERM;
500 if (copy_from_user(&dmhreq, arg, 500 if (copy_from_user(&dmhreq, arg,
501 sizeof(compat_xfs_fsop_setdm_handlereq_t))) 501 sizeof(compat_xfs_fsop_setdm_handlereq_t)))
502 return -XFS_ERROR(EFAULT); 502 return -EFAULT;
503 503
504 dentry = xfs_compat_handlereq_to_dentry(parfilp, &dmhreq.hreq); 504 dentry = xfs_compat_handlereq_to_dentry(parfilp, &dmhreq.hreq);
505 if (IS_ERR(dentry)) 505 if (IS_ERR(dentry))
506 return PTR_ERR(dentry); 506 return PTR_ERR(dentry);
507 507
508 if (IS_IMMUTABLE(dentry->d_inode) || IS_APPEND(dentry->d_inode)) { 508 if (IS_IMMUTABLE(dentry->d_inode) || IS_APPEND(dentry->d_inode)) {
509 error = -XFS_ERROR(EPERM); 509 error = -EPERM;
510 goto out; 510 goto out;
511 } 511 }
512 512
513 if (copy_from_user(&fsd, compat_ptr(dmhreq.data), sizeof(fsd))) { 513 if (copy_from_user(&fsd, compat_ptr(dmhreq.data), sizeof(fsd))) {
514 error = -XFS_ERROR(EFAULT); 514 error = -EFAULT;
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:
@@ -588,7 +588,7 @@ xfs_file_compat_ioctl(
588 struct xfs_flock64 bf; 588 struct xfs_flock64 bf;
589 589
590 if (xfs_compat_flock64_copyin(&bf, arg)) 590 if (xfs_compat_flock64_copyin(&bf, arg))
591 return -XFS_ERROR(EFAULT); 591 return -EFAULT;
592 cmd = _NATIVE_IOC(cmd, struct xfs_flock64); 592 cmd = _NATIVE_IOC(cmd, struct xfs_flock64);
593 return xfs_ioc_space(ip, inode, filp, ioflags, cmd, &bf); 593 return xfs_ioc_space(ip, inode, filp, ioflags, cmd, &bf);
594 } 594 }
@@ -598,25 +598,25 @@ xfs_file_compat_ioctl(
598 struct xfs_growfs_data in; 598 struct xfs_growfs_data in;
599 599
600 if (xfs_compat_growfs_data_copyin(&in, arg)) 600 if (xfs_compat_growfs_data_copyin(&in, arg))
601 return -XFS_ERROR(EFAULT); 601 return -EFAULT;
602 error = mnt_want_write_file(filp); 602 error = mnt_want_write_file(filp);
603 if (error) 603 if (error)
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;
611 611
612 if (xfs_compat_growfs_rt_copyin(&in, arg)) 612 if (xfs_compat_growfs_rt_copyin(&in, arg))
613 return -XFS_ERROR(EFAULT); 613 return -EFAULT;
614 error = mnt_want_write_file(filp); 614 error = mnt_want_write_file(filp);
615 if (error) 615 if (error)
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 */
@@ -633,13 +633,13 @@ xfs_file_compat_ioctl(
633 if (copy_from_user(&sxp, sxu, 633 if (copy_from_user(&sxp, sxu,
634 offsetof(struct xfs_swapext, sx_stat)) || 634 offsetof(struct xfs_swapext, sx_stat)) ||
635 xfs_ioctl32_bstat_copyin(&sxp.sx_stat, &sxu->sx_stat)) 635 xfs_ioctl32_bstat_copyin(&sxp.sx_stat, &sxu->sx_stat))
636 return -XFS_ERROR(EFAULT); 636 return -EFAULT;
637 error = mnt_want_write_file(filp); 637 error = mnt_want_write_file(filp);
638 if (error) 638 if (error)
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:
@@ -651,7 +651,7 @@ xfs_file_compat_ioctl(
651 struct xfs_fsop_handlereq hreq; 651 struct xfs_fsop_handlereq hreq;
652 652
653 if (xfs_compat_handlereq_copyin(&hreq, arg)) 653 if (xfs_compat_handlereq_copyin(&hreq, arg))
654 return -XFS_ERROR(EFAULT); 654 return -EFAULT;
655 cmd = _NATIVE_IOC(cmd, struct xfs_fsop_handlereq); 655 cmd = _NATIVE_IOC(cmd, struct xfs_fsop_handlereq);
656 return xfs_find_handle(cmd, &hreq); 656 return xfs_find_handle(cmd, &hreq);
657 } 657 }
@@ -659,14 +659,14 @@ xfs_file_compat_ioctl(
659 struct xfs_fsop_handlereq hreq; 659 struct xfs_fsop_handlereq hreq;
660 660
661 if (xfs_compat_handlereq_copyin(&hreq, arg)) 661 if (xfs_compat_handlereq_copyin(&hreq, arg))
662 return -XFS_ERROR(EFAULT); 662 return -EFAULT;
663 return xfs_open_by_handle(filp, &hreq); 663 return xfs_open_by_handle(filp, &hreq);
664 } 664 }
665 case XFS_IOC_READLINK_BY_HANDLE_32: { 665 case XFS_IOC_READLINK_BY_HANDLE_32: {
666 struct xfs_fsop_handlereq hreq; 666 struct xfs_fsop_handlereq hreq;
667 667
668 if (xfs_compat_handlereq_copyin(&hreq, arg)) 668 if (xfs_compat_handlereq_copyin(&hreq, arg))
669 return -XFS_ERROR(EFAULT); 669 return -EFAULT;
670 return xfs_readlink_by_handle(filp, &hreq); 670 return xfs_readlink_by_handle(filp, &hreq);
671 } 671 }
672 case XFS_IOC_ATTRLIST_BY_HANDLE_32: 672 case XFS_IOC_ATTRLIST_BY_HANDLE_32:
@@ -676,6 +676,6 @@ xfs_file_compat_ioctl(
676 case XFS_IOC_FSSETDM_BY_HANDLE_32: 676 case XFS_IOC_FSSETDM_BY_HANDLE_32:
677 return xfs_compat_fssetdm_by_handle(filp, arg); 677 return xfs_compat_fssetdm_by_handle(filp, arg);
678 default: 678 default:
679 return -XFS_ERROR(ENOIOCTLCMD); 679 return -ENOIOCTLCMD;
680 } 680 }
681} 681}
diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c
index 6d3ec2b6ee29..17400f0f076c 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
@@ -138,7 +138,7 @@ xfs_iomap_write_direct(
138 138
139 error = xfs_qm_dqattach(ip, 0); 139 error = xfs_qm_dqattach(ip, 0);
140 if (error) 140 if (error)
141 return XFS_ERROR(error); 141 return error;
142 142
143 rt = XFS_IS_REALTIME_INODE(ip); 143 rt = XFS_IS_REALTIME_INODE(ip);
144 extsz = xfs_get_extsz_hint(ip); 144 extsz = xfs_get_extsz_hint(ip);
@@ -148,7 +148,7 @@ xfs_iomap_write_direct(
148 if ((offset + count) > XFS_ISIZE(ip)) { 148 if ((offset + count) > XFS_ISIZE(ip)) {
149 error = xfs_iomap_eof_align_last_fsb(mp, ip, extsz, &last_fsb); 149 error = xfs_iomap_eof_align_last_fsb(mp, ip, extsz, &last_fsb);
150 if (error) 150 if (error)
151 return XFS_ERROR(error); 151 return error;
152 } else { 152 } else {
153 if (nmaps && (imap->br_startblock == HOLESTARTBLOCK)) 153 if (nmaps && (imap->br_startblock == HOLESTARTBLOCK))
154 last_fsb = MIN(last_fsb, (xfs_fileoff_t) 154 last_fsb = MIN(last_fsb, (xfs_fileoff_t)
@@ -188,7 +188,7 @@ xfs_iomap_write_direct(
188 */ 188 */
189 if (error) { 189 if (error) {
190 xfs_trans_cancel(tp, 0); 190 xfs_trans_cancel(tp, 0);
191 return XFS_ERROR(error); 191 return error;
192 } 192 }
193 193
194 xfs_ilock(ip, XFS_ILOCK_EXCL); 194 xfs_ilock(ip, XFS_ILOCK_EXCL);
@@ -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 = XFS_ERROR(ENOSPC); 228 error = -ENOSPC;
229 goto out_unlock; 229 goto out_unlock;
230 } 230 }
231 231
@@ -552,7 +552,7 @@ xfs_iomap_write_delay(
552 */ 552 */
553 error = xfs_qm_dqattach_locked(ip, 0); 553 error = xfs_qm_dqattach_locked(ip, 0);
554 if (error) 554 if (error)
555 return XFS_ERROR(error); 555 return error;
556 556
557 extsz = xfs_get_extsz_hint(ip); 557 extsz = xfs_get_extsz_hint(ip);
558 offset_fsb = XFS_B_TO_FSBT(mp, offset); 558 offset_fsb = XFS_B_TO_FSBT(mp, offset);
@@ -596,11 +596,11 @@ 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 XFS_ERROR(error); 603 return error;
604 } 604 }
605 605
606 /* 606 /*
@@ -614,7 +614,7 @@ retry:
614 error = 0; 614 error = 0;
615 goto retry; 615 goto retry;
616 } 616 }
617 return XFS_ERROR(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)))
@@ -663,7 +663,7 @@ xfs_iomap_write_allocate(
663 */ 663 */
664 error = xfs_qm_dqattach(ip, 0); 664 error = xfs_qm_dqattach(ip, 0);
665 if (error) 665 if (error)
666 return XFS_ERROR(error); 666 return error;
667 667
668 offset_fsb = XFS_B_TO_FSBT(mp, offset); 668 offset_fsb = XFS_B_TO_FSBT(mp, offset);
669 count_fsb = imap->br_blockcount; 669 count_fsb = imap->br_blockcount;
@@ -690,7 +690,7 @@ xfs_iomap_write_allocate(
690 nres, 0); 690 nres, 0);
691 if (error) { 691 if (error) {
692 xfs_trans_cancel(tp, 0); 692 xfs_trans_cancel(tp, 0);
693 return XFS_ERROR(error); 693 return error;
694 } 694 }
695 xfs_ilock(ip, XFS_ILOCK_EXCL); 695 xfs_ilock(ip, XFS_ILOCK_EXCL);
696 xfs_trans_ijoin(tp, ip, 0); 696 xfs_trans_ijoin(tp, ip, 0);
@@ -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 }
@@ -793,7 +793,7 @@ trans_cancel:
793 xfs_trans_cancel(tp, XFS_TRANS_RELEASE_LOG_RES | XFS_TRANS_ABORT); 793 xfs_trans_cancel(tp, XFS_TRANS_RELEASE_LOG_RES | XFS_TRANS_ABORT);
794error0: 794error0:
795 xfs_iunlock(ip, XFS_ILOCK_EXCL); 795 xfs_iunlock(ip, XFS_ILOCK_EXCL);
796 return XFS_ERROR(error); 796 return error;
797} 797}
798 798
799int 799int
@@ -853,7 +853,7 @@ xfs_iomap_write_unwritten(
853 resblks, 0); 853 resblks, 0);
854 if (error) { 854 if (error) {
855 xfs_trans_cancel(tp, 0); 855 xfs_trans_cancel(tp, 0);
856 return XFS_ERROR(error); 856 return error;
857 } 857 }
858 858
859 xfs_ilock(ip, XFS_ILOCK_EXCL); 859 xfs_ilock(ip, XFS_ILOCK_EXCL);
@@ -892,7 +892,7 @@ xfs_iomap_write_unwritten(
892 error = xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES); 892 error = xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES);
893 xfs_iunlock(ip, XFS_ILOCK_EXCL); 893 xfs_iunlock(ip, XFS_ILOCK_EXCL);
894 if (error) 894 if (error)
895 return XFS_ERROR(error); 895 return error;
896 896
897 if (!(imap.br_startblock || XFS_IS_REALTIME_INODE(ip))) 897 if (!(imap.br_startblock || XFS_IS_REALTIME_INODE(ip)))
898 return xfs_alert_fsblock_zero(ip, &imap); 898 return xfs_alert_fsblock_zero(ip, &imap);
@@ -915,5 +915,5 @@ error_on_bmapi_transaction:
915 xfs_bmap_cancel(&free_list); 915 xfs_bmap_cancel(&free_list);
916 xfs_trans_cancel(tp, (XFS_TRANS_RELEASE_LOG_RES | XFS_TRANS_ABORT)); 916 xfs_trans_cancel(tp, (XFS_TRANS_RELEASE_LOG_RES | XFS_TRANS_ABORT));
917 xfs_iunlock(ip, XFS_ILOCK_EXCL); 917 xfs_iunlock(ip, XFS_ILOCK_EXCL);
918 return XFS_ERROR(error); 918 return error;
919} 919}
diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
index 205613a06068..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
@@ -441,7 +441,7 @@ xfs_vn_getattr(
441 trace_xfs_getattr(ip); 441 trace_xfs_getattr(ip);
442 442
443 if (XFS_FORCED_SHUTDOWN(mp)) 443 if (XFS_FORCED_SHUTDOWN(mp))
444 return -XFS_ERROR(EIO); 444 return -EIO;
445 445
446 stat->size = XFS_ISIZE(ip); 446 stat->size = XFS_ISIZE(ip);
447 stat->dev = inode->i_sb->s_dev; 447 stat->dev = inode->i_sb->s_dev;
@@ -546,14 +546,14 @@ 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 XFS_ERROR(EROFS); 549 return -EROFS;
550 550
551 if (XFS_FORCED_SHUTDOWN(mp)) 551 if (XFS_FORCED_SHUTDOWN(mp))
552 return XFS_ERROR(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 XFS_ERROR(error); 556 return error;
557 } 557 }
558 558
559 ASSERT((mask & ATTR_SIZE) == 0); 559 ASSERT((mask & ATTR_SIZE) == 0);
@@ -703,7 +703,7 @@ xfs_setattr_nonsize(
703 xfs_qm_dqrele(gdqp); 703 xfs_qm_dqrele(gdqp);
704 704
705 if (error) 705 if (error)
706 return XFS_ERROR(error); 706 return error;
707 707
708 /* 708 /*
709 * XXX(hch): Updating the ACL entries is not atomic vs the i_mode 709 * XXX(hch): Updating the ACL entries is not atomic vs the i_mode
@@ -713,9 +713,9 @@ 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 XFS_ERROR(error); 718 return error;
719 } 719 }
720 720
721 return 0; 721 return 0;
@@ -748,14 +748,14 @@ 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 XFS_ERROR(EROFS); 751 return -EROFS;
752 752
753 if (XFS_FORCED_SHUTDOWN(mp)) 753 if (XFS_FORCED_SHUTDOWN(mp))
754 return XFS_ERROR(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 XFS_ERROR(error); 758 return error;
759 759
760 ASSERT(xfs_isilocked(ip, XFS_IOLOCK_EXCL)); 760 ASSERT(xfs_isilocked(ip, XFS_IOLOCK_EXCL));
761 ASSERT(S_ISREG(ip->i_d.di_mode)); 761 ASSERT(S_ISREG(ip->i_d.di_mode));
@@ -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 cb64f222d607..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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(ENOMEM); 157 return -ENOMEM;
158 if (copy_to_user(ubuffer, buffer, sizeof(*buffer))) 158 if (copy_to_user(ubuffer, buffer, sizeof(*buffer)))
159 return XFS_ERROR(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,8 +551,8 @@ 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 XFS_ERROR(EINVAL) : error; 555 EINVAL : error;
556 else 556 else
557 return 0; 557 return 0;
558 } 558 }
@@ -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 = XFS_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 = XFS_ERROR(EFAULT); 691 error = -EFAULT;
692 else 692 else
693 *count += bufidx; 693 *count += bufidx;
694 } 694 }
diff --git a/fs/xfs/xfs_linux.h b/fs/xfs/xfs_linux.h
index 825249d2dfc1..f59b966bf903 100644
--- a/fs/xfs/xfs_linux.h
+++ b/fs/xfs/xfs_linux.h
@@ -331,7 +331,7 @@ static inline __uint64_t roundup_64(__uint64_t x, __uint32_t y)
331{ 331{
332 x += y - 1; 332 x += y - 1;
333 do_div(x, y); 333 do_div(x, y);
334 return(x * y); 334 return x * y;
335} 335}
336 336
337static inline __uint64_t howmany_64(__uint64_t x, __uint32_t y) 337static inline __uint64_t howmany_64(__uint64_t x, __uint32_t y)
diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c
index 292308dede6d..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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(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 b3425b34e3d5..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 XFS_ERROR(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 981af0f6504b..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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(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 = XFS_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 = XFS_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 = XFS_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 XFS_ERROR(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 = XFS_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 = XFS_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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(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 = XFS_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 XFS_ERROR(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 XFS_ERROR(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 }
@@ -2919,7 +2920,7 @@ out_release:
2919error: 2920error:
2920 if (need_free) 2921 if (need_free)
2921 kmem_free(in_f); 2922 kmem_free(in_f);
2922 return XFS_ERROR(error); 2923 return error;
2923} 2924}
2924 2925
2925/* 2926/*
@@ -2946,7 +2947,7 @@ xlog_recover_quotaoff_pass1(
2946 if (qoff_f->qf_flags & XFS_GQUOTA_ACCT) 2947 if (qoff_f->qf_flags & XFS_GQUOTA_ACCT)
2947 log->l_quotaoffs_flag |= XFS_DQ_GROUP; 2948 log->l_quotaoffs_flag |= XFS_DQ_GROUP;
2948 2949
2949 return (0); 2950 return 0;
2950} 2951}
2951 2952
2952/* 2953/*
@@ -2971,17 +2972,17 @@ xlog_recover_dquot_pass2(
2971 * Filesystems are required to send in quota flags at mount time. 2972 * Filesystems are required to send in quota flags at mount time.
2972 */ 2973 */
2973 if (mp->m_qflags == 0) 2974 if (mp->m_qflags == 0)
2974 return (0); 2975 return 0;
2975 2976
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 XFS_ERROR(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 XFS_ERROR(EIO); 2985 return -EIO;
2985 } 2986 }
2986 2987
2987 /* 2988 /*
@@ -2990,7 +2991,7 @@ xlog_recover_dquot_pass2(
2990 type = recddq->d_flags & (XFS_DQ_USER | XFS_DQ_PROJ | XFS_DQ_GROUP); 2991 type = recddq->d_flags & (XFS_DQ_USER | XFS_DQ_PROJ | XFS_DQ_GROUP);
2991 ASSERT(type); 2992 ASSERT(type);
2992 if (log->l_quotaoffs_flag & type) 2993 if (log->l_quotaoffs_flag & type)
2993 return (0); 2994 return 0;
2994 2995
2995 /* 2996 /*
2996 * At this point we know that quota was _not_ turned off. 2997 * At this point we know that quota was _not_ turned off.
@@ -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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(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 (XFS_ERROR(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 (XFS_ERROR(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 (XFS_ERROR(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 = XFS_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 = XFS_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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(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 3507cd0ec400..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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(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 = XFS_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 = XFS_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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(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 6d26759c779a..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 XFS_ERROR(EINVAL); 1229 return -EINVAL;
1230 } 1230 }
1231 1231
1232 /* 1232 /*
@@ -1463,7 +1463,7 @@ xfs_qm_quotacheck(
1463 } 1463 }
1464 } else 1464 } else
1465 xfs_notice(mp, "Quotacheck: Done."); 1465 xfs_notice(mp, "Quotacheck: Done.");
1466 return (error); 1466 return error;
1467} 1467}
1468 1468
1469/* 1469/*
@@ -1493,7 +1493,7 @@ xfs_qm_init_quotainos(
1493 error = xfs_iget(mp, NULL, mp->m_sb.sb_uquotino, 1493 error = xfs_iget(mp, NULL, mp->m_sb.sb_uquotino,
1494 0, 0, &uip); 1494 0, 0, &uip);
1495 if (error) 1495 if (error)
1496 return XFS_ERROR(error); 1496 return error;
1497 } 1497 }
1498 if (XFS_IS_GQUOTA_ON(mp) && 1498 if (XFS_IS_GQUOTA_ON(mp) &&
1499 mp->m_sb.sb_gquotino != NULLFSINO) { 1499 mp->m_sb.sb_gquotino != NULLFSINO) {
@@ -1563,7 +1563,7 @@ error_rele:
1563 IRELE(gip); 1563 IRELE(gip);
1564 if (pip) 1564 if (pip)
1565 IRELE(pip); 1565 IRELE(pip);
1566 return XFS_ERROR(error); 1566 return error;
1567} 1567}
1568 1568
1569STATIC void 1569STATIC void
@@ -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);
@@ -1895,7 +1895,7 @@ xfs_qm_vop_chown_reserve(
1895 -((xfs_qcnt_t)delblks), 0, blkflags); 1895 -((xfs_qcnt_t)delblks), 0, blkflags);
1896 } 1896 }
1897 1897
1898 return (0); 1898 return 0;
1899} 1899}
1900 1900
1901int 1901int
diff --git a/fs/xfs/xfs_qm_bhv.c b/fs/xfs/xfs_qm_bhv.c
index e9be63abd8d2..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 XFS_ERROR(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 bbc813caba4c..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 XFS_ERROR(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);
@@ -94,7 +94,7 @@ xfs_qm_scall_quotaoff(
94 94
95 /* XXX what to do if error ? Revert back to old vals incore ? */ 95 /* XXX what to do if error ? Revert back to old vals incore ? */
96 error = xfs_qm_write_sb_changes(mp, XFS_SB_QFLAGS); 96 error = xfs_qm_write_sb_changes(mp, XFS_SB_QFLAGS);
97 return (error); 97 return error;
98 } 98 }
99 99
100 dqtype = 0; 100 dqtype = 0;
@@ -198,7 +198,7 @@ xfs_qm_scall_quotaoff(
198 if (mp->m_qflags == 0) { 198 if (mp->m_qflags == 0) {
199 mutex_unlock(&q->qi_quotaofflock); 199 mutex_unlock(&q->qi_quotaofflock);
200 xfs_qm_destroy_quotainfo(mp); 200 xfs_qm_destroy_quotainfo(mp);
201 return (0); 201 return 0;
202 } 202 }
203 203
204 /* 204 /*
@@ -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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(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,11 +372,11 @@ 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 XFS_ERROR(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)))
379 return (error); 379 return error;
380 /* 380 /*
381 * If we aren't trying to switch on quota enforcement, we are done. 381 * If we aren't trying to switch on quota enforcement, we are done.
382 */ 382 */
@@ -387,10 +387,10 @@ xfs_qm_scall_quotaon(
387 ((mp->m_sb.sb_qflags & XFS_GQUOTA_ACCT) != 387 ((mp->m_sb.sb_qflags & XFS_GQUOTA_ACCT) !=
388 (mp->m_qflags & XFS_GQUOTA_ACCT)) || 388 (mp->m_qflags & XFS_GQUOTA_ACCT)) ||
389 (flags & XFS_ALL_QUOTA_ENFD) == 0) 389 (flags & XFS_ALL_QUOTA_ENFD) == 0)
390 return (0); 390 return 0;
391 391
392 if (! XFS_IS_QUOTA_RUNNING(mp)) 392 if (! XFS_IS_QUOTA_RUNNING(mp))
393 return XFS_ERROR(ESRCH); 393 return -ESRCH;
394 394
395 /* 395 /*
396 * Switch on quota enforcement in core. 396 * Switch on quota enforcement in core.
@@ -399,7 +399,7 @@ xfs_qm_scall_quotaon(
399 mp->m_qflags |= (flags & XFS_ALL_QUOTA_ENFD); 399 mp->m_qflags |= (flags & XFS_ALL_QUOTA_ENFD);
400 mutex_unlock(&mp->m_quotainfo->qi_quotaofflock); 400 mutex_unlock(&mp->m_quotainfo->qi_quotaofflock);
401 401
402 return (0); 402 return 0;
403} 403}
404 404
405 405
@@ -426,7 +426,7 @@ xfs_qm_scall_getqstat(
426 if (!xfs_sb_version_hasquota(&mp->m_sb)) { 426 if (!xfs_sb_version_hasquota(&mp->m_sb)) {
427 out->qs_uquota.qfs_ino = NULLFSINO; 427 out->qs_uquota.qfs_ino = NULLFSINO;
428 out->qs_gquota.qfs_ino = NULLFSINO; 428 out->qs_gquota.qfs_ino = NULLFSINO;
429 return (0); 429 return 0;
430 } 430 }
431 431
432 out->qs_flags = (__uint16_t) xfs_qm_export_flags(mp->m_qflags & 432 out->qs_flags = (__uint16_t) xfs_qm_export_flags(mp->m_qflags &
@@ -514,7 +514,7 @@ xfs_qm_scall_getqstatv(
514 out->qs_uquota.qfs_ino = NULLFSINO; 514 out->qs_uquota.qfs_ino = NULLFSINO;
515 out->qs_gquota.qfs_ino = NULLFSINO; 515 out->qs_gquota.qfs_ino = NULLFSINO;
516 out->qs_pquota.qfs_ino = NULLFSINO; 516 out->qs_pquota.qfs_ino = NULLFSINO;
517 return (0); 517 return 0;
518 } 518 }
519 519
520 out->qs_flags = (__uint16_t) xfs_qm_export_flags(mp->m_qflags & 520 out->qs_flags = (__uint16_t) xfs_qm_export_flags(mp->m_qflags &
@@ -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);
@@ -758,7 +758,7 @@ xfs_qm_log_quotaoff_end(
758 error = xfs_trans_reserve(tp, &M_RES(mp)->tr_qm_equotaoff, 0, 0); 758 error = xfs_trans_reserve(tp, &M_RES(mp)->tr_qm_equotaoff, 0, 0);
759 if (error) { 759 if (error) {
760 xfs_trans_cancel(tp, 0); 760 xfs_trans_cancel(tp, 0);
761 return (error); 761 return error;
762 } 762 }
763 763
764 qoffi = xfs_trans_get_qoff_item(tp, startqoff, 764 qoffi = xfs_trans_get_qoff_item(tp, startqoff,
@@ -772,7 +772,7 @@ xfs_qm_log_quotaoff_end(
772 */ 772 */
773 xfs_trans_set_sync(tp); 773 xfs_trans_set_sync(tp);
774 error = xfs_trans_commit(tp, 0); 774 error = xfs_trans_commit(tp, 0);
775 return (error); 775 return error;
776} 776}
777 777
778 778
@@ -822,7 +822,7 @@ error0:
822 spin_unlock(&mp->m_sb_lock); 822 spin_unlock(&mp->m_sb_lock);
823 } 823 }
824 *qoffstartp = qoffi; 824 *qoffstartp = qoffi;
825 return (error); 825 return error;
826} 826}
827 827
828 828
@@ -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 = XFS_ERROR(ENOENT); 853 error = -ENOENT;
854 goto out_put; 854 goto out_put;
855 } 855 }
856 856
@@ -953,7 +953,7 @@ xfs_qm_export_flags(
953 uflags |= FS_QUOTA_GDQ_ENFD; 953 uflags |= FS_QUOTA_GDQ_ENFD;
954 if (flags & XFS_PQUOTA_ENFD) 954 if (flags & XFS_PQUOTA_ENFD)
955 uflags |= FS_QUOTA_PDQ_ENFD; 955 uflags |= FS_QUOTA_PDQ_ENFD;
956 return (uflags); 956 return uflags;
957} 957}
958 958
959 959
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 ec5ca65c6211..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 = XFS_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 = XFS_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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(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 8f0333b3f7a0..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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(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 XFS_ERROR(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 d69363c833e1..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 XFS_ERROR(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 XFS_ERROR(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 = XFS_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 XFS_ERROR(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 XFS_ERROR(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 = XFS_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 XFS_ERROR(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 XFS_ERROR(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 d03932564ccb..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 (XFS_ERROR(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 = XFS_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 = XFS_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 = XFS_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);
@@ -1024,7 +1024,7 @@ xfs_trans_roll(
1024 */ 1024 */
1025 error = xfs_trans_commit(trans, 0); 1025 error = xfs_trans_commit(trans, 0);
1026 if (error) 1026 if (error)
1027 return (error); 1027 return error;
1028 1028
1029 trans = *tpp; 1029 trans = *tpp;
1030 1030
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 b8eef0549f3f..96c898e7ac9a 100644
--- a/fs/xfs/xfs_trans_buf.c
+++ b/fs/xfs/xfs_trans_buf.c
@@ -166,7 +166,7 @@ xfs_trans_get_buf_map(
166 ASSERT(atomic_read(&bip->bli_refcount) > 0); 166 ASSERT(atomic_read(&bip->bli_refcount) > 0);
167 bip->bli_recur++; 167 bip->bli_recur++;
168 trace_xfs_trans_get_buf_recur(bip); 168 trace_xfs_trans_get_buf_recur(bip);
169 return (bp); 169 return bp;
170 } 170 }
171 171
172 bp = xfs_buf_get_map(target, map, nmaps, flags); 172 bp = xfs_buf_get_map(target, map, nmaps, flags);
@@ -178,7 +178,7 @@ xfs_trans_get_buf_map(
178 178
179 _xfs_trans_bjoin(tp, bp, 1); 179 _xfs_trans_bjoin(tp, bp, 1);
180 trace_xfs_trans_get_buf(bp->b_fspriv); 180 trace_xfs_trans_get_buf(bp->b_fspriv);
181 return (bp); 181 return bp;
182} 182}
183 183
184/* 184/*
@@ -201,9 +201,8 @@ xfs_trans_getsb(xfs_trans_t *tp,
201 * Default to just trying to lock the superblock buffer 201 * Default to just trying to lock the superblock buffer
202 * if tp is NULL. 202 * if tp is NULL.
203 */ 203 */
204 if (tp == NULL) { 204 if (tp == NULL)
205 return (xfs_getsb(mp, flags)); 205 return xfs_getsb(mp, flags);
206 }
207 206
208 /* 207 /*
209 * If the superblock buffer already has this transaction 208 * If the superblock buffer already has this transaction
@@ -218,7 +217,7 @@ xfs_trans_getsb(xfs_trans_t *tp,
218 ASSERT(atomic_read(&bip->bli_refcount) > 0); 217 ASSERT(atomic_read(&bip->bli_refcount) > 0);
219 bip->bli_recur++; 218 bip->bli_recur++;
220 trace_xfs_trans_getsb_recur(bip); 219 trace_xfs_trans_getsb_recur(bip);
221 return (bp); 220 return bp;
222 } 221 }
223 222
224 bp = xfs_getsb(mp, flags); 223 bp = xfs_getsb(mp, flags);
@@ -227,7 +226,7 @@ xfs_trans_getsb(xfs_trans_t *tp,
227 226
228 _xfs_trans_bjoin(tp, bp, 1); 227 _xfs_trans_bjoin(tp, bp, 1);
229 trace_xfs_trans_getsb(bp->b_fspriv); 228 trace_xfs_trans_getsb(bp->b_fspriv);
230 return (bp); 229 return bp;
231} 230}
232 231
233#ifdef DEBUG 232#ifdef DEBUG
@@ -267,7 +266,7 @@ xfs_trans_read_buf_map(
267 bp = xfs_buf_read_map(target, map, nmaps, flags, ops); 266 bp = xfs_buf_read_map(target, map, nmaps, flags, ops);
268 if (!bp) 267 if (!bp)
269 return (flags & XBF_TRYLOCK) ? 268 return (flags & XBF_TRYLOCK) ?
270 EAGAIN : XFS_ERROR(ENOMEM); 269 -EAGAIN : -ENOMEM;
271 270
272 if (bp->b_error) { 271 if (bp->b_error) {
273 error = bp->b_error; 272 error = bp->b_error;
@@ -277,8 +276,8 @@ xfs_trans_read_buf_map(
277 xfs_buf_relse(bp); 276 xfs_buf_relse(bp);
278 277
279 /* bad CRC means corrupted metadata */ 278 /* bad CRC means corrupted metadata */
280 if (error == EFSBADCRC) 279 if (error == -EFSBADCRC)
281 error = EFSCORRUPTED; 280 error = -EFSCORRUPTED;
282 return error; 281 return error;
283 } 282 }
284#ifdef DEBUG 283#ifdef DEBUG
@@ -287,7 +286,7 @@ xfs_trans_read_buf_map(
287 if (((xfs_req_num++) % xfs_error_mod) == 0) { 286 if (((xfs_req_num++) % xfs_error_mod) == 0) {
288 xfs_buf_relse(bp); 287 xfs_buf_relse(bp);
289 xfs_debug(mp, "Returning error!"); 288 xfs_debug(mp, "Returning error!");
290 return XFS_ERROR(EIO); 289 return -EIO;
291 } 290 }
292 } 291 }
293 } 292 }
@@ -343,8 +342,8 @@ xfs_trans_read_buf_map(
343 xfs_force_shutdown(tp->t_mountp, 342 xfs_force_shutdown(tp->t_mountp,
344 SHUTDOWN_META_IO_ERROR); 343 SHUTDOWN_META_IO_ERROR);
345 /* bad CRC means corrupted metadata */ 344 /* bad CRC means corrupted metadata */
346 if (error == EFSBADCRC) 345 if (error == -EFSBADCRC)
347 error = EFSCORRUPTED; 346 error = -EFSCORRUPTED;
348 return error; 347 return error;
349 } 348 }
350 } 349 }
@@ -355,7 +354,7 @@ xfs_trans_read_buf_map(
355 if (XFS_FORCED_SHUTDOWN(mp)) { 354 if (XFS_FORCED_SHUTDOWN(mp)) {
356 trace_xfs_trans_read_buf_shut(bp, _RET_IP_); 355 trace_xfs_trans_read_buf_shut(bp, _RET_IP_);
357 *bpp = NULL; 356 *bpp = NULL;
358 return XFS_ERROR(EIO); 357 return -EIO;
359 } 358 }
360 359
361 360
@@ -372,7 +371,7 @@ xfs_trans_read_buf_map(
372 if (bp == NULL) { 371 if (bp == NULL) {
373 *bpp = NULL; 372 *bpp = NULL;
374 return (flags & XBF_TRYLOCK) ? 373 return (flags & XBF_TRYLOCK) ?
375 0 : XFS_ERROR(ENOMEM); 374 0 : -ENOMEM;
376 } 375 }
377 if (bp->b_error) { 376 if (bp->b_error) {
378 error = bp->b_error; 377 error = bp->b_error;
@@ -384,8 +383,8 @@ xfs_trans_read_buf_map(
384 xfs_buf_relse(bp); 383 xfs_buf_relse(bp);
385 384
386 /* bad CRC means corrupted metadata */ 385 /* bad CRC means corrupted metadata */
387 if (error == EFSBADCRC) 386 if (error == -EFSBADCRC)
388 error = EFSCORRUPTED; 387 error = -EFSCORRUPTED;
389 return error; 388 return error;
390 } 389 }
391#ifdef DEBUG 390#ifdef DEBUG
@@ -396,7 +395,7 @@ xfs_trans_read_buf_map(
396 SHUTDOWN_META_IO_ERROR); 395 SHUTDOWN_META_IO_ERROR);
397 xfs_buf_relse(bp); 396 xfs_buf_relse(bp);
398 xfs_debug(mp, "Returning trans error!"); 397 xfs_debug(mp, "Returning trans error!");
399 return XFS_ERROR(EIO); 398 return -EIO;
400 } 399 }
401 } 400 }
402 } 401 }
@@ -414,7 +413,7 @@ shutdown_abort:
414 trace_xfs_trans_read_buf_shut(bp, _RET_IP_); 413 trace_xfs_trans_read_buf_shut(bp, _RET_IP_);
415 xfs_buf_relse(bp); 414 xfs_buf_relse(bp);
416 *bpp = NULL; 415 *bpp = NULL;
417 return XFS_ERROR(EIO); 416 return -EIO;
418} 417}
419 418
420/* 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