diff options
-rw-r--r-- | Documentation/ABI/testing/sysfs-fs-xfs | 39 | ||||
-rw-r--r-- | fs/xfs/Kconfig | 1 | ||||
-rw-r--r-- | fs/xfs/Makefile | 71 | ||||
-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) | 60 | ||||
-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) | 99 | ||||
-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) | 46 | ||||
-rw-r--r-- | fs/xfs/libxfs/xfs_btree.h (renamed from fs/xfs/xfs_btree.h) | 2 | ||||
-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) | 112 | ||||
-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) | 75 | ||||
-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) | 14 | ||||
-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) | 36 | ||||
-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) | 4 | ||||
-rw-r--r-- | fs/xfs/libxfs/xfs_log_format.h (renamed from fs/xfs/xfs_log_format.h) | 4 | ||||
-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) | 2 | ||||
-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) | 56 | ||||
-rw-r--r-- | fs/xfs/libxfs/xfs_sb.h (renamed from fs/xfs/xfs_sb.h) | 8 | ||||
-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.c | 8 | ||||
-rw-r--r-- | fs/xfs/xfs_aops.c | 18 | ||||
-rw-r--r-- | fs/xfs/xfs_attr_inactive.c | 22 | ||||
-rw-r--r-- | fs/xfs/xfs_attr_list.c | 38 | ||||
-rw-r--r-- | fs/xfs/xfs_bmap_util.c | 174 | ||||
-rw-r--r-- | fs/xfs/xfs_buf.c | 40 | ||||
-rw-r--r-- | fs/xfs/xfs_buf.h | 2 | ||||
-rw-r--r-- | fs/xfs/xfs_buf_item.c | 4 | ||||
-rw-r--r-- | fs/xfs/xfs_dir2_readdir.c | 4 | ||||
-rw-r--r-- | fs/xfs/xfs_discard.c | 18 | ||||
-rw-r--r-- | fs/xfs/xfs_dquot.c | 41 | ||||
-rw-r--r-- | fs/xfs/xfs_dquot.h | 15 | ||||
-rw-r--r-- | fs/xfs/xfs_error.c | 25 | ||||
-rw-r--r-- | fs/xfs/xfs_error.h | 13 | ||||
-rw-r--r-- | fs/xfs/xfs_export.c | 10 | ||||
-rw-r--r-- | fs/xfs/xfs_extfree_item.c | 2 | ||||
-rw-r--r-- | fs/xfs/xfs_file.c | 75 | ||||
-rw-r--r-- | fs/xfs/xfs_filestream.c | 4 | ||||
-rw-r--r-- | fs/xfs/xfs_fs.h | 7 | ||||
-rw-r--r-- | fs/xfs/xfs_fsops.c | 42 | ||||
-rw-r--r-- | fs/xfs/xfs_icache.c | 148 | ||||
-rw-r--r-- | fs/xfs/xfs_icache.h | 13 | ||||
-rw-r--r-- | fs/xfs/xfs_inode.c | 68 | ||||
-rw-r--r-- | fs/xfs/xfs_inode.h | 10 | ||||
-rw-r--r-- | fs/xfs/xfs_inode_item.c | 2 | ||||
-rw-r--r-- | fs/xfs/xfs_ioctl.c | 266 | ||||
-rw-r--r-- | fs/xfs/xfs_ioctl32.c | 111 | ||||
-rw-r--r-- | fs/xfs/xfs_iomap.c | 54 | ||||
-rw-r--r-- | fs/xfs/xfs_iops.c | 72 | ||||
-rw-r--r-- | fs/xfs/xfs_itable.c | 579 | ||||
-rw-r--r-- | fs/xfs/xfs_itable.h | 23 | ||||
-rw-r--r-- | fs/xfs/xfs_linux.h | 27 | ||||
-rw-r--r-- | fs/xfs/xfs_log.c | 69 | ||||
-rw-r--r-- | fs/xfs/xfs_log_cil.c | 8 | ||||
-rw-r--r-- | fs/xfs/xfs_log_priv.h | 2 | ||||
-rw-r--r-- | fs/xfs/xfs_log_recover.c | 284 | ||||
-rw-r--r-- | fs/xfs/xfs_mount.c | 97 | ||||
-rw-r--r-- | fs/xfs/xfs_mount.h | 1 | ||||
-rw-r--r-- | fs/xfs/xfs_mru_cache.c | 14 | ||||
-rw-r--r-- | fs/xfs/xfs_qm.c | 229 | ||||
-rw-r--r-- | fs/xfs/xfs_qm.h | 1 | ||||
-rw-r--r-- | fs/xfs/xfs_qm_bhv.c | 2 | ||||
-rw-r--r-- | fs/xfs/xfs_qm_syscalls.c | 46 | ||||
-rw-r--r-- | fs/xfs/xfs_quotaops.c | 20 | ||||
-rw-r--r-- | fs/xfs/xfs_rtalloc.c | 24 | ||||
-rw-r--r-- | fs/xfs/xfs_rtalloc.h | 2 | ||||
-rw-r--r-- | fs/xfs/xfs_super.c | 132 | ||||
-rw-r--r-- | fs/xfs/xfs_super.h | 15 | ||||
-rw-r--r-- | fs/xfs/xfs_symlink.c | 30 | ||||
-rw-r--r-- | fs/xfs/xfs_sysfs.c | 165 | ||||
-rw-r--r-- | fs/xfs/xfs_sysfs.h | 59 | ||||
-rw-r--r-- | fs/xfs/xfs_trans.c | 10 | ||||
-rw-r--r-- | fs/xfs/xfs_trans_ail.c | 4 | ||||
-rw-r--r-- | fs/xfs/xfs_trans_buf.c | 37 | ||||
-rw-r--r-- | fs/xfs/xfs_trans_dquot.c | 4 | ||||
-rw-r--r-- | fs/xfs/xfs_types.h | 29 | ||||
-rw-r--r-- | fs/xfs/xfs_vnode.h | 46 | ||||
-rw-r--r-- | fs/xfs/xfs_xattr.c | 6 |
116 files changed, 2252 insertions, 2044 deletions
diff --git a/Documentation/ABI/testing/sysfs-fs-xfs b/Documentation/ABI/testing/sysfs-fs-xfs new file mode 100644 index 000000000000..ea0cc8c42093 --- /dev/null +++ b/Documentation/ABI/testing/sysfs-fs-xfs | |||
@@ -0,0 +1,39 @@ | |||
1 | What: /sys/fs/xfs/<disk>/log/log_head_lsn | ||
2 | Date: July 2014 | ||
3 | KernelVersion: 3.17 | ||
4 | Contact: xfs@oss.sgi.com | ||
5 | Description: | ||
6 | The log sequence number (LSN) of the current head of the | ||
7 | log. The LSN is exported in "cycle:basic block" format. | ||
8 | Users: xfstests | ||
9 | |||
10 | What: /sys/fs/xfs/<disk>/log/log_tail_lsn | ||
11 | Date: July 2014 | ||
12 | KernelVersion: 3.17 | ||
13 | Contact: xfs@oss.sgi.com | ||
14 | Description: | ||
15 | The log sequence number (LSN) of the current tail of the | ||
16 | log. The LSN is exported in "cycle:basic block" format. | ||
17 | |||
18 | What: /sys/fs/xfs/<disk>/log/reserve_grant_head | ||
19 | Date: July 2014 | ||
20 | KernelVersion: 3.17 | ||
21 | Contact: xfs@oss.sgi.com | ||
22 | Description: | ||
23 | The current state of the log reserve grant head. It | ||
24 | represents the total log reservation of all currently | ||
25 | outstanding transactions. The grant head is exported in | ||
26 | "cycle:bytes" format. | ||
27 | Users: xfstests | ||
28 | |||
29 | What: /sys/fs/xfs/<disk>/log/write_grant_head | ||
30 | Date: July 2014 | ||
31 | KernelVersion: 3.17 | ||
32 | Contact: xfs@oss.sgi.com | ||
33 | Description: | ||
34 | The current state of the log write grant head. It | ||
35 | represents the total log reservation of all currently | ||
36 | oustanding transactions, including regrants due to | ||
37 | rolling transactions. The grant head is exported in | ||
38 | "cycle:bytes" format. | ||
39 | Users: xfstests | ||
diff --git a/fs/xfs/Kconfig b/fs/xfs/Kconfig index 399e8cec6e60..5d47b4df61ea 100644 --- a/fs/xfs/Kconfig +++ b/fs/xfs/Kconfig | |||
@@ -1,6 +1,7 @@ | |||
1 | config XFS_FS | 1 | config XFS_FS |
2 | tristate "XFS filesystem support" | 2 | tristate "XFS filesystem support" |
3 | depends on BLOCK | 3 | depends on BLOCK |
4 | depends on (64BIT || LBDAF) | ||
4 | select EXPORTFS | 5 | select EXPORTFS |
5 | select LIBCRC32C | 6 | select LIBCRC32C |
6 | help | 7 | help |
diff --git a/fs/xfs/Makefile b/fs/xfs/Makefile index c21f43506661..d61799949580 100644 --- a/fs/xfs/Makefile +++ b/fs/xfs/Makefile | |||
@@ -17,6 +17,7 @@ | |||
17 | # | 17 | # |
18 | 18 | ||
19 | ccflags-y += -I$(src) # needed for trace events | 19 | ccflags-y += -I$(src) # needed for trace events |
20 | ccflags-y += -I$(src)/libxfs | ||
20 | 21 | ||
21 | ccflags-$(CONFIG_XFS_DEBUG) += -g | 22 | ccflags-$(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 |
26 | xfs-y += xfs_trace.o | 27 | xfs-y += xfs_trace.o |
27 | 28 | ||
29 | # build the libxfs code first | ||
30 | xfs-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 | ||
58 | xfs-$(CONFIG_XFS_RT) += $(addprefix libxfs/, \ | ||
59 | xfs_rtbitmap.o \ | ||
60 | ) | ||
61 | |||
28 | # highlevel code | 62 | # highlevel code |
29 | xfs-y += xfs_aops.o \ | 63 | xfs-y += xfs_aops.o \ |
30 | xfs_attr_inactive.o \ | 64 | xfs_attr_inactive.o \ |
@@ -45,53 +79,27 @@ 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 \ |
51 | xfs_mru_cache.o \ | 86 | xfs_mru_cache.o \ |
52 | xfs_super.o \ | 87 | xfs_super.o \ |
53 | xfs_symlink.o \ | 88 | xfs_symlink.o \ |
89 | xfs_sysfs.o \ | ||
54 | xfs_trans.o \ | 90 | xfs_trans.o \ |
55 | xfs_xattr.o \ | 91 | xfs_xattr.o \ |
56 | kmem.o \ | 92 | kmem.o \ |
57 | uuid.o | 93 | uuid.o |
58 | 94 | ||
59 | # code shared with libxfs | ||
60 | xfs-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 | 95 | # low-level transaction/log code |
90 | xfs-y += xfs_log.o \ | 96 | xfs-y += xfs_log.o \ |
91 | xfs_log_cil.o \ | 97 | xfs_log_cil.o \ |
92 | xfs_buf_item.o \ | 98 | xfs_buf_item.o \ |
93 | xfs_extfree_item.o \ | 99 | xfs_extfree_item.o \ |
100 | xfs_icreate_item.o \ | ||
94 | xfs_inode_item.o \ | 101 | xfs_inode_item.o \ |
102 | xfs_log_recover.o \ | ||
95 | xfs_trans_ail.o \ | 103 | xfs_trans_ail.o \ |
96 | xfs_trans_buf.o \ | 104 | xfs_trans_buf.o \ |
97 | xfs_trans_extfree.o \ | 105 | xfs_trans_extfree.o \ |
@@ -107,8 +115,7 @@ xfs-$(CONFIG_XFS_QUOTA) += xfs_dquot.o \ | |||
107 | xfs_quotaops.o | 115 | xfs_quotaops.o |
108 | 116 | ||
109 | # xfs_rtbitmap is shared with libxfs | 117 | # xfs_rtbitmap is shared with libxfs |
110 | xfs-$(CONFIG_XFS_RT) += xfs_rtalloc.o \ | 118 | xfs-$(CONFIG_XFS_RT) += xfs_rtalloc.o |
111 | xfs_rtbitmap.o | ||
112 | 119 | ||
113 | xfs-$(CONFIG_XFS_POSIX_ACL) += xfs_acl.o | 120 | xfs-$(CONFIG_XFS_POSIX_ACL) += xfs_acl.o |
114 | xfs-$(CONFIG_PROC_FS) += xfs_stats.o | 121 | xfs-$(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 | ||
1298 | out: | 1298 | out: |
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 | ||
742 | out: | 742 | out: |
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..de2d26d32844 100644 --- a/fs/xfs/xfs_bmap.c +++ b/fs/xfs/libxfs/xfs_bmap.c | |||
@@ -392,7 +392,7 @@ xfs_bmap_check_leaf_extents( | |||
392 | pp = XFS_BMAP_BROOT_PTR_ADDR(mp, block, 1, ifp->if_broot_bytes); | 392 | pp = XFS_BMAP_BROOT_PTR_ADDR(mp, block, 1, ifp->if_broot_bytes); |
393 | bno = be64_to_cpu(*pp); | 393 | bno = be64_to_cpu(*pp); |
394 | 394 | ||
395 | ASSERT(bno != NULLDFSBNO); | 395 | ASSERT(bno != NULLFSBLOCK); |
396 | ASSERT(XFS_FSB_TO_AGNO(mp, bno) < mp->m_sb.sb_agcount); | 396 | ASSERT(XFS_FSB_TO_AGNO(mp, bno) < mp->m_sb.sb_agcount); |
397 | ASSERT(XFS_FSB_TO_AGBNO(mp, bno) < mp->m_sb.sb_agblocks); | 397 | ASSERT(XFS_FSB_TO_AGBNO(mp, bno) < mp->m_sb.sb_agblocks); |
398 | 398 | ||
@@ -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 | ||
@@ -1299,7 +1299,7 @@ xfs_bmap_read_extents( | |||
1299 | ASSERT(level > 0); | 1299 | ASSERT(level > 0); |
1300 | pp = XFS_BMAP_BROOT_PTR_ADDR(mp, block, 1, ifp->if_broot_bytes); | 1300 | pp = XFS_BMAP_BROOT_PTR_ADDR(mp, block, 1, ifp->if_broot_bytes); |
1301 | bno = be64_to_cpu(*pp); | 1301 | bno = be64_to_cpu(*pp); |
1302 | ASSERT(bno != NULLDFSBNO); | 1302 | ASSERT(bno != NULLFSBLOCK); |
1303 | ASSERT(XFS_FSB_TO_AGNO(mp, bno) < mp->m_sb.sb_agcount); | 1303 | ASSERT(XFS_FSB_TO_AGNO(mp, bno) < mp->m_sb.sb_agcount); |
1304 | ASSERT(XFS_FSB_TO_AGBNO(mp, bno) < mp->m_sb.sb_agblocks); | 1304 | ASSERT(XFS_FSB_TO_AGBNO(mp, bno) < mp->m_sb.sb_agblocks); |
1305 | /* | 1305 | /* |
@@ -1399,7 +1399,7 @@ xfs_bmap_read_extents( | |||
1399 | return 0; | 1399 | return 0; |
1400 | error0: | 1400 | error0: |
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 | ||
@@ -1429,11 +1429,7 @@ xfs_bmap_search_multi_extents( | |||
1429 | gotp->br_startoff = 0xffa5a5a5a5a5a5a5LL; | 1429 | gotp->br_startoff = 0xffa5a5a5a5a5a5a5LL; |
1430 | gotp->br_blockcount = 0xa55a5a5a5a5a5a5aLL; | 1430 | gotp->br_blockcount = 0xa55a5a5a5a5a5a5aLL; |
1431 | gotp->br_state = XFS_EXT_INVALID; | 1431 | gotp->br_state = XFS_EXT_INVALID; |
1432 | #if XFS_BIG_BLKNOS | ||
1433 | gotp->br_startblock = 0xffffa5a5a5a5a5a5LL; | 1432 | gotp->br_startblock = 0xffffa5a5a5a5a5a5LL; |
1434 | #else | ||
1435 | gotp->br_startblock = 0xffffa5a5; | ||
1436 | #endif | ||
1437 | prevp->br_startoff = NULLFILEOFF; | 1433 | prevp->br_startoff = NULLFILEOFF; |
1438 | 1434 | ||
1439 | ep = xfs_iext_bno_to_ext(ifp, bno, &lastx); | 1435 | ep = xfs_iext_bno_to_ext(ifp, bno, &lastx); |
@@ -1576,7 +1572,7 @@ xfs_bmap_last_before( | |||
1576 | if (XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_BTREE && | 1572 | if (XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_BTREE && |
1577 | XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_EXTENTS && | 1573 | XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_EXTENTS && |
1578 | XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_LOCAL) | 1574 | XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_LOCAL) |
1579 | return XFS_ERROR(EIO); | 1575 | return -EIO; |
1580 | if (XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_LOCAL) { | 1576 | if (XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_LOCAL) { |
1581 | *last_block = 0; | 1577 | *last_block = 0; |
1582 | return 0; | 1578 | return 0; |
@@ -1690,7 +1686,7 @@ xfs_bmap_last_offset( | |||
1690 | 1686 | ||
1691 | if (XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_BTREE && | 1687 | if (XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_BTREE && |
1692 | XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_EXTENTS) | 1688 | XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_EXTENTS) |
1693 | return XFS_ERROR(EIO); | 1689 | return -EIO; |
1694 | 1690 | ||
1695 | error = xfs_bmap_last_extent(NULL, ip, whichfork, &rec, &is_empty); | 1691 | error = xfs_bmap_last_extent(NULL, ip, whichfork, &rec, &is_empty); |
1696 | if (error || is_empty) | 1692 | if (error || is_empty) |
@@ -3323,7 +3319,7 @@ xfs_bmap_extsize_align( | |||
3323 | if (orig_off < align_off || | 3319 | if (orig_off < align_off || |
3324 | orig_end > align_off + align_alen || | 3320 | orig_end > align_off + align_alen || |
3325 | align_alen - temp < orig_alen) | 3321 | align_alen - temp < orig_alen) |
3326 | return XFS_ERROR(EINVAL); | 3322 | return -EINVAL; |
3327 | /* | 3323 | /* |
3328 | * Try to fix it by moving the start up. | 3324 | * Try to fix it by moving the start up. |
3329 | */ | 3325 | */ |
@@ -3348,7 +3344,7 @@ xfs_bmap_extsize_align( | |||
3348 | * Result doesn't cover the request, fail it. | 3344 | * Result doesn't cover the request, fail it. |
3349 | */ | 3345 | */ |
3350 | if (orig_off < align_off || orig_end > align_off + align_alen) | 3346 | if (orig_off < align_off || orig_end > align_off + align_alen) |
3351 | return XFS_ERROR(EINVAL); | 3347 | return -EINVAL; |
3352 | } else { | 3348 | } else { |
3353 | ASSERT(orig_off >= align_off); | 3349 | ASSERT(orig_off >= align_off); |
3354 | ASSERT(orig_end <= align_off + align_alen); | 3350 | ASSERT(orig_end <= align_off + align_alen); |
@@ -4051,11 +4047,11 @@ xfs_bmapi_read( | |||
4051 | XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_BTREE), | 4047 | XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_BTREE), |
4052 | mp, XFS_ERRTAG_BMAPIFORMAT, XFS_RANDOM_BMAPIFORMAT))) { | 4048 | mp, XFS_ERRTAG_BMAPIFORMAT, XFS_RANDOM_BMAPIFORMAT))) { |
4053 | XFS_ERROR_REPORT("xfs_bmapi_read", XFS_ERRLEVEL_LOW, mp); | 4049 | XFS_ERROR_REPORT("xfs_bmapi_read", XFS_ERRLEVEL_LOW, mp); |
4054 | return XFS_ERROR(EFSCORRUPTED); | 4050 | return -EFSCORRUPTED; |
4055 | } | 4051 | } |
4056 | 4052 | ||
4057 | if (XFS_FORCED_SHUTDOWN(mp)) | 4053 | if (XFS_FORCED_SHUTDOWN(mp)) |
4058 | return XFS_ERROR(EIO); | 4054 | return -EIO; |
4059 | 4055 | ||
4060 | XFS_STATS_INC(xs_blk_mapr); | 4056 | XFS_STATS_INC(xs_blk_mapr); |
4061 | 4057 | ||
@@ -4246,11 +4242,11 @@ xfs_bmapi_delay( | |||
4246 | XFS_IFORK_FORMAT(ip, XFS_DATA_FORK) != XFS_DINODE_FMT_BTREE), | 4242 | XFS_IFORK_FORMAT(ip, XFS_DATA_FORK) != XFS_DINODE_FMT_BTREE), |
4247 | mp, XFS_ERRTAG_BMAPIFORMAT, XFS_RANDOM_BMAPIFORMAT))) { | 4243 | mp, XFS_ERRTAG_BMAPIFORMAT, XFS_RANDOM_BMAPIFORMAT))) { |
4248 | XFS_ERROR_REPORT("xfs_bmapi_delay", XFS_ERRLEVEL_LOW, mp); | 4244 | XFS_ERROR_REPORT("xfs_bmapi_delay", XFS_ERRLEVEL_LOW, mp); |
4249 | return XFS_ERROR(EFSCORRUPTED); | 4245 | return -EFSCORRUPTED; |
4250 | } | 4246 | } |
4251 | 4247 | ||
4252 | if (XFS_FORCED_SHUTDOWN(mp)) | 4248 | if (XFS_FORCED_SHUTDOWN(mp)) |
4253 | return XFS_ERROR(EIO); | 4249 | return -EIO; |
4254 | 4250 | ||
4255 | XFS_STATS_INC(xs_blk_mapw); | 4251 | XFS_STATS_INC(xs_blk_mapw); |
4256 | 4252 | ||
@@ -4469,7 +4465,7 @@ xfs_bmapi_convert_unwritten( | |||
4469 | * so generate another request. | 4465 | * so generate another request. |
4470 | */ | 4466 | */ |
4471 | if (mval->br_blockcount < len) | 4467 | if (mval->br_blockcount < len) |
4472 | return EAGAIN; | 4468 | return -EAGAIN; |
4473 | return 0; | 4469 | return 0; |
4474 | } | 4470 | } |
4475 | 4471 | ||
@@ -4540,11 +4536,11 @@ xfs_bmapi_write( | |||
4540 | XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_BTREE), | 4536 | XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_BTREE), |
4541 | mp, XFS_ERRTAG_BMAPIFORMAT, XFS_RANDOM_BMAPIFORMAT))) { | 4537 | mp, XFS_ERRTAG_BMAPIFORMAT, XFS_RANDOM_BMAPIFORMAT))) { |
4542 | XFS_ERROR_REPORT("xfs_bmapi_write", XFS_ERRLEVEL_LOW, mp); | 4538 | XFS_ERROR_REPORT("xfs_bmapi_write", XFS_ERRLEVEL_LOW, mp); |
4543 | return XFS_ERROR(EFSCORRUPTED); | 4539 | return -EFSCORRUPTED; |
4544 | } | 4540 | } |
4545 | 4541 | ||
4546 | if (XFS_FORCED_SHUTDOWN(mp)) | 4542 | if (XFS_FORCED_SHUTDOWN(mp)) |
4547 | return XFS_ERROR(EIO); | 4543 | return -EIO; |
4548 | 4544 | ||
4549 | ifp = XFS_IFORK_PTR(ip, whichfork); | 4545 | ifp = XFS_IFORK_PTR(ip, whichfork); |
4550 | 4546 | ||
@@ -4620,7 +4616,7 @@ xfs_bmapi_write( | |||
4620 | 4616 | ||
4621 | /* Execute unwritten extent conversion if necessary */ | 4617 | /* Execute unwritten extent conversion if necessary */ |
4622 | error = xfs_bmapi_convert_unwritten(&bma, mval, len, flags); | 4618 | error = xfs_bmapi_convert_unwritten(&bma, mval, len, flags); |
4623 | if (error == EAGAIN) | 4619 | if (error == -EAGAIN) |
4624 | continue; | 4620 | continue; |
4625 | if (error) | 4621 | if (error) |
4626 | goto error0; | 4622 | goto error0; |
@@ -4922,7 +4918,7 @@ xfs_bmap_del_extent( | |||
4922 | goto done; | 4918 | goto done; |
4923 | cur->bc_rec.b = new; | 4919 | cur->bc_rec.b = new; |
4924 | error = xfs_btree_insert(cur, &i); | 4920 | error = xfs_btree_insert(cur, &i); |
4925 | if (error && error != ENOSPC) | 4921 | if (error && error != -ENOSPC) |
4926 | goto done; | 4922 | goto done; |
4927 | /* | 4923 | /* |
4928 | * If get no-space back from btree insert, | 4924 | * If get no-space back from btree insert, |
@@ -4930,7 +4926,7 @@ xfs_bmap_del_extent( | |||
4930 | * block reservation. | 4926 | * block reservation. |
4931 | * Fix up our state and return the error. | 4927 | * Fix up our state and return the error. |
4932 | */ | 4928 | */ |
4933 | if (error == ENOSPC) { | 4929 | if (error == -ENOSPC) { |
4934 | /* | 4930 | /* |
4935 | * Reset the cursor, don't trust | 4931 | * Reset the cursor, don't trust |
4936 | * it after any insert operation. | 4932 | * it after any insert operation. |
@@ -4958,7 +4954,7 @@ xfs_bmap_del_extent( | |||
4958 | xfs_bmbt_set_blockcount(ep, | 4954 | xfs_bmbt_set_blockcount(ep, |
4959 | got.br_blockcount); | 4955 | got.br_blockcount); |
4960 | flags = 0; | 4956 | flags = 0; |
4961 | error = XFS_ERROR(ENOSPC); | 4957 | error = -ENOSPC; |
4962 | goto done; | 4958 | goto done; |
4963 | } | 4959 | } |
4964 | XFS_WANT_CORRUPTED_GOTO(i == 1, done); | 4960 | XFS_WANT_CORRUPTED_GOTO(i == 1, done); |
@@ -5076,11 +5072,11 @@ xfs_bunmapi( | |||
5076 | XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_BTREE)) { | 5072 | XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_BTREE)) { |
5077 | XFS_ERROR_REPORT("xfs_bunmapi", XFS_ERRLEVEL_LOW, | 5073 | XFS_ERROR_REPORT("xfs_bunmapi", XFS_ERRLEVEL_LOW, |
5078 | ip->i_mount); | 5074 | ip->i_mount); |
5079 | return XFS_ERROR(EFSCORRUPTED); | 5075 | return -EFSCORRUPTED; |
5080 | } | 5076 | } |
5081 | mp = ip->i_mount; | 5077 | mp = ip->i_mount; |
5082 | if (XFS_FORCED_SHUTDOWN(mp)) | 5078 | if (XFS_FORCED_SHUTDOWN(mp)) |
5083 | return XFS_ERROR(EIO); | 5079 | return -EIO; |
5084 | 5080 | ||
5085 | ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); | 5081 | ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); |
5086 | ASSERT(len > 0); | 5082 | ASSERT(len > 0); |
@@ -5325,7 +5321,7 @@ xfs_bunmapi( | |||
5325 | del.br_startoff > got.br_startoff && | 5321 | del.br_startoff > got.br_startoff && |
5326 | del.br_startoff + del.br_blockcount < | 5322 | del.br_startoff + del.br_blockcount < |
5327 | got.br_startoff + got.br_blockcount) { | 5323 | got.br_startoff + got.br_blockcount) { |
5328 | error = XFS_ERROR(ENOSPC); | 5324 | error = -ENOSPC; |
5329 | goto error0; | 5325 | goto error0; |
5330 | } | 5326 | } |
5331 | error = xfs_bmap_del_extent(ip, tp, &lastx, flist, cur, &del, | 5327 | error = xfs_bmap_del_extent(ip, tp, &lastx, flist, cur, &del, |
@@ -5449,11 +5445,11 @@ xfs_bmap_shift_extents( | |||
5449 | mp, XFS_ERRTAG_BMAPIFORMAT, XFS_RANDOM_BMAPIFORMAT))) { | 5445 | mp, XFS_ERRTAG_BMAPIFORMAT, XFS_RANDOM_BMAPIFORMAT))) { |
5450 | XFS_ERROR_REPORT("xfs_bmap_shift_extents", | 5446 | XFS_ERROR_REPORT("xfs_bmap_shift_extents", |
5451 | XFS_ERRLEVEL_LOW, mp); | 5447 | XFS_ERRLEVEL_LOW, mp); |
5452 | return XFS_ERROR(EFSCORRUPTED); | 5448 | return -EFSCORRUPTED; |
5453 | } | 5449 | } |
5454 | 5450 | ||
5455 | if (XFS_FORCED_SHUTDOWN(mp)) | 5451 | if (XFS_FORCED_SHUTDOWN(mp)) |
5456 | return XFS_ERROR(EIO); | 5452 | return -EIO; |
5457 | 5453 | ||
5458 | ASSERT(current_ext != NULL); | 5454 | ASSERT(current_ext != NULL); |
5459 | 5455 | ||
@@ -5516,14 +5512,14 @@ xfs_bmap_shift_extents( | |||
5516 | *current_ext - 1), &left); | 5512 | *current_ext - 1), &left); |
5517 | 5513 | ||
5518 | if (startoff < left.br_startoff + left.br_blockcount) | 5514 | if (startoff < left.br_startoff + left.br_blockcount) |
5519 | error = XFS_ERROR(EINVAL); | 5515 | error = -EINVAL; |
5520 | } else if (offset_shift_fsb > got.br_startoff) { | 5516 | } else if (offset_shift_fsb > got.br_startoff) { |
5521 | /* | 5517 | /* |
5522 | * When first extent is shifted, offset_shift_fsb | 5518 | * When first extent is shifted, offset_shift_fsb |
5523 | * should be less than the stating offset of | 5519 | * should be less than the stating offset of |
5524 | * the first extent. | 5520 | * the first extent. |
5525 | */ | 5521 | */ |
5526 | error = XFS_ERROR(EINVAL); | 5522 | error = -EINVAL; |
5527 | } | 5523 | } |
5528 | 5524 | ||
5529 | if (error) | 5525 | 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..fba753308f31 100644 --- a/fs/xfs/xfs_bmap_btree.c +++ b/fs/xfs/libxfs/xfs_bmap_btree.c | |||
@@ -111,23 +111,8 @@ __xfs_bmbt_get_all( | |||
111 | ext_flag = (int)(l0 >> (64 - BMBT_EXNTFLAG_BITLEN)); | 111 | ext_flag = (int)(l0 >> (64 - BMBT_EXNTFLAG_BITLEN)); |
112 | s->br_startoff = ((xfs_fileoff_t)l0 & | 112 | s->br_startoff = ((xfs_fileoff_t)l0 & |
113 | xfs_mask64lo(64 - BMBT_EXNTFLAG_BITLEN)) >> 9; | 113 | xfs_mask64lo(64 - BMBT_EXNTFLAG_BITLEN)) >> 9; |
114 | #if XFS_BIG_BLKNOS | ||
115 | s->br_startblock = (((xfs_fsblock_t)l0 & xfs_mask64lo(9)) << 43) | | 114 | s->br_startblock = (((xfs_fsblock_t)l0 & xfs_mask64lo(9)) << 43) | |
116 | (((xfs_fsblock_t)l1) >> 21); | 115 | (((xfs_fsblock_t)l1) >> 21); |
117 | #else | ||
118 | #ifdef DEBUG | ||
119 | { | ||
120 | xfs_dfsbno_t b; | ||
121 | |||
122 | b = (((xfs_dfsbno_t)l0 & xfs_mask64lo(9)) << 43) | | ||
123 | (((xfs_dfsbno_t)l1) >> 21); | ||
124 | ASSERT((b >> 32) == 0 || isnulldstartblock(b)); | ||
125 | s->br_startblock = (xfs_fsblock_t)b; | ||
126 | } | ||
127 | #else /* !DEBUG */ | ||
128 | s->br_startblock = (xfs_fsblock_t)(((xfs_dfsbno_t)l1) >> 21); | ||
129 | #endif /* DEBUG */ | ||
130 | #endif /* XFS_BIG_BLKNOS */ | ||
131 | s->br_blockcount = (xfs_filblks_t)(l1 & xfs_mask64lo(21)); | 116 | s->br_blockcount = (xfs_filblks_t)(l1 & xfs_mask64lo(21)); |
132 | /* This is xfs_extent_state() in-line */ | 117 | /* This is xfs_extent_state() in-line */ |
133 | if (ext_flag) { | 118 | if (ext_flag) { |
@@ -163,21 +148,8 @@ xfs_fsblock_t | |||
163 | xfs_bmbt_get_startblock( | 148 | xfs_bmbt_get_startblock( |
164 | xfs_bmbt_rec_host_t *r) | 149 | xfs_bmbt_rec_host_t *r) |
165 | { | 150 | { |
166 | #if XFS_BIG_BLKNOS | ||
167 | return (((xfs_fsblock_t)r->l0 & xfs_mask64lo(9)) << 43) | | 151 | return (((xfs_fsblock_t)r->l0 & xfs_mask64lo(9)) << 43) | |
168 | (((xfs_fsblock_t)r->l1) >> 21); | 152 | (((xfs_fsblock_t)r->l1) >> 21); |
169 | #else | ||
170 | #ifdef DEBUG | ||
171 | xfs_dfsbno_t b; | ||
172 | |||
173 | b = (((xfs_dfsbno_t)r->l0 & xfs_mask64lo(9)) << 43) | | ||
174 | (((xfs_dfsbno_t)r->l1) >> 21); | ||
175 | ASSERT((b >> 32) == 0 || isnulldstartblock(b)); | ||
176 | return (xfs_fsblock_t)b; | ||
177 | #else /* !DEBUG */ | ||
178 | return (xfs_fsblock_t)(((xfs_dfsbno_t)r->l1) >> 21); | ||
179 | #endif /* DEBUG */ | ||
180 | #endif /* XFS_BIG_BLKNOS */ | ||
181 | } | 153 | } |
182 | 154 | ||
183 | /* | 155 | /* |
@@ -241,7 +213,6 @@ xfs_bmbt_set_allf( | |||
241 | ASSERT((startoff & xfs_mask64hi(64-BMBT_STARTOFF_BITLEN)) == 0); | 213 | ASSERT((startoff & xfs_mask64hi(64-BMBT_STARTOFF_BITLEN)) == 0); |
242 | ASSERT((blockcount & xfs_mask64hi(64-BMBT_BLOCKCOUNT_BITLEN)) == 0); | 214 | ASSERT((blockcount & xfs_mask64hi(64-BMBT_BLOCKCOUNT_BITLEN)) == 0); |
243 | 215 | ||
244 | #if XFS_BIG_BLKNOS | ||
245 | ASSERT((startblock & xfs_mask64hi(64-BMBT_STARTBLOCK_BITLEN)) == 0); | 216 | ASSERT((startblock & xfs_mask64hi(64-BMBT_STARTBLOCK_BITLEN)) == 0); |
246 | 217 | ||
247 | r->l0 = ((xfs_bmbt_rec_base_t)extent_flag << 63) | | 218 | r->l0 = ((xfs_bmbt_rec_base_t)extent_flag << 63) | |
@@ -250,23 +221,6 @@ xfs_bmbt_set_allf( | |||
250 | r->l1 = ((xfs_bmbt_rec_base_t)startblock << 21) | | 221 | r->l1 = ((xfs_bmbt_rec_base_t)startblock << 21) | |
251 | ((xfs_bmbt_rec_base_t)blockcount & | 222 | ((xfs_bmbt_rec_base_t)blockcount & |
252 | (xfs_bmbt_rec_base_t)xfs_mask64lo(21)); | 223 | (xfs_bmbt_rec_base_t)xfs_mask64lo(21)); |
253 | #else /* !XFS_BIG_BLKNOS */ | ||
254 | if (isnullstartblock(startblock)) { | ||
255 | r->l0 = ((xfs_bmbt_rec_base_t)extent_flag << 63) | | ||
256 | ((xfs_bmbt_rec_base_t)startoff << 9) | | ||
257 | (xfs_bmbt_rec_base_t)xfs_mask64lo(9); | ||
258 | r->l1 = xfs_mask64hi(11) | | ||
259 | ((xfs_bmbt_rec_base_t)startblock << 21) | | ||
260 | ((xfs_bmbt_rec_base_t)blockcount & | ||
261 | (xfs_bmbt_rec_base_t)xfs_mask64lo(21)); | ||
262 | } else { | ||
263 | r->l0 = ((xfs_bmbt_rec_base_t)extent_flag << 63) | | ||
264 | ((xfs_bmbt_rec_base_t)startoff << 9); | ||
265 | r->l1 = ((xfs_bmbt_rec_base_t)startblock << 21) | | ||
266 | ((xfs_bmbt_rec_base_t)blockcount & | ||
267 | (xfs_bmbt_rec_base_t)xfs_mask64lo(21)); | ||
268 | } | ||
269 | #endif /* XFS_BIG_BLKNOS */ | ||
270 | } | 224 | } |
271 | 225 | ||
272 | /* | 226 | /* |
@@ -298,8 +252,6 @@ xfs_bmbt_disk_set_allf( | |||
298 | ASSERT(state == XFS_EXT_NORM || state == XFS_EXT_UNWRITTEN); | 252 | ASSERT(state == XFS_EXT_NORM || state == XFS_EXT_UNWRITTEN); |
299 | ASSERT((startoff & xfs_mask64hi(64-BMBT_STARTOFF_BITLEN)) == 0); | 253 | ASSERT((startoff & xfs_mask64hi(64-BMBT_STARTOFF_BITLEN)) == 0); |
300 | ASSERT((blockcount & xfs_mask64hi(64-BMBT_BLOCKCOUNT_BITLEN)) == 0); | 254 | ASSERT((blockcount & xfs_mask64hi(64-BMBT_BLOCKCOUNT_BITLEN)) == 0); |
301 | |||
302 | #if XFS_BIG_BLKNOS | ||
303 | ASSERT((startblock & xfs_mask64hi(64-BMBT_STARTBLOCK_BITLEN)) == 0); | 255 | ASSERT((startblock & xfs_mask64hi(64-BMBT_STARTBLOCK_BITLEN)) == 0); |
304 | 256 | ||
305 | r->l0 = cpu_to_be64( | 257 | r->l0 = cpu_to_be64( |
@@ -310,26 +262,6 @@ xfs_bmbt_disk_set_allf( | |||
310 | ((xfs_bmbt_rec_base_t)startblock << 21) | | 262 | ((xfs_bmbt_rec_base_t)startblock << 21) | |
311 | ((xfs_bmbt_rec_base_t)blockcount & | 263 | ((xfs_bmbt_rec_base_t)blockcount & |
312 | (xfs_bmbt_rec_base_t)xfs_mask64lo(21))); | 264 | (xfs_bmbt_rec_base_t)xfs_mask64lo(21))); |
313 | #else /* !XFS_BIG_BLKNOS */ | ||
314 | if (isnullstartblock(startblock)) { | ||
315 | r->l0 = cpu_to_be64( | ||
316 | ((xfs_bmbt_rec_base_t)extent_flag << 63) | | ||
317 | ((xfs_bmbt_rec_base_t)startoff << 9) | | ||
318 | (xfs_bmbt_rec_base_t)xfs_mask64lo(9)); | ||
319 | r->l1 = cpu_to_be64(xfs_mask64hi(11) | | ||
320 | ((xfs_bmbt_rec_base_t)startblock << 21) | | ||
321 | ((xfs_bmbt_rec_base_t)blockcount & | ||
322 | (xfs_bmbt_rec_base_t)xfs_mask64lo(21))); | ||
323 | } else { | ||
324 | r->l0 = cpu_to_be64( | ||
325 | ((xfs_bmbt_rec_base_t)extent_flag << 63) | | ||
326 | ((xfs_bmbt_rec_base_t)startoff << 9)); | ||
327 | r->l1 = cpu_to_be64( | ||
328 | ((xfs_bmbt_rec_base_t)startblock << 21) | | ||
329 | ((xfs_bmbt_rec_base_t)blockcount & | ||
330 | (xfs_bmbt_rec_base_t)xfs_mask64lo(21))); | ||
331 | } | ||
332 | #endif /* XFS_BIG_BLKNOS */ | ||
333 | } | 265 | } |
334 | 266 | ||
335 | /* | 267 | /* |
@@ -365,24 +297,11 @@ xfs_bmbt_set_startblock( | |||
365 | xfs_bmbt_rec_host_t *r, | 297 | xfs_bmbt_rec_host_t *r, |
366 | xfs_fsblock_t v) | 298 | xfs_fsblock_t v) |
367 | { | 299 | { |
368 | #if XFS_BIG_BLKNOS | ||
369 | ASSERT((v & xfs_mask64hi(12)) == 0); | 300 | ASSERT((v & xfs_mask64hi(12)) == 0); |
370 | r->l0 = (r->l0 & (xfs_bmbt_rec_base_t)xfs_mask64hi(55)) | | 301 | r->l0 = (r->l0 & (xfs_bmbt_rec_base_t)xfs_mask64hi(55)) | |
371 | (xfs_bmbt_rec_base_t)(v >> 43); | 302 | (xfs_bmbt_rec_base_t)(v >> 43); |
372 | r->l1 = (r->l1 & (xfs_bmbt_rec_base_t)xfs_mask64lo(21)) | | 303 | r->l1 = (r->l1 & (xfs_bmbt_rec_base_t)xfs_mask64lo(21)) | |
373 | (xfs_bmbt_rec_base_t)(v << 21); | 304 | (xfs_bmbt_rec_base_t)(v << 21); |
374 | #else /* !XFS_BIG_BLKNOS */ | ||
375 | if (isnullstartblock(v)) { | ||
376 | r->l0 |= (xfs_bmbt_rec_base_t)xfs_mask64lo(9); | ||
377 | r->l1 = (xfs_bmbt_rec_base_t)xfs_mask64hi(11) | | ||
378 | ((xfs_bmbt_rec_base_t)v << 21) | | ||
379 | (r->l1 & (xfs_bmbt_rec_base_t)xfs_mask64lo(21)); | ||
380 | } else { | ||
381 | r->l0 &= ~(xfs_bmbt_rec_base_t)xfs_mask64lo(9); | ||
382 | r->l1 = ((xfs_bmbt_rec_base_t)v << 21) | | ||
383 | (r->l1 & (xfs_bmbt_rec_base_t)xfs_mask64lo(21)); | ||
384 | } | ||
385 | #endif /* XFS_BIG_BLKNOS */ | ||
386 | } | 305 | } |
387 | 306 | ||
388 | /* | 307 | /* |
@@ -438,8 +357,8 @@ xfs_bmbt_to_bmdr( | |||
438 | cpu_to_be64(XFS_BUF_DADDR_NULL)); | 357 | cpu_to_be64(XFS_BUF_DADDR_NULL)); |
439 | } else | 358 | } else |
440 | ASSERT(rblock->bb_magic == cpu_to_be32(XFS_BMAP_MAGIC)); | 359 | ASSERT(rblock->bb_magic == cpu_to_be32(XFS_BMAP_MAGIC)); |
441 | ASSERT(rblock->bb_u.l.bb_leftsib == cpu_to_be64(NULLDFSBNO)); | 360 | ASSERT(rblock->bb_u.l.bb_leftsib == cpu_to_be64(NULLFSBLOCK)); |
442 | ASSERT(rblock->bb_u.l.bb_rightsib == cpu_to_be64(NULLDFSBNO)); | 361 | ASSERT(rblock->bb_u.l.bb_rightsib == cpu_to_be64(NULLFSBLOCK)); |
443 | ASSERT(rblock->bb_level != 0); | 362 | ASSERT(rblock->bb_level != 0); |
444 | dblock->bb_level = rblock->bb_level; | 363 | dblock->bb_level = rblock->bb_level; |
445 | dblock->bb_numrecs = rblock->bb_numrecs; | 364 | dblock->bb_numrecs = rblock->bb_numrecs; |
@@ -554,7 +473,7 @@ xfs_bmbt_alloc_block( | |||
554 | args.minlen = args.maxlen = args.prod = 1; | 473 | args.minlen = args.maxlen = args.prod = 1; |
555 | args.wasdel = cur->bc_private.b.flags & XFS_BTCUR_BPRV_WASDEL; | 474 | args.wasdel = cur->bc_private.b.flags & XFS_BTCUR_BPRV_WASDEL; |
556 | if (!args.wasdel && xfs_trans_get_block_res(args.tp) == 0) { | 475 | if (!args.wasdel && xfs_trans_get_block_res(args.tp) == 0) { |
557 | error = XFS_ERROR(ENOSPC); | 476 | error = -ENOSPC; |
558 | goto error0; | 477 | goto error0; |
559 | } | 478 | } |
560 | error = xfs_alloc_vextent(&args); | 479 | error = xfs_alloc_vextent(&args); |
@@ -763,11 +682,11 @@ xfs_bmbt_verify( | |||
763 | 682 | ||
764 | /* sibling pointer verification */ | 683 | /* sibling pointer verification */ |
765 | if (!block->bb_u.l.bb_leftsib || | 684 | if (!block->bb_u.l.bb_leftsib || |
766 | (block->bb_u.l.bb_leftsib != cpu_to_be64(NULLDFSBNO) && | 685 | (block->bb_u.l.bb_leftsib != cpu_to_be64(NULLFSBLOCK) && |
767 | !XFS_FSB_SANITY_CHECK(mp, be64_to_cpu(block->bb_u.l.bb_leftsib)))) | 686 | !XFS_FSB_SANITY_CHECK(mp, be64_to_cpu(block->bb_u.l.bb_leftsib)))) |
768 | return false; | 687 | return false; |
769 | if (!block->bb_u.l.bb_rightsib || | 688 | if (!block->bb_u.l.bb_rightsib || |
770 | (block->bb_u.l.bb_rightsib != cpu_to_be64(NULLDFSBNO) && | 689 | (block->bb_u.l.bb_rightsib != cpu_to_be64(NULLFSBLOCK) && |
771 | !XFS_FSB_SANITY_CHECK(mp, be64_to_cpu(block->bb_u.l.bb_rightsib)))) | 690 | !XFS_FSB_SANITY_CHECK(mp, be64_to_cpu(block->bb_u.l.bb_rightsib)))) |
772 | return false; | 691 | return false; |
773 | 692 | ||
@@ -779,9 +698,9 @@ xfs_bmbt_read_verify( | |||
779 | struct xfs_buf *bp) | 698 | struct xfs_buf *bp) |
780 | { | 699 | { |
781 | if (!xfs_btree_lblock_verify_crc(bp)) | 700 | if (!xfs_btree_lblock_verify_crc(bp)) |
782 | xfs_buf_ioerror(bp, EFSBADCRC); | 701 | xfs_buf_ioerror(bp, -EFSBADCRC); |
783 | else if (!xfs_bmbt_verify(bp)) | 702 | else if (!xfs_bmbt_verify(bp)) |
784 | xfs_buf_ioerror(bp, EFSCORRUPTED); | 703 | xfs_buf_ioerror(bp, -EFSCORRUPTED); |
785 | 704 | ||
786 | if (bp->b_error) { | 705 | if (bp->b_error) { |
787 | trace_xfs_btree_corrupt(bp, _RET_IP_); | 706 | trace_xfs_btree_corrupt(bp, _RET_IP_); |
@@ -795,7 +714,7 @@ xfs_bmbt_write_verify( | |||
795 | { | 714 | { |
796 | if (!xfs_bmbt_verify(bp)) { | 715 | if (!xfs_bmbt_verify(bp)) { |
797 | trace_xfs_btree_corrupt(bp, _RET_IP_); | 716 | trace_xfs_btree_corrupt(bp, _RET_IP_); |
798 | xfs_buf_ioerror(bp, EFSCORRUPTED); | 717 | xfs_buf_ioerror(bp, -EFSCORRUPTED); |
799 | xfs_verifier_error(bp); | 718 | xfs_verifier_error(bp); |
800 | return; | 719 | return; |
801 | } | 720 | } |
@@ -959,7 +878,7 @@ xfs_bmbt_change_owner( | |||
959 | 878 | ||
960 | cur = xfs_bmbt_init_cursor(ip->i_mount, tp, ip, whichfork); | 879 | cur = xfs_bmbt_init_cursor(ip->i_mount, tp, ip, whichfork); |
961 | if (!cur) | 880 | if (!cur) |
962 | return ENOMEM; | 881 | return -ENOMEM; |
963 | 882 | ||
964 | error = xfs_btree_change_owner(cur, new_owner, buffer_list); | 883 | error = xfs_btree_change_owner(cur, new_owner, buffer_list); |
965 | xfs_btree_del_cursor(cur, error ? XFS_BTREE_ERROR : XFS_BTREE_NOERROR); | 884 | 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..8fe6a93ff473 100644 --- a/fs/xfs/xfs_btree.c +++ b/fs/xfs/libxfs/xfs_btree.c | |||
@@ -78,11 +78,11 @@ xfs_btree_check_lblock( | |||
78 | be16_to_cpu(block->bb_numrecs) <= | 78 | be16_to_cpu(block->bb_numrecs) <= |
79 | cur->bc_ops->get_maxrecs(cur, level) && | 79 | cur->bc_ops->get_maxrecs(cur, level) && |
80 | block->bb_u.l.bb_leftsib && | 80 | block->bb_u.l.bb_leftsib && |
81 | (block->bb_u.l.bb_leftsib == cpu_to_be64(NULLDFSBNO) || | 81 | (block->bb_u.l.bb_leftsib == cpu_to_be64(NULLFSBLOCK) || |
82 | XFS_FSB_SANITY_CHECK(mp, | 82 | XFS_FSB_SANITY_CHECK(mp, |
83 | be64_to_cpu(block->bb_u.l.bb_leftsib))) && | 83 | be64_to_cpu(block->bb_u.l.bb_leftsib))) && |
84 | block->bb_u.l.bb_rightsib && | 84 | block->bb_u.l.bb_rightsib && |
85 | (block->bb_u.l.bb_rightsib == cpu_to_be64(NULLDFSBNO) || | 85 | (block->bb_u.l.bb_rightsib == cpu_to_be64(NULLFSBLOCK) || |
86 | XFS_FSB_SANITY_CHECK(mp, | 86 | XFS_FSB_SANITY_CHECK(mp, |
87 | be64_to_cpu(block->bb_u.l.bb_rightsib))); | 87 | be64_to_cpu(block->bb_u.l.bb_rightsib))); |
88 | 88 | ||
@@ -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 | } |
@@ -167,12 +167,12 @@ xfs_btree_check_block( | |||
167 | int /* error (0 or EFSCORRUPTED) */ | 167 | int /* error (0 or EFSCORRUPTED) */ |
168 | xfs_btree_check_lptr( | 168 | xfs_btree_check_lptr( |
169 | struct xfs_btree_cur *cur, /* btree cursor */ | 169 | struct xfs_btree_cur *cur, /* btree cursor */ |
170 | xfs_dfsbno_t bno, /* btree block disk address */ | 170 | xfs_fsblock_t bno, /* btree block disk address */ |
171 | int level) /* btree block level */ | 171 | int level) /* btree block level */ |
172 | { | 172 | { |
173 | XFS_WANT_CORRUPTED_RETURN( | 173 | XFS_WANT_CORRUPTED_RETURN( |
174 | level > 0 && | 174 | level > 0 && |
175 | bno != NULLDFSBNO && | 175 | bno != NULLFSBLOCK && |
176 | XFS_FSB_SANITY_CHECK(cur->bc_mp, bno)); | 176 | XFS_FSB_SANITY_CHECK(cur->bc_mp, bno)); |
177 | return 0; | 177 | return 0; |
178 | } | 178 | } |
@@ -595,7 +595,7 @@ xfs_btree_islastblock( | |||
595 | block = xfs_btree_get_block(cur, level, &bp); | 595 | block = xfs_btree_get_block(cur, level, &bp); |
596 | xfs_btree_check_block(cur, block, level, bp); | 596 | xfs_btree_check_block(cur, block, level, bp); |
597 | if (cur->bc_flags & XFS_BTREE_LONG_PTRS) | 597 | if (cur->bc_flags & XFS_BTREE_LONG_PTRS) |
598 | return block->bb_u.l.bb_rightsib == cpu_to_be64(NULLDFSBNO); | 598 | return block->bb_u.l.bb_rightsib == cpu_to_be64(NULLFSBLOCK); |
599 | else | 599 | else |
600 | return block->bb_u.s.bb_rightsib == cpu_to_be32(NULLAGBLOCK); | 600 | return block->bb_u.s.bb_rightsib == cpu_to_be32(NULLAGBLOCK); |
601 | } | 601 | } |
@@ -771,16 +771,16 @@ xfs_btree_readahead_lblock( | |||
771 | struct xfs_btree_block *block) | 771 | struct xfs_btree_block *block) |
772 | { | 772 | { |
773 | int rval = 0; | 773 | int rval = 0; |
774 | xfs_dfsbno_t left = be64_to_cpu(block->bb_u.l.bb_leftsib); | 774 | xfs_fsblock_t left = be64_to_cpu(block->bb_u.l.bb_leftsib); |
775 | xfs_dfsbno_t right = be64_to_cpu(block->bb_u.l.bb_rightsib); | 775 | xfs_fsblock_t right = be64_to_cpu(block->bb_u.l.bb_rightsib); |
776 | 776 | ||
777 | if ((lr & XFS_BTCUR_LEFTRA) && left != NULLDFSBNO) { | 777 | if ((lr & XFS_BTCUR_LEFTRA) && left != NULLFSBLOCK) { |
778 | xfs_btree_reada_bufl(cur->bc_mp, left, 1, | 778 | xfs_btree_reada_bufl(cur->bc_mp, left, 1, |
779 | cur->bc_ops->buf_ops); | 779 | cur->bc_ops->buf_ops); |
780 | rval++; | 780 | rval++; |
781 | } | 781 | } |
782 | 782 | ||
783 | if ((lr & XFS_BTCUR_RIGHTRA) && right != NULLDFSBNO) { | 783 | if ((lr & XFS_BTCUR_RIGHTRA) && right != NULLFSBLOCK) { |
784 | xfs_btree_reada_bufl(cur->bc_mp, right, 1, | 784 | xfs_btree_reada_bufl(cur->bc_mp, right, 1, |
785 | cur->bc_ops->buf_ops); | 785 | cur->bc_ops->buf_ops); |
786 | rval++; | 786 | rval++; |
@@ -852,7 +852,7 @@ xfs_btree_ptr_to_daddr( | |||
852 | union xfs_btree_ptr *ptr) | 852 | union xfs_btree_ptr *ptr) |
853 | { | 853 | { |
854 | if (cur->bc_flags & XFS_BTREE_LONG_PTRS) { | 854 | if (cur->bc_flags & XFS_BTREE_LONG_PTRS) { |
855 | ASSERT(ptr->l != cpu_to_be64(NULLDFSBNO)); | 855 | ASSERT(ptr->l != cpu_to_be64(NULLFSBLOCK)); |
856 | 856 | ||
857 | return XFS_FSB_TO_DADDR(cur->bc_mp, be64_to_cpu(ptr->l)); | 857 | return XFS_FSB_TO_DADDR(cur->bc_mp, be64_to_cpu(ptr->l)); |
858 | } else { | 858 | } else { |
@@ -900,9 +900,9 @@ xfs_btree_setbuf( | |||
900 | 900 | ||
901 | b = XFS_BUF_TO_BLOCK(bp); | 901 | b = XFS_BUF_TO_BLOCK(bp); |
902 | if (cur->bc_flags & XFS_BTREE_LONG_PTRS) { | 902 | if (cur->bc_flags & XFS_BTREE_LONG_PTRS) { |
903 | if (b->bb_u.l.bb_leftsib == cpu_to_be64(NULLDFSBNO)) | 903 | if (b->bb_u.l.bb_leftsib == cpu_to_be64(NULLFSBLOCK)) |
904 | cur->bc_ra[lev] |= XFS_BTCUR_LEFTRA; | 904 | cur->bc_ra[lev] |= XFS_BTCUR_LEFTRA; |
905 | if (b->bb_u.l.bb_rightsib == cpu_to_be64(NULLDFSBNO)) | 905 | if (b->bb_u.l.bb_rightsib == cpu_to_be64(NULLFSBLOCK)) |
906 | cur->bc_ra[lev] |= XFS_BTCUR_RIGHTRA; | 906 | cur->bc_ra[lev] |= XFS_BTCUR_RIGHTRA; |
907 | } else { | 907 | } else { |
908 | if (b->bb_u.s.bb_leftsib == cpu_to_be32(NULLAGBLOCK)) | 908 | if (b->bb_u.s.bb_leftsib == cpu_to_be32(NULLAGBLOCK)) |
@@ -918,7 +918,7 @@ xfs_btree_ptr_is_null( | |||
918 | union xfs_btree_ptr *ptr) | 918 | union xfs_btree_ptr *ptr) |
919 | { | 919 | { |
920 | if (cur->bc_flags & XFS_BTREE_LONG_PTRS) | 920 | if (cur->bc_flags & XFS_BTREE_LONG_PTRS) |
921 | return ptr->l == cpu_to_be64(NULLDFSBNO); | 921 | return ptr->l == cpu_to_be64(NULLFSBLOCK); |
922 | else | 922 | else |
923 | return ptr->s == cpu_to_be32(NULLAGBLOCK); | 923 | return ptr->s == cpu_to_be32(NULLAGBLOCK); |
924 | } | 924 | } |
@@ -929,7 +929,7 @@ xfs_btree_set_ptr_null( | |||
929 | union xfs_btree_ptr *ptr) | 929 | union xfs_btree_ptr *ptr) |
930 | { | 930 | { |
931 | if (cur->bc_flags & XFS_BTREE_LONG_PTRS) | 931 | if (cur->bc_flags & XFS_BTREE_LONG_PTRS) |
932 | ptr->l = cpu_to_be64(NULLDFSBNO); | 932 | ptr->l = cpu_to_be64(NULLFSBLOCK); |
933 | else | 933 | else |
934 | ptr->s = cpu_to_be32(NULLAGBLOCK); | 934 | ptr->s = cpu_to_be32(NULLAGBLOCK); |
935 | } | 935 | } |
@@ -997,8 +997,8 @@ xfs_btree_init_block_int( | |||
997 | buf->bb_numrecs = cpu_to_be16(numrecs); | 997 | buf->bb_numrecs = cpu_to_be16(numrecs); |
998 | 998 | ||
999 | if (flags & XFS_BTREE_LONG_PTRS) { | 999 | if (flags & XFS_BTREE_LONG_PTRS) { |
1000 | buf->bb_u.l.bb_leftsib = cpu_to_be64(NULLDFSBNO); | 1000 | buf->bb_u.l.bb_leftsib = cpu_to_be64(NULLFSBLOCK); |
1001 | buf->bb_u.l.bb_rightsib = cpu_to_be64(NULLDFSBNO); | 1001 | buf->bb_u.l.bb_rightsib = cpu_to_be64(NULLFSBLOCK); |
1002 | if (flags & XFS_BTREE_CRC_BLOCKS) { | 1002 | if (flags & XFS_BTREE_CRC_BLOCKS) { |
1003 | buf->bb_u.l.bb_blkno = cpu_to_be64(blkno); | 1003 | buf->bb_u.l.bb_blkno = cpu_to_be64(blkno); |
1004 | buf->bb_u.l.bb_owner = cpu_to_be64(owner); | 1004 | buf->bb_u.l.bb_owner = cpu_to_be64(owner); |
@@ -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..8f18bab73ea5 100644 --- a/fs/xfs/xfs_btree.h +++ b/fs/xfs/libxfs/xfs_btree.h | |||
@@ -258,7 +258,7 @@ xfs_btree_check_block( | |||
258 | int /* error (0 or EFSCORRUPTED) */ | 258 | int /* error (0 or EFSCORRUPTED) */ |
259 | xfs_btree_check_lptr( | 259 | xfs_btree_check_lptr( |
260 | struct xfs_btree_cur *cur, /* btree cursor */ | 260 | struct xfs_btree_cur *cur, /* btree cursor */ |
261 | xfs_dfsbno_t ptr, /* btree block disk address */ | 261 | xfs_fsblock_t ptr, /* btree block disk address */ |
262 | int level); /* btree block level */ | 262 | int level); /* btree block level */ |
263 | 263 | ||
264 | /* | 264 | /* |
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..2c42ae28d027 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) || |
@@ -2004,7 +2004,7 @@ xfs_da_grow_inode_int( | |||
2004 | struct xfs_trans *tp = args->trans; | 2004 | struct xfs_trans *tp = args->trans; |
2005 | struct xfs_inode *dp = args->dp; | 2005 | struct xfs_inode *dp = args->dp; |
2006 | int w = args->whichfork; | 2006 | int w = args->whichfork; |
2007 | xfs_drfsbno_t nblks = dp->i_d.di_nblocks; | 2007 | xfs_rfsblock_t nblks = dp->i_d.di_nblocks; |
2008 | struct xfs_bmbt_irec map, *mapp; | 2008 | struct xfs_bmbt_irec map, *mapp; |
2009 | int nmap, error, got, i, mapi; | 2009 | int nmap, error, got, i, mapi; |
2010 | 2010 | ||
@@ -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 | ||
394 | out_check_rval: | 394 | out_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..5079e051ef08 100644 --- a/fs/xfs/xfs_dir2_sf.c +++ b/fs/xfs/libxfs/xfs_dir2_sf.c | |||
@@ -51,10 +51,9 @@ static void xfs_dir2_sf_check(xfs_da_args_t *args); | |||
51 | #else | 51 | #else |
52 | #define xfs_dir2_sf_check(args) | 52 | #define xfs_dir2_sf_check(args) |
53 | #endif /* DEBUG */ | 53 | #endif /* DEBUG */ |
54 | #if XFS_BIG_INUMS | 54 | |
55 | static void xfs_dir2_sf_toino4(xfs_da_args_t *args); | 55 | static void xfs_dir2_sf_toino4(xfs_da_args_t *args); |
56 | static void xfs_dir2_sf_toino8(xfs_da_args_t *args); | 56 | static void xfs_dir2_sf_toino8(xfs_da_args_t *args); |
57 | #endif /* XFS_BIG_INUMS */ | ||
58 | 57 | ||
59 | /* | 58 | /* |
60 | * Given a block directory (dp/block), calculate its size as a shortform (sf) | 59 | * Given a block directory (dp/block), calculate its size as a shortform (sf) |
@@ -117,10 +116,10 @@ xfs_dir2_block_sfsize( | |||
117 | isdotdot = | 116 | isdotdot = |
118 | dep->namelen == 2 && | 117 | dep->namelen == 2 && |
119 | dep->name[0] == '.' && dep->name[1] == '.'; | 118 | dep->name[0] == '.' && dep->name[1] == '.'; |
120 | #if XFS_BIG_INUMS | 119 | |
121 | if (!isdot) | 120 | if (!isdot) |
122 | i8count += be64_to_cpu(dep->inumber) > XFS_DIR2_MAX_SHORT_INUM; | 121 | i8count += be64_to_cpu(dep->inumber) > XFS_DIR2_MAX_SHORT_INUM; |
123 | #endif | 122 | |
124 | /* take into account the file type field */ | 123 | /* take into account the file type field */ |
125 | if (!isdot && !isdotdot) { | 124 | if (!isdot && !isdotdot) { |
126 | count++; | 125 | count++; |
@@ -251,7 +250,7 @@ xfs_dir2_block_to_sf( | |||
251 | logflags = XFS_ILOG_CORE; | 250 | logflags = XFS_ILOG_CORE; |
252 | error = xfs_dir2_shrink_inode(args, args->geo->datablk, bp); | 251 | error = xfs_dir2_shrink_inode(args, args->geo->datablk, bp); |
253 | if (error) { | 252 | if (error) { |
254 | ASSERT(error != ENOSPC); | 253 | ASSERT(error != -ENOSPC); |
255 | goto out; | 254 | goto out; |
256 | } | 255 | } |
257 | 256 | ||
@@ -299,7 +298,7 @@ xfs_dir2_sf_addname( | |||
299 | 298 | ||
300 | trace_xfs_dir2_sf_addname(args); | 299 | trace_xfs_dir2_sf_addname(args); |
301 | 300 | ||
302 | ASSERT(xfs_dir2_sf_lookup(args) == ENOENT); | 301 | ASSERT(xfs_dir2_sf_lookup(args) == -ENOENT); |
303 | dp = args->dp; | 302 | dp = args->dp; |
304 | ASSERT(dp->i_df.if_flags & XFS_IFINLINE); | 303 | ASSERT(dp->i_df.if_flags & XFS_IFINLINE); |
305 | /* | 304 | /* |
@@ -307,7 +306,7 @@ xfs_dir2_sf_addname( | |||
307 | */ | 306 | */ |
308 | if (dp->i_d.di_size < offsetof(xfs_dir2_sf_hdr_t, parent)) { | 307 | if (dp->i_d.di_size < offsetof(xfs_dir2_sf_hdr_t, parent)) { |
309 | ASSERT(XFS_FORCED_SHUTDOWN(dp->i_mount)); | 308 | ASSERT(XFS_FORCED_SHUTDOWN(dp->i_mount)); |
310 | return XFS_ERROR(EIO); | 309 | return -EIO; |
311 | } | 310 | } |
312 | ASSERT(dp->i_df.if_bytes == dp->i_d.di_size); | 311 | ASSERT(dp->i_df.if_bytes == dp->i_d.di_size); |
313 | ASSERT(dp->i_df.if_u1.if_data != NULL); | 312 | ASSERT(dp->i_df.if_u1.if_data != NULL); |
@@ -318,7 +317,7 @@ xfs_dir2_sf_addname( | |||
318 | */ | 317 | */ |
319 | incr_isize = dp->d_ops->sf_entsize(sfp, args->namelen); | 318 | incr_isize = dp->d_ops->sf_entsize(sfp, args->namelen); |
320 | objchange = 0; | 319 | objchange = 0; |
321 | #if XFS_BIG_INUMS | 320 | |
322 | /* | 321 | /* |
323 | * Do we have to change to 8 byte inodes? | 322 | * Do we have to change to 8 byte inodes? |
324 | */ | 323 | */ |
@@ -332,7 +331,7 @@ xfs_dir2_sf_addname( | |||
332 | (uint)sizeof(xfs_dir2_ino4_t)); | 331 | (uint)sizeof(xfs_dir2_ino4_t)); |
333 | objchange = 1; | 332 | objchange = 1; |
334 | } | 333 | } |
335 | #endif | 334 | |
336 | new_isize = (int)dp->i_d.di_size + incr_isize; | 335 | new_isize = (int)dp->i_d.di_size + incr_isize; |
337 | /* | 336 | /* |
338 | * Won't fit as shortform any more (due to size), | 337 | * Won't fit as shortform any more (due to size), |
@@ -345,7 +344,7 @@ xfs_dir2_sf_addname( | |||
345 | * Just checking or no space reservation, it doesn't fit. | 344 | * Just checking or no space reservation, it doesn't fit. |
346 | */ | 345 | */ |
347 | if ((args->op_flags & XFS_DA_OP_JUSTCHECK) || args->total == 0) | 346 | if ((args->op_flags & XFS_DA_OP_JUSTCHECK) || args->total == 0) |
348 | return XFS_ERROR(ENOSPC); | 347 | return -ENOSPC; |
349 | /* | 348 | /* |
350 | * Convert to block form then add the name. | 349 | * Convert to block form then add the name. |
351 | */ | 350 | */ |
@@ -370,10 +369,8 @@ xfs_dir2_sf_addname( | |||
370 | */ | 369 | */ |
371 | else { | 370 | else { |
372 | ASSERT(pick == 2); | 371 | ASSERT(pick == 2); |
373 | #if XFS_BIG_INUMS | ||
374 | if (objchange) | 372 | if (objchange) |
375 | xfs_dir2_sf_toino8(args); | 373 | xfs_dir2_sf_toino8(args); |
376 | #endif | ||
377 | xfs_dir2_sf_addname_hard(args, objchange, new_isize); | 374 | xfs_dir2_sf_addname_hard(args, objchange, new_isize); |
378 | } | 375 | } |
379 | xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_DDATA); | 376 | xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_DDATA); |
@@ -425,10 +422,8 @@ xfs_dir2_sf_addname_easy( | |||
425 | * Update the header and inode. | 422 | * Update the header and inode. |
426 | */ | 423 | */ |
427 | sfp->count++; | 424 | sfp->count++; |
428 | #if XFS_BIG_INUMS | ||
429 | if (args->inumber > XFS_DIR2_MAX_SHORT_INUM) | 425 | if (args->inumber > XFS_DIR2_MAX_SHORT_INUM) |
430 | sfp->i8count++; | 426 | sfp->i8count++; |
431 | #endif | ||
432 | dp->i_d.di_size = new_isize; | 427 | dp->i_d.di_size = new_isize; |
433 | xfs_dir2_sf_check(args); | 428 | xfs_dir2_sf_check(args); |
434 | } | 429 | } |
@@ -516,10 +511,8 @@ xfs_dir2_sf_addname_hard( | |||
516 | dp->d_ops->sf_put_ino(sfp, sfep, args->inumber); | 511 | dp->d_ops->sf_put_ino(sfp, sfep, args->inumber); |
517 | dp->d_ops->sf_put_ftype(sfep, args->filetype); | 512 | dp->d_ops->sf_put_ftype(sfep, args->filetype); |
518 | sfp->count++; | 513 | sfp->count++; |
519 | #if XFS_BIG_INUMS | ||
520 | if (args->inumber > XFS_DIR2_MAX_SHORT_INUM && !objchange) | 514 | if (args->inumber > XFS_DIR2_MAX_SHORT_INUM && !objchange) |
521 | sfp->i8count++; | 515 | sfp->i8count++; |
522 | #endif | ||
523 | /* | 516 | /* |
524 | * If there's more left to copy, do that. | 517 | * If there's more left to copy, do that. |
525 | */ | 518 | */ |
@@ -593,13 +586,8 @@ xfs_dir2_sf_addname_pick( | |||
593 | /* | 586 | /* |
594 | * If changing the inode number size, do it the hard way. | 587 | * If changing the inode number size, do it the hard way. |
595 | */ | 588 | */ |
596 | #if XFS_BIG_INUMS | 589 | if (objchange) |
597 | if (objchange) { | ||
598 | return 2; | 590 | return 2; |
599 | } | ||
600 | #else | ||
601 | ASSERT(objchange == 0); | ||
602 | #endif | ||
603 | /* | 591 | /* |
604 | * If it won't fit at the end then do it the hard way (use the hole). | 592 | * If it won't fit at the end then do it the hard way (use the hole). |
605 | */ | 593 | */ |
@@ -650,7 +638,6 @@ xfs_dir2_sf_check( | |||
650 | ASSERT(dp->d_ops->sf_get_ftype(sfep) < XFS_DIR3_FT_MAX); | 638 | ASSERT(dp->d_ops->sf_get_ftype(sfep) < XFS_DIR3_FT_MAX); |
651 | } | 639 | } |
652 | ASSERT(i8count == sfp->i8count); | 640 | ASSERT(i8count == sfp->i8count); |
653 | ASSERT(XFS_BIG_INUMS || i8count == 0); | ||
654 | ASSERT((char *)sfep - (char *)sfp == dp->i_d.di_size); | 641 | ASSERT((char *)sfep - (char *)sfp == dp->i_d.di_size); |
655 | ASSERT(offset + | 642 | ASSERT(offset + |
656 | (sfp->count + 2) * (uint)sizeof(xfs_dir2_leaf_entry_t) + | 643 | (sfp->count + 2) * (uint)sizeof(xfs_dir2_leaf_entry_t) + |
@@ -738,7 +725,7 @@ xfs_dir2_sf_lookup( | |||
738 | */ | 725 | */ |
739 | if (dp->i_d.di_size < offsetof(xfs_dir2_sf_hdr_t, parent)) { | 726 | if (dp->i_d.di_size < offsetof(xfs_dir2_sf_hdr_t, parent)) { |
740 | ASSERT(XFS_FORCED_SHUTDOWN(dp->i_mount)); | 727 | ASSERT(XFS_FORCED_SHUTDOWN(dp->i_mount)); |
741 | return XFS_ERROR(EIO); | 728 | return -EIO; |
742 | } | 729 | } |
743 | ASSERT(dp->i_df.if_bytes == dp->i_d.di_size); | 730 | ASSERT(dp->i_df.if_bytes == dp->i_d.di_size); |
744 | ASSERT(dp->i_df.if_u1.if_data != NULL); | 731 | ASSERT(dp->i_df.if_u1.if_data != NULL); |
@@ -751,7 +738,7 @@ xfs_dir2_sf_lookup( | |||
751 | args->inumber = dp->i_ino; | 738 | args->inumber = dp->i_ino; |
752 | args->cmpresult = XFS_CMP_EXACT; | 739 | args->cmpresult = XFS_CMP_EXACT; |
753 | args->filetype = XFS_DIR3_FT_DIR; | 740 | args->filetype = XFS_DIR3_FT_DIR; |
754 | return XFS_ERROR(EEXIST); | 741 | return -EEXIST; |
755 | } | 742 | } |
756 | /* | 743 | /* |
757 | * Special case for .. | 744 | * Special case for .. |
@@ -761,7 +748,7 @@ xfs_dir2_sf_lookup( | |||
761 | args->inumber = dp->d_ops->sf_get_parent_ino(sfp); | 748 | args->inumber = dp->d_ops->sf_get_parent_ino(sfp); |
762 | args->cmpresult = XFS_CMP_EXACT; | 749 | args->cmpresult = XFS_CMP_EXACT; |
763 | args->filetype = XFS_DIR3_FT_DIR; | 750 | args->filetype = XFS_DIR3_FT_DIR; |
764 | return XFS_ERROR(EEXIST); | 751 | return -EEXIST; |
765 | } | 752 | } |
766 | /* | 753 | /* |
767 | * Loop over all the entries trying to match ours. | 754 | * Loop over all the entries trying to match ours. |
@@ -781,20 +768,20 @@ xfs_dir2_sf_lookup( | |||
781 | args->inumber = dp->d_ops->sf_get_ino(sfp, sfep); | 768 | args->inumber = dp->d_ops->sf_get_ino(sfp, sfep); |
782 | args->filetype = dp->d_ops->sf_get_ftype(sfep); | 769 | args->filetype = dp->d_ops->sf_get_ftype(sfep); |
783 | if (cmp == XFS_CMP_EXACT) | 770 | if (cmp == XFS_CMP_EXACT) |
784 | return XFS_ERROR(EEXIST); | 771 | return -EEXIST; |
785 | ci_sfep = sfep; | 772 | ci_sfep = sfep; |
786 | } | 773 | } |
787 | } | 774 | } |
788 | ASSERT(args->op_flags & XFS_DA_OP_OKNOENT); | 775 | ASSERT(args->op_flags & XFS_DA_OP_OKNOENT); |
789 | /* | 776 | /* |
790 | * Here, we can only be doing a lookup (not a rename or replace). | 777 | * Here, we can only be doing a lookup (not a rename or replace). |
791 | * If a case-insensitive match was not found, return ENOENT. | 778 | * If a case-insensitive match was not found, return -ENOENT. |
792 | */ | 779 | */ |
793 | if (!ci_sfep) | 780 | if (!ci_sfep) |
794 | return XFS_ERROR(ENOENT); | 781 | return -ENOENT; |
795 | /* otherwise process the CI match as required by the caller */ | 782 | /* otherwise process the CI match as required by the caller */ |
796 | error = xfs_dir_cilookup_result(args, ci_sfep->name, ci_sfep->namelen); | 783 | error = xfs_dir_cilookup_result(args, ci_sfep->name, ci_sfep->namelen); |
797 | return XFS_ERROR(error); | 784 | return error; |
798 | } | 785 | } |
799 | 786 | ||
800 | /* | 787 | /* |
@@ -824,7 +811,7 @@ xfs_dir2_sf_removename( | |||
824 | */ | 811 | */ |
825 | if (oldsize < offsetof(xfs_dir2_sf_hdr_t, parent)) { | 812 | if (oldsize < offsetof(xfs_dir2_sf_hdr_t, parent)) { |
826 | ASSERT(XFS_FORCED_SHUTDOWN(dp->i_mount)); | 813 | ASSERT(XFS_FORCED_SHUTDOWN(dp->i_mount)); |
827 | return XFS_ERROR(EIO); | 814 | return -EIO; |
828 | } | 815 | } |
829 | ASSERT(dp->i_df.if_bytes == oldsize); | 816 | ASSERT(dp->i_df.if_bytes == oldsize); |
830 | ASSERT(dp->i_df.if_u1.if_data != NULL); | 817 | ASSERT(dp->i_df.if_u1.if_data != NULL); |
@@ -847,7 +834,7 @@ xfs_dir2_sf_removename( | |||
847 | * Didn't find it. | 834 | * Didn't find it. |
848 | */ | 835 | */ |
849 | if (i == sfp->count) | 836 | if (i == sfp->count) |
850 | return XFS_ERROR(ENOENT); | 837 | return -ENOENT; |
851 | /* | 838 | /* |
852 | * Calculate sizes. | 839 | * Calculate sizes. |
853 | */ | 840 | */ |
@@ -870,7 +857,6 @@ xfs_dir2_sf_removename( | |||
870 | */ | 857 | */ |
871 | xfs_idata_realloc(dp, newsize - oldsize, XFS_DATA_FORK); | 858 | xfs_idata_realloc(dp, newsize - oldsize, XFS_DATA_FORK); |
872 | sfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data; | 859 | sfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data; |
873 | #if XFS_BIG_INUMS | ||
874 | /* | 860 | /* |
875 | * Are we changing inode number size? | 861 | * Are we changing inode number size? |
876 | */ | 862 | */ |
@@ -880,7 +866,6 @@ xfs_dir2_sf_removename( | |||
880 | else | 866 | else |
881 | sfp->i8count--; | 867 | sfp->i8count--; |
882 | } | 868 | } |
883 | #endif | ||
884 | xfs_dir2_sf_check(args); | 869 | xfs_dir2_sf_check(args); |
885 | xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_DDATA); | 870 | xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_DDATA); |
886 | return 0; | 871 | return 0; |
@@ -895,12 +880,8 @@ xfs_dir2_sf_replace( | |||
895 | { | 880 | { |
896 | xfs_inode_t *dp; /* incore directory inode */ | 881 | xfs_inode_t *dp; /* incore directory inode */ |
897 | int i; /* entry index */ | 882 | int i; /* entry index */ |
898 | #if XFS_BIG_INUMS || defined(DEBUG) | ||
899 | xfs_ino_t ino=0; /* entry old inode number */ | 883 | xfs_ino_t ino=0; /* entry old inode number */ |
900 | #endif | ||
901 | #if XFS_BIG_INUMS | ||
902 | int i8elevated; /* sf_toino8 set i8count=1 */ | 884 | int i8elevated; /* sf_toino8 set i8count=1 */ |
903 | #endif | ||
904 | xfs_dir2_sf_entry_t *sfep; /* shortform directory entry */ | 885 | xfs_dir2_sf_entry_t *sfep; /* shortform directory entry */ |
905 | xfs_dir2_sf_hdr_t *sfp; /* shortform structure */ | 886 | xfs_dir2_sf_hdr_t *sfp; /* shortform structure */ |
906 | 887 | ||
@@ -914,13 +895,13 @@ xfs_dir2_sf_replace( | |||
914 | */ | 895 | */ |
915 | if (dp->i_d.di_size < offsetof(xfs_dir2_sf_hdr_t, parent)) { | 896 | if (dp->i_d.di_size < offsetof(xfs_dir2_sf_hdr_t, parent)) { |
916 | ASSERT(XFS_FORCED_SHUTDOWN(dp->i_mount)); | 897 | ASSERT(XFS_FORCED_SHUTDOWN(dp->i_mount)); |
917 | return XFS_ERROR(EIO); | 898 | return -EIO; |
918 | } | 899 | } |
919 | ASSERT(dp->i_df.if_bytes == dp->i_d.di_size); | 900 | ASSERT(dp->i_df.if_bytes == dp->i_d.di_size); |
920 | ASSERT(dp->i_df.if_u1.if_data != NULL); | 901 | ASSERT(dp->i_df.if_u1.if_data != NULL); |
921 | sfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data; | 902 | sfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data; |
922 | ASSERT(dp->i_d.di_size >= xfs_dir2_sf_hdr_size(sfp->i8count)); | 903 | ASSERT(dp->i_d.di_size >= xfs_dir2_sf_hdr_size(sfp->i8count)); |
923 | #if XFS_BIG_INUMS | 904 | |
924 | /* | 905 | /* |
925 | * New inode number is large, and need to convert to 8-byte inodes. | 906 | * New inode number is large, and need to convert to 8-byte inodes. |
926 | */ | 907 | */ |
@@ -951,17 +932,15 @@ xfs_dir2_sf_replace( | |||
951 | sfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data; | 932 | sfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data; |
952 | } else | 933 | } else |
953 | i8elevated = 0; | 934 | i8elevated = 0; |
954 | #endif | 935 | |
955 | ASSERT(args->namelen != 1 || args->name[0] != '.'); | 936 | ASSERT(args->namelen != 1 || args->name[0] != '.'); |
956 | /* | 937 | /* |
957 | * Replace ..'s entry. | 938 | * Replace ..'s entry. |
958 | */ | 939 | */ |
959 | if (args->namelen == 2 && | 940 | if (args->namelen == 2 && |
960 | args->name[0] == '.' && args->name[1] == '.') { | 941 | args->name[0] == '.' && args->name[1] == '.') { |
961 | #if XFS_BIG_INUMS || defined(DEBUG) | ||
962 | ino = dp->d_ops->sf_get_parent_ino(sfp); | 942 | ino = dp->d_ops->sf_get_parent_ino(sfp); |
963 | ASSERT(args->inumber != ino); | 943 | ASSERT(args->inumber != ino); |
964 | #endif | ||
965 | dp->d_ops->sf_put_parent_ino(sfp, args->inumber); | 944 | dp->d_ops->sf_put_parent_ino(sfp, args->inumber); |
966 | } | 945 | } |
967 | /* | 946 | /* |
@@ -972,10 +951,8 @@ xfs_dir2_sf_replace( | |||
972 | i++, sfep = dp->d_ops->sf_nextentry(sfp, sfep)) { | 951 | i++, sfep = dp->d_ops->sf_nextentry(sfp, sfep)) { |
973 | if (xfs_da_compname(args, sfep->name, sfep->namelen) == | 952 | if (xfs_da_compname(args, sfep->name, sfep->namelen) == |
974 | XFS_CMP_EXACT) { | 953 | XFS_CMP_EXACT) { |
975 | #if XFS_BIG_INUMS || defined(DEBUG) | ||
976 | ino = dp->d_ops->sf_get_ino(sfp, sfep); | 954 | ino = dp->d_ops->sf_get_ino(sfp, sfep); |
977 | ASSERT(args->inumber != ino); | 955 | ASSERT(args->inumber != ino); |
978 | #endif | ||
979 | dp->d_ops->sf_put_ino(sfp, sfep, args->inumber); | 956 | dp->d_ops->sf_put_ino(sfp, sfep, args->inumber); |
980 | dp->d_ops->sf_put_ftype(sfep, args->filetype); | 957 | dp->d_ops->sf_put_ftype(sfep, args->filetype); |
981 | break; | 958 | break; |
@@ -986,14 +963,11 @@ xfs_dir2_sf_replace( | |||
986 | */ | 963 | */ |
987 | if (i == sfp->count) { | 964 | if (i == sfp->count) { |
988 | ASSERT(args->op_flags & XFS_DA_OP_OKNOENT); | 965 | ASSERT(args->op_flags & XFS_DA_OP_OKNOENT); |
989 | #if XFS_BIG_INUMS | ||
990 | if (i8elevated) | 966 | if (i8elevated) |
991 | xfs_dir2_sf_toino4(args); | 967 | xfs_dir2_sf_toino4(args); |
992 | #endif | 968 | return -ENOENT; |
993 | return XFS_ERROR(ENOENT); | ||
994 | } | 969 | } |
995 | } | 970 | } |
996 | #if XFS_BIG_INUMS | ||
997 | /* | 971 | /* |
998 | * See if the old number was large, the new number is small. | 972 | * See if the old number was large, the new number is small. |
999 | */ | 973 | */ |
@@ -1020,13 +994,11 @@ xfs_dir2_sf_replace( | |||
1020 | if (!i8elevated) | 994 | if (!i8elevated) |
1021 | sfp->i8count++; | 995 | sfp->i8count++; |
1022 | } | 996 | } |
1023 | #endif | ||
1024 | xfs_dir2_sf_check(args); | 997 | xfs_dir2_sf_check(args); |
1025 | xfs_trans_log_inode(args->trans, dp, XFS_ILOG_DDATA); | 998 | xfs_trans_log_inode(args->trans, dp, XFS_ILOG_DDATA); |
1026 | return 0; | 999 | return 0; |
1027 | } | 1000 | } |
1028 | 1001 | ||
1029 | #if XFS_BIG_INUMS | ||
1030 | /* | 1002 | /* |
1031 | * Convert from 8-byte inode numbers to 4-byte inode numbers. | 1003 | * Convert from 8-byte inode numbers to 4-byte inode numbers. |
1032 | * The last 8-byte inode number is gone, but the count is still 1. | 1004 | * The last 8-byte inode number is gone, but the count is still 1. |
@@ -1181,4 +1153,3 @@ xfs_dir2_sf_toino8( | |||
1181 | dp->i_d.di_size = newsize; | 1153 | dp->i_d.di_size = newsize; |
1182 | xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_DDATA); | 1154 | xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_DDATA); |
1183 | } | 1155 | } |
1184 | #endif /* 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..7e42bba9a420 100644 --- a/fs/xfs/xfs_format.h +++ b/fs/xfs/libxfs/xfs_format.h | |||
@@ -68,11 +68,7 @@ struct xfs_ifork; | |||
68 | #define XFS_RTLOBIT(w) xfs_lowbit32(w) | 68 | #define XFS_RTLOBIT(w) xfs_lowbit32(w) |
69 | #define XFS_RTHIBIT(w) xfs_highbit32(w) | 69 | #define XFS_RTHIBIT(w) xfs_highbit32(w) |
70 | 70 | ||
71 | #if XFS_BIG_BLKNOS | ||
72 | #define XFS_RTBLOCKLOG(b) xfs_highbit64(b) | 71 | #define XFS_RTBLOCKLOG(b) xfs_highbit64(b) |
73 | #else | ||
74 | #define XFS_RTBLOCKLOG(b) xfs_highbit32(b) | ||
75 | #endif | ||
76 | 72 | ||
77 | /* | 73 | /* |
78 | * Dquot and dquot block format definitions | 74 | * Dquot and dquot block format definitions |
@@ -304,23 +300,15 @@ typedef struct xfs_bmbt_rec_host { | |||
304 | * Values and macros for delayed-allocation startblock fields. | 300 | * Values and macros for delayed-allocation startblock fields. |
305 | */ | 301 | */ |
306 | #define STARTBLOCKVALBITS 17 | 302 | #define STARTBLOCKVALBITS 17 |
307 | #define STARTBLOCKMASKBITS (15 + XFS_BIG_BLKNOS * 20) | 303 | #define STARTBLOCKMASKBITS (15 + 20) |
308 | #define DSTARTBLOCKMASKBITS (15 + 20) | ||
309 | #define STARTBLOCKMASK \ | 304 | #define STARTBLOCKMASK \ |
310 | (((((xfs_fsblock_t)1) << STARTBLOCKMASKBITS) - 1) << STARTBLOCKVALBITS) | 305 | (((((xfs_fsblock_t)1) << STARTBLOCKMASKBITS) - 1) << STARTBLOCKVALBITS) |
311 | #define DSTARTBLOCKMASK \ | ||
312 | (((((xfs_dfsbno_t)1) << DSTARTBLOCKMASKBITS) - 1) << STARTBLOCKVALBITS) | ||
313 | 306 | ||
314 | static inline int isnullstartblock(xfs_fsblock_t x) | 307 | static inline int isnullstartblock(xfs_fsblock_t x) |
315 | { | 308 | { |
316 | return ((x) & STARTBLOCKMASK) == STARTBLOCKMASK; | 309 | return ((x) & STARTBLOCKMASK) == STARTBLOCKMASK; |
317 | } | 310 | } |
318 | 311 | ||
319 | static inline int isnulldstartblock(xfs_dfsbno_t x) | ||
320 | { | ||
321 | return ((x) & DSTARTBLOCKMASK) == DSTARTBLOCKMASK; | ||
322 | } | ||
323 | |||
324 | static inline xfs_fsblock_t nullstartblock(int k) | 312 | static inline xfs_fsblock_t nullstartblock(int k) |
325 | { | 313 | { |
326 | ASSERT(k < (1 << STARTBLOCKVALBITS)); | 314 | ASSERT(k < (1 << STARTBLOCKVALBITS)); |
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); |
1426 | out_error: | 1426 | out_error: |
1427 | xfs_perag_put(pag); | 1427 | xfs_perag_put(pag); |
1428 | return XFS_ERROR(error); | 1428 | return error; |
1429 | } | 1429 | } |
1430 | 1430 | ||
1431 | STATIC int | 1431 | STATIC 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..6a00f7fed69d 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); |
@@ -528,7 +528,7 @@ xfs_iroot_realloc( | |||
528 | ifp->if_broot_bytes = (int)new_size; | 528 | ifp->if_broot_bytes = (int)new_size; |
529 | ASSERT(XFS_BMAP_BMDR_SPACE(ifp->if_broot) <= | 529 | ASSERT(XFS_BMAP_BMDR_SPACE(ifp->if_broot) <= |
530 | XFS_IFORK_SIZE(ip, whichfork)); | 530 | XFS_IFORK_SIZE(ip, whichfork)); |
531 | memmove(np, op, cur_max * (uint)sizeof(xfs_dfsbno_t)); | 531 | memmove(np, op, cur_max * (uint)sizeof(xfs_fsblock_t)); |
532 | return; | 532 | return; |
533 | } | 533 | } |
534 | 534 | ||
@@ -575,7 +575,7 @@ xfs_iroot_realloc( | |||
575 | ifp->if_broot_bytes); | 575 | ifp->if_broot_bytes); |
576 | np = (char *)XFS_BMAP_BROOT_PTR_ADDR(mp, new_broot, 1, | 576 | np = (char *)XFS_BMAP_BROOT_PTR_ADDR(mp, new_broot, 1, |
577 | (int)new_size); | 577 | (int)new_size); |
578 | memcpy(np, op, new_max * (uint)sizeof(xfs_dfsbno_t)); | 578 | memcpy(np, op, new_max * (uint)sizeof(xfs_fsblock_t)); |
579 | } | 579 | } |
580 | kmem_free(ifp->if_broot); | 580 | kmem_free(ifp->if_broot); |
581 | ifp->if_broot = new_broot; | 581 | ifp->if_broot = new_broot; |
@@ -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..4ff2278e147a 100644 --- a/fs/xfs/xfs_inum.h +++ b/fs/xfs/libxfs/xfs_inum.h | |||
@@ -54,11 +54,7 @@ struct xfs_mount; | |||
54 | #define XFS_OFFBNO_TO_AGINO(mp,b,o) \ | 54 | #define XFS_OFFBNO_TO_AGINO(mp,b,o) \ |
55 | ((xfs_agino_t)(((b) << XFS_INO_OFFSET_BITS(mp)) | (o))) | 55 | ((xfs_agino_t)(((b) << XFS_INO_OFFSET_BITS(mp)) | (o))) |
56 | 56 | ||
57 | #if XFS_BIG_INUMS | ||
58 | #define XFS_MAXINUMBER ((xfs_ino_t)((1ULL << 56) - 1ULL)) | 57 | #define XFS_MAXINUMBER ((xfs_ino_t)((1ULL << 56) - 1ULL)) |
59 | #else | ||
60 | #define XFS_MAXINUMBER ((xfs_ino_t)((1ULL << 32) - 1ULL)) | ||
61 | #endif | ||
62 | #define XFS_MAXINUMBER_32 ((xfs_ino_t)((1ULL << 32) - 1ULL)) | 58 | #define XFS_MAXINUMBER_32 ((xfs_ino_t)((1ULL << 32) - 1ULL)) |
63 | 59 | ||
64 | #endif /* __XFS_INUM_H__ */ | 60 | #endif /* __XFS_INUM_H__ */ |
diff --git a/fs/xfs/xfs_log_format.h b/fs/xfs/libxfs/xfs_log_format.h index f0969c77bdbe..aff12f2d4428 100644 --- a/fs/xfs/xfs_log_format.h +++ b/fs/xfs/libxfs/xfs_log_format.h | |||
@@ -380,7 +380,7 @@ typedef struct xfs_icdinode { | |||
380 | xfs_ictimestamp_t di_mtime; /* time last modified */ | 380 | xfs_ictimestamp_t di_mtime; /* time last modified */ |
381 | xfs_ictimestamp_t di_ctime; /* time created/inode modified */ | 381 | xfs_ictimestamp_t di_ctime; /* time created/inode modified */ |
382 | xfs_fsize_t di_size; /* number of bytes in file */ | 382 | xfs_fsize_t di_size; /* number of bytes in file */ |
383 | xfs_drfsbno_t di_nblocks; /* # of direct & btree blocks used */ | 383 | xfs_rfsblock_t di_nblocks; /* # of direct & btree blocks used */ |
384 | xfs_extlen_t di_extsize; /* basic/minimum extent size for file */ | 384 | xfs_extlen_t di_extsize; /* basic/minimum extent size for file */ |
385 | xfs_extnum_t di_nextents; /* number of extents in data fork */ | 385 | xfs_extnum_t di_nextents; /* number of extents in data fork */ |
386 | xfs_aextnum_t di_anextents; /* number of extents in attribute fork*/ | 386 | xfs_aextnum_t di_anextents; /* number of extents in attribute fork*/ |
@@ -516,7 +516,7 @@ xfs_blft_from_flags(struct xfs_buf_log_format *blf) | |||
516 | * EFI/EFD log format definitions | 516 | * EFI/EFD log format definitions |
517 | */ | 517 | */ |
518 | typedef struct xfs_extent { | 518 | typedef struct xfs_extent { |
519 | xfs_dfsbno_t ext_start; | 519 | xfs_fsblock_t ext_start; |
520 | xfs_extlen_t ext_len; | 520 | xfs_extlen_t ext_len; |
521 | } xfs_extent_t; | 521 | } xfs_extent_t; |
522 | 522 | ||
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..1b0a08379759 100644 --- a/fs/xfs/xfs_quota_defs.h +++ b/fs/xfs/libxfs/xfs_quota_defs.h | |||
@@ -98,8 +98,6 @@ typedef __uint16_t xfs_qwarncnt_t; | |||
98 | #define XFS_IS_QUOTA_ON(mp) ((mp)->m_qflags & (XFS_UQUOTA_ACTIVE | \ | 98 | #define XFS_IS_QUOTA_ON(mp) ((mp)->m_qflags & (XFS_UQUOTA_ACTIVE | \ |
99 | XFS_GQUOTA_ACTIVE | \ | 99 | XFS_GQUOTA_ACTIVE | \ |
100 | XFS_PQUOTA_ACTIVE)) | 100 | XFS_PQUOTA_ACTIVE)) |
101 | #define XFS_IS_OQUOTA_ON(mp) ((mp)->m_qflags & (XFS_GQUOTA_ACTIVE | \ | ||
102 | XFS_PQUOTA_ACTIVE)) | ||
103 | #define XFS_IS_UQUOTA_ON(mp) ((mp)->m_qflags & XFS_UQUOTA_ACTIVE) | 101 | #define XFS_IS_UQUOTA_ON(mp) ((mp)->m_qflags & XFS_UQUOTA_ACTIVE) |
104 | #define XFS_IS_GQUOTA_ON(mp) ((mp)->m_qflags & XFS_GQUOTA_ACTIVE) | 102 | #define XFS_IS_GQUOTA_ON(mp) ((mp)->m_qflags & XFS_GQUOTA_ACTIVE) |
105 | #define XFS_IS_PQUOTA_ON(mp) ((mp)->m_qflags & XFS_PQUOTA_ACTIVE) | 103 | #define XFS_IS_PQUOTA_ON(mp) ((mp)->m_qflags & XFS_PQUOTA_ACTIVE) |
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..ad525a5623a4 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 | } |
@@ -386,10 +386,11 @@ xfs_sb_quota_from_disk(struct xfs_sb *sbp) | |||
386 | } | 386 | } |
387 | } | 387 | } |
388 | 388 | ||
389 | void | 389 | static void |
390 | xfs_sb_from_disk( | 390 | __xfs_sb_from_disk( |
391 | struct xfs_sb *to, | 391 | struct xfs_sb *to, |
392 | xfs_dsb_t *from) | 392 | xfs_dsb_t *from, |
393 | bool convert_xquota) | ||
393 | { | 394 | { |
394 | to->sb_magicnum = be32_to_cpu(from->sb_magicnum); | 395 | to->sb_magicnum = be32_to_cpu(from->sb_magicnum); |
395 | to->sb_blocksize = be32_to_cpu(from->sb_blocksize); | 396 | to->sb_blocksize = be32_to_cpu(from->sb_blocksize); |
@@ -445,6 +446,17 @@ xfs_sb_from_disk( | |||
445 | to->sb_pad = 0; | 446 | to->sb_pad = 0; |
446 | to->sb_pquotino = be64_to_cpu(from->sb_pquotino); | 447 | to->sb_pquotino = be64_to_cpu(from->sb_pquotino); |
447 | to->sb_lsn = be64_to_cpu(from->sb_lsn); | 448 | to->sb_lsn = be64_to_cpu(from->sb_lsn); |
449 | /* Convert on-disk flags to in-memory flags? */ | ||
450 | if (convert_xquota) | ||
451 | xfs_sb_quota_from_disk(to); | ||
452 | } | ||
453 | |||
454 | void | ||
455 | xfs_sb_from_disk( | ||
456 | struct xfs_sb *to, | ||
457 | xfs_dsb_t *from) | ||
458 | { | ||
459 | __xfs_sb_from_disk(to, from, true); | ||
448 | } | 460 | } |
449 | 461 | ||
450 | static inline void | 462 | static inline void |
@@ -577,7 +589,11 @@ xfs_sb_verify( | |||
577 | struct xfs_mount *mp = bp->b_target->bt_mount; | 589 | struct xfs_mount *mp = bp->b_target->bt_mount; |
578 | struct xfs_sb sb; | 590 | struct xfs_sb sb; |
579 | 591 | ||
580 | xfs_sb_from_disk(&sb, XFS_BUF_TO_SBP(bp)); | 592 | /* |
593 | * Use call variant which doesn't convert quota flags from disk | ||
594 | * format, because xfs_mount_validate_sb checks the on-disk flags. | ||
595 | */ | ||
596 | __xfs_sb_from_disk(&sb, XFS_BUF_TO_SBP(bp), false); | ||
581 | 597 | ||
582 | /* | 598 | /* |
583 | * Only check the in progress field for the primary superblock as | 599 | * Only check the in progress field for the primary superblock as |
@@ -620,7 +636,7 @@ xfs_sb_read_verify( | |||
620 | /* Only fail bad secondaries on a known V5 filesystem */ | 636 | /* Only fail bad secondaries on a known V5 filesystem */ |
621 | if (bp->b_bn == XFS_SB_DADDR || | 637 | if (bp->b_bn == XFS_SB_DADDR || |
622 | xfs_sb_version_hascrc(&mp->m_sb)) { | 638 | xfs_sb_version_hascrc(&mp->m_sb)) { |
623 | error = EFSBADCRC; | 639 | error = -EFSBADCRC; |
624 | goto out_error; | 640 | goto out_error; |
625 | } | 641 | } |
626 | } | 642 | } |
@@ -630,7 +646,7 @@ xfs_sb_read_verify( | |||
630 | out_error: | 646 | out_error: |
631 | if (error) { | 647 | if (error) { |
632 | xfs_buf_ioerror(bp, error); | 648 | xfs_buf_ioerror(bp, error); |
633 | if (error == EFSCORRUPTED || error == EFSBADCRC) | 649 | if (error == -EFSCORRUPTED || error == -EFSBADCRC) |
634 | xfs_verifier_error(bp); | 650 | xfs_verifier_error(bp); |
635 | } | 651 | } |
636 | } | 652 | } |
@@ -653,7 +669,7 @@ xfs_sb_quiet_read_verify( | |||
653 | return; | 669 | return; |
654 | } | 670 | } |
655 | /* quietly fail */ | 671 | /* quietly fail */ |
656 | xfs_buf_ioerror(bp, EWRONGFS); | 672 | xfs_buf_ioerror(bp, -EWRONGFS); |
657 | } | 673 | } |
658 | 674 | ||
659 | static void | 675 | static void |
diff --git a/fs/xfs/xfs_sb.h b/fs/xfs/libxfs/xfs_sb.h index c43c2d609a24..2e739708afd3 100644 --- a/fs/xfs/xfs_sb.h +++ b/fs/xfs/libxfs/xfs_sb.h | |||
@@ -87,11 +87,11 @@ struct xfs_trans; | |||
87 | typedef struct xfs_sb { | 87 | typedef struct xfs_sb { |
88 | __uint32_t sb_magicnum; /* magic number == XFS_SB_MAGIC */ | 88 | __uint32_t sb_magicnum; /* magic number == XFS_SB_MAGIC */ |
89 | __uint32_t sb_blocksize; /* logical block size, bytes */ | 89 | __uint32_t sb_blocksize; /* logical block size, bytes */ |
90 | xfs_drfsbno_t sb_dblocks; /* number of data blocks */ | 90 | xfs_rfsblock_t sb_dblocks; /* number of data blocks */ |
91 | xfs_drfsbno_t sb_rblocks; /* number of realtime blocks */ | 91 | xfs_rfsblock_t sb_rblocks; /* number of realtime blocks */ |
92 | xfs_drtbno_t sb_rextents; /* number of realtime extents */ | 92 | xfs_rtblock_t sb_rextents; /* number of realtime extents */ |
93 | uuid_t sb_uuid; /* file system unique id */ | 93 | uuid_t sb_uuid; /* file system unique id */ |
94 | xfs_dfsbno_t sb_logstart; /* starting block of log if internal */ | 94 | xfs_fsblock_t sb_logstart; /* starting block of log if internal */ |
95 | xfs_ino_t sb_rootino; /* root inode number */ | 95 | xfs_ino_t sb_rootino; /* root inode number */ |
96 | xfs_ino_t sb_rbmino; /* bitmap inode for realtime extents */ | 96 | xfs_ino_t sb_rbmino; /* bitmap inode for realtime extents */ |
97 | xfs_ino_t sb_rsumino; /* summary inode for rt bitmap */ | 97 | xfs_ino_t sb_rsumino; /* summary inode for rt bitmap */ |
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 | ||
241 | done: | 241 | done: |
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 | ||
1416 | out_unlock: | 1416 | out_unlock: |
1417 | xfs_iunlock(ip, lockmode); | 1417 | xfs_iunlock(ip, lockmode); |
1418 | return -error; | 1418 | return error; |
1419 | } | 1419 | } |
1420 | 1420 | ||
1421 | int | 1421 | int |
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 | ||
448 | out: | 448 | out: |
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 | ||
219 | STATIC int | 219 | STATIC 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 | ||
506 | int | 506 | int |
@@ -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..2f1e30d39a35 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 { |
@@ -425,14 +425,14 @@ xfs_bmap_count_blocks( | |||
425 | ASSERT(level > 0); | 425 | ASSERT(level > 0); |
426 | pp = XFS_BMAP_BROOT_PTR_ADDR(mp, block, 1, ifp->if_broot_bytes); | 426 | pp = XFS_BMAP_BROOT_PTR_ADDR(mp, block, 1, ifp->if_broot_bytes); |
427 | bno = be64_to_cpu(*pp); | 427 | bno = be64_to_cpu(*pp); |
428 | ASSERT(bno != NULLDFSBNO); | 428 | ASSERT(bno != NULLFSBLOCK); |
429 | ASSERT(XFS_FSB_TO_AGNO(mp, bno) < mp->m_sb.sb_agcount); | 429 | ASSERT(XFS_FSB_TO_AGNO(mp, bno) < mp->m_sb.sb_agcount); |
430 | ASSERT(XFS_FSB_TO_AGBNO(mp, bno) < mp->m_sb.sb_agblocks); | 430 | ASSERT(XFS_FSB_TO_AGBNO(mp, bno) < mp->m_sb.sb_agblocks); |
431 | 431 | ||
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) |
@@ -809,7 +809,7 @@ xfs_can_free_eofblocks(struct xfs_inode *ip, bool force) | |||
809 | * have speculative prealloc/delalloc blocks to remove. | 809 | * have speculative prealloc/delalloc blocks to remove. |
810 | */ | 810 | */ |
811 | if (VFS_I(ip)->i_size == 0 && | 811 | if (VFS_I(ip)->i_size == 0 && |
812 | VN_CACHED(VFS_I(ip)) == 0 && | 812 | VFS_I(ip)->i_mapping->nrpages == 0 && |
813 | ip->i_delayed_blks == 0) | 813 | ip->i_delayed_blks == 0) |
814 | return false; | 814 | return false; |
815 | 815 | ||
@@ -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,26 +1599,50 @@ 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; |
1619 | } | 1619 | } |
1620 | 1620 | ||
1621 | int | 1621 | int |
1622 | xfs_swap_extent_flush( | ||
1623 | struct xfs_inode *ip) | ||
1624 | { | ||
1625 | int error; | ||
1626 | |||
1627 | error = filemap_write_and_wait(VFS_I(ip)->i_mapping); | ||
1628 | if (error) | ||
1629 | return error; | ||
1630 | truncate_pagecache_range(VFS_I(ip), 0, -1); | ||
1631 | |||
1632 | /* Verify O_DIRECT for ftmp */ | ||
1633 | if (VFS_I(ip)->i_mapping->nrpages) | ||
1634 | return -EINVAL; | ||
1635 | |||
1636 | /* | ||
1637 | * Don't try to swap extents on mmap()d files because we can't lock | ||
1638 | * out races against page faults safely. | ||
1639 | */ | ||
1640 | if (mapping_mapped(VFS_I(ip)->i_mapping)) | ||
1641 | return -EBUSY; | ||
1642 | return 0; | ||
1643 | } | ||
1644 | |||
1645 | int | ||
1622 | xfs_swap_extents( | 1646 | xfs_swap_extents( |
1623 | xfs_inode_t *ip, /* target inode */ | 1647 | xfs_inode_t *ip, /* target inode */ |
1624 | xfs_inode_t *tip, /* tmp inode */ | 1648 | xfs_inode_t *tip, /* tmp inode */ |
@@ -1633,51 +1657,57 @@ xfs_swap_extents( | |||
1633 | int aforkblks = 0; | 1657 | int aforkblks = 0; |
1634 | int taforkblks = 0; | 1658 | int taforkblks = 0; |
1635 | __uint64_t tmp; | 1659 | __uint64_t tmp; |
1660 | int lock_flags; | ||
1636 | 1661 | ||
1637 | tempifp = kmem_alloc(sizeof(xfs_ifork_t), KM_MAYFAIL); | 1662 | tempifp = kmem_alloc(sizeof(xfs_ifork_t), KM_MAYFAIL); |
1638 | if (!tempifp) { | 1663 | if (!tempifp) { |
1639 | error = XFS_ERROR(ENOMEM); | 1664 | error = -ENOMEM; |
1640 | goto out; | 1665 | goto out; |
1641 | } | 1666 | } |
1642 | 1667 | ||
1643 | /* | 1668 | /* |
1644 | * we have to do two separate lock calls here to keep lockdep | 1669 | * Lock up the inodes against other IO and truncate to begin with. |
1645 | * happy. If we try to get all the locks in one call, lock will | 1670 | * Then we can ensure the inodes are flushed and have no page cache |
1646 | * report false positives when we drop the ILOCK and regain them | 1671 | * safely. Once we have done this we can take the ilocks and do the rest |
1647 | * below. | 1672 | * of the checks. |
1648 | */ | 1673 | */ |
1674 | lock_flags = XFS_IOLOCK_EXCL; | ||
1649 | xfs_lock_two_inodes(ip, tip, XFS_IOLOCK_EXCL); | 1675 | xfs_lock_two_inodes(ip, tip, XFS_IOLOCK_EXCL); |
1650 | xfs_lock_two_inodes(ip, tip, XFS_ILOCK_EXCL); | ||
1651 | 1676 | ||
1652 | /* Verify that both files have the same format */ | 1677 | /* Verify that both files have the same format */ |
1653 | if ((ip->i_d.di_mode & S_IFMT) != (tip->i_d.di_mode & S_IFMT)) { | 1678 | if ((ip->i_d.di_mode & S_IFMT) != (tip->i_d.di_mode & S_IFMT)) { |
1654 | error = XFS_ERROR(EINVAL); | 1679 | error = -EINVAL; |
1655 | goto out_unlock; | 1680 | goto out_unlock; |
1656 | } | 1681 | } |
1657 | 1682 | ||
1658 | /* Verify both files are either real-time or non-realtime */ | 1683 | /* Verify both files are either real-time or non-realtime */ |
1659 | if (XFS_IS_REALTIME_INODE(ip) != XFS_IS_REALTIME_INODE(tip)) { | 1684 | if (XFS_IS_REALTIME_INODE(ip) != XFS_IS_REALTIME_INODE(tip)) { |
1660 | error = XFS_ERROR(EINVAL); | 1685 | error = -EINVAL; |
1661 | goto out_unlock; | 1686 | goto out_unlock; |
1662 | } | 1687 | } |
1663 | 1688 | ||
1664 | error = -filemap_write_and_wait(VFS_I(tip)->i_mapping); | 1689 | error = xfs_swap_extent_flush(ip); |
1690 | if (error) | ||
1691 | goto out_unlock; | ||
1692 | error = xfs_swap_extent_flush(tip); | ||
1665 | if (error) | 1693 | if (error) |
1666 | goto out_unlock; | 1694 | goto out_unlock; |
1667 | truncate_pagecache_range(VFS_I(tip), 0, -1); | ||
1668 | 1695 | ||
1669 | /* Verify O_DIRECT for ftmp */ | 1696 | tp = xfs_trans_alloc(mp, XFS_TRANS_SWAPEXT); |
1670 | if (VN_CACHED(VFS_I(tip)) != 0) { | 1697 | error = xfs_trans_reserve(tp, &M_RES(mp)->tr_ichange, 0, 0); |
1671 | error = XFS_ERROR(EINVAL); | 1698 | if (error) { |
1699 | xfs_trans_cancel(tp, 0); | ||
1672 | goto out_unlock; | 1700 | goto out_unlock; |
1673 | } | 1701 | } |
1702 | xfs_lock_two_inodes(ip, tip, XFS_ILOCK_EXCL); | ||
1703 | lock_flags |= XFS_ILOCK_EXCL; | ||
1674 | 1704 | ||
1675 | /* Verify all data are being swapped */ | 1705 | /* Verify all data are being swapped */ |
1676 | if (sxp->sx_offset != 0 || | 1706 | if (sxp->sx_offset != 0 || |
1677 | sxp->sx_length != ip->i_d.di_size || | 1707 | sxp->sx_length != ip->i_d.di_size || |
1678 | sxp->sx_length != tip->i_d.di_size) { | 1708 | sxp->sx_length != tip->i_d.di_size) { |
1679 | error = XFS_ERROR(EFAULT); | 1709 | error = -EFAULT; |
1680 | goto out_unlock; | 1710 | goto out_trans_cancel; |
1681 | } | 1711 | } |
1682 | 1712 | ||
1683 | trace_xfs_swap_extent_before(ip, 0); | 1713 | trace_xfs_swap_extent_before(ip, 0); |
@@ -1689,7 +1719,7 @@ xfs_swap_extents( | |||
1689 | xfs_notice(mp, | 1719 | xfs_notice(mp, |
1690 | "%s: inode 0x%llx format is incompatible for exchanging.", | 1720 | "%s: inode 0x%llx format is incompatible for exchanging.", |
1691 | __func__, ip->i_ino); | 1721 | __func__, ip->i_ino); |
1692 | goto out_unlock; | 1722 | goto out_trans_cancel; |
1693 | } | 1723 | } |
1694 | 1724 | ||
1695 | /* | 1725 | /* |
@@ -1703,43 +1733,9 @@ xfs_swap_extents( | |||
1703 | (sbp->bs_ctime.tv_nsec != VFS_I(ip)->i_ctime.tv_nsec) || | 1733 | (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) || | 1734 | (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)) { | 1735 | (sbp->bs_mtime.tv_nsec != VFS_I(ip)->i_mtime.tv_nsec)) { |
1706 | error = XFS_ERROR(EBUSY); | 1736 | error = -EBUSY; |
1707 | goto out_unlock; | 1737 | goto out_trans_cancel; |
1708 | } | ||
1709 | |||
1710 | /* We need to fail if the file is memory mapped. Once we have tossed | ||
1711 | * all existing pages, the page fault will have no option | ||
1712 | * but to go to the filesystem for pages. By making the page fault call | ||
1713 | * vop_read (or write in the case of autogrow) they block on the iolock | ||
1714 | * until we have switched the extents. | ||
1715 | */ | ||
1716 | if (VN_MAPPED(VFS_I(ip))) { | ||
1717 | error = XFS_ERROR(EBUSY); | ||
1718 | goto out_unlock; | ||
1719 | } | ||
1720 | |||
1721 | xfs_iunlock(ip, XFS_ILOCK_EXCL); | ||
1722 | xfs_iunlock(tip, XFS_ILOCK_EXCL); | ||
1723 | |||
1724 | /* | ||
1725 | * There is a race condition here since we gave up the | ||
1726 | * ilock. However, the data fork will not change since | ||
1727 | * we have the iolock (locked for truncation too) so we | ||
1728 | * are safe. We don't really care if non-io related | ||
1729 | * fields change. | ||
1730 | */ | ||
1731 | truncate_pagecache_range(VFS_I(ip), 0, -1); | ||
1732 | |||
1733 | tp = xfs_trans_alloc(mp, XFS_TRANS_SWAPEXT); | ||
1734 | error = xfs_trans_reserve(tp, &M_RES(mp)->tr_ichange, 0, 0); | ||
1735 | if (error) { | ||
1736 | xfs_iunlock(ip, XFS_IOLOCK_EXCL); | ||
1737 | xfs_iunlock(tip, XFS_IOLOCK_EXCL); | ||
1738 | xfs_trans_cancel(tp, 0); | ||
1739 | goto out; | ||
1740 | } | 1738 | } |
1741 | xfs_lock_two_inodes(ip, tip, XFS_ILOCK_EXCL); | ||
1742 | |||
1743 | /* | 1739 | /* |
1744 | * Count the number of extended attribute blocks | 1740 | * Count the number of extended attribute blocks |
1745 | */ | 1741 | */ |
@@ -1757,8 +1753,8 @@ xfs_swap_extents( | |||
1757 | goto out_trans_cancel; | 1753 | goto out_trans_cancel; |
1758 | } | 1754 | } |
1759 | 1755 | ||
1760 | xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL | XFS_IOLOCK_EXCL); | 1756 | xfs_trans_ijoin(tp, ip, lock_flags); |
1761 | xfs_trans_ijoin(tp, tip, XFS_ILOCK_EXCL | XFS_IOLOCK_EXCL); | 1757 | xfs_trans_ijoin(tp, tip, lock_flags); |
1762 | 1758 | ||
1763 | /* | 1759 | /* |
1764 | * Before we've swapped the forks, lets set the owners of the forks | 1760 | * Before we've swapped the forks, lets set the owners of the forks |
@@ -1887,8 +1883,8 @@ out: | |||
1887 | return error; | 1883 | return error; |
1888 | 1884 | ||
1889 | out_unlock: | 1885 | out_unlock: |
1890 | xfs_iunlock(ip, XFS_ILOCK_EXCL | XFS_IOLOCK_EXCL); | 1886 | xfs_iunlock(ip, lock_flags); |
1891 | xfs_iunlock(tip, XFS_ILOCK_EXCL | XFS_IOLOCK_EXCL); | 1887 | xfs_iunlock(tip, lock_flags); |
1892 | goto out; | 1888 | goto out; |
1893 | 1889 | ||
1894 | out_trans_cancel: | 1890 | out_trans_cancel: |
diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c index 7a34a1ae6552..cd7b8ca9b064 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 | ||
1139 | STATIC int | 1139 | STATIC 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 | ||
@@ -1330,6 +1330,20 @@ _xfs_buf_ioapply( | |||
1330 | SHUTDOWN_CORRUPT_INCORE); | 1330 | SHUTDOWN_CORRUPT_INCORE); |
1331 | return; | 1331 | return; |
1332 | } | 1332 | } |
1333 | } else if (bp->b_bn != XFS_BUF_DADDR_NULL) { | ||
1334 | struct xfs_mount *mp = bp->b_target->bt_mount; | ||
1335 | |||
1336 | /* | ||
1337 | * non-crc filesystems don't attach verifiers during | ||
1338 | * log recovery, so don't warn for such filesystems. | ||
1339 | */ | ||
1340 | if (xfs_sb_version_hascrc(&mp->m_sb)) { | ||
1341 | xfs_warn(mp, | ||
1342 | "%s: no ops on block 0x%llx/0x%x", | ||
1343 | __func__, bp->b_bn, bp->b_length); | ||
1344 | xfs_hex_dump(bp->b_addr, 64); | ||
1345 | dump_stack(); | ||
1346 | } | ||
1333 | } | 1347 | } |
1334 | } else if (bp->b_flags & XBF_READ_AHEAD) { | 1348 | } else if (bp->b_flags & XBF_READ_AHEAD) { |
1335 | rw = READA; | 1349 | rw = READA; |
@@ -1628,7 +1642,7 @@ xfs_setsize_buftarg( | |||
1628 | xfs_warn(btp->bt_mount, | 1642 | xfs_warn(btp->bt_mount, |
1629 | "Cannot set_blocksize to %u on device %s", | 1643 | "Cannot set_blocksize to %u on device %s", |
1630 | sectorsize, name); | 1644 | sectorsize, name); |
1631 | return EINVAL; | 1645 | return -EINVAL; |
1632 | } | 1646 | } |
1633 | 1647 | ||
1634 | /* Set up device logical sector size mask */ | 1648 | /* 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..63c2de49f61d 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 | ||
406 | STATIC int | 406 | STATIC 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 | ||
@@ -974,7 +974,8 @@ xfs_qm_dqflush( | |||
974 | * Get the buffer containing the on-disk dquot | 974 | * Get the buffer containing the on-disk dquot |
975 | */ | 975 | */ |
976 | error = xfs_trans_read_buf(mp, NULL, mp->m_ddev_targp, dqp->q_blkno, | 976 | error = xfs_trans_read_buf(mp, NULL, mp->m_ddev_targp, dqp->q_blkno, |
977 | mp->m_quotainfo->qi_dqchunklen, 0, &bp, NULL); | 977 | mp->m_quotainfo->qi_dqchunklen, 0, &bp, |
978 | &xfs_dquot_buf_ops); | ||
978 | if (error) | 979 | if (error) |
979 | goto out_unlock; | 980 | goto out_unlock; |
980 | 981 | ||
@@ -992,7 +993,7 @@ xfs_qm_dqflush( | |||
992 | xfs_buf_relse(bp); | 993 | xfs_buf_relse(bp); |
993 | xfs_dqfunlock(dqp); | 994 | xfs_dqfunlock(dqp); |
994 | xfs_force_shutdown(mp, SHUTDOWN_CORRUPT_INCORE); | 995 | xfs_force_shutdown(mp, SHUTDOWN_CORRUPT_INCORE); |
995 | return XFS_ERROR(EIO); | 996 | return -EIO; |
996 | } | 997 | } |
997 | 998 | ||
998 | /* This is the only portion of data that needs to persist */ | 999 | /* This is the only portion of data that needs to persist */ |
@@ -1045,7 +1046,7 @@ xfs_qm_dqflush( | |||
1045 | 1046 | ||
1046 | out_unlock: | 1047 | out_unlock: |
1047 | xfs_dqfunlock(dqp); | 1048 | xfs_dqfunlock(dqp); |
1048 | return XFS_ERROR(EIO); | 1049 | return -EIO; |
1049 | } | 1050 | } |
1050 | 1051 | ||
1051 | /* | 1052 | /* |
diff --git a/fs/xfs/xfs_dquot.h b/fs/xfs/xfs_dquot.h index 68a68f704837..c24c67e22a2a 100644 --- a/fs/xfs/xfs_dquot.h +++ b/fs/xfs/xfs_dquot.h | |||
@@ -139,6 +139,21 @@ static inline xfs_dquot_t *xfs_inode_dquot(struct xfs_inode *ip, int type) | |||
139 | } | 139 | } |
140 | } | 140 | } |
141 | 141 | ||
142 | /* | ||
143 | * Check whether a dquot is under low free space conditions. We assume the quota | ||
144 | * is enabled and enforced. | ||
145 | */ | ||
146 | static inline bool xfs_dquot_lowsp(struct xfs_dquot *dqp) | ||
147 | { | ||
148 | int64_t freesp; | ||
149 | |||
150 | freesp = be64_to_cpu(dqp->q_core.d_blk_hardlimit) - dqp->q_res_bcount; | ||
151 | if (freesp < dqp->q_low_space[XFS_QLOWSP_1_PCNT]) | ||
152 | return true; | ||
153 | |||
154 | return false; | ||
155 | } | ||
156 | |||
142 | #define XFS_DQ_IS_LOCKED(dqp) (mutex_is_locked(&((dqp)->q_qlock))) | 157 | #define XFS_DQ_IS_LOCKED(dqp) (mutex_is_locked(&((dqp)->q_qlock))) |
143 | #define XFS_DQ_IS_DIRTY(dqp) ((dqp)->dq_flags & XFS_DQ_DIRTY) | 158 | #define XFS_DQ_IS_DIRTY(dqp) ((dqp)->dq_flags & XFS_DQ_DIRTY) |
144 | #define XFS_QM_ISUDQ(dqp) ((dqp)->dq_flags & XFS_DQ_USER) | 159 | #define XFS_QM_ISUDQ(dqp) ((dqp)->dq_flags & XFS_DQ_USER) |
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 | ||
30 | int xfs_etrap[XFS_ERROR_NTRAP] = { | ||
31 | 0, | ||
32 | }; | ||
33 | |||
34 | int | ||
35 | xfs_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 | |||
53 | int xfs_etest[XFS_NUM_INJECT_ERROR]; | 30 | int xfs_etest[XFS_NUM_INJECT_ERROR]; |
54 | int64_t xfs_etest_fsid[XFS_NUM_INJECT_ERROR]; | 31 | int64_t xfs_etest_fsid[XFS_NUM_INJECT_ERROR]; |
55 | char * xfs_etest_fsname[XFS_NUM_INJECT_ERROR]; | 32 | char * 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 | ||
23 | extern int xfs_etrap[XFS_ERROR_NTRAP]; | ||
24 | extern 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 | |||
30 | struct xfs_mount; | 21 | struct xfs_mount; |
31 | 22 | ||
32 | extern void xfs_error_report(const char *tag, int level, struct xfs_mount *mp, | 23 | extern void xfs_error_report(const char *tag, int level, struct xfs_mount *mp, |
@@ -56,7 +47,7 @@ extern void xfs_verifier_error(struct xfs_buf *bp); | |||
56 | 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 | ||
243 | const struct export_operations xfs_export_operations = { | 243 | const 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..076b1708d134 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c | |||
@@ -38,6 +38,7 @@ | |||
38 | #include "xfs_trace.h" | 38 | #include "xfs_trace.h" |
39 | #include "xfs_log.h" | 39 | #include "xfs_log.h" |
40 | #include "xfs_dinode.h" | 40 | #include "xfs_dinode.h" |
41 | #include "xfs_icache.h" | ||
41 | 42 | ||
42 | #include <linux/aio.h> | 43 | #include <linux/aio.h> |
43 | #include <linux/dcache.h> | 44 | #include <linux/dcache.h> |
@@ -155,7 +156,7 @@ xfs_dir_fsync( | |||
155 | 156 | ||
156 | if (!lsn) | 157 | if (!lsn) |
157 | return 0; | 158 | return 0; |
158 | return -_xfs_log_force_lsn(mp, lsn, XFS_LOG_SYNC, NULL); | 159 | return _xfs_log_force_lsn(mp, lsn, XFS_LOG_SYNC, NULL); |
159 | } | 160 | } |
160 | 161 | ||
161 | STATIC int | 162 | STATIC int |
@@ -179,7 +180,7 @@ xfs_file_fsync( | |||
179 | return error; | 180 | return error; |
180 | 181 | ||
181 | if (XFS_FORCED_SHUTDOWN(mp)) | 182 | if (XFS_FORCED_SHUTDOWN(mp)) |
182 | return -XFS_ERROR(EIO); | 183 | return -EIO; |
183 | 184 | ||
184 | xfs_iflags_clear(ip, XFS_ITRUNCATED); | 185 | xfs_iflags_clear(ip, XFS_ITRUNCATED); |
185 | 186 | ||
@@ -225,7 +226,7 @@ xfs_file_fsync( | |||
225 | !log_flushed) | 226 | !log_flushed) |
226 | xfs_blkdev_issue_flush(mp->m_ddev_targp); | 227 | xfs_blkdev_issue_flush(mp->m_ddev_targp); |
227 | 228 | ||
228 | return -error; | 229 | return error; |
229 | } | 230 | } |
230 | 231 | ||
231 | STATIC ssize_t | 232 | STATIC ssize_t |
@@ -246,11 +247,11 @@ xfs_file_read_iter( | |||
246 | XFS_STATS_INC(xs_read_calls); | 247 | XFS_STATS_INC(xs_read_calls); |
247 | 248 | ||
248 | if (unlikely(file->f_flags & O_DIRECT)) | 249 | if (unlikely(file->f_flags & O_DIRECT)) |
249 | ioflags |= IO_ISDIRECT; | 250 | ioflags |= XFS_IO_ISDIRECT; |
250 | if (file->f_mode & FMODE_NOCMTIME) | 251 | if (file->f_mode & FMODE_NOCMTIME) |
251 | ioflags |= IO_INVIS; | 252 | ioflags |= XFS_IO_INVIS; |
252 | 253 | ||
253 | if (unlikely(ioflags & IO_ISDIRECT)) { | 254 | if (unlikely(ioflags & XFS_IO_ISDIRECT)) { |
254 | xfs_buftarg_t *target = | 255 | xfs_buftarg_t *target = |
255 | XFS_IS_REALTIME_INODE(ip) ? | 256 | XFS_IS_REALTIME_INODE(ip) ? |
256 | mp->m_rtdev_targp : mp->m_ddev_targp; | 257 | mp->m_rtdev_targp : mp->m_ddev_targp; |
@@ -258,7 +259,7 @@ xfs_file_read_iter( | |||
258 | if ((pos | size) & target->bt_logical_sectormask) { | 259 | if ((pos | size) & target->bt_logical_sectormask) { |
259 | if (pos == i_size_read(inode)) | 260 | if (pos == i_size_read(inode)) |
260 | return 0; | 261 | return 0; |
261 | return -XFS_ERROR(EINVAL); | 262 | return -EINVAL; |
262 | } | 263 | } |
263 | } | 264 | } |
264 | 265 | ||
@@ -283,7 +284,7 @@ xfs_file_read_iter( | |||
283 | * proceeed concurrently without serialisation. | 284 | * proceeed concurrently without serialisation. |
284 | */ | 285 | */ |
285 | xfs_rw_ilock(ip, XFS_IOLOCK_SHARED); | 286 | xfs_rw_ilock(ip, XFS_IOLOCK_SHARED); |
286 | if ((ioflags & IO_ISDIRECT) && inode->i_mapping->nrpages) { | 287 | if ((ioflags & XFS_IO_ISDIRECT) && inode->i_mapping->nrpages) { |
287 | xfs_rw_iunlock(ip, XFS_IOLOCK_SHARED); | 288 | xfs_rw_iunlock(ip, XFS_IOLOCK_SHARED); |
288 | xfs_rw_ilock(ip, XFS_IOLOCK_EXCL); | 289 | xfs_rw_ilock(ip, XFS_IOLOCK_EXCL); |
289 | 290 | ||
@@ -325,7 +326,7 @@ xfs_file_splice_read( | |||
325 | XFS_STATS_INC(xs_read_calls); | 326 | XFS_STATS_INC(xs_read_calls); |
326 | 327 | ||
327 | if (infilp->f_mode & FMODE_NOCMTIME) | 328 | if (infilp->f_mode & FMODE_NOCMTIME) |
328 | ioflags |= IO_INVIS; | 329 | ioflags |= XFS_IO_INVIS; |
329 | 330 | ||
330 | if (XFS_FORCED_SHUTDOWN(ip->i_mount)) | 331 | if (XFS_FORCED_SHUTDOWN(ip->i_mount)) |
331 | return -EIO; | 332 | return -EIO; |
@@ -524,7 +525,7 @@ restart: | |||
524 | xfs_rw_ilock(ip, *iolock); | 525 | xfs_rw_ilock(ip, *iolock); |
525 | goto restart; | 526 | goto restart; |
526 | } | 527 | } |
527 | error = -xfs_zero_eof(ip, *pos, i_size_read(inode)); | 528 | error = xfs_zero_eof(ip, *pos, i_size_read(inode)); |
528 | if (error) | 529 | if (error) |
529 | return error; | 530 | return error; |
530 | } | 531 | } |
@@ -594,7 +595,7 @@ xfs_file_dio_aio_write( | |||
594 | 595 | ||
595 | /* DIO must be aligned to device logical sector size */ | 596 | /* DIO must be aligned to device logical sector size */ |
596 | if ((pos | count) & target->bt_logical_sectormask) | 597 | if ((pos | count) & target->bt_logical_sectormask) |
597 | return -XFS_ERROR(EINVAL); | 598 | return -EINVAL; |
598 | 599 | ||
599 | /* "unaligned" here means not aligned to a filesystem block */ | 600 | /* "unaligned" here means not aligned to a filesystem block */ |
600 | if ((pos & mp->m_blockmask) || ((pos + count) & mp->m_blockmask)) | 601 | if ((pos & mp->m_blockmask) || ((pos + count) & mp->m_blockmask)) |
@@ -689,14 +690,28 @@ write_retry: | |||
689 | ret = generic_perform_write(file, from, pos); | 690 | ret = generic_perform_write(file, from, pos); |
690 | if (likely(ret >= 0)) | 691 | if (likely(ret >= 0)) |
691 | iocb->ki_pos = pos + ret; | 692 | iocb->ki_pos = pos + ret; |
693 | |||
692 | /* | 694 | /* |
693 | * If we just got an ENOSPC, try to write back all dirty inodes to | 695 | * If we hit a space limit, try to free up some lingering preallocated |
694 | * convert delalloc space to free up some of the excess reserved | 696 | * space before returning an error. In the case of ENOSPC, first try to |
695 | * metadata space. | 697 | * write back all dirty inodes to free up some of the excess reserved |
698 | * metadata space. This reduces the chances that the eofblocks scan | ||
699 | * waits on dirty mappings. Since xfs_flush_inodes() is serialized, this | ||
700 | * also behaves as a filter to prevent too many eofblocks scans from | ||
701 | * running at the same time. | ||
696 | */ | 702 | */ |
697 | if (ret == -ENOSPC && !enospc) { | 703 | if (ret == -EDQUOT && !enospc) { |
704 | enospc = xfs_inode_free_quota_eofblocks(ip); | ||
705 | if (enospc) | ||
706 | goto write_retry; | ||
707 | } else if (ret == -ENOSPC && !enospc) { | ||
708 | struct xfs_eofblocks eofb = {0}; | ||
709 | |||
698 | enospc = 1; | 710 | enospc = 1; |
699 | xfs_flush_inodes(ip->i_mount); | 711 | xfs_flush_inodes(ip->i_mount); |
712 | eofb.eof_scan_owner = ip->i_ino; /* for locking */ | ||
713 | eofb.eof_flags = XFS_EOF_FLAGS_SYNC; | ||
714 | xfs_icache_free_eofblocks(ip->i_mount, &eofb); | ||
700 | goto write_retry; | 715 | goto write_retry; |
701 | } | 716 | } |
702 | 717 | ||
@@ -772,7 +787,7 @@ xfs_file_fallocate( | |||
772 | unsigned blksize_mask = (1 << inode->i_blkbits) - 1; | 787 | unsigned blksize_mask = (1 << inode->i_blkbits) - 1; |
773 | 788 | ||
774 | if (offset & blksize_mask || len & blksize_mask) { | 789 | if (offset & blksize_mask || len & blksize_mask) { |
775 | error = EINVAL; | 790 | error = -EINVAL; |
776 | goto out_unlock; | 791 | goto out_unlock; |
777 | } | 792 | } |
778 | 793 | ||
@@ -781,7 +796,7 @@ xfs_file_fallocate( | |||
781 | * in which case it is effectively a truncate operation | 796 | * in which case it is effectively a truncate operation |
782 | */ | 797 | */ |
783 | if (offset + len >= i_size_read(inode)) { | 798 | if (offset + len >= i_size_read(inode)) { |
784 | error = EINVAL; | 799 | error = -EINVAL; |
785 | goto out_unlock; | 800 | goto out_unlock; |
786 | } | 801 | } |
787 | 802 | ||
@@ -794,7 +809,7 @@ xfs_file_fallocate( | |||
794 | if (!(mode & FALLOC_FL_KEEP_SIZE) && | 809 | if (!(mode & FALLOC_FL_KEEP_SIZE) && |
795 | offset + len > i_size_read(inode)) { | 810 | offset + len > i_size_read(inode)) { |
796 | new_size = offset + len; | 811 | new_size = offset + len; |
797 | error = -inode_newsize_ok(inode, new_size); | 812 | error = inode_newsize_ok(inode, new_size); |
798 | if (error) | 813 | if (error) |
799 | goto out_unlock; | 814 | goto out_unlock; |
800 | } | 815 | } |
@@ -844,7 +859,7 @@ xfs_file_fallocate( | |||
844 | 859 | ||
845 | out_unlock: | 860 | out_unlock: |
846 | xfs_iunlock(ip, XFS_IOLOCK_EXCL); | 861 | xfs_iunlock(ip, XFS_IOLOCK_EXCL); |
847 | return -error; | 862 | return error; |
848 | } | 863 | } |
849 | 864 | ||
850 | 865 | ||
@@ -889,7 +904,7 @@ xfs_file_release( | |||
889 | struct inode *inode, | 904 | struct inode *inode, |
890 | struct file *filp) | 905 | struct file *filp) |
891 | { | 906 | { |
892 | return -xfs_release(XFS_I(inode)); | 907 | return xfs_release(XFS_I(inode)); |
893 | } | 908 | } |
894 | 909 | ||
895 | STATIC int | 910 | STATIC int |
@@ -918,7 +933,7 @@ xfs_file_readdir( | |||
918 | 933 | ||
919 | error = xfs_readdir(ip, ctx, bufsize); | 934 | error = xfs_readdir(ip, ctx, bufsize); |
920 | if (error) | 935 | if (error) |
921 | return -error; | 936 | return error; |
922 | return 0; | 937 | return 0; |
923 | } | 938 | } |
924 | 939 | ||
@@ -1184,7 +1199,7 @@ xfs_seek_data( | |||
1184 | 1199 | ||
1185 | isize = i_size_read(inode); | 1200 | isize = i_size_read(inode); |
1186 | if (start >= isize) { | 1201 | if (start >= isize) { |
1187 | error = ENXIO; | 1202 | error = -ENXIO; |
1188 | goto out_unlock; | 1203 | goto out_unlock; |
1189 | } | 1204 | } |
1190 | 1205 | ||
@@ -1206,7 +1221,7 @@ xfs_seek_data( | |||
1206 | 1221 | ||
1207 | /* No extents at given offset, must be beyond EOF */ | 1222 | /* No extents at given offset, must be beyond EOF */ |
1208 | if (nmap == 0) { | 1223 | if (nmap == 0) { |
1209 | error = ENXIO; | 1224 | error = -ENXIO; |
1210 | goto out_unlock; | 1225 | goto out_unlock; |
1211 | } | 1226 | } |
1212 | 1227 | ||
@@ -1237,7 +1252,7 @@ xfs_seek_data( | |||
1237 | * we are reading after EOF if nothing in map[1]. | 1252 | * we are reading after EOF if nothing in map[1]. |
1238 | */ | 1253 | */ |
1239 | if (nmap == 1) { | 1254 | if (nmap == 1) { |
1240 | error = ENXIO; | 1255 | error = -ENXIO; |
1241 | goto out_unlock; | 1256 | goto out_unlock; |
1242 | } | 1257 | } |
1243 | 1258 | ||
@@ -1250,7 +1265,7 @@ xfs_seek_data( | |||
1250 | fsbno = map[i - 1].br_startoff + map[i - 1].br_blockcount; | 1265 | fsbno = map[i - 1].br_startoff + map[i - 1].br_blockcount; |
1251 | start = XFS_FSB_TO_B(mp, fsbno); | 1266 | start = XFS_FSB_TO_B(mp, fsbno); |
1252 | if (start >= isize) { | 1267 | if (start >= isize) { |
1253 | error = ENXIO; | 1268 | error = -ENXIO; |
1254 | goto out_unlock; | 1269 | goto out_unlock; |
1255 | } | 1270 | } |
1256 | } | 1271 | } |
@@ -1262,7 +1277,7 @@ out_unlock: | |||
1262 | xfs_iunlock(ip, lock); | 1277 | xfs_iunlock(ip, lock); |
1263 | 1278 | ||
1264 | if (error) | 1279 | if (error) |
1265 | return -error; | 1280 | return error; |
1266 | return offset; | 1281 | return offset; |
1267 | } | 1282 | } |
1268 | 1283 | ||
@@ -1282,13 +1297,13 @@ xfs_seek_hole( | |||
1282 | int error; | 1297 | int error; |
1283 | 1298 | ||
1284 | if (XFS_FORCED_SHUTDOWN(mp)) | 1299 | if (XFS_FORCED_SHUTDOWN(mp)) |
1285 | return -XFS_ERROR(EIO); | 1300 | return -EIO; |
1286 | 1301 | ||
1287 | lock = xfs_ilock_data_map_shared(ip); | 1302 | lock = xfs_ilock_data_map_shared(ip); |
1288 | 1303 | ||
1289 | isize = i_size_read(inode); | 1304 | isize = i_size_read(inode); |
1290 | if (start >= isize) { | 1305 | if (start >= isize) { |
1291 | error = ENXIO; | 1306 | error = -ENXIO; |
1292 | goto out_unlock; | 1307 | goto out_unlock; |
1293 | } | 1308 | } |
1294 | 1309 | ||
@@ -1307,7 +1322,7 @@ xfs_seek_hole( | |||
1307 | 1322 | ||
1308 | /* No extents at given offset, must be beyond EOF */ | 1323 | /* No extents at given offset, must be beyond EOF */ |
1309 | if (nmap == 0) { | 1324 | if (nmap == 0) { |
1310 | error = ENXIO; | 1325 | error = -ENXIO; |
1311 | goto out_unlock; | 1326 | goto out_unlock; |
1312 | } | 1327 | } |
1313 | 1328 | ||
@@ -1370,7 +1385,7 @@ out_unlock: | |||
1370 | xfs_iunlock(ip, lock); | 1385 | xfs_iunlock(ip, lock); |
1371 | 1386 | ||
1372 | if (error) | 1387 | if (error) |
1373 | return -error; | 1388 | return error; |
1374 | return offset; | 1389 | return offset; |
1375 | } | 1390 | } |
1376 | 1391 | ||
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_fs.h b/fs/xfs/xfs_fs.h index d34703dbcb42..18dc721ca19f 100644 --- a/fs/xfs/xfs_fs.h +++ b/fs/xfs/xfs_fs.h | |||
@@ -255,8 +255,8 @@ typedef struct xfs_fsop_resblks { | |||
255 | ((2 * 1024 * 1024 * 1024ULL) - XFS_MIN_LOG_BYTES) | 255 | ((2 * 1024 * 1024 * 1024ULL) - XFS_MIN_LOG_BYTES) |
256 | 256 | ||
257 | /* Used for sanity checks on superblock */ | 257 | /* Used for sanity checks on superblock */ |
258 | #define XFS_MAX_DBLOCKS(s) ((xfs_drfsbno_t)(s)->sb_agcount * (s)->sb_agblocks) | 258 | #define XFS_MAX_DBLOCKS(s) ((xfs_rfsblock_t)(s)->sb_agcount * (s)->sb_agblocks) |
259 | #define XFS_MIN_DBLOCKS(s) ((xfs_drfsbno_t)((s)->sb_agcount - 1) * \ | 259 | #define XFS_MIN_DBLOCKS(s) ((xfs_rfsblock_t)((s)->sb_agcount - 1) * \ |
260 | (s)->sb_agblocks + XFS_MIN_AG_BLOCKS) | 260 | (s)->sb_agblocks + XFS_MIN_AG_BLOCKS) |
261 | 261 | ||
262 | /* | 262 | /* |
@@ -375,6 +375,9 @@ struct xfs_fs_eofblocks { | |||
375 | #define XFS_EOF_FLAGS_GID (1 << 2) /* filter by gid */ | 375 | #define XFS_EOF_FLAGS_GID (1 << 2) /* filter by gid */ |
376 | #define XFS_EOF_FLAGS_PRID (1 << 3) /* filter by project id */ | 376 | #define XFS_EOF_FLAGS_PRID (1 << 3) /* filter by project id */ |
377 | #define XFS_EOF_FLAGS_MINFILESIZE (1 << 4) /* filter by min file size */ | 377 | #define XFS_EOF_FLAGS_MINFILESIZE (1 << 4) /* filter by min file size */ |
378 | #define XFS_EOF_FLAGS_UNION (1 << 5) /* union filter algorithm; | ||
379 | * kernel only, not included in | ||
380 | * valid mask */ | ||
378 | #define XFS_EOF_FLAGS_VALID \ | 381 | #define XFS_EOF_FLAGS_VALID \ |
379 | (XFS_EOF_FLAGS_SYNC | \ | 382 | (XFS_EOF_FLAGS_SYNC | \ |
380 | XFS_EOF_FLAGS_UID | \ | 383 | XFS_EOF_FLAGS_UID | \ |
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..981b2cf51985 100644 --- a/fs/xfs/xfs_icache.c +++ b/fs/xfs/xfs_icache.c | |||
@@ -33,6 +33,9 @@ | |||
33 | #include "xfs_trace.h" | 33 | #include "xfs_trace.h" |
34 | #include "xfs_icache.h" | 34 | #include "xfs_icache.h" |
35 | #include "xfs_bmap_util.h" | 35 | #include "xfs_bmap_util.h" |
36 | #include "xfs_quota.h" | ||
37 | #include "xfs_dquot_item.h" | ||
38 | #include "xfs_dquot.h" | ||
36 | 39 | ||
37 | #include <linux/kthread.h> | 40 | #include <linux/kthread.h> |
38 | #include <linux/freezer.h> | 41 | #include <linux/freezer.h> |
@@ -158,7 +161,7 @@ xfs_iget_cache_hit( | |||
158 | if (ip->i_ino != ino) { | 161 | if (ip->i_ino != ino) { |
159 | trace_xfs_iget_skip(ip); | 162 | trace_xfs_iget_skip(ip); |
160 | XFS_STATS_INC(xs_ig_frecycle); | 163 | XFS_STATS_INC(xs_ig_frecycle); |
161 | error = EAGAIN; | 164 | error = -EAGAIN; |
162 | goto out_error; | 165 | goto out_error; |
163 | } | 166 | } |
164 | 167 | ||
@@ -176,7 +179,7 @@ xfs_iget_cache_hit( | |||
176 | if (ip->i_flags & (XFS_INEW|XFS_IRECLAIM)) { | 179 | if (ip->i_flags & (XFS_INEW|XFS_IRECLAIM)) { |
177 | trace_xfs_iget_skip(ip); | 180 | trace_xfs_iget_skip(ip); |
178 | XFS_STATS_INC(xs_ig_frecycle); | 181 | XFS_STATS_INC(xs_ig_frecycle); |
179 | error = EAGAIN; | 182 | error = -EAGAIN; |
180 | goto out_error; | 183 | goto out_error; |
181 | } | 184 | } |
182 | 185 | ||
@@ -184,7 +187,7 @@ xfs_iget_cache_hit( | |||
184 | * If lookup is racing with unlink return an error immediately. | 187 | * If lookup is racing with unlink return an error immediately. |
185 | */ | 188 | */ |
186 | if (ip->i_d.di_mode == 0 && !(flags & XFS_IGET_CREATE)) { | 189 | if (ip->i_d.di_mode == 0 && !(flags & XFS_IGET_CREATE)) { |
187 | error = ENOENT; | 190 | error = -ENOENT; |
188 | goto out_error; | 191 | goto out_error; |
189 | } | 192 | } |
190 | 193 | ||
@@ -206,7 +209,7 @@ xfs_iget_cache_hit( | |||
206 | spin_unlock(&ip->i_flags_lock); | 209 | spin_unlock(&ip->i_flags_lock); |
207 | rcu_read_unlock(); | 210 | rcu_read_unlock(); |
208 | 211 | ||
209 | error = -inode_init_always(mp->m_super, inode); | 212 | error = inode_init_always(mp->m_super, inode); |
210 | if (error) { | 213 | if (error) { |
211 | /* | 214 | /* |
212 | * Re-initializing the inode failed, and we are in deep | 215 | * Re-initializing the inode failed, and we are in deep |
@@ -243,7 +246,7 @@ xfs_iget_cache_hit( | |||
243 | /* If the VFS inode is being torn down, pause and try again. */ | 246 | /* If the VFS inode is being torn down, pause and try again. */ |
244 | if (!igrab(inode)) { | 247 | if (!igrab(inode)) { |
245 | trace_xfs_iget_skip(ip); | 248 | trace_xfs_iget_skip(ip); |
246 | error = EAGAIN; | 249 | error = -EAGAIN; |
247 | goto out_error; | 250 | goto out_error; |
248 | } | 251 | } |
249 | 252 | ||
@@ -285,7 +288,7 @@ xfs_iget_cache_miss( | |||
285 | 288 | ||
286 | ip = xfs_inode_alloc(mp, ino); | 289 | ip = xfs_inode_alloc(mp, ino); |
287 | if (!ip) | 290 | if (!ip) |
288 | return ENOMEM; | 291 | return -ENOMEM; |
289 | 292 | ||
290 | error = xfs_iread(mp, tp, ip, flags); | 293 | error = xfs_iread(mp, tp, ip, flags); |
291 | if (error) | 294 | if (error) |
@@ -294,7 +297,7 @@ xfs_iget_cache_miss( | |||
294 | trace_xfs_iget_miss(ip); | 297 | trace_xfs_iget_miss(ip); |
295 | 298 | ||
296 | if ((ip->i_d.di_mode == 0) && !(flags & XFS_IGET_CREATE)) { | 299 | if ((ip->i_d.di_mode == 0) && !(flags & XFS_IGET_CREATE)) { |
297 | error = ENOENT; | 300 | error = -ENOENT; |
298 | goto out_destroy; | 301 | goto out_destroy; |
299 | } | 302 | } |
300 | 303 | ||
@@ -305,7 +308,7 @@ xfs_iget_cache_miss( | |||
305 | * recurse into the file system. | 308 | * recurse into the file system. |
306 | */ | 309 | */ |
307 | if (radix_tree_preload(GFP_NOFS)) { | 310 | if (radix_tree_preload(GFP_NOFS)) { |
308 | error = EAGAIN; | 311 | error = -EAGAIN; |
309 | goto out_destroy; | 312 | goto out_destroy; |
310 | } | 313 | } |
311 | 314 | ||
@@ -341,7 +344,7 @@ xfs_iget_cache_miss( | |||
341 | if (unlikely(error)) { | 344 | if (unlikely(error)) { |
342 | WARN_ON(error != -EEXIST); | 345 | WARN_ON(error != -EEXIST); |
343 | XFS_STATS_INC(xs_ig_dup); | 346 | XFS_STATS_INC(xs_ig_dup); |
344 | error = EAGAIN; | 347 | error = -EAGAIN; |
345 | goto out_preload_end; | 348 | goto out_preload_end; |
346 | } | 349 | } |
347 | spin_unlock(&pag->pag_ici_lock); | 350 | spin_unlock(&pag->pag_ici_lock); |
@@ -408,7 +411,7 @@ xfs_iget( | |||
408 | 411 | ||
409 | /* reject inode numbers outside existing AGs */ | 412 | /* reject inode numbers outside existing AGs */ |
410 | if (!ino || XFS_INO_TO_AGNO(mp, ino) >= mp->m_sb.sb_agcount) | 413 | if (!ino || XFS_INO_TO_AGNO(mp, ino) >= mp->m_sb.sb_agcount) |
411 | return EINVAL; | 414 | return -EINVAL; |
412 | 415 | ||
413 | /* get the perag structure and ensure that it's inode capable */ | 416 | /* get the perag structure and ensure that it's inode capable */ |
414 | pag = xfs_perag_get(mp, XFS_INO_TO_AGNO(mp, ino)); | 417 | pag = xfs_perag_get(mp, XFS_INO_TO_AGNO(mp, ino)); |
@@ -445,7 +448,7 @@ again: | |||
445 | return 0; | 448 | return 0; |
446 | 449 | ||
447 | out_error_or_again: | 450 | out_error_or_again: |
448 | if (error == EAGAIN) { | 451 | if (error == -EAGAIN) { |
449 | delay(1); | 452 | delay(1); |
450 | goto again; | 453 | goto again; |
451 | } | 454 | } |
@@ -489,18 +492,18 @@ xfs_inode_ag_walk_grab( | |||
489 | 492 | ||
490 | /* nothing to sync during shutdown */ | 493 | /* nothing to sync during shutdown */ |
491 | if (XFS_FORCED_SHUTDOWN(ip->i_mount)) | 494 | if (XFS_FORCED_SHUTDOWN(ip->i_mount)) |
492 | return EFSCORRUPTED; | 495 | return -EFSCORRUPTED; |
493 | 496 | ||
494 | /* If we can't grab the inode, it must on it's way to reclaim. */ | 497 | /* If we can't grab the inode, it must on it's way to reclaim. */ |
495 | if (!igrab(inode)) | 498 | if (!igrab(inode)) |
496 | return ENOENT; | 499 | return -ENOENT; |
497 | 500 | ||
498 | /* inode is valid */ | 501 | /* inode is valid */ |
499 | return 0; | 502 | return 0; |
500 | 503 | ||
501 | out_unlock_noent: | 504 | out_unlock_noent: |
502 | spin_unlock(&ip->i_flags_lock); | 505 | spin_unlock(&ip->i_flags_lock); |
503 | return ENOENT; | 506 | return -ENOENT; |
504 | } | 507 | } |
505 | 508 | ||
506 | STATIC int | 509 | STATIC int |
@@ -583,16 +586,16 @@ restart: | |||
583 | continue; | 586 | continue; |
584 | error = execute(batch[i], flags, args); | 587 | error = execute(batch[i], flags, args); |
585 | IRELE(batch[i]); | 588 | IRELE(batch[i]); |
586 | if (error == EAGAIN) { | 589 | if (error == -EAGAIN) { |
587 | skipped++; | 590 | skipped++; |
588 | continue; | 591 | continue; |
589 | } | 592 | } |
590 | if (error && last_error != EFSCORRUPTED) | 593 | if (error && last_error != -EFSCORRUPTED) |
591 | last_error = error; | 594 | last_error = error; |
592 | } | 595 | } |
593 | 596 | ||
594 | /* bail out if the filesystem is corrupted. */ | 597 | /* bail out if the filesystem is corrupted. */ |
595 | if (error == EFSCORRUPTED) | 598 | if (error == -EFSCORRUPTED) |
596 | break; | 599 | break; |
597 | 600 | ||
598 | cond_resched(); | 601 | cond_resched(); |
@@ -652,11 +655,11 @@ xfs_inode_ag_iterator( | |||
652 | xfs_perag_put(pag); | 655 | xfs_perag_put(pag); |
653 | if (error) { | 656 | if (error) { |
654 | last_error = error; | 657 | last_error = error; |
655 | if (error == EFSCORRUPTED) | 658 | if (error == -EFSCORRUPTED) |
656 | break; | 659 | break; |
657 | } | 660 | } |
658 | } | 661 | } |
659 | return XFS_ERROR(last_error); | 662 | return last_error; |
660 | } | 663 | } |
661 | 664 | ||
662 | int | 665 | int |
@@ -680,11 +683,11 @@ xfs_inode_ag_iterator_tag( | |||
680 | xfs_perag_put(pag); | 683 | xfs_perag_put(pag); |
681 | if (error) { | 684 | if (error) { |
682 | last_error = error; | 685 | last_error = error; |
683 | if (error == EFSCORRUPTED) | 686 | if (error == -EFSCORRUPTED) |
684 | break; | 687 | break; |
685 | } | 688 | } |
686 | } | 689 | } |
687 | return XFS_ERROR(last_error); | 690 | return last_error; |
688 | } | 691 | } |
689 | 692 | ||
690 | /* | 693 | /* |
@@ -944,7 +947,7 @@ restart: | |||
944 | * see the stale flag set on the inode. | 947 | * see the stale flag set on the inode. |
945 | */ | 948 | */ |
946 | error = xfs_iflush(ip, &bp); | 949 | error = xfs_iflush(ip, &bp); |
947 | if (error == EAGAIN) { | 950 | if (error == -EAGAIN) { |
948 | xfs_iunlock(ip, XFS_ILOCK_EXCL); | 951 | xfs_iunlock(ip, XFS_ILOCK_EXCL); |
949 | /* backoff longer than in xfs_ifree_cluster */ | 952 | /* backoff longer than in xfs_ifree_cluster */ |
950 | delay(2); | 953 | delay(2); |
@@ -997,7 +1000,7 @@ out: | |||
997 | xfs_iflags_clear(ip, XFS_IRECLAIM); | 1000 | xfs_iflags_clear(ip, XFS_IRECLAIM); |
998 | xfs_iunlock(ip, XFS_ILOCK_EXCL); | 1001 | xfs_iunlock(ip, XFS_ILOCK_EXCL); |
999 | /* | 1002 | /* |
1000 | * We could return EAGAIN here to make reclaim rescan the inode tree in | 1003 | * 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 | 1004 | * 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 | 1005 | * 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 | 1006 | * the idle state. Instead, return 0 to let the next scheduled |
@@ -1100,7 +1103,7 @@ restart: | |||
1100 | if (!batch[i]) | 1103 | if (!batch[i]) |
1101 | continue; | 1104 | continue; |
1102 | error = xfs_reclaim_inode(batch[i], pag, flags); | 1105 | error = xfs_reclaim_inode(batch[i], pag, flags); |
1103 | if (error && last_error != EFSCORRUPTED) | 1106 | if (error && last_error != -EFSCORRUPTED) |
1104 | last_error = error; | 1107 | last_error = error; |
1105 | } | 1108 | } |
1106 | 1109 | ||
@@ -1129,7 +1132,7 @@ restart: | |||
1129 | trylock = 0; | 1132 | trylock = 0; |
1130 | goto restart; | 1133 | goto restart; |
1131 | } | 1134 | } |
1132 | return XFS_ERROR(last_error); | 1135 | return last_error; |
1133 | } | 1136 | } |
1134 | 1137 | ||
1135 | int | 1138 | int |
@@ -1203,6 +1206,30 @@ xfs_inode_match_id( | |||
1203 | return 1; | 1206 | return 1; |
1204 | } | 1207 | } |
1205 | 1208 | ||
1209 | /* | ||
1210 | * A union-based inode filtering algorithm. Process the inode if any of the | ||
1211 | * criteria match. This is for global/internal scans only. | ||
1212 | */ | ||
1213 | STATIC int | ||
1214 | xfs_inode_match_id_union( | ||
1215 | struct xfs_inode *ip, | ||
1216 | struct xfs_eofblocks *eofb) | ||
1217 | { | ||
1218 | if ((eofb->eof_flags & XFS_EOF_FLAGS_UID) && | ||
1219 | uid_eq(VFS_I(ip)->i_uid, eofb->eof_uid)) | ||
1220 | return 1; | ||
1221 | |||
1222 | if ((eofb->eof_flags & XFS_EOF_FLAGS_GID) && | ||
1223 | gid_eq(VFS_I(ip)->i_gid, eofb->eof_gid)) | ||
1224 | return 1; | ||
1225 | |||
1226 | if ((eofb->eof_flags & XFS_EOF_FLAGS_PRID) && | ||
1227 | xfs_get_projid(ip) == eofb->eof_prid) | ||
1228 | return 1; | ||
1229 | |||
1230 | return 0; | ||
1231 | } | ||
1232 | |||
1206 | STATIC int | 1233 | STATIC int |
1207 | xfs_inode_free_eofblocks( | 1234 | xfs_inode_free_eofblocks( |
1208 | struct xfs_inode *ip, | 1235 | struct xfs_inode *ip, |
@@ -1211,6 +1238,10 @@ xfs_inode_free_eofblocks( | |||
1211 | { | 1238 | { |
1212 | int ret; | 1239 | int ret; |
1213 | struct xfs_eofblocks *eofb = args; | 1240 | struct xfs_eofblocks *eofb = args; |
1241 | bool need_iolock = true; | ||
1242 | int match; | ||
1243 | |||
1244 | ASSERT(!eofb || (eofb && eofb->eof_scan_owner != 0)); | ||
1214 | 1245 | ||
1215 | if (!xfs_can_free_eofblocks(ip, false)) { | 1246 | if (!xfs_can_free_eofblocks(ip, false)) { |
1216 | /* inode could be preallocated or append-only */ | 1247 | /* inode could be preallocated or append-only */ |
@@ -1228,19 +1259,31 @@ xfs_inode_free_eofblocks( | |||
1228 | return 0; | 1259 | return 0; |
1229 | 1260 | ||
1230 | if (eofb) { | 1261 | if (eofb) { |
1231 | if (!xfs_inode_match_id(ip, eofb)) | 1262 | if (eofb->eof_flags & XFS_EOF_FLAGS_UNION) |
1263 | match = xfs_inode_match_id_union(ip, eofb); | ||
1264 | else | ||
1265 | match = xfs_inode_match_id(ip, eofb); | ||
1266 | if (!match) | ||
1232 | return 0; | 1267 | return 0; |
1233 | 1268 | ||
1234 | /* skip the inode if the file size is too small */ | 1269 | /* skip the inode if the file size is too small */ |
1235 | if (eofb->eof_flags & XFS_EOF_FLAGS_MINFILESIZE && | 1270 | if (eofb->eof_flags & XFS_EOF_FLAGS_MINFILESIZE && |
1236 | XFS_ISIZE(ip) < eofb->eof_min_file_size) | 1271 | XFS_ISIZE(ip) < eofb->eof_min_file_size) |
1237 | return 0; | 1272 | return 0; |
1273 | |||
1274 | /* | ||
1275 | * A scan owner implies we already hold the iolock. Skip it in | ||
1276 | * xfs_free_eofblocks() to avoid deadlock. This also eliminates | ||
1277 | * the possibility of EAGAIN being returned. | ||
1278 | */ | ||
1279 | if (eofb->eof_scan_owner == ip->i_ino) | ||
1280 | need_iolock = false; | ||
1238 | } | 1281 | } |
1239 | 1282 | ||
1240 | ret = xfs_free_eofblocks(ip->i_mount, ip, true); | 1283 | ret = xfs_free_eofblocks(ip->i_mount, ip, need_iolock); |
1241 | 1284 | ||
1242 | /* don't revisit the inode if we're not waiting */ | 1285 | /* don't revisit the inode if we're not waiting */ |
1243 | if (ret == EAGAIN && !(flags & SYNC_WAIT)) | 1286 | if (ret == -EAGAIN && !(flags & SYNC_WAIT)) |
1244 | ret = 0; | 1287 | ret = 0; |
1245 | 1288 | ||
1246 | return ret; | 1289 | return ret; |
@@ -1260,6 +1303,55 @@ xfs_icache_free_eofblocks( | |||
1260 | eofb, XFS_ICI_EOFBLOCKS_TAG); | 1303 | eofb, XFS_ICI_EOFBLOCKS_TAG); |
1261 | } | 1304 | } |
1262 | 1305 | ||
1306 | /* | ||
1307 | * Run eofblocks scans on the quotas applicable to the inode. For inodes with | ||
1308 | * multiple quotas, we don't know exactly which quota caused an allocation | ||
1309 | * failure. We make a best effort by including each quota under low free space | ||
1310 | * conditions (less than 1% free space) in the scan. | ||
1311 | */ | ||
1312 | int | ||
1313 | xfs_inode_free_quota_eofblocks( | ||
1314 | struct xfs_inode *ip) | ||
1315 | { | ||
1316 | int scan = 0; | ||
1317 | struct xfs_eofblocks eofb = {0}; | ||
1318 | struct xfs_dquot *dq; | ||
1319 | |||
1320 | ASSERT(xfs_isilocked(ip, XFS_IOLOCK_EXCL)); | ||
1321 | |||
1322 | /* | ||
1323 | * Set the scan owner to avoid a potential livelock. Otherwise, the scan | ||
1324 | * can repeatedly trylock on the inode we're currently processing. We | ||
1325 | * run a sync scan to increase effectiveness and use the union filter to | ||
1326 | * cover all applicable quotas in a single scan. | ||
1327 | */ | ||
1328 | eofb.eof_scan_owner = ip->i_ino; | ||
1329 | eofb.eof_flags = XFS_EOF_FLAGS_UNION|XFS_EOF_FLAGS_SYNC; | ||
1330 | |||
1331 | if (XFS_IS_UQUOTA_ENFORCED(ip->i_mount)) { | ||
1332 | dq = xfs_inode_dquot(ip, XFS_DQ_USER); | ||
1333 | if (dq && xfs_dquot_lowsp(dq)) { | ||
1334 | eofb.eof_uid = VFS_I(ip)->i_uid; | ||
1335 | eofb.eof_flags |= XFS_EOF_FLAGS_UID; | ||
1336 | scan = 1; | ||
1337 | } | ||
1338 | } | ||
1339 | |||
1340 | if (XFS_IS_GQUOTA_ENFORCED(ip->i_mount)) { | ||
1341 | dq = xfs_inode_dquot(ip, XFS_DQ_GROUP); | ||
1342 | if (dq && xfs_dquot_lowsp(dq)) { | ||
1343 | eofb.eof_gid = VFS_I(ip)->i_gid; | ||
1344 | eofb.eof_flags |= XFS_EOF_FLAGS_GID; | ||
1345 | scan = 1; | ||
1346 | } | ||
1347 | } | ||
1348 | |||
1349 | if (scan) | ||
1350 | xfs_icache_free_eofblocks(ip->i_mount, &eofb); | ||
1351 | |||
1352 | return scan; | ||
1353 | } | ||
1354 | |||
1263 | void | 1355 | void |
1264 | xfs_inode_set_eofblocks_tag( | 1356 | xfs_inode_set_eofblocks_tag( |
1265 | xfs_inode_t *ip) | 1357 | xfs_inode_t *ip) |
diff --git a/fs/xfs/xfs_icache.h b/fs/xfs/xfs_icache.h index 9cf017b899be..46748b86b12f 100644 --- a/fs/xfs/xfs_icache.h +++ b/fs/xfs/xfs_icache.h | |||
@@ -27,6 +27,7 @@ struct xfs_eofblocks { | |||
27 | kgid_t eof_gid; | 27 | kgid_t eof_gid; |
28 | prid_t eof_prid; | 28 | prid_t eof_prid; |
29 | __u64 eof_min_file_size; | 29 | __u64 eof_min_file_size; |
30 | xfs_ino_t eof_scan_owner; | ||
30 | }; | 31 | }; |
31 | 32 | ||
32 | #define SYNC_WAIT 0x0001 /* wait for i/o to complete */ | 33 | #define SYNC_WAIT 0x0001 /* wait for i/o to complete */ |
@@ -57,6 +58,7 @@ void xfs_inode_set_reclaim_tag(struct xfs_inode *ip); | |||
57 | void xfs_inode_set_eofblocks_tag(struct xfs_inode *ip); | 58 | void xfs_inode_set_eofblocks_tag(struct xfs_inode *ip); |
58 | void xfs_inode_clear_eofblocks_tag(struct xfs_inode *ip); | 59 | void xfs_inode_clear_eofblocks_tag(struct xfs_inode *ip); |
59 | int xfs_icache_free_eofblocks(struct xfs_mount *, struct xfs_eofblocks *); | 60 | int xfs_icache_free_eofblocks(struct xfs_mount *, struct xfs_eofblocks *); |
61 | int xfs_inode_free_quota_eofblocks(struct xfs_inode *ip); | ||
60 | void xfs_eofblocks_worker(struct work_struct *); | 62 | void xfs_eofblocks_worker(struct work_struct *); |
61 | 63 | ||
62 | int xfs_inode_ag_iterator(struct xfs_mount *mp, | 64 | int xfs_inode_ag_iterator(struct xfs_mount *mp, |
@@ -72,31 +74,32 @@ xfs_fs_eofblocks_from_user( | |||
72 | struct xfs_eofblocks *dst) | 74 | struct xfs_eofblocks *dst) |
73 | { | 75 | { |
74 | if (src->eof_version != XFS_EOFBLOCKS_VERSION) | 76 | if (src->eof_version != XFS_EOFBLOCKS_VERSION) |
75 | return EINVAL; | 77 | return -EINVAL; |
76 | 78 | ||
77 | if (src->eof_flags & ~XFS_EOF_FLAGS_VALID) | 79 | if (src->eof_flags & ~XFS_EOF_FLAGS_VALID) |
78 | return EINVAL; | 80 | return -EINVAL; |
79 | 81 | ||
80 | if (memchr_inv(&src->pad32, 0, sizeof(src->pad32)) || | 82 | if (memchr_inv(&src->pad32, 0, sizeof(src->pad32)) || |
81 | memchr_inv(src->pad64, 0, sizeof(src->pad64))) | 83 | memchr_inv(src->pad64, 0, sizeof(src->pad64))) |
82 | return EINVAL; | 84 | return -EINVAL; |
83 | 85 | ||
84 | dst->eof_flags = src->eof_flags; | 86 | dst->eof_flags = src->eof_flags; |
85 | dst->eof_prid = src->eof_prid; | 87 | dst->eof_prid = src->eof_prid; |
86 | dst->eof_min_file_size = src->eof_min_file_size; | 88 | dst->eof_min_file_size = src->eof_min_file_size; |
89 | dst->eof_scan_owner = NULLFSINO; | ||
87 | 90 | ||
88 | dst->eof_uid = INVALID_UID; | 91 | dst->eof_uid = INVALID_UID; |
89 | if (src->eof_flags & XFS_EOF_FLAGS_UID) { | 92 | if (src->eof_flags & XFS_EOF_FLAGS_UID) { |
90 | dst->eof_uid = make_kuid(current_user_ns(), src->eof_uid); | 93 | dst->eof_uid = make_kuid(current_user_ns(), src->eof_uid); |
91 | if (!uid_valid(dst->eof_uid)) | 94 | if (!uid_valid(dst->eof_uid)) |
92 | return EINVAL; | 95 | return -EINVAL; |
93 | } | 96 | } |
94 | 97 | ||
95 | dst->eof_gid = INVALID_GID; | 98 | dst->eof_gid = INVALID_GID; |
96 | if (src->eof_flags & XFS_EOF_FLAGS_GID) { | 99 | if (src->eof_flags & XFS_EOF_FLAGS_GID) { |
97 | dst->eof_gid = make_kgid(current_user_ns(), src->eof_gid); | 100 | dst->eof_gid = make_kgid(current_user_ns(), src->eof_gid); |
98 | if (!gid_valid(dst->eof_gid)) | 101 | if (!gid_valid(dst->eof_gid)) |
99 | return EINVAL; | 102 | return -EINVAL; |
100 | } | 103 | } |
101 | return 0; | 104 | return 0; |
102 | } | 105 | } |
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index a6115fe1ac94..fea3c92fb3f0 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 | ||
@@ -1635,8 +1635,8 @@ xfs_release( | |||
1635 | truncated = xfs_iflags_test_and_clear(ip, XFS_ITRUNCATED); | 1635 | truncated = xfs_iflags_test_and_clear(ip, XFS_ITRUNCATED); |
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 (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); |
3169 | cluster_corrupt_out: | 3169 | cluster_corrupt_out: |
3170 | error = XFS_ERROR(EFSCORRUPTED); | 3170 | error = -EFSCORRUPTED; |
3171 | abort_out: | 3171 | abort_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 | ||
3333 | corrupt_out: | 3333 | corrupt_out: |
3334 | return XFS_ERROR(EFSCORRUPTED); | 3334 | return -EFSCORRUPTED; |
3335 | } | 3335 | } |
diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h index f72bffa67266..c10e3fadd9af 100644 --- a/fs/xfs/xfs_inode.h +++ b/fs/xfs/xfs_inode.h | |||
@@ -398,4 +398,14 @@ do { \ | |||
398 | 398 | ||
399 | extern struct kmem_zone *xfs_inode_zone; | 399 | extern struct kmem_zone *xfs_inode_zone; |
400 | 400 | ||
401 | /* | ||
402 | * Flags for read/write calls | ||
403 | */ | ||
404 | #define XFS_IO_ISDIRECT 0x00001 /* bypass page cache */ | ||
405 | #define XFS_IO_INVIS 0x00002 /* don't update inode timestamps */ | ||
406 | |||
407 | #define XFS_IO_FLAGS \ | ||
408 | { XFS_IO_ISDIRECT, "DIRECT" }, \ | ||
409 | { XFS_IO_INVIS, "INVIS"} | ||
410 | |||
401 | #endif /* __XFS_INODE_H__ */ | 411 | #endif /* __XFS_INODE_H__ */ |
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..3799695b9249 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 | ||
473 | out_kfree: | 473 | out_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 | ||
503 | int | 500 | int |
@@ -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 | ||
606 | int | 603 | int |
@@ -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) |
@@ -739,7 +736,7 @@ xfs_ioc_space( | |||
739 | xfs_ilock(ip, XFS_ILOCK_EXCL); | 736 | xfs_ilock(ip, XFS_ILOCK_EXCL); |
740 | xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL); | 737 | xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL); |
741 | 738 | ||
742 | if (!(ioflags & IO_INVIS)) { | 739 | if (!(ioflags & XFS_IO_INVIS)) { |
743 | ip->i_d.di_mode &= ~S_ISUID; | 740 | ip->i_d.di_mode &= ~S_ISUID; |
744 | if (ip->i_d.di_mode & S_IXGRP) | 741 | if (ip->i_d.di_mode & S_IXGRP) |
745 | ip->i_d.di_mode &= ~S_ISGID; | 742 | ip->i_d.di_mode &= ~S_ISGID; |
@@ -759,7 +756,7 @@ xfs_ioc_space( | |||
759 | out_unlock: | 756 | out_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 | ||
765 | STATIC int | 762 | STATIC int |
@@ -781,41 +778,41 @@ 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, |
800 | bulkreq.ubuffer, xfs_inumbers_fmt); | 797 | bulkreq.ubuffer, xfs_inumbers_fmt); |
801 | else if (cmd == XFS_IOC_FSBULKSTAT_SINGLE) | 798 | else if (cmd == XFS_IOC_FSBULKSTAT_SINGLE) |
802 | error = xfs_bulkstat_single(mp, &inlast, | 799 | error = xfs_bulkstat_one(mp, inlast, bulkreq.ubuffer, |
803 | bulkreq.ubuffer, &done); | 800 | sizeof(xfs_bstat_t), NULL, &done); |
804 | else /* XFS_IOC_FSBULKSTAT */ | 801 | else /* XFS_IOC_FSBULKSTAT */ |
805 | error = xfs_bulkstat(mp, &inlast, &count, xfs_bulkstat_one, | 802 | error = xfs_bulkstat(mp, &inlast, &count, xfs_bulkstat_one, |
806 | sizeof(xfs_bstat_t), bulkreq.ubuffer, | 803 | sizeof(xfs_bstat_t), bulkreq.ubuffer, |
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 | ||
1307 | STATIC int | 1304 | STATIC 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 | ||
1352 | STATIC int | 1349 | STATIC 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,23 +1370,23 @@ 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 & XFS_IO_INVIS) |
1383 | bmx.bmv_iflags |= BMV_IF_NO_DMAPI_READ; | 1380 | bmx.bmv_iflags |= BMV_IF_NO_DMAPI_READ; |
1384 | 1381 | ||
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 | ||
@@ -1523,7 +1520,7 @@ xfs_file_ioctl( | |||
1523 | int error; | 1520 | int error; |
1524 | 1521 | ||
1525 | if (filp->f_mode & FMODE_NOCMTIME) | 1522 | if (filp->f_mode & FMODE_NOCMTIME) |
1526 | ioflags |= IO_INVIS; | 1523 | ioflags |= XFS_IO_INVIS; |
1527 | 1524 | ||
1528 | trace_xfs_file_ioctl(ip); | 1525 | trace_xfs_file_ioctl(ip); |
1529 | 1526 | ||
@@ -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..a554646ff141 100644 --- a/fs/xfs/xfs_ioctl32.c +++ b/fs/xfs/xfs_ioctl32.c | |||
@@ -28,7 +28,6 @@ | |||
28 | #include "xfs_sb.h" | 28 | #include "xfs_sb.h" |
29 | #include "xfs_ag.h" | 29 | #include "xfs_ag.h" |
30 | #include "xfs_mount.h" | 30 | #include "xfs_mount.h" |
31 | #include "xfs_vnode.h" | ||
32 | #include "xfs_inode.h" | 31 | #include "xfs_inode.h" |
33 | #include "xfs_itable.h" | 32 | #include "xfs_itable.h" |
34 | #include "xfs_error.h" | 33 | #include "xfs_error.h" |
@@ -56,7 +55,7 @@ xfs_compat_flock64_copyin( | |||
56 | get_user(bf->l_sysid, &arg32->l_sysid) || | 55 | get_user(bf->l_sysid, &arg32->l_sysid) || |
57 | get_user(bf->l_pid, &arg32->l_pid) || | 56 | get_user(bf->l_pid, &arg32->l_pid) || |
58 | copy_from_user(bf->l_pad, &arg32->l_pad, 4*sizeof(u32))) | 57 | copy_from_user(bf->l_pad, &arg32->l_pad, 4*sizeof(u32))) |
59 | return -XFS_ERROR(EFAULT); | 58 | return -EFAULT; |
60 | return 0; | 59 | return 0; |
61 | } | 60 | } |
62 | 61 | ||
@@ -70,10 +69,10 @@ xfs_compat_ioc_fsgeometry_v1( | |||
70 | 69 | ||
71 | error = xfs_fs_geometry(mp, &fsgeo, 3); | 70 | error = xfs_fs_geometry(mp, &fsgeo, 3); |
72 | if (error) | 71 | if (error) |
73 | return -error; | 72 | return error; |
74 | /* The 32-bit variant simply has some padding at the end */ | 73 | /* 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))) | 74 | if (copy_to_user(arg32, &fsgeo, sizeof(struct compat_xfs_fsop_geom_v1))) |
76 | return -XFS_ERROR(EFAULT); | 75 | return -EFAULT; |
77 | return 0; | 76 | return 0; |
78 | } | 77 | } |
79 | 78 | ||
@@ -84,7 +83,7 @@ xfs_compat_growfs_data_copyin( | |||
84 | { | 83 | { |
85 | if (get_user(in->newblocks, &arg32->newblocks) || | 84 | if (get_user(in->newblocks, &arg32->newblocks) || |
86 | get_user(in->imaxpct, &arg32->imaxpct)) | 85 | get_user(in->imaxpct, &arg32->imaxpct)) |
87 | return -XFS_ERROR(EFAULT); | 86 | return -EFAULT; |
88 | return 0; | 87 | return 0; |
89 | } | 88 | } |
90 | 89 | ||
@@ -95,14 +94,14 @@ xfs_compat_growfs_rt_copyin( | |||
95 | { | 94 | { |
96 | if (get_user(in->newblocks, &arg32->newblocks) || | 95 | if (get_user(in->newblocks, &arg32->newblocks) || |
97 | get_user(in->extsize, &arg32->extsize)) | 96 | get_user(in->extsize, &arg32->extsize)) |
98 | return -XFS_ERROR(EFAULT); | 97 | return -EFAULT; |
99 | return 0; | 98 | return 0; |
100 | } | 99 | } |
101 | 100 | ||
102 | STATIC int | 101 | STATIC int |
103 | xfs_inumbers_fmt_compat( | 102 | xfs_inumbers_fmt_compat( |
104 | void __user *ubuffer, | 103 | void __user *ubuffer, |
105 | const xfs_inogrp_t *buffer, | 104 | const struct xfs_inogrp *buffer, |
106 | long count, | 105 | long count, |
107 | long *written) | 106 | long *written) |
108 | { | 107 | { |
@@ -113,7 +112,7 @@ xfs_inumbers_fmt_compat( | |||
113 | if (put_user(buffer[i].xi_startino, &p32[i].xi_startino) || | 112 | if (put_user(buffer[i].xi_startino, &p32[i].xi_startino) || |
114 | put_user(buffer[i].xi_alloccount, &p32[i].xi_alloccount) || | 113 | put_user(buffer[i].xi_alloccount, &p32[i].xi_alloccount) || |
115 | put_user(buffer[i].xi_allocmask, &p32[i].xi_allocmask)) | 114 | put_user(buffer[i].xi_allocmask, &p32[i].xi_allocmask)) |
116 | return -XFS_ERROR(EFAULT); | 115 | return -EFAULT; |
117 | } | 116 | } |
118 | *written = count * sizeof(*p32); | 117 | *written = count * sizeof(*p32); |
119 | return 0; | 118 | return 0; |
@@ -132,7 +131,7 @@ xfs_ioctl32_bstime_copyin( | |||
132 | 131 | ||
133 | if (get_user(sec32, &bstime32->tv_sec) || | 132 | if (get_user(sec32, &bstime32->tv_sec) || |
134 | get_user(bstime->tv_nsec, &bstime32->tv_nsec)) | 133 | get_user(bstime->tv_nsec, &bstime32->tv_nsec)) |
135 | return -XFS_ERROR(EFAULT); | 134 | return -EFAULT; |
136 | bstime->tv_sec = sec32; | 135 | bstime->tv_sec = sec32; |
137 | return 0; | 136 | return 0; |
138 | } | 137 | } |
@@ -164,7 +163,7 @@ xfs_ioctl32_bstat_copyin( | |||
164 | get_user(bstat->bs_dmevmask, &bstat32->bs_dmevmask) || | 163 | get_user(bstat->bs_dmevmask, &bstat32->bs_dmevmask) || |
165 | get_user(bstat->bs_dmstate, &bstat32->bs_dmstate) || | 164 | get_user(bstat->bs_dmstate, &bstat32->bs_dmstate) || |
166 | get_user(bstat->bs_aextents, &bstat32->bs_aextents)) | 165 | get_user(bstat->bs_aextents, &bstat32->bs_aextents)) |
167 | return -XFS_ERROR(EFAULT); | 166 | return -EFAULT; |
168 | return 0; | 167 | return 0; |
169 | } | 168 | } |
170 | 169 | ||
@@ -180,7 +179,7 @@ xfs_bstime_store_compat( | |||
180 | sec32 = p->tv_sec; | 179 | sec32 = p->tv_sec; |
181 | if (put_user(sec32, &p32->tv_sec) || | 180 | if (put_user(sec32, &p32->tv_sec) || |
182 | put_user(p->tv_nsec, &p32->tv_nsec)) | 181 | put_user(p->tv_nsec, &p32->tv_nsec)) |
183 | return -XFS_ERROR(EFAULT); | 182 | return -EFAULT; |
184 | return 0; | 183 | return 0; |
185 | } | 184 | } |
186 | 185 | ||
@@ -195,7 +194,7 @@ xfs_bulkstat_one_fmt_compat( | |||
195 | compat_xfs_bstat_t __user *p32 = ubuffer; | 194 | compat_xfs_bstat_t __user *p32 = ubuffer; |
196 | 195 | ||
197 | if (ubsize < sizeof(*p32)) | 196 | if (ubsize < sizeof(*p32)) |
198 | return XFS_ERROR(ENOMEM); | 197 | return -ENOMEM; |
199 | 198 | ||
200 | if (put_user(buffer->bs_ino, &p32->bs_ino) || | 199 | if (put_user(buffer->bs_ino, &p32->bs_ino) || |
201 | put_user(buffer->bs_mode, &p32->bs_mode) || | 200 | put_user(buffer->bs_mode, &p32->bs_mode) || |
@@ -218,7 +217,7 @@ xfs_bulkstat_one_fmt_compat( | |||
218 | put_user(buffer->bs_dmevmask, &p32->bs_dmevmask) || | 217 | put_user(buffer->bs_dmevmask, &p32->bs_dmevmask) || |
219 | put_user(buffer->bs_dmstate, &p32->bs_dmstate) || | 218 | put_user(buffer->bs_dmstate, &p32->bs_dmstate) || |
220 | put_user(buffer->bs_aextents, &p32->bs_aextents)) | 219 | put_user(buffer->bs_aextents, &p32->bs_aextents)) |
221 | return XFS_ERROR(EFAULT); | 220 | return -EFAULT; |
222 | if (ubused) | 221 | if (ubused) |
223 | *ubused = sizeof(*p32); | 222 | *ubused = sizeof(*p32); |
224 | return 0; | 223 | return 0; |
@@ -256,30 +255,30 @@ xfs_compat_ioc_bulkstat( | |||
256 | /* should be called again (unused here, but used in dmapi) */ | 255 | /* should be called again (unused here, but used in dmapi) */ |
257 | 256 | ||
258 | if (!capable(CAP_SYS_ADMIN)) | 257 | if (!capable(CAP_SYS_ADMIN)) |
259 | return -XFS_ERROR(EPERM); | 258 | return -EPERM; |
260 | 259 | ||
261 | if (XFS_FORCED_SHUTDOWN(mp)) | 260 | if (XFS_FORCED_SHUTDOWN(mp)) |
262 | return -XFS_ERROR(EIO); | 261 | return -EIO; |
263 | 262 | ||
264 | if (get_user(addr, &p32->lastip)) | 263 | if (get_user(addr, &p32->lastip)) |
265 | return -XFS_ERROR(EFAULT); | 264 | return -EFAULT; |
266 | bulkreq.lastip = compat_ptr(addr); | 265 | bulkreq.lastip = compat_ptr(addr); |
267 | if (get_user(bulkreq.icount, &p32->icount) || | 266 | if (get_user(bulkreq.icount, &p32->icount) || |
268 | get_user(addr, &p32->ubuffer)) | 267 | get_user(addr, &p32->ubuffer)) |
269 | return -XFS_ERROR(EFAULT); | 268 | return -EFAULT; |
270 | bulkreq.ubuffer = compat_ptr(addr); | 269 | bulkreq.ubuffer = compat_ptr(addr); |
271 | if (get_user(addr, &p32->ocount)) | 270 | if (get_user(addr, &p32->ocount)) |
272 | return -XFS_ERROR(EFAULT); | 271 | return -EFAULT; |
273 | bulkreq.ocount = compat_ptr(addr); | 272 | bulkreq.ocount = compat_ptr(addr); |
274 | 273 | ||
275 | if (copy_from_user(&inlast, bulkreq.lastip, sizeof(__s64))) | 274 | if (copy_from_user(&inlast, bulkreq.lastip, sizeof(__s64))) |
276 | return -XFS_ERROR(EFAULT); | 275 | return -EFAULT; |
277 | 276 | ||
278 | if ((count = bulkreq.icount) <= 0) | 277 | if ((count = bulkreq.icount) <= 0) |
279 | return -XFS_ERROR(EINVAL); | 278 | return -EINVAL; |
280 | 279 | ||
281 | if (bulkreq.ubuffer == NULL) | 280 | if (bulkreq.ubuffer == NULL) |
282 | return -XFS_ERROR(EINVAL); | 281 | return -EINVAL; |
283 | 282 | ||
284 | if (cmd == XFS_IOC_FSINUMBERS_32) { | 283 | if (cmd == XFS_IOC_FSINUMBERS_32) { |
285 | error = xfs_inumbers(mp, &inlast, &count, | 284 | error = xfs_inumbers(mp, &inlast, &count, |
@@ -294,17 +293,17 @@ xfs_compat_ioc_bulkstat( | |||
294 | xfs_bulkstat_one_compat, sizeof(compat_xfs_bstat_t), | 293 | xfs_bulkstat_one_compat, sizeof(compat_xfs_bstat_t), |
295 | bulkreq.ubuffer, &done); | 294 | bulkreq.ubuffer, &done); |
296 | } else | 295 | } else |
297 | error = XFS_ERROR(EINVAL); | 296 | error = -EINVAL; |
298 | if (error) | 297 | if (error) |
299 | return -error; | 298 | return error; |
300 | 299 | ||
301 | if (bulkreq.ocount != NULL) { | 300 | if (bulkreq.ocount != NULL) { |
302 | if (copy_to_user(bulkreq.lastip, &inlast, | 301 | if (copy_to_user(bulkreq.lastip, &inlast, |
303 | sizeof(xfs_ino_t))) | 302 | sizeof(xfs_ino_t))) |
304 | return -XFS_ERROR(EFAULT); | 303 | return -EFAULT; |
305 | 304 | ||
306 | if (copy_to_user(bulkreq.ocount, &count, sizeof(count))) | 305 | if (copy_to_user(bulkreq.ocount, &count, sizeof(count))) |
307 | return -XFS_ERROR(EFAULT); | 306 | return -EFAULT; |
308 | } | 307 | } |
309 | 308 | ||
310 | return 0; | 309 | return 0; |
@@ -318,7 +317,7 @@ xfs_compat_handlereq_copyin( | |||
318 | compat_xfs_fsop_handlereq_t hreq32; | 317 | compat_xfs_fsop_handlereq_t hreq32; |
319 | 318 | ||
320 | if (copy_from_user(&hreq32, arg32, sizeof(compat_xfs_fsop_handlereq_t))) | 319 | if (copy_from_user(&hreq32, arg32, sizeof(compat_xfs_fsop_handlereq_t))) |
321 | return -XFS_ERROR(EFAULT); | 320 | return -EFAULT; |
322 | 321 | ||
323 | hreq->fd = hreq32.fd; | 322 | hreq->fd = hreq32.fd; |
324 | hreq->path = compat_ptr(hreq32.path); | 323 | hreq->path = compat_ptr(hreq32.path); |
@@ -352,19 +351,19 @@ xfs_compat_attrlist_by_handle( | |||
352 | char *kbuf; | 351 | char *kbuf; |
353 | 352 | ||
354 | if (!capable(CAP_SYS_ADMIN)) | 353 | if (!capable(CAP_SYS_ADMIN)) |
355 | return -XFS_ERROR(EPERM); | 354 | return -EPERM; |
356 | if (copy_from_user(&al_hreq, arg, | 355 | if (copy_from_user(&al_hreq, arg, |
357 | sizeof(compat_xfs_fsop_attrlist_handlereq_t))) | 356 | sizeof(compat_xfs_fsop_attrlist_handlereq_t))) |
358 | return -XFS_ERROR(EFAULT); | 357 | return -EFAULT; |
359 | if (al_hreq.buflen < sizeof(struct attrlist) || | 358 | if (al_hreq.buflen < sizeof(struct attrlist) || |
360 | al_hreq.buflen > XATTR_LIST_MAX) | 359 | al_hreq.buflen > XATTR_LIST_MAX) |
361 | return -XFS_ERROR(EINVAL); | 360 | return -EINVAL; |
362 | 361 | ||
363 | /* | 362 | /* |
364 | * Reject flags, only allow namespaces. | 363 | * Reject flags, only allow namespaces. |
365 | */ | 364 | */ |
366 | if (al_hreq.flags & ~(ATTR_ROOT | ATTR_SECURE)) | 365 | if (al_hreq.flags & ~(ATTR_ROOT | ATTR_SECURE)) |
367 | return -XFS_ERROR(EINVAL); | 366 | return -EINVAL; |
368 | 367 | ||
369 | dentry = xfs_compat_handlereq_to_dentry(parfilp, &al_hreq.hreq); | 368 | dentry = xfs_compat_handlereq_to_dentry(parfilp, &al_hreq.hreq); |
370 | if (IS_ERR(dentry)) | 369 | if (IS_ERR(dentry)) |
@@ -376,7 +375,7 @@ xfs_compat_attrlist_by_handle( | |||
376 | goto out_dput; | 375 | goto out_dput; |
377 | 376 | ||
378 | cursor = (attrlist_cursor_kern_t *)&al_hreq.pos; | 377 | cursor = (attrlist_cursor_kern_t *)&al_hreq.pos; |
379 | error = -xfs_attr_list(XFS_I(dentry->d_inode), kbuf, al_hreq.buflen, | 378 | error = xfs_attr_list(XFS_I(dentry->d_inode), kbuf, al_hreq.buflen, |
380 | al_hreq.flags, cursor); | 379 | al_hreq.flags, cursor); |
381 | if (error) | 380 | if (error) |
382 | goto out_kfree; | 381 | goto out_kfree; |
@@ -404,10 +403,10 @@ xfs_compat_attrmulti_by_handle( | |||
404 | unsigned char *attr_name; | 403 | unsigned char *attr_name; |
405 | 404 | ||
406 | if (!capable(CAP_SYS_ADMIN)) | 405 | if (!capable(CAP_SYS_ADMIN)) |
407 | return -XFS_ERROR(EPERM); | 406 | return -EPERM; |
408 | if (copy_from_user(&am_hreq, arg, | 407 | if (copy_from_user(&am_hreq, arg, |
409 | sizeof(compat_xfs_fsop_attrmulti_handlereq_t))) | 408 | sizeof(compat_xfs_fsop_attrmulti_handlereq_t))) |
410 | return -XFS_ERROR(EFAULT); | 409 | return -EFAULT; |
411 | 410 | ||
412 | /* overflow check */ | 411 | /* overflow check */ |
413 | if (am_hreq.opcount >= INT_MAX / sizeof(compat_xfs_attr_multiop_t)) | 412 | if (am_hreq.opcount >= INT_MAX / sizeof(compat_xfs_attr_multiop_t)) |
@@ -417,7 +416,7 @@ xfs_compat_attrmulti_by_handle( | |||
417 | if (IS_ERR(dentry)) | 416 | if (IS_ERR(dentry)) |
418 | return PTR_ERR(dentry); | 417 | return PTR_ERR(dentry); |
419 | 418 | ||
420 | error = E2BIG; | 419 | error = -E2BIG; |
421 | size = am_hreq.opcount * sizeof(compat_xfs_attr_multiop_t); | 420 | size = am_hreq.opcount * sizeof(compat_xfs_attr_multiop_t); |
422 | if (!size || size > 16 * PAGE_SIZE) | 421 | if (!size || size > 16 * PAGE_SIZE) |
423 | goto out_dput; | 422 | goto out_dput; |
@@ -428,7 +427,7 @@ xfs_compat_attrmulti_by_handle( | |||
428 | goto out_dput; | 427 | goto out_dput; |
429 | } | 428 | } |
430 | 429 | ||
431 | error = ENOMEM; | 430 | error = -ENOMEM; |
432 | attr_name = kmalloc(MAXNAMELEN, GFP_KERNEL); | 431 | attr_name = kmalloc(MAXNAMELEN, GFP_KERNEL); |
433 | if (!attr_name) | 432 | if (!attr_name) |
434 | goto out_kfree_ops; | 433 | goto out_kfree_ops; |
@@ -439,7 +438,7 @@ xfs_compat_attrmulti_by_handle( | |||
439 | compat_ptr(ops[i].am_attrname), | 438 | compat_ptr(ops[i].am_attrname), |
440 | MAXNAMELEN); | 439 | MAXNAMELEN); |
441 | if (ops[i].am_error == 0 || ops[i].am_error == MAXNAMELEN) | 440 | if (ops[i].am_error == 0 || ops[i].am_error == MAXNAMELEN) |
442 | error = ERANGE; | 441 | error = -ERANGE; |
443 | if (ops[i].am_error < 0) | 442 | if (ops[i].am_error < 0) |
444 | break; | 443 | break; |
445 | 444 | ||
@@ -470,19 +469,19 @@ xfs_compat_attrmulti_by_handle( | |||
470 | mnt_drop_write_file(parfilp); | 469 | mnt_drop_write_file(parfilp); |
471 | break; | 470 | break; |
472 | default: | 471 | default: |
473 | ops[i].am_error = EINVAL; | 472 | ops[i].am_error = -EINVAL; |
474 | } | 473 | } |
475 | } | 474 | } |
476 | 475 | ||
477 | if (copy_to_user(compat_ptr(am_hreq.ops), ops, size)) | 476 | if (copy_to_user(compat_ptr(am_hreq.ops), ops, size)) |
478 | error = XFS_ERROR(EFAULT); | 477 | error = -EFAULT; |
479 | 478 | ||
480 | kfree(attr_name); | 479 | kfree(attr_name); |
481 | out_kfree_ops: | 480 | out_kfree_ops: |
482 | kfree(ops); | 481 | kfree(ops); |
483 | out_dput: | 482 | out_dput: |
484 | dput(dentry); | 483 | dput(dentry); |
485 | return -error; | 484 | return error; |
486 | } | 485 | } |
487 | 486 | ||
488 | STATIC int | 487 | STATIC int |
@@ -496,26 +495,26 @@ xfs_compat_fssetdm_by_handle( | |||
496 | struct dentry *dentry; | 495 | struct dentry *dentry; |
497 | 496 | ||
498 | if (!capable(CAP_MKNOD)) | 497 | if (!capable(CAP_MKNOD)) |
499 | return -XFS_ERROR(EPERM); | 498 | return -EPERM; |
500 | if (copy_from_user(&dmhreq, arg, | 499 | if (copy_from_user(&dmhreq, arg, |
501 | sizeof(compat_xfs_fsop_setdm_handlereq_t))) | 500 | sizeof(compat_xfs_fsop_setdm_handlereq_t))) |
502 | return -XFS_ERROR(EFAULT); | 501 | return -EFAULT; |
503 | 502 | ||
504 | dentry = xfs_compat_handlereq_to_dentry(parfilp, &dmhreq.hreq); | 503 | dentry = xfs_compat_handlereq_to_dentry(parfilp, &dmhreq.hreq); |
505 | if (IS_ERR(dentry)) | 504 | if (IS_ERR(dentry)) |
506 | return PTR_ERR(dentry); | 505 | return PTR_ERR(dentry); |
507 | 506 | ||
508 | if (IS_IMMUTABLE(dentry->d_inode) || IS_APPEND(dentry->d_inode)) { | 507 | if (IS_IMMUTABLE(dentry->d_inode) || IS_APPEND(dentry->d_inode)) { |
509 | error = -XFS_ERROR(EPERM); | 508 | error = -EPERM; |
510 | goto out; | 509 | goto out; |
511 | } | 510 | } |
512 | 511 | ||
513 | if (copy_from_user(&fsd, compat_ptr(dmhreq.data), sizeof(fsd))) { | 512 | if (copy_from_user(&fsd, compat_ptr(dmhreq.data), sizeof(fsd))) { |
514 | error = -XFS_ERROR(EFAULT); | 513 | error = -EFAULT; |
515 | goto out; | 514 | goto out; |
516 | } | 515 | } |
517 | 516 | ||
518 | error = -xfs_set_dmattrs(XFS_I(dentry->d_inode), fsd.fsd_dmevmask, | 517 | error = xfs_set_dmattrs(XFS_I(dentry->d_inode), fsd.fsd_dmevmask, |
519 | fsd.fsd_dmstate); | 518 | fsd.fsd_dmstate); |
520 | 519 | ||
521 | out: | 520 | out: |
@@ -537,7 +536,7 @@ xfs_file_compat_ioctl( | |||
537 | int error; | 536 | int error; |
538 | 537 | ||
539 | if (filp->f_mode & FMODE_NOCMTIME) | 538 | if (filp->f_mode & FMODE_NOCMTIME) |
540 | ioflags |= IO_INVIS; | 539 | ioflags |= XFS_IO_INVIS; |
541 | 540 | ||
542 | trace_xfs_file_compat_ioctl(ip); | 541 | trace_xfs_file_compat_ioctl(ip); |
543 | 542 | ||
@@ -588,7 +587,7 @@ xfs_file_compat_ioctl( | |||
588 | struct xfs_flock64 bf; | 587 | struct xfs_flock64 bf; |
589 | 588 | ||
590 | if (xfs_compat_flock64_copyin(&bf, arg)) | 589 | if (xfs_compat_flock64_copyin(&bf, arg)) |
591 | return -XFS_ERROR(EFAULT); | 590 | return -EFAULT; |
592 | cmd = _NATIVE_IOC(cmd, struct xfs_flock64); | 591 | cmd = _NATIVE_IOC(cmd, struct xfs_flock64); |
593 | return xfs_ioc_space(ip, inode, filp, ioflags, cmd, &bf); | 592 | return xfs_ioc_space(ip, inode, filp, ioflags, cmd, &bf); |
594 | } | 593 | } |
@@ -598,25 +597,25 @@ xfs_file_compat_ioctl( | |||
598 | struct xfs_growfs_data in; | 597 | struct xfs_growfs_data in; |
599 | 598 | ||
600 | if (xfs_compat_growfs_data_copyin(&in, arg)) | 599 | if (xfs_compat_growfs_data_copyin(&in, arg)) |
601 | return -XFS_ERROR(EFAULT); | 600 | return -EFAULT; |
602 | error = mnt_want_write_file(filp); | 601 | error = mnt_want_write_file(filp); |
603 | if (error) | 602 | if (error) |
604 | return error; | 603 | return error; |
605 | error = xfs_growfs_data(mp, &in); | 604 | error = xfs_growfs_data(mp, &in); |
606 | mnt_drop_write_file(filp); | 605 | mnt_drop_write_file(filp); |
607 | return -error; | 606 | return error; |
608 | } | 607 | } |
609 | case XFS_IOC_FSGROWFSRT_32: { | 608 | case XFS_IOC_FSGROWFSRT_32: { |
610 | struct xfs_growfs_rt in; | 609 | struct xfs_growfs_rt in; |
611 | 610 | ||
612 | if (xfs_compat_growfs_rt_copyin(&in, arg)) | 611 | if (xfs_compat_growfs_rt_copyin(&in, arg)) |
613 | return -XFS_ERROR(EFAULT); | 612 | return -EFAULT; |
614 | error = mnt_want_write_file(filp); | 613 | error = mnt_want_write_file(filp); |
615 | if (error) | 614 | if (error) |
616 | return error; | 615 | return error; |
617 | error = xfs_growfs_rt(mp, &in); | 616 | error = xfs_growfs_rt(mp, &in); |
618 | mnt_drop_write_file(filp); | 617 | mnt_drop_write_file(filp); |
619 | return -error; | 618 | return error; |
620 | } | 619 | } |
621 | #endif | 620 | #endif |
622 | /* long changes size, but xfs only copiese out 32 bits */ | 621 | /* long changes size, but xfs only copiese out 32 bits */ |
@@ -633,13 +632,13 @@ xfs_file_compat_ioctl( | |||
633 | if (copy_from_user(&sxp, sxu, | 632 | if (copy_from_user(&sxp, sxu, |
634 | offsetof(struct xfs_swapext, sx_stat)) || | 633 | offsetof(struct xfs_swapext, sx_stat)) || |
635 | xfs_ioctl32_bstat_copyin(&sxp.sx_stat, &sxu->sx_stat)) | 634 | xfs_ioctl32_bstat_copyin(&sxp.sx_stat, &sxu->sx_stat)) |
636 | return -XFS_ERROR(EFAULT); | 635 | return -EFAULT; |
637 | error = mnt_want_write_file(filp); | 636 | error = mnt_want_write_file(filp); |
638 | if (error) | 637 | if (error) |
639 | return error; | 638 | return error; |
640 | error = xfs_ioc_swapext(&sxp); | 639 | error = xfs_ioc_swapext(&sxp); |
641 | mnt_drop_write_file(filp); | 640 | mnt_drop_write_file(filp); |
642 | return -error; | 641 | return error; |
643 | } | 642 | } |
644 | case XFS_IOC_FSBULKSTAT_32: | 643 | case XFS_IOC_FSBULKSTAT_32: |
645 | case XFS_IOC_FSBULKSTAT_SINGLE_32: | 644 | case XFS_IOC_FSBULKSTAT_SINGLE_32: |
@@ -651,7 +650,7 @@ xfs_file_compat_ioctl( | |||
651 | struct xfs_fsop_handlereq hreq; | 650 | struct xfs_fsop_handlereq hreq; |
652 | 651 | ||
653 | if (xfs_compat_handlereq_copyin(&hreq, arg)) | 652 | if (xfs_compat_handlereq_copyin(&hreq, arg)) |
654 | return -XFS_ERROR(EFAULT); | 653 | return -EFAULT; |
655 | cmd = _NATIVE_IOC(cmd, struct xfs_fsop_handlereq); | 654 | cmd = _NATIVE_IOC(cmd, struct xfs_fsop_handlereq); |
656 | return xfs_find_handle(cmd, &hreq); | 655 | return xfs_find_handle(cmd, &hreq); |
657 | } | 656 | } |
@@ -659,14 +658,14 @@ xfs_file_compat_ioctl( | |||
659 | struct xfs_fsop_handlereq hreq; | 658 | struct xfs_fsop_handlereq hreq; |
660 | 659 | ||
661 | if (xfs_compat_handlereq_copyin(&hreq, arg)) | 660 | if (xfs_compat_handlereq_copyin(&hreq, arg)) |
662 | return -XFS_ERROR(EFAULT); | 661 | return -EFAULT; |
663 | return xfs_open_by_handle(filp, &hreq); | 662 | return xfs_open_by_handle(filp, &hreq); |
664 | } | 663 | } |
665 | case XFS_IOC_READLINK_BY_HANDLE_32: { | 664 | case XFS_IOC_READLINK_BY_HANDLE_32: { |
666 | struct xfs_fsop_handlereq hreq; | 665 | struct xfs_fsop_handlereq hreq; |
667 | 666 | ||
668 | if (xfs_compat_handlereq_copyin(&hreq, arg)) | 667 | if (xfs_compat_handlereq_copyin(&hreq, arg)) |
669 | return -XFS_ERROR(EFAULT); | 668 | return -EFAULT; |
670 | return xfs_readlink_by_handle(filp, &hreq); | 669 | return xfs_readlink_by_handle(filp, &hreq); |
671 | } | 670 | } |
672 | case XFS_IOC_ATTRLIST_BY_HANDLE_32: | 671 | case XFS_IOC_ATTRLIST_BY_HANDLE_32: |
@@ -676,6 +675,6 @@ xfs_file_compat_ioctl( | |||
676 | case XFS_IOC_FSSETDM_BY_HANDLE_32: | 675 | case XFS_IOC_FSSETDM_BY_HANDLE_32: |
677 | return xfs_compat_fssetdm_by_handle(filp, arg); | 676 | return xfs_compat_fssetdm_by_handle(filp, arg); |
678 | default: | 677 | default: |
679 | return -XFS_ERROR(ENOIOCTLCMD); | 678 | return -ENOIOCTLCMD; |
680 | } | 679 | } |
681 | } | 680 | } |
diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c index 6d3ec2b6ee29..e9c47b6f5e5a 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 | ||
116 | int | 116 | int |
@@ -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 | ||
@@ -397,7 +397,8 @@ xfs_quota_calc_throttle( | |||
397 | struct xfs_inode *ip, | 397 | struct xfs_inode *ip, |
398 | int type, | 398 | int type, |
399 | xfs_fsblock_t *qblocks, | 399 | xfs_fsblock_t *qblocks, |
400 | int *qshift) | 400 | int *qshift, |
401 | int64_t *qfreesp) | ||
401 | { | 402 | { |
402 | int64_t freesp; | 403 | int64_t freesp; |
403 | int shift = 0; | 404 | int shift = 0; |
@@ -406,6 +407,7 @@ xfs_quota_calc_throttle( | |||
406 | /* over hi wmark, squash the prealloc completely */ | 407 | /* over hi wmark, squash the prealloc completely */ |
407 | if (dq->q_res_bcount >= dq->q_prealloc_hi_wmark) { | 408 | if (dq->q_res_bcount >= dq->q_prealloc_hi_wmark) { |
408 | *qblocks = 0; | 409 | *qblocks = 0; |
410 | *qfreesp = 0; | ||
409 | return; | 411 | return; |
410 | } | 412 | } |
411 | 413 | ||
@@ -418,6 +420,9 @@ xfs_quota_calc_throttle( | |||
418 | shift += 2; | 420 | shift += 2; |
419 | } | 421 | } |
420 | 422 | ||
423 | if (freesp < *qfreesp) | ||
424 | *qfreesp = freesp; | ||
425 | |||
421 | /* only overwrite the throttle values if we are more aggressive */ | 426 | /* only overwrite the throttle values if we are more aggressive */ |
422 | if ((freesp >> shift) < (*qblocks >> *qshift)) { | 427 | if ((freesp >> shift) < (*qblocks >> *qshift)) { |
423 | *qblocks = freesp; | 428 | *qblocks = freesp; |
@@ -476,15 +481,18 @@ xfs_iomap_prealloc_size( | |||
476 | } | 481 | } |
477 | 482 | ||
478 | /* | 483 | /* |
479 | * Check each quota to cap the prealloc size and provide a shift | 484 | * Check each quota to cap the prealloc size, provide a shift value to |
480 | * value to throttle with. | 485 | * throttle with and adjust amount of available space. |
481 | */ | 486 | */ |
482 | if (xfs_quota_need_throttle(ip, XFS_DQ_USER, alloc_blocks)) | 487 | if (xfs_quota_need_throttle(ip, XFS_DQ_USER, alloc_blocks)) |
483 | xfs_quota_calc_throttle(ip, XFS_DQ_USER, &qblocks, &qshift); | 488 | xfs_quota_calc_throttle(ip, XFS_DQ_USER, &qblocks, &qshift, |
489 | &freesp); | ||
484 | if (xfs_quota_need_throttle(ip, XFS_DQ_GROUP, alloc_blocks)) | 490 | if (xfs_quota_need_throttle(ip, XFS_DQ_GROUP, alloc_blocks)) |
485 | xfs_quota_calc_throttle(ip, XFS_DQ_GROUP, &qblocks, &qshift); | 491 | xfs_quota_calc_throttle(ip, XFS_DQ_GROUP, &qblocks, &qshift, |
492 | &freesp); | ||
486 | if (xfs_quota_need_throttle(ip, XFS_DQ_PROJ, alloc_blocks)) | 493 | if (xfs_quota_need_throttle(ip, XFS_DQ_PROJ, alloc_blocks)) |
487 | xfs_quota_calc_throttle(ip, XFS_DQ_PROJ, &qblocks, &qshift); | 494 | xfs_quota_calc_throttle(ip, XFS_DQ_PROJ, &qblocks, &qshift, |
495 | &freesp); | ||
488 | 496 | ||
489 | /* | 497 | /* |
490 | * The final prealloc size is set to the minimum of free space available | 498 | * The final prealloc size is set to the minimum of free space available |
@@ -552,7 +560,7 @@ xfs_iomap_write_delay( | |||
552 | */ | 560 | */ |
553 | error = xfs_qm_dqattach_locked(ip, 0); | 561 | error = xfs_qm_dqattach_locked(ip, 0); |
554 | if (error) | 562 | if (error) |
555 | return XFS_ERROR(error); | 563 | return error; |
556 | 564 | ||
557 | extsz = xfs_get_extsz_hint(ip); | 565 | extsz = xfs_get_extsz_hint(ip); |
558 | offset_fsb = XFS_B_TO_FSBT(mp, offset); | 566 | offset_fsb = XFS_B_TO_FSBT(mp, offset); |
@@ -596,11 +604,11 @@ retry: | |||
596 | imap, &nimaps, XFS_BMAPI_ENTIRE); | 604 | imap, &nimaps, XFS_BMAPI_ENTIRE); |
597 | switch (error) { | 605 | switch (error) { |
598 | case 0: | 606 | case 0: |
599 | case ENOSPC: | 607 | case -ENOSPC: |
600 | case EDQUOT: | 608 | case -EDQUOT: |
601 | break; | 609 | break; |
602 | default: | 610 | default: |
603 | return XFS_ERROR(error); | 611 | return error; |
604 | } | 612 | } |
605 | 613 | ||
606 | /* | 614 | /* |
@@ -614,7 +622,7 @@ retry: | |||
614 | error = 0; | 622 | error = 0; |
615 | goto retry; | 623 | goto retry; |
616 | } | 624 | } |
617 | return XFS_ERROR(error ? error : ENOSPC); | 625 | return error ? error : -ENOSPC; |
618 | } | 626 | } |
619 | 627 | ||
620 | if (!(imap[0].br_startblock || XFS_IS_REALTIME_INODE(ip))) | 628 | if (!(imap[0].br_startblock || XFS_IS_REALTIME_INODE(ip))) |
@@ -663,7 +671,7 @@ xfs_iomap_write_allocate( | |||
663 | */ | 671 | */ |
664 | error = xfs_qm_dqattach(ip, 0); | 672 | error = xfs_qm_dqattach(ip, 0); |
665 | if (error) | 673 | if (error) |
666 | return XFS_ERROR(error); | 674 | return error; |
667 | 675 | ||
668 | offset_fsb = XFS_B_TO_FSBT(mp, offset); | 676 | offset_fsb = XFS_B_TO_FSBT(mp, offset); |
669 | count_fsb = imap->br_blockcount; | 677 | count_fsb = imap->br_blockcount; |
@@ -690,7 +698,7 @@ xfs_iomap_write_allocate( | |||
690 | nres, 0); | 698 | nres, 0); |
691 | if (error) { | 699 | if (error) { |
692 | xfs_trans_cancel(tp, 0); | 700 | xfs_trans_cancel(tp, 0); |
693 | return XFS_ERROR(error); | 701 | return error; |
694 | } | 702 | } |
695 | xfs_ilock(ip, XFS_ILOCK_EXCL); | 703 | xfs_ilock(ip, XFS_ILOCK_EXCL); |
696 | xfs_trans_ijoin(tp, ip, 0); | 704 | xfs_trans_ijoin(tp, ip, 0); |
@@ -739,7 +747,7 @@ xfs_iomap_write_allocate( | |||
739 | if ((map_start_fsb + count_fsb) > last_block) { | 747 | if ((map_start_fsb + count_fsb) > last_block) { |
740 | count_fsb = last_block - map_start_fsb; | 748 | count_fsb = last_block - map_start_fsb; |
741 | if (count_fsb == 0) { | 749 | if (count_fsb == 0) { |
742 | error = EAGAIN; | 750 | error = -EAGAIN; |
743 | goto trans_cancel; | 751 | goto trans_cancel; |
744 | } | 752 | } |
745 | } | 753 | } |
@@ -793,7 +801,7 @@ trans_cancel: | |||
793 | xfs_trans_cancel(tp, XFS_TRANS_RELEASE_LOG_RES | XFS_TRANS_ABORT); | 801 | xfs_trans_cancel(tp, XFS_TRANS_RELEASE_LOG_RES | XFS_TRANS_ABORT); |
794 | error0: | 802 | error0: |
795 | xfs_iunlock(ip, XFS_ILOCK_EXCL); | 803 | xfs_iunlock(ip, XFS_ILOCK_EXCL); |
796 | return XFS_ERROR(error); | 804 | return error; |
797 | } | 805 | } |
798 | 806 | ||
799 | int | 807 | int |
@@ -853,7 +861,7 @@ xfs_iomap_write_unwritten( | |||
853 | resblks, 0); | 861 | resblks, 0); |
854 | if (error) { | 862 | if (error) { |
855 | xfs_trans_cancel(tp, 0); | 863 | xfs_trans_cancel(tp, 0); |
856 | return XFS_ERROR(error); | 864 | return error; |
857 | } | 865 | } |
858 | 866 | ||
859 | xfs_ilock(ip, XFS_ILOCK_EXCL); | 867 | xfs_ilock(ip, XFS_ILOCK_EXCL); |
@@ -892,7 +900,7 @@ xfs_iomap_write_unwritten( | |||
892 | error = xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES); | 900 | error = xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES); |
893 | xfs_iunlock(ip, XFS_ILOCK_EXCL); | 901 | xfs_iunlock(ip, XFS_ILOCK_EXCL); |
894 | if (error) | 902 | if (error) |
895 | return XFS_ERROR(error); | 903 | return error; |
896 | 904 | ||
897 | if (!(imap.br_startblock || XFS_IS_REALTIME_INODE(ip))) | 905 | if (!(imap.br_startblock || XFS_IS_REALTIME_INODE(ip))) |
898 | return xfs_alert_fsblock_zero(ip, &imap); | 906 | return xfs_alert_fsblock_zero(ip, &imap); |
@@ -915,5 +923,5 @@ error_on_bmapi_transaction: | |||
915 | xfs_bmap_cancel(&free_list); | 923 | xfs_bmap_cancel(&free_list); |
916 | xfs_trans_cancel(tp, (XFS_TRANS_RELEASE_LOG_RES | XFS_TRANS_ABORT)); | 924 | xfs_trans_cancel(tp, (XFS_TRANS_RELEASE_LOG_RES | XFS_TRANS_ABORT)); |
917 | xfs_iunlock(ip, XFS_ILOCK_EXCL); | 925 | xfs_iunlock(ip, XFS_ILOCK_EXCL); |
918 | return XFS_ERROR(error); | 926 | return error; |
919 | } | 927 | } |
diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c index 205613a06068..72129493e9d3 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 | ||
381 | STATIC int | 381 | STATIC 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 | ||
956 | STATIC int | 956 | STATIC 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 | ||
1042 | STATIC int | 1042 | STATIC int |
@@ -1055,12 +1055,12 @@ xfs_vn_fiemap( | |||
1055 | return error; | 1055 | return error; |
1056 | 1056 | ||
1057 | /* Set up bmap header for xfs internal routine */ | 1057 | /* Set up bmap header for xfs internal routine */ |
1058 | bm.bmv_offset = BTOBB(start); | 1058 | bm.bmv_offset = BTOBBT(start); |
1059 | /* Special case for whole file */ | 1059 | /* Special case for whole file */ |
1060 | if (length == FIEMAP_MAX_OFFSET) | 1060 | if (length == FIEMAP_MAX_OFFSET) |
1061 | bm.bmv_length = -1LL; | 1061 | bm.bmv_length = -1LL; |
1062 | else | 1062 | else |
1063 | bm.bmv_length = BTOBB(length); | 1063 | bm.bmv_length = BTOBB(start + length) - bm.bmv_offset; |
1064 | 1064 | ||
1065 | /* We add one because in getbmap world count includes the header */ | 1065 | /* We add one because in getbmap world count includes the header */ |
1066 | bm.bmv_count = !fieinfo->fi_extents_max ? MAXEXTNUM : | 1066 | bm.bmv_count = !fieinfo->fi_extents_max ? MAXEXTNUM : |
@@ -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..f71be9c68017 100644 --- a/fs/xfs/xfs_itable.c +++ b/fs/xfs/xfs_itable.c | |||
@@ -67,19 +67,17 @@ 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), |
78 | XFS_ILOCK_SHARED, &ip); | 78 | XFS_ILOCK_SHARED, &ip); |
79 | if (error) { | 79 | if (error) |
80 | *stat = BULKSTAT_RV_NOTHING; | ||
81 | goto out_free; | 80 | goto out_free; |
82 | } | ||
83 | 81 | ||
84 | ASSERT(ip != NULL); | 82 | ASSERT(ip != NULL); |
85 | ASSERT(ip->i_imap.im_blkno != 0); | 83 | ASSERT(ip->i_imap.im_blkno != 0); |
@@ -136,7 +134,6 @@ xfs_bulkstat_one_int( | |||
136 | IRELE(ip); | 134 | IRELE(ip); |
137 | 135 | ||
138 | error = formatter(buffer, ubsize, ubused, buf); | 136 | error = formatter(buffer, ubsize, ubused, buf); |
139 | |||
140 | if (!error) | 137 | if (!error) |
141 | *stat = BULKSTAT_RV_DIDONE; | 138 | *stat = BULKSTAT_RV_DIDONE; |
142 | 139 | ||
@@ -154,9 +151,9 @@ xfs_bulkstat_one_fmt( | |||
154 | const xfs_bstat_t *buffer) | 151 | const xfs_bstat_t *buffer) |
155 | { | 152 | { |
156 | if (ubsize < sizeof(*buffer)) | 153 | if (ubsize < sizeof(*buffer)) |
157 | return XFS_ERROR(ENOMEM); | 154 | return -ENOMEM; |
158 | if (copy_to_user(ubuffer, buffer, sizeof(*buffer))) | 155 | if (copy_to_user(ubuffer, buffer, sizeof(*buffer))) |
159 | return XFS_ERROR(EFAULT); | 156 | return -EFAULT; |
160 | if (ubused) | 157 | if (ubused) |
161 | *ubused = sizeof(*buffer); | 158 | *ubused = sizeof(*buffer); |
162 | return 0; | 159 | return 0; |
@@ -175,9 +172,170 @@ xfs_bulkstat_one( | |||
175 | xfs_bulkstat_one_fmt, ubused, stat); | 172 | xfs_bulkstat_one_fmt, ubused, stat); |
176 | } | 173 | } |
177 | 174 | ||
175 | /* | ||
176 | * Loop over all clusters in a chunk for a given incore inode allocation btree | ||
177 | * record. Do a readahead if there are any allocated inodes in that cluster. | ||
178 | */ | ||
179 | STATIC void | ||
180 | xfs_bulkstat_ichunk_ra( | ||
181 | struct xfs_mount *mp, | ||
182 | xfs_agnumber_t agno, | ||
183 | struct xfs_inobt_rec_incore *irec) | ||
184 | { | ||
185 | xfs_agblock_t agbno; | ||
186 | struct blk_plug plug; | ||
187 | int blks_per_cluster; | ||
188 | int inodes_per_cluster; | ||
189 | int i; /* inode chunk index */ | ||
190 | |||
191 | agbno = XFS_AGINO_TO_AGBNO(mp, irec->ir_startino); | ||
192 | blks_per_cluster = xfs_icluster_size_fsb(mp); | ||
193 | inodes_per_cluster = blks_per_cluster << mp->m_sb.sb_inopblog; | ||
194 | |||
195 | blk_start_plug(&plug); | ||
196 | for (i = 0; i < XFS_INODES_PER_CHUNK; | ||
197 | i += inodes_per_cluster, agbno += blks_per_cluster) { | ||
198 | if (xfs_inobt_maskn(i, inodes_per_cluster) & ~irec->ir_free) { | ||
199 | xfs_btree_reada_bufs(mp, agno, agbno, blks_per_cluster, | ||
200 | &xfs_inode_buf_ops); | ||
201 | } | ||
202 | } | ||
203 | blk_finish_plug(&plug); | ||
204 | } | ||
205 | |||
206 | /* | ||
207 | * Lookup the inode chunk that the given inode lives in and then get the record | ||
208 | * if we found the chunk. If the inode was not the last in the chunk and there | ||
209 | * are some left allocated, update the data for the pointed-to record as well as | ||
210 | * return the count of grabbed inodes. | ||
211 | */ | ||
212 | STATIC int | ||
213 | xfs_bulkstat_grab_ichunk( | ||
214 | struct xfs_btree_cur *cur, /* btree cursor */ | ||
215 | xfs_agino_t agino, /* starting inode of chunk */ | ||
216 | int *icount,/* return # of inodes grabbed */ | ||
217 | struct xfs_inobt_rec_incore *irec) /* btree record */ | ||
218 | { | ||
219 | int idx; /* index into inode chunk */ | ||
220 | int stat; | ||
221 | int error = 0; | ||
222 | |||
223 | /* Lookup the inode chunk that this inode lives in */ | ||
224 | error = xfs_inobt_lookup(cur, agino, XFS_LOOKUP_LE, &stat); | ||
225 | if (error) | ||
226 | return error; | ||
227 | if (!stat) { | ||
228 | *icount = 0; | ||
229 | return error; | ||
230 | } | ||
231 | |||
232 | /* Get the record, should always work */ | ||
233 | error = xfs_inobt_get_rec(cur, irec, &stat); | ||
234 | if (error) | ||
235 | return error; | ||
236 | XFS_WANT_CORRUPTED_RETURN(stat == 1); | ||
237 | |||
238 | /* Check if the record contains the inode in request */ | ||
239 | if (irec->ir_startino + XFS_INODES_PER_CHUNK <= agino) | ||
240 | return -EINVAL; | ||
241 | |||
242 | idx = agino - irec->ir_startino + 1; | ||
243 | if (idx < XFS_INODES_PER_CHUNK && | ||
244 | (xfs_inobt_maskn(idx, XFS_INODES_PER_CHUNK - idx) & ~irec->ir_free)) { | ||
245 | int i; | ||
246 | |||
247 | /* We got a right chunk with some left inodes allocated at it. | ||
248 | * Grab the chunk record. Mark all the uninteresting inodes | ||
249 | * free -- because they're before our start point. | ||
250 | */ | ||
251 | for (i = 0; i < idx; i++) { | ||
252 | if (XFS_INOBT_MASK(i) & ~irec->ir_free) | ||
253 | irec->ir_freecount++; | ||
254 | } | ||
255 | |||
256 | irec->ir_free |= xfs_inobt_maskn(0, idx); | ||
257 | *icount = XFS_INODES_PER_CHUNK - irec->ir_freecount; | ||
258 | } | ||
259 | |||
260 | return 0; | ||
261 | } | ||
262 | |||
178 | #define XFS_BULKSTAT_UBLEFT(ubleft) ((ubleft) >= statstruct_size) | 263 | #define XFS_BULKSTAT_UBLEFT(ubleft) ((ubleft) >= statstruct_size) |
179 | 264 | ||
180 | /* | 265 | /* |
266 | * Process inodes in chunk with a pointer to a formatter function | ||
267 | * that will iget the inode and fill in the appropriate structure. | ||
268 | */ | ||
269 | int | ||
270 | xfs_bulkstat_ag_ichunk( | ||
271 | struct xfs_mount *mp, | ||
272 | xfs_agnumber_t agno, | ||
273 | struct xfs_inobt_rec_incore *irbp, | ||
274 | bulkstat_one_pf formatter, | ||
275 | size_t statstruct_size, | ||
276 | struct xfs_bulkstat_agichunk *acp) | ||
277 | { | ||
278 | xfs_ino_t lastino = acp->ac_lastino; | ||
279 | char __user **ubufp = acp->ac_ubuffer; | ||
280 | int ubleft = acp->ac_ubleft; | ||
281 | int ubelem = acp->ac_ubelem; | ||
282 | int chunkidx, clustidx; | ||
283 | int error = 0; | ||
284 | xfs_agino_t agino; | ||
285 | |||
286 | for (agino = irbp->ir_startino, chunkidx = clustidx = 0; | ||
287 | XFS_BULKSTAT_UBLEFT(ubleft) && | ||
288 | irbp->ir_freecount < XFS_INODES_PER_CHUNK; | ||
289 | chunkidx++, clustidx++, agino++) { | ||
290 | int fmterror; /* bulkstat formatter result */ | ||
291 | int ubused; | ||
292 | xfs_ino_t ino = XFS_AGINO_TO_INO(mp, agno, agino); | ||
293 | |||
294 | ASSERT(chunkidx < XFS_INODES_PER_CHUNK); | ||
295 | |||
296 | /* Skip if this inode is free */ | ||
297 | if (XFS_INOBT_MASK(chunkidx) & irbp->ir_free) { | ||
298 | lastino = ino; | ||
299 | continue; | ||
300 | } | ||
301 | |||
302 | /* | ||
303 | * Count used inodes as free so we can tell when the | ||
304 | * chunk is used up. | ||
305 | */ | ||
306 | irbp->ir_freecount++; | ||
307 | |||
308 | /* Get the inode and fill in a single buffer */ | ||
309 | ubused = statstruct_size; | ||
310 | error = formatter(mp, ino, *ubufp, ubleft, &ubused, &fmterror); | ||
311 | if (fmterror == BULKSTAT_RV_NOTHING) { | ||
312 | if (error && error != -ENOENT && error != -EINVAL) { | ||
313 | ubleft = 0; | ||
314 | break; | ||
315 | } | ||
316 | lastino = ino; | ||
317 | continue; | ||
318 | } | ||
319 | if (fmterror == BULKSTAT_RV_GIVEUP) { | ||
320 | ubleft = 0; | ||
321 | ASSERT(error); | ||
322 | break; | ||
323 | } | ||
324 | if (*ubufp) | ||
325 | *ubufp += ubused; | ||
326 | ubleft -= ubused; | ||
327 | ubelem++; | ||
328 | lastino = ino; | ||
329 | } | ||
330 | |||
331 | acp->ac_lastino = lastino; | ||
332 | acp->ac_ubleft = ubleft; | ||
333 | acp->ac_ubelem = ubelem; | ||
334 | |||
335 | return error; | ||
336 | } | ||
337 | |||
338 | /* | ||
181 | * Return stat information in bulk (by-inode) for the filesystem. | 339 | * Return stat information in bulk (by-inode) for the filesystem. |
182 | */ | 340 | */ |
183 | int /* error status */ | 341 | int /* error status */ |
@@ -190,13 +348,10 @@ xfs_bulkstat( | |||
190 | char __user *ubuffer, /* buffer with inode stats */ | 348 | char __user *ubuffer, /* buffer with inode stats */ |
191 | int *done) /* 1 if there are more stats to get */ | 349 | int *done) /* 1 if there are more stats to get */ |
192 | { | 350 | { |
193 | xfs_agblock_t agbno=0;/* allocation group block number */ | ||
194 | xfs_buf_t *agbp; /* agi header buffer */ | 351 | xfs_buf_t *agbp; /* agi header buffer */ |
195 | xfs_agi_t *agi; /* agi header data */ | 352 | xfs_agi_t *agi; /* agi header data */ |
196 | xfs_agino_t agino; /* inode # in allocation group */ | 353 | xfs_agino_t agino; /* inode # in allocation group */ |
197 | xfs_agnumber_t agno; /* allocation group number */ | 354 | xfs_agnumber_t agno; /* allocation group number */ |
198 | int chunkidx; /* current index into inode chunk */ | ||
199 | int clustidx; /* current index into inode cluster */ | ||
200 | xfs_btree_cur_t *cur; /* btree cursor for ialloc btree */ | 355 | xfs_btree_cur_t *cur; /* btree cursor for ialloc btree */ |
201 | int end_of_ag; /* set if we've seen the ag end */ | 356 | int end_of_ag; /* set if we've seen the ag end */ |
202 | int error; /* error code */ | 357 | int error; /* error code */ |
@@ -209,8 +364,6 @@ xfs_bulkstat( | |||
209 | xfs_inobt_rec_incore_t *irbuf; /* start of irec buffer */ | 364 | xfs_inobt_rec_incore_t *irbuf; /* start of irec buffer */ |
210 | xfs_inobt_rec_incore_t *irbufend; /* end of good irec buffer entries */ | 365 | xfs_inobt_rec_incore_t *irbufend; /* end of good irec buffer entries */ |
211 | xfs_ino_t lastino; /* last inode number returned */ | 366 | xfs_ino_t lastino; /* last inode number returned */ |
212 | int blks_per_cluster; /* # of blocks per cluster */ | ||
213 | int inodes_per_cluster;/* # of inodes per cluster */ | ||
214 | int nirbuf; /* size of irbuf */ | 367 | int nirbuf; /* size of irbuf */ |
215 | int rval; /* return value error code */ | 368 | int rval; /* return value error code */ |
216 | int tmp; /* result value from btree calls */ | 369 | int tmp; /* result value from btree calls */ |
@@ -218,7 +371,6 @@ xfs_bulkstat( | |||
218 | int ubleft; /* bytes left in user's buffer */ | 371 | int ubleft; /* bytes left in user's buffer */ |
219 | char __user *ubufp; /* pointer into user's buffer */ | 372 | char __user *ubufp; /* pointer into user's buffer */ |
220 | int ubelem; /* spaces used in user's buffer */ | 373 | int ubelem; /* spaces used in user's buffer */ |
221 | int ubused; /* bytes used by formatter */ | ||
222 | 374 | ||
223 | /* | 375 | /* |
224 | * Get the last inode value, see if there's nothing to do. | 376 | * Get the last inode value, see if there's nothing to do. |
@@ -233,20 +385,16 @@ xfs_bulkstat( | |||
233 | *ubcountp = 0; | 385 | *ubcountp = 0; |
234 | return 0; | 386 | return 0; |
235 | } | 387 | } |
236 | if (!ubcountp || *ubcountp <= 0) { | 388 | |
237 | return EINVAL; | ||
238 | } | ||
239 | ubcount = *ubcountp; /* statstruct's */ | 389 | ubcount = *ubcountp; /* statstruct's */ |
240 | ubleft = ubcount * statstruct_size; /* bytes */ | 390 | ubleft = ubcount * statstruct_size; /* bytes */ |
241 | *ubcountp = ubelem = 0; | 391 | *ubcountp = ubelem = 0; |
242 | *done = 0; | 392 | *done = 0; |
243 | fmterror = 0; | 393 | fmterror = 0; |
244 | ubufp = ubuffer; | 394 | ubufp = ubuffer; |
245 | blks_per_cluster = xfs_icluster_size_fsb(mp); | ||
246 | inodes_per_cluster = blks_per_cluster << mp->m_sb.sb_inopblog; | ||
247 | irbuf = kmem_zalloc_greedy(&irbsize, PAGE_SIZE, PAGE_SIZE * 4); | 395 | irbuf = kmem_zalloc_greedy(&irbsize, PAGE_SIZE, PAGE_SIZE * 4); |
248 | if (!irbuf) | 396 | if (!irbuf) |
249 | return ENOMEM; | 397 | return -ENOMEM; |
250 | 398 | ||
251 | nirbuf = irbsize / sizeof(*irbuf); | 399 | nirbuf = irbsize / sizeof(*irbuf); |
252 | 400 | ||
@@ -258,14 +406,8 @@ xfs_bulkstat( | |||
258 | while (XFS_BULKSTAT_UBLEFT(ubleft) && agno < mp->m_sb.sb_agcount) { | 406 | while (XFS_BULKSTAT_UBLEFT(ubleft) && agno < mp->m_sb.sb_agcount) { |
259 | cond_resched(); | 407 | cond_resched(); |
260 | error = xfs_ialloc_read_agi(mp, NULL, agno, &agbp); | 408 | error = xfs_ialloc_read_agi(mp, NULL, agno, &agbp); |
261 | if (error) { | 409 | if (error) |
262 | /* | 410 | break; |
263 | * Skip this allocation group and go to the next one. | ||
264 | */ | ||
265 | agno++; | ||
266 | agino = 0; | ||
267 | continue; | ||
268 | } | ||
269 | agi = XFS_BUF_TO_AGI(agbp); | 411 | agi = XFS_BUF_TO_AGI(agbp); |
270 | /* | 412 | /* |
271 | * Allocate and initialize a btree cursor for ialloc btree. | 413 | * Allocate and initialize a btree cursor for ialloc btree. |
@@ -275,96 +417,39 @@ xfs_bulkstat( | |||
275 | irbp = irbuf; | 417 | irbp = irbuf; |
276 | irbufend = irbuf + nirbuf; | 418 | irbufend = irbuf + nirbuf; |
277 | end_of_ag = 0; | 419 | end_of_ag = 0; |
278 | /* | 420 | icount = 0; |
279 | * If we're returning in the middle of an allocation group, | ||
280 | * we need to get the remainder of the chunk we're in. | ||
281 | */ | ||
282 | if (agino > 0) { | 421 | if (agino > 0) { |
283 | xfs_inobt_rec_incore_t r; | ||
284 | |||
285 | /* | 422 | /* |
286 | * Lookup the inode chunk that this inode lives in. | 423 | * In the middle of an allocation group, we need to get |
424 | * the remainder of the chunk we're in. | ||
287 | */ | 425 | */ |
288 | error = xfs_inobt_lookup(cur, agino, XFS_LOOKUP_LE, | 426 | struct xfs_inobt_rec_incore r; |
289 | &tmp); | 427 | |
290 | if (!error && /* no I/O error */ | 428 | error = xfs_bulkstat_grab_ichunk(cur, agino, &icount, &r); |
291 | tmp && /* lookup succeeded */ | 429 | if (error) |
292 | /* got the record, should always work */ | 430 | break; |
293 | !(error = xfs_inobt_get_rec(cur, &r, &i)) && | 431 | if (icount) { |
294 | i == 1 && | ||
295 | /* this is the right chunk */ | ||
296 | agino < r.ir_startino + XFS_INODES_PER_CHUNK && | ||
297 | /* lastino was not last in chunk */ | ||
298 | (chunkidx = agino - r.ir_startino + 1) < | ||
299 | XFS_INODES_PER_CHUNK && | ||
300 | /* there are some left allocated */ | ||
301 | xfs_inobt_maskn(chunkidx, | ||
302 | XFS_INODES_PER_CHUNK - chunkidx) & | ||
303 | ~r.ir_free) { | ||
304 | /* | ||
305 | * Grab the chunk record. Mark all the | ||
306 | * uninteresting inodes (because they're | ||
307 | * before our start point) free. | ||
308 | */ | ||
309 | for (i = 0; i < chunkidx; i++) { | ||
310 | if (XFS_INOBT_MASK(i) & ~r.ir_free) | ||
311 | r.ir_freecount++; | ||
312 | } | ||
313 | r.ir_free |= xfs_inobt_maskn(0, chunkidx); | ||
314 | irbp->ir_startino = r.ir_startino; | 432 | irbp->ir_startino = r.ir_startino; |
315 | irbp->ir_freecount = r.ir_freecount; | 433 | irbp->ir_freecount = r.ir_freecount; |
316 | irbp->ir_free = r.ir_free; | 434 | irbp->ir_free = r.ir_free; |
317 | irbp++; | 435 | irbp++; |
318 | agino = r.ir_startino + XFS_INODES_PER_CHUNK; | 436 | agino = r.ir_startino + XFS_INODES_PER_CHUNK; |
319 | icount = XFS_INODES_PER_CHUNK - r.ir_freecount; | ||
320 | } else { | ||
321 | /* | ||
322 | * If any of those tests failed, bump the | ||
323 | * inode number (just in case). | ||
324 | */ | ||
325 | agino++; | ||
326 | icount = 0; | ||
327 | } | 437 | } |
328 | /* | 438 | /* Increment to the next record */ |
329 | * In any case, increment to the next record. | 439 | error = xfs_btree_increment(cur, 0, &tmp); |
330 | */ | ||
331 | if (!error) | ||
332 | error = xfs_btree_increment(cur, 0, &tmp); | ||
333 | } else { | 440 | } else { |
334 | /* | 441 | /* Start of ag. Lookup the first inode chunk */ |
335 | * Start of ag. Lookup the first inode chunk. | ||
336 | */ | ||
337 | error = xfs_inobt_lookup(cur, 0, XFS_LOOKUP_GE, &tmp); | 442 | error = xfs_inobt_lookup(cur, 0, XFS_LOOKUP_GE, &tmp); |
338 | icount = 0; | ||
339 | } | 443 | } |
444 | if (error) | ||
445 | break; | ||
446 | |||
340 | /* | 447 | /* |
341 | * Loop through inode btree records in this ag, | 448 | * Loop through inode btree records in this ag, |
342 | * until we run out of inodes or space in the buffer. | 449 | * until we run out of inodes or space in the buffer. |
343 | */ | 450 | */ |
344 | while (irbp < irbufend && icount < ubcount) { | 451 | while (irbp < irbufend && icount < ubcount) { |
345 | xfs_inobt_rec_incore_t r; | 452 | struct xfs_inobt_rec_incore r; |
346 | |||
347 | /* | ||
348 | * Loop as long as we're unable to read the | ||
349 | * inode btree. | ||
350 | */ | ||
351 | while (error) { | ||
352 | agino += XFS_INODES_PER_CHUNK; | ||
353 | if (XFS_AGINO_TO_AGBNO(mp, agino) >= | ||
354 | be32_to_cpu(agi->agi_length)) | ||
355 | break; | ||
356 | error = xfs_inobt_lookup(cur, agino, | ||
357 | XFS_LOOKUP_GE, &tmp); | ||
358 | cond_resched(); | ||
359 | } | ||
360 | /* | ||
361 | * If ran off the end of the ag either with an error, | ||
362 | * or the normal way, set end and stop collecting. | ||
363 | */ | ||
364 | if (error) { | ||
365 | end_of_ag = 1; | ||
366 | break; | ||
367 | } | ||
368 | 453 | ||
369 | error = xfs_inobt_get_rec(cur, &r, &i); | 454 | error = xfs_inobt_get_rec(cur, &r, &i); |
370 | if (error || i == 0) { | 455 | if (error || i == 0) { |
@@ -377,25 +462,7 @@ xfs_bulkstat( | |||
377 | * Also start read-ahead now for this chunk. | 462 | * Also start read-ahead now for this chunk. |
378 | */ | 463 | */ |
379 | if (r.ir_freecount < XFS_INODES_PER_CHUNK) { | 464 | if (r.ir_freecount < XFS_INODES_PER_CHUNK) { |
380 | struct blk_plug plug; | 465 | xfs_bulkstat_ichunk_ra(mp, agno, &r); |
381 | /* | ||
382 | * Loop over all clusters in the next chunk. | ||
383 | * Do a readahead if there are any allocated | ||
384 | * inodes in that cluster. | ||
385 | */ | ||
386 | blk_start_plug(&plug); | ||
387 | agbno = XFS_AGINO_TO_AGBNO(mp, r.ir_startino); | ||
388 | for (chunkidx = 0; | ||
389 | chunkidx < XFS_INODES_PER_CHUNK; | ||
390 | chunkidx += inodes_per_cluster, | ||
391 | agbno += blks_per_cluster) { | ||
392 | if (xfs_inobt_maskn(chunkidx, | ||
393 | inodes_per_cluster) & ~r.ir_free) | ||
394 | xfs_btree_reada_bufs(mp, agno, | ||
395 | agbno, blks_per_cluster, | ||
396 | &xfs_inode_buf_ops); | ||
397 | } | ||
398 | blk_finish_plug(&plug); | ||
399 | irbp->ir_startino = r.ir_startino; | 466 | irbp->ir_startino = r.ir_startino; |
400 | irbp->ir_freecount = r.ir_freecount; | 467 | irbp->ir_freecount = r.ir_freecount; |
401 | irbp->ir_free = r.ir_free; | 468 | irbp->ir_free = r.ir_free; |
@@ -422,57 +489,20 @@ xfs_bulkstat( | |||
422 | irbufend = irbp; | 489 | irbufend = irbp; |
423 | for (irbp = irbuf; | 490 | for (irbp = irbuf; |
424 | irbp < irbufend && XFS_BULKSTAT_UBLEFT(ubleft); irbp++) { | 491 | irbp < irbufend && XFS_BULKSTAT_UBLEFT(ubleft); irbp++) { |
425 | /* | 492 | struct xfs_bulkstat_agichunk ac; |
426 | * Now process this chunk of inodes. | 493 | |
427 | */ | 494 | ac.ac_lastino = lastino; |
428 | for (agino = irbp->ir_startino, chunkidx = clustidx = 0; | 495 | ac.ac_ubuffer = &ubuffer; |
429 | XFS_BULKSTAT_UBLEFT(ubleft) && | 496 | ac.ac_ubleft = ubleft; |
430 | irbp->ir_freecount < XFS_INODES_PER_CHUNK; | 497 | ac.ac_ubelem = ubelem; |
431 | chunkidx++, clustidx++, agino++) { | 498 | error = xfs_bulkstat_ag_ichunk(mp, agno, irbp, |
432 | ASSERT(chunkidx < XFS_INODES_PER_CHUNK); | 499 | formatter, statstruct_size, &ac); |
433 | 500 | if (error) | |
434 | ino = XFS_AGINO_TO_INO(mp, agno, agino); | 501 | rval = error; |
435 | /* | 502 | |
436 | * Skip if this inode is free. | 503 | lastino = ac.ac_lastino; |
437 | */ | 504 | ubleft = ac.ac_ubleft; |
438 | if (XFS_INOBT_MASK(chunkidx) & irbp->ir_free) { | 505 | ubelem = ac.ac_ubelem; |
439 | lastino = ino; | ||
440 | continue; | ||
441 | } | ||
442 | /* | ||
443 | * Count used inodes as free so we can tell | ||
444 | * when the chunk is used up. | ||
445 | */ | ||
446 | irbp->ir_freecount++; | ||
447 | |||
448 | /* | ||
449 | * Get the inode and fill in a single buffer. | ||
450 | */ | ||
451 | ubused = statstruct_size; | ||
452 | error = formatter(mp, ino, ubufp, ubleft, | ||
453 | &ubused, &fmterror); | ||
454 | if (fmterror == BULKSTAT_RV_NOTHING) { | ||
455 | if (error && error != ENOENT && | ||
456 | error != EINVAL) { | ||
457 | ubleft = 0; | ||
458 | rval = error; | ||
459 | break; | ||
460 | } | ||
461 | lastino = ino; | ||
462 | continue; | ||
463 | } | ||
464 | if (fmterror == BULKSTAT_RV_GIVEUP) { | ||
465 | ubleft = 0; | ||
466 | ASSERT(error); | ||
467 | rval = error; | ||
468 | break; | ||
469 | } | ||
470 | if (ubufp) | ||
471 | ubufp += ubused; | ||
472 | ubleft -= ubused; | ||
473 | ubelem++; | ||
474 | lastino = ino; | ||
475 | } | ||
476 | 506 | ||
477 | cond_resched(); | 507 | cond_resched(); |
478 | } | 508 | } |
@@ -512,58 +542,10 @@ xfs_bulkstat( | |||
512 | return rval; | 542 | return rval; |
513 | } | 543 | } |
514 | 544 | ||
515 | /* | ||
516 | * Return stat information in bulk (by-inode) for the filesystem. | ||
517 | * Special case for non-sequential one inode bulkstat. | ||
518 | */ | ||
519 | int /* error status */ | ||
520 | xfs_bulkstat_single( | ||
521 | xfs_mount_t *mp, /* mount point for filesystem */ | ||
522 | xfs_ino_t *lastinop, /* inode to return */ | ||
523 | char __user *buffer, /* buffer with inode stats */ | ||
524 | int *done) /* 1 if there are more stats to get */ | ||
525 | { | ||
526 | int count; /* count value for bulkstat call */ | ||
527 | int error; /* return value */ | ||
528 | xfs_ino_t ino; /* filesystem inode number */ | ||
529 | int res; /* result from bs1 */ | ||
530 | |||
531 | /* | ||
532 | * note that requesting valid inode numbers which are not allocated | ||
533 | * to inodes will most likely cause xfs_imap_to_bp to generate warning | ||
534 | * messages about bad magic numbers. This is ok. The fact that | ||
535 | * the inode isn't actually an inode is handled by the | ||
536 | * error check below. Done this way to make the usual case faster | ||
537 | * at the expense of the error case. | ||
538 | */ | ||
539 | |||
540 | ino = *lastinop; | ||
541 | error = xfs_bulkstat_one(mp, ino, buffer, sizeof(xfs_bstat_t), | ||
542 | NULL, &res); | ||
543 | if (error) { | ||
544 | /* | ||
545 | * Special case way failed, do it the "long" way | ||
546 | * to see if that works. | ||
547 | */ | ||
548 | (*lastinop)--; | ||
549 | count = 1; | ||
550 | if (xfs_bulkstat(mp, lastinop, &count, xfs_bulkstat_one, | ||
551 | sizeof(xfs_bstat_t), buffer, done)) | ||
552 | return error; | ||
553 | if (count == 0 || (xfs_ino_t)*lastinop != ino) | ||
554 | return error == EFSCORRUPTED ? | ||
555 | XFS_ERROR(EINVAL) : error; | ||
556 | else | ||
557 | return 0; | ||
558 | } | ||
559 | *done = 0; | ||
560 | return 0; | ||
561 | } | ||
562 | |||
563 | int | 545 | int |
564 | xfs_inumbers_fmt( | 546 | xfs_inumbers_fmt( |
565 | void __user *ubuffer, /* buffer to write to */ | 547 | void __user *ubuffer, /* buffer to write to */ |
566 | const xfs_inogrp_t *buffer, /* buffer to read from */ | 548 | const struct xfs_inogrp *buffer, /* buffer to read from */ |
567 | long count, /* # of elements to read */ | 549 | long count, /* # of elements to read */ |
568 | long *written) /* # of bytes written */ | 550 | long *written) /* # of bytes written */ |
569 | { | 551 | { |
@@ -578,127 +560,104 @@ xfs_inumbers_fmt( | |||
578 | */ | 560 | */ |
579 | int /* error status */ | 561 | int /* error status */ |
580 | xfs_inumbers( | 562 | xfs_inumbers( |
581 | xfs_mount_t *mp, /* mount point for filesystem */ | 563 | struct xfs_mount *mp,/* mount point for filesystem */ |
582 | xfs_ino_t *lastino, /* last inode returned */ | 564 | xfs_ino_t *lastino,/* last inode returned */ |
583 | int *count, /* size of buffer/count returned */ | 565 | int *count,/* size of buffer/count returned */ |
584 | void __user *ubuffer,/* buffer with inode descriptions */ | 566 | void __user *ubuffer,/* buffer with inode descriptions */ |
585 | inumbers_fmt_pf formatter) | 567 | inumbers_fmt_pf formatter) |
586 | { | 568 | { |
587 | xfs_buf_t *agbp; | 569 | xfs_agnumber_t agno = XFS_INO_TO_AGNO(mp, *lastino); |
588 | xfs_agino_t agino; | 570 | xfs_agino_t agino = XFS_INO_TO_AGINO(mp, *lastino); |
589 | xfs_agnumber_t agno; | 571 | struct xfs_btree_cur *cur = NULL; |
590 | int bcount; | 572 | struct xfs_buf *agbp = NULL; |
591 | xfs_inogrp_t *buffer; | 573 | struct xfs_inogrp *buffer; |
592 | int bufidx; | 574 | int bcount; |
593 | xfs_btree_cur_t *cur; | 575 | int left = *count; |
594 | int error; | 576 | int bufidx = 0; |
595 | xfs_inobt_rec_incore_t r; | 577 | int error = 0; |
596 | int i; | 578 | |
597 | xfs_ino_t ino; | ||
598 | int left; | ||
599 | int tmp; | ||
600 | |||
601 | ino = (xfs_ino_t)*lastino; | ||
602 | agno = XFS_INO_TO_AGNO(mp, ino); | ||
603 | agino = XFS_INO_TO_AGINO(mp, ino); | ||
604 | left = *count; | ||
605 | *count = 0; | 579 | *count = 0; |
580 | if (agno >= mp->m_sb.sb_agcount || | ||
581 | *lastino != XFS_AGINO_TO_INO(mp, agno, agino)) | ||
582 | return error; | ||
583 | |||
606 | bcount = MIN(left, (int)(PAGE_SIZE / sizeof(*buffer))); | 584 | bcount = MIN(left, (int)(PAGE_SIZE / sizeof(*buffer))); |
607 | buffer = kmem_alloc(bcount * sizeof(*buffer), KM_SLEEP); | 585 | buffer = kmem_alloc(bcount * sizeof(*buffer), KM_SLEEP); |
608 | error = bufidx = 0; | 586 | do { |
609 | cur = NULL; | 587 | struct xfs_inobt_rec_incore r; |
610 | agbp = NULL; | 588 | int stat; |
611 | while (left > 0 && agno < mp->m_sb.sb_agcount) { | 589 | |
612 | if (agbp == NULL) { | 590 | if (!agbp) { |
613 | error = xfs_ialloc_read_agi(mp, NULL, agno, &agbp); | 591 | error = xfs_ialloc_read_agi(mp, NULL, agno, &agbp); |
614 | if (error) { | 592 | if (error) |
615 | /* | 593 | break; |
616 | * If we can't read the AGI of this ag, | 594 | |
617 | * then just skip to the next one. | ||
618 | */ | ||
619 | ASSERT(cur == NULL); | ||
620 | agbp = NULL; | ||
621 | agno++; | ||
622 | agino = 0; | ||
623 | continue; | ||
624 | } | ||
625 | cur = xfs_inobt_init_cursor(mp, NULL, agbp, agno, | 595 | cur = xfs_inobt_init_cursor(mp, NULL, agbp, agno, |
626 | XFS_BTNUM_INO); | 596 | XFS_BTNUM_INO); |
627 | error = xfs_inobt_lookup(cur, agino, XFS_LOOKUP_GE, | 597 | error = xfs_inobt_lookup(cur, agino, XFS_LOOKUP_GE, |
628 | &tmp); | 598 | &stat); |
629 | if (error) { | 599 | if (error) |
630 | xfs_btree_del_cursor(cur, XFS_BTREE_ERROR); | 600 | break; |
631 | cur = NULL; | 601 | if (!stat) |
632 | xfs_buf_relse(agbp); | 602 | goto next_ag; |
633 | agbp = NULL; | ||
634 | /* | ||
635 | * Move up the last inode in the current | ||
636 | * chunk. The lookup_ge will always get | ||
637 | * us the first inode in the next chunk. | ||
638 | */ | ||
639 | agino += XFS_INODES_PER_CHUNK - 1; | ||
640 | continue; | ||
641 | } | ||
642 | } | ||
643 | error = xfs_inobt_get_rec(cur, &r, &i); | ||
644 | if (error || i == 0) { | ||
645 | xfs_buf_relse(agbp); | ||
646 | agbp = NULL; | ||
647 | xfs_btree_del_cursor(cur, XFS_BTREE_NOERROR); | ||
648 | cur = NULL; | ||
649 | agno++; | ||
650 | agino = 0; | ||
651 | continue; | ||
652 | } | 603 | } |
604 | |||
605 | error = xfs_inobt_get_rec(cur, &r, &stat); | ||
606 | if (error) | ||
607 | break; | ||
608 | if (!stat) | ||
609 | goto next_ag; | ||
610 | |||
653 | agino = r.ir_startino + XFS_INODES_PER_CHUNK - 1; | 611 | agino = r.ir_startino + XFS_INODES_PER_CHUNK - 1; |
654 | buffer[bufidx].xi_startino = | 612 | buffer[bufidx].xi_startino = |
655 | XFS_AGINO_TO_INO(mp, agno, r.ir_startino); | 613 | XFS_AGINO_TO_INO(mp, agno, r.ir_startino); |
656 | buffer[bufidx].xi_alloccount = | 614 | buffer[bufidx].xi_alloccount = |
657 | XFS_INODES_PER_CHUNK - r.ir_freecount; | 615 | XFS_INODES_PER_CHUNK - r.ir_freecount; |
658 | buffer[bufidx].xi_allocmask = ~r.ir_free; | 616 | buffer[bufidx].xi_allocmask = ~r.ir_free; |
659 | bufidx++; | 617 | if (++bufidx == bcount) { |
660 | left--; | 618 | long written; |
661 | if (bufidx == bcount) { | 619 | |
662 | long written; | 620 | error = formatter(ubuffer, buffer, bufidx, &written); |
663 | if (formatter(ubuffer, buffer, bufidx, &written)) { | 621 | if (error) |
664 | error = XFS_ERROR(EFAULT); | ||
665 | break; | 622 | break; |
666 | } | ||
667 | ubuffer += written; | 623 | ubuffer += written; |
668 | *count += bufidx; | 624 | *count += bufidx; |
669 | bufidx = 0; | 625 | bufidx = 0; |
670 | } | 626 | } |
671 | if (left) { | 627 | if (!--left) |
672 | error = xfs_btree_increment(cur, 0, &tmp); | 628 | break; |
673 | if (error) { | 629 | |
674 | xfs_btree_del_cursor(cur, XFS_BTREE_ERROR); | 630 | error = xfs_btree_increment(cur, 0, &stat); |
675 | cur = NULL; | 631 | if (error) |
676 | xfs_buf_relse(agbp); | 632 | break; |
677 | agbp = NULL; | 633 | if (stat) |
678 | /* | 634 | continue; |
679 | * The agino value has already been bumped. | 635 | |
680 | * Just try to skip up to it. | 636 | next_ag: |
681 | */ | 637 | xfs_btree_del_cursor(cur, XFS_BTREE_ERROR); |
682 | agino += XFS_INODES_PER_CHUNK; | 638 | cur = NULL; |
683 | continue; | 639 | xfs_buf_relse(agbp); |
684 | } | 640 | agbp = NULL; |
685 | } | 641 | agino = 0; |
686 | } | 642 | } while (++agno < mp->m_sb.sb_agcount); |
643 | |||
687 | if (!error) { | 644 | if (!error) { |
688 | if (bufidx) { | 645 | if (bufidx) { |
689 | long written; | 646 | long written; |
690 | if (formatter(ubuffer, buffer, bufidx, &written)) | 647 | |
691 | error = XFS_ERROR(EFAULT); | 648 | error = formatter(ubuffer, buffer, bufidx, &written); |
692 | else | 649 | if (!error) |
693 | *count += bufidx; | 650 | *count += bufidx; |
694 | } | 651 | } |
695 | *lastino = XFS_AGINO_TO_INO(mp, agno, agino); | 652 | *lastino = XFS_AGINO_TO_INO(mp, agno, agino); |
696 | } | 653 | } |
654 | |||
697 | kmem_free(buffer); | 655 | kmem_free(buffer); |
698 | if (cur) | 656 | if (cur) |
699 | xfs_btree_del_cursor(cur, (error ? XFS_BTREE_ERROR : | 657 | xfs_btree_del_cursor(cur, (error ? XFS_BTREE_ERROR : |
700 | XFS_BTREE_NOERROR)); | 658 | XFS_BTREE_NOERROR)); |
701 | if (agbp) | 659 | if (agbp) |
702 | xfs_buf_relse(agbp); | 660 | xfs_buf_relse(agbp); |
661 | |||
703 | return error; | 662 | return error; |
704 | } | 663 | } |
diff --git a/fs/xfs/xfs_itable.h b/fs/xfs/xfs_itable.h index 97295d91d170..aaed08022eb9 100644 --- a/fs/xfs/xfs_itable.h +++ b/fs/xfs/xfs_itable.h | |||
@@ -30,6 +30,22 @@ typedef int (*bulkstat_one_pf)(struct xfs_mount *mp, | |||
30 | int *ubused, | 30 | int *ubused, |
31 | int *stat); | 31 | int *stat); |
32 | 32 | ||
33 | struct xfs_bulkstat_agichunk { | ||
34 | xfs_ino_t ac_lastino; /* last inode returned */ | ||
35 | char __user **ac_ubuffer;/* pointer into user's buffer */ | ||
36 | int ac_ubleft; /* bytes left in user's buffer */ | ||
37 | int ac_ubelem; /* spaces used in user's buffer */ | ||
38 | }; | ||
39 | |||
40 | int | ||
41 | xfs_bulkstat_ag_ichunk( | ||
42 | struct xfs_mount *mp, | ||
43 | xfs_agnumber_t agno, | ||
44 | struct xfs_inobt_rec_incore *irbp, | ||
45 | bulkstat_one_pf formatter, | ||
46 | size_t statstruct_size, | ||
47 | struct xfs_bulkstat_agichunk *acp); | ||
48 | |||
33 | /* | 49 | /* |
34 | * Values for stat return value. | 50 | * Values for stat return value. |
35 | */ | 51 | */ |
@@ -50,13 +66,6 @@ xfs_bulkstat( | |||
50 | char __user *ubuffer,/* buffer with inode stats */ | 66 | char __user *ubuffer,/* buffer with inode stats */ |
51 | int *done); /* 1 if there are more stats to get */ | 67 | int *done); /* 1 if there are more stats to get */ |
52 | 68 | ||
53 | int | ||
54 | xfs_bulkstat_single( | ||
55 | xfs_mount_t *mp, | ||
56 | xfs_ino_t *lastinop, | ||
57 | char __user *buffer, | ||
58 | int *done); | ||
59 | |||
60 | typedef int (*bulkstat_one_fmt_pf)( /* used size in bytes or negative error */ | 69 | typedef int (*bulkstat_one_fmt_pf)( /* used size in bytes or negative error */ |
61 | void __user *ubuffer, /* buffer to write to */ | 70 | void __user *ubuffer, /* buffer to write to */ |
62 | int ubsize, /* remaining user buffer sz */ | 71 | int ubsize, /* remaining user buffer sz */ |
diff --git a/fs/xfs/xfs_linux.h b/fs/xfs/xfs_linux.h index 825249d2dfc1..d10dc8f397c9 100644 --- a/fs/xfs/xfs_linux.h +++ b/fs/xfs/xfs_linux.h | |||
@@ -21,18 +21,6 @@ | |||
21 | #include <linux/types.h> | 21 | #include <linux/types.h> |
22 | 22 | ||
23 | /* | 23 | /* |
24 | * XFS_BIG_BLKNOS needs block layer disk addresses to be 64 bits. | ||
25 | * XFS_BIG_INUMS requires XFS_BIG_BLKNOS to be set. | ||
26 | */ | ||
27 | #if defined(CONFIG_LBDAF) || (BITS_PER_LONG == 64) | ||
28 | # define XFS_BIG_BLKNOS 1 | ||
29 | # define XFS_BIG_INUMS 1 | ||
30 | #else | ||
31 | # define XFS_BIG_BLKNOS 0 | ||
32 | # define XFS_BIG_INUMS 0 | ||
33 | #endif | ||
34 | |||
35 | /* | ||
36 | * Kernel specific type declarations for XFS | 24 | * Kernel specific type declarations for XFS |
37 | */ | 25 | */ |
38 | typedef signed char __int8_t; | 26 | typedef signed char __int8_t; |
@@ -113,7 +101,7 @@ typedef __uint64_t __psunsigned_t; | |||
113 | #include <asm/byteorder.h> | 101 | #include <asm/byteorder.h> |
114 | #include <asm/unaligned.h> | 102 | #include <asm/unaligned.h> |
115 | 103 | ||
116 | #include "xfs_vnode.h" | 104 | #include "xfs_fs.h" |
117 | #include "xfs_stats.h" | 105 | #include "xfs_stats.h" |
118 | #include "xfs_sysctl.h" | 106 | #include "xfs_sysctl.h" |
119 | #include "xfs_iops.h" | 107 | #include "xfs_iops.h" |
@@ -191,6 +179,17 @@ typedef __uint64_t __psunsigned_t; | |||
191 | #define MAX(a,b) (max(a,b)) | 179 | #define MAX(a,b) (max(a,b)) |
192 | #define howmany(x, y) (((x)+((y)-1))/(y)) | 180 | #define howmany(x, y) (((x)+((y)-1))/(y)) |
193 | 181 | ||
182 | /* | ||
183 | * XFS wrapper structure for sysfs support. It depends on external data | ||
184 | * structures and is embedded in various internal data structures to implement | ||
185 | * the XFS sysfs object heirarchy. Define it here for broad access throughout | ||
186 | * the codebase. | ||
187 | */ | ||
188 | struct xfs_kobj { | ||
189 | struct kobject kobject; | ||
190 | struct completion complete; | ||
191 | }; | ||
192 | |||
194 | /* Kernel uid/gid conversion. These are used to convert to/from the on disk | 193 | /* Kernel uid/gid conversion. These are used to convert to/from the on disk |
195 | * uid_t/gid_t types to the kuid_t/kgid_t types that the kernel uses internally. | 194 | * uid_t/gid_t types to the kuid_t/kgid_t types that the kernel uses internally. |
196 | * The conversion here is type only, the value will remain the same since we | 195 | * The conversion here is type only, the value will remain the same since we |
@@ -331,7 +330,7 @@ static inline __uint64_t roundup_64(__uint64_t x, __uint32_t y) | |||
331 | { | 330 | { |
332 | x += y - 1; | 331 | x += y - 1; |
333 | do_div(x, y); | 332 | do_div(x, y); |
334 | return(x * y); | 333 | return x * y; |
335 | } | 334 | } |
336 | 335 | ||
337 | static inline __uint64_t howmany_64(__uint64_t x, __uint32_t y) | 336 | static 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..ca4fd5bd8522 100644 --- a/fs/xfs/xfs_log.c +++ b/fs/xfs/xfs_log.c | |||
@@ -34,6 +34,7 @@ | |||
34 | #include "xfs_trace.h" | 34 | #include "xfs_trace.h" |
35 | #include "xfs_fsops.h" | 35 | #include "xfs_fsops.h" |
36 | #include "xfs_cksum.h" | 36 | #include "xfs_cksum.h" |
37 | #include "xfs_sysfs.h" | ||
37 | 38 | ||
38 | kmem_zone_t *xfs_log_ticket_zone; | 39 | kmem_zone_t *xfs_log_ticket_zone; |
39 | 40 | ||
@@ -283,7 +284,7 @@ xlog_grant_head_wait( | |||
283 | return 0; | 284 | return 0; |
284 | shutdown: | 285 | shutdown: |
285 | list_del_init(&tic->t_queue); | 286 | list_del_init(&tic->t_queue); |
286 | return XFS_ERROR(EIO); | 287 | return -EIO; |
287 | } | 288 | } |
288 | 289 | ||
289 | /* | 290 | /* |
@@ -377,7 +378,7 @@ xfs_log_regrant( | |||
377 | int error = 0; | 378 | int error = 0; |
378 | 379 | ||
379 | if (XLOG_FORCED_SHUTDOWN(log)) | 380 | if (XLOG_FORCED_SHUTDOWN(log)) |
380 | return XFS_ERROR(EIO); | 381 | return -EIO; |
381 | 382 | ||
382 | XFS_STATS_INC(xs_try_logspace); | 383 | XFS_STATS_INC(xs_try_logspace); |
383 | 384 | ||
@@ -446,7 +447,7 @@ xfs_log_reserve( | |||
446 | ASSERT(client == XFS_TRANSACTION || client == XFS_LOG); | 447 | ASSERT(client == XFS_TRANSACTION || client == XFS_LOG); |
447 | 448 | ||
448 | if (XLOG_FORCED_SHUTDOWN(log)) | 449 | if (XLOG_FORCED_SHUTDOWN(log)) |
449 | return XFS_ERROR(EIO); | 450 | return -EIO; |
450 | 451 | ||
451 | XFS_STATS_INC(xs_try_logspace); | 452 | XFS_STATS_INC(xs_try_logspace); |
452 | 453 | ||
@@ -454,7 +455,7 @@ xfs_log_reserve( | |||
454 | tic = xlog_ticket_alloc(log, unit_bytes, cnt, client, permanent, | 455 | tic = xlog_ticket_alloc(log, unit_bytes, cnt, client, permanent, |
455 | KM_SLEEP | KM_MAYFAIL); | 456 | KM_SLEEP | KM_MAYFAIL); |
456 | if (!tic) | 457 | if (!tic) |
457 | return XFS_ERROR(ENOMEM); | 458 | return -ENOMEM; |
458 | 459 | ||
459 | tic->t_trans_type = t_type; | 460 | tic->t_trans_type = t_type; |
460 | *ticp = tic; | 461 | *ticp = tic; |
@@ -590,7 +591,7 @@ xfs_log_release_iclog( | |||
590 | { | 591 | { |
591 | if (xlog_state_release_iclog(mp->m_log, iclog)) { | 592 | if (xlog_state_release_iclog(mp->m_log, iclog)) { |
592 | xfs_force_shutdown(mp, SHUTDOWN_LOG_IO_ERROR); | 593 | xfs_force_shutdown(mp, SHUTDOWN_LOG_IO_ERROR); |
593 | return EIO; | 594 | return -EIO; |
594 | } | 595 | } |
595 | 596 | ||
596 | return 0; | 597 | return 0; |
@@ -628,7 +629,7 @@ xfs_log_mount( | |||
628 | 629 | ||
629 | mp->m_log = xlog_alloc_log(mp, log_target, blk_offset, num_bblks); | 630 | mp->m_log = xlog_alloc_log(mp, log_target, blk_offset, num_bblks); |
630 | if (IS_ERR(mp->m_log)) { | 631 | if (IS_ERR(mp->m_log)) { |
631 | error = -PTR_ERR(mp->m_log); | 632 | error = PTR_ERR(mp->m_log); |
632 | goto out; | 633 | goto out; |
633 | } | 634 | } |
634 | 635 | ||
@@ -652,18 +653,18 @@ xfs_log_mount( | |||
652 | xfs_warn(mp, | 653 | xfs_warn(mp, |
653 | "Log size %d blocks too small, minimum size is %d blocks", | 654 | "Log size %d blocks too small, minimum size is %d blocks", |
654 | mp->m_sb.sb_logblocks, min_logfsbs); | 655 | mp->m_sb.sb_logblocks, min_logfsbs); |
655 | error = EINVAL; | 656 | error = -EINVAL; |
656 | } else if (mp->m_sb.sb_logblocks > XFS_MAX_LOG_BLOCKS) { | 657 | } else if (mp->m_sb.sb_logblocks > XFS_MAX_LOG_BLOCKS) { |
657 | xfs_warn(mp, | 658 | xfs_warn(mp, |
658 | "Log size %d blocks too large, maximum size is %lld blocks", | 659 | "Log size %d blocks too large, maximum size is %lld blocks", |
659 | mp->m_sb.sb_logblocks, XFS_MAX_LOG_BLOCKS); | 660 | mp->m_sb.sb_logblocks, XFS_MAX_LOG_BLOCKS); |
660 | error = EINVAL; | 661 | error = -EINVAL; |
661 | } else if (XFS_FSB_TO_B(mp, mp->m_sb.sb_logblocks) > XFS_MAX_LOG_BYTES) { | 662 | } else if (XFS_FSB_TO_B(mp, mp->m_sb.sb_logblocks) > XFS_MAX_LOG_BYTES) { |
662 | xfs_warn(mp, | 663 | xfs_warn(mp, |
663 | "log size %lld bytes too large, maximum size is %lld bytes", | 664 | "log size %lld bytes too large, maximum size is %lld bytes", |
664 | XFS_FSB_TO_B(mp, mp->m_sb.sb_logblocks), | 665 | XFS_FSB_TO_B(mp, mp->m_sb.sb_logblocks), |
665 | XFS_MAX_LOG_BYTES); | 666 | XFS_MAX_LOG_BYTES); |
666 | error = EINVAL; | 667 | error = -EINVAL; |
667 | } | 668 | } |
668 | if (error) { | 669 | if (error) { |
669 | if (xfs_sb_version_hascrc(&mp->m_sb)) { | 670 | if (xfs_sb_version_hascrc(&mp->m_sb)) { |
@@ -707,6 +708,11 @@ xfs_log_mount( | |||
707 | } | 708 | } |
708 | } | 709 | } |
709 | 710 | ||
711 | error = xfs_sysfs_init(&mp->m_log->l_kobj, &xfs_log_ktype, &mp->m_kobj, | ||
712 | "log"); | ||
713 | if (error) | ||
714 | goto out_destroy_ail; | ||
715 | |||
710 | /* Normal transactions can now occur */ | 716 | /* Normal transactions can now occur */ |
711 | mp->m_log->l_flags &= ~XLOG_ACTIVE_RECOVERY; | 717 | mp->m_log->l_flags &= ~XLOG_ACTIVE_RECOVERY; |
712 | 718 | ||
@@ -947,6 +953,9 @@ xfs_log_unmount( | |||
947 | xfs_log_quiesce(mp); | 953 | xfs_log_quiesce(mp); |
948 | 954 | ||
949 | xfs_trans_ail_destroy(mp); | 955 | xfs_trans_ail_destroy(mp); |
956 | |||
957 | xfs_sysfs_del(&mp->m_log->l_kobj); | ||
958 | |||
950 | xlog_dealloc_log(mp->m_log); | 959 | xlog_dealloc_log(mp->m_log); |
951 | } | 960 | } |
952 | 961 | ||
@@ -1313,7 +1322,7 @@ xlog_alloc_log( | |||
1313 | xlog_in_core_t *iclog, *prev_iclog=NULL; | 1322 | xlog_in_core_t *iclog, *prev_iclog=NULL; |
1314 | xfs_buf_t *bp; | 1323 | xfs_buf_t *bp; |
1315 | int i; | 1324 | int i; |
1316 | int error = ENOMEM; | 1325 | int error = -ENOMEM; |
1317 | uint log2_size = 0; | 1326 | uint log2_size = 0; |
1318 | 1327 | ||
1319 | log = kmem_zalloc(sizeof(struct xlog), KM_MAYFAIL); | 1328 | log = kmem_zalloc(sizeof(struct xlog), KM_MAYFAIL); |
@@ -1340,7 +1349,7 @@ xlog_alloc_log( | |||
1340 | xlog_grant_head_init(&log->l_reserve_head); | 1349 | xlog_grant_head_init(&log->l_reserve_head); |
1341 | xlog_grant_head_init(&log->l_write_head); | 1350 | xlog_grant_head_init(&log->l_write_head); |
1342 | 1351 | ||
1343 | error = EFSCORRUPTED; | 1352 | error = -EFSCORRUPTED; |
1344 | if (xfs_sb_version_hassector(&mp->m_sb)) { | 1353 | if (xfs_sb_version_hassector(&mp->m_sb)) { |
1345 | log2_size = mp->m_sb.sb_logsectlog; | 1354 | log2_size = mp->m_sb.sb_logsectlog; |
1346 | if (log2_size < BBSHIFT) { | 1355 | if (log2_size < BBSHIFT) { |
@@ -1369,8 +1378,14 @@ xlog_alloc_log( | |||
1369 | 1378 | ||
1370 | xlog_get_iclog_buffer_size(mp, log); | 1379 | xlog_get_iclog_buffer_size(mp, log); |
1371 | 1380 | ||
1372 | error = ENOMEM; | 1381 | /* |
1373 | bp = xfs_buf_alloc(mp->m_logdev_targp, 0, BTOBB(log->l_iclog_size), 0); | 1382 | * Use a NULL block for the extra log buffer used during splits so that |
1383 | * it will trigger errors if we ever try to do IO on it without first | ||
1384 | * having set it up properly. | ||
1385 | */ | ||
1386 | error = -ENOMEM; | ||
1387 | bp = xfs_buf_alloc(mp->m_logdev_targp, XFS_BUF_DADDR_NULL, | ||
1388 | BTOBB(log->l_iclog_size), 0); | ||
1374 | if (!bp) | 1389 | if (!bp) |
1375 | goto out_free_log; | 1390 | goto out_free_log; |
1376 | 1391 | ||
@@ -1463,7 +1478,7 @@ out_free_iclog: | |||
1463 | out_free_log: | 1478 | out_free_log: |
1464 | kmem_free(log); | 1479 | kmem_free(log); |
1465 | out: | 1480 | out: |
1466 | return ERR_PTR(-error); | 1481 | return ERR_PTR(error); |
1467 | } /* xlog_alloc_log */ | 1482 | } /* xlog_alloc_log */ |
1468 | 1483 | ||
1469 | 1484 | ||
@@ -1661,7 +1676,7 @@ xlog_bdstrat( | |||
1661 | 1676 | ||
1662 | xfs_buf_lock(bp); | 1677 | xfs_buf_lock(bp); |
1663 | if (iclog->ic_state & XLOG_STATE_IOERROR) { | 1678 | if (iclog->ic_state & XLOG_STATE_IOERROR) { |
1664 | xfs_buf_ioerror(bp, EIO); | 1679 | xfs_buf_ioerror(bp, -EIO); |
1665 | xfs_buf_stale(bp); | 1680 | xfs_buf_stale(bp); |
1666 | xfs_buf_ioend(bp, 0); | 1681 | xfs_buf_ioend(bp, 0); |
1667 | /* | 1682 | /* |
@@ -2360,7 +2375,7 @@ xlog_write( | |||
2360 | 2375 | ||
2361 | ophdr = xlog_write_setup_ophdr(log, ptr, ticket, flags); | 2376 | ophdr = xlog_write_setup_ophdr(log, ptr, ticket, flags); |
2362 | if (!ophdr) | 2377 | if (!ophdr) |
2363 | return XFS_ERROR(EIO); | 2378 | return -EIO; |
2364 | 2379 | ||
2365 | xlog_write_adv_cnt(&ptr, &len, &log_offset, | 2380 | xlog_write_adv_cnt(&ptr, &len, &log_offset, |
2366 | sizeof(struct xlog_op_header)); | 2381 | sizeof(struct xlog_op_header)); |
@@ -2859,7 +2874,7 @@ restart: | |||
2859 | spin_lock(&log->l_icloglock); | 2874 | spin_lock(&log->l_icloglock); |
2860 | if (XLOG_FORCED_SHUTDOWN(log)) { | 2875 | if (XLOG_FORCED_SHUTDOWN(log)) { |
2861 | spin_unlock(&log->l_icloglock); | 2876 | spin_unlock(&log->l_icloglock); |
2862 | return XFS_ERROR(EIO); | 2877 | return -EIO; |
2863 | } | 2878 | } |
2864 | 2879 | ||
2865 | iclog = log->l_iclog; | 2880 | iclog = log->l_iclog; |
@@ -3047,7 +3062,7 @@ xlog_state_release_iclog( | |||
3047 | int sync = 0; /* do we sync? */ | 3062 | int sync = 0; /* do we sync? */ |
3048 | 3063 | ||
3049 | if (iclog->ic_state & XLOG_STATE_IOERROR) | 3064 | if (iclog->ic_state & XLOG_STATE_IOERROR) |
3050 | return XFS_ERROR(EIO); | 3065 | return -EIO; |
3051 | 3066 | ||
3052 | ASSERT(atomic_read(&iclog->ic_refcnt) > 0); | 3067 | ASSERT(atomic_read(&iclog->ic_refcnt) > 0); |
3053 | if (!atomic_dec_and_lock(&iclog->ic_refcnt, &log->l_icloglock)) | 3068 | if (!atomic_dec_and_lock(&iclog->ic_refcnt, &log->l_icloglock)) |
@@ -3055,7 +3070,7 @@ xlog_state_release_iclog( | |||
3055 | 3070 | ||
3056 | if (iclog->ic_state & XLOG_STATE_IOERROR) { | 3071 | if (iclog->ic_state & XLOG_STATE_IOERROR) { |
3057 | spin_unlock(&log->l_icloglock); | 3072 | spin_unlock(&log->l_icloglock); |
3058 | return XFS_ERROR(EIO); | 3073 | return -EIO; |
3059 | } | 3074 | } |
3060 | ASSERT(iclog->ic_state == XLOG_STATE_ACTIVE || | 3075 | ASSERT(iclog->ic_state == XLOG_STATE_ACTIVE || |
3061 | iclog->ic_state == XLOG_STATE_WANT_SYNC); | 3076 | iclog->ic_state == XLOG_STATE_WANT_SYNC); |
@@ -3172,7 +3187,7 @@ _xfs_log_force( | |||
3172 | iclog = log->l_iclog; | 3187 | iclog = log->l_iclog; |
3173 | if (iclog->ic_state & XLOG_STATE_IOERROR) { | 3188 | if (iclog->ic_state & XLOG_STATE_IOERROR) { |
3174 | spin_unlock(&log->l_icloglock); | 3189 | spin_unlock(&log->l_icloglock); |
3175 | return XFS_ERROR(EIO); | 3190 | return -EIO; |
3176 | } | 3191 | } |
3177 | 3192 | ||
3178 | /* If the head iclog is not active nor dirty, we just attach | 3193 | /* If the head iclog is not active nor dirty, we just attach |
@@ -3210,7 +3225,7 @@ _xfs_log_force( | |||
3210 | spin_unlock(&log->l_icloglock); | 3225 | spin_unlock(&log->l_icloglock); |
3211 | 3226 | ||
3212 | if (xlog_state_release_iclog(log, iclog)) | 3227 | if (xlog_state_release_iclog(log, iclog)) |
3213 | return XFS_ERROR(EIO); | 3228 | return -EIO; |
3214 | 3229 | ||
3215 | if (log_flushed) | 3230 | if (log_flushed) |
3216 | *log_flushed = 1; | 3231 | *log_flushed = 1; |
@@ -3246,7 +3261,7 @@ maybe_sleep: | |||
3246 | */ | 3261 | */ |
3247 | if (iclog->ic_state & XLOG_STATE_IOERROR) { | 3262 | if (iclog->ic_state & XLOG_STATE_IOERROR) { |
3248 | spin_unlock(&log->l_icloglock); | 3263 | spin_unlock(&log->l_icloglock); |
3249 | return XFS_ERROR(EIO); | 3264 | return -EIO; |
3250 | } | 3265 | } |
3251 | XFS_STATS_INC(xs_log_force_sleep); | 3266 | XFS_STATS_INC(xs_log_force_sleep); |
3252 | xlog_wait(&iclog->ic_force_wait, &log->l_icloglock); | 3267 | xlog_wait(&iclog->ic_force_wait, &log->l_icloglock); |
@@ -3256,7 +3271,7 @@ maybe_sleep: | |||
3256 | * and the memory read should be atomic. | 3271 | * and the memory read should be atomic. |
3257 | */ | 3272 | */ |
3258 | if (iclog->ic_state & XLOG_STATE_IOERROR) | 3273 | if (iclog->ic_state & XLOG_STATE_IOERROR) |
3259 | return XFS_ERROR(EIO); | 3274 | return -EIO; |
3260 | if (log_flushed) | 3275 | if (log_flushed) |
3261 | *log_flushed = 1; | 3276 | *log_flushed = 1; |
3262 | } else { | 3277 | } else { |
@@ -3324,7 +3339,7 @@ try_again: | |||
3324 | iclog = log->l_iclog; | 3339 | iclog = log->l_iclog; |
3325 | if (iclog->ic_state & XLOG_STATE_IOERROR) { | 3340 | if (iclog->ic_state & XLOG_STATE_IOERROR) { |
3326 | spin_unlock(&log->l_icloglock); | 3341 | spin_unlock(&log->l_icloglock); |
3327 | return XFS_ERROR(EIO); | 3342 | return -EIO; |
3328 | } | 3343 | } |
3329 | 3344 | ||
3330 | do { | 3345 | do { |
@@ -3375,7 +3390,7 @@ try_again: | |||
3375 | xlog_state_switch_iclogs(log, iclog, 0); | 3390 | xlog_state_switch_iclogs(log, iclog, 0); |
3376 | spin_unlock(&log->l_icloglock); | 3391 | spin_unlock(&log->l_icloglock); |
3377 | if (xlog_state_release_iclog(log, iclog)) | 3392 | if (xlog_state_release_iclog(log, iclog)) |
3378 | return XFS_ERROR(EIO); | 3393 | return -EIO; |
3379 | if (log_flushed) | 3394 | if (log_flushed) |
3380 | *log_flushed = 1; | 3395 | *log_flushed = 1; |
3381 | spin_lock(&log->l_icloglock); | 3396 | spin_lock(&log->l_icloglock); |
@@ -3390,7 +3405,7 @@ try_again: | |||
3390 | */ | 3405 | */ |
3391 | if (iclog->ic_state & XLOG_STATE_IOERROR) { | 3406 | if (iclog->ic_state & XLOG_STATE_IOERROR) { |
3392 | spin_unlock(&log->l_icloglock); | 3407 | spin_unlock(&log->l_icloglock); |
3393 | return XFS_ERROR(EIO); | 3408 | return -EIO; |
3394 | } | 3409 | } |
3395 | XFS_STATS_INC(xs_log_force_sleep); | 3410 | XFS_STATS_INC(xs_log_force_sleep); |
3396 | xlog_wait(&iclog->ic_force_wait, &log->l_icloglock); | 3411 | xlog_wait(&iclog->ic_force_wait, &log->l_icloglock); |
@@ -3400,7 +3415,7 @@ try_again: | |||
3400 | * and the memory read should be atomic. | 3415 | * and the memory read should be atomic. |
3401 | */ | 3416 | */ |
3402 | if (iclog->ic_state & XLOG_STATE_IOERROR) | 3417 | if (iclog->ic_state & XLOG_STATE_IOERROR) |
3403 | return XFS_ERROR(EIO); | 3418 | return -EIO; |
3404 | 3419 | ||
3405 | if (log_flushed) | 3420 | if (log_flushed) |
3406 | *log_flushed = 1; | 3421 | *log_flushed = 1; |
diff --git a/fs/xfs/xfs_log_cil.c b/fs/xfs/xfs_log_cil.c index b3425b34e3d5..f6b79e5325dd 100644 --- a/fs/xfs/xfs_log_cil.c +++ b/fs/xfs/xfs_log_cil.c | |||
@@ -78,8 +78,6 @@ xlog_cil_init_post_recovery( | |||
78 | { | 78 | { |
79 | log->l_cilp->xc_ctx->ticket = xlog_cil_ticket_alloc(log); | 79 | log->l_cilp->xc_ctx->ticket = xlog_cil_ticket_alloc(log); |
80 | log->l_cilp->xc_ctx->sequence = 1; | 80 | log->l_cilp->xc_ctx->sequence = 1; |
81 | log->l_cilp->xc_ctx->commit_lsn = xlog_assign_lsn(log->l_curr_cycle, | ||
82 | log->l_curr_block); | ||
83 | } | 81 | } |
84 | 82 | ||
85 | /* | 83 | /* |
@@ -634,7 +632,7 @@ out_abort_free_ticket: | |||
634 | xfs_log_ticket_put(tic); | 632 | xfs_log_ticket_put(tic); |
635 | out_abort: | 633 | out_abort: |
636 | xlog_cil_committed(ctx, XFS_LI_ABORTED); | 634 | xlog_cil_committed(ctx, XFS_LI_ABORTED); |
637 | return XFS_ERROR(EIO); | 635 | return -EIO; |
638 | } | 636 | } |
639 | 637 | ||
640 | static void | 638 | static void |
@@ -928,12 +926,12 @@ xlog_cil_init( | |||
928 | 926 | ||
929 | cil = kmem_zalloc(sizeof(*cil), KM_SLEEP|KM_MAYFAIL); | 927 | cil = kmem_zalloc(sizeof(*cil), KM_SLEEP|KM_MAYFAIL); |
930 | if (!cil) | 928 | if (!cil) |
931 | return ENOMEM; | 929 | return -ENOMEM; |
932 | 930 | ||
933 | ctx = kmem_zalloc(sizeof(*ctx), KM_SLEEP|KM_MAYFAIL); | 931 | ctx = kmem_zalloc(sizeof(*ctx), KM_SLEEP|KM_MAYFAIL); |
934 | if (!ctx) { | 932 | if (!ctx) { |
935 | kmem_free(cil); | 933 | kmem_free(cil); |
936 | return ENOMEM; | 934 | return -ENOMEM; |
937 | } | 935 | } |
938 | 936 | ||
939 | INIT_WORK(&cil->xc_push_work, xlog_cil_push_work); | 937 | INIT_WORK(&cil->xc_push_work, xlog_cil_push_work); |
diff --git a/fs/xfs/xfs_log_priv.h b/fs/xfs/xfs_log_priv.h index 9bc403a9e54f..db7cbdeb2b42 100644 --- a/fs/xfs/xfs_log_priv.h +++ b/fs/xfs/xfs_log_priv.h | |||
@@ -405,6 +405,8 @@ struct xlog { | |||
405 | struct xlog_grant_head l_reserve_head; | 405 | struct xlog_grant_head l_reserve_head; |
406 | struct xlog_grant_head l_write_head; | 406 | struct xlog_grant_head l_write_head; |
407 | 407 | ||
408 | struct xfs_kobj l_kobj; | ||
409 | |||
408 | /* The following field are used for debugging; need to hold icloglock */ | 410 | /* The following field are used for debugging; need to hold icloglock */ |
409 | #ifdef DEBUG | 411 | #ifdef DEBUG |
410 | char *l_iclog_bak[XLOG_MAX_ICLOGS]; | 412 | char *l_iclog_bak[XLOG_MAX_ICLOGS]; |
diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c index 981af0f6504b..1fd5787add99 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 | */ |
1098 | STATIC int | 1100 | STATIC int |
1099 | xlog_find_zeroed( | 1101 | xlog_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; |
1190 | bp_err: | 1191 | bp_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, |
@@ -2125,6 +2126,17 @@ xlog_recover_validate_buf_type( | |||
2125 | __uint16_t magic16; | 2126 | __uint16_t magic16; |
2126 | __uint16_t magicda; | 2127 | __uint16_t magicda; |
2127 | 2128 | ||
2129 | /* | ||
2130 | * We can only do post recovery validation on items on CRC enabled | ||
2131 | * fielsystems as we need to know when the buffer was written to be able | ||
2132 | * to determine if we should have replayed the item. If we replay old | ||
2133 | * metadata over a newer buffer, then it will enter a temporarily | ||
2134 | * inconsistent state resulting in verification failures. Hence for now | ||
2135 | * just avoid the verification stage for non-crc filesystems | ||
2136 | */ | ||
2137 | if (!xfs_sb_version_hascrc(&mp->m_sb)) | ||
2138 | return; | ||
2139 | |||
2128 | magic32 = be32_to_cpu(*(__be32 *)bp->b_addr); | 2140 | magic32 = be32_to_cpu(*(__be32 *)bp->b_addr); |
2129 | magic16 = be16_to_cpu(*(__be16*)bp->b_addr); | 2141 | magic16 = be16_to_cpu(*(__be16*)bp->b_addr); |
2130 | magicda = be16_to_cpu(info->magic); | 2142 | magicda = be16_to_cpu(info->magic); |
@@ -2162,8 +2174,6 @@ xlog_recover_validate_buf_type( | |||
2162 | bp->b_ops = &xfs_agf_buf_ops; | 2174 | bp->b_ops = &xfs_agf_buf_ops; |
2163 | break; | 2175 | break; |
2164 | case XFS_BLFT_AGFL_BUF: | 2176 | case XFS_BLFT_AGFL_BUF: |
2165 | if (!xfs_sb_version_hascrc(&mp->m_sb)) | ||
2166 | break; | ||
2167 | if (magic32 != XFS_AGFL_MAGIC) { | 2177 | if (magic32 != XFS_AGFL_MAGIC) { |
2168 | xfs_warn(mp, "Bad AGFL block magic!"); | 2178 | xfs_warn(mp, "Bad AGFL block magic!"); |
2169 | ASSERT(0); | 2179 | ASSERT(0); |
@@ -2196,10 +2206,6 @@ xlog_recover_validate_buf_type( | |||
2196 | #endif | 2206 | #endif |
2197 | break; | 2207 | break; |
2198 | case XFS_BLFT_DINO_BUF: | 2208 | case XFS_BLFT_DINO_BUF: |
2199 | /* | ||
2200 | * we get here with inode allocation buffers, not buffers that | ||
2201 | * track unlinked list changes. | ||
2202 | */ | ||
2203 | if (magic16 != XFS_DINODE_MAGIC) { | 2209 | if (magic16 != XFS_DINODE_MAGIC) { |
2204 | xfs_warn(mp, "Bad INODE block magic!"); | 2210 | xfs_warn(mp, "Bad INODE block magic!"); |
2205 | ASSERT(0); | 2211 | ASSERT(0); |
@@ -2279,8 +2285,6 @@ xlog_recover_validate_buf_type( | |||
2279 | bp->b_ops = &xfs_attr3_leaf_buf_ops; | 2285 | bp->b_ops = &xfs_attr3_leaf_buf_ops; |
2280 | break; | 2286 | break; |
2281 | case XFS_BLFT_ATTR_RMT_BUF: | 2287 | case XFS_BLFT_ATTR_RMT_BUF: |
2282 | if (!xfs_sb_version_hascrc(&mp->m_sb)) | ||
2283 | break; | ||
2284 | if (magic32 != XFS_ATTR3_RMT_MAGIC) { | 2288 | if (magic32 != XFS_ATTR3_RMT_MAGIC) { |
2285 | xfs_warn(mp, "Bad attr remote magic!"); | 2289 | xfs_warn(mp, "Bad attr remote magic!"); |
2286 | ASSERT(0); | 2290 | ASSERT(0); |
@@ -2387,16 +2391,7 @@ xlog_recover_do_reg_buffer( | |||
2387 | /* Shouldn't be any more regions */ | 2391 | /* Shouldn't be any more regions */ |
2388 | ASSERT(i == item->ri_total); | 2392 | ASSERT(i == item->ri_total); |
2389 | 2393 | ||
2390 | /* | 2394 | xlog_recover_validate_buf_type(mp, bp, buf_f); |
2391 | * We can only do post recovery validation on items on CRC enabled | ||
2392 | * fielsystems as we need to know when the buffer was written to be able | ||
2393 | * to determine if we should have replayed the item. If we replay old | ||
2394 | * metadata over a newer buffer, then it will enter a temporarily | ||
2395 | * inconsistent state resulting in verification failures. Hence for now | ||
2396 | * just avoid the verification stage for non-crc filesystems | ||
2397 | */ | ||
2398 | if (xfs_sb_version_hascrc(&mp->m_sb)) | ||
2399 | xlog_recover_validate_buf_type(mp, bp, buf_f); | ||
2400 | } | 2395 | } |
2401 | 2396 | ||
2402 | /* | 2397 | /* |
@@ -2404,8 +2399,11 @@ xlog_recover_do_reg_buffer( | |||
2404 | * Simple algorithm: if we have found a QUOTAOFF log item of the same type | 2399 | * Simple algorithm: if we have found a QUOTAOFF log item of the same type |
2405 | * (ie. USR or GRP), then just toss this buffer away; don't recover it. | 2400 | * (ie. USR or GRP), then just toss this buffer away; don't recover it. |
2406 | * Else, treat it as a regular buffer and do recovery. | 2401 | * Else, treat it as a regular buffer and do recovery. |
2402 | * | ||
2403 | * Return false if the buffer was tossed and true if we recovered the buffer to | ||
2404 | * indicate to the caller if the buffer needs writing. | ||
2407 | */ | 2405 | */ |
2408 | STATIC void | 2406 | STATIC bool |
2409 | xlog_recover_do_dquot_buffer( | 2407 | xlog_recover_do_dquot_buffer( |
2410 | struct xfs_mount *mp, | 2408 | struct xfs_mount *mp, |
2411 | struct xlog *log, | 2409 | struct xlog *log, |
@@ -2420,9 +2418,8 @@ xlog_recover_do_dquot_buffer( | |||
2420 | /* | 2418 | /* |
2421 | * Filesystems are required to send in quota flags at mount time. | 2419 | * Filesystems are required to send in quota flags at mount time. |
2422 | */ | 2420 | */ |
2423 | if (mp->m_qflags == 0) { | 2421 | if (!mp->m_qflags) |
2424 | return; | 2422 | return false; |
2425 | } | ||
2426 | 2423 | ||
2427 | type = 0; | 2424 | type = 0; |
2428 | if (buf_f->blf_flags & XFS_BLF_UDQUOT_BUF) | 2425 | if (buf_f->blf_flags & XFS_BLF_UDQUOT_BUF) |
@@ -2435,9 +2432,10 @@ xlog_recover_do_dquot_buffer( | |||
2435 | * This type of quotas was turned off, so ignore this buffer | 2432 | * This type of quotas was turned off, so ignore this buffer |
2436 | */ | 2433 | */ |
2437 | if (log->l_quotaoffs_flag & type) | 2434 | if (log->l_quotaoffs_flag & type) |
2438 | return; | 2435 | return false; |
2439 | 2436 | ||
2440 | xlog_recover_do_reg_buffer(mp, item, bp, buf_f); | 2437 | xlog_recover_do_reg_buffer(mp, item, bp, buf_f); |
2438 | return true; | ||
2441 | } | 2439 | } |
2442 | 2440 | ||
2443 | /* | 2441 | /* |
@@ -2496,7 +2494,7 @@ xlog_recover_buffer_pass2( | |||
2496 | bp = xfs_buf_read(mp->m_ddev_targp, buf_f->blf_blkno, buf_f->blf_len, | 2494 | bp = xfs_buf_read(mp->m_ddev_targp, buf_f->blf_blkno, buf_f->blf_len, |
2497 | buf_flags, NULL); | 2495 | buf_flags, NULL); |
2498 | if (!bp) | 2496 | if (!bp) |
2499 | return XFS_ERROR(ENOMEM); | 2497 | return -ENOMEM; |
2500 | error = bp->b_error; | 2498 | error = bp->b_error; |
2501 | if (error) { | 2499 | if (error) { |
2502 | xfs_buf_ioerror_alert(bp, "xlog_recover_do..(read#1)"); | 2500 | xfs_buf_ioerror_alert(bp, "xlog_recover_do..(read#1)"); |
@@ -2504,23 +2502,44 @@ xlog_recover_buffer_pass2( | |||
2504 | } | 2502 | } |
2505 | 2503 | ||
2506 | /* | 2504 | /* |
2507 | * recover the buffer only if we get an LSN from it and it's less than | 2505 | * Recover the buffer only if we get an LSN from it and it's less than |
2508 | * the lsn of the transaction we are replaying. | 2506 | * the lsn of the transaction we are replaying. |
2507 | * | ||
2508 | * Note that we have to be extremely careful of readahead here. | ||
2509 | * Readahead does not attach verfiers to the buffers so if we don't | ||
2510 | * actually do any replay after readahead because of the LSN we found | ||
2511 | * in the buffer if more recent than that current transaction then we | ||
2512 | * need to attach the verifier directly. Failure to do so can lead to | ||
2513 | * future recovery actions (e.g. EFI and unlinked list recovery) can | ||
2514 | * operate on the buffers and they won't get the verifier attached. This | ||
2515 | * can lead to blocks on disk having the correct content but a stale | ||
2516 | * CRC. | ||
2517 | * | ||
2518 | * It is safe to assume these clean buffers are currently up to date. | ||
2519 | * If the buffer is dirtied by a later transaction being replayed, then | ||
2520 | * the verifier will be reset to match whatever recover turns that | ||
2521 | * buffer into. | ||
2509 | */ | 2522 | */ |
2510 | lsn = xlog_recover_get_buf_lsn(mp, bp); | 2523 | lsn = xlog_recover_get_buf_lsn(mp, bp); |
2511 | if (lsn && lsn != -1 && XFS_LSN_CMP(lsn, current_lsn) >= 0) | 2524 | if (lsn && lsn != -1 && XFS_LSN_CMP(lsn, current_lsn) >= 0) { |
2525 | xlog_recover_validate_buf_type(mp, bp, buf_f); | ||
2512 | goto out_release; | 2526 | goto out_release; |
2527 | } | ||
2513 | 2528 | ||
2514 | if (buf_f->blf_flags & XFS_BLF_INODE_BUF) { | 2529 | if (buf_f->blf_flags & XFS_BLF_INODE_BUF) { |
2515 | error = xlog_recover_do_inode_buffer(mp, item, bp, buf_f); | 2530 | error = xlog_recover_do_inode_buffer(mp, item, bp, buf_f); |
2531 | if (error) | ||
2532 | goto out_release; | ||
2516 | } else if (buf_f->blf_flags & | 2533 | } else if (buf_f->blf_flags & |
2517 | (XFS_BLF_UDQUOT_BUF|XFS_BLF_PDQUOT_BUF|XFS_BLF_GDQUOT_BUF)) { | 2534 | (XFS_BLF_UDQUOT_BUF|XFS_BLF_PDQUOT_BUF|XFS_BLF_GDQUOT_BUF)) { |
2518 | xlog_recover_do_dquot_buffer(mp, log, item, bp, buf_f); | 2535 | bool dirty; |
2536 | |||
2537 | dirty = xlog_recover_do_dquot_buffer(mp, log, item, bp, buf_f); | ||
2538 | if (!dirty) | ||
2539 | goto out_release; | ||
2519 | } else { | 2540 | } else { |
2520 | xlog_recover_do_reg_buffer(mp, item, bp, buf_f); | 2541 | xlog_recover_do_reg_buffer(mp, item, bp, buf_f); |
2521 | } | 2542 | } |
2522 | if (error) | ||
2523 | goto out_release; | ||
2524 | 2543 | ||
2525 | /* | 2544 | /* |
2526 | * Perform delayed write on the buffer. Asynchronous writes will be | 2545 | * Perform delayed write on the buffer. Asynchronous writes will be |
@@ -2598,7 +2617,7 @@ xfs_recover_inode_owner_change( | |||
2598 | 2617 | ||
2599 | ip = xfs_inode_alloc(mp, in_f->ilf_ino); | 2618 | ip = xfs_inode_alloc(mp, in_f->ilf_ino); |
2600 | if (!ip) | 2619 | if (!ip) |
2601 | return ENOMEM; | 2620 | return -ENOMEM; |
2602 | 2621 | ||
2603 | /* instantiate the inode */ | 2622 | /* instantiate the inode */ |
2604 | xfs_dinode_from_disk(&ip->i_d, dip); | 2623 | xfs_dinode_from_disk(&ip->i_d, dip); |
@@ -2676,7 +2695,7 @@ xlog_recover_inode_pass2( | |||
2676 | bp = xfs_buf_read(mp->m_ddev_targp, in_f->ilf_blkno, in_f->ilf_len, 0, | 2695 | bp = xfs_buf_read(mp->m_ddev_targp, in_f->ilf_blkno, in_f->ilf_len, 0, |
2677 | &xfs_inode_buf_ops); | 2696 | &xfs_inode_buf_ops); |
2678 | if (!bp) { | 2697 | if (!bp) { |
2679 | error = ENOMEM; | 2698 | error = -ENOMEM; |
2680 | goto error; | 2699 | goto error; |
2681 | } | 2700 | } |
2682 | error = bp->b_error; | 2701 | error = bp->b_error; |
@@ -2697,7 +2716,7 @@ xlog_recover_inode_pass2( | |||
2697 | __func__, dip, bp, in_f->ilf_ino); | 2716 | __func__, dip, bp, in_f->ilf_ino); |
2698 | XFS_ERROR_REPORT("xlog_recover_inode_pass2(1)", | 2717 | XFS_ERROR_REPORT("xlog_recover_inode_pass2(1)", |
2699 | XFS_ERRLEVEL_LOW, mp); | 2718 | XFS_ERRLEVEL_LOW, mp); |
2700 | error = EFSCORRUPTED; | 2719 | error = -EFSCORRUPTED; |
2701 | goto out_release; | 2720 | goto out_release; |
2702 | } | 2721 | } |
2703 | dicp = item->ri_buf[1].i_addr; | 2722 | dicp = item->ri_buf[1].i_addr; |
@@ -2707,7 +2726,7 @@ xlog_recover_inode_pass2( | |||
2707 | __func__, item, in_f->ilf_ino); | 2726 | __func__, item, in_f->ilf_ino); |
2708 | XFS_ERROR_REPORT("xlog_recover_inode_pass2(2)", | 2727 | XFS_ERROR_REPORT("xlog_recover_inode_pass2(2)", |
2709 | XFS_ERRLEVEL_LOW, mp); | 2728 | XFS_ERRLEVEL_LOW, mp); |
2710 | error = EFSCORRUPTED; | 2729 | error = -EFSCORRUPTED; |
2711 | goto out_release; | 2730 | goto out_release; |
2712 | } | 2731 | } |
2713 | 2732 | ||
@@ -2764,7 +2783,7 @@ xlog_recover_inode_pass2( | |||
2764 | "%s: Bad regular inode log record, rec ptr 0x%p, " | 2783 | "%s: Bad regular inode log record, rec ptr 0x%p, " |
2765 | "ino ptr = 0x%p, ino bp = 0x%p, ino %Ld", | 2784 | "ino ptr = 0x%p, ino bp = 0x%p, ino %Ld", |
2766 | __func__, item, dip, bp, in_f->ilf_ino); | 2785 | __func__, item, dip, bp, in_f->ilf_ino); |
2767 | error = EFSCORRUPTED; | 2786 | error = -EFSCORRUPTED; |
2768 | goto out_release; | 2787 | goto out_release; |
2769 | } | 2788 | } |
2770 | } else if (unlikely(S_ISDIR(dicp->di_mode))) { | 2789 | } else if (unlikely(S_ISDIR(dicp->di_mode))) { |
@@ -2777,7 +2796,7 @@ xlog_recover_inode_pass2( | |||
2777 | "%s: Bad dir inode log record, rec ptr 0x%p, " | 2796 | "%s: Bad dir inode log record, rec ptr 0x%p, " |
2778 | "ino ptr = 0x%p, ino bp = 0x%p, ino %Ld", | 2797 | "ino ptr = 0x%p, ino bp = 0x%p, ino %Ld", |
2779 | __func__, item, dip, bp, in_f->ilf_ino); | 2798 | __func__, item, dip, bp, in_f->ilf_ino); |
2780 | error = EFSCORRUPTED; | 2799 | error = -EFSCORRUPTED; |
2781 | goto out_release; | 2800 | goto out_release; |
2782 | } | 2801 | } |
2783 | } | 2802 | } |
@@ -2790,7 +2809,7 @@ xlog_recover_inode_pass2( | |||
2790 | __func__, item, dip, bp, in_f->ilf_ino, | 2809 | __func__, item, dip, bp, in_f->ilf_ino, |
2791 | dicp->di_nextents + dicp->di_anextents, | 2810 | dicp->di_nextents + dicp->di_anextents, |
2792 | dicp->di_nblocks); | 2811 | dicp->di_nblocks); |
2793 | error = EFSCORRUPTED; | 2812 | error = -EFSCORRUPTED; |
2794 | goto out_release; | 2813 | goto out_release; |
2795 | } | 2814 | } |
2796 | if (unlikely(dicp->di_forkoff > mp->m_sb.sb_inodesize)) { | 2815 | if (unlikely(dicp->di_forkoff > mp->m_sb.sb_inodesize)) { |
@@ -2800,7 +2819,7 @@ xlog_recover_inode_pass2( | |||
2800 | "%s: Bad inode log record, rec ptr 0x%p, dino ptr 0x%p, " | 2819 | "%s: Bad inode log record, rec ptr 0x%p, dino ptr 0x%p, " |
2801 | "dino bp 0x%p, ino %Ld, forkoff 0x%x", __func__, | 2820 | "dino bp 0x%p, ino %Ld, forkoff 0x%x", __func__, |
2802 | item, dip, bp, in_f->ilf_ino, dicp->di_forkoff); | 2821 | item, dip, bp, in_f->ilf_ino, dicp->di_forkoff); |
2803 | error = EFSCORRUPTED; | 2822 | error = -EFSCORRUPTED; |
2804 | goto out_release; | 2823 | goto out_release; |
2805 | } | 2824 | } |
2806 | isize = xfs_icdinode_size(dicp->di_version); | 2825 | isize = xfs_icdinode_size(dicp->di_version); |
@@ -2810,7 +2829,7 @@ xlog_recover_inode_pass2( | |||
2810 | xfs_alert(mp, | 2829 | xfs_alert(mp, |
2811 | "%s: Bad inode log record length %d, rec ptr 0x%p", | 2830 | "%s: Bad inode log record length %d, rec ptr 0x%p", |
2812 | __func__, item->ri_buf[1].i_len, item); | 2831 | __func__, item->ri_buf[1].i_len, item); |
2813 | error = EFSCORRUPTED; | 2832 | error = -EFSCORRUPTED; |
2814 | goto out_release; | 2833 | goto out_release; |
2815 | } | 2834 | } |
2816 | 2835 | ||
@@ -2898,7 +2917,7 @@ xlog_recover_inode_pass2( | |||
2898 | default: | 2917 | default: |
2899 | xfs_warn(log->l_mp, "%s: Invalid flag", __func__); | 2918 | xfs_warn(log->l_mp, "%s: Invalid flag", __func__); |
2900 | ASSERT(0); | 2919 | ASSERT(0); |
2901 | error = EIO; | 2920 | error = -EIO; |
2902 | goto out_release; | 2921 | goto out_release; |
2903 | } | 2922 | } |
2904 | } | 2923 | } |
@@ -2919,7 +2938,7 @@ out_release: | |||
2919 | error: | 2938 | error: |
2920 | if (need_free) | 2939 | if (need_free) |
2921 | kmem_free(in_f); | 2940 | kmem_free(in_f); |
2922 | return XFS_ERROR(error); | 2941 | return error; |
2923 | } | 2942 | } |
2924 | 2943 | ||
2925 | /* | 2944 | /* |
@@ -2946,7 +2965,7 @@ xlog_recover_quotaoff_pass1( | |||
2946 | if (qoff_f->qf_flags & XFS_GQUOTA_ACCT) | 2965 | if (qoff_f->qf_flags & XFS_GQUOTA_ACCT) |
2947 | log->l_quotaoffs_flag |= XFS_DQ_GROUP; | 2966 | log->l_quotaoffs_flag |= XFS_DQ_GROUP; |
2948 | 2967 | ||
2949 | return (0); | 2968 | return 0; |
2950 | } | 2969 | } |
2951 | 2970 | ||
2952 | /* | 2971 | /* |
@@ -2971,17 +2990,17 @@ xlog_recover_dquot_pass2( | |||
2971 | * Filesystems are required to send in quota flags at mount time. | 2990 | * Filesystems are required to send in quota flags at mount time. |
2972 | */ | 2991 | */ |
2973 | if (mp->m_qflags == 0) | 2992 | if (mp->m_qflags == 0) |
2974 | return (0); | 2993 | return 0; |
2975 | 2994 | ||
2976 | recddq = item->ri_buf[1].i_addr; | 2995 | recddq = item->ri_buf[1].i_addr; |
2977 | if (recddq == NULL) { | 2996 | if (recddq == NULL) { |
2978 | xfs_alert(log->l_mp, "NULL dquot in %s.", __func__); | 2997 | xfs_alert(log->l_mp, "NULL dquot in %s.", __func__); |
2979 | return XFS_ERROR(EIO); | 2998 | return -EIO; |
2980 | } | 2999 | } |
2981 | if (item->ri_buf[1].i_len < sizeof(xfs_disk_dquot_t)) { | 3000 | if (item->ri_buf[1].i_len < sizeof(xfs_disk_dquot_t)) { |
2982 | xfs_alert(log->l_mp, "dquot too small (%d) in %s.", | 3001 | xfs_alert(log->l_mp, "dquot too small (%d) in %s.", |
2983 | item->ri_buf[1].i_len, __func__); | 3002 | item->ri_buf[1].i_len, __func__); |
2984 | return XFS_ERROR(EIO); | 3003 | return -EIO; |
2985 | } | 3004 | } |
2986 | 3005 | ||
2987 | /* | 3006 | /* |
@@ -2990,7 +3009,7 @@ xlog_recover_dquot_pass2( | |||
2990 | type = recddq->d_flags & (XFS_DQ_USER | XFS_DQ_PROJ | XFS_DQ_GROUP); | 3009 | type = recddq->d_flags & (XFS_DQ_USER | XFS_DQ_PROJ | XFS_DQ_GROUP); |
2991 | ASSERT(type); | 3010 | ASSERT(type); |
2992 | if (log->l_quotaoffs_flag & type) | 3011 | if (log->l_quotaoffs_flag & type) |
2993 | return (0); | 3012 | return 0; |
2994 | 3013 | ||
2995 | /* | 3014 | /* |
2996 | * At this point we know that quota was _not_ turned off. | 3015 | * At this point we know that quota was _not_ turned off. |
@@ -3007,12 +3026,19 @@ xlog_recover_dquot_pass2( | |||
3007 | error = xfs_dqcheck(mp, recddq, dq_f->qlf_id, 0, XFS_QMOPT_DOWARN, | 3026 | error = xfs_dqcheck(mp, recddq, dq_f->qlf_id, 0, XFS_QMOPT_DOWARN, |
3008 | "xlog_recover_dquot_pass2 (log copy)"); | 3027 | "xlog_recover_dquot_pass2 (log copy)"); |
3009 | if (error) | 3028 | if (error) |
3010 | return XFS_ERROR(EIO); | 3029 | return -EIO; |
3011 | ASSERT(dq_f->qlf_len == 1); | 3030 | ASSERT(dq_f->qlf_len == 1); |
3012 | 3031 | ||
3032 | /* | ||
3033 | * At this point we are assuming that the dquots have been allocated | ||
3034 | * and hence the buffer has valid dquots stamped in it. It should, | ||
3035 | * therefore, pass verifier validation. If the dquot is bad, then the | ||
3036 | * we'll return an error here, so we don't need to specifically check | ||
3037 | * the dquot in the buffer after the verifier has run. | ||
3038 | */ | ||
3013 | error = xfs_trans_read_buf(mp, NULL, mp->m_ddev_targp, dq_f->qlf_blkno, | 3039 | error = xfs_trans_read_buf(mp, NULL, mp->m_ddev_targp, dq_f->qlf_blkno, |
3014 | XFS_FSB_TO_BB(mp, dq_f->qlf_len), 0, &bp, | 3040 | XFS_FSB_TO_BB(mp, dq_f->qlf_len), 0, &bp, |
3015 | NULL); | 3041 | &xfs_dquot_buf_ops); |
3016 | if (error) | 3042 | if (error) |
3017 | return error; | 3043 | return error; |
3018 | 3044 | ||
@@ -3020,18 +3046,6 @@ xlog_recover_dquot_pass2( | |||
3020 | ddq = (xfs_disk_dquot_t *)xfs_buf_offset(bp, dq_f->qlf_boffset); | 3046 | ddq = (xfs_disk_dquot_t *)xfs_buf_offset(bp, dq_f->qlf_boffset); |
3021 | 3047 | ||
3022 | /* | 3048 | /* |
3023 | * At least the magic num portion should be on disk because this | ||
3024 | * was among a chunk of dquots created earlier, and we did some | ||
3025 | * minimal initialization then. | ||
3026 | */ | ||
3027 | error = xfs_dqcheck(mp, ddq, dq_f->qlf_id, 0, XFS_QMOPT_DOWARN, | ||
3028 | "xlog_recover_dquot_pass2"); | ||
3029 | if (error) { | ||
3030 | xfs_buf_relse(bp); | ||
3031 | return XFS_ERROR(EIO); | ||
3032 | } | ||
3033 | |||
3034 | /* | ||
3035 | * If the dquot has an LSN in it, recover the dquot only if it's less | 3049 | * If the dquot has an LSN in it, recover the dquot only if it's less |
3036 | * than the lsn of the transaction we are replaying. | 3050 | * than the lsn of the transaction we are replaying. |
3037 | */ | 3051 | */ |
@@ -3178,38 +3192,38 @@ xlog_recover_do_icreate_pass2( | |||
3178 | icl = (struct xfs_icreate_log *)item->ri_buf[0].i_addr; | 3192 | icl = (struct xfs_icreate_log *)item->ri_buf[0].i_addr; |
3179 | if (icl->icl_type != XFS_LI_ICREATE) { | 3193 | if (icl->icl_type != XFS_LI_ICREATE) { |
3180 | xfs_warn(log->l_mp, "xlog_recover_do_icreate_trans: bad type"); | 3194 | xfs_warn(log->l_mp, "xlog_recover_do_icreate_trans: bad type"); |
3181 | return EINVAL; | 3195 | return -EINVAL; |
3182 | } | 3196 | } |
3183 | 3197 | ||
3184 | if (icl->icl_size != 1) { | 3198 | if (icl->icl_size != 1) { |
3185 | xfs_warn(log->l_mp, "xlog_recover_do_icreate_trans: bad icl size"); | 3199 | xfs_warn(log->l_mp, "xlog_recover_do_icreate_trans: bad icl size"); |
3186 | return EINVAL; | 3200 | return -EINVAL; |
3187 | } | 3201 | } |
3188 | 3202 | ||
3189 | agno = be32_to_cpu(icl->icl_ag); | 3203 | agno = be32_to_cpu(icl->icl_ag); |
3190 | if (agno >= mp->m_sb.sb_agcount) { | 3204 | if (agno >= mp->m_sb.sb_agcount) { |
3191 | xfs_warn(log->l_mp, "xlog_recover_do_icreate_trans: bad agno"); | 3205 | xfs_warn(log->l_mp, "xlog_recover_do_icreate_trans: bad agno"); |
3192 | return EINVAL; | 3206 | return -EINVAL; |
3193 | } | 3207 | } |
3194 | agbno = be32_to_cpu(icl->icl_agbno); | 3208 | agbno = be32_to_cpu(icl->icl_agbno); |
3195 | if (!agbno || agbno == NULLAGBLOCK || agbno >= mp->m_sb.sb_agblocks) { | 3209 | if (!agbno || agbno == NULLAGBLOCK || agbno >= mp->m_sb.sb_agblocks) { |
3196 | xfs_warn(log->l_mp, "xlog_recover_do_icreate_trans: bad agbno"); | 3210 | xfs_warn(log->l_mp, "xlog_recover_do_icreate_trans: bad agbno"); |
3197 | return EINVAL; | 3211 | return -EINVAL; |
3198 | } | 3212 | } |
3199 | isize = be32_to_cpu(icl->icl_isize); | 3213 | isize = be32_to_cpu(icl->icl_isize); |
3200 | if (isize != mp->m_sb.sb_inodesize) { | 3214 | if (isize != mp->m_sb.sb_inodesize) { |
3201 | xfs_warn(log->l_mp, "xlog_recover_do_icreate_trans: bad isize"); | 3215 | xfs_warn(log->l_mp, "xlog_recover_do_icreate_trans: bad isize"); |
3202 | return EINVAL; | 3216 | return -EINVAL; |
3203 | } | 3217 | } |
3204 | count = be32_to_cpu(icl->icl_count); | 3218 | count = be32_to_cpu(icl->icl_count); |
3205 | if (!count) { | 3219 | if (!count) { |
3206 | xfs_warn(log->l_mp, "xlog_recover_do_icreate_trans: bad count"); | 3220 | xfs_warn(log->l_mp, "xlog_recover_do_icreate_trans: bad count"); |
3207 | return EINVAL; | 3221 | return -EINVAL; |
3208 | } | 3222 | } |
3209 | length = be32_to_cpu(icl->icl_length); | 3223 | length = be32_to_cpu(icl->icl_length); |
3210 | if (!length || length >= mp->m_sb.sb_agblocks) { | 3224 | if (!length || length >= mp->m_sb.sb_agblocks) { |
3211 | xfs_warn(log->l_mp, "xlog_recover_do_icreate_trans: bad length"); | 3225 | xfs_warn(log->l_mp, "xlog_recover_do_icreate_trans: bad length"); |
3212 | return EINVAL; | 3226 | return -EINVAL; |
3213 | } | 3227 | } |
3214 | 3228 | ||
3215 | /* existing allocation is fixed value */ | 3229 | /* existing allocation is fixed value */ |
@@ -3218,7 +3232,7 @@ xlog_recover_do_icreate_pass2( | |||
3218 | if (count != mp->m_ialloc_inos || | 3232 | if (count != mp->m_ialloc_inos || |
3219 | length != mp->m_ialloc_blks) { | 3233 | length != mp->m_ialloc_blks) { |
3220 | xfs_warn(log->l_mp, "xlog_recover_do_icreate_trans: bad count 2"); | 3234 | xfs_warn(log->l_mp, "xlog_recover_do_icreate_trans: bad count 2"); |
3221 | return EINVAL; | 3235 | return -EINVAL; |
3222 | } | 3236 | } |
3223 | 3237 | ||
3224 | /* | 3238 | /* |
@@ -3389,7 +3403,7 @@ xlog_recover_commit_pass1( | |||
3389 | xfs_warn(log->l_mp, "%s: invalid item type (%d)", | 3403 | xfs_warn(log->l_mp, "%s: invalid item type (%d)", |
3390 | __func__, ITEM_TYPE(item)); | 3404 | __func__, ITEM_TYPE(item)); |
3391 | ASSERT(0); | 3405 | ASSERT(0); |
3392 | return XFS_ERROR(EIO); | 3406 | return -EIO; |
3393 | } | 3407 | } |
3394 | } | 3408 | } |
3395 | 3409 | ||
@@ -3425,7 +3439,7 @@ xlog_recover_commit_pass2( | |||
3425 | xfs_warn(log->l_mp, "%s: invalid item type (%d)", | 3439 | xfs_warn(log->l_mp, "%s: invalid item type (%d)", |
3426 | __func__, ITEM_TYPE(item)); | 3440 | __func__, ITEM_TYPE(item)); |
3427 | ASSERT(0); | 3441 | ASSERT(0); |
3428 | return XFS_ERROR(EIO); | 3442 | return -EIO; |
3429 | } | 3443 | } |
3430 | } | 3444 | } |
3431 | 3445 | ||
@@ -3560,7 +3574,7 @@ xlog_recover_process_data( | |||
3560 | 3574 | ||
3561 | /* check the log format matches our own - else we can't recover */ | 3575 | /* check the log format matches our own - else we can't recover */ |
3562 | if (xlog_header_check_recover(log->l_mp, rhead)) | 3576 | if (xlog_header_check_recover(log->l_mp, rhead)) |
3563 | return (XFS_ERROR(EIO)); | 3577 | return -EIO; |
3564 | 3578 | ||
3565 | while ((dp < lp) && num_logops) { | 3579 | while ((dp < lp) && num_logops) { |
3566 | ASSERT(dp + sizeof(xlog_op_header_t) <= lp); | 3580 | ASSERT(dp + sizeof(xlog_op_header_t) <= lp); |
@@ -3571,7 +3585,7 @@ xlog_recover_process_data( | |||
3571 | xfs_warn(log->l_mp, "%s: bad clientid 0x%x", | 3585 | xfs_warn(log->l_mp, "%s: bad clientid 0x%x", |
3572 | __func__, ohead->oh_clientid); | 3586 | __func__, ohead->oh_clientid); |
3573 | ASSERT(0); | 3587 | ASSERT(0); |
3574 | return (XFS_ERROR(EIO)); | 3588 | return -EIO; |
3575 | } | 3589 | } |
3576 | tid = be32_to_cpu(ohead->oh_tid); | 3590 | tid = be32_to_cpu(ohead->oh_tid); |
3577 | hash = XLOG_RHASH(tid); | 3591 | hash = XLOG_RHASH(tid); |
@@ -3585,7 +3599,7 @@ xlog_recover_process_data( | |||
3585 | xfs_warn(log->l_mp, "%s: bad length 0x%x", | 3599 | xfs_warn(log->l_mp, "%s: bad length 0x%x", |
3586 | __func__, be32_to_cpu(ohead->oh_len)); | 3600 | __func__, be32_to_cpu(ohead->oh_len)); |
3587 | WARN_ON(1); | 3601 | WARN_ON(1); |
3588 | return (XFS_ERROR(EIO)); | 3602 | return -EIO; |
3589 | } | 3603 | } |
3590 | flags = ohead->oh_flags & ~XLOG_END_TRANS; | 3604 | flags = ohead->oh_flags & ~XLOG_END_TRANS; |
3591 | if (flags & XLOG_WAS_CONT_TRANS) | 3605 | if (flags & XLOG_WAS_CONT_TRANS) |
@@ -3607,7 +3621,7 @@ xlog_recover_process_data( | |||
3607 | xfs_warn(log->l_mp, "%s: bad transaction", | 3621 | xfs_warn(log->l_mp, "%s: bad transaction", |
3608 | __func__); | 3622 | __func__); |
3609 | ASSERT(0); | 3623 | ASSERT(0); |
3610 | error = XFS_ERROR(EIO); | 3624 | error = -EIO; |
3611 | break; | 3625 | break; |
3612 | case 0: | 3626 | case 0: |
3613 | case XLOG_CONTINUE_TRANS: | 3627 | case XLOG_CONTINUE_TRANS: |
@@ -3618,7 +3632,7 @@ xlog_recover_process_data( | |||
3618 | xfs_warn(log->l_mp, "%s: bad flag 0x%x", | 3632 | xfs_warn(log->l_mp, "%s: bad flag 0x%x", |
3619 | __func__, flags); | 3633 | __func__, flags); |
3620 | ASSERT(0); | 3634 | ASSERT(0); |
3621 | error = XFS_ERROR(EIO); | 3635 | error = -EIO; |
3622 | break; | 3636 | break; |
3623 | } | 3637 | } |
3624 | if (error) { | 3638 | if (error) { |
@@ -3669,7 +3683,7 @@ xlog_recover_process_efi( | |||
3669 | */ | 3683 | */ |
3670 | set_bit(XFS_EFI_RECOVERED, &efip->efi_flags); | 3684 | set_bit(XFS_EFI_RECOVERED, &efip->efi_flags); |
3671 | xfs_efi_release(efip, efip->efi_format.efi_nextents); | 3685 | xfs_efi_release(efip, efip->efi_format.efi_nextents); |
3672 | return XFS_ERROR(EIO); | 3686 | return -EIO; |
3673 | } | 3687 | } |
3674 | } | 3688 | } |
3675 | 3689 | ||
@@ -3969,7 +3983,7 @@ xlog_unpack_data_crc( | |||
3969 | * CRC protection by punting an error back up the stack. | 3983 | * CRC protection by punting an error back up the stack. |
3970 | */ | 3984 | */ |
3971 | if (xfs_sb_version_hascrc(&log->l_mp->m_sb)) | 3985 | if (xfs_sb_version_hascrc(&log->l_mp->m_sb)) |
3972 | return EFSCORRUPTED; | 3986 | return -EFSCORRUPTED; |
3973 | } | 3987 | } |
3974 | 3988 | ||
3975 | return 0; | 3989 | return 0; |
@@ -4018,14 +4032,14 @@ xlog_valid_rec_header( | |||
4018 | if (unlikely(rhead->h_magicno != cpu_to_be32(XLOG_HEADER_MAGIC_NUM))) { | 4032 | if (unlikely(rhead->h_magicno != cpu_to_be32(XLOG_HEADER_MAGIC_NUM))) { |
4019 | XFS_ERROR_REPORT("xlog_valid_rec_header(1)", | 4033 | XFS_ERROR_REPORT("xlog_valid_rec_header(1)", |
4020 | XFS_ERRLEVEL_LOW, log->l_mp); | 4034 | XFS_ERRLEVEL_LOW, log->l_mp); |
4021 | return XFS_ERROR(EFSCORRUPTED); | 4035 | return -EFSCORRUPTED; |
4022 | } | 4036 | } |
4023 | if (unlikely( | 4037 | if (unlikely( |
4024 | (!rhead->h_version || | 4038 | (!rhead->h_version || |
4025 | (be32_to_cpu(rhead->h_version) & (~XLOG_VERSION_OKBITS))))) { | 4039 | (be32_to_cpu(rhead->h_version) & (~XLOG_VERSION_OKBITS))))) { |
4026 | xfs_warn(log->l_mp, "%s: unrecognised log version (%d).", | 4040 | xfs_warn(log->l_mp, "%s: unrecognised log version (%d).", |
4027 | __func__, be32_to_cpu(rhead->h_version)); | 4041 | __func__, be32_to_cpu(rhead->h_version)); |
4028 | return XFS_ERROR(EIO); | 4042 | return -EIO; |
4029 | } | 4043 | } |
4030 | 4044 | ||
4031 | /* LR body must have data or it wouldn't have been written */ | 4045 | /* LR body must have data or it wouldn't have been written */ |
@@ -4033,12 +4047,12 @@ xlog_valid_rec_header( | |||
4033 | if (unlikely( hlen <= 0 || hlen > INT_MAX )) { | 4047 | if (unlikely( hlen <= 0 || hlen > INT_MAX )) { |
4034 | XFS_ERROR_REPORT("xlog_valid_rec_header(2)", | 4048 | XFS_ERROR_REPORT("xlog_valid_rec_header(2)", |
4035 | XFS_ERRLEVEL_LOW, log->l_mp); | 4049 | XFS_ERRLEVEL_LOW, log->l_mp); |
4036 | return XFS_ERROR(EFSCORRUPTED); | 4050 | return -EFSCORRUPTED; |
4037 | } | 4051 | } |
4038 | if (unlikely( blkno > log->l_logBBsize || blkno > INT_MAX )) { | 4052 | if (unlikely( blkno > log->l_logBBsize || blkno > INT_MAX )) { |
4039 | XFS_ERROR_REPORT("xlog_valid_rec_header(3)", | 4053 | XFS_ERROR_REPORT("xlog_valid_rec_header(3)", |
4040 | XFS_ERRLEVEL_LOW, log->l_mp); | 4054 | XFS_ERRLEVEL_LOW, log->l_mp); |
4041 | return XFS_ERROR(EFSCORRUPTED); | 4055 | return -EFSCORRUPTED; |
4042 | } | 4056 | } |
4043 | return 0; | 4057 | return 0; |
4044 | } | 4058 | } |
@@ -4081,7 +4095,7 @@ xlog_do_recovery_pass( | |||
4081 | */ | 4095 | */ |
4082 | hbp = xlog_get_bp(log, 1); | 4096 | hbp = xlog_get_bp(log, 1); |
4083 | if (!hbp) | 4097 | if (!hbp) |
4084 | return ENOMEM; | 4098 | return -ENOMEM; |
4085 | 4099 | ||
4086 | error = xlog_bread(log, tail_blk, 1, hbp, &offset); | 4100 | error = xlog_bread(log, tail_blk, 1, hbp, &offset); |
4087 | if (error) | 4101 | if (error) |
@@ -4110,11 +4124,11 @@ xlog_do_recovery_pass( | |||
4110 | } | 4124 | } |
4111 | 4125 | ||
4112 | if (!hbp) | 4126 | if (!hbp) |
4113 | return ENOMEM; | 4127 | return -ENOMEM; |
4114 | dbp = xlog_get_bp(log, BTOBB(h_size)); | 4128 | dbp = xlog_get_bp(log, BTOBB(h_size)); |
4115 | if (!dbp) { | 4129 | if (!dbp) { |
4116 | xlog_put_bp(hbp); | 4130 | xlog_put_bp(hbp); |
4117 | return ENOMEM; | 4131 | return -ENOMEM; |
4118 | } | 4132 | } |
4119 | 4133 | ||
4120 | memset(rhash, 0, sizeof(rhash)); | 4134 | memset(rhash, 0, sizeof(rhash)); |
@@ -4388,7 +4402,7 @@ xlog_do_recover( | |||
4388 | * If IO errors happened during recovery, bail out. | 4402 | * If IO errors happened during recovery, bail out. |
4389 | */ | 4403 | */ |
4390 | if (XFS_FORCED_SHUTDOWN(log->l_mp)) { | 4404 | if (XFS_FORCED_SHUTDOWN(log->l_mp)) { |
4391 | return (EIO); | 4405 | return -EIO; |
4392 | } | 4406 | } |
4393 | 4407 | ||
4394 | /* | 4408 | /* |
@@ -4415,7 +4429,7 @@ xlog_do_recover( | |||
4415 | 4429 | ||
4416 | if (XFS_FORCED_SHUTDOWN(log->l_mp)) { | 4430 | if (XFS_FORCED_SHUTDOWN(log->l_mp)) { |
4417 | xfs_buf_relse(bp); | 4431 | xfs_buf_relse(bp); |
4418 | return XFS_ERROR(EIO); | 4432 | return -EIO; |
4419 | } | 4433 | } |
4420 | 4434 | ||
4421 | xfs_buf_iorequest(bp); | 4435 | xfs_buf_iorequest(bp); |
@@ -4492,7 +4506,7 @@ xlog_recover( | |||
4492 | "Please recover the log on a kernel that supports the unknown features.", | 4506 | "Please recover the log on a kernel that supports the unknown features.", |
4493 | (log->l_mp->m_sb.sb_features_log_incompat & | 4507 | (log->l_mp->m_sb.sb_features_log_incompat & |
4494 | XFS_SB_FEAT_INCOMPAT_LOG_UNKNOWN)); | 4508 | XFS_SB_FEAT_INCOMPAT_LOG_UNKNOWN)); |
4495 | return EINVAL; | 4509 | return -EINVAL; |
4496 | } | 4510 | } |
4497 | 4511 | ||
4498 | xfs_notice(log->l_mp, "Starting recovery (logdev: %s)", | 4512 | 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..fbf0384a466f 100644 --- a/fs/xfs/xfs_mount.c +++ b/fs/xfs/xfs_mount.c | |||
@@ -42,6 +42,7 @@ | |||
42 | #include "xfs_trace.h" | 42 | #include "xfs_trace.h" |
43 | #include "xfs_icache.h" | 43 | #include "xfs_icache.h" |
44 | #include "xfs_dinode.h" | 44 | #include "xfs_dinode.h" |
45 | #include "xfs_sysfs.h" | ||
45 | 46 | ||
46 | 47 | ||
47 | #ifdef HAVE_PERCPU_SB | 48 | #ifdef HAVE_PERCPU_SB |
@@ -60,6 +61,8 @@ static DEFINE_MUTEX(xfs_uuid_table_mutex); | |||
60 | static int xfs_uuid_table_size; | 61 | static int xfs_uuid_table_size; |
61 | static uuid_t *xfs_uuid_table; | 62 | static uuid_t *xfs_uuid_table; |
62 | 63 | ||
64 | extern struct kset *xfs_kset; | ||
65 | |||
63 | /* | 66 | /* |
64 | * See if the UUID is unique among mounted XFS filesystems. | 67 | * See if the UUID is unique among mounted XFS filesystems. |
65 | * Mount fails if UUID is nil or a FS with the same UUID is already mounted. | 68 | * Mount fails if UUID is nil or a FS with the same UUID is already mounted. |
@@ -76,7 +79,7 @@ xfs_uuid_mount( | |||
76 | 79 | ||
77 | if (uuid_is_nil(uuid)) { | 80 | if (uuid_is_nil(uuid)) { |
78 | xfs_warn(mp, "Filesystem has nil UUID - can't mount"); | 81 | xfs_warn(mp, "Filesystem has nil UUID - can't mount"); |
79 | return XFS_ERROR(EINVAL); | 82 | return -EINVAL; |
80 | } | 83 | } |
81 | 84 | ||
82 | mutex_lock(&xfs_uuid_table_mutex); | 85 | mutex_lock(&xfs_uuid_table_mutex); |
@@ -104,7 +107,7 @@ xfs_uuid_mount( | |||
104 | out_duplicate: | 107 | out_duplicate: |
105 | mutex_unlock(&xfs_uuid_table_mutex); | 108 | mutex_unlock(&xfs_uuid_table_mutex); |
106 | xfs_warn(mp, "Filesystem has duplicate UUID %pU - can't mount", uuid); | 109 | xfs_warn(mp, "Filesystem has duplicate UUID %pU - can't mount", uuid); |
107 | return XFS_ERROR(EINVAL); | 110 | return -EINVAL; |
108 | } | 111 | } |
109 | 112 | ||
110 | STATIC void | 113 | STATIC void |
@@ -173,13 +176,9 @@ xfs_sb_validate_fsb_count( | |||
173 | ASSERT(PAGE_SHIFT >= sbp->sb_blocklog); | 176 | ASSERT(PAGE_SHIFT >= sbp->sb_blocklog); |
174 | ASSERT(sbp->sb_blocklog >= BBSHIFT); | 177 | ASSERT(sbp->sb_blocklog >= BBSHIFT); |
175 | 178 | ||
176 | #if XFS_BIG_BLKNOS /* Limited by ULONG_MAX of page cache index */ | 179 | /* Limited by ULONG_MAX of page cache index */ |
177 | if (nblocks >> (PAGE_CACHE_SHIFT - sbp->sb_blocklog) > ULONG_MAX) | 180 | if (nblocks >> (PAGE_CACHE_SHIFT - sbp->sb_blocklog) > ULONG_MAX) |
178 | return EFBIG; | 181 | return -EFBIG; |
179 | #else /* Limited by UINT_MAX of sectors */ | ||
180 | if (nblocks << (sbp->sb_blocklog - BBSHIFT) > UINT_MAX) | ||
181 | return EFBIG; | ||
182 | #endif | ||
183 | return 0; | 182 | return 0; |
184 | } | 183 | } |
185 | 184 | ||
@@ -250,9 +249,9 @@ xfs_initialize_perag( | |||
250 | mp->m_flags &= ~XFS_MOUNT_32BITINODES; | 249 | mp->m_flags &= ~XFS_MOUNT_32BITINODES; |
251 | 250 | ||
252 | if (mp->m_flags & XFS_MOUNT_32BITINODES) | 251 | if (mp->m_flags & XFS_MOUNT_32BITINODES) |
253 | index = xfs_set_inode32(mp); | 252 | index = xfs_set_inode32(mp, agcount); |
254 | else | 253 | else |
255 | index = xfs_set_inode64(mp); | 254 | index = xfs_set_inode64(mp, agcount); |
256 | 255 | ||
257 | if (maxagi) | 256 | if (maxagi) |
258 | *maxagi = index; | 257 | *maxagi = index; |
@@ -308,15 +307,15 @@ reread: | |||
308 | if (!bp) { | 307 | if (!bp) { |
309 | if (loud) | 308 | if (loud) |
310 | xfs_warn(mp, "SB buffer read failed"); | 309 | xfs_warn(mp, "SB buffer read failed"); |
311 | return EIO; | 310 | return -EIO; |
312 | } | 311 | } |
313 | if (bp->b_error) { | 312 | if (bp->b_error) { |
314 | error = bp->b_error; | 313 | error = bp->b_error; |
315 | if (loud) | 314 | if (loud) |
316 | xfs_warn(mp, "SB validate failed with error %d.", error); | 315 | xfs_warn(mp, "SB validate failed with error %d.", error); |
317 | /* bad CRC means corrupted metadata */ | 316 | /* bad CRC means corrupted metadata */ |
318 | if (error == EFSBADCRC) | 317 | if (error == -EFSBADCRC) |
319 | error = EFSCORRUPTED; | 318 | error = -EFSCORRUPTED; |
320 | goto release_buf; | 319 | goto release_buf; |
321 | } | 320 | } |
322 | 321 | ||
@@ -324,7 +323,6 @@ reread: | |||
324 | * Initialize the mount structure from the superblock. | 323 | * Initialize the mount structure from the superblock. |
325 | */ | 324 | */ |
326 | xfs_sb_from_disk(sbp, XFS_BUF_TO_SBP(bp)); | 325 | xfs_sb_from_disk(sbp, XFS_BUF_TO_SBP(bp)); |
327 | xfs_sb_quota_from_disk(sbp); | ||
328 | 326 | ||
329 | /* | 327 | /* |
330 | * If we haven't validated the superblock, do so now before we try | 328 | * If we haven't validated the superblock, do so now before we try |
@@ -333,7 +331,7 @@ reread: | |||
333 | if (sbp->sb_magicnum != XFS_SB_MAGIC) { | 331 | if (sbp->sb_magicnum != XFS_SB_MAGIC) { |
334 | if (loud) | 332 | if (loud) |
335 | xfs_warn(mp, "Invalid superblock magic number"); | 333 | xfs_warn(mp, "Invalid superblock magic number"); |
336 | error = EINVAL; | 334 | error = -EINVAL; |
337 | goto release_buf; | 335 | goto release_buf; |
338 | } | 336 | } |
339 | 337 | ||
@@ -344,7 +342,7 @@ reread: | |||
344 | if (loud) | 342 | if (loud) |
345 | xfs_warn(mp, "device supports %u byte sectors (not %u)", | 343 | xfs_warn(mp, "device supports %u byte sectors (not %u)", |
346 | sector_size, sbp->sb_sectsize); | 344 | sector_size, sbp->sb_sectsize); |
347 | error = ENOSYS; | 345 | error = -ENOSYS; |
348 | goto release_buf; | 346 | goto release_buf; |
349 | } | 347 | } |
350 | 348 | ||
@@ -392,7 +390,7 @@ xfs_update_alignment(xfs_mount_t *mp) | |||
392 | xfs_warn(mp, | 390 | xfs_warn(mp, |
393 | "alignment check failed: sunit/swidth vs. blocksize(%d)", | 391 | "alignment check failed: sunit/swidth vs. blocksize(%d)", |
394 | sbp->sb_blocksize); | 392 | sbp->sb_blocksize); |
395 | return XFS_ERROR(EINVAL); | 393 | return -EINVAL; |
396 | } else { | 394 | } else { |
397 | /* | 395 | /* |
398 | * Convert the stripe unit and width to FSBs. | 396 | * Convert the stripe unit and width to FSBs. |
@@ -402,14 +400,14 @@ xfs_update_alignment(xfs_mount_t *mp) | |||
402 | xfs_warn(mp, | 400 | xfs_warn(mp, |
403 | "alignment check failed: sunit/swidth vs. agsize(%d)", | 401 | "alignment check failed: sunit/swidth vs. agsize(%d)", |
404 | sbp->sb_agblocks); | 402 | sbp->sb_agblocks); |
405 | return XFS_ERROR(EINVAL); | 403 | return -EINVAL; |
406 | } else if (mp->m_dalign) { | 404 | } else if (mp->m_dalign) { |
407 | mp->m_swidth = XFS_BB_TO_FSBT(mp, mp->m_swidth); | 405 | mp->m_swidth = XFS_BB_TO_FSBT(mp, mp->m_swidth); |
408 | } else { | 406 | } else { |
409 | xfs_warn(mp, | 407 | xfs_warn(mp, |
410 | "alignment check failed: sunit(%d) less than bsize(%d)", | 408 | "alignment check failed: sunit(%d) less than bsize(%d)", |
411 | mp->m_dalign, sbp->sb_blocksize); | 409 | mp->m_dalign, sbp->sb_blocksize); |
412 | return XFS_ERROR(EINVAL); | 410 | return -EINVAL; |
413 | } | 411 | } |
414 | } | 412 | } |
415 | 413 | ||
@@ -429,7 +427,7 @@ xfs_update_alignment(xfs_mount_t *mp) | |||
429 | } else { | 427 | } else { |
430 | xfs_warn(mp, | 428 | xfs_warn(mp, |
431 | "cannot change alignment: superblock does not support data alignment"); | 429 | "cannot change alignment: superblock does not support data alignment"); |
432 | return XFS_ERROR(EINVAL); | 430 | return -EINVAL; |
433 | } | 431 | } |
434 | } else if ((mp->m_flags & XFS_MOUNT_NOALIGN) != XFS_MOUNT_NOALIGN && | 432 | } else if ((mp->m_flags & XFS_MOUNT_NOALIGN) != XFS_MOUNT_NOALIGN && |
435 | xfs_sb_version_hasdalign(&mp->m_sb)) { | 433 | xfs_sb_version_hasdalign(&mp->m_sb)) { |
@@ -556,14 +554,14 @@ xfs_check_sizes(xfs_mount_t *mp) | |||
556 | d = (xfs_daddr_t)XFS_FSB_TO_BB(mp, mp->m_sb.sb_dblocks); | 554 | 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) { | 555 | if (XFS_BB_TO_FSB(mp, d) != mp->m_sb.sb_dblocks) { |
558 | xfs_warn(mp, "filesystem size mismatch detected"); | 556 | xfs_warn(mp, "filesystem size mismatch detected"); |
559 | return XFS_ERROR(EFBIG); | 557 | return -EFBIG; |
560 | } | 558 | } |
561 | bp = xfs_buf_read_uncached(mp->m_ddev_targp, | 559 | bp = xfs_buf_read_uncached(mp->m_ddev_targp, |
562 | d - XFS_FSS_TO_BB(mp, 1), | 560 | d - XFS_FSS_TO_BB(mp, 1), |
563 | XFS_FSS_TO_BB(mp, 1), 0, NULL); | 561 | XFS_FSS_TO_BB(mp, 1), 0, NULL); |
564 | if (!bp) { | 562 | if (!bp) { |
565 | xfs_warn(mp, "last sector read failed"); | 563 | xfs_warn(mp, "last sector read failed"); |
566 | return EIO; | 564 | return -EIO; |
567 | } | 565 | } |
568 | xfs_buf_relse(bp); | 566 | xfs_buf_relse(bp); |
569 | 567 | ||
@@ -571,14 +569,14 @@ xfs_check_sizes(xfs_mount_t *mp) | |||
571 | d = (xfs_daddr_t)XFS_FSB_TO_BB(mp, mp->m_sb.sb_logblocks); | 569 | 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) { | 570 | if (XFS_BB_TO_FSB(mp, d) != mp->m_sb.sb_logblocks) { |
573 | xfs_warn(mp, "log size mismatch detected"); | 571 | xfs_warn(mp, "log size mismatch detected"); |
574 | return XFS_ERROR(EFBIG); | 572 | return -EFBIG; |
575 | } | 573 | } |
576 | bp = xfs_buf_read_uncached(mp->m_logdev_targp, | 574 | bp = xfs_buf_read_uncached(mp->m_logdev_targp, |
577 | d - XFS_FSB_TO_BB(mp, 1), | 575 | d - XFS_FSB_TO_BB(mp, 1), |
578 | XFS_FSB_TO_BB(mp, 1), 0, NULL); | 576 | XFS_FSB_TO_BB(mp, 1), 0, NULL); |
579 | if (!bp) { | 577 | if (!bp) { |
580 | xfs_warn(mp, "log device read failed"); | 578 | xfs_warn(mp, "log device read failed"); |
581 | return EIO; | 579 | return -EIO; |
582 | } | 580 | } |
583 | xfs_buf_relse(bp); | 581 | xfs_buf_relse(bp); |
584 | } | 582 | } |
@@ -731,10 +729,15 @@ xfs_mountfs( | |||
731 | 729 | ||
732 | xfs_set_maxicount(mp); | 730 | xfs_set_maxicount(mp); |
733 | 731 | ||
734 | error = xfs_uuid_mount(mp); | 732 | mp->m_kobj.kobject.kset = xfs_kset; |
733 | error = xfs_sysfs_init(&mp->m_kobj, &xfs_mp_ktype, NULL, mp->m_fsname); | ||
735 | if (error) | 734 | if (error) |
736 | goto out; | 735 | goto out; |
737 | 736 | ||
737 | error = xfs_uuid_mount(mp); | ||
738 | if (error) | ||
739 | goto out_remove_sysfs; | ||
740 | |||
738 | /* | 741 | /* |
739 | * Set the minimum read and write sizes | 742 | * Set the minimum read and write sizes |
740 | */ | 743 | */ |
@@ -816,7 +819,7 @@ xfs_mountfs( | |||
816 | if (!sbp->sb_logblocks) { | 819 | if (!sbp->sb_logblocks) { |
817 | xfs_warn(mp, "no log defined"); | 820 | xfs_warn(mp, "no log defined"); |
818 | XFS_ERROR_REPORT("xfs_mountfs", XFS_ERRLEVEL_LOW, mp); | 821 | XFS_ERROR_REPORT("xfs_mountfs", XFS_ERRLEVEL_LOW, mp); |
819 | error = XFS_ERROR(EFSCORRUPTED); | 822 | error = -EFSCORRUPTED; |
820 | goto out_free_perag; | 823 | goto out_free_perag; |
821 | } | 824 | } |
822 | 825 | ||
@@ -855,7 +858,7 @@ xfs_mountfs( | |||
855 | !mp->m_sb.sb_inprogress) { | 858 | !mp->m_sb.sb_inprogress) { |
856 | error = xfs_initialize_perag_data(mp, sbp->sb_agcount); | 859 | error = xfs_initialize_perag_data(mp, sbp->sb_agcount); |
857 | if (error) | 860 | if (error) |
858 | goto out_fail_wait; | 861 | goto out_log_dealloc; |
859 | } | 862 | } |
860 | 863 | ||
861 | /* | 864 | /* |
@@ -876,7 +879,7 @@ xfs_mountfs( | |||
876 | xfs_iunlock(rip, XFS_ILOCK_EXCL); | 879 | xfs_iunlock(rip, XFS_ILOCK_EXCL); |
877 | XFS_ERROR_REPORT("xfs_mountfs_int(2)", XFS_ERRLEVEL_LOW, | 880 | XFS_ERROR_REPORT("xfs_mountfs_int(2)", XFS_ERRLEVEL_LOW, |
878 | mp); | 881 | mp); |
879 | error = XFS_ERROR(EFSCORRUPTED); | 882 | error = -EFSCORRUPTED; |
880 | goto out_rele_rip; | 883 | goto out_rele_rip; |
881 | } | 884 | } |
882 | mp->m_rootip = rip; /* save it */ | 885 | mp->m_rootip = rip; /* save it */ |
@@ -927,7 +930,7 @@ xfs_mountfs( | |||
927 | xfs_notice(mp, "resetting quota flags"); | 930 | xfs_notice(mp, "resetting quota flags"); |
928 | error = xfs_mount_reset_sbqflags(mp); | 931 | error = xfs_mount_reset_sbqflags(mp); |
929 | if (error) | 932 | if (error) |
930 | return error; | 933 | goto out_rtunmount; |
931 | } | 934 | } |
932 | } | 935 | } |
933 | 936 | ||
@@ -989,6 +992,8 @@ xfs_mountfs( | |||
989 | xfs_da_unmount(mp); | 992 | xfs_da_unmount(mp); |
990 | out_remove_uuid: | 993 | out_remove_uuid: |
991 | xfs_uuid_unmount(mp); | 994 | xfs_uuid_unmount(mp); |
995 | out_remove_sysfs: | ||
996 | xfs_sysfs_del(&mp->m_kobj); | ||
992 | out: | 997 | out: |
993 | return error; | 998 | return error; |
994 | } | 999 | } |
@@ -1071,6 +1076,8 @@ xfs_unmountfs( | |||
1071 | xfs_errortag_clearall(mp, 0); | 1076 | xfs_errortag_clearall(mp, 0); |
1072 | #endif | 1077 | #endif |
1073 | xfs_free_perag(mp); | 1078 | xfs_free_perag(mp); |
1079 | |||
1080 | xfs_sysfs_del(&mp->m_kobj); | ||
1074 | } | 1081 | } |
1075 | 1082 | ||
1076 | int | 1083 | int |
@@ -1152,7 +1159,7 @@ xfs_mod_incore_sb_unlocked( | |||
1152 | lcounter += delta; | 1159 | lcounter += delta; |
1153 | if (lcounter < 0) { | 1160 | if (lcounter < 0) { |
1154 | ASSERT(0); | 1161 | ASSERT(0); |
1155 | return XFS_ERROR(EINVAL); | 1162 | return -EINVAL; |
1156 | } | 1163 | } |
1157 | mp->m_sb.sb_icount = lcounter; | 1164 | mp->m_sb.sb_icount = lcounter; |
1158 | return 0; | 1165 | return 0; |
@@ -1161,7 +1168,7 @@ xfs_mod_incore_sb_unlocked( | |||
1161 | lcounter += delta; | 1168 | lcounter += delta; |
1162 | if (lcounter < 0) { | 1169 | if (lcounter < 0) { |
1163 | ASSERT(0); | 1170 | ASSERT(0); |
1164 | return XFS_ERROR(EINVAL); | 1171 | return -EINVAL; |
1165 | } | 1172 | } |
1166 | mp->m_sb.sb_ifree = lcounter; | 1173 | mp->m_sb.sb_ifree = lcounter; |
1167 | return 0; | 1174 | return 0; |
@@ -1191,7 +1198,7 @@ xfs_mod_incore_sb_unlocked( | |||
1191 | * blocks if were allowed to. | 1198 | * blocks if were allowed to. |
1192 | */ | 1199 | */ |
1193 | if (!rsvd) | 1200 | if (!rsvd) |
1194 | return XFS_ERROR(ENOSPC); | 1201 | return -ENOSPC; |
1195 | 1202 | ||
1196 | lcounter = (long long)mp->m_resblks_avail + delta; | 1203 | lcounter = (long long)mp->m_resblks_avail + delta; |
1197 | if (lcounter >= 0) { | 1204 | if (lcounter >= 0) { |
@@ -1202,7 +1209,7 @@ xfs_mod_incore_sb_unlocked( | |||
1202 | "Filesystem \"%s\": reserve blocks depleted! " | 1209 | "Filesystem \"%s\": reserve blocks depleted! " |
1203 | "Consider increasing reserve pool size.", | 1210 | "Consider increasing reserve pool size.", |
1204 | mp->m_fsname); | 1211 | mp->m_fsname); |
1205 | return XFS_ERROR(ENOSPC); | 1212 | return -ENOSPC; |
1206 | } | 1213 | } |
1207 | 1214 | ||
1208 | mp->m_sb.sb_fdblocks = lcounter + XFS_ALLOC_SET_ASIDE(mp); | 1215 | mp->m_sb.sb_fdblocks = lcounter + XFS_ALLOC_SET_ASIDE(mp); |
@@ -1211,7 +1218,7 @@ xfs_mod_incore_sb_unlocked( | |||
1211 | lcounter = (long long)mp->m_sb.sb_frextents; | 1218 | lcounter = (long long)mp->m_sb.sb_frextents; |
1212 | lcounter += delta; | 1219 | lcounter += delta; |
1213 | if (lcounter < 0) { | 1220 | if (lcounter < 0) { |
1214 | return XFS_ERROR(ENOSPC); | 1221 | return -ENOSPC; |
1215 | } | 1222 | } |
1216 | mp->m_sb.sb_frextents = lcounter; | 1223 | mp->m_sb.sb_frextents = lcounter; |
1217 | return 0; | 1224 | return 0; |
@@ -1220,7 +1227,7 @@ xfs_mod_incore_sb_unlocked( | |||
1220 | lcounter += delta; | 1227 | lcounter += delta; |
1221 | if (lcounter < 0) { | 1228 | if (lcounter < 0) { |
1222 | ASSERT(0); | 1229 | ASSERT(0); |
1223 | return XFS_ERROR(EINVAL); | 1230 | return -EINVAL; |
1224 | } | 1231 | } |
1225 | mp->m_sb.sb_dblocks = lcounter; | 1232 | mp->m_sb.sb_dblocks = lcounter; |
1226 | return 0; | 1233 | return 0; |
@@ -1229,7 +1236,7 @@ xfs_mod_incore_sb_unlocked( | |||
1229 | scounter += delta; | 1236 | scounter += delta; |
1230 | if (scounter < 0) { | 1237 | if (scounter < 0) { |
1231 | ASSERT(0); | 1238 | ASSERT(0); |
1232 | return XFS_ERROR(EINVAL); | 1239 | return -EINVAL; |
1233 | } | 1240 | } |
1234 | mp->m_sb.sb_agcount = scounter; | 1241 | mp->m_sb.sb_agcount = scounter; |
1235 | return 0; | 1242 | return 0; |
@@ -1238,7 +1245,7 @@ xfs_mod_incore_sb_unlocked( | |||
1238 | scounter += delta; | 1245 | scounter += delta; |
1239 | if (scounter < 0) { | 1246 | if (scounter < 0) { |
1240 | ASSERT(0); | 1247 | ASSERT(0); |
1241 | return XFS_ERROR(EINVAL); | 1248 | return -EINVAL; |
1242 | } | 1249 | } |
1243 | mp->m_sb.sb_imax_pct = scounter; | 1250 | mp->m_sb.sb_imax_pct = scounter; |
1244 | return 0; | 1251 | return 0; |
@@ -1247,7 +1254,7 @@ xfs_mod_incore_sb_unlocked( | |||
1247 | scounter += delta; | 1254 | scounter += delta; |
1248 | if (scounter < 0) { | 1255 | if (scounter < 0) { |
1249 | ASSERT(0); | 1256 | ASSERT(0); |
1250 | return XFS_ERROR(EINVAL); | 1257 | return -EINVAL; |
1251 | } | 1258 | } |
1252 | mp->m_sb.sb_rextsize = scounter; | 1259 | mp->m_sb.sb_rextsize = scounter; |
1253 | return 0; | 1260 | return 0; |
@@ -1256,7 +1263,7 @@ xfs_mod_incore_sb_unlocked( | |||
1256 | scounter += delta; | 1263 | scounter += delta; |
1257 | if (scounter < 0) { | 1264 | if (scounter < 0) { |
1258 | ASSERT(0); | 1265 | ASSERT(0); |
1259 | return XFS_ERROR(EINVAL); | 1266 | return -EINVAL; |
1260 | } | 1267 | } |
1261 | mp->m_sb.sb_rbmblocks = scounter; | 1268 | mp->m_sb.sb_rbmblocks = scounter; |
1262 | return 0; | 1269 | return 0; |
@@ -1265,7 +1272,7 @@ xfs_mod_incore_sb_unlocked( | |||
1265 | lcounter += delta; | 1272 | lcounter += delta; |
1266 | if (lcounter < 0) { | 1273 | if (lcounter < 0) { |
1267 | ASSERT(0); | 1274 | ASSERT(0); |
1268 | return XFS_ERROR(EINVAL); | 1275 | return -EINVAL; |
1269 | } | 1276 | } |
1270 | mp->m_sb.sb_rblocks = lcounter; | 1277 | mp->m_sb.sb_rblocks = lcounter; |
1271 | return 0; | 1278 | return 0; |
@@ -1274,7 +1281,7 @@ xfs_mod_incore_sb_unlocked( | |||
1274 | lcounter += delta; | 1281 | lcounter += delta; |
1275 | if (lcounter < 0) { | 1282 | if (lcounter < 0) { |
1276 | ASSERT(0); | 1283 | ASSERT(0); |
1277 | return XFS_ERROR(EINVAL); | 1284 | return -EINVAL; |
1278 | } | 1285 | } |
1279 | mp->m_sb.sb_rextents = lcounter; | 1286 | mp->m_sb.sb_rextents = lcounter; |
1280 | return 0; | 1287 | return 0; |
@@ -1283,13 +1290,13 @@ xfs_mod_incore_sb_unlocked( | |||
1283 | scounter += delta; | 1290 | scounter += delta; |
1284 | if (scounter < 0) { | 1291 | if (scounter < 0) { |
1285 | ASSERT(0); | 1292 | ASSERT(0); |
1286 | return XFS_ERROR(EINVAL); | 1293 | return -EINVAL; |
1287 | } | 1294 | } |
1288 | mp->m_sb.sb_rextslog = scounter; | 1295 | mp->m_sb.sb_rextslog = scounter; |
1289 | return 0; | 1296 | return 0; |
1290 | default: | 1297 | default: |
1291 | ASSERT(0); | 1298 | ASSERT(0); |
1292 | return XFS_ERROR(EINVAL); | 1299 | return -EINVAL; |
1293 | } | 1300 | } |
1294 | } | 1301 | } |
1295 | 1302 | ||
@@ -1452,7 +1459,7 @@ xfs_dev_is_read_only( | |||
1452 | (mp->m_rtdev_targp && xfs_readonly_buftarg(mp->m_rtdev_targp))) { | 1459 | (mp->m_rtdev_targp && xfs_readonly_buftarg(mp->m_rtdev_targp))) { |
1453 | xfs_notice(mp, "%s required on read-only device.", message); | 1460 | xfs_notice(mp, "%s required on read-only device.", message); |
1454 | xfs_notice(mp, "write access unavailable, cannot proceed."); | 1461 | xfs_notice(mp, "write access unavailable, cannot proceed."); |
1455 | return EROFS; | 1462 | return -EROFS; |
1456 | } | 1463 | } |
1457 | return 0; | 1464 | return 0; |
1458 | } | 1465 | } |
@@ -1995,7 +2002,7 @@ slow_path: | |||
1995 | * (e.g. lots of space just got freed). After that | 2002 | * (e.g. lots of space just got freed). After that |
1996 | * we are done. | 2003 | * we are done. |
1997 | */ | 2004 | */ |
1998 | if (ret != ENOSPC) | 2005 | if (ret != -ENOSPC) |
1999 | xfs_icsb_balance_counter(mp, field, 0); | 2006 | xfs_icsb_balance_counter(mp, field, 0); |
2000 | xfs_icsb_unlock(mp); | 2007 | xfs_icsb_unlock(mp); |
2001 | return ret; | 2008 | return ret; |
diff --git a/fs/xfs/xfs_mount.h b/fs/xfs/xfs_mount.h index 7295a0b7c343..b0447c86e7e2 100644 --- a/fs/xfs/xfs_mount.h +++ b/fs/xfs/xfs_mount.h | |||
@@ -166,6 +166,7 @@ typedef struct xfs_mount { | |||
166 | on the next remount,rw */ | 166 | on the next remount,rw */ |
167 | int64_t m_low_space[XFS_LOWSP_MAX]; | 167 | int64_t m_low_space[XFS_LOWSP_MAX]; |
168 | /* low free space thresholds */ | 168 | /* low free space thresholds */ |
169 | struct xfs_kobj m_kobj; | ||
169 | 170 | ||
170 | struct workqueue_struct *m_data_workqueue; | 171 | struct workqueue_struct *m_data_workqueue; |
171 | struct workqueue_struct *m_unwritten_workqueue; | 172 | struct workqueue_struct *m_unwritten_workqueue; |
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..10232102b4a6 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; |
@@ -221,100 +221,6 @@ xfs_qm_unmount( | |||
221 | } | 221 | } |
222 | } | 222 | } |
223 | 223 | ||
224 | |||
225 | /* | ||
226 | * This is called from xfs_mountfs to start quotas and initialize all | ||
227 | * necessary data structures like quotainfo. This is also responsible for | ||
228 | * running a quotacheck as necessary. We are guaranteed that the superblock | ||
229 | * is consistently read in at this point. | ||
230 | * | ||
231 | * If we fail here, the mount will continue with quota turned off. We don't | ||
232 | * need to inidicate success or failure at all. | ||
233 | */ | ||
234 | void | ||
235 | xfs_qm_mount_quotas( | ||
236 | xfs_mount_t *mp) | ||
237 | { | ||
238 | int error = 0; | ||
239 | uint sbf; | ||
240 | |||
241 | /* | ||
242 | * If quotas on realtime volumes is not supported, we disable | ||
243 | * quotas immediately. | ||
244 | */ | ||
245 | if (mp->m_sb.sb_rextents) { | ||
246 | xfs_notice(mp, "Cannot turn on quotas for realtime filesystem"); | ||
247 | mp->m_qflags = 0; | ||
248 | goto write_changes; | ||
249 | } | ||
250 | |||
251 | ASSERT(XFS_IS_QUOTA_RUNNING(mp)); | ||
252 | |||
253 | /* | ||
254 | * Allocate the quotainfo structure inside the mount struct, and | ||
255 | * create quotainode(s), and change/rev superblock if necessary. | ||
256 | */ | ||
257 | error = xfs_qm_init_quotainfo(mp); | ||
258 | if (error) { | ||
259 | /* | ||
260 | * We must turn off quotas. | ||
261 | */ | ||
262 | ASSERT(mp->m_quotainfo == NULL); | ||
263 | mp->m_qflags = 0; | ||
264 | goto write_changes; | ||
265 | } | ||
266 | /* | ||
267 | * If any of the quotas are not consistent, do a quotacheck. | ||
268 | */ | ||
269 | if (XFS_QM_NEED_QUOTACHECK(mp)) { | ||
270 | error = xfs_qm_quotacheck(mp); | ||
271 | if (error) { | ||
272 | /* Quotacheck failed and disabled quotas. */ | ||
273 | return; | ||
274 | } | ||
275 | } | ||
276 | /* | ||
277 | * If one type of quotas is off, then it will lose its | ||
278 | * quotachecked status, since we won't be doing accounting for | ||
279 | * that type anymore. | ||
280 | */ | ||
281 | if (!XFS_IS_UQUOTA_ON(mp)) | ||
282 | mp->m_qflags &= ~XFS_UQUOTA_CHKD; | ||
283 | if (!XFS_IS_GQUOTA_ON(mp)) | ||
284 | mp->m_qflags &= ~XFS_GQUOTA_CHKD; | ||
285 | if (!XFS_IS_PQUOTA_ON(mp)) | ||
286 | mp->m_qflags &= ~XFS_PQUOTA_CHKD; | ||
287 | |||
288 | write_changes: | ||
289 | /* | ||
290 | * We actually don't have to acquire the m_sb_lock at all. | ||
291 | * This can only be called from mount, and that's single threaded. XXX | ||
292 | */ | ||
293 | spin_lock(&mp->m_sb_lock); | ||
294 | sbf = mp->m_sb.sb_qflags; | ||
295 | mp->m_sb.sb_qflags = mp->m_qflags & XFS_MOUNT_QUOTA_ALL; | ||
296 | spin_unlock(&mp->m_sb_lock); | ||
297 | |||
298 | if (sbf != (mp->m_qflags & XFS_MOUNT_QUOTA_ALL)) { | ||
299 | if (xfs_qm_write_sb_changes(mp, XFS_SB_QFLAGS)) { | ||
300 | /* | ||
301 | * We could only have been turning quotas off. | ||
302 | * We aren't in very good shape actually because | ||
303 | * the incore structures are convinced that quotas are | ||
304 | * off, but the on disk superblock doesn't know that ! | ||
305 | */ | ||
306 | ASSERT(!(XFS_IS_QUOTA_RUNNING(mp))); | ||
307 | xfs_alert(mp, "%s: Superblock update failed!", | ||
308 | __func__); | ||
309 | } | ||
310 | } | ||
311 | |||
312 | if (error) { | ||
313 | xfs_warn(mp, "Failed to initialize disk quotas."); | ||
314 | return; | ||
315 | } | ||
316 | } | ||
317 | |||
318 | /* | 224 | /* |
319 | * Called from the vfsops layer. | 225 | * Called from the vfsops layer. |
320 | */ | 226 | */ |
@@ -671,7 +577,7 @@ xfs_qm_init_quotainfo( | |||
671 | 577 | ||
672 | qinf = mp->m_quotainfo = kmem_zalloc(sizeof(xfs_quotainfo_t), KM_SLEEP); | 578 | qinf = mp->m_quotainfo = kmem_zalloc(sizeof(xfs_quotainfo_t), KM_SLEEP); |
673 | 579 | ||
674 | error = -list_lru_init(&qinf->qi_lru); | 580 | error = list_lru_init(&qinf->qi_lru); |
675 | if (error) | 581 | if (error) |
676 | goto out_free_qinf; | 582 | goto out_free_qinf; |
677 | 583 | ||
@@ -995,7 +901,7 @@ xfs_qm_dqiter_bufs( | |||
995 | * will leave a trace in the log indicating corruption has | 901 | * will leave a trace in the log indicating corruption has |
996 | * been detected. | 902 | * been detected. |
997 | */ | 903 | */ |
998 | if (error == EFSCORRUPTED) { | 904 | if (error == -EFSCORRUPTED) { |
999 | error = xfs_trans_read_buf(mp, NULL, mp->m_ddev_targp, | 905 | error = xfs_trans_read_buf(mp, NULL, mp->m_ddev_targp, |
1000 | XFS_FSB_TO_DADDR(mp, bno), | 906 | XFS_FSB_TO_DADDR(mp, bno), |
1001 | mp->m_quotainfo->qi_dqchunklen, 0, &bp, | 907 | mp->m_quotainfo->qi_dqchunklen, 0, &bp, |
@@ -1005,6 +911,12 @@ xfs_qm_dqiter_bufs( | |||
1005 | if (error) | 911 | if (error) |
1006 | break; | 912 | break; |
1007 | 913 | ||
914 | /* | ||
915 | * A corrupt buffer might not have a verifier attached, so | ||
916 | * make sure we have the correct one attached before writeback | ||
917 | * occurs. | ||
918 | */ | ||
919 | bp->b_ops = &xfs_dquot_buf_ops; | ||
1008 | xfs_qm_reset_dqcounts(mp, bp, firstid, type); | 920 | xfs_qm_reset_dqcounts(mp, bp, firstid, type); |
1009 | xfs_buf_delwri_queue(bp, buffer_list); | 921 | xfs_buf_delwri_queue(bp, buffer_list); |
1010 | xfs_buf_relse(bp); | 922 | xfs_buf_relse(bp); |
@@ -1090,7 +1002,7 @@ xfs_qm_dqiterate( | |||
1090 | xfs_buf_readahead(mp->m_ddev_targp, | 1002 | xfs_buf_readahead(mp->m_ddev_targp, |
1091 | XFS_FSB_TO_DADDR(mp, rablkno), | 1003 | XFS_FSB_TO_DADDR(mp, rablkno), |
1092 | mp->m_quotainfo->qi_dqchunklen, | 1004 | mp->m_quotainfo->qi_dqchunklen, |
1093 | NULL); | 1005 | &xfs_dquot_buf_ops); |
1094 | rablkno++; | 1006 | rablkno++; |
1095 | } | 1007 | } |
1096 | } | 1008 | } |
@@ -1138,8 +1050,8 @@ xfs_qm_quotacheck_dqadjust( | |||
1138 | /* | 1050 | /* |
1139 | * Shouldn't be able to turn off quotas here. | 1051 | * Shouldn't be able to turn off quotas here. |
1140 | */ | 1052 | */ |
1141 | ASSERT(error != ESRCH); | 1053 | ASSERT(error != -ESRCH); |
1142 | ASSERT(error != ENOENT); | 1054 | ASSERT(error != -ENOENT); |
1143 | return error; | 1055 | return error; |
1144 | } | 1056 | } |
1145 | 1057 | ||
@@ -1226,7 +1138,7 @@ xfs_qm_dqusage_adjust( | |||
1226 | */ | 1138 | */ |
1227 | if (xfs_is_quota_inode(&mp->m_sb, ino)) { | 1139 | if (xfs_is_quota_inode(&mp->m_sb, ino)) { |
1228 | *res = BULKSTAT_RV_NOTHING; | 1140 | *res = BULKSTAT_RV_NOTHING; |
1229 | return XFS_ERROR(EINVAL); | 1141 | return -EINVAL; |
1230 | } | 1142 | } |
1231 | 1143 | ||
1232 | /* | 1144 | /* |
@@ -1330,7 +1242,7 @@ out_unlock: | |||
1330 | * Walk thru all the filesystem inodes and construct a consistent view | 1242 | * Walk thru all the filesystem inodes and construct a consistent view |
1331 | * of the disk quota world. If the quotacheck fails, disable quotas. | 1243 | * of the disk quota world. If the quotacheck fails, disable quotas. |
1332 | */ | 1244 | */ |
1333 | int | 1245 | STATIC int |
1334 | xfs_qm_quotacheck( | 1246 | xfs_qm_quotacheck( |
1335 | xfs_mount_t *mp) | 1247 | xfs_mount_t *mp) |
1336 | { | 1248 | { |
@@ -1463,7 +1375,100 @@ xfs_qm_quotacheck( | |||
1463 | } | 1375 | } |
1464 | } else | 1376 | } else |
1465 | xfs_notice(mp, "Quotacheck: Done."); | 1377 | xfs_notice(mp, "Quotacheck: Done."); |
1466 | return (error); | 1378 | return error; |
1379 | } | ||
1380 | |||
1381 | /* | ||
1382 | * This is called from xfs_mountfs to start quotas and initialize all | ||
1383 | * necessary data structures like quotainfo. This is also responsible for | ||
1384 | * running a quotacheck as necessary. We are guaranteed that the superblock | ||
1385 | * is consistently read in at this point. | ||
1386 | * | ||
1387 | * If we fail here, the mount will continue with quota turned off. We don't | ||
1388 | * need to inidicate success or failure at all. | ||
1389 | */ | ||
1390 | void | ||
1391 | xfs_qm_mount_quotas( | ||
1392 | struct xfs_mount *mp) | ||
1393 | { | ||
1394 | int error = 0; | ||
1395 | uint sbf; | ||
1396 | |||
1397 | /* | ||
1398 | * If quotas on realtime volumes is not supported, we disable | ||
1399 | * quotas immediately. | ||
1400 | */ | ||
1401 | if (mp->m_sb.sb_rextents) { | ||
1402 | xfs_notice(mp, "Cannot turn on quotas for realtime filesystem"); | ||
1403 | mp->m_qflags = 0; | ||
1404 | goto write_changes; | ||
1405 | } | ||
1406 | |||
1407 | ASSERT(XFS_IS_QUOTA_RUNNING(mp)); | ||
1408 | |||
1409 | /* | ||
1410 | * Allocate the quotainfo structure inside the mount struct, and | ||
1411 | * create quotainode(s), and change/rev superblock if necessary. | ||
1412 | */ | ||
1413 | error = xfs_qm_init_quotainfo(mp); | ||
1414 | if (error) { | ||
1415 | /* | ||
1416 | * We must turn off quotas. | ||
1417 | */ | ||
1418 | ASSERT(mp->m_quotainfo == NULL); | ||
1419 | mp->m_qflags = 0; | ||
1420 | goto write_changes; | ||
1421 | } | ||
1422 | /* | ||
1423 | * If any of the quotas are not consistent, do a quotacheck. | ||
1424 | */ | ||
1425 | if (XFS_QM_NEED_QUOTACHECK(mp)) { | ||
1426 | error = xfs_qm_quotacheck(mp); | ||
1427 | if (error) { | ||
1428 | /* Quotacheck failed and disabled quotas. */ | ||
1429 | return; | ||
1430 | } | ||
1431 | } | ||
1432 | /* | ||
1433 | * If one type of quotas is off, then it will lose its | ||
1434 | * quotachecked status, since we won't be doing accounting for | ||
1435 | * that type anymore. | ||
1436 | */ | ||
1437 | if (!XFS_IS_UQUOTA_ON(mp)) | ||
1438 | mp->m_qflags &= ~XFS_UQUOTA_CHKD; | ||
1439 | if (!XFS_IS_GQUOTA_ON(mp)) | ||
1440 | mp->m_qflags &= ~XFS_GQUOTA_CHKD; | ||
1441 | if (!XFS_IS_PQUOTA_ON(mp)) | ||
1442 | mp->m_qflags &= ~XFS_PQUOTA_CHKD; | ||
1443 | |||
1444 | write_changes: | ||
1445 | /* | ||
1446 | * We actually don't have to acquire the m_sb_lock at all. | ||
1447 | * This can only be called from mount, and that's single threaded. XXX | ||
1448 | */ | ||
1449 | spin_lock(&mp->m_sb_lock); | ||
1450 | sbf = mp->m_sb.sb_qflags; | ||
1451 | mp->m_sb.sb_qflags = mp->m_qflags & XFS_MOUNT_QUOTA_ALL; | ||
1452 | spin_unlock(&mp->m_sb_lock); | ||
1453 | |||
1454 | if (sbf != (mp->m_qflags & XFS_MOUNT_QUOTA_ALL)) { | ||
1455 | if (xfs_qm_write_sb_changes(mp, XFS_SB_QFLAGS)) { | ||
1456 | /* | ||
1457 | * We could only have been turning quotas off. | ||
1458 | * We aren't in very good shape actually because | ||
1459 | * the incore structures are convinced that quotas are | ||
1460 | * off, but the on disk superblock doesn't know that ! | ||
1461 | */ | ||
1462 | ASSERT(!(XFS_IS_QUOTA_RUNNING(mp))); | ||
1463 | xfs_alert(mp, "%s: Superblock update failed!", | ||
1464 | __func__); | ||
1465 | } | ||
1466 | } | ||
1467 | |||
1468 | if (error) { | ||
1469 | xfs_warn(mp, "Failed to initialize disk quotas."); | ||
1470 | return; | ||
1471 | } | ||
1467 | } | 1472 | } |
1468 | 1473 | ||
1469 | /* | 1474 | /* |
@@ -1493,7 +1498,7 @@ xfs_qm_init_quotainos( | |||
1493 | error = xfs_iget(mp, NULL, mp->m_sb.sb_uquotino, | 1498 | error = xfs_iget(mp, NULL, mp->m_sb.sb_uquotino, |
1494 | 0, 0, &uip); | 1499 | 0, 0, &uip); |
1495 | if (error) | 1500 | if (error) |
1496 | return XFS_ERROR(error); | 1501 | return error; |
1497 | } | 1502 | } |
1498 | if (XFS_IS_GQUOTA_ON(mp) && | 1503 | if (XFS_IS_GQUOTA_ON(mp) && |
1499 | mp->m_sb.sb_gquotino != NULLFSINO) { | 1504 | mp->m_sb.sb_gquotino != NULLFSINO) { |
@@ -1563,7 +1568,7 @@ error_rele: | |||
1563 | IRELE(gip); | 1568 | IRELE(gip); |
1564 | if (pip) | 1569 | if (pip) |
1565 | IRELE(pip); | 1570 | IRELE(pip); |
1566 | return XFS_ERROR(error); | 1571 | return error; |
1567 | } | 1572 | } |
1568 | 1573 | ||
1569 | STATIC void | 1574 | STATIC void |
@@ -1679,7 +1684,7 @@ xfs_qm_vop_dqalloc( | |||
1679 | XFS_QMOPT_DOWARN, | 1684 | XFS_QMOPT_DOWARN, |
1680 | &uq); | 1685 | &uq); |
1681 | if (error) { | 1686 | if (error) { |
1682 | ASSERT(error != ENOENT); | 1687 | ASSERT(error != -ENOENT); |
1683 | return error; | 1688 | return error; |
1684 | } | 1689 | } |
1685 | /* | 1690 | /* |
@@ -1706,7 +1711,7 @@ xfs_qm_vop_dqalloc( | |||
1706 | XFS_QMOPT_DOWARN, | 1711 | XFS_QMOPT_DOWARN, |
1707 | &gq); | 1712 | &gq); |
1708 | if (error) { | 1713 | if (error) { |
1709 | ASSERT(error != ENOENT); | 1714 | ASSERT(error != -ENOENT); |
1710 | goto error_rele; | 1715 | goto error_rele; |
1711 | } | 1716 | } |
1712 | xfs_dqunlock(gq); | 1717 | xfs_dqunlock(gq); |
@@ -1726,7 +1731,7 @@ xfs_qm_vop_dqalloc( | |||
1726 | XFS_QMOPT_DOWARN, | 1731 | XFS_QMOPT_DOWARN, |
1727 | &pq); | 1732 | &pq); |
1728 | if (error) { | 1733 | if (error) { |
1729 | ASSERT(error != ENOENT); | 1734 | ASSERT(error != -ENOENT); |
1730 | goto error_rele; | 1735 | goto error_rele; |
1731 | } | 1736 | } |
1732 | xfs_dqunlock(pq); | 1737 | xfs_dqunlock(pq); |
@@ -1895,7 +1900,7 @@ xfs_qm_vop_chown_reserve( | |||
1895 | -((xfs_qcnt_t)delblks), 0, blkflags); | 1900 | -((xfs_qcnt_t)delblks), 0, blkflags); |
1896 | } | 1901 | } |
1897 | 1902 | ||
1898 | return (0); | 1903 | return 0; |
1899 | } | 1904 | } |
1900 | 1905 | ||
1901 | int | 1906 | int |
diff --git a/fs/xfs/xfs_qm.h b/fs/xfs/xfs_qm.h index 797fd4636273..3a07a937e232 100644 --- a/fs/xfs/xfs_qm.h +++ b/fs/xfs/xfs_qm.h | |||
@@ -157,7 +157,6 @@ struct xfs_dquot_acct { | |||
157 | #define XFS_QM_RTBWARNLIMIT 5 | 157 | #define XFS_QM_RTBWARNLIMIT 5 |
158 | 158 | ||
159 | extern void xfs_qm_destroy_quotainfo(struct xfs_mount *); | 159 | extern void xfs_qm_destroy_quotainfo(struct xfs_mount *); |
160 | extern int xfs_qm_quotacheck(struct xfs_mount *); | ||
161 | extern int xfs_qm_write_sb_changes(struct xfs_mount *, __int64_t); | 160 | extern int xfs_qm_write_sb_changes(struct xfs_mount *, __int64_t); |
162 | 161 | ||
163 | /* dquot stuff */ | 162 | /* dquot stuff */ |
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..b238027df987 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 | ||
57 | STATIC int | 57 | STATIC 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 | ||
69 | STATIC int | 69 | STATIC 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 | ||
@@ -123,11 +123,11 @@ xfs_fs_rm_xquota( | |||
123 | flags |= XFS_DQ_USER; | 123 | flags |= XFS_DQ_USER; |
124 | if (uflags & FS_GROUP_QUOTA) | 124 | if (uflags & FS_GROUP_QUOTA) |
125 | flags |= XFS_DQ_GROUP; | 125 | flags |= XFS_DQ_GROUP; |
126 | if (uflags & FS_USER_QUOTA) | 126 | if (uflags & FS_PROJ_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 | ||
132 | STATIC int | 132 | STATIC int |
133 | xfs_fs_get_dqblk( | 133 | xfs_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..909e143b87ae 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; |
907 | error_cancel: | 907 | error_cancel: |
908 | xfs_trans_cancel(tp, cancelflags); | 908 | xfs_trans_cancel(tp, cancelflags); |
909 | goto error; | 909 | goto error; |
@@ -944,9 +944,9 @@ xfs_growfs_rt( | |||
944 | xfs_buf_t *bp; /* temporary buffer */ | 944 | xfs_buf_t *bp; /* temporary buffer */ |
945 | int error; /* error return value */ | 945 | int error; /* error return value */ |
946 | xfs_mount_t *nmp; /* new (fake) mount structure */ | 946 | xfs_mount_t *nmp; /* new (fake) mount structure */ |
947 | xfs_drfsbno_t nrblocks; /* new number of realtime blocks */ | 947 | xfs_rfsblock_t nrblocks; /* new number of realtime blocks */ |
948 | xfs_extlen_t nrbmblocks; /* new number of rt bitmap blocks */ | 948 | xfs_extlen_t nrbmblocks; /* new number of rt bitmap blocks */ |
949 | xfs_drtbno_t nrextents; /* new number of realtime extents */ | 949 | xfs_rtblock_t nrextents; /* new number of realtime extents */ |
950 | uint8_t nrextslog; /* new log2 of sb_rextents */ | 950 | uint8_t nrextslog; /* new log2 of sb_rextents */ |
951 | xfs_extlen_t nrsumblocks; /* new number of summary blocks */ | 951 | xfs_extlen_t nrsumblocks; /* new number of summary blocks */ |
952 | uint nrsumlevels; /* new rt summary levels */ | 952 | uint nrsumlevels; /* new rt summary levels */ |
@@ -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..b194652033cd 100644 --- a/fs/xfs/xfs_super.c +++ b/fs/xfs/xfs_super.c | |||
@@ -61,6 +61,7 @@ | |||
61 | static const struct super_operations xfs_super_operations; | 61 | static const struct super_operations xfs_super_operations; |
62 | static kmem_zone_t *xfs_ioend_zone; | 62 | static kmem_zone_t *xfs_ioend_zone; |
63 | mempool_t *xfs_ioend_pool; | 63 | mempool_t *xfs_ioend_pool; |
64 | struct kset *xfs_kset; | ||
64 | 65 | ||
65 | #define MNTOPT_LOGBUFS "logbufs" /* number of XFS log buffers */ | 66 | #define MNTOPT_LOGBUFS "logbufs" /* number of XFS log buffers */ |
66 | #define MNTOPT_LOGBSIZE "logbsize" /* size of XFS log buffers */ | 67 | #define MNTOPT_LOGBSIZE "logbsize" /* size of XFS log buffers */ |
@@ -185,7 +186,7 @@ xfs_parseargs( | |||
185 | */ | 186 | */ |
186 | mp->m_fsname = kstrndup(sb->s_id, MAXNAMELEN, GFP_KERNEL); | 187 | mp->m_fsname = kstrndup(sb->s_id, MAXNAMELEN, GFP_KERNEL); |
187 | if (!mp->m_fsname) | 188 | if (!mp->m_fsname) |
188 | return ENOMEM; | 189 | return -ENOMEM; |
189 | mp->m_fsname_len = strlen(mp->m_fsname) + 1; | 190 | mp->m_fsname_len = strlen(mp->m_fsname) + 1; |
190 | 191 | ||
191 | /* | 192 | /* |
@@ -204,9 +205,6 @@ xfs_parseargs( | |||
204 | */ | 205 | */ |
205 | mp->m_flags |= XFS_MOUNT_BARRIER; | 206 | mp->m_flags |= XFS_MOUNT_BARRIER; |
206 | mp->m_flags |= XFS_MOUNT_COMPAT_IOSIZE; | 207 | mp->m_flags |= XFS_MOUNT_COMPAT_IOSIZE; |
207 | #if !XFS_BIG_INUMS | ||
208 | mp->m_flags |= XFS_MOUNT_SMALL_INUMS; | ||
209 | #endif | ||
210 | 208 | ||
211 | /* | 209 | /* |
212 | * These can be overridden by the mount option parsing. | 210 | * These can be overridden by the mount option parsing. |
@@ -227,57 +225,57 @@ xfs_parseargs( | |||
227 | if (!value || !*value) { | 225 | if (!value || !*value) { |
228 | xfs_warn(mp, "%s option requires an argument", | 226 | xfs_warn(mp, "%s option requires an argument", |
229 | this_char); | 227 | this_char); |
230 | return EINVAL; | 228 | return -EINVAL; |
231 | } | 229 | } |
232 | if (kstrtoint(value, 10, &mp->m_logbufs)) | 230 | if (kstrtoint(value, 10, &mp->m_logbufs)) |
233 | return EINVAL; | 231 | return -EINVAL; |
234 | } else if (!strcmp(this_char, MNTOPT_LOGBSIZE)) { | 232 | } else if (!strcmp(this_char, MNTOPT_LOGBSIZE)) { |
235 | if (!value || !*value) { | 233 | if (!value || !*value) { |
236 | xfs_warn(mp, "%s option requires an argument", | 234 | xfs_warn(mp, "%s option requires an argument", |
237 | this_char); | 235 | this_char); |
238 | return EINVAL; | 236 | return -EINVAL; |
239 | } | 237 | } |
240 | if (suffix_kstrtoint(value, 10, &mp->m_logbsize)) | 238 | if (suffix_kstrtoint(value, 10, &mp->m_logbsize)) |
241 | return EINVAL; | 239 | return -EINVAL; |
242 | } else if (!strcmp(this_char, MNTOPT_LOGDEV)) { | 240 | } else if (!strcmp(this_char, MNTOPT_LOGDEV)) { |
243 | if (!value || !*value) { | 241 | if (!value || !*value) { |
244 | xfs_warn(mp, "%s option requires an argument", | 242 | xfs_warn(mp, "%s option requires an argument", |
245 | this_char); | 243 | this_char); |
246 | return EINVAL; | 244 | return -EINVAL; |
247 | } | 245 | } |
248 | mp->m_logname = kstrndup(value, MAXNAMELEN, GFP_KERNEL); | 246 | mp->m_logname = kstrndup(value, MAXNAMELEN, GFP_KERNEL); |
249 | if (!mp->m_logname) | 247 | if (!mp->m_logname) |
250 | return ENOMEM; | 248 | return -ENOMEM; |
251 | } else if (!strcmp(this_char, MNTOPT_MTPT)) { | 249 | } else if (!strcmp(this_char, MNTOPT_MTPT)) { |
252 | xfs_warn(mp, "%s option not allowed on this system", | 250 | xfs_warn(mp, "%s option not allowed on this system", |
253 | this_char); | 251 | this_char); |
254 | return EINVAL; | 252 | return -EINVAL; |
255 | } else if (!strcmp(this_char, MNTOPT_RTDEV)) { | 253 | } else if (!strcmp(this_char, MNTOPT_RTDEV)) { |
256 | if (!value || !*value) { | 254 | if (!value || !*value) { |
257 | xfs_warn(mp, "%s option requires an argument", | 255 | xfs_warn(mp, "%s option requires an argument", |
258 | this_char); | 256 | this_char); |
259 | return EINVAL; | 257 | return -EINVAL; |
260 | } | 258 | } |
261 | mp->m_rtname = kstrndup(value, MAXNAMELEN, GFP_KERNEL); | 259 | mp->m_rtname = kstrndup(value, MAXNAMELEN, GFP_KERNEL); |
262 | if (!mp->m_rtname) | 260 | if (!mp->m_rtname) |
263 | return ENOMEM; | 261 | return -ENOMEM; |
264 | } else if (!strcmp(this_char, MNTOPT_BIOSIZE)) { | 262 | } else if (!strcmp(this_char, MNTOPT_BIOSIZE)) { |
265 | if (!value || !*value) { | 263 | if (!value || !*value) { |
266 | xfs_warn(mp, "%s option requires an argument", | 264 | xfs_warn(mp, "%s option requires an argument", |
267 | this_char); | 265 | this_char); |
268 | return EINVAL; | 266 | return -EINVAL; |
269 | } | 267 | } |
270 | if (kstrtoint(value, 10, &iosize)) | 268 | if (kstrtoint(value, 10, &iosize)) |
271 | return EINVAL; | 269 | return -EINVAL; |
272 | iosizelog = ffs(iosize) - 1; | 270 | iosizelog = ffs(iosize) - 1; |
273 | } else if (!strcmp(this_char, MNTOPT_ALLOCSIZE)) { | 271 | } else if (!strcmp(this_char, MNTOPT_ALLOCSIZE)) { |
274 | if (!value || !*value) { | 272 | if (!value || !*value) { |
275 | xfs_warn(mp, "%s option requires an argument", | 273 | xfs_warn(mp, "%s option requires an argument", |
276 | this_char); | 274 | this_char); |
277 | return EINVAL; | 275 | return -EINVAL; |
278 | } | 276 | } |
279 | if (suffix_kstrtoint(value, 10, &iosize)) | 277 | if (suffix_kstrtoint(value, 10, &iosize)) |
280 | return EINVAL; | 278 | return -EINVAL; |
281 | iosizelog = ffs(iosize) - 1; | 279 | iosizelog = ffs(iosize) - 1; |
282 | } else if (!strcmp(this_char, MNTOPT_GRPID) || | 280 | } else if (!strcmp(this_char, MNTOPT_GRPID) || |
283 | !strcmp(this_char, MNTOPT_BSDGROUPS)) { | 281 | !strcmp(this_char, MNTOPT_BSDGROUPS)) { |
@@ -297,27 +295,22 @@ xfs_parseargs( | |||
297 | if (!value || !*value) { | 295 | if (!value || !*value) { |
298 | xfs_warn(mp, "%s option requires an argument", | 296 | xfs_warn(mp, "%s option requires an argument", |
299 | this_char); | 297 | this_char); |
300 | return EINVAL; | 298 | return -EINVAL; |
301 | } | 299 | } |
302 | if (kstrtoint(value, 10, &dsunit)) | 300 | if (kstrtoint(value, 10, &dsunit)) |
303 | return EINVAL; | 301 | return -EINVAL; |
304 | } else if (!strcmp(this_char, MNTOPT_SWIDTH)) { | 302 | } else if (!strcmp(this_char, MNTOPT_SWIDTH)) { |
305 | if (!value || !*value) { | 303 | if (!value || !*value) { |
306 | xfs_warn(mp, "%s option requires an argument", | 304 | xfs_warn(mp, "%s option requires an argument", |
307 | this_char); | 305 | this_char); |
308 | return EINVAL; | 306 | return -EINVAL; |
309 | } | 307 | } |
310 | if (kstrtoint(value, 10, &dswidth)) | 308 | if (kstrtoint(value, 10, &dswidth)) |
311 | return EINVAL; | 309 | return -EINVAL; |
312 | } else if (!strcmp(this_char, MNTOPT_32BITINODE)) { | 310 | } else if (!strcmp(this_char, MNTOPT_32BITINODE)) { |
313 | mp->m_flags |= XFS_MOUNT_SMALL_INUMS; | 311 | mp->m_flags |= XFS_MOUNT_SMALL_INUMS; |
314 | } else if (!strcmp(this_char, MNTOPT_64BITINODE)) { | 312 | } else if (!strcmp(this_char, MNTOPT_64BITINODE)) { |
315 | mp->m_flags &= ~XFS_MOUNT_SMALL_INUMS; | 313 | mp->m_flags &= ~XFS_MOUNT_SMALL_INUMS; |
316 | #if !XFS_BIG_INUMS | ||
317 | xfs_warn(mp, "%s option not allowed on this system", | ||
318 | this_char); | ||
319 | return EINVAL; | ||
320 | #endif | ||
321 | } else if (!strcmp(this_char, MNTOPT_NOUUID)) { | 314 | } else if (!strcmp(this_char, MNTOPT_NOUUID)) { |
322 | mp->m_flags |= XFS_MOUNT_NOUUID; | 315 | mp->m_flags |= XFS_MOUNT_NOUUID; |
323 | } else if (!strcmp(this_char, MNTOPT_BARRIER)) { | 316 | } else if (!strcmp(this_char, MNTOPT_BARRIER)) { |
@@ -390,7 +383,7 @@ xfs_parseargs( | |||
390 | "irixsgid is now a sysctl(2) variable, option is deprecated."); | 383 | "irixsgid is now a sysctl(2) variable, option is deprecated."); |
391 | } else { | 384 | } else { |
392 | xfs_warn(mp, "unknown mount option [%s].", this_char); | 385 | xfs_warn(mp, "unknown mount option [%s].", this_char); |
393 | return EINVAL; | 386 | return -EINVAL; |
394 | } | 387 | } |
395 | } | 388 | } |
396 | 389 | ||
@@ -400,32 +393,32 @@ xfs_parseargs( | |||
400 | if ((mp->m_flags & XFS_MOUNT_NORECOVERY) && | 393 | if ((mp->m_flags & XFS_MOUNT_NORECOVERY) && |
401 | !(mp->m_flags & XFS_MOUNT_RDONLY)) { | 394 | !(mp->m_flags & XFS_MOUNT_RDONLY)) { |
402 | xfs_warn(mp, "no-recovery mounts must be read-only."); | 395 | xfs_warn(mp, "no-recovery mounts must be read-only."); |
403 | return EINVAL; | 396 | return -EINVAL; |
404 | } | 397 | } |
405 | 398 | ||
406 | if ((mp->m_flags & XFS_MOUNT_NOALIGN) && (dsunit || dswidth)) { | 399 | if ((mp->m_flags & XFS_MOUNT_NOALIGN) && (dsunit || dswidth)) { |
407 | xfs_warn(mp, | 400 | xfs_warn(mp, |
408 | "sunit and swidth options incompatible with the noalign option"); | 401 | "sunit and swidth options incompatible with the noalign option"); |
409 | return EINVAL; | 402 | return -EINVAL; |
410 | } | 403 | } |
411 | 404 | ||
412 | #ifndef CONFIG_XFS_QUOTA | 405 | #ifndef CONFIG_XFS_QUOTA |
413 | if (XFS_IS_QUOTA_RUNNING(mp)) { | 406 | if (XFS_IS_QUOTA_RUNNING(mp)) { |
414 | xfs_warn(mp, "quota support not available in this kernel."); | 407 | xfs_warn(mp, "quota support not available in this kernel."); |
415 | return EINVAL; | 408 | return -EINVAL; |
416 | } | 409 | } |
417 | #endif | 410 | #endif |
418 | 411 | ||
419 | if ((dsunit && !dswidth) || (!dsunit && dswidth)) { | 412 | if ((dsunit && !dswidth) || (!dsunit && dswidth)) { |
420 | xfs_warn(mp, "sunit and swidth must be specified together"); | 413 | xfs_warn(mp, "sunit and swidth must be specified together"); |
421 | return EINVAL; | 414 | return -EINVAL; |
422 | } | 415 | } |
423 | 416 | ||
424 | if (dsunit && (dswidth % dsunit != 0)) { | 417 | if (dsunit && (dswidth % dsunit != 0)) { |
425 | xfs_warn(mp, | 418 | xfs_warn(mp, |
426 | "stripe width (%d) must be a multiple of the stripe unit (%d)", | 419 | "stripe width (%d) must be a multiple of the stripe unit (%d)", |
427 | dswidth, dsunit); | 420 | dswidth, dsunit); |
428 | return EINVAL; | 421 | return -EINVAL; |
429 | } | 422 | } |
430 | 423 | ||
431 | done: | 424 | done: |
@@ -446,7 +439,7 @@ done: | |||
446 | mp->m_logbufs > XLOG_MAX_ICLOGS)) { | 439 | mp->m_logbufs > XLOG_MAX_ICLOGS)) { |
447 | xfs_warn(mp, "invalid logbufs value: %d [not %d-%d]", | 440 | xfs_warn(mp, "invalid logbufs value: %d [not %d-%d]", |
448 | mp->m_logbufs, XLOG_MIN_ICLOGS, XLOG_MAX_ICLOGS); | 441 | mp->m_logbufs, XLOG_MIN_ICLOGS, XLOG_MAX_ICLOGS); |
449 | return XFS_ERROR(EINVAL); | 442 | return -EINVAL; |
450 | } | 443 | } |
451 | if (mp->m_logbsize != -1 && | 444 | if (mp->m_logbsize != -1 && |
452 | mp->m_logbsize != 0 && | 445 | mp->m_logbsize != 0 && |
@@ -456,7 +449,7 @@ done: | |||
456 | xfs_warn(mp, | 449 | xfs_warn(mp, |
457 | "invalid logbufsize: %d [not 16k,32k,64k,128k or 256k]", | 450 | "invalid logbufsize: %d [not 16k,32k,64k,128k or 256k]", |
458 | mp->m_logbsize); | 451 | mp->m_logbsize); |
459 | return XFS_ERROR(EINVAL); | 452 | return -EINVAL; |
460 | } | 453 | } |
461 | 454 | ||
462 | if (iosizelog) { | 455 | if (iosizelog) { |
@@ -465,7 +458,7 @@ done: | |||
465 | xfs_warn(mp, "invalid log iosize: %d [not %d-%d]", | 458 | xfs_warn(mp, "invalid log iosize: %d [not %d-%d]", |
466 | iosizelog, XFS_MIN_IO_LOG, | 459 | iosizelog, XFS_MIN_IO_LOG, |
467 | XFS_MAX_IO_LOG); | 460 | XFS_MAX_IO_LOG); |
468 | return XFS_ERROR(EINVAL); | 461 | return -EINVAL; |
469 | } | 462 | } |
470 | 463 | ||
471 | mp->m_flags |= XFS_MOUNT_DFLT_IOSIZE; | 464 | mp->m_flags |= XFS_MOUNT_DFLT_IOSIZE; |
@@ -597,15 +590,20 @@ xfs_max_file_offset( | |||
597 | return (((__uint64_t)pagefactor) << bitshift) - 1; | 590 | return (((__uint64_t)pagefactor) << bitshift) - 1; |
598 | } | 591 | } |
599 | 592 | ||
593 | /* | ||
594 | * xfs_set_inode32() and xfs_set_inode64() are passed an agcount | ||
595 | * because in the growfs case, mp->m_sb.sb_agcount is not updated | ||
596 | * yet to the potentially higher ag count. | ||
597 | */ | ||
600 | xfs_agnumber_t | 598 | xfs_agnumber_t |
601 | xfs_set_inode32(struct xfs_mount *mp) | 599 | xfs_set_inode32(struct xfs_mount *mp, xfs_agnumber_t agcount) |
602 | { | 600 | { |
603 | xfs_agnumber_t index = 0; | 601 | xfs_agnumber_t index = 0; |
604 | xfs_agnumber_t maxagi = 0; | 602 | xfs_agnumber_t maxagi = 0; |
605 | xfs_sb_t *sbp = &mp->m_sb; | 603 | xfs_sb_t *sbp = &mp->m_sb; |
606 | xfs_agnumber_t max_metadata; | 604 | xfs_agnumber_t max_metadata; |
607 | xfs_agino_t agino = XFS_OFFBNO_TO_AGINO(mp, sbp->sb_agblocks -1, 0); | 605 | xfs_agino_t agino; |
608 | xfs_ino_t ino = XFS_AGINO_TO_INO(mp, sbp->sb_agcount -1, agino); | 606 | xfs_ino_t ino; |
609 | xfs_perag_t *pag; | 607 | xfs_perag_t *pag; |
610 | 608 | ||
611 | /* Calculate how much should be reserved for inodes to meet | 609 | /* Calculate how much should be reserved for inodes to meet |
@@ -620,10 +618,12 @@ xfs_set_inode32(struct xfs_mount *mp) | |||
620 | do_div(icount, sbp->sb_agblocks); | 618 | do_div(icount, sbp->sb_agblocks); |
621 | max_metadata = icount; | 619 | max_metadata = icount; |
622 | } else { | 620 | } else { |
623 | max_metadata = sbp->sb_agcount; | 621 | max_metadata = agcount; |
624 | } | 622 | } |
625 | 623 | ||
626 | for (index = 0; index < sbp->sb_agcount; index++) { | 624 | agino = XFS_OFFBNO_TO_AGINO(mp, sbp->sb_agblocks - 1, 0); |
625 | |||
626 | for (index = 0; index < agcount; index++) { | ||
627 | ino = XFS_AGINO_TO_INO(mp, index, agino); | 627 | ino = XFS_AGINO_TO_INO(mp, index, agino); |
628 | 628 | ||
629 | if (ino > XFS_MAXINUMBER_32) { | 629 | if (ino > XFS_MAXINUMBER_32) { |
@@ -648,11 +648,11 @@ xfs_set_inode32(struct xfs_mount *mp) | |||
648 | } | 648 | } |
649 | 649 | ||
650 | xfs_agnumber_t | 650 | xfs_agnumber_t |
651 | xfs_set_inode64(struct xfs_mount *mp) | 651 | xfs_set_inode64(struct xfs_mount *mp, xfs_agnumber_t agcount) |
652 | { | 652 | { |
653 | xfs_agnumber_t index = 0; | 653 | xfs_agnumber_t index = 0; |
654 | 654 | ||
655 | for (index = 0; index < mp->m_sb.sb_agcount; index++) { | 655 | for (index = 0; index < agcount; index++) { |
656 | struct xfs_perag *pag; | 656 | struct xfs_perag *pag; |
657 | 657 | ||
658 | pag = xfs_perag_get(mp, index); | 658 | pag = xfs_perag_get(mp, index); |
@@ -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 | ||
692 | STATIC void | 692 | STATIC 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; |
@@ -1188,6 +1188,7 @@ xfs_fs_remount( | |||
1188 | char *options) | 1188 | char *options) |
1189 | { | 1189 | { |
1190 | struct xfs_mount *mp = XFS_M(sb); | 1190 | struct xfs_mount *mp = XFS_M(sb); |
1191 | xfs_sb_t *sbp = &mp->m_sb; | ||
1191 | substring_t args[MAX_OPT_ARGS]; | 1192 | substring_t args[MAX_OPT_ARGS]; |
1192 | char *p; | 1193 | char *p; |
1193 | int error; | 1194 | int error; |
@@ -1208,10 +1209,10 @@ xfs_fs_remount( | |||
1208 | mp->m_flags &= ~XFS_MOUNT_BARRIER; | 1209 | mp->m_flags &= ~XFS_MOUNT_BARRIER; |
1209 | break; | 1210 | break; |
1210 | case Opt_inode64: | 1211 | case Opt_inode64: |
1211 | mp->m_maxagi = xfs_set_inode64(mp); | 1212 | mp->m_maxagi = xfs_set_inode64(mp, sbp->sb_agcount); |
1212 | break; | 1213 | break; |
1213 | case Opt_inode32: | 1214 | case Opt_inode32: |
1214 | mp->m_maxagi = xfs_set_inode32(mp); | 1215 | mp->m_maxagi = xfs_set_inode32(mp, sbp->sb_agcount); |
1215 | break; | 1216 | break; |
1216 | default: | 1217 | default: |
1217 | /* | 1218 | /* |
@@ -1295,7 +1296,7 @@ xfs_fs_freeze( | |||
1295 | 1296 | ||
1296 | xfs_save_resvblks(mp); | 1297 | xfs_save_resvblks(mp); |
1297 | xfs_quiesce_attr(mp); | 1298 | xfs_quiesce_attr(mp); |
1298 | return -xfs_fs_log_dummy(mp); | 1299 | return xfs_fs_log_dummy(mp); |
1299 | } | 1300 | } |
1300 | 1301 | ||
1301 | STATIC int | 1302 | STATIC int |
@@ -1314,7 +1315,7 @@ xfs_fs_show_options( | |||
1314 | struct seq_file *m, | 1315 | struct seq_file *m, |
1315 | struct dentry *root) | 1316 | struct dentry *root) |
1316 | { | 1317 | { |
1317 | return -xfs_showargs(XFS_M(root->d_sb), m); | 1318 | return xfs_showargs(XFS_M(root->d_sb), m); |
1318 | } | 1319 | } |
1319 | 1320 | ||
1320 | /* | 1321 | /* |
@@ -1336,14 +1337,14 @@ xfs_finish_flags( | |||
1336 | mp->m_logbsize < mp->m_sb.sb_logsunit) { | 1337 | mp->m_logbsize < mp->m_sb.sb_logsunit) { |
1337 | xfs_warn(mp, | 1338 | xfs_warn(mp, |
1338 | "logbuf size must be greater than or equal to log stripe size"); | 1339 | "logbuf size must be greater than or equal to log stripe size"); |
1339 | return XFS_ERROR(EINVAL); | 1340 | return -EINVAL; |
1340 | } | 1341 | } |
1341 | } else { | 1342 | } else { |
1342 | /* Fail a mount if the logbuf is larger than 32K */ | 1343 | /* Fail a mount if the logbuf is larger than 32K */ |
1343 | if (mp->m_logbsize > XLOG_BIG_RECORD_BSIZE) { | 1344 | if (mp->m_logbsize > XLOG_BIG_RECORD_BSIZE) { |
1344 | xfs_warn(mp, | 1345 | xfs_warn(mp, |
1345 | "logbuf size for version 1 logs must be 16K or 32K"); | 1346 | "logbuf size for version 1 logs must be 16K or 32K"); |
1346 | return XFS_ERROR(EINVAL); | 1347 | return -EINVAL; |
1347 | } | 1348 | } |
1348 | } | 1349 | } |
1349 | 1350 | ||
@@ -1355,7 +1356,7 @@ xfs_finish_flags( | |||
1355 | xfs_warn(mp, | 1356 | xfs_warn(mp, |
1356 | "Cannot mount a V5 filesystem as %s. %s is always enabled for V5 filesystems.", | 1357 | "Cannot mount a V5 filesystem as %s. %s is always enabled for V5 filesystems.", |
1357 | MNTOPT_NOATTR2, MNTOPT_ATTR2); | 1358 | MNTOPT_NOATTR2, MNTOPT_ATTR2); |
1358 | return XFS_ERROR(EINVAL); | 1359 | return -EINVAL; |
1359 | } | 1360 | } |
1360 | 1361 | ||
1361 | /* | 1362 | /* |
@@ -1372,7 +1373,7 @@ xfs_finish_flags( | |||
1372 | if ((mp->m_sb.sb_flags & XFS_SBF_READONLY) && !ronly) { | 1373 | if ((mp->m_sb.sb_flags & XFS_SBF_READONLY) && !ronly) { |
1373 | xfs_warn(mp, | 1374 | xfs_warn(mp, |
1374 | "cannot mount a read-only filesystem as read-write"); | 1375 | "cannot mount a read-only filesystem as read-write"); |
1375 | return XFS_ERROR(EROFS); | 1376 | return -EROFS; |
1376 | } | 1377 | } |
1377 | 1378 | ||
1378 | if ((mp->m_qflags & (XFS_GQUOTA_ACCT | XFS_GQUOTA_ACTIVE)) && | 1379 | if ((mp->m_qflags & (XFS_GQUOTA_ACCT | XFS_GQUOTA_ACTIVE)) && |
@@ -1380,7 +1381,7 @@ xfs_finish_flags( | |||
1380 | !xfs_sb_version_has_pquotino(&mp->m_sb)) { | 1381 | !xfs_sb_version_has_pquotino(&mp->m_sb)) { |
1381 | xfs_warn(mp, | 1382 | xfs_warn(mp, |
1382 | "Super block does not support project and group quota together"); | 1383 | "Super block does not support project and group quota together"); |
1383 | return XFS_ERROR(EINVAL); | 1384 | return -EINVAL; |
1384 | } | 1385 | } |
1385 | 1386 | ||
1386 | return 0; | 1387 | return 0; |
@@ -1394,7 +1395,7 @@ xfs_fs_fill_super( | |||
1394 | { | 1395 | { |
1395 | struct inode *root; | 1396 | struct inode *root; |
1396 | struct xfs_mount *mp = NULL; | 1397 | struct xfs_mount *mp = NULL; |
1397 | int flags = 0, error = ENOMEM; | 1398 | int flags = 0, error = -ENOMEM; |
1398 | 1399 | ||
1399 | mp = kzalloc(sizeof(struct xfs_mount), GFP_KERNEL); | 1400 | mp = kzalloc(sizeof(struct xfs_mount), GFP_KERNEL); |
1400 | if (!mp) | 1401 | if (!mp) |
@@ -1428,11 +1429,11 @@ xfs_fs_fill_super( | |||
1428 | if (error) | 1429 | if (error) |
1429 | goto out_free_fsname; | 1430 | goto out_free_fsname; |
1430 | 1431 | ||
1431 | error = -xfs_init_mount_workqueues(mp); | 1432 | error = xfs_init_mount_workqueues(mp); |
1432 | if (error) | 1433 | if (error) |
1433 | goto out_close_devices; | 1434 | goto out_close_devices; |
1434 | 1435 | ||
1435 | error = -xfs_icsb_init_counters(mp); | 1436 | error = xfs_icsb_init_counters(mp); |
1436 | if (error) | 1437 | if (error) |
1437 | goto out_destroy_workqueues; | 1438 | goto out_destroy_workqueues; |
1438 | 1439 | ||
@@ -1474,12 +1475,12 @@ xfs_fs_fill_super( | |||
1474 | 1475 | ||
1475 | root = igrab(VFS_I(mp->m_rootip)); | 1476 | root = igrab(VFS_I(mp->m_rootip)); |
1476 | if (!root) { | 1477 | if (!root) { |
1477 | error = ENOENT; | 1478 | error = -ENOENT; |
1478 | goto out_unmount; | 1479 | goto out_unmount; |
1479 | } | 1480 | } |
1480 | sb->s_root = d_make_root(root); | 1481 | sb->s_root = d_make_root(root); |
1481 | if (!sb->s_root) { | 1482 | if (!sb->s_root) { |
1482 | error = ENOMEM; | 1483 | error = -ENOMEM; |
1483 | goto out_unmount; | 1484 | goto out_unmount; |
1484 | } | 1485 | } |
1485 | 1486 | ||
@@ -1499,7 +1500,7 @@ out_destroy_workqueues: | |||
1499 | xfs_free_fsname(mp); | 1500 | xfs_free_fsname(mp); |
1500 | kfree(mp); | 1501 | kfree(mp); |
1501 | out: | 1502 | out: |
1502 | return -error; | 1503 | return error; |
1503 | 1504 | ||
1504 | out_unmount: | 1505 | out_unmount: |
1505 | xfs_filestream_unmount(mp); | 1506 | xfs_filestream_unmount(mp); |
@@ -1761,9 +1762,15 @@ init_xfs_fs(void) | |||
1761 | if (error) | 1762 | if (error) |
1762 | goto out_cleanup_procfs; | 1763 | goto out_cleanup_procfs; |
1763 | 1764 | ||
1765 | xfs_kset = kset_create_and_add("xfs", NULL, fs_kobj); | ||
1766 | if (!xfs_kset) { | ||
1767 | error = -ENOMEM; | ||
1768 | goto out_sysctl_unregister;; | ||
1769 | } | ||
1770 | |||
1764 | error = xfs_qm_init(); | 1771 | error = xfs_qm_init(); |
1765 | if (error) | 1772 | if (error) |
1766 | goto out_sysctl_unregister; | 1773 | goto out_kset_unregister; |
1767 | 1774 | ||
1768 | error = register_filesystem(&xfs_fs_type); | 1775 | error = register_filesystem(&xfs_fs_type); |
1769 | if (error) | 1776 | if (error) |
@@ -1772,6 +1779,8 @@ init_xfs_fs(void) | |||
1772 | 1779 | ||
1773 | out_qm_exit: | 1780 | out_qm_exit: |
1774 | xfs_qm_exit(); | 1781 | xfs_qm_exit(); |
1782 | out_kset_unregister: | ||
1783 | kset_unregister(xfs_kset); | ||
1775 | out_sysctl_unregister: | 1784 | out_sysctl_unregister: |
1776 | xfs_sysctl_unregister(); | 1785 | xfs_sysctl_unregister(); |
1777 | out_cleanup_procfs: | 1786 | out_cleanup_procfs: |
@@ -1793,6 +1802,7 @@ exit_xfs_fs(void) | |||
1793 | { | 1802 | { |
1794 | xfs_qm_exit(); | 1803 | xfs_qm_exit(); |
1795 | unregister_filesystem(&xfs_fs_type); | 1804 | unregister_filesystem(&xfs_fs_type); |
1805 | kset_unregister(xfs_kset); | ||
1796 | xfs_sysctl_unregister(); | 1806 | xfs_sysctl_unregister(); |
1797 | xfs_cleanup_procfs(); | 1807 | xfs_cleanup_procfs(); |
1798 | xfs_buf_terminate(); | 1808 | xfs_buf_terminate(); |
diff --git a/fs/xfs/xfs_super.h b/fs/xfs/xfs_super.h index bbe3d15a7904..2b830c2f322e 100644 --- a/fs/xfs/xfs_super.h +++ b/fs/xfs/xfs_super.h | |||
@@ -44,16 +44,6 @@ extern void xfs_qm_exit(void); | |||
44 | # define XFS_REALTIME_STRING | 44 | # define XFS_REALTIME_STRING |
45 | #endif | 45 | #endif |
46 | 46 | ||
47 | #if XFS_BIG_BLKNOS | ||
48 | # if XFS_BIG_INUMS | ||
49 | # define XFS_BIGFS_STRING "large block/inode numbers, " | ||
50 | # else | ||
51 | # define XFS_BIGFS_STRING "large block numbers, " | ||
52 | # endif | ||
53 | #else | ||
54 | # define XFS_BIGFS_STRING | ||
55 | #endif | ||
56 | |||
57 | #ifdef DEBUG | 47 | #ifdef DEBUG |
58 | # define XFS_DBG_STRING "debug" | 48 | # define XFS_DBG_STRING "debug" |
59 | #else | 49 | #else |
@@ -64,7 +54,6 @@ extern void xfs_qm_exit(void); | |||
64 | #define XFS_BUILD_OPTIONS XFS_ACL_STRING \ | 54 | #define XFS_BUILD_OPTIONS XFS_ACL_STRING \ |
65 | XFS_SECURITY_STRING \ | 55 | XFS_SECURITY_STRING \ |
66 | XFS_REALTIME_STRING \ | 56 | XFS_REALTIME_STRING \ |
67 | XFS_BIGFS_STRING \ | ||
68 | XFS_DBG_STRING /* DBG must be last */ | 57 | XFS_DBG_STRING /* DBG must be last */ |
69 | 58 | ||
70 | struct xfs_inode; | 59 | struct xfs_inode; |
@@ -76,8 +65,8 @@ extern __uint64_t xfs_max_file_offset(unsigned int); | |||
76 | 65 | ||
77 | extern void xfs_flush_inodes(struct xfs_mount *mp); | 66 | extern void xfs_flush_inodes(struct xfs_mount *mp); |
78 | extern void xfs_blkdev_issue_flush(struct xfs_buftarg *); | 67 | extern void xfs_blkdev_issue_flush(struct xfs_buftarg *); |
79 | extern xfs_agnumber_t xfs_set_inode32(struct xfs_mount *); | 68 | extern xfs_agnumber_t xfs_set_inode32(struct xfs_mount *, xfs_agnumber_t agcount); |
80 | extern xfs_agnumber_t xfs_set_inode64(struct xfs_mount *); | 69 | extern xfs_agnumber_t xfs_set_inode64(struct xfs_mount *, xfs_agnumber_t agcount); |
81 | 70 | ||
82 | extern const struct export_operations xfs_export_operations; | 71 | extern const struct export_operations xfs_export_operations; |
83 | extern const struct xattr_handler *xfs_xattr_handlers[]; | 72 | extern const struct xattr_handler *xfs_xattr_handlers[]; |
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_sysfs.c b/fs/xfs/xfs_sysfs.c new file mode 100644 index 000000000000..9835139ce1ec --- /dev/null +++ b/fs/xfs/xfs_sysfs.c | |||
@@ -0,0 +1,165 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2014 Red Hat, Inc. | ||
3 | * All Rights Reserved. | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or | ||
6 | * modify it under the terms of the GNU General Public License as | ||
7 | * published by the Free Software Foundation. | ||
8 | * | ||
9 | * This program is distributed in the hope that it would be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License | ||
15 | * along with this program; if not, write the Free Software Foundation, | ||
16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
17 | */ | ||
18 | |||
19 | #include "xfs.h" | ||
20 | #include "xfs_sysfs.h" | ||
21 | #include "xfs_log_format.h" | ||
22 | #include "xfs_log.h" | ||
23 | #include "xfs_log_priv.h" | ||
24 | |||
25 | struct xfs_sysfs_attr { | ||
26 | struct attribute attr; | ||
27 | ssize_t (*show)(char *buf, void *data); | ||
28 | ssize_t (*store)(const char *buf, size_t count, void *data); | ||
29 | }; | ||
30 | |||
31 | static inline struct xfs_sysfs_attr * | ||
32 | to_attr(struct attribute *attr) | ||
33 | { | ||
34 | return container_of(attr, struct xfs_sysfs_attr, attr); | ||
35 | } | ||
36 | |||
37 | #define XFS_SYSFS_ATTR_RW(name) \ | ||
38 | static struct xfs_sysfs_attr xfs_sysfs_attr_##name = __ATTR_RW(name) | ||
39 | #define XFS_SYSFS_ATTR_RO(name) \ | ||
40 | static struct xfs_sysfs_attr xfs_sysfs_attr_##name = __ATTR_RO(name) | ||
41 | |||
42 | #define ATTR_LIST(name) &xfs_sysfs_attr_##name.attr | ||
43 | |||
44 | /* | ||
45 | * xfs_mount kobject. This currently has no attributes and thus no need for show | ||
46 | * and store helpers. The mp kobject serves as the per-mount parent object that | ||
47 | * is identified by the fsname under sysfs. | ||
48 | */ | ||
49 | |||
50 | struct kobj_type xfs_mp_ktype = { | ||
51 | .release = xfs_sysfs_release, | ||
52 | }; | ||
53 | |||
54 | /* xlog */ | ||
55 | |||
56 | STATIC ssize_t | ||
57 | log_head_lsn_show( | ||
58 | char *buf, | ||
59 | void *data) | ||
60 | { | ||
61 | struct xlog *log = data; | ||
62 | int cycle; | ||
63 | int block; | ||
64 | |||
65 | spin_lock(&log->l_icloglock); | ||
66 | cycle = log->l_curr_cycle; | ||
67 | block = log->l_curr_block; | ||
68 | spin_unlock(&log->l_icloglock); | ||
69 | |||
70 | return snprintf(buf, PAGE_SIZE, "%d:%d\n", cycle, block); | ||
71 | } | ||
72 | XFS_SYSFS_ATTR_RO(log_head_lsn); | ||
73 | |||
74 | STATIC ssize_t | ||
75 | log_tail_lsn_show( | ||
76 | char *buf, | ||
77 | void *data) | ||
78 | { | ||
79 | struct xlog *log = data; | ||
80 | int cycle; | ||
81 | int block; | ||
82 | |||
83 | xlog_crack_atomic_lsn(&log->l_tail_lsn, &cycle, &block); | ||
84 | return snprintf(buf, PAGE_SIZE, "%d:%d\n", cycle, block); | ||
85 | } | ||
86 | XFS_SYSFS_ATTR_RO(log_tail_lsn); | ||
87 | |||
88 | STATIC ssize_t | ||
89 | reserve_grant_head_show( | ||
90 | char *buf, | ||
91 | void *data) | ||
92 | { | ||
93 | struct xlog *log = data; | ||
94 | int cycle; | ||
95 | int bytes; | ||
96 | |||
97 | xlog_crack_grant_head(&log->l_reserve_head.grant, &cycle, &bytes); | ||
98 | return snprintf(buf, PAGE_SIZE, "%d:%d\n", cycle, bytes); | ||
99 | } | ||
100 | XFS_SYSFS_ATTR_RO(reserve_grant_head); | ||
101 | |||
102 | STATIC ssize_t | ||
103 | write_grant_head_show( | ||
104 | char *buf, | ||
105 | void *data) | ||
106 | { | ||
107 | struct xlog *log = data; | ||
108 | int cycle; | ||
109 | int bytes; | ||
110 | |||
111 | xlog_crack_grant_head(&log->l_write_head.grant, &cycle, &bytes); | ||
112 | return snprintf(buf, PAGE_SIZE, "%d:%d\n", cycle, bytes); | ||
113 | } | ||
114 | XFS_SYSFS_ATTR_RO(write_grant_head); | ||
115 | |||
116 | static struct attribute *xfs_log_attrs[] = { | ||
117 | ATTR_LIST(log_head_lsn), | ||
118 | ATTR_LIST(log_tail_lsn), | ||
119 | ATTR_LIST(reserve_grant_head), | ||
120 | ATTR_LIST(write_grant_head), | ||
121 | NULL, | ||
122 | }; | ||
123 | |||
124 | static inline struct xlog * | ||
125 | to_xlog(struct kobject *kobject) | ||
126 | { | ||
127 | struct xfs_kobj *kobj = to_kobj(kobject); | ||
128 | return container_of(kobj, struct xlog, l_kobj); | ||
129 | } | ||
130 | |||
131 | STATIC ssize_t | ||
132 | xfs_log_show( | ||
133 | struct kobject *kobject, | ||
134 | struct attribute *attr, | ||
135 | char *buf) | ||
136 | { | ||
137 | struct xlog *log = to_xlog(kobject); | ||
138 | struct xfs_sysfs_attr *xfs_attr = to_attr(attr); | ||
139 | |||
140 | return xfs_attr->show ? xfs_attr->show(buf, log) : 0; | ||
141 | } | ||
142 | |||
143 | STATIC ssize_t | ||
144 | xfs_log_store( | ||
145 | struct kobject *kobject, | ||
146 | struct attribute *attr, | ||
147 | const char *buf, | ||
148 | size_t count) | ||
149 | { | ||
150 | struct xlog *log = to_xlog(kobject); | ||
151 | struct xfs_sysfs_attr *xfs_attr = to_attr(attr); | ||
152 | |||
153 | return xfs_attr->store ? xfs_attr->store(buf, count, log) : 0; | ||
154 | } | ||
155 | |||
156 | static struct sysfs_ops xfs_log_ops = { | ||
157 | .show = xfs_log_show, | ||
158 | .store = xfs_log_store, | ||
159 | }; | ||
160 | |||
161 | struct kobj_type xfs_log_ktype = { | ||
162 | .release = xfs_sysfs_release, | ||
163 | .sysfs_ops = &xfs_log_ops, | ||
164 | .default_attrs = xfs_log_attrs, | ||
165 | }; | ||
diff --git a/fs/xfs/xfs_sysfs.h b/fs/xfs/xfs_sysfs.h new file mode 100644 index 000000000000..54a2091183c0 --- /dev/null +++ b/fs/xfs/xfs_sysfs.h | |||
@@ -0,0 +1,59 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2014 Red Hat, Inc. | ||
3 | * All Rights Reserved. | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or | ||
6 | * modify it under the terms of the GNU General Public License as | ||
7 | * published by the Free Software Foundation. | ||
8 | * | ||
9 | * This program is distributed in the hope that it would be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License | ||
15 | * along with this program; if not, write the Free Software Foundation, | ||
16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
17 | */ | ||
18 | |||
19 | #ifndef __XFS_SYSFS_H__ | ||
20 | #define __XFS_SYSFS_H__ | ||
21 | |||
22 | extern struct kobj_type xfs_mp_ktype; /* xfs_mount */ | ||
23 | extern struct kobj_type xfs_log_ktype; /* xlog */ | ||
24 | |||
25 | static inline struct xfs_kobj * | ||
26 | to_kobj(struct kobject *kobject) | ||
27 | { | ||
28 | return container_of(kobject, struct xfs_kobj, kobject); | ||
29 | } | ||
30 | |||
31 | static inline void | ||
32 | xfs_sysfs_release(struct kobject *kobject) | ||
33 | { | ||
34 | struct xfs_kobj *kobj = to_kobj(kobject); | ||
35 | complete(&kobj->complete); | ||
36 | } | ||
37 | |||
38 | static inline int | ||
39 | xfs_sysfs_init( | ||
40 | struct xfs_kobj *kobj, | ||
41 | struct kobj_type *ktype, | ||
42 | struct xfs_kobj *parent_kobj, | ||
43 | const char *name) | ||
44 | { | ||
45 | init_completion(&kobj->complete); | ||
46 | return kobject_init_and_add(&kobj->kobject, ktype, | ||
47 | &parent_kobj->kobject, "%s", name); | ||
48 | } | ||
49 | |||
50 | static inline void | ||
51 | xfs_sysfs_del( | ||
52 | struct xfs_kobj *kobj) | ||
53 | { | ||
54 | kobject_del(&kobj->kobject); | ||
55 | kobject_put(&kobj->kobject); | ||
56 | wait_for_completion(&kobj->complete); | ||
57 | } | ||
58 | |||
59 | #endif /* __XFS_SYSFS_H__ */ | ||
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 | ||
782 | out_free_ailp: | 782 | out_free_ailp: |
783 | kmem_free(ailp); | 783 | kmem_free(ailp); |
784 | return ENOMEM; | 784 | return -ENOMEM; |
785 | } | 785 | } |
786 | 786 | ||
787 | void | 787 | void |
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( | |||
722 | error_return: | 722 | error_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_types.h b/fs/xfs/xfs_types.h index 65c6e6650b1a..b79dc66b2ecd 100644 --- a/fs/xfs/xfs_types.h +++ b/fs/xfs/xfs_types.h | |||
@@ -38,43 +38,18 @@ typedef __int32_t xfs_tid_t; /* transaction identifier */ | |||
38 | typedef __uint32_t xfs_dablk_t; /* dir/attr block number (in file) */ | 38 | typedef __uint32_t xfs_dablk_t; /* dir/attr block number (in file) */ |
39 | typedef __uint32_t xfs_dahash_t; /* dir/attr hash value */ | 39 | typedef __uint32_t xfs_dahash_t; /* dir/attr hash value */ |
40 | 40 | ||
41 | /* | ||
42 | * These types are 64 bits on disk but are either 32 or 64 bits in memory. | ||
43 | * Disk based types: | ||
44 | */ | ||
45 | typedef __uint64_t xfs_dfsbno_t; /* blockno in filesystem (agno|agbno) */ | ||
46 | typedef __uint64_t xfs_drfsbno_t; /* blockno in filesystem (raw) */ | ||
47 | typedef __uint64_t xfs_drtbno_t; /* extent (block) in realtime area */ | ||
48 | typedef __uint64_t xfs_dfiloff_t; /* block number in a file */ | ||
49 | typedef __uint64_t xfs_dfilblks_t; /* number of blocks in a file */ | ||
50 | |||
51 | /* | ||
52 | * Memory based types are conditional. | ||
53 | */ | ||
54 | #if XFS_BIG_BLKNOS | ||
55 | typedef __uint64_t xfs_fsblock_t; /* blockno in filesystem (agno|agbno) */ | 41 | typedef __uint64_t xfs_fsblock_t; /* blockno in filesystem (agno|agbno) */ |
56 | typedef __uint64_t xfs_rfsblock_t; /* blockno in filesystem (raw) */ | 42 | typedef __uint64_t xfs_rfsblock_t; /* blockno in filesystem (raw) */ |
57 | typedef __uint64_t xfs_rtblock_t; /* extent (block) in realtime area */ | 43 | typedef __uint64_t xfs_rtblock_t; /* extent (block) in realtime area */ |
58 | typedef __int64_t xfs_srtblock_t; /* signed version of xfs_rtblock_t */ | ||
59 | #else | ||
60 | typedef __uint32_t xfs_fsblock_t; /* blockno in filesystem (agno|agbno) */ | ||
61 | typedef __uint32_t xfs_rfsblock_t; /* blockno in filesystem (raw) */ | ||
62 | typedef __uint32_t xfs_rtblock_t; /* extent (block) in realtime area */ | ||
63 | typedef __int32_t xfs_srtblock_t; /* signed version of xfs_rtblock_t */ | ||
64 | #endif | ||
65 | typedef __uint64_t xfs_fileoff_t; /* block number in a file */ | 44 | typedef __uint64_t xfs_fileoff_t; /* block number in a file */ |
66 | typedef __int64_t xfs_sfiloff_t; /* signed block number in a file */ | ||
67 | typedef __uint64_t xfs_filblks_t; /* number of blocks in a file */ | 45 | typedef __uint64_t xfs_filblks_t; /* number of blocks in a file */ |
68 | 46 | ||
47 | typedef __int64_t xfs_srtblock_t; /* signed version of xfs_rtblock_t */ | ||
48 | typedef __int64_t xfs_sfiloff_t; /* signed block number in a file */ | ||
69 | 49 | ||
70 | /* | 50 | /* |
71 | * Null values for the types. | 51 | * Null values for the types. |
72 | */ | 52 | */ |
73 | #define NULLDFSBNO ((xfs_dfsbno_t)-1) | ||
74 | #define NULLDRFSBNO ((xfs_drfsbno_t)-1) | ||
75 | #define NULLDRTBNO ((xfs_drtbno_t)-1) | ||
76 | #define NULLDFILOFF ((xfs_dfiloff_t)-1) | ||
77 | |||
78 | #define NULLFSBLOCK ((xfs_fsblock_t)-1) | 53 | #define NULLFSBLOCK ((xfs_fsblock_t)-1) |
79 | #define NULLRFSBLOCK ((xfs_rfsblock_t)-1) | 54 | #define NULLRFSBLOCK ((xfs_rfsblock_t)-1) |
80 | #define NULLRTBLOCK ((xfs_rtblock_t)-1) | 55 | #define NULLRTBLOCK ((xfs_rtblock_t)-1) |
diff --git a/fs/xfs/xfs_vnode.h b/fs/xfs/xfs_vnode.h deleted file mode 100644 index e8a77383c0d5..000000000000 --- a/fs/xfs/xfs_vnode.h +++ /dev/null | |||
@@ -1,46 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2000-2005 Silicon Graphics, Inc. | ||
3 | * All Rights Reserved. | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or | ||
6 | * modify it under the terms of the GNU General Public License as | ||
7 | * published by the Free Software Foundation. | ||
8 | * | ||
9 | * This program is distributed in the hope that it would be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License | ||
15 | * along with this program; if not, write the Free Software Foundation, | ||
16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
17 | */ | ||
18 | #ifndef __XFS_VNODE_H__ | ||
19 | #define __XFS_VNODE_H__ | ||
20 | |||
21 | #include "xfs_fs.h" | ||
22 | |||
23 | struct file; | ||
24 | struct xfs_inode; | ||
25 | struct attrlist_cursor_kern; | ||
26 | |||
27 | /* | ||
28 | * Flags for read/write calls - same values as IRIX | ||
29 | */ | ||
30 | #define IO_ISDIRECT 0x00004 /* bypass page cache */ | ||
31 | #define IO_INVIS 0x00020 /* don't update inode timestamps */ | ||
32 | |||
33 | #define XFS_IO_FLAGS \ | ||
34 | { IO_ISDIRECT, "DIRECT" }, \ | ||
35 | { IO_INVIS, "INVIS"} | ||
36 | |||
37 | /* | ||
38 | * Some useful predicates. | ||
39 | */ | ||
40 | #define VN_MAPPED(vp) mapping_mapped(vp->i_mapping) | ||
41 | #define VN_CACHED(vp) (vp->i_mapping->nrpages) | ||
42 | #define VN_DIRTY(vp) mapping_tagged(vp->i_mapping, \ | ||
43 | PAGECACHE_TAG_DIRTY) | ||
44 | |||
45 | |||
46 | #endif /* __XFS_VNODE_H__ */ | ||
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 | ||