aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/filesystems/xfs.txt142
-rw-r--r--fs/quota.c8
-rw-r--r--fs/xfs/Kconfig2
-rw-r--r--fs/xfs/Makefile-linux-2.61
-rw-r--r--fs/xfs/linux-2.6/kmem.c39
-rw-r--r--fs/xfs/linux-2.6/kmem.h52
-rw-r--r--fs/xfs/linux-2.6/mrlock.h36
-rw-r--r--fs/xfs/linux-2.6/mutex.h36
-rw-r--r--fs/xfs/linux-2.6/sema.h36
-rw-r--r--fs/xfs/linux-2.6/spin.h36
-rw-r--r--fs/xfs/linux-2.6/sv.h36
-rw-r--r--fs/xfs/linux-2.6/time.h36
-rw-r--r--fs/xfs/linux-2.6/xfs_aops.c80
-rw-r--r--fs/xfs/linux-2.6/xfs_aops.h36
-rw-r--r--fs/xfs/linux-2.6/xfs_buf.c218
-rw-r--r--fs/xfs/linux-2.6/xfs_buf.h73
-rw-r--r--fs/xfs/linux-2.6/xfs_cred.h36
-rw-r--r--fs/xfs/linux-2.6/xfs_export.c47
-rw-r--r--fs/xfs/linux-2.6/xfs_export.h36
-rw-r--r--fs/xfs/linux-2.6/xfs_file.c41
-rw-r--r--fs/xfs/linux-2.6/xfs_fs_subr.c38
-rw-r--r--fs/xfs/linux-2.6/xfs_fs_subr.h57
-rw-r--r--fs/xfs/linux-2.6/xfs_globals.c42
-rw-r--r--fs/xfs/linux-2.6/xfs_globals.h41
-rw-r--r--fs/xfs/linux-2.6/xfs_ioctl.c55
-rw-r--r--fs/xfs/linux-2.6/xfs_ioctl32.c38
-rw-r--r--fs/xfs/linux-2.6/xfs_ioctl32.h44
-rw-r--r--fs/xfs/linux-2.6/xfs_iops.c180
-rw-r--r--fs/xfs/linux-2.6/xfs_iops.h40
-rw-r--r--fs/xfs/linux-2.6/xfs_linux.h56
-rw-r--r--fs/xfs/linux-2.6/xfs_lrw.c69
-rw-r--r--fs/xfs/linux-2.6/xfs_lrw.h41
-rw-r--r--fs/xfs/linux-2.6/xfs_stats.c37
-rw-r--r--fs/xfs/linux-2.6/xfs_stats.h36
-rw-r--r--fs/xfs/linux-2.6/xfs_super.c132
-rw-r--r--fs/xfs/linux-2.6/xfs_super.h37
-rw-r--r--fs/xfs/linux-2.6/xfs_sysctl.c56
-rw-r--r--fs/xfs/linux-2.6/xfs_sysctl.h37
-rw-r--r--fs/xfs/linux-2.6/xfs_version.h41
-rw-r--r--fs/xfs/linux-2.6/xfs_vfs.c38
-rw-r--r--fs/xfs/linux-2.6/xfs_vfs.h37
-rw-r--r--fs/xfs/linux-2.6/xfs_vnode.c40
-rw-r--r--fs/xfs/linux-2.6/xfs_vnode.h55
-rw-r--r--fs/xfs/quota/Makefile1
-rw-r--r--fs/xfs/quota/Makefile-linux-2.653
-rw-r--r--fs/xfs/quota/xfs_dquot.c237
-rw-r--r--fs/xfs/quota/xfs_dquot.h36
-rw-r--r--fs/xfs/quota/xfs_dquot_item.c53
-rw-r--r--fs/xfs/quota/xfs_dquot_item.h36
-rw-r--r--fs/xfs/quota/xfs_qm.c187
-rw-r--r--fs/xfs/quota/xfs_qm.h42
-rw-r--r--fs/xfs/quota/xfs_qm_bhv.c53
-rw-r--r--fs/xfs/quota/xfs_qm_stats.c53
-rw-r--r--fs/xfs/quota/xfs_qm_stats.h37
-rw-r--r--fs/xfs/quota/xfs_qm_syscalls.c173
-rw-r--r--fs/xfs/quota/xfs_quota_priv.h36
-rw-r--r--fs/xfs/quota/xfs_trans_dquot.c102
-rw-r--r--fs/xfs/support/debug.c38
-rw-r--r--fs/xfs/support/debug.h43
-rw-r--r--fs/xfs/support/ktrace.c39
-rw-r--r--fs/xfs/support/ktrace.h38
-rw-r--r--fs/xfs/support/move.c37
-rw-r--r--fs/xfs/support/move.h36
-rw-r--r--fs/xfs/support/qsort.c155
-rw-r--r--fs/xfs/support/qsort.h41
-rw-r--r--fs/xfs/support/uuid.c37
-rw-r--r--fs/xfs/support/uuid.h52
-rw-r--r--fs/xfs/xfs.h44
-rw-r--r--fs/xfs/xfs_acl.c55
-rw-r--r--fs/xfs/xfs_acl.h36
-rw-r--r--fs/xfs/xfs_ag.h242
-rw-r--r--fs/xfs/xfs_alloc.c200
-rw-r--r--fs/xfs/xfs_alloc.h36
-rw-r--r--fs/xfs/xfs_alloc_btree.c475
-rw-r--r--fs/xfs/xfs_alloc_btree.h186
-rw-r--r--fs/xfs/xfs_arch.h51
-rw-r--r--fs/xfs/xfs_attr.c230
-rw-r--r--fs/xfs/xfs_attr.h44
-rw-r--r--fs/xfs/xfs_attr_leaf.c273
-rw-r--r--fs/xfs/xfs_attr_leaf.h129
-rw-r--r--fs/xfs/xfs_attr_sf.h65
-rw-r--r--fs/xfs/xfs_behavior.c37
-rw-r--r--fs/xfs/xfs_behavior.h36
-rw-r--r--fs/xfs/xfs_bit.c44
-rw-r--r--fs/xfs/xfs_bit.h72
-rw-r--r--fs/xfs/xfs_bmap.c244
-rw-r--r--fs/xfs/xfs_bmap.h58
-rw-r--r--fs/xfs/xfs_bmap_btree.c286
-rw-r--r--fs/xfs/xfs_bmap_btree.h644
-rw-r--r--fs/xfs/xfs_btree.c160
-rw-r--r--fs/xfs/xfs_btree.h211
-rw-r--r--fs/xfs/xfs_buf_item.c54
-rw-r--r--fs/xfs/xfs_buf_item.h36
-rw-r--r--fs/xfs/xfs_cap.h36
-rw-r--r--fs/xfs/xfs_clnt.h52
-rw-r--r--fs/xfs/xfs_da_btree.c101
-rw-r--r--fs/xfs/xfs_da_btree.h108
-rw-r--r--fs/xfs/xfs_dfrag.c123
-rw-r--r--fs/xfs/xfs_dfrag.h36
-rw-r--r--fs/xfs/xfs_dinode.h205
-rw-r--r--fs/xfs/xfs_dir.c70
-rw-r--r--fs/xfs/xfs_dir.h36
-rw-r--r--fs/xfs/xfs_dir2.c57
-rw-r--r--fs/xfs/xfs_dir2.h36
-rw-r--r--fs/xfs/xfs_dir2_block.c56
-rw-r--r--fs/xfs/xfs_dir2_block.h98
-rw-r--r--fs/xfs/xfs_dir2_data.c52
-rw-r--r--fs/xfs/xfs_dir2_data.h129
-rw-r--r--fs/xfs/xfs_dir2_leaf.c54
-rw-r--r--fs/xfs/xfs_dir2_leaf.h350
-rw-r--r--fs/xfs/xfs_dir2_node.c52
-rw-r--r--fs/xfs/xfs_dir2_node.h147
-rw-r--r--fs/xfs/xfs_dir2_sf.c59
-rw-r--r--fs/xfs/xfs_dir2_sf.h230
-rw-r--r--fs/xfs/xfs_dir2_trace.c47
-rw-r--r--fs/xfs/xfs_dir2_trace.h36
-rw-r--r--fs/xfs/xfs_dir_leaf.c64
-rw-r--r--fs/xfs/xfs_dir_leaf.h73
-rw-r--r--fs/xfs/xfs_dir_sf.h109
-rw-r--r--fs/xfs/xfs_dmapi.h36
-rw-r--r--fs/xfs/xfs_dmops.c41
-rw-r--r--fs/xfs/xfs_error.c46
-rw-r--r--fs/xfs/xfs_error.h104
-rw-r--r--fs/xfs/xfs_extfree_item.c47
-rw-r--r--fs/xfs/xfs_extfree_item.h36
-rw-r--r--fs/xfs/xfs_fs.h40
-rw-r--r--fs/xfs/xfs_fsops.c161
-rw-r--r--fs/xfs/xfs_fsops.h74
-rw-r--r--fs/xfs/xfs_ialloc.c133
-rw-r--r--fs/xfs/xfs_ialloc.h76
-rw-r--r--fs/xfs/xfs_ialloc_btree.c306
-rw-r--r--fs/xfs/xfs_ialloc_btree.h247
-rw-r--r--fs/xfs/xfs_iget.c54
-rw-r--r--fs/xfs/xfs_imap.h36
-rw-r--r--fs/xfs/xfs_inode.c153
-rw-r--r--fs/xfs/xfs_inode.h132
-rw-r--r--fs/xfs/xfs_inode_item.c60
-rw-r--r--fs/xfs/xfs_inode_item.h77
-rw-r--r--fs/xfs/xfs_inum.h140
-rw-r--r--fs/xfs/xfs_iocore.c57
-rw-r--r--fs/xfs/xfs_iomap.c69
-rw-r--r--fs/xfs/xfs_iomap.h36
-rw-r--r--fs/xfs/xfs_itable.c52
-rw-r--r--fs/xfs/xfs_itable.h33
-rw-r--r--fs/xfs/xfs_log.c281
-rw-r--r--fs/xfs/xfs_log.h45
-rw-r--r--fs/xfs/xfs_log_priv.h179
-rw-r--r--fs/xfs/xfs_log_recover.c174
-rw-r--r--fs/xfs/xfs_log_recover.h36
-rw-r--r--fs/xfs/xfs_mac.h36
-rw-r--r--fs/xfs/xfs_macros.c2141
-rw-r--r--fs/xfs/xfs_macros.h104
-rw-r--r--fs/xfs/xfs_mount.c73
-rw-r--r--fs/xfs/xfs_mount.h186
-rw-r--r--fs/xfs/xfs_qmops.c41
-rw-r--r--fs/xfs/xfs_quota.h80
-rw-r--r--fs/xfs/xfs_refcache.h36
-rw-r--r--fs/xfs/xfs_rename.c49
-rw-r--r--fs/xfs/xfs_rtalloc.c55
-rw-r--r--fs/xfs/xfs_rtalloc.h36
-rw-r--r--fs/xfs/xfs_rw.c58
-rw-r--r--fs/xfs/xfs_rw.h135
-rw-r--r--fs/xfs/xfs_sb.h448
-rw-r--r--fs/xfs/xfs_trans.c112
-rw-r--r--fs/xfs/xfs_trans.h176
-rw-r--r--fs/xfs/xfs_trans_ail.c41
-rw-r--r--fs/xfs/xfs_trans_buf.c53
-rw-r--r--fs/xfs/xfs_trans_extfree.c41
-rw-r--r--fs/xfs/xfs_trans_inode.c54
-rw-r--r--fs/xfs/xfs_trans_item.c41
-rw-r--r--fs/xfs/xfs_trans_priv.h36
-rw-r--r--fs/xfs/xfs_trans_space.h36
-rw-r--r--fs/xfs/xfs_types.h42
-rw-r--r--fs/xfs/xfs_utils.c47
-rw-r--r--fs/xfs/xfs_utils.h36
-rw-r--r--fs/xfs/xfs_vfsops.c181
-rw-r--r--fs/xfs/xfs_vnodeops.c144
-rw-r--r--include/linux/dqblk_xfs.h20
178 files changed, 5785 insertions, 11967 deletions
diff --git a/Documentation/filesystems/xfs.txt b/Documentation/filesystems/xfs.txt
index c7d5d0c7067d..74aeb142ae5f 100644
--- a/Documentation/filesystems/xfs.txt
+++ b/Documentation/filesystems/xfs.txt
@@ -19,15 +19,43 @@ Mount Options
19 19
20When mounting an XFS filesystem, the following options are accepted. 20When mounting an XFS filesystem, the following options are accepted.
21 21
22 biosize=size 22 allocsize=size
23 Sets the preferred buffered I/O size (default size is 64K). 23 Sets the buffered I/O end-of-file preallocation size when
24 "size" must be expressed as the logarithm (base2) of the 24 doing delayed allocation writeout (default size is 64KiB).
25 desired I/O size. 25 Valid values for this option are page size (typically 4KiB)
26 Valid values for this option are 14 through 16, inclusive 26 through to 1GiB, inclusive, in power-of-2 increments.
27 (i.e. 16K, 32K, and 64K bytes). On machines with a 4K 27
28 pagesize, 13 (8K bytes) is also a valid size. 28 attr2/noattr2
29 The preferred buffered I/O size can also be altered on an 29 The options enable/disable (default is disabled for backward
30 individual file basis using the ioctl(2) system call. 30 compatibility on-disk) an "opportunistic" improvement to be
31 made in the way inline extended attributes are stored on-disk.
32 When the new form is used for the first time (by setting or
33 removing extended attributes) the on-disk superblock feature
34 bit field will be updated to reflect this format being in use.
35
36 barrier
37 Enables the use of block layer write barriers for writes into
38 the journal and unwritten extent conversion. This allows for
39 drive level write caching to be enabled, for devices that
40 support write barriers.
41
42 dmapi
43 Enable the DMAPI (Data Management API) event callouts.
44 Use with the "mtpt" option.
45
46 grpid/bsdgroups and nogrpid/sysvgroups
47 These options define what group ID a newly created file gets.
48 When grpid is set, it takes the group ID of the directory in
49 which it is created; otherwise (the default) it takes the fsgid
50 of the current process, unless the directory has the setgid bit
51 set, in which case it takes the gid from the parent directory,
52 and also gets the setgid bit set if it is a directory itself.
53
54 ihashsize=value
55 Sets the number of hash buckets available for hashing the
56 in-memory inodes of the specified mount point. If a value
57 of zero is used, the value selected by the default algorithm
58 will be displayed in /proc/mounts.
31 59
32 ikeep/noikeep 60 ikeep/noikeep
33 When inode clusters are emptied of inodes, keep them around 61 When inode clusters are emptied of inodes, keep them around
@@ -35,12 +63,31 @@ When mounting an XFS filesystem, the following options are accepted.
35 and is still the default for now. Using the noikeep option, 63 and is still the default for now. Using the noikeep option,
36 inode clusters are returned to the free space pool. 64 inode clusters are returned to the free space pool.
37 65
66 inode64
67 Indicates that XFS is allowed to create inodes at any location
68 in the filesystem, including those which will result in inode
69 numbers occupying more than 32 bits of significance. This is
70 provided for backwards compatibility, but causes problems for
71 backup applications that cannot handle large inode numbers.
72
73 largeio/nolargeio
74 If "nolargeio" is specified, the optimal I/O reported in
75 st_blksize by stat(2) will be as small as possible to allow user
76 applications to avoid inefficient read/modify/write I/O.
77 If "largeio" specified, a filesystem that has a "swidth" specified
78 will return the "swidth" value (in bytes) in st_blksize. If the
79 filesystem does not have a "swidth" specified but does specify
80 an "allocsize" then "allocsize" (in bytes) will be returned
81 instead.
82 If neither of these two options are specified, then filesystem
83 will behave as if "nolargeio" was specified.
84
38 logbufs=value 85 logbufs=value
39 Set the number of in-memory log buffers. Valid numbers range 86 Set the number of in-memory log buffers. Valid numbers range
40 from 2-8 inclusive. 87 from 2-8 inclusive.
41 The default value is 8 buffers for filesystems with a 88 The default value is 8 buffers for filesystems with a
42 blocksize of 64K, 4 buffers for filesystems with a blocksize 89 blocksize of 64KiB, 4 buffers for filesystems with a blocksize
43 of 32K, 3 buffers for filesystems with a blocksize of 16K 90 of 32KiB, 3 buffers for filesystems with a blocksize of 16KiB
44 and 2 buffers for all other configurations. Increasing the 91 and 2 buffers for all other configurations. Increasing the
45 number of buffers may increase performance on some workloads 92 number of buffers may increase performance on some workloads
46 at the cost of the memory used for the additional log buffers 93 at the cost of the memory used for the additional log buffers
@@ -49,10 +96,10 @@ When mounting an XFS filesystem, the following options are accepted.
49 logbsize=value 96 logbsize=value
50 Set the size of each in-memory log buffer. 97 Set the size of each in-memory log buffer.
51 Size may be specified in bytes, or in kilobytes with a "k" suffix. 98 Size may be specified in bytes, or in kilobytes with a "k" suffix.
52 Valid sizes for version 1 and version 2 logs are 16384 (16k) and 99 Valid sizes for version 1 and version 2 logs are 16384 (16k) and
53 32768 (32k). Valid sizes for version 2 logs also include 100 32768 (32k). Valid sizes for version 2 logs also include
54 65536 (64k), 131072 (128k) and 262144 (256k). 101 65536 (64k), 131072 (128k) and 262144 (256k).
55 The default value for machines with more than 32MB of memory 102 The default value for machines with more than 32MiB of memory
56 is 32768, machines with less memory use 16384 by default. 103 is 32768, machines with less memory use 16384 by default.
57 104
58 logdev=device and rtdev=device 105 logdev=device and rtdev=device
@@ -62,6 +109,11 @@ When mounting an XFS filesystem, the following options are accepted.
62 optional, and the log section can be separate from the data 109 optional, and the log section can be separate from the data
63 section or contained within it. 110 section or contained within it.
64 111
112 mtpt=mountpoint
113 Use with the "dmapi" option. The value specified here will be
114 included in the DMAPI mount event, and should be the path of
115 the actual mountpoint that is used.
116
65 noalign 117 noalign
66 Data allocations will not be aligned at stripe unit boundaries. 118 Data allocations will not be aligned at stripe unit boundaries.
67 119
@@ -91,13 +143,17 @@ When mounting an XFS filesystem, the following options are accepted.
91 O_SYNC writes can be lost if the system crashes. 143 O_SYNC writes can be lost if the system crashes.
92 If timestamp updates are critical, use the osyncisosync option. 144 If timestamp updates are critical, use the osyncisosync option.
93 145
94 quota/usrquota/uqnoenforce 146 uquota/usrquota/uqnoenforce/quota
95 User disk quota accounting enabled, and limits (optionally) 147 User disk quota accounting enabled, and limits (optionally)
96 enforced. 148 enforced. Refer to xfs_quota(8) for further details.
97 149
98 grpquota/gqnoenforce 150 gquota/grpquota/gqnoenforce
99 Group disk quota accounting enabled and limits (optionally) 151 Group disk quota accounting enabled and limits (optionally)
100 enforced. 152 enforced. Refer to xfs_quota(8) for further details.
153
154 pquota/prjquota/pqnoenforce
155 Project disk quota accounting enabled and limits (optionally)
156 enforced. Refer to xfs_quota(8) for further details.
101 157
102 sunit=value and swidth=value 158 sunit=value and swidth=value
103 Used to specify the stripe unit and width for a RAID device or 159 Used to specify the stripe unit and width for a RAID device or
@@ -113,15 +169,21 @@ When mounting an XFS filesystem, the following options are accepted.
113 The "swidth" option is required if the "sunit" option has been 169 The "swidth" option is required if the "sunit" option has been
114 specified, and must be a multiple of the "sunit" value. 170 specified, and must be a multiple of the "sunit" value.
115 171
172 swalloc
173 Data allocations will be rounded up to stripe width boundaries
174 when the current end of file is being extended and the file
175 size is larger than the stripe width size.
176
177
116sysctls 178sysctls
117======= 179=======
118 180
119The following sysctls are available for the XFS filesystem: 181The following sysctls are available for the XFS filesystem:
120 182
121 fs.xfs.stats_clear (Min: 0 Default: 0 Max: 1) 183 fs.xfs.stats_clear (Min: 0 Default: 0 Max: 1)
122 Setting this to "1" clears accumulated XFS statistics 184 Setting this to "1" clears accumulated XFS statistics
123 in /proc/fs/xfs/stat. It then immediately resets to "0". 185 in /proc/fs/xfs/stat. It then immediately resets to "0".
124 186
125 fs.xfs.xfssyncd_centisecs (Min: 100 Default: 3000 Max: 720000) 187 fs.xfs.xfssyncd_centisecs (Min: 100 Default: 3000 Max: 720000)
126 The interval at which the xfssyncd thread flushes metadata 188 The interval at which the xfssyncd thread flushes metadata
127 out to disk. This thread will flush log activity out, and 189 out to disk. This thread will flush log activity out, and
@@ -143,9 +205,9 @@ The following sysctls are available for the XFS filesystem:
143 XFS_ERRLEVEL_HIGH: 5 205 XFS_ERRLEVEL_HIGH: 5
144 206
145 fs.xfs.panic_mask (Min: 0 Default: 0 Max: 127) 207 fs.xfs.panic_mask (Min: 0 Default: 0 Max: 127)
146 Causes certain error conditions to call BUG(). Value is a bitmask; 208 Causes certain error conditions to call BUG(). Value is a bitmask;
147 AND together the tags which represent errors which should cause panics: 209 AND together the tags which represent errors which should cause panics:
148 210
149 XFS_NO_PTAG 0 211 XFS_NO_PTAG 0
150 XFS_PTAG_IFLUSH 0x00000001 212 XFS_PTAG_IFLUSH 0x00000001
151 XFS_PTAG_LOGRES 0x00000002 213 XFS_PTAG_LOGRES 0x00000002
@@ -155,7 +217,7 @@ The following sysctls are available for the XFS filesystem:
155 XFS_PTAG_SHUTDOWN_IOERROR 0x00000020 217 XFS_PTAG_SHUTDOWN_IOERROR 0x00000020
156 XFS_PTAG_SHUTDOWN_LOGERROR 0x00000040 218 XFS_PTAG_SHUTDOWN_LOGERROR 0x00000040
157 219
158 This option is intended for debugging only. 220 This option is intended for debugging only.
159 221
160 fs.xfs.irix_symlink_mode (Min: 0 Default: 0 Max: 1) 222 fs.xfs.irix_symlink_mode (Min: 0 Default: 0 Max: 1)
161 Controls whether symlinks are created with mode 0777 (default) 223 Controls whether symlinks are created with mode 0777 (default)
@@ -164,25 +226,37 @@ The following sysctls are available for the XFS filesystem:
164 fs.xfs.irix_sgid_inherit (Min: 0 Default: 0 Max: 1) 226 fs.xfs.irix_sgid_inherit (Min: 0 Default: 0 Max: 1)
165 Controls files created in SGID directories. 227 Controls files created in SGID directories.
166 If the group ID of the new file does not match the effective group 228 If the group ID of the new file does not match the effective group
167 ID or one of the supplementary group IDs of the parent dir, the 229 ID or one of the supplementary group IDs of the parent dir, the
168 ISGID bit is cleared if the irix_sgid_inherit compatibility sysctl 230 ISGID bit is cleared if the irix_sgid_inherit compatibility sysctl
169 is set. 231 is set.
170 232
171 fs.xfs.restrict_chown (Min: 0 Default: 1 Max: 1) 233 fs.xfs.restrict_chown (Min: 0 Default: 1 Max: 1)
172 Controls whether unprivileged users can use chown to "give away" 234 Controls whether unprivileged users can use chown to "give away"
173 a file to another user. 235 a file to another user.
174 236
175 fs.xfs.inherit_sync (Min: 0 Default: 1 Max 1) 237 fs.xfs.inherit_sync (Min: 0 Default: 1 Max: 1)
176 Setting this to "1" will cause the "sync" flag set 238 Setting this to "1" will cause the "sync" flag set
177 by the chattr(1) command on a directory to be 239 by the xfs_io(8) chattr command on a directory to be
178 inherited by files in that directory. 240 inherited by files in that directory.
179 241
180 fs.xfs.inherit_nodump (Min: 0 Default: 1 Max 1) 242 fs.xfs.inherit_nodump (Min: 0 Default: 1 Max: 1)
181 Setting this to "1" will cause the "nodump" flag set 243 Setting this to "1" will cause the "nodump" flag set
182 by the chattr(1) command on a directory to be 244 by the xfs_io(8) chattr command on a directory to be
183 inherited by files in that directory. 245 inherited by files in that directory.
184 246
185 fs.xfs.inherit_noatime (Min: 0 Default: 1 Max 1) 247 fs.xfs.inherit_noatime (Min: 0 Default: 1 Max: 1)
186 Setting this to "1" will cause the "noatime" flag set 248 Setting this to "1" will cause the "noatime" flag set
187 by the chattr(1) command on a directory to be 249 by the xfs_io(8) chattr command on a directory to be
188 inherited by files in that directory. 250 inherited by files in that directory.
251
252 fs.xfs.inherit_nosymlinks (Min: 0 Default: 1 Max: 1)
253 Setting this to "1" will cause the "nosymlinks" flag set
254 by the xfs_io(8) chattr command on a directory to be
255 inherited by files in that directory.
256
257 fs.xfs.rotorstep (Min: 1 Default: 1 Max: 256)
258 In "inode32" allocation mode, this option determines how many
259 files the allocator attempts to allocate in the same allocation
260 group before moving to the next allocation group. The intent
261 is to control the rate at which the allocator moves between
262 allocation groups when allocating extents for new files.
diff --git a/fs/quota.c b/fs/quota.c
index f5d1cff55196..1df7832b4e08 100644
--- a/fs/quota.c
+++ b/fs/quota.c
@@ -118,6 +118,10 @@ static int xqm_quotactl_valid(struct super_block *sb, int type, int cmd, qid_t i
118 if (!sb->s_qcop->get_xquota) 118 if (!sb->s_qcop->get_xquota)
119 return -ENOSYS; 119 return -ENOSYS;
120 break; 120 break;
121 case Q_XQUOTASYNC:
122 if (!sb->s_qcop->quota_sync)
123 return -ENOSYS;
124 break;
121 default: 125 default:
122 return -EINVAL; 126 return -EINVAL;
123 } 127 }
@@ -128,7 +132,7 @@ static int xqm_quotactl_valid(struct super_block *sb, int type, int cmd, qid_t i
128 (type == XQM_GRPQUOTA && !in_egroup_p(id))) && 132 (type == XQM_GRPQUOTA && !in_egroup_p(id))) &&
129 !capable(CAP_SYS_ADMIN)) 133 !capable(CAP_SYS_ADMIN))
130 return -EPERM; 134 return -EPERM;
131 } else if (cmd != Q_XGETQSTAT) { 135 } else if (cmd != Q_XGETQSTAT && cmd != Q_XQUOTASYNC) {
132 if (!capable(CAP_SYS_ADMIN)) 136 if (!capable(CAP_SYS_ADMIN))
133 return -EPERM; 137 return -EPERM;
134 } 138 }
@@ -322,6 +326,8 @@ static int do_quotactl(struct super_block *sb, int type, int cmd, qid_t id, void
322 return -EFAULT; 326 return -EFAULT;
323 return 0; 327 return 0;
324 } 328 }
329 case Q_XQUOTASYNC:
330 return sb->s_qcop->quota_sync(sb, type);
325 /* We never reach here unless validity check is broken */ 331 /* We never reach here unless validity check is broken */
326 default: 332 default:
327 BUG(); 333 BUG();
diff --git a/fs/xfs/Kconfig b/fs/xfs/Kconfig
index 8e8f32dabe53..bac27d66151d 100644
--- a/fs/xfs/Kconfig
+++ b/fs/xfs/Kconfig
@@ -24,7 +24,7 @@ config XFS_EXPORT
24 default y 24 default y
25 25
26config XFS_QUOTA 26config XFS_QUOTA
27 tristate "XFS Quota support" 27 bool "XFS Quota support"
28 depends on XFS_FS 28 depends on XFS_FS
29 help 29 help
30 If you say Y here, you will be able to set limits for disk usage on 30 If you say Y here, you will be able to set limits for disk usage on
diff --git a/fs/xfs/Makefile-linux-2.6 b/fs/xfs/Makefile-linux-2.6
index d8c87fa21ad1..97bd4743b461 100644
--- a/fs/xfs/Makefile-linux-2.6
+++ b/fs/xfs/Makefile-linux-2.6
@@ -109,7 +109,6 @@ xfs-y += xfs_alloc.o \
109 xfs_dfrag.o \ 109 xfs_dfrag.o \
110 xfs_log.o \ 110 xfs_log.o \
111 xfs_log_recover.o \ 111 xfs_log_recover.o \
112 xfs_macros.o \
113 xfs_mount.o \ 112 xfs_mount.o \
114 xfs_rename.o \ 113 xfs_rename.o \
115 xfs_trans.o \ 114 xfs_trans.o \
diff --git a/fs/xfs/linux-2.6/kmem.c b/fs/xfs/linux-2.6/kmem.c
index 3c92162dc728..aba7fcf881a2 100644
--- a/fs/xfs/linux-2.6/kmem.c
+++ b/fs/xfs/linux-2.6/kmem.c
@@ -1,49 +1,32 @@
1/* 1/*
2 * Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32
33#include <linux/sched.h> 18#include <linux/sched.h>
34#include <linux/mm.h> 19#include <linux/mm.h>
35#include <linux/vmalloc.h> 20#include <linux/vmalloc.h>
36#include <linux/highmem.h> 21#include <linux/highmem.h>
37#include <linux/swap.h> 22#include <linux/swap.h>
38#include <linux/blkdev.h> 23#include <linux/blkdev.h>
39
40#include "time.h" 24#include "time.h"
41#include "kmem.h" 25#include "kmem.h"
42 26
43#define MAX_VMALLOCS 6 27#define MAX_VMALLOCS 6
44#define MAX_SLAB_SIZE 0x20000 28#define MAX_SLAB_SIZE 0x20000
45 29
46
47void * 30void *
48kmem_alloc(size_t size, unsigned int __nocast flags) 31kmem_alloc(size_t size, unsigned int __nocast flags)
49{ 32{
diff --git a/fs/xfs/linux-2.6/kmem.h b/fs/xfs/linux-2.6/kmem.h
index f4bb78c268c0..8f82c1a20dc5 100644
--- a/fs/xfs/linux-2.6/kmem.h
+++ b/fs/xfs/linux-2.6/kmem.h
@@ -1,33 +1,19 @@
1/* 1/*
2 * Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32#ifndef __XFS_SUPPORT_KMEM_H__ 18#ifndef __XFS_SUPPORT_KMEM_H__
33#define __XFS_SUPPORT_KMEM_H__ 19#define __XFS_SUPPORT_KMEM_H__
@@ -83,7 +69,7 @@ typedef unsigned long xfs_pflags_t;
83 69
84static __inline gfp_t kmem_flags_convert(unsigned int __nocast flags) 70static __inline gfp_t kmem_flags_convert(unsigned int __nocast flags)
85{ 71{
86 gfp_t lflags = __GFP_NOWARN; /* we'll report problems, if need be */ 72 gfp_t lflags = __GFP_NOWARN; /* we'll report problems, if need be */
87 73
88#ifdef DEBUG 74#ifdef DEBUG
89 if (unlikely(flags & ~(KM_SLEEP|KM_NOSLEEP|KM_NOFS|KM_MAYFAIL))) { 75 if (unlikely(flags & ~(KM_SLEEP|KM_NOSLEEP|KM_NOFS|KM_MAYFAIL))) {
@@ -102,7 +88,7 @@ static __inline gfp_t kmem_flags_convert(unsigned int __nocast flags)
102 if (PFLAGS_TEST_FSTRANS() || (flags & KM_NOFS)) 88 if (PFLAGS_TEST_FSTRANS() || (flags & KM_NOFS))
103 lflags &= ~__GFP_FS; 89 lflags &= ~__GFP_FS;
104 } 90 }
105 91
106 return lflags; 92 return lflags;
107} 93}
108 94
@@ -125,13 +111,13 @@ kmem_zone_destroy(kmem_zone_t *zone)
125 BUG(); 111 BUG();
126} 112}
127 113
128extern void *kmem_zone_zalloc(kmem_zone_t *, unsigned int __nocast); 114extern void *kmem_zone_zalloc(kmem_zone_t *, unsigned int __nocast);
129extern void *kmem_zone_alloc(kmem_zone_t *, unsigned int __nocast); 115extern void *kmem_zone_alloc(kmem_zone_t *, unsigned int __nocast);
130 116
131extern void *kmem_alloc(size_t, unsigned int __nocast); 117extern void *kmem_alloc(size_t, unsigned int __nocast);
132extern void *kmem_realloc(void *, size_t, size_t, unsigned int __nocast); 118extern void *kmem_realloc(void *, size_t, size_t, unsigned int __nocast);
133extern void *kmem_zalloc(size_t, unsigned int __nocast); 119extern void *kmem_zalloc(size_t, unsigned int __nocast);
134extern void kmem_free(void *, size_t); 120extern void kmem_free(void *, size_t);
135 121
136typedef struct shrinker *kmem_shaker_t; 122typedef struct shrinker *kmem_shaker_t;
137typedef int (*kmem_shake_func_t)(int, gfp_t); 123typedef int (*kmem_shake_func_t)(int, gfp_t);
diff --git a/fs/xfs/linux-2.6/mrlock.h b/fs/xfs/linux-2.6/mrlock.h
index d2c11a098ff2..16b44c3c2362 100644
--- a/fs/xfs/linux-2.6/mrlock.h
+++ b/fs/xfs/linux-2.6/mrlock.h
@@ -1,33 +1,19 @@
1/* 1/*
2 * Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32#ifndef __XFS_SUPPORT_MRLOCK_H__ 18#ifndef __XFS_SUPPORT_MRLOCK_H__
33#define __XFS_SUPPORT_MRLOCK_H__ 19#define __XFS_SUPPORT_MRLOCK_H__
diff --git a/fs/xfs/linux-2.6/mutex.h b/fs/xfs/linux-2.6/mutex.h
index 0b296bb944cb..ce773d89a923 100644
--- a/fs/xfs/linux-2.6/mutex.h
+++ b/fs/xfs/linux-2.6/mutex.h
@@ -1,33 +1,19 @@
1/* 1/*
2 * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32#ifndef __XFS_SUPPORT_MUTEX_H__ 18#ifndef __XFS_SUPPORT_MUTEX_H__
33#define __XFS_SUPPORT_MUTEX_H__ 19#define __XFS_SUPPORT_MUTEX_H__
diff --git a/fs/xfs/linux-2.6/sema.h b/fs/xfs/linux-2.6/sema.h
index 30b67b4e1cbf..194a84490bd1 100644
--- a/fs/xfs/linux-2.6/sema.h
+++ b/fs/xfs/linux-2.6/sema.h
@@ -1,33 +1,19 @@
1/* 1/*
2 * Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32#ifndef __XFS_SUPPORT_SEMA_H__ 18#ifndef __XFS_SUPPORT_SEMA_H__
33#define __XFS_SUPPORT_SEMA_H__ 19#define __XFS_SUPPORT_SEMA_H__
diff --git a/fs/xfs/linux-2.6/spin.h b/fs/xfs/linux-2.6/spin.h
index 0039504069a5..50a6191178f4 100644
--- a/fs/xfs/linux-2.6/spin.h
+++ b/fs/xfs/linux-2.6/spin.h
@@ -1,33 +1,19 @@
1/* 1/*
2 * Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32#ifndef __XFS_SUPPORT_SPIN_H__ 18#ifndef __XFS_SUPPORT_SPIN_H__
33#define __XFS_SUPPORT_SPIN_H__ 19#define __XFS_SUPPORT_SPIN_H__
diff --git a/fs/xfs/linux-2.6/sv.h b/fs/xfs/linux-2.6/sv.h
index 821d3167e05b..9a8ad481b008 100644
--- a/fs/xfs/linux-2.6/sv.h
+++ b/fs/xfs/linux-2.6/sv.h
@@ -1,33 +1,19 @@
1/* 1/*
2 * Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32#ifndef __XFS_SUPPORT_SV_H__ 18#ifndef __XFS_SUPPORT_SV_H__
33#define __XFS_SUPPORT_SV_H__ 19#define __XFS_SUPPORT_SV_H__
diff --git a/fs/xfs/linux-2.6/time.h b/fs/xfs/linux-2.6/time.h
index b0d2873ab274..387e695a184c 100644
--- a/fs/xfs/linux-2.6/time.h
+++ b/fs/xfs/linux-2.6/time.h
@@ -1,33 +1,19 @@
1/* 1/*
2 * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32#ifndef __XFS_SUPPORT_TIME_H__ 18#ifndef __XFS_SUPPORT_TIME_H__
33#define __XFS_SUPPORT_TIME_H__ 19#define __XFS_SUPPORT_TIME_H__
diff --git a/fs/xfs/linux-2.6/xfs_aops.c b/fs/xfs/linux-2.6/xfs_aops.c
index 7aa398724706..c6108971b4e6 100644
--- a/fs/xfs/linux-2.6/xfs_aops.c
+++ b/fs/xfs/linux-2.6/xfs_aops.c
@@ -1,39 +1,26 @@
1/* 1/*
2 * Copyright (c) 2000-2005 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32
33#include "xfs.h" 18#include "xfs.h"
34#include "xfs_inum.h" 19#include "xfs_bit.h"
35#include "xfs_log.h" 20#include "xfs_log.h"
21#include "xfs_inum.h"
36#include "xfs_sb.h" 22#include "xfs_sb.h"
23#include "xfs_ag.h"
37#include "xfs_dir.h" 24#include "xfs_dir.h"
38#include "xfs_dir2.h" 25#include "xfs_dir2.h"
39#include "xfs_trans.h" 26#include "xfs_trans.h"
@@ -42,13 +29,13 @@
42#include "xfs_bmap_btree.h" 29#include "xfs_bmap_btree.h"
43#include "xfs_alloc_btree.h" 30#include "xfs_alloc_btree.h"
44#include "xfs_ialloc_btree.h" 31#include "xfs_ialloc_btree.h"
45#include "xfs_alloc.h"
46#include "xfs_btree.h"
47#include "xfs_attr_sf.h"
48#include "xfs_dir_sf.h" 32#include "xfs_dir_sf.h"
49#include "xfs_dir2_sf.h" 33#include "xfs_dir2_sf.h"
34#include "xfs_attr_sf.h"
50#include "xfs_dinode.h" 35#include "xfs_dinode.h"
51#include "xfs_inode.h" 36#include "xfs_inode.h"
37#include "xfs_alloc.h"
38#include "xfs_btree.h"
52#include "xfs_error.h" 39#include "xfs_error.h"
53#include "xfs_rw.h" 40#include "xfs_rw.h"
54#include "xfs_iomap.h" 41#include "xfs_iomap.h"
@@ -761,8 +748,9 @@ xfs_page_state_convert(
761 if (page->index >= end_index) { 748 if (page->index >= end_index) {
762 if ((page->index >= end_index + 1) || 749 if ((page->index >= end_index + 1) ||
763 !(i_size_read(inode) & (PAGE_CACHE_SIZE - 1))) { 750 !(i_size_read(inode) & (PAGE_CACHE_SIZE - 1))) {
764 err = -EIO; 751 if (startio)
765 goto error; 752 unlock_page(page);
753 return 0;
766 } 754 }
767 } 755 }
768 756
@@ -948,15 +936,18 @@ __linvfs_get_block(
948{ 936{
949 vnode_t *vp = LINVFS_GET_VP(inode); 937 vnode_t *vp = LINVFS_GET_VP(inode);
950 xfs_iomap_t iomap; 938 xfs_iomap_t iomap;
939 xfs_off_t offset;
940 ssize_t size;
951 int retpbbm = 1; 941 int retpbbm = 1;
952 int error; 942 int error;
953 ssize_t size;
954 loff_t offset = (loff_t)iblock << inode->i_blkbits;
955 943
956 if (blocks) 944 if (blocks) {
957 size = blocks << inode->i_blkbits; 945 offset = blocks << inode->i_blkbits; /* 64 bit goodness */
958 else 946 size = (ssize_t) min_t(xfs_off_t, offset, LONG_MAX);
947 } else {
959 size = 1 << inode->i_blkbits; 948 size = 1 << inode->i_blkbits;
949 }
950 offset = (xfs_off_t)iblock << inode->i_blkbits;
960 951
961 VOP_BMAP(vp, offset, size, 952 VOP_BMAP(vp, offset, size,
962 create ? flags : BMAPI_READ, &iomap, &retpbbm, error); 953 create ? flags : BMAPI_READ, &iomap, &retpbbm, error);
@@ -967,8 +958,8 @@ __linvfs_get_block(
967 return 0; 958 return 0;
968 959
969 if (iomap.iomap_bn != IOMAP_DADDR_NULL) { 960 if (iomap.iomap_bn != IOMAP_DADDR_NULL) {
970 xfs_daddr_t bn; 961 xfs_daddr_t bn;
971 loff_t delta; 962 xfs_off_t delta;
972 963
973 /* For unwritten extents do not report a disk address on 964 /* For unwritten extents do not report a disk address on
974 * the read case (treat as if we're reading into a hole). 965 * the read case (treat as if we're reading into a hole).
@@ -1000,9 +991,8 @@ __linvfs_get_block(
1000 */ 991 */
1001 if (create && 992 if (create &&
1002 ((!buffer_mapped(bh_result) && !buffer_uptodate(bh_result)) || 993 ((!buffer_mapped(bh_result) && !buffer_uptodate(bh_result)) ||
1003 (offset >= i_size_read(inode)) || (iomap.iomap_flags & IOMAP_NEW))) { 994 (offset >= i_size_read(inode)) || (iomap.iomap_flags & IOMAP_NEW)))
1004 set_buffer_new(bh_result); 995 set_buffer_new(bh_result);
1005 }
1006 996
1007 if (iomap.iomap_flags & IOMAP_DELAY) { 997 if (iomap.iomap_flags & IOMAP_DELAY) {
1008 BUG_ON(direct); 998 BUG_ON(direct);
@@ -1014,9 +1004,11 @@ __linvfs_get_block(
1014 } 1004 }
1015 1005
1016 if (blocks) { 1006 if (blocks) {
1017 bh_result->b_size = (ssize_t)min( 1007 ASSERT(iomap.iomap_bsize - iomap.iomap_delta > 0);
1018 (loff_t)(iomap.iomap_bsize - iomap.iomap_delta), 1008 offset = min_t(xfs_off_t,
1019 (loff_t)(blocks << inode->i_blkbits)); 1009 iomap.iomap_bsize - iomap.iomap_delta,
1010 blocks << inode->i_blkbits);
1011 bh_result->b_size = (u32) min_t(xfs_off_t, UINT_MAX, offset);
1020 } 1012 }
1021 1013
1022 return 0; 1014 return 0;
diff --git a/fs/xfs/linux-2.6/xfs_aops.h b/fs/xfs/linux-2.6/xfs_aops.h
index 2fa62974a04d..4720758a9ade 100644
--- a/fs/xfs/linux-2.6/xfs_aops.h
+++ b/fs/xfs/linux-2.6/xfs_aops.h
@@ -1,33 +1,19 @@
1/* 1/*
2 * Copyright (c) 2005 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32#ifndef __XFS_AOPS_H__ 18#ifndef __XFS_AOPS_H__
33#define __XFS_AOPS_H__ 19#define __XFS_AOPS_H__
diff --git a/fs/xfs/linux-2.6/xfs_buf.c b/fs/xfs/linux-2.6/xfs_buf.c
index 4cd46abe8434..6fe21d2b8847 100644
--- a/fs/xfs/linux-2.6/xfs_buf.c
+++ b/fs/xfs/linux-2.6/xfs_buf.c
@@ -1,46 +1,20 @@
1/* 1/*
2 * Copyright (c) 2000-2005 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * 12 * GNU General Public License for more details.
12 * Further, this software is distributed without any warranty that it is
13 * free of the rightful claim of any third person regarding infringement
14 * or the like. Any license provided herein, whether implied or
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */
32
33/*
34 * The xfs_buf.c code provides an abstract buffer cache model on top
35 * of the Linux page cache. Cached metadata blocks for a file system
36 * are hashed to the inode for the block device. xfs_buf.c assembles
37 * buffers (xfs_buf_t) on demand to aggregate such cached pages for I/O.
38 *
39 * Written by Steve Lord, Jim Mostek, Russell Cattelan
40 * and Rajagopal Ananthanarayanan ("ananth") at SGI.
41 * 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
42 */ 17 */
43
44#include <linux/stddef.h> 18#include <linux/stddef.h>
45#include <linux/errno.h> 19#include <linux/errno.h>
46#include <linux/slab.h> 20#include <linux/slab.h>
@@ -55,13 +29,8 @@
55#include <linux/blkdev.h> 29#include <linux/blkdev.h>
56#include <linux/hash.h> 30#include <linux/hash.h>
57#include <linux/kthread.h> 31#include <linux/kthread.h>
58
59#include "xfs_linux.h" 32#include "xfs_linux.h"
60 33
61/*
62 * File wide globals
63 */
64
65STATIC kmem_cache_t *pagebuf_zone; 34STATIC kmem_cache_t *pagebuf_zone;
66STATIC kmem_shaker_t pagebuf_shake; 35STATIC kmem_shaker_t pagebuf_shake;
67STATIC int xfsbufd_wakeup(int, gfp_t); 36STATIC int xfsbufd_wakeup(int, gfp_t);
@@ -70,10 +39,6 @@ STATIC void pagebuf_delwri_queue(xfs_buf_t *, int);
70STATIC struct workqueue_struct *xfslogd_workqueue; 39STATIC struct workqueue_struct *xfslogd_workqueue;
71struct workqueue_struct *xfsdatad_workqueue; 40struct workqueue_struct *xfsdatad_workqueue;
72 41
73/*
74 * Pagebuf debugging
75 */
76
77#ifdef PAGEBUF_TRACE 42#ifdef PAGEBUF_TRACE
78void 43void
79pagebuf_trace( 44pagebuf_trace(
@@ -112,10 +77,6 @@ ktrace_t *pagebuf_trace_buf;
112# define PB_GET_OWNER(pb) do { } while (0) 77# define PB_GET_OWNER(pb) do { } while (0)
113#endif 78#endif
114 79
115/*
116 * Pagebuf allocation / freeing.
117 */
118
119#define pb_to_gfp(flags) \ 80#define pb_to_gfp(flags) \
120 ((((flags) & PBF_READ_AHEAD) ? __GFP_NORETRY : \ 81 ((((flags) & PBF_READ_AHEAD) ? __GFP_NORETRY : \
121 ((flags) & PBF_DONT_BLOCK) ? GFP_NOFS : GFP_KERNEL) | __GFP_NOWARN) 82 ((flags) & PBF_DONT_BLOCK) ? GFP_NOFS : GFP_KERNEL) | __GFP_NOWARN)
@@ -123,7 +84,6 @@ ktrace_t *pagebuf_trace_buf;
123#define pb_to_km(flags) \ 84#define pb_to_km(flags) \
124 (((flags) & PBF_DONT_BLOCK) ? KM_NOFS : KM_SLEEP) 85 (((flags) & PBF_DONT_BLOCK) ? KM_NOFS : KM_SLEEP)
125 86
126
127#define pagebuf_allocate(flags) \ 87#define pagebuf_allocate(flags) \
128 kmem_zone_alloc(pagebuf_zone, pb_to_km(flags)) 88 kmem_zone_alloc(pagebuf_zone, pb_to_km(flags))
129#define pagebuf_deallocate(pb) \ 89#define pagebuf_deallocate(pb) \
@@ -286,7 +246,7 @@ _pagebuf_initialize(
286 * most cases but may be reset (e.g. XFS recovery). 246 * most cases but may be reset (e.g. XFS recovery).
287 */ 247 */
288 pb->pb_buffer_length = pb->pb_count_desired = range_length; 248 pb->pb_buffer_length = pb->pb_count_desired = range_length;
289 pb->pb_flags = flags | PBF_NONE; 249 pb->pb_flags = flags;
290 pb->pb_bn = XFS_BUF_DADDR_NULL; 250 pb->pb_bn = XFS_BUF_DADDR_NULL;
291 atomic_set(&pb->pb_pin_count, 0); 251 atomic_set(&pb->pb_pin_count, 0);
292 init_waitqueue_head(&pb->pb_waiters); 252 init_waitqueue_head(&pb->pb_waiters);
@@ -458,14 +418,8 @@ _pagebuf_lookup_pages(
458 unlock_page(bp->pb_pages[i]); 418 unlock_page(bp->pb_pages[i]);
459 } 419 }
460 420
461 if (page_count) { 421 if (page_count == bp->pb_page_count)
462 /* if we have any uptodate pages, mark that in the buffer */ 422 bp->pb_flags |= PBF_DONE;
463 bp->pb_flags &= ~PBF_NONE;
464
465 /* if some pages aren't uptodate, mark that in the buffer */
466 if (page_count != bp->pb_page_count)
467 bp->pb_flags |= PBF_PARTIAL;
468 }
469 423
470 PB_TRACE(bp, "lookup_pages", (long)page_count); 424 PB_TRACE(bp, "lookup_pages", (long)page_count);
471 return error; 425 return error;
@@ -676,7 +630,7 @@ xfs_buf_read_flags(
676 630
677 pb = xfs_buf_get_flags(target, ioff, isize, flags); 631 pb = xfs_buf_get_flags(target, ioff, isize, flags);
678 if (pb) { 632 if (pb) {
679 if (PBF_NOT_DONE(pb)) { 633 if (!XFS_BUF_ISDONE(pb)) {
680 PB_TRACE(pb, "read", (unsigned long)flags); 634 PB_TRACE(pb, "read", (unsigned long)flags);
681 XFS_STATS_INC(pb_get_read); 635 XFS_STATS_INC(pb_get_read);
682 pagebuf_iostart(pb, flags); 636 pagebuf_iostart(pb, flags);
@@ -813,7 +767,7 @@ pagebuf_get_no_daddr(
813 bp = pagebuf_allocate(0); 767 bp = pagebuf_allocate(0);
814 if (unlikely(bp == NULL)) 768 if (unlikely(bp == NULL))
815 goto fail; 769 goto fail;
816 _pagebuf_initialize(bp, target, 0, len, PBF_FORCEIO); 770 _pagebuf_initialize(bp, target, 0, len, 0);
817 771
818 try_again: 772 try_again:
819 data = kmem_alloc(malloc_len, KM_SLEEP | KM_MAYFAIL); 773 data = kmem_alloc(malloc_len, KM_SLEEP | KM_MAYFAIL);
@@ -876,39 +830,18 @@ pagebuf_rele(
876 830
877 PB_TRACE(pb, "rele", pb->pb_relse); 831 PB_TRACE(pb, "rele", pb->pb_relse);
878 832
879 /*
880 * pagebuf_lookup buffers are not hashed, not delayed write,
881 * and don't have their own release routines. Special case.
882 */
883 if (unlikely(!hash)) {
884 ASSERT(!pb->pb_relse);
885 if (atomic_dec_and_test(&pb->pb_hold))
886 xfs_buf_free(pb);
887 return;
888 }
889
890 if (atomic_dec_and_lock(&pb->pb_hold, &hash->bh_lock)) { 833 if (atomic_dec_and_lock(&pb->pb_hold, &hash->bh_lock)) {
891 int do_free = 1;
892
893 if (pb->pb_relse) { 834 if (pb->pb_relse) {
894 atomic_inc(&pb->pb_hold); 835 atomic_inc(&pb->pb_hold);
895 spin_unlock(&hash->bh_lock); 836 spin_unlock(&hash->bh_lock);
896 (*(pb->pb_relse)) (pb); 837 (*(pb->pb_relse)) (pb);
897 spin_lock(&hash->bh_lock); 838 } else if (pb->pb_flags & PBF_FS_MANAGED) {
898 do_free = 0;
899 }
900
901 if (pb->pb_flags & PBF_FS_MANAGED) {
902 do_free = 0;
903 }
904
905 if (do_free) {
906 ASSERT((pb->pb_flags & (PBF_DELWRI|_PBF_DELWRI_Q)) == 0);
907 list_del_init(&pb->pb_hash_list);
908 spin_unlock(&hash->bh_lock); 839 spin_unlock(&hash->bh_lock);
909 pagebuf_free(pb);
910 } else { 840 } else {
841 ASSERT(!(pb->pb_flags & (PBF_DELWRI|_PBF_DELWRI_Q)));
842 list_del_init(&pb->pb_hash_list);
911 spin_unlock(&hash->bh_lock); 843 spin_unlock(&hash->bh_lock);
844 pagebuf_free(pb);
912 } 845 }
913 } else { 846 } else {
914 /* 847 /*
@@ -1121,21 +1054,18 @@ pagebuf_iodone_work(
1121void 1054void
1122pagebuf_iodone( 1055pagebuf_iodone(
1123 xfs_buf_t *pb, 1056 xfs_buf_t *pb,
1124 int dataio,
1125 int schedule) 1057 int schedule)
1126{ 1058{
1127 pb->pb_flags &= ~(PBF_READ | PBF_WRITE); 1059 pb->pb_flags &= ~(PBF_READ | PBF_WRITE);
1128 if (pb->pb_error == 0) { 1060 if (pb->pb_error == 0)
1129 pb->pb_flags &= ~(PBF_PARTIAL | PBF_NONE); 1061 pb->pb_flags |= PBF_DONE;
1130 }
1131 1062
1132 PB_TRACE(pb, "iodone", pb->pb_iodone); 1063 PB_TRACE(pb, "iodone", pb->pb_iodone);
1133 1064
1134 if ((pb->pb_iodone) || (pb->pb_flags & PBF_ASYNC)) { 1065 if ((pb->pb_iodone) || (pb->pb_flags & PBF_ASYNC)) {
1135 if (schedule) { 1066 if (schedule) {
1136 INIT_WORK(&pb->pb_iodone_work, pagebuf_iodone_work, pb); 1067 INIT_WORK(&pb->pb_iodone_work, pagebuf_iodone_work, pb);
1137 queue_work(dataio ? xfsdatad_workqueue : 1068 queue_work(xfslogd_workqueue, &pb->pb_iodone_work);
1138 xfslogd_workqueue, &pb->pb_iodone_work);
1139 } else { 1069 } else {
1140 pagebuf_iodone_work(pb); 1070 pagebuf_iodone_work(pb);
1141 } 1071 }
@@ -1235,7 +1165,7 @@ _pagebuf_iodone(
1235{ 1165{
1236 if (atomic_dec_and_test(&pb->pb_io_remaining) == 1) { 1166 if (atomic_dec_and_test(&pb->pb_io_remaining) == 1) {
1237 pb->pb_locked = 0; 1167 pb->pb_locked = 0;
1238 pagebuf_iodone(pb, (pb->pb_flags & PBF_FS_DATAIOD), schedule); 1168 pagebuf_iodone(pb, schedule);
1239 } 1169 }
1240} 1170}
1241 1171
@@ -1304,6 +1234,11 @@ _pagebuf_ioapply(
1304 rw = (pb->pb_flags & PBF_READ) ? READ : WRITE; 1234 rw = (pb->pb_flags & PBF_READ) ? READ : WRITE;
1305 } 1235 }
1306 1236
1237 if (pb->pb_flags & PBF_ORDERED) {
1238 ASSERT(!(pb->pb_flags & PBF_READ));
1239 rw = WRITE_BARRIER;
1240 }
1241
1307 /* Special code path for reading a sub page size pagebuf in -- 1242 /* Special code path for reading a sub page size pagebuf in --
1308 * we populate up the whole page, and hence the other metadata 1243 * we populate up the whole page, and hence the other metadata
1309 * in the same page. This optimization is only valid when the 1244 * in the same page. This optimization is only valid when the
@@ -1750,8 +1685,8 @@ STATIC int xfsbufd_force_sleep;
1750 1685
1751STATIC int 1686STATIC int
1752xfsbufd_wakeup( 1687xfsbufd_wakeup(
1753 int priority, 1688 int priority,
1754 gfp_t mask) 1689 gfp_t mask)
1755{ 1690{
1756 if (xfsbufd_force_sleep) 1691 if (xfsbufd_force_sleep)
1757 return 0; 1692 return 0;
@@ -1781,8 +1716,8 @@ xfsbufd(
1781 xfsbufd_force_sleep = 0; 1716 xfsbufd_force_sleep = 0;
1782 } 1717 }
1783 1718
1784 schedule_timeout_interruptible 1719 schedule_timeout_interruptible(
1785 (xfs_buf_timer_centisecs * msecs_to_jiffies(10)); 1720 xfs_buf_timer_centisecs * msecs_to_jiffies(10));
1786 1721
1787 age = xfs_buf_age_centisecs * msecs_to_jiffies(10); 1722 age = xfs_buf_age_centisecs * msecs_to_jiffies(10);
1788 spin_lock(&pbd_delwrite_lock); 1723 spin_lock(&pbd_delwrite_lock);
@@ -1891,14 +1826,22 @@ xfs_flush_buftarg(
1891 return pincount; 1826 return pincount;
1892} 1827}
1893 1828
1894STATIC int 1829int __init
1895xfs_buf_daemons_start(void) 1830pagebuf_init(void)
1896{ 1831{
1897 int error = -ENOMEM; 1832 int error = -ENOMEM;
1898 1833
1834#ifdef PAGEBUF_TRACE
1835 pagebuf_trace_buf = ktrace_alloc(PAGEBUF_TRACE_SIZE, KM_SLEEP);
1836#endif
1837
1838 pagebuf_zone = kmem_zone_init(sizeof(xfs_buf_t), "xfs_buf");
1839 if (!pagebuf_zone)
1840 goto out_free_trace_buf;
1841
1899 xfslogd_workqueue = create_workqueue("xfslogd"); 1842 xfslogd_workqueue = create_workqueue("xfslogd");
1900 if (!xfslogd_workqueue) 1843 if (!xfslogd_workqueue)
1901 goto out; 1844 goto out_free_buf_zone;
1902 1845
1903 xfsdatad_workqueue = create_workqueue("xfsdatad"); 1846 xfsdatad_workqueue = create_workqueue("xfsdatad");
1904 if (!xfsdatad_workqueue) 1847 if (!xfsdatad_workqueue)
@@ -1909,82 +1852,37 @@ xfs_buf_daemons_start(void)
1909 error = PTR_ERR(xfsbufd_task); 1852 error = PTR_ERR(xfsbufd_task);
1910 goto out_destroy_xfsdatad_workqueue; 1853 goto out_destroy_xfsdatad_workqueue;
1911 } 1854 }
1855
1856 pagebuf_shake = kmem_shake_register(xfsbufd_wakeup);
1857 if (!pagebuf_shake)
1858 goto out_stop_xfsbufd;
1859
1912 return 0; 1860 return 0;
1913 1861
1862 out_stop_xfsbufd:
1863 kthread_stop(xfsbufd_task);
1914 out_destroy_xfsdatad_workqueue: 1864 out_destroy_xfsdatad_workqueue:
1915 destroy_workqueue(xfsdatad_workqueue); 1865 destroy_workqueue(xfsdatad_workqueue);
1916 out_destroy_xfslogd_workqueue: 1866 out_destroy_xfslogd_workqueue:
1917 destroy_workqueue(xfslogd_workqueue); 1867 destroy_workqueue(xfslogd_workqueue);
1918 out:
1919 return error;
1920}
1921
1922/*
1923 * Note: do not mark as __exit, it is called from pagebuf_terminate.
1924 */
1925STATIC void
1926xfs_buf_daemons_stop(void)
1927{
1928 kthread_stop(xfsbufd_task);
1929 destroy_workqueue(xfslogd_workqueue);
1930 destroy_workqueue(xfsdatad_workqueue);
1931}
1932
1933/*
1934 * Initialization and Termination
1935 */
1936
1937int __init
1938pagebuf_init(void)
1939{
1940 int error = -ENOMEM;
1941
1942 pagebuf_zone = kmem_zone_init(sizeof(xfs_buf_t), "xfs_buf");
1943 if (!pagebuf_zone)
1944 goto out;
1945
1946#ifdef PAGEBUF_TRACE
1947 pagebuf_trace_buf = ktrace_alloc(PAGEBUF_TRACE_SIZE, KM_SLEEP);
1948#endif
1949
1950 error = xfs_buf_daemons_start();
1951 if (error)
1952 goto out_free_buf_zone;
1953
1954 pagebuf_shake = kmem_shake_register(xfsbufd_wakeup);
1955 if (!pagebuf_shake) {
1956 error = -ENOMEM;
1957 goto out_stop_daemons;
1958 }
1959
1960 return 0;
1961
1962 out_stop_daemons:
1963 xfs_buf_daemons_stop();
1964 out_free_buf_zone: 1868 out_free_buf_zone:
1869 kmem_zone_destroy(pagebuf_zone);
1870 out_free_trace_buf:
1965#ifdef PAGEBUF_TRACE 1871#ifdef PAGEBUF_TRACE
1966 ktrace_free(pagebuf_trace_buf); 1872 ktrace_free(pagebuf_trace_buf);
1967#endif 1873#endif
1968 kmem_zone_destroy(pagebuf_zone);
1969 out:
1970 return error; 1874 return error;
1971} 1875}
1972 1876
1973
1974/*
1975 * pagebuf_terminate.
1976 *
1977 * Note: do not mark as __exit, this is also called from the __init code.
1978 */
1979void 1877void
1980pagebuf_terminate(void) 1878pagebuf_terminate(void)
1981{ 1879{
1982 xfs_buf_daemons_stop(); 1880 kmem_shake_deregister(pagebuf_shake);
1983 1881 kthread_stop(xfsbufd_task);
1882 destroy_workqueue(xfsdatad_workqueue);
1883 destroy_workqueue(xfslogd_workqueue);
1884 kmem_zone_destroy(pagebuf_zone);
1984#ifdef PAGEBUF_TRACE 1885#ifdef PAGEBUF_TRACE
1985 ktrace_free(pagebuf_trace_buf); 1886 ktrace_free(pagebuf_trace_buf);
1986#endif 1887#endif
1987
1988 kmem_zone_destroy(pagebuf_zone);
1989 kmem_shake_deregister(pagebuf_shake);
1990} 1888}
diff --git a/fs/xfs/linux-2.6/xfs_buf.h b/fs/xfs/linux-2.6/xfs_buf.h
index 67c19f799232..237a35b915d1 100644
--- a/fs/xfs/linux-2.6/xfs_buf.h
+++ b/fs/xfs/linux-2.6/xfs_buf.h
@@ -1,39 +1,20 @@
1/* 1/*
2 * Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32
33/*
34 * Written by Steve Lord, Jim Mostek, Russell Cattelan at SGI
35 */
36
37#ifndef __XFS_BUF_H__ 18#ifndef __XFS_BUF_H__
38#define __XFS_BUF_H__ 19#define __XFS_BUF_H__
39 20
@@ -69,15 +50,12 @@ typedef enum page_buf_flags_e { /* pb_flags values */
69 PBF_READ = (1 << 0), /* buffer intended for reading from device */ 50 PBF_READ = (1 << 0), /* buffer intended for reading from device */
70 PBF_WRITE = (1 << 1), /* buffer intended for writing to device */ 51 PBF_WRITE = (1 << 1), /* buffer intended for writing to device */
71 PBF_MAPPED = (1 << 2), /* buffer mapped (pb_addr valid) */ 52 PBF_MAPPED = (1 << 2), /* buffer mapped (pb_addr valid) */
72 PBF_PARTIAL = (1 << 3), /* buffer partially read */
73 PBF_ASYNC = (1 << 4), /* initiator will not wait for completion */ 53 PBF_ASYNC = (1 << 4), /* initiator will not wait for completion */
74 PBF_NONE = (1 << 5), /* buffer not read at all */ 54 PBF_DONE = (1 << 5), /* all pages in the buffer uptodate */
75 PBF_DELWRI = (1 << 6), /* buffer has dirty pages */ 55 PBF_DELWRI = (1 << 6), /* buffer has dirty pages */
76 PBF_STALE = (1 << 7), /* buffer has been staled, do not find it */ 56 PBF_STALE = (1 << 7), /* buffer has been staled, do not find it */
77 PBF_FS_MANAGED = (1 << 8), /* filesystem controls freeing memory */ 57 PBF_FS_MANAGED = (1 << 8), /* filesystem controls freeing memory */
78 PBF_FS_DATAIOD = (1 << 9), /* schedule IO completion on fs datad */ 58 PBF_ORDERED = (1 << 11), /* use ordered writes */
79 PBF_FORCEIO = (1 << 10), /* ignore any cache state */
80 PBF_FLUSH = (1 << 11), /* flush disk write cache */
81 PBF_READ_AHEAD = (1 << 12), /* asynchronous read-ahead */ 59 PBF_READ_AHEAD = (1 << 12), /* asynchronous read-ahead */
82 60
83 /* flags used only as arguments to access routines */ 61 /* flags used only as arguments to access routines */
@@ -92,9 +70,6 @@ typedef enum page_buf_flags_e { /* pb_flags values */
92 _PBF_DELWRI_Q = (1 << 21), /* buffer on delwri queue */ 70 _PBF_DELWRI_Q = (1 << 21), /* buffer on delwri queue */
93} page_buf_flags_t; 71} page_buf_flags_t;
94 72
95#define PBF_UPDATE (PBF_READ | PBF_WRITE)
96#define PBF_NOT_DONE(pb) (((pb)->pb_flags & (PBF_PARTIAL|PBF_NONE)) != 0)
97#define PBF_DONE(pb) (((pb)->pb_flags & (PBF_PARTIAL|PBF_NONE)) == 0)
98 73
99typedef struct xfs_bufhash { 74typedef struct xfs_bufhash {
100 struct list_head bh_list; 75 struct list_head bh_list;
@@ -258,7 +233,6 @@ extern void pagebuf_unlock( /* unlock buffer */
258 233
259extern void pagebuf_iodone( /* mark buffer I/O complete */ 234extern void pagebuf_iodone( /* mark buffer I/O complete */
260 xfs_buf_t *, /* buffer to mark */ 235 xfs_buf_t *, /* buffer to mark */
261 int, /* use data/log helper thread. */
262 int); /* run completion locally, or in 236 int); /* run completion locally, or in
263 * a helper thread. */ 237 * a helper thread. */
264 238
@@ -378,21 +352,21 @@ extern void pagebuf_trace(
378#define XFS_BUF_GETERROR(x) pagebuf_geterror(x) 352#define XFS_BUF_GETERROR(x) pagebuf_geterror(x)
379#define XFS_BUF_ISERROR(x) (pagebuf_geterror(x)?1:0) 353#define XFS_BUF_ISERROR(x) (pagebuf_geterror(x)?1:0)
380 354
381#define XFS_BUF_DONE(x) ((x)->pb_flags &= ~(PBF_PARTIAL|PBF_NONE)) 355#define XFS_BUF_DONE(x) ((x)->pb_flags |= PBF_DONE)
382#define XFS_BUF_UNDONE(x) ((x)->pb_flags |= PBF_PARTIAL|PBF_NONE) 356#define XFS_BUF_UNDONE(x) ((x)->pb_flags &= ~PBF_DONE)
383#define XFS_BUF_ISDONE(x) (!(PBF_NOT_DONE(x))) 357#define XFS_BUF_ISDONE(x) ((x)->pb_flags & PBF_DONE)
384 358
385#define XFS_BUF_BUSY(x) ((x)->pb_flags |= PBF_FORCEIO) 359#define XFS_BUF_BUSY(x) do { } while (0)
386#define XFS_BUF_UNBUSY(x) ((x)->pb_flags &= ~PBF_FORCEIO) 360#define XFS_BUF_UNBUSY(x) do { } while (0)
387#define XFS_BUF_ISBUSY(x) (1) 361#define XFS_BUF_ISBUSY(x) (1)
388 362
389#define XFS_BUF_ASYNC(x) ((x)->pb_flags |= PBF_ASYNC) 363#define XFS_BUF_ASYNC(x) ((x)->pb_flags |= PBF_ASYNC)
390#define XFS_BUF_UNASYNC(x) ((x)->pb_flags &= ~PBF_ASYNC) 364#define XFS_BUF_UNASYNC(x) ((x)->pb_flags &= ~PBF_ASYNC)
391#define XFS_BUF_ISASYNC(x) ((x)->pb_flags & PBF_ASYNC) 365#define XFS_BUF_ISASYNC(x) ((x)->pb_flags & PBF_ASYNC)
392 366
393#define XFS_BUF_FLUSH(x) ((x)->pb_flags |= PBF_FLUSH) 367#define XFS_BUF_ORDERED(x) ((x)->pb_flags |= PBF_ORDERED)
394#define XFS_BUF_UNFLUSH(x) ((x)->pb_flags &= ~PBF_FLUSH) 368#define XFS_BUF_UNORDERED(x) ((x)->pb_flags &= ~PBF_ORDERED)
395#define XFS_BUF_ISFLUSH(x) ((x)->pb_flags & PBF_FLUSH) 369#define XFS_BUF_ISORDERED(x) ((x)->pb_flags & PBF_ORDERED)
396 370
397#define XFS_BUF_SHUT(x) printk("XFS_BUF_SHUT not implemented yet\n") 371#define XFS_BUF_SHUT(x) printk("XFS_BUF_SHUT not implemented yet\n")
398#define XFS_BUF_UNSHUT(x) printk("XFS_BUF_UNSHUT not implemented yet\n") 372#define XFS_BUF_UNSHUT(x) printk("XFS_BUF_UNSHUT not implemented yet\n")
@@ -412,9 +386,6 @@ extern void pagebuf_trace(
412 386
413#define XFS_BUF_BP_ISMAPPED(bp) 1 387#define XFS_BUF_BP_ISMAPPED(bp) 1
414 388
415#define XFS_BUF_DATAIO(x) ((x)->pb_flags |= PBF_FS_DATAIOD)
416#define XFS_BUF_UNDATAIO(x) ((x)->pb_flags &= ~PBF_FS_DATAIOD)
417
418#define XFS_BUF_IODONE_FUNC(buf) (buf)->pb_iodone 389#define XFS_BUF_IODONE_FUNC(buf) (buf)->pb_iodone
419#define XFS_BUF_SET_IODONE_FUNC(buf, func) \ 390#define XFS_BUF_SET_IODONE_FUNC(buf, func) \
420 (buf)->pb_iodone = (func) 391 (buf)->pb_iodone = (func)
@@ -510,7 +481,7 @@ static inline void xfs_buf_relse(xfs_buf_t *bp)
510 pagebuf_trace(bp, id, NULL, (void *)__builtin_return_address(0)) 481 pagebuf_trace(bp, id, NULL, (void *)__builtin_return_address(0))
511 482
512#define xfs_biodone(pb) \ 483#define xfs_biodone(pb) \
513 pagebuf_iodone(pb, (pb->pb_flags & PBF_FS_DATAIOD), 0) 484 pagebuf_iodone(pb, 0)
514 485
515#define xfs_biomove(pb, off, len, data, rw) \ 486#define xfs_biomove(pb, off, len, data, rw) \
516 pagebuf_iomove((pb), (off), (len), (data), \ 487 pagebuf_iomove((pb), (off), (len), (data), \
diff --git a/fs/xfs/linux-2.6/xfs_cred.h b/fs/xfs/linux-2.6/xfs_cred.h
index 00c45849d41a..4af491024727 100644
--- a/fs/xfs/linux-2.6/xfs_cred.h
+++ b/fs/xfs/linux-2.6/xfs_cred.h
@@ -1,33 +1,19 @@
1/* 1/*
2 * Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32#ifndef __XFS_CRED_H__ 18#ifndef __XFS_CRED_H__
33#define __XFS_CRED_H__ 19#define __XFS_CRED_H__
diff --git a/fs/xfs/linux-2.6/xfs_export.c b/fs/xfs/linux-2.6/xfs_export.c
index f372a1a5e168..80eb249f2fa0 100644
--- a/fs/xfs/linux-2.6/xfs_export.c
+++ b/fs/xfs/linux-2.6/xfs_export.c
@@ -1,35 +1,20 @@
1/* 1/*
2 * Copyright (c) 2004-2005 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2004-2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32
33#include "xfs.h" 18#include "xfs.h"
34#include "xfs_types.h" 19#include "xfs_types.h"
35#include "xfs_dmapi.h" 20#include "xfs_dmapi.h"
@@ -41,7 +26,7 @@
41#include "xfs_export.h" 26#include "xfs_export.h"
42 27
43/* 28/*
44 * XFS encode and decodes the fileid portion of NFS filehandles 29 * XFS encodes and decodes the fileid portion of NFS filehandles
45 * itself instead of letting the generic NFS code do it. This 30 * itself instead of letting the generic NFS code do it. This
46 * allows filesystems with 64 bit inode numbers to be exported. 31 * allows filesystems with 64 bit inode numbers to be exported.
47 * 32 *
@@ -51,7 +36,6 @@
51 * remains in that code. 36 * remains in that code.
52 */ 37 */
53 38
54
55STATIC struct dentry * 39STATIC struct dentry *
56linvfs_decode_fh( 40linvfs_decode_fh(
57 struct super_block *sb, 41 struct super_block *sb,
@@ -92,7 +76,7 @@ linvfs_decode_fh(
92 p = xfs_fileid_decode_fid2(p, &pfid, is64); 76 p = xfs_fileid_decode_fid2(p, &pfid, is64);
93 parent = &pfid; 77 parent = &pfid;
94 } 78 }
95 79
96 fh = (__u32 *)&ifid; 80 fh = (__u32 *)&ifid;
97 return find_exported_dentry(sb, fh, parent, acceptable, context); 81 return find_exported_dentry(sb, fh, parent, acceptable, context);
98} 82}
@@ -112,9 +96,8 @@ linvfs_encode_fh(
112 int is64 = 0; 96 int is64 = 0;
113#if XFS_BIG_INUMS 97#if XFS_BIG_INUMS
114 vfs_t *vfs = LINVFS_GET_VFS(inode->i_sb); 98 vfs_t *vfs = LINVFS_GET_VFS(inode->i_sb);
115 xfs_mount_t *mp = XFS_VFSTOM(vfs); 99
116 100 if (!(vfs->vfs_flag & VFS_32BITINODES)) {
117 if (!(mp->m_flags & XFS_MOUNT_32BITINOOPT)) {
118 /* filesystem may contain 64bit inode numbers */ 101 /* filesystem may contain 64bit inode numbers */
119 is64 = XFS_FILEID_TYPE_64FLAG; 102 is64 = XFS_FILEID_TYPE_64FLAG;
120 } 103 }
diff --git a/fs/xfs/linux-2.6/xfs_export.h b/fs/xfs/linux-2.6/xfs_export.h
index 60b2abac1c18..e5b0559700a4 100644
--- a/fs/xfs/linux-2.6/xfs_export.h
+++ b/fs/xfs/linux-2.6/xfs_export.h
@@ -1,33 +1,19 @@
1/* 1/*
2 * Copyright (c) 2005 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32#ifndef __XFS_EXPORT_H__ 18#ifndef __XFS_EXPORT_H__
33#define __XFS_EXPORT_H__ 19#define __XFS_EXPORT_H__
diff --git a/fs/xfs/linux-2.6/xfs_file.c b/fs/xfs/linux-2.6/xfs_file.c
index 3881622bcf08..06111d0bbae4 100644
--- a/fs/xfs/linux-2.6/xfs_file.c
+++ b/fs/xfs/linux-2.6/xfs_file.c
@@ -1,39 +1,26 @@
1/* 1/*
2 * Copyright (c) 2000-2005 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32
33#include "xfs.h" 18#include "xfs.h"
34#include "xfs_inum.h" 19#include "xfs_bit.h"
35#include "xfs_log.h" 20#include "xfs_log.h"
21#include "xfs_inum.h"
36#include "xfs_sb.h" 22#include "xfs_sb.h"
23#include "xfs_ag.h"
37#include "xfs_dir.h" 24#include "xfs_dir.h"
38#include "xfs_dir2.h" 25#include "xfs_dir2.h"
39#include "xfs_trans.h" 26#include "xfs_trans.h"
diff --git a/fs/xfs/linux-2.6/xfs_fs_subr.c b/fs/xfs/linux-2.6/xfs_fs_subr.c
index 05ebd30ec96f..f89340c61bf2 100644
--- a/fs/xfs/linux-2.6/xfs_fs_subr.c
+++ b/fs/xfs/linux-2.6/xfs_fs_subr.c
@@ -1,33 +1,19 @@
1/* 1/*
2 * Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32 18
33#include "xfs.h" 19#include "xfs.h"
@@ -117,6 +103,8 @@ fs_flush_pages(
117 103
118 if (VN_CACHED(vp)) { 104 if (VN_CACHED(vp)) {
119 filemap_fdatawrite(ip->i_mapping); 105 filemap_fdatawrite(ip->i_mapping);
106 if (flags & XFS_B_ASYNC)
107 return 0;
120 filemap_fdatawait(ip->i_mapping); 108 filemap_fdatawait(ip->i_mapping);
121 } 109 }
122 110
diff --git a/fs/xfs/linux-2.6/xfs_fs_subr.h b/fs/xfs/linux-2.6/xfs_fs_subr.h
index 2db9ddbd4567..aee9ccdd18f7 100644
--- a/fs/xfs/linux-2.6/xfs_fs_subr.h
+++ b/fs/xfs/linux-2.6/xfs_fs_subr.h
@@ -1,48 +1,29 @@
1/* 1/*
2 * Copyright (c) 2000, 2002 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000,2002,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */
32#ifndef __XFS_SUBR_H__
33#define __XFS_SUBR_H__
34
35/*
36 * Utilities shared among file system implementations.
37 */ 17 */
18#ifndef __XFS_FS_SUBR_H__
19#define __XFS_FS_SUBR_H__
38 20
39struct cred; 21struct cred;
40 22extern int fs_noerr(void);
41extern int fs_noerr(void); 23extern int fs_nosys(void);
42extern int fs_nosys(void); 24extern void fs_noval(void);
43extern void fs_noval(void); 25extern void fs_tosspages(bhv_desc_t *, xfs_off_t, xfs_off_t, int);
44extern void fs_tosspages(bhv_desc_t *, xfs_off_t, xfs_off_t, int); 26extern void fs_flushinval_pages(bhv_desc_t *, xfs_off_t, xfs_off_t, int);
45extern void fs_flushinval_pages(bhv_desc_t *, xfs_off_t, xfs_off_t, int); 27extern int fs_flush_pages(bhv_desc_t *, xfs_off_t, xfs_off_t, uint64_t, int);
46extern int fs_flush_pages(bhv_desc_t *, xfs_off_t, xfs_off_t, uint64_t, int);
47 28
48#endif /* __XFS_FS_SUBR_H__ */ 29#endif /* __XFS_FS_SUBR_H__ */
diff --git a/fs/xfs/linux-2.6/xfs_globals.c b/fs/xfs/linux-2.6/xfs_globals.c
index a6da5b4fd240..6e8085f34635 100644
--- a/fs/xfs/linux-2.6/xfs_globals.c
+++ b/fs/xfs/linux-2.6/xfs_globals.c
@@ -1,40 +1,20 @@
1/* 1/*
2 * Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32
33/*
34 * This file contains globals needed by XFS that were normally defined
35 * somewhere else in IRIX.
36 */
37
38#include "xfs.h" 18#include "xfs.h"
39#include "xfs_cred.h" 19#include "xfs_cred.h"
40#include "xfs_sysctl.h" 20#include "xfs_sysctl.h"
diff --git a/fs/xfs/linux-2.6/xfs_globals.h b/fs/xfs/linux-2.6/xfs_globals.h
index e81e2f38a853..e1a22bfcf865 100644
--- a/fs/xfs/linux-2.6/xfs_globals.h
+++ b/fs/xfs/linux-2.6/xfs_globals.h
@@ -1,42 +1,23 @@
1/* 1/*
2 * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32#ifndef __XFS_GLOBALS_H__ 18#ifndef __XFS_GLOBALS_H__
33#define __XFS_GLOBALS_H__ 19#define __XFS_GLOBALS_H__
34 20
35/*
36 * This file declares globals needed by XFS that were normally defined
37 * somewhere else in IRIX.
38 */
39
40extern uint64_t xfs_panic_mask; /* set to cause more panics */ 21extern uint64_t xfs_panic_mask; /* set to cause more panics */
41extern unsigned long xfs_physmem; 22extern unsigned long xfs_physmem;
42extern struct cred *sys_cred; 23extern struct cred *sys_cred;
diff --git a/fs/xfs/linux-2.6/xfs_ioctl.c b/fs/xfs/linux-2.6/xfs_ioctl.c
index 6a3326bcd8d0..b78b5eb9e96c 100644
--- a/fs/xfs/linux-2.6/xfs_ioctl.c
+++ b/fs/xfs/linux-2.6/xfs_ioctl.c
@@ -1,67 +1,52 @@
1/* 1/*
2 * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32
33#include "xfs.h" 18#include "xfs.h"
34
35#include "xfs_fs.h" 19#include "xfs_fs.h"
36#include "xfs_inum.h" 20#include "xfs_bit.h"
37#include "xfs_log.h" 21#include "xfs_log.h"
22#include "xfs_inum.h"
38#include "xfs_trans.h" 23#include "xfs_trans.h"
39#include "xfs_sb.h" 24#include "xfs_sb.h"
25#include "xfs_ag.h"
40#include "xfs_dir.h" 26#include "xfs_dir.h"
41#include "xfs_dir2.h" 27#include "xfs_dir2.h"
42#include "xfs_alloc.h" 28#include "xfs_alloc.h"
43#include "xfs_dmapi.h" 29#include "xfs_dmapi.h"
44#include "xfs_mount.h" 30#include "xfs_mount.h"
45#include "xfs_alloc_btree.h"
46#include "xfs_bmap_btree.h" 31#include "xfs_bmap_btree.h"
32#include "xfs_alloc_btree.h"
47#include "xfs_ialloc_btree.h" 33#include "xfs_ialloc_btree.h"
48#include "xfs_btree.h"
49#include "xfs_ialloc.h"
50#include "xfs_attr_sf.h"
51#include "xfs_dir_sf.h" 34#include "xfs_dir_sf.h"
35#include "xfs_attr_sf.h"
52#include "xfs_dir2_sf.h" 36#include "xfs_dir2_sf.h"
53#include "xfs_dinode.h" 37#include "xfs_dinode.h"
54#include "xfs_inode.h" 38#include "xfs_inode.h"
55#include "xfs_bmap.h" 39#include "xfs_btree.h"
56#include "xfs_bit.h" 40#include "xfs_ialloc.h"
57#include "xfs_rtalloc.h" 41#include "xfs_rtalloc.h"
58#include "xfs_error.h"
59#include "xfs_itable.h" 42#include "xfs_itable.h"
43#include "xfs_error.h"
60#include "xfs_rw.h" 44#include "xfs_rw.h"
61#include "xfs_acl.h" 45#include "xfs_acl.h"
62#include "xfs_cap.h" 46#include "xfs_cap.h"
63#include "xfs_mac.h" 47#include "xfs_mac.h"
64#include "xfs_attr.h" 48#include "xfs_attr.h"
49#include "xfs_bmap.h"
65#include "xfs_buf_item.h" 50#include "xfs_buf_item.h"
66#include "xfs_utils.h" 51#include "xfs_utils.h"
67#include "xfs_dfrag.h" 52#include "xfs_dfrag.h"
diff --git a/fs/xfs/linux-2.6/xfs_ioctl32.c b/fs/xfs/linux-2.6/xfs_ioctl32.c
index 4636b7f86f1f..c83ae15bb0e6 100644
--- a/fs/xfs/linux-2.6/xfs_ioctl32.c
+++ b/fs/xfs/linux-2.6/xfs_ioctl32.c
@@ -1,35 +1,20 @@
1/* 1/*
2 * Copyright (c) 2004-2005 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2004-2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32
33#include <linux/config.h> 18#include <linux/config.h>
34#include <linux/compat.h> 19#include <linux/compat.h>
35#include <linux/init.h> 20#include <linux/init.h>
@@ -39,7 +24,6 @@
39#include <linux/types.h> 24#include <linux/types.h>
40#include <linux/fs.h> 25#include <linux/fs.h>
41#include <asm/uaccess.h> 26#include <asm/uaccess.h>
42
43#include "xfs.h" 27#include "xfs.h"
44#include "xfs_types.h" 28#include "xfs_types.h"
45#include "xfs_fs.h" 29#include "xfs_fs.h"
diff --git a/fs/xfs/linux-2.6/xfs_ioctl32.h b/fs/xfs/linux-2.6/xfs_ioctl32.h
index c874793a1dc9..011c273bec50 100644
--- a/fs/xfs/linux-2.6/xfs_ioctl32.h
+++ b/fs/xfs/linux-2.6/xfs_ioctl32.h
@@ -1,34 +1,24 @@
1/* 1/*
2 * Copyright (c) 2004-2005 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2004-2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
18#ifndef __XFS_IOCTL32_H__
19#define __XFS_IOCTL32_H__
20
21extern long linvfs_compat_ioctl(struct file *, unsigned, unsigned long);
22extern long linvfs_compat_invis_ioctl(struct file *f, unsigned, unsigned long);
32 23
33long linvfs_compat_ioctl(struct file *f, unsigned cmd, unsigned long arg); 24#endif /* __XFS_IOCTL32_H__ */
34long linvfs_compat_invis_ioctl(struct file *f, unsigned cmd, unsigned long arg);
diff --git a/fs/xfs/linux-2.6/xfs_iops.c b/fs/xfs/linux-2.6/xfs_iops.c
index 77708a8c9f87..14215a7db59f 100644
--- a/fs/xfs/linux-2.6/xfs_iops.c
+++ b/fs/xfs/linux-2.6/xfs_iops.c
@@ -1,39 +1,25 @@
1/* 1/*
2 * Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32
33#include "xfs.h" 18#include "xfs.h"
34#include "xfs_fs.h" 19#include "xfs_fs.h"
35#include "xfs_inum.h" 20#include "xfs_bit.h"
36#include "xfs_log.h" 21#include "xfs_log.h"
22#include "xfs_inum.h"
37#include "xfs_trans.h" 23#include "xfs_trans.h"
38#include "xfs_sb.h" 24#include "xfs_sb.h"
39#include "xfs_ag.h" 25#include "xfs_ag.h"
@@ -43,18 +29,17 @@
43#include "xfs_dmapi.h" 29#include "xfs_dmapi.h"
44#include "xfs_quota.h" 30#include "xfs_quota.h"
45#include "xfs_mount.h" 31#include "xfs_mount.h"
46#include "xfs_alloc_btree.h"
47#include "xfs_bmap_btree.h" 32#include "xfs_bmap_btree.h"
33#include "xfs_alloc_btree.h"
48#include "xfs_ialloc_btree.h" 34#include "xfs_ialloc_btree.h"
49#include "xfs_btree.h"
50#include "xfs_ialloc.h"
51#include "xfs_attr_sf.h"
52#include "xfs_dir_sf.h" 35#include "xfs_dir_sf.h"
53#include "xfs_dir2_sf.h" 36#include "xfs_dir2_sf.h"
37#include "xfs_attr_sf.h"
54#include "xfs_dinode.h" 38#include "xfs_dinode.h"
55#include "xfs_inode.h" 39#include "xfs_inode.h"
56#include "xfs_bmap.h" 40#include "xfs_bmap.h"
57#include "xfs_bit.h" 41#include "xfs_btree.h"
42#include "xfs_ialloc.h"
58#include "xfs_rtalloc.h" 43#include "xfs_rtalloc.h"
59#include "xfs_error.h" 44#include "xfs_error.h"
60#include "xfs_itable.h" 45#include "xfs_itable.h"
@@ -69,6 +54,137 @@
69#include <linux/xattr.h> 54#include <linux/xattr.h>
70#include <linux/namei.h> 55#include <linux/namei.h>
71 56
57/*
58 * Change the requested timestamp in the given inode.
59 * We don't lock across timestamp updates, and we don't log them but
60 * we do record the fact that there is dirty information in core.
61 *
62 * NOTE -- callers MUST combine XFS_ICHGTIME_MOD or XFS_ICHGTIME_CHG
63 * with XFS_ICHGTIME_ACC to be sure that access time
64 * update will take. Calling first with XFS_ICHGTIME_ACC
65 * and then XFS_ICHGTIME_MOD may fail to modify the access
66 * timestamp if the filesystem is mounted noacctm.
67 */
68void
69xfs_ichgtime(
70 xfs_inode_t *ip,
71 int flags)
72{
73 struct inode *inode = LINVFS_GET_IP(XFS_ITOV(ip));
74 timespec_t tv;
75
76 /*
77 * We're not supposed to change timestamps in readonly-mounted
78 * filesystems. Throw it away if anyone asks us.
79 */
80 if (unlikely(IS_RDONLY(inode)))
81 return;
82
83 /*
84 * Don't update access timestamps on reads if mounted "noatime".
85 * Throw it away if anyone asks us.
86 */
87 if (unlikely(
88 (ip->i_mount->m_flags & XFS_MOUNT_NOATIME || IS_NOATIME(inode)) &&
89 (flags & (XFS_ICHGTIME_ACC|XFS_ICHGTIME_MOD|XFS_ICHGTIME_CHG)) ==
90 XFS_ICHGTIME_ACC))
91 return;
92
93 nanotime(&tv);
94 if (flags & XFS_ICHGTIME_MOD) {
95 inode->i_mtime = tv;
96 ip->i_d.di_mtime.t_sec = (__int32_t)tv.tv_sec;
97 ip->i_d.di_mtime.t_nsec = (__int32_t)tv.tv_nsec;
98 }
99 if (flags & XFS_ICHGTIME_ACC) {
100 inode->i_atime = tv;
101 ip->i_d.di_atime.t_sec = (__int32_t)tv.tv_sec;
102 ip->i_d.di_atime.t_nsec = (__int32_t)tv.tv_nsec;
103 }
104 if (flags & XFS_ICHGTIME_CHG) {
105 inode->i_ctime = tv;
106 ip->i_d.di_ctime.t_sec = (__int32_t)tv.tv_sec;
107 ip->i_d.di_ctime.t_nsec = (__int32_t)tv.tv_nsec;
108 }
109
110 /*
111 * We update the i_update_core field _after_ changing
112 * the timestamps in order to coordinate properly with
113 * xfs_iflush() so that we don't lose timestamp updates.
114 * This keeps us from having to hold the inode lock
115 * while doing this. We use the SYNCHRONIZE macro to
116 * ensure that the compiler does not reorder the update
117 * of i_update_core above the timestamp updates above.
118 */
119 SYNCHRONIZE();
120 ip->i_update_core = 1;
121 if (!(inode->i_state & I_LOCK))
122 mark_inode_dirty_sync(inode);
123}
124
125/*
126 * Variant on the above which avoids querying the system clock
127 * in situations where we know the Linux inode timestamps have
128 * just been updated (and so we can update our inode cheaply).
129 * We also skip the readonly and noatime checks here, they are
130 * also catered for already.
131 */
132void
133xfs_ichgtime_fast(
134 xfs_inode_t *ip,
135 struct inode *inode,
136 int flags)
137{
138 timespec_t *tvp;
139
140 /*
141 * We're not supposed to change timestamps in readonly-mounted
142 * filesystems. Throw it away if anyone asks us.
143 */
144 if (unlikely(IS_RDONLY(inode)))
145 return;
146
147 /*
148 * Don't update access timestamps on reads if mounted "noatime".
149 * Throw it away if anyone asks us.
150 */
151 if (unlikely(
152 (ip->i_mount->m_flags & XFS_MOUNT_NOATIME || IS_NOATIME(inode)) &&
153 ((flags & (XFS_ICHGTIME_ACC|XFS_ICHGTIME_MOD|XFS_ICHGTIME_CHG)) ==
154 XFS_ICHGTIME_ACC)))
155 return;
156
157 if (flags & XFS_ICHGTIME_MOD) {
158 tvp = &inode->i_mtime;
159 ip->i_d.di_mtime.t_sec = (__int32_t)tvp->tv_sec;
160 ip->i_d.di_mtime.t_nsec = (__int32_t)tvp->tv_nsec;
161 }
162 if (flags & XFS_ICHGTIME_ACC) {
163 tvp = &inode->i_atime;
164 ip->i_d.di_atime.t_sec = (__int32_t)tvp->tv_sec;
165 ip->i_d.di_atime.t_nsec = (__int32_t)tvp->tv_nsec;
166 }
167 if (flags & XFS_ICHGTIME_CHG) {
168 tvp = &inode->i_ctime;
169 ip->i_d.di_ctime.t_sec = (__int32_t)tvp->tv_sec;
170 ip->i_d.di_ctime.t_nsec = (__int32_t)tvp->tv_nsec;
171 }
172
173 /*
174 * We update the i_update_core field _after_ changing
175 * the timestamps in order to coordinate properly with
176 * xfs_iflush() so that we don't lose timestamp updates.
177 * This keeps us from having to hold the inode lock
178 * while doing this. We use the SYNCHRONIZE macro to
179 * ensure that the compiler does not reorder the update
180 * of i_update_core above the timestamp updates above.
181 */
182 SYNCHRONIZE();
183 ip->i_update_core = 1;
184 if (!(inode->i_state & I_LOCK))
185 mark_inode_dirty_sync(inode);
186}
187
72 188
73/* 189/*
74 * Pull the link count and size up from the xfs inode to the linux inode 190 * Pull the link count and size up from the xfs inode to the linux inode
diff --git a/fs/xfs/linux-2.6/xfs_iops.h b/fs/xfs/linux-2.6/xfs_iops.h
index 6a69a62c36b0..ee784b63acbf 100644
--- a/fs/xfs/linux-2.6/xfs_iops.h
+++ b/fs/xfs/linux-2.6/xfs_iops.h
@@ -1,33 +1,19 @@
1/* 1/*
2 * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32#ifndef __XFS_IOPS_H__ 18#ifndef __XFS_IOPS_H__
33#define __XFS_IOPS_H__ 19#define __XFS_IOPS_H__
@@ -48,4 +34,8 @@ extern void linvfs_unwritten_done(struct buffer_head *, int);
48extern int xfs_ioctl(struct bhv_desc *, struct inode *, struct file *, 34extern int xfs_ioctl(struct bhv_desc *, struct inode *, struct file *,
49 int, unsigned int, void __user *); 35 int, unsigned int, void __user *);
50 36
37struct xfs_inode;
38extern void xfs_ichgtime(struct xfs_inode *, int);
39extern void xfs_ichgtime_fast(struct xfs_inode *, struct inode *, int);
40
51#endif /* __XFS_IOPS_H__ */ 41#endif /* __XFS_IOPS_H__ */
diff --git a/fs/xfs/linux-2.6/xfs_linux.h b/fs/xfs/linux-2.6/xfs_linux.h
index 68c5d885ed9c..44fed10af0dd 100644
--- a/fs/xfs/linux-2.6/xfs_linux.h
+++ b/fs/xfs/linux-2.6/xfs_linux.h
@@ -1,33 +1,19 @@
1/* 1/*
2 * Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32#ifndef __XFS_LINUX__ 18#ifndef __XFS_LINUX__
33#define __XFS_LINUX__ 19#define __XFS_LINUX__
@@ -197,10 +183,6 @@ static inline void set_buffer_unwritten_io(struct buffer_head *bh)
197/* bytes to clicks */ 183/* bytes to clicks */
198#define btoc(x) (((__psunsigned_t)(x)+(NBPC-1))>>BPCSHIFT) 184#define btoc(x) (((__psunsigned_t)(x)+(NBPC-1))>>BPCSHIFT)
199 185
200#ifndef CELL_CAPABLE
201#define FSC_NOTIFY_NAME_CHANGED(vp)
202#endif
203
204#ifndef ENOATTR 186#ifndef ENOATTR
205#define ENOATTR ENODATA /* Attribute not found */ 187#define ENOATTR ENODATA /* Attribute not found */
206#endif 188#endif
@@ -235,30 +217,18 @@ static inline void set_buffer_unwritten_io(struct buffer_head *bh)
235#define Q_XSETPQLIM XQM_CMD(10) /* set projects disk limits */ 217#define Q_XSETPQLIM XQM_CMD(10) /* set projects disk limits */
236#define Q_XGETPQUOTA XQM_CMD(11) /* get projects disk limits */ 218#define Q_XGETPQUOTA XQM_CMD(11) /* get projects disk limits */
237 219
238/* IRIX uses a dynamic sizing algorithm (ndquot = 200 + numprocs*2) */ 220#define dfltprid 0
239/* we may well need to fine-tune this if it ever becomes an issue. */
240#define DQUOT_MAX_HEURISTIC 1024 /* NR_DQUOTS */
241#define ndquot DQUOT_MAX_HEURISTIC
242
243/* IRIX uses the current size of the name cache to guess a good value */
244/* - this isn't the same but is a good enough starting point for now. */
245#define DQUOT_HASH_HEURISTIC files_stat.nr_files
246
247/* IRIX inodes maintain the project ID also, zero this field on Linux */
248#define DEFAULT_PROJID 0
249#define dfltprid DEFAULT_PROJID
250
251#define MAXPATHLEN 1024 221#define MAXPATHLEN 1024
252 222
253#define MIN(a,b) (min(a,b)) 223#define MIN(a,b) (min(a,b))
254#define MAX(a,b) (max(a,b)) 224#define MAX(a,b) (max(a,b))
255#define howmany(x, y) (((x)+((y)-1))/(y)) 225#define howmany(x, y) (((x)+((y)-1))/(y))
256#define roundup(x, y) ((((x)+((y)-1))/(y))*(y)) 226#define roundup(x, y) ((((x)+((y)-1))/(y))*(y))
257#define qsort(a,n,s,fn) sort(a,n,s,fn,NULL)
258 227
259/* 228/*
260 * Various platform dependent calls that don't fit anywhere else 229 * Various platform dependent calls that don't fit anywhere else
261 */ 230 */
231#define xfs_sort(a,n,s,fn) sort(a,n,s,fn,NULL)
262#define xfs_stack_trace() dump_stack() 232#define xfs_stack_trace() dump_stack()
263#define xfs_itruncate_data(ip, off) \ 233#define xfs_itruncate_data(ip, off) \
264 (-vmtruncate(LINVFS_GET_IP(XFS_ITOV(ip)), (off))) 234 (-vmtruncate(LINVFS_GET_IP(XFS_ITOV(ip)), (off)))
diff --git a/fs/xfs/linux-2.6/xfs_lrw.c b/fs/xfs/linux-2.6/xfs_lrw.c
index 3b5fabe8dae9..279e9bc92aba 100644
--- a/fs/xfs/linux-2.6/xfs_lrw.c
+++ b/fs/xfs/linux-2.6/xfs_lrw.c
@@ -1,44 +1,25 @@
1/* 1/*
2 * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32/*
33 * fs/xfs/linux/xfs_lrw.c (Linux Read Write stuff)
34 *
35 */
36
37#include "xfs.h" 18#include "xfs.h"
38
39#include "xfs_fs.h" 19#include "xfs_fs.h"
40#include "xfs_inum.h" 20#include "xfs_bit.h"
41#include "xfs_log.h" 21#include "xfs_log.h"
22#include "xfs_inum.h"
42#include "xfs_trans.h" 23#include "xfs_trans.h"
43#include "xfs_sb.h" 24#include "xfs_sb.h"
44#include "xfs_ag.h" 25#include "xfs_ag.h"
@@ -48,18 +29,17 @@
48#include "xfs_dmapi.h" 29#include "xfs_dmapi.h"
49#include "xfs_quota.h" 30#include "xfs_quota.h"
50#include "xfs_mount.h" 31#include "xfs_mount.h"
51#include "xfs_alloc_btree.h"
52#include "xfs_bmap_btree.h" 32#include "xfs_bmap_btree.h"
33#include "xfs_alloc_btree.h"
53#include "xfs_ialloc_btree.h" 34#include "xfs_ialloc_btree.h"
54#include "xfs_btree.h"
55#include "xfs_ialloc.h"
56#include "xfs_attr_sf.h"
57#include "xfs_dir_sf.h" 35#include "xfs_dir_sf.h"
58#include "xfs_dir2_sf.h" 36#include "xfs_dir2_sf.h"
37#include "xfs_attr_sf.h"
59#include "xfs_dinode.h" 38#include "xfs_dinode.h"
60#include "xfs_inode.h" 39#include "xfs_inode.h"
61#include "xfs_bmap.h" 40#include "xfs_bmap.h"
62#include "xfs_bit.h" 41#include "xfs_btree.h"
42#include "xfs_ialloc.h"
63#include "xfs_rtalloc.h" 43#include "xfs_rtalloc.h"
64#include "xfs_error.h" 44#include "xfs_error.h"
65#include "xfs_itable.h" 45#include "xfs_itable.h"
@@ -302,7 +282,7 @@ xfs_read(
302 xfs_iunlock(ip, XFS_IOLOCK_SHARED); 282 xfs_iunlock(ip, XFS_IOLOCK_SHARED);
303 283
304 if (likely(!(ioflags & IO_INVIS))) 284 if (likely(!(ioflags & IO_INVIS)))
305 xfs_ichgtime(ip, XFS_ICHGTIME_ACC); 285 xfs_ichgtime_fast(ip, inode, XFS_ICHGTIME_ACC);
306 286
307unlock_isem: 287unlock_isem:
308 if (unlikely(ioflags & IO_ISDIRECT)) 288 if (unlikely(ioflags & IO_ISDIRECT))
@@ -367,7 +347,7 @@ xfs_sendfile(
367 XFS_STATS_ADD(xs_read_bytes, ret); 347 XFS_STATS_ADD(xs_read_bytes, ret);
368 348
369 if (likely(!(ioflags & IO_INVIS))) 349 if (likely(!(ioflags & IO_INVIS)))
370 xfs_ichgtime(ip, XFS_ICHGTIME_ACC); 350 xfs_ichgtime_fast(ip, LINVFS_GET_IP(vp), XFS_ICHGTIME_ACC);
371 351
372 return ret; 352 return ret;
373} 353}
@@ -732,15 +712,10 @@ start:
732 } 712 }
733 } 713 }
734 714
735 /* 715 if (likely(!(ioflags & IO_INVIS))) {
736 * On Linux, generic_file_write updates the times even if
737 * no data is copied in so long as the write had a size.
738 *
739 * We must update xfs' times since revalidate will overcopy xfs.
740 */
741 if (!(ioflags & IO_INVIS)) {
742 xfs_ichgtime(xip, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG);
743 inode_update_time(inode, 1); 716 inode_update_time(inode, 1);
717 xfs_ichgtime_fast(xip, inode,
718 XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG);
744 } 719 }
745 720
746 /* 721 /*
diff --git a/fs/xfs/linux-2.6/xfs_lrw.h b/fs/xfs/linux-2.6/xfs_lrw.h
index 6294dcdb797c..38864a88d42d 100644
--- a/fs/xfs/linux-2.6/xfs_lrw.h
+++ b/fs/xfs/linux-2.6/xfs_lrw.h
@@ -1,33 +1,19 @@
1/* 1/*
2 * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32#ifndef __XFS_LRW_H__ 18#ifndef __XFS_LRW_H__
33#define __XFS_LRW_H__ 19#define __XFS_LRW_H__
@@ -107,9 +93,4 @@ extern ssize_t xfs_sendfile(struct bhv_desc *, struct file *,
107 93
108extern int xfs_dev_is_read_only(struct xfs_mount *, char *); 94extern int xfs_dev_is_read_only(struct xfs_mount *, char *);
109 95
110#define XFS_FSB_TO_DB_IO(io,fsb) \
111 (((io)->io_flags & XFS_IOCORE_RT) ? \
112 XFS_FSB_TO_BB((io)->io_mount, (fsb)) : \
113 XFS_FSB_TO_DADDR((io)->io_mount, (fsb)))
114
115#endif /* __XFS_LRW_H__ */ 96#endif /* __XFS_LRW_H__ */
diff --git a/fs/xfs/linux-2.6/xfs_stats.c b/fs/xfs/linux-2.6/xfs_stats.c
index aaf5ddba47f3..6c40a74be7c8 100644
--- a/fs/xfs/linux-2.6/xfs_stats.c
+++ b/fs/xfs/linux-2.6/xfs_stats.c
@@ -1,35 +1,20 @@
1/* 1/*
2 * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32
33#include "xfs.h" 18#include "xfs.h"
34#include <linux/proc_fs.h> 19#include <linux/proc_fs.h>
35 20
diff --git a/fs/xfs/linux-2.6/xfs_stats.h b/fs/xfs/linux-2.6/xfs_stats.h
index 3f756a6c3eb0..50027c4a5618 100644
--- a/fs/xfs/linux-2.6/xfs_stats.h
+++ b/fs/xfs/linux-2.6/xfs_stats.h
@@ -1,33 +1,19 @@
1/* 1/*
2 * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32#ifndef __XFS_STATS_H__ 18#ifndef __XFS_STATS_H__
33#define __XFS_STATS_H__ 19#define __XFS_STATS_H__
diff --git a/fs/xfs/linux-2.6/xfs_super.c b/fs/xfs/linux-2.6/xfs_super.c
index 2302454d8d47..6116b5bf433e 100644
--- a/fs/xfs/linux-2.6/xfs_super.c
+++ b/fs/xfs/linux-2.6/xfs_super.c
@@ -1,60 +1,45 @@
1/* 1/*
2 * Copyright (c) 2000-2005 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32
33#include "xfs.h" 18#include "xfs.h"
34 19#include "xfs_bit.h"
35#include "xfs_inum.h"
36#include "xfs_log.h" 20#include "xfs_log.h"
37#include "xfs_clnt.h" 21#include "xfs_clnt.h"
22#include "xfs_inum.h"
38#include "xfs_trans.h" 23#include "xfs_trans.h"
39#include "xfs_sb.h" 24#include "xfs_sb.h"
25#include "xfs_ag.h"
40#include "xfs_dir.h" 26#include "xfs_dir.h"
41#include "xfs_dir2.h" 27#include "xfs_dir2.h"
42#include "xfs_alloc.h" 28#include "xfs_alloc.h"
43#include "xfs_dmapi.h" 29#include "xfs_dmapi.h"
44#include "xfs_quota.h" 30#include "xfs_quota.h"
45#include "xfs_mount.h" 31#include "xfs_mount.h"
46#include "xfs_alloc_btree.h"
47#include "xfs_bmap_btree.h" 32#include "xfs_bmap_btree.h"
33#include "xfs_alloc_btree.h"
48#include "xfs_ialloc_btree.h" 34#include "xfs_ialloc_btree.h"
49#include "xfs_btree.h"
50#include "xfs_ialloc.h"
51#include "xfs_attr_sf.h"
52#include "xfs_dir_sf.h" 35#include "xfs_dir_sf.h"
53#include "xfs_dir2_sf.h" 36#include "xfs_dir2_sf.h"
37#include "xfs_attr_sf.h"
54#include "xfs_dinode.h" 38#include "xfs_dinode.h"
55#include "xfs_inode.h" 39#include "xfs_inode.h"
40#include "xfs_btree.h"
41#include "xfs_ialloc.h"
56#include "xfs_bmap.h" 42#include "xfs_bmap.h"
57#include "xfs_bit.h"
58#include "xfs_rtalloc.h" 43#include "xfs_rtalloc.h"
59#include "xfs_error.h" 44#include "xfs_error.h"
60#include "xfs_itable.h" 45#include "xfs_itable.h"
@@ -189,7 +174,7 @@ xfs_revalidate_inode(
189 break; 174 break;
190 } 175 }
191 176
192 inode->i_blksize = PAGE_CACHE_SIZE; 177 inode->i_blksize = xfs_preferred_iosize(mp);
193 inode->i_generation = ip->i_d.di_gen; 178 inode->i_generation = ip->i_d.di_gen;
194 i_size_write(inode, ip->i_d.di_size); 179 i_size_write(inode, ip->i_d.di_size);
195 inode->i_blocks = 180 inode->i_blocks =
@@ -278,6 +263,72 @@ xfs_blkdev_put(
278 close_bdev_excl(bdev); 263 close_bdev_excl(bdev);
279} 264}
280 265
266/*
267 * Try to write out the superblock using barriers.
268 */
269STATIC int
270xfs_barrier_test(
271 xfs_mount_t *mp)
272{
273 xfs_buf_t *sbp = xfs_getsb(mp, 0);
274 int error;
275
276 XFS_BUF_UNDONE(sbp);
277 XFS_BUF_UNREAD(sbp);
278 XFS_BUF_UNDELAYWRITE(sbp);
279 XFS_BUF_WRITE(sbp);
280 XFS_BUF_UNASYNC(sbp);
281 XFS_BUF_ORDERED(sbp);
282
283 xfsbdstrat(mp, sbp);
284 error = xfs_iowait(sbp);
285
286 /*
287 * Clear all the flags we set and possible error state in the
288 * buffer. We only did the write to try out whether barriers
289 * worked and shouldn't leave any traces in the superblock
290 * buffer.
291 */
292 XFS_BUF_DONE(sbp);
293 XFS_BUF_ERROR(sbp, 0);
294 XFS_BUF_UNORDERED(sbp);
295
296 xfs_buf_relse(sbp);
297 return error;
298}
299
300void
301xfs_mountfs_check_barriers(xfs_mount_t *mp)
302{
303 int error;
304
305 if (mp->m_logdev_targp != mp->m_ddev_targp) {
306 xfs_fs_cmn_err(CE_NOTE, mp,
307 "Disabling barriers, not supported with external log device");
308 mp->m_flags &= ~XFS_MOUNT_BARRIER;
309 }
310
311 if (mp->m_ddev_targp->pbr_bdev->bd_disk->queue->ordered ==
312 QUEUE_ORDERED_NONE) {
313 xfs_fs_cmn_err(CE_NOTE, mp,
314 "Disabling barriers, not supported by the underlying device");
315 mp->m_flags &= ~XFS_MOUNT_BARRIER;
316 }
317
318 error = xfs_barrier_test(mp);
319 if (error) {
320 xfs_fs_cmn_err(CE_NOTE, mp,
321 "Disabling barriers, trial barrier write failed");
322 mp->m_flags &= ~XFS_MOUNT_BARRIER;
323 }
324}
325
326void
327xfs_blkdev_issue_flush(
328 xfs_buftarg_t *buftarg)
329{
330 blkdev_issue_flush(buftarg->pbr_bdev, NULL);
331}
281 332
282STATIC struct inode * 333STATIC struct inode *
283linvfs_alloc_inode( 334linvfs_alloc_inode(
@@ -701,6 +752,18 @@ linvfs_show_options(
701} 752}
702 753
703STATIC int 754STATIC int
755linvfs_quotasync(
756 struct super_block *sb,
757 int type)
758{
759 struct vfs *vfsp = LINVFS_GET_VFS(sb);
760 int error;
761
762 VFS_QUOTACTL(vfsp, Q_XQUOTASYNC, 0, (caddr_t)NULL, error);
763 return -error;
764}
765
766STATIC int
704linvfs_getxstate( 767linvfs_getxstate(
705 struct super_block *sb, 768 struct super_block *sb,
706 struct fs_quota_stat *fqs) 769 struct fs_quota_stat *fqs)
@@ -868,6 +931,7 @@ STATIC struct super_operations linvfs_sops = {
868}; 931};
869 932
870STATIC struct quotactl_ops linvfs_qops = { 933STATIC struct quotactl_ops linvfs_qops = {
934 .quota_sync = linvfs_quotasync,
871 .get_xstate = linvfs_getxstate, 935 .get_xstate = linvfs_getxstate,
872 .set_xstate = linvfs_setxstate, 936 .set_xstate = linvfs_setxstate,
873 .get_xquota = linvfs_getxquota, 937 .get_xquota = linvfs_getxquota,
diff --git a/fs/xfs/linux-2.6/xfs_super.h b/fs/xfs/linux-2.6/xfs_super.h
index ec7e0035c731..df59408dca06 100644
--- a/fs/xfs/linux-2.6/xfs_super.h
+++ b/fs/xfs/linux-2.6/xfs_super.h
@@ -1,33 +1,19 @@
1/* 1/*
2 * Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32#ifndef __XFS_SUPER_H__ 18#ifndef __XFS_SUPER_H__
33#define __XFS_SUPER_H__ 19#define __XFS_SUPER_H__
@@ -132,6 +118,7 @@ extern void xfs_flush_device(struct xfs_inode *);
132extern int xfs_blkdev_get(struct xfs_mount *, const char *, 118extern int xfs_blkdev_get(struct xfs_mount *, const char *,
133 struct block_device **); 119 struct block_device **);
134extern void xfs_blkdev_put(struct block_device *); 120extern void xfs_blkdev_put(struct block_device *);
121extern void xfs_blkdev_issue_flush(struct xfs_buftarg *);
135 122
136extern struct export_operations linvfs_export_ops; 123extern struct export_operations linvfs_export_ops;
137 124
diff --git a/fs/xfs/linux-2.6/xfs_sysctl.c b/fs/xfs/linux-2.6/xfs_sysctl.c
index 0dc010356f4d..a02564972420 100644
--- a/fs/xfs/linux-2.6/xfs_sysctl.c
+++ b/fs/xfs/linux-2.6/xfs_sysctl.c
@@ -1,44 +1,26 @@
1/* 1/*
2 * Copyright (c) 2001-2004 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2001-2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32
33#include "xfs.h" 18#include "xfs.h"
34#include "xfs_rw.h"
35#include <linux/sysctl.h> 19#include <linux/sysctl.h>
36#include <linux/proc_fs.h> 20#include <linux/proc_fs.h>
37 21
38
39static struct ctl_table_header *xfs_table_header; 22static struct ctl_table_header *xfs_table_header;
40 23
41
42#ifdef CONFIG_PROC_FS 24#ifdef CONFIG_PROC_FS
43STATIC int 25STATIC int
44xfs_stats_clear_proc_handler( 26xfs_stats_clear_proc_handler(
@@ -76,7 +58,7 @@ xfs_stats_clear_proc_handler(
76STATIC ctl_table xfs_table[] = { 58STATIC ctl_table xfs_table[] = {
77 {XFS_RESTRICT_CHOWN, "restrict_chown", &xfs_params.restrict_chown.val, 59 {XFS_RESTRICT_CHOWN, "restrict_chown", &xfs_params.restrict_chown.val,
78 sizeof(int), 0644, NULL, &proc_dointvec_minmax, 60 sizeof(int), 0644, NULL, &proc_dointvec_minmax,
79 &sysctl_intvec, NULL, 61 &sysctl_intvec, NULL,
80 &xfs_params.restrict_chown.min, &xfs_params.restrict_chown.max}, 62 &xfs_params.restrict_chown.min, &xfs_params.restrict_chown.max},
81 63
82 {XFS_SGID_INHERIT, "irix_sgid_inherit", &xfs_params.sgid_inherit.val, 64 {XFS_SGID_INHERIT, "irix_sgid_inherit", &xfs_params.sgid_inherit.val,
@@ -86,22 +68,22 @@ STATIC ctl_table xfs_table[] = {
86 68
87 {XFS_SYMLINK_MODE, "irix_symlink_mode", &xfs_params.symlink_mode.val, 69 {XFS_SYMLINK_MODE, "irix_symlink_mode", &xfs_params.symlink_mode.val,
88 sizeof(int), 0644, NULL, &proc_dointvec_minmax, 70 sizeof(int), 0644, NULL, &proc_dointvec_minmax,
89 &sysctl_intvec, NULL, 71 &sysctl_intvec, NULL,
90 &xfs_params.symlink_mode.min, &xfs_params.symlink_mode.max}, 72 &xfs_params.symlink_mode.min, &xfs_params.symlink_mode.max},
91 73
92 {XFS_PANIC_MASK, "panic_mask", &xfs_params.panic_mask.val, 74 {XFS_PANIC_MASK, "panic_mask", &xfs_params.panic_mask.val,
93 sizeof(int), 0644, NULL, &proc_dointvec_minmax, 75 sizeof(int), 0644, NULL, &proc_dointvec_minmax,
94 &sysctl_intvec, NULL, 76 &sysctl_intvec, NULL,
95 &xfs_params.panic_mask.min, &xfs_params.panic_mask.max}, 77 &xfs_params.panic_mask.min, &xfs_params.panic_mask.max},
96 78
97 {XFS_ERRLEVEL, "error_level", &xfs_params.error_level.val, 79 {XFS_ERRLEVEL, "error_level", &xfs_params.error_level.val,
98 sizeof(int), 0644, NULL, &proc_dointvec_minmax, 80 sizeof(int), 0644, NULL, &proc_dointvec_minmax,
99 &sysctl_intvec, NULL, 81 &sysctl_intvec, NULL,
100 &xfs_params.error_level.min, &xfs_params.error_level.max}, 82 &xfs_params.error_level.min, &xfs_params.error_level.max},
101 83
102 {XFS_SYNCD_TIMER, "xfssyncd_centisecs", &xfs_params.syncd_timer.val, 84 {XFS_SYNCD_TIMER, "xfssyncd_centisecs", &xfs_params.syncd_timer.val,
103 sizeof(int), 0644, NULL, &proc_dointvec_minmax, 85 sizeof(int), 0644, NULL, &proc_dointvec_minmax,
104 &sysctl_intvec, NULL, 86 &sysctl_intvec, NULL,
105 &xfs_params.syncd_timer.min, &xfs_params.syncd_timer.max}, 87 &xfs_params.syncd_timer.min, &xfs_params.syncd_timer.max},
106 88
107 {XFS_INHERIT_SYNC, "inherit_sync", &xfs_params.inherit_sync.val, 89 {XFS_INHERIT_SYNC, "inherit_sync", &xfs_params.inherit_sync.val,
@@ -118,7 +100,7 @@ STATIC ctl_table xfs_table[] = {
118 sizeof(int), 0644, NULL, &proc_dointvec_minmax, 100 sizeof(int), 0644, NULL, &proc_dointvec_minmax,
119 &sysctl_intvec, NULL, 101 &sysctl_intvec, NULL,
120 &xfs_params.inherit_noatim.min, &xfs_params.inherit_noatim.max}, 102 &xfs_params.inherit_noatim.min, &xfs_params.inherit_noatim.max},
121 103
122 {XFS_BUF_TIMER, "xfsbufd_centisecs", &xfs_params.xfs_buf_timer.val, 104 {XFS_BUF_TIMER, "xfsbufd_centisecs", &xfs_params.xfs_buf_timer.val,
123 sizeof(int), 0644, NULL, &proc_dointvec_minmax, 105 sizeof(int), 0644, NULL, &proc_dointvec_minmax,
124 &sysctl_intvec, NULL, 106 &sysctl_intvec, NULL,
@@ -136,14 +118,14 @@ STATIC ctl_table xfs_table[] = {
136 118
137 {XFS_ROTORSTEP, "rotorstep", &xfs_params.rotorstep.val, 119 {XFS_ROTORSTEP, "rotorstep", &xfs_params.rotorstep.val,
138 sizeof(int), 0644, NULL, &proc_dointvec_minmax, 120 sizeof(int), 0644, NULL, &proc_dointvec_minmax,
139 &sysctl_intvec, NULL, 121 &sysctl_intvec, NULL,
140 &xfs_params.rotorstep.min, &xfs_params.rotorstep.max}, 122 &xfs_params.rotorstep.min, &xfs_params.rotorstep.max},
141 123
142 /* please keep this the last entry */ 124 /* please keep this the last entry */
143#ifdef CONFIG_PROC_FS 125#ifdef CONFIG_PROC_FS
144 {XFS_STATS_CLEAR, "stats_clear", &xfs_params.stats_clear.val, 126 {XFS_STATS_CLEAR, "stats_clear", &xfs_params.stats_clear.val,
145 sizeof(int), 0644, NULL, &xfs_stats_clear_proc_handler, 127 sizeof(int), 0644, NULL, &xfs_stats_clear_proc_handler,
146 &sysctl_intvec, NULL, 128 &sysctl_intvec, NULL,
147 &xfs_params.stats_clear.min, &xfs_params.stats_clear.max}, 129 &xfs_params.stats_clear.min, &xfs_params.stats_clear.max},
148#endif /* CONFIG_PROC_FS */ 130#endif /* CONFIG_PROC_FS */
149 131
diff --git a/fs/xfs/linux-2.6/xfs_sysctl.h b/fs/xfs/linux-2.6/xfs_sysctl.h
index a39a95020a58..bc8c11f13722 100644
--- a/fs/xfs/linux-2.6/xfs_sysctl.h
+++ b/fs/xfs/linux-2.6/xfs_sysctl.h
@@ -1,35 +1,20 @@
1/* 1/*
2 * Copyright (c) 2001-2004 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2001-2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32
33#ifndef __XFS_SYSCTL_H__ 18#ifndef __XFS_SYSCTL_H__
34#define __XFS_SYSCTL_H__ 19#define __XFS_SYSCTL_H__
35 20
diff --git a/fs/xfs/linux-2.6/xfs_version.h b/fs/xfs/linux-2.6/xfs_version.h
index 96f96394417e..f8d279d7563a 100644
--- a/fs/xfs/linux-2.6/xfs_version.h
+++ b/fs/xfs/linux-2.6/xfs_version.h
@@ -1,34 +1,22 @@
1/* 1/*
2 * Copyright (c) 2001-2002 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2001-2002,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
18#ifndef __XFS_VERSION_H__
19#define __XFS_VERSION_H__
32 20
33/* 21/*
34 * Dummy file that can contain a timestamp to put into the 22 * Dummy file that can contain a timestamp to put into the
@@ -36,9 +24,6 @@
36 * running 24 * running
37 */ 25 */
38 26
39#ifndef __XFS_VERSION_H__
40#define __XFS_VERSION_H__
41
42#define XFS_VERSION_STRING "SGI XFS" 27#define XFS_VERSION_STRING "SGI XFS"
43 28
44#endif /* __XFS_VERSION_H__ */ 29#endif /* __XFS_VERSION_H__ */
diff --git a/fs/xfs/linux-2.6/xfs_vfs.c b/fs/xfs/linux-2.6/xfs_vfs.c
index 34cc902ec119..c855d62e5344 100644
--- a/fs/xfs/linux-2.6/xfs_vfs.c
+++ b/fs/xfs/linux-2.6/xfs_vfs.c
@@ -1,38 +1,22 @@
1/* 1/*
2 * Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32
33#include "xfs.h" 18#include "xfs.h"
34#include "xfs_fs.h" 19#include "xfs_fs.h"
35#include "xfs_macros.h"
36#include "xfs_inum.h" 20#include "xfs_inum.h"
37#include "xfs_log.h" 21#include "xfs_log.h"
38#include "xfs_clnt.h" 22#include "xfs_clnt.h"
diff --git a/fs/xfs/linux-2.6/xfs_vfs.h b/fs/xfs/linux-2.6/xfs_vfs.h
index f0ab574fb47a..57caf9eddee0 100644
--- a/fs/xfs/linux-2.6/xfs_vfs.h
+++ b/fs/xfs/linux-2.6/xfs_vfs.h
@@ -1,33 +1,19 @@
1/* 1/*
2 * Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32#ifndef __XFS_VFS_H__ 18#ifndef __XFS_VFS_H__
33#define __XFS_VFS_H__ 19#define __XFS_VFS_H__
@@ -95,6 +81,7 @@ typedef enum {
95#define VFS_RDONLY 0x0001 /* read-only vfs */ 81#define VFS_RDONLY 0x0001 /* read-only vfs */
96#define VFS_GRPID 0x0002 /* group-ID assigned from directory */ 82#define VFS_GRPID 0x0002 /* group-ID assigned from directory */
97#define VFS_DMI 0x0004 /* filesystem has the DMI enabled */ 83#define VFS_DMI 0x0004 /* filesystem has the DMI enabled */
84#define VFS_32BITINODES 0x0008 /* do not use inums above 32 bits */
98#define VFS_END 0x0008 /* max flag */ 85#define VFS_END 0x0008 /* max flag */
99 86
100#define SYNC_ATTR 0x0001 /* sync attributes */ 87#define SYNC_ATTR 0x0001 /* sync attributes */
diff --git a/fs/xfs/linux-2.6/xfs_vnode.c b/fs/xfs/linux-2.6/xfs_vnode.c
index 268f45bf6a9a..e9bbcb4d6243 100644
--- a/fs/xfs/linux-2.6/xfs_vnode.c
+++ b/fs/xfs/linux-2.6/xfs_vnode.c
@@ -1,38 +1,22 @@
1/* 1/*
2 * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32
33#include "xfs.h" 18#include "xfs.h"
34 19
35
36uint64_t vn_generation; /* vnode generation number */ 20uint64_t vn_generation; /* vnode generation number */
37DEFINE_SPINLOCK(vnumber_lock); 21DEFINE_SPINLOCK(vnumber_lock);
38 22
@@ -44,7 +28,6 @@ DEFINE_SPINLOCK(vnumber_lock);
44#define vptosync(v) (&vsync[((unsigned long)v) % NVSYNC]) 28#define vptosync(v) (&vsync[((unsigned long)v) % NVSYNC])
45STATIC wait_queue_head_t vsync[NVSYNC]; 29STATIC wait_queue_head_t vsync[NVSYNC];
46 30
47
48void 31void
49vn_init(void) 32vn_init(void)
50{ 33{
@@ -124,6 +107,7 @@ vn_revalidate_core(
124 inode->i_mtime = vap->va_mtime; 107 inode->i_mtime = vap->va_mtime;
125 inode->i_ctime = vap->va_ctime; 108 inode->i_ctime = vap->va_ctime;
126 inode->i_atime = vap->va_atime; 109 inode->i_atime = vap->va_atime;
110 inode->i_blksize = vap->va_blocksize;
127 if (vap->va_xflags & XFS_XFLAG_IMMUTABLE) 111 if (vap->va_xflags & XFS_XFLAG_IMMUTABLE)
128 inode->i_flags |= S_IMMUTABLE; 112 inode->i_flags |= S_IMMUTABLE;
129 else 113 else
diff --git a/fs/xfs/linux-2.6/xfs_vnode.h b/fs/xfs/linux-2.6/xfs_vnode.h
index 35f306cebb87..f2bbb327c081 100644
--- a/fs/xfs/linux-2.6/xfs_vnode.h
+++ b/fs/xfs/linux-2.6/xfs_vnode.h
@@ -1,33 +1,19 @@
1/* 1/*
2 * Copyright (c) 2000-2005 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 * 17 *
32 * Portions Copyright (c) 1989, 1993 18 * Portions Copyright (c) 1989, 1993
33 * The Regents of the University of California. All rights reserved. 19 * The Regents of the University of California. All rights reserved.
@@ -216,11 +202,12 @@ typedef void (*vop_rwunlock_t)(bhv_desc_t *, vrwlock_t);
216typedef int (*vop_bmap_t)(bhv_desc_t *, xfs_off_t, ssize_t, int, 202typedef int (*vop_bmap_t)(bhv_desc_t *, xfs_off_t, ssize_t, int,
217 struct xfs_iomap *, int *); 203 struct xfs_iomap *, int *);
218typedef int (*vop_reclaim_t)(bhv_desc_t *); 204typedef int (*vop_reclaim_t)(bhv_desc_t *);
219typedef int (*vop_attr_get_t)(bhv_desc_t *, char *, char *, int *, int, 205typedef int (*vop_attr_get_t)(bhv_desc_t *, const char *, char *, int *,
220 struct cred *); 206 int, struct cred *);
221typedef int (*vop_attr_set_t)(bhv_desc_t *, char *, char *, int, int, 207typedef int (*vop_attr_set_t)(bhv_desc_t *, const char *, char *, int,
222 struct cred *); 208 int, struct cred *);
223typedef int (*vop_attr_remove_t)(bhv_desc_t *, char *, int, struct cred *); 209typedef int (*vop_attr_remove_t)(bhv_desc_t *, const char *,
210 int, struct cred *);
224typedef int (*vop_attr_list_t)(bhv_desc_t *, char *, int, int, 211typedef int (*vop_attr_list_t)(bhv_desc_t *, char *, int, int,
225 struct attrlist_cursor_kern *, struct cred *); 212 struct attrlist_cursor_kern *, struct cred *);
226typedef void (*vop_link_removed_t)(bhv_desc_t *, vnode_t *, int); 213typedef void (*vop_link_removed_t)(bhv_desc_t *, vnode_t *, int);
@@ -566,13 +553,6 @@ static __inline__ void vn_flagclr(struct vnode *vp, uint flag)
566} 553}
567 554
568/* 555/*
569 * Update modify/access/change times on the vnode
570 */
571#define VN_MTIMESET(vp, tvp) (LINVFS_GET_IP(vp)->i_mtime = *(tvp))
572#define VN_ATIMESET(vp, tvp) (LINVFS_GET_IP(vp)->i_atime = *(tvp))
573#define VN_CTIMESET(vp, tvp) (LINVFS_GET_IP(vp)->i_ctime = *(tvp))
574
575/*
576 * Dealing with bad inodes 556 * Dealing with bad inodes
577 */ 557 */
578static inline void vn_mark_bad(struct vnode *vp) 558static inline void vn_mark_bad(struct vnode *vp)
@@ -603,6 +583,7 @@ static inline int VN_BAD(struct vnode *vp)
603#define ATTR_LAZY 0x80 /* set/get attributes lazily */ 583#define ATTR_LAZY 0x80 /* set/get attributes lazily */
604#define ATTR_NONBLOCK 0x100 /* return EAGAIN if operation would block */ 584#define ATTR_NONBLOCK 0x100 /* return EAGAIN if operation would block */
605#define ATTR_NOLOCK 0x200 /* Don't grab any conflicting locks */ 585#define ATTR_NOLOCK 0x200 /* Don't grab any conflicting locks */
586#define ATTR_NOSIZETOK 0x400 /* Don't get the SIZE token */
606 587
607/* 588/*
608 * Flags to VOP_FSYNC and VOP_RECLAIM. 589 * Flags to VOP_FSYNC and VOP_RECLAIM.
diff --git a/fs/xfs/quota/Makefile b/fs/xfs/quota/Makefile
deleted file mode 100644
index 7a4f725b2824..000000000000
--- a/fs/xfs/quota/Makefile
+++ /dev/null
@@ -1 +0,0 @@
1include $(TOPDIR)/fs/xfs/quota/Makefile-linux-$(VERSION).$(PATCHLEVEL)
diff --git a/fs/xfs/quota/Makefile-linux-2.6 b/fs/xfs/quota/Makefile-linux-2.6
deleted file mode 100644
index 93e60e839355..000000000000
--- a/fs/xfs/quota/Makefile-linux-2.6
+++ /dev/null
@@ -1,53 +0,0 @@
1#
2# Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved.
3#
4# This program is free software; you can redistribute it and/or modify it
5# under the terms of version 2 of the GNU General Public License as
6# published by the Free Software Foundation.
7#
8# This program is distributed in the hope that it would be useful, but
9# WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11#
12# Further, this software is distributed without any warranty that it is
13# free of the rightful claim of any third person regarding infringement
14# or the like. Any license provided herein, whether implied or
15# otherwise, applies only to this software file. Patent licenses, if
16# any, provided herein do not apply to combinations of this program with
17# other software, or any other product whatsoever.
18#
19# You should have received a copy of the GNU General Public License along
20# with this program; if not, write the Free Software Foundation, Inc., 59
21# Temple Place - Suite 330, Boston MA 02111-1307, USA.
22#
23# Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24# Mountain View, CA 94043, or:
25#
26# http://www.sgi.com
27#
28# For further information regarding this notice, see:
29#
30# http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31#
32
33EXTRA_CFLAGS += -I $(TOPDIR)/fs/xfs -I $(TOPDIR)/fs/xfs/linux-2.6
34
35ifeq ($(CONFIG_XFS_DEBUG),y)
36 EXTRA_CFLAGS += -g -DDEBUG
37 #EXTRA_CFLAGS += -DQUOTADEBUG
38endif
39ifeq ($(CONFIG_XFS_TRACE),y)
40 EXTRA_CFLAGS += -DXFS_DQUOT_TRACE
41 EXTRA_CFLAGS += -DXFS_VNODE_TRACE
42endif
43
44xfs-$(CONFIG_XFS_QUOTA) += xfs_dquot.o \
45 xfs_dquot_item.o \
46 xfs_trans_dquot.o \
47 xfs_qm_syscalls.o \
48 xfs_qm_bhv.o \
49 xfs_qm.o
50
51ifeq ($(CONFIG_XFS_QUOTA),y)
52xfs-$(CONFIG_PROC_FS) += xfs_qm_stats.o
53endif
diff --git a/fs/xfs/quota/xfs_dquot.c b/fs/xfs/quota/xfs_dquot.c
index e2e8d35fa4d0..00b5043dfa5a 100644
--- a/fs/xfs/quota/xfs_dquot.c
+++ b/fs/xfs/quota/xfs_dquot.c
@@ -1,39 +1,25 @@
1/* 1/*
2 * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2003 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32
33#include "xfs.h" 18#include "xfs.h"
34#include "xfs_fs.h" 19#include "xfs_fs.h"
35#include "xfs_inum.h" 20#include "xfs_bit.h"
36#include "xfs_log.h" 21#include "xfs_log.h"
22#include "xfs_inum.h"
37#include "xfs_trans.h" 23#include "xfs_trans.h"
38#include "xfs_sb.h" 24#include "xfs_sb.h"
39#include "xfs_ag.h" 25#include "xfs_ag.h"
@@ -43,18 +29,17 @@
43#include "xfs_dmapi.h" 29#include "xfs_dmapi.h"
44#include "xfs_quota.h" 30#include "xfs_quota.h"
45#include "xfs_mount.h" 31#include "xfs_mount.h"
46#include "xfs_alloc_btree.h"
47#include "xfs_bmap_btree.h" 32#include "xfs_bmap_btree.h"
33#include "xfs_alloc_btree.h"
48#include "xfs_ialloc_btree.h" 34#include "xfs_ialloc_btree.h"
49#include "xfs_btree.h"
50#include "xfs_ialloc.h"
51#include "xfs_attr_sf.h"
52#include "xfs_dir_sf.h" 35#include "xfs_dir_sf.h"
53#include "xfs_dir2_sf.h" 36#include "xfs_dir2_sf.h"
37#include "xfs_attr_sf.h"
54#include "xfs_dinode.h" 38#include "xfs_dinode.h"
55#include "xfs_inode.h" 39#include "xfs_inode.h"
40#include "xfs_btree.h"
41#include "xfs_ialloc.h"
56#include "xfs_bmap.h" 42#include "xfs_bmap.h"
57#include "xfs_bit.h"
58#include "xfs_rtalloc.h" 43#include "xfs_rtalloc.h"
59#include "xfs_error.h" 44#include "xfs_error.h"
60#include "xfs_itable.h" 45#include "xfs_itable.h"
@@ -66,7 +51,6 @@
66#include "xfs_buf_item.h" 51#include "xfs_buf_item.h"
67#include "xfs_trans_space.h" 52#include "xfs_trans_space.h"
68#include "xfs_trans_priv.h" 53#include "xfs_trans_priv.h"
69
70#include "xfs_qm.h" 54#include "xfs_qm.h"
71 55
72 56
@@ -112,7 +96,7 @@ xfs_qm_dqinit(
112 96
113 brandnewdquot = xfs_qm_dqalloc_incore(&dqp); 97 brandnewdquot = xfs_qm_dqalloc_incore(&dqp);
114 dqp->dq_flags = type; 98 dqp->dq_flags = type;
115 INT_SET(dqp->q_core.d_id, ARCH_CONVERT, id); 99 dqp->q_core.d_id = cpu_to_be32(id);
116 dqp->q_mount = mp; 100 dqp->q_mount = mp;
117 101
118 /* 102 /*
@@ -194,10 +178,10 @@ xfs_qm_dqinit_core(
194 /* 178 /*
195 * Caller has zero'd the entire dquot 'chunk' already. 179 * Caller has zero'd the entire dquot 'chunk' already.
196 */ 180 */
197 INT_SET(d->dd_diskdq.d_magic, ARCH_CONVERT, XFS_DQUOT_MAGIC); 181 d->dd_diskdq.d_magic = cpu_to_be16(XFS_DQUOT_MAGIC);
198 INT_SET(d->dd_diskdq.d_version, ARCH_CONVERT, XFS_DQUOT_VERSION); 182 d->dd_diskdq.d_version = XFS_DQUOT_VERSION;
199 INT_SET(d->dd_diskdq.d_id, ARCH_CONVERT, id); 183 d->dd_diskdq.d_id = cpu_to_be32(id);
200 INT_SET(d->dd_diskdq.d_flags, ARCH_CONVERT, type); 184 d->dd_diskdq.d_flags = type;
201} 185}
202 186
203 187
@@ -227,19 +211,13 @@ __xfs_dqtrace_entry(
227 (void *)(__psint_t)dqp->q_nrefs, 211 (void *)(__psint_t)dqp->q_nrefs,
228 (void *)(__psint_t)dqp->dq_flags, 212 (void *)(__psint_t)dqp->dq_flags,
229 (void *)(__psint_t)dqp->q_res_bcount, 213 (void *)(__psint_t)dqp->q_res_bcount,
230 (void *)(__psint_t)INT_GET(dqp->q_core.d_bcount, 214 (void *)(__psint_t)be64_to_cpu(dqp->q_core.d_bcount),
231 ARCH_CONVERT), 215 (void *)(__psint_t)be64_to_cpu(dqp->q_core.d_icount),
232 (void *)(__psint_t)INT_GET(dqp->q_core.d_icount, 216 (void *)(__psint_t)be64_to_cpu(dqp->q_core.d_blk_hardlimit),
233 ARCH_CONVERT), 217 (void *)(__psint_t)be64_to_cpu(dqp->q_core.d_blk_softlimit),
234 (void *)(__psint_t)INT_GET(dqp->q_core.d_blk_hardlimit, 218 (void *)(__psint_t)be64_to_cpu(dqp->q_core.d_ino_hardlimit),
235 ARCH_CONVERT), 219 (void *)(__psint_t)be64_to_cpu(dqp->q_core.d_ino_softlimit),
236 (void *)(__psint_t)INT_GET(dqp->q_core.d_blk_softlimit, 220 (void *)(__psint_t)be32_to_cpu(dqp->q_core.d_id),
237 ARCH_CONVERT),
238 (void *)(__psint_t)INT_GET(dqp->q_core.d_ino_hardlimit,
239 ARCH_CONVERT),
240 (void *)(__psint_t)INT_GET(dqp->q_core.d_ino_softlimit,
241 ARCH_CONVERT),
242 (void *)(__psint_t)INT_GET(dqp->q_core.d_id, ARCH_CONVERT),
243 (void *)(__psint_t)current_pid(), 221 (void *)(__psint_t)current_pid(),
244 (void *)(__psint_t)ino, 222 (void *)(__psint_t)ino,
245 (void *)(__psint_t)retaddr, 223 (void *)(__psint_t)retaddr,
@@ -264,17 +242,17 @@ xfs_qm_adjust_dqlimits(
264 ASSERT(d->d_id); 242 ASSERT(d->d_id);
265 243
266 if (q->qi_bsoftlimit && !d->d_blk_softlimit) 244 if (q->qi_bsoftlimit && !d->d_blk_softlimit)
267 INT_SET(d->d_blk_softlimit, ARCH_CONVERT, q->qi_bsoftlimit); 245 d->d_blk_softlimit = cpu_to_be64(q->qi_bsoftlimit);
268 if (q->qi_bhardlimit && !d->d_blk_hardlimit) 246 if (q->qi_bhardlimit && !d->d_blk_hardlimit)
269 INT_SET(d->d_blk_hardlimit, ARCH_CONVERT, q->qi_bhardlimit); 247 d->d_blk_hardlimit = cpu_to_be64(q->qi_bhardlimit);
270 if (q->qi_isoftlimit && !d->d_ino_softlimit) 248 if (q->qi_isoftlimit && !d->d_ino_softlimit)
271 INT_SET(d->d_ino_softlimit, ARCH_CONVERT, q->qi_isoftlimit); 249 d->d_ino_softlimit = cpu_to_be64(q->qi_isoftlimit);
272 if (q->qi_ihardlimit && !d->d_ino_hardlimit) 250 if (q->qi_ihardlimit && !d->d_ino_hardlimit)
273 INT_SET(d->d_ino_hardlimit, ARCH_CONVERT, q->qi_ihardlimit); 251 d->d_ino_hardlimit = cpu_to_be64(q->qi_ihardlimit);
274 if (q->qi_rtbsoftlimit && !d->d_rtb_softlimit) 252 if (q->qi_rtbsoftlimit && !d->d_rtb_softlimit)
275 INT_SET(d->d_rtb_softlimit, ARCH_CONVERT, q->qi_rtbsoftlimit); 253 d->d_rtb_softlimit = cpu_to_be64(q->qi_rtbsoftlimit);
276 if (q->qi_rtbhardlimit && !d->d_rtb_hardlimit) 254 if (q->qi_rtbhardlimit && !d->d_rtb_hardlimit)
277 INT_SET(d->d_rtb_hardlimit, ARCH_CONVERT, q->qi_rtbhardlimit); 255 d->d_rtb_hardlimit = cpu_to_be64(q->qi_rtbhardlimit);
278} 256}
279 257
280/* 258/*
@@ -298,81 +276,81 @@ xfs_qm_adjust_dqtimers(
298 ASSERT(d->d_id); 276 ASSERT(d->d_id);
299 277
300#ifdef QUOTADEBUG 278#ifdef QUOTADEBUG
301 if (INT_GET(d->d_blk_hardlimit, ARCH_CONVERT)) 279 if (d->d_blk_hardlimit)
302 ASSERT(INT_GET(d->d_blk_softlimit, ARCH_CONVERT) <= 280 ASSERT(be64_to_cpu(d->d_blk_softlimit) <=
303 INT_GET(d->d_blk_hardlimit, ARCH_CONVERT)); 281 be64_to_cpu(d->d_blk_hardlimit));
304 if (INT_GET(d->d_ino_hardlimit, ARCH_CONVERT)) 282 if (d->d_ino_hardlimit)
305 ASSERT(INT_GET(d->d_ino_softlimit, ARCH_CONVERT) <= 283 ASSERT(be64_to_cpu(d->d_ino_softlimit) <=
306 INT_GET(d->d_ino_hardlimit, ARCH_CONVERT)); 284 be64_to_cpu(d->d_ino_hardlimit));
307 if (INT_GET(d->d_rtb_hardlimit, ARCH_CONVERT)) 285 if (d->d_rtb_hardlimit)
308 ASSERT(INT_GET(d->d_rtb_softlimit, ARCH_CONVERT) <= 286 ASSERT(be64_to_cpu(d->d_rtb_softlimit) <=
309 INT_GET(d->d_rtb_hardlimit, ARCH_CONVERT)); 287 be64_to_cpu(d->d_rtb_hardlimit));
310#endif 288#endif
311 if (!d->d_btimer) { 289 if (!d->d_btimer) {
312 if ((INT_GET(d->d_blk_softlimit, ARCH_CONVERT) && 290 if ((d->d_blk_softlimit &&
313 (INT_GET(d->d_bcount, ARCH_CONVERT) >= 291 (be64_to_cpu(d->d_bcount) >=
314 INT_GET(d->d_blk_softlimit, ARCH_CONVERT))) || 292 be64_to_cpu(d->d_blk_softlimit))) ||
315 (INT_GET(d->d_blk_hardlimit, ARCH_CONVERT) && 293 (d->d_blk_hardlimit &&
316 (INT_GET(d->d_bcount, ARCH_CONVERT) >= 294 (be64_to_cpu(d->d_bcount) >=
317 INT_GET(d->d_blk_hardlimit, ARCH_CONVERT)))) { 295 be64_to_cpu(d->d_blk_hardlimit)))) {
318 INT_SET(d->d_btimer, ARCH_CONVERT, 296 d->d_btimer = cpu_to_be32(get_seconds() +
319 get_seconds() + XFS_QI_BTIMELIMIT(mp)); 297 XFS_QI_BTIMELIMIT(mp));
320 } else { 298 } else {
321 d->d_bwarns = 0; 299 d->d_bwarns = 0;
322 } 300 }
323 } else { 301 } else {
324 if ((!d->d_blk_softlimit || 302 if ((!d->d_blk_softlimit ||
325 (INT_GET(d->d_bcount, ARCH_CONVERT) < 303 (be64_to_cpu(d->d_bcount) <
326 INT_GET(d->d_blk_softlimit, ARCH_CONVERT))) && 304 be64_to_cpu(d->d_blk_softlimit))) &&
327 (!d->d_blk_hardlimit || 305 (!d->d_blk_hardlimit ||
328 (INT_GET(d->d_bcount, ARCH_CONVERT) < 306 (be64_to_cpu(d->d_bcount) <
329 INT_GET(d->d_blk_hardlimit, ARCH_CONVERT)))) { 307 be64_to_cpu(d->d_blk_hardlimit)))) {
330 d->d_btimer = 0; 308 d->d_btimer = 0;
331 } 309 }
332 } 310 }
333 311
334 if (!d->d_itimer) { 312 if (!d->d_itimer) {
335 if ((INT_GET(d->d_ino_softlimit, ARCH_CONVERT) && 313 if ((d->d_ino_softlimit &&
336 (INT_GET(d->d_icount, ARCH_CONVERT) >= 314 (be64_to_cpu(d->d_icount) >=
337 INT_GET(d->d_ino_softlimit, ARCH_CONVERT))) || 315 be64_to_cpu(d->d_ino_softlimit))) ||
338 (INT_GET(d->d_ino_hardlimit, ARCH_CONVERT) && 316 (d->d_ino_hardlimit &&
339 (INT_GET(d->d_icount, ARCH_CONVERT) >= 317 (be64_to_cpu(d->d_icount) >=
340 INT_GET(d->d_ino_hardlimit, ARCH_CONVERT)))) { 318 be64_to_cpu(d->d_ino_hardlimit)))) {
341 INT_SET(d->d_itimer, ARCH_CONVERT, 319 d->d_itimer = cpu_to_be32(get_seconds() +
342 get_seconds() + XFS_QI_ITIMELIMIT(mp)); 320 XFS_QI_ITIMELIMIT(mp));
343 } else { 321 } else {
344 d->d_iwarns = 0; 322 d->d_iwarns = 0;
345 } 323 }
346 } else { 324 } else {
347 if ((!d->d_ino_softlimit || 325 if ((!d->d_ino_softlimit ||
348 (INT_GET(d->d_icount, ARCH_CONVERT) < 326 (be64_to_cpu(d->d_icount) <
349 INT_GET(d->d_ino_softlimit, ARCH_CONVERT))) && 327 be64_to_cpu(d->d_ino_softlimit))) &&
350 (!d->d_ino_hardlimit || 328 (!d->d_ino_hardlimit ||
351 (INT_GET(d->d_icount, ARCH_CONVERT) < 329 (be64_to_cpu(d->d_icount) <
352 INT_GET(d->d_ino_hardlimit, ARCH_CONVERT)))) { 330 be64_to_cpu(d->d_ino_hardlimit)))) {
353 d->d_itimer = 0; 331 d->d_itimer = 0;
354 } 332 }
355 } 333 }
356 334
357 if (!d->d_rtbtimer) { 335 if (!d->d_rtbtimer) {
358 if ((INT_GET(d->d_rtb_softlimit, ARCH_CONVERT) && 336 if ((d->d_rtb_softlimit &&
359 (INT_GET(d->d_rtbcount, ARCH_CONVERT) >= 337 (be64_to_cpu(d->d_rtbcount) >=
360 INT_GET(d->d_rtb_softlimit, ARCH_CONVERT))) || 338 be64_to_cpu(d->d_rtb_softlimit))) ||
361 (INT_GET(d->d_rtb_hardlimit, ARCH_CONVERT) && 339 (d->d_rtb_hardlimit &&
362 (INT_GET(d->d_rtbcount, ARCH_CONVERT) >= 340 (be64_to_cpu(d->d_rtbcount) >=
363 INT_GET(d->d_rtb_hardlimit, ARCH_CONVERT)))) { 341 be64_to_cpu(d->d_rtb_hardlimit)))) {
364 INT_SET(d->d_rtbtimer, ARCH_CONVERT, 342 d->d_rtbtimer = cpu_to_be32(get_seconds() +
365 get_seconds() + XFS_QI_RTBTIMELIMIT(mp)); 343 XFS_QI_RTBTIMELIMIT(mp));
366 } else { 344 } else {
367 d->d_rtbwarns = 0; 345 d->d_rtbwarns = 0;
368 } 346 }
369 } else { 347 } else {
370 if ((!d->d_rtb_softlimit || 348 if ((!d->d_rtb_softlimit ||
371 (INT_GET(d->d_rtbcount, ARCH_CONVERT) < 349 (be64_to_cpu(d->d_rtbcount) <
372 INT_GET(d->d_rtb_softlimit, ARCH_CONVERT))) && 350 be64_to_cpu(d->d_rtb_softlimit))) &&
373 (!d->d_rtb_hardlimit || 351 (!d->d_rtb_hardlimit ||
374 (INT_GET(d->d_rtbcount, ARCH_CONVERT) < 352 (be64_to_cpu(d->d_rtbcount) <
375 INT_GET(d->d_rtb_hardlimit, ARCH_CONVERT)))) { 353 be64_to_cpu(d->d_rtb_hardlimit)))) {
376 d->d_rtbtimer = 0; 354 d->d_rtbtimer = 0;
377 } 355 }
378 } 356 }
@@ -490,7 +468,7 @@ xfs_qm_dqalloc(
490 * Make a chunk of dquots out of this buffer and log 468 * Make a chunk of dquots out of this buffer and log
491 * the entire thing. 469 * the entire thing.
492 */ 470 */
493 xfs_qm_init_dquot_blk(tp, mp, INT_GET(dqp->q_core.d_id, ARCH_CONVERT), 471 xfs_qm_init_dquot_blk(tp, mp, be32_to_cpu(dqp->q_core.d_id),
494 dqp->dq_flags & XFS_DQ_ALLTYPES, bp); 472 dqp->dq_flags & XFS_DQ_ALLTYPES, bp);
495 473
496 /* 474 /*
@@ -554,7 +532,7 @@ xfs_qm_dqtobp(
554 xfs_trans_t *tp = (tpp ? *tpp : NULL); 532 xfs_trans_t *tp = (tpp ? *tpp : NULL);
555 533
556 mp = dqp->q_mount; 534 mp = dqp->q_mount;
557 id = INT_GET(dqp->q_core.d_id, ARCH_CONVERT); 535 id = be32_to_cpu(dqp->q_core.d_id);
558 nmaps = 1; 536 nmaps = 1;
559 newdquot = B_FALSE; 537 newdquot = B_FALSE;
560 538
@@ -563,8 +541,7 @@ xfs_qm_dqtobp(
563 */ 541 */
564 if (dqp->q_blkno == (xfs_daddr_t) 0) { 542 if (dqp->q_blkno == (xfs_daddr_t) 0) {
565 /* We use the id as an index */ 543 /* We use the id as an index */
566 dqp->q_fileoffset = (xfs_fileoff_t) ((uint)id / 544 dqp->q_fileoffset = (xfs_fileoff_t)id / XFS_QM_DQPERBLK(mp);
567 XFS_QM_DQPERBLK(mp));
568 nmaps = 1; 545 nmaps = 1;
569 quotip = XFS_DQ_TO_QIP(dqp); 546 quotip = XFS_DQ_TO_QIP(dqp);
570 xfs_ilock(quotip, XFS_ILOCK_SHARED); 547 xfs_ilock(quotip, XFS_ILOCK_SHARED);
@@ -694,16 +671,16 @@ xfs_qm_dqread(
694 671
695 /* copy everything from disk dquot to the incore dquot */ 672 /* copy everything from disk dquot to the incore dquot */
696 memcpy(&dqp->q_core, ddqp, sizeof(xfs_disk_dquot_t)); 673 memcpy(&dqp->q_core, ddqp, sizeof(xfs_disk_dquot_t));
697 ASSERT(INT_GET(dqp->q_core.d_id, ARCH_CONVERT) == id); 674 ASSERT(be32_to_cpu(dqp->q_core.d_id) == id);
698 xfs_qm_dquot_logitem_init(dqp); 675 xfs_qm_dquot_logitem_init(dqp);
699 676
700 /* 677 /*
701 * Reservation counters are defined as reservation plus current usage 678 * Reservation counters are defined as reservation plus current usage
702 * to avoid having to add everytime. 679 * to avoid having to add everytime.
703 */ 680 */
704 dqp->q_res_bcount = INT_GET(ddqp->d_bcount, ARCH_CONVERT); 681 dqp->q_res_bcount = be64_to_cpu(ddqp->d_bcount);
705 dqp->q_res_icount = INT_GET(ddqp->d_icount, ARCH_CONVERT); 682 dqp->q_res_icount = be64_to_cpu(ddqp->d_icount);
706 dqp->q_res_rtbcount = INT_GET(ddqp->d_rtbcount, ARCH_CONVERT); 683 dqp->q_res_rtbcount = be64_to_cpu(ddqp->d_rtbcount);
707 684
708 /* Mark the buf so that this will stay incore a little longer */ 685 /* Mark the buf so that this will stay incore a little longer */
709 XFS_BUF_SET_VTYPE_REF(bp, B_FS_DQUOT, XFS_DQUOT_REF); 686 XFS_BUF_SET_VTYPE_REF(bp, B_FS_DQUOT, XFS_DQUOT_REF);
@@ -829,7 +806,7 @@ xfs_qm_dqlookup(
829 * dqlock to look at the id field of the dquot, since the 806 * dqlock to look at the id field of the dquot, since the
830 * id can't be modified without the hashlock anyway. 807 * id can't be modified without the hashlock anyway.
831 */ 808 */
832 if (INT_GET(dqp->q_core.d_id, ARCH_CONVERT) == id && dqp->q_mount == mp) { 809 if (be32_to_cpu(dqp->q_core.d_id) == id && dqp->q_mount == mp) {
833 xfs_dqtrace_entry(dqp, "DQFOUND BY LOOKUP"); 810 xfs_dqtrace_entry(dqp, "DQFOUND BY LOOKUP");
834 /* 811 /*
835 * All in core dquots must be on the dqlist of mp 812 * All in core dquots must be on the dqlist of mp
@@ -860,7 +837,7 @@ xfs_qm_dqlookup(
860 * id couldn't have changed; we had the hashlock all 837 * id couldn't have changed; we had the hashlock all
861 * along 838 * along
862 */ 839 */
863 ASSERT(INT_GET(dqp->q_core.d_id, ARCH_CONVERT) == id); 840 ASSERT(be32_to_cpu(dqp->q_core.d_id) == id);
864 841
865 if (flist_locked) { 842 if (flist_locked) {
866 if (dqp->q_nrefs != 0) { 843 if (dqp->q_nrefs != 0) {
@@ -1282,7 +1259,7 @@ xfs_qm_dqflush(
1282 return (error); 1259 return (error);
1283 } 1260 }
1284 1261
1285 if (xfs_qm_dqcheck(&dqp->q_core, INT_GET(ddqp->d_id, ARCH_CONVERT), 1262 if (xfs_qm_dqcheck(&dqp->q_core, be32_to_cpu(ddqp->d_id),
1286 0, XFS_QMOPT_DOWARN, "dqflush (incore copy)")) { 1263 0, XFS_QMOPT_DOWARN, "dqflush (incore copy)")) {
1287 xfs_force_shutdown(dqp->q_mount, XFS_CORRUPT_INCORE); 1264 xfs_force_shutdown(dqp->q_mount, XFS_CORRUPT_INCORE);
1288 return XFS_ERROR(EIO); 1265 return XFS_ERROR(EIO);
@@ -1435,8 +1412,8 @@ xfs_dqlock2(
1435{ 1412{
1436 if (d1 && d2) { 1413 if (d1 && d2) {
1437 ASSERT(d1 != d2); 1414 ASSERT(d1 != d2);
1438 if (INT_GET(d1->q_core.d_id, ARCH_CONVERT) > 1415 if (be32_to_cpu(d1->q_core.d_id) >
1439 INT_GET(d2->q_core.d_id, ARCH_CONVERT)) { 1416 be32_to_cpu(d2->q_core.d_id)) {
1440 xfs_dqlock(d2); 1417 xfs_dqlock(d2);
1441 xfs_dqlock(d1); 1418 xfs_dqlock(d1);
1442 } else { 1419 } else {
@@ -1558,33 +1535,33 @@ xfs_qm_dqprint(xfs_dquot_t *dqp)
1558{ 1535{
1559 cmn_err(CE_DEBUG, "-----------KERNEL DQUOT----------------"); 1536 cmn_err(CE_DEBUG, "-----------KERNEL DQUOT----------------");
1560 cmn_err(CE_DEBUG, "---- dquotID = %d", 1537 cmn_err(CE_DEBUG, "---- dquotID = %d",
1561 (int)INT_GET(dqp->q_core.d_id, ARCH_CONVERT)); 1538 (int)be32_to_cpu(dqp->q_core.d_id));
1562 cmn_err(CE_DEBUG, "---- type = %s", DQFLAGTO_TYPESTR(dqp)); 1539 cmn_err(CE_DEBUG, "---- type = %s", DQFLAGTO_TYPESTR(dqp));
1563 cmn_err(CE_DEBUG, "---- fs = 0x%p", dqp->q_mount); 1540 cmn_err(CE_DEBUG, "---- fs = 0x%p", dqp->q_mount);
1564 cmn_err(CE_DEBUG, "---- blkno = 0x%x", (int) dqp->q_blkno); 1541 cmn_err(CE_DEBUG, "---- blkno = 0x%x", (int) dqp->q_blkno);
1565 cmn_err(CE_DEBUG, "---- boffset = 0x%x", (int) dqp->q_bufoffset); 1542 cmn_err(CE_DEBUG, "---- boffset = 0x%x", (int) dqp->q_bufoffset);
1566 cmn_err(CE_DEBUG, "---- blkhlimit = %Lu (0x%x)", 1543 cmn_err(CE_DEBUG, "---- blkhlimit = %Lu (0x%x)",
1567 INT_GET(dqp->q_core.d_blk_hardlimit, ARCH_CONVERT), 1544 be64_to_cpu(dqp->q_core.d_blk_hardlimit),
1568 (int) INT_GET(dqp->q_core.d_blk_hardlimit, ARCH_CONVERT)); 1545 (int)be64_to_cpu(dqp->q_core.d_blk_hardlimit));
1569 cmn_err(CE_DEBUG, "---- blkslimit = %Lu (0x%x)", 1546 cmn_err(CE_DEBUG, "---- blkslimit = %Lu (0x%x)",
1570 INT_GET(dqp->q_core.d_blk_softlimit, ARCH_CONVERT), 1547 be64_to_cpu(dqp->q_core.d_blk_softlimit),
1571 (int)INT_GET(dqp->q_core.d_blk_softlimit, ARCH_CONVERT)); 1548 (int)be64_to_cpu(dqp->q_core.d_blk_softlimit));
1572 cmn_err(CE_DEBUG, "---- inohlimit = %Lu (0x%x)", 1549 cmn_err(CE_DEBUG, "---- inohlimit = %Lu (0x%x)",
1573 INT_GET(dqp->q_core.d_ino_hardlimit, ARCH_CONVERT), 1550 be64_to_cpu(dqp->q_core.d_ino_hardlimit),
1574 (int)INT_GET(dqp->q_core.d_ino_hardlimit, ARCH_CONVERT)); 1551 (int)be64_to_cpu(dqp->q_core.d_ino_hardlimit));
1575 cmn_err(CE_DEBUG, "---- inoslimit = %Lu (0x%x)", 1552 cmn_err(CE_DEBUG, "---- inoslimit = %Lu (0x%x)",
1576 INT_GET(dqp->q_core.d_ino_softlimit, ARCH_CONVERT), 1553 be64_to_cpu(dqp->q_core.d_ino_softlimit),
1577 (int)INT_GET(dqp->q_core.d_ino_softlimit, ARCH_CONVERT)); 1554 (int)be64_to_cpu(dqp->q_core.d_ino_softlimit));
1578 cmn_err(CE_DEBUG, "---- bcount = %Lu (0x%x)", 1555 cmn_err(CE_DEBUG, "---- bcount = %Lu (0x%x)",
1579 INT_GET(dqp->q_core.d_bcount, ARCH_CONVERT), 1556 be64_to_cpu(dqp->q_core.d_bcount),
1580 (int)INT_GET(dqp->q_core.d_bcount, ARCH_CONVERT)); 1557 (int)be64_to_cpu(dqp->q_core.d_bcount));
1581 cmn_err(CE_DEBUG, "---- icount = %Lu (0x%x)", 1558 cmn_err(CE_DEBUG, "---- icount = %Lu (0x%x)",
1582 INT_GET(dqp->q_core.d_icount, ARCH_CONVERT), 1559 be64_to_cpu(dqp->q_core.d_icount),
1583 (int)INT_GET(dqp->q_core.d_icount, ARCH_CONVERT)); 1560 (int)be64_to_cpu(dqp->q_core.d_icount));
1584 cmn_err(CE_DEBUG, "---- btimer = %d", 1561 cmn_err(CE_DEBUG, "---- btimer = %d",
1585 (int)INT_GET(dqp->q_core.d_btimer, ARCH_CONVERT)); 1562 (int)be32_to_cpu(dqp->q_core.d_btimer));
1586 cmn_err(CE_DEBUG, "---- itimer = %d", 1563 cmn_err(CE_DEBUG, "---- itimer = %d",
1587 (int)INT_GET(dqp->q_core.d_itimer, ARCH_CONVERT)); 1564 (int)be32_to_cpu(dqp->q_core.d_itimer));
1588 cmn_err(CE_DEBUG, "---------------------------"); 1565 cmn_err(CE_DEBUG, "---------------------------");
1589} 1566}
1590#endif 1567#endif
diff --git a/fs/xfs/quota/xfs_dquot.h b/fs/xfs/quota/xfs_dquot.h
index 8ebc87176c78..c0c629663a5c 100644
--- a/fs/xfs/quota/xfs_dquot.h
+++ b/fs/xfs/quota/xfs_dquot.h
@@ -1,33 +1,19 @@
1/* 1/*
2 * Copyright (c) 2000-2005 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32#ifndef __XFS_DQUOT_H__ 18#ifndef __XFS_DQUOT_H__
33#define __XFS_DQUOT_H__ 19#define __XFS_DQUOT_H__
diff --git a/fs/xfs/quota/xfs_dquot_item.c b/fs/xfs/quota/xfs_dquot_item.c
index e74eaa7dd1bc..2f69822344e5 100644
--- a/fs/xfs/quota/xfs_dquot_item.c
+++ b/fs/xfs/quota/xfs_dquot_item.c
@@ -1,39 +1,25 @@
1/* 1/*
2 * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2003 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32
33#include "xfs.h" 18#include "xfs.h"
34#include "xfs_fs.h" 19#include "xfs_fs.h"
35#include "xfs_inum.h" 20#include "xfs_bit.h"
36#include "xfs_log.h" 21#include "xfs_log.h"
22#include "xfs_inum.h"
37#include "xfs_trans.h" 23#include "xfs_trans.h"
38#include "xfs_sb.h" 24#include "xfs_sb.h"
39#include "xfs_ag.h" 25#include "xfs_ag.h"
@@ -43,18 +29,17 @@
43#include "xfs_dmapi.h" 29#include "xfs_dmapi.h"
44#include "xfs_quota.h" 30#include "xfs_quota.h"
45#include "xfs_mount.h" 31#include "xfs_mount.h"
46#include "xfs_alloc_btree.h"
47#include "xfs_bmap_btree.h" 32#include "xfs_bmap_btree.h"
33#include "xfs_alloc_btree.h"
48#include "xfs_ialloc_btree.h" 34#include "xfs_ialloc_btree.h"
49#include "xfs_btree.h"
50#include "xfs_ialloc.h"
51#include "xfs_attr_sf.h"
52#include "xfs_dir_sf.h" 35#include "xfs_dir_sf.h"
53#include "xfs_dir2_sf.h" 36#include "xfs_dir2_sf.h"
37#include "xfs_attr_sf.h"
54#include "xfs_dinode.h" 38#include "xfs_dinode.h"
55#include "xfs_inode.h" 39#include "xfs_inode.h"
56#include "xfs_bmap.h" 40#include "xfs_bmap.h"
57#include "xfs_bit.h" 41#include "xfs_btree.h"
42#include "xfs_ialloc.h"
58#include "xfs_rtalloc.h" 43#include "xfs_rtalloc.h"
59#include "xfs_error.h" 44#include "xfs_error.h"
60#include "xfs_itable.h" 45#include "xfs_itable.h"
@@ -65,10 +50,8 @@
65#include "xfs_attr.h" 50#include "xfs_attr.h"
66#include "xfs_buf_item.h" 51#include "xfs_buf_item.h"
67#include "xfs_trans_priv.h" 52#include "xfs_trans_priv.h"
68
69#include "xfs_qm.h" 53#include "xfs_qm.h"
70 54
71
72/* 55/*
73 * returns the number of iovecs needed to log the given dquot item. 56 * returns the number of iovecs needed to log the given dquot item.
74 */ 57 */
@@ -467,7 +450,7 @@ xfs_qm_dquot_logitem_init(
467 lp->qli_item.li_mountp = dqp->q_mount; 450 lp->qli_item.li_mountp = dqp->q_mount;
468 lp->qli_dquot = dqp; 451 lp->qli_dquot = dqp;
469 lp->qli_format.qlf_type = XFS_LI_DQUOT; 452 lp->qli_format.qlf_type = XFS_LI_DQUOT;
470 lp->qli_format.qlf_id = INT_GET(dqp->q_core.d_id, ARCH_CONVERT); 453 lp->qli_format.qlf_id = be32_to_cpu(dqp->q_core.d_id);
471 lp->qli_format.qlf_blkno = dqp->q_blkno; 454 lp->qli_format.qlf_blkno = dqp->q_blkno;
472 lp->qli_format.qlf_len = 1; 455 lp->qli_format.qlf_len = 1;
473 /* 456 /*
diff --git a/fs/xfs/quota/xfs_dquot_item.h b/fs/xfs/quota/xfs_dquot_item.h
index 9c6500dabcaa..5a632531f843 100644
--- a/fs/xfs/quota/xfs_dquot_item.h
+++ b/fs/xfs/quota/xfs_dquot_item.h
@@ -1,33 +1,19 @@
1/* 1/*
2 * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2003 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32#ifndef __XFS_DQUOT_ITEM_H__ 18#ifndef __XFS_DQUOT_ITEM_H__
33#define __XFS_DQUOT_ITEM_H__ 19#define __XFS_DQUOT_ITEM_H__
diff --git a/fs/xfs/quota/xfs_qm.c b/fs/xfs/quota/xfs_qm.c
index efde16e0a913..1aea42d71a64 100644
--- a/fs/xfs/quota/xfs_qm.c
+++ b/fs/xfs/quota/xfs_qm.c
@@ -1,39 +1,25 @@
1/* 1/*
2 * Copyright (c) 2000-2005 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32
33#include "xfs.h" 18#include "xfs.h"
34#include "xfs_fs.h" 19#include "xfs_fs.h"
35#include "xfs_inum.h" 20#include "xfs_bit.h"
36#include "xfs_log.h" 21#include "xfs_log.h"
22#include "xfs_inum.h"
37#include "xfs_clnt.h" 23#include "xfs_clnt.h"
38#include "xfs_trans.h" 24#include "xfs_trans.h"
39#include "xfs_sb.h" 25#include "xfs_sb.h"
@@ -44,21 +30,20 @@
44#include "xfs_dmapi.h" 30#include "xfs_dmapi.h"
45#include "xfs_quota.h" 31#include "xfs_quota.h"
46#include "xfs_mount.h" 32#include "xfs_mount.h"
47#include "xfs_alloc_btree.h"
48#include "xfs_bmap_btree.h" 33#include "xfs_bmap_btree.h"
34#include "xfs_alloc_btree.h"
49#include "xfs_ialloc_btree.h" 35#include "xfs_ialloc_btree.h"
50#include "xfs_btree.h"
51#include "xfs_ialloc.h"
52#include "xfs_attr_sf.h"
53#include "xfs_dir_sf.h" 36#include "xfs_dir_sf.h"
54#include "xfs_dir2_sf.h" 37#include "xfs_dir2_sf.h"
38#include "xfs_attr_sf.h"
55#include "xfs_dinode.h" 39#include "xfs_dinode.h"
56#include "xfs_inode.h" 40#include "xfs_inode.h"
57#include "xfs_bmap.h" 41#include "xfs_btree.h"
58#include "xfs_bit.h" 42#include "xfs_ialloc.h"
43#include "xfs_itable.h"
59#include "xfs_rtalloc.h" 44#include "xfs_rtalloc.h"
60#include "xfs_error.h" 45#include "xfs_error.h"
61#include "xfs_itable.h" 46#include "xfs_bmap.h"
62#include "xfs_rw.h" 47#include "xfs_rw.h"
63#include "xfs_acl.h" 48#include "xfs_acl.h"
64#include "xfs_cap.h" 49#include "xfs_cap.h"
@@ -67,7 +52,6 @@
67#include "xfs_buf_item.h" 52#include "xfs_buf_item.h"
68#include "xfs_trans_space.h" 53#include "xfs_trans_space.h"
69#include "xfs_utils.h" 54#include "xfs_utils.h"
70
71#include "xfs_qm.h" 55#include "xfs_qm.h"
72 56
73/* 57/*
@@ -76,8 +60,9 @@
76 * quota functionality, including maintaining the freelist and hash 60 * quota functionality, including maintaining the freelist and hash
77 * tables of dquots. 61 * tables of dquots.
78 */ 62 */
79mutex_t xfs_Gqm_lock; 63mutex_t xfs_Gqm_lock;
80struct xfs_qm *xfs_Gqm; 64struct xfs_qm *xfs_Gqm;
65uint ndquot;
81 66
82kmem_zone_t *qm_dqzone; 67kmem_zone_t *qm_dqzone;
83kmem_zone_t *qm_dqtrxzone; 68kmem_zone_t *qm_dqtrxzone;
@@ -107,10 +92,10 @@ extern mutex_t qcheck_lock;
107 for (dqp = (l)->qh_next; dqp != NULL; dqp = dqp->NXT) { \ 92 for (dqp = (l)->qh_next; dqp != NULL; dqp = dqp->NXT) { \
108 cmn_err(CE_DEBUG, " %d. \"%d (%s)\" " \ 93 cmn_err(CE_DEBUG, " %d. \"%d (%s)\" " \
109 "bcnt = %d, icnt = %d, refs = %d", \ 94 "bcnt = %d, icnt = %d, refs = %d", \
110 ++i, (int) INT_GET(dqp->q_core.d_id, ARCH_CONVERT), \ 95 ++i, (int) be32_to_cpu(dqp->q_core.d_id), \
111 DQFLAGTO_TYPESTR(dqp), \ 96 DQFLAGTO_TYPESTR(dqp), \
112 (int) INT_GET(dqp->q_core.d_bcount, ARCH_CONVERT), \ 97 (int) be64_to_cpu(dqp->q_core.d_bcount), \
113 (int) INT_GET(dqp->q_core.d_icount, ARCH_CONVERT), \ 98 (int) be64_to_cpu(dqp->q_core.d_icount), \
114 (int) dqp->q_nrefs); } \ 99 (int) dqp->q_nrefs); } \
115} 100}
116#else 101#else
@@ -124,25 +109,25 @@ extern mutex_t qcheck_lock;
124STATIC struct xfs_qm * 109STATIC struct xfs_qm *
125xfs_Gqm_init(void) 110xfs_Gqm_init(void)
126{ 111{
127 xfs_qm_t *xqm; 112 xfs_dqhash_t *udqhash, *gdqhash;
128 int hsize, i; 113 xfs_qm_t *xqm;
129 114 uint i, hsize, flags = KM_SLEEP | KM_MAYFAIL;
130 xqm = kmem_zalloc(sizeof(xfs_qm_t), KM_SLEEP);
131 ASSERT(xqm);
132 115
133 /* 116 /*
134 * Initialize the dquot hash tables. 117 * Initialize the dquot hash tables.
135 */ 118 */
136 hsize = (DQUOT_HASH_HEURISTIC < XFS_QM_NCSIZE_THRESHOLD) ? 119 hsize = XFS_QM_HASHSIZE_HIGH;
137 XFS_QM_HASHSIZE_LOW : XFS_QM_HASHSIZE_HIGH; 120 while (!(udqhash = kmem_zalloc(hsize * sizeof(xfs_dqhash_t), flags))) {
138 xqm->qm_dqhashmask = hsize - 1; 121 if ((hsize >>= 1) <= XFS_QM_HASHSIZE_LOW)
122 flags = KM_SLEEP;
123 }
124 gdqhash = kmem_zalloc(hsize * sizeof(xfs_dqhash_t), KM_SLEEP);
125 ndquot = hsize << 8;
139 126
140 xqm->qm_usr_dqhtable = (xfs_dqhash_t *)kmem_zalloc(hsize * 127 xqm = kmem_zalloc(sizeof(xfs_qm_t), KM_SLEEP);
141 sizeof(xfs_dqhash_t), 128 xqm->qm_dqhashmask = hsize - 1;
142 KM_SLEEP); 129 xqm->qm_usr_dqhtable = udqhash;
143 xqm->qm_grp_dqhtable = (xfs_dqhash_t *)kmem_zalloc(hsize * 130 xqm->qm_grp_dqhtable = gdqhash;
144 sizeof(xfs_dqhash_t),
145 KM_SLEEP);
146 ASSERT(xqm->qm_usr_dqhtable != NULL); 131 ASSERT(xqm->qm_usr_dqhtable != NULL);
147 ASSERT(xqm->qm_grp_dqhtable != NULL); 132 ASSERT(xqm->qm_grp_dqhtable != NULL);
148 133
@@ -743,7 +728,7 @@ xfs_qm_dqattach_one(
743 */ 728 */
744 if (udqhint && 729 if (udqhint &&
745 (dqp = udqhint->q_gdquot) && 730 (dqp = udqhint->q_gdquot) &&
746 (INT_GET(dqp->q_core.d_id, ARCH_CONVERT) == id)) { 731 (be32_to_cpu(dqp->q_core.d_id) == id)) {
747 ASSERT(XFS_DQ_IS_LOCKED(udqhint)); 732 ASSERT(XFS_DQ_IS_LOCKED(udqhint));
748 xfs_dqlock(dqp); 733 xfs_dqlock(dqp);
749 XFS_DQHOLD(dqp); 734 XFS_DQHOLD(dqp);
@@ -1213,42 +1198,24 @@ xfs_qm_init_quotainfo(
1213 * a user or group before he or she can not perform any 1198 * a user or group before he or she can not perform any
1214 * more writing. If it is zero, a default is used. 1199 * more writing. If it is zero, a default is used.
1215 */ 1200 */
1216 qinf->qi_btimelimit = 1201 qinf->qi_btimelimit = ddqp->d_btimer ?
1217 INT_GET(ddqp->d_btimer, ARCH_CONVERT) ? 1202 be32_to_cpu(ddqp->d_btimer) : XFS_QM_BTIMELIMIT;
1218 INT_GET(ddqp->d_btimer, ARCH_CONVERT) : 1203 qinf->qi_itimelimit = ddqp->d_itimer ?
1219 XFS_QM_BTIMELIMIT; 1204 be32_to_cpu(ddqp->d_itimer) : XFS_QM_ITIMELIMIT;
1220 qinf->qi_itimelimit = 1205 qinf->qi_rtbtimelimit = ddqp->d_rtbtimer ?
1221 INT_GET(ddqp->d_itimer, ARCH_CONVERT) ? 1206 be32_to_cpu(ddqp->d_rtbtimer) : XFS_QM_RTBTIMELIMIT;
1222 INT_GET(ddqp->d_itimer, ARCH_CONVERT) : 1207 qinf->qi_bwarnlimit = ddqp->d_bwarns ?
1223 XFS_QM_ITIMELIMIT; 1208 be16_to_cpu(ddqp->d_bwarns) : XFS_QM_BWARNLIMIT;
1224 qinf->qi_rtbtimelimit = 1209 qinf->qi_iwarnlimit = ddqp->d_iwarns ?
1225 INT_GET(ddqp->d_rtbtimer, ARCH_CONVERT) ? 1210 be16_to_cpu(ddqp->d_iwarns) : XFS_QM_IWARNLIMIT;
1226 INT_GET(ddqp->d_rtbtimer, ARCH_CONVERT) : 1211 qinf->qi_rtbwarnlimit = ddqp->d_rtbwarns ?
1227 XFS_QM_RTBTIMELIMIT; 1212 be16_to_cpu(ddqp->d_rtbwarns) : XFS_QM_RTBWARNLIMIT;
1228 qinf->qi_bwarnlimit = 1213 qinf->qi_bhardlimit = be64_to_cpu(ddqp->d_blk_hardlimit);
1229 INT_GET(ddqp->d_bwarns, ARCH_CONVERT) ? 1214 qinf->qi_bsoftlimit = be64_to_cpu(ddqp->d_blk_softlimit);
1230 INT_GET(ddqp->d_bwarns, ARCH_CONVERT) : 1215 qinf->qi_ihardlimit = be64_to_cpu(ddqp->d_ino_hardlimit);
1231 XFS_QM_BWARNLIMIT; 1216 qinf->qi_isoftlimit = be64_to_cpu(ddqp->d_ino_softlimit);
1232 qinf->qi_iwarnlimit = 1217 qinf->qi_rtbhardlimit = be64_to_cpu(ddqp->d_rtb_hardlimit);
1233 INT_GET(ddqp->d_iwarns, ARCH_CONVERT) ? 1218 qinf->qi_rtbsoftlimit = be64_to_cpu(ddqp->d_rtb_softlimit);
1234 INT_GET(ddqp->d_iwarns, ARCH_CONVERT) :
1235 XFS_QM_IWARNLIMIT;
1236 qinf->qi_rtbwarnlimit =
1237 INT_GET(ddqp->d_rtbwarns, ARCH_CONVERT) ?
1238 INT_GET(ddqp->d_rtbwarns, ARCH_CONVERT) :
1239 XFS_QM_RTBWARNLIMIT;
1240 qinf->qi_bhardlimit =
1241 INT_GET(ddqp->d_blk_hardlimit, ARCH_CONVERT);
1242 qinf->qi_bsoftlimit =
1243 INT_GET(ddqp->d_blk_softlimit, ARCH_CONVERT);
1244 qinf->qi_ihardlimit =
1245 INT_GET(ddqp->d_ino_hardlimit, ARCH_CONVERT);
1246 qinf->qi_isoftlimit =
1247 INT_GET(ddqp->d_ino_softlimit, ARCH_CONVERT);
1248 qinf->qi_rtbhardlimit =
1249 INT_GET(ddqp->d_rtb_hardlimit, ARCH_CONVERT);
1250 qinf->qi_rtbsoftlimit =
1251 INT_GET(ddqp->d_rtb_softlimit, ARCH_CONVERT);
1252 1219
1253 /* 1220 /*
1254 * We sent the XFS_QMOPT_DQSUSER flag to dqget because 1221 * We sent the XFS_QMOPT_DQSUSER flag to dqget because
@@ -1527,15 +1494,15 @@ xfs_qm_reset_dqcounts(
1527 */ 1494 */
1528 (void) xfs_qm_dqcheck(ddq, id+j, type, XFS_QMOPT_DQREPAIR, 1495 (void) xfs_qm_dqcheck(ddq, id+j, type, XFS_QMOPT_DQREPAIR,
1529 "xfs_quotacheck"); 1496 "xfs_quotacheck");
1530 INT_SET(ddq->d_bcount, ARCH_CONVERT, 0ULL); 1497 ddq->d_bcount = 0;
1531 INT_SET(ddq->d_icount, ARCH_CONVERT, 0ULL); 1498 ddq->d_icount = 0;
1532 INT_SET(ddq->d_rtbcount, ARCH_CONVERT, 0ULL); 1499 ddq->d_rtbcount = 0;
1533 INT_SET(ddq->d_btimer, ARCH_CONVERT, (time_t)0); 1500 ddq->d_btimer = 0;
1534 INT_SET(ddq->d_itimer, ARCH_CONVERT, (time_t)0); 1501 ddq->d_itimer = 0;
1535 INT_SET(ddq->d_rtbtimer, ARCH_CONVERT, (time_t)0); 1502 ddq->d_rtbtimer = 0;
1536 INT_SET(ddq->d_bwarns, ARCH_CONVERT, 0UL); 1503 ddq->d_bwarns = 0;
1537 INT_SET(ddq->d_iwarns, ARCH_CONVERT, 0UL); 1504 ddq->d_iwarns = 0;
1538 INT_SET(ddq->d_rtbwarns, ARCH_CONVERT, 0UL); 1505 ddq->d_rtbwarns = 0;
1539 ddq = (xfs_disk_dquot_t *) ((xfs_dqblk_t *)ddq + 1); 1506 ddq = (xfs_disk_dquot_t *) ((xfs_dqblk_t *)ddq + 1);
1540 } 1507 }
1541 1508
@@ -1708,14 +1675,14 @@ xfs_qm_quotacheck_dqadjust(
1708 * Adjust the inode count and the block count to reflect this inode's 1675 * Adjust the inode count and the block count to reflect this inode's
1709 * resource usage. 1676 * resource usage.
1710 */ 1677 */
1711 INT_MOD(dqp->q_core.d_icount, ARCH_CONVERT, +1); 1678 be64_add(&dqp->q_core.d_icount, 1);
1712 dqp->q_res_icount++; 1679 dqp->q_res_icount++;
1713 if (nblks) { 1680 if (nblks) {
1714 INT_MOD(dqp->q_core.d_bcount, ARCH_CONVERT, nblks); 1681 be64_add(&dqp->q_core.d_bcount, nblks);
1715 dqp->q_res_bcount += nblks; 1682 dqp->q_res_bcount += nblks;
1716 } 1683 }
1717 if (rtblks) { 1684 if (rtblks) {
1718 INT_MOD(dqp->q_core.d_rtbcount, ARCH_CONVERT, rtblks); 1685 be64_add(&dqp->q_core.d_rtbcount, rtblks);
1719 dqp->q_res_rtbcount += rtblks; 1686 dqp->q_res_rtbcount += rtblks;
1720 } 1687 }
1721 1688
@@ -2202,7 +2169,7 @@ xfs_qm_shake_freelist(
2202 xfs_dqtrace_entry(dqp, "DQSHAKE: UNLINKING"); 2169 xfs_dqtrace_entry(dqp, "DQSHAKE: UNLINKING");
2203#ifdef QUOTADEBUG 2170#ifdef QUOTADEBUG
2204 cmn_err(CE_DEBUG, "Shake 0x%p, ID 0x%x\n", 2171 cmn_err(CE_DEBUG, "Shake 0x%p, ID 0x%x\n",
2205 dqp, INT_GET(dqp->q_core.d_id, ARCH_CONVERT)); 2172 dqp, be32_to_cpu(dqp->q_core.d_id));
2206#endif 2173#endif
2207 ASSERT(dqp->q_nrefs == 0); 2174 ASSERT(dqp->q_nrefs == 0);
2208 nextdqp = dqp->dq_flnext; 2175 nextdqp = dqp->dq_flnext;
@@ -2670,7 +2637,7 @@ xfs_qm_vop_chown_reserve(
2670 XFS_QMOPT_RES_RTBLKS : XFS_QMOPT_RES_REGBLKS; 2637 XFS_QMOPT_RES_RTBLKS : XFS_QMOPT_RES_REGBLKS;
2671 2638
2672 if (XFS_IS_UQUOTA_ON(mp) && udqp && 2639 if (XFS_IS_UQUOTA_ON(mp) && udqp &&
2673 ip->i_d.di_uid != (uid_t)INT_GET(udqp->q_core.d_id, ARCH_CONVERT)) { 2640 ip->i_d.di_uid != (uid_t)be32_to_cpu(udqp->q_core.d_id)) {
2674 delblksudq = udqp; 2641 delblksudq = udqp;
2675 /* 2642 /*
2676 * If there are delayed allocation blocks, then we have to 2643 * If there are delayed allocation blocks, then we have to
@@ -2683,10 +2650,10 @@ xfs_qm_vop_chown_reserve(
2683 } 2650 }
2684 } 2651 }
2685 if (XFS_IS_OQUOTA_ON(ip->i_mount) && gdqp) { 2652 if (XFS_IS_OQUOTA_ON(ip->i_mount) && gdqp) {
2686 if ((XFS_IS_GQUOTA_ON(ip->i_mount) && ip->i_d.di_gid != 2653 if ((XFS_IS_GQUOTA_ON(ip->i_mount) &&
2687 INT_GET(gdqp->q_core.d_id, ARCH_CONVERT)) || 2654 ip->i_d.di_gid != be32_to_cpu(gdqp->q_core.d_id)) ||
2688 (XFS_IS_PQUOTA_ON(ip->i_mount) && ip->i_d.di_projid != 2655 (XFS_IS_PQUOTA_ON(ip->i_mount) &&
2689 INT_GET(gdqp->q_core.d_id, ARCH_CONVERT))) { 2656 ip->i_d.di_projid != be32_to_cpu(gdqp->q_core.d_id))) {
2690 delblksgdq = gdqp; 2657 delblksgdq = gdqp;
2691 if (delblks) { 2658 if (delblks) {
2692 ASSERT(ip->i_gdquot); 2659 ASSERT(ip->i_gdquot);
@@ -2776,7 +2743,7 @@ xfs_qm_vop_dqattach_and_dqmod_newinode(
2776 xfs_dqunlock(udqp); 2743 xfs_dqunlock(udqp);
2777 ASSERT(ip->i_udquot == NULL); 2744 ASSERT(ip->i_udquot == NULL);
2778 ip->i_udquot = udqp; 2745 ip->i_udquot = udqp;
2779 ASSERT(ip->i_d.di_uid == INT_GET(udqp->q_core.d_id, ARCH_CONVERT)); 2746 ASSERT(ip->i_d.di_uid == be32_to_cpu(udqp->q_core.d_id));
2780 xfs_trans_mod_dquot(tp, udqp, XFS_TRANS_DQ_ICOUNT, 1); 2747 xfs_trans_mod_dquot(tp, udqp, XFS_TRANS_DQ_ICOUNT, 1);
2781 } 2748 }
2782 if (gdqp) { 2749 if (gdqp) {
@@ -2785,7 +2752,7 @@ xfs_qm_vop_dqattach_and_dqmod_newinode(
2785 xfs_dqunlock(gdqp); 2752 xfs_dqunlock(gdqp);
2786 ASSERT(ip->i_gdquot == NULL); 2753 ASSERT(ip->i_gdquot == NULL);
2787 ip->i_gdquot = gdqp; 2754 ip->i_gdquot = gdqp;
2788 ASSERT(ip->i_d.di_gid == INT_GET(gdqp->q_core.d_id, ARCH_CONVERT)); 2755 ASSERT(ip->i_d.di_gid == be32_to_cpu(gdqp->q_core.d_id));
2789 xfs_trans_mod_dquot(tp, gdqp, XFS_TRANS_DQ_ICOUNT, 1); 2756 xfs_trans_mod_dquot(tp, gdqp, XFS_TRANS_DQ_ICOUNT, 1);
2790 } 2757 }
2791} 2758}
diff --git a/fs/xfs/quota/xfs_qm.h b/fs/xfs/quota/xfs_qm.h
index 0b00b3c67015..12da259f2fcb 100644
--- a/fs/xfs/quota/xfs_qm.h
+++ b/fs/xfs/quota/xfs_qm.h
@@ -1,33 +1,19 @@
1/* 1/*
2 * Copyright (c) 2000-2005 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32#ifndef __XFS_QM_H__ 18#ifndef __XFS_QM_H__
33#define __XFS_QM_H__ 19#define __XFS_QM_H__
@@ -40,6 +26,7 @@
40struct xfs_qm; 26struct xfs_qm;
41struct xfs_inode; 27struct xfs_inode;
42 28
29extern uint ndquot;
43extern mutex_t xfs_Gqm_lock; 30extern mutex_t xfs_Gqm_lock;
44extern struct xfs_qm *xfs_Gqm; 31extern struct xfs_qm *xfs_Gqm;
45extern kmem_zone_t *qm_dqzone; 32extern kmem_zone_t *qm_dqzone;
@@ -65,9 +52,8 @@ extern kmem_zone_t *qm_dqtrxzone;
65/* 52/*
66 * Dquot hashtable constants/threshold values. 53 * Dquot hashtable constants/threshold values.
67 */ 54 */
68#define XFS_QM_NCSIZE_THRESHOLD 5000 55#define XFS_QM_HASHSIZE_LOW (NBPP / sizeof(xfs_dqhash_t))
69#define XFS_QM_HASHSIZE_LOW 32 56#define XFS_QM_HASHSIZE_HIGH ((NBPP * 4) / sizeof(xfs_dqhash_t))
70#define XFS_QM_HASHSIZE_HIGH 64
71 57
72/* 58/*
73 * We output a cmn_err when quotachecking a quota file with more than 59 * We output a cmn_err when quotachecking a quota file with more than
diff --git a/fs/xfs/quota/xfs_qm_bhv.c b/fs/xfs/quota/xfs_qm_bhv.c
index 8890a18a99d8..d9d2993de435 100644
--- a/fs/xfs/quota/xfs_qm_bhv.c
+++ b/fs/xfs/quota/xfs_qm_bhv.c
@@ -1,70 +1,55 @@
1/* 1/*
2 * Copyright (c) 2000-2005 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32
33#include "xfs.h" 18#include "xfs.h"
34#include "xfs_fs.h" 19#include "xfs_fs.h"
35#include "xfs_inum.h" 20#include "xfs_bit.h"
36#include "xfs_log.h" 21#include "xfs_log.h"
22#include "xfs_inum.h"
37#include "xfs_clnt.h" 23#include "xfs_clnt.h"
38#include "xfs_trans.h" 24#include "xfs_trans.h"
39#include "xfs_sb.h" 25#include "xfs_sb.h"
26#include "xfs_ag.h"
40#include "xfs_dir.h" 27#include "xfs_dir.h"
41#include "xfs_dir2.h" 28#include "xfs_dir2.h"
42#include "xfs_alloc.h" 29#include "xfs_alloc.h"
43#include "xfs_dmapi.h" 30#include "xfs_dmapi.h"
44#include "xfs_quota.h" 31#include "xfs_quota.h"
45#include "xfs_mount.h" 32#include "xfs_mount.h"
46#include "xfs_alloc_btree.h"
47#include "xfs_bmap_btree.h" 33#include "xfs_bmap_btree.h"
34#include "xfs_alloc_btree.h"
48#include "xfs_ialloc_btree.h" 35#include "xfs_ialloc_btree.h"
49#include "xfs_btree.h"
50#include "xfs_ialloc.h"
51#include "xfs_attr_sf.h"
52#include "xfs_dir_sf.h" 36#include "xfs_dir_sf.h"
53#include "xfs_dir2_sf.h" 37#include "xfs_dir2_sf.h"
38#include "xfs_attr_sf.h"
54#include "xfs_dinode.h" 39#include "xfs_dinode.h"
55#include "xfs_inode.h" 40#include "xfs_inode.h"
41#include "xfs_ialloc.h"
42#include "xfs_itable.h"
43#include "xfs_btree.h"
56#include "xfs_bmap.h" 44#include "xfs_bmap.h"
57#include "xfs_bit.h"
58#include "xfs_rtalloc.h" 45#include "xfs_rtalloc.h"
59#include "xfs_error.h" 46#include "xfs_error.h"
60#include "xfs_itable.h"
61#include "xfs_rw.h" 47#include "xfs_rw.h"
62#include "xfs_acl.h" 48#include "xfs_acl.h"
63#include "xfs_cap.h" 49#include "xfs_cap.h"
64#include "xfs_mac.h" 50#include "xfs_mac.h"
65#include "xfs_attr.h" 51#include "xfs_attr.h"
66#include "xfs_buf_item.h" 52#include "xfs_buf_item.h"
67
68#include "xfs_qm.h" 53#include "xfs_qm.h"
69 54
70#define MNTOPT_QUOTA "quota" /* disk quotas (user) */ 55#define MNTOPT_QUOTA "quota" /* disk quotas (user) */
diff --git a/fs/xfs/quota/xfs_qm_stats.c b/fs/xfs/quota/xfs_qm_stats.c
index 29978e037fee..0570f7733550 100644
--- a/fs/xfs/quota/xfs_qm_stats.c
+++ b/fs/xfs/quota/xfs_qm_stats.c
@@ -1,69 +1,54 @@
1/* 1/*
2 * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2003 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32
33#include "xfs.h" 18#include "xfs.h"
34#include "xfs_fs.h" 19#include "xfs_fs.h"
35#include "xfs_inum.h" 20#include "xfs_bit.h"
36#include "xfs_log.h" 21#include "xfs_log.h"
22#include "xfs_inum.h"
37#include "xfs_trans.h" 23#include "xfs_trans.h"
38#include "xfs_sb.h" 24#include "xfs_sb.h"
25#include "xfs_ag.h"
39#include "xfs_dir.h" 26#include "xfs_dir.h"
40#include "xfs_dir2.h" 27#include "xfs_dir2.h"
41#include "xfs_alloc.h" 28#include "xfs_alloc.h"
42#include "xfs_dmapi.h" 29#include "xfs_dmapi.h"
43#include "xfs_quota.h" 30#include "xfs_quota.h"
44#include "xfs_mount.h" 31#include "xfs_mount.h"
45#include "xfs_alloc_btree.h"
46#include "xfs_bmap_btree.h" 32#include "xfs_bmap_btree.h"
33#include "xfs_alloc_btree.h"
47#include "xfs_ialloc_btree.h" 34#include "xfs_ialloc_btree.h"
48#include "xfs_btree.h"
49#include "xfs_ialloc.h"
50#include "xfs_attr_sf.h"
51#include "xfs_dir_sf.h" 35#include "xfs_dir_sf.h"
52#include "xfs_dir2_sf.h" 36#include "xfs_dir2_sf.h"
37#include "xfs_attr_sf.h"
53#include "xfs_dinode.h" 38#include "xfs_dinode.h"
54#include "xfs_inode.h" 39#include "xfs_inode.h"
40#include "xfs_ialloc.h"
41#include "xfs_itable.h"
55#include "xfs_bmap.h" 42#include "xfs_bmap.h"
56#include "xfs_bit.h" 43#include "xfs_btree.h"
57#include "xfs_rtalloc.h" 44#include "xfs_rtalloc.h"
58#include "xfs_error.h" 45#include "xfs_error.h"
59#include "xfs_itable.h"
60#include "xfs_rw.h" 46#include "xfs_rw.h"
61#include "xfs_acl.h" 47#include "xfs_acl.h"
62#include "xfs_cap.h" 48#include "xfs_cap.h"
63#include "xfs_mac.h" 49#include "xfs_mac.h"
64#include "xfs_attr.h" 50#include "xfs_attr.h"
65#include "xfs_buf_item.h" 51#include "xfs_buf_item.h"
66
67#include "xfs_qm.h" 52#include "xfs_qm.h"
68 53
69struct xqmstats xqmstats; 54struct xqmstats xqmstats;
diff --git a/fs/xfs/quota/xfs_qm_stats.h b/fs/xfs/quota/xfs_qm_stats.h
index 8093c5c284ec..a50ffabcf554 100644
--- a/fs/xfs/quota/xfs_qm_stats.h
+++ b/fs/xfs/quota/xfs_qm_stats.h
@@ -1,38 +1,23 @@
1/* 1/*
2 * Copyright (c) 2002 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2002 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32#ifndef __XFS_QM_STATS_H__ 18#ifndef __XFS_QM_STATS_H__
33#define __XFS_QM_STATS_H__ 19#define __XFS_QM_STATS_H__
34 20
35
36#if defined(CONFIG_PROC_FS) && !defined(XFS_STATS_OFF) 21#if defined(CONFIG_PROC_FS) && !defined(XFS_STATS_OFF)
37 22
38/* 23/*
diff --git a/fs/xfs/quota/xfs_qm_syscalls.c b/fs/xfs/quota/xfs_qm_syscalls.c
index 15e02e8a9d4f..24690e1af659 100644
--- a/fs/xfs/quota/xfs_qm_syscalls.c
+++ b/fs/xfs/quota/xfs_qm_syscalls.c
@@ -1,62 +1,48 @@
1/* 1/*
2 * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32
33#include "xfs.h" 18#include "xfs.h"
34#include "xfs_fs.h" 19#include "xfs_fs.h"
35#include "xfs_inum.h" 20#include "xfs_bit.h"
36#include "xfs_log.h" 21#include "xfs_log.h"
22#include "xfs_inum.h"
37#include "xfs_trans.h" 23#include "xfs_trans.h"
38#include "xfs_sb.h" 24#include "xfs_sb.h"
25#include "xfs_ag.h"
39#include "xfs_dir.h" 26#include "xfs_dir.h"
40#include "xfs_dir2.h" 27#include "xfs_dir2.h"
41#include "xfs_alloc.h" 28#include "xfs_alloc.h"
42#include "xfs_dmapi.h" 29#include "xfs_dmapi.h"
43#include "xfs_quota.h" 30#include "xfs_quota.h"
44#include "xfs_mount.h" 31#include "xfs_mount.h"
45#include "xfs_alloc_btree.h"
46#include "xfs_bmap_btree.h" 32#include "xfs_bmap_btree.h"
33#include "xfs_alloc_btree.h"
47#include "xfs_ialloc_btree.h" 34#include "xfs_ialloc_btree.h"
48#include "xfs_btree.h"
49#include "xfs_ialloc.h"
50#include "xfs_attr_sf.h"
51#include "xfs_dir_sf.h" 35#include "xfs_dir_sf.h"
52#include "xfs_dir2_sf.h" 36#include "xfs_dir2_sf.h"
37#include "xfs_attr_sf.h"
53#include "xfs_dinode.h" 38#include "xfs_dinode.h"
54#include "xfs_inode.h" 39#include "xfs_inode.h"
40#include "xfs_ialloc.h"
41#include "xfs_itable.h"
55#include "xfs_bmap.h" 42#include "xfs_bmap.h"
56#include "xfs_bit.h" 43#include "xfs_btree.h"
57#include "xfs_rtalloc.h" 44#include "xfs_rtalloc.h"
58#include "xfs_error.h" 45#include "xfs_error.h"
59#include "xfs_itable.h"
60#include "xfs_rw.h" 46#include "xfs_rw.h"
61#include "xfs_acl.h" 47#include "xfs_acl.h"
62#include "xfs_cap.h" 48#include "xfs_cap.h"
@@ -64,7 +50,6 @@
64#include "xfs_attr.h" 50#include "xfs_attr.h"
65#include "xfs_buf_item.h" 51#include "xfs_buf_item.h"
66#include "xfs_utils.h" 52#include "xfs_utils.h"
67
68#include "xfs_qm.h" 53#include "xfs_qm.h"
69 54
70#ifdef DEBUG 55#ifdef DEBUG
@@ -109,10 +94,7 @@ xfs_qm_quotactl(
109 vfsp = bhvtovfs(bdp); 94 vfsp = bhvtovfs(bdp);
110 mp = XFS_VFSTOM(vfsp); 95 mp = XFS_VFSTOM(vfsp);
111 96
112 if (addr == NULL && cmd != Q_SYNC) 97 ASSERT(addr != NULL || cmd == Q_XQUOTASYNC);
113 return XFS_ERROR(EINVAL);
114 if (id < 0 && cmd != Q_SYNC)
115 return XFS_ERROR(EINVAL);
116 98
117 /* 99 /*
118 * The following commands are valid even when quotaoff. 100 * The following commands are valid even when quotaoff.
@@ -122,7 +104,7 @@ xfs_qm_quotactl(
122 /* 104 /*
123 * Truncate quota files. quota must be off. 105 * Truncate quota files. quota must be off.
124 */ 106 */
125 if (XFS_IS_QUOTA_ON(mp) || addr == NULL) 107 if (XFS_IS_QUOTA_ON(mp))
126 return XFS_ERROR(EINVAL); 108 return XFS_ERROR(EINVAL);
127 if (vfsp->vfs_flag & VFS_RDONLY) 109 if (vfsp->vfs_flag & VFS_RDONLY)
128 return XFS_ERROR(EROFS); 110 return XFS_ERROR(EROFS);
@@ -140,8 +122,6 @@ xfs_qm_quotactl(
140 * QUOTAON - enabling quota enforcement. 122 * QUOTAON - enabling quota enforcement.
141 * Quota accounting must be turned on at mount time. 123 * Quota accounting must be turned on at mount time.
142 */ 124 */
143 if (addr == NULL)
144 return XFS_ERROR(EINVAL);
145 if (vfsp->vfs_flag & VFS_RDONLY) 125 if (vfsp->vfs_flag & VFS_RDONLY)
146 return XFS_ERROR(EROFS); 126 return XFS_ERROR(EROFS);
147 return (xfs_qm_scall_quotaon(mp, 127 return (xfs_qm_scall_quotaon(mp,
@@ -152,6 +132,9 @@ xfs_qm_quotactl(
152 return XFS_ERROR(EROFS); 132 return XFS_ERROR(EROFS);
153 break; 133 break;
154 134
135 case Q_XQUOTASYNC:
136 return (xfs_sync_inodes(mp, SYNC_DELWRI, 0, NULL));
137
155 default: 138 default:
156 break; 139 break;
157 } 140 }
@@ -655,13 +638,13 @@ xfs_qm_scall_setqlim(
655 */ 638 */
656 hard = (newlim->d_fieldmask & FS_DQ_BHARD) ? 639 hard = (newlim->d_fieldmask & FS_DQ_BHARD) ?
657 (xfs_qcnt_t) XFS_BB_TO_FSB(mp, newlim->d_blk_hardlimit) : 640 (xfs_qcnt_t) XFS_BB_TO_FSB(mp, newlim->d_blk_hardlimit) :
658 INT_GET(ddq->d_blk_hardlimit, ARCH_CONVERT); 641 be64_to_cpu(ddq->d_blk_hardlimit);
659 soft = (newlim->d_fieldmask & FS_DQ_BSOFT) ? 642 soft = (newlim->d_fieldmask & FS_DQ_BSOFT) ?
660 (xfs_qcnt_t) XFS_BB_TO_FSB(mp, newlim->d_blk_softlimit) : 643 (xfs_qcnt_t) XFS_BB_TO_FSB(mp, newlim->d_blk_softlimit) :
661 INT_GET(ddq->d_blk_softlimit, ARCH_CONVERT); 644 be64_to_cpu(ddq->d_blk_softlimit);
662 if (hard == 0 || hard >= soft) { 645 if (hard == 0 || hard >= soft) {
663 INT_SET(ddq->d_blk_hardlimit, ARCH_CONVERT, hard); 646 ddq->d_blk_hardlimit = cpu_to_be64(hard);
664 INT_SET(ddq->d_blk_softlimit, ARCH_CONVERT, soft); 647 ddq->d_blk_softlimit = cpu_to_be64(soft);
665 if (id == 0) { 648 if (id == 0) {
666 mp->m_quotainfo->qi_bhardlimit = hard; 649 mp->m_quotainfo->qi_bhardlimit = hard;
667 mp->m_quotainfo->qi_bsoftlimit = soft; 650 mp->m_quotainfo->qi_bsoftlimit = soft;
@@ -671,13 +654,13 @@ xfs_qm_scall_setqlim(
671 } 654 }
672 hard = (newlim->d_fieldmask & FS_DQ_RTBHARD) ? 655 hard = (newlim->d_fieldmask & FS_DQ_RTBHARD) ?
673 (xfs_qcnt_t) XFS_BB_TO_FSB(mp, newlim->d_rtb_hardlimit) : 656 (xfs_qcnt_t) XFS_BB_TO_FSB(mp, newlim->d_rtb_hardlimit) :
674 INT_GET(ddq->d_rtb_hardlimit, ARCH_CONVERT); 657 be64_to_cpu(ddq->d_rtb_hardlimit);
675 soft = (newlim->d_fieldmask & FS_DQ_RTBSOFT) ? 658 soft = (newlim->d_fieldmask & FS_DQ_RTBSOFT) ?
676 (xfs_qcnt_t) XFS_BB_TO_FSB(mp, newlim->d_rtb_softlimit) : 659 (xfs_qcnt_t) XFS_BB_TO_FSB(mp, newlim->d_rtb_softlimit) :
677 INT_GET(ddq->d_rtb_softlimit, ARCH_CONVERT); 660 be64_to_cpu(ddq->d_rtb_softlimit);
678 if (hard == 0 || hard >= soft) { 661 if (hard == 0 || hard >= soft) {
679 INT_SET(ddq->d_rtb_hardlimit, ARCH_CONVERT, hard); 662 ddq->d_rtb_hardlimit = cpu_to_be64(hard);
680 INT_SET(ddq->d_rtb_softlimit, ARCH_CONVERT, soft); 663 ddq->d_rtb_softlimit = cpu_to_be64(soft);
681 if (id == 0) { 664 if (id == 0) {
682 mp->m_quotainfo->qi_rtbhardlimit = hard; 665 mp->m_quotainfo->qi_rtbhardlimit = hard;
683 mp->m_quotainfo->qi_rtbsoftlimit = soft; 666 mp->m_quotainfo->qi_rtbsoftlimit = soft;
@@ -688,13 +671,13 @@ xfs_qm_scall_setqlim(
688 671
689 hard = (newlim->d_fieldmask & FS_DQ_IHARD) ? 672 hard = (newlim->d_fieldmask & FS_DQ_IHARD) ?
690 (xfs_qcnt_t) newlim->d_ino_hardlimit : 673 (xfs_qcnt_t) newlim->d_ino_hardlimit :
691 INT_GET(ddq->d_ino_hardlimit, ARCH_CONVERT); 674 be64_to_cpu(ddq->d_ino_hardlimit);
692 soft = (newlim->d_fieldmask & FS_DQ_ISOFT) ? 675 soft = (newlim->d_fieldmask & FS_DQ_ISOFT) ?
693 (xfs_qcnt_t) newlim->d_ino_softlimit : 676 (xfs_qcnt_t) newlim->d_ino_softlimit :
694 INT_GET(ddq->d_ino_softlimit, ARCH_CONVERT); 677 be64_to_cpu(ddq->d_ino_softlimit);
695 if (hard == 0 || hard >= soft) { 678 if (hard == 0 || hard >= soft) {
696 INT_SET(ddq->d_ino_hardlimit, ARCH_CONVERT, hard); 679 ddq->d_ino_hardlimit = cpu_to_be64(hard);
697 INT_SET(ddq->d_ino_softlimit, ARCH_CONVERT, soft); 680 ddq->d_ino_softlimit = cpu_to_be64(soft);
698 if (id == 0) { 681 if (id == 0) {
699 mp->m_quotainfo->qi_ihardlimit = hard; 682 mp->m_quotainfo->qi_ihardlimit = hard;
700 mp->m_quotainfo->qi_isoftlimit = soft; 683 mp->m_quotainfo->qi_isoftlimit = soft;
@@ -707,11 +690,11 @@ xfs_qm_scall_setqlim(
707 * Update warnings counter(s) if requested 690 * Update warnings counter(s) if requested
708 */ 691 */
709 if (newlim->d_fieldmask & FS_DQ_BWARNS) 692 if (newlim->d_fieldmask & FS_DQ_BWARNS)
710 INT_SET(ddq->d_bwarns, ARCH_CONVERT, newlim->d_bwarns); 693 ddq->d_bwarns = cpu_to_be16(newlim->d_bwarns);
711 if (newlim->d_fieldmask & FS_DQ_IWARNS) 694 if (newlim->d_fieldmask & FS_DQ_IWARNS)
712 INT_SET(ddq->d_iwarns, ARCH_CONVERT, newlim->d_iwarns); 695 ddq->d_iwarns = cpu_to_be16(newlim->d_iwarns);
713 if (newlim->d_fieldmask & FS_DQ_RTBWARNS) 696 if (newlim->d_fieldmask & FS_DQ_RTBWARNS)
714 INT_SET(ddq->d_rtbwarns, ARCH_CONVERT, newlim->d_rtbwarns); 697 ddq->d_rtbwarns = cpu_to_be16(newlim->d_rtbwarns);
715 698
716 if (id == 0) { 699 if (id == 0) {
717 /* 700 /*
@@ -723,15 +706,15 @@ xfs_qm_scall_setqlim(
723 */ 706 */
724 if (newlim->d_fieldmask & FS_DQ_BTIMER) { 707 if (newlim->d_fieldmask & FS_DQ_BTIMER) {
725 mp->m_quotainfo->qi_btimelimit = newlim->d_btimer; 708 mp->m_quotainfo->qi_btimelimit = newlim->d_btimer;
726 INT_SET(ddq->d_btimer, ARCH_CONVERT, newlim->d_btimer); 709 ddq->d_btimer = cpu_to_be32(newlim->d_btimer);
727 } 710 }
728 if (newlim->d_fieldmask & FS_DQ_ITIMER) { 711 if (newlim->d_fieldmask & FS_DQ_ITIMER) {
729 mp->m_quotainfo->qi_itimelimit = newlim->d_itimer; 712 mp->m_quotainfo->qi_itimelimit = newlim->d_itimer;
730 INT_SET(ddq->d_itimer, ARCH_CONVERT, newlim->d_itimer); 713 ddq->d_itimer = cpu_to_be32(newlim->d_itimer);
731 } 714 }
732 if (newlim->d_fieldmask & FS_DQ_RTBTIMER) { 715 if (newlim->d_fieldmask & FS_DQ_RTBTIMER) {
733 mp->m_quotainfo->qi_rtbtimelimit = newlim->d_rtbtimer; 716 mp->m_quotainfo->qi_rtbtimelimit = newlim->d_rtbtimer;
734 INT_SET(ddq->d_rtbtimer, ARCH_CONVERT, newlim->d_rtbtimer); 717 ddq->d_rtbtimer = cpu_to_be32(newlim->d_rtbtimer);
735 } 718 }
736 if (newlim->d_fieldmask & FS_DQ_BWARNS) 719 if (newlim->d_fieldmask & FS_DQ_BWARNS)
737 mp->m_quotainfo->qi_bwarnlimit = newlim->d_bwarns; 720 mp->m_quotainfo->qi_bwarnlimit = newlim->d_bwarns;
@@ -902,33 +885,27 @@ xfs_qm_export_dquot(
902{ 885{
903 memset(dst, 0, sizeof(*dst)); 886 memset(dst, 0, sizeof(*dst));
904 dst->d_version = FS_DQUOT_VERSION; /* different from src->d_version */ 887 dst->d_version = FS_DQUOT_VERSION; /* different from src->d_version */
905 dst->d_flags = 888 dst->d_flags = xfs_qm_export_qtype_flags(src->d_flags);
906 xfs_qm_export_qtype_flags(INT_GET(src->d_flags, ARCH_CONVERT)); 889 dst->d_id = be32_to_cpu(src->d_id);
907 dst->d_id = INT_GET(src->d_id, ARCH_CONVERT); 890 dst->d_blk_hardlimit =
908 dst->d_blk_hardlimit = (__uint64_t) 891 XFS_FSB_TO_BB(mp, be64_to_cpu(src->d_blk_hardlimit));
909 XFS_FSB_TO_BB(mp, INT_GET(src->d_blk_hardlimit, ARCH_CONVERT)); 892 dst->d_blk_softlimit =
910 dst->d_blk_softlimit = (__uint64_t) 893 XFS_FSB_TO_BB(mp, be64_to_cpu(src->d_blk_softlimit));
911 XFS_FSB_TO_BB(mp, INT_GET(src->d_blk_softlimit, ARCH_CONVERT)); 894 dst->d_ino_hardlimit = be64_to_cpu(src->d_ino_hardlimit);
912 dst->d_ino_hardlimit = (__uint64_t) 895 dst->d_ino_softlimit = be64_to_cpu(src->d_ino_softlimit);
913 INT_GET(src->d_ino_hardlimit, ARCH_CONVERT); 896 dst->d_bcount = XFS_FSB_TO_BB(mp, be64_to_cpu(src->d_bcount));
914 dst->d_ino_softlimit = (__uint64_t) 897 dst->d_icount = be64_to_cpu(src->d_icount);
915 INT_GET(src->d_ino_softlimit, ARCH_CONVERT); 898 dst->d_btimer = be32_to_cpu(src->d_btimer);
916 dst->d_bcount = (__uint64_t) 899 dst->d_itimer = be32_to_cpu(src->d_itimer);
917 XFS_FSB_TO_BB(mp, INT_GET(src->d_bcount, ARCH_CONVERT)); 900 dst->d_iwarns = be16_to_cpu(src->d_iwarns);
918 dst->d_icount = (__uint64_t) INT_GET(src->d_icount, ARCH_CONVERT); 901 dst->d_bwarns = be16_to_cpu(src->d_bwarns);
919 dst->d_btimer = (__uint32_t) INT_GET(src->d_btimer, ARCH_CONVERT); 902 dst->d_rtb_hardlimit =
920 dst->d_itimer = (__uint32_t) INT_GET(src->d_itimer, ARCH_CONVERT); 903 XFS_FSB_TO_BB(mp, be64_to_cpu(src->d_rtb_hardlimit));
921 dst->d_iwarns = INT_GET(src->d_iwarns, ARCH_CONVERT); 904 dst->d_rtb_softlimit =
922 dst->d_bwarns = INT_GET(src->d_bwarns, ARCH_CONVERT); 905 XFS_FSB_TO_BB(mp, be64_to_cpu(src->d_rtb_softlimit));
923 906 dst->d_rtbcount = XFS_FSB_TO_BB(mp, be64_to_cpu(src->d_rtbcount));
924 dst->d_rtb_hardlimit = (__uint64_t) 907 dst->d_rtbtimer = be32_to_cpu(src->d_rtbtimer);
925 XFS_FSB_TO_BB(mp, INT_GET(src->d_rtb_hardlimit, ARCH_CONVERT)); 908 dst->d_rtbwarns = be16_to_cpu(src->d_rtbwarns);
926 dst->d_rtb_softlimit = (__uint64_t)
927 XFS_FSB_TO_BB(mp, INT_GET(src->d_rtb_softlimit, ARCH_CONVERT));
928 dst->d_rtbcount = (__uint64_t)
929 XFS_FSB_TO_BB(mp, INT_GET(src->d_rtbcount, ARCH_CONVERT));
930 dst->d_rtbtimer = (__uint32_t) INT_GET(src->d_rtbtimer, ARCH_CONVERT);
931 dst->d_rtbwarns = INT_GET(src->d_rtbwarns, ARCH_CONVERT);
932 909
933 /* 910 /*
934 * Internally, we don't reset all the timers when quota enforcement 911 * Internally, we don't reset all the timers when quota enforcement
@@ -1222,10 +1199,10 @@ xfs_qm_dqtest_failed(
1222 qmtest_nfails++; 1199 qmtest_nfails++;
1223 if (error) 1200 if (error)
1224 cmn_err(CE_DEBUG, "quotacheck failed id=%d, err=%d\nreason: %s", 1201 cmn_err(CE_DEBUG, "quotacheck failed id=%d, err=%d\nreason: %s",
1225 INT_GET(d->d_id, ARCH_CONVERT), error, reason); 1202 d->d_id, error, reason);
1226 else 1203 else
1227 cmn_err(CE_DEBUG, "quotacheck failed id=%d (%s) [%d != %d]", 1204 cmn_err(CE_DEBUG, "quotacheck failed id=%d (%s) [%d != %d]",
1228 INT_GET(d->d_id, ARCH_CONVERT), reason, (int)a, (int)b); 1205 d->d_id, reason, (int)a, (int)b);
1229 xfs_qm_dqtest_print(d); 1206 xfs_qm_dqtest_print(d);
1230 if (dqp) 1207 if (dqp)
1231 xfs_qm_dqprint(dqp); 1208 xfs_qm_dqprint(dqp);
@@ -1237,21 +1214,21 @@ xfs_dqtest_cmp2(
1237 xfs_dquot_t *dqp) 1214 xfs_dquot_t *dqp)
1238{ 1215{
1239 int err = 0; 1216 int err = 0;
1240 if (INT_GET(dqp->q_core.d_icount, ARCH_CONVERT) != d->d_icount) { 1217 if (be64_to_cpu(dqp->q_core.d_icount) != d->d_icount) {
1241 xfs_qm_dqtest_failed(d, dqp, "icount mismatch", 1218 xfs_qm_dqtest_failed(d, dqp, "icount mismatch",
1242 INT_GET(dqp->q_core.d_icount, ARCH_CONVERT), 1219 be64_to_cpu(dqp->q_core.d_icount),
1243 d->d_icount, 0); 1220 d->d_icount, 0);
1244 err++; 1221 err++;
1245 } 1222 }
1246 if (INT_GET(dqp->q_core.d_bcount, ARCH_CONVERT) != d->d_bcount) { 1223 if (be64_to_cpu(dqp->q_core.d_bcount) != d->d_bcount) {
1247 xfs_qm_dqtest_failed(d, dqp, "bcount mismatch", 1224 xfs_qm_dqtest_failed(d, dqp, "bcount mismatch",
1248 INT_GET(dqp->q_core.d_bcount, ARCH_CONVERT), 1225 be64_to_cpu(dqp->q_core.d_bcount),
1249 d->d_bcount, 0); 1226 d->d_bcount, 0);
1250 err++; 1227 err++;
1251 } 1228 }
1252 if (INT_GET(dqp->q_core.d_blk_softlimit, ARCH_CONVERT) && 1229 if (dqp->q_core.d_blk_softlimit &&
1253 INT_GET(dqp->q_core.d_bcount, ARCH_CONVERT) >= 1230 be64_to_cpu(dqp->q_core.d_bcount) >=
1254 INT_GET(dqp->q_core.d_blk_softlimit, ARCH_CONVERT)) { 1231 be64_to_cpu(dqp->q_core.d_blk_softlimit)) {
1255 if (!dqp->q_core.d_btimer && dqp->q_core.d_id) { 1232 if (!dqp->q_core.d_btimer && dqp->q_core.d_id) {
1256 cmn_err(CE_DEBUG, 1233 cmn_err(CE_DEBUG,
1257 "%d [%s] [0x%p] BLK TIMER NOT STARTED", 1234 "%d [%s] [0x%p] BLK TIMER NOT STARTED",
@@ -1259,9 +1236,9 @@ xfs_dqtest_cmp2(
1259 err++; 1236 err++;
1260 } 1237 }
1261 } 1238 }
1262 if (INT_GET(dqp->q_core.d_ino_softlimit, ARCH_CONVERT) && 1239 if (dqp->q_core.d_ino_softlimit &&
1263 INT_GET(dqp->q_core.d_icount, ARCH_CONVERT) >= 1240 be64_to_cpu(dqp->q_core.d_icount) >=
1264 INT_GET(dqp->q_core.d_ino_softlimit, ARCH_CONVERT)) { 1241 be64_to_cpu(dqp->q_core.d_ino_softlimit)) {
1265 if (!dqp->q_core.d_itimer && dqp->q_core.d_id) { 1242 if (!dqp->q_core.d_itimer && dqp->q_core.d_id) {
1266 cmn_err(CE_DEBUG, 1243 cmn_err(CE_DEBUG,
1267 "%d [%s] [0x%p] INO TIMER NOT STARTED", 1244 "%d [%s] [0x%p] INO TIMER NOT STARTED",
diff --git a/fs/xfs/quota/xfs_quota_priv.h b/fs/xfs/quota/xfs_quota_priv.h
index bf413e70ec07..7a9f3beb818c 100644
--- a/fs/xfs/quota/xfs_quota_priv.h
+++ b/fs/xfs/quota/xfs_quota_priv.h
@@ -1,33 +1,19 @@
1/* 1/*
2 * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2003 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32#ifndef __XFS_QUOTA_PRIV_H__ 18#ifndef __XFS_QUOTA_PRIV_H__
33#define __XFS_QUOTA_PRIV_H__ 19#define __XFS_QUOTA_PRIV_H__
diff --git a/fs/xfs/quota/xfs_trans_dquot.c b/fs/xfs/quota/xfs_trans_dquot.c
index 3b99daf8a640..3290975d31f7 100644
--- a/fs/xfs/quota/xfs_trans_dquot.c
+++ b/fs/xfs/quota/xfs_trans_dquot.c
@@ -1,39 +1,25 @@
1/* 1/*
2 * Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2002 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32
33#include "xfs.h" 18#include "xfs.h"
34#include "xfs_fs.h" 19#include "xfs_fs.h"
35#include "xfs_inum.h" 20#include "xfs_bit.h"
36#include "xfs_log.h" 21#include "xfs_log.h"
22#include "xfs_inum.h"
37#include "xfs_trans.h" 23#include "xfs_trans.h"
38#include "xfs_sb.h" 24#include "xfs_sb.h"
39#include "xfs_ag.h" 25#include "xfs_ag.h"
@@ -43,21 +29,20 @@
43#include "xfs_dmapi.h" 29#include "xfs_dmapi.h"
44#include "xfs_quota.h" 30#include "xfs_quota.h"
45#include "xfs_mount.h" 31#include "xfs_mount.h"
46#include "xfs_alloc_btree.h"
47#include "xfs_bmap_btree.h" 32#include "xfs_bmap_btree.h"
33#include "xfs_alloc_btree.h"
48#include "xfs_ialloc_btree.h" 34#include "xfs_ialloc_btree.h"
49#include "xfs_btree.h"
50#include "xfs_ialloc.h"
51#include "xfs_attr_sf.h" 35#include "xfs_attr_sf.h"
52#include "xfs_dir_sf.h" 36#include "xfs_dir_sf.h"
53#include "xfs_dir2_sf.h" 37#include "xfs_dir2_sf.h"
54#include "xfs_dinode.h" 38#include "xfs_dinode.h"
55#include "xfs_inode.h" 39#include "xfs_inode.h"
40#include "xfs_ialloc.h"
41#include "xfs_itable.h"
42#include "xfs_btree.h"
56#include "xfs_bmap.h" 43#include "xfs_bmap.h"
57#include "xfs_bit.h"
58#include "xfs_rtalloc.h" 44#include "xfs_rtalloc.h"
59#include "xfs_error.h" 45#include "xfs_error.h"
60#include "xfs_itable.h"
61#include "xfs_rw.h" 46#include "xfs_rw.h"
62#include "xfs_acl.h" 47#include "xfs_acl.h"
63#include "xfs_cap.h" 48#include "xfs_cap.h"
@@ -65,7 +50,6 @@
65#include "xfs_attr.h" 50#include "xfs_attr.h"
66#include "xfs_buf_item.h" 51#include "xfs_buf_item.h"
67#include "xfs_trans_priv.h" 52#include "xfs_trans_priv.h"
68
69#include "xfs_qm.h" 53#include "xfs_qm.h"
70 54
71STATIC void xfs_trans_alloc_dqinfo(xfs_trans_t *); 55STATIC void xfs_trans_alloc_dqinfo(xfs_trans_t *);
@@ -429,25 +413,25 @@ xfs_trans_apply_dquot_deltas(
429 qtrx->qt_delrtb_delta; 413 qtrx->qt_delrtb_delta;
430#ifdef QUOTADEBUG 414#ifdef QUOTADEBUG
431 if (totalbdelta < 0) 415 if (totalbdelta < 0)
432 ASSERT(INT_GET(d->d_bcount, ARCH_CONVERT) >= 416 ASSERT(be64_to_cpu(d->d_bcount) >=
433 (xfs_qcnt_t) -totalbdelta); 417 (xfs_qcnt_t) -totalbdelta);
434 418
435 if (totalrtbdelta < 0) 419 if (totalrtbdelta < 0)
436 ASSERT(INT_GET(d->d_rtbcount, ARCH_CONVERT) >= 420 ASSERT(be64_to_cpu(d->d_rtbcount) >=
437 (xfs_qcnt_t) -totalrtbdelta); 421 (xfs_qcnt_t) -totalrtbdelta);
438 422
439 if (qtrx->qt_icount_delta < 0) 423 if (qtrx->qt_icount_delta < 0)
440 ASSERT(INT_GET(d->d_icount, ARCH_CONVERT) >= 424 ASSERT(be64_to_cpu(d->d_icount) >=
441 (xfs_qcnt_t) -qtrx->qt_icount_delta); 425 (xfs_qcnt_t) -qtrx->qt_icount_delta);
442#endif 426#endif
443 if (totalbdelta) 427 if (totalbdelta)
444 INT_MOD(d->d_bcount, ARCH_CONVERT, (xfs_qcnt_t)totalbdelta); 428 be64_add(&d->d_bcount, (xfs_qcnt_t)totalbdelta);
445 429
446 if (qtrx->qt_icount_delta) 430 if (qtrx->qt_icount_delta)
447 INT_MOD(d->d_icount, ARCH_CONVERT, (xfs_qcnt_t)qtrx->qt_icount_delta); 431 be64_add(&d->d_icount, (xfs_qcnt_t)qtrx->qt_icount_delta);
448 432
449 if (totalrtbdelta) 433 if (totalrtbdelta)
450 INT_MOD(d->d_rtbcount, ARCH_CONVERT, (xfs_qcnt_t)totalrtbdelta); 434 be64_add(&d->d_rtbcount, (xfs_qcnt_t)totalrtbdelta);
451 435
452 /* 436 /*
453 * Get any default limits in use. 437 * Get any default limits in use.
@@ -531,11 +515,11 @@ xfs_trans_apply_dquot_deltas(
531 } 515 }
532 516
533 ASSERT(dqp->q_res_bcount >= 517 ASSERT(dqp->q_res_bcount >=
534 INT_GET(dqp->q_core.d_bcount, ARCH_CONVERT)); 518 be64_to_cpu(dqp->q_core.d_bcount));
535 ASSERT(dqp->q_res_icount >= 519 ASSERT(dqp->q_res_icount >=
536 INT_GET(dqp->q_core.d_icount, ARCH_CONVERT)); 520 be64_to_cpu(dqp->q_core.d_icount));
537 ASSERT(dqp->q_res_rtbcount >= 521 ASSERT(dqp->q_res_rtbcount >=
538 INT_GET(dqp->q_core.d_rtbcount, ARCH_CONVERT)); 522 be64_to_cpu(dqp->q_core.d_rtbcount));
539 } 523 }
540 /* 524 /*
541 * Do the group quotas next 525 * Do the group quotas next
@@ -642,26 +626,26 @@ xfs_trans_dqresv(
642 } 626 }
643 ASSERT(XFS_DQ_IS_LOCKED(dqp)); 627 ASSERT(XFS_DQ_IS_LOCKED(dqp));
644 if (flags & XFS_TRANS_DQ_RES_BLKS) { 628 if (flags & XFS_TRANS_DQ_RES_BLKS) {
645 hardlimit = INT_GET(dqp->q_core.d_blk_hardlimit, ARCH_CONVERT); 629 hardlimit = be64_to_cpu(dqp->q_core.d_blk_hardlimit);
646 if (!hardlimit) 630 if (!hardlimit)
647 hardlimit = q->qi_bhardlimit; 631 hardlimit = q->qi_bhardlimit;
648 softlimit = INT_GET(dqp->q_core.d_blk_softlimit, ARCH_CONVERT); 632 softlimit = be64_to_cpu(dqp->q_core.d_blk_softlimit);
649 if (!softlimit) 633 if (!softlimit)
650 softlimit = q->qi_bsoftlimit; 634 softlimit = q->qi_bsoftlimit;
651 timer = INT_GET(dqp->q_core.d_btimer, ARCH_CONVERT); 635 timer = be32_to_cpu(dqp->q_core.d_btimer);
652 warns = INT_GET(dqp->q_core.d_bwarns, ARCH_CONVERT); 636 warns = be16_to_cpu(dqp->q_core.d_bwarns);
653 warnlimit = XFS_QI_BWARNLIMIT(dqp->q_mount); 637 warnlimit = XFS_QI_BWARNLIMIT(dqp->q_mount);
654 resbcountp = &dqp->q_res_bcount; 638 resbcountp = &dqp->q_res_bcount;
655 } else { 639 } else {
656 ASSERT(flags & XFS_TRANS_DQ_RES_RTBLKS); 640 ASSERT(flags & XFS_TRANS_DQ_RES_RTBLKS);
657 hardlimit = INT_GET(dqp->q_core.d_rtb_hardlimit, ARCH_CONVERT); 641 hardlimit = be64_to_cpu(dqp->q_core.d_rtb_hardlimit);
658 if (!hardlimit) 642 if (!hardlimit)
659 hardlimit = q->qi_rtbhardlimit; 643 hardlimit = q->qi_rtbhardlimit;
660 softlimit = INT_GET(dqp->q_core.d_rtb_softlimit, ARCH_CONVERT); 644 softlimit = be64_to_cpu(dqp->q_core.d_rtb_softlimit);
661 if (!softlimit) 645 if (!softlimit)
662 softlimit = q->qi_rtbsoftlimit; 646 softlimit = q->qi_rtbsoftlimit;
663 timer = INT_GET(dqp->q_core.d_rtbtimer, ARCH_CONVERT); 647 timer = be32_to_cpu(dqp->q_core.d_rtbtimer);
664 warns = INT_GET(dqp->q_core.d_rtbwarns, ARCH_CONVERT); 648 warns = be16_to_cpu(dqp->q_core.d_rtbwarns);
665 warnlimit = XFS_QI_RTBWARNLIMIT(dqp->q_mount); 649 warnlimit = XFS_QI_RTBWARNLIMIT(dqp->q_mount);
666 resbcountp = &dqp->q_res_rtbcount; 650 resbcountp = &dqp->q_res_rtbcount;
667 } 651 }
@@ -700,16 +684,14 @@ xfs_trans_dqresv(
700 } 684 }
701 } 685 }
702 if (ninos > 0) { 686 if (ninos > 0) {
703 count = INT_GET(dqp->q_core.d_icount, ARCH_CONVERT); 687 count = be64_to_cpu(dqp->q_core.d_icount);
704 timer = INT_GET(dqp->q_core.d_itimer, ARCH_CONVERT); 688 timer = be32_to_cpu(dqp->q_core.d_itimer);
705 warns = INT_GET(dqp->q_core.d_iwarns, ARCH_CONVERT); 689 warns = be16_to_cpu(dqp->q_core.d_iwarns);
706 warnlimit = XFS_QI_IWARNLIMIT(dqp->q_mount); 690 warnlimit = XFS_QI_IWARNLIMIT(dqp->q_mount);
707 hardlimit = INT_GET(dqp->q_core.d_ino_hardlimit, 691 hardlimit = be64_to_cpu(dqp->q_core.d_ino_hardlimit);
708 ARCH_CONVERT);
709 if (!hardlimit) 692 if (!hardlimit)
710 hardlimit = q->qi_ihardlimit; 693 hardlimit = q->qi_ihardlimit;
711 softlimit = INT_GET(dqp->q_core.d_ino_softlimit, 694 softlimit = be64_to_cpu(dqp->q_core.d_ino_softlimit);
712 ARCH_CONVERT);
713 if (!softlimit) 695 if (!softlimit)
714 softlimit = q->qi_isoftlimit; 696 softlimit = q->qi_isoftlimit;
715 if (hardlimit > 0ULL && count >= hardlimit) { 697 if (hardlimit > 0ULL && count >= hardlimit) {
@@ -756,9 +738,9 @@ xfs_trans_dqresv(
756 XFS_TRANS_DQ_RES_INOS, 738 XFS_TRANS_DQ_RES_INOS,
757 ninos); 739 ninos);
758 } 740 }
759 ASSERT(dqp->q_res_bcount >= INT_GET(dqp->q_core.d_bcount, ARCH_CONVERT)); 741 ASSERT(dqp->q_res_bcount >= be64_to_cpu(dqp->q_core.d_bcount));
760 ASSERT(dqp->q_res_rtbcount >= INT_GET(dqp->q_core.d_rtbcount, ARCH_CONVERT)); 742 ASSERT(dqp->q_res_rtbcount >= be64_to_cpu(dqp->q_core.d_rtbcount));
761 ASSERT(dqp->q_res_icount >= INT_GET(dqp->q_core.d_icount, ARCH_CONVERT)); 743 ASSERT(dqp->q_res_icount >= be64_to_cpu(dqp->q_core.d_icount));
762 744
763error_return: 745error_return:
764 if (! (flags & XFS_QMOPT_DQLOCK)) { 746 if (! (flags & XFS_QMOPT_DQLOCK)) {
diff --git a/fs/xfs/support/debug.c b/fs/xfs/support/debug.c
index 4e1a5ec22fa3..bb6dc91ea261 100644
--- a/fs/xfs/support/debug.c
+++ b/fs/xfs/support/debug.c
@@ -1,38 +1,22 @@
1/* 1/*
2 * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32
33#include "debug.h" 18#include "debug.h"
34#include "spin.h" 19#include "spin.h"
35
36#include <asm/page.h> 20#include <asm/page.h>
37#include <linux/sched.h> 21#include <linux/sched.h>
38#include <linux/kernel.h> 22#include <linux/kernel.h>
diff --git a/fs/xfs/support/debug.h b/fs/xfs/support/debug.h
index c5b9365a7e2a..aff558664c32 100644
--- a/fs/xfs/support/debug.h
+++ b/fs/xfs/support/debug.h
@@ -1,33 +1,19 @@
1/* 1/*
2 * Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32#ifndef __XFS_SUPPORT_DEBUG_H__ 18#ifndef __XFS_SUPPORT_DEBUG_H__
33#define __XFS_SUPPORT_DEBUG_H__ 19#define __XFS_SUPPORT_DEBUG_H__
@@ -41,9 +27,10 @@
41#define CE_ALERT 1 /* alert */ 27#define CE_ALERT 1 /* alert */
42#define CE_PANIC 0 /* panic */ 28#define CE_PANIC 0 /* panic */
43 29
44extern void icmn_err(int, char *, va_list); 30extern void icmn_err(int, char *, va_list)
45/* PRINTFLIKE2 */ 31 __attribute__ ((format (printf, 2, 0)));
46extern void cmn_err(int, char *, ...); 32extern void cmn_err(int, char *, ...)
33 __attribute__ ((format (printf, 2, 3)));
47 34
48#ifndef STATIC 35#ifndef STATIC
49# define STATIC static 36# define STATIC static
diff --git a/fs/xfs/support/ktrace.c b/fs/xfs/support/ktrace.c
index fa8394f9437d..841aa4c15b8a 100644
--- a/fs/xfs/support/ktrace.c
+++ b/fs/xfs/support/ktrace.c
@@ -1,35 +1,20 @@
1/* 1/*
2 * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32
33#include <xfs.h> 18#include <xfs.h>
34 19
35static kmem_zone_t *ktrace_hdr_zone; 20static kmem_zone_t *ktrace_hdr_zone;
@@ -65,7 +50,7 @@ ktrace_uninit(void)
65 * number of entries. 50 * number of entries.
66 */ 51 */
67ktrace_t * 52ktrace_t *
68ktrace_alloc(int nentries, int sleep) 53ktrace_alloc(int nentries, unsigned int __nocast sleep)
69{ 54{
70 ktrace_t *ktp; 55 ktrace_t *ktp;
71 ktrace_entry_t *ktep; 56 ktrace_entry_t *ktep;
diff --git a/fs/xfs/support/ktrace.h b/fs/xfs/support/ktrace.h
index 92d1a1a5d04b..0d73216287c0 100644
--- a/fs/xfs/support/ktrace.h
+++ b/fs/xfs/support/ktrace.h
@@ -1,33 +1,19 @@
1/* 1/*
2 * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32#ifndef __XFS_SUPPORT_KTRACE_H__ 18#ifndef __XFS_SUPPORT_KTRACE_H__
33#define __XFS_SUPPORT_KTRACE_H__ 19#define __XFS_SUPPORT_KTRACE_H__
@@ -66,7 +52,7 @@ typedef struct ktrace_snap {
66extern void ktrace_init(int zentries); 52extern void ktrace_init(int zentries);
67extern void ktrace_uninit(void); 53extern void ktrace_uninit(void);
68 54
69extern ktrace_t *ktrace_alloc(int, int); 55extern ktrace_t *ktrace_alloc(int, unsigned int __nocast);
70extern void ktrace_free(ktrace_t *); 56extern void ktrace_free(ktrace_t *);
71 57
72extern void ktrace_enter( 58extern void ktrace_enter(
diff --git a/fs/xfs/support/move.c b/fs/xfs/support/move.c
index 15b5194f16b2..caefa17b80fe 100644
--- a/fs/xfs/support/move.c
+++ b/fs/xfs/support/move.c
@@ -1,35 +1,20 @@
1/* 1/*
2 * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32
33#include <xfs.h> 18#include <xfs.h>
34 19
35/* Read from kernel buffer at src to user/kernel buffer defined 20/* Read from kernel buffer at src to user/kernel buffer defined
diff --git a/fs/xfs/support/move.h b/fs/xfs/support/move.h
index 3d406dc1c89e..97a2498d2da3 100644
--- a/fs/xfs/support/move.h
+++ b/fs/xfs/support/move.h
@@ -1,34 +1,20 @@
1/* 1/*
2 * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 * 17 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 *
32 * Portions Copyright (c) 1982, 1986, 1993, 1994 18 * Portions Copyright (c) 1982, 1986, 1993, 1994
33 * The Regents of the University of California. All rights reserved. 19 * The Regents of the University of California. All rights reserved.
34 * 20 *
diff --git a/fs/xfs/support/qsort.c b/fs/xfs/support/qsort.c
deleted file mode 100644
index 1ec824140cf7..000000000000
--- a/fs/xfs/support/qsort.c
+++ /dev/null
@@ -1,155 +0,0 @@
1/*
2 * Copyright (c) 1992, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. Neither the name of the University nor the names of its contributors
14 * may be used to endorse or promote products derived from this software
15 * without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 */
29
30#include <linux/kernel.h>
31#include <linux/string.h>
32
33/*
34 * Qsort routine from Bentley & McIlroy's "Engineering a Sort Function".
35 */
36#define swapcode(TYPE, parmi, parmj, n) { \
37 long i = (n) / sizeof (TYPE); \
38 register TYPE *pi = (TYPE *) (parmi); \
39 register TYPE *pj = (TYPE *) (parmj); \
40 do { \
41 register TYPE t = *pi; \
42 *pi++ = *pj; \
43 *pj++ = t; \
44 } while (--i > 0); \
45}
46
47#define SWAPINIT(a, es) swaptype = ((char *)a - (char *)0) % sizeof(long) || \
48 es % sizeof(long) ? 2 : es == sizeof(long)? 0 : 1;
49
50static __inline void
51swapfunc(char *a, char *b, int n, int swaptype)
52{
53 if (swaptype <= 1)
54 swapcode(long, a, b, n)
55 else
56 swapcode(char, a, b, n)
57}
58
59#define swap(a, b) \
60 if (swaptype == 0) { \
61 long t = *(long *)(a); \
62 *(long *)(a) = *(long *)(b); \
63 *(long *)(b) = t; \
64 } else \
65 swapfunc(a, b, es, swaptype)
66
67#define vecswap(a, b, n) if ((n) > 0) swapfunc(a, b, n, swaptype)
68
69static __inline char *
70med3(char *a, char *b, char *c, int (*cmp)(const void *, const void *))
71{
72 return cmp(a, b) < 0 ?
73 (cmp(b, c) < 0 ? b : (cmp(a, c) < 0 ? c : a ))
74 :(cmp(b, c) > 0 ? b : (cmp(a, c) < 0 ? a : c ));
75}
76
77void
78qsort(void *aa, size_t n, size_t es, int (*cmp)(const void *, const void *))
79{
80 char *pa, *pb, *pc, *pd, *pl, *pm, *pn;
81 int d, r, swaptype, swap_cnt;
82 register char *a = aa;
83
84loop: SWAPINIT(a, es);
85 swap_cnt = 0;
86 if (n < 7) {
87 for (pm = (char *)a + es; pm < (char *) a + n * es; pm += es)
88 for (pl = pm; pl > (char *) a && cmp(pl - es, pl) > 0;
89 pl -= es)
90 swap(pl, pl - es);
91 return;
92 }
93 pm = (char *)a + (n / 2) * es;
94 if (n > 7) {
95 pl = (char *)a;
96 pn = (char *)a + (n - 1) * es;
97 if (n > 40) {
98 d = (n / 8) * es;
99 pl = med3(pl, pl + d, pl + 2 * d, cmp);
100 pm = med3(pm - d, pm, pm + d, cmp);
101 pn = med3(pn - 2 * d, pn - d, pn, cmp);
102 }
103 pm = med3(pl, pm, pn, cmp);
104 }
105 swap(a, pm);
106 pa = pb = (char *)a + es;
107
108 pc = pd = (char *)a + (n - 1) * es;
109 for (;;) {
110 while (pb <= pc && (r = cmp(pb, a)) <= 0) {
111 if (r == 0) {
112 swap_cnt = 1;
113 swap(pa, pb);
114 pa += es;
115 }
116 pb += es;
117 }
118 while (pb <= pc && (r = cmp(pc, a)) >= 0) {
119 if (r == 0) {
120 swap_cnt = 1;
121 swap(pc, pd);
122 pd -= es;
123 }
124 pc -= es;
125 }
126 if (pb > pc)
127 break;
128 swap(pb, pc);
129 swap_cnt = 1;
130 pb += es;
131 pc -= es;
132 }
133 if (swap_cnt == 0) { /* Switch to insertion sort */
134 for (pm = (char *) a + es; pm < (char *) a + n * es; pm += es)
135 for (pl = pm; pl > (char *) a && cmp(pl - es, pl) > 0;
136 pl -= es)
137 swap(pl, pl - es);
138 return;
139 }
140
141 pn = (char *)a + n * es;
142 r = min(pa - (char *)a, pb - pa);
143 vecswap(a, pb - r, r);
144 r = min((long)(pd - pc), (long)(pn - pd - es));
145 vecswap(pb, pn - r, r);
146 if ((r = pb - pa) > es)
147 qsort(a, r / es, es, cmp);
148 if ((r = pd - pc) > es) {
149 /* Iterate rather than recurse to save stack space */
150 a = pn - r;
151 n = r / es;
152 goto loop;
153 }
154/* qsort(pn - r, r / es, es, cmp);*/
155}
diff --git a/fs/xfs/support/qsort.h b/fs/xfs/support/qsort.h
deleted file mode 100644
index 94263106d716..000000000000
--- a/fs/xfs/support/qsort.h
+++ /dev/null
@@ -1,41 +0,0 @@
1/*
2 * Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of version 2 of the GNU General Public License as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it would be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 *
12 * Further, this software is distributed without any warranty that it is
13 * free of the rightful claim of any third person regarding infringement
14 * or the like. Any license provided herein, whether implied or
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */
32
33#ifndef QSORT_H
34#define QSORT_H
35
36extern void qsort (void *const pbase,
37 size_t total_elems,
38 size_t size,
39 int (*cmp)(const void *, const void *));
40
41#endif
diff --git a/fs/xfs/support/uuid.c b/fs/xfs/support/uuid.c
index 81f40cfcb267..70ce40914c8a 100644
--- a/fs/xfs/support/uuid.c
+++ b/fs/xfs/support/uuid.c
@@ -1,35 +1,20 @@
1/* 1/*
2 * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32
33#include <xfs.h> 18#include <xfs.h>
34 19
35static mutex_t uuid_monitor; 20static mutex_t uuid_monitor;
diff --git a/fs/xfs/support/uuid.h b/fs/xfs/support/uuid.h
index 5220ea58ba2b..b6f5922199ba 100644
--- a/fs/xfs/support/uuid.h
+++ b/fs/xfs/support/uuid.h
@@ -1,33 +1,19 @@
1/* 1/*
2 * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32#ifndef __XFS_SUPPORT_UUID_H__ 18#ifndef __XFS_SUPPORT_UUID_H__
33#define __XFS_SUPPORT_UUID_H__ 19#define __XFS_SUPPORT_UUID_H__
@@ -36,13 +22,13 @@ typedef struct {
36 unsigned char __u_bits[16]; 22 unsigned char __u_bits[16];
37} uuid_t; 23} uuid_t;
38 24
39void uuid_init(void); 25extern void uuid_init(void);
40void uuid_create_nil(uuid_t *uuid); 26extern void uuid_create_nil(uuid_t *uuid);
41int uuid_is_nil(uuid_t *uuid); 27extern int uuid_is_nil(uuid_t *uuid);
42int uuid_equal(uuid_t *uuid1, uuid_t *uuid2); 28extern int uuid_equal(uuid_t *uuid1, uuid_t *uuid2);
43void uuid_getnodeuniq(uuid_t *uuid, int fsid [2]); 29extern void uuid_getnodeuniq(uuid_t *uuid, int fsid [2]);
44__uint64_t uuid_hash64(uuid_t *uuid); 30extern __uint64_t uuid_hash64(uuid_t *uuid);
45int uuid_table_insert(uuid_t *uuid); 31extern int uuid_table_insert(uuid_t *uuid);
46void uuid_table_remove(uuid_t *uuid); 32extern void uuid_table_remove(uuid_t *uuid);
47 33
48#endif /* __XFS_SUPPORT_UUID_H__ */ 34#endif /* __XFS_SUPPORT_UUID_H__ */
diff --git a/fs/xfs/xfs.h b/fs/xfs/xfs.h
index 7e276dcaf4dc..99b50d2bda9b 100644
--- a/fs/xfs/xfs.h
+++ b/fs/xfs/xfs.h
@@ -1,40 +1,28 @@
1/* 1/*
2 * Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32#ifndef __XFS_H__ 18#ifndef __XFS_H__
33#define __XFS_H__ 19#define __XFS_H__
34 20
21#include <linux/version.h>
22#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
35#include <linux-2.6/xfs_linux.h> 23#include <linux-2.6/xfs_linux.h>
36 24#else
37#include <xfs_fs.h> 25#include <linux-2.4/xfs_linux.h>
38#include <xfs_macros.h> 26#endif
39 27
40#endif /* __XFS_H__ */ 28#endif /* __XFS_H__ */
diff --git a/fs/xfs/xfs_acl.c b/fs/xfs/xfs_acl.c
index 92fd1d67f878..cc9c91b9e771 100644
--- a/fs/xfs/xfs_acl.c
+++ b/fs/xfs/xfs_acl.c
@@ -1,49 +1,37 @@
1/* 1/*
2 * Copyright (c) 2001-2002 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2001-2002,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32
33#include "xfs.h" 18#include "xfs.h"
34 19#include "xfs_fs.h"
20#include "xfs_types.h"
21#include "xfs_bit.h"
35#include "xfs_inum.h" 22#include "xfs_inum.h"
23#include "xfs_ag.h"
36#include "xfs_dir.h" 24#include "xfs_dir.h"
37#include "xfs_dir2.h" 25#include "xfs_dir2.h"
38#include "xfs_alloc_btree.h"
39#include "xfs_bmap_btree.h" 26#include "xfs_bmap_btree.h"
27#include "xfs_alloc_btree.h"
40#include "xfs_ialloc_btree.h" 28#include "xfs_ialloc_btree.h"
41#include "xfs_btree.h"
42#include "xfs_attr_sf.h"
43#include "xfs_dir_sf.h" 29#include "xfs_dir_sf.h"
44#include "xfs_dir2_sf.h" 30#include "xfs_dir2_sf.h"
31#include "xfs_attr_sf.h"
45#include "xfs_dinode.h" 32#include "xfs_dinode.h"
46#include "xfs_inode.h" 33#include "xfs_inode.h"
34#include "xfs_btree.h"
47#include "xfs_acl.h" 35#include "xfs_acl.h"
48#include "xfs_mac.h" 36#include "xfs_mac.h"
49#include "xfs_attr.h" 37#include "xfs_attr.h"
@@ -155,7 +143,7 @@ posix_acl_xattr_to_xfs(
155} 143}
156 144
157/* 145/*
158 * Comparison function called from qsort(). 146 * Comparison function called from xfs_sort().
159 * Primary key is ae_tag, secondary key is ae_id. 147 * Primary key is ae_tag, secondary key is ae_id.
160 */ 148 */
161STATIC int 149STATIC int
@@ -189,8 +177,8 @@ posix_acl_xfs_to_xattr(
189 return -ERANGE; 177 return -ERANGE;
190 178
191 /* Need to sort src XFS ACL by <ae_tag,ae_id> */ 179 /* Need to sort src XFS ACL by <ae_tag,ae_id> */
192 qsort(src->acl_entry, src->acl_cnt, sizeof(src->acl_entry[0]), 180 xfs_sort(src->acl_entry, src->acl_cnt, sizeof(src->acl_entry[0]),
193 xfs_acl_entry_compare); 181 xfs_acl_entry_compare);
194 182
195 dest->a_version = cpu_to_le32(POSIX_ACL_XATTR_VERSION); 183 dest->a_version = cpu_to_le32(POSIX_ACL_XATTR_VERSION);
196 dest_entry = &dest->a_entries[0]; 184 dest_entry = &dest->a_entries[0];
@@ -448,6 +436,7 @@ xfs_acl_access(
448 int seen_userobj = 0; 436 int seen_userobj = 0;
449 437
450 matched.ae_tag = 0; /* Invalid type */ 438 matched.ae_tag = 0; /* Invalid type */
439 matched.ae_perm = 0;
451 md >>= 6; /* Normalize the bits for comparison */ 440 md >>= 6; /* Normalize the bits for comparison */
452 441
453 for (i = 0; i < fap->acl_cnt; i++) { 442 for (i = 0; i < fap->acl_cnt; i++) {
diff --git a/fs/xfs/xfs_acl.h b/fs/xfs/xfs_acl.h
index 0363eb46d357..f9315bc960cb 100644
--- a/fs/xfs/xfs_acl.h
+++ b/fs/xfs/xfs_acl.h
@@ -1,33 +1,19 @@
1/* 1/*
2 * Copyright (c) 2001-2004 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2001-2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32#ifndef __XFS_ACL_H__ 18#ifndef __XFS_ACL_H__
33#define __XFS_ACL_H__ 19#define __XFS_ACL_H__
diff --git a/fs/xfs/xfs_ag.h b/fs/xfs/xfs_ag.h
index 96b70f7fba39..a96e2ffce0cc 100644
--- a/fs/xfs/xfs_ag.h
+++ b/fs/xfs/xfs_ag.h
@@ -1,33 +1,19 @@
1/* 1/*
2 * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32#ifndef __XFS_AG_H__ 18#ifndef __XFS_AG_H__
33#define __XFS_AG_H__ 19#define __XFS_AG_H__
@@ -46,18 +32,9 @@ struct xfs_trans;
46#define XFS_AGI_MAGIC 0x58414749 /* 'XAGI' */ 32#define XFS_AGI_MAGIC 0x58414749 /* 'XAGI' */
47#define XFS_AGF_VERSION 1 33#define XFS_AGF_VERSION 1
48#define XFS_AGI_VERSION 1 34#define XFS_AGI_VERSION 1
49#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_AGF_GOOD_VERSION) 35
50int xfs_agf_good_version(unsigned v); 36#define XFS_AGF_GOOD_VERSION(v) ((v) == XFS_AGF_VERSION)
51#define XFS_AGF_GOOD_VERSION(v) xfs_agf_good_version(v) 37#define XFS_AGI_GOOD_VERSION(v) ((v) == XFS_AGI_VERSION)
52#else
53#define XFS_AGF_GOOD_VERSION(v) ((v) == XFS_AGF_VERSION)
54#endif
55#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_AGI_GOOD_VERSION)
56int xfs_agi_good_version(unsigned v);
57#define XFS_AGI_GOOD_VERSION(v) xfs_agi_good_version(v)
58#else
59#define XFS_AGI_GOOD_VERSION(v) ((v) == XFS_AGI_VERSION)
60#endif
61 38
62/* 39/*
63 * Btree number 0 is bno, 1 is cnt. This value gives the size of the 40 * Btree number 0 is bno, 1 is cnt. This value gives the size of the
@@ -71,27 +48,26 @@ int xfs_agi_good_version(unsigned v);
71 * are > 64k, our value cannot be confused for an EFS superblock's. 48 * are > 64k, our value cannot be confused for an EFS superblock's.
72 */ 49 */
73 50
74typedef struct xfs_agf 51typedef struct xfs_agf {
75{
76 /* 52 /*
77 * Common allocation group header information 53 * Common allocation group header information
78 */ 54 */
79 __uint32_t agf_magicnum; /* magic number == XFS_AGF_MAGIC */ 55 __be32 agf_magicnum; /* magic number == XFS_AGF_MAGIC */
80 __uint32_t agf_versionnum; /* header version == XFS_AGF_VERSION */ 56 __be32 agf_versionnum; /* header version == XFS_AGF_VERSION */
81 xfs_agnumber_t agf_seqno; /* sequence # starting from 0 */ 57 __be32 agf_seqno; /* sequence # starting from 0 */
82 xfs_agblock_t agf_length; /* size in blocks of a.g. */ 58 __be32 agf_length; /* size in blocks of a.g. */
83 /* 59 /*
84 * Freespace information 60 * Freespace information
85 */ 61 */
86 xfs_agblock_t agf_roots[XFS_BTNUM_AGF]; /* root blocks */ 62 __be32 agf_roots[XFS_BTNUM_AGF]; /* root blocks */
87 __uint32_t agf_spare0; /* spare field */ 63 __be32 agf_spare0; /* spare field */
88 __uint32_t agf_levels[XFS_BTNUM_AGF]; /* btree levels */ 64 __be32 agf_levels[XFS_BTNUM_AGF]; /* btree levels */
89 __uint32_t agf_spare1; /* spare field */ 65 __be32 agf_spare1; /* spare field */
90 __uint32_t agf_flfirst; /* first freelist block's index */ 66 __be32 agf_flfirst; /* first freelist block's index */
91 __uint32_t agf_fllast; /* last freelist block's index */ 67 __be32 agf_fllast; /* last freelist block's index */
92 __uint32_t agf_flcount; /* count of blocks in freelist */ 68 __be32 agf_flcount; /* count of blocks in freelist */
93 xfs_extlen_t agf_freeblks; /* total free blocks */ 69 __be32 agf_freeblks; /* total free blocks */
94 xfs_extlen_t agf_longest; /* longest free space */ 70 __be32 agf_longest; /* longest free space */
95} xfs_agf_t; 71} xfs_agf_t;
96 72
97#define XFS_AGF_MAGICNUM 0x00000001 73#define XFS_AGF_MAGICNUM 0x00000001
@@ -110,43 +86,39 @@ typedef struct xfs_agf
110 86
111/* disk block (xfs_daddr_t) in the AG */ 87/* disk block (xfs_daddr_t) in the AG */
112#define XFS_AGF_DADDR(mp) ((xfs_daddr_t)(1 << (mp)->m_sectbb_log)) 88#define XFS_AGF_DADDR(mp) ((xfs_daddr_t)(1 << (mp)->m_sectbb_log))
113#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_AGF_BLOCK) 89#define XFS_AGF_BLOCK(mp) XFS_HDR_BLOCK(mp, XFS_AGF_DADDR(mp))
114xfs_agblock_t xfs_agf_block(struct xfs_mount *mp); 90#define XFS_BUF_TO_AGF(bp) ((xfs_agf_t *)XFS_BUF_PTR(bp))
115#define XFS_AGF_BLOCK(mp) xfs_agf_block(mp) 91
116#else
117#define XFS_AGF_BLOCK(mp) XFS_HDR_BLOCK(mp, XFS_AGF_DADDR(mp))
118#endif
119 92
120/* 93/*
121 * Size of the unlinked inode hash table in the agi. 94 * Size of the unlinked inode hash table in the agi.
122 */ 95 */
123#define XFS_AGI_UNLINKED_BUCKETS 64 96#define XFS_AGI_UNLINKED_BUCKETS 64
124 97
125typedef struct xfs_agi 98typedef struct xfs_agi {
126{
127 /* 99 /*
128 * Common allocation group header information 100 * Common allocation group header information
129 */ 101 */
130 __uint32_t agi_magicnum; /* magic number == XFS_AGI_MAGIC */ 102 __be32 agi_magicnum; /* magic number == XFS_AGI_MAGIC */
131 __uint32_t agi_versionnum; /* header version == XFS_AGI_VERSION */ 103 __be32 agi_versionnum; /* header version == XFS_AGI_VERSION */
132 xfs_agnumber_t agi_seqno; /* sequence # starting from 0 */ 104 __be32 agi_seqno; /* sequence # starting from 0 */
133 xfs_agblock_t agi_length; /* size in blocks of a.g. */ 105 __be32 agi_length; /* size in blocks of a.g. */
134 /* 106 /*
135 * Inode information 107 * Inode information
136 * Inodes are mapped by interpreting the inode number, so no 108 * Inodes are mapped by interpreting the inode number, so no
137 * mapping data is needed here. 109 * mapping data is needed here.
138 */ 110 */
139 xfs_agino_t agi_count; /* count of allocated inodes */ 111 __be32 agi_count; /* count of allocated inodes */
140 xfs_agblock_t agi_root; /* root of inode btree */ 112 __be32 agi_root; /* root of inode btree */
141 __uint32_t agi_level; /* levels in inode btree */ 113 __be32 agi_level; /* levels in inode btree */
142 xfs_agino_t agi_freecount; /* number of free inodes */ 114 __be32 agi_freecount; /* number of free inodes */
143 xfs_agino_t agi_newino; /* new inode just allocated */ 115 __be32 agi_newino; /* new inode just allocated */
144 xfs_agino_t agi_dirino; /* last directory inode chunk */ 116 __be32 agi_dirino; /* last directory inode chunk */
145 /* 117 /*
146 * Hash table of inodes which have been unlinked but are 118 * Hash table of inodes which have been unlinked but are
147 * still being referenced. 119 * still being referenced.
148 */ 120 */
149 xfs_agino_t agi_unlinked[XFS_AGI_UNLINKED_BUCKETS]; 121 __be32 agi_unlinked[XFS_AGI_UNLINKED_BUCKETS];
150} xfs_agi_t; 122} xfs_agi_t;
151 123
152#define XFS_AGI_MAGICNUM 0x00000001 124#define XFS_AGI_MAGICNUM 0x00000001
@@ -165,25 +137,17 @@ typedef struct xfs_agi
165 137
166/* disk block (xfs_daddr_t) in the AG */ 138/* disk block (xfs_daddr_t) in the AG */
167#define XFS_AGI_DADDR(mp) ((xfs_daddr_t)(2 << (mp)->m_sectbb_log)) 139#define XFS_AGI_DADDR(mp) ((xfs_daddr_t)(2 << (mp)->m_sectbb_log))
168#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_AGI_BLOCK) 140#define XFS_AGI_BLOCK(mp) XFS_HDR_BLOCK(mp, XFS_AGI_DADDR(mp))
169xfs_agblock_t xfs_agi_block(struct xfs_mount *mp); 141#define XFS_BUF_TO_AGI(bp) ((xfs_agi_t *)XFS_BUF_PTR(bp))
170#define XFS_AGI_BLOCK(mp) xfs_agi_block(mp)
171#else
172#define XFS_AGI_BLOCK(mp) XFS_HDR_BLOCK(mp, XFS_AGI_DADDR(mp))
173#endif
174 142
175/* 143/*
176 * The third a.g. block contains the a.g. freelist, an array 144 * The third a.g. block contains the a.g. freelist, an array
177 * of block pointers to blocks owned by the allocation btree code. 145 * of block pointers to blocks owned by the allocation btree code.
178 */ 146 */
179#define XFS_AGFL_DADDR(mp) ((xfs_daddr_t)(3 << (mp)->m_sectbb_log)) 147#define XFS_AGFL_DADDR(mp) ((xfs_daddr_t)(3 << (mp)->m_sectbb_log))
180#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_AGFL_BLOCK) 148#define XFS_AGFL_BLOCK(mp) XFS_HDR_BLOCK(mp, XFS_AGFL_DADDR(mp))
181xfs_agblock_t xfs_agfl_block(struct xfs_mount *mp);
182#define XFS_AGFL_BLOCK(mp) xfs_agfl_block(mp)
183#else
184#define XFS_AGFL_BLOCK(mp) XFS_HDR_BLOCK(mp, XFS_AGFL_DADDR(mp))
185#endif
186#define XFS_AGFL_SIZE(mp) ((mp)->m_sb.sb_sectsize / sizeof(xfs_agblock_t)) 149#define XFS_AGFL_SIZE(mp) ((mp)->m_sb.sb_sectsize / sizeof(xfs_agblock_t))
150#define XFS_BUF_TO_AGFL(bp) ((xfs_agfl_t *)XFS_BUF_PTR(bp))
187 151
188typedef struct xfs_agfl { 152typedef struct xfs_agfl {
189 xfs_agblock_t agfl_bno[1]; /* actually XFS_AGFL_SIZE(mp) */ 153 xfs_agblock_t agfl_bno[1]; /* actually XFS_AGFL_SIZE(mp) */
@@ -230,116 +194,38 @@ typedef struct xfs_perag
230 xfs_perag_busy_t *pagb_list; /* unstable blocks */ 194 xfs_perag_busy_t *pagb_list; /* unstable blocks */
231} xfs_perag_t; 195} xfs_perag_t;
232 196
233#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_AG_MAXLEVELS) 197#define XFS_AG_MAXLEVELS(mp) ((mp)->m_ag_maxlevels)
234int xfs_ag_maxlevels(struct xfs_mount *mp);
235#define XFS_AG_MAXLEVELS(mp) xfs_ag_maxlevels(mp)
236#else
237#define XFS_AG_MAXLEVELS(mp) ((mp)->m_ag_maxlevels)
238#endif
239#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_MIN_FREELIST)
240int xfs_min_freelist(xfs_agf_t *a, struct xfs_mount *mp);
241#define XFS_MIN_FREELIST(a,mp) xfs_min_freelist(a,mp)
242#else
243#define XFS_MIN_FREELIST(a,mp) \
244 XFS_MIN_FREELIST_RAW( \
245 INT_GET((a)->agf_levels[XFS_BTNUM_BNOi], ARCH_CONVERT), \
246 INT_GET((a)->agf_levels[XFS_BTNUM_CNTi], ARCH_CONVERT), mp)
247#endif
248#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_MIN_FREELIST_PAG)
249int xfs_min_freelist_pag(xfs_perag_t *pag, struct xfs_mount *mp);
250#define XFS_MIN_FREELIST_PAG(pag,mp) xfs_min_freelist_pag(pag,mp)
251#else
252#define XFS_MIN_FREELIST_PAG(pag,mp) \
253 XFS_MIN_FREELIST_RAW((uint_t)(pag)->pagf_levels[XFS_BTNUM_BNOi], \
254 (uint_t)(pag)->pagf_levels[XFS_BTNUM_CNTi], mp)
255#endif
256#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_MIN_FREELIST_RAW)
257int xfs_min_freelist_raw(int bl, int cl, struct xfs_mount *mp);
258#define XFS_MIN_FREELIST_RAW(bl,cl,mp) xfs_min_freelist_raw(bl,cl,mp)
259#else
260#define XFS_MIN_FREELIST_RAW(bl,cl,mp) \ 198#define XFS_MIN_FREELIST_RAW(bl,cl,mp) \
261 (MIN(bl + 1, XFS_AG_MAXLEVELS(mp)) + \ 199 (MIN(bl + 1, XFS_AG_MAXLEVELS(mp)) + MIN(cl + 1, XFS_AG_MAXLEVELS(mp)))
262 MIN(cl + 1, XFS_AG_MAXLEVELS(mp))) 200#define XFS_MIN_FREELIST(a,mp) \
263#endif 201 (XFS_MIN_FREELIST_RAW( \
202 be32_to_cpu((a)->agf_levels[XFS_BTNUM_BNOi]), \
203 be32_to_cpu((a)->agf_levels[XFS_BTNUM_CNTi]), mp))
204#define XFS_MIN_FREELIST_PAG(pag,mp) \
205 (XFS_MIN_FREELIST_RAW( \
206 (uint_t)(pag)->pagf_levels[XFS_BTNUM_BNOi], \
207 (uint_t)(pag)->pagf_levels[XFS_BTNUM_CNTi], mp))
264 208
265#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_AGB_TO_FSB) 209#define XFS_AGB_TO_FSB(mp,agno,agbno) \
266xfs_fsblock_t xfs_agb_to_fsb(struct xfs_mount *mp, xfs_agnumber_t agno,
267 xfs_agblock_t agbno);
268#define XFS_AGB_TO_FSB(mp,agno,agbno) xfs_agb_to_fsb(mp,agno,agbno)
269#else
270#define XFS_AGB_TO_FSB(mp,agno,agbno) \
271 (((xfs_fsblock_t)(agno) << (mp)->m_sb.sb_agblklog) | (agbno)) 210 (((xfs_fsblock_t)(agno) << (mp)->m_sb.sb_agblklog) | (agbno))
272#endif 211#define XFS_FSB_TO_AGNO(mp,fsbno) \
273#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_FSB_TO_AGNO)
274xfs_agnumber_t xfs_fsb_to_agno(struct xfs_mount *mp, xfs_fsblock_t fsbno);
275#define XFS_FSB_TO_AGNO(mp,fsbno) xfs_fsb_to_agno(mp,fsbno)
276#else
277#define XFS_FSB_TO_AGNO(mp,fsbno) \
278 ((xfs_agnumber_t)((fsbno) >> (mp)->m_sb.sb_agblklog)) 212 ((xfs_agnumber_t)((fsbno) >> (mp)->m_sb.sb_agblklog))
279#endif 213#define XFS_FSB_TO_AGBNO(mp,fsbno) \
280#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_FSB_TO_AGBNO)
281xfs_agblock_t xfs_fsb_to_agbno(struct xfs_mount *mp, xfs_fsblock_t fsbno);
282#define XFS_FSB_TO_AGBNO(mp,fsbno) xfs_fsb_to_agbno(mp,fsbno)
283#else
284#define XFS_FSB_TO_AGBNO(mp,fsbno) \
285 ((xfs_agblock_t)((fsbno) & XFS_MASK32LO((mp)->m_sb.sb_agblklog))) 214 ((xfs_agblock_t)((fsbno) & XFS_MASK32LO((mp)->m_sb.sb_agblklog)))
286#endif 215#define XFS_AGB_TO_DADDR(mp,agno,agbno) \
287 216 ((xfs_daddr_t)XFS_FSB_TO_BB(mp, \
288#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_AGB_TO_DADDR) 217 (xfs_fsblock_t)(agno) * (mp)->m_sb.sb_agblocks + (agbno)))
289xfs_daddr_t xfs_agb_to_daddr(struct xfs_mount *mp, xfs_agnumber_t agno, 218#define XFS_AG_DADDR(mp,agno,d) (XFS_AGB_TO_DADDR(mp, agno, 0) + (d))
290 xfs_agblock_t agbno);
291#define XFS_AGB_TO_DADDR(mp,agno,agbno) xfs_agb_to_daddr(mp,agno,agbno)
292#else
293#define XFS_AGB_TO_DADDR(mp,agno,agbno) \
294 ((xfs_daddr_t)(XFS_FSB_TO_BB(mp, \
295 (xfs_fsblock_t)(agno) * (mp)->m_sb.sb_agblocks + (agbno))))
296#endif
297/*
298 * XFS_DADDR_TO_AGNO and XFS_DADDR_TO_AGBNO moved to xfs_mount.h
299 * to avoid header file ordering change
300 */
301
302#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_AG_DADDR)
303xfs_daddr_t xfs_ag_daddr(struct xfs_mount *mp, xfs_agnumber_t agno,
304 xfs_daddr_t d);
305#define XFS_AG_DADDR(mp,agno,d) xfs_ag_daddr(mp,agno,d)
306#else
307#define XFS_AG_DADDR(mp,agno,d) (XFS_AGB_TO_DADDR(mp, agno, 0) + (d))
308#endif
309
310#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BUF_TO_AGF)
311xfs_agf_t *xfs_buf_to_agf(struct xfs_buf *bp);
312#define XFS_BUF_TO_AGF(bp) xfs_buf_to_agf(bp)
313#else
314#define XFS_BUF_TO_AGF(bp) ((xfs_agf_t *)XFS_BUF_PTR(bp))
315#endif
316#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BUF_TO_AGI)
317xfs_agi_t *xfs_buf_to_agi(struct xfs_buf *bp);
318#define XFS_BUF_TO_AGI(bp) xfs_buf_to_agi(bp)
319#else
320#define XFS_BUF_TO_AGI(bp) ((xfs_agi_t *)XFS_BUF_PTR(bp))
321#endif
322#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BUF_TO_AGFL)
323xfs_agfl_t *xfs_buf_to_agfl(struct xfs_buf *bp);
324#define XFS_BUF_TO_AGFL(bp) xfs_buf_to_agfl(bp)
325#else
326#define XFS_BUF_TO_AGFL(bp) ((xfs_agfl_t *)XFS_BUF_PTR(bp))
327#endif
328 219
329/* 220/*
330 * For checking for bad ranges of xfs_daddr_t's, covering multiple 221 * For checking for bad ranges of xfs_daddr_t's, covering multiple
331 * allocation groups or a single xfs_daddr_t that's a superblock copy. 222 * allocation groups or a single xfs_daddr_t that's a superblock copy.
332 */ 223 */
333#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_AG_CHECK_DADDR)
334void xfs_ag_check_daddr(struct xfs_mount *mp, xfs_daddr_t d, xfs_extlen_t len);
335#define XFS_AG_CHECK_DADDR(mp,d,len) xfs_ag_check_daddr(mp,d,len)
336#else
337#define XFS_AG_CHECK_DADDR(mp,d,len) \ 224#define XFS_AG_CHECK_DADDR(mp,d,len) \
338 ((len) == 1 ? \ 225 ((len) == 1 ? \
339 ASSERT((d) == XFS_SB_DADDR || \ 226 ASSERT((d) == XFS_SB_DADDR || \
340 XFS_DADDR_TO_AGBNO(mp, d) != XFS_SB_DADDR) : \ 227 XFS_DADDR_TO_AGBNO(mp, d) != XFS_SB_DADDR) : \
341 ASSERT(XFS_DADDR_TO_AGNO(mp, d) == \ 228 ASSERT(XFS_DADDR_TO_AGNO(mp, d) == \
342 XFS_DADDR_TO_AGNO(mp, (d) + (len) - 1))) 229 XFS_DADDR_TO_AGNO(mp, (d) + (len) - 1)))
343#endif
344 230
345#endif /* __XFS_AG_H__ */ 231#endif /* __XFS_AG_H__ */
diff --git a/fs/xfs/xfs_alloc.c b/fs/xfs/xfs_alloc.c
index dcfe19703620..f4328e1e2a74 100644
--- a/fs/xfs/xfs_alloc.c
+++ b/fs/xfs/xfs_alloc.c
@@ -1,56 +1,44 @@
1/* 1/*
2 * Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */
32
33/*
34 * Free space allocation for XFS.
35 */ 17 */
36#include "xfs.h" 18#include "xfs.h"
37#include "xfs_macros.h" 19#include "xfs_fs.h"
38#include "xfs_types.h" 20#include "xfs_types.h"
39#include "xfs_inum.h" 21#include "xfs_bit.h"
40#include "xfs_log.h" 22#include "xfs_log.h"
23#include "xfs_inum.h"
41#include "xfs_trans.h" 24#include "xfs_trans.h"
42#include "xfs_sb.h" 25#include "xfs_sb.h"
43#include "xfs_ag.h" 26#include "xfs_ag.h"
44#include "xfs_dir.h" 27#include "xfs_dir.h"
28#include "xfs_dir2.h"
45#include "xfs_dmapi.h" 29#include "xfs_dmapi.h"
46#include "xfs_mount.h" 30#include "xfs_mount.h"
47#include "xfs_alloc_btree.h"
48#include "xfs_bmap_btree.h" 31#include "xfs_bmap_btree.h"
32#include "xfs_alloc_btree.h"
49#include "xfs_ialloc_btree.h" 33#include "xfs_ialloc_btree.h"
34#include "xfs_dir_sf.h"
35#include "xfs_dir2_sf.h"
36#include "xfs_attr_sf.h"
37#include "xfs_dinode.h"
38#include "xfs_inode.h"
50#include "xfs_btree.h" 39#include "xfs_btree.h"
51#include "xfs_ialloc.h" 40#include "xfs_ialloc.h"
52#include "xfs_alloc.h" 41#include "xfs_alloc.h"
53#include "xfs_bit.h"
54#include "xfs_error.h" 42#include "xfs_error.h"
55 43
56 44
@@ -243,8 +231,8 @@ xfs_alloc_fix_minleft(
243 if (args->minleft == 0) 231 if (args->minleft == 0)
244 return 1; 232 return 1;
245 agf = XFS_BUF_TO_AGF(args->agbp); 233 agf = XFS_BUF_TO_AGF(args->agbp);
246 diff = INT_GET(agf->agf_freeblks, ARCH_CONVERT) 234 diff = be32_to_cpu(agf->agf_freeblks)
247 + INT_GET(agf->agf_flcount, ARCH_CONVERT) 235 + be32_to_cpu(agf->agf_flcount)
248 - args->len - args->minleft; 236 - args->len - args->minleft;
249 if (diff >= 0) 237 if (diff >= 0)
250 return 1; 238 return 1;
@@ -319,7 +307,8 @@ xfs_alloc_fixup_trees(
319 bnoblock = XFS_BUF_TO_ALLOC_BLOCK(bno_cur->bc_bufs[0]); 307 bnoblock = XFS_BUF_TO_ALLOC_BLOCK(bno_cur->bc_bufs[0]);
320 cntblock = XFS_BUF_TO_ALLOC_BLOCK(cnt_cur->bc_bufs[0]); 308 cntblock = XFS_BUF_TO_ALLOC_BLOCK(cnt_cur->bc_bufs[0]);
321 XFS_WANT_CORRUPTED_RETURN( 309 XFS_WANT_CORRUPTED_RETURN(
322 INT_GET(bnoblock->bb_numrecs, ARCH_CONVERT) == INT_GET(cntblock->bb_numrecs, ARCH_CONVERT)); 310 be16_to_cpu(bnoblock->bb_numrecs) ==
311 be16_to_cpu(cntblock->bb_numrecs));
323 } 312 }
324 } 313 }
325#endif 314#endif
@@ -505,21 +494,17 @@ xfs_alloc_trace_modagf(
505 (void *)str, 494 (void *)str,
506 (void *)mp, 495 (void *)mp,
507 (void *)(__psint_t)flags, 496 (void *)(__psint_t)flags,
508 (void *)(__psunsigned_t)INT_GET(agf->agf_seqno, ARCH_CONVERT), 497 (void *)(__psunsigned_t)be32_to_cpu(agf->agf_seqno),
509 (void *)(__psunsigned_t)INT_GET(agf->agf_length, ARCH_CONVERT), 498 (void *)(__psunsigned_t)be32_to_cpu(agf->agf_length),
510 (void *)(__psunsigned_t)INT_GET(agf->agf_roots[XFS_BTNUM_BNO], 499 (void *)(__psunsigned_t)be32_to_cpu(agf->agf_roots[XFS_BTNUM_BNO]),
511 ARCH_CONVERT), 500 (void *)(__psunsigned_t)be32_to_cpu(agf->agf_roots[XFS_BTNUM_CNT]),
512 (void *)(__psunsigned_t)INT_GET(agf->agf_roots[XFS_BTNUM_CNT], 501 (void *)(__psunsigned_t)be32_to_cpu(agf->agf_levels[XFS_BTNUM_BNO]),
513 ARCH_CONVERT), 502 (void *)(__psunsigned_t)be32_to_cpu(agf->agf_levels[XFS_BTNUM_CNT]),
514 (void *)(__psunsigned_t)INT_GET(agf->agf_levels[XFS_BTNUM_BNO], 503 (void *)(__psunsigned_t)be32_to_cpu(agf->agf_flfirst),
515 ARCH_CONVERT), 504 (void *)(__psunsigned_t)be32_to_cpu(agf->agf_fllast),
516 (void *)(__psunsigned_t)INT_GET(agf->agf_levels[XFS_BTNUM_CNT], 505 (void *)(__psunsigned_t)be32_to_cpu(agf->agf_flcount),
517 ARCH_CONVERT), 506 (void *)(__psunsigned_t)be32_to_cpu(agf->agf_freeblks),
518 (void *)(__psunsigned_t)INT_GET(agf->agf_flfirst, ARCH_CONVERT), 507 (void *)(__psunsigned_t)be32_to_cpu(agf->agf_longest));
519 (void *)(__psunsigned_t)INT_GET(agf->agf_fllast, ARCH_CONVERT),
520 (void *)(__psunsigned_t)INT_GET(agf->agf_flcount, ARCH_CONVERT),
521 (void *)(__psunsigned_t)INT_GET(agf->agf_freeblks, ARCH_CONVERT),
522 (void *)(__psunsigned_t)INT_GET(agf->agf_longest, ARCH_CONVERT));
523} 508}
524 509
525STATIC void 510STATIC void
@@ -612,12 +597,12 @@ xfs_alloc_ag_vextent(
612 if (!(args->wasfromfl)) { 597 if (!(args->wasfromfl)) {
613 598
614 agf = XFS_BUF_TO_AGF(args->agbp); 599 agf = XFS_BUF_TO_AGF(args->agbp);
615 INT_MOD(agf->agf_freeblks, ARCH_CONVERT, -(args->len)); 600 be32_add(&agf->agf_freeblks, -(args->len));
616 xfs_trans_agblocks_delta(args->tp, 601 xfs_trans_agblocks_delta(args->tp,
617 -((long)(args->len))); 602 -((long)(args->len)));
618 args->pag->pagf_freeblks -= args->len; 603 args->pag->pagf_freeblks -= args->len;
619 ASSERT(INT_GET(agf->agf_freeblks, ARCH_CONVERT) 604 ASSERT(be32_to_cpu(agf->agf_freeblks) <=
620 <= INT_GET(agf->agf_length, ARCH_CONVERT)); 605 be32_to_cpu(agf->agf_length));
621 TRACE_MODAGF(NULL, agf, XFS_AGF_FREEBLKS); 606 TRACE_MODAGF(NULL, agf, XFS_AGF_FREEBLKS);
622 xfs_alloc_log_agf(args->tp, args->agbp, 607 xfs_alloc_log_agf(args->tp, args->agbp,
623 XFS_AGF_FREEBLKS); 608 XFS_AGF_FREEBLKS);
@@ -723,8 +708,7 @@ xfs_alloc_ag_vextent_exact(
723 cnt_cur = xfs_btree_init_cursor(args->mp, args->tp, args->agbp, 708 cnt_cur = xfs_btree_init_cursor(args->mp, args->tp, args->agbp,
724 args->agno, XFS_BTNUM_CNT, NULL, 0); 709 args->agno, XFS_BTNUM_CNT, NULL, 0);
725 ASSERT(args->agbno + args->len <= 710 ASSERT(args->agbno + args->len <=
726 INT_GET(XFS_BUF_TO_AGF(args->agbp)->agf_length, 711 be32_to_cpu(XFS_BUF_TO_AGF(args->agbp)->agf_length));
727 ARCH_CONVERT));
728 if ((error = xfs_alloc_fixup_trees(cnt_cur, bno_cur, fbno, flen, 712 if ((error = xfs_alloc_fixup_trees(cnt_cur, bno_cur, fbno, flen,
729 args->agbno, args->len, XFSA_FIXUP_BNO_OK))) { 713 args->agbno, args->len, XFSA_FIXUP_BNO_OK))) {
730 xfs_btree_del_cursor(cnt_cur, XFS_BTREE_ERROR); 714 xfs_btree_del_cursor(cnt_cur, XFS_BTREE_ERROR);
@@ -897,8 +881,7 @@ xfs_alloc_ag_vextent_near(
897 goto error0; 881 goto error0;
898 XFS_WANT_CORRUPTED_GOTO(i == 1, error0); 882 XFS_WANT_CORRUPTED_GOTO(i == 1, error0);
899 ltend = ltbno + ltlen; 883 ltend = ltbno + ltlen;
900 ASSERT(ltend <= INT_GET(XFS_BUF_TO_AGF(args->agbp)->agf_length, 884 ASSERT(ltend <= be32_to_cpu(XFS_BUF_TO_AGF(args->agbp)->agf_length));
901 ARCH_CONVERT));
902 args->len = blen; 885 args->len = blen;
903 if (!xfs_alloc_fix_minleft(args)) { 886 if (!xfs_alloc_fix_minleft(args)) {
904 xfs_btree_del_cursor(cnt_cur, XFS_BTREE_NOERROR); 887 xfs_btree_del_cursor(cnt_cur, XFS_BTREE_NOERROR);
@@ -1253,8 +1236,7 @@ xfs_alloc_ag_vextent_near(
1253 ltlen, &ltnew); 1236 ltlen, &ltnew);
1254 ASSERT(ltnew >= ltbno); 1237 ASSERT(ltnew >= ltbno);
1255 ASSERT(ltnew + rlen <= ltend); 1238 ASSERT(ltnew + rlen <= ltend);
1256 ASSERT(ltnew + rlen <= INT_GET(XFS_BUF_TO_AGF(args->agbp)->agf_length, 1239 ASSERT(ltnew + rlen <= be32_to_cpu(XFS_BUF_TO_AGF(args->agbp)->agf_length));
1257 ARCH_CONVERT));
1258 args->agbno = ltnew; 1240 args->agbno = ltnew;
1259 if ((error = xfs_alloc_fixup_trees(cnt_cur, bno_cur_lt, ltbno, ltlen, 1241 if ((error = xfs_alloc_fixup_trees(cnt_cur, bno_cur_lt, ltbno, ltlen,
1260 ltnew, rlen, XFSA_FIXUP_BNO_OK))) 1242 ltnew, rlen, XFSA_FIXUP_BNO_OK)))
@@ -1417,8 +1399,7 @@ xfs_alloc_ag_vextent_size(
1417 args->agbno = rbno; 1399 args->agbno = rbno;
1418 XFS_WANT_CORRUPTED_GOTO( 1400 XFS_WANT_CORRUPTED_GOTO(
1419 args->agbno + args->len <= 1401 args->agbno + args->len <=
1420 INT_GET(XFS_BUF_TO_AGF(args->agbp)->agf_length, 1402 be32_to_cpu(XFS_BUF_TO_AGF(args->agbp)->agf_length),
1421 ARCH_CONVERT),
1422 error0); 1403 error0);
1423 TRACE_ALLOC("normal", args); 1404 TRACE_ALLOC("normal", args);
1424 return 0; 1405 return 0;
@@ -1466,8 +1447,8 @@ xfs_alloc_ag_vextent_small(
1466 * freelist. 1447 * freelist.
1467 */ 1448 */
1468 else if (args->minlen == 1 && args->alignment == 1 && !args->isfl && 1449 else if (args->minlen == 1 && args->alignment == 1 && !args->isfl &&
1469 (INT_GET(XFS_BUF_TO_AGF(args->agbp)->agf_flcount, 1450 (be32_to_cpu(XFS_BUF_TO_AGF(args->agbp)->agf_flcount)
1470 ARCH_CONVERT) > args->minleft)) { 1451 > args->minleft)) {
1471 if ((error = xfs_alloc_get_freelist(args->tp, args->agbp, &fbno))) 1452 if ((error = xfs_alloc_get_freelist(args->tp, args->agbp, &fbno)))
1472 goto error0; 1453 goto error0;
1473 if (fbno != NULLAGBLOCK) { 1454 if (fbno != NULLAGBLOCK) {
@@ -1482,8 +1463,7 @@ xfs_alloc_ag_vextent_small(
1482 args->agbno = fbno; 1463 args->agbno = fbno;
1483 XFS_WANT_CORRUPTED_GOTO( 1464 XFS_WANT_CORRUPTED_GOTO(
1484 args->agbno + args->len <= 1465 args->agbno + args->len <=
1485 INT_GET(XFS_BUF_TO_AGF(args->agbp)->agf_length, 1466 be32_to_cpu(XFS_BUF_TO_AGF(args->agbp)->agf_length),
1486 ARCH_CONVERT),
1487 error0); 1467 error0);
1488 args->wasfromfl = 1; 1468 args->wasfromfl = 1;
1489 TRACE_ALLOC("freelist", args); 1469 TRACE_ALLOC("freelist", args);
@@ -1757,12 +1737,12 @@ xfs_free_ag_extent(
1757 1737
1758 agf = XFS_BUF_TO_AGF(agbp); 1738 agf = XFS_BUF_TO_AGF(agbp);
1759 pag = &mp->m_perag[agno]; 1739 pag = &mp->m_perag[agno];
1760 INT_MOD(agf->agf_freeblks, ARCH_CONVERT, len); 1740 be32_add(&agf->agf_freeblks, len);
1761 xfs_trans_agblocks_delta(tp, len); 1741 xfs_trans_agblocks_delta(tp, len);
1762 pag->pagf_freeblks += len; 1742 pag->pagf_freeblks += len;
1763 XFS_WANT_CORRUPTED_GOTO( 1743 XFS_WANT_CORRUPTED_GOTO(
1764 INT_GET(agf->agf_freeblks, ARCH_CONVERT) 1744 be32_to_cpu(agf->agf_freeblks) <=
1765 <= INT_GET(agf->agf_length, ARCH_CONVERT), 1745 be32_to_cpu(agf->agf_length),
1766 error0); 1746 error0);
1767 TRACE_MODAGF(NULL, agf, XFS_AGF_FREEBLKS); 1747 TRACE_MODAGF(NULL, agf, XFS_AGF_FREEBLKS);
1768 xfs_alloc_log_agf(tp, agbp, XFS_AGF_FREEBLKS); 1748 xfs_alloc_log_agf(tp, agbp, XFS_AGF_FREEBLKS);
@@ -1909,18 +1889,18 @@ xfs_alloc_fix_freelist(
1909 */ 1889 */
1910 agf = XFS_BUF_TO_AGF(agbp); 1890 agf = XFS_BUF_TO_AGF(agbp);
1911 need = XFS_MIN_FREELIST(agf, mp); 1891 need = XFS_MIN_FREELIST(agf, mp);
1912 delta = need > INT_GET(agf->agf_flcount, ARCH_CONVERT) ? 1892 delta = need > be32_to_cpu(agf->agf_flcount) ?
1913 (need - INT_GET(agf->agf_flcount, ARCH_CONVERT)) : 0; 1893 (need - be32_to_cpu(agf->agf_flcount)) : 0;
1914 /* 1894 /*
1915 * If there isn't enough total or single-extent, reject it. 1895 * If there isn't enough total or single-extent, reject it.
1916 */ 1896 */
1917 longest = INT_GET(agf->agf_longest, ARCH_CONVERT); 1897 longest = be32_to_cpu(agf->agf_longest);
1918 longest = (longest > delta) ? (longest - delta) : 1898 longest = (longest > delta) ? (longest - delta) :
1919 (INT_GET(agf->agf_flcount, ARCH_CONVERT) > 0 || longest > 0); 1899 (be32_to_cpu(agf->agf_flcount) > 0 || longest > 0);
1920 if (args->minlen + args->alignment + args->minalignslop - 1 > longest || 1900 if (args->minlen + args->alignment + args->minalignslop - 1 > longest ||
1921 (args->minleft && 1901 (args->minleft &&
1922 (int)(INT_GET(agf->agf_freeblks, ARCH_CONVERT) + 1902 (int)(be32_to_cpu(agf->agf_freeblks) +
1923 INT_GET(agf->agf_flcount, ARCH_CONVERT) - need - args->total) < 1903 be32_to_cpu(agf->agf_flcount) - need - args->total) <
1924 (int)args->minleft)) { 1904 (int)args->minleft)) {
1925 xfs_trans_brelse(tp, agbp); 1905 xfs_trans_brelse(tp, agbp);
1926 args->agbp = NULL; 1906 args->agbp = NULL;
@@ -1929,7 +1909,7 @@ xfs_alloc_fix_freelist(
1929 /* 1909 /*
1930 * Make the freelist shorter if it's too long. 1910 * Make the freelist shorter if it's too long.
1931 */ 1911 */
1932 while (INT_GET(agf->agf_flcount, ARCH_CONVERT) > need) { 1912 while (be32_to_cpu(agf->agf_flcount) > need) {
1933 xfs_buf_t *bp; 1913 xfs_buf_t *bp;
1934 1914
1935 if ((error = xfs_alloc_get_freelist(tp, agbp, &bno))) 1915 if ((error = xfs_alloc_get_freelist(tp, agbp, &bno)))
@@ -1956,9 +1936,9 @@ xfs_alloc_fix_freelist(
1956 /* 1936 /*
1957 * Make the freelist longer if it's too short. 1937 * Make the freelist longer if it's too short.
1958 */ 1938 */
1959 while (INT_GET(agf->agf_flcount, ARCH_CONVERT) < need) { 1939 while (be32_to_cpu(agf->agf_flcount) < need) {
1960 targs.agbno = 0; 1940 targs.agbno = 0;
1961 targs.maxlen = need - INT_GET(agf->agf_flcount, ARCH_CONVERT); 1941 targs.maxlen = need - be32_to_cpu(agf->agf_flcount);
1962 /* 1942 /*
1963 * Allocate as many blocks as possible at once. 1943 * Allocate as many blocks as possible at once.
1964 */ 1944 */
@@ -2018,19 +1998,19 @@ xfs_alloc_get_freelist(
2018 */ 1998 */
2019 mp = tp->t_mountp; 1999 mp = tp->t_mountp;
2020 if ((error = xfs_alloc_read_agfl(mp, tp, 2000 if ((error = xfs_alloc_read_agfl(mp, tp,
2021 INT_GET(agf->agf_seqno, ARCH_CONVERT), &agflbp))) 2001 be32_to_cpu(agf->agf_seqno), &agflbp)))
2022 return error; 2002 return error;
2023 agfl = XFS_BUF_TO_AGFL(agflbp); 2003 agfl = XFS_BUF_TO_AGFL(agflbp);
2024 /* 2004 /*
2025 * Get the block number and update the data structures. 2005 * Get the block number and update the data structures.
2026 */ 2006 */
2027 bno = INT_GET(agfl->agfl_bno[INT_GET(agf->agf_flfirst, ARCH_CONVERT)], ARCH_CONVERT); 2007 bno = INT_GET(agfl->agfl_bno[be32_to_cpu(agf->agf_flfirst)], ARCH_CONVERT);
2028 INT_MOD(agf->agf_flfirst, ARCH_CONVERT, 1); 2008 be32_add(&agf->agf_flfirst, 1);
2029 xfs_trans_brelse(tp, agflbp); 2009 xfs_trans_brelse(tp, agflbp);
2030 if (INT_GET(agf->agf_flfirst, ARCH_CONVERT) == XFS_AGFL_SIZE(mp)) 2010 if (be32_to_cpu(agf->agf_flfirst) == XFS_AGFL_SIZE(mp))
2031 agf->agf_flfirst = 0; 2011 agf->agf_flfirst = 0;
2032 pag = &mp->m_perag[INT_GET(agf->agf_seqno, ARCH_CONVERT)]; 2012 pag = &mp->m_perag[be32_to_cpu(agf->agf_seqno)];
2033 INT_MOD(agf->agf_flcount, ARCH_CONVERT, -1); 2013 be32_add(&agf->agf_flcount, -1);
2034 xfs_trans_agflist_delta(tp, -1); 2014 xfs_trans_agflist_delta(tp, -1);
2035 pag->pagf_flcount--; 2015 pag->pagf_flcount--;
2036 TRACE_MODAGF(NULL, agf, XFS_AGF_FLFIRST | XFS_AGF_FLCOUNT); 2016 TRACE_MODAGF(NULL, agf, XFS_AGF_FLFIRST | XFS_AGF_FLCOUNT);
@@ -2045,7 +2025,7 @@ xfs_alloc_get_freelist(
2045 * the freeing transaction must be pushed to disk NOW by forcing 2025 * the freeing transaction must be pushed to disk NOW by forcing
2046 * to disk all iclogs up that transaction's LSN. 2026 * to disk all iclogs up that transaction's LSN.
2047 */ 2027 */
2048 xfs_alloc_search_busy(tp, INT_GET(agf->agf_seqno, ARCH_CONVERT), bno, 1); 2028 xfs_alloc_search_busy(tp, be32_to_cpu(agf->agf_seqno), bno, 1);
2049 return 0; 2029 return 0;
2050} 2030}
2051 2031
@@ -2123,18 +2103,18 @@ xfs_alloc_put_freelist(
2123 mp = tp->t_mountp; 2103 mp = tp->t_mountp;
2124 2104
2125 if (!agflbp && (error = xfs_alloc_read_agfl(mp, tp, 2105 if (!agflbp && (error = xfs_alloc_read_agfl(mp, tp,
2126 INT_GET(agf->agf_seqno, ARCH_CONVERT), &agflbp))) 2106 be32_to_cpu(agf->agf_seqno), &agflbp)))
2127 return error; 2107 return error;
2128 agfl = XFS_BUF_TO_AGFL(agflbp); 2108 agfl = XFS_BUF_TO_AGFL(agflbp);
2129 INT_MOD(agf->agf_fllast, ARCH_CONVERT, 1); 2109 be32_add(&agf->agf_fllast, 1);
2130 if (INT_GET(agf->agf_fllast, ARCH_CONVERT) == XFS_AGFL_SIZE(mp)) 2110 if (be32_to_cpu(agf->agf_fllast) == XFS_AGFL_SIZE(mp))
2131 agf->agf_fllast = 0; 2111 agf->agf_fllast = 0;
2132 pag = &mp->m_perag[INT_GET(agf->agf_seqno, ARCH_CONVERT)]; 2112 pag = &mp->m_perag[be32_to_cpu(agf->agf_seqno)];
2133 INT_MOD(agf->agf_flcount, ARCH_CONVERT, 1); 2113 be32_add(&agf->agf_flcount, 1);
2134 xfs_trans_agflist_delta(tp, 1); 2114 xfs_trans_agflist_delta(tp, 1);
2135 pag->pagf_flcount++; 2115 pag->pagf_flcount++;
2136 ASSERT(INT_GET(agf->agf_flcount, ARCH_CONVERT) <= XFS_AGFL_SIZE(mp)); 2116 ASSERT(be32_to_cpu(agf->agf_flcount) <= XFS_AGFL_SIZE(mp));
2137 blockp = &agfl->agfl_bno[INT_GET(agf->agf_fllast, ARCH_CONVERT)]; 2117 blockp = &agfl->agfl_bno[be32_to_cpu(agf->agf_fllast)];
2138 INT_SET(*blockp, ARCH_CONVERT, bno); 2118 INT_SET(*blockp, ARCH_CONVERT, bno);
2139 TRACE_MODAGF(NULL, agf, XFS_AGF_FLLAST | XFS_AGF_FLCOUNT); 2119 TRACE_MODAGF(NULL, agf, XFS_AGF_FLLAST | XFS_AGF_FLCOUNT);
2140 xfs_alloc_log_agf(tp, agbp, XFS_AGF_FLLAST | XFS_AGF_FLCOUNT); 2120 xfs_alloc_log_agf(tp, agbp, XFS_AGF_FLLAST | XFS_AGF_FLCOUNT);
@@ -2181,14 +2161,12 @@ xfs_alloc_read_agf(
2181 */ 2161 */
2182 agf = XFS_BUF_TO_AGF(bp); 2162 agf = XFS_BUF_TO_AGF(bp);
2183 agf_ok = 2163 agf_ok =
2184 INT_GET(agf->agf_magicnum, ARCH_CONVERT) == XFS_AGF_MAGIC && 2164 be32_to_cpu(agf->agf_magicnum) == XFS_AGF_MAGIC &&
2185 XFS_AGF_GOOD_VERSION( 2165 XFS_AGF_GOOD_VERSION(be32_to_cpu(agf->agf_versionnum)) &&
2186 INT_GET(agf->agf_versionnum, ARCH_CONVERT)) && 2166 be32_to_cpu(agf->agf_freeblks) <= be32_to_cpu(agf->agf_length) &&
2187 INT_GET(agf->agf_freeblks, ARCH_CONVERT) <= 2167 be32_to_cpu(agf->agf_flfirst) < XFS_AGFL_SIZE(mp) &&
2188 INT_GET(agf->agf_length, ARCH_CONVERT) && 2168 be32_to_cpu(agf->agf_fllast) < XFS_AGFL_SIZE(mp) &&
2189 INT_GET(agf->agf_flfirst, ARCH_CONVERT) < XFS_AGFL_SIZE(mp) && 2169 be32_to_cpu(agf->agf_flcount) <= XFS_AGFL_SIZE(mp);
2190 INT_GET(agf->agf_fllast, ARCH_CONVERT) < XFS_AGFL_SIZE(mp) &&
2191 INT_GET(agf->agf_flcount, ARCH_CONVERT) <= XFS_AGFL_SIZE(mp);
2192 if (unlikely(XFS_TEST_ERROR(!agf_ok, mp, XFS_ERRTAG_ALLOC_READ_AGF, 2170 if (unlikely(XFS_TEST_ERROR(!agf_ok, mp, XFS_ERRTAG_ALLOC_READ_AGF,
2193 XFS_RANDOM_ALLOC_READ_AGF))) { 2171 XFS_RANDOM_ALLOC_READ_AGF))) {
2194 XFS_CORRUPTION_ERROR("xfs_alloc_read_agf", 2172 XFS_CORRUPTION_ERROR("xfs_alloc_read_agf",
@@ -2198,13 +2176,13 @@ xfs_alloc_read_agf(
2198 } 2176 }
2199 pag = &mp->m_perag[agno]; 2177 pag = &mp->m_perag[agno];
2200 if (!pag->pagf_init) { 2178 if (!pag->pagf_init) {
2201 pag->pagf_freeblks = INT_GET(agf->agf_freeblks, ARCH_CONVERT); 2179 pag->pagf_freeblks = be32_to_cpu(agf->agf_freeblks);
2202 pag->pagf_flcount = INT_GET(agf->agf_flcount, ARCH_CONVERT); 2180 pag->pagf_flcount = be32_to_cpu(agf->agf_flcount);
2203 pag->pagf_longest = INT_GET(agf->agf_longest, ARCH_CONVERT); 2181 pag->pagf_longest = be32_to_cpu(agf->agf_longest);
2204 pag->pagf_levels[XFS_BTNUM_BNOi] = 2182 pag->pagf_levels[XFS_BTNUM_BNOi] =
2205 INT_GET(agf->agf_levels[XFS_BTNUM_BNOi], ARCH_CONVERT); 2183 be32_to_cpu(agf->agf_levels[XFS_BTNUM_BNOi]);
2206 pag->pagf_levels[XFS_BTNUM_CNTi] = 2184 pag->pagf_levels[XFS_BTNUM_CNTi] =
2207 INT_GET(agf->agf_levels[XFS_BTNUM_CNTi], ARCH_CONVERT); 2185 be32_to_cpu(agf->agf_levels[XFS_BTNUM_CNTi]);
2208 spinlock_init(&pag->pagb_lock, "xfspagb"); 2186 spinlock_init(&pag->pagb_lock, "xfspagb");
2209 pag->pagb_list = kmem_zalloc(XFS_PAGB_NUM_SLOTS * 2187 pag->pagb_list = kmem_zalloc(XFS_PAGB_NUM_SLOTS *
2210 sizeof(xfs_perag_busy_t), KM_SLEEP); 2188 sizeof(xfs_perag_busy_t), KM_SLEEP);
@@ -2212,13 +2190,13 @@ xfs_alloc_read_agf(
2212 } 2190 }
2213#ifdef DEBUG 2191#ifdef DEBUG
2214 else if (!XFS_FORCED_SHUTDOWN(mp)) { 2192 else if (!XFS_FORCED_SHUTDOWN(mp)) {
2215 ASSERT(pag->pagf_freeblks == INT_GET(agf->agf_freeblks, ARCH_CONVERT)); 2193 ASSERT(pag->pagf_freeblks == be32_to_cpu(agf->agf_freeblks));
2216 ASSERT(pag->pagf_flcount == INT_GET(agf->agf_flcount, ARCH_CONVERT)); 2194 ASSERT(pag->pagf_flcount == be32_to_cpu(agf->agf_flcount));
2217 ASSERT(pag->pagf_longest == INT_GET(agf->agf_longest, ARCH_CONVERT)); 2195 ASSERT(pag->pagf_longest == be32_to_cpu(agf->agf_longest));
2218 ASSERT(pag->pagf_levels[XFS_BTNUM_BNOi] == 2196 ASSERT(pag->pagf_levels[XFS_BTNUM_BNOi] ==
2219 INT_GET(agf->agf_levels[XFS_BTNUM_BNOi], ARCH_CONVERT)); 2197 be32_to_cpu(agf->agf_levels[XFS_BTNUM_BNOi]));
2220 ASSERT(pag->pagf_levels[XFS_BTNUM_CNTi] == 2198 ASSERT(pag->pagf_levels[XFS_BTNUM_CNTi] ==
2221 INT_GET(agf->agf_levels[XFS_BTNUM_CNTi], ARCH_CONVERT)); 2199 be32_to_cpu(agf->agf_levels[XFS_BTNUM_CNTi]));
2222 } 2200 }
2223#endif 2201#endif
2224 XFS_BUF_SET_VTYPE_REF(bp, B_FS_AGF, XFS_AGF_REF); 2202 XFS_BUF_SET_VTYPE_REF(bp, B_FS_AGF, XFS_AGF_REF);
@@ -2467,7 +2445,7 @@ xfs_free_extent(
2467#ifdef DEBUG 2445#ifdef DEBUG
2468 ASSERT(args.agbp != NULL); 2446 ASSERT(args.agbp != NULL);
2469 agf = XFS_BUF_TO_AGF(args.agbp); 2447 agf = XFS_BUF_TO_AGF(args.agbp);
2470 ASSERT(args.agbno + len <= INT_GET(agf->agf_length, ARCH_CONVERT)); 2448 ASSERT(args.agbno + len <= be32_to_cpu(agf->agf_length));
2471#endif 2449#endif
2472 error = xfs_free_ag_extent(tp, args.agbp, args.agno, args.agbno, 2450 error = xfs_free_ag_extent(tp, args.agbp, args.agno, args.agbno,
2473 len, 0); 2451 len, 0);
diff --git a/fs/xfs/xfs_alloc.h b/fs/xfs/xfs_alloc.h
index 72329c86351c..3546dea27b7d 100644
--- a/fs/xfs/xfs_alloc.h
+++ b/fs/xfs/xfs_alloc.h
@@ -1,33 +1,19 @@
1/* 1/*
2 * Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32#ifndef __XFS_ALLOC_H__ 18#ifndef __XFS_ALLOC_H__
33#define __XFS_ALLOC_H__ 19#define __XFS_ALLOC_H__
diff --git a/fs/xfs/xfs_alloc_btree.c b/fs/xfs/xfs_alloc_btree.c
index e0355a12d946..a1d92da86ccd 100644
--- a/fs/xfs/xfs_alloc_btree.c
+++ b/fs/xfs/xfs_alloc_btree.c
@@ -1,53 +1,41 @@
1/* 1/*
2 * Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2001,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32
33/*
34 * Free space allocation for XFS.
35 */
36
37#include "xfs.h" 18#include "xfs.h"
38#include "xfs_macros.h" 19#include "xfs_fs.h"
39#include "xfs_types.h" 20#include "xfs_types.h"
40#include "xfs_inum.h" 21#include "xfs_bit.h"
41#include "xfs_log.h" 22#include "xfs_log.h"
23#include "xfs_inum.h"
42#include "xfs_trans.h" 24#include "xfs_trans.h"
43#include "xfs_sb.h" 25#include "xfs_sb.h"
44#include "xfs_ag.h" 26#include "xfs_ag.h"
45#include "xfs_dir.h" 27#include "xfs_dir.h"
28#include "xfs_dir2.h"
46#include "xfs_dmapi.h" 29#include "xfs_dmapi.h"
47#include "xfs_mount.h" 30#include "xfs_mount.h"
31#include "xfs_bmap_btree.h"
48#include "xfs_alloc_btree.h" 32#include "xfs_alloc_btree.h"
49#include "xfs_ialloc_btree.h" 33#include "xfs_ialloc_btree.h"
50#include "xfs_bmap_btree.h" 34#include "xfs_dir_sf.h"
35#include "xfs_dir2_sf.h"
36#include "xfs_attr_sf.h"
37#include "xfs_dinode.h"
38#include "xfs_inode.h"
51#include "xfs_btree.h" 39#include "xfs_btree.h"
52#include "xfs_ialloc.h" 40#include "xfs_ialloc.h"
53#include "xfs_alloc.h" 41#include "xfs_alloc.h"
@@ -129,7 +117,7 @@ xfs_alloc_delrec(
129 /* 117 /*
130 * Fail if we're off the end of the block. 118 * Fail if we're off the end of the block.
131 */ 119 */
132 if (ptr > INT_GET(block->bb_numrecs, ARCH_CONVERT)) { 120 if (ptr > be16_to_cpu(block->bb_numrecs)) {
133 *stat = 0; 121 *stat = 0;
134 return 0; 122 return 0;
135 } 123 }
@@ -143,18 +131,18 @@ xfs_alloc_delrec(
143 lkp = XFS_ALLOC_KEY_ADDR(block, 1, cur); 131 lkp = XFS_ALLOC_KEY_ADDR(block, 1, cur);
144 lpp = XFS_ALLOC_PTR_ADDR(block, 1, cur); 132 lpp = XFS_ALLOC_PTR_ADDR(block, 1, cur);
145#ifdef DEBUG 133#ifdef DEBUG
146 for (i = ptr; i < INT_GET(block->bb_numrecs, ARCH_CONVERT); i++) { 134 for (i = ptr; i < be16_to_cpu(block->bb_numrecs); i++) {
147 if ((error = xfs_btree_check_sptr(cur, INT_GET(lpp[i], ARCH_CONVERT), level))) 135 if ((error = xfs_btree_check_sptr(cur, be32_to_cpu(lpp[i]), level)))
148 return error; 136 return error;
149 } 137 }
150#endif 138#endif
151 if (ptr < INT_GET(block->bb_numrecs, ARCH_CONVERT)) { 139 if (ptr < be16_to_cpu(block->bb_numrecs)) {
152 memmove(&lkp[ptr - 1], &lkp[ptr], 140 memmove(&lkp[ptr - 1], &lkp[ptr],
153 (INT_GET(block->bb_numrecs, ARCH_CONVERT) - ptr) * sizeof(*lkp)); /* INT_: mem copy */ 141 (be16_to_cpu(block->bb_numrecs) - ptr) * sizeof(*lkp));
154 memmove(&lpp[ptr - 1], &lpp[ptr], 142 memmove(&lpp[ptr - 1], &lpp[ptr],
155 (INT_GET(block->bb_numrecs, ARCH_CONVERT) - ptr) * sizeof(*lpp)); /* INT_: mem copy */ 143 (be16_to_cpu(block->bb_numrecs) - ptr) * sizeof(*lpp));
156 xfs_alloc_log_ptrs(cur, bp, ptr, INT_GET(block->bb_numrecs, ARCH_CONVERT) - 1); 144 xfs_alloc_log_ptrs(cur, bp, ptr, be16_to_cpu(block->bb_numrecs) - 1);
157 xfs_alloc_log_keys(cur, bp, ptr, INT_GET(block->bb_numrecs, ARCH_CONVERT) - 1); 145 xfs_alloc_log_keys(cur, bp, ptr, be16_to_cpu(block->bb_numrecs) - 1);
158 } 146 }
159 } 147 }
160 /* 148 /*
@@ -163,25 +151,25 @@ xfs_alloc_delrec(
163 */ 151 */
164 else { 152 else {
165 lrp = XFS_ALLOC_REC_ADDR(block, 1, cur); 153 lrp = XFS_ALLOC_REC_ADDR(block, 1, cur);
166 if (ptr < INT_GET(block->bb_numrecs, ARCH_CONVERT)) { 154 if (ptr < be16_to_cpu(block->bb_numrecs)) {
167 memmove(&lrp[ptr - 1], &lrp[ptr], 155 memmove(&lrp[ptr - 1], &lrp[ptr],
168 (INT_GET(block->bb_numrecs, ARCH_CONVERT) - ptr) * sizeof(*lrp)); 156 (be16_to_cpu(block->bb_numrecs) - ptr) * sizeof(*lrp));
169 xfs_alloc_log_recs(cur, bp, ptr, INT_GET(block->bb_numrecs, ARCH_CONVERT) - 1); 157 xfs_alloc_log_recs(cur, bp, ptr, be16_to_cpu(block->bb_numrecs) - 1);
170 } 158 }
171 /* 159 /*
172 * If it's the first record in the block, we'll need a key 160 * If it's the first record in the block, we'll need a key
173 * structure to pass up to the next level (updkey). 161 * structure to pass up to the next level (updkey).
174 */ 162 */
175 if (ptr == 1) { 163 if (ptr == 1) {
176 key.ar_startblock = lrp->ar_startblock; /* INT_: direct copy */ 164 key.ar_startblock = lrp->ar_startblock;
177 key.ar_blockcount = lrp->ar_blockcount; /* INT_: direct copy */ 165 key.ar_blockcount = lrp->ar_blockcount;
178 lkp = &key; 166 lkp = &key;
179 } 167 }
180 } 168 }
181 /* 169 /*
182 * Decrement and log the number of entries in the block. 170 * Decrement and log the number of entries in the block.
183 */ 171 */
184 INT_MOD(block->bb_numrecs, ARCH_CONVERT, -1); 172 be16_add(&block->bb_numrecs, -1);
185 xfs_alloc_log_block(cur->bc_tp, bp, XFS_BB_NUMRECS); 173 xfs_alloc_log_block(cur->bc_tp, bp, XFS_BB_NUMRECS);
186 /* 174 /*
187 * See if the longest free extent in the allocation group was 175 * See if the longest free extent in the allocation group was
@@ -194,24 +182,24 @@ xfs_alloc_delrec(
194 182
195 if (level == 0 && 183 if (level == 0 &&
196 cur->bc_btnum == XFS_BTNUM_CNT && 184 cur->bc_btnum == XFS_BTNUM_CNT &&
197 INT_GET(block->bb_rightsib, ARCH_CONVERT) == NULLAGBLOCK && 185 be32_to_cpu(block->bb_rightsib) == NULLAGBLOCK &&
198 ptr > INT_GET(block->bb_numrecs, ARCH_CONVERT)) { 186 ptr > be16_to_cpu(block->bb_numrecs)) {
199 ASSERT(ptr == INT_GET(block->bb_numrecs, ARCH_CONVERT) + 1); 187 ASSERT(ptr == be16_to_cpu(block->bb_numrecs) + 1);
200 /* 188 /*
201 * There are still records in the block. Grab the size 189 * There are still records in the block. Grab the size
202 * from the last one. 190 * from the last one.
203 */ 191 */
204 if (INT_GET(block->bb_numrecs, ARCH_CONVERT)) { 192 if (be16_to_cpu(block->bb_numrecs)) {
205 rrp = XFS_ALLOC_REC_ADDR(block, INT_GET(block->bb_numrecs, ARCH_CONVERT), cur); 193 rrp = XFS_ALLOC_REC_ADDR(block, be16_to_cpu(block->bb_numrecs), cur);
206 INT_COPY(agf->agf_longest, rrp->ar_blockcount, ARCH_CONVERT); 194 agf->agf_longest = rrp->ar_blockcount;
207 } 195 }
208 /* 196 /*
209 * No free extents left. 197 * No free extents left.
210 */ 198 */
211 else 199 else
212 agf->agf_longest = 0; 200 agf->agf_longest = 0;
213 mp->m_perag[INT_GET(agf->agf_seqno, ARCH_CONVERT)].pagf_longest = 201 mp->m_perag[be32_to_cpu(agf->agf_seqno)].pagf_longest =
214 INT_GET(agf->agf_longest, ARCH_CONVERT); 202 be32_to_cpu(agf->agf_longest);
215 xfs_alloc_log_agf(cur->bc_tp, cur->bc_private.a.agbp, 203 xfs_alloc_log_agf(cur->bc_tp, cur->bc_private.a.agbp,
216 XFS_AGF_LONGEST); 204 XFS_AGF_LONGEST);
217 } 205 }
@@ -225,15 +213,15 @@ xfs_alloc_delrec(
225 * and it's NOT the leaf level, 213 * and it's NOT the leaf level,
226 * then we can get rid of this level. 214 * then we can get rid of this level.
227 */ 215 */
228 if (INT_GET(block->bb_numrecs, ARCH_CONVERT) == 1 && level > 0) { 216 if (be16_to_cpu(block->bb_numrecs) == 1 && level > 0) {
229 /* 217 /*
230 * lpp is still set to the first pointer in the block. 218 * lpp is still set to the first pointer in the block.
231 * Make it the new root of the btree. 219 * Make it the new root of the btree.
232 */ 220 */
233 bno = INT_GET(agf->agf_roots[cur->bc_btnum], ARCH_CONVERT); 221 bno = be32_to_cpu(agf->agf_roots[cur->bc_btnum]);
234 INT_COPY(agf->agf_roots[cur->bc_btnum], *lpp, ARCH_CONVERT); 222 agf->agf_roots[cur->bc_btnum] = *lpp;
235 INT_MOD(agf->agf_levels[cur->bc_btnum], ARCH_CONVERT, -1); 223 be32_add(&agf->agf_levels[cur->bc_btnum], -1);
236 mp->m_perag[INT_GET(agf->agf_seqno, ARCH_CONVERT)].pagf_levels[cur->bc_btnum]--; 224 mp->m_perag[be32_to_cpu(agf->agf_seqno)].pagf_levels[cur->bc_btnum]--;
237 /* 225 /*
238 * Put this buffer/block on the ag's freelist. 226 * Put this buffer/block on the ag's freelist.
239 */ 227 */
@@ -255,7 +243,7 @@ xfs_alloc_delrec(
255 * that freed the block. 243 * that freed the block.
256 */ 244 */
257 xfs_alloc_mark_busy(cur->bc_tp, 245 xfs_alloc_mark_busy(cur->bc_tp,
258 INT_GET(agf->agf_seqno, ARCH_CONVERT), bno, 1); 246 be32_to_cpu(agf->agf_seqno), bno, 1);
259 247
260 xfs_trans_agbtree_delta(cur->bc_tp, -1); 248 xfs_trans_agbtree_delta(cur->bc_tp, -1);
261 xfs_alloc_log_agf(cur->bc_tp, cur->bc_private.a.agbp, 249 xfs_alloc_log_agf(cur->bc_tp, cur->bc_private.a.agbp,
@@ -281,7 +269,7 @@ xfs_alloc_delrec(
281 * If the number of records remaining in the block is at least 269 * If the number of records remaining in the block is at least
282 * the minimum, we're done. 270 * the minimum, we're done.
283 */ 271 */
284 if (INT_GET(block->bb_numrecs, ARCH_CONVERT) >= XFS_ALLOC_BLOCK_MINRECS(level, cur)) { 272 if (be16_to_cpu(block->bb_numrecs) >= XFS_ALLOC_BLOCK_MINRECS(level, cur)) {
285 if (level > 0 && (error = xfs_alloc_decrement(cur, level, &i))) 273 if (level > 0 && (error = xfs_alloc_decrement(cur, level, &i)))
286 return error; 274 return error;
287 *stat = 1; 275 *stat = 1;
@@ -292,8 +280,8 @@ xfs_alloc_delrec(
292 * tree balanced. Look at the left and right sibling blocks to 280 * tree balanced. Look at the left and right sibling blocks to
293 * see if we can re-balance by moving only one record. 281 * see if we can re-balance by moving only one record.
294 */ 282 */
295 rbno = INT_GET(block->bb_rightsib, ARCH_CONVERT); 283 rbno = be32_to_cpu(block->bb_rightsib);
296 lbno = INT_GET(block->bb_leftsib, ARCH_CONVERT); 284 lbno = be32_to_cpu(block->bb_leftsib);
297 bno = NULLAGBLOCK; 285 bno = NULLAGBLOCK;
298 ASSERT(rbno != NULLAGBLOCK || lbno != NULLAGBLOCK); 286 ASSERT(rbno != NULLAGBLOCK || lbno != NULLAGBLOCK);
299 /* 287 /*
@@ -330,18 +318,18 @@ xfs_alloc_delrec(
330 /* 318 /*
331 * Grab the current block number, for future use. 319 * Grab the current block number, for future use.
332 */ 320 */
333 bno = INT_GET(right->bb_leftsib, ARCH_CONVERT); 321 bno = be32_to_cpu(right->bb_leftsib);
334 /* 322 /*
335 * If right block is full enough so that removing one entry 323 * If right block is full enough so that removing one entry
336 * won't make it too empty, and left-shifting an entry out 324 * won't make it too empty, and left-shifting an entry out
337 * of right to us works, we're done. 325 * of right to us works, we're done.
338 */ 326 */
339 if (INT_GET(right->bb_numrecs, ARCH_CONVERT) - 1 >= 327 if (be16_to_cpu(right->bb_numrecs) - 1 >=
340 XFS_ALLOC_BLOCK_MINRECS(level, cur)) { 328 XFS_ALLOC_BLOCK_MINRECS(level, cur)) {
341 if ((error = xfs_alloc_lshift(tcur, level, &i))) 329 if ((error = xfs_alloc_lshift(tcur, level, &i)))
342 goto error0; 330 goto error0;
343 if (i) { 331 if (i) {
344 ASSERT(INT_GET(block->bb_numrecs, ARCH_CONVERT) >= 332 ASSERT(be16_to_cpu(block->bb_numrecs) >=
345 XFS_ALLOC_BLOCK_MINRECS(level, cur)); 333 XFS_ALLOC_BLOCK_MINRECS(level, cur));
346 xfs_btree_del_cursor(tcur, 334 xfs_btree_del_cursor(tcur,
347 XFS_BTREE_NOERROR); 335 XFS_BTREE_NOERROR);
@@ -358,7 +346,7 @@ xfs_alloc_delrec(
358 * future reference, and fix up the temp cursor to point 346 * future reference, and fix up the temp cursor to point
359 * to our block again (last record). 347 * to our block again (last record).
360 */ 348 */
361 rrecs = INT_GET(right->bb_numrecs, ARCH_CONVERT); 349 rrecs = be16_to_cpu(right->bb_numrecs);
362 if (lbno != NULLAGBLOCK) { 350 if (lbno != NULLAGBLOCK) {
363 i = xfs_btree_firstrec(tcur, level); 351 i = xfs_btree_firstrec(tcur, level);
364 XFS_WANT_CORRUPTED_GOTO(i == 1, error0); 352 XFS_WANT_CORRUPTED_GOTO(i == 1, error0);
@@ -394,18 +382,18 @@ xfs_alloc_delrec(
394 /* 382 /*
395 * Grab the current block number, for future use. 383 * Grab the current block number, for future use.
396 */ 384 */
397 bno = INT_GET(left->bb_rightsib, ARCH_CONVERT); 385 bno = be32_to_cpu(left->bb_rightsib);
398 /* 386 /*
399 * If left block is full enough so that removing one entry 387 * If left block is full enough so that removing one entry
400 * won't make it too empty, and right-shifting an entry out 388 * won't make it too empty, and right-shifting an entry out
401 * of left to us works, we're done. 389 * of left to us works, we're done.
402 */ 390 */
403 if (INT_GET(left->bb_numrecs, ARCH_CONVERT) - 1 >= 391 if (be16_to_cpu(left->bb_numrecs) - 1 >=
404 XFS_ALLOC_BLOCK_MINRECS(level, cur)) { 392 XFS_ALLOC_BLOCK_MINRECS(level, cur)) {
405 if ((error = xfs_alloc_rshift(tcur, level, &i))) 393 if ((error = xfs_alloc_rshift(tcur, level, &i)))
406 goto error0; 394 goto error0;
407 if (i) { 395 if (i) {
408 ASSERT(INT_GET(block->bb_numrecs, ARCH_CONVERT) >= 396 ASSERT(be16_to_cpu(block->bb_numrecs) >=
409 XFS_ALLOC_BLOCK_MINRECS(level, cur)); 397 XFS_ALLOC_BLOCK_MINRECS(level, cur));
410 xfs_btree_del_cursor(tcur, 398 xfs_btree_del_cursor(tcur,
411 XFS_BTREE_NOERROR); 399 XFS_BTREE_NOERROR);
@@ -419,7 +407,7 @@ xfs_alloc_delrec(
419 * Otherwise, grab the number of records in right for 407 * Otherwise, grab the number of records in right for
420 * future reference. 408 * future reference.
421 */ 409 */
422 lrecs = INT_GET(left->bb_numrecs, ARCH_CONVERT); 410 lrecs = be16_to_cpu(left->bb_numrecs);
423 } 411 }
424 /* 412 /*
425 * Delete the temp cursor, we're done with it. 413 * Delete the temp cursor, we're done with it.
@@ -433,7 +421,7 @@ xfs_alloc_delrec(
433 * See if we can join with the left neighbor block. 421 * See if we can join with the left neighbor block.
434 */ 422 */
435 if (lbno != NULLAGBLOCK && 423 if (lbno != NULLAGBLOCK &&
436 lrecs + INT_GET(block->bb_numrecs, ARCH_CONVERT) <= XFS_ALLOC_BLOCK_MAXRECS(level, cur)) { 424 lrecs + be16_to_cpu(block->bb_numrecs) <= XFS_ALLOC_BLOCK_MAXRECS(level, cur)) {
437 /* 425 /*
438 * Set "right" to be the starting block, 426 * Set "right" to be the starting block,
439 * "left" to be the left neighbor. 427 * "left" to be the left neighbor.
@@ -453,7 +441,7 @@ xfs_alloc_delrec(
453 * If that won't work, see if we can join with the right neighbor block. 441 * If that won't work, see if we can join with the right neighbor block.
454 */ 442 */
455 else if (rbno != NULLAGBLOCK && 443 else if (rbno != NULLAGBLOCK &&
456 rrecs + INT_GET(block->bb_numrecs, ARCH_CONVERT) <= 444 rrecs + be16_to_cpu(block->bb_numrecs) <=
457 XFS_ALLOC_BLOCK_MAXRECS(level, cur)) { 445 XFS_ALLOC_BLOCK_MAXRECS(level, cur)) {
458 /* 446 /*
459 * Set "left" to be the starting block, 447 * Set "left" to be the starting block,
@@ -488,31 +476,34 @@ xfs_alloc_delrec(
488 /* 476 /*
489 * It's a non-leaf. Move keys and pointers. 477 * It's a non-leaf. Move keys and pointers.
490 */ 478 */
491 lkp = XFS_ALLOC_KEY_ADDR(left, INT_GET(left->bb_numrecs, ARCH_CONVERT) + 1, cur); 479 lkp = XFS_ALLOC_KEY_ADDR(left, be16_to_cpu(left->bb_numrecs) + 1, cur);
492 lpp = XFS_ALLOC_PTR_ADDR(left, INT_GET(left->bb_numrecs, ARCH_CONVERT) + 1, cur); 480 lpp = XFS_ALLOC_PTR_ADDR(left, be16_to_cpu(left->bb_numrecs) + 1, cur);
493 rkp = XFS_ALLOC_KEY_ADDR(right, 1, cur); 481 rkp = XFS_ALLOC_KEY_ADDR(right, 1, cur);
494 rpp = XFS_ALLOC_PTR_ADDR(right, 1, cur); 482 rpp = XFS_ALLOC_PTR_ADDR(right, 1, cur);
495#ifdef DEBUG 483#ifdef DEBUG
496 for (i = 0; i < INT_GET(right->bb_numrecs, ARCH_CONVERT); i++) { 484 for (i = 0; i < be16_to_cpu(right->bb_numrecs); i++) {
497 if ((error = xfs_btree_check_sptr(cur, INT_GET(rpp[i], ARCH_CONVERT), level))) 485 if ((error = xfs_btree_check_sptr(cur, be32_to_cpu(rpp[i]), level)))
498 return error; 486 return error;
499 } 487 }
500#endif 488#endif
501 memcpy(lkp, rkp, INT_GET(right->bb_numrecs, ARCH_CONVERT) * sizeof(*lkp)); /* INT_: structure copy */ 489 memcpy(lkp, rkp, be16_to_cpu(right->bb_numrecs) * sizeof(*lkp));
502 memcpy(lpp, rpp, INT_GET(right->bb_numrecs, ARCH_CONVERT) * sizeof(*lpp)); /* INT_: structure copy */ 490 memcpy(lpp, rpp, be16_to_cpu(right->bb_numrecs) * sizeof(*lpp));
503 xfs_alloc_log_keys(cur, lbp, INT_GET(left->bb_numrecs, ARCH_CONVERT) + 1, 491 xfs_alloc_log_keys(cur, lbp, be16_to_cpu(left->bb_numrecs) + 1,
504 INT_GET(left->bb_numrecs, ARCH_CONVERT) + INT_GET(right->bb_numrecs, ARCH_CONVERT)); 492 be16_to_cpu(left->bb_numrecs) +
505 xfs_alloc_log_ptrs(cur, lbp, INT_GET(left->bb_numrecs, ARCH_CONVERT) + 1, 493 be16_to_cpu(right->bb_numrecs));
506 INT_GET(left->bb_numrecs, ARCH_CONVERT) + INT_GET(right->bb_numrecs, ARCH_CONVERT)); 494 xfs_alloc_log_ptrs(cur, lbp, be16_to_cpu(left->bb_numrecs) + 1,
495 be16_to_cpu(left->bb_numrecs) +
496 be16_to_cpu(right->bb_numrecs));
507 } else { 497 } else {
508 /* 498 /*
509 * It's a leaf. Move records. 499 * It's a leaf. Move records.
510 */ 500 */
511 lrp = XFS_ALLOC_REC_ADDR(left, INT_GET(left->bb_numrecs, ARCH_CONVERT) + 1, cur); 501 lrp = XFS_ALLOC_REC_ADDR(left, be16_to_cpu(left->bb_numrecs) + 1, cur);
512 rrp = XFS_ALLOC_REC_ADDR(right, 1, cur); 502 rrp = XFS_ALLOC_REC_ADDR(right, 1, cur);
513 memcpy(lrp, rrp, INT_GET(right->bb_numrecs, ARCH_CONVERT) * sizeof(*lrp)); 503 memcpy(lrp, rrp, be16_to_cpu(right->bb_numrecs) * sizeof(*lrp));
514 xfs_alloc_log_recs(cur, lbp, INT_GET(left->bb_numrecs, ARCH_CONVERT) + 1, 504 xfs_alloc_log_recs(cur, lbp, be16_to_cpu(left->bb_numrecs) + 1,
515 INT_GET(left->bb_numrecs, ARCH_CONVERT) + INT_GET(right->bb_numrecs, ARCH_CONVERT)); 505 be16_to_cpu(left->bb_numrecs) +
506 be16_to_cpu(right->bb_numrecs));
516 } 507 }
517 /* 508 /*
518 * If we joined with the left neighbor, set the buffer in the 509 * If we joined with the left neighbor, set the buffer in the
@@ -520,7 +511,7 @@ xfs_alloc_delrec(
520 */ 511 */
521 if (bp != lbp) { 512 if (bp != lbp) {
522 xfs_btree_setbuf(cur, level, lbp); 513 xfs_btree_setbuf(cur, level, lbp);
523 cur->bc_ptrs[level] += INT_GET(left->bb_numrecs, ARCH_CONVERT); 514 cur->bc_ptrs[level] += be16_to_cpu(left->bb_numrecs);
524 } 515 }
525 /* 516 /*
526 * If we joined with the right neighbor and there's a level above 517 * If we joined with the right neighbor and there's a level above
@@ -532,28 +523,28 @@ xfs_alloc_delrec(
532 /* 523 /*
533 * Fix up the number of records in the surviving block. 524 * Fix up the number of records in the surviving block.
534 */ 525 */
535 INT_MOD(left->bb_numrecs, ARCH_CONVERT, INT_GET(right->bb_numrecs, ARCH_CONVERT)); 526 be16_add(&left->bb_numrecs, be16_to_cpu(right->bb_numrecs));
536 /* 527 /*
537 * Fix up the right block pointer in the surviving block, and log it. 528 * Fix up the right block pointer in the surviving block, and log it.
538 */ 529 */
539 left->bb_rightsib = right->bb_rightsib; /* INT_: direct copy */ 530 left->bb_rightsib = right->bb_rightsib;
540 xfs_alloc_log_block(cur->bc_tp, lbp, XFS_BB_NUMRECS | XFS_BB_RIGHTSIB); 531 xfs_alloc_log_block(cur->bc_tp, lbp, XFS_BB_NUMRECS | XFS_BB_RIGHTSIB);
541 /* 532 /*
542 * If there is a right sibling now, make it point to the 533 * If there is a right sibling now, make it point to the
543 * remaining block. 534 * remaining block.
544 */ 535 */
545 if (INT_GET(left->bb_rightsib, ARCH_CONVERT) != NULLAGBLOCK) { 536 if (be32_to_cpu(left->bb_rightsib) != NULLAGBLOCK) {
546 xfs_alloc_block_t *rrblock; 537 xfs_alloc_block_t *rrblock;
547 xfs_buf_t *rrbp; 538 xfs_buf_t *rrbp;
548 539
549 if ((error = xfs_btree_read_bufs(mp, cur->bc_tp, 540 if ((error = xfs_btree_read_bufs(mp, cur->bc_tp,
550 cur->bc_private.a.agno, INT_GET(left->bb_rightsib, ARCH_CONVERT), 0, 541 cur->bc_private.a.agno, be32_to_cpu(left->bb_rightsib), 0,
551 &rrbp, XFS_ALLOC_BTREE_REF))) 542 &rrbp, XFS_ALLOC_BTREE_REF)))
552 return error; 543 return error;
553 rrblock = XFS_BUF_TO_ALLOC_BLOCK(rrbp); 544 rrblock = XFS_BUF_TO_ALLOC_BLOCK(rrbp);
554 if ((error = xfs_btree_check_sblock(cur, rrblock, level, rrbp))) 545 if ((error = xfs_btree_check_sblock(cur, rrblock, level, rrbp)))
555 return error; 546 return error;
556 INT_SET(rrblock->bb_leftsib, ARCH_CONVERT, lbno); 547 rrblock->bb_leftsib = cpu_to_be32(lbno);
557 xfs_alloc_log_block(cur->bc_tp, rrbp, XFS_BB_LEFTSIB); 548 xfs_alloc_log_block(cur->bc_tp, rrbp, XFS_BB_LEFTSIB);
558 } 549 }
559 /* 550 /*
@@ -574,10 +565,9 @@ xfs_alloc_delrec(
574 * busy block is allocated, the iclog is pushed up to the 565 * busy block is allocated, the iclog is pushed up to the
575 * LSN that freed the block. 566 * LSN that freed the block.
576 */ 567 */
577 xfs_alloc_mark_busy(cur->bc_tp, 568 xfs_alloc_mark_busy(cur->bc_tp, be32_to_cpu(agf->agf_seqno), bno, 1);
578 INT_GET(agf->agf_seqno, ARCH_CONVERT), bno, 1);
579
580 xfs_trans_agbtree_delta(cur->bc_tp, -1); 569 xfs_trans_agbtree_delta(cur->bc_tp, -1);
570
581 /* 571 /*
582 * Adjust the current level's cursor so that we're left referring 572 * Adjust the current level's cursor so that we're left referring
583 * to the right node, after we're done. 573 * to the right node, after we're done.
@@ -625,7 +615,15 @@ xfs_alloc_insrec(
625 int ptr; /* index in btree block for this rec */ 615 int ptr; /* index in btree block for this rec */
626 xfs_alloc_rec_t *rp; /* pointer to btree records */ 616 xfs_alloc_rec_t *rp; /* pointer to btree records */
627 617
628 ASSERT(INT_GET(recp->ar_blockcount, ARCH_CONVERT) > 0); 618 ASSERT(be32_to_cpu(recp->ar_blockcount) > 0);
619
620 /*
621 * GCC doesn't understand the (arguably complex) control flow in
622 * this function and complains about uninitialized structure fields
623 * without this.
624 */
625 memset(&nrec, 0, sizeof(nrec));
626
629 /* 627 /*
630 * If we made it to the root level, allocate a new root block 628 * If we made it to the root level, allocate a new root block
631 * and we're done. 629 * and we're done.
@@ -641,8 +639,8 @@ xfs_alloc_insrec(
641 /* 639 /*
642 * Make a key out of the record data to be inserted, and save it. 640 * Make a key out of the record data to be inserted, and save it.
643 */ 641 */
644 key.ar_startblock = recp->ar_startblock; /* INT_: direct copy */ 642 key.ar_startblock = recp->ar_startblock;
645 key.ar_blockcount = recp->ar_blockcount; /* INT_: direct copy */ 643 key.ar_blockcount = recp->ar_blockcount;
646 optr = ptr = cur->bc_ptrs[level]; 644 optr = ptr = cur->bc_ptrs[level];
647 /* 645 /*
648 * If we're off the left edge, return failure. 646 * If we're off the left edge, return failure.
@@ -663,7 +661,7 @@ xfs_alloc_insrec(
663 /* 661 /*
664 * Check that the new entry is being inserted in the right place. 662 * Check that the new entry is being inserted in the right place.
665 */ 663 */
666 if (ptr <= INT_GET(block->bb_numrecs, ARCH_CONVERT)) { 664 if (ptr <= be16_to_cpu(block->bb_numrecs)) {
667 if (level == 0) { 665 if (level == 0) {
668 rp = XFS_ALLOC_REC_ADDR(block, ptr, cur); 666 rp = XFS_ALLOC_REC_ADDR(block, ptr, cur);
669 xfs_btree_check_rec(cur->bc_btnum, recp, rp); 667 xfs_btree_check_rec(cur->bc_btnum, recp, rp);
@@ -679,7 +677,7 @@ xfs_alloc_insrec(
679 * If the block is full, we can't insert the new entry until we 677 * If the block is full, we can't insert the new entry until we
680 * make the block un-full. 678 * make the block un-full.
681 */ 679 */
682 if (INT_GET(block->bb_numrecs, ARCH_CONVERT) == XFS_ALLOC_BLOCK_MAXRECS(level, cur)) { 680 if (be16_to_cpu(block->bb_numrecs) == XFS_ALLOC_BLOCK_MAXRECS(level, cur)) {
683 /* 681 /*
684 * First, try shifting an entry to the right neighbor. 682 * First, try shifting an entry to the right neighbor.
685 */ 683 */
@@ -716,8 +714,8 @@ xfs_alloc_insrec(
716 return error; 714 return error;
717#endif 715#endif
718 ptr = cur->bc_ptrs[level]; 716 ptr = cur->bc_ptrs[level];
719 nrec.ar_startblock = nkey.ar_startblock; /* INT_: direct copy */ 717 nrec.ar_startblock = nkey.ar_startblock;
720 nrec.ar_blockcount = nkey.ar_blockcount; /* INT_: direct copy */ 718 nrec.ar_blockcount = nkey.ar_blockcount;
721 } 719 }
722 /* 720 /*
723 * Otherwise the insert fails. 721 * Otherwise the insert fails.
@@ -741,15 +739,15 @@ xfs_alloc_insrec(
741 kp = XFS_ALLOC_KEY_ADDR(block, 1, cur); 739 kp = XFS_ALLOC_KEY_ADDR(block, 1, cur);
742 pp = XFS_ALLOC_PTR_ADDR(block, 1, cur); 740 pp = XFS_ALLOC_PTR_ADDR(block, 1, cur);
743#ifdef DEBUG 741#ifdef DEBUG
744 for (i = INT_GET(block->bb_numrecs, ARCH_CONVERT); i >= ptr; i--) { 742 for (i = be16_to_cpu(block->bb_numrecs); i >= ptr; i--) {
745 if ((error = xfs_btree_check_sptr(cur, INT_GET(pp[i - 1], ARCH_CONVERT), level))) 743 if ((error = xfs_btree_check_sptr(cur, be32_to_cpu(pp[i - 1]), level)))
746 return error; 744 return error;
747 } 745 }
748#endif 746#endif
749 memmove(&kp[ptr], &kp[ptr - 1], 747 memmove(&kp[ptr], &kp[ptr - 1],
750 (INT_GET(block->bb_numrecs, ARCH_CONVERT) - ptr + 1) * sizeof(*kp)); /* INT_: copy */ 748 (be16_to_cpu(block->bb_numrecs) - ptr + 1) * sizeof(*kp));
751 memmove(&pp[ptr], &pp[ptr - 1], 749 memmove(&pp[ptr], &pp[ptr - 1],
752 (INT_GET(block->bb_numrecs, ARCH_CONVERT) - ptr + 1) * sizeof(*pp)); /* INT_: copy */ 750 (be16_to_cpu(block->bb_numrecs) - ptr + 1) * sizeof(*pp));
753#ifdef DEBUG 751#ifdef DEBUG
754 if ((error = xfs_btree_check_sptr(cur, *bnop, level))) 752 if ((error = xfs_btree_check_sptr(cur, *bnop, level)))
755 return error; 753 return error;
@@ -758,12 +756,12 @@ xfs_alloc_insrec(
758 * Now stuff the new data in, bump numrecs and log the new data. 756 * Now stuff the new data in, bump numrecs and log the new data.
759 */ 757 */
760 kp[ptr - 1] = key; 758 kp[ptr - 1] = key;
761 INT_SET(pp[ptr - 1], ARCH_CONVERT, *bnop); 759 pp[ptr - 1] = cpu_to_be32(*bnop);
762 INT_MOD(block->bb_numrecs, ARCH_CONVERT, +1); 760 be16_add(&block->bb_numrecs, 1);
763 xfs_alloc_log_keys(cur, bp, ptr, INT_GET(block->bb_numrecs, ARCH_CONVERT)); 761 xfs_alloc_log_keys(cur, bp, ptr, be16_to_cpu(block->bb_numrecs));
764 xfs_alloc_log_ptrs(cur, bp, ptr, INT_GET(block->bb_numrecs, ARCH_CONVERT)); 762 xfs_alloc_log_ptrs(cur, bp, ptr, be16_to_cpu(block->bb_numrecs));
765#ifdef DEBUG 763#ifdef DEBUG
766 if (ptr < INT_GET(block->bb_numrecs, ARCH_CONVERT)) 764 if (ptr < be16_to_cpu(block->bb_numrecs))
767 xfs_btree_check_key(cur->bc_btnum, kp + ptr - 1, 765 xfs_btree_check_key(cur->bc_btnum, kp + ptr - 1,
768 kp + ptr); 766 kp + ptr);
769#endif 767#endif
@@ -773,16 +771,16 @@ xfs_alloc_insrec(
773 */ 771 */
774 rp = XFS_ALLOC_REC_ADDR(block, 1, cur); 772 rp = XFS_ALLOC_REC_ADDR(block, 1, cur);
775 memmove(&rp[ptr], &rp[ptr - 1], 773 memmove(&rp[ptr], &rp[ptr - 1],
776 (INT_GET(block->bb_numrecs, ARCH_CONVERT) - ptr + 1) * sizeof(*rp)); 774 (be16_to_cpu(block->bb_numrecs) - ptr + 1) * sizeof(*rp));
777 /* 775 /*
778 * Now stuff the new record in, bump numrecs 776 * Now stuff the new record in, bump numrecs
779 * and log the new data. 777 * and log the new data.
780 */ 778 */
781 rp[ptr - 1] = *recp; /* INT_: struct copy */ 779 rp[ptr - 1] = *recp; /* INT_: struct copy */
782 INT_MOD(block->bb_numrecs, ARCH_CONVERT, +1); 780 be16_add(&block->bb_numrecs, 1);
783 xfs_alloc_log_recs(cur, bp, ptr, INT_GET(block->bb_numrecs, ARCH_CONVERT)); 781 xfs_alloc_log_recs(cur, bp, ptr, be16_to_cpu(block->bb_numrecs));
784#ifdef DEBUG 782#ifdef DEBUG
785 if (ptr < INT_GET(block->bb_numrecs, ARCH_CONVERT)) 783 if (ptr < be16_to_cpu(block->bb_numrecs))
786 xfs_btree_check_rec(cur->bc_btnum, rp + ptr - 1, 784 xfs_btree_check_rec(cur->bc_btnum, rp + ptr - 1,
787 rp + ptr); 785 rp + ptr);
788#endif 786#endif
@@ -804,16 +802,16 @@ xfs_alloc_insrec(
804 agf = XFS_BUF_TO_AGF(cur->bc_private.a.agbp); 802 agf = XFS_BUF_TO_AGF(cur->bc_private.a.agbp);
805 if (level == 0 && 803 if (level == 0 &&
806 cur->bc_btnum == XFS_BTNUM_CNT && 804 cur->bc_btnum == XFS_BTNUM_CNT &&
807 INT_GET(block->bb_rightsib, ARCH_CONVERT) == NULLAGBLOCK && 805 be32_to_cpu(block->bb_rightsib) == NULLAGBLOCK &&
808 INT_GET(recp->ar_blockcount, ARCH_CONVERT) > INT_GET(agf->agf_longest, ARCH_CONVERT)) { 806 be32_to_cpu(recp->ar_blockcount) > be32_to_cpu(agf->agf_longest)) {
809 /* 807 /*
810 * If this is a leaf in the by-size btree and there 808 * If this is a leaf in the by-size btree and there
811 * is no right sibling block and this block is bigger 809 * is no right sibling block and this block is bigger
812 * than the previous longest block, update it. 810 * than the previous longest block, update it.
813 */ 811 */
814 INT_COPY(agf->agf_longest, recp->ar_blockcount, ARCH_CONVERT); 812 agf->agf_longest = recp->ar_blockcount;
815 cur->bc_mp->m_perag[INT_GET(agf->agf_seqno, ARCH_CONVERT)].pagf_longest 813 cur->bc_mp->m_perag[be32_to_cpu(agf->agf_seqno)].pagf_longest
816 = INT_GET(recp->ar_blockcount, ARCH_CONVERT); 814 = be32_to_cpu(recp->ar_blockcount);
817 xfs_alloc_log_agf(cur->bc_tp, cur->bc_private.a.agbp, 815 xfs_alloc_log_agf(cur->bc_tp, cur->bc_private.a.agbp,
818 XFS_AGF_LONGEST); 816 XFS_AGF_LONGEST);
819 } 817 }
@@ -923,8 +921,9 @@ xfs_alloc_log_recs(
923 921
924 agf = XFS_BUF_TO_AGF(cur->bc_private.a.agbp); 922 agf = XFS_BUF_TO_AGF(cur->bc_private.a.agbp);
925 for (p = &rp[rfirst - 1]; p <= &rp[rlast - 1]; p++) 923 for (p = &rp[rfirst - 1]; p <= &rp[rlast - 1]; p++)
926 ASSERT(INT_GET(p->ar_startblock, ARCH_CONVERT) + INT_GET(p->ar_blockcount, ARCH_CONVERT) <= 924 ASSERT(be32_to_cpu(p->ar_startblock) +
927 INT_GET(agf->agf_length, ARCH_CONVERT)); 925 be32_to_cpu(p->ar_blockcount) <=
926 be32_to_cpu(agf->agf_length));
928 } 927 }
929#endif 928#endif
930 first = (int)((xfs_caddr_t)&rp[rfirst - 1] - (xfs_caddr_t)block); 929 first = (int)((xfs_caddr_t)&rp[rfirst - 1] - (xfs_caddr_t)block);
@@ -961,8 +960,8 @@ xfs_alloc_lookup(
961 xfs_agf_t *agf; /* a.g. freespace header */ 960 xfs_agf_t *agf; /* a.g. freespace header */
962 961
963 agf = XFS_BUF_TO_AGF(cur->bc_private.a.agbp); 962 agf = XFS_BUF_TO_AGF(cur->bc_private.a.agbp);
964 agno = INT_GET(agf->agf_seqno, ARCH_CONVERT); 963 agno = be32_to_cpu(agf->agf_seqno);
965 agbno = INT_GET(agf->agf_roots[cur->bc_btnum], ARCH_CONVERT); 964 agbno = be32_to_cpu(agf->agf_roots[cur->bc_btnum]);
966 } 965 }
967 /* 966 /*
968 * Iterate over each level in the btree, starting at the root. 967 * Iterate over each level in the btree, starting at the root.
@@ -1029,7 +1028,7 @@ xfs_alloc_lookup(
1029 * Set low and high entry numbers, 1-based. 1028 * Set low and high entry numbers, 1-based.
1030 */ 1029 */
1031 low = 1; 1030 low = 1;
1032 if (!(high = INT_GET(block->bb_numrecs, ARCH_CONVERT))) { 1031 if (!(high = be16_to_cpu(block->bb_numrecs))) {
1033 /* 1032 /*
1034 * If the block is empty, the tree must 1033 * If the block is empty, the tree must
1035 * be an empty leaf. 1034 * be an empty leaf.
@@ -1058,14 +1057,14 @@ xfs_alloc_lookup(
1058 xfs_alloc_key_t *kkp; 1057 xfs_alloc_key_t *kkp;
1059 1058
1060 kkp = kkbase + keyno - 1; 1059 kkp = kkbase + keyno - 1;
1061 startblock = INT_GET(kkp->ar_startblock, ARCH_CONVERT); 1060 startblock = be32_to_cpu(kkp->ar_startblock);
1062 blockcount = INT_GET(kkp->ar_blockcount, ARCH_CONVERT); 1061 blockcount = be32_to_cpu(kkp->ar_blockcount);
1063 } else { 1062 } else {
1064 xfs_alloc_rec_t *krp; 1063 xfs_alloc_rec_t *krp;
1065 1064
1066 krp = krbase + keyno - 1; 1065 krp = krbase + keyno - 1;
1067 startblock = INT_GET(krp->ar_startblock, ARCH_CONVERT); 1066 startblock = be32_to_cpu(krp->ar_startblock);
1068 blockcount = INT_GET(krp->ar_blockcount, ARCH_CONVERT); 1067 blockcount = be32_to_cpu(krp->ar_blockcount);
1069 } 1068 }
1070 /* 1069 /*
1071 * Compute difference to get next direction. 1070 * Compute difference to get next direction.
@@ -1105,7 +1104,7 @@ xfs_alloc_lookup(
1105 */ 1104 */
1106 if (diff > 0 && --keyno < 1) 1105 if (diff > 0 && --keyno < 1)
1107 keyno = 1; 1106 keyno = 1;
1108 agbno = INT_GET(*XFS_ALLOC_PTR_ADDR(block, keyno, cur), ARCH_CONVERT); 1107 agbno = be32_to_cpu(*XFS_ALLOC_PTR_ADDR(block, keyno, cur));
1109#ifdef DEBUG 1108#ifdef DEBUG
1110 if ((error = xfs_btree_check_sptr(cur, agbno, level))) 1109 if ((error = xfs_btree_check_sptr(cur, agbno, level)))
1111 return error; 1110 return error;
@@ -1124,8 +1123,8 @@ xfs_alloc_lookup(
1124 * not the last block, we're in the wrong block. 1123 * not the last block, we're in the wrong block.
1125 */ 1124 */
1126 if (dir == XFS_LOOKUP_GE && 1125 if (dir == XFS_LOOKUP_GE &&
1127 keyno > INT_GET(block->bb_numrecs, ARCH_CONVERT) && 1126 keyno > be16_to_cpu(block->bb_numrecs) &&
1128 INT_GET(block->bb_rightsib, ARCH_CONVERT) != NULLAGBLOCK) { 1127 be32_to_cpu(block->bb_rightsib) != NULLAGBLOCK) {
1129 int i; 1128 int i;
1130 1129
1131 cur->bc_ptrs[0] = keyno; 1130 cur->bc_ptrs[0] = keyno;
@@ -1142,7 +1141,7 @@ xfs_alloc_lookup(
1142 /* 1141 /*
1143 * Return if we succeeded or not. 1142 * Return if we succeeded or not.
1144 */ 1143 */
1145 if (keyno == 0 || keyno > INT_GET(block->bb_numrecs, ARCH_CONVERT)) 1144 if (keyno == 0 || keyno > be16_to_cpu(block->bb_numrecs))
1146 *stat = 0; 1145 *stat = 0;
1147 else 1146 else
1148 *stat = ((dir != XFS_LOOKUP_EQ) || (diff == 0)); 1147 *stat = ((dir != XFS_LOOKUP_EQ) || (diff == 0));
@@ -1185,7 +1184,7 @@ xfs_alloc_lshift(
1185 /* 1184 /*
1186 * If we've got no left sibling then we can't shift an entry left. 1185 * If we've got no left sibling then we can't shift an entry left.
1187 */ 1186 */
1188 if (INT_GET(right->bb_leftsib, ARCH_CONVERT) == NULLAGBLOCK) { 1187 if (be32_to_cpu(right->bb_leftsib) == NULLAGBLOCK) {
1189 *stat = 0; 1188 *stat = 0;
1190 return 0; 1189 return 0;
1191 } 1190 }
@@ -1201,8 +1200,8 @@ xfs_alloc_lshift(
1201 * Set up the left neighbor as "left". 1200 * Set up the left neighbor as "left".
1202 */ 1201 */
1203 if ((error = xfs_btree_read_bufs(cur->bc_mp, cur->bc_tp, 1202 if ((error = xfs_btree_read_bufs(cur->bc_mp, cur->bc_tp,
1204 cur->bc_private.a.agno, INT_GET(right->bb_leftsib, ARCH_CONVERT), 0, &lbp, 1203 cur->bc_private.a.agno, be32_to_cpu(right->bb_leftsib),
1205 XFS_ALLOC_BTREE_REF))) 1204 0, &lbp, XFS_ALLOC_BTREE_REF)))
1206 return error; 1205 return error;
1207 left = XFS_BUF_TO_ALLOC_BLOCK(lbp); 1206 left = XFS_BUF_TO_ALLOC_BLOCK(lbp);
1208 if ((error = xfs_btree_check_sblock(cur, left, level, lbp))) 1207 if ((error = xfs_btree_check_sblock(cur, left, level, lbp)))
@@ -1210,11 +1209,11 @@ xfs_alloc_lshift(
1210 /* 1209 /*
1211 * If it's full, it can't take another entry. 1210 * If it's full, it can't take another entry.
1212 */ 1211 */
1213 if (INT_GET(left->bb_numrecs, ARCH_CONVERT) == XFS_ALLOC_BLOCK_MAXRECS(level, cur)) { 1212 if (be16_to_cpu(left->bb_numrecs) == XFS_ALLOC_BLOCK_MAXRECS(level, cur)) {
1214 *stat = 0; 1213 *stat = 0;
1215 return 0; 1214 return 0;
1216 } 1215 }
1217 nrec = INT_GET(left->bb_numrecs, ARCH_CONVERT) + 1; 1216 nrec = be16_to_cpu(left->bb_numrecs) + 1;
1218 /* 1217 /*
1219 * If non-leaf, copy a key and a ptr to the left block. 1218 * If non-leaf, copy a key and a ptr to the left block.
1220 */ 1219 */
@@ -1229,7 +1228,7 @@ xfs_alloc_lshift(
1229 lpp = XFS_ALLOC_PTR_ADDR(left, nrec, cur); 1228 lpp = XFS_ALLOC_PTR_ADDR(left, nrec, cur);
1230 rpp = XFS_ALLOC_PTR_ADDR(right, 1, cur); 1229 rpp = XFS_ALLOC_PTR_ADDR(right, 1, cur);
1231#ifdef DEBUG 1230#ifdef DEBUG
1232 if ((error = xfs_btree_check_sptr(cur, INT_GET(*rpp, ARCH_CONVERT), level))) 1231 if ((error = xfs_btree_check_sptr(cur, be32_to_cpu(*rpp), level)))
1233 return error; 1232 return error;
1234#endif 1233#endif
1235 *lpp = *rpp; /* INT_: copy */ 1234 *lpp = *rpp; /* INT_: copy */
@@ -1251,30 +1250,30 @@ xfs_alloc_lshift(
1251 /* 1250 /*
1252 * Bump and log left's numrecs, decrement and log right's numrecs. 1251 * Bump and log left's numrecs, decrement and log right's numrecs.
1253 */ 1252 */
1254 INT_MOD(left->bb_numrecs, ARCH_CONVERT, +1); 1253 be16_add(&left->bb_numrecs, 1);
1255 xfs_alloc_log_block(cur->bc_tp, lbp, XFS_BB_NUMRECS); 1254 xfs_alloc_log_block(cur->bc_tp, lbp, XFS_BB_NUMRECS);
1256 INT_MOD(right->bb_numrecs, ARCH_CONVERT, -1); 1255 be16_add(&right->bb_numrecs, -1);
1257 xfs_alloc_log_block(cur->bc_tp, rbp, XFS_BB_NUMRECS); 1256 xfs_alloc_log_block(cur->bc_tp, rbp, XFS_BB_NUMRECS);
1258 /* 1257 /*
1259 * Slide the contents of right down one entry. 1258 * Slide the contents of right down one entry.
1260 */ 1259 */
1261 if (level > 0) { 1260 if (level > 0) {
1262#ifdef DEBUG 1261#ifdef DEBUG
1263 for (i = 0; i < INT_GET(right->bb_numrecs, ARCH_CONVERT); i++) { 1262 for (i = 0; i < be16_to_cpu(right->bb_numrecs); i++) {
1264 if ((error = xfs_btree_check_sptr(cur, INT_GET(rpp[i + 1], ARCH_CONVERT), 1263 if ((error = xfs_btree_check_sptr(cur, be32_to_cpu(rpp[i + 1]),
1265 level))) 1264 level)))
1266 return error; 1265 return error;
1267 } 1266 }
1268#endif 1267#endif
1269 memmove(rkp, rkp + 1, INT_GET(right->bb_numrecs, ARCH_CONVERT) * sizeof(*rkp)); 1268 memmove(rkp, rkp + 1, be16_to_cpu(right->bb_numrecs) * sizeof(*rkp));
1270 memmove(rpp, rpp + 1, INT_GET(right->bb_numrecs, ARCH_CONVERT) * sizeof(*rpp)); 1269 memmove(rpp, rpp + 1, be16_to_cpu(right->bb_numrecs) * sizeof(*rpp));
1271 xfs_alloc_log_keys(cur, rbp, 1, INT_GET(right->bb_numrecs, ARCH_CONVERT)); 1270 xfs_alloc_log_keys(cur, rbp, 1, be16_to_cpu(right->bb_numrecs));
1272 xfs_alloc_log_ptrs(cur, rbp, 1, INT_GET(right->bb_numrecs, ARCH_CONVERT)); 1271 xfs_alloc_log_ptrs(cur, rbp, 1, be16_to_cpu(right->bb_numrecs));
1273 } else { 1272 } else {
1274 memmove(rrp, rrp + 1, INT_GET(right->bb_numrecs, ARCH_CONVERT) * sizeof(*rrp)); 1273 memmove(rrp, rrp + 1, be16_to_cpu(right->bb_numrecs) * sizeof(*rrp));
1275 xfs_alloc_log_recs(cur, rbp, 1, INT_GET(right->bb_numrecs, ARCH_CONVERT)); 1274 xfs_alloc_log_recs(cur, rbp, 1, be16_to_cpu(right->bb_numrecs));
1276 key.ar_startblock = rrp->ar_startblock; /* INT_: direct copy */ 1275 key.ar_startblock = rrp->ar_startblock;
1277 key.ar_blockcount = rrp->ar_blockcount; /* INT_: direct copy */ 1276 key.ar_blockcount = rrp->ar_blockcount;
1278 rkp = &key; 1277 rkp = &key;
1279 } 1278 }
1280 /* 1279 /*
@@ -1339,9 +1338,9 @@ xfs_alloc_newroot(
1339 xfs_agnumber_t seqno; 1338 xfs_agnumber_t seqno;
1340 1339
1341 agf = XFS_BUF_TO_AGF(cur->bc_private.a.agbp); 1340 agf = XFS_BUF_TO_AGF(cur->bc_private.a.agbp);
1342 INT_SET(agf->agf_roots[cur->bc_btnum], ARCH_CONVERT, nbno); 1341 agf->agf_roots[cur->bc_btnum] = cpu_to_be32(nbno);
1343 INT_MOD(agf->agf_levels[cur->bc_btnum], ARCH_CONVERT, 1); 1342 be32_add(&agf->agf_levels[cur->bc_btnum], 1);
1344 seqno = INT_GET(agf->agf_seqno, ARCH_CONVERT); 1343 seqno = be32_to_cpu(agf->agf_seqno);
1345 mp->m_perag[seqno].pagf_levels[cur->bc_btnum]++; 1344 mp->m_perag[seqno].pagf_levels[cur->bc_btnum]++;
1346 xfs_alloc_log_agf(cur->bc_tp, cur->bc_private.a.agbp, 1345 xfs_alloc_log_agf(cur->bc_tp, cur->bc_private.a.agbp,
1347 XFS_AGF_ROOTS | XFS_AGF_LEVELS); 1346 XFS_AGF_ROOTS | XFS_AGF_LEVELS);
@@ -1358,12 +1357,12 @@ xfs_alloc_newroot(
1358 if ((error = xfs_btree_check_sblock(cur, left, cur->bc_nlevels - 1, lbp))) 1357 if ((error = xfs_btree_check_sblock(cur, left, cur->bc_nlevels - 1, lbp)))
1359 return error; 1358 return error;
1360#endif 1359#endif
1361 if (INT_GET(left->bb_rightsib, ARCH_CONVERT) != NULLAGBLOCK) { 1360 if (be32_to_cpu(left->bb_rightsib) != NULLAGBLOCK) {
1362 /* 1361 /*
1363 * Our block is left, pick up the right block. 1362 * Our block is left, pick up the right block.
1364 */ 1363 */
1365 lbno = XFS_DADDR_TO_AGBNO(mp, XFS_BUF_ADDR(lbp)); 1364 lbno = XFS_DADDR_TO_AGBNO(mp, XFS_BUF_ADDR(lbp));
1366 rbno = INT_GET(left->bb_rightsib, ARCH_CONVERT); 1365 rbno = be32_to_cpu(left->bb_rightsib);
1367 if ((error = xfs_btree_read_bufs(mp, cur->bc_tp, 1366 if ((error = xfs_btree_read_bufs(mp, cur->bc_tp,
1368 cur->bc_private.a.agno, rbno, 0, &rbp, 1367 cur->bc_private.a.agno, rbno, 0, &rbp,
1369 XFS_ALLOC_BTREE_REF))) 1368 XFS_ALLOC_BTREE_REF)))
@@ -1380,7 +1379,7 @@ xfs_alloc_newroot(
1380 rbp = lbp; 1379 rbp = lbp;
1381 right = left; 1380 right = left;
1382 rbno = XFS_DADDR_TO_AGBNO(mp, XFS_BUF_ADDR(rbp)); 1381 rbno = XFS_DADDR_TO_AGBNO(mp, XFS_BUF_ADDR(rbp));
1383 lbno = INT_GET(right->bb_leftsib, ARCH_CONVERT); 1382 lbno = be32_to_cpu(right->bb_leftsib);
1384 if ((error = xfs_btree_read_bufs(mp, cur->bc_tp, 1383 if ((error = xfs_btree_read_bufs(mp, cur->bc_tp,
1385 cur->bc_private.a.agno, lbno, 0, &lbp, 1384 cur->bc_private.a.agno, lbno, 0, &lbp,
1386 XFS_ALLOC_BTREE_REF))) 1385 XFS_ALLOC_BTREE_REF)))
@@ -1394,11 +1393,11 @@ xfs_alloc_newroot(
1394 /* 1393 /*
1395 * Fill in the new block's btree header and log it. 1394 * Fill in the new block's btree header and log it.
1396 */ 1395 */
1397 INT_SET(new->bb_magic, ARCH_CONVERT, xfs_magics[cur->bc_btnum]); 1396 new->bb_magic = cpu_to_be32(xfs_magics[cur->bc_btnum]);
1398 INT_SET(new->bb_level, ARCH_CONVERT, (__uint16_t)cur->bc_nlevels); 1397 new->bb_level = cpu_to_be16(cur->bc_nlevels);
1399 INT_SET(new->bb_numrecs, ARCH_CONVERT, 2); 1398 new->bb_numrecs = cpu_to_be16(2);
1400 INT_SET(new->bb_leftsib, ARCH_CONVERT, NULLAGBLOCK); 1399 new->bb_leftsib = cpu_to_be32(NULLAGBLOCK);
1401 INT_SET(new->bb_rightsib, ARCH_CONVERT, NULLAGBLOCK); 1400 new->bb_rightsib = cpu_to_be32(NULLAGBLOCK);
1402 xfs_alloc_log_block(cur->bc_tp, nbp, XFS_BB_ALL_BITS); 1401 xfs_alloc_log_block(cur->bc_tp, nbp, XFS_BB_ALL_BITS);
1403 ASSERT(lbno != NULLAGBLOCK && rbno != NULLAGBLOCK); 1402 ASSERT(lbno != NULLAGBLOCK && rbno != NULLAGBLOCK);
1404 /* 1403 /*
@@ -1408,18 +1407,18 @@ xfs_alloc_newroot(
1408 xfs_alloc_key_t *kp; /* btree key pointer */ 1407 xfs_alloc_key_t *kp; /* btree key pointer */
1409 1408
1410 kp = XFS_ALLOC_KEY_ADDR(new, 1, cur); 1409 kp = XFS_ALLOC_KEY_ADDR(new, 1, cur);
1411 if (INT_GET(left->bb_level, ARCH_CONVERT) > 0) { 1410 if (be16_to_cpu(left->bb_level) > 0) {
1412 kp[0] = *XFS_ALLOC_KEY_ADDR(left, 1, cur); /* INT_: structure copy */ 1411 kp[0] = *XFS_ALLOC_KEY_ADDR(left, 1, cur); /* INT_: structure copy */
1413 kp[1] = *XFS_ALLOC_KEY_ADDR(right, 1, cur);/* INT_: structure copy */ 1412 kp[1] = *XFS_ALLOC_KEY_ADDR(right, 1, cur);/* INT_: structure copy */
1414 } else { 1413 } else {
1415 xfs_alloc_rec_t *rp; /* btree record pointer */ 1414 xfs_alloc_rec_t *rp; /* btree record pointer */
1416 1415
1417 rp = XFS_ALLOC_REC_ADDR(left, 1, cur); 1416 rp = XFS_ALLOC_REC_ADDR(left, 1, cur);
1418 kp[0].ar_startblock = rp->ar_startblock; /* INT_: direct copy */ 1417 kp[0].ar_startblock = rp->ar_startblock;
1419 kp[0].ar_blockcount = rp->ar_blockcount; /* INT_: direct copy */ 1418 kp[0].ar_blockcount = rp->ar_blockcount;
1420 rp = XFS_ALLOC_REC_ADDR(right, 1, cur); 1419 rp = XFS_ALLOC_REC_ADDR(right, 1, cur);
1421 kp[1].ar_startblock = rp->ar_startblock; /* INT_: direct copy */ 1420 kp[1].ar_startblock = rp->ar_startblock;
1422 kp[1].ar_blockcount = rp->ar_blockcount; /* INT_: direct copy */ 1421 kp[1].ar_blockcount = rp->ar_blockcount;
1423 } 1422 }
1424 } 1423 }
1425 xfs_alloc_log_keys(cur, nbp, 1, 2); 1424 xfs_alloc_log_keys(cur, nbp, 1, 2);
@@ -1430,8 +1429,8 @@ xfs_alloc_newroot(
1430 xfs_alloc_ptr_t *pp; /* btree address pointer */ 1429 xfs_alloc_ptr_t *pp; /* btree address pointer */
1431 1430
1432 pp = XFS_ALLOC_PTR_ADDR(new, 1, cur); 1431 pp = XFS_ALLOC_PTR_ADDR(new, 1, cur);
1433 INT_SET(pp[0], ARCH_CONVERT, lbno); 1432 pp[0] = cpu_to_be32(lbno);
1434 INT_SET(pp[1], ARCH_CONVERT, rbno); 1433 pp[1] = cpu_to_be32(rbno);
1435 } 1434 }
1436 xfs_alloc_log_ptrs(cur, nbp, 1, 2); 1435 xfs_alloc_log_ptrs(cur, nbp, 1, 2);
1437 /* 1436 /*
@@ -1476,7 +1475,7 @@ xfs_alloc_rshift(
1476 /* 1475 /*
1477 * If we've got no right sibling then we can't shift an entry right. 1476 * If we've got no right sibling then we can't shift an entry right.
1478 */ 1477 */
1479 if (INT_GET(left->bb_rightsib, ARCH_CONVERT) == NULLAGBLOCK) { 1478 if (be32_to_cpu(left->bb_rightsib) == NULLAGBLOCK) {
1480 *stat = 0; 1479 *stat = 0;
1481 return 0; 1480 return 0;
1482 } 1481 }
@@ -1484,7 +1483,7 @@ xfs_alloc_rshift(
1484 * If the cursor entry is the one that would be moved, don't 1483 * If the cursor entry is the one that would be moved, don't
1485 * do it... it's too complicated. 1484 * do it... it's too complicated.
1486 */ 1485 */
1487 if (cur->bc_ptrs[level] >= INT_GET(left->bb_numrecs, ARCH_CONVERT)) { 1486 if (cur->bc_ptrs[level] >= be16_to_cpu(left->bb_numrecs)) {
1488 *stat = 0; 1487 *stat = 0;
1489 return 0; 1488 return 0;
1490 } 1489 }
@@ -1492,8 +1491,8 @@ xfs_alloc_rshift(
1492 * Set up the right neighbor as "right". 1491 * Set up the right neighbor as "right".
1493 */ 1492 */
1494 if ((error = xfs_btree_read_bufs(cur->bc_mp, cur->bc_tp, 1493 if ((error = xfs_btree_read_bufs(cur->bc_mp, cur->bc_tp,
1495 cur->bc_private.a.agno, INT_GET(left->bb_rightsib, ARCH_CONVERT), 0, &rbp, 1494 cur->bc_private.a.agno, be32_to_cpu(left->bb_rightsib),
1496 XFS_ALLOC_BTREE_REF))) 1495 0, &rbp, XFS_ALLOC_BTREE_REF)))
1497 return error; 1496 return error;
1498 right = XFS_BUF_TO_ALLOC_BLOCK(rbp); 1497 right = XFS_BUF_TO_ALLOC_BLOCK(rbp);
1499 if ((error = xfs_btree_check_sblock(cur, right, level, rbp))) 1498 if ((error = xfs_btree_check_sblock(cur, right, level, rbp)))
@@ -1501,7 +1500,7 @@ xfs_alloc_rshift(
1501 /* 1500 /*
1502 * If it's full, it can't take another entry. 1501 * If it's full, it can't take another entry.
1503 */ 1502 */
1504 if (INT_GET(right->bb_numrecs, ARCH_CONVERT) == XFS_ALLOC_BLOCK_MAXRECS(level, cur)) { 1503 if (be16_to_cpu(right->bb_numrecs) == XFS_ALLOC_BLOCK_MAXRECS(level, cur)) {
1505 *stat = 0; 1504 *stat = 0;
1506 return 0; 1505 return 0;
1507 } 1506 }
@@ -1514,47 +1513,47 @@ xfs_alloc_rshift(
1514 xfs_alloc_ptr_t *lpp; /* address pointer for left block */ 1513 xfs_alloc_ptr_t *lpp; /* address pointer for left block */
1515 xfs_alloc_ptr_t *rpp; /* address pointer for right block */ 1514 xfs_alloc_ptr_t *rpp; /* address pointer for right block */
1516 1515
1517 lkp = XFS_ALLOC_KEY_ADDR(left, INT_GET(left->bb_numrecs, ARCH_CONVERT), cur); 1516 lkp = XFS_ALLOC_KEY_ADDR(left, be16_to_cpu(left->bb_numrecs), cur);
1518 lpp = XFS_ALLOC_PTR_ADDR(left, INT_GET(left->bb_numrecs, ARCH_CONVERT), cur); 1517 lpp = XFS_ALLOC_PTR_ADDR(left, be16_to_cpu(left->bb_numrecs), cur);
1519 rkp = XFS_ALLOC_KEY_ADDR(right, 1, cur); 1518 rkp = XFS_ALLOC_KEY_ADDR(right, 1, cur);
1520 rpp = XFS_ALLOC_PTR_ADDR(right, 1, cur); 1519 rpp = XFS_ALLOC_PTR_ADDR(right, 1, cur);
1521#ifdef DEBUG 1520#ifdef DEBUG
1522 for (i = INT_GET(right->bb_numrecs, ARCH_CONVERT) - 1; i >= 0; i--) { 1521 for (i = be16_to_cpu(right->bb_numrecs) - 1; i >= 0; i--) {
1523 if ((error = xfs_btree_check_sptr(cur, INT_GET(rpp[i], ARCH_CONVERT), level))) 1522 if ((error = xfs_btree_check_sptr(cur, be32_to_cpu(rpp[i]), level)))
1524 return error; 1523 return error;
1525 } 1524 }
1526#endif 1525#endif
1527 memmove(rkp + 1, rkp, INT_GET(right->bb_numrecs, ARCH_CONVERT) * sizeof(*rkp)); 1526 memmove(rkp + 1, rkp, be16_to_cpu(right->bb_numrecs) * sizeof(*rkp));
1528 memmove(rpp + 1, rpp, INT_GET(right->bb_numrecs, ARCH_CONVERT) * sizeof(*rpp)); 1527 memmove(rpp + 1, rpp, be16_to_cpu(right->bb_numrecs) * sizeof(*rpp));
1529#ifdef DEBUG 1528#ifdef DEBUG
1530 if ((error = xfs_btree_check_sptr(cur, INT_GET(*lpp, ARCH_CONVERT), level))) 1529 if ((error = xfs_btree_check_sptr(cur, be32_to_cpu(*lpp), level)))
1531 return error; 1530 return error;
1532#endif 1531#endif
1533 *rkp = *lkp; /* INT_: copy */ 1532 *rkp = *lkp; /* INT_: copy */
1534 *rpp = *lpp; /* INT_: copy */ 1533 *rpp = *lpp; /* INT_: copy */
1535 xfs_alloc_log_keys(cur, rbp, 1, INT_GET(right->bb_numrecs, ARCH_CONVERT) + 1); 1534 xfs_alloc_log_keys(cur, rbp, 1, be16_to_cpu(right->bb_numrecs) + 1);
1536 xfs_alloc_log_ptrs(cur, rbp, 1, INT_GET(right->bb_numrecs, ARCH_CONVERT) + 1); 1535 xfs_alloc_log_ptrs(cur, rbp, 1, be16_to_cpu(right->bb_numrecs) + 1);
1537 xfs_btree_check_key(cur->bc_btnum, rkp, rkp + 1); 1536 xfs_btree_check_key(cur->bc_btnum, rkp, rkp + 1);
1538 } else { 1537 } else {
1539 xfs_alloc_rec_t *lrp; /* record pointer for left block */ 1538 xfs_alloc_rec_t *lrp; /* record pointer for left block */
1540 xfs_alloc_rec_t *rrp; /* record pointer for right block */ 1539 xfs_alloc_rec_t *rrp; /* record pointer for right block */
1541 1540
1542 lrp = XFS_ALLOC_REC_ADDR(left, INT_GET(left->bb_numrecs, ARCH_CONVERT), cur); 1541 lrp = XFS_ALLOC_REC_ADDR(left, be16_to_cpu(left->bb_numrecs), cur);
1543 rrp = XFS_ALLOC_REC_ADDR(right, 1, cur); 1542 rrp = XFS_ALLOC_REC_ADDR(right, 1, cur);
1544 memmove(rrp + 1, rrp, INT_GET(right->bb_numrecs, ARCH_CONVERT) * sizeof(*rrp)); 1543 memmove(rrp + 1, rrp, be16_to_cpu(right->bb_numrecs) * sizeof(*rrp));
1545 *rrp = *lrp; 1544 *rrp = *lrp;
1546 xfs_alloc_log_recs(cur, rbp, 1, INT_GET(right->bb_numrecs, ARCH_CONVERT) + 1); 1545 xfs_alloc_log_recs(cur, rbp, 1, be16_to_cpu(right->bb_numrecs) + 1);
1547 key.ar_startblock = rrp->ar_startblock; /* INT_: direct copy */ 1546 key.ar_startblock = rrp->ar_startblock;
1548 key.ar_blockcount = rrp->ar_blockcount; /* INT_: direct copy */ 1547 key.ar_blockcount = rrp->ar_blockcount;
1549 rkp = &key; 1548 rkp = &key;
1550 xfs_btree_check_rec(cur->bc_btnum, rrp, rrp + 1); 1549 xfs_btree_check_rec(cur->bc_btnum, rrp, rrp + 1);
1551 } 1550 }
1552 /* 1551 /*
1553 * Decrement and log left's numrecs, bump and log right's numrecs. 1552 * Decrement and log left's numrecs, bump and log right's numrecs.
1554 */ 1553 */
1555 INT_MOD(left->bb_numrecs, ARCH_CONVERT, -1); 1554 be16_add(&left->bb_numrecs, -1);
1556 xfs_alloc_log_block(cur->bc_tp, lbp, XFS_BB_NUMRECS); 1555 xfs_alloc_log_block(cur->bc_tp, lbp, XFS_BB_NUMRECS);
1557 INT_MOD(right->bb_numrecs, ARCH_CONVERT, +1); 1556 be16_add(&right->bb_numrecs, 1);
1558 xfs_alloc_log_block(cur->bc_tp, rbp, XFS_BB_NUMRECS); 1557 xfs_alloc_log_block(cur->bc_tp, rbp, XFS_BB_NUMRECS);
1559 /* 1558 /*
1560 * Using a temporary cursor, update the parent key values of the 1559 * Using a temporary cursor, update the parent key values of the
@@ -1627,17 +1626,17 @@ xfs_alloc_split(
1627 /* 1626 /*
1628 * Fill in the btree header for the new block. 1627 * Fill in the btree header for the new block.
1629 */ 1628 */
1630 INT_SET(right->bb_magic, ARCH_CONVERT, xfs_magics[cur->bc_btnum]); 1629 right->bb_magic = cpu_to_be32(xfs_magics[cur->bc_btnum]);
1631 right->bb_level = left->bb_level; /* INT_: direct copy */ 1630 right->bb_level = left->bb_level;
1632 INT_SET(right->bb_numrecs, ARCH_CONVERT, (__uint16_t)(INT_GET(left->bb_numrecs, ARCH_CONVERT) / 2)); 1631 right->bb_numrecs = cpu_to_be16(be16_to_cpu(left->bb_numrecs) / 2);
1633 /* 1632 /*
1634 * Make sure that if there's an odd number of entries now, that 1633 * Make sure that if there's an odd number of entries now, that
1635 * each new block will have the same number of entries. 1634 * each new block will have the same number of entries.
1636 */ 1635 */
1637 if ((INT_GET(left->bb_numrecs, ARCH_CONVERT) & 1) && 1636 if ((be16_to_cpu(left->bb_numrecs) & 1) &&
1638 cur->bc_ptrs[level] <= INT_GET(right->bb_numrecs, ARCH_CONVERT) + 1) 1637 cur->bc_ptrs[level] <= be16_to_cpu(right->bb_numrecs) + 1)
1639 INT_MOD(right->bb_numrecs, ARCH_CONVERT, +1); 1638 be16_add(&right->bb_numrecs, 1);
1640 i = INT_GET(left->bb_numrecs, ARCH_CONVERT) - INT_GET(right->bb_numrecs, ARCH_CONVERT) + 1; 1639 i = be16_to_cpu(left->bb_numrecs) - be16_to_cpu(right->bb_numrecs) + 1;
1641 /* 1640 /*
1642 * For non-leaf blocks, copy keys and addresses over to the new block. 1641 * For non-leaf blocks, copy keys and addresses over to the new block.
1643 */ 1642 */
@@ -1652,15 +1651,15 @@ xfs_alloc_split(
1652 rkp = XFS_ALLOC_KEY_ADDR(right, 1, cur); 1651 rkp = XFS_ALLOC_KEY_ADDR(right, 1, cur);
1653 rpp = XFS_ALLOC_PTR_ADDR(right, 1, cur); 1652 rpp = XFS_ALLOC_PTR_ADDR(right, 1, cur);
1654#ifdef DEBUG 1653#ifdef DEBUG
1655 for (i = 0; i < INT_GET(right->bb_numrecs, ARCH_CONVERT); i++) { 1654 for (i = 0; i < be16_to_cpu(right->bb_numrecs); i++) {
1656 if ((error = xfs_btree_check_sptr(cur, INT_GET(lpp[i], ARCH_CONVERT), level))) 1655 if ((error = xfs_btree_check_sptr(cur, be32_to_cpu(lpp[i]), level)))
1657 return error; 1656 return error;
1658 } 1657 }
1659#endif 1658#endif
1660 memcpy(rkp, lkp, INT_GET(right->bb_numrecs, ARCH_CONVERT) * sizeof(*rkp)); /* INT_: copy */ 1659 memcpy(rkp, lkp, be16_to_cpu(right->bb_numrecs) * sizeof(*rkp));
1661 memcpy(rpp, lpp, INT_GET(right->bb_numrecs, ARCH_CONVERT) * sizeof(*rpp)); /* INT_: copy */ 1660 memcpy(rpp, lpp, be16_to_cpu(right->bb_numrecs) * sizeof(*rpp));
1662 xfs_alloc_log_keys(cur, rbp, 1, INT_GET(right->bb_numrecs, ARCH_CONVERT)); 1661 xfs_alloc_log_keys(cur, rbp, 1, be16_to_cpu(right->bb_numrecs));
1663 xfs_alloc_log_ptrs(cur, rbp, 1, INT_GET(right->bb_numrecs, ARCH_CONVERT)); 1662 xfs_alloc_log_ptrs(cur, rbp, 1, be16_to_cpu(right->bb_numrecs));
1664 *keyp = *rkp; 1663 *keyp = *rkp;
1665 } 1664 }
1666 /* 1665 /*
@@ -1672,38 +1671,38 @@ xfs_alloc_split(
1672 1671
1673 lrp = XFS_ALLOC_REC_ADDR(left, i, cur); 1672 lrp = XFS_ALLOC_REC_ADDR(left, i, cur);
1674 rrp = XFS_ALLOC_REC_ADDR(right, 1, cur); 1673 rrp = XFS_ALLOC_REC_ADDR(right, 1, cur);
1675 memcpy(rrp, lrp, INT_GET(right->bb_numrecs, ARCH_CONVERT) * sizeof(*rrp)); 1674 memcpy(rrp, lrp, be16_to_cpu(right->bb_numrecs) * sizeof(*rrp));
1676 xfs_alloc_log_recs(cur, rbp, 1, INT_GET(right->bb_numrecs, ARCH_CONVERT)); 1675 xfs_alloc_log_recs(cur, rbp, 1, be16_to_cpu(right->bb_numrecs));
1677 keyp->ar_startblock = rrp->ar_startblock; /* INT_: direct copy */ 1676 keyp->ar_startblock = rrp->ar_startblock;
1678 keyp->ar_blockcount = rrp->ar_blockcount; /* INT_: direct copy */ 1677 keyp->ar_blockcount = rrp->ar_blockcount;
1679 } 1678 }
1680 /* 1679 /*
1681 * Find the left block number by looking in the buffer. 1680 * Find the left block number by looking in the buffer.
1682 * Adjust numrecs, sibling pointers. 1681 * Adjust numrecs, sibling pointers.
1683 */ 1682 */
1684 lbno = XFS_DADDR_TO_AGBNO(cur->bc_mp, XFS_BUF_ADDR(lbp)); 1683 lbno = XFS_DADDR_TO_AGBNO(cur->bc_mp, XFS_BUF_ADDR(lbp));
1685 INT_MOD(left->bb_numrecs, ARCH_CONVERT, -(INT_GET(right->bb_numrecs, ARCH_CONVERT))); 1684 be16_add(&left->bb_numrecs, -(be16_to_cpu(right->bb_numrecs)));
1686 right->bb_rightsib = left->bb_rightsib; /* INT_: direct copy */ 1685 right->bb_rightsib = left->bb_rightsib;
1687 INT_SET(left->bb_rightsib, ARCH_CONVERT, rbno); 1686 left->bb_rightsib = cpu_to_be32(rbno);
1688 INT_SET(right->bb_leftsib, ARCH_CONVERT, lbno); 1687 right->bb_leftsib = cpu_to_be32(lbno);
1689 xfs_alloc_log_block(cur->bc_tp, rbp, XFS_BB_ALL_BITS); 1688 xfs_alloc_log_block(cur->bc_tp, rbp, XFS_BB_ALL_BITS);
1690 xfs_alloc_log_block(cur->bc_tp, lbp, XFS_BB_NUMRECS | XFS_BB_RIGHTSIB); 1689 xfs_alloc_log_block(cur->bc_tp, lbp, XFS_BB_NUMRECS | XFS_BB_RIGHTSIB);
1691 /* 1690 /*
1692 * If there's a block to the new block's right, make that block 1691 * If there's a block to the new block's right, make that block
1693 * point back to right instead of to left. 1692 * point back to right instead of to left.
1694 */ 1693 */
1695 if (INT_GET(right->bb_rightsib, ARCH_CONVERT) != NULLAGBLOCK) { 1694 if (be32_to_cpu(right->bb_rightsib) != NULLAGBLOCK) {
1696 xfs_alloc_block_t *rrblock; /* rr btree block */ 1695 xfs_alloc_block_t *rrblock; /* rr btree block */
1697 xfs_buf_t *rrbp; /* buffer for rrblock */ 1696 xfs_buf_t *rrbp; /* buffer for rrblock */
1698 1697
1699 if ((error = xfs_btree_read_bufs(cur->bc_mp, cur->bc_tp, 1698 if ((error = xfs_btree_read_bufs(cur->bc_mp, cur->bc_tp,
1700 cur->bc_private.a.agno, INT_GET(right->bb_rightsib, ARCH_CONVERT), 0, 1699 cur->bc_private.a.agno, be32_to_cpu(right->bb_rightsib), 0,
1701 &rrbp, XFS_ALLOC_BTREE_REF))) 1700 &rrbp, XFS_ALLOC_BTREE_REF)))
1702 return error; 1701 return error;
1703 rrblock = XFS_BUF_TO_ALLOC_BLOCK(rrbp); 1702 rrblock = XFS_BUF_TO_ALLOC_BLOCK(rrbp);
1704 if ((error = xfs_btree_check_sblock(cur, rrblock, level, rrbp))) 1703 if ((error = xfs_btree_check_sblock(cur, rrblock, level, rrbp)))
1705 return error; 1704 return error;
1706 INT_SET(rrblock->bb_leftsib, ARCH_CONVERT, rbno); 1705 rrblock->bb_leftsib = cpu_to_be32(rbno);
1707 xfs_alloc_log_block(cur->bc_tp, rrbp, XFS_BB_LEFTSIB); 1706 xfs_alloc_log_block(cur->bc_tp, rrbp, XFS_BB_LEFTSIB);
1708 } 1707 }
1709 /* 1708 /*
@@ -1711,9 +1710,9 @@ xfs_alloc_split(
1711 * If it's just pointing past the last entry in left, then we'll 1710 * If it's just pointing past the last entry in left, then we'll
1712 * insert there, so don't change anything in that case. 1711 * insert there, so don't change anything in that case.
1713 */ 1712 */
1714 if (cur->bc_ptrs[level] > INT_GET(left->bb_numrecs, ARCH_CONVERT) + 1) { 1713 if (cur->bc_ptrs[level] > be16_to_cpu(left->bb_numrecs) + 1) {
1715 xfs_btree_setbuf(cur, level, rbp); 1714 xfs_btree_setbuf(cur, level, rbp);
1716 cur->bc_ptrs[level] -= INT_GET(left->bb_numrecs, ARCH_CONVERT); 1715 cur->bc_ptrs[level] -= be16_to_cpu(left->bb_numrecs);
1717 } 1716 }
1718 /* 1717 /*
1719 * If there are more levels, we'll need another cursor which refers to 1718 * If there are more levels, we'll need another cursor which refers to
@@ -1811,7 +1810,7 @@ xfs_alloc_decrement(
1811 /* 1810 /*
1812 * If we just went off the left edge of the tree, return failure. 1811 * If we just went off the left edge of the tree, return failure.
1813 */ 1812 */
1814 if (INT_GET(block->bb_leftsib, ARCH_CONVERT) == NULLAGBLOCK) { 1813 if (be32_to_cpu(block->bb_leftsib) == NULLAGBLOCK) {
1815 *stat = 0; 1814 *stat = 0;
1816 return 0; 1815 return 0;
1817 } 1816 }
@@ -1840,7 +1839,7 @@ xfs_alloc_decrement(
1840 xfs_agblock_t agbno; /* block number of btree block */ 1839 xfs_agblock_t agbno; /* block number of btree block */
1841 xfs_buf_t *bp; /* buffer pointer for block */ 1840 xfs_buf_t *bp; /* buffer pointer for block */
1842 1841
1843 agbno = INT_GET(*XFS_ALLOC_PTR_ADDR(block, cur->bc_ptrs[lev], cur), ARCH_CONVERT); 1842 agbno = be32_to_cpu(*XFS_ALLOC_PTR_ADDR(block, cur->bc_ptrs[lev], cur));
1844 if ((error = xfs_btree_read_bufs(cur->bc_mp, cur->bc_tp, 1843 if ((error = xfs_btree_read_bufs(cur->bc_mp, cur->bc_tp,
1845 cur->bc_private.a.agno, agbno, 0, &bp, 1844 cur->bc_private.a.agno, agbno, 0, &bp,
1846 XFS_ALLOC_BTREE_REF))) 1845 XFS_ALLOC_BTREE_REF)))
@@ -1850,7 +1849,7 @@ xfs_alloc_decrement(
1850 block = XFS_BUF_TO_ALLOC_BLOCK(bp); 1849 block = XFS_BUF_TO_ALLOC_BLOCK(bp);
1851 if ((error = xfs_btree_check_sblock(cur, block, lev, bp))) 1850 if ((error = xfs_btree_check_sblock(cur, block, lev, bp)))
1852 return error; 1851 return error;
1853 cur->bc_ptrs[lev] = INT_GET(block->bb_numrecs, ARCH_CONVERT); 1852 cur->bc_ptrs[lev] = be16_to_cpu(block->bb_numrecs);
1854 } 1853 }
1855 *stat = 1; 1854 *stat = 1;
1856 return 0; 1855 return 0;
@@ -1917,7 +1916,7 @@ xfs_alloc_get_rec(
1917 /* 1916 /*
1918 * Off the right end or left end, return failure. 1917 * Off the right end or left end, return failure.
1919 */ 1918 */
1920 if (ptr > INT_GET(block->bb_numrecs, ARCH_CONVERT) || ptr <= 0) { 1919 if (ptr > be16_to_cpu(block->bb_numrecs) || ptr <= 0) {
1921 *stat = 0; 1920 *stat = 0;
1922 return 0; 1921 return 0;
1923 } 1922 }
@@ -1928,8 +1927,8 @@ xfs_alloc_get_rec(
1928 xfs_alloc_rec_t *rec; /* record data */ 1927 xfs_alloc_rec_t *rec; /* record data */
1929 1928
1930 rec = XFS_ALLOC_REC_ADDR(block, ptr, cur); 1929 rec = XFS_ALLOC_REC_ADDR(block, ptr, cur);
1931 *bno = INT_GET(rec->ar_startblock, ARCH_CONVERT); 1930 *bno = be32_to_cpu(rec->ar_startblock);
1932 *len = INT_GET(rec->ar_blockcount, ARCH_CONVERT); 1931 *len = be32_to_cpu(rec->ar_blockcount);
1933 } 1932 }
1934 *stat = 1; 1933 *stat = 1;
1935 return 0; 1934 return 0;
@@ -1968,14 +1967,14 @@ xfs_alloc_increment(
1968 * Increment the ptr at this level. If we're still in the block 1967 * Increment the ptr at this level. If we're still in the block
1969 * then we're done. 1968 * then we're done.
1970 */ 1969 */
1971 if (++cur->bc_ptrs[level] <= INT_GET(block->bb_numrecs, ARCH_CONVERT)) { 1970 if (++cur->bc_ptrs[level] <= be16_to_cpu(block->bb_numrecs)) {
1972 *stat = 1; 1971 *stat = 1;
1973 return 0; 1972 return 0;
1974 } 1973 }
1975 /* 1974 /*
1976 * If we just went off the right edge of the tree, return failure. 1975 * If we just went off the right edge of the tree, return failure.
1977 */ 1976 */
1978 if (INT_GET(block->bb_rightsib, ARCH_CONVERT) == NULLAGBLOCK) { 1977 if (be32_to_cpu(block->bb_rightsib) == NULLAGBLOCK) {
1979 *stat = 0; 1978 *stat = 0;
1980 return 0; 1979 return 0;
1981 } 1980 }
@@ -1990,7 +1989,7 @@ xfs_alloc_increment(
1990 if ((error = xfs_btree_check_sblock(cur, block, lev, bp))) 1989 if ((error = xfs_btree_check_sblock(cur, block, lev, bp)))
1991 return error; 1990 return error;
1992#endif 1991#endif
1993 if (++cur->bc_ptrs[lev] <= INT_GET(block->bb_numrecs, ARCH_CONVERT)) 1992 if (++cur->bc_ptrs[lev] <= be16_to_cpu(block->bb_numrecs))
1994 break; 1993 break;
1995 /* 1994 /*
1996 * Read-ahead the right block, we're going to read it 1995 * Read-ahead the right block, we're going to read it
@@ -2010,7 +2009,7 @@ xfs_alloc_increment(
2010 lev > level; ) { 2009 lev > level; ) {
2011 xfs_agblock_t agbno; /* block number of btree block */ 2010 xfs_agblock_t agbno; /* block number of btree block */
2012 2011
2013 agbno = INT_GET(*XFS_ALLOC_PTR_ADDR(block, cur->bc_ptrs[lev], cur), ARCH_CONVERT); 2012 agbno = be32_to_cpu(*XFS_ALLOC_PTR_ADDR(block, cur->bc_ptrs[lev], cur));
2014 if ((error = xfs_btree_read_bufs(cur->bc_mp, cur->bc_tp, 2013 if ((error = xfs_btree_read_bufs(cur->bc_mp, cur->bc_tp,
2015 cur->bc_private.a.agno, agbno, 0, &bp, 2014 cur->bc_private.a.agno, agbno, 0, &bp,
2016 XFS_ALLOC_BTREE_REF))) 2015 XFS_ALLOC_BTREE_REF)))
@@ -2045,8 +2044,8 @@ xfs_alloc_insert(
2045 2044
2046 level = 0; 2045 level = 0;
2047 nbno = NULLAGBLOCK; 2046 nbno = NULLAGBLOCK;
2048 INT_SET(nrec.ar_startblock, ARCH_CONVERT, cur->bc_rec.a.ar_startblock); 2047 nrec.ar_startblock = cpu_to_be32(cur->bc_rec.a.ar_startblock);
2049 INT_SET(nrec.ar_blockcount, ARCH_CONVERT, cur->bc_rec.a.ar_blockcount); 2048 nrec.ar_blockcount = cpu_to_be32(cur->bc_rec.a.ar_blockcount);
2050 ncur = (xfs_btree_cur_t *)0; 2049 ncur = (xfs_btree_cur_t *)0;
2051 pcur = cur; 2050 pcur = cur;
2052 /* 2051 /*
@@ -2167,8 +2166,8 @@ xfs_alloc_update(
2167 /* 2166 /*
2168 * Fill in the new contents and log them. 2167 * Fill in the new contents and log them.
2169 */ 2168 */
2170 INT_SET(rp->ar_startblock, ARCH_CONVERT, bno); 2169 rp->ar_startblock = cpu_to_be32(bno);
2171 INT_SET(rp->ar_blockcount, ARCH_CONVERT, len); 2170 rp->ar_blockcount = cpu_to_be32(len);
2172 xfs_alloc_log_recs(cur, cur->bc_bufs[0], ptr, ptr); 2171 xfs_alloc_log_recs(cur, cur->bc_bufs[0], ptr, ptr);
2173 } 2172 }
2174 /* 2173 /*
@@ -2177,15 +2176,15 @@ xfs_alloc_update(
2177 * extent in the a.g., which we cache in the a.g. freelist header. 2176 * extent in the a.g., which we cache in the a.g. freelist header.
2178 */ 2177 */
2179 if (cur->bc_btnum == XFS_BTNUM_CNT && 2178 if (cur->bc_btnum == XFS_BTNUM_CNT &&
2180 INT_GET(block->bb_rightsib, ARCH_CONVERT) == NULLAGBLOCK && 2179 be32_to_cpu(block->bb_rightsib) == NULLAGBLOCK &&
2181 ptr == INT_GET(block->bb_numrecs, ARCH_CONVERT)) { 2180 ptr == be16_to_cpu(block->bb_numrecs)) {
2182 xfs_agf_t *agf; /* a.g. freespace header */ 2181 xfs_agf_t *agf; /* a.g. freespace header */
2183 xfs_agnumber_t seqno; 2182 xfs_agnumber_t seqno;
2184 2183
2185 agf = XFS_BUF_TO_AGF(cur->bc_private.a.agbp); 2184 agf = XFS_BUF_TO_AGF(cur->bc_private.a.agbp);
2186 seqno = INT_GET(agf->agf_seqno, ARCH_CONVERT); 2185 seqno = be32_to_cpu(agf->agf_seqno);
2187 cur->bc_mp->m_perag[seqno].pagf_longest = len; 2186 cur->bc_mp->m_perag[seqno].pagf_longest = len;
2188 INT_SET(agf->agf_longest, ARCH_CONVERT, len); 2187 agf->agf_longest = cpu_to_be32(len);
2189 xfs_alloc_log_agf(cur->bc_tp, cur->bc_private.a.agbp, 2188 xfs_alloc_log_agf(cur->bc_tp, cur->bc_private.a.agbp,
2190 XFS_AGF_LONGEST); 2189 XFS_AGF_LONGEST);
2191 } 2190 }
@@ -2195,8 +2194,8 @@ xfs_alloc_update(
2195 if (ptr == 1) { 2194 if (ptr == 1) {
2196 xfs_alloc_key_t key; /* key containing [bno, len] */ 2195 xfs_alloc_key_t key; /* key containing [bno, len] */
2197 2196
2198 INT_SET(key.ar_startblock, ARCH_CONVERT, bno); 2197 key.ar_startblock = cpu_to_be32(bno);
2199 INT_SET(key.ar_blockcount, ARCH_CONVERT, len); 2198 key.ar_blockcount = cpu_to_be32(len);
2200 if ((error = xfs_alloc_updkey(cur, &key, 1))) 2199 if ((error = xfs_alloc_updkey(cur, &key, 1)))
2201 return error; 2200 return error;
2202 } 2201 }
diff --git a/fs/xfs/xfs_alloc_btree.h b/fs/xfs/xfs_alloc_btree.h
index ed5161a572ef..bce81c7a4fdc 100644
--- a/fs/xfs/xfs_alloc_btree.h
+++ b/fs/xfs/xfs_alloc_btree.h
@@ -1,33 +1,19 @@
1/* 1/*
2 * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32#ifndef __XFS_ALLOC_BTREE_H__ 18#ifndef __XFS_ALLOC_BTREE_H__
33#define __XFS_ALLOC_BTREE_H__ 19#define __XFS_ALLOC_BTREE_H__
@@ -52,48 +38,29 @@ struct xfs_mount;
52/* 38/*
53 * Data record/key structure 39 * Data record/key structure
54 */ 40 */
55typedef struct xfs_alloc_rec 41typedef struct xfs_alloc_rec {
56{ 42 __be32 ar_startblock; /* starting block number */
43 __be32 ar_blockcount; /* count of free blocks */
44} xfs_alloc_rec_t, xfs_alloc_key_t;
45
46typedef struct xfs_alloc_rec_incore {
57 xfs_agblock_t ar_startblock; /* starting block number */ 47 xfs_agblock_t ar_startblock; /* starting block number */
58 xfs_extlen_t ar_blockcount; /* count of free blocks */ 48 xfs_extlen_t ar_blockcount; /* count of free blocks */
59} xfs_alloc_rec_t, xfs_alloc_key_t; 49} xfs_alloc_rec_incore_t;
60 50
61typedef xfs_agblock_t xfs_alloc_ptr_t; /* btree pointer type */ 51/* btree pointer type */
62 /* btree block header type */ 52typedef __be32 xfs_alloc_ptr_t;
53/* btree block header type */
63typedef struct xfs_btree_sblock xfs_alloc_block_t; 54typedef struct xfs_btree_sblock xfs_alloc_block_t;
64 55
65#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BUF_TO_ALLOC_BLOCK) 56#define XFS_BUF_TO_ALLOC_BLOCK(bp) ((xfs_alloc_block_t *)XFS_BUF_PTR(bp))
66xfs_alloc_block_t *xfs_buf_to_alloc_block(struct xfs_buf *bp);
67#define XFS_BUF_TO_ALLOC_BLOCK(bp) xfs_buf_to_alloc_block(bp)
68#else
69#define XFS_BUF_TO_ALLOC_BLOCK(bp) ((xfs_alloc_block_t *)(XFS_BUF_PTR(bp)))
70#endif
71 57
72/* 58/*
73 * Real block structures have a size equal to the disk block size. 59 * Real block structures have a size equal to the disk block size.
74 */ 60 */
75
76#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_ALLOC_BLOCK_SIZE)
77int xfs_alloc_block_size(int lev, struct xfs_btree_cur *cur);
78#define XFS_ALLOC_BLOCK_SIZE(lev,cur) xfs_alloc_block_size(lev,cur)
79#else
80#define XFS_ALLOC_BLOCK_SIZE(lev,cur) (1 << (cur)->bc_blocklog) 61#define XFS_ALLOC_BLOCK_SIZE(lev,cur) (1 << (cur)->bc_blocklog)
81#endif 62#define XFS_ALLOC_BLOCK_MAXRECS(lev,cur) ((cur)->bc_mp->m_alloc_mxr[lev != 0])
82 63#define XFS_ALLOC_BLOCK_MINRECS(lev,cur) ((cur)->bc_mp->m_alloc_mnr[lev != 0])
83#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_ALLOC_BLOCK_MAXRECS)
84int xfs_alloc_block_maxrecs(int lev, struct xfs_btree_cur *cur);
85#define XFS_ALLOC_BLOCK_MAXRECS(lev,cur) xfs_alloc_block_maxrecs(lev,cur)
86#else
87#define XFS_ALLOC_BLOCK_MAXRECS(lev,cur) \
88 ((cur)->bc_mp->m_alloc_mxr[lev != 0])
89#endif
90#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_ALLOC_BLOCK_MINRECS)
91int xfs_alloc_block_minrecs(int lev, struct xfs_btree_cur *cur);
92#define XFS_ALLOC_BLOCK_MINRECS(lev,cur) xfs_alloc_block_minrecs(lev,cur)
93#else
94#define XFS_ALLOC_BLOCK_MINRECS(lev,cur) \
95 ((cur)->bc_mp->m_alloc_mnr[lev != 0])
96#endif
97 64
98/* 65/*
99 * Minimum and maximum blocksize and sectorsize. 66 * Minimum and maximum blocksize and sectorsize.
@@ -113,145 +80,80 @@ int xfs_alloc_block_minrecs(int lev, struct xfs_btree_cur *cur);
113 * Block numbers in the AG: 80 * Block numbers in the AG:
114 * SB is sector 0, AGF is sector 1, AGI is sector 2, AGFL is sector 3. 81 * SB is sector 0, AGF is sector 1, AGI is sector 2, AGFL is sector 3.
115 */ 82 */
116#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BNO_BLOCK)
117xfs_agblock_t xfs_bno_block(struct xfs_mount *mp);
118#define XFS_BNO_BLOCK(mp) xfs_bno_block(mp)
119#else
120#define XFS_BNO_BLOCK(mp) ((xfs_agblock_t)(XFS_AGFL_BLOCK(mp) + 1)) 83#define XFS_BNO_BLOCK(mp) ((xfs_agblock_t)(XFS_AGFL_BLOCK(mp) + 1))
121#endif
122#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_CNT_BLOCK)
123xfs_agblock_t xfs_cnt_block(struct xfs_mount *mp);
124#define XFS_CNT_BLOCK(mp) xfs_cnt_block(mp)
125#else
126#define XFS_CNT_BLOCK(mp) ((xfs_agblock_t)(XFS_BNO_BLOCK(mp) + 1)) 84#define XFS_CNT_BLOCK(mp) ((xfs_agblock_t)(XFS_BNO_BLOCK(mp) + 1))
127#endif
128 85
129/* 86/*
130 * Record, key, and pointer address macros for btree blocks. 87 * Record, key, and pointer address macros for btree blocks.
131 */ 88 */
132#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_ALLOC_REC_ADDR)
133xfs_alloc_rec_t *xfs_alloc_rec_addr(xfs_alloc_block_t *bb, int i,
134 struct xfs_btree_cur *cur);
135#define XFS_ALLOC_REC_ADDR(bb,i,cur) xfs_alloc_rec_addr(bb,i,cur)
136#else
137#define XFS_ALLOC_REC_ADDR(bb,i,cur) \ 89#define XFS_ALLOC_REC_ADDR(bb,i,cur) \
138 XFS_BTREE_REC_ADDR(XFS_ALLOC_BLOCK_SIZE(0,cur), xfs_alloc, bb, i, \ 90 XFS_BTREE_REC_ADDR(XFS_ALLOC_BLOCK_SIZE(0,cur), xfs_alloc, \
139 XFS_ALLOC_BLOCK_MAXRECS(0, cur)) 91 bb, i, XFS_ALLOC_BLOCK_MAXRECS(0, cur))
140#endif
141 92
142#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_ALLOC_KEY_ADDR)
143xfs_alloc_key_t *xfs_alloc_key_addr(xfs_alloc_block_t *bb, int i,
144 struct xfs_btree_cur *cur);
145#define XFS_ALLOC_KEY_ADDR(bb,i,cur) xfs_alloc_key_addr(bb,i,cur)
146#else
147#define XFS_ALLOC_KEY_ADDR(bb,i,cur) \ 93#define XFS_ALLOC_KEY_ADDR(bb,i,cur) \
148 XFS_BTREE_KEY_ADDR(XFS_ALLOC_BLOCK_SIZE(1,cur), xfs_alloc, bb, i, \ 94 XFS_BTREE_KEY_ADDR(XFS_ALLOC_BLOCK_SIZE(1,cur), xfs_alloc, \
149 XFS_ALLOC_BLOCK_MAXRECS(1, cur)) 95 bb, i, XFS_ALLOC_BLOCK_MAXRECS(1, cur))
150#endif
151 96
152#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_ALLOC_PTR_ADDR)
153xfs_alloc_ptr_t *xfs_alloc_ptr_addr(xfs_alloc_block_t *bb, int i,
154 struct xfs_btree_cur *cur);
155#define XFS_ALLOC_PTR_ADDR(bb,i,cur) xfs_alloc_ptr_addr(bb,i,cur)
156#else
157#define XFS_ALLOC_PTR_ADDR(bb,i,cur) \ 97#define XFS_ALLOC_PTR_ADDR(bb,i,cur) \
158 XFS_BTREE_PTR_ADDR(XFS_ALLOC_BLOCK_SIZE(1,cur), xfs_alloc, bb, i, \ 98 XFS_BTREE_PTR_ADDR(XFS_ALLOC_BLOCK_SIZE(1,cur), xfs_alloc, \
159 XFS_ALLOC_BLOCK_MAXRECS(1, cur)) 99 bb, i, XFS_ALLOC_BLOCK_MAXRECS(1, cur))
160#endif
161
162/*
163 * Prototypes for externally visible routines.
164 */
165 100
166/* 101/*
167 * Decrement cursor by one record at the level. 102 * Decrement cursor by one record at the level.
168 * For nonzero levels the leaf-ward information is untouched. 103 * For nonzero levels the leaf-ward information is untouched.
169 */ 104 */
170int /* error */ 105extern int xfs_alloc_decrement(struct xfs_btree_cur *cur, int level, int *stat);
171xfs_alloc_decrement(
172 struct xfs_btree_cur *cur, /* btree cursor */
173 int level, /* level in btree, 0 is leaf */
174 int *stat); /* success/failure */
175 106
176/* 107/*
177 * Delete the record pointed to by cur. 108 * Delete the record pointed to by cur.
178 * The cursor refers to the place where the record was (could be inserted) 109 * The cursor refers to the place where the record was (could be inserted)
179 * when the operation returns. 110 * when the operation returns.
180 */ 111 */
181int /* error */ 112extern int xfs_alloc_delete(struct xfs_btree_cur *cur, int *stat);
182xfs_alloc_delete(
183 struct xfs_btree_cur *cur, /* btree cursor */
184 int *stat); /* success/failure */
185 113
186/* 114/*
187 * Get the data from the pointed-to record. 115 * Get the data from the pointed-to record.
188 */ 116 */
189int /* error */ 117extern int xfs_alloc_get_rec(struct xfs_btree_cur *cur, xfs_agblock_t *bno,
190xfs_alloc_get_rec( 118 xfs_extlen_t *len, int *stat);
191 struct xfs_btree_cur *cur, /* btree cursor */
192 xfs_agblock_t *bno, /* output: starting block of extent */
193 xfs_extlen_t *len, /* output: length of extent */
194 int *stat); /* output: success/failure */
195 119
196/* 120/*
197 * Increment cursor by one record at the level. 121 * Increment cursor by one record at the level.
198 * For nonzero levels the leaf-ward information is untouched. 122 * For nonzero levels the leaf-ward information is untouched.
199 */ 123 */
200int /* error */ 124extern int xfs_alloc_increment(struct xfs_btree_cur *cur, int level, int *stat);
201xfs_alloc_increment(
202 struct xfs_btree_cur *cur, /* btree cursor */
203 int level, /* level in btree, 0 is leaf */
204 int *stat); /* success/failure */
205 125
206/* 126/*
207 * Insert the current record at the point referenced by cur. 127 * Insert the current record at the point referenced by cur.
208 * The cursor may be inconsistent on return if splits have been done. 128 * The cursor may be inconsistent on return if splits have been done.
209 */ 129 */
210int /* error */ 130extern int xfs_alloc_insert(struct xfs_btree_cur *cur, int *stat);
211xfs_alloc_insert(
212 struct xfs_btree_cur *cur, /* btree cursor */
213 int *stat); /* success/failure */
214 131
215/* 132/*
216 * Lookup the record equal to [bno, len] in the btree given by cur. 133 * Lookup the record equal to [bno, len] in the btree given by cur.
217 */ 134 */
218int /* error */ 135extern int xfs_alloc_lookup_eq(struct xfs_btree_cur *cur, xfs_agblock_t bno,
219xfs_alloc_lookup_eq( 136 xfs_extlen_t len, int *stat);
220 struct xfs_btree_cur *cur, /* btree cursor */
221 xfs_agblock_t bno, /* starting block of extent */
222 xfs_extlen_t len, /* length of extent */
223 int *stat); /* success/failure */
224 137
225/* 138/*
226 * Lookup the first record greater than or equal to [bno, len] 139 * Lookup the first record greater than or equal to [bno, len]
227 * in the btree given by cur. 140 * in the btree given by cur.
228 */ 141 */
229int /* error */ 142extern int xfs_alloc_lookup_ge(struct xfs_btree_cur *cur, xfs_agblock_t bno,
230xfs_alloc_lookup_ge( 143 xfs_extlen_t len, int *stat);
231 struct xfs_btree_cur *cur, /* btree cursor */
232 xfs_agblock_t bno, /* starting block of extent */
233 xfs_extlen_t len, /* length of extent */
234 int *stat); /* success/failure */
235 144
236/* 145/*
237 * Lookup the first record less than or equal to [bno, len] 146 * Lookup the first record less than or equal to [bno, len]
238 * in the btree given by cur. 147 * in the btree given by cur.
239 */ 148 */
240int /* error */ 149extern int xfs_alloc_lookup_le(struct xfs_btree_cur *cur, xfs_agblock_t bno,
241xfs_alloc_lookup_le( 150 xfs_extlen_t len, int *stat);
242 struct xfs_btree_cur *cur, /* btree cursor */
243 xfs_agblock_t bno, /* starting block of extent */
244 xfs_extlen_t len, /* length of extent */
245 int *stat); /* success/failure */
246 151
247/* 152/*
248 * Update the record referred to by cur, to the value given by [bno, len]. 153 * Update the record referred to by cur, to the value given by [bno, len].
249 * This either works (return 0) or gets an EFSCORRUPTED error. 154 * This either works (return 0) or gets an EFSCORRUPTED error.
250 */ 155 */
251int /* error */ 156extern int xfs_alloc_update(struct xfs_btree_cur *cur, xfs_agblock_t bno,
252xfs_alloc_update( 157 xfs_extlen_t len);
253 struct xfs_btree_cur *cur, /* btree cursor */
254 xfs_agblock_t bno, /* starting block of extent */
255 xfs_extlen_t len); /* length of extent */
256 158
257#endif /* __XFS_ALLOC_BTREE_H__ */ 159#endif /* __XFS_ALLOC_BTREE_H__ */
diff --git a/fs/xfs/xfs_arch.h b/fs/xfs/xfs_arch.h
index 5ab0dd885b1b..68e5051d8e24 100644
--- a/fs/xfs/xfs_arch.h
+++ b/fs/xfs/xfs_arch.h
@@ -1,33 +1,19 @@
1/* 1/*
2 * Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32#ifndef __XFS_ARCH_H__ 18#ifndef __XFS_ARCH_H__
33#define __XFS_ARCH_H__ 19#define __XFS_ARCH_H__
@@ -168,6 +154,21 @@
168 } \ 154 } \
169} 155}
170 156
157static inline void be16_add(__be16 *a, __s16 b)
158{
159 *a = cpu_to_be16(be16_to_cpu(*a) + b);
160}
161
162static inline void be32_add(__be32 *a, __s32 b)
163{
164 *a = cpu_to_be32(be32_to_cpu(*a) + b);
165}
166
167static inline void be64_add(__be64 *a, __s64 b)
168{
169 *a = cpu_to_be64(be64_to_cpu(*a) + b);
170}
171
171/* 172/*
172 * In directories inode numbers are stored as unaligned arrays of unsigned 173 * In directories inode numbers are stored as unaligned arrays of unsigned
173 * 8bit integers on disk. 174 * 8bit integers on disk.
diff --git a/fs/xfs/xfs_attr.c b/fs/xfs/xfs_attr.c
index a41ad3a5e554..5484eeb460c8 100644
--- a/fs/xfs/xfs_attr.c
+++ b/fs/xfs/xfs_attr.c
@@ -1,41 +1,26 @@
1/* 1/*
2 * Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32
33#include "xfs.h" 18#include "xfs.h"
34 19#include "xfs_fs.h"
35#include "xfs_macros.h"
36#include "xfs_types.h" 20#include "xfs_types.h"
37#include "xfs_inum.h" 21#include "xfs_bit.h"
38#include "xfs_log.h" 22#include "xfs_log.h"
23#include "xfs_inum.h"
39#include "xfs_trans.h" 24#include "xfs_trans.h"
40#include "xfs_sb.h" 25#include "xfs_sb.h"
41#include "xfs_ag.h" 26#include "xfs_ag.h"
@@ -43,27 +28,26 @@
43#include "xfs_dir2.h" 28#include "xfs_dir2.h"
44#include "xfs_dmapi.h" 29#include "xfs_dmapi.h"
45#include "xfs_mount.h" 30#include "xfs_mount.h"
46#include "xfs_alloc_btree.h" 31#include "xfs_da_btree.h"
47#include "xfs_bmap_btree.h" 32#include "xfs_bmap_btree.h"
33#include "xfs_alloc_btree.h"
48#include "xfs_ialloc_btree.h" 34#include "xfs_ialloc_btree.h"
49#include "xfs_alloc.h"
50#include "xfs_btree.h"
51#include "xfs_attr_sf.h"
52#include "xfs_dir_sf.h" 35#include "xfs_dir_sf.h"
53#include "xfs_dir2_sf.h" 36#include "xfs_dir2_sf.h"
37#include "xfs_attr_sf.h"
54#include "xfs_dinode.h" 38#include "xfs_dinode.h"
55#include "xfs_inode_item.h"
56#include "xfs_inode.h" 39#include "xfs_inode.h"
40#include "xfs_alloc.h"
41#include "xfs_btree.h"
42#include "xfs_inode_item.h"
57#include "xfs_bmap.h" 43#include "xfs_bmap.h"
58#include "xfs_da_btree.h"
59#include "xfs_attr.h" 44#include "xfs_attr.h"
60#include "xfs_attr_leaf.h" 45#include "xfs_attr_leaf.h"
61#include "xfs_error.h" 46#include "xfs_error.h"
62#include "xfs_bit.h"
63#include "xfs_quota.h" 47#include "xfs_quota.h"
64#include "xfs_rw.h"
65#include "xfs_trans_space.h" 48#include "xfs_trans_space.h"
66#include "xfs_acl.h" 49#include "xfs_acl.h"
50#include "xfs_rw.h"
67 51
68/* 52/*
69 * xfs_attr.c 53 * xfs_attr.c
@@ -122,7 +106,7 @@ ktrace_t *xfs_attr_trace_buf;
122 *========================================================================*/ 106 *========================================================================*/
123 107
124int 108int
125xfs_attr_fetch(xfs_inode_t *ip, char *name, int namelen, 109xfs_attr_fetch(xfs_inode_t *ip, const char *name, int namelen,
126 char *value, int *valuelenp, int flags, struct cred *cred) 110 char *value, int *valuelenp, int flags, struct cred *cred)
127{ 111{
128 xfs_da_args_t args; 112 xfs_da_args_t args;
@@ -177,7 +161,7 @@ xfs_attr_fetch(xfs_inode_t *ip, char *name, int namelen,
177} 161}
178 162
179int 163int
180xfs_attr_get(bhv_desc_t *bdp, char *name, char *value, int *valuelenp, 164xfs_attr_get(bhv_desc_t *bdp, const char *name, char *value, int *valuelenp,
181 int flags, struct cred *cred) 165 int flags, struct cred *cred)
182{ 166{
183 xfs_inode_t *ip = XFS_BHVTOI(bdp); 167 xfs_inode_t *ip = XFS_BHVTOI(bdp);
@@ -200,40 +184,18 @@ xfs_attr_get(bhv_desc_t *bdp, char *name, char *value, int *valuelenp,
200 return(error); 184 return(error);
201} 185}
202 186
203/*ARGSUSED*/ 187STATIC int
204int /* error */ 188xfs_attr_set_int(xfs_inode_t *dp, const char *name, int namelen,
205xfs_attr_set(bhv_desc_t *bdp, char *name, char *value, int valuelen, int flags, 189 char *value, int valuelen, int flags)
206 struct cred *cred)
207{ 190{
208 xfs_da_args_t args; 191 xfs_da_args_t args;
209 xfs_inode_t *dp;
210 xfs_fsblock_t firstblock; 192 xfs_fsblock_t firstblock;
211 xfs_bmap_free_t flist; 193 xfs_bmap_free_t flist;
212 int error, err2, committed; 194 int error, err2, committed;
213 int local, size; 195 int local, size;
214 uint nblks; 196 uint nblks;
215 xfs_mount_t *mp; 197 xfs_mount_t *mp = dp->i_mount;
216 int rsvd = (flags & ATTR_ROOT) != 0; 198 int rsvd = (flags & ATTR_ROOT) != 0;
217 int namelen;
218
219 namelen = strlen(name);
220 if (namelen >= MAXNAMELEN)
221 return EFAULT; /* match IRIX behaviour */
222
223 XFS_STATS_INC(xs_attr_set);
224
225 dp = XFS_BHVTOI(bdp);
226 mp = dp->i_mount;
227 if (XFS_FORCED_SHUTDOWN(mp))
228 return (EIO);
229
230 xfs_ilock(dp, XFS_ILOCK_SHARED);
231 if (!(flags & ATTR_SECURE) &&
232 (error = xfs_iaccess(dp, S_IWUSR, cred))) {
233 xfs_iunlock(dp, XFS_ILOCK_SHARED);
234 return(XFS_ERROR(error));
235 }
236 xfs_iunlock(dp, XFS_ILOCK_SHARED);
237 199
238 /* 200 /*
239 * Attach the dquots to the inode. 201 * Attach the dquots to the inode.
@@ -242,12 +204,18 @@ xfs_attr_set(bhv_desc_t *bdp, char *name, char *value, int valuelen, int flags,
242 return (error); 204 return (error);
243 205
244 /* 206 /*
207 * Determine space new attribute will use, and if it would be
208 * "local" or "remote" (note: local != inline).
209 */
210 size = xfs_attr_leaf_newentsize(namelen, valuelen,
211 mp->m_sb.sb_blocksize, &local);
212
213 /*
245 * If the inode doesn't have an attribute fork, add one. 214 * If the inode doesn't have an attribute fork, add one.
246 * (inode must not be locked when we call this routine) 215 * (inode must not be locked when we call this routine)
247 */ 216 */
248 if (XFS_IFORK_Q(dp) == 0) { 217 if (XFS_IFORK_Q(dp) == 0) {
249 error = xfs_bmap_add_attrfork(dp, rsvd); 218 if ((error = xfs_bmap_add_attrfork(dp, size, rsvd)))
250 if (error)
251 return(error); 219 return(error);
252 } 220 }
253 221
@@ -265,13 +233,9 @@ xfs_attr_set(bhv_desc_t *bdp, char *name, char *value, int valuelen, int flags,
265 args.firstblock = &firstblock; 233 args.firstblock = &firstblock;
266 args.flist = &flist; 234 args.flist = &flist;
267 args.whichfork = XFS_ATTR_FORK; 235 args.whichfork = XFS_ATTR_FORK;
236 args.addname = 1;
268 args.oknoent = 1; 237 args.oknoent = 1;
269 238
270 /* Determine space new attribute will use, and if it will be inline
271 * or out of line.
272 */
273 size = xfs_attr_leaf_newentsize(&args, mp->m_sb.sb_blocksize, &local);
274
275 nblks = XFS_DAENTER_SPACE_RES(mp, XFS_ATTR_FORK); 239 nblks = XFS_DAENTER_SPACE_RES(mp, XFS_ATTR_FORK);
276 if (local) { 240 if (local) {
277 if (size > (mp->m_sb.sb_blocksize >> 1)) { 241 if (size > (mp->m_sb.sb_blocksize >> 1)) {
@@ -343,7 +307,7 @@ xfs_attr_set(bhv_desc_t *bdp, char *name, char *value, int valuelen, int flags,
343 * Build initial attribute list (if required). 307 * Build initial attribute list (if required).
344 */ 308 */
345 if (dp->i_d.di_aformat == XFS_DINODE_FMT_EXTENTS) 309 if (dp->i_d.di_aformat == XFS_DINODE_FMT_EXTENTS)
346 (void)xfs_attr_shortform_create(&args); 310 xfs_attr_shortform_create(&args);
347 311
348 /* 312 /*
349 * Try to add the attr to the attribute list in 313 * Try to add the attr to the attribute list in
@@ -456,32 +420,21 @@ out:
456 return(error); 420 return(error);
457} 421}
458 422
459/* 423int
460 * Generic handler routine to remove a name from an attribute list. 424xfs_attr_set(bhv_desc_t *bdp, const char *name, char *value, int valuelen, int flags,
461 * Transitions attribute list from Btree to shortform as necessary. 425 struct cred *cred)
462 */
463/*ARGSUSED*/
464int /* error */
465xfs_attr_remove(bhv_desc_t *bdp, char *name, int flags, struct cred *cred)
466{ 426{
467 xfs_da_args_t args; 427 xfs_inode_t *dp;
468 xfs_inode_t *dp; 428 int namelen, error;
469 xfs_fsblock_t firstblock;
470 xfs_bmap_free_t flist;
471 int error;
472 xfs_mount_t *mp;
473 int namelen;
474 429
475 ASSERT(MAXNAMELEN-1<=0xff); /* length is stored in uint8 */
476 namelen = strlen(name); 430 namelen = strlen(name);
477 if (namelen>=MAXNAMELEN) 431 if (namelen >= MAXNAMELEN)
478 return EFAULT; /* match irix behaviour */ 432 return EFAULT; /* match IRIX behaviour */
479 433
480 XFS_STATS_INC(xs_attr_remove); 434 XFS_STATS_INC(xs_attr_set);
481 435
482 dp = XFS_BHVTOI(bdp); 436 dp = XFS_BHVTOI(bdp);
483 mp = dp->i_mount; 437 if (XFS_FORCED_SHUTDOWN(dp->i_mount))
484 if (XFS_FORCED_SHUTDOWN(mp))
485 return (EIO); 438 return (EIO);
486 439
487 xfs_ilock(dp, XFS_ILOCK_SHARED); 440 xfs_ilock(dp, XFS_ILOCK_SHARED);
@@ -489,14 +442,25 @@ xfs_attr_remove(bhv_desc_t *bdp, char *name, int flags, struct cred *cred)
489 (error = xfs_iaccess(dp, S_IWUSR, cred))) { 442 (error = xfs_iaccess(dp, S_IWUSR, cred))) {
490 xfs_iunlock(dp, XFS_ILOCK_SHARED); 443 xfs_iunlock(dp, XFS_ILOCK_SHARED);
491 return(XFS_ERROR(error)); 444 return(XFS_ERROR(error));
492 } else if (XFS_IFORK_Q(dp) == 0 ||
493 (dp->i_d.di_aformat == XFS_DINODE_FMT_EXTENTS &&
494 dp->i_d.di_anextents == 0)) {
495 xfs_iunlock(dp, XFS_ILOCK_SHARED);
496 return(XFS_ERROR(ENOATTR));
497 } 445 }
498 xfs_iunlock(dp, XFS_ILOCK_SHARED); 446 xfs_iunlock(dp, XFS_ILOCK_SHARED);
499 447
448 return xfs_attr_set_int(dp, name, namelen, value, valuelen, flags);
449}
450
451/*
452 * Generic handler routine to remove a name from an attribute list.
453 * Transitions attribute list from Btree to shortform as necessary.
454 */
455STATIC int
456xfs_attr_remove_int(xfs_inode_t *dp, const char *name, int namelen, int flags)
457{
458 xfs_da_args_t args;
459 xfs_fsblock_t firstblock;
460 xfs_bmap_free_t flist;
461 int error;
462 xfs_mount_t *mp = dp->i_mount;
463
500 /* 464 /*
501 * Fill in the arg structure for this request. 465 * Fill in the arg structure for this request.
502 */ 466 */
@@ -544,7 +508,6 @@ xfs_attr_remove(bhv_desc_t *bdp, char *name, int flags, struct cred *cred)
544 XFS_ATTRRM_LOG_COUNT))) { 508 XFS_ATTRRM_LOG_COUNT))) {
545 xfs_trans_cancel(args.trans, 0); 509 xfs_trans_cancel(args.trans, 0);
546 return(error); 510 return(error);
547
548 } 511 }
549 512
550 xfs_ilock(dp, XFS_ILOCK_EXCL); 513 xfs_ilock(dp, XFS_ILOCK_EXCL);
@@ -612,6 +575,38 @@ out:
612 return(error); 575 return(error);
613} 576}
614 577
578int
579xfs_attr_remove(bhv_desc_t *bdp, const char *name, int flags, struct cred *cred)
580{
581 xfs_inode_t *dp;
582 int namelen, error;
583
584 namelen = strlen(name);
585 if (namelen >= MAXNAMELEN)
586 return EFAULT; /* match IRIX behaviour */
587
588 XFS_STATS_INC(xs_attr_remove);
589
590 dp = XFS_BHVTOI(bdp);
591 if (XFS_FORCED_SHUTDOWN(dp->i_mount))
592 return (EIO);
593
594 xfs_ilock(dp, XFS_ILOCK_SHARED);
595 if (!(flags & ATTR_SECURE) &&
596 (error = xfs_iaccess(dp, S_IWUSR, cred))) {
597 xfs_iunlock(dp, XFS_ILOCK_SHARED);
598 return(XFS_ERROR(error));
599 } else if (XFS_IFORK_Q(dp) == 0 ||
600 (dp->i_d.di_aformat == XFS_DINODE_FMT_EXTENTS &&
601 dp->i_d.di_anextents == 0)) {
602 xfs_iunlock(dp, XFS_ILOCK_SHARED);
603 return(XFS_ERROR(ENOATTR));
604 }
605 xfs_iunlock(dp, XFS_ILOCK_SHARED);
606
607 return xfs_attr_remove_int(dp, name, namelen, flags);
608}
609
615/* 610/*
616 * Generate a list of extended attribute names and optionally 611 * Generate a list of extended attribute names and optionally
617 * also value lengths. Positive return value follows the XFS 612 * also value lengths. Positive return value follows the XFS
@@ -811,7 +806,7 @@ out:
811STATIC int 806STATIC int
812xfs_attr_shortform_addname(xfs_da_args_t *args) 807xfs_attr_shortform_addname(xfs_da_args_t *args)
813{ 808{
814 int newsize, retval; 809 int newsize, forkoff, retval;
815 810
816 retval = xfs_attr_shortform_lookup(args); 811 retval = xfs_attr_shortform_lookup(args);
817 if ((args->flags & ATTR_REPLACE) && (retval == ENOATTR)) { 812 if ((args->flags & ATTR_REPLACE) && (retval == ENOATTR)) {
@@ -823,16 +818,18 @@ xfs_attr_shortform_addname(xfs_da_args_t *args)
823 ASSERT(retval == 0); 818 ASSERT(retval == 0);
824 } 819 }
825 820
821 if (args->namelen >= XFS_ATTR_SF_ENTSIZE_MAX ||
822 args->valuelen >= XFS_ATTR_SF_ENTSIZE_MAX)
823 return(XFS_ERROR(ENOSPC));
824
826 newsize = XFS_ATTR_SF_TOTSIZE(args->dp); 825 newsize = XFS_ATTR_SF_TOTSIZE(args->dp);
827 newsize += XFS_ATTR_SF_ENTSIZE_BYNAME(args->namelen, args->valuelen); 826 newsize += XFS_ATTR_SF_ENTSIZE_BYNAME(args->namelen, args->valuelen);
828 if ((newsize <= XFS_IFORK_ASIZE(args->dp)) && 827
829 (args->namelen < XFS_ATTR_SF_ENTSIZE_MAX) && 828 forkoff = xfs_attr_shortform_bytesfit(args->dp, newsize);
830 (args->valuelen < XFS_ATTR_SF_ENTSIZE_MAX)) { 829 if (!forkoff)
831 retval = xfs_attr_shortform_add(args);
832 ASSERT(retval == 0);
833 } else {
834 return(XFS_ERROR(ENOSPC)); 830 return(XFS_ERROR(ENOSPC));
835 } 831
832 xfs_attr_shortform_add(args, forkoff);
836 return(0); 833 return(0);
837} 834}
838 835
@@ -852,7 +849,7 @@ xfs_attr_leaf_addname(xfs_da_args_t *args)
852{ 849{
853 xfs_inode_t *dp; 850 xfs_inode_t *dp;
854 xfs_dabuf_t *bp; 851 xfs_dabuf_t *bp;
855 int retval, error, committed; 852 int retval, error, committed, forkoff;
856 853
857 /* 854 /*
858 * Read the (only) block in the attribute list in. 855 * Read the (only) block in the attribute list in.
@@ -995,9 +992,9 @@ xfs_attr_leaf_addname(xfs_da_args_t *args)
995 /* 992 /*
996 * If the result is small enough, shrink it all into the inode. 993 * If the result is small enough, shrink it all into the inode.
997 */ 994 */
998 if (xfs_attr_shortform_allfit(bp, dp)) { 995 if ((forkoff = xfs_attr_shortform_allfit(bp, dp))) {
999 XFS_BMAP_INIT(args->flist, args->firstblock); 996 XFS_BMAP_INIT(args->flist, args->firstblock);
1000 error = xfs_attr_leaf_to_shortform(bp, args); 997 error = xfs_attr_leaf_to_shortform(bp, args, forkoff);
1001 /* bp is gone due to xfs_da_shrink_inode */ 998 /* bp is gone due to xfs_da_shrink_inode */
1002 if (!error) { 999 if (!error) {
1003 error = xfs_bmap_finish(&args->trans, 1000 error = xfs_bmap_finish(&args->trans,
@@ -1049,8 +1046,7 @@ xfs_attr_leaf_removename(xfs_da_args_t *args)
1049{ 1046{
1050 xfs_inode_t *dp; 1047 xfs_inode_t *dp;
1051 xfs_dabuf_t *bp; 1048 xfs_dabuf_t *bp;
1052 int committed; 1049 int error, committed, forkoff;
1053 int error;
1054 1050
1055 /* 1051 /*
1056 * Remove the attribute. 1052 * Remove the attribute.
@@ -1075,9 +1071,9 @@ xfs_attr_leaf_removename(xfs_da_args_t *args)
1075 /* 1071 /*
1076 * If the result is small enough, shrink it all into the inode. 1072 * If the result is small enough, shrink it all into the inode.
1077 */ 1073 */
1078 if (xfs_attr_shortform_allfit(bp, dp)) { 1074 if ((forkoff = xfs_attr_shortform_allfit(bp, dp))) {
1079 XFS_BMAP_INIT(args->flist, args->firstblock); 1075 XFS_BMAP_INIT(args->flist, args->firstblock);
1080 error = xfs_attr_leaf_to_shortform(bp, args); 1076 error = xfs_attr_leaf_to_shortform(bp, args, forkoff);
1081 /* bp is gone due to xfs_da_shrink_inode */ 1077 /* bp is gone due to xfs_da_shrink_inode */
1082 if (!error) { 1078 if (!error) {
1083 error = xfs_bmap_finish(&args->trans, args->flist, 1079 error = xfs_bmap_finish(&args->trans, args->flist,
@@ -1448,7 +1444,7 @@ xfs_attr_node_removename(xfs_da_args_t *args)
1448 xfs_da_state_blk_t *blk; 1444 xfs_da_state_blk_t *blk;
1449 xfs_inode_t *dp; 1445 xfs_inode_t *dp;
1450 xfs_dabuf_t *bp; 1446 xfs_dabuf_t *bp;
1451 int retval, error, committed; 1447 int retval, error, committed, forkoff;
1452 1448
1453 /* 1449 /*
1454 * Tie a string around our finger to remind us where we are. 1450 * Tie a string around our finger to remind us where we are.
@@ -1569,9 +1565,9 @@ xfs_attr_node_removename(xfs_da_args_t *args)
1569 bp->data)->hdr.info.magic, ARCH_CONVERT) 1565 bp->data)->hdr.info.magic, ARCH_CONVERT)
1570 == XFS_ATTR_LEAF_MAGIC); 1566 == XFS_ATTR_LEAF_MAGIC);
1571 1567
1572 if (xfs_attr_shortform_allfit(bp, dp)) { 1568 if ((forkoff = xfs_attr_shortform_allfit(bp, dp))) {
1573 XFS_BMAP_INIT(args->flist, args->firstblock); 1569 XFS_BMAP_INIT(args->flist, args->firstblock);
1574 error = xfs_attr_leaf_to_shortform(bp, args); 1570 error = xfs_attr_leaf_to_shortform(bp, args, forkoff);
1575 /* bp is gone due to xfs_da_shrink_inode */ 1571 /* bp is gone due to xfs_da_shrink_inode */
1576 if (!error) { 1572 if (!error) {
1577 error = xfs_bmap_finish(&args->trans, 1573 error = xfs_bmap_finish(&args->trans,
diff --git a/fs/xfs/xfs_attr.h b/fs/xfs/xfs_attr.h
index 45ab1c542baf..b2c7b9fcded3 100644
--- a/fs/xfs/xfs_attr.h
+++ b/fs/xfs/xfs_attr.h
@@ -1,33 +1,19 @@
1/* 1/*
2 * Copyright (c) 2000, 2002-2003 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000,2002-2003,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32#ifndef __XFS_ATTR_H__ 18#ifndef __XFS_ATTR_H__
33#define __XFS_ATTR_H__ 19#define __XFS_ATTR_H__
@@ -172,15 +158,15 @@ struct xfs_da_args;
172/* 158/*
173 * Overall external interface routines. 159 * Overall external interface routines.
174 */ 160 */
175int xfs_attr_get(bhv_desc_t *, char *, char *, int *, int, struct cred *); 161int xfs_attr_get(bhv_desc_t *, const char *, char *, int *, int, struct cred *);
176int xfs_attr_set(bhv_desc_t *, char *, char *, int, int, struct cred *); 162int xfs_attr_set(bhv_desc_t *, const char *, char *, int, int, struct cred *);
177int xfs_attr_remove(bhv_desc_t *, char *, int, struct cred *); 163int xfs_attr_remove(bhv_desc_t *, const char *, int, struct cred *);
178int xfs_attr_list(bhv_desc_t *, char *, int, int, 164int xfs_attr_list(bhv_desc_t *, char *, int, int,
179 struct attrlist_cursor_kern *, struct cred *); 165 struct attrlist_cursor_kern *, struct cred *);
180int xfs_attr_inactive(struct xfs_inode *dp); 166int xfs_attr_inactive(struct xfs_inode *dp);
181 167
182int xfs_attr_shortform_getvalue(struct xfs_da_args *); 168int xfs_attr_shortform_getvalue(struct xfs_da_args *);
183int xfs_attr_fetch(struct xfs_inode *, char *, int, 169int xfs_attr_fetch(struct xfs_inode *, const char *, int,
184 char *, int *, int, struct cred *); 170 char *, int *, int, struct cred *);
185 171
186#endif /* __XFS_ATTR_H__ */ 172#endif /* __XFS_ATTR_H__ */
diff --git a/fs/xfs/xfs_attr_leaf.c b/fs/xfs/xfs_attr_leaf.c
index 1cdd574c63a9..35e557b00db2 100644
--- a/fs/xfs/xfs_attr_leaf.c
+++ b/fs/xfs/xfs_attr_leaf.c
@@ -1,46 +1,26 @@
1/* 1/*
2 * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32/*
33 * xfs_attr_leaf.c
34 *
35 * GROT: figure out how to recover gracefully when bmap returns ENOSPC.
36 */
37
38#include "xfs.h" 18#include "xfs.h"
39 19#include "xfs_fs.h"
40#include "xfs_macros.h"
41#include "xfs_types.h" 20#include "xfs_types.h"
42#include "xfs_inum.h" 21#include "xfs_bit.h"
43#include "xfs_log.h" 22#include "xfs_log.h"
23#include "xfs_inum.h"
44#include "xfs_trans.h" 24#include "xfs_trans.h"
45#include "xfs_sb.h" 25#include "xfs_sb.h"
46#include "xfs_ag.h" 26#include "xfs_ag.h"
@@ -48,23 +28,22 @@
48#include "xfs_dir2.h" 28#include "xfs_dir2.h"
49#include "xfs_dmapi.h" 29#include "xfs_dmapi.h"
50#include "xfs_mount.h" 30#include "xfs_mount.h"
51#include "xfs_alloc_btree.h" 31#include "xfs_da_btree.h"
52#include "xfs_bmap_btree.h" 32#include "xfs_bmap_btree.h"
33#include "xfs_alloc_btree.h"
53#include "xfs_ialloc_btree.h" 34#include "xfs_ialloc_btree.h"
54#include "xfs_alloc.h" 35#include "xfs_alloc.h"
55#include "xfs_btree.h" 36#include "xfs_btree.h"
56#include "xfs_attr_sf.h"
57#include "xfs_dir_sf.h" 37#include "xfs_dir_sf.h"
58#include "xfs_dir2_sf.h" 38#include "xfs_dir2_sf.h"
39#include "xfs_attr_sf.h"
59#include "xfs_dinode.h" 40#include "xfs_dinode.h"
60#include "xfs_inode_item.h"
61#include "xfs_inode.h" 41#include "xfs_inode.h"
42#include "xfs_inode_item.h"
62#include "xfs_bmap.h" 43#include "xfs_bmap.h"
63#include "xfs_da_btree.h"
64#include "xfs_attr.h" 44#include "xfs_attr.h"
65#include "xfs_attr_leaf.h" 45#include "xfs_attr_leaf.h"
66#include "xfs_error.h" 46#include "xfs_error.h"
67#include "xfs_bit.h"
68 47
69/* 48/*
70 * xfs_attr_leaf.c 49 * xfs_attr_leaf.c
@@ -118,13 +97,82 @@ STATIC int xfs_attr_put_listent(xfs_attr_list_context_t *context,
118 97
119 98
120/*======================================================================== 99/*========================================================================
121 * External routines when dirsize < XFS_LITINO(mp). 100 * External routines when attribute fork size < XFS_LITINO(mp).
122 *========================================================================*/ 101 *========================================================================*/
123 102
124/* 103/*
125 * Create the initial contents of a shortform attribute list. 104 * Query whether the requested number of additional bytes of extended
105 * attribute space will be able to fit inline.
106 * Returns zero if not, else the di_forkoff fork offset to be used in the
107 * literal area for attribute data once the new bytes have been added.
108 *
109 * di_forkoff must be 8 byte aligned, hence is stored as a >>3 value;
110 * special case for dev/uuid inodes, they have fixed size data forks.
126 */ 111 */
127int 112int
113xfs_attr_shortform_bytesfit(xfs_inode_t *dp, int bytes)
114{
115 int offset;
116 int minforkoff; /* lower limit on valid forkoff locations */
117 int maxforkoff; /* upper limit on valid forkoff locations */
118 xfs_mount_t *mp = dp->i_mount;
119
120 offset = (XFS_LITINO(mp) - bytes) >> 3; /* rounded down */
121
122 switch (dp->i_d.di_format) {
123 case XFS_DINODE_FMT_DEV:
124 minforkoff = roundup(sizeof(xfs_dev_t), 8) >> 3;
125 return (offset >= minforkoff) ? minforkoff : 0;
126 case XFS_DINODE_FMT_UUID:
127 minforkoff = roundup(sizeof(uuid_t), 8) >> 3;
128 return (offset >= minforkoff) ? minforkoff : 0;
129 }
130
131 if (unlikely(mp->m_flags & XFS_MOUNT_COMPAT_ATTR)) {
132 if (bytes <= XFS_IFORK_ASIZE(dp))
133 return mp->m_attroffset >> 3;
134 return 0;
135 }
136
137 /* data fork btree root can have at least this many key/ptr pairs */
138 minforkoff = MAX(dp->i_df.if_bytes, XFS_BMDR_SPACE_CALC(MINDBTPTRS));
139 minforkoff = roundup(minforkoff, 8) >> 3;
140
141 /* attr fork btree root can have at least this many key/ptr pairs */
142 maxforkoff = XFS_LITINO(mp) - XFS_BMDR_SPACE_CALC(MINABTPTRS);
143 maxforkoff = maxforkoff >> 3; /* rounded down */
144
145 if (offset >= minforkoff && offset < maxforkoff)
146 return offset;
147 if (offset >= maxforkoff)
148 return maxforkoff;
149 return 0;
150}
151
152/*
153 * Switch on the ATTR2 superblock bit (implies also FEATURES2)
154 */
155STATIC void
156xfs_sbversion_add_attr2(xfs_mount_t *mp, xfs_trans_t *tp)
157{
158 unsigned long s;
159
160 if (!(mp->m_flags & XFS_MOUNT_COMPAT_ATTR) &&
161 !(XFS_SB_VERSION_HASATTR2(&mp->m_sb))) {
162 s = XFS_SB_LOCK(mp);
163 if (!XFS_SB_VERSION_HASATTR2(&mp->m_sb)) {
164 XFS_SB_VERSION_ADDATTR2(&mp->m_sb);
165 XFS_SB_UNLOCK(mp, s);
166 xfs_mod_sb(tp, XFS_SB_VERSIONNUM | XFS_SB_FEATURES2);
167 } else
168 XFS_SB_UNLOCK(mp, s);
169 }
170}
171
172/*
173 * Create the initial contents of a shortform attribute list.
174 */
175void
128xfs_attr_shortform_create(xfs_da_args_t *args) 176xfs_attr_shortform_create(xfs_da_args_t *args)
129{ 177{
130 xfs_attr_sf_hdr_t *hdr; 178 xfs_attr_sf_hdr_t *hdr;
@@ -148,29 +196,37 @@ xfs_attr_shortform_create(xfs_da_args_t *args)
148 hdr->count = 0; 196 hdr->count = 0;
149 INT_SET(hdr->totsize, ARCH_CONVERT, sizeof(*hdr)); 197 INT_SET(hdr->totsize, ARCH_CONVERT, sizeof(*hdr));
150 xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_ADATA); 198 xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_ADATA);
151 return(0);
152} 199}
153 200
154/* 201/*
155 * Add a name/value pair to the shortform attribute list. 202 * Add a name/value pair to the shortform attribute list.
156 * Overflow from the inode has already been checked for. 203 * Overflow from the inode has already been checked for.
157 */ 204 */
158int 205void
159xfs_attr_shortform_add(xfs_da_args_t *args) 206xfs_attr_shortform_add(xfs_da_args_t *args, int forkoff)
160{ 207{
161 xfs_attr_shortform_t *sf; 208 xfs_attr_shortform_t *sf;
162 xfs_attr_sf_entry_t *sfe; 209 xfs_attr_sf_entry_t *sfe;
163 int i, offset, size; 210 int i, offset, size;
211 xfs_mount_t *mp;
164 xfs_inode_t *dp; 212 xfs_inode_t *dp;
165 xfs_ifork_t *ifp; 213 xfs_ifork_t *ifp;
166 214
167 dp = args->dp; 215 dp = args->dp;
216 mp = dp->i_mount;
217 dp->i_d.di_forkoff = forkoff;
218 dp->i_df.if_ext_max =
219 XFS_IFORK_DSIZE(dp) / (uint)sizeof(xfs_bmbt_rec_t);
220 dp->i_afp->if_ext_max =
221 XFS_IFORK_ASIZE(dp) / (uint)sizeof(xfs_bmbt_rec_t);
222
168 ifp = dp->i_afp; 223 ifp = dp->i_afp;
169 ASSERT(ifp->if_flags & XFS_IFINLINE); 224 ASSERT(ifp->if_flags & XFS_IFINLINE);
170 sf = (xfs_attr_shortform_t *)ifp->if_u1.if_data; 225 sf = (xfs_attr_shortform_t *)ifp->if_u1.if_data;
171 sfe = &sf->list[0]; 226 sfe = &sf->list[0];
172 for (i = 0; i < INT_GET(sf->hdr.count, ARCH_CONVERT); 227 for (i = 0; i < INT_GET(sf->hdr.count, ARCH_CONVERT);
173 sfe = XFS_ATTR_SF_NEXTENTRY(sfe), i++) { 228 sfe = XFS_ATTR_SF_NEXTENTRY(sfe), i++) {
229#ifdef DEBUG
174 if (sfe->namelen != args->namelen) 230 if (sfe->namelen != args->namelen)
175 continue; 231 continue;
176 if (memcmp(args->name, sfe->nameval, args->namelen) != 0) 232 if (memcmp(args->name, sfe->nameval, args->namelen) != 0)
@@ -181,7 +237,8 @@ xfs_attr_shortform_add(xfs_da_args_t *args)
181 if (((args->flags & ATTR_ROOT) != 0) != 237 if (((args->flags & ATTR_ROOT) != 0) !=
182 ((sfe->flags & XFS_ATTR_ROOT) != 0)) 238 ((sfe->flags & XFS_ATTR_ROOT) != 0))
183 continue; 239 continue;
184 return(XFS_ERROR(EEXIST)); 240 ASSERT(0);
241#endif
185 } 242 }
186 243
187 offset = (char *)sfe - (char *)sf; 244 offset = (char *)sfe - (char *)sf;
@@ -200,11 +257,11 @@ xfs_attr_shortform_add(xfs_da_args_t *args)
200 INT_MOD(sf->hdr.totsize, ARCH_CONVERT, size); 257 INT_MOD(sf->hdr.totsize, ARCH_CONVERT, size);
201 xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_ADATA); 258 xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_ADATA);
202 259
203 return(0); 260 xfs_sbversion_add_attr2(mp, args->trans);
204} 261}
205 262
206/* 263/*
207 * Remove a name from the shortform attribute list structure. 264 * Remove an attribute from the shortform attribute list structure.
208 */ 265 */
209int 266int
210xfs_attr_shortform_remove(xfs_da_args_t *args) 267xfs_attr_shortform_remove(xfs_da_args_t *args)
@@ -212,17 +269,16 @@ xfs_attr_shortform_remove(xfs_da_args_t *args)
212 xfs_attr_shortform_t *sf; 269 xfs_attr_shortform_t *sf;
213 xfs_attr_sf_entry_t *sfe; 270 xfs_attr_sf_entry_t *sfe;
214 int base, size=0, end, totsize, i; 271 int base, size=0, end, totsize, i;
272 xfs_mount_t *mp;
215 xfs_inode_t *dp; 273 xfs_inode_t *dp;
216 274
217 /*
218 * Remove the attribute.
219 */
220 dp = args->dp; 275 dp = args->dp;
276 mp = dp->i_mount;
221 base = sizeof(xfs_attr_sf_hdr_t); 277 base = sizeof(xfs_attr_sf_hdr_t);
222 sf = (xfs_attr_shortform_t *)dp->i_afp->if_u1.if_data; 278 sf = (xfs_attr_shortform_t *)dp->i_afp->if_u1.if_data;
223 sfe = &sf->list[0]; 279 sfe = &sf->list[0];
224 for (i = 0; i < INT_GET(sf->hdr.count, ARCH_CONVERT); 280 end = INT_GET(sf->hdr.count, ARCH_CONVERT);
225 sfe = XFS_ATTR_SF_NEXTENTRY(sfe), 281 for (i = 0; i < end; sfe = XFS_ATTR_SF_NEXTENTRY(sfe),
226 base += size, i++) { 282 base += size, i++) {
227 size = XFS_ATTR_SF_ENTSIZE(sfe); 283 size = XFS_ATTR_SF_ENTSIZE(sfe);
228 if (sfe->namelen != args->namelen) 284 if (sfe->namelen != args->namelen)
@@ -237,19 +293,51 @@ xfs_attr_shortform_remove(xfs_da_args_t *args)
237 continue; 293 continue;
238 break; 294 break;
239 } 295 }
240 if (i == INT_GET(sf->hdr.count, ARCH_CONVERT)) 296 if (i == end)
241 return(XFS_ERROR(ENOATTR)); 297 return(XFS_ERROR(ENOATTR));
242 298
299 /*
300 * Fix up the attribute fork data, covering the hole
301 */
243 end = base + size; 302 end = base + size;
244 totsize = INT_GET(sf->hdr.totsize, ARCH_CONVERT); 303 totsize = INT_GET(sf->hdr.totsize, ARCH_CONVERT);
245 if (end != totsize) { 304 if (end != totsize)
246 memmove(&((char *)sf)[base], &((char *)sf)[end], 305 memmove(&((char *)sf)[base], &((char *)sf)[end], totsize - end);
247 totsize - end);
248 }
249 INT_MOD(sf->hdr.count, ARCH_CONVERT, -1); 306 INT_MOD(sf->hdr.count, ARCH_CONVERT, -1);
250 INT_MOD(sf->hdr.totsize, ARCH_CONVERT, -size); 307 INT_MOD(sf->hdr.totsize, ARCH_CONVERT, -size);
251 xfs_idata_realloc(dp, -size, XFS_ATTR_FORK); 308
252 xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_ADATA); 309 /*
310 * Fix up the start offset of the attribute fork
311 */
312 totsize -= size;
313 if (totsize == sizeof(xfs_attr_sf_hdr_t) && !args->addname) {
314 /*
315 * Last attribute now removed, revert to original
316 * inode format making all literal area available
317 * to the data fork once more.
318 */
319 xfs_idestroy_fork(dp, XFS_ATTR_FORK);
320 dp->i_d.di_forkoff = 0;
321 dp->i_d.di_aformat = XFS_DINODE_FMT_EXTENTS;
322 ASSERT(dp->i_d.di_anextents == 0);
323 ASSERT(dp->i_afp == NULL);
324 dp->i_df.if_ext_max =
325 XFS_IFORK_DSIZE(dp) / (uint)sizeof(xfs_bmbt_rec_t);
326 xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE);
327 } else {
328 xfs_idata_realloc(dp, -size, XFS_ATTR_FORK);
329 dp->i_d.di_forkoff = xfs_attr_shortform_bytesfit(dp, totsize);
330 ASSERT(dp->i_d.di_forkoff);
331 ASSERT(totsize > sizeof(xfs_attr_sf_hdr_t) || args->addname);
332 dp->i_afp->if_ext_max =
333 XFS_IFORK_ASIZE(dp) / (uint)sizeof(xfs_bmbt_rec_t);
334 dp->i_df.if_ext_max =
335 XFS_IFORK_DSIZE(dp) / (uint)sizeof(xfs_bmbt_rec_t);
336 xfs_trans_log_inode(args->trans, dp,
337 XFS_ILOG_CORE | XFS_ILOG_ADATA);
338 }
339
340 xfs_sbversion_add_attr2(mp, args->trans);
253 341
254 return(0); 342 return(0);
255} 343}
@@ -561,7 +649,7 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context)
561 /* 649 /*
562 * Sort the entries on hash then entno. 650 * Sort the entries on hash then entno.
563 */ 651 */
564 qsort(sbuf, nsbuf, sizeof(*sbuf), xfs_attr_shortform_compare); 652 xfs_sort(sbuf, nsbuf, sizeof(*sbuf), xfs_attr_shortform_compare);
565 653
566 /* 654 /*
567 * Re-find our place IN THE SORTED LIST. 655 * Re-find our place IN THE SORTED LIST.
@@ -649,14 +737,16 @@ xfs_attr_shortform_allfit(xfs_dabuf_t *bp, xfs_inode_t *dp)
649 + name_loc->namelen 737 + name_loc->namelen
650 + INT_GET(name_loc->valuelen, ARCH_CONVERT); 738 + INT_GET(name_loc->valuelen, ARCH_CONVERT);
651 } 739 }
652 return( bytes < XFS_IFORK_ASIZE(dp) ); 740 if (bytes == sizeof(struct xfs_attr_sf_hdr))
741 return(-1);
742 return(xfs_attr_shortform_bytesfit(dp, bytes));
653} 743}
654 744
655/* 745/*
656 * Convert a leaf attribute list to shortform attribute list 746 * Convert a leaf attribute list to shortform attribute list
657 */ 747 */
658int 748int
659xfs_attr_leaf_to_shortform(xfs_dabuf_t *bp, xfs_da_args_t *args) 749xfs_attr_leaf_to_shortform(xfs_dabuf_t *bp, xfs_da_args_t *args, int forkoff)
660{ 750{
661 xfs_attr_leafblock_t *leaf; 751 xfs_attr_leafblock_t *leaf;
662 xfs_attr_leaf_entry_t *entry; 752 xfs_attr_leaf_entry_t *entry;
@@ -683,9 +773,25 @@ xfs_attr_leaf_to_shortform(xfs_dabuf_t *bp, xfs_da_args_t *args)
683 error = xfs_da_shrink_inode(args, 0, bp); 773 error = xfs_da_shrink_inode(args, 0, bp);
684 if (error) 774 if (error)
685 goto out; 775 goto out;
686 error = xfs_attr_shortform_create(args); 776
687 if (error) 777 if (forkoff == -1) {
778 /*
779 * Last attribute was removed, revert to original
780 * inode format making all literal area available
781 * to the data fork once more.
782 */
783 xfs_idestroy_fork(dp, XFS_ATTR_FORK);
784 dp->i_d.di_forkoff = 0;
785 dp->i_d.di_aformat = XFS_DINODE_FMT_EXTENTS;
786 ASSERT(dp->i_d.di_anextents == 0);
787 ASSERT(dp->i_afp == NULL);
788 dp->i_df.if_ext_max =
789 XFS_IFORK_DSIZE(dp) / (uint)sizeof(xfs_bmbt_rec_t);
790 xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE);
688 goto out; 791 goto out;
792 }
793
794 xfs_attr_shortform_create(args);
689 795
690 /* 796 /*
691 * Copy the attributes 797 * Copy the attributes
@@ -713,7 +819,7 @@ xfs_attr_leaf_to_shortform(xfs_dabuf_t *bp, xfs_da_args_t *args)
713 nargs.hashval = INT_GET(entry->hashval, ARCH_CONVERT); 819 nargs.hashval = INT_GET(entry->hashval, ARCH_CONVERT);
714 nargs.flags = (entry->flags & XFS_ATTR_SECURE) ? ATTR_SECURE : 820 nargs.flags = (entry->flags & XFS_ATTR_SECURE) ? ATTR_SECURE :
715 ((entry->flags & XFS_ATTR_ROOT) ? ATTR_ROOT : 0); 821 ((entry->flags & XFS_ATTR_ROOT) ? ATTR_ROOT : 0);
716 xfs_attr_shortform_add(&nargs); 822 xfs_attr_shortform_add(&nargs, forkoff);
717 } 823 }
718 error = 0; 824 error = 0;
719 825
@@ -898,7 +1004,7 @@ xfs_attr_leaf_add(xfs_dabuf_t *bp, xfs_da_args_t *args)
898 ASSERT((args->index >= 0) 1004 ASSERT((args->index >= 0)
899 && (args->index <= INT_GET(leaf->hdr.count, ARCH_CONVERT))); 1005 && (args->index <= INT_GET(leaf->hdr.count, ARCH_CONVERT)));
900 hdr = &leaf->hdr; 1006 hdr = &leaf->hdr;
901 entsize = xfs_attr_leaf_newentsize(args, 1007 entsize = xfs_attr_leaf_newentsize(args->namelen, args->valuelen,
902 args->trans->t_mountp->m_sb.sb_blocksize, NULL); 1008 args->trans->t_mountp->m_sb.sb_blocksize, NULL);
903 1009
904 /* 1010 /*
@@ -995,13 +1101,14 @@ xfs_attr_leaf_add_work(xfs_dabuf_t *bp, xfs_da_args_t *args, int mapindex)
995 mp = args->trans->t_mountp; 1101 mp = args->trans->t_mountp;
996 ASSERT(INT_GET(map->base, ARCH_CONVERT) < XFS_LBSIZE(mp)); 1102 ASSERT(INT_GET(map->base, ARCH_CONVERT) < XFS_LBSIZE(mp));
997 ASSERT((INT_GET(map->base, ARCH_CONVERT) & 0x3) == 0); 1103 ASSERT((INT_GET(map->base, ARCH_CONVERT) & 0x3) == 0);
998 ASSERT(INT_GET(map->size, ARCH_CONVERT) 1104 ASSERT(INT_GET(map->size, ARCH_CONVERT) >=
999 >= xfs_attr_leaf_newentsize(args, 1105 xfs_attr_leaf_newentsize(args->namelen, args->valuelen,
1000 mp->m_sb.sb_blocksize, NULL)); 1106 mp->m_sb.sb_blocksize, NULL));
1001 ASSERT(INT_GET(map->size, ARCH_CONVERT) < XFS_LBSIZE(mp)); 1107 ASSERT(INT_GET(map->size, ARCH_CONVERT) < XFS_LBSIZE(mp));
1002 ASSERT((INT_GET(map->size, ARCH_CONVERT) & 0x3) == 0); 1108 ASSERT((INT_GET(map->size, ARCH_CONVERT) & 0x3) == 0);
1003 INT_MOD(map->size, ARCH_CONVERT, 1109 INT_MOD(map->size, ARCH_CONVERT,
1004 -xfs_attr_leaf_newentsize(args, mp->m_sb.sb_blocksize, &tmp)); 1110 -xfs_attr_leaf_newentsize(args->namelen, args->valuelen,
1111 mp->m_sb.sb_blocksize, &tmp));
1005 INT_SET(entry->nameidx, ARCH_CONVERT, 1112 INT_SET(entry->nameidx, ARCH_CONVERT,
1006 INT_GET(map->base, ARCH_CONVERT) 1113 INT_GET(map->base, ARCH_CONVERT)
1007 + INT_GET(map->size, ARCH_CONVERT)); 1114 + INT_GET(map->size, ARCH_CONVERT));
@@ -1357,8 +1464,10 @@ xfs_attr_leaf_figure_balance(xfs_da_state_t *state,
1357 half = (max+1) * sizeof(*entry); 1464 half = (max+1) * sizeof(*entry);
1358 half += INT_GET(hdr1->usedbytes, ARCH_CONVERT) 1465 half += INT_GET(hdr1->usedbytes, ARCH_CONVERT)
1359 + INT_GET(hdr2->usedbytes, ARCH_CONVERT) 1466 + INT_GET(hdr2->usedbytes, ARCH_CONVERT)
1360 + xfs_attr_leaf_newentsize(state->args, 1467 + xfs_attr_leaf_newentsize(
1361 state->blocksize, NULL); 1468 state->args->namelen,
1469 state->args->valuelen,
1470 state->blocksize, NULL);
1362 half /= 2; 1471 half /= 2;
1363 lastdelta = state->blocksize; 1472 lastdelta = state->blocksize;
1364 entry = &leaf1->entries[0]; 1473 entry = &leaf1->entries[0];
@@ -1370,9 +1479,10 @@ xfs_attr_leaf_figure_balance(xfs_da_state_t *state,
1370 */ 1479 */
1371 if (count == blk1->index) { 1480 if (count == blk1->index) {
1372 tmp = totallen + sizeof(*entry) + 1481 tmp = totallen + sizeof(*entry) +
1373 xfs_attr_leaf_newentsize(state->args, 1482 xfs_attr_leaf_newentsize(
1374 state->blocksize, 1483 state->args->namelen,
1375 NULL); 1484 state->args->valuelen,
1485 state->blocksize, NULL);
1376 if (XFS_ATTR_ABS(half - tmp) > lastdelta) 1486 if (XFS_ATTR_ABS(half - tmp) > lastdelta)
1377 break; 1487 break;
1378 lastdelta = XFS_ATTR_ABS(half - tmp); 1488 lastdelta = XFS_ATTR_ABS(half - tmp);
@@ -1408,9 +1518,10 @@ xfs_attr_leaf_figure_balance(xfs_da_state_t *state,
1408 totallen -= count * sizeof(*entry); 1518 totallen -= count * sizeof(*entry);
1409 if (foundit) { 1519 if (foundit) {
1410 totallen -= sizeof(*entry) + 1520 totallen -= sizeof(*entry) +
1411 xfs_attr_leaf_newentsize(state->args, 1521 xfs_attr_leaf_newentsize(
1412 state->blocksize, 1522 state->args->namelen,
1413 NULL); 1523 state->args->valuelen,
1524 state->blocksize, NULL);
1414 } 1525 }
1415 1526
1416 *countarg = count; 1527 *countarg = count;
@@ -2253,17 +2364,17 @@ xfs_attr_leaf_entsize(xfs_attr_leafblock_t *leaf, int index)
2253 * a "local" or a "remote" attribute. 2364 * a "local" or a "remote" attribute.
2254 */ 2365 */
2255int 2366int
2256xfs_attr_leaf_newentsize(xfs_da_args_t *args, int blocksize, int *local) 2367xfs_attr_leaf_newentsize(int namelen, int valuelen, int blocksize, int *local)
2257{ 2368{
2258 int size; 2369 int size;
2259 2370
2260 size = XFS_ATTR_LEAF_ENTSIZE_LOCAL(args->namelen, args->valuelen); 2371 size = XFS_ATTR_LEAF_ENTSIZE_LOCAL(namelen, valuelen);
2261 if (size < XFS_ATTR_LEAF_ENTSIZE_LOCAL_MAX(blocksize)) { 2372 if (size < XFS_ATTR_LEAF_ENTSIZE_LOCAL_MAX(blocksize)) {
2262 if (local) { 2373 if (local) {
2263 *local = 1; 2374 *local = 1;
2264 } 2375 }
2265 } else { 2376 } else {
2266 size = XFS_ATTR_LEAF_ENTSIZE_REMOTE(args->namelen); 2377 size = XFS_ATTR_LEAF_ENTSIZE_REMOTE(namelen);
2267 if (local) { 2378 if (local) {
2268 *local = 0; 2379 *local = 0;
2269 } 2380 }
diff --git a/fs/xfs/xfs_attr_leaf.h b/fs/xfs/xfs_attr_leaf.h
index 0a4cfad6df91..f6143ff251a0 100644
--- a/fs/xfs/xfs_attr_leaf.h
+++ b/fs/xfs/xfs_attr_leaf.h
@@ -1,33 +1,19 @@
1/* 1/*
2 * Copyright (c) 2000, 2002-2003 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000,2002-2003,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32#ifndef __XFS_ATTR_LEAF_H__ 18#ifndef __XFS_ATTR_LEAF_H__
33#define __XFS_ATTR_LEAF_H__ 19#define __XFS_ATTR_LEAF_H__
@@ -146,65 +132,58 @@ typedef struct xfs_attr_leaf_name_remote xfs_attr_leaf_name_remote_t;
146/* 132/*
147 * Cast typed pointers for "local" and "remote" name/value structs. 133 * Cast typed pointers for "local" and "remote" name/value structs.
148 */ 134 */
149#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_ATTR_LEAF_NAME_REMOTE)
150xfs_attr_leaf_name_remote_t *
151xfs_attr_leaf_name_remote(xfs_attr_leafblock_t *leafp, int idx);
152#define XFS_ATTR_LEAF_NAME_REMOTE(leafp,idx) \ 135#define XFS_ATTR_LEAF_NAME_REMOTE(leafp,idx) \
153 xfs_attr_leaf_name_remote(leafp,idx) 136 xfs_attr_leaf_name_remote(leafp,idx)
154#else 137static inline xfs_attr_leaf_name_remote_t *
155#define XFS_ATTR_LEAF_NAME_REMOTE(leafp,idx) /* remote name struct ptr */ \ 138xfs_attr_leaf_name_remote(xfs_attr_leafblock_t *leafp, int idx)
156 ((xfs_attr_leaf_name_remote_t *) \ 139{
157 &((char *)(leafp))[ INT_GET((leafp)->entries[idx].nameidx, ARCH_CONVERT) ]) 140 return (xfs_attr_leaf_name_remote_t *) &((char *)
158#endif 141 (leafp))[INT_GET((leafp)->entries[idx].nameidx, ARCH_CONVERT)];
159#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_ATTR_LEAF_NAME_LOCAL) 142}
160xfs_attr_leaf_name_local_t * 143
161xfs_attr_leaf_name_local(xfs_attr_leafblock_t *leafp, int idx);
162#define XFS_ATTR_LEAF_NAME_LOCAL(leafp,idx) \ 144#define XFS_ATTR_LEAF_NAME_LOCAL(leafp,idx) \
163 xfs_attr_leaf_name_local(leafp,idx) 145 xfs_attr_leaf_name_local(leafp,idx)
164#else 146static inline xfs_attr_leaf_name_local_t *
165#define XFS_ATTR_LEAF_NAME_LOCAL(leafp,idx) /* local name struct ptr */ \ 147xfs_attr_leaf_name_local(xfs_attr_leafblock_t *leafp, int idx)
166 ((xfs_attr_leaf_name_local_t *) \ 148{
167 &((char *)(leafp))[ INT_GET((leafp)->entries[idx].nameidx, ARCH_CONVERT) ]) 149 return (xfs_attr_leaf_name_local_t *) &((char *)
168#endif 150 (leafp))[INT_GET((leafp)->entries[idx].nameidx, ARCH_CONVERT)];
169#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_ATTR_LEAF_NAME) 151}
170char *xfs_attr_leaf_name(xfs_attr_leafblock_t *leafp, int idx); 152
171#define XFS_ATTR_LEAF_NAME(leafp,idx) xfs_attr_leaf_name(leafp,idx) 153#define XFS_ATTR_LEAF_NAME(leafp,idx) xfs_attr_leaf_name(leafp,idx)
172#else 154static inline char *xfs_attr_leaf_name(xfs_attr_leafblock_t *leafp, int idx)
173#define XFS_ATTR_LEAF_NAME(leafp,idx) /* generic name struct ptr */ \ 155{
174 (&((char *)(leafp))[ INT_GET((leafp)->entries[idx].nameidx, ARCH_CONVERT) ]) 156 return (&((char *)
175#endif 157 (leafp))[INT_GET((leafp)->entries[idx].nameidx, ARCH_CONVERT)]);
158}
176 159
177/* 160/*
178 * Calculate total bytes used (including trailing pad for alignment) for 161 * Calculate total bytes used (including trailing pad for alignment) for
179 * a "local" name/value structure, a "remote" name/value structure, and 162 * a "local" name/value structure, a "remote" name/value structure, and
180 * a pointer which might be either. 163 * a pointer which might be either.
181 */ 164 */
182#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_ATTR_LEAF_ENTSIZE_REMOTE)
183int xfs_attr_leaf_entsize_remote(int nlen);
184#define XFS_ATTR_LEAF_ENTSIZE_REMOTE(nlen) \ 165#define XFS_ATTR_LEAF_ENTSIZE_REMOTE(nlen) \
185 xfs_attr_leaf_entsize_remote(nlen) 166 xfs_attr_leaf_entsize_remote(nlen)
186#else 167static inline int xfs_attr_leaf_entsize_remote(int nlen)
187#define XFS_ATTR_LEAF_ENTSIZE_REMOTE(nlen) /* space for remote struct */ \ 168{
188 (((uint)sizeof(xfs_attr_leaf_name_remote_t) - 1 + (nlen) + \ 169 return ((uint)sizeof(xfs_attr_leaf_name_remote_t) - 1 + (nlen) + \
189 XFS_ATTR_LEAF_NAME_ALIGN - 1) & ~(XFS_ATTR_LEAF_NAME_ALIGN - 1)) 170 XFS_ATTR_LEAF_NAME_ALIGN - 1) & ~(XFS_ATTR_LEAF_NAME_ALIGN - 1);
190#endif 171}
191#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_ATTR_LEAF_ENTSIZE_LOCAL) 172
192int xfs_attr_leaf_entsize_local(int nlen, int vlen);
193#define XFS_ATTR_LEAF_ENTSIZE_LOCAL(nlen,vlen) \ 173#define XFS_ATTR_LEAF_ENTSIZE_LOCAL(nlen,vlen) \
194 xfs_attr_leaf_entsize_local(nlen,vlen) 174 xfs_attr_leaf_entsize_local(nlen,vlen)
195#else 175static inline int xfs_attr_leaf_entsize_local(int nlen, int vlen)
196#define XFS_ATTR_LEAF_ENTSIZE_LOCAL(nlen,vlen) /* space for local struct */ \ 176{
197 (((uint)sizeof(xfs_attr_leaf_name_local_t) - 1 + (nlen) + (vlen) + \ 177 return ((uint)sizeof(xfs_attr_leaf_name_local_t) - 1 + (nlen) + (vlen) +
198 XFS_ATTR_LEAF_NAME_ALIGN - 1) & ~(XFS_ATTR_LEAF_NAME_ALIGN - 1)) 178 XFS_ATTR_LEAF_NAME_ALIGN - 1) & ~(XFS_ATTR_LEAF_NAME_ALIGN - 1);
199#endif 179}
200#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_ATTR_LEAF_ENTSIZE_LOCAL_MAX) 180
201int xfs_attr_leaf_entsize_local_max(int bsize);
202#define XFS_ATTR_LEAF_ENTSIZE_LOCAL_MAX(bsize) \ 181#define XFS_ATTR_LEAF_ENTSIZE_LOCAL_MAX(bsize) \
203 xfs_attr_leaf_entsize_local_max(bsize) 182 xfs_attr_leaf_entsize_local_max(bsize)
204#else 183static inline int xfs_attr_leaf_entsize_local_max(int bsize)
205#define XFS_ATTR_LEAF_ENTSIZE_LOCAL_MAX(bsize) /* max local struct size */ \ 184{
206 (((bsize) >> 1) + ((bsize) >> 2)) 185 return (((bsize) >> 1) + ((bsize) >> 2));
207#endif 186}
208 187
209 188
210/*======================================================================== 189/*========================================================================
@@ -237,23 +216,25 @@ typedef struct xfs_attr_inactive_list {
237 *========================================================================*/ 216 *========================================================================*/
238 217
239/* 218/*
240 * Internal routines when dirsize < XFS_LITINO(mp). 219 * Internal routines when attribute fork size < XFS_LITINO(mp).
241 */ 220 */
242int xfs_attr_shortform_create(struct xfs_da_args *args); 221void xfs_attr_shortform_create(struct xfs_da_args *args);
243int xfs_attr_shortform_add(struct xfs_da_args *add); 222void xfs_attr_shortform_add(struct xfs_da_args *args, int forkoff);
244int xfs_attr_shortform_lookup(struct xfs_da_args *args); 223int xfs_attr_shortform_lookup(struct xfs_da_args *args);
245int xfs_attr_shortform_getvalue(struct xfs_da_args *args); 224int xfs_attr_shortform_getvalue(struct xfs_da_args *args);
246int xfs_attr_shortform_to_leaf(struct xfs_da_args *args); 225int xfs_attr_shortform_to_leaf(struct xfs_da_args *args);
247int xfs_attr_shortform_remove(struct xfs_da_args *remove); 226int xfs_attr_shortform_remove(struct xfs_da_args *args);
248int xfs_attr_shortform_list(struct xfs_attr_list_context *context); 227int xfs_attr_shortform_list(struct xfs_attr_list_context *context);
249int xfs_attr_shortform_allfit(struct xfs_dabuf *bp, struct xfs_inode *dp); 228int xfs_attr_shortform_allfit(struct xfs_dabuf *bp, struct xfs_inode *dp);
229int xfs_attr_shortform_bytesfit(xfs_inode_t *dp, int bytes);
230
250 231
251/* 232/*
252 * Internal routines when dirsize == XFS_LBSIZE(mp). 233 * Internal routines when attribute fork size == XFS_LBSIZE(mp).
253 */ 234 */
254int xfs_attr_leaf_to_node(struct xfs_da_args *args); 235int xfs_attr_leaf_to_node(struct xfs_da_args *args);
255int xfs_attr_leaf_to_shortform(struct xfs_dabuf *bp, 236int xfs_attr_leaf_to_shortform(struct xfs_dabuf *bp,
256 struct xfs_da_args *args); 237 struct xfs_da_args *args, int forkoff);
257int xfs_attr_leaf_clearflag(struct xfs_da_args *args); 238int xfs_attr_leaf_clearflag(struct xfs_da_args *args);
258int xfs_attr_leaf_setflag(struct xfs_da_args *args); 239int xfs_attr_leaf_setflag(struct xfs_da_args *args);
259int xfs_attr_leaf_flipflags(xfs_da_args_t *args); 240int xfs_attr_leaf_flipflags(xfs_da_args_t *args);
@@ -289,7 +270,7 @@ int xfs_attr_root_inactive(struct xfs_trans **trans, struct xfs_inode *dp);
289xfs_dahash_t xfs_attr_leaf_lasthash(struct xfs_dabuf *bp, int *count); 270xfs_dahash_t xfs_attr_leaf_lasthash(struct xfs_dabuf *bp, int *count);
290int xfs_attr_leaf_order(struct xfs_dabuf *leaf1_bp, 271int xfs_attr_leaf_order(struct xfs_dabuf *leaf1_bp,
291 struct xfs_dabuf *leaf2_bp); 272 struct xfs_dabuf *leaf2_bp);
292int xfs_attr_leaf_newentsize(struct xfs_da_args *args, int blocksize, 273int xfs_attr_leaf_newentsize(int namelen, int valuelen, int blocksize,
293 int *local); 274 int *local);
294int xfs_attr_rolltrans(struct xfs_trans **transp, struct xfs_inode *dp); 275int xfs_attr_rolltrans(struct xfs_trans **transp, struct xfs_inode *dp);
295 276
diff --git a/fs/xfs/xfs_attr_sf.h b/fs/xfs/xfs_attr_sf.h
index ef7d2942d306..ffed6ca81a52 100644
--- a/fs/xfs/xfs_attr_sf.h
+++ b/fs/xfs/xfs_attr_sf.h
@@ -1,33 +1,19 @@
1/* 1/*
2 * Copyright (c) 2000, 2002 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000,2002,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32#ifndef __XFS_ATTR_SF_H__ 18#ifndef __XFS_ATTR_SF_H__
33#define __XFS_ATTR_SF_H__ 19#define __XFS_ATTR_SF_H__
@@ -71,38 +57,17 @@ typedef struct xfs_attr_sf_sort {
71 char *name; /* name value, pointer into buffer */ 57 char *name; /* name value, pointer into buffer */
72} xfs_attr_sf_sort_t; 58} xfs_attr_sf_sort_t;
73 59
74#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_ATTR_SF_ENTSIZE_BYNAME)
75int xfs_attr_sf_entsize_byname(int nlen, int vlen);
76#define XFS_ATTR_SF_ENTSIZE_BYNAME(nlen,vlen) \
77 xfs_attr_sf_entsize_byname(nlen,vlen)
78#else
79#define XFS_ATTR_SF_ENTSIZE_BYNAME(nlen,vlen) /* space name/value uses */ \ 60#define XFS_ATTR_SF_ENTSIZE_BYNAME(nlen,vlen) /* space name/value uses */ \
80 ((int)sizeof(xfs_attr_sf_entry_t)-1 + (nlen)+(vlen)) 61 (((int)sizeof(xfs_attr_sf_entry_t)-1 + (nlen)+(vlen)))
81#endif
82#define XFS_ATTR_SF_ENTSIZE_MAX /* max space for name&value */ \ 62#define XFS_ATTR_SF_ENTSIZE_MAX /* max space for name&value */ \
83 ((1 << (NBBY*(int)sizeof(__uint8_t))) - 1) 63 ((1 << (NBBY*(int)sizeof(__uint8_t))) - 1)
84#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_ATTR_SF_ENTSIZE)
85int xfs_attr_sf_entsize(xfs_attr_sf_entry_t *sfep);
86#define XFS_ATTR_SF_ENTSIZE(sfep) xfs_attr_sf_entsize(sfep)
87#else
88#define XFS_ATTR_SF_ENTSIZE(sfep) /* space an entry uses */ \ 64#define XFS_ATTR_SF_ENTSIZE(sfep) /* space an entry uses */ \
89 ((int)sizeof(xfs_attr_sf_entry_t)-1 + (sfep)->namelen+(sfep)->valuelen) 65 ((int)sizeof(xfs_attr_sf_entry_t)-1 + (sfep)->namelen+(sfep)->valuelen)
90#endif
91#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_ATTR_SF_NEXTENTRY)
92xfs_attr_sf_entry_t *xfs_attr_sf_nextentry(xfs_attr_sf_entry_t *sfep);
93#define XFS_ATTR_SF_NEXTENTRY(sfep) xfs_attr_sf_nextentry(sfep)
94#else
95#define XFS_ATTR_SF_NEXTENTRY(sfep) /* next entry in struct */ \ 66#define XFS_ATTR_SF_NEXTENTRY(sfep) /* next entry in struct */ \
96 ((xfs_attr_sf_entry_t *) \ 67 ((xfs_attr_sf_entry_t *)((char *)(sfep) + XFS_ATTR_SF_ENTSIZE(sfep)))
97 ((char *)(sfep) + XFS_ATTR_SF_ENTSIZE(sfep)))
98#endif
99#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_ATTR_SF_TOTSIZE)
100int xfs_attr_sf_totsize(struct xfs_inode *dp);
101#define XFS_ATTR_SF_TOTSIZE(dp) xfs_attr_sf_totsize(dp)
102#else
103#define XFS_ATTR_SF_TOTSIZE(dp) /* total space in use */ \ 68#define XFS_ATTR_SF_TOTSIZE(dp) /* total space in use */ \
104 (INT_GET(((xfs_attr_shortform_t *)((dp)->i_afp->if_u1.if_data))->hdr.totsize, ARCH_CONVERT)) 69 (INT_GET(((xfs_attr_shortform_t *) \
105#endif 70 ((dp)->i_afp->if_u1.if_data))->hdr.totsize, ARCH_CONVERT))
106 71
107#if defined(XFS_ATTR_TRACE) 72#if defined(XFS_ATTR_TRACE)
108/* 73/*
diff --git a/fs/xfs/xfs_behavior.c b/fs/xfs/xfs_behavior.c
index 16088e175ecc..9880adae3938 100644
--- a/fs/xfs/xfs_behavior.c
+++ b/fs/xfs/xfs_behavior.c
@@ -1,34 +1,19 @@
1/* 1/*
2 * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * 12 * GNU General Public License for more details.
12 * Further, this software is distributed without any warranty that it is
13 * free of the rightful claim of any third person regarding infringement
14 * or the like. Any license provided herein, whether implied or
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 * 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
32 */ 17 */
33#include "xfs.h" 18#include "xfs.h"
34 19
diff --git a/fs/xfs/xfs_behavior.h b/fs/xfs/xfs_behavior.h
index d5ed5a843921..2cd89bb5ab10 100644
--- a/fs/xfs/xfs_behavior.h
+++ b/fs/xfs/xfs_behavior.h
@@ -1,33 +1,19 @@
1/* 1/*
2 * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32#ifndef __XFS_BEHAVIOR_H__ 18#ifndef __XFS_BEHAVIOR_H__
33#define __XFS_BEHAVIOR_H__ 19#define __XFS_BEHAVIOR_H__
diff --git a/fs/xfs/xfs_bit.c b/fs/xfs/xfs_bit.c
index 76c9ad3875ef..43be6a7e47c6 100644
--- a/fs/xfs/xfs_bit.c
+++ b/fs/xfs/xfs_bit.c
@@ -1,45 +1,29 @@
1/* 1/*
2 * Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32
33/*
34 * XFS bit manipulation routines, used in non-realtime code.
35 */
36
37#include "xfs.h" 18#include "xfs.h"
38#include "xfs_bit.h" 19#include "xfs_bit.h"
39#include "xfs_log.h" 20#include "xfs_log.h"
40#include "xfs_trans.h" 21#include "xfs_trans.h"
41#include "xfs_buf_item.h" 22#include "xfs_buf_item.h"
42 23
24/*
25 * XFS bit manipulation routines, used in non-realtime code.
26 */
43 27
44#ifndef HAVE_ARCH_HIGHBIT 28#ifndef HAVE_ARCH_HIGHBIT
45/* 29/*
diff --git a/fs/xfs/xfs_bit.h b/fs/xfs/xfs_bit.h
index 1e7f57ddf7a8..0bbe56817542 100644
--- a/fs/xfs/xfs_bit.h
+++ b/fs/xfs/xfs_bit.h
@@ -1,33 +1,19 @@
1/* 1/*
2 * Copyright (c) 2000, 2002 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000,2002,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32#ifndef __XFS_BIT_H__ 18#ifndef __XFS_BIT_H__
33#define __XFS_BIT_H__ 19#define __XFS_BIT_H__
@@ -39,30 +25,26 @@
39/* 25/*
40 * masks with n high/low bits set, 32-bit values & 64-bit values 26 * masks with n high/low bits set, 32-bit values & 64-bit values
41 */ 27 */
42#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_MASK32HI)
43__uint32_t xfs_mask32hi(int n);
44#define XFS_MASK32HI(n) xfs_mask32hi(n) 28#define XFS_MASK32HI(n) xfs_mask32hi(n)
45#else 29static inline __uint32_t xfs_mask32hi(int n)
46#define XFS_MASK32HI(n) ((__uint32_t)-1 << (32 - (n))) 30{
47#endif 31 return (__uint32_t)-1 << (32 - (n));
48#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_MASK64HI) 32}
49__uint64_t xfs_mask64hi(int n);
50#define XFS_MASK64HI(n) xfs_mask64hi(n) 33#define XFS_MASK64HI(n) xfs_mask64hi(n)
51#else 34static inline __uint64_t xfs_mask64hi(int n)
52#define XFS_MASK64HI(n) ((__uint64_t)-1 << (64 - (n))) 35{
53#endif 36 return (__uint64_t)-1 << (64 - (n));
54#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_MASK32LO) 37}
55__uint32_t xfs_mask32lo(int n);
56#define XFS_MASK32LO(n) xfs_mask32lo(n) 38#define XFS_MASK32LO(n) xfs_mask32lo(n)
57#else 39static inline __uint32_t xfs_mask32lo(int n)
58#define XFS_MASK32LO(n) (((__uint32_t)1 << (n)) - 1) 40{
59#endif 41 return ((__uint32_t)1 << (n)) - 1;
60#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_MASK64LO) 42}
61__uint64_t xfs_mask64lo(int n);
62#define XFS_MASK64LO(n) xfs_mask64lo(n) 43#define XFS_MASK64LO(n) xfs_mask64lo(n)
63#else 44static inline __uint64_t xfs_mask64lo(int n)
64#define XFS_MASK64LO(n) (((__uint64_t)1 << (n)) - 1) 45{
65#endif 46 return ((__uint64_t)1 << (n)) - 1;
47}
66 48
67/* Get high bit set out of 32-bit argument, -1 if none set */ 49/* Get high bit set out of 32-bit argument, -1 if none set */
68extern int xfs_highbit32(__uint32_t v); 50extern int xfs_highbit32(__uint32_t v);
diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c
index 3e76def1283d..e415a4698e9c 100644
--- a/fs/xfs/xfs_bmap.c
+++ b/fs/xfs/xfs_bmap.c
@@ -1,68 +1,53 @@
1/* 1/*
2 * Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32
33#include "xfs.h" 18#include "xfs.h"
34 19#include "xfs_fs.h"
35#include "xfs_macros.h"
36#include "xfs_types.h" 20#include "xfs_types.h"
37#include "xfs_inum.h" 21#include "xfs_bit.h"
38#include "xfs_log.h" 22#include "xfs_log.h"
23#include "xfs_inum.h"
39#include "xfs_trans.h" 24#include "xfs_trans.h"
40#include "xfs_sb.h" 25#include "xfs_sb.h"
41#include "xfs_ag.h" 26#include "xfs_ag.h"
42#include "xfs_dir.h" 27#include "xfs_dir.h"
43#include "xfs_dir2.h" 28#include "xfs_dir2.h"
44#include "xfs_dmapi.h" 29#include "xfs_da_btree.h"
45#include "xfs_mount.h"
46#include "xfs_alloc_btree.h"
47#include "xfs_bmap_btree.h" 30#include "xfs_bmap_btree.h"
31#include "xfs_alloc_btree.h"
48#include "xfs_ialloc_btree.h" 32#include "xfs_ialloc_btree.h"
49#include "xfs_btree.h"
50#include "xfs_ialloc.h"
51#include "xfs_attr_sf.h"
52#include "xfs_dir_sf.h" 33#include "xfs_dir_sf.h"
53#include "xfs_dir2_sf.h" 34#include "xfs_dir2_sf.h"
35#include "xfs_attr_sf.h"
54#include "xfs_dinode.h" 36#include "xfs_dinode.h"
55#include "xfs_inode_item.h"
56#include "xfs_inode.h" 37#include "xfs_inode.h"
38#include "xfs_btree.h"
39#include "xfs_dmapi.h"
40#include "xfs_mount.h"
41#include "xfs_ialloc.h"
57#include "xfs_itable.h" 42#include "xfs_itable.h"
43#include "xfs_inode_item.h"
58#include "xfs_extfree_item.h" 44#include "xfs_extfree_item.h"
59#include "xfs_alloc.h" 45#include "xfs_alloc.h"
60#include "xfs_bmap.h" 46#include "xfs_bmap.h"
61#include "xfs_rtalloc.h" 47#include "xfs_rtalloc.h"
62#include "xfs_error.h" 48#include "xfs_error.h"
63#include "xfs_da_btree.h"
64#include "xfs_dir_leaf.h" 49#include "xfs_dir_leaf.h"
65#include "xfs_bit.h" 50#include "xfs_attr_leaf.h"
66#include "xfs_rw.h" 51#include "xfs_rw.h"
67#include "xfs_quota.h" 52#include "xfs_quota.h"
68#include "xfs_trans_space.h" 53#include "xfs_trans_space.h"
@@ -438,6 +423,12 @@ xfs_bmap_count_leaves(
438 int numrecs, 423 int numrecs,
439 int *count); 424 int *count);
440 425
426STATIC int
427xfs_bmap_disk_count_leaves(
428 xfs_bmbt_rec_t *frp,
429 int numrecs,
430 int *count);
431
441/* 432/*
442 * Bmap internal routines. 433 * Bmap internal routines.
443 */ 434 */
@@ -2772,8 +2763,8 @@ xfs_bmap_btree_to_extents(
2772 ASSERT(ifp->if_flags & XFS_IFEXTENTS); 2763 ASSERT(ifp->if_flags & XFS_IFEXTENTS);
2773 ASSERT(XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_BTREE); 2764 ASSERT(XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_BTREE);
2774 rblock = ifp->if_broot; 2765 rblock = ifp->if_broot;
2775 ASSERT(INT_GET(rblock->bb_level, ARCH_CONVERT) == 1); 2766 ASSERT(be16_to_cpu(rblock->bb_level) == 1);
2776 ASSERT(INT_GET(rblock->bb_numrecs, ARCH_CONVERT) == 1); 2767 ASSERT(be16_to_cpu(rblock->bb_numrecs) == 1);
2777 ASSERT(XFS_BMAP_BROOT_MAXRECS(ifp->if_broot_bytes) == 1); 2768 ASSERT(XFS_BMAP_BROOT_MAXRECS(ifp->if_broot_bytes) == 1);
2778 mp = ip->i_mount; 2769 mp = ip->i_mount;
2779 pp = XFS_BMAP_BROOT_PTR_ADDR(rblock, 1, ifp->if_broot_bytes); 2770 pp = XFS_BMAP_BROOT_PTR_ADDR(rblock, 1, ifp->if_broot_bytes);
@@ -3216,11 +3207,11 @@ xfs_bmap_extents_to_btree(
3216 * Fill in the root. 3207 * Fill in the root.
3217 */ 3208 */
3218 block = ifp->if_broot; 3209 block = ifp->if_broot;
3219 INT_SET(block->bb_magic, ARCH_CONVERT, XFS_BMAP_MAGIC); 3210 block->bb_magic = cpu_to_be32(XFS_BMAP_MAGIC);
3220 INT_SET(block->bb_level, ARCH_CONVERT, 1); 3211 block->bb_level = cpu_to_be16(1);
3221 INT_SET(block->bb_numrecs, ARCH_CONVERT, 1); 3212 block->bb_numrecs = cpu_to_be16(1);
3222 INT_SET(block->bb_leftsib, ARCH_CONVERT, NULLDFSBNO); 3213 block->bb_leftsib = cpu_to_be64(NULLDFSBNO);
3223 INT_SET(block->bb_rightsib, ARCH_CONVERT, NULLDFSBNO); 3214 block->bb_rightsib = cpu_to_be64(NULLDFSBNO);
3224 /* 3215 /*
3225 * Need a cursor. Can't allocate until bb_level is filled in. 3216 * Need a cursor. Can't allocate until bb_level is filled in.
3226 */ 3217 */
@@ -3273,10 +3264,10 @@ xfs_bmap_extents_to_btree(
3273 * Fill in the child block. 3264 * Fill in the child block.
3274 */ 3265 */
3275 ablock = XFS_BUF_TO_BMBT_BLOCK(abp); 3266 ablock = XFS_BUF_TO_BMBT_BLOCK(abp);
3276 INT_SET(ablock->bb_magic, ARCH_CONVERT, XFS_BMAP_MAGIC); 3267 ablock->bb_magic = cpu_to_be32(XFS_BMAP_MAGIC);
3277 ablock->bb_level = 0; 3268 ablock->bb_level = 0;
3278 INT_SET(ablock->bb_leftsib, ARCH_CONVERT, NULLDFSBNO); 3269 ablock->bb_leftsib = cpu_to_be64(NULLDFSBNO);
3279 INT_SET(ablock->bb_rightsib, ARCH_CONVERT, NULLDFSBNO); 3270 ablock->bb_rightsib = cpu_to_be64(NULLDFSBNO);
3280 arp = XFS_BMAP_REC_IADDR(ablock, 1, cur); 3271 arp = XFS_BMAP_REC_IADDR(ablock, 1, cur);
3281 nextents = ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t); 3272 nextents = ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t);
3282 for (ep = ifp->if_u1.if_extents, cnt = i = 0; i < nextents; i++, ep++) { 3273 for (ep = ifp->if_u1.if_extents, cnt = i = 0; i < nextents; i++, ep++) {
@@ -3286,8 +3277,8 @@ xfs_bmap_extents_to_btree(
3286 arp++; cnt++; 3277 arp++; cnt++;
3287 } 3278 }
3288 } 3279 }
3289 INT_SET(ablock->bb_numrecs, ARCH_CONVERT, cnt); 3280 ASSERT(cnt == XFS_IFORK_NEXTENTS(ip, whichfork));
3290 ASSERT(INT_GET(ablock->bb_numrecs, ARCH_CONVERT) == XFS_IFORK_NEXTENTS(ip, whichfork)); 3281 ablock->bb_numrecs = cpu_to_be16(cnt);
3291 /* 3282 /*
3292 * Fill in the root key and pointer. 3283 * Fill in the root key and pointer.
3293 */ 3284 */
@@ -3301,7 +3292,7 @@ xfs_bmap_extents_to_btree(
3301 * the root is at the right level. 3292 * the root is at the right level.
3302 */ 3293 */
3303 xfs_bmbt_log_block(cur, abp, XFS_BB_ALL_BITS); 3294 xfs_bmbt_log_block(cur, abp, XFS_BB_ALL_BITS);
3304 xfs_bmbt_log_recs(cur, abp, 1, INT_GET(ablock->bb_numrecs, ARCH_CONVERT)); 3295 xfs_bmbt_log_recs(cur, abp, 1, be16_to_cpu(ablock->bb_numrecs));
3305 ASSERT(*curp == NULL); 3296 ASSERT(*curp == NULL);
3306 *curp = cur; 3297 *curp = cur;
3307 *logflagsp = XFS_ILOG_CORE | XFS_ILOG_FBROOT(whichfork); 3298 *logflagsp = XFS_ILOG_CORE | XFS_ILOG_FBROOT(whichfork);
@@ -3337,6 +3328,29 @@ xfs_bmap_insert_exlist(
3337} 3328}
3338 3329
3339/* 3330/*
3331 * Helper routine to reset inode di_forkoff field when switching
3332 * attribute fork from local to extent format - we reset it where
3333 * possible to make space available for inline data fork extents.
3334 */
3335STATIC void
3336xfs_bmap_forkoff_reset(
3337 xfs_mount_t *mp,
3338 xfs_inode_t *ip,
3339 int whichfork)
3340{
3341 if (whichfork == XFS_ATTR_FORK &&
3342 (ip->i_d.di_format != XFS_DINODE_FMT_DEV) &&
3343 (ip->i_d.di_format != XFS_DINODE_FMT_UUID) &&
3344 ((mp->m_attroffset >> 3) > ip->i_d.di_forkoff)) {
3345 ip->i_d.di_forkoff = mp->m_attroffset >> 3;
3346 ip->i_df.if_ext_max = XFS_IFORK_DSIZE(ip) /
3347 (uint)sizeof(xfs_bmbt_rec_t);
3348 ip->i_afp->if_ext_max = XFS_IFORK_ASIZE(ip) /
3349 (uint)sizeof(xfs_bmbt_rec_t);
3350 }
3351}
3352
3353/*
3340 * Convert a local file to an extents file. 3354 * Convert a local file to an extents file.
3341 * This code is out of bounds for data forks of regular files, 3355 * This code is out of bounds for data forks of regular files,
3342 * since the file data needs to get logged so things will stay consistent. 3356 * since the file data needs to get logged so things will stay consistent.
@@ -3403,6 +3417,7 @@ xfs_bmap_local_to_extents(
3403 memcpy((char *)XFS_BUF_PTR(bp), ifp->if_u1.if_data, 3417 memcpy((char *)XFS_BUF_PTR(bp), ifp->if_u1.if_data,
3404 ifp->if_bytes); 3418 ifp->if_bytes);
3405 xfs_trans_log_buf(tp, bp, 0, ifp->if_bytes - 1); 3419 xfs_trans_log_buf(tp, bp, 0, ifp->if_bytes - 1);
3420 xfs_bmap_forkoff_reset(args.mp, ip, whichfork);
3406 xfs_idata_realloc(ip, -ifp->if_bytes, whichfork); 3421 xfs_idata_realloc(ip, -ifp->if_bytes, whichfork);
3407 xfs_iext_realloc(ip, 1, whichfork); 3422 xfs_iext_realloc(ip, 1, whichfork);
3408 ep = ifp->if_u1.if_extents; 3423 ep = ifp->if_u1.if_extents;
@@ -3413,8 +3428,10 @@ xfs_bmap_local_to_extents(
3413 XFS_TRANS_MOD_DQUOT_BYINO(args.mp, tp, ip, 3428 XFS_TRANS_MOD_DQUOT_BYINO(args.mp, tp, ip,
3414 XFS_TRANS_DQ_BCOUNT, 1L); 3429 XFS_TRANS_DQ_BCOUNT, 1L);
3415 flags |= XFS_ILOG_FEXT(whichfork); 3430 flags |= XFS_ILOG_FEXT(whichfork);
3416 } else 3431 } else {
3417 ASSERT(XFS_IFORK_NEXTENTS(ip, whichfork) == 0); 3432 ASSERT(XFS_IFORK_NEXTENTS(ip, whichfork) == 0);
3433 xfs_bmap_forkoff_reset(ip->i_mount, ip, whichfork);
3434 }
3418 ifp->if_flags &= ~XFS_IFINLINE; 3435 ifp->if_flags &= ~XFS_IFINLINE;
3419 ifp->if_flags |= XFS_IFEXTENTS; 3436 ifp->if_flags |= XFS_IFEXTENTS;
3420 XFS_IFORK_FMT_SET(ip, whichfork, XFS_DINODE_FMT_EXTENTS); 3437 XFS_IFORK_FMT_SET(ip, whichfork, XFS_DINODE_FMT_EXTENTS);
@@ -3796,22 +3813,24 @@ xfs_bunmap_trace(
3796int /* error code */ 3813int /* error code */
3797xfs_bmap_add_attrfork( 3814xfs_bmap_add_attrfork(
3798 xfs_inode_t *ip, /* incore inode pointer */ 3815 xfs_inode_t *ip, /* incore inode pointer */
3799 int rsvd) /* OK to allocated reserved blocks in trans */ 3816 int size, /* space new attribute needs */
3817 int rsvd) /* xact may use reserved blks */
3800{ 3818{
3801 int blks; /* space reservation */
3802 int committed; /* xaction was committed */
3803 int error; /* error return value */
3804 xfs_fsblock_t firstblock; /* 1st block/ag allocated */ 3819 xfs_fsblock_t firstblock; /* 1st block/ag allocated */
3805 xfs_bmap_free_t flist; /* freed extent list */ 3820 xfs_bmap_free_t flist; /* freed extent list */
3806 int logflags; /* logging flags */
3807 xfs_mount_t *mp; /* mount structure */ 3821 xfs_mount_t *mp; /* mount structure */
3808 unsigned long s; /* spinlock spl value */
3809 xfs_trans_t *tp; /* transaction pointer */ 3822 xfs_trans_t *tp; /* transaction pointer */
3823 unsigned long s; /* spinlock spl value */
3824 int blks; /* space reservation */
3825 int version = 1; /* superblock attr version */
3826 int committed; /* xaction was committed */
3827 int logflags; /* logging flags */
3828 int error; /* error return value */
3810 3829
3830 ASSERT(XFS_IFORK_Q(ip) == 0);
3811 ASSERT(ip->i_df.if_ext_max == 3831 ASSERT(ip->i_df.if_ext_max ==
3812 XFS_IFORK_DSIZE(ip) / (uint)sizeof(xfs_bmbt_rec_t)); 3832 XFS_IFORK_DSIZE(ip) / (uint)sizeof(xfs_bmbt_rec_t));
3813 if (XFS_IFORK_Q(ip)) 3833
3814 return 0;
3815 mp = ip->i_mount; 3834 mp = ip->i_mount;
3816 ASSERT(!XFS_NOT_DQATTACHED(mp, ip)); 3835 ASSERT(!XFS_NOT_DQATTACHED(mp, ip));
3817 tp = xfs_trans_alloc(mp, XFS_TRANS_ADDAFORK); 3836 tp = xfs_trans_alloc(mp, XFS_TRANS_ADDAFORK);
@@ -3853,7 +3872,11 @@ xfs_bmap_add_attrfork(
3853 case XFS_DINODE_FMT_LOCAL: 3872 case XFS_DINODE_FMT_LOCAL:
3854 case XFS_DINODE_FMT_EXTENTS: 3873 case XFS_DINODE_FMT_EXTENTS:
3855 case XFS_DINODE_FMT_BTREE: 3874 case XFS_DINODE_FMT_BTREE:
3856 ip->i_d.di_forkoff = mp->m_attroffset >> 3; 3875 ip->i_d.di_forkoff = xfs_attr_shortform_bytesfit(ip, size);
3876 if (!ip->i_d.di_forkoff)
3877 ip->i_d.di_forkoff = mp->m_attroffset >> 3;
3878 else if (!(mp->m_flags & XFS_MOUNT_COMPAT_ATTR))
3879 version = 2;
3857 break; 3880 break;
3858 default: 3881 default:
3859 ASSERT(0); 3882 ASSERT(0);
@@ -3890,12 +3913,22 @@ xfs_bmap_add_attrfork(
3890 xfs_trans_log_inode(tp, ip, logflags); 3913 xfs_trans_log_inode(tp, ip, logflags);
3891 if (error) 3914 if (error)
3892 goto error2; 3915 goto error2;
3893 if (!XFS_SB_VERSION_HASATTR(&mp->m_sb)) { 3916 if (!XFS_SB_VERSION_HASATTR(&mp->m_sb) ||
3917 (!XFS_SB_VERSION_HASATTR2(&mp->m_sb) && version == 2)) {
3918 __int64_t sbfields = 0;
3919
3894 s = XFS_SB_LOCK(mp); 3920 s = XFS_SB_LOCK(mp);
3895 if (!XFS_SB_VERSION_HASATTR(&mp->m_sb)) { 3921 if (!XFS_SB_VERSION_HASATTR(&mp->m_sb)) {
3896 XFS_SB_VERSION_ADDATTR(&mp->m_sb); 3922 XFS_SB_VERSION_ADDATTR(&mp->m_sb);
3923 sbfields |= XFS_SB_VERSIONNUM;
3924 }
3925 if (!XFS_SB_VERSION_HASATTR2(&mp->m_sb) && version == 2) {
3926 XFS_SB_VERSION_ADDATTR2(&mp->m_sb);
3927 sbfields |= (XFS_SB_VERSIONNUM | XFS_SB_FEATURES2);
3928 }
3929 if (sbfields) {
3897 XFS_SB_UNLOCK(mp, s); 3930 XFS_SB_UNLOCK(mp, s);
3898 xfs_mod_sb(tp, XFS_SB_VERSIONNUM); 3931 xfs_mod_sb(tp, sbfields);
3899 } else 3932 } else
3900 XFS_SB_UNLOCK(mp, s); 3933 XFS_SB_UNLOCK(mp, s);
3901 } 3934 }
@@ -3988,13 +4021,19 @@ xfs_bmap_compute_maxlevels(
3988 * (a signed 32-bit number, xfs_extnum_t), or by di_anextents 4021 * (a signed 32-bit number, xfs_extnum_t), or by di_anextents
3989 * (a signed 16-bit number, xfs_aextnum_t). 4022 * (a signed 16-bit number, xfs_aextnum_t).
3990 */ 4023 */
3991 maxleafents = (whichfork == XFS_DATA_FORK) ? MAXEXTNUM : MAXAEXTNUM; 4024 if (whichfork == XFS_DATA_FORK) {
4025 maxleafents = MAXEXTNUM;
4026 sz = (mp->m_flags & XFS_MOUNT_COMPAT_ATTR) ?
4027 mp->m_attroffset : XFS_BMDR_SPACE_CALC(MINDBTPTRS);
4028 } else {
4029 maxleafents = MAXAEXTNUM;
4030 sz = (mp->m_flags & XFS_MOUNT_COMPAT_ATTR) ?
4031 mp->m_sb.sb_inodesize - mp->m_attroffset :
4032 XFS_BMDR_SPACE_CALC(MINABTPTRS);
4033 }
4034 maxrootrecs = (int)XFS_BTREE_BLOCK_MAXRECS(sz, xfs_bmdr, 0);
3992 minleafrecs = mp->m_bmap_dmnr[0]; 4035 minleafrecs = mp->m_bmap_dmnr[0];
3993 minnoderecs = mp->m_bmap_dmnr[1]; 4036 minnoderecs = mp->m_bmap_dmnr[1];
3994 sz = (whichfork == XFS_DATA_FORK) ?
3995 mp->m_attroffset :
3996 mp->m_sb.sb_inodesize - mp->m_attroffset;
3997 maxrootrecs = (int)XFS_BTREE_BLOCK_MAXRECS(sz, xfs_bmdr, 0);
3998 maxblocks = (maxleafents + minleafrecs - 1) / minleafrecs; 4037 maxblocks = (maxleafents + minleafrecs - 1) / minleafrecs;
3999 for (level = 1; maxblocks > 1; level++) { 4038 for (level = 1; maxblocks > 1; level++) {
4000 if (maxblocks <= maxrootrecs) 4039 if (maxblocks <= maxrootrecs)
@@ -4332,8 +4371,8 @@ xfs_bmap_read_extents(
4332 /* 4371 /*
4333 * Root level must use BMAP_BROOT_PTR_ADDR macro to get ptr out. 4372 * Root level must use BMAP_BROOT_PTR_ADDR macro to get ptr out.
4334 */ 4373 */
4335 ASSERT(INT_GET(block->bb_level, ARCH_CONVERT) > 0); 4374 level = be16_to_cpu(block->bb_level);
4336 level = INT_GET(block->bb_level, ARCH_CONVERT); 4375 ASSERT(level > 0);
4337 pp = XFS_BMAP_BROOT_PTR_ADDR(block, 1, ifp->if_broot_bytes); 4376 pp = XFS_BMAP_BROOT_PTR_ADDR(block, 1, ifp->if_broot_bytes);
4338 ASSERT(INT_GET(*pp, ARCH_CONVERT) != NULLDFSBNO); 4377 ASSERT(INT_GET(*pp, ARCH_CONVERT) != NULLDFSBNO);
4339 ASSERT(XFS_FSB_TO_AGNO(mp, INT_GET(*pp, ARCH_CONVERT)) < mp->m_sb.sb_agcount); 4378 ASSERT(XFS_FSB_TO_AGNO(mp, INT_GET(*pp, ARCH_CONVERT)) < mp->m_sb.sb_agcount);
@@ -4376,7 +4415,7 @@ xfs_bmap_read_extents(
4376 xfs_extnum_t num_recs; 4415 xfs_extnum_t num_recs;
4377 4416
4378 4417
4379 num_recs = INT_GET(block->bb_numrecs, ARCH_CONVERT); 4418 num_recs = be16_to_cpu(block->bb_numrecs);
4380 if (unlikely(i + num_recs > room)) { 4419 if (unlikely(i + num_recs > room)) {
4381 ASSERT(i + num_recs <= room); 4420 ASSERT(i + num_recs <= room);
4382 xfs_fs_cmn_err(CE_WARN, ip->i_mount, 4421 xfs_fs_cmn_err(CE_WARN, ip->i_mount,
@@ -4393,7 +4432,7 @@ xfs_bmap_read_extents(
4393 /* 4432 /*
4394 * Read-ahead the next leaf block, if any. 4433 * Read-ahead the next leaf block, if any.
4395 */ 4434 */
4396 nextbno = INT_GET(block->bb_rightsib, ARCH_CONVERT); 4435 nextbno = be64_to_cpu(block->bb_rightsib);
4397 if (nextbno != NULLFSBLOCK) 4436 if (nextbno != NULLFSBLOCK)
4398 xfs_btree_reada_bufl(mp, nextbno, 1); 4437 xfs_btree_reada_bufl(mp, nextbno, 1);
4399 /* 4438 /*
@@ -4650,7 +4689,7 @@ xfs_bmapi(
4650 } 4689 }
4651 if (wr && *firstblock == NULLFSBLOCK) { 4690 if (wr && *firstblock == NULLFSBLOCK) {
4652 if (XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_BTREE) 4691 if (XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_BTREE)
4653 minleft = INT_GET(ifp->if_broot->bb_level, ARCH_CONVERT) + 1; 4692 minleft = be16_to_cpu(ifp->if_broot->bb_level) + 1;
4654 else 4693 else
4655 minleft = 1; 4694 minleft = 1;
4656 } else 4695 } else
@@ -5692,12 +5731,13 @@ xfs_getbmap(
5692 out.bmv_offset = XFS_FSB_TO_BB(mp, map[i].br_startoff); 5731 out.bmv_offset = XFS_FSB_TO_BB(mp, map[i].br_startoff);
5693 out.bmv_length = XFS_FSB_TO_BB(mp, map[i].br_blockcount); 5732 out.bmv_length = XFS_FSB_TO_BB(mp, map[i].br_blockcount);
5694 ASSERT(map[i].br_startblock != DELAYSTARTBLOCK); 5733 ASSERT(map[i].br_startblock != DELAYSTARTBLOCK);
5695 if (prealloced && 5734 if (map[i].br_startblock == HOLESTARTBLOCK &&
5696 map[i].br_startblock == HOLESTARTBLOCK && 5735 ((prealloced && out.bmv_offset + out.bmv_length == bmvend) ||
5697 out.bmv_offset + out.bmv_length == bmvend) { 5736 whichfork == XFS_ATTR_FORK )) {
5698 /* 5737 /*
5699 * came to hole at end of file 5738 * came to hole at end of file or the end of
5700 */ 5739 attribute fork
5740 */
5701 goto unlock_and_return; 5741 goto unlock_and_return;
5702 } else { 5742 } else {
5703 out.bmv_block = 5743 out.bmv_block =
@@ -5927,10 +5967,10 @@ xfs_check_block(
5927 xfs_bmbt_ptr_t *pp, *thispa; /* pointer to block address */ 5967 xfs_bmbt_ptr_t *pp, *thispa; /* pointer to block address */
5928 xfs_bmbt_key_t *prevp, *keyp; 5968 xfs_bmbt_key_t *prevp, *keyp;
5929 5969
5930 ASSERT(INT_GET(block->bb_level, ARCH_CONVERT) > 0); 5970 ASSERT(be16_to_cpu(block->bb_level) > 0);
5931 5971
5932 prevp = NULL; 5972 prevp = NULL;
5933 for( i = 1; i <= INT_GET(block->bb_numrecs, ARCH_CONVERT);i++) { 5973 for( i = 1; i <= be16_to_cpu(block->bb_numrecs); i++) {
5934 dmxr = mp->m_bmap_dmxr[0]; 5974 dmxr = mp->m_bmap_dmxr[0];
5935 5975
5936 if (root) { 5976 if (root) {
@@ -5955,7 +5995,7 @@ xfs_check_block(
5955 pp = XFS_BTREE_PTR_ADDR(mp->m_sb.sb_blocksize, 5995 pp = XFS_BTREE_PTR_ADDR(mp->m_sb.sb_blocksize,
5956 xfs_bmbt, block, i, dmxr); 5996 xfs_bmbt, block, i, dmxr);
5957 } 5997 }
5958 for (j = i+1; j <= INT_GET(block->bb_numrecs, ARCH_CONVERT); j++) { 5998 for (j = i+1; j <= be16_to_cpu(block->bb_numrecs); j++) {
5959 if (root) { 5999 if (root) {
5960 thispa = XFS_BMAP_BROOT_PTR_ADDR(block, j, sz); 6000 thispa = XFS_BMAP_BROOT_PTR_ADDR(block, j, sz);
5961 } else { 6001 } else {
@@ -6008,8 +6048,8 @@ xfs_bmap_check_leaf_extents(
6008 /* 6048 /*
6009 * Root level must use BMAP_BROOT_PTR_ADDR macro to get ptr out. 6049 * Root level must use BMAP_BROOT_PTR_ADDR macro to get ptr out.
6010 */ 6050 */
6011 ASSERT(INT_GET(block->bb_level, ARCH_CONVERT) > 0); 6051 level = be16_to_cpu(block->bb_level);
6012 level = INT_GET(block->bb_level, ARCH_CONVERT); 6052 ASSERT(level > 0);
6013 xfs_check_block(block, mp, 1, ifp->if_broot_bytes); 6053 xfs_check_block(block, mp, 1, ifp->if_broot_bytes);
6014 pp = XFS_BMAP_BROOT_PTR_ADDR(block, 1, ifp->if_broot_bytes); 6054 pp = XFS_BMAP_BROOT_PTR_ADDR(block, 1, ifp->if_broot_bytes);
6015 ASSERT(INT_GET(*pp, ARCH_CONVERT) != NULLDFSBNO); 6055 ASSERT(INT_GET(*pp, ARCH_CONVERT) != NULLDFSBNO);
@@ -6069,13 +6109,13 @@ xfs_bmap_check_leaf_extents(
6069 xfs_extnum_t num_recs; 6109 xfs_extnum_t num_recs;
6070 6110
6071 6111
6072 num_recs = INT_GET(block->bb_numrecs, ARCH_CONVERT); 6112 num_recs = be16_to_cpu(block->bb_numrecs);
6073 6113
6074 /* 6114 /*
6075 * Read-ahead the next leaf block, if any. 6115 * Read-ahead the next leaf block, if any.
6076 */ 6116 */
6077 6117
6078 nextbno = INT_GET(block->bb_rightsib, ARCH_CONVERT); 6118 nextbno = be64_to_cpu(block->bb_rightsib);
6079 6119
6080 /* 6120 /*
6081 * Check all the extents to make sure they are OK. 6121 * Check all the extents to make sure they are OK.
@@ -6131,7 +6171,7 @@ error0:
6131 xfs_trans_brelse(NULL, bp); 6171 xfs_trans_brelse(NULL, bp);
6132error_norelse: 6172error_norelse:
6133 cmn_err(CE_WARN, "%s: BAD after btree leaves for %d extents", 6173 cmn_err(CE_WARN, "%s: BAD after btree leaves for %d extents",
6134 i, __FUNCTION__); 6174 __FUNCTION__, i);
6135 panic("%s: CORRUPTED BTREE OR SOMETHING", __FUNCTION__); 6175 panic("%s: CORRUPTED BTREE OR SOMETHING", __FUNCTION__);
6136 return; 6176 return;
6137} 6177}
@@ -6172,8 +6212,8 @@ xfs_bmap_count_blocks(
6172 * Root level must use BMAP_BROOT_PTR_ADDR macro to get ptr out. 6212 * Root level must use BMAP_BROOT_PTR_ADDR macro to get ptr out.
6173 */ 6213 */
6174 block = ifp->if_broot; 6214 block = ifp->if_broot;
6175 ASSERT(INT_GET(block->bb_level, ARCH_CONVERT) > 0); 6215 level = be16_to_cpu(block->bb_level);
6176 level = INT_GET(block->bb_level, ARCH_CONVERT); 6216 ASSERT(level > 0);
6177 pp = XFS_BMAP_BROOT_PTR_ADDR(block, 1, ifp->if_broot_bytes); 6217 pp = XFS_BMAP_BROOT_PTR_ADDR(block, 1, ifp->if_broot_bytes);
6178 ASSERT(INT_GET(*pp, ARCH_CONVERT) != NULLDFSBNO); 6218 ASSERT(INT_GET(*pp, ARCH_CONVERT) != NULLDFSBNO);
6179 ASSERT(XFS_FSB_TO_AGNO(mp, INT_GET(*pp, ARCH_CONVERT)) < mp->m_sb.sb_agcount); 6219 ASSERT(XFS_FSB_TO_AGNO(mp, INT_GET(*pp, ARCH_CONVERT)) < mp->m_sb.sb_agcount);
@@ -6218,14 +6258,14 @@ xfs_bmap_count_tree(
6218 6258
6219 if (--level) { 6259 if (--level) {
6220 /* Not at node above leafs, count this level of nodes */ 6260 /* Not at node above leafs, count this level of nodes */
6221 nextbno = INT_GET(block->bb_rightsib, ARCH_CONVERT); 6261 nextbno = be64_to_cpu(block->bb_rightsib);
6222 while (nextbno != NULLFSBLOCK) { 6262 while (nextbno != NULLFSBLOCK) {
6223 if ((error = xfs_btree_read_bufl(mp, tp, nextbno, 6263 if ((error = xfs_btree_read_bufl(mp, tp, nextbno,
6224 0, &nbp, XFS_BMAP_BTREE_REF))) 6264 0, &nbp, XFS_BMAP_BTREE_REF)))
6225 return error; 6265 return error;
6226 *count += 1; 6266 *count += 1;
6227 nextblock = XFS_BUF_TO_BMBT_BLOCK(nbp); 6267 nextblock = XFS_BUF_TO_BMBT_BLOCK(nbp);
6228 nextbno = INT_GET(nextblock->bb_rightsib, ARCH_CONVERT); 6268 nextbno = be64_to_cpu(nextblock->bb_rightsib);
6229 xfs_trans_brelse(tp, nbp); 6269 xfs_trans_brelse(tp, nbp);
6230 } 6270 }
6231 6271
@@ -6244,11 +6284,11 @@ xfs_bmap_count_tree(
6244 } else { 6284 } else {
6245 /* count all level 1 nodes and their leaves */ 6285 /* count all level 1 nodes and their leaves */
6246 for (;;) { 6286 for (;;) {
6247 nextbno = INT_GET(block->bb_rightsib, ARCH_CONVERT); 6287 nextbno = be64_to_cpu(block->bb_rightsib);
6248 numrecs = INT_GET(block->bb_numrecs, ARCH_CONVERT); 6288 numrecs = be16_to_cpu(block->bb_numrecs);
6249 frp = XFS_BTREE_REC_ADDR(mp->m_sb.sb_blocksize, 6289 frp = XFS_BTREE_REC_ADDR(mp->m_sb.sb_blocksize,
6250 xfs_bmbt, block, 1, mp->m_bmap_dmxr[0]); 6290 xfs_bmbt, block, 1, mp->m_bmap_dmxr[0]);
6251 if (unlikely(xfs_bmap_count_leaves(frp, numrecs, count) < 0)) { 6291 if (unlikely(xfs_bmap_disk_count_leaves(frp, numrecs, count) < 0)) {
6252 xfs_trans_brelse(tp, bp); 6292 xfs_trans_brelse(tp, bp);
6253 XFS_ERROR_REPORT("xfs_bmap_count_tree(2)", 6293 XFS_ERROR_REPORT("xfs_bmap_count_tree(2)",
6254 XFS_ERRLEVEL_LOW, mp); 6294 XFS_ERRLEVEL_LOW, mp);
@@ -6280,6 +6320,22 @@ xfs_bmap_count_leaves(
6280 int b; 6320 int b;
6281 6321
6282 for ( b = 1; b <= numrecs; b++, frp++) 6322 for ( b = 1; b <= numrecs; b++, frp++)
6323 *count += xfs_bmbt_get_blockcount(frp);
6324 return 0;
6325}
6326
6327/*
6328 * Count leaf blocks given a pointer to an extent list originally in btree format.
6329 */
6330int
6331xfs_bmap_disk_count_leaves(
6332 xfs_bmbt_rec_t *frp,
6333 int numrecs,
6334 int *count)
6335{
6336 int b;
6337
6338 for ( b = 1; b <= numrecs; b++, frp++)
6283 *count += xfs_bmbt_disk_get_blockcount(frp); 6339 *count += xfs_bmbt_disk_get_blockcount(frp);
6284 return 0; 6340 return 0;
6285} 6341}
diff --git a/fs/xfs/xfs_bmap.h b/fs/xfs/xfs_bmap.h
index e6d22ec9b2e4..2e0717a01309 100644
--- a/fs/xfs/xfs_bmap.h
+++ b/fs/xfs/xfs_bmap.h
@@ -1,33 +1,19 @@
1/* 1/*
2 * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32#ifndef __XFS_BMAP_H__ 18#ifndef __XFS_BMAP_H__
33#define __XFS_BMAP_H__ 19#define __XFS_BMAP_H__
@@ -77,12 +63,11 @@ typedef struct xfs_bmap_free
77 /* combine contig. space */ 63 /* combine contig. space */
78#define XFS_BMAPI_CONTIG 0x400 /* must allocate only one extent */ 64#define XFS_BMAPI_CONTIG 0x400 /* must allocate only one extent */
79 65
80#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMAPI_AFLAG)
81int xfs_bmapi_aflag(int w);
82#define XFS_BMAPI_AFLAG(w) xfs_bmapi_aflag(w) 66#define XFS_BMAPI_AFLAG(w) xfs_bmapi_aflag(w)
83#else 67static inline int xfs_bmapi_aflag(int w)
84#define XFS_BMAPI_AFLAG(w) ((w) == XFS_ATTR_FORK ? XFS_BMAPI_ATTRFORK : 0) 68{
85#endif 69 return (w == XFS_ATTR_FORK ? XFS_BMAPI_ATTRFORK : 0);
70}
86 71
87/* 72/*
88 * Special values for xfs_bmbt_irec_t br_startblock field. 73 * Special values for xfs_bmbt_irec_t br_startblock field.
@@ -90,14 +75,12 @@ int xfs_bmapi_aflag(int w);
90#define DELAYSTARTBLOCK ((xfs_fsblock_t)-1LL) 75#define DELAYSTARTBLOCK ((xfs_fsblock_t)-1LL)
91#define HOLESTARTBLOCK ((xfs_fsblock_t)-2LL) 76#define HOLESTARTBLOCK ((xfs_fsblock_t)-2LL)
92 77
93#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMAP_INIT)
94void xfs_bmap_init(xfs_bmap_free_t *flp, xfs_fsblock_t *fbp);
95#define XFS_BMAP_INIT(flp,fbp) xfs_bmap_init(flp,fbp) 78#define XFS_BMAP_INIT(flp,fbp) xfs_bmap_init(flp,fbp)
96#else 79static inline void xfs_bmap_init(xfs_bmap_free_t *flp, xfs_fsblock_t *fbp)
97#define XFS_BMAP_INIT(flp,fbp) \ 80{
98 ((flp)->xbf_first = NULL, (flp)->xbf_count = 0, \ 81 ((flp)->xbf_first = NULL, (flp)->xbf_count = 0, \
99 (flp)->xbf_low = 0, *(fbp) = NULLFSBLOCK) 82 (flp)->xbf_low = 0, *(fbp) = NULLFSBLOCK);
100#endif 83}
101 84
102/* 85/*
103 * Argument structure for xfs_bmap_alloc. 86 * Argument structure for xfs_bmap_alloc.
@@ -156,7 +139,8 @@ xfs_bmap_trace_exlist(
156int /* error code */ 139int /* error code */
157xfs_bmap_add_attrfork( 140xfs_bmap_add_attrfork(
158 struct xfs_inode *ip, /* incore inode pointer */ 141 struct xfs_inode *ip, /* incore inode pointer */
159 int rsvd); /* flag for reserved block allocation */ 142 int size, /* space needed for new attribute */
143 int rsvd); /* flag for reserved block allocation */
160 144
161/* 145/*
162 * Add the extent to the list of extents to be free at transaction end. 146 * Add the extent to the list of extents to be free at transaction end.
diff --git a/fs/xfs/xfs_bmap_btree.c b/fs/xfs/xfs_bmap_btree.c
index 09a77b17565b..3f1383d160e8 100644
--- a/fs/xfs/xfs_bmap_btree.c
+++ b/fs/xfs/xfs_bmap_btree.c
@@ -1,41 +1,26 @@
1/* 1/*
2 * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32
33#include "xfs.h" 18#include "xfs.h"
34 19#include "xfs_fs.h"
35#include "xfs_macros.h"
36#include "xfs_types.h" 20#include "xfs_types.h"
37#include "xfs_inum.h" 21#include "xfs_bit.h"
38#include "xfs_log.h" 22#include "xfs_log.h"
23#include "xfs_inum.h"
39#include "xfs_trans.h" 24#include "xfs_trans.h"
40#include "xfs_sb.h" 25#include "xfs_sb.h"
41#include "xfs_ag.h" 26#include "xfs_ag.h"
@@ -43,20 +28,19 @@
43#include "xfs_dir2.h" 28#include "xfs_dir2.h"
44#include "xfs_dmapi.h" 29#include "xfs_dmapi.h"
45#include "xfs_mount.h" 30#include "xfs_mount.h"
46#include "xfs_alloc_btree.h"
47#include "xfs_bmap_btree.h" 31#include "xfs_bmap_btree.h"
32#include "xfs_alloc_btree.h"
48#include "xfs_ialloc_btree.h" 33#include "xfs_ialloc_btree.h"
49#include "xfs_btree.h"
50#include "xfs_ialloc.h"
51#include "xfs_itable.h"
52#include "xfs_attr_sf.h"
53#include "xfs_dir_sf.h" 34#include "xfs_dir_sf.h"
54#include "xfs_dir2_sf.h" 35#include "xfs_dir2_sf.h"
36#include "xfs_attr_sf.h"
55#include "xfs_dinode.h" 37#include "xfs_dinode.h"
56#include "xfs_inode_item.h"
57#include "xfs_inode.h" 38#include "xfs_inode.h"
39#include "xfs_inode_item.h"
58#include "xfs_alloc.h" 40#include "xfs_alloc.h"
59#include "xfs_bit.h" 41#include "xfs_btree.h"
42#include "xfs_ialloc.h"
43#include "xfs_itable.h"
60#include "xfs_bmap.h" 44#include "xfs_bmap.h"
61#include "xfs_error.h" 45#include "xfs_error.h"
62#include "xfs_quota.h" 46#include "xfs_quota.h"
@@ -382,7 +366,7 @@ xfs_bmbt_delrec(
382 return 0; 366 return 0;
383 } 367 }
384 block = xfs_bmbt_get_block(cur, level, &bp); 368 block = xfs_bmbt_get_block(cur, level, &bp);
385 numrecs = INT_GET(block->bb_numrecs, ARCH_CONVERT); 369 numrecs = be16_to_cpu(block->bb_numrecs);
386#ifdef DEBUG 370#ifdef DEBUG
387 if ((error = xfs_btree_check_lblock(cur, block, level, bp))) { 371 if ((error = xfs_btree_check_lblock(cur, block, level, bp))) {
388 XFS_BMBT_TRACE_CURSOR(cur, ERROR); 372 XFS_BMBT_TRACE_CURSOR(cur, ERROR);
@@ -427,7 +411,7 @@ xfs_bmbt_delrec(
427 } 411 }
428 } 412 }
429 numrecs--; 413 numrecs--;
430 INT_SET(block->bb_numrecs, ARCH_CONVERT, numrecs); 414 block->bb_numrecs = cpu_to_be16(numrecs);
431 xfs_bmbt_log_block(cur, bp, XFS_BB_NUMRECS); 415 xfs_bmbt_log_block(cur, bp, XFS_BB_NUMRECS);
432 /* 416 /*
433 * We're at the root level. 417 * We're at the root level.
@@ -463,8 +447,8 @@ xfs_bmbt_delrec(
463 *stat = 1; 447 *stat = 1;
464 return 0; 448 return 0;
465 } 449 }
466 rbno = INT_GET(block->bb_rightsib, ARCH_CONVERT); 450 rbno = be64_to_cpu(block->bb_rightsib);
467 lbno = INT_GET(block->bb_leftsib, ARCH_CONVERT); 451 lbno = be64_to_cpu(block->bb_leftsib);
468 /* 452 /*
469 * One child of root, need to get a chance to copy its contents 453 * One child of root, need to get a chance to copy its contents
470 * into the root and delete it. Can't go up to next level, 454 * into the root and delete it. Can't go up to next level,
@@ -508,15 +492,15 @@ xfs_bmbt_delrec(
508 goto error0; 492 goto error0;
509 } 493 }
510#endif 494#endif
511 bno = INT_GET(right->bb_leftsib, ARCH_CONVERT); 495 bno = be64_to_cpu(right->bb_leftsib);
512 if (INT_GET(right->bb_numrecs, ARCH_CONVERT) - 1 >= 496 if (be16_to_cpu(right->bb_numrecs) - 1 >=
513 XFS_BMAP_BLOCK_IMINRECS(level, cur)) { 497 XFS_BMAP_BLOCK_IMINRECS(level, cur)) {
514 if ((error = xfs_bmbt_lshift(tcur, level, &i))) { 498 if ((error = xfs_bmbt_lshift(tcur, level, &i))) {
515 XFS_BMBT_TRACE_CURSOR(cur, ERROR); 499 XFS_BMBT_TRACE_CURSOR(cur, ERROR);
516 goto error0; 500 goto error0;
517 } 501 }
518 if (i) { 502 if (i) {
519 ASSERT(INT_GET(block->bb_numrecs, ARCH_CONVERT) >= 503 ASSERT(be16_to_cpu(block->bb_numrecs) >=
520 XFS_BMAP_BLOCK_IMINRECS(level, tcur)); 504 XFS_BMAP_BLOCK_IMINRECS(level, tcur));
521 xfs_btree_del_cursor(tcur, XFS_BTREE_NOERROR); 505 xfs_btree_del_cursor(tcur, XFS_BTREE_NOERROR);
522 tcur = NULL; 506 tcur = NULL;
@@ -533,7 +517,7 @@ xfs_bmbt_delrec(
533 return 0; 517 return 0;
534 } 518 }
535 } 519 }
536 rrecs = INT_GET(right->bb_numrecs, ARCH_CONVERT); 520 rrecs = be16_to_cpu(right->bb_numrecs);
537 if (lbno != NULLFSBLOCK) { 521 if (lbno != NULLFSBLOCK) {
538 i = xfs_btree_firstrec(tcur, level); 522 i = xfs_btree_firstrec(tcur, level);
539 XFS_WANT_CORRUPTED_GOTO(i == 1, error0); 523 XFS_WANT_CORRUPTED_GOTO(i == 1, error0);
@@ -564,15 +548,15 @@ xfs_bmbt_delrec(
564 goto error0; 548 goto error0;
565 } 549 }
566#endif 550#endif
567 bno = INT_GET(left->bb_rightsib, ARCH_CONVERT); 551 bno = be64_to_cpu(left->bb_rightsib);
568 if (INT_GET(left->bb_numrecs, ARCH_CONVERT) - 1 >= 552 if (be16_to_cpu(left->bb_numrecs) - 1 >=
569 XFS_BMAP_BLOCK_IMINRECS(level, cur)) { 553 XFS_BMAP_BLOCK_IMINRECS(level, cur)) {
570 if ((error = xfs_bmbt_rshift(tcur, level, &i))) { 554 if ((error = xfs_bmbt_rshift(tcur, level, &i))) {
571 XFS_BMBT_TRACE_CURSOR(cur, ERROR); 555 XFS_BMBT_TRACE_CURSOR(cur, ERROR);
572 goto error0; 556 goto error0;
573 } 557 }
574 if (i) { 558 if (i) {
575 ASSERT(INT_GET(block->bb_numrecs, ARCH_CONVERT) >= 559 ASSERT(be16_to_cpu(block->bb_numrecs) >=
576 XFS_BMAP_BLOCK_IMINRECS(level, tcur)); 560 XFS_BMAP_BLOCK_IMINRECS(level, tcur));
577 xfs_btree_del_cursor(tcur, XFS_BTREE_NOERROR); 561 xfs_btree_del_cursor(tcur, XFS_BTREE_NOERROR);
578 tcur = NULL; 562 tcur = NULL;
@@ -583,14 +567,14 @@ xfs_bmbt_delrec(
583 return 0; 567 return 0;
584 } 568 }
585 } 569 }
586 lrecs = INT_GET(left->bb_numrecs, ARCH_CONVERT); 570 lrecs = be16_to_cpu(left->bb_numrecs);
587 } 571 }
588 xfs_btree_del_cursor(tcur, XFS_BTREE_NOERROR); 572 xfs_btree_del_cursor(tcur, XFS_BTREE_NOERROR);
589 tcur = NULL; 573 tcur = NULL;
590 mp = cur->bc_mp; 574 mp = cur->bc_mp;
591 ASSERT(bno != NULLFSBLOCK); 575 ASSERT(bno != NULLFSBLOCK);
592 if (lbno != NULLFSBLOCK && 576 if (lbno != NULLFSBLOCK &&
593 lrecs + INT_GET(block->bb_numrecs, ARCH_CONVERT) <= XFS_BMAP_BLOCK_IMAXRECS(level, cur)) { 577 lrecs + be16_to_cpu(block->bb_numrecs) <= XFS_BMAP_BLOCK_IMAXRECS(level, cur)) {
594 rbno = bno; 578 rbno = bno;
595 right = block; 579 right = block;
596 rbp = bp; 580 rbp = bp;
@@ -605,7 +589,7 @@ xfs_bmbt_delrec(
605 goto error0; 589 goto error0;
606 } 590 }
607 } else if (rbno != NULLFSBLOCK && 591 } else if (rbno != NULLFSBLOCK &&
608 rrecs + INT_GET(block->bb_numrecs, ARCH_CONVERT) <= 592 rrecs + be16_to_cpu(block->bb_numrecs) <=
609 XFS_BMAP_BLOCK_IMAXRECS(level, cur)) { 593 XFS_BMAP_BLOCK_IMAXRECS(level, cur)) {
610 lbno = bno; 594 lbno = bno;
611 left = block; 595 left = block;
@@ -620,7 +604,7 @@ xfs_bmbt_delrec(
620 XFS_BMBT_TRACE_CURSOR(cur, ERROR); 604 XFS_BMBT_TRACE_CURSOR(cur, ERROR);
621 goto error0; 605 goto error0;
622 } 606 }
623 lrecs = INT_GET(left->bb_numrecs, ARCH_CONVERT); 607 lrecs = be16_to_cpu(left->bb_numrecs);
624 } else { 608 } else {
625 if (level > 0 && (error = xfs_bmbt_decrement(cur, level, &i))) { 609 if (level > 0 && (error = xfs_bmbt_decrement(cur, level, &i))) {
626 XFS_BMBT_TRACE_CURSOR(cur, ERROR); 610 XFS_BMBT_TRACE_CURSOR(cur, ERROR);
@@ -630,8 +614,8 @@ xfs_bmbt_delrec(
630 *stat = 1; 614 *stat = 1;
631 return 0; 615 return 0;
632 } 616 }
633 numlrecs = INT_GET(left->bb_numrecs, ARCH_CONVERT); 617 numlrecs = be16_to_cpu(left->bb_numrecs);
634 numrrecs = INT_GET(right->bb_numrecs, ARCH_CONVERT); 618 numrrecs = be16_to_cpu(right->bb_numrecs);
635 if (level > 0) { 619 if (level > 0) {
636 lkp = XFS_BMAP_KEY_IADDR(left, numlrecs + 1, cur); 620 lkp = XFS_BMAP_KEY_IADDR(left, numlrecs + 1, cur);
637 lpp = XFS_BMAP_PTR_IADDR(left, numlrecs + 1, cur); 621 lpp = XFS_BMAP_PTR_IADDR(left, numlrecs + 1, cur);
@@ -655,12 +639,12 @@ xfs_bmbt_delrec(
655 memcpy(lrp, rrp, numrrecs * sizeof(*lrp)); 639 memcpy(lrp, rrp, numrrecs * sizeof(*lrp));
656 xfs_bmbt_log_recs(cur, lbp, numlrecs + 1, numlrecs + numrrecs); 640 xfs_bmbt_log_recs(cur, lbp, numlrecs + 1, numlrecs + numrrecs);
657 } 641 }
658 INT_MOD(left->bb_numrecs, ARCH_CONVERT, numrrecs); 642 be16_add(&left->bb_numrecs, numrrecs);
659 left->bb_rightsib = right->bb_rightsib; /* INT_: direct copy */ 643 left->bb_rightsib = right->bb_rightsib;
660 xfs_bmbt_log_block(cur, lbp, XFS_BB_RIGHTSIB | XFS_BB_NUMRECS); 644 xfs_bmbt_log_block(cur, lbp, XFS_BB_RIGHTSIB | XFS_BB_NUMRECS);
661 if (INT_GET(left->bb_rightsib, ARCH_CONVERT) != NULLDFSBNO) { 645 if (be64_to_cpu(left->bb_rightsib) != NULLDFSBNO) {
662 if ((error = xfs_btree_read_bufl(mp, cur->bc_tp, 646 if ((error = xfs_btree_read_bufl(mp, cur->bc_tp,
663 INT_GET(left->bb_rightsib, ARCH_CONVERT), 647 be64_to_cpu(left->bb_rightsib),
664 0, &rrbp, XFS_BMAP_BTREE_REF))) { 648 0, &rrbp, XFS_BMAP_BTREE_REF))) {
665 XFS_BMBT_TRACE_CURSOR(cur, ERROR); 649 XFS_BMBT_TRACE_CURSOR(cur, ERROR);
666 goto error0; 650 goto error0;
@@ -670,7 +654,7 @@ xfs_bmbt_delrec(
670 XFS_BMBT_TRACE_CURSOR(cur, ERROR); 654 XFS_BMBT_TRACE_CURSOR(cur, ERROR);
671 goto error0; 655 goto error0;
672 } 656 }
673 INT_SET(rrblock->bb_leftsib, ARCH_CONVERT, lbno); 657 rrblock->bb_leftsib = cpu_to_be64(lbno);
674 xfs_bmbt_log_block(cur, rrbp, XFS_BB_LEFTSIB); 658 xfs_bmbt_log_block(cur, rrbp, XFS_BB_LEFTSIB);
675 } 659 }
676 xfs_bmap_add_free(XFS_DADDR_TO_FSB(mp, XFS_BUF_ADDR(rbp)), 1, 660 xfs_bmap_add_free(XFS_DADDR_TO_FSB(mp, XFS_BUF_ADDR(rbp)), 1,
@@ -727,7 +711,7 @@ xfs_bmbt_get_rec(
727 if ((error = xfs_btree_check_lblock(cur, block, 0, bp))) 711 if ((error = xfs_btree_check_lblock(cur, block, 0, bp)))
728 return error; 712 return error;
729#endif 713#endif
730 if (ptr > INT_GET(block->bb_numrecs, ARCH_CONVERT) || ptr <= 0) { 714 if (ptr > be16_to_cpu(block->bb_numrecs) || ptr <= 0) {
731 *stat = 0; 715 *stat = 0;
732 return 0; 716 return 0;
733 } 717 }
@@ -788,7 +772,7 @@ xfs_bmbt_insrec(
788 } 772 }
789 XFS_STATS_INC(xs_bmbt_insrec); 773 XFS_STATS_INC(xs_bmbt_insrec);
790 block = xfs_bmbt_get_block(cur, level, &bp); 774 block = xfs_bmbt_get_block(cur, level, &bp);
791 numrecs = INT_GET(block->bb_numrecs, ARCH_CONVERT); 775 numrecs = be16_to_cpu(block->bb_numrecs);
792#ifdef DEBUG 776#ifdef DEBUG
793 if ((error = xfs_btree_check_lblock(cur, block, level, bp))) { 777 if ((error = xfs_btree_check_lblock(cur, block, level, bp))) {
794 XFS_BMBT_TRACE_CURSOR(cur, ERROR); 778 XFS_BMBT_TRACE_CURSOR(cur, ERROR);
@@ -870,7 +854,7 @@ xfs_bmbt_insrec(
870 } 854 }
871 } 855 }
872 } 856 }
873 numrecs = INT_GET(block->bb_numrecs, ARCH_CONVERT); 857 numrecs = be16_to_cpu(block->bb_numrecs);
874 if (level > 0) { 858 if (level > 0) {
875 kp = XFS_BMAP_KEY_IADDR(block, 1, cur); 859 kp = XFS_BMAP_KEY_IADDR(block, 1, cur);
876 pp = XFS_BMAP_PTR_IADDR(block, 1, cur); 860 pp = XFS_BMAP_PTR_IADDR(block, 1, cur);
@@ -897,7 +881,7 @@ xfs_bmbt_insrec(
897 kp[ptr - 1] = key; 881 kp[ptr - 1] = key;
898 INT_SET(pp[ptr - 1], ARCH_CONVERT, *bnop); 882 INT_SET(pp[ptr - 1], ARCH_CONVERT, *bnop);
899 numrecs++; 883 numrecs++;
900 INT_SET(block->bb_numrecs, ARCH_CONVERT, numrecs); 884 block->bb_numrecs = cpu_to_be16(numrecs);
901 xfs_bmbt_log_keys(cur, bp, ptr, numrecs); 885 xfs_bmbt_log_keys(cur, bp, ptr, numrecs);
902 xfs_bmbt_log_ptrs(cur, bp, ptr, numrecs); 886 xfs_bmbt_log_ptrs(cur, bp, ptr, numrecs);
903 } else { 887 } else {
@@ -906,7 +890,7 @@ xfs_bmbt_insrec(
906 (numrecs - ptr + 1) * sizeof(*rp)); 890 (numrecs - ptr + 1) * sizeof(*rp));
907 rp[ptr - 1] = *recp; 891 rp[ptr - 1] = *recp;
908 numrecs++; 892 numrecs++;
909 INT_SET(block->bb_numrecs, ARCH_CONVERT, numrecs); 893 block->bb_numrecs = cpu_to_be16(numrecs);
910 xfs_bmbt_log_recs(cur, bp, ptr, numrecs); 894 xfs_bmbt_log_recs(cur, bp, ptr, numrecs);
911 } 895 }
912 xfs_bmbt_log_block(cur, bp, XFS_BB_NUMRECS); 896 xfs_bmbt_log_block(cur, bp, XFS_BB_NUMRECS);
@@ -971,7 +955,7 @@ xfs_bmbt_killroot(
971 /* 955 /*
972 * Give up if the root has multiple children. 956 * Give up if the root has multiple children.
973 */ 957 */
974 if (INT_GET(block->bb_numrecs, ARCH_CONVERT) != 1) { 958 if (be16_to_cpu(block->bb_numrecs) != 1) {
975 XFS_BMBT_TRACE_CURSOR(cur, EXIT); 959 XFS_BMBT_TRACE_CURSOR(cur, EXIT);
976 return 0; 960 return 0;
977 } 961 }
@@ -982,37 +966,37 @@ xfs_bmbt_killroot(
982 */ 966 */
983 cbp = cur->bc_bufs[level - 1]; 967 cbp = cur->bc_bufs[level - 1];
984 cblock = XFS_BUF_TO_BMBT_BLOCK(cbp); 968 cblock = XFS_BUF_TO_BMBT_BLOCK(cbp);
985 if (INT_GET(cblock->bb_numrecs, ARCH_CONVERT) > XFS_BMAP_BLOCK_DMAXRECS(level, cur)) { 969 if (be16_to_cpu(cblock->bb_numrecs) > XFS_BMAP_BLOCK_DMAXRECS(level, cur)) {
986 XFS_BMBT_TRACE_CURSOR(cur, EXIT); 970 XFS_BMBT_TRACE_CURSOR(cur, EXIT);
987 return 0; 971 return 0;
988 } 972 }
989 ASSERT(INT_GET(cblock->bb_leftsib, ARCH_CONVERT) == NULLDFSBNO); 973 ASSERT(be64_to_cpu(cblock->bb_leftsib) == NULLDFSBNO);
990 ASSERT(INT_GET(cblock->bb_rightsib, ARCH_CONVERT) == NULLDFSBNO); 974 ASSERT(be64_to_cpu(cblock->bb_rightsib) == NULLDFSBNO);
991 ip = cur->bc_private.b.ip; 975 ip = cur->bc_private.b.ip;
992 ifp = XFS_IFORK_PTR(ip, cur->bc_private.b.whichfork); 976 ifp = XFS_IFORK_PTR(ip, cur->bc_private.b.whichfork);
993 ASSERT(XFS_BMAP_BLOCK_IMAXRECS(level, cur) == 977 ASSERT(XFS_BMAP_BLOCK_IMAXRECS(level, cur) ==
994 XFS_BMAP_BROOT_MAXRECS(ifp->if_broot_bytes)); 978 XFS_BMAP_BROOT_MAXRECS(ifp->if_broot_bytes));
995 i = (int)(INT_GET(cblock->bb_numrecs, ARCH_CONVERT) - XFS_BMAP_BLOCK_IMAXRECS(level, cur)); 979 i = (int)(be16_to_cpu(cblock->bb_numrecs) - XFS_BMAP_BLOCK_IMAXRECS(level, cur));
996 if (i) { 980 if (i) {
997 xfs_iroot_realloc(ip, i, cur->bc_private.b.whichfork); 981 xfs_iroot_realloc(ip, i, cur->bc_private.b.whichfork);
998 block = ifp->if_broot; 982 block = ifp->if_broot;
999 } 983 }
1000 INT_MOD(block->bb_numrecs, ARCH_CONVERT, i); 984 be16_add(&block->bb_numrecs, i);
1001 ASSERT(INT_GET(block->bb_numrecs, ARCH_CONVERT) == INT_GET(cblock->bb_numrecs, ARCH_CONVERT)); 985 ASSERT(block->bb_numrecs == cblock->bb_numrecs);
1002 kp = XFS_BMAP_KEY_IADDR(block, 1, cur); 986 kp = XFS_BMAP_KEY_IADDR(block, 1, cur);
1003 ckp = XFS_BMAP_KEY_IADDR(cblock, 1, cur); 987 ckp = XFS_BMAP_KEY_IADDR(cblock, 1, cur);
1004 memcpy(kp, ckp, INT_GET(block->bb_numrecs, ARCH_CONVERT) * sizeof(*kp)); 988 memcpy(kp, ckp, be16_to_cpu(block->bb_numrecs) * sizeof(*kp));
1005 pp = XFS_BMAP_PTR_IADDR(block, 1, cur); 989 pp = XFS_BMAP_PTR_IADDR(block, 1, cur);
1006 cpp = XFS_BMAP_PTR_IADDR(cblock, 1, cur); 990 cpp = XFS_BMAP_PTR_IADDR(cblock, 1, cur);
1007#ifdef DEBUG 991#ifdef DEBUG
1008 for (i = 0; i < INT_GET(cblock->bb_numrecs, ARCH_CONVERT); i++) { 992 for (i = 0; i < be16_to_cpu(cblock->bb_numrecs); i++) {
1009 if ((error = xfs_btree_check_lptr(cur, INT_GET(cpp[i], ARCH_CONVERT), level - 1))) { 993 if ((error = xfs_btree_check_lptr(cur, INT_GET(cpp[i], ARCH_CONVERT), level - 1))) {
1010 XFS_BMBT_TRACE_CURSOR(cur, ERROR); 994 XFS_BMBT_TRACE_CURSOR(cur, ERROR);
1011 return error; 995 return error;
1012 } 996 }
1013 } 997 }
1014#endif 998#endif
1015 memcpy(pp, cpp, INT_GET(block->bb_numrecs, ARCH_CONVERT) * sizeof(*pp)); 999 memcpy(pp, cpp, be16_to_cpu(block->bb_numrecs) * sizeof(*pp));
1016 xfs_bmap_add_free(XFS_DADDR_TO_FSB(cur->bc_mp, XFS_BUF_ADDR(cbp)), 1, 1000 xfs_bmap_add_free(XFS_DADDR_TO_FSB(cur->bc_mp, XFS_BUF_ADDR(cbp)), 1,
1017 cur->bc_private.b.flist, cur->bc_mp); 1001 cur->bc_private.b.flist, cur->bc_mp);
1018 ip->i_d.di_nblocks--; 1002 ip->i_d.di_nblocks--;
@@ -1020,7 +1004,7 @@ xfs_bmbt_killroot(
1020 XFS_TRANS_DQ_BCOUNT, -1L); 1004 XFS_TRANS_DQ_BCOUNT, -1L);
1021 xfs_trans_binval(cur->bc_tp, cbp); 1005 xfs_trans_binval(cur->bc_tp, cbp);
1022 cur->bc_bufs[level - 1] = NULL; 1006 cur->bc_bufs[level - 1] = NULL;
1023 INT_MOD(block->bb_level, ARCH_CONVERT, -1); 1007 be16_add(&block->bb_level, -1);
1024 xfs_trans_log_inode(cur->bc_tp, ip, 1008 xfs_trans_log_inode(cur->bc_tp, ip,
1025 XFS_ILOG_CORE | XFS_ILOG_FBROOT(cur->bc_private.b.whichfork)); 1009 XFS_ILOG_CORE | XFS_ILOG_FBROOT(cur->bc_private.b.whichfork));
1026 cur->bc_nlevels--; 1010 cur->bc_nlevels--;
@@ -1176,7 +1160,7 @@ xfs_bmbt_lookup(
1176 else 1160 else
1177 krbase = XFS_BMAP_REC_IADDR(block, 1, cur); 1161 krbase = XFS_BMAP_REC_IADDR(block, 1, cur);
1178 low = 1; 1162 low = 1;
1179 if (!(high = INT_GET(block->bb_numrecs, ARCH_CONVERT))) { 1163 if (!(high = be16_to_cpu(block->bb_numrecs))) {
1180 ASSERT(level == 0); 1164 ASSERT(level == 0);
1181 cur->bc_ptrs[0] = dir != XFS_LOOKUP_LE; 1165 cur->bc_ptrs[0] = dir != XFS_LOOKUP_LE;
1182 XFS_BMBT_TRACE_CURSOR(cur, EXIT); 1166 XFS_BMBT_TRACE_CURSOR(cur, EXIT);
@@ -1223,8 +1207,8 @@ xfs_bmbt_lookup(
1223 * If ge search and we went off the end of the block, but it's 1207 * If ge search and we went off the end of the block, but it's
1224 * not the last block, we're in the wrong block. 1208 * not the last block, we're in the wrong block.
1225 */ 1209 */
1226 if (dir == XFS_LOOKUP_GE && keyno > INT_GET(block->bb_numrecs, ARCH_CONVERT) && 1210 if (dir == XFS_LOOKUP_GE && keyno > be16_to_cpu(block->bb_numrecs) &&
1227 INT_GET(block->bb_rightsib, ARCH_CONVERT) != NULLDFSBNO) { 1211 be64_to_cpu(block->bb_rightsib) != NULLDFSBNO) {
1228 cur->bc_ptrs[0] = keyno; 1212 cur->bc_ptrs[0] = keyno;
1229 if ((error = xfs_bmbt_increment(cur, 0, &i))) { 1213 if ((error = xfs_bmbt_increment(cur, 0, &i))) {
1230 XFS_BMBT_TRACE_CURSOR(cur, ERROR); 1214 XFS_BMBT_TRACE_CURSOR(cur, ERROR);
@@ -1239,7 +1223,7 @@ xfs_bmbt_lookup(
1239 else if (dir == XFS_LOOKUP_LE && diff > 0) 1223 else if (dir == XFS_LOOKUP_LE && diff > 0)
1240 keyno--; 1224 keyno--;
1241 cur->bc_ptrs[0] = keyno; 1225 cur->bc_ptrs[0] = keyno;
1242 if (keyno == 0 || keyno > INT_GET(block->bb_numrecs, ARCH_CONVERT)) { 1226 if (keyno == 0 || keyno > be16_to_cpu(block->bb_numrecs)) {
1243 XFS_BMBT_TRACE_CURSOR(cur, EXIT); 1227 XFS_BMBT_TRACE_CURSOR(cur, EXIT);
1244 *stat = 0; 1228 *stat = 0;
1245 } else { 1229 } else {
@@ -1296,7 +1280,7 @@ xfs_bmbt_lshift(
1296 return error; 1280 return error;
1297 } 1281 }
1298#endif 1282#endif
1299 if (INT_GET(right->bb_leftsib, ARCH_CONVERT) == NULLDFSBNO) { 1283 if (be64_to_cpu(right->bb_leftsib) == NULLDFSBNO) {
1300 XFS_BMBT_TRACE_CURSOR(cur, EXIT); 1284 XFS_BMBT_TRACE_CURSOR(cur, EXIT);
1301 *stat = 0; 1285 *stat = 0;
1302 return 0; 1286 return 0;
@@ -1307,7 +1291,7 @@ xfs_bmbt_lshift(
1307 return 0; 1291 return 0;
1308 } 1292 }
1309 mp = cur->bc_mp; 1293 mp = cur->bc_mp;
1310 if ((error = xfs_btree_read_bufl(mp, cur->bc_tp, INT_GET(right->bb_leftsib, ARCH_CONVERT), 0, 1294 if ((error = xfs_btree_read_bufl(mp, cur->bc_tp, be64_to_cpu(right->bb_leftsib), 0,
1311 &lbp, XFS_BMAP_BTREE_REF))) { 1295 &lbp, XFS_BMAP_BTREE_REF))) {
1312 XFS_BMBT_TRACE_CURSOR(cur, ERROR); 1296 XFS_BMBT_TRACE_CURSOR(cur, ERROR);
1313 return error; 1297 return error;
@@ -1317,12 +1301,12 @@ xfs_bmbt_lshift(
1317 XFS_BMBT_TRACE_CURSOR(cur, ERROR); 1301 XFS_BMBT_TRACE_CURSOR(cur, ERROR);
1318 return error; 1302 return error;
1319 } 1303 }
1320 if (INT_GET(left->bb_numrecs, ARCH_CONVERT) == XFS_BMAP_BLOCK_IMAXRECS(level, cur)) { 1304 if (be16_to_cpu(left->bb_numrecs) == XFS_BMAP_BLOCK_IMAXRECS(level, cur)) {
1321 XFS_BMBT_TRACE_CURSOR(cur, EXIT); 1305 XFS_BMBT_TRACE_CURSOR(cur, EXIT);
1322 *stat = 0; 1306 *stat = 0;
1323 return 0; 1307 return 0;
1324 } 1308 }
1325 lrecs = INT_GET(left->bb_numrecs, ARCH_CONVERT) + 1; 1309 lrecs = be16_to_cpu(left->bb_numrecs) + 1;
1326 if (level > 0) { 1310 if (level > 0) {
1327 lkp = XFS_BMAP_KEY_IADDR(left, lrecs, cur); 1311 lkp = XFS_BMAP_KEY_IADDR(left, lrecs, cur);
1328 rkp = XFS_BMAP_KEY_IADDR(right, 1, cur); 1312 rkp = XFS_BMAP_KEY_IADDR(right, 1, cur);
@@ -1344,7 +1328,7 @@ xfs_bmbt_lshift(
1344 *lrp = *rrp; 1328 *lrp = *rrp;
1345 xfs_bmbt_log_recs(cur, lbp, lrecs, lrecs); 1329 xfs_bmbt_log_recs(cur, lbp, lrecs, lrecs);
1346 } 1330 }
1347 INT_SET(left->bb_numrecs, ARCH_CONVERT, lrecs); 1331 left->bb_numrecs = cpu_to_be16(lrecs);
1348 xfs_bmbt_log_block(cur, lbp, XFS_BB_NUMRECS); 1332 xfs_bmbt_log_block(cur, lbp, XFS_BB_NUMRECS);
1349#ifdef DEBUG 1333#ifdef DEBUG
1350 if (level > 0) 1334 if (level > 0)
@@ -1352,8 +1336,8 @@ xfs_bmbt_lshift(
1352 else 1336 else
1353 xfs_btree_check_rec(XFS_BTNUM_BMAP, lrp - 1, lrp); 1337 xfs_btree_check_rec(XFS_BTNUM_BMAP, lrp - 1, lrp);
1354#endif 1338#endif
1355 rrecs = INT_GET(right->bb_numrecs, ARCH_CONVERT) - 1; 1339 rrecs = be16_to_cpu(right->bb_numrecs) - 1;
1356 INT_SET(right->bb_numrecs, ARCH_CONVERT, rrecs); 1340 right->bb_numrecs = cpu_to_be16(rrecs);
1357 xfs_bmbt_log_block(cur, rbp, XFS_BB_NUMRECS); 1341 xfs_bmbt_log_block(cur, rbp, XFS_BB_NUMRECS);
1358 if (level > 0) { 1342 if (level > 0) {
1359#ifdef DEBUG 1343#ifdef DEBUG
@@ -1430,18 +1414,18 @@ xfs_bmbt_rshift(
1430 return error; 1414 return error;
1431 } 1415 }
1432#endif 1416#endif
1433 if (INT_GET(left->bb_rightsib, ARCH_CONVERT) == NULLDFSBNO) { 1417 if (be64_to_cpu(left->bb_rightsib) == NULLDFSBNO) {
1434 XFS_BMBT_TRACE_CURSOR(cur, EXIT); 1418 XFS_BMBT_TRACE_CURSOR(cur, EXIT);
1435 *stat = 0; 1419 *stat = 0;
1436 return 0; 1420 return 0;
1437 } 1421 }
1438 if (cur->bc_ptrs[level] >= INT_GET(left->bb_numrecs, ARCH_CONVERT)) { 1422 if (cur->bc_ptrs[level] >= be16_to_cpu(left->bb_numrecs)) {
1439 XFS_BMBT_TRACE_CURSOR(cur, EXIT); 1423 XFS_BMBT_TRACE_CURSOR(cur, EXIT);
1440 *stat = 0; 1424 *stat = 0;
1441 return 0; 1425 return 0;
1442 } 1426 }
1443 mp = cur->bc_mp; 1427 mp = cur->bc_mp;
1444 if ((error = xfs_btree_read_bufl(mp, cur->bc_tp, INT_GET(left->bb_rightsib, ARCH_CONVERT), 0, 1428 if ((error = xfs_btree_read_bufl(mp, cur->bc_tp, be64_to_cpu(left->bb_rightsib), 0,
1445 &rbp, XFS_BMAP_BTREE_REF))) { 1429 &rbp, XFS_BMAP_BTREE_REF))) {
1446 XFS_BMBT_TRACE_CURSOR(cur, ERROR); 1430 XFS_BMBT_TRACE_CURSOR(cur, ERROR);
1447 return error; 1431 return error;
@@ -1451,26 +1435,26 @@ xfs_bmbt_rshift(
1451 XFS_BMBT_TRACE_CURSOR(cur, ERROR); 1435 XFS_BMBT_TRACE_CURSOR(cur, ERROR);
1452 return error; 1436 return error;
1453 } 1437 }
1454 if (INT_GET(right->bb_numrecs, ARCH_CONVERT) == XFS_BMAP_BLOCK_IMAXRECS(level, cur)) { 1438 if (be16_to_cpu(right->bb_numrecs) == XFS_BMAP_BLOCK_IMAXRECS(level, cur)) {
1455 XFS_BMBT_TRACE_CURSOR(cur, EXIT); 1439 XFS_BMBT_TRACE_CURSOR(cur, EXIT);
1456 *stat = 0; 1440 *stat = 0;
1457 return 0; 1441 return 0;
1458 } 1442 }
1459 if (level > 0) { 1443 if (level > 0) {
1460 lkp = XFS_BMAP_KEY_IADDR(left, INT_GET(left->bb_numrecs, ARCH_CONVERT), cur); 1444 lkp = XFS_BMAP_KEY_IADDR(left, be16_to_cpu(left->bb_numrecs), cur);
1461 lpp = XFS_BMAP_PTR_IADDR(left, INT_GET(left->bb_numrecs, ARCH_CONVERT), cur); 1445 lpp = XFS_BMAP_PTR_IADDR(left, be16_to_cpu(left->bb_numrecs), cur);
1462 rkp = XFS_BMAP_KEY_IADDR(right, 1, cur); 1446 rkp = XFS_BMAP_KEY_IADDR(right, 1, cur);
1463 rpp = XFS_BMAP_PTR_IADDR(right, 1, cur); 1447 rpp = XFS_BMAP_PTR_IADDR(right, 1, cur);
1464#ifdef DEBUG 1448#ifdef DEBUG
1465 for (i = INT_GET(right->bb_numrecs, ARCH_CONVERT) - 1; i >= 0; i--) { 1449 for (i = be16_to_cpu(right->bb_numrecs) - 1; i >= 0; i--) {
1466 if ((error = xfs_btree_check_lptr(cur, INT_GET(rpp[i], ARCH_CONVERT), level))) { 1450 if ((error = xfs_btree_check_lptr(cur, INT_GET(rpp[i], ARCH_CONVERT), level))) {
1467 XFS_BMBT_TRACE_CURSOR(cur, ERROR); 1451 XFS_BMBT_TRACE_CURSOR(cur, ERROR);
1468 return error; 1452 return error;
1469 } 1453 }
1470 } 1454 }
1471#endif 1455#endif
1472 memmove(rkp + 1, rkp, INT_GET(right->bb_numrecs, ARCH_CONVERT) * sizeof(*rkp)); 1456 memmove(rkp + 1, rkp, be16_to_cpu(right->bb_numrecs) * sizeof(*rkp));
1473 memmove(rpp + 1, rpp, INT_GET(right->bb_numrecs, ARCH_CONVERT) * sizeof(*rpp)); 1457 memmove(rpp + 1, rpp, be16_to_cpu(right->bb_numrecs) * sizeof(*rpp));
1474#ifdef DEBUG 1458#ifdef DEBUG
1475 if ((error = xfs_btree_check_lptr(cur, INT_GET(*lpp, ARCH_CONVERT), level))) { 1459 if ((error = xfs_btree_check_lptr(cur, INT_GET(*lpp, ARCH_CONVERT), level))) {
1476 XFS_BMBT_TRACE_CURSOR(cur, ERROR); 1460 XFS_BMBT_TRACE_CURSOR(cur, ERROR);
@@ -1479,21 +1463,21 @@ xfs_bmbt_rshift(
1479#endif 1463#endif
1480 *rkp = *lkp; 1464 *rkp = *lkp;
1481 *rpp = *lpp; /* INT_: direct copy */ 1465 *rpp = *lpp; /* INT_: direct copy */
1482 xfs_bmbt_log_keys(cur, rbp, 1, INT_GET(right->bb_numrecs, ARCH_CONVERT) + 1); 1466 xfs_bmbt_log_keys(cur, rbp, 1, be16_to_cpu(right->bb_numrecs) + 1);
1483 xfs_bmbt_log_ptrs(cur, rbp, 1, INT_GET(right->bb_numrecs, ARCH_CONVERT) + 1); 1467 xfs_bmbt_log_ptrs(cur, rbp, 1, be16_to_cpu(right->bb_numrecs) + 1);
1484 } else { 1468 } else {
1485 lrp = XFS_BMAP_REC_IADDR(left, INT_GET(left->bb_numrecs, ARCH_CONVERT), cur); 1469 lrp = XFS_BMAP_REC_IADDR(left, be16_to_cpu(left->bb_numrecs), cur);
1486 rrp = XFS_BMAP_REC_IADDR(right, 1, cur); 1470 rrp = XFS_BMAP_REC_IADDR(right, 1, cur);
1487 memmove(rrp + 1, rrp, INT_GET(right->bb_numrecs, ARCH_CONVERT) * sizeof(*rrp)); 1471 memmove(rrp + 1, rrp, be16_to_cpu(right->bb_numrecs) * sizeof(*rrp));
1488 *rrp = *lrp; 1472 *rrp = *lrp;
1489 xfs_bmbt_log_recs(cur, rbp, 1, INT_GET(right->bb_numrecs, ARCH_CONVERT) + 1); 1473 xfs_bmbt_log_recs(cur, rbp, 1, be16_to_cpu(right->bb_numrecs) + 1);
1490 INT_SET(key.br_startoff, ARCH_CONVERT, 1474 INT_SET(key.br_startoff, ARCH_CONVERT,
1491 xfs_bmbt_disk_get_startoff(rrp)); 1475 xfs_bmbt_disk_get_startoff(rrp));
1492 rkp = &key; 1476 rkp = &key;
1493 } 1477 }
1494 INT_MOD(left->bb_numrecs, ARCH_CONVERT, -1); 1478 be16_add(&left->bb_numrecs, -1);
1495 xfs_bmbt_log_block(cur, lbp, XFS_BB_NUMRECS); 1479 xfs_bmbt_log_block(cur, lbp, XFS_BB_NUMRECS);
1496 INT_MOD(right->bb_numrecs, ARCH_CONVERT, +1); 1480 be16_add(&right->bb_numrecs, 1);
1497#ifdef DEBUG 1481#ifdef DEBUG
1498 if (level > 0) 1482 if (level > 0)
1499 xfs_btree_check_key(XFS_BTNUM_BMAP, rkp, rkp + 1); 1483 xfs_btree_check_key(XFS_BTNUM_BMAP, rkp, rkp + 1);
@@ -1624,47 +1608,47 @@ xfs_bmbt_split(
1624 return error; 1608 return error;
1625 } 1609 }
1626#endif 1610#endif
1627 INT_SET(right->bb_magic, ARCH_CONVERT, XFS_BMAP_MAGIC); 1611 right->bb_magic = cpu_to_be32(XFS_BMAP_MAGIC);
1628 right->bb_level = left->bb_level; /* INT_: direct copy */ 1612 right->bb_level = left->bb_level;
1629 INT_SET(right->bb_numrecs, ARCH_CONVERT, (__uint16_t)(INT_GET(left->bb_numrecs, ARCH_CONVERT) / 2)); 1613 right->bb_numrecs = cpu_to_be16(be16_to_cpu(left->bb_numrecs) / 2);
1630 if ((INT_GET(left->bb_numrecs, ARCH_CONVERT) & 1) && 1614 if ((be16_to_cpu(left->bb_numrecs) & 1) &&
1631 cur->bc_ptrs[level] <= INT_GET(right->bb_numrecs, ARCH_CONVERT) + 1) 1615 cur->bc_ptrs[level] <= be16_to_cpu(right->bb_numrecs) + 1)
1632 INT_MOD(right->bb_numrecs, ARCH_CONVERT, +1); 1616 be16_add(&right->bb_numrecs, 1);
1633 i = INT_GET(left->bb_numrecs, ARCH_CONVERT) - INT_GET(right->bb_numrecs, ARCH_CONVERT) + 1; 1617 i = be16_to_cpu(left->bb_numrecs) - be16_to_cpu(right->bb_numrecs) + 1;
1634 if (level > 0) { 1618 if (level > 0) {
1635 lkp = XFS_BMAP_KEY_IADDR(left, i, cur); 1619 lkp = XFS_BMAP_KEY_IADDR(left, i, cur);
1636 lpp = XFS_BMAP_PTR_IADDR(left, i, cur); 1620 lpp = XFS_BMAP_PTR_IADDR(left, i, cur);
1637 rkp = XFS_BMAP_KEY_IADDR(right, 1, cur); 1621 rkp = XFS_BMAP_KEY_IADDR(right, 1, cur);
1638 rpp = XFS_BMAP_PTR_IADDR(right, 1, cur); 1622 rpp = XFS_BMAP_PTR_IADDR(right, 1, cur);
1639#ifdef DEBUG 1623#ifdef DEBUG
1640 for (i = 0; i < INT_GET(right->bb_numrecs, ARCH_CONVERT); i++) { 1624 for (i = 0; i < be16_to_cpu(right->bb_numrecs); i++) {
1641 if ((error = xfs_btree_check_lptr(cur, INT_GET(lpp[i], ARCH_CONVERT), level))) { 1625 if ((error = xfs_btree_check_lptr(cur, INT_GET(lpp[i], ARCH_CONVERT), level))) {
1642 XFS_BMBT_TRACE_CURSOR(cur, ERROR); 1626 XFS_BMBT_TRACE_CURSOR(cur, ERROR);
1643 return error; 1627 return error;
1644 } 1628 }
1645 } 1629 }
1646#endif 1630#endif
1647 memcpy(rkp, lkp, INT_GET(right->bb_numrecs, ARCH_CONVERT) * sizeof(*rkp)); 1631 memcpy(rkp, lkp, be16_to_cpu(right->bb_numrecs) * sizeof(*rkp));
1648 memcpy(rpp, lpp, INT_GET(right->bb_numrecs, ARCH_CONVERT) * sizeof(*rpp)); 1632 memcpy(rpp, lpp, be16_to_cpu(right->bb_numrecs) * sizeof(*rpp));
1649 xfs_bmbt_log_keys(cur, rbp, 1, INT_GET(right->bb_numrecs, ARCH_CONVERT)); 1633 xfs_bmbt_log_keys(cur, rbp, 1, be16_to_cpu(right->bb_numrecs));
1650 xfs_bmbt_log_ptrs(cur, rbp, 1, INT_GET(right->bb_numrecs, ARCH_CONVERT)); 1634 xfs_bmbt_log_ptrs(cur, rbp, 1, be16_to_cpu(right->bb_numrecs));
1651 keyp->br_startoff = INT_GET(rkp->br_startoff, ARCH_CONVERT); 1635 keyp->br_startoff = INT_GET(rkp->br_startoff, ARCH_CONVERT);
1652 } else { 1636 } else {
1653 lrp = XFS_BMAP_REC_IADDR(left, i, cur); 1637 lrp = XFS_BMAP_REC_IADDR(left, i, cur);
1654 rrp = XFS_BMAP_REC_IADDR(right, 1, cur); 1638 rrp = XFS_BMAP_REC_IADDR(right, 1, cur);
1655 memcpy(rrp, lrp, INT_GET(right->bb_numrecs, ARCH_CONVERT) * sizeof(*rrp)); 1639 memcpy(rrp, lrp, be16_to_cpu(right->bb_numrecs) * sizeof(*rrp));
1656 xfs_bmbt_log_recs(cur, rbp, 1, INT_GET(right->bb_numrecs, ARCH_CONVERT)); 1640 xfs_bmbt_log_recs(cur, rbp, 1, be16_to_cpu(right->bb_numrecs));
1657 keyp->br_startoff = xfs_bmbt_disk_get_startoff(rrp); 1641 keyp->br_startoff = xfs_bmbt_disk_get_startoff(rrp);
1658 } 1642 }
1659 INT_MOD(left->bb_numrecs, ARCH_CONVERT, -(INT_GET(right->bb_numrecs, ARCH_CONVERT))); 1643 be16_add(&left->bb_numrecs, -(be16_to_cpu(right->bb_numrecs)));
1660 right->bb_rightsib = left->bb_rightsib; /* INT_: direct copy */ 1644 right->bb_rightsib = left->bb_rightsib;
1661 INT_SET(left->bb_rightsib, ARCH_CONVERT, args.fsbno); 1645 left->bb_rightsib = cpu_to_be64(args.fsbno);
1662 INT_SET(right->bb_leftsib, ARCH_CONVERT, lbno); 1646 right->bb_leftsib = cpu_to_be64(lbno);
1663 xfs_bmbt_log_block(cur, rbp, XFS_BB_ALL_BITS); 1647 xfs_bmbt_log_block(cur, rbp, XFS_BB_ALL_BITS);
1664 xfs_bmbt_log_block(cur, lbp, XFS_BB_NUMRECS | XFS_BB_RIGHTSIB); 1648 xfs_bmbt_log_block(cur, lbp, XFS_BB_NUMRECS | XFS_BB_RIGHTSIB);
1665 if (INT_GET(right->bb_rightsib, ARCH_CONVERT) != NULLDFSBNO) { 1649 if (be64_to_cpu(right->bb_rightsib) != NULLDFSBNO) {
1666 if ((error = xfs_btree_read_bufl(args.mp, args.tp, 1650 if ((error = xfs_btree_read_bufl(args.mp, args.tp,
1667 INT_GET(right->bb_rightsib, ARCH_CONVERT), 0, &rrbp, 1651 be64_to_cpu(right->bb_rightsib), 0, &rrbp,
1668 XFS_BMAP_BTREE_REF))) { 1652 XFS_BMAP_BTREE_REF))) {
1669 XFS_BMBT_TRACE_CURSOR(cur, ERROR); 1653 XFS_BMBT_TRACE_CURSOR(cur, ERROR);
1670 return error; 1654 return error;
@@ -1674,12 +1658,12 @@ xfs_bmbt_split(
1674 XFS_BMBT_TRACE_CURSOR(cur, ERROR); 1658 XFS_BMBT_TRACE_CURSOR(cur, ERROR);
1675 return error; 1659 return error;
1676 } 1660 }
1677 INT_SET(rrblock->bb_leftsib, ARCH_CONVERT, args.fsbno); 1661 rrblock->bb_leftsib = cpu_to_be64(args.fsbno);
1678 xfs_bmbt_log_block(cur, rrbp, XFS_BB_LEFTSIB); 1662 xfs_bmbt_log_block(cur, rrbp, XFS_BB_LEFTSIB);
1679 } 1663 }
1680 if (cur->bc_ptrs[level] > INT_GET(left->bb_numrecs, ARCH_CONVERT) + 1) { 1664 if (cur->bc_ptrs[level] > be16_to_cpu(left->bb_numrecs) + 1) {
1681 xfs_btree_setbuf(cur, level, rbp); 1665 xfs_btree_setbuf(cur, level, rbp);
1682 cur->bc_ptrs[level] -= INT_GET(left->bb_numrecs, ARCH_CONVERT); 1666 cur->bc_ptrs[level] -= be16_to_cpu(left->bb_numrecs);
1683 } 1667 }
1684 if (level + 1 < cur->bc_nlevels) { 1668 if (level + 1 < cur->bc_nlevels) {
1685 if ((error = xfs_btree_dup_cursor(cur, curp))) { 1669 if ((error = xfs_btree_dup_cursor(cur, curp))) {
@@ -1751,18 +1735,18 @@ xfs_bmdr_to_bmbt(
1751 xfs_bmbt_key_t *tkp; 1735 xfs_bmbt_key_t *tkp;
1752 xfs_bmbt_ptr_t *tpp; 1736 xfs_bmbt_ptr_t *tpp;
1753 1737
1754 INT_SET(rblock->bb_magic, ARCH_CONVERT, XFS_BMAP_MAGIC); 1738 rblock->bb_magic = cpu_to_be32(XFS_BMAP_MAGIC);
1755 rblock->bb_level = dblock->bb_level; /* both in on-disk format */ 1739 rblock->bb_level = dblock->bb_level;
1756 ASSERT(INT_GET(rblock->bb_level, ARCH_CONVERT) > 0); 1740 ASSERT(be16_to_cpu(rblock->bb_level) > 0);
1757 rblock->bb_numrecs = dblock->bb_numrecs;/* both in on-disk format */ 1741 rblock->bb_numrecs = dblock->bb_numrecs;
1758 INT_SET(rblock->bb_leftsib, ARCH_CONVERT, NULLDFSBNO); 1742 rblock->bb_leftsib = cpu_to_be64(NULLDFSBNO);
1759 INT_SET(rblock->bb_rightsib, ARCH_CONVERT, NULLDFSBNO); 1743 rblock->bb_rightsib = cpu_to_be64(NULLDFSBNO);
1760 dmxr = (int)XFS_BTREE_BLOCK_MAXRECS(dblocklen, xfs_bmdr, 0); 1744 dmxr = (int)XFS_BTREE_BLOCK_MAXRECS(dblocklen, xfs_bmdr, 0);
1761 fkp = XFS_BTREE_KEY_ADDR(dblocklen, xfs_bmdr, dblock, 1, dmxr); 1745 fkp = XFS_BTREE_KEY_ADDR(dblocklen, xfs_bmdr, dblock, 1, dmxr);
1762 tkp = XFS_BMAP_BROOT_KEY_ADDR(rblock, 1, rblocklen); 1746 tkp = XFS_BMAP_BROOT_KEY_ADDR(rblock, 1, rblocklen);
1763 fpp = XFS_BTREE_PTR_ADDR(dblocklen, xfs_bmdr, dblock, 1, dmxr); 1747 fpp = XFS_BTREE_PTR_ADDR(dblocklen, xfs_bmdr, dblock, 1, dmxr);
1764 tpp = XFS_BMAP_BROOT_PTR_ADDR(rblock, 1, rblocklen); 1748 tpp = XFS_BMAP_BROOT_PTR_ADDR(rblock, 1, rblocklen);
1765 dmxr = INT_GET(dblock->bb_numrecs, ARCH_CONVERT); 1749 dmxr = be16_to_cpu(dblock->bb_numrecs);
1766 memcpy(tkp, fkp, sizeof(*fkp) * dmxr); 1750 memcpy(tkp, fkp, sizeof(*fkp) * dmxr);
1767 memcpy(tpp, fpp, sizeof(*fpp) * dmxr); /* INT_: direct copy */ 1751 memcpy(tpp, fpp, sizeof(*fpp) * dmxr); /* INT_: direct copy */
1768} 1752}
@@ -1805,7 +1789,7 @@ xfs_bmbt_decrement(
1805 return error; 1789 return error;
1806 } 1790 }
1807#endif 1791#endif
1808 if (INT_GET(block->bb_leftsib, ARCH_CONVERT) == NULLDFSBNO) { 1792 if (be64_to_cpu(block->bb_leftsib) == NULLDFSBNO) {
1809 XFS_BMBT_TRACE_CURSOR(cur, EXIT); 1793 XFS_BMBT_TRACE_CURSOR(cur, EXIT);
1810 *stat = 0; 1794 *stat = 0;
1811 return 0; 1795 return 0;
@@ -1837,7 +1821,7 @@ xfs_bmbt_decrement(
1837 XFS_BMBT_TRACE_CURSOR(cur, ERROR); 1821 XFS_BMBT_TRACE_CURSOR(cur, ERROR);
1838 return error; 1822 return error;
1839 } 1823 }
1840 cur->bc_ptrs[lev] = INT_GET(block->bb_numrecs, ARCH_CONVERT); 1824 cur->bc_ptrs[lev] = be16_to_cpu(block->bb_numrecs);
1841 } 1825 }
1842 XFS_BMBT_TRACE_CURSOR(cur, EXIT); 1826 XFS_BMBT_TRACE_CURSOR(cur, EXIT);
1843 *stat = 1; 1827 *stat = 1;
@@ -2123,12 +2107,12 @@ xfs_bmbt_increment(
2123 return error; 2107 return error;
2124 } 2108 }
2125#endif 2109#endif
2126 if (++cur->bc_ptrs[level] <= INT_GET(block->bb_numrecs, ARCH_CONVERT)) { 2110 if (++cur->bc_ptrs[level] <= be16_to_cpu(block->bb_numrecs)) {
2127 XFS_BMBT_TRACE_CURSOR(cur, EXIT); 2111 XFS_BMBT_TRACE_CURSOR(cur, EXIT);
2128 *stat = 1; 2112 *stat = 1;
2129 return 0; 2113 return 0;
2130 } 2114 }
2131 if (INT_GET(block->bb_rightsib, ARCH_CONVERT) == NULLDFSBNO) { 2115 if (be64_to_cpu(block->bb_rightsib) == NULLDFSBNO) {
2132 XFS_BMBT_TRACE_CURSOR(cur, EXIT); 2116 XFS_BMBT_TRACE_CURSOR(cur, EXIT);
2133 *stat = 0; 2117 *stat = 0;
2134 return 0; 2118 return 0;
@@ -2141,7 +2125,7 @@ xfs_bmbt_increment(
2141 return error; 2125 return error;
2142 } 2126 }
2143#endif 2127#endif
2144 if (++cur->bc_ptrs[lev] <= INT_GET(block->bb_numrecs, ARCH_CONVERT)) 2128 if (++cur->bc_ptrs[lev] <= be16_to_cpu(block->bb_numrecs))
2145 break; 2129 break;
2146 if (lev < cur->bc_nlevels - 1) 2130 if (lev < cur->bc_nlevels - 1)
2147 xfs_btree_readahead(cur, lev, XFS_BTCUR_RIGHTRA); 2131 xfs_btree_readahead(cur, lev, XFS_BTCUR_RIGHTRA);
@@ -2403,23 +2387,23 @@ xfs_bmbt_newroot(
2403 bp = xfs_btree_get_bufl(args.mp, cur->bc_tp, args.fsbno, 0); 2387 bp = xfs_btree_get_bufl(args.mp, cur->bc_tp, args.fsbno, 0);
2404 cblock = XFS_BUF_TO_BMBT_BLOCK(bp); 2388 cblock = XFS_BUF_TO_BMBT_BLOCK(bp);
2405 *cblock = *block; 2389 *cblock = *block;
2406 INT_MOD(block->bb_level, ARCH_CONVERT, +1); 2390 be16_add(&block->bb_level, 1);
2407 INT_SET(block->bb_numrecs, ARCH_CONVERT, 1); 2391 block->bb_numrecs = cpu_to_be16(1);
2408 cur->bc_nlevels++; 2392 cur->bc_nlevels++;
2409 cur->bc_ptrs[level + 1] = 1; 2393 cur->bc_ptrs[level + 1] = 1;
2410 kp = XFS_BMAP_KEY_IADDR(block, 1, cur); 2394 kp = XFS_BMAP_KEY_IADDR(block, 1, cur);
2411 ckp = XFS_BMAP_KEY_IADDR(cblock, 1, cur); 2395 ckp = XFS_BMAP_KEY_IADDR(cblock, 1, cur);
2412 memcpy(ckp, kp, INT_GET(cblock->bb_numrecs, ARCH_CONVERT) * sizeof(*kp)); 2396 memcpy(ckp, kp, be16_to_cpu(cblock->bb_numrecs) * sizeof(*kp));
2413 cpp = XFS_BMAP_PTR_IADDR(cblock, 1, cur); 2397 cpp = XFS_BMAP_PTR_IADDR(cblock, 1, cur);
2414#ifdef DEBUG 2398#ifdef DEBUG
2415 for (i = 0; i < INT_GET(cblock->bb_numrecs, ARCH_CONVERT); i++) { 2399 for (i = 0; i < be16_to_cpu(cblock->bb_numrecs); i++) {
2416 if ((error = xfs_btree_check_lptr(cur, INT_GET(pp[i], ARCH_CONVERT), level))) { 2400 if ((error = xfs_btree_check_lptr(cur, INT_GET(pp[i], ARCH_CONVERT), level))) {
2417 XFS_BMBT_TRACE_CURSOR(cur, ERROR); 2401 XFS_BMBT_TRACE_CURSOR(cur, ERROR);
2418 return error; 2402 return error;
2419 } 2403 }
2420 } 2404 }
2421#endif 2405#endif
2422 memcpy(cpp, pp, INT_GET(cblock->bb_numrecs, ARCH_CONVERT) * sizeof(*pp)); 2406 memcpy(cpp, pp, be16_to_cpu(cblock->bb_numrecs) * sizeof(*pp));
2423#ifdef DEBUG 2407#ifdef DEBUG
2424 if ((error = xfs_btree_check_lptr(cur, (xfs_bmbt_ptr_t)args.fsbno, 2408 if ((error = xfs_btree_check_lptr(cur, (xfs_bmbt_ptr_t)args.fsbno,
2425 level))) { 2409 level))) {
@@ -2428,7 +2412,7 @@ xfs_bmbt_newroot(
2428 } 2412 }
2429#endif 2413#endif
2430 INT_SET(*pp, ARCH_CONVERT, args.fsbno); 2414 INT_SET(*pp, ARCH_CONVERT, args.fsbno);
2431 xfs_iroot_realloc(cur->bc_private.b.ip, 1 - INT_GET(cblock->bb_numrecs, ARCH_CONVERT), 2415 xfs_iroot_realloc(cur->bc_private.b.ip, 1 - be16_to_cpu(cblock->bb_numrecs),
2432 cur->bc_private.b.whichfork); 2416 cur->bc_private.b.whichfork);
2433 xfs_btree_setbuf(cur, level, bp); 2417 xfs_btree_setbuf(cur, level, bp);
2434 /* 2418 /*
@@ -2436,8 +2420,8 @@ xfs_bmbt_newroot(
2436 * the root is at the right level. 2420 * the root is at the right level.
2437 */ 2421 */
2438 xfs_bmbt_log_block(cur, bp, XFS_BB_ALL_BITS); 2422 xfs_bmbt_log_block(cur, bp, XFS_BB_ALL_BITS);
2439 xfs_bmbt_log_keys(cur, bp, 1, INT_GET(cblock->bb_numrecs, ARCH_CONVERT)); 2423 xfs_bmbt_log_keys(cur, bp, 1, be16_to_cpu(cblock->bb_numrecs));
2440 xfs_bmbt_log_ptrs(cur, bp, 1, INT_GET(cblock->bb_numrecs, ARCH_CONVERT)); 2424 xfs_bmbt_log_ptrs(cur, bp, 1, be16_to_cpu(cblock->bb_numrecs));
2441 XFS_BMBT_TRACE_CURSOR(cur, EXIT); 2425 XFS_BMBT_TRACE_CURSOR(cur, EXIT);
2442 *logflags |= 2426 *logflags |=
2443 XFS_ILOG_CORE | XFS_ILOG_FBROOT(cur->bc_private.b.whichfork); 2427 XFS_ILOG_CORE | XFS_ILOG_FBROOT(cur->bc_private.b.whichfork);
@@ -2705,18 +2689,18 @@ xfs_bmbt_to_bmdr(
2705 xfs_bmbt_key_t *tkp; 2689 xfs_bmbt_key_t *tkp;
2706 xfs_bmbt_ptr_t *tpp; 2690 xfs_bmbt_ptr_t *tpp;
2707 2691
2708 ASSERT(INT_GET(rblock->bb_magic, ARCH_CONVERT) == XFS_BMAP_MAGIC); 2692 ASSERT(be32_to_cpu(rblock->bb_magic) == XFS_BMAP_MAGIC);
2709 ASSERT(INT_GET(rblock->bb_leftsib, ARCH_CONVERT) == NULLDFSBNO); 2693 ASSERT(be64_to_cpu(rblock->bb_leftsib) == NULLDFSBNO);
2710 ASSERT(INT_GET(rblock->bb_rightsib, ARCH_CONVERT) == NULLDFSBNO); 2694 ASSERT(be64_to_cpu(rblock->bb_rightsib) == NULLDFSBNO);
2711 ASSERT(INT_GET(rblock->bb_level, ARCH_CONVERT) > 0); 2695 ASSERT(be16_to_cpu(rblock->bb_level) > 0);
2712 dblock->bb_level = rblock->bb_level; /* both in on-disk format */ 2696 dblock->bb_level = rblock->bb_level;
2713 dblock->bb_numrecs = rblock->bb_numrecs;/* both in on-disk format */ 2697 dblock->bb_numrecs = rblock->bb_numrecs;
2714 dmxr = (int)XFS_BTREE_BLOCK_MAXRECS(dblocklen, xfs_bmdr, 0); 2698 dmxr = (int)XFS_BTREE_BLOCK_MAXRECS(dblocklen, xfs_bmdr, 0);
2715 fkp = XFS_BMAP_BROOT_KEY_ADDR(rblock, 1, rblocklen); 2699 fkp = XFS_BMAP_BROOT_KEY_ADDR(rblock, 1, rblocklen);
2716 tkp = XFS_BTREE_KEY_ADDR(dblocklen, xfs_bmdr, dblock, 1, dmxr); 2700 tkp = XFS_BTREE_KEY_ADDR(dblocklen, xfs_bmdr, dblock, 1, dmxr);
2717 fpp = XFS_BMAP_BROOT_PTR_ADDR(rblock, 1, rblocklen); 2701 fpp = XFS_BMAP_BROOT_PTR_ADDR(rblock, 1, rblocklen);
2718 tpp = XFS_BTREE_PTR_ADDR(dblocklen, xfs_bmdr, dblock, 1, dmxr); 2702 tpp = XFS_BTREE_PTR_ADDR(dblocklen, xfs_bmdr, dblock, 1, dmxr);
2719 dmxr = INT_GET(dblock->bb_numrecs, ARCH_CONVERT); 2703 dmxr = be16_to_cpu(dblock->bb_numrecs);
2720 memcpy(tkp, fkp, sizeof(*fkp) * dmxr); 2704 memcpy(tkp, fkp, sizeof(*fkp) * dmxr);
2721 memcpy(tpp, fpp, sizeof(*fpp) * dmxr); /* INT_: direct copy */ 2705 memcpy(tpp, fpp, sizeof(*fpp) * dmxr); /* INT_: direct copy */
2722} 2706}
diff --git a/fs/xfs/xfs_bmap_btree.h b/fs/xfs/xfs_bmap_btree.h
index 2cf4fe45cbcb..e095a2d344ae 100644
--- a/fs/xfs/xfs_bmap_btree.h
+++ b/fs/xfs/xfs_bmap_btree.h
@@ -1,33 +1,19 @@
1/* 1/*
2 * Copyright (c) 2000,2002-2004 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000,2002-2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32#ifndef __XFS_BMAP_BTREE_H__ 18#ifndef __XFS_BMAP_BTREE_H__
33#define __XFS_BMAP_BTREE_H__ 19#define __XFS_BMAP_BTREE_H__
@@ -42,10 +28,9 @@ struct xfs_inode;
42/* 28/*
43 * Bmap root header, on-disk form only. 29 * Bmap root header, on-disk form only.
44 */ 30 */
45typedef struct xfs_bmdr_block 31typedef struct xfs_bmdr_block {
46{ 32 __be16 bb_level; /* 0 is a leaf */
47 __uint16_t bb_level; /* 0 is a leaf */ 33 __be16 bb_numrecs; /* current # of data records */
48 __uint16_t bb_numrecs; /* current # of data records */
49} xfs_bmdr_block_t; 34} xfs_bmdr_block_t;
50 35
51/* 36/*
@@ -114,31 +99,31 @@ typedef xfs_bmbt_rec_64_t xfs_bmbt_rec_t, xfs_bmdr_rec_t;
114 (((((xfs_fsblock_t)1) << STARTBLOCKMASKBITS) - 1) << STARTBLOCKVALBITS) 99 (((((xfs_fsblock_t)1) << STARTBLOCKMASKBITS) - 1) << STARTBLOCKVALBITS)
115#define DSTARTBLOCKMASK \ 100#define DSTARTBLOCKMASK \
116 (((((xfs_dfsbno_t)1) << DSTARTBLOCKMASKBITS) - 1) << STARTBLOCKVALBITS) 101 (((((xfs_dfsbno_t)1) << DSTARTBLOCKMASKBITS) - 1) << STARTBLOCKVALBITS)
117#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_ISNULLSTARTBLOCK) 102
118int isnullstartblock(xfs_fsblock_t x);
119#define ISNULLSTARTBLOCK(x) isnullstartblock(x) 103#define ISNULLSTARTBLOCK(x) isnullstartblock(x)
120#else 104static inline int isnullstartblock(xfs_fsblock_t x)
121#define ISNULLSTARTBLOCK(x) (((x) & STARTBLOCKMASK) == STARTBLOCKMASK) 105{
122#endif 106 return ((x) & STARTBLOCKMASK) == STARTBLOCKMASK;
123#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_ISNULLDSTARTBLOCK) 107}
124int isnulldstartblock(xfs_dfsbno_t x); 108
125#define ISNULLDSTARTBLOCK(x) isnulldstartblock(x) 109#define ISNULLDSTARTBLOCK(x) isnulldstartblock(x)
126#else 110static inline int isnulldstartblock(xfs_dfsbno_t x)
127#define ISNULLDSTARTBLOCK(x) (((x) & DSTARTBLOCKMASK) == DSTARTBLOCKMASK) 111{
128#endif 112 return ((x) & DSTARTBLOCKMASK) == DSTARTBLOCKMASK;
129#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_NULLSTARTBLOCK) 113}
130xfs_fsblock_t nullstartblock(int k); 114
131#define NULLSTARTBLOCK(k) nullstartblock(k) 115#define NULLSTARTBLOCK(k) nullstartblock(k)
132#else 116static inline xfs_fsblock_t nullstartblock(int k)
133#define NULLSTARTBLOCK(k) \ 117{
134 ((ASSERT(k < (1 << STARTBLOCKVALBITS))), (STARTBLOCKMASK | (k))) 118 ASSERT(k < (1 << STARTBLOCKVALBITS));
135#endif 119 return STARTBLOCKMASK | (k);
136#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_STARTBLOCKVAL) 120}
137xfs_filblks_t startblockval(xfs_fsblock_t x); 121
138#define STARTBLOCKVAL(x) startblockval(x) 122#define STARTBLOCKVAL(x) startblockval(x)
139#else 123static inline xfs_filblks_t startblockval(xfs_fsblock_t x)
140#define STARTBLOCKVAL(x) ((xfs_filblks_t)((x) & ~STARTBLOCKMASK)) 124{
141#endif 125 return (xfs_filblks_t)((x) & ~STARTBLOCKMASK);
126}
142 127
143/* 128/*
144 * Possible extent formats. 129 * Possible extent formats.
@@ -159,14 +144,9 @@ typedef enum {
159/* 144/*
160 * Extent state and extent format macros. 145 * Extent state and extent format macros.
161 */ 146 */
162#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_EXTFMT_INODE ) 147#define XFS_EXTFMT_INODE(x) \
163xfs_exntfmt_t xfs_extfmt_inode(struct xfs_inode *ip); 148 (XFS_SB_VERSION_HASEXTFLGBIT(&((x)->i_mount->m_sb)) ? \
164#define XFS_EXTFMT_INODE(x) xfs_extfmt_inode(x) 149 XFS_EXTFMT_HASSTATE : XFS_EXTFMT_NOSTATE)
165#else
166#define XFS_EXTFMT_INODE(x) \
167 (XFS_SB_VERSION_HASEXTFLGBIT(&((x)->i_mount->m_sb)) ? \
168 XFS_EXTFMT_HASSTATE : XFS_EXTFMT_NOSTATE)
169#endif
170#define ISUNWRITTEN(x) ((x)->br_state == XFS_EXT_UNWRITTEN) 150#define ISUNWRITTEN(x) ((x)->br_state == XFS_EXT_UNWRITTEN)
171 151
172/* 152/*
@@ -192,248 +172,110 @@ typedef xfs_dfsbno_t xfs_bmbt_ptr_t, xfs_bmdr_ptr_t; /* btree pointer type */
192 /* btree block header type */ 172 /* btree block header type */
193typedef struct xfs_btree_lblock xfs_bmbt_block_t; 173typedef struct xfs_btree_lblock xfs_bmbt_block_t;
194 174
195#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BUF_TO_BMBT_BLOCK) 175#define XFS_BUF_TO_BMBT_BLOCK(bp) ((xfs_bmbt_block_t *)XFS_BUF_PTR(bp))
196xfs_bmbt_block_t *xfs_buf_to_bmbt_block(struct xfs_buf *bp);
197#define XFS_BUF_TO_BMBT_BLOCK(bp) xfs_buf_to_bmbt_block(bp)
198#else
199#define XFS_BUF_TO_BMBT_BLOCK(bp) ((xfs_bmbt_block_t *)(XFS_BUF_PTR(bp)))
200#endif
201 176
202#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMAP_RBLOCK_DSIZE) 177#define XFS_BMAP_IBLOCK_SIZE(lev,cur) (1 << (cur)->bc_blocklog)
203int xfs_bmap_rblock_dsize(int lev, struct xfs_btree_cur *cur); 178#define XFS_BMAP_RBLOCK_DSIZE(lev,cur) ((cur)->bc_private.b.forksize)
204#define XFS_BMAP_RBLOCK_DSIZE(lev,cur) xfs_bmap_rblock_dsize(lev,cur) 179#define XFS_BMAP_RBLOCK_ISIZE(lev,cur) \
205#else
206#define XFS_BMAP_RBLOCK_DSIZE(lev,cur) ((cur)->bc_private.b.forksize)
207#endif
208#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMAP_RBLOCK_ISIZE)
209int xfs_bmap_rblock_isize(int lev, struct xfs_btree_cur *cur);
210#define XFS_BMAP_RBLOCK_ISIZE(lev,cur) xfs_bmap_rblock_isize(lev,cur)
211#else
212#define XFS_BMAP_RBLOCK_ISIZE(lev,cur) \
213 ((int)XFS_IFORK_PTR((cur)->bc_private.b.ip, \ 180 ((int)XFS_IFORK_PTR((cur)->bc_private.b.ip, \
214 (cur)->bc_private.b.whichfork)->if_broot_bytes) 181 (cur)->bc_private.b.whichfork)->if_broot_bytes)
215#endif
216#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMAP_IBLOCK_SIZE)
217int xfs_bmap_iblock_size(int lev, struct xfs_btree_cur *cur);
218#define XFS_BMAP_IBLOCK_SIZE(lev,cur) xfs_bmap_iblock_size(lev,cur)
219#else
220#define XFS_BMAP_IBLOCK_SIZE(lev,cur) (1 << (cur)->bc_blocklog)
221#endif
222 182
223#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMAP_BLOCK_DSIZE) 183#define XFS_BMAP_BLOCK_DSIZE(lev,cur) \
224int xfs_bmap_block_dsize(int lev, struct xfs_btree_cur *cur); 184 (((lev) == (cur)->bc_nlevels - 1 ? \
225#define XFS_BMAP_BLOCK_DSIZE(lev,cur) xfs_bmap_block_dsize(lev,cur) 185 XFS_BMAP_RBLOCK_DSIZE(lev,cur) : XFS_BMAP_IBLOCK_SIZE(lev,cur)))
226#else 186#define XFS_BMAP_BLOCK_ISIZE(lev,cur) \
227#define XFS_BMAP_BLOCK_DSIZE(lev,cur) \ 187 (((lev) == (cur)->bc_nlevels - 1 ? \
228 ((lev) == (cur)->bc_nlevels - 1 ? \ 188 XFS_BMAP_RBLOCK_ISIZE(lev,cur) : XFS_BMAP_IBLOCK_SIZE(lev,cur)))
229 XFS_BMAP_RBLOCK_DSIZE(lev,cur) : \
230 XFS_BMAP_IBLOCK_SIZE(lev,cur))
231#endif
232#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMAP_BLOCK_ISIZE)
233int xfs_bmap_block_isize(int lev, struct xfs_btree_cur *cur);
234#define XFS_BMAP_BLOCK_ISIZE(lev,cur) xfs_bmap_block_isize(lev,cur)
235#else
236#define XFS_BMAP_BLOCK_ISIZE(lev,cur) \
237 ((lev) == (cur)->bc_nlevels - 1 ? \
238 XFS_BMAP_RBLOCK_ISIZE(lev,cur) : \
239 XFS_BMAP_IBLOCK_SIZE(lev,cur))
240#endif
241 189
242#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMAP_BLOCK_DMAXRECS)
243int xfs_bmap_block_dmaxrecs(int lev, struct xfs_btree_cur *cur);
244#define XFS_BMAP_BLOCK_DMAXRECS(lev,cur) xfs_bmap_block_dmaxrecs(lev,cur)
245#else
246#define XFS_BMAP_BLOCK_DMAXRECS(lev,cur) \ 190#define XFS_BMAP_BLOCK_DMAXRECS(lev,cur) \
247 ((lev) == (cur)->bc_nlevels - 1 ? \ 191 (((lev) == (cur)->bc_nlevels - 1 ? \
248 XFS_BTREE_BLOCK_MAXRECS(XFS_BMAP_RBLOCK_DSIZE(lev,cur), \ 192 XFS_BTREE_BLOCK_MAXRECS(XFS_BMAP_RBLOCK_DSIZE(lev,cur), \
249 xfs_bmdr, (lev) == 0) : \ 193 xfs_bmdr, (lev) == 0) : \
250 ((cur)->bc_mp->m_bmap_dmxr[(lev) != 0])) 194 ((cur)->bc_mp->m_bmap_dmxr[(lev) != 0])))
251#endif
252#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMAP_BLOCK_IMAXRECS)
253int xfs_bmap_block_imaxrecs(int lev, struct xfs_btree_cur *cur);
254#define XFS_BMAP_BLOCK_IMAXRECS(lev,cur) xfs_bmap_block_imaxrecs(lev,cur)
255#else
256#define XFS_BMAP_BLOCK_IMAXRECS(lev,cur) \ 195#define XFS_BMAP_BLOCK_IMAXRECS(lev,cur) \
257 ((lev) == (cur)->bc_nlevels - 1 ? \ 196 (((lev) == (cur)->bc_nlevels - 1 ? \
258 XFS_BTREE_BLOCK_MAXRECS(XFS_BMAP_RBLOCK_ISIZE(lev,cur), \ 197 XFS_BTREE_BLOCK_MAXRECS(XFS_BMAP_RBLOCK_ISIZE(lev,cur),\
259 xfs_bmbt, (lev) == 0) : \ 198 xfs_bmbt, (lev) == 0) : \
260 ((cur)->bc_mp->m_bmap_dmxr[(lev) != 0])) 199 ((cur)->bc_mp->m_bmap_dmxr[(lev) != 0])))
261#endif
262 200
263#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMAP_BLOCK_DMINRECS)
264int xfs_bmap_block_dminrecs(int lev, struct xfs_btree_cur *cur);
265#define XFS_BMAP_BLOCK_DMINRECS(lev,cur) xfs_bmap_block_dminrecs(lev,cur)
266#else
267#define XFS_BMAP_BLOCK_DMINRECS(lev,cur) \ 201#define XFS_BMAP_BLOCK_DMINRECS(lev,cur) \
268 ((lev) == (cur)->bc_nlevels - 1 ? \ 202 (((lev) == (cur)->bc_nlevels - 1 ? \
269 XFS_BTREE_BLOCK_MINRECS(XFS_BMAP_RBLOCK_DSIZE(lev,cur), \ 203 XFS_BTREE_BLOCK_MINRECS(XFS_BMAP_RBLOCK_DSIZE(lev,cur),\
270 xfs_bmdr, (lev) == 0) : \ 204 xfs_bmdr, (lev) == 0) : \
271 ((cur)->bc_mp->m_bmap_dmnr[(lev) != 0])) 205 ((cur)->bc_mp->m_bmap_dmnr[(lev) != 0])))
272#endif
273#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMAP_BLOCK_IMINRECS)
274int xfs_bmap_block_iminrecs(int lev, struct xfs_btree_cur *cur);
275#define XFS_BMAP_BLOCK_IMINRECS(lev,cur) xfs_bmap_block_iminrecs(lev,cur)
276#else
277#define XFS_BMAP_BLOCK_IMINRECS(lev,cur) \ 206#define XFS_BMAP_BLOCK_IMINRECS(lev,cur) \
278 ((lev) == (cur)->bc_nlevels - 1 ? \ 207 (((lev) == (cur)->bc_nlevels - 1 ? \
279 XFS_BTREE_BLOCK_MINRECS(XFS_BMAP_RBLOCK_ISIZE(lev,cur), \ 208 XFS_BTREE_BLOCK_MINRECS(XFS_BMAP_RBLOCK_ISIZE(lev,cur),\
280 xfs_bmbt, (lev) == 0) : \ 209 xfs_bmbt, (lev) == 0) : \
281 ((cur)->bc_mp->m_bmap_dmnr[(lev) != 0])) 210 ((cur)->bc_mp->m_bmap_dmnr[(lev) != 0])))
282#endif 211
283 212#define XFS_BMAP_REC_DADDR(bb,i,cur) \
284#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMAP_REC_DADDR) 213 (XFS_BTREE_REC_ADDR(XFS_BMAP_BLOCK_DSIZE( \
285xfs_bmbt_rec_t * 214 be16_to_cpu((bb)->bb_level), cur), \
286xfs_bmap_rec_daddr(xfs_bmbt_block_t *bb, int i, struct xfs_btree_cur *cur); 215 xfs_bmbt, bb, i, XFS_BMAP_BLOCK_DMAXRECS( \
287#define XFS_BMAP_REC_DADDR(bb,i,cur) xfs_bmap_rec_daddr(bb,i,cur) 216 be16_to_cpu((bb)->bb_level), cur)))
288#else 217#define XFS_BMAP_REC_IADDR(bb,i,cur) \
289#define XFS_BMAP_REC_DADDR(bb,i,cur) \ 218 (XFS_BTREE_REC_ADDR(XFS_BMAP_BLOCK_ISIZE( \
290 XFS_BTREE_REC_ADDR(XFS_BMAP_BLOCK_DSIZE( \ 219 be16_to_cpu((bb)->bb_level), cur), \
291 INT_GET((bb)->bb_level, ARCH_CONVERT), cur), \ 220 xfs_bmbt, bb, i, XFS_BMAP_BLOCK_IMAXRECS( \
292 xfs_bmbt, bb, i, XFS_BMAP_BLOCK_DMAXRECS( \ 221 be16_to_cpu((bb)->bb_level), cur)))
293 INT_GET((bb)->bb_level, ARCH_CONVERT), cur)) 222
294#endif 223#define XFS_BMAP_KEY_DADDR(bb,i,cur) \
295#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMAP_REC_IADDR) 224 (XFS_BTREE_KEY_ADDR(XFS_BMAP_BLOCK_DSIZE( \
296xfs_bmbt_rec_t * 225 be16_to_cpu((bb)->bb_level), cur), \
297xfs_bmap_rec_iaddr(xfs_bmbt_block_t *bb, int i, struct xfs_btree_cur *cur); 226 xfs_bmbt, bb, i, XFS_BMAP_BLOCK_DMAXRECS( \
298#define XFS_BMAP_REC_IADDR(bb,i,cur) xfs_bmap_rec_iaddr(bb,i,cur) 227 be16_to_cpu((bb)->bb_level), cur)))
299#else 228#define XFS_BMAP_KEY_IADDR(bb,i,cur) \
300#define XFS_BMAP_REC_IADDR(bb,i,cur) \ 229 (XFS_BTREE_KEY_ADDR(XFS_BMAP_BLOCK_ISIZE( \
301 XFS_BTREE_REC_ADDR(XFS_BMAP_BLOCK_ISIZE( \ 230 be16_to_cpu((bb)->bb_level), cur), \
302 INT_GET((bb)->bb_level, ARCH_CONVERT), cur), \ 231 xfs_bmbt, bb, i, XFS_BMAP_BLOCK_IMAXRECS( \
303 xfs_bmbt, bb, i, XFS_BMAP_BLOCK_IMAXRECS( \ 232 be16_to_cpu((bb)->bb_level), cur)))
304 INT_GET((bb)->bb_level, ARCH_CONVERT), cur)) 233
305#endif 234#define XFS_BMAP_PTR_DADDR(bb,i,cur) \
306 235 (XFS_BTREE_PTR_ADDR(XFS_BMAP_BLOCK_DSIZE( \
307#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMAP_KEY_DADDR) 236 be16_to_cpu((bb)->bb_level), cur), \
308xfs_bmbt_key_t * 237 xfs_bmbt, bb, i, XFS_BMAP_BLOCK_DMAXRECS( \
309xfs_bmap_key_daddr(xfs_bmbt_block_t *bb, int i, struct xfs_btree_cur *cur); 238 be16_to_cpu((bb)->bb_level), cur)))
310#define XFS_BMAP_KEY_DADDR(bb,i,cur) xfs_bmap_key_daddr(bb,i,cur) 239#define XFS_BMAP_PTR_IADDR(bb,i,cur) \
311#else 240 (XFS_BTREE_PTR_ADDR(XFS_BMAP_BLOCK_ISIZE( \
312#define XFS_BMAP_KEY_DADDR(bb,i,cur) \ 241 be16_to_cpu((bb)->bb_level), cur), \
313 XFS_BTREE_KEY_ADDR(XFS_BMAP_BLOCK_DSIZE( \ 242 xfs_bmbt, bb, i, XFS_BMAP_BLOCK_IMAXRECS( \
314 INT_GET((bb)->bb_level, ARCH_CONVERT), cur), \ 243 be16_to_cpu((bb)->bb_level), cur)))
315 xfs_bmbt, bb, i, XFS_BMAP_BLOCK_DMAXRECS( \
316 INT_GET((bb)->bb_level, ARCH_CONVERT), cur))
317#endif
318#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMAP_KEY_IADDR)
319xfs_bmbt_key_t *
320xfs_bmap_key_iaddr(xfs_bmbt_block_t *bb, int i, struct xfs_btree_cur *cur);
321#define XFS_BMAP_KEY_IADDR(bb,i,cur) xfs_bmap_key_iaddr(bb,i,cur)
322#else
323#define XFS_BMAP_KEY_IADDR(bb,i,cur) \
324 XFS_BTREE_KEY_ADDR(XFS_BMAP_BLOCK_ISIZE( \
325 INT_GET((bb)->bb_level, ARCH_CONVERT), cur), \
326 xfs_bmbt, bb, i, XFS_BMAP_BLOCK_IMAXRECS( \
327 INT_GET((bb)->bb_level, ARCH_CONVERT), cur))
328#endif
329
330#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMAP_PTR_DADDR)
331xfs_bmbt_ptr_t *
332xfs_bmap_ptr_daddr(xfs_bmbt_block_t *bb, int i, struct xfs_btree_cur *cur);
333#define XFS_BMAP_PTR_DADDR(bb,i,cur) xfs_bmap_ptr_daddr(bb,i,cur)
334#else
335#define XFS_BMAP_PTR_DADDR(bb,i,cur) \
336 XFS_BTREE_PTR_ADDR(XFS_BMAP_BLOCK_DSIZE( \
337 INT_GET((bb)->bb_level, ARCH_CONVERT), cur), \
338 xfs_bmbt, bb, i, XFS_BMAP_BLOCK_DMAXRECS( \
339 INT_GET((bb)->bb_level, ARCH_CONVERT), cur))
340#endif
341#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMAP_PTR_IADDR)
342xfs_bmbt_ptr_t *
343xfs_bmap_ptr_iaddr(xfs_bmbt_block_t *bb, int i, struct xfs_btree_cur *cur);
344#define XFS_BMAP_PTR_IADDR(bb,i,cur) xfs_bmap_ptr_iaddr(bb,i,cur)
345#else
346#define XFS_BMAP_PTR_IADDR(bb,i,cur) \
347 XFS_BTREE_PTR_ADDR(XFS_BMAP_BLOCK_ISIZE( \
348 INT_GET((bb)->bb_level, ARCH_CONVERT), cur), \
349 xfs_bmbt, bb, i, XFS_BMAP_BLOCK_IMAXRECS( \
350 INT_GET((bb)->bb_level, ARCH_CONVERT), cur))
351#endif
352 244
353/* 245/*
354 * These are to be used when we know the size of the block and 246 * These are to be used when we know the size of the block and
355 * we don't have a cursor. 247 * we don't have a cursor.
356 */ 248 */
357#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMAP_BROOT_REC_ADDR)
358xfs_bmbt_rec_t *xfs_bmap_broot_rec_addr(xfs_bmbt_block_t *bb, int i, int sz);
359#define XFS_BMAP_BROOT_REC_ADDR(bb,i,sz) xfs_bmap_broot_rec_addr(bb,i,sz)
360#else
361#define XFS_BMAP_BROOT_REC_ADDR(bb,i,sz) \ 249#define XFS_BMAP_BROOT_REC_ADDR(bb,i,sz) \
362 XFS_BTREE_REC_ADDR(sz,xfs_bmbt,bb,i,XFS_BMAP_BROOT_MAXRECS(sz)) 250 (XFS_BTREE_REC_ADDR(sz,xfs_bmbt,bb,i,XFS_BMAP_BROOT_MAXRECS(sz)))
363#endif
364#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMAP_BROOT_KEY_ADDR)
365xfs_bmbt_key_t *xfs_bmap_broot_key_addr(xfs_bmbt_block_t *bb, int i, int sz);
366#define XFS_BMAP_BROOT_KEY_ADDR(bb,i,sz) xfs_bmap_broot_key_addr(bb,i,sz)
367#else
368#define XFS_BMAP_BROOT_KEY_ADDR(bb,i,sz) \ 251#define XFS_BMAP_BROOT_KEY_ADDR(bb,i,sz) \
369 XFS_BTREE_KEY_ADDR(sz,xfs_bmbt,bb,i,XFS_BMAP_BROOT_MAXRECS(sz)) 252 (XFS_BTREE_KEY_ADDR(sz,xfs_bmbt,bb,i,XFS_BMAP_BROOT_MAXRECS(sz)))
370#endif
371#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMAP_BROOT_PTR_ADDR)
372xfs_bmbt_ptr_t *xfs_bmap_broot_ptr_addr(xfs_bmbt_block_t *bb, int i, int sz);
373#define XFS_BMAP_BROOT_PTR_ADDR(bb,i,sz) xfs_bmap_broot_ptr_addr(bb,i,sz)
374#else
375#define XFS_BMAP_BROOT_PTR_ADDR(bb,i,sz) \ 253#define XFS_BMAP_BROOT_PTR_ADDR(bb,i,sz) \
376 XFS_BTREE_PTR_ADDR(sz,xfs_bmbt,bb,i,XFS_BMAP_BROOT_MAXRECS(sz)) 254 (XFS_BTREE_PTR_ADDR(sz,xfs_bmbt,bb,i,XFS_BMAP_BROOT_MAXRECS(sz)))
377#endif 255
256#define XFS_BMAP_BROOT_NUMRECS(bb) be16_to_cpu((bb)->bb_numrecs)
257#define XFS_BMAP_BROOT_MAXRECS(sz) XFS_BTREE_BLOCK_MAXRECS(sz,xfs_bmbt,0)
378 258
379#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMAP_BROOT_NUMRECS)
380int xfs_bmap_broot_numrecs(xfs_bmdr_block_t *bb);
381#define XFS_BMAP_BROOT_NUMRECS(bb) xfs_bmap_broot_numrecs(bb)
382#else
383#define XFS_BMAP_BROOT_NUMRECS(bb) (INT_GET((bb)->bb_numrecs, ARCH_CONVERT))
384#endif
385#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMAP_BROOT_MAXRECS)
386int xfs_bmap_broot_maxrecs(int sz);
387#define XFS_BMAP_BROOT_MAXRECS(sz) xfs_bmap_broot_maxrecs(sz)
388#else
389#define XFS_BMAP_BROOT_MAXRECS(sz) XFS_BTREE_BLOCK_MAXRECS(sz,xfs_bmbt,0)
390#endif
391#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMAP_BROOT_SPACE_CALC)
392int xfs_bmap_broot_space_calc(int nrecs);
393#define XFS_BMAP_BROOT_SPACE_CALC(nrecs) xfs_bmap_broot_space_calc(nrecs)
394#else
395#define XFS_BMAP_BROOT_SPACE_CALC(nrecs) \ 259#define XFS_BMAP_BROOT_SPACE_CALC(nrecs) \
396 ((int)(sizeof(xfs_bmbt_block_t) + \ 260 (int)(sizeof(xfs_bmbt_block_t) + \
397 ((nrecs) * (sizeof(xfs_bmbt_key_t) + sizeof(xfs_bmbt_ptr_t))))) 261 ((nrecs) * (sizeof(xfs_bmbt_key_t) + sizeof(xfs_bmbt_ptr_t))))
398#endif 262
399#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMAP_BROOT_SPACE)
400int xfs_bmap_broot_space(xfs_bmdr_block_t *bb);
401#define XFS_BMAP_BROOT_SPACE(bb) xfs_bmap_broot_space(bb)
402#else
403#define XFS_BMAP_BROOT_SPACE(bb) \ 263#define XFS_BMAP_BROOT_SPACE(bb) \
404 XFS_BMAP_BROOT_SPACE_CALC(INT_GET((bb)->bb_numrecs, ARCH_CONVERT)) 264 (XFS_BMAP_BROOT_SPACE_CALC(be16_to_cpu((bb)->bb_numrecs)))
405#endif 265#define XFS_BMDR_SPACE_CALC(nrecs) \
406#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMDR_SPACE_CALC) 266 (int)(sizeof(xfs_bmdr_block_t) + \
407int xfs_bmdr_space_calc(int nrecs); 267 ((nrecs) * (sizeof(xfs_bmbt_key_t) + sizeof(xfs_bmbt_ptr_t))))
408#define XFS_BMDR_SPACE_CALC(nrecs) xfs_bmdr_space_calc(nrecs)
409#else
410#define XFS_BMDR_SPACE_CALC(nrecs) \
411 ((int)(sizeof(xfs_bmdr_block_t) + \
412 ((nrecs) * (sizeof(xfs_bmbt_key_t) + sizeof(xfs_bmbt_ptr_t)))))
413#endif
414 268
415/* 269/*
416 * Maximum number of bmap btree levels. 270 * Maximum number of bmap btree levels.
417 */ 271 */
418#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BM_MAXLEVELS) 272#define XFS_BM_MAXLEVELS(mp,w) ((mp)->m_bm_maxlevels[(w)])
419int xfs_bm_maxlevels(struct xfs_mount *mp, int w);
420#define XFS_BM_MAXLEVELS(mp,w) xfs_bm_maxlevels(mp,w)
421#else
422#define XFS_BM_MAXLEVELS(mp,w) ((mp)->m_bm_maxlevels[w])
423#endif
424 273
425#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMAP_SANITY_CHECK) 274#define XFS_BMAP_SANITY_CHECK(mp,bb,level) \
426int xfs_bmap_sanity_check(struct xfs_mount *mp, xfs_bmbt_block_t *bb, 275 (be32_to_cpu((bb)->bb_magic) == XFS_BMAP_MAGIC && \
427 int level); 276 be16_to_cpu((bb)->bb_level) == level && \
428#define XFS_BMAP_SANITY_CHECK(mp,bb,level) \ 277 be16_to_cpu((bb)->bb_numrecs) > 0 && \
429 xfs_bmap_sanity_check(mp,bb,level) 278 be16_to_cpu((bb)->bb_numrecs) <= (mp)->m_bmap_dmxr[(level) != 0])
430#else
431#define XFS_BMAP_SANITY_CHECK(mp,bb,level) \
432 (INT_GET((bb)->bb_magic, ARCH_CONVERT) == XFS_BMAP_MAGIC && \
433 INT_GET((bb)->bb_level, ARCH_CONVERT) == level && \
434 INT_GET((bb)->bb_numrecs, ARCH_CONVERT) > 0 && \
435 INT_GET((bb)->bb_numrecs, ARCH_CONVERT) <= (mp)->m_bmap_dmxr[(level) != 0])
436#endif
437 279
438 280
439#ifdef __KERNEL__ 281#ifdef __KERNEL__
@@ -459,234 +301,84 @@ extern ktrace_t *xfs_bmbt_trace_buf;
459/* 301/*
460 * Prototypes for xfs_bmap.c to call. 302 * Prototypes for xfs_bmap.c to call.
461 */ 303 */
462 304extern void xfs_bmdr_to_bmbt(xfs_bmdr_block_t *, int, xfs_bmbt_block_t *, int);
463void 305extern int xfs_bmbt_decrement(struct xfs_btree_cur *, int, int *);
464xfs_bmdr_to_bmbt( 306extern int xfs_bmbt_delete(struct xfs_btree_cur *, int *);
465 xfs_bmdr_block_t *, 307extern void xfs_bmbt_get_all(xfs_bmbt_rec_t *r, xfs_bmbt_irec_t *s);
466 int, 308extern xfs_bmbt_block_t *xfs_bmbt_get_block(struct xfs_btree_cur *cur,
467 xfs_bmbt_block_t *, 309 int, struct xfs_buf **bpp);
468 int); 310extern xfs_filblks_t xfs_bmbt_get_blockcount(xfs_bmbt_rec_t *r);
469 311extern xfs_fsblock_t xfs_bmbt_get_startblock(xfs_bmbt_rec_t *r);
470int 312extern xfs_fileoff_t xfs_bmbt_get_startoff(xfs_bmbt_rec_t *r);
471xfs_bmbt_decrement( 313extern xfs_exntst_t xfs_bmbt_get_state(xfs_bmbt_rec_t *r);
472 struct xfs_btree_cur *,
473 int,
474 int *);
475
476int
477xfs_bmbt_delete(
478 struct xfs_btree_cur *,
479 int *);
480
481void
482xfs_bmbt_get_all(
483 xfs_bmbt_rec_t *r,
484 xfs_bmbt_irec_t *s);
485
486xfs_bmbt_block_t *
487xfs_bmbt_get_block(
488 struct xfs_btree_cur *cur,
489 int level,
490 struct xfs_buf **bpp);
491
492xfs_filblks_t
493xfs_bmbt_get_blockcount(
494 xfs_bmbt_rec_t *r);
495
496xfs_fsblock_t
497xfs_bmbt_get_startblock(
498 xfs_bmbt_rec_t *r);
499
500xfs_fileoff_t
501xfs_bmbt_get_startoff(
502 xfs_bmbt_rec_t *r);
503
504xfs_exntst_t
505xfs_bmbt_get_state(
506 xfs_bmbt_rec_t *r);
507 314
508#ifndef XFS_NATIVE_HOST 315#ifndef XFS_NATIVE_HOST
509void 316extern void xfs_bmbt_disk_get_all(xfs_bmbt_rec_t *r, xfs_bmbt_irec_t *s);
510xfs_bmbt_disk_get_all( 317extern xfs_exntst_t xfs_bmbt_disk_get_state(xfs_bmbt_rec_t *r);
511 xfs_bmbt_rec_t *r, 318extern xfs_filblks_t xfs_bmbt_disk_get_blockcount(xfs_bmbt_rec_t *r);
512 xfs_bmbt_irec_t *s); 319extern xfs_fsblock_t xfs_bmbt_disk_get_startblock(xfs_bmbt_rec_t *r);
513 320extern xfs_fileoff_t xfs_bmbt_disk_get_startoff(xfs_bmbt_rec_t *r);
514xfs_exntst_t 321#else
515xfs_bmbt_disk_get_state( 322#define xfs_bmbt_disk_get_all(r, s) xfs_bmbt_get_all(r, s)
516 xfs_bmbt_rec_t *r); 323#define xfs_bmbt_disk_get_state(r) xfs_bmbt_get_state(r)
517 324#define xfs_bmbt_disk_get_blockcount(r) xfs_bmbt_get_blockcount(r)
518xfs_filblks_t 325#define xfs_bmbt_disk_get_startblock(r) xfs_bmbt_get_blockcount(r)
519xfs_bmbt_disk_get_blockcount( 326#define xfs_bmbt_disk_get_startoff(r) xfs_bmbt_get_startoff(r)
520 xfs_bmbt_rec_t *r);
521
522xfs_fsblock_t
523xfs_bmbt_disk_get_startblock(
524 xfs_bmbt_rec_t *r);
525
526xfs_fileoff_t
527xfs_bmbt_disk_get_startoff(
528 xfs_bmbt_rec_t *r);
529
530#else
531#define xfs_bmbt_disk_get_all(r, s) \
532 xfs_bmbt_get_all(r, s)
533#define xfs_bmbt_disk_get_state(r) \
534 xfs_bmbt_get_state(r)
535#define xfs_bmbt_disk_get_blockcount(r) \
536 xfs_bmbt_get_blockcount(r)
537#define xfs_bmbt_disk_get_startblock(r) \
538 xfs_bmbt_get_blockcount(r)
539#define xfs_bmbt_disk_get_startoff(r) \
540 xfs_bmbt_get_startoff(r)
541#endif /* XFS_NATIVE_HOST */ 327#endif /* XFS_NATIVE_HOST */
542 328
543int 329extern int xfs_bmbt_increment(struct xfs_btree_cur *, int, int *);
544xfs_bmbt_increment( 330extern int xfs_bmbt_insert(struct xfs_btree_cur *, int *);
545 struct xfs_btree_cur *, 331extern void xfs_bmbt_log_block(struct xfs_btree_cur *, struct xfs_buf *, int);
546 int, 332extern void xfs_bmbt_log_recs(struct xfs_btree_cur *, struct xfs_buf *, int,
547 int *); 333 int);
548 334extern int xfs_bmbt_lookup_eq(struct xfs_btree_cur *, xfs_fileoff_t,
549int 335 xfs_fsblock_t, xfs_filblks_t, int *);
550xfs_bmbt_insert( 336extern int xfs_bmbt_lookup_ge(struct xfs_btree_cur *, xfs_fileoff_t,
551 struct xfs_btree_cur *, 337 xfs_fsblock_t, xfs_filblks_t, int *);
552 int *);
553
554void
555xfs_bmbt_log_block(
556 struct xfs_btree_cur *,
557 struct xfs_buf *,
558 int);
559
560void
561xfs_bmbt_log_recs(
562 struct xfs_btree_cur *,
563 struct xfs_buf *,
564 int,
565 int);
566
567int
568xfs_bmbt_lookup_eq(
569 struct xfs_btree_cur *,
570 xfs_fileoff_t,
571 xfs_fsblock_t,
572 xfs_filblks_t,
573 int *);
574
575int
576xfs_bmbt_lookup_ge(
577 struct xfs_btree_cur *,
578 xfs_fileoff_t,
579 xfs_fsblock_t,
580 xfs_filblks_t,
581 int *);
582 338
583/* 339/*
584 * Give the bmap btree a new root block. Copy the old broot contents 340 * Give the bmap btree a new root block. Copy the old broot contents
585 * down into a real block and make the broot point to it. 341 * down into a real block and make the broot point to it.
586 */ 342 */
587int /* error */ 343extern int xfs_bmbt_newroot(struct xfs_btree_cur *cur, int *lflags, int *stat);
588xfs_bmbt_newroot( 344
589 struct xfs_btree_cur *cur, /* btree cursor */ 345extern void xfs_bmbt_set_all(xfs_bmbt_rec_t *r, xfs_bmbt_irec_t *s);
590 int *logflags, /* logging flags for inode */ 346extern void xfs_bmbt_set_allf(xfs_bmbt_rec_t *r, xfs_fileoff_t o,
591 int *stat); /* return status - 0 fail */ 347 xfs_fsblock_t b, xfs_filblks_t c, xfs_exntst_t v);
592 348extern void xfs_bmbt_set_blockcount(xfs_bmbt_rec_t *r, xfs_filblks_t v);
593void 349extern void xfs_bmbt_set_startblock(xfs_bmbt_rec_t *r, xfs_fsblock_t v);
594xfs_bmbt_set_all( 350extern void xfs_bmbt_set_startoff(xfs_bmbt_rec_t *r, xfs_fileoff_t v);
595 xfs_bmbt_rec_t *r, 351extern void xfs_bmbt_set_state(xfs_bmbt_rec_t *r, xfs_exntst_t v);
596 xfs_bmbt_irec_t *s);
597
598void
599xfs_bmbt_set_allf(
600 xfs_bmbt_rec_t *r,
601 xfs_fileoff_t o,
602 xfs_fsblock_t b,
603 xfs_filblks_t c,
604 xfs_exntst_t v);
605
606void
607xfs_bmbt_set_blockcount(
608 xfs_bmbt_rec_t *r,
609 xfs_filblks_t v);
610
611void
612xfs_bmbt_set_startblock(
613 xfs_bmbt_rec_t *r,
614 xfs_fsblock_t v);
615
616void
617xfs_bmbt_set_startoff(
618 xfs_bmbt_rec_t *r,
619 xfs_fileoff_t v);
620
621void
622xfs_bmbt_set_state(
623 xfs_bmbt_rec_t *r,
624 xfs_exntst_t v);
625 352
626#ifndef XFS_NATIVE_HOST 353#ifndef XFS_NATIVE_HOST
627void 354extern void xfs_bmbt_disk_set_all(xfs_bmbt_rec_t *r, xfs_bmbt_irec_t *s);
628xfs_bmbt_disk_set_all( 355extern void xfs_bmbt_disk_set_allf(xfs_bmbt_rec_t *r, xfs_fileoff_t o,
629 xfs_bmbt_rec_t *r, 356 xfs_fsblock_t b, xfs_filblks_t c, xfs_exntst_t v);
630 xfs_bmbt_irec_t *s);
631
632void
633xfs_bmbt_disk_set_allf(
634 xfs_bmbt_rec_t *r,
635 xfs_fileoff_t o,
636 xfs_fsblock_t b,
637 xfs_filblks_t c,
638 xfs_exntst_t v);
639#else 357#else
640#define xfs_bmbt_disk_set_all(r, s) \ 358#define xfs_bmbt_disk_set_all(r, s) xfs_bmbt_set_all(r, s)
641 xfs_bmbt_set_all(r, s) 359#define xfs_bmbt_disk_set_allf(r, o, b, c, v) xfs_bmbt_set_allf(r, o, b, c, v)
642#define xfs_bmbt_disk_set_allf(r, o, b, c, v) \
643 xfs_bmbt_set_allf(r, o, b, c, v)
644#endif /* XFS_NATIVE_HOST */ 360#endif /* XFS_NATIVE_HOST */
645 361
646void 362extern void xfs_bmbt_to_bmdr(xfs_bmbt_block_t *, int, xfs_bmdr_block_t *, int);
647xfs_bmbt_to_bmdr( 363extern int xfs_bmbt_update(struct xfs_btree_cur *, xfs_fileoff_t,
648 xfs_bmbt_block_t *, 364 xfs_fsblock_t, xfs_filblks_t, xfs_exntst_t);
649 int,
650 xfs_bmdr_block_t *,
651 int);
652
653int
654xfs_bmbt_update(
655 struct xfs_btree_cur *,
656 xfs_fileoff_t,
657 xfs_fsblock_t,
658 xfs_filblks_t,
659 xfs_exntst_t);
660 365
661#ifdef DEBUG 366#ifdef DEBUG
662/* 367/*
663 * Get the data from the pointed-to record. 368 * Get the data from the pointed-to record.
664 */ 369 */
665int 370extern int xfs_bmbt_get_rec(struct xfs_btree_cur *, xfs_fileoff_t *,
666xfs_bmbt_get_rec( 371 xfs_fsblock_t *, xfs_filblks_t *,
667 struct xfs_btree_cur *, 372 xfs_exntst_t *, int *);
668 xfs_fileoff_t *,
669 xfs_fsblock_t *,
670 xfs_filblks_t *,
671 xfs_exntst_t *,
672 int *);
673#endif 373#endif
674 374
675
676/* 375/*
677 * Search an extent list for the extent which includes block 376 * Search an extent list for the extent which includes block
678 * bno. 377 * bno.
679 */ 378 */
680xfs_bmbt_rec_t * 379xfs_bmbt_rec_t *xfs_bmap_do_search_extents(xfs_bmbt_rec_t *,
681xfs_bmap_do_search_extents( 380 xfs_extnum_t, xfs_extnum_t, xfs_fileoff_t, int *,
682 xfs_bmbt_rec_t *, 381 xfs_extnum_t *, xfs_bmbt_irec_t *, xfs_bmbt_irec_t *);
683 xfs_extnum_t,
684 xfs_extnum_t,
685 xfs_fileoff_t,
686 int *,
687 xfs_extnum_t *,
688 xfs_bmbt_irec_t *,
689 xfs_bmbt_irec_t *);
690 382
691#endif /* __KERNEL__ */ 383#endif /* __KERNEL__ */
692 384
diff --git a/fs/xfs/xfs_btree.c b/fs/xfs/xfs_btree.c
index 0cc63d657a14..52d5d095fc35 100644
--- a/fs/xfs/xfs_btree.c
+++ b/fs/xfs/xfs_btree.c
@@ -1,45 +1,26 @@
1/* 1/*
2 * Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32
33/*
34 * This file contains common code for the space manager's btree implementations.
35 */
36
37#include "xfs.h" 18#include "xfs.h"
38 19#include "xfs_fs.h"
39#include "xfs_macros.h"
40#include "xfs_types.h" 20#include "xfs_types.h"
41#include "xfs_inum.h" 21#include "xfs_bit.h"
42#include "xfs_log.h" 22#include "xfs_log.h"
23#include "xfs_inum.h"
43#include "xfs_trans.h" 24#include "xfs_trans.h"
44#include "xfs_sb.h" 25#include "xfs_sb.h"
45#include "xfs_ag.h" 26#include "xfs_ag.h"
@@ -47,17 +28,16 @@
47#include "xfs_dir2.h" 28#include "xfs_dir2.h"
48#include "xfs_dmapi.h" 29#include "xfs_dmapi.h"
49#include "xfs_mount.h" 30#include "xfs_mount.h"
50#include "xfs_alloc_btree.h"
51#include "xfs_bmap_btree.h" 31#include "xfs_bmap_btree.h"
32#include "xfs_alloc_btree.h"
52#include "xfs_ialloc_btree.h" 33#include "xfs_ialloc_btree.h"
53#include "xfs_btree.h"
54#include "xfs_ialloc.h"
55#include "xfs_attr_sf.h"
56#include "xfs_dir_sf.h" 34#include "xfs_dir_sf.h"
57#include "xfs_dir2_sf.h" 35#include "xfs_dir2_sf.h"
36#include "xfs_attr_sf.h"
58#include "xfs_dinode.h" 37#include "xfs_dinode.h"
59#include "xfs_inode.h" 38#include "xfs_inode.h"
60#include "xfs_bit.h" 39#include "xfs_btree.h"
40#include "xfs_ialloc.h"
61#include "xfs_error.h" 41#include "xfs_error.h"
62 42
63/* 43/*
@@ -110,11 +90,14 @@ xfs_btree_maxrecs(
110 switch (cur->bc_btnum) { 90 switch (cur->bc_btnum) {
111 case XFS_BTNUM_BNO: 91 case XFS_BTNUM_BNO:
112 case XFS_BTNUM_CNT: 92 case XFS_BTNUM_CNT:
113 return (int)XFS_ALLOC_BLOCK_MAXRECS(INT_GET(block->bb_h.bb_level, ARCH_CONVERT), cur); 93 return (int)XFS_ALLOC_BLOCK_MAXRECS(
94 be16_to_cpu(block->bb_h.bb_level), cur);
114 case XFS_BTNUM_BMAP: 95 case XFS_BTNUM_BMAP:
115 return (int)XFS_BMAP_BLOCK_IMAXRECS(INT_GET(block->bb_h.bb_level, ARCH_CONVERT), cur); 96 return (int)XFS_BMAP_BLOCK_IMAXRECS(
97 be16_to_cpu(block->bb_h.bb_level), cur);
116 case XFS_BTNUM_INO: 98 case XFS_BTNUM_INO:
117 return (int)XFS_INOBT_BLOCK_MAXRECS(INT_GET(block->bb_h.bb_level, ARCH_CONVERT), cur); 99 return (int)XFS_INOBT_BLOCK_MAXRECS(
100 be16_to_cpu(block->bb_h.bb_level), cur);
118 default: 101 default:
119 ASSERT(0); 102 ASSERT(0);
120 return 0; 103 return 0;
@@ -160,7 +143,7 @@ xfs_btree_check_key(
160 143
161 k1 = ak1; 144 k1 = ak1;
162 k2 = ak2; 145 k2 = ak2;
163 ASSERT(INT_GET(k1->ar_startblock, ARCH_CONVERT) < INT_GET(k2->ar_startblock, ARCH_CONVERT)); 146 ASSERT(be32_to_cpu(k1->ar_startblock) < be32_to_cpu(k2->ar_startblock));
164 break; 147 break;
165 } 148 }
166 case XFS_BTNUM_CNT: { 149 case XFS_BTNUM_CNT: {
@@ -169,9 +152,9 @@ xfs_btree_check_key(
169 152
170 k1 = ak1; 153 k1 = ak1;
171 k2 = ak2; 154 k2 = ak2;
172 ASSERT(INT_GET(k1->ar_blockcount, ARCH_CONVERT) < INT_GET(k2->ar_blockcount, ARCH_CONVERT) || 155 ASSERT(be32_to_cpu(k1->ar_blockcount) < be32_to_cpu(k2->ar_blockcount) ||
173 (INT_GET(k1->ar_blockcount, ARCH_CONVERT) == INT_GET(k2->ar_blockcount, ARCH_CONVERT) && 156 (k1->ar_blockcount == k2->ar_blockcount &&
174 INT_GET(k1->ar_startblock, ARCH_CONVERT) < INT_GET(k2->ar_startblock, ARCH_CONVERT))); 157 be32_to_cpu(k1->ar_startblock) < be32_to_cpu(k2->ar_startblock)));
175 break; 158 break;
176 } 159 }
177 case XFS_BTNUM_BMAP: { 160 case XFS_BTNUM_BMAP: {
@@ -214,16 +197,16 @@ xfs_btree_check_lblock(
214 197
215 mp = cur->bc_mp; 198 mp = cur->bc_mp;
216 lblock_ok = 199 lblock_ok =
217 INT_GET(block->bb_magic, ARCH_CONVERT) == xfs_magics[cur->bc_btnum] && 200 be32_to_cpu(block->bb_magic) == xfs_magics[cur->bc_btnum] &&
218 INT_GET(block->bb_level, ARCH_CONVERT) == level && 201 be16_to_cpu(block->bb_level) == level &&
219 INT_GET(block->bb_numrecs, ARCH_CONVERT) <= 202 be16_to_cpu(block->bb_numrecs) <=
220 xfs_btree_maxrecs(cur, (xfs_btree_block_t *)block) && 203 xfs_btree_maxrecs(cur, (xfs_btree_block_t *)block) &&
221 block->bb_leftsib && 204 block->bb_leftsib &&
222 (INT_GET(block->bb_leftsib, ARCH_CONVERT) == NULLDFSBNO || 205 (be64_to_cpu(block->bb_leftsib) == NULLDFSBNO ||
223 XFS_FSB_SANITY_CHECK(mp, INT_GET(block->bb_leftsib, ARCH_CONVERT))) && 206 XFS_FSB_SANITY_CHECK(mp, be64_to_cpu(block->bb_leftsib))) &&
224 block->bb_rightsib && 207 block->bb_rightsib &&
225 (INT_GET(block->bb_rightsib, ARCH_CONVERT) == NULLDFSBNO || 208 (be64_to_cpu(block->bb_rightsib) == NULLDFSBNO ||
226 XFS_FSB_SANITY_CHECK(mp, INT_GET(block->bb_rightsib, ARCH_CONVERT))); 209 XFS_FSB_SANITY_CHECK(mp, be64_to_cpu(block->bb_rightsib)));
227 if (unlikely(XFS_TEST_ERROR(!lblock_ok, mp, XFS_ERRTAG_BTREE_CHECK_LBLOCK, 210 if (unlikely(XFS_TEST_ERROR(!lblock_ok, mp, XFS_ERRTAG_BTREE_CHECK_LBLOCK,
228 XFS_RANDOM_BTREE_CHECK_LBLOCK))) { 211 XFS_RANDOM_BTREE_CHECK_LBLOCK))) {
229 if (bp) 212 if (bp)
@@ -271,8 +254,9 @@ xfs_btree_check_rec(
271 254
272 r1 = ar1; 255 r1 = ar1;
273 r2 = ar2; 256 r2 = ar2;
274 ASSERT(INT_GET(r1->ar_startblock, ARCH_CONVERT) + INT_GET(r1->ar_blockcount, ARCH_CONVERT) <= 257 ASSERT(be32_to_cpu(r1->ar_startblock) +
275 INT_GET(r2->ar_startblock, ARCH_CONVERT)); 258 be32_to_cpu(r1->ar_blockcount) <=
259 be32_to_cpu(r2->ar_startblock));
276 break; 260 break;
277 } 261 }
278 case XFS_BTNUM_CNT: { 262 case XFS_BTNUM_CNT: {
@@ -281,9 +265,9 @@ xfs_btree_check_rec(
281 265
282 r1 = ar1; 266 r1 = ar1;
283 r2 = ar2; 267 r2 = ar2;
284 ASSERT(INT_GET(r1->ar_blockcount, ARCH_CONVERT) < INT_GET(r2->ar_blockcount, ARCH_CONVERT) || 268 ASSERT(be32_to_cpu(r1->ar_blockcount) < be32_to_cpu(r2->ar_blockcount) ||
285 (INT_GET(r1->ar_blockcount, ARCH_CONVERT) == INT_GET(r2->ar_blockcount, ARCH_CONVERT) && 269 (r1->ar_blockcount == r2->ar_blockcount &&
286 INT_GET(r1->ar_startblock, ARCH_CONVERT) < INT_GET(r2->ar_startblock, ARCH_CONVERT))); 270 be32_to_cpu(r1->ar_startblock) < be32_to_cpu(r2->ar_startblock)));
287 break; 271 break;
288 } 272 }
289 case XFS_BTNUM_BMAP: { 273 case XFS_BTNUM_BMAP: {
@@ -331,17 +315,17 @@ xfs_btree_check_sblock(
331 315
332 agbp = cur->bc_private.a.agbp; 316 agbp = cur->bc_private.a.agbp;
333 agf = XFS_BUF_TO_AGF(agbp); 317 agf = XFS_BUF_TO_AGF(agbp);
334 agflen = INT_GET(agf->agf_length, ARCH_CONVERT); 318 agflen = be32_to_cpu(agf->agf_length);
335 sblock_ok = 319 sblock_ok =
336 INT_GET(block->bb_magic, ARCH_CONVERT) == xfs_magics[cur->bc_btnum] && 320 be32_to_cpu(block->bb_magic) == xfs_magics[cur->bc_btnum] &&
337 INT_GET(block->bb_level, ARCH_CONVERT) == level && 321 be16_to_cpu(block->bb_level) == level &&
338 INT_GET(block->bb_numrecs, ARCH_CONVERT) <= 322 be16_to_cpu(block->bb_numrecs) <=
339 xfs_btree_maxrecs(cur, (xfs_btree_block_t *)block) && 323 xfs_btree_maxrecs(cur, (xfs_btree_block_t *)block) &&
340 (INT_GET(block->bb_leftsib, ARCH_CONVERT) == NULLAGBLOCK || 324 (be32_to_cpu(block->bb_leftsib) == NULLAGBLOCK ||
341 INT_GET(block->bb_leftsib, ARCH_CONVERT) < agflen) && 325 be32_to_cpu(block->bb_leftsib) < agflen) &&
342 block->bb_leftsib && 326 block->bb_leftsib &&
343 (INT_GET(block->bb_rightsib, ARCH_CONVERT) == NULLAGBLOCK || 327 (be32_to_cpu(block->bb_rightsib) == NULLAGBLOCK ||
344 INT_GET(block->bb_rightsib, ARCH_CONVERT) < agflen) && 328 be32_to_cpu(block->bb_rightsib) < agflen) &&
345 block->bb_rightsib; 329 block->bb_rightsib;
346 if (unlikely(XFS_TEST_ERROR(!sblock_ok, cur->bc_mp, 330 if (unlikely(XFS_TEST_ERROR(!sblock_ok, cur->bc_mp,
347 XFS_ERRTAG_BTREE_CHECK_SBLOCK, 331 XFS_ERRTAG_BTREE_CHECK_SBLOCK,
@@ -372,7 +356,7 @@ xfs_btree_check_sptr(
372 XFS_WANT_CORRUPTED_RETURN( 356 XFS_WANT_CORRUPTED_RETURN(
373 level > 0 && 357 level > 0 &&
374 ptr != NULLAGBLOCK && ptr != 0 && 358 ptr != NULLAGBLOCK && ptr != 0 &&
375 ptr < INT_GET(agf->agf_length, ARCH_CONVERT)); 359 ptr < be32_to_cpu(agf->agf_length));
376 return 0; 360 return 0;
377} 361}
378 362
@@ -611,15 +595,15 @@ xfs_btree_init_cursor(
611 case XFS_BTNUM_BNO: 595 case XFS_BTNUM_BNO:
612 case XFS_BTNUM_CNT: 596 case XFS_BTNUM_CNT:
613 agf = XFS_BUF_TO_AGF(agbp); 597 agf = XFS_BUF_TO_AGF(agbp);
614 nlevels = INT_GET(agf->agf_levels[btnum], ARCH_CONVERT); 598 nlevels = be32_to_cpu(agf->agf_levels[btnum]);
615 break; 599 break;
616 case XFS_BTNUM_BMAP: 600 case XFS_BTNUM_BMAP:
617 ifp = XFS_IFORK_PTR(ip, whichfork); 601 ifp = XFS_IFORK_PTR(ip, whichfork);
618 nlevels = INT_GET(ifp->if_broot->bb_level, ARCH_CONVERT) + 1; 602 nlevels = be16_to_cpu(ifp->if_broot->bb_level) + 1;
619 break; 603 break;
620 case XFS_BTNUM_INO: 604 case XFS_BTNUM_INO:
621 agi = XFS_BUF_TO_AGI(agbp); 605 agi = XFS_BUF_TO_AGI(agbp);
622 nlevels = INT_GET(agi->agi_level, ARCH_CONVERT); 606 nlevels = be32_to_cpu(agi->agi_level);
623 break; 607 break;
624 default: 608 default:
625 ASSERT(0); 609 ASSERT(0);
@@ -683,9 +667,9 @@ xfs_btree_islastblock(
683 block = xfs_btree_get_block(cur, level, &bp); 667 block = xfs_btree_get_block(cur, level, &bp);
684 xfs_btree_check_block(cur, block, level, bp); 668 xfs_btree_check_block(cur, block, level, bp);
685 if (XFS_BTREE_LONG_PTRS(cur->bc_btnum)) 669 if (XFS_BTREE_LONG_PTRS(cur->bc_btnum))
686 return INT_GET(block->bb_u.l.bb_rightsib, ARCH_CONVERT) == NULLDFSBNO; 670 return be64_to_cpu(block->bb_u.l.bb_rightsib) == NULLDFSBNO;
687 else 671 else
688 return INT_GET(block->bb_u.s.bb_rightsib, ARCH_CONVERT) == NULLAGBLOCK; 672 return be32_to_cpu(block->bb_u.s.bb_rightsib) == NULLAGBLOCK;
689} 673}
690 674
691/* 675/*
@@ -713,7 +697,7 @@ xfs_btree_lastrec(
713 /* 697 /*
714 * Set the ptr value to numrecs, that's the last record/key. 698 * Set the ptr value to numrecs, that's the last record/key.
715 */ 699 */
716 cur->bc_ptrs[level] = INT_GET(block->bb_h.bb_numrecs, ARCH_CONVERT); 700 cur->bc_ptrs[level] = be16_to_cpu(block->bb_h.bb_numrecs);
717 return 1; 701 return 1;
718} 702}
719 703
@@ -883,38 +867,38 @@ xfs_btree_readahead_core(
883 case XFS_BTNUM_BNO: 867 case XFS_BTNUM_BNO:
884 case XFS_BTNUM_CNT: 868 case XFS_BTNUM_CNT:
885 a = XFS_BUF_TO_ALLOC_BLOCK(cur->bc_bufs[lev]); 869 a = XFS_BUF_TO_ALLOC_BLOCK(cur->bc_bufs[lev]);
886 if ((lr & XFS_BTCUR_LEFTRA) && INT_GET(a->bb_leftsib, ARCH_CONVERT) != NULLAGBLOCK) { 870 if ((lr & XFS_BTCUR_LEFTRA) && be32_to_cpu(a->bb_leftsib) != NULLAGBLOCK) {
887 xfs_btree_reada_bufs(cur->bc_mp, cur->bc_private.a.agno, 871 xfs_btree_reada_bufs(cur->bc_mp, cur->bc_private.a.agno,
888 INT_GET(a->bb_leftsib, ARCH_CONVERT), 1); 872 be32_to_cpu(a->bb_leftsib), 1);
889 rval++; 873 rval++;
890 } 874 }
891 if ((lr & XFS_BTCUR_RIGHTRA) && INT_GET(a->bb_rightsib, ARCH_CONVERT) != NULLAGBLOCK) { 875 if ((lr & XFS_BTCUR_RIGHTRA) && be32_to_cpu(a->bb_rightsib) != NULLAGBLOCK) {
892 xfs_btree_reada_bufs(cur->bc_mp, cur->bc_private.a.agno, 876 xfs_btree_reada_bufs(cur->bc_mp, cur->bc_private.a.agno,
893 INT_GET(a->bb_rightsib, ARCH_CONVERT), 1); 877 be32_to_cpu(a->bb_rightsib), 1);
894 rval++; 878 rval++;
895 } 879 }
896 break; 880 break;
897 case XFS_BTNUM_BMAP: 881 case XFS_BTNUM_BMAP:
898 b = XFS_BUF_TO_BMBT_BLOCK(cur->bc_bufs[lev]); 882 b = XFS_BUF_TO_BMBT_BLOCK(cur->bc_bufs[lev]);
899 if ((lr & XFS_BTCUR_LEFTRA) && INT_GET(b->bb_leftsib, ARCH_CONVERT) != NULLDFSBNO) { 883 if ((lr & XFS_BTCUR_LEFTRA) && be64_to_cpu(b->bb_leftsib) != NULLDFSBNO) {
900 xfs_btree_reada_bufl(cur->bc_mp, INT_GET(b->bb_leftsib, ARCH_CONVERT), 1); 884 xfs_btree_reada_bufl(cur->bc_mp, be64_to_cpu(b->bb_leftsib), 1);
901 rval++; 885 rval++;
902 } 886 }
903 if ((lr & XFS_BTCUR_RIGHTRA) && INT_GET(b->bb_rightsib, ARCH_CONVERT) != NULLDFSBNO) { 887 if ((lr & XFS_BTCUR_RIGHTRA) && be64_to_cpu(b->bb_rightsib) != NULLDFSBNO) {
904 xfs_btree_reada_bufl(cur->bc_mp, INT_GET(b->bb_rightsib, ARCH_CONVERT), 1); 888 xfs_btree_reada_bufl(cur->bc_mp, be64_to_cpu(b->bb_rightsib), 1);
905 rval++; 889 rval++;
906 } 890 }
907 break; 891 break;
908 case XFS_BTNUM_INO: 892 case XFS_BTNUM_INO:
909 i = XFS_BUF_TO_INOBT_BLOCK(cur->bc_bufs[lev]); 893 i = XFS_BUF_TO_INOBT_BLOCK(cur->bc_bufs[lev]);
910 if ((lr & XFS_BTCUR_LEFTRA) && INT_GET(i->bb_leftsib, ARCH_CONVERT) != NULLAGBLOCK) { 894 if ((lr & XFS_BTCUR_LEFTRA) && be32_to_cpu(i->bb_leftsib) != NULLAGBLOCK) {
911 xfs_btree_reada_bufs(cur->bc_mp, cur->bc_private.i.agno, 895 xfs_btree_reada_bufs(cur->bc_mp, cur->bc_private.i.agno,
912 INT_GET(i->bb_leftsib, ARCH_CONVERT), 1); 896 be32_to_cpu(i->bb_leftsib), 1);
913 rval++; 897 rval++;
914 } 898 }
915 if ((lr & XFS_BTCUR_RIGHTRA) && INT_GET(i->bb_rightsib, ARCH_CONVERT) != NULLAGBLOCK) { 899 if ((lr & XFS_BTCUR_RIGHTRA) && be32_to_cpu(i->bb_rightsib) != NULLAGBLOCK) {
916 xfs_btree_reada_bufs(cur->bc_mp, cur->bc_private.i.agno, 900 xfs_btree_reada_bufs(cur->bc_mp, cur->bc_private.i.agno,
917 INT_GET(i->bb_rightsib, ARCH_CONVERT), 1); 901 be32_to_cpu(i->bb_rightsib), 1);
918 rval++; 902 rval++;
919 } 903 }
920 break; 904 break;
@@ -946,14 +930,14 @@ xfs_btree_setbuf(
946 return; 930 return;
947 b = XFS_BUF_TO_BLOCK(bp); 931 b = XFS_BUF_TO_BLOCK(bp);
948 if (XFS_BTREE_LONG_PTRS(cur->bc_btnum)) { 932 if (XFS_BTREE_LONG_PTRS(cur->bc_btnum)) {
949 if (INT_GET(b->bb_u.l.bb_leftsib, ARCH_CONVERT) == NULLDFSBNO) 933 if (be64_to_cpu(b->bb_u.l.bb_leftsib) == NULLDFSBNO)
950 cur->bc_ra[lev] |= XFS_BTCUR_LEFTRA; 934 cur->bc_ra[lev] |= XFS_BTCUR_LEFTRA;
951 if (INT_GET(b->bb_u.l.bb_rightsib, ARCH_CONVERT) == NULLDFSBNO) 935 if (be64_to_cpu(b->bb_u.l.bb_rightsib) == NULLDFSBNO)
952 cur->bc_ra[lev] |= XFS_BTCUR_RIGHTRA; 936 cur->bc_ra[lev] |= XFS_BTCUR_RIGHTRA;
953 } else { 937 } else {
954 if (INT_GET(b->bb_u.s.bb_leftsib, ARCH_CONVERT) == NULLAGBLOCK) 938 if (be32_to_cpu(b->bb_u.s.bb_leftsib) == NULLAGBLOCK)
955 cur->bc_ra[lev] |= XFS_BTCUR_LEFTRA; 939 cur->bc_ra[lev] |= XFS_BTCUR_LEFTRA;
956 if (INT_GET(b->bb_u.s.bb_rightsib, ARCH_CONVERT) == NULLAGBLOCK) 940 if (be32_to_cpu(b->bb_u.s.bb_rightsib) == NULLAGBLOCK)
957 cur->bc_ra[lev] |= XFS_BTCUR_RIGHTRA; 941 cur->bc_ra[lev] |= XFS_BTCUR_RIGHTRA;
958 } 942 }
959} 943}
diff --git a/fs/xfs/xfs_btree.h b/fs/xfs/xfs_btree.h
index 09b4e1532a35..44f1bd98064a 100644
--- a/fs/xfs/xfs_btree.h
+++ b/fs/xfs/xfs_btree.h
@@ -1,33 +1,19 @@
1/* 1/*
2 * Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2001,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32#ifndef __XFS_BTREE_H__ 18#ifndef __XFS_BTREE_H__
33#define __XFS_BTREE_H__ 19#define __XFS_BTREE_H__
@@ -53,25 +39,23 @@ struct xfs_trans;
53/* 39/*
54 * Short form header: space allocation btrees. 40 * Short form header: space allocation btrees.
55 */ 41 */
56typedef struct xfs_btree_sblock 42typedef struct xfs_btree_sblock {
57{ 43 __be32 bb_magic; /* magic number for block type */
58 __uint32_t bb_magic; /* magic number for block type */ 44 __be16 bb_level; /* 0 is a leaf */
59 __uint16_t bb_level; /* 0 is a leaf */ 45 __be16 bb_numrecs; /* current # of data records */
60 __uint16_t bb_numrecs; /* current # of data records */ 46 __be32 bb_leftsib; /* left sibling block or NULLAGBLOCK */
61 xfs_agblock_t bb_leftsib; /* left sibling block or NULLAGBLOCK */ 47 __be32 bb_rightsib; /* right sibling block or NULLAGBLOCK */
62 xfs_agblock_t bb_rightsib; /* right sibling block or NULLAGBLOCK */
63} xfs_btree_sblock_t; 48} xfs_btree_sblock_t;
64 49
65/* 50/*
66 * Long form header: bmap btrees. 51 * Long form header: bmap btrees.
67 */ 52 */
68typedef struct xfs_btree_lblock 53typedef struct xfs_btree_lblock {
69{ 54 __be32 bb_magic; /* magic number for block type */
70 __uint32_t bb_magic; /* magic number for block type */ 55 __be16 bb_level; /* 0 is a leaf */
71 __uint16_t bb_level; /* 0 is a leaf */ 56 __be16 bb_numrecs; /* current # of data records */
72 __uint16_t bb_numrecs; /* current # of data records */ 57 __be64 bb_leftsib; /* left sibling block or NULLDFSBNO */
73 xfs_dfsbno_t bb_leftsib; /* left sibling block or NULLDFSBNO */ 58 __be64 bb_rightsib; /* right sibling block or NULLDFSBNO */
74 xfs_dfsbno_t bb_rightsib; /* right sibling block or NULLDFSBNO */
75} xfs_btree_lblock_t; 59} xfs_btree_lblock_t;
76 60
77/* 61/*
@@ -79,24 +63,23 @@ typedef struct xfs_btree_lblock
79 */ 63 */
80typedef struct xfs_btree_hdr 64typedef struct xfs_btree_hdr
81{ 65{
82 __uint32_t bb_magic; /* magic number for block type */ 66 __be32 bb_magic; /* magic number for block type */
83 __uint16_t bb_level; /* 0 is a leaf */ 67 __be16 bb_level; /* 0 is a leaf */
84 __uint16_t bb_numrecs; /* current # of data records */ 68 __be16 bb_numrecs; /* current # of data records */
85} xfs_btree_hdr_t; 69} xfs_btree_hdr_t;
86 70
87typedef struct xfs_btree_block 71typedef struct xfs_btree_block {
88{
89 xfs_btree_hdr_t bb_h; /* header */ 72 xfs_btree_hdr_t bb_h; /* header */
90 union { 73 union {
91 struct { 74 struct {
92 xfs_agblock_t bb_leftsib; 75 __be32 bb_leftsib;
93 xfs_agblock_t bb_rightsib; 76 __be32 bb_rightsib;
94 } s; /* short form pointers */ 77 } s; /* short form pointers */
95 struct { 78 struct {
96 xfs_dfsbno_t bb_leftsib; 79 __be64 bb_leftsib;
97 xfs_dfsbno_t bb_rightsib; 80 __be64 bb_rightsib;
98 } l; /* long form pointers */ 81 } l; /* long form pointers */
99 } bb_u; /* rest */ 82 } bb_u; /* rest */
100} xfs_btree_block_t; 83} xfs_btree_block_t;
101 84
102/* 85/*
@@ -113,12 +96,7 @@ typedef struct xfs_btree_block
113/* 96/*
114 * Boolean to select which form of xfs_btree_block_t.bb_u to use. 97 * Boolean to select which form of xfs_btree_block_t.bb_u to use.
115 */ 98 */
116#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BTREE_LONG_PTRS)
117int xfs_btree_long_ptrs(xfs_btnum_t btnum);
118#define XFS_BTREE_LONG_PTRS(btnum) ((btnum) == XFS_BTNUM_BMAP)
119#else
120#define XFS_BTREE_LONG_PTRS(btnum) ((btnum) == XFS_BTNUM_BMAP) 99#define XFS_BTREE_LONG_PTRS(btnum) ((btnum) == XFS_BTNUM_BMAP)
121#endif
122 100
123/* 101/*
124 * Magic numbers for btree blocks. 102 * Magic numbers for btree blocks.
@@ -165,7 +143,7 @@ typedef struct xfs_btree_cur
165 struct xfs_trans *bc_tp; /* transaction we're in, if any */ 143 struct xfs_trans *bc_tp; /* transaction we're in, if any */
166 struct xfs_mount *bc_mp; /* file system mount struct */ 144 struct xfs_mount *bc_mp; /* file system mount struct */
167 union { 145 union {
168 xfs_alloc_rec_t a; 146 xfs_alloc_rec_incore_t a;
169 xfs_bmbt_irec_t b; 147 xfs_bmbt_irec_t b;
170 xfs_inobt_rec_t i; 148 xfs_inobt_rec_t i;
171 } bc_rec; /* current insert/search record value */ 149 } bc_rec; /* current insert/search record value */
@@ -205,24 +183,10 @@ typedef struct xfs_btree_cur
205/* 183/*
206 * Convert from buffer to btree block header. 184 * Convert from buffer to btree block header.
207 */ 185 */
208#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BUF_TO_BLOCK) 186#define XFS_BUF_TO_BLOCK(bp) ((xfs_btree_block_t *)XFS_BUF_PTR(bp))
209xfs_btree_block_t *xfs_buf_to_block(struct xfs_buf *bp); 187#define XFS_BUF_TO_LBLOCK(bp) ((xfs_btree_lblock_t *)XFS_BUF_PTR(bp))
210#define XFS_BUF_TO_BLOCK(bp) xfs_buf_to_block(bp) 188#define XFS_BUF_TO_SBLOCK(bp) ((xfs_btree_sblock_t *)XFS_BUF_PTR(bp))
211#else 189
212#define XFS_BUF_TO_BLOCK(bp) ((xfs_btree_block_t *)(XFS_BUF_PTR(bp)))
213#endif
214#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BUF_TO_LBLOCK)
215xfs_btree_lblock_t *xfs_buf_to_lblock(struct xfs_buf *bp);
216#define XFS_BUF_TO_LBLOCK(bp) xfs_buf_to_lblock(bp)
217#else
218#define XFS_BUF_TO_LBLOCK(bp) ((xfs_btree_lblock_t *)(XFS_BUF_PTR(bp)))
219#endif
220#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BUF_TO_SBLOCK)
221xfs_btree_sblock_t *xfs_buf_to_sblock(struct xfs_buf *bp);
222#define XFS_BUF_TO_SBLOCK(bp) xfs_buf_to_sblock(bp)
223#else
224#define XFS_BUF_TO_SBLOCK(bp) ((xfs_btree_sblock_t *)(XFS_BUF_PTR(bp)))
225#endif
226 190
227#ifdef __KERNEL__ 191#ifdef __KERNEL__
228 192
@@ -477,106 +441,33 @@ xfs_btree_setbuf(
477/* 441/*
478 * Min and max functions for extlen, agblock, fileoff, and filblks types. 442 * Min and max functions for extlen, agblock, fileoff, and filblks types.
479 */ 443 */
480#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_EXTLEN_MIN)
481xfs_extlen_t xfs_extlen_min(xfs_extlen_t a, xfs_extlen_t b);
482#define XFS_EXTLEN_MIN(a,b) xfs_extlen_min(a,b)
483#else
484#define XFS_EXTLEN_MIN(a,b) \ 444#define XFS_EXTLEN_MIN(a,b) \
485 ((xfs_extlen_t)(a) < (xfs_extlen_t)(b) ? \ 445 ((xfs_extlen_t)(a) < (xfs_extlen_t)(b) ? \
486 (xfs_extlen_t)(a) : (xfs_extlen_t)(b)) 446 (xfs_extlen_t)(a) : (xfs_extlen_t)(b))
487#endif
488#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_EXTLEN_MAX)
489xfs_extlen_t xfs_extlen_max(xfs_extlen_t a, xfs_extlen_t b);
490#define XFS_EXTLEN_MAX(a,b) xfs_extlen_max(a,b)
491#else
492#define XFS_EXTLEN_MAX(a,b) \ 447#define XFS_EXTLEN_MAX(a,b) \
493 ((xfs_extlen_t)(a) > (xfs_extlen_t)(b) ? \ 448 ((xfs_extlen_t)(a) > (xfs_extlen_t)(b) ? \
494 (xfs_extlen_t)(a) : (xfs_extlen_t)(b)) 449 (xfs_extlen_t)(a) : (xfs_extlen_t)(b))
495#endif
496
497#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_AGBLOCK_MIN)
498xfs_agblock_t xfs_agblock_min(xfs_agblock_t a, xfs_agblock_t b);
499#define XFS_AGBLOCK_MIN(a,b) xfs_agblock_min(a,b)
500#else
501#define XFS_AGBLOCK_MIN(a,b) \ 450#define XFS_AGBLOCK_MIN(a,b) \
502 ((xfs_agblock_t)(a) < (xfs_agblock_t)(b) ? \ 451 ((xfs_agblock_t)(a) < (xfs_agblock_t)(b) ? \
503 (xfs_agblock_t)(a) : (xfs_agblock_t)(b)) 452 (xfs_agblock_t)(a) : (xfs_agblock_t)(b))
504#endif
505#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_AGBLOCK_MAX)
506xfs_agblock_t xfs_agblock_max(xfs_agblock_t a, xfs_agblock_t b);
507#define XFS_AGBLOCK_MAX(a,b) xfs_agblock_max(a,b)
508#else
509#define XFS_AGBLOCK_MAX(a,b) \ 453#define XFS_AGBLOCK_MAX(a,b) \
510 ((xfs_agblock_t)(a) > (xfs_agblock_t)(b) ? \ 454 ((xfs_agblock_t)(a) > (xfs_agblock_t)(b) ? \
511 (xfs_agblock_t)(a) : (xfs_agblock_t)(b)) 455 (xfs_agblock_t)(a) : (xfs_agblock_t)(b))
512#endif
513
514#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_FILEOFF_MIN)
515xfs_fileoff_t xfs_fileoff_min(xfs_fileoff_t a, xfs_fileoff_t b);
516#define XFS_FILEOFF_MIN(a,b) xfs_fileoff_min(a,b)
517#else
518#define XFS_FILEOFF_MIN(a,b) \ 456#define XFS_FILEOFF_MIN(a,b) \
519 ((xfs_fileoff_t)(a) < (xfs_fileoff_t)(b) ? \ 457 ((xfs_fileoff_t)(a) < (xfs_fileoff_t)(b) ? \
520 (xfs_fileoff_t)(a) : (xfs_fileoff_t)(b)) 458 (xfs_fileoff_t)(a) : (xfs_fileoff_t)(b))
521#endif
522#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_FILEOFF_MAX)
523xfs_fileoff_t xfs_fileoff_max(xfs_fileoff_t a, xfs_fileoff_t b);
524#define XFS_FILEOFF_MAX(a,b) xfs_fileoff_max(a,b)
525#else
526#define XFS_FILEOFF_MAX(a,b) \ 459#define XFS_FILEOFF_MAX(a,b) \
527 ((xfs_fileoff_t)(a) > (xfs_fileoff_t)(b) ? \ 460 ((xfs_fileoff_t)(a) > (xfs_fileoff_t)(b) ? \
528 (xfs_fileoff_t)(a) : (xfs_fileoff_t)(b)) 461 (xfs_fileoff_t)(a) : (xfs_fileoff_t)(b))
529#endif
530
531#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_FILBLKS_MIN)
532xfs_filblks_t xfs_filblks_min(xfs_filblks_t a, xfs_filblks_t b);
533#define XFS_FILBLKS_MIN(a,b) xfs_filblks_min(a,b)
534#else
535#define XFS_FILBLKS_MIN(a,b) \ 462#define XFS_FILBLKS_MIN(a,b) \
536 ((xfs_filblks_t)(a) < (xfs_filblks_t)(b) ? \ 463 ((xfs_filblks_t)(a) < (xfs_filblks_t)(b) ? \
537 (xfs_filblks_t)(a) : (xfs_filblks_t)(b)) 464 (xfs_filblks_t)(a) : (xfs_filblks_t)(b))
538#endif
539#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_FILBLKS_MAX)
540xfs_filblks_t xfs_filblks_max(xfs_filblks_t a, xfs_filblks_t b);
541#define XFS_FILBLKS_MAX(a,b) xfs_filblks_max(a,b)
542#else
543#define XFS_FILBLKS_MAX(a,b) \ 465#define XFS_FILBLKS_MAX(a,b) \
544 ((xfs_filblks_t)(a) > (xfs_filblks_t)(b) ? \ 466 ((xfs_filblks_t)(a) > (xfs_filblks_t)(b) ? \
545 (xfs_filblks_t)(a) : (xfs_filblks_t)(b)) 467 (xfs_filblks_t)(a) : (xfs_filblks_t)(b))
546#endif 468
547#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_FSB_SANITY_CHECK)
548int xfs_fsb_sanity_check(struct xfs_mount *mp, xfs_fsblock_t fsb);
549#define XFS_FSB_SANITY_CHECK(mp,fsb) xfs_fsb_sanity_check(mp,fsb)
550#else
551#define XFS_FSB_SANITY_CHECK(mp,fsb) \ 469#define XFS_FSB_SANITY_CHECK(mp,fsb) \
552 (XFS_FSB_TO_AGNO(mp, fsb) < mp->m_sb.sb_agcount && \ 470 (XFS_FSB_TO_AGNO(mp, fsb) < mp->m_sb.sb_agcount && \
553 XFS_FSB_TO_AGBNO(mp, fsb) < mp->m_sb.sb_agblocks) 471 XFS_FSB_TO_AGBNO(mp, fsb) < mp->m_sb.sb_agblocks)
554#endif
555
556/*
557 * Macros to set EFSCORRUPTED & return/branch.
558 */
559#define XFS_WANT_CORRUPTED_GOTO(x,l) \
560 { \
561 int fs_is_ok = (x); \
562 ASSERT(fs_is_ok); \
563 if (unlikely(!fs_is_ok)) { \
564 XFS_ERROR_REPORT("XFS_WANT_CORRUPTED_GOTO", \
565 XFS_ERRLEVEL_LOW, NULL); \
566 error = XFS_ERROR(EFSCORRUPTED); \
567 goto l; \
568 } \
569 }
570
571#define XFS_WANT_CORRUPTED_RETURN(x) \
572 { \
573 int fs_is_ok = (x); \
574 ASSERT(fs_is_ok); \
575 if (unlikely(!fs_is_ok)) { \
576 XFS_ERROR_REPORT("XFS_WANT_CORRUPTED_RETURN", \
577 XFS_ERRLEVEL_LOW, NULL); \
578 return XFS_ERROR(EFSCORRUPTED); \
579 } \
580 }
581 472
582#endif /* __XFS_BTREE_H__ */ 473#endif /* __XFS_BTREE_H__ */
diff --git a/fs/xfs/xfs_buf_item.c b/fs/xfs/xfs_buf_item.c
index a264657acfd9..07e2324152b1 100644
--- a/fs/xfs/xfs_buf_item.c
+++ b/fs/xfs/xfs_buf_item.c
@@ -1,57 +1,33 @@
1/* 1/*
2 * Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */
32
33/*
34 * This file contains the implementation of the xfs_buf_log_item.
35 * It contains the item operations used to manipulate the buf log
36 * items as well as utility routines used by the buffer specific
37 * transaction routines.
38 */ 17 */
39
40#include "xfs.h" 18#include "xfs.h"
41 19#include "xfs_fs.h"
42#include "xfs_macros.h"
43#include "xfs_types.h" 20#include "xfs_types.h"
44#include "xfs_inum.h" 21#include "xfs_bit.h"
45#include "xfs_log.h" 22#include "xfs_log.h"
23#include "xfs_inum.h"
46#include "xfs_trans.h" 24#include "xfs_trans.h"
47#include "xfs_buf_item.h"
48#include "xfs_sb.h" 25#include "xfs_sb.h"
49#include "xfs_dir.h" 26#include "xfs_dir.h"
50#include "xfs_dmapi.h" 27#include "xfs_dmapi.h"
51#include "xfs_mount.h" 28#include "xfs_mount.h"
29#include "xfs_buf_item.h"
52#include "xfs_trans_priv.h" 30#include "xfs_trans_priv.h"
53#include "xfs_rw.h"
54#include "xfs_bit.h"
55#include "xfs_error.h" 31#include "xfs_error.h"
56 32
57 33
diff --git a/fs/xfs/xfs_buf_item.h b/fs/xfs/xfs_buf_item.h
index 01aed5f2d579..07c708c2b529 100644
--- a/fs/xfs/xfs_buf_item.h
+++ b/fs/xfs/xfs_buf_item.h
@@ -1,33 +1,19 @@
1/* 1/*
2 * Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2001,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32#ifndef __XFS_BUF_ITEM_H__ 18#ifndef __XFS_BUF_ITEM_H__
33#define __XFS_BUF_ITEM_H__ 19#define __XFS_BUF_ITEM_H__
diff --git a/fs/xfs/xfs_cap.h b/fs/xfs/xfs_cap.h
index 2deac7303758..433ec537f9bd 100644
--- a/fs/xfs/xfs_cap.h
+++ b/fs/xfs/xfs_cap.h
@@ -1,33 +1,19 @@
1/* 1/*
2 * Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32#ifndef __XFS_CAP_H__ 18#ifndef __XFS_CAP_H__
33#define __XFS_CAP_H__ 19#define __XFS_CAP_H__
diff --git a/fs/xfs/xfs_clnt.h b/fs/xfs/xfs_clnt.h
index b3215ffe0be8..328a528b926d 100644
--- a/fs/xfs/xfs_clnt.h
+++ b/fs/xfs/xfs_clnt.h
@@ -1,33 +1,19 @@
1/* 1/*
2 * Copyright (c) 2000-2005 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32#ifndef __XFS_CLNT_H__ 18#ifndef __XFS_CLNT_H__
33#define __XFS_CLNT_H__ 19#define __XFS_CLNT_H__
@@ -55,6 +41,7 @@
55 */ 41 */
56struct xfs_mount_args { 42struct xfs_mount_args {
57 int flags; /* flags -> see XFSMNT_... macros below */ 43 int flags; /* flags -> see XFSMNT_... macros below */
44 int flags2; /* flags -> see XFSMNT2_... macros below */
58 int logbufs; /* Number of log buffers, -1 to default */ 45 int logbufs; /* Number of log buffers, -1 to default */
59 int logbufsize; /* Size of log buffers, -1 to default */ 46 int logbufsize; /* Size of log buffers, -1 to default */
60 char fsname[MAXNAMELEN+1]; /* data device name */ 47 char fsname[MAXNAMELEN+1]; /* data device name */
@@ -68,9 +55,9 @@ struct xfs_mount_args {
68}; 55};
69 56
70/* 57/*
71 * XFS mount option flags 58 * XFS mount option flags -- args->flags1
72 */ 59 */
73#define XFSMNT_CHKLOG 0x00000001 /* check log */ 60#define XFSMNT_COMPAT_ATTR 0x00000001 /* do not use ATTR2 format */
74#define XFSMNT_WSYNC 0x00000002 /* safe mode nfs mount 61#define XFSMNT_WSYNC 0x00000002 /* safe mode nfs mount
75 * compatible */ 62 * compatible */
76#define XFSMNT_INO64 0x00000004 /* move inode numbers up 63#define XFSMNT_INO64 0x00000004 /* move inode numbers up
@@ -91,7 +78,7 @@ struct xfs_mount_args {
91#define XFSMNT_SHARED 0x00001000 /* shared XFS mount */ 78#define XFSMNT_SHARED 0x00001000 /* shared XFS mount */
92#define XFSMNT_IOSIZE 0x00002000 /* optimize for I/O size */ 79#define XFSMNT_IOSIZE 0x00002000 /* optimize for I/O size */
93#define XFSMNT_OSYNCISOSYNC 0x00004000 /* o_sync is REALLY o_sync */ 80#define XFSMNT_OSYNCISOSYNC 0x00004000 /* o_sync is REALLY o_sync */
94 /* (osyncisdsync is now default) */ 81 /* (osyncisdsync is default) */
95#define XFSMNT_32BITINODES 0x00200000 /* restrict inodes to 32 82#define XFSMNT_32BITINODES 0x00200000 /* restrict inodes to 32
96 * bits of address space */ 83 * bits of address space */
97#define XFSMNT_GQUOTA 0x00400000 /* group quota accounting */ 84#define XFSMNT_GQUOTA 0x00400000 /* group quota accounting */
@@ -99,12 +86,19 @@ struct xfs_mount_args {
99 * enforcement */ 86 * enforcement */
100#define XFSMNT_NOUUID 0x01000000 /* Ignore fs uuid */ 87#define XFSMNT_NOUUID 0x01000000 /* Ignore fs uuid */
101#define XFSMNT_DMAPI 0x02000000 /* enable dmapi/xdsm */ 88#define XFSMNT_DMAPI 0x02000000 /* enable dmapi/xdsm */
102#define XFSMNT_NOLOGFLUSH 0x04000000 /* Don't flush for log blocks */ 89#define XFSMNT_BARRIER 0x04000000 /* use write barriers */
103#define XFSMNT_IDELETE 0x08000000 /* inode cluster delete */ 90#define XFSMNT_IDELETE 0x08000000 /* inode cluster delete */
104#define XFSMNT_SWALLOC 0x10000000 /* turn on stripe width 91#define XFSMNT_SWALLOC 0x10000000 /* turn on stripe width
105 * allocation */ 92 * allocation */
106#define XFSMNT_IHASHSIZE 0x20000000 /* inode hash table size */ 93#define XFSMNT_IHASHSIZE 0x20000000 /* inode hash table size */
107#define XFSMNT_DIRSYNC 0x40000000 /* sync creat,link,unlink,rename 94#define XFSMNT_DIRSYNC 0x40000000 /* sync creat,link,unlink,rename
108 * symlink,mkdir,rmdir,mknod */ 95 * symlink,mkdir,rmdir,mknod */
96#define XFSMNT_FLAGS2 0x80000000 /* more flags set in flags2 */
97
98/*
99 * XFS mount option flags -- args->flags2
100 */
101#define XFSMNT2_COMPAT_IOSIZE 0x00000001 /* don't report large preferred
102 * I/O size in stat(2) */
109 103
110#endif /* __XFS_CLNT_H__ */ 104#endif /* __XFS_CLNT_H__ */
diff --git a/fs/xfs/xfs_da_btree.c b/fs/xfs/xfs_da_btree.c
index 8b792ddf2164..473671fa5c13 100644
--- a/fs/xfs/xfs_da_btree.c
+++ b/fs/xfs/xfs_da_btree.c
@@ -1,41 +1,26 @@
1/* 1/*
2 * Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32
33#include "xfs.h" 18#include "xfs.h"
34 19#include "xfs_fs.h"
35#include "xfs_macros.h"
36#include "xfs_types.h" 20#include "xfs_types.h"
37#include "xfs_inum.h" 21#include "xfs_bit.h"
38#include "xfs_log.h" 22#include "xfs_log.h"
23#include "xfs_inum.h"
39#include "xfs_trans.h" 24#include "xfs_trans.h"
40#include "xfs_sb.h" 25#include "xfs_sb.h"
41#include "xfs_ag.h" 26#include "xfs_ag.h"
@@ -43,19 +28,19 @@
43#include "xfs_dir2.h" 28#include "xfs_dir2.h"
44#include "xfs_dmapi.h" 29#include "xfs_dmapi.h"
45#include "xfs_mount.h" 30#include "xfs_mount.h"
46#include "xfs_alloc_btree.h" 31#include "xfs_da_btree.h"
47#include "xfs_bmap_btree.h" 32#include "xfs_bmap_btree.h"
33#include "xfs_alloc_btree.h"
48#include "xfs_ialloc_btree.h" 34#include "xfs_ialloc_btree.h"
49#include "xfs_alloc.h"
50#include "xfs_btree.h"
51#include "xfs_attr_sf.h"
52#include "xfs_dir_sf.h" 35#include "xfs_dir_sf.h"
53#include "xfs_dir2_sf.h" 36#include "xfs_dir2_sf.h"
37#include "xfs_attr_sf.h"
54#include "xfs_dinode.h" 38#include "xfs_dinode.h"
55#include "xfs_inode_item.h"
56#include "xfs_inode.h" 39#include "xfs_inode.h"
40#include "xfs_inode_item.h"
41#include "xfs_alloc.h"
42#include "xfs_btree.h"
57#include "xfs_bmap.h" 43#include "xfs_bmap.h"
58#include "xfs_da_btree.h"
59#include "xfs_attr.h" 44#include "xfs_attr.h"
60#include "xfs_attr_leaf.h" 45#include "xfs_attr_leaf.h"
61#include "xfs_dir_leaf.h" 46#include "xfs_dir_leaf.h"
@@ -64,7 +49,6 @@
64#include "xfs_dir2_block.h" 49#include "xfs_dir2_block.h"
65#include "xfs_dir2_node.h" 50#include "xfs_dir2_node.h"
66#include "xfs_error.h" 51#include "xfs_error.h"
67#include "xfs_bit.h"
68 52
69/* 53/*
70 * xfs_da_btree.c 54 * xfs_da_btree.c
@@ -190,9 +174,6 @@ xfs_da_split(xfs_da_state_t *state)
190 */ 174 */
191 switch (oldblk->magic) { 175 switch (oldblk->magic) {
192 case XFS_ATTR_LEAF_MAGIC: 176 case XFS_ATTR_LEAF_MAGIC:
193#ifndef __KERNEL__
194 return(ENOTTY);
195#else
196 error = xfs_attr_leaf_split(state, oldblk, newblk); 177 error = xfs_attr_leaf_split(state, oldblk, newblk);
197 if ((error != 0) && (error != ENOSPC)) { 178 if ((error != 0) && (error != ENOSPC)) {
198 return(error); /* GROT: attr is inconsistent */ 179 return(error); /* GROT: attr is inconsistent */
@@ -218,7 +199,6 @@ xfs_da_split(xfs_da_state_t *state)
218 return(error); /* GROT: attr inconsistent */ 199 return(error); /* GROT: attr inconsistent */
219 addblk = newblk; 200 addblk = newblk;
220 break; 201 break;
221#endif
222 case XFS_DIR_LEAF_MAGIC: 202 case XFS_DIR_LEAF_MAGIC:
223 ASSERT(XFS_DIR_IS_V1(state->mp)); 203 ASSERT(XFS_DIR_IS_V1(state->mp));
224 error = xfs_dir_leaf_split(state, oldblk, newblk); 204 error = xfs_dir_leaf_split(state, oldblk, newblk);
@@ -449,7 +429,8 @@ xfs_da_node_split(xfs_da_state_t *state, xfs_da_state_blk_t *oldblk,
449 /* 429 /*
450 * With V2 the extra block is data or freespace. 430 * With V2 the extra block is data or freespace.
451 */ 431 */
452 useextra = state->extravalid && XFS_DIR_IS_V1(state->mp); 432 useextra = state->extravalid && (XFS_DIR_IS_V1(state->mp) ||
433 state->args->whichfork == XFS_ATTR_FORK);
453 newcount = 1 + useextra; 434 newcount = 1 + useextra;
454 /* 435 /*
455 * Do we have to split the node? 436 * Do we have to split the node?
@@ -706,18 +687,12 @@ xfs_da_join(xfs_da_state_t *state)
706 */ 687 */
707 switch (drop_blk->magic) { 688 switch (drop_blk->magic) {
708 case XFS_ATTR_LEAF_MAGIC: 689 case XFS_ATTR_LEAF_MAGIC:
709#ifndef __KERNEL__
710 error = ENOTTY;
711#else
712 error = xfs_attr_leaf_toosmall(state, &action); 690 error = xfs_attr_leaf_toosmall(state, &action);
713#endif
714 if (error) 691 if (error)
715 return(error); 692 return(error);
716 if (action == 0) 693 if (action == 0)
717 return(0); 694 return(0);
718#ifdef __KERNEL__
719 xfs_attr_leaf_unbalance(state, drop_blk, save_blk); 695 xfs_attr_leaf_unbalance(state, drop_blk, save_blk);
720#endif
721 break; 696 break;
722 case XFS_DIR_LEAF_MAGIC: 697 case XFS_DIR_LEAF_MAGIC:
723 ASSERT(XFS_DIR_IS_V1(state->mp)); 698 ASSERT(XFS_DIR_IS_V1(state->mp));
@@ -973,13 +948,11 @@ xfs_da_fixhashpath(xfs_da_state_t *state, xfs_da_state_path_t *path)
973 level = path->active-1; 948 level = path->active-1;
974 blk = &path->blk[ level ]; 949 blk = &path->blk[ level ];
975 switch (blk->magic) { 950 switch (blk->magic) {
976#ifdef __KERNEL__
977 case XFS_ATTR_LEAF_MAGIC: 951 case XFS_ATTR_LEAF_MAGIC:
978 lasthash = xfs_attr_leaf_lasthash(blk->bp, &count); 952 lasthash = xfs_attr_leaf_lasthash(blk->bp, &count);
979 if (count == 0) 953 if (count == 0)
980 return; 954 return;
981 break; 955 break;
982#endif
983 case XFS_DIR_LEAF_MAGIC: 956 case XFS_DIR_LEAF_MAGIC:
984 ASSERT(XFS_DIR_IS_V1(state->mp)); 957 ASSERT(XFS_DIR_IS_V1(state->mp));
985 lasthash = xfs_dir_leaf_lasthash(blk->bp, &count); 958 lasthash = xfs_dir_leaf_lasthash(blk->bp, &count);
@@ -1220,12 +1193,10 @@ xfs_da_node_lookup_int(xfs_da_state_t *state, int *result)
1220 blkno = INT_GET(btree->before, ARCH_CONVERT); 1193 blkno = INT_GET(btree->before, ARCH_CONVERT);
1221 } 1194 }
1222 } 1195 }
1223#ifdef __KERNEL__
1224 else if (INT_GET(curr->magic, ARCH_CONVERT) == XFS_ATTR_LEAF_MAGIC) { 1196 else if (INT_GET(curr->magic, ARCH_CONVERT) == XFS_ATTR_LEAF_MAGIC) {
1225 blk->hashval = xfs_attr_leaf_lasthash(blk->bp, NULL); 1197 blk->hashval = xfs_attr_leaf_lasthash(blk->bp, NULL);
1226 break; 1198 break;
1227 } 1199 }
1228#endif
1229 else if (INT_GET(curr->magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC) { 1200 else if (INT_GET(curr->magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC) {
1230 blk->hashval = xfs_dir_leaf_lasthash(blk->bp, NULL); 1201 blk->hashval = xfs_dir_leaf_lasthash(blk->bp, NULL);
1231 break; 1202 break;
@@ -1252,13 +1223,11 @@ xfs_da_node_lookup_int(xfs_da_state_t *state, int *result)
1252 retval = xfs_dir2_leafn_lookup_int(blk->bp, args, 1223 retval = xfs_dir2_leafn_lookup_int(blk->bp, args,
1253 &blk->index, state); 1224 &blk->index, state);
1254 } 1225 }
1255#ifdef __KERNEL__
1256 else if (blk->magic == XFS_ATTR_LEAF_MAGIC) { 1226 else if (blk->magic == XFS_ATTR_LEAF_MAGIC) {
1257 retval = xfs_attr_leaf_lookup_int(blk->bp, args); 1227 retval = xfs_attr_leaf_lookup_int(blk->bp, args);
1258 blk->index = args->index; 1228 blk->index = args->index;
1259 args->blkno = blk->blkno; 1229 args->blkno = blk->blkno;
1260 } 1230 }
1261#endif
1262 if (((retval == ENOENT) || (retval == ENOATTR)) && 1231 if (((retval == ENOENT) || (retval == ENOATTR)) &&
1263 (blk->hashval == args->hashval)) { 1232 (blk->hashval == args->hashval)) {
1264 error = xfs_da_path_shift(state, &state->path, 1, 1, 1233 error = xfs_da_path_shift(state, &state->path, 1, 1,
@@ -1268,12 +1237,10 @@ xfs_da_node_lookup_int(xfs_da_state_t *state, int *result)
1268 if (retval == 0) { 1237 if (retval == 0) {
1269 continue; 1238 continue;
1270 } 1239 }
1271#ifdef __KERNEL__
1272 else if (blk->magic == XFS_ATTR_LEAF_MAGIC) { 1240 else if (blk->magic == XFS_ATTR_LEAF_MAGIC) {
1273 /* path_shift() gives ENOENT */ 1241 /* path_shift() gives ENOENT */
1274 retval = XFS_ERROR(ENOATTR); 1242 retval = XFS_ERROR(ENOATTR);
1275 } 1243 }
1276#endif
1277 } 1244 }
1278 break; 1245 break;
1279 } 1246 }
@@ -1312,11 +1279,9 @@ xfs_da_blk_link(xfs_da_state_t *state, xfs_da_state_blk_t *old_blk,
1312 ASSERT(old_blk->magic == new_blk->magic); 1279 ASSERT(old_blk->magic == new_blk->magic);
1313 1280
1314 switch (old_blk->magic) { 1281 switch (old_blk->magic) {
1315#ifdef __KERNEL__
1316 case XFS_ATTR_LEAF_MAGIC: 1282 case XFS_ATTR_LEAF_MAGIC:
1317 before = xfs_attr_leaf_order(old_blk->bp, new_blk->bp); 1283 before = xfs_attr_leaf_order(old_blk->bp, new_blk->bp);
1318 break; 1284 break;
1319#endif
1320 case XFS_DIR_LEAF_MAGIC: 1285 case XFS_DIR_LEAF_MAGIC:
1321 ASSERT(XFS_DIR_IS_V1(state->mp)); 1286 ASSERT(XFS_DIR_IS_V1(state->mp));
1322 before = xfs_dir_leaf_order(old_blk->bp, new_blk->bp); 1287 before = xfs_dir_leaf_order(old_blk->bp, new_blk->bp);
@@ -1587,12 +1552,10 @@ xfs_da_path_shift(xfs_da_state_t *state, xfs_da_state_path_t *path,
1587 ASSERT(level == path->active-1); 1552 ASSERT(level == path->active-1);
1588 blk->index = 0; 1553 blk->index = 0;
1589 switch(blk->magic) { 1554 switch(blk->magic) {
1590#ifdef __KERNEL__
1591 case XFS_ATTR_LEAF_MAGIC: 1555 case XFS_ATTR_LEAF_MAGIC:
1592 blk->hashval = xfs_attr_leaf_lasthash(blk->bp, 1556 blk->hashval = xfs_attr_leaf_lasthash(blk->bp,
1593 NULL); 1557 NULL);
1594 break; 1558 break;
1595#endif
1596 case XFS_DIR_LEAF_MAGIC: 1559 case XFS_DIR_LEAF_MAGIC:
1597 ASSERT(XFS_DIR_IS_V1(state->mp)); 1560 ASSERT(XFS_DIR_IS_V1(state->mp));
1598 blk->hashval = xfs_dir_leaf_lasthash(blk->bp, 1561 blk->hashval = xfs_dir_leaf_lasthash(blk->bp,
@@ -1626,19 +1589,10 @@ xfs_da_path_shift(xfs_da_state_t *state, xfs_da_state_path_t *path,
1626 * This is implemented with some source-level loop unrolling. 1589 * This is implemented with some source-level loop unrolling.
1627 */ 1590 */
1628xfs_dahash_t 1591xfs_dahash_t
1629xfs_da_hashname(uchar_t *name, int namelen) 1592xfs_da_hashname(const uchar_t *name, int namelen)
1630{ 1593{
1631 xfs_dahash_t hash; 1594 xfs_dahash_t hash;
1632 1595
1633#ifdef SLOWVERSION
1634 /*
1635 * This is the old one-byte-at-a-time version.
1636 */
1637 for (hash = 0; namelen > 0; namelen--)
1638 hash = *name++ ^ rol32(hash, 7);
1639
1640 return(hash);
1641#else
1642 /* 1596 /*
1643 * Do four characters at a time as long as we can. 1597 * Do four characters at a time as long as we can.
1644 */ 1598 */
@@ -1657,12 +1611,9 @@ xfs_da_hashname(uchar_t *name, int namelen)
1657 return (name[0] << 7) ^ (name[1] << 0) ^ rol32(hash, 7 * 2); 1611 return (name[0] << 7) ^ (name[1] << 0) ^ rol32(hash, 7 * 2);
1658 case 1: 1612 case 1:
1659 return (name[0] << 0) ^ rol32(hash, 7 * 1); 1613 return (name[0] << 0) ^ rol32(hash, 7 * 1);
1660 case 0: 1614 default: /* case 0: */
1661 return hash; 1615 return hash;
1662 } 1616 }
1663 /* NOTREACHED */
1664#endif
1665 return 0; /* keep gcc happy */
1666} 1617}
1667 1618
1668/* 1619/*
@@ -2200,20 +2151,16 @@ xfs_da_do_buf(
2200 error = bp ? XFS_BUF_GETERROR(bp) : XFS_ERROR(EIO); 2151 error = bp ? XFS_BUF_GETERROR(bp) : XFS_ERROR(EIO);
2201 break; 2152 break;
2202 case 1: 2153 case 1:
2203#ifndef __KERNEL__
2204 case 2: 2154 case 2:
2205#endif
2206 bp = NULL; 2155 bp = NULL;
2207 error = xfs_trans_read_buf(mp, trans, mp->m_ddev_targp, 2156 error = xfs_trans_read_buf(mp, trans, mp->m_ddev_targp,
2208 mappedbno, nmapped, 0, &bp); 2157 mappedbno, nmapped, 0, &bp);
2209 break; 2158 break;
2210#ifdef __KERNEL__
2211 case 3: 2159 case 3:
2212 xfs_baread(mp->m_ddev_targp, mappedbno, nmapped); 2160 xfs_baread(mp->m_ddev_targp, mappedbno, nmapped);
2213 error = 0; 2161 error = 0;
2214 bp = NULL; 2162 bp = NULL;
2215 break; 2163 break;
2216#endif
2217 } 2164 }
2218 if (error) { 2165 if (error) {
2219 if (bp) 2166 if (bp)
diff --git a/fs/xfs/xfs_da_btree.h b/fs/xfs/xfs_da_btree.h
index 3a9b9e809c60..41352113721a 100644
--- a/fs/xfs/xfs_da_btree.h
+++ b/fs/xfs/xfs_da_btree.h
@@ -1,33 +1,19 @@
1/* 1/*
2 * Copyright (c) 2000, 2002 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000,2002,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32#ifndef __XFS_DA_BTREE_H__ 18#ifndef __XFS_DA_BTREE_H__
33#define __XFS_DA_BTREE_H__ 19#define __XFS_DA_BTREE_H__
@@ -92,72 +78,24 @@ typedef struct xfs_da_node_entry xfs_da_node_entry_t;
92 78
93#define XFS_DA_MAXHASH ((xfs_dahash_t)-1) /* largest valid hash value */ 79#define XFS_DA_MAXHASH ((xfs_dahash_t)-1) /* largest valid hash value */
94 80
95/* 81#define XFS_LBSIZE(mp) (mp)->m_sb.sb_blocksize
96 * Macros used by directory code to interface to the filesystem. 82#define XFS_LBLOG(mp) (mp)->m_sb.sb_blocklog
97 */
98#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_LBSIZE)
99int xfs_lbsize(struct xfs_mount *mp);
100#define XFS_LBSIZE(mp) xfs_lbsize(mp)
101#else
102#define XFS_LBSIZE(mp) ((mp)->m_sb.sb_blocksize)
103#endif
104#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_LBLOG)
105int xfs_lblog(struct xfs_mount *mp);
106#define XFS_LBLOG(mp) xfs_lblog(mp)
107#else
108#define XFS_LBLOG(mp) ((mp)->m_sb.sb_blocklog)
109#endif
110 83
111/*
112 * Macros used by directory code to interface to the kernel
113 */
114
115/*
116 * Macros used to manipulate directory off_t's
117 */
118#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DA_MAKE_BNOENTRY)
119__uint32_t xfs_da_make_bnoentry(struct xfs_mount *mp, xfs_dablk_t bno,
120 int entry);
121#define XFS_DA_MAKE_BNOENTRY(mp,bno,entry) \ 84#define XFS_DA_MAKE_BNOENTRY(mp,bno,entry) \
122 xfs_da_make_bnoentry(mp,bno,entry)
123#else
124#define XFS_DA_MAKE_BNOENTRY(mp,bno,entry) \
125 (((bno) << (mp)->m_dircook_elog) | (entry)) 85 (((bno) << (mp)->m_dircook_elog) | (entry))
126#endif
127#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DA_MAKE_COOKIE)
128xfs_off_t xfs_da_make_cookie(struct xfs_mount *mp, xfs_dablk_t bno, int entry,
129 xfs_dahash_t hash);
130#define XFS_DA_MAKE_COOKIE(mp,bno,entry,hash) \ 86#define XFS_DA_MAKE_COOKIE(mp,bno,entry,hash) \
131 xfs_da_make_cookie(mp,bno,entry,hash)
132#else
133#define XFS_DA_MAKE_COOKIE(mp,bno,entry,hash) \
134 (((xfs_off_t)XFS_DA_MAKE_BNOENTRY(mp, bno, entry) << 32) | (hash)) 87 (((xfs_off_t)XFS_DA_MAKE_BNOENTRY(mp, bno, entry) << 32) | (hash))
135#endif 88#define XFS_DA_COOKIE_HASH(mp,cookie) ((xfs_dahash_t)cookie)
136#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DA_COOKIE_HASH) 89#define XFS_DA_COOKIE_BNO(mp,cookie) \
137xfs_dahash_t xfs_da_cookie_hash(struct xfs_mount *mp, xfs_off_t cookie); 90 ((((xfs_off_t)(cookie) >> 31) == -1LL ? \
138#define XFS_DA_COOKIE_HASH(mp,cookie) xfs_da_cookie_hash(mp,cookie)
139#else
140#define XFS_DA_COOKIE_HASH(mp,cookie) ((xfs_dahash_t)(cookie))
141#endif
142#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DA_COOKIE_BNO)
143xfs_dablk_t xfs_da_cookie_bno(struct xfs_mount *mp, xfs_off_t cookie);
144#define XFS_DA_COOKIE_BNO(mp,cookie) xfs_da_cookie_bno(mp,cookie)
145#else
146#define XFS_DA_COOKIE_BNO(mp,cookie) \
147 (((xfs_off_t)(cookie) >> 31) == -1LL ? \
148 (xfs_dablk_t)0 : \ 91 (xfs_dablk_t)0 : \
149 (xfs_dablk_t)((xfs_off_t)(cookie) >> ((mp)->m_dircook_elog + 32))) 92 (xfs_dablk_t)((xfs_off_t)(cookie) >> \
150#endif 93 ((mp)->m_dircook_elog + 32))))
151#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DA_COOKIE_ENTRY) 94#define XFS_DA_COOKIE_ENTRY(mp,cookie) \
152int xfs_da_cookie_entry(struct xfs_mount *mp, xfs_off_t cookie); 95 ((((xfs_off_t)(cookie) >> 31) == -1LL ? \
153#define XFS_DA_COOKIE_ENTRY(mp,cookie) xfs_da_cookie_entry(mp,cookie)
154#else
155#define XFS_DA_COOKIE_ENTRY(mp,cookie) \
156 (((xfs_off_t)(cookie) >> 31) == -1LL ? \
157 (xfs_dablk_t)0 : \ 96 (xfs_dablk_t)0 : \
158 (xfs_dablk_t)(((xfs_off_t)(cookie) >> 32) & \ 97 (xfs_dablk_t)(((xfs_off_t)(cookie) >> 32) & \
159 ((1 << (mp)->m_dircook_elog) - 1))) 98 ((1 << (mp)->m_dircook_elog) - 1))))
160#endif
161 99
162 100
163/*======================================================================== 101/*========================================================================
@@ -168,7 +106,7 @@ int xfs_da_cookie_entry(struct xfs_mount *mp, xfs_off_t cookie);
168 * Structure to ease passing around component names. 106 * Structure to ease passing around component names.
169 */ 107 */
170typedef struct xfs_da_args { 108typedef struct xfs_da_args {
171 uchar_t *name; /* string (maybe not NULL terminated) */ 109 const uchar_t *name; /* string (maybe not NULL terminated) */
172 int namelen; /* length of string (maybe no NULL) */ 110 int namelen; /* length of string (maybe no NULL) */
173 uchar_t *value; /* set of bytes (maybe contain NULLs) */ 111 uchar_t *value; /* set of bytes (maybe contain NULLs) */
174 int valuelen; /* length of value */ 112 int valuelen; /* length of value */
@@ -314,7 +252,7 @@ xfs_daddr_t xfs_da_reada_buf(struct xfs_trans *trans, struct xfs_inode *dp,
314int xfs_da_shrink_inode(xfs_da_args_t *args, xfs_dablk_t dead_blkno, 252int xfs_da_shrink_inode(xfs_da_args_t *args, xfs_dablk_t dead_blkno,
315 xfs_dabuf_t *dead_buf); 253 xfs_dabuf_t *dead_buf);
316 254
317uint xfs_da_hashname(uchar_t *name_string, int name_length); 255uint xfs_da_hashname(const uchar_t *name_string, int name_length);
318uint xfs_da_log2_roundup(uint i); 256uint xfs_da_log2_roundup(uint i);
319xfs_da_state_t *xfs_da_state_alloc(void); 257xfs_da_state_t *xfs_da_state_alloc(void);
320void xfs_da_state_free(xfs_da_state_t *state); 258void xfs_da_state_free(xfs_da_state_t *state);
diff --git a/fs/xfs/xfs_dfrag.c b/fs/xfs/xfs_dfrag.c
index 681be5c93af5..070259a4254c 100644
--- a/fs/xfs/xfs_dfrag.c
+++ b/fs/xfs/xfs_dfrag.c
@@ -1,58 +1,44 @@
1/* 1/*
2 * Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32
33#include "xfs.h" 18#include "xfs.h"
34#include "xfs_macros.h" 19#include "xfs_fs.h"
35#include "xfs_types.h" 20#include "xfs_types.h"
36#include "xfs_inum.h" 21#include "xfs_bit.h"
37#include "xfs_log.h" 22#include "xfs_log.h"
23#include "xfs_inum.h"
38#include "xfs_trans.h" 24#include "xfs_trans.h"
39#include "xfs_sb.h" 25#include "xfs_sb.h"
26#include "xfs_ag.h"
40#include "xfs_dir.h" 27#include "xfs_dir.h"
41#include "xfs_dir2.h" 28#include "xfs_dir2.h"
42#include "xfs_dmapi.h" 29#include "xfs_dmapi.h"
43#include "xfs_mount.h" 30#include "xfs_mount.h"
44#include "xfs_ag.h"
45#include "xfs_alloc_btree.h"
46#include "xfs_bmap_btree.h" 31#include "xfs_bmap_btree.h"
32#include "xfs_alloc_btree.h"
47#include "xfs_ialloc_btree.h" 33#include "xfs_ialloc_btree.h"
48#include "xfs_btree.h"
49#include "xfs_attr_sf.h"
50#include "xfs_dir_sf.h" 34#include "xfs_dir_sf.h"
51#include "xfs_dir2_sf.h" 35#include "xfs_dir2_sf.h"
36#include "xfs_attr_sf.h"
52#include "xfs_dinode.h" 37#include "xfs_dinode.h"
53#include "xfs_inode_item.h"
54#include "xfs_inode.h" 38#include "xfs_inode.h"
39#include "xfs_inode_item.h"
55#include "xfs_bmap.h" 40#include "xfs_bmap.h"
41#include "xfs_btree.h"
56#include "xfs_ialloc.h" 42#include "xfs_ialloc.h"
57#include "xfs_itable.h" 43#include "xfs_itable.h"
58#include "xfs_dfrag.h" 44#include "xfs_dfrag.h"
@@ -65,9 +51,9 @@
65 */ 51 */
66int 52int
67xfs_swapext( 53xfs_swapext(
68 xfs_swapext_t __user *sxp) 54 xfs_swapext_t __user *sxu)
69{ 55{
70 xfs_swapext_t sx; 56 xfs_swapext_t *sxp;
71 xfs_inode_t *ip=NULL, *tip=NULL, *ips[2]; 57 xfs_inode_t *ip=NULL, *tip=NULL, *ips[2];
72 xfs_trans_t *tp; 58 xfs_trans_t *tp;
73 xfs_mount_t *mp; 59 xfs_mount_t *mp;
@@ -76,20 +62,29 @@ xfs_swapext(
76 vnode_t *vp, *tvp; 62 vnode_t *vp, *tvp;
77 bhv_desc_t *bdp, *tbdp; 63 bhv_desc_t *bdp, *tbdp;
78 vn_bhv_head_t *bhp, *tbhp; 64 vn_bhv_head_t *bhp, *tbhp;
79 uint lock_flags=0; 65 static uint lock_flags = XFS_ILOCK_EXCL | XFS_IOLOCK_EXCL;
80 int ilf_fields, tilf_fields; 66 int ilf_fields, tilf_fields;
81 int error = 0; 67 int error = 0;
82 xfs_ifork_t tempif, *ifp, *tifp; 68 xfs_ifork_t *tempifp, *ifp, *tifp;
83 __uint64_t tmp; 69 __uint64_t tmp;
84 int aforkblks = 0; 70 int aforkblks = 0;
85 int taforkblks = 0; 71 int taforkblks = 0;
86 int locked = 0; 72 char locked = 0;
87 73
88 if (copy_from_user(&sx, sxp, sizeof(sx))) 74 sxp = kmem_alloc(sizeof(xfs_swapext_t), KM_MAYFAIL);
89 return XFS_ERROR(EFAULT); 75 tempifp = kmem_alloc(sizeof(xfs_ifork_t), KM_MAYFAIL);
76 if (!sxp || !tempifp) {
77 error = XFS_ERROR(ENOMEM);
78 goto error0;
79 }
80
81 if (copy_from_user(sxp, sxu, sizeof(xfs_swapext_t))) {
82 error = XFS_ERROR(EFAULT);
83 goto error0;
84 }
90 85
91 /* Pull information for the target fd */ 86 /* Pull information for the target fd */
92 if (((fp = fget((int)sx.sx_fdtarget)) == NULL) || 87 if (((fp = fget((int)sxp->sx_fdtarget)) == NULL) ||
93 ((vp = LINVFS_GET_VP(fp->f_dentry->d_inode)) == NULL)) { 88 ((vp = LINVFS_GET_VP(fp->f_dentry->d_inode)) == NULL)) {
94 error = XFS_ERROR(EINVAL); 89 error = XFS_ERROR(EINVAL);
95 goto error0; 90 goto error0;
@@ -104,7 +99,7 @@ xfs_swapext(
104 ip = XFS_BHVTOI(bdp); 99 ip = XFS_BHVTOI(bdp);
105 } 100 }
106 101
107 if (((tfp = fget((int)sx.sx_fdtmp)) == NULL) || 102 if (((tfp = fget((int)sxp->sx_fdtmp)) == NULL) ||
108 ((tvp = LINVFS_GET_VP(tfp->f_dentry->d_inode)) == NULL)) { 103 ((tvp = LINVFS_GET_VP(tfp->f_dentry->d_inode)) == NULL)) {
109 error = XFS_ERROR(EINVAL); 104 error = XFS_ERROR(EINVAL);
110 goto error0; 105 goto error0;
@@ -131,7 +126,7 @@ xfs_swapext(
131 126
132 mp = ip->i_mount; 127 mp = ip->i_mount;
133 128
134 sbp = &sx.sx_stat; 129 sbp = &sxp->sx_stat;
135 130
136 if (XFS_FORCED_SHUTDOWN(mp)) { 131 if (XFS_FORCED_SHUTDOWN(mp)) {
137 error = XFS_ERROR(EIO); 132 error = XFS_ERROR(EIO);
@@ -148,7 +143,7 @@ xfs_swapext(
148 ips[0] = tip; 143 ips[0] = tip;
149 ips[1] = ip; 144 ips[1] = ip;
150 } 145 }
151 lock_flags = XFS_ILOCK_EXCL | XFS_IOLOCK_EXCL; 146
152 xfs_lock_inodes(ips, 2, 0, lock_flags); 147 xfs_lock_inodes(ips, 2, 0, lock_flags);
153 148
154 /* Check permissions */ 149 /* Check permissions */
@@ -192,9 +187,9 @@ xfs_swapext(
192 } 187 }
193 188
194 /* Verify all data are being swapped */ 189 /* Verify all data are being swapped */
195 if (sx.sx_offset != 0 || 190 if (sxp->sx_offset != 0 ||
196 sx.sx_length != ip->i_d.di_size || 191 sxp->sx_length != ip->i_d.di_size ||
197 sx.sx_length != tip->i_d.di_size) { 192 sxp->sx_length != tip->i_d.di_size) {
198 error = XFS_ERROR(EFAULT); 193 error = XFS_ERROR(EFAULT);
199 goto error0; 194 goto error0;
200 } 195 }
@@ -255,7 +250,8 @@ xfs_swapext(
255 xfs_iunlock(ip, XFS_IOLOCK_EXCL); 250 xfs_iunlock(ip, XFS_IOLOCK_EXCL);
256 xfs_iunlock(tip, XFS_IOLOCK_EXCL); 251 xfs_iunlock(tip, XFS_IOLOCK_EXCL);
257 xfs_trans_cancel(tp, 0); 252 xfs_trans_cancel(tp, 0);
258 return error; 253 locked = 0;
254 goto error0;
259 } 255 }
260 xfs_lock_inodes(ips, 2, 0, XFS_ILOCK_EXCL); 256 xfs_lock_inodes(ips, 2, 0, XFS_ILOCK_EXCL);
261 257
@@ -266,10 +262,8 @@ xfs_swapext(
266 (ip->i_d.di_aformat != XFS_DINODE_FMT_LOCAL)) { 262 (ip->i_d.di_aformat != XFS_DINODE_FMT_LOCAL)) {
267 error = xfs_bmap_count_blocks(tp, ip, XFS_ATTR_FORK, &aforkblks); 263 error = xfs_bmap_count_blocks(tp, ip, XFS_ATTR_FORK, &aforkblks);
268 if (error) { 264 if (error) {
269 xfs_iunlock(ip, lock_flags);
270 xfs_iunlock(tip, lock_flags);
271 xfs_trans_cancel(tp, 0); 265 xfs_trans_cancel(tp, 0);
272 return error; 266 goto error0;
273 } 267 }
274 } 268 }
275 if ( ((XFS_IFORK_Q(tip) != 0) && (tip->i_d.di_anextents > 0)) && 269 if ( ((XFS_IFORK_Q(tip) != 0) && (tip->i_d.di_anextents > 0)) &&
@@ -277,10 +271,8 @@ xfs_swapext(
277 error = xfs_bmap_count_blocks(tp, tip, XFS_ATTR_FORK, 271 error = xfs_bmap_count_blocks(tp, tip, XFS_ATTR_FORK,
278 &taforkblks); 272 &taforkblks);
279 if (error) { 273 if (error) {
280 xfs_iunlock(ip, lock_flags);
281 xfs_iunlock(tip, lock_flags);
282 xfs_trans_cancel(tp, 0); 274 xfs_trans_cancel(tp, 0);
283 return error; 275 goto error0;
284 } 276 }
285 } 277 }
286 278
@@ -289,9 +281,9 @@ xfs_swapext(
289 */ 281 */
290 ifp = &ip->i_df; 282 ifp = &ip->i_df;
291 tifp = &tip->i_df; 283 tifp = &tip->i_df;
292 tempif = *ifp; /* struct copy */ 284 *tempifp = *ifp; /* struct copy */
293 *ifp = *tifp; /* struct copy */ 285 *ifp = *tifp; /* struct copy */
294 *tifp = tempif; /* struct copy */ 286 *tifp = *tempifp; /* struct copy */
295 287
296 /* 288 /*
297 * Fix the on-disk inode values 289 * Fix the on-disk inode values
@@ -369,11 +361,7 @@ xfs_swapext(
369 } 361 }
370 362
371 error = xfs_trans_commit(tp, XFS_TRANS_SWAPEXT, NULL); 363 error = xfs_trans_commit(tp, XFS_TRANS_SWAPEXT, NULL);
372 364 locked = 0;
373 fput(fp);
374 fput(tfp);
375
376 return error;
377 365
378 error0: 366 error0:
379 if (locked) { 367 if (locked) {
@@ -381,8 +369,15 @@ xfs_swapext(
381 xfs_iunlock(tip, lock_flags); 369 xfs_iunlock(tip, lock_flags);
382 } 370 }
383 371
384 if (fp != NULL) fput(fp); 372 if (fp != NULL)
385 if (tfp != NULL) fput(tfp); 373 fput(fp);
374 if (tfp != NULL)
375 fput(tfp);
376
377 if (sxp != NULL)
378 kmem_free(sxp, sizeof(xfs_swapext_t));
379 if (tempifp != NULL)
380 kmem_free(tempifp, sizeof(xfs_ifork_t));
386 381
387 return error; 382 return error;
388} 383}
diff --git a/fs/xfs/xfs_dfrag.h b/fs/xfs/xfs_dfrag.h
index 904860594b8f..f678559abc45 100644
--- a/fs/xfs/xfs_dfrag.h
+++ b/fs/xfs/xfs_dfrag.h
@@ -1,33 +1,19 @@
1/* 1/*
2 * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32#ifndef __XFS_DFRAG_H__ 18#ifndef __XFS_DFRAG_H__
33#define __XFS_DFRAG_H__ 19#define __XFS_DFRAG_H__
diff --git a/fs/xfs/xfs_dinode.h b/fs/xfs/xfs_dinode.h
index f5c932b064e6..c5a0e537ff1a 100644
--- a/fs/xfs/xfs_dinode.h
+++ b/fs/xfs/xfs_dinode.h
@@ -1,33 +1,19 @@
1/* 1/*
2 * Copyright (c) 2000, 2002 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000,2002,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32#ifndef __XFS_DINODE_H__ 18#ifndef __XFS_DINODE_H__
33#define __XFS_DINODE_H__ 19#define __XFS_DINODE_H__
@@ -37,13 +23,8 @@ struct xfs_mount;
37 23
38#define XFS_DINODE_VERSION_1 1 24#define XFS_DINODE_VERSION_1 1
39#define XFS_DINODE_VERSION_2 2 25#define XFS_DINODE_VERSION_2 2
40#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DINODE_GOOD_VERSION) 26#define XFS_DINODE_GOOD_VERSION(v) \
41int xfs_dinode_good_version(int v); 27 (((v) == XFS_DINODE_VERSION_1 || (v) == XFS_DINODE_VERSION_2))
42#define XFS_DINODE_GOOD_VERSION(v) xfs_dinode_good_version(v)
43#else
44#define XFS_DINODE_GOOD_VERSION(v) (((v) == XFS_DINODE_VERSION_1) || \
45 ((v) == XFS_DINODE_VERSION_2))
46#endif
47#define XFS_DINODE_MAGIC 0x494e /* 'IN' */ 28#define XFS_DINODE_MAGIC 0x494e /* 'IN' */
48 29
49/* 30/*
@@ -184,75 +165,30 @@ typedef enum xfs_dinode_fmt
184/* 165/*
185 * Inode size for given fs. 166 * Inode size for given fs.
186 */ 167 */
187#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_LITINO)
188int xfs_litino(struct xfs_mount *mp);
189#define XFS_LITINO(mp) xfs_litino(mp)
190#else
191#define XFS_LITINO(mp) ((mp)->m_litino) 168#define XFS_LITINO(mp) ((mp)->m_litino)
192#endif
193#define XFS_BROOT_SIZE_ADJ \ 169#define XFS_BROOT_SIZE_ADJ \
194 (sizeof(xfs_bmbt_block_t) - sizeof(xfs_bmdr_block_t)) 170 (sizeof(xfs_bmbt_block_t) - sizeof(xfs_bmdr_block_t))
195 171
196/* 172/*
197 * Fork identifiers. Here so utilities can use them without including
198 * xfs_inode.h.
199 */
200#define XFS_DATA_FORK 0
201#define XFS_ATTR_FORK 1
202
203/*
204 * Inode data & attribute fork sizes, per inode. 173 * Inode data & attribute fork sizes, per inode.
205 */ 174 */
206#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_CFORK_Q)
207int xfs_cfork_q_disk(xfs_dinode_core_t *dcp);
208int xfs_cfork_q(xfs_dinode_core_t *dcp);
209#define XFS_CFORK_Q_DISK(dcp) xfs_cfork_q_disk(dcp)
210#define XFS_CFORK_Q(dcp) xfs_cfork_q(dcp)
211#else
212#define XFS_CFORK_Q_DISK(dcp) ((dcp)->di_forkoff != 0)
213#define XFS_CFORK_Q(dcp) ((dcp)->di_forkoff != 0) 175#define XFS_CFORK_Q(dcp) ((dcp)->di_forkoff != 0)
176#define XFS_CFORK_Q_DISK(dcp) ((dcp)->di_forkoff != 0)
214 177
215#endif
216#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_CFORK_BOFF)
217int xfs_cfork_boff_disk(xfs_dinode_core_t *dcp);
218int xfs_cfork_boff(xfs_dinode_core_t *dcp);
219#define XFS_CFORK_BOFF_DISK(dcp) xfs_cfork_boff_disk(dcp)
220#define XFS_CFORK_BOFF(dcp) xfs_cfork_boff(dcp)
221#else
222#define XFS_CFORK_BOFF_DISK(dcp) ((int)(INT_GET((dcp)->di_forkoff, ARCH_CONVERT) << 3))
223#define XFS_CFORK_BOFF(dcp) ((int)((dcp)->di_forkoff << 3)) 178#define XFS_CFORK_BOFF(dcp) ((int)((dcp)->di_forkoff << 3))
179#define XFS_CFORK_BOFF_DISK(dcp) \
180 ((int)(INT_GET((dcp)->di_forkoff, ARCH_CONVERT) << 3))
224 181
225#endif
226#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_CFORK_DSIZE)
227int xfs_cfork_dsize_disk(xfs_dinode_core_t *dcp, struct xfs_mount *mp);
228int xfs_cfork_dsize(xfs_dinode_core_t *dcp, struct xfs_mount *mp);
229#define XFS_CFORK_DSIZE_DISK(dcp,mp) xfs_cfork_dsize_disk(dcp,mp)
230#define XFS_CFORK_DSIZE(dcp,mp) xfs_cfork_dsize(dcp,mp)
231#else
232#define XFS_CFORK_DSIZE_DISK(dcp,mp) \ 182#define XFS_CFORK_DSIZE_DISK(dcp,mp) \
233 (XFS_CFORK_Q_DISK(dcp) ? XFS_CFORK_BOFF_DISK(dcp) : XFS_LITINO(mp)) 183 (XFS_CFORK_Q_DISK(dcp) ? XFS_CFORK_BOFF_DISK(dcp) : XFS_LITINO(mp))
234#define XFS_CFORK_DSIZE(dcp,mp) \ 184#define XFS_CFORK_DSIZE(dcp,mp) \
235 (XFS_CFORK_Q(dcp) ? XFS_CFORK_BOFF(dcp) : XFS_LITINO(mp)) 185 (XFS_CFORK_Q(dcp) ? XFS_CFORK_BOFF(dcp) : XFS_LITINO(mp))
236 186
237#endif
238#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_CFORK_ASIZE)
239int xfs_cfork_asize_disk(xfs_dinode_core_t *dcp, struct xfs_mount *mp);
240int xfs_cfork_asize(xfs_dinode_core_t *dcp, struct xfs_mount *mp);
241#define XFS_CFORK_ASIZE_DISK(dcp,mp) xfs_cfork_asize_disk(dcp,mp)
242#define XFS_CFORK_ASIZE(dcp,mp) xfs_cfork_asize(dcp,mp)
243#else
244#define XFS_CFORK_ASIZE_DISK(dcp,mp) \ 187#define XFS_CFORK_ASIZE_DISK(dcp,mp) \
245 (XFS_CFORK_Q_DISK(dcp) ? XFS_LITINO(mp) - XFS_CFORK_BOFF_DISK(dcp) : 0) 188 (XFS_CFORK_Q_DISK(dcp) ? XFS_LITINO(mp) - XFS_CFORK_BOFF_DISK(dcp) : 0)
246#define XFS_CFORK_ASIZE(dcp,mp) \ 189#define XFS_CFORK_ASIZE(dcp,mp) \
247 (XFS_CFORK_Q(dcp) ? XFS_LITINO(mp) - XFS_CFORK_BOFF(dcp) : 0) 190 (XFS_CFORK_Q(dcp) ? XFS_LITINO(mp) - XFS_CFORK_BOFF(dcp) : 0)
248 191
249#endif
250#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_CFORK_SIZE)
251int xfs_cfork_size_disk(xfs_dinode_core_t *dcp, struct xfs_mount *mp, int w);
252int xfs_cfork_size(xfs_dinode_core_t *dcp, struct xfs_mount *mp, int w);
253#define XFS_CFORK_SIZE_DISK(dcp,mp,w) xfs_cfork_size_disk(dcp,mp,w)
254#define XFS_CFORK_SIZE(dcp,mp,w) xfs_cfork_size(dcp,mp,w)
255#else
256#define XFS_CFORK_SIZE_DISK(dcp,mp,w) \ 192#define XFS_CFORK_SIZE_DISK(dcp,mp,w) \
257 ((w) == XFS_DATA_FORK ? \ 193 ((w) == XFS_DATA_FORK ? \
258 XFS_CFORK_DSIZE_DISK(dcp, mp) : \ 194 XFS_CFORK_DSIZE_DISK(dcp, mp) : \
@@ -261,93 +197,26 @@ int xfs_cfork_size(xfs_dinode_core_t *dcp, struct xfs_mount *mp, int w);
261 ((w) == XFS_DATA_FORK ? \ 197 ((w) == XFS_DATA_FORK ? \
262 XFS_CFORK_DSIZE(dcp, mp) : XFS_CFORK_ASIZE(dcp, mp)) 198 XFS_CFORK_DSIZE(dcp, mp) : XFS_CFORK_ASIZE(dcp, mp))
263 199
264#endif 200#define XFS_DFORK_DSIZE(dip,mp) \
265 201 XFS_CFORK_DSIZE_DISK(&(dip)->di_core, mp)
266#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DFORK_DSIZE) 202#define XFS_DFORK_ASIZE(dip,mp) \
267int xfs_dfork_dsize(xfs_dinode_t *dip, struct xfs_mount *mp); 203 XFS_CFORK_ASIZE_DISK(&(dip)->di_core, mp)
268#define XFS_DFORK_DSIZE(dip,mp) xfs_dfork_dsize(dip,mp) 204#define XFS_DFORK_SIZE(dip,mp,w) \
269#else 205 XFS_CFORK_SIZE_DISK(&(dip)->di_core, mp, w)
270#define XFS_DFORK_DSIZE(dip,mp) XFS_CFORK_DSIZE_DISK(&(dip)->di_core, mp)
271
272#endif
273#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DFORK_ASIZE)
274int xfs_dfork_asize(xfs_dinode_t *dip, struct xfs_mount *mp);
275#define XFS_DFORK_ASIZE(dip,mp) xfs_dfork_asize(dip,mp)
276#else
277#define XFS_DFORK_ASIZE(dip,mp) XFS_CFORK_ASIZE_DISK(&(dip)->di_core, mp)
278 206
279#endif
280#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DFORK_SIZE)
281int xfs_dfork_size(xfs_dinode_t *dip, struct xfs_mount *mp, int w);
282#define XFS_DFORK_SIZE(dip,mp,w) xfs_dfork_size(dip,mp,w)
283#else
284#define XFS_DFORK_SIZE(dip,mp,w) XFS_CFORK_SIZE_DISK(&(dip)->di_core, mp, w)
285
286#endif
287
288/*
289 * Macros for accessing per-fork disk inode information.
290 */
291#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DFORK_Q)
292int xfs_dfork_q(xfs_dinode_t *dip);
293#define XFS_DFORK_Q(dip) xfs_dfork_q(dip)
294#else
295#define XFS_DFORK_Q(dip) XFS_CFORK_Q_DISK(&(dip)->di_core) 207#define XFS_DFORK_Q(dip) XFS_CFORK_Q_DISK(&(dip)->di_core)
296
297#endif
298#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DFORK_BOFF)
299int xfs_dfork_boff(xfs_dinode_t *dip);
300#define XFS_DFORK_BOFF(dip) xfs_dfork_boff(dip)
301#else
302#define XFS_DFORK_BOFF(dip) XFS_CFORK_BOFF_DISK(&(dip)->di_core) 208#define XFS_DFORK_BOFF(dip) XFS_CFORK_BOFF_DISK(&(dip)->di_core)
303
304#endif
305#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DFORK_DPTR)
306char *xfs_dfork_dptr(xfs_dinode_t *dip);
307#define XFS_DFORK_DPTR(dip) xfs_dfork_dptr(dip)
308#else
309#define XFS_DFORK_DPTR(dip) ((dip)->di_u.di_c) 209#define XFS_DFORK_DPTR(dip) ((dip)->di_u.di_c)
310 210#define XFS_DFORK_APTR(dip) \
311#endif 211 ((dip)->di_u.di_c + XFS_DFORK_BOFF(dip))
312#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DFORK_APTR)
313char *xfs_dfork_aptr(xfs_dinode_t *dip);
314#define XFS_DFORK_APTR(dip) xfs_dfork_aptr(dip)
315#else
316#define XFS_DFORK_APTR(dip) ((dip)->di_u.di_c + XFS_DFORK_BOFF(dip))
317
318#endif
319#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DFORK_PTR)
320char *xfs_dfork_ptr(xfs_dinode_t *dip, int w);
321#define XFS_DFORK_PTR(dip,w) xfs_dfork_ptr(dip,w)
322#else
323#define XFS_DFORK_PTR(dip,w) \ 212#define XFS_DFORK_PTR(dip,w) \
324 ((w) == XFS_DATA_FORK ? XFS_DFORK_DPTR(dip) : XFS_DFORK_APTR(dip)) 213 ((w) == XFS_DATA_FORK ? XFS_DFORK_DPTR(dip) : XFS_DFORK_APTR(dip))
325 214#define XFS_CFORK_FORMAT(dcp,w) \
326#endif
327#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_CFORK_FORMAT)
328int xfs_cfork_format(xfs_dinode_core_t *dcp, int w);
329#define XFS_CFORK_FORMAT(dcp,w) xfs_cfork_format(dcp,w)
330#else
331#define XFS_CFORK_FORMAT(dcp,w) \
332 ((w) == XFS_DATA_FORK ? (dcp)->di_format : (dcp)->di_aformat) 215 ((w) == XFS_DATA_FORK ? (dcp)->di_format : (dcp)->di_aformat)
333
334#endif
335#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_CFORK_FMT_SET)
336void xfs_cfork_fmt_set(xfs_dinode_core_t *dcp, int w, int n);
337#define XFS_CFORK_FMT_SET(dcp,w,n) xfs_cfork_fmt_set(dcp,w,n)
338#else
339#define XFS_CFORK_FMT_SET(dcp,w,n) \ 216#define XFS_CFORK_FMT_SET(dcp,w,n) \
340 ((w) == XFS_DATA_FORK ? \ 217 ((w) == XFS_DATA_FORK ? \
341 ((dcp)->di_format = (n)) : \ 218 ((dcp)->di_format = (n)) : ((dcp)->di_aformat = (n)))
342 ((dcp)->di_aformat = (n)))
343 219
344#endif
345#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_CFORK_NEXTENTS)
346int xfs_cfork_nextents_disk(xfs_dinode_core_t *dcp, int w);
347int xfs_cfork_nextents(xfs_dinode_core_t *dcp, int w);
348#define XFS_CFORK_NEXTENTS_DISK(dcp,w) xfs_cfork_nextents_disk(dcp,w)
349#define XFS_CFORK_NEXTENTS(dcp,w) xfs_cfork_nextents(dcp,w)
350#else
351#define XFS_CFORK_NEXTENTS_DISK(dcp,w) \ 220#define XFS_CFORK_NEXTENTS_DISK(dcp,w) \
352 ((w) == XFS_DATA_FORK ? \ 221 ((w) == XFS_DATA_FORK ? \
353 INT_GET((dcp)->di_nextents, ARCH_CONVERT) : \ 222 INT_GET((dcp)->di_nextents, ARCH_CONVERT) : \
@@ -355,31 +224,13 @@ int xfs_cfork_nextents(xfs_dinode_core_t *dcp, int w);
355#define XFS_CFORK_NEXTENTS(dcp,w) \ 224#define XFS_CFORK_NEXTENTS(dcp,w) \
356 ((w) == XFS_DATA_FORK ? (dcp)->di_nextents : (dcp)->di_anextents) 225 ((w) == XFS_DATA_FORK ? (dcp)->di_nextents : (dcp)->di_anextents)
357 226
358#endif
359#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_CFORK_NEXT_SET)
360void xfs_cfork_next_set(xfs_dinode_core_t *dcp, int w, int n);
361#define XFS_CFORK_NEXT_SET(dcp,w,n) xfs_cfork_next_set(dcp,w,n)
362#else
363#define XFS_CFORK_NEXT_SET(dcp,w,n) \ 227#define XFS_CFORK_NEXT_SET(dcp,w,n) \
364 ((w) == XFS_DATA_FORK ? \ 228 ((w) == XFS_DATA_FORK ? \
365 ((dcp)->di_nextents = (n)) : \ 229 ((dcp)->di_nextents = (n)) : ((dcp)->di_anextents = (n)))
366 ((dcp)->di_anextents = (n)))
367
368#endif
369 230
370#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DFORK_NEXTENTS)
371int xfs_dfork_nextents(xfs_dinode_t *dip, int w);
372#define XFS_DFORK_NEXTENTS(dip,w) xfs_dfork_nextents(dip,w)
373#else
374#define XFS_DFORK_NEXTENTS(dip,w) XFS_CFORK_NEXTENTS_DISK(&(dip)->di_core, w) 231#define XFS_DFORK_NEXTENTS(dip,w) XFS_CFORK_NEXTENTS_DISK(&(dip)->di_core, w)
375#endif
376 232
377#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BUF_TO_DINODE) 233#define XFS_BUF_TO_DINODE(bp) ((xfs_dinode_t *)XFS_BUF_PTR(bp))
378xfs_dinode_t *xfs_buf_to_dinode(struct xfs_buf *bp);
379#define XFS_BUF_TO_DINODE(bp) xfs_buf_to_dinode(bp)
380#else
381#define XFS_BUF_TO_DINODE(bp) ((xfs_dinode_t *)(XFS_BUF_PTR(bp)))
382#endif
383 234
384/* 235/*
385 * Values for di_flags 236 * Values for di_flags
diff --git a/fs/xfs/xfs_dir.c b/fs/xfs/xfs_dir.c
index ba30bc7682f2..3dd30391f551 100644
--- a/fs/xfs/xfs_dir.c
+++ b/fs/xfs/xfs_dir.c
@@ -1,59 +1,43 @@
1/* 1/*
2 * Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2001,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32
33#include "xfs.h" 18#include "xfs.h"
34 19#include "xfs_fs.h"
35#include "xfs_macros.h"
36#include "xfs_types.h" 20#include "xfs_types.h"
37#include "xfs_inum.h"
38#include "xfs_log.h" 21#include "xfs_log.h"
22#include "xfs_inum.h"
39#include "xfs_trans.h" 23#include "xfs_trans.h"
40#include "xfs_sb.h" 24#include "xfs_sb.h"
41#include "xfs_dir.h" 25#include "xfs_dir.h"
42#include "xfs_dir2.h" 26#include "xfs_dir2.h"
43#include "xfs_dmapi.h" 27#include "xfs_dmapi.h"
44#include "xfs_mount.h" 28#include "xfs_mount.h"
45#include "xfs_alloc_btree.h" 29#include "xfs_da_btree.h"
46#include "xfs_bmap_btree.h" 30#include "xfs_bmap_btree.h"
31#include "xfs_alloc_btree.h"
47#include "xfs_ialloc_btree.h" 32#include "xfs_ialloc_btree.h"
48#include "xfs_alloc.h" 33#include "xfs_alloc.h"
49#include "xfs_btree.h" 34#include "xfs_btree.h"
50#include "xfs_attr_sf.h"
51#include "xfs_dir_sf.h" 35#include "xfs_dir_sf.h"
52#include "xfs_dir2_sf.h" 36#include "xfs_dir2_sf.h"
37#include "xfs_attr_sf.h"
53#include "xfs_dinode.h" 38#include "xfs_dinode.h"
54#include "xfs_inode.h" 39#include "xfs_inode.h"
55#include "xfs_bmap.h" 40#include "xfs_bmap.h"
56#include "xfs_da_btree.h"
57#include "xfs_dir_leaf.h" 41#include "xfs_dir_leaf.h"
58#include "xfs_error.h" 42#include "xfs_error.h"
59 43
@@ -192,11 +176,23 @@ xfs_dir_mount(xfs_mount_t *mp)
192 uint shortcount, leafcount, count; 176 uint shortcount, leafcount, count;
193 177
194 mp->m_dirversion = 1; 178 mp->m_dirversion = 1;
195 shortcount = (mp->m_attroffset - (uint)sizeof(xfs_dir_sf_hdr_t)) / 179 if (mp->m_flags & XFS_MOUNT_COMPAT_ATTR) {
196 (uint)sizeof(xfs_dir_sf_entry_t); 180 shortcount = (mp->m_attroffset -
197 leafcount = (XFS_LBSIZE(mp) - (uint)sizeof(xfs_dir_leaf_hdr_t)) / 181 (uint)sizeof(xfs_dir_sf_hdr_t)) /
198 ((uint)sizeof(xfs_dir_leaf_entry_t) + 182 (uint)sizeof(xfs_dir_sf_entry_t);
199 (uint)sizeof(xfs_dir_leaf_name_t)); 183 leafcount = (XFS_LBSIZE(mp) -
184 (uint)sizeof(xfs_dir_leaf_hdr_t)) /
185 ((uint)sizeof(xfs_dir_leaf_entry_t) +
186 (uint)sizeof(xfs_dir_leaf_name_t));
187 } else {
188 shortcount = (XFS_BMDR_SPACE_CALC(MINABTPTRS) -
189 (uint)sizeof(xfs_dir_sf_hdr_t)) /
190 (uint)sizeof(xfs_dir_sf_entry_t);
191 leafcount = (XFS_LBSIZE(mp) -
192 (uint)sizeof(xfs_dir_leaf_hdr_t)) /
193 ((uint)sizeof(xfs_dir_leaf_entry_t) +
194 (uint)sizeof(xfs_dir_leaf_name_t));
195 }
200 count = shortcount > leafcount ? shortcount : leafcount; 196 count = shortcount > leafcount ? shortcount : leafcount;
201 mp->m_dircook_elog = xfs_da_log2_roundup(count + 1); 197 mp->m_dircook_elog = xfs_da_log2_roundup(count + 1);
202 ASSERT(mp->m_dircook_elog <= mp->m_sb.sb_blocklog); 198 ASSERT(mp->m_dircook_elog <= mp->m_sb.sb_blocklog);
diff --git a/fs/xfs/xfs_dir.h b/fs/xfs/xfs_dir.h
index 4dbc9f54cca5..488defe86ba6 100644
--- a/fs/xfs/xfs_dir.h
+++ b/fs/xfs/xfs_dir.h
@@ -1,33 +1,19 @@
1/* 1/*
2 * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32#ifndef __XFS_DIR_H__ 18#ifndef __XFS_DIR_H__
33#define __XFS_DIR_H__ 19#define __XFS_DIR_H__
diff --git a/fs/xfs/xfs_dir2.c b/fs/xfs/xfs_dir2.c
index 49fc0a3695ae..022c8398ab62 100644
--- a/fs/xfs/xfs_dir2.c
+++ b/fs/xfs/xfs_dir2.c
@@ -1,46 +1,26 @@
1/* 1/*
2 * Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2001,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32
33/*
34 * XFS v2 directory implmentation.
35 * Top-level and utility routines.
36 */
37
38#include "xfs.h" 18#include "xfs.h"
39 19#include "xfs_fs.h"
40#include "xfs_macros.h"
41#include "xfs_types.h" 20#include "xfs_types.h"
42#include "xfs_inum.h" 21#include "xfs_bit.h"
43#include "xfs_log.h" 22#include "xfs_log.h"
23#include "xfs_inum.h"
44#include "xfs_trans.h" 24#include "xfs_trans.h"
45#include "xfs_sb.h" 25#include "xfs_sb.h"
46#include "xfs_ag.h" 26#include "xfs_ag.h"
@@ -48,16 +28,16 @@
48#include "xfs_dir2.h" 28#include "xfs_dir2.h"
49#include "xfs_dmapi.h" 29#include "xfs_dmapi.h"
50#include "xfs_mount.h" 30#include "xfs_mount.h"
51#include "xfs_alloc_btree.h" 31#include "xfs_da_btree.h"
52#include "xfs_bmap_btree.h" 32#include "xfs_bmap_btree.h"
53#include "xfs_attr_sf.h" 33#include "xfs_alloc_btree.h"
54#include "xfs_dir_sf.h" 34#include "xfs_dir_sf.h"
55#include "xfs_dir2_sf.h" 35#include "xfs_dir2_sf.h"
36#include "xfs_attr_sf.h"
56#include "xfs_dinode.h" 37#include "xfs_dinode.h"
57#include "xfs_inode_item.h"
58#include "xfs_inode.h" 38#include "xfs_inode.h"
39#include "xfs_inode_item.h"
59#include "xfs_bmap.h" 40#include "xfs_bmap.h"
60#include "xfs_da_btree.h"
61#include "xfs_dir_leaf.h" 41#include "xfs_dir_leaf.h"
62#include "xfs_dir2_data.h" 42#include "xfs_dir2_data.h"
63#include "xfs_dir2_leaf.h" 43#include "xfs_dir2_leaf.h"
@@ -65,7 +45,6 @@
65#include "xfs_dir2_node.h" 45#include "xfs_dir2_node.h"
66#include "xfs_dir2_trace.h" 46#include "xfs_dir2_trace.h"
67#include "xfs_error.h" 47#include "xfs_error.h"
68#include "xfs_bit.h"
69 48
70/* 49/*
71 * Declarations for interface routines. 50 * Declarations for interface routines.
diff --git a/fs/xfs/xfs_dir2.h b/fs/xfs/xfs_dir2.h
index 8f4fc7f23bcd..7e24ffeda9e1 100644
--- a/fs/xfs/xfs_dir2.h
+++ b/fs/xfs/xfs_dir2.h
@@ -1,33 +1,19 @@
1/* 1/*
2 * Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2001,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32#ifndef __XFS_DIR2_H__ 18#ifndef __XFS_DIR2_H__
33#define __XFS_DIR2_H__ 19#define __XFS_DIR2_H__
diff --git a/fs/xfs/xfs_dir2_block.c b/fs/xfs/xfs_dir2_block.c
index bc4c40fcd479..31bc99faa704 100644
--- a/fs/xfs/xfs_dir2_block.c
+++ b/fs/xfs/xfs_dir2_block.c
@@ -1,61 +1,39 @@
1/* 1/*
2 * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32
33/*
34 * xfs_dir2_block.c
35 * XFS V2 directory implementation, single-block form.
36 * See xfs_dir2_block.h for the format.
37 */
38
39#include "xfs.h" 18#include "xfs.h"
40 19#include "xfs_fs.h"
41#include "xfs_macros.h"
42#include "xfs_types.h" 20#include "xfs_types.h"
43#include "xfs_inum.h"
44#include "xfs_log.h" 21#include "xfs_log.h"
22#include "xfs_inum.h"
45#include "xfs_trans.h" 23#include "xfs_trans.h"
46#include "xfs_sb.h" 24#include "xfs_sb.h"
47#include "xfs_dir.h" 25#include "xfs_dir.h"
48#include "xfs_dir2.h" 26#include "xfs_dir2.h"
49#include "xfs_dmapi.h" 27#include "xfs_dmapi.h"
50#include "xfs_mount.h" 28#include "xfs_mount.h"
29#include "xfs_da_btree.h"
51#include "xfs_bmap_btree.h" 30#include "xfs_bmap_btree.h"
52#include "xfs_attr_sf.h"
53#include "xfs_dir_sf.h" 31#include "xfs_dir_sf.h"
54#include "xfs_dir2_sf.h" 32#include "xfs_dir2_sf.h"
33#include "xfs_attr_sf.h"
55#include "xfs_dinode.h" 34#include "xfs_dinode.h"
56#include "xfs_inode_item.h"
57#include "xfs_inode.h" 35#include "xfs_inode.h"
58#include "xfs_da_btree.h" 36#include "xfs_inode_item.h"
59#include "xfs_dir_leaf.h" 37#include "xfs_dir_leaf.h"
60#include "xfs_dir2_data.h" 38#include "xfs_dir2_data.h"
61#include "xfs_dir2_leaf.h" 39#include "xfs_dir2_leaf.h"
@@ -1234,7 +1212,7 @@ xfs_dir2_sf_to_block(
1234 /* 1212 /*
1235 * Sort the leaf entries by hash value. 1213 * Sort the leaf entries by hash value.
1236 */ 1214 */
1237 qsort(blp, INT_GET(btp->count, ARCH_CONVERT), sizeof(*blp), xfs_dir2_block_sort); 1215 xfs_sort(blp, INT_GET(btp->count, ARCH_CONVERT), sizeof(*blp), xfs_dir2_block_sort);
1238 /* 1216 /*
1239 * Log the leaf entry area and tail. 1217 * Log the leaf entry area and tail.
1240 * Already logged the header in data_init, ignore needlog. 1218 * Already logged the header in data_init, ignore needlog.
diff --git a/fs/xfs/xfs_dir2_block.h b/fs/xfs/xfs_dir2_block.h
index 5a578b84e246..a2e5cb98a838 100644
--- a/fs/xfs/xfs_dir2_block.h
+++ b/fs/xfs/xfs_dir2_block.h
@@ -1,33 +1,19 @@
1/* 1/*
2 * Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2001,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32#ifndef __XFS_DIR2_BLOCK_H__ 18#ifndef __XFS_DIR2_BLOCK_H__
33#define __XFS_DIR2_BLOCK_H__ 19#define __XFS_DIR2_BLOCK_H__
@@ -74,53 +60,37 @@ typedef struct xfs_dir2_block {
74/* 60/*
75 * Pointer to the leaf header embedded in a data block (1-block format) 61 * Pointer to the leaf header embedded in a data block (1-block format)
76 */ 62 */
77#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR2_BLOCK_TAIL_P)
78xfs_dir2_block_tail_t *
79xfs_dir2_block_tail_p(struct xfs_mount *mp, xfs_dir2_block_t *block);
80#define XFS_DIR2_BLOCK_TAIL_P(mp,block) xfs_dir2_block_tail_p(mp,block) 63#define XFS_DIR2_BLOCK_TAIL_P(mp,block) xfs_dir2_block_tail_p(mp,block)
81#else 64static inline xfs_dir2_block_tail_t *
82#define XFS_DIR2_BLOCK_TAIL_P(mp,block) \ 65xfs_dir2_block_tail_p(struct xfs_mount *mp, xfs_dir2_block_t *block)
83 (((xfs_dir2_block_tail_t *)((char *)(block) + (mp)->m_dirblksize)) - 1) 66{
84#endif 67 return (((xfs_dir2_block_tail_t *)
68 ((char *)(block) + (mp)->m_dirblksize)) - 1);
69}
85 70
86/* 71/*
87 * Pointer to the leaf entries embedded in a data block (1-block format) 72 * Pointer to the leaf entries embedded in a data block (1-block format)
88 */ 73 */
89#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR2_BLOCK_LEAF_P) 74#define XFS_DIR2_BLOCK_LEAF_P(btp) xfs_dir2_block_leaf_p(btp)
90struct xfs_dir2_leaf_entry *xfs_dir2_block_leaf_p(xfs_dir2_block_tail_t *btp); 75static inline struct xfs_dir2_leaf_entry *
91#define XFS_DIR2_BLOCK_LEAF_P(btp) \ 76xfs_dir2_block_leaf_p(xfs_dir2_block_tail_t *btp)
92 xfs_dir2_block_leaf_p(btp) 77{
93#else 78 return (((struct xfs_dir2_leaf_entry *)
94#define XFS_DIR2_BLOCK_LEAF_P(btp) \ 79 (btp)) - INT_GET((btp)->count, ARCH_CONVERT));
95 (((struct xfs_dir2_leaf_entry *)(btp)) - INT_GET((btp)->count, ARCH_CONVERT)) 80}
96#endif
97 81
98/* 82/*
99 * Function declarations. 83 * Function declarations.
100 */ 84 */
101 85extern int xfs_dir2_block_addname(struct xfs_da_args *args);
102extern int 86extern int xfs_dir2_block_getdents(struct xfs_trans *tp, struct xfs_inode *dp,
103 xfs_dir2_block_addname(struct xfs_da_args *args); 87 struct uio *uio, int *eofp,
104 88 struct xfs_dirent *dbp, xfs_dir2_put_t put);
105extern int 89extern int xfs_dir2_block_lookup(struct xfs_da_args *args);
106 xfs_dir2_block_getdents(struct xfs_trans *tp, struct xfs_inode *dp, 90extern int xfs_dir2_block_removename(struct xfs_da_args *args);
107 struct uio *uio, int *eofp, struct xfs_dirent *dbp, 91extern int xfs_dir2_block_replace(struct xfs_da_args *args);
108 xfs_dir2_put_t put); 92extern int xfs_dir2_leaf_to_block(struct xfs_da_args *args,
109 93 struct xfs_dabuf *lbp, struct xfs_dabuf *dbp);
110extern int 94extern int xfs_dir2_sf_to_block(struct xfs_da_args *args);
111 xfs_dir2_block_lookup(struct xfs_da_args *args);
112
113extern int
114 xfs_dir2_block_removename(struct xfs_da_args *args);
115
116extern int
117 xfs_dir2_block_replace(struct xfs_da_args *args);
118
119extern int
120 xfs_dir2_leaf_to_block(struct xfs_da_args *args, struct xfs_dabuf *lbp,
121 struct xfs_dabuf *dbp);
122
123extern int
124 xfs_dir2_sf_to_block(struct xfs_da_args *args);
125 95
126#endif /* __XFS_DIR2_BLOCK_H__ */ 96#endif /* __XFS_DIR2_BLOCK_H__ */
diff --git a/fs/xfs/xfs_dir2_data.c b/fs/xfs/xfs_dir2_data.c
index a0aa0e44ff9d..5b7c47e2f14a 100644
--- a/fs/xfs/xfs_dir2_data.c
+++ b/fs/xfs/xfs_dir2_data.c
@@ -1,60 +1,38 @@
1/* 1/*
2 * Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */
32
33/*
34 * xfs_dir2_data.c
35 * Core data block handling routines for XFS V2 directories.
36 * See xfs_dir2_data.h for data structures.
37 */ 17 */
38
39#include "xfs.h" 18#include "xfs.h"
40 19#include "xfs_fs.h"
41#include "xfs_macros.h"
42#include "xfs_types.h" 20#include "xfs_types.h"
43#include "xfs_inum.h"
44#include "xfs_log.h" 21#include "xfs_log.h"
22#include "xfs_inum.h"
45#include "xfs_trans.h" 23#include "xfs_trans.h"
46#include "xfs_sb.h" 24#include "xfs_sb.h"
47#include "xfs_dir.h" 25#include "xfs_dir.h"
48#include "xfs_dir2.h" 26#include "xfs_dir2.h"
49#include "xfs_dmapi.h" 27#include "xfs_dmapi.h"
50#include "xfs_mount.h" 28#include "xfs_mount.h"
29#include "xfs_da_btree.h"
51#include "xfs_bmap_btree.h" 30#include "xfs_bmap_btree.h"
52#include "xfs_attr_sf.h"
53#include "xfs_dir_sf.h" 31#include "xfs_dir_sf.h"
54#include "xfs_dir2_sf.h" 32#include "xfs_dir2_sf.h"
33#include "xfs_attr_sf.h"
55#include "xfs_dinode.h" 34#include "xfs_dinode.h"
56#include "xfs_inode.h" 35#include "xfs_inode.h"
57#include "xfs_da_btree.h"
58#include "xfs_dir_leaf.h" 36#include "xfs_dir_leaf.h"
59#include "xfs_dir2_data.h" 37#include "xfs_dir2_data.h"
60#include "xfs_dir2_leaf.h" 38#include "xfs_dir2_leaf.h"
diff --git a/fs/xfs/xfs_dir2_data.h b/fs/xfs/xfs_dir2_data.h
index 476cac920bf5..5e3a7f9ec735 100644
--- a/fs/xfs/xfs_dir2_data.h
+++ b/fs/xfs/xfs_dir2_data.h
@@ -1,33 +1,19 @@
1/* 1/*
2 * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32#ifndef __XFS_DIR2_DATA_H__ 18#ifndef __XFS_DIR2_DATA_H__
33#define __XFS_DIR2_DATA_H__ 19#define __XFS_DIR2_DATA_H__
@@ -137,88 +123,65 @@ typedef struct xfs_dir2_data {
137/* 123/*
138 * Size of a data entry. 124 * Size of a data entry.
139 */ 125 */
140#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR2_DATA_ENTSIZE)
141int xfs_dir2_data_entsize(int n);
142#define XFS_DIR2_DATA_ENTSIZE(n) xfs_dir2_data_entsize(n) 126#define XFS_DIR2_DATA_ENTSIZE(n) xfs_dir2_data_entsize(n)
143#else 127static inline int xfs_dir2_data_entsize(int n)
144#define XFS_DIR2_DATA_ENTSIZE(n) \ 128{
145 ((int)(roundup(offsetof(xfs_dir2_data_entry_t, name[0]) + (n) + \ 129 return (int)roundup(offsetof(xfs_dir2_data_entry_t, name[0]) + (n) + \
146 (uint)sizeof(xfs_dir2_data_off_t), XFS_DIR2_DATA_ALIGN))) 130 (uint)sizeof(xfs_dir2_data_off_t), XFS_DIR2_DATA_ALIGN);
147#endif 131}
148 132
149/* 133/*
150 * Pointer to an entry's tag word. 134 * Pointer to an entry's tag word.
151 */ 135 */
152#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR2_DATA_ENTRY_TAG_P)
153xfs_dir2_data_off_t *xfs_dir2_data_entry_tag_p(xfs_dir2_data_entry_t *dep);
154#define XFS_DIR2_DATA_ENTRY_TAG_P(dep) xfs_dir2_data_entry_tag_p(dep) 136#define XFS_DIR2_DATA_ENTRY_TAG_P(dep) xfs_dir2_data_entry_tag_p(dep)
155#else 137static inline xfs_dir2_data_off_t *
156#define XFS_DIR2_DATA_ENTRY_TAG_P(dep) \ 138xfs_dir2_data_entry_tag_p(xfs_dir2_data_entry_t *dep)
157 ((xfs_dir2_data_off_t *)\ 139{
158 ((char *)(dep) + XFS_DIR2_DATA_ENTSIZE((dep)->namelen) - \ 140 return (xfs_dir2_data_off_t *) \
159 (uint)sizeof(xfs_dir2_data_off_t))) 141 ((char *)(dep) + XFS_DIR2_DATA_ENTSIZE((dep)->namelen) - \
160#endif 142 (uint)sizeof(xfs_dir2_data_off_t));
143}
161 144
162/* 145/*
163 * Pointer to a freespace's tag word. 146 * Pointer to a freespace's tag word.
164 */ 147 */
165#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR2_DATA_UNUSED_TAG_P)
166xfs_dir2_data_off_t *xfs_dir2_data_unused_tag_p(xfs_dir2_data_unused_t *dup);
167#define XFS_DIR2_DATA_UNUSED_TAG_P(dup) \ 148#define XFS_DIR2_DATA_UNUSED_TAG_P(dup) \
168 xfs_dir2_data_unused_tag_p(dup) 149 xfs_dir2_data_unused_tag_p(dup)
169#else 150static inline xfs_dir2_data_off_t *
170#define XFS_DIR2_DATA_UNUSED_TAG_P(dup) \ 151xfs_dir2_data_unused_tag_p(xfs_dir2_data_unused_t *dup)
171 ((xfs_dir2_data_off_t *)\ 152{
172 ((char *)(dup) + INT_GET((dup)->length, ARCH_CONVERT) \ 153 return (xfs_dir2_data_off_t *) \
173 - (uint)sizeof(xfs_dir2_data_off_t))) 154 ((char *)(dup) + INT_GET((dup)->length, ARCH_CONVERT) \
174#endif 155 - (uint)sizeof(xfs_dir2_data_off_t));
156}
175 157
176/* 158/*
177 * Function declarations. 159 * Function declarations.
178 */ 160 */
179
180#ifdef DEBUG 161#ifdef DEBUG
181extern void 162extern void xfs_dir2_data_check(struct xfs_inode *dp, struct xfs_dabuf *bp);
182 xfs_dir2_data_check(struct xfs_inode *dp, struct xfs_dabuf *bp);
183#else 163#else
184#define xfs_dir2_data_check(dp,bp) 164#define xfs_dir2_data_check(dp,bp)
185#endif 165#endif
186 166extern xfs_dir2_data_free_t *xfs_dir2_data_freefind(xfs_dir2_data_t *d,
187extern xfs_dir2_data_free_t * 167 xfs_dir2_data_unused_t *dup);
188 xfs_dir2_data_freefind(xfs_dir2_data_t *d, 168extern xfs_dir2_data_free_t *xfs_dir2_data_freeinsert(xfs_dir2_data_t *d,
189 xfs_dir2_data_unused_t *dup); 169 xfs_dir2_data_unused_t *dup, int *loghead);
190 170extern void xfs_dir2_data_freescan(struct xfs_mount *mp, xfs_dir2_data_t *d,
191extern xfs_dir2_data_free_t * 171 int *loghead, char *aendp);
192 xfs_dir2_data_freeinsert(xfs_dir2_data_t *d, 172extern int xfs_dir2_data_init(struct xfs_da_args *args, xfs_dir2_db_t blkno,
193 xfs_dir2_data_unused_t *dup, int *loghead); 173 struct xfs_dabuf **bpp);
194 174extern void xfs_dir2_data_log_entry(struct xfs_trans *tp, struct xfs_dabuf *bp,
195extern void
196 xfs_dir2_data_freescan(struct xfs_mount *mp, xfs_dir2_data_t *d,
197 int *loghead, char *aendp);
198
199extern int
200 xfs_dir2_data_init(struct xfs_da_args *args, xfs_dir2_db_t blkno,
201 struct xfs_dabuf **bpp);
202
203extern void
204 xfs_dir2_data_log_entry(struct xfs_trans *tp, struct xfs_dabuf *bp,
205 xfs_dir2_data_entry_t *dep); 175 xfs_dir2_data_entry_t *dep);
206 176extern void xfs_dir2_data_log_header(struct xfs_trans *tp,
207extern void 177 struct xfs_dabuf *bp);
208 xfs_dir2_data_log_header(struct xfs_trans *tp, struct xfs_dabuf *bp); 178extern void xfs_dir2_data_log_unused(struct xfs_trans *tp, struct xfs_dabuf *bp,
209 179 xfs_dir2_data_unused_t *dup);
210extern void 180extern void xfs_dir2_data_make_free(struct xfs_trans *tp, struct xfs_dabuf *bp,
211 xfs_dir2_data_log_unused(struct xfs_trans *tp, struct xfs_dabuf *bp,
212 xfs_dir2_data_unused_t *dup);
213
214extern void
215 xfs_dir2_data_make_free(struct xfs_trans *tp, struct xfs_dabuf *bp,
216 xfs_dir2_data_aoff_t offset, 181 xfs_dir2_data_aoff_t offset,
217 xfs_dir2_data_aoff_t len, int *needlogp, 182 xfs_dir2_data_aoff_t len, int *needlogp,
218 int *needscanp); 183 int *needscanp);
219 184extern void xfs_dir2_data_use_free(struct xfs_trans *tp, struct xfs_dabuf *bp,
220extern void
221 xfs_dir2_data_use_free(struct xfs_trans *tp, struct xfs_dabuf *bp,
222 xfs_dir2_data_unused_t *dup, 185 xfs_dir2_data_unused_t *dup,
223 xfs_dir2_data_aoff_t offset, 186 xfs_dir2_data_aoff_t offset,
224 xfs_dir2_data_aoff_t len, int *needlogp, 187 xfs_dir2_data_aoff_t len, int *needlogp,
diff --git a/fs/xfs/xfs_dir2_leaf.c b/fs/xfs/xfs_dir2_leaf.c
index 056f5283904b..d342b6b55239 100644
--- a/fs/xfs/xfs_dir2_leaf.c
+++ b/fs/xfs/xfs_dir2_leaf.c
@@ -1,49 +1,26 @@
1/* 1/*
2 * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */
32
33/*
34 * xfs_dir2_leaf.c
35 * XFS directory version 2 implementation - single leaf form
36 * see xfs_dir2_leaf.h for data structures.
37 * These directories have multiple XFS_DIR2_DATA blocks and one
38 * XFS_DIR2_LEAF1 block containing the hash table and freespace map.
39 */ 17 */
40
41#include "xfs.h" 18#include "xfs.h"
42 19#include "xfs_fs.h"
43#include "xfs_macros.h"
44#include "xfs_types.h" 20#include "xfs_types.h"
45#include "xfs_inum.h" 21#include "xfs_bit.h"
46#include "xfs_log.h" 22#include "xfs_log.h"
23#include "xfs_inum.h"
47#include "xfs_trans.h" 24#include "xfs_trans.h"
48#include "xfs_sb.h" 25#include "xfs_sb.h"
49#include "xfs_ag.h" 26#include "xfs_ag.h"
@@ -51,6 +28,7 @@
51#include "xfs_dir2.h" 28#include "xfs_dir2.h"
52#include "xfs_dmapi.h" 29#include "xfs_dmapi.h"
53#include "xfs_mount.h" 30#include "xfs_mount.h"
31#include "xfs_da_btree.h"
54#include "xfs_bmap_btree.h" 32#include "xfs_bmap_btree.h"
55#include "xfs_attr_sf.h" 33#include "xfs_attr_sf.h"
56#include "xfs_dir_sf.h" 34#include "xfs_dir_sf.h"
@@ -58,14 +36,12 @@
58#include "xfs_dinode.h" 36#include "xfs_dinode.h"
59#include "xfs_inode.h" 37#include "xfs_inode.h"
60#include "xfs_bmap.h" 38#include "xfs_bmap.h"
61#include "xfs_da_btree.h"
62#include "xfs_dir2_data.h" 39#include "xfs_dir2_data.h"
63#include "xfs_dir2_leaf.h" 40#include "xfs_dir2_leaf.h"
64#include "xfs_dir2_block.h" 41#include "xfs_dir2_block.h"
65#include "xfs_dir2_node.h" 42#include "xfs_dir2_node.h"
66#include "xfs_dir2_trace.h" 43#include "xfs_dir2_trace.h"
67#include "xfs_error.h" 44#include "xfs_error.h"
68#include "xfs_bit.h"
69 45
70/* 46/*
71 * Local function declarations. 47 * Local function declarations.
diff --git a/fs/xfs/xfs_dir2_leaf.h b/fs/xfs/xfs_dir2_leaf.h
index 3303cd6f4c00..1393993d61e9 100644
--- a/fs/xfs/xfs_dir2_leaf.h
+++ b/fs/xfs/xfs_dir2_leaf.h
@@ -1,41 +1,23 @@
1/* 1/*
2 * Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2001,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32#ifndef __XFS_DIR2_LEAF_H__ 18#ifndef __XFS_DIR2_LEAF_H__
33#define __XFS_DIR2_LEAF_H__ 19#define __XFS_DIR2_LEAF_H__
34 20
35/*
36 * Directory version 2, leaf block structures.
37 */
38
39struct uio; 21struct uio;
40struct xfs_dabuf; 22struct xfs_dabuf;
41struct xfs_da_args; 23struct xfs_da_args;
@@ -44,10 +26,6 @@ struct xfs_mount;
44struct xfs_trans; 26struct xfs_trans;
45 27
46/* 28/*
47 * Constants.
48 */
49
50/*
51 * Offset of the leaf/node space. First block in this space 29 * Offset of the leaf/node space. First block in this space
52 * is the btree root. 30 * is the btree root.
53 */ 31 */
@@ -57,10 +35,6 @@ struct xfs_trans;
57 XFS_DIR2_BYTE_TO_DB(mp, XFS_DIR2_LEAF_OFFSET) 35 XFS_DIR2_BYTE_TO_DB(mp, XFS_DIR2_LEAF_OFFSET)
58 36
59/* 37/*
60 * Types.
61 */
62
63/*
64 * Offset in data space of a data entry. 38 * Offset in data space of a data entry.
65 */ 39 */
66typedef __uint32_t xfs_dir2_dataptr_t; 40typedef __uint32_t xfs_dir2_dataptr_t;
@@ -68,10 +42,6 @@ typedef __uint32_t xfs_dir2_dataptr_t;
68#define XFS_DIR2_NULL_DATAPTR ((xfs_dir2_dataptr_t)0) 42#define XFS_DIR2_NULL_DATAPTR ((xfs_dir2_dataptr_t)0)
69 43
70/* 44/*
71 * Structures.
72 */
73
74/*
75 * Leaf block header. 45 * Leaf block header.
76 */ 46 */
77typedef struct xfs_dir2_leaf_hdr { 47typedef struct xfs_dir2_leaf_hdr {
@@ -109,245 +79,193 @@ typedef struct xfs_dir2_leaf {
109} xfs_dir2_leaf_t; 79} xfs_dir2_leaf_t;
110 80
111/* 81/*
112 * Macros. 82 * DB blocks here are logical directory block numbers, not filesystem blocks.
113 * The DB blocks are logical directory block numbers, not filesystem blocks.
114 */ 83 */
115 84
116#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR2_MAX_LEAF_ENTS) 85#define XFS_DIR2_MAX_LEAF_ENTS(mp) xfs_dir2_max_leaf_ents(mp)
117int 86static inline int xfs_dir2_max_leaf_ents(struct xfs_mount *mp)
118xfs_dir2_max_leaf_ents(struct xfs_mount *mp); 87{
119#define XFS_DIR2_MAX_LEAF_ENTS(mp) \ 88 return (int)(((mp)->m_dirblksize - (uint)sizeof(xfs_dir2_leaf_hdr_t)) /
120 xfs_dir2_max_leaf_ents(mp) 89 (uint)sizeof(xfs_dir2_leaf_entry_t));
121#else 90}
122#define XFS_DIR2_MAX_LEAF_ENTS(mp) \
123 ((int)(((mp)->m_dirblksize - (uint)sizeof(xfs_dir2_leaf_hdr_t)) / \
124 (uint)sizeof(xfs_dir2_leaf_entry_t)))
125#endif
126 91
127/* 92/*
128 * Get address of the bestcount field in the single-leaf block. 93 * Get address of the bestcount field in the single-leaf block.
129 */ 94 */
130#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR2_LEAF_TAIL_P) 95#define XFS_DIR2_LEAF_TAIL_P(mp,lp) xfs_dir2_leaf_tail_p(mp, lp)
131xfs_dir2_leaf_tail_t * 96static inline xfs_dir2_leaf_tail_t *
132xfs_dir2_leaf_tail_p(struct xfs_mount *mp, xfs_dir2_leaf_t *lp); 97xfs_dir2_leaf_tail_p(struct xfs_mount *mp, xfs_dir2_leaf_t *lp)
133#define XFS_DIR2_LEAF_TAIL_P(mp,lp) \ 98{
134 xfs_dir2_leaf_tail_p(mp, lp) 99 return (xfs_dir2_leaf_tail_t *)
135#else 100 ((char *)(lp) + (mp)->m_dirblksize -
136#define XFS_DIR2_LEAF_TAIL_P(mp,lp) \ 101 (uint)sizeof(xfs_dir2_leaf_tail_t));
137 ((xfs_dir2_leaf_tail_t *)\ 102}
138 ((char *)(lp) + (mp)->m_dirblksize - \
139 (uint)sizeof(xfs_dir2_leaf_tail_t)))
140#endif
141 103
142/* 104/*
143 * Get address of the bests array in the single-leaf block. 105 * Get address of the bests array in the single-leaf block.
144 */ 106 */
145#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR2_LEAF_BESTS_P)
146xfs_dir2_data_off_t *
147xfs_dir2_leaf_bests_p(xfs_dir2_leaf_tail_t *ltp);
148#define XFS_DIR2_LEAF_BESTS_P(ltp) xfs_dir2_leaf_bests_p(ltp) 107#define XFS_DIR2_LEAF_BESTS_P(ltp) xfs_dir2_leaf_bests_p(ltp)
149#else 108static inline xfs_dir2_data_off_t *
150#define XFS_DIR2_LEAF_BESTS_P(ltp) \ 109xfs_dir2_leaf_bests_p(xfs_dir2_leaf_tail_t *ltp)
151 ((xfs_dir2_data_off_t *)(ltp) - INT_GET((ltp)->bestcount, ARCH_CONVERT)) 110{
152#endif 111 return (xfs_dir2_data_off_t *)
112 (ltp) - INT_GET((ltp)->bestcount, ARCH_CONVERT);
113}
153 114
154/* 115/*
155 * Convert dataptr to byte in file space 116 * Convert dataptr to byte in file space
156 */ 117 */
157#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR2_DATAPTR_TO_BYTE)
158xfs_dir2_off_t
159xfs_dir2_dataptr_to_byte(struct xfs_mount *mp, xfs_dir2_dataptr_t dp);
160#define XFS_DIR2_DATAPTR_TO_BYTE(mp,dp) xfs_dir2_dataptr_to_byte(mp, dp) 118#define XFS_DIR2_DATAPTR_TO_BYTE(mp,dp) xfs_dir2_dataptr_to_byte(mp, dp)
161#else 119static inline xfs_dir2_off_t
162#define XFS_DIR2_DATAPTR_TO_BYTE(mp,dp) \ 120xfs_dir2_dataptr_to_byte(struct xfs_mount *mp, xfs_dir2_dataptr_t dp)
163 ((xfs_dir2_off_t)(dp) << XFS_DIR2_DATA_ALIGN_LOG) 121{
164#endif 122 return (xfs_dir2_off_t)(dp) << XFS_DIR2_DATA_ALIGN_LOG;
123}
165 124
166/* 125/*
167 * Convert byte in file space to dataptr. It had better be aligned. 126 * Convert byte in file space to dataptr. It had better be aligned.
168 */ 127 */
169#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR2_BYTE_TO_DATAPTR)
170xfs_dir2_dataptr_t
171xfs_dir2_byte_to_dataptr(struct xfs_mount *mp, xfs_dir2_off_t by);
172#define XFS_DIR2_BYTE_TO_DATAPTR(mp,by) xfs_dir2_byte_to_dataptr(mp,by) 128#define XFS_DIR2_BYTE_TO_DATAPTR(mp,by) xfs_dir2_byte_to_dataptr(mp,by)
173#else 129static inline xfs_dir2_dataptr_t
174#define XFS_DIR2_BYTE_TO_DATAPTR(mp,by) \ 130xfs_dir2_byte_to_dataptr(struct xfs_mount *mp, xfs_dir2_off_t by)
175 ((xfs_dir2_dataptr_t)((by) >> XFS_DIR2_DATA_ALIGN_LOG)) 131{
176#endif 132 return (xfs_dir2_dataptr_t)((by) >> XFS_DIR2_DATA_ALIGN_LOG);
133}
134
135/*
136 * Convert byte in space to (DB) block
137 */
138#define XFS_DIR2_BYTE_TO_DB(mp,by) xfs_dir2_byte_to_db(mp, by)
139static inline xfs_dir2_db_t
140xfs_dir2_byte_to_db(struct xfs_mount *mp, xfs_dir2_off_t by)
141{
142 return (xfs_dir2_db_t)((by) >> \
143 ((mp)->m_sb.sb_blocklog + (mp)->m_sb.sb_dirblklog));
144}
177 145
178/* 146/*
179 * Convert dataptr to a block number 147 * Convert dataptr to a block number
180 */ 148 */
181#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR2_DATAPTR_TO_DB)
182xfs_dir2_db_t
183xfs_dir2_dataptr_to_db(struct xfs_mount *mp, xfs_dir2_dataptr_t dp);
184#define XFS_DIR2_DATAPTR_TO_DB(mp,dp) xfs_dir2_dataptr_to_db(mp, dp) 149#define XFS_DIR2_DATAPTR_TO_DB(mp,dp) xfs_dir2_dataptr_to_db(mp, dp)
185#else 150static inline xfs_dir2_db_t
186#define XFS_DIR2_DATAPTR_TO_DB(mp,dp) \ 151xfs_dir2_dataptr_to_db(struct xfs_mount *mp, xfs_dir2_dataptr_t dp)
187 XFS_DIR2_BYTE_TO_DB(mp, XFS_DIR2_DATAPTR_TO_BYTE(mp, dp)) 152{
188#endif 153 return XFS_DIR2_BYTE_TO_DB(mp, XFS_DIR2_DATAPTR_TO_BYTE(mp, dp));
154}
155
156/*
157 * Convert byte in space to offset in a block
158 */
159#define XFS_DIR2_BYTE_TO_OFF(mp,by) xfs_dir2_byte_to_off(mp, by)
160static inline xfs_dir2_data_aoff_t
161xfs_dir2_byte_to_off(struct xfs_mount *mp, xfs_dir2_off_t by)
162{
163 return (xfs_dir2_data_aoff_t)((by) & \
164 ((1 << ((mp)->m_sb.sb_blocklog + (mp)->m_sb.sb_dirblklog)) - 1));
165}
189 166
190/* 167/*
191 * Convert dataptr to a byte offset in a block 168 * Convert dataptr to a byte offset in a block
192 */ 169 */
193#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR2_DATAPTR_TO_OFF)
194xfs_dir2_data_aoff_t
195xfs_dir2_dataptr_to_off(struct xfs_mount *mp, xfs_dir2_dataptr_t dp);
196#define XFS_DIR2_DATAPTR_TO_OFF(mp,dp) xfs_dir2_dataptr_to_off(mp, dp) 170#define XFS_DIR2_DATAPTR_TO_OFF(mp,dp) xfs_dir2_dataptr_to_off(mp, dp)
197#else 171static inline xfs_dir2_data_aoff_t
198#define XFS_DIR2_DATAPTR_TO_OFF(mp,dp) \ 172xfs_dir2_dataptr_to_off(struct xfs_mount *mp, xfs_dir2_dataptr_t dp)
199 XFS_DIR2_BYTE_TO_OFF(mp, XFS_DIR2_DATAPTR_TO_BYTE(mp, dp)) 173{
200#endif 174 return XFS_DIR2_BYTE_TO_OFF(mp, XFS_DIR2_DATAPTR_TO_BYTE(mp, dp));
175}
201 176
202/* 177/*
203 * Convert block and offset to byte in space 178 * Convert block and offset to byte in space
204 */ 179 */
205#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR2_DB_OFF_TO_BYTE)
206xfs_dir2_off_t
207xfs_dir2_db_off_to_byte(struct xfs_mount *mp, xfs_dir2_db_t db,
208 xfs_dir2_data_aoff_t o);
209#define XFS_DIR2_DB_OFF_TO_BYTE(mp,db,o) \ 180#define XFS_DIR2_DB_OFF_TO_BYTE(mp,db,o) \
210 xfs_dir2_db_off_to_byte(mp, db, o) 181 xfs_dir2_db_off_to_byte(mp, db, o)
211#else 182static inline xfs_dir2_off_t
212#define XFS_DIR2_DB_OFF_TO_BYTE(mp,db,o) \ 183xfs_dir2_db_off_to_byte(struct xfs_mount *mp, xfs_dir2_db_t db,
213 (((xfs_dir2_off_t)(db) << \ 184 xfs_dir2_data_aoff_t o)
214 ((mp)->m_sb.sb_blocklog + (mp)->m_sb.sb_dirblklog)) + (o)) 185{
215#endif 186 return ((xfs_dir2_off_t)(db) << \
187 ((mp)->m_sb.sb_blocklog + (mp)->m_sb.sb_dirblklog)) + (o);
188}
216 189
217/* 190/*
218 * Convert byte in space to (DB) block 191 * Convert block (DB) to block (dablk)
219 */ 192 */
220#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR2_BYTE_TO_DB) 193#define XFS_DIR2_DB_TO_DA(mp,db) xfs_dir2_db_to_da(mp, db)
221xfs_dir2_db_t xfs_dir2_byte_to_db(struct xfs_mount *mp, xfs_dir2_off_t by); 194static inline xfs_dablk_t
222#define XFS_DIR2_BYTE_TO_DB(mp,by) xfs_dir2_byte_to_db(mp, by) 195xfs_dir2_db_to_da(struct xfs_mount *mp, xfs_dir2_db_t db)
223#else 196{
224#define XFS_DIR2_BYTE_TO_DB(mp,by) \ 197 return (xfs_dablk_t)((db) << (mp)->m_sb.sb_dirblklog);
225 ((xfs_dir2_db_t)((by) >> \ 198}
226 ((mp)->m_sb.sb_blocklog + (mp)->m_sb.sb_dirblklog)))
227#endif
228 199
229/* 200/*
230 * Convert byte in space to (DA) block 201 * Convert byte in space to (DA) block
231 */ 202 */
232#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR2_BYTE_TO_DA)
233xfs_dablk_t xfs_dir2_byte_to_da(struct xfs_mount *mp, xfs_dir2_off_t by);
234#define XFS_DIR2_BYTE_TO_DA(mp,by) xfs_dir2_byte_to_da(mp, by) 203#define XFS_DIR2_BYTE_TO_DA(mp,by) xfs_dir2_byte_to_da(mp, by)
235#else 204static inline xfs_dablk_t
236#define XFS_DIR2_BYTE_TO_DA(mp,by) \ 205xfs_dir2_byte_to_da(struct xfs_mount *mp, xfs_dir2_off_t by)
237 XFS_DIR2_DB_TO_DA(mp, XFS_DIR2_BYTE_TO_DB(mp, by)) 206{
238#endif 207 return XFS_DIR2_DB_TO_DA(mp, XFS_DIR2_BYTE_TO_DB(mp, by));
239 208}
240/*
241 * Convert byte in space to offset in a block
242 */
243#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR2_BYTE_TO_OFF)
244xfs_dir2_data_aoff_t
245xfs_dir2_byte_to_off(struct xfs_mount *mp, xfs_dir2_off_t by);
246#define XFS_DIR2_BYTE_TO_OFF(mp,by) xfs_dir2_byte_to_off(mp, by)
247#else
248#define XFS_DIR2_BYTE_TO_OFF(mp,by) \
249 ((xfs_dir2_data_aoff_t)((by) & \
250 ((1 << ((mp)->m_sb.sb_blocklog + \
251 (mp)->m_sb.sb_dirblklog)) - 1)))
252#endif
253 209
254/* 210/*
255 * Convert block and offset to dataptr 211 * Convert block and offset to dataptr
256 */ 212 */
257#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR2_DB_OFF_TO_DATAPTR)
258xfs_dir2_dataptr_t
259xfs_dir2_db_off_to_dataptr(struct xfs_mount *mp, xfs_dir2_db_t db,
260 xfs_dir2_data_aoff_t o);
261#define XFS_DIR2_DB_OFF_TO_DATAPTR(mp,db,o) \ 213#define XFS_DIR2_DB_OFF_TO_DATAPTR(mp,db,o) \
262 xfs_dir2_db_off_to_dataptr(mp, db, o) 214 xfs_dir2_db_off_to_dataptr(mp, db, o)
263#else 215static inline xfs_dir2_dataptr_t
264#define XFS_DIR2_DB_OFF_TO_DATAPTR(mp,db,o) \ 216xfs_dir2_db_off_to_dataptr(struct xfs_mount *mp, xfs_dir2_db_t db,
265 XFS_DIR2_BYTE_TO_DATAPTR(mp, XFS_DIR2_DB_OFF_TO_BYTE(mp, db, o)) 217 xfs_dir2_data_aoff_t o)
266#endif 218{
267 219 return XFS_DIR2_BYTE_TO_DATAPTR(mp, XFS_DIR2_DB_OFF_TO_BYTE(mp, db, o));
268/* 220}
269 * Convert block (DB) to block (dablk)
270 */
271#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR2_DB_TO_DA)
272xfs_dablk_t xfs_dir2_db_to_da(struct xfs_mount *mp, xfs_dir2_db_t db);
273#define XFS_DIR2_DB_TO_DA(mp,db) xfs_dir2_db_to_da(mp, db)
274#else
275#define XFS_DIR2_DB_TO_DA(mp,db) \
276 ((xfs_dablk_t)((db) << (mp)->m_sb.sb_dirblklog))
277#endif
278 221
279/* 222/*
280 * Convert block (dablk) to block (DB) 223 * Convert block (dablk) to block (DB)
281 */ 224 */
282#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR2_DA_TO_DB)
283xfs_dir2_db_t xfs_dir2_da_to_db(struct xfs_mount *mp, xfs_dablk_t da);
284#define XFS_DIR2_DA_TO_DB(mp,da) xfs_dir2_da_to_db(mp, da) 225#define XFS_DIR2_DA_TO_DB(mp,da) xfs_dir2_da_to_db(mp, da)
285#else 226static inline xfs_dir2_db_t
286#define XFS_DIR2_DA_TO_DB(mp,da) \ 227xfs_dir2_da_to_db(struct xfs_mount *mp, xfs_dablk_t da)
287 ((xfs_dir2_db_t)((da) >> (mp)->m_sb.sb_dirblklog)) 228{
288#endif 229 return (xfs_dir2_db_t)((da) >> (mp)->m_sb.sb_dirblklog);
230}
289 231
290/* 232/*
291 * Convert block (dablk) to byte offset in space 233 * Convert block (dablk) to byte offset in space
292 */ 234 */
293#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR2_DA_TO_BYTE)
294xfs_dir2_off_t xfs_dir2_da_to_byte(struct xfs_mount *mp, xfs_dablk_t da);
295#define XFS_DIR2_DA_TO_BYTE(mp,da) xfs_dir2_da_to_byte(mp, da) 235#define XFS_DIR2_DA_TO_BYTE(mp,da) xfs_dir2_da_to_byte(mp, da)
296#else 236static inline xfs_dir2_off_t
297#define XFS_DIR2_DA_TO_BYTE(mp,da) \ 237xfs_dir2_da_to_byte(struct xfs_mount *mp, xfs_dablk_t da)
298 XFS_DIR2_DB_OFF_TO_BYTE(mp, XFS_DIR2_DA_TO_DB(mp, da), 0) 238{
299#endif 239 return XFS_DIR2_DB_OFF_TO_BYTE(mp, XFS_DIR2_DA_TO_DB(mp, da), 0);
240}
300 241
301/* 242/*
302 * Function declarations. 243 * Function declarations.
303 */ 244 */
304 245extern int xfs_dir2_block_to_leaf(struct xfs_da_args *args,
305extern int 246 struct xfs_dabuf *dbp);
306 xfs_dir2_block_to_leaf(struct xfs_da_args *args, struct xfs_dabuf *dbp); 247extern int xfs_dir2_leaf_addname(struct xfs_da_args *args);
307 248extern void xfs_dir2_leaf_compact(struct xfs_da_args *args,
308extern int 249 struct xfs_dabuf *bp);
309 xfs_dir2_leaf_addname(struct xfs_da_args *args); 250extern void xfs_dir2_leaf_compact_x1(struct xfs_dabuf *bp, int *indexp,
310 251 int *lowstalep, int *highstalep,
311extern void 252 int *lowlogp, int *highlogp);
312 xfs_dir2_leaf_compact(struct xfs_da_args *args, struct xfs_dabuf *bp); 253extern int xfs_dir2_leaf_getdents(struct xfs_trans *tp, struct xfs_inode *dp,
313 254 struct uio *uio, int *eofp,
314extern void 255 struct xfs_dirent *dbp, xfs_dir2_put_t put);
315 xfs_dir2_leaf_compact_x1(struct xfs_dabuf *bp, int *indexp, 256extern int xfs_dir2_leaf_init(struct xfs_da_args *args, xfs_dir2_db_t bno,
316 int *lowstalep, int *highstalep, int *lowlogp, 257 struct xfs_dabuf **bpp, int magic);
317 int *highlogp); 258extern void xfs_dir2_leaf_log_ents(struct xfs_trans *tp, struct xfs_dabuf *bp,
318 259 int first, int last);
319extern int 260extern void xfs_dir2_leaf_log_header(struct xfs_trans *tp,
320 xfs_dir2_leaf_getdents(struct xfs_trans *tp, struct xfs_inode *dp, 261 struct xfs_dabuf *bp);
321 struct uio *uio, int *eofp, struct xfs_dirent *dbp, 262extern int xfs_dir2_leaf_lookup(struct xfs_da_args *args);
322 xfs_dir2_put_t put); 263extern int xfs_dir2_leaf_removename(struct xfs_da_args *args);
323 264extern int xfs_dir2_leaf_replace(struct xfs_da_args *args);
324extern int 265extern int xfs_dir2_leaf_search_hash(struct xfs_da_args *args,
325 xfs_dir2_leaf_init(struct xfs_da_args *args, xfs_dir2_db_t bno, 266 struct xfs_dabuf *lbp);
326 struct xfs_dabuf **bpp, int magic); 267extern int xfs_dir2_leaf_trim_data(struct xfs_da_args *args,
327 268 struct xfs_dabuf *lbp, xfs_dir2_db_t db);
328extern void 269extern int xfs_dir2_node_to_leaf(struct xfs_da_state *state);
329 xfs_dir2_leaf_log_ents(struct xfs_trans *tp, struct xfs_dabuf *bp,
330 int first, int last);
331
332extern void
333 xfs_dir2_leaf_log_header(struct xfs_trans *tp, struct xfs_dabuf *bp);
334
335extern int
336 xfs_dir2_leaf_lookup(struct xfs_da_args *args);
337
338extern int
339 xfs_dir2_leaf_removename(struct xfs_da_args *args);
340
341extern int
342 xfs_dir2_leaf_replace(struct xfs_da_args *args);
343
344extern int
345 xfs_dir2_leaf_search_hash(struct xfs_da_args *args,
346 struct xfs_dabuf *lbp);
347extern int
348 xfs_dir2_leaf_trim_data(struct xfs_da_args *args, struct xfs_dabuf *lbp, xfs_dir2_db_t db);
349
350extern int
351 xfs_dir2_node_to_leaf(struct xfs_da_state *state);
352 270
353#endif /* __XFS_DIR2_LEAF_H__ */ 271#endif /* __XFS_DIR2_LEAF_H__ */
diff --git a/fs/xfs/xfs_dir2_node.c b/fs/xfs/xfs_dir2_node.c
index a7615d86bfb7..641f8633d254 100644
--- a/fs/xfs/xfs_dir2_node.c
+++ b/fs/xfs/xfs_dir2_node.c
@@ -1,61 +1,39 @@
1/* 1/*
2 * Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */
32
33/*
34 * xfs_dir2_node.c
35 * XFS directory implementation, version 2, node form files
36 * See data structures in xfs_dir2_node.h and xfs_da_btree.h.
37 */ 17 */
38
39#include "xfs.h" 18#include "xfs.h"
40 19#include "xfs_fs.h"
41#include "xfs_macros.h"
42#include "xfs_types.h" 20#include "xfs_types.h"
43#include "xfs_inum.h"
44#include "xfs_log.h" 21#include "xfs_log.h"
22#include "xfs_inum.h"
45#include "xfs_trans.h" 23#include "xfs_trans.h"
46#include "xfs_sb.h" 24#include "xfs_sb.h"
47#include "xfs_dir.h" 25#include "xfs_dir.h"
48#include "xfs_dir2.h" 26#include "xfs_dir2.h"
49#include "xfs_dmapi.h" 27#include "xfs_dmapi.h"
50#include "xfs_mount.h" 28#include "xfs_mount.h"
29#include "xfs_da_btree.h"
51#include "xfs_bmap_btree.h" 30#include "xfs_bmap_btree.h"
52#include "xfs_attr_sf.h"
53#include "xfs_dir_sf.h" 31#include "xfs_dir_sf.h"
54#include "xfs_dir2_sf.h" 32#include "xfs_dir2_sf.h"
33#include "xfs_attr_sf.h"
55#include "xfs_dinode.h" 34#include "xfs_dinode.h"
56#include "xfs_inode.h" 35#include "xfs_inode.h"
57#include "xfs_bmap.h" 36#include "xfs_bmap.h"
58#include "xfs_da_btree.h"
59#include "xfs_dir2_data.h" 37#include "xfs_dir2_data.h"
60#include "xfs_dir2_leaf.h" 38#include "xfs_dir2_leaf.h"
61#include "xfs_dir2_block.h" 39#include "xfs_dir2_block.h"
diff --git a/fs/xfs/xfs_dir2_node.h b/fs/xfs/xfs_dir2_node.h
index 96db420c7c5c..0ab8fbd59512 100644
--- a/fs/xfs/xfs_dir2_node.h
+++ b/fs/xfs/xfs_dir2_node.h
@@ -1,33 +1,19 @@
1/* 1/*
2 * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32#ifndef __XFS_DIR2_NODE_H__ 18#ifndef __XFS_DIR2_NODE_H__
33#define __XFS_DIR2_NODE_H__ 19#define __XFS_DIR2_NODE_H__
@@ -45,10 +31,6 @@ struct xfs_inode;
45struct xfs_trans; 31struct xfs_trans;
46 32
47/* 33/*
48 * Constants.
49 */
50
51/*
52 * Offset of the freespace index. 34 * Offset of the freespace index.
53 */ 35 */
54#define XFS_DIR2_FREE_SPACE 2 36#define XFS_DIR2_FREE_SPACE 2
@@ -58,9 +40,6 @@ struct xfs_trans;
58 40
59#define XFS_DIR2_FREE_MAGIC 0x58443246 /* XD2F */ 41#define XFS_DIR2_FREE_MAGIC 0x58443246 /* XD2F */
60 42
61/*
62 * Structures.
63 */
64typedef struct xfs_dir2_free_hdr { 43typedef struct xfs_dir2_free_hdr {
65 __uint32_t magic; /* XFS_DIR2_FREE_MAGIC */ 44 __uint32_t magic; /* XFS_DIR2_FREE_MAGIC */
66 __int32_t firstdb; /* db of first entry */ 45 __int32_t firstdb; /* db of first entry */
@@ -73,87 +52,53 @@ typedef struct xfs_dir2_free {
73 xfs_dir2_data_off_t bests[1]; /* best free counts */ 52 xfs_dir2_data_off_t bests[1]; /* best free counts */
74 /* unused entries are -1 */ 53 /* unused entries are -1 */
75} xfs_dir2_free_t; 54} xfs_dir2_free_t;
55
76#define XFS_DIR2_MAX_FREE_BESTS(mp) \ 56#define XFS_DIR2_MAX_FREE_BESTS(mp) \
77 (((mp)->m_dirblksize - (uint)sizeof(xfs_dir2_free_hdr_t)) / \ 57 (((mp)->m_dirblksize - (uint)sizeof(xfs_dir2_free_hdr_t)) / \
78 (uint)sizeof(xfs_dir2_data_off_t)) 58 (uint)sizeof(xfs_dir2_data_off_t))
79 59
80/* 60/*
81 * Macros.
82 */
83
84/*
85 * Convert data space db to the corresponding free db. 61 * Convert data space db to the corresponding free db.
86 */ 62 */
87#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR2_DB_TO_FDB)
88xfs_dir2_db_t
89xfs_dir2_db_to_fdb(struct xfs_mount *mp, xfs_dir2_db_t db);
90#define XFS_DIR2_DB_TO_FDB(mp,db) xfs_dir2_db_to_fdb(mp, db) 63#define XFS_DIR2_DB_TO_FDB(mp,db) xfs_dir2_db_to_fdb(mp, db)
91#else 64static inline xfs_dir2_db_t
92#define XFS_DIR2_DB_TO_FDB(mp,db) \ 65xfs_dir2_db_to_fdb(struct xfs_mount *mp, xfs_dir2_db_t db)
93 (XFS_DIR2_FREE_FIRSTDB(mp) + (db) / XFS_DIR2_MAX_FREE_BESTS(mp)) 66{
94#endif 67 return (XFS_DIR2_FREE_FIRSTDB(mp) + (db) / XFS_DIR2_MAX_FREE_BESTS(mp));
68}
95 69
96/* 70/*
97 * Convert data space db to the corresponding index in a free db. 71 * Convert data space db to the corresponding index in a free db.
98 */ 72 */
99#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR2_DB_TO_FDINDEX)
100int
101xfs_dir2_db_to_fdindex(struct xfs_mount *mp, xfs_dir2_db_t db);
102#define XFS_DIR2_DB_TO_FDINDEX(mp,db) xfs_dir2_db_to_fdindex(mp, db) 73#define XFS_DIR2_DB_TO_FDINDEX(mp,db) xfs_dir2_db_to_fdindex(mp, db)
103#else 74static inline int
104#define XFS_DIR2_DB_TO_FDINDEX(mp,db) ((db) % XFS_DIR2_MAX_FREE_BESTS(mp)) 75xfs_dir2_db_to_fdindex(struct xfs_mount *mp, xfs_dir2_db_t db)
105#endif 76{
106 77 return ((db) % XFS_DIR2_MAX_FREE_BESTS(mp));
107/* 78}
108 * Functions. 79
109 */ 80extern void xfs_dir2_free_log_bests(struct xfs_trans *tp, struct xfs_dabuf *bp,
110 81 int first, int last);
111extern void 82extern int xfs_dir2_leaf_to_node(struct xfs_da_args *args,
112 xfs_dir2_free_log_bests(struct xfs_trans *tp, struct xfs_dabuf *bp, 83 struct xfs_dabuf *lbp);
113 int first, int last); 84extern xfs_dahash_t xfs_dir2_leafn_lasthash(struct xfs_dabuf *bp, int *count);
114 85extern int xfs_dir2_leafn_lookup_int(struct xfs_dabuf *bp,
115extern int 86 struct xfs_da_args *args, int *indexp,
116 xfs_dir2_leaf_to_node(struct xfs_da_args *args, struct xfs_dabuf *lbp); 87 struct xfs_da_state *state);
117 88extern int xfs_dir2_leafn_order(struct xfs_dabuf *leaf1_bp,
118extern xfs_dahash_t 89 struct xfs_dabuf *leaf2_bp);
119 xfs_dir2_leafn_lasthash(struct xfs_dabuf *bp, int *count); 90extern int xfs_dir2_leafn_split(struct xfs_da_state *state,
120 91 struct xfs_da_state_blk *oldblk,
121extern int 92 struct xfs_da_state_blk *newblk);
122 xfs_dir2_leafn_lookup_int(struct xfs_dabuf *bp, 93extern int xfs_dir2_leafn_toosmall(struct xfs_da_state *state, int *action);
123 struct xfs_da_args *args, int *indexp, 94extern void xfs_dir2_leafn_unbalance(struct xfs_da_state *state,
124 struct xfs_da_state *state); 95 struct xfs_da_state_blk *drop_blk,
125 96 struct xfs_da_state_blk *save_blk);
126extern int 97extern int xfs_dir2_node_addname(struct xfs_da_args *args);
127 xfs_dir2_leafn_order(struct xfs_dabuf *leaf1_bp, 98extern int xfs_dir2_node_lookup(struct xfs_da_args *args);
128 struct xfs_dabuf *leaf2_bp); 99extern int xfs_dir2_node_removename(struct xfs_da_args *args);
129 100extern int xfs_dir2_node_replace(struct xfs_da_args *args);
130extern int 101extern int xfs_dir2_node_trim_free(struct xfs_da_args *args, xfs_fileoff_t fo,
131 xfs_dir2_leafn_split(struct xfs_da_state *state, 102 int *rvalp);
132 struct xfs_da_state_blk *oldblk,
133 struct xfs_da_state_blk *newblk);
134
135extern int
136 xfs_dir2_leafn_toosmall(struct xfs_da_state *state, int *action);
137
138extern void
139 xfs_dir2_leafn_unbalance(struct xfs_da_state *state,
140 struct xfs_da_state_blk *drop_blk,
141 struct xfs_da_state_blk *save_blk);
142
143extern int
144 xfs_dir2_node_addname(struct xfs_da_args *args);
145
146extern int
147 xfs_dir2_node_lookup(struct xfs_da_args *args);
148
149extern int
150 xfs_dir2_node_removename(struct xfs_da_args *args);
151
152extern int
153 xfs_dir2_node_replace(struct xfs_da_args *args);
154
155extern int
156 xfs_dir2_node_trim_free(struct xfs_da_args *args, xfs_fileoff_t fo,
157 int *rvalp);
158 103
159#endif /* __XFS_DIR2_NODE_H__ */ 104#endif /* __XFS_DIR2_NODE_H__ */
diff --git a/fs/xfs/xfs_dir2_sf.c b/fs/xfs/xfs_dir2_sf.c
index 6bbc61674411..ec8e7476c8b7 100644
--- a/fs/xfs/xfs_dir2_sf.c
+++ b/fs/xfs/xfs_dir2_sf.c
@@ -1,60 +1,39 @@
1/* 1/*
2 * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32
33/*
34 * xfs_dir2_sf.c
35 * Shortform directory implementation for v2 directories.
36 */
37
38#include "xfs.h" 18#include "xfs.h"
39 19#include "xfs_fs.h"
40#include "xfs_macros.h"
41#include "xfs_types.h" 20#include "xfs_types.h"
42#include "xfs_inum.h"
43#include "xfs_log.h" 21#include "xfs_log.h"
22#include "xfs_inum.h"
44#include "xfs_trans.h" 23#include "xfs_trans.h"
45#include "xfs_sb.h" 24#include "xfs_sb.h"
46#include "xfs_dir.h" 25#include "xfs_dir.h"
47#include "xfs_dir2.h" 26#include "xfs_dir2.h"
48#include "xfs_dmapi.h" 27#include "xfs_dmapi.h"
49#include "xfs_mount.h" 28#include "xfs_mount.h"
29#include "xfs_da_btree.h"
50#include "xfs_bmap_btree.h" 30#include "xfs_bmap_btree.h"
51#include "xfs_attr_sf.h"
52#include "xfs_dir_sf.h" 31#include "xfs_dir_sf.h"
53#include "xfs_dir2_sf.h" 32#include "xfs_dir2_sf.h"
33#include "xfs_attr_sf.h"
54#include "xfs_dinode.h" 34#include "xfs_dinode.h"
55#include "xfs_inode_item.h"
56#include "xfs_inode.h" 35#include "xfs_inode.h"
57#include "xfs_da_btree.h" 36#include "xfs_inode_item.h"
58#include "xfs_dir_leaf.h" 37#include "xfs_dir_leaf.h"
59#include "xfs_error.h" 38#include "xfs_error.h"
60#include "xfs_dir2_data.h" 39#include "xfs_dir2_data.h"
@@ -107,7 +86,7 @@ xfs_dir2_block_sfsize(
107 int isdotdot; /* entry is ".." */ 86 int isdotdot; /* entry is ".." */
108 xfs_mount_t *mp; /* mount structure pointer */ 87 xfs_mount_t *mp; /* mount structure pointer */
109 int namelen; /* total name bytes */ 88 int namelen; /* total name bytes */
110 xfs_ino_t parent; /* parent inode number */ 89 xfs_ino_t parent = 0; /* parent inode number */
111 int size=0; /* total computed size */ 90 int size=0; /* total computed size */
112 91
113 mp = dp->i_mount; 92 mp = dp->i_mount;
@@ -298,11 +277,11 @@ xfs_dir2_sf_addname(
298 int incr_isize; /* total change in size */ 277 int incr_isize; /* total change in size */
299 int new_isize; /* di_size after adding name */ 278 int new_isize; /* di_size after adding name */
300 int objchange; /* changing to 8-byte inodes */ 279 int objchange; /* changing to 8-byte inodes */
301 xfs_dir2_data_aoff_t offset; /* offset for new entry */ 280 xfs_dir2_data_aoff_t offset = 0; /* offset for new entry */
302 int old_isize; /* di_size before adding name */ 281 int old_isize; /* di_size before adding name */
303 int pick; /* which algorithm to use */ 282 int pick; /* which algorithm to use */
304 xfs_dir2_sf_t *sfp; /* shortform structure */ 283 xfs_dir2_sf_t *sfp; /* shortform structure */
305 xfs_dir2_sf_entry_t *sfep; /* shortform entry */ 284 xfs_dir2_sf_entry_t *sfep = NULL; /* shortform entry */
306 285
307 xfs_dir2_trace_args("sf_addname", args); 286 xfs_dir2_trace_args("sf_addname", args);
308 ASSERT(xfs_dir2_sf_lookup(args) == ENOENT); 287 ASSERT(xfs_dir2_sf_lookup(args) == ENOENT);
diff --git a/fs/xfs/xfs_dir2_sf.h b/fs/xfs/xfs_dir2_sf.h
index bac6f5a2a312..42f015b70018 100644
--- a/fs/xfs/xfs_dir2_sf.h
+++ b/fs/xfs/xfs_dir2_sf.h
@@ -1,33 +1,19 @@
1/* 1/*
2 * Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2001,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32#ifndef __XFS_DIR2_SF_H__ 18#ifndef __XFS_DIR2_SF_H__
33#define __XFS_DIR2_SF_H__ 19#define __XFS_DIR2_SF_H__
@@ -104,140 +90,106 @@ typedef struct xfs_dir2_sf {
104 xfs_dir2_sf_entry_t list[1]; /* shortform entries */ 90 xfs_dir2_sf_entry_t list[1]; /* shortform entries */
105} xfs_dir2_sf_t; 91} xfs_dir2_sf_t;
106 92
107#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR2_SF_HDR_SIZE)
108int xfs_dir2_sf_hdr_size(int i8count);
109#define XFS_DIR2_SF_HDR_SIZE(i8count) xfs_dir2_sf_hdr_size(i8count) 93#define XFS_DIR2_SF_HDR_SIZE(i8count) xfs_dir2_sf_hdr_size(i8count)
110#else 94static inline int xfs_dir2_sf_hdr_size(int i8count)
111#define XFS_DIR2_SF_HDR_SIZE(i8count) \ 95{
112 ((uint)sizeof(xfs_dir2_sf_hdr_t) - \ 96 return ((uint)sizeof(xfs_dir2_sf_hdr_t) - \
113 ((i8count) == 0) * \ 97 ((i8count) == 0) * \
114 ((uint)sizeof(xfs_dir2_ino8_t) - (uint)sizeof(xfs_dir2_ino4_t))) 98 ((uint)sizeof(xfs_dir2_ino8_t) - (uint)sizeof(xfs_dir2_ino4_t)));
115#endif 99}
116 100
117#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR2_SF_INUMBERP)
118xfs_dir2_inou_t *xfs_dir2_sf_inumberp(xfs_dir2_sf_entry_t *sfep);
119#define XFS_DIR2_SF_INUMBERP(sfep) xfs_dir2_sf_inumberp(sfep) 101#define XFS_DIR2_SF_INUMBERP(sfep) xfs_dir2_sf_inumberp(sfep)
120#else 102static inline xfs_dir2_inou_t *xfs_dir2_sf_inumberp(xfs_dir2_sf_entry_t *sfep)
121#define XFS_DIR2_SF_INUMBERP(sfep) \ 103{
122 ((xfs_dir2_inou_t *)&(sfep)->name[(sfep)->namelen]) 104 return (xfs_dir2_inou_t *)&(sfep)->name[(sfep)->namelen];
123#endif 105}
124
125#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR2_SF_GET_INUMBER)
126xfs_intino_t xfs_dir2_sf_get_inumber(xfs_dir2_sf_t *sfp, xfs_dir2_inou_t *from);
127#define XFS_DIR2_SF_GET_INUMBER(sfp, from) \
128 xfs_dir2_sf_get_inumber(sfp, from)
129 106
130#else 107#define XFS_DIR2_SF_GET_INUMBER(sfp, from) \
131#define XFS_DIR2_SF_GET_INUMBER(sfp, from) \ 108 xfs_dir2_sf_get_inumber(sfp, from)
132 ((sfp)->hdr.i8count == 0 ? \ 109static inline xfs_intino_t
110xfs_dir2_sf_get_inumber(xfs_dir2_sf_t *sfp, xfs_dir2_inou_t *from)
111{
112 return ((sfp)->hdr.i8count == 0 ? \
133 (xfs_intino_t)XFS_GET_DIR_INO4((from)->i4) : \ 113 (xfs_intino_t)XFS_GET_DIR_INO4((from)->i4) : \
134 (xfs_intino_t)XFS_GET_DIR_INO8((from)->i8)) 114 (xfs_intino_t)XFS_GET_DIR_INO8((from)->i8));
135#endif 115}
136 116
137#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR2_SF_PUT_INUMBER) 117#define XFS_DIR2_SF_PUT_INUMBER(sfp,from,to) \
138void xfs_dir2_sf_put_inumber(xfs_dir2_sf_t *sfp, xfs_ino_t *from,
139 xfs_dir2_inou_t *to);
140#define XFS_DIR2_SF_PUT_INUMBER(sfp,from,to) \
141 xfs_dir2_sf_put_inumber(sfp,from,to) 118 xfs_dir2_sf_put_inumber(sfp,from,to)
142#else 119static inline void xfs_dir2_sf_put_inumber(xfs_dir2_sf_t *sfp, xfs_ino_t *from,
143#define XFS_DIR2_SF_PUT_INUMBER(sfp,from,to) \ 120 xfs_dir2_inou_t *to)
144 if ((sfp)->hdr.i8count == 0) { \ 121{
145 XFS_PUT_DIR_INO4(*(from), (to)->i4); \ 122 if ((sfp)->hdr.i8count == 0)
146 } else { \ 123 XFS_PUT_DIR_INO4(*(from), (to)->i4);
147 XFS_PUT_DIR_INO8(*(from), (to)->i8); \ 124 else
148 } 125 XFS_PUT_DIR_INO8(*(from), (to)->i8);
149#endif 126}
150 127
151#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR2_SF_GET_OFFSET)
152xfs_dir2_data_aoff_t xfs_dir2_sf_get_offset(xfs_dir2_sf_entry_t *sfep);
153#define XFS_DIR2_SF_GET_OFFSET(sfep) \ 128#define XFS_DIR2_SF_GET_OFFSET(sfep) \
154 xfs_dir2_sf_get_offset(sfep) 129 xfs_dir2_sf_get_offset(sfep)
155#else 130static inline xfs_dir2_data_aoff_t
156#define XFS_DIR2_SF_GET_OFFSET(sfep) \ 131xfs_dir2_sf_get_offset(xfs_dir2_sf_entry_t *sfep)
157 INT_GET_UNALIGNED_16_BE(&(sfep)->offset.i) 132{
158#endif 133 return INT_GET_UNALIGNED_16_BE(&(sfep)->offset.i);
134}
159 135
160#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR2_SF_PUT_OFFSET)
161void xfs_dir2_sf_put_offset(xfs_dir2_sf_entry_t *sfep,
162 xfs_dir2_data_aoff_t off);
163#define XFS_DIR2_SF_PUT_OFFSET(sfep,off) \ 136#define XFS_DIR2_SF_PUT_OFFSET(sfep,off) \
164 xfs_dir2_sf_put_offset(sfep,off) 137 xfs_dir2_sf_put_offset(sfep,off)
165#else 138static inline void
166#define XFS_DIR2_SF_PUT_OFFSET(sfep,off) \ 139xfs_dir2_sf_put_offset(xfs_dir2_sf_entry_t *sfep, xfs_dir2_data_aoff_t off)
167 INT_SET_UNALIGNED_16_BE(&(sfep)->offset.i,off) 140{
168#endif 141 INT_SET_UNALIGNED_16_BE(&(sfep)->offset.i, off);
142}
169 143
170#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR2_SF_ENTSIZE_BYNAME)
171int xfs_dir2_sf_entsize_byname(xfs_dir2_sf_t *sfp, int len);
172#define XFS_DIR2_SF_ENTSIZE_BYNAME(sfp,len) \ 144#define XFS_DIR2_SF_ENTSIZE_BYNAME(sfp,len) \
173 xfs_dir2_sf_entsize_byname(sfp,len) 145 xfs_dir2_sf_entsize_byname(sfp,len)
174#else 146static inline int xfs_dir2_sf_entsize_byname(xfs_dir2_sf_t *sfp, int len)
175#define XFS_DIR2_SF_ENTSIZE_BYNAME(sfp,len) /* space a name uses */ \ 147{
176 ((uint)sizeof(xfs_dir2_sf_entry_t) - 1 + (len) - \ 148 return ((uint)sizeof(xfs_dir2_sf_entry_t) - 1 + (len) - \
177 ((sfp)->hdr.i8count == 0) * \ 149 ((sfp)->hdr.i8count == 0) * \
178 ((uint)sizeof(xfs_dir2_ino8_t) - (uint)sizeof(xfs_dir2_ino4_t))) 150 ((uint)sizeof(xfs_dir2_ino8_t) - (uint)sizeof(xfs_dir2_ino4_t)));
179#endif 151}
180 152
181#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR2_SF_ENTSIZE_BYENTRY)
182int xfs_dir2_sf_entsize_byentry(xfs_dir2_sf_t *sfp, xfs_dir2_sf_entry_t *sfep);
183#define XFS_DIR2_SF_ENTSIZE_BYENTRY(sfp,sfep) \ 153#define XFS_DIR2_SF_ENTSIZE_BYENTRY(sfp,sfep) \
184 xfs_dir2_sf_entsize_byentry(sfp,sfep) 154 xfs_dir2_sf_entsize_byentry(sfp,sfep)
185#else 155static inline int
186#define XFS_DIR2_SF_ENTSIZE_BYENTRY(sfp,sfep) /* space an entry uses */ \ 156xfs_dir2_sf_entsize_byentry(xfs_dir2_sf_t *sfp, xfs_dir2_sf_entry_t *sfep)
187 ((uint)sizeof(xfs_dir2_sf_entry_t) - 1 + (sfep)->namelen - \ 157{
188 ((sfp)->hdr.i8count == 0) * \ 158 return ((uint)sizeof(xfs_dir2_sf_entry_t) - 1 + (sfep)->namelen - \
189 ((uint)sizeof(xfs_dir2_ino8_t) - (uint)sizeof(xfs_dir2_ino4_t))) 159 ((sfp)->hdr.i8count == 0) * \
190#endif 160 ((uint)sizeof(xfs_dir2_ino8_t) - (uint)sizeof(xfs_dir2_ino4_t)));
191 161}
192#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR2_SF_FIRSTENTRY) 162
193xfs_dir2_sf_entry_t *xfs_dir2_sf_firstentry(xfs_dir2_sf_t *sfp);
194#define XFS_DIR2_SF_FIRSTENTRY(sfp) xfs_dir2_sf_firstentry(sfp) 163#define XFS_DIR2_SF_FIRSTENTRY(sfp) xfs_dir2_sf_firstentry(sfp)
195#else 164static inline xfs_dir2_sf_entry_t *xfs_dir2_sf_firstentry(xfs_dir2_sf_t *sfp)
196#define XFS_DIR2_SF_FIRSTENTRY(sfp) /* first entry in struct */ \ 165{
197 ((xfs_dir2_sf_entry_t *) \ 166 return ((xfs_dir2_sf_entry_t *) \
198 ((char *)(sfp) + XFS_DIR2_SF_HDR_SIZE(sfp->hdr.i8count))) 167 ((char *)(sfp) + XFS_DIR2_SF_HDR_SIZE(sfp->hdr.i8count)));
199#endif 168}
200 169
201#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR2_SF_NEXTENTRY) 170#define XFS_DIR2_SF_NEXTENTRY(sfp,sfep) xfs_dir2_sf_nextentry(sfp,sfep)
202xfs_dir2_sf_entry_t *xfs_dir2_sf_nextentry(xfs_dir2_sf_t *sfp, 171static inline xfs_dir2_sf_entry_t *
203 xfs_dir2_sf_entry_t *sfep); 172xfs_dir2_sf_nextentry(xfs_dir2_sf_t *sfp, xfs_dir2_sf_entry_t *sfep)
204#define XFS_DIR2_SF_NEXTENTRY(sfp,sfep) xfs_dir2_sf_nextentry(sfp,sfep) 173{
205#else 174 return ((xfs_dir2_sf_entry_t *) \
206#define XFS_DIR2_SF_NEXTENTRY(sfp,sfep) /* next entry in struct */ \ 175 ((char *)(sfep) + XFS_DIR2_SF_ENTSIZE_BYENTRY(sfp,sfep)));
207 ((xfs_dir2_sf_entry_t *) \ 176}
208 ((char *)(sfep) + XFS_DIR2_SF_ENTSIZE_BYENTRY(sfp,sfep)))
209#endif
210 177
211/* 178/*
212 * Functions. 179 * Functions.
213 */ 180 */
214 181extern int xfs_dir2_block_sfsize(struct xfs_inode *dp,
215extern int 182 struct xfs_dir2_block *block,
216 xfs_dir2_block_sfsize(struct xfs_inode *dp, 183 xfs_dir2_sf_hdr_t *sfhp);
217 struct xfs_dir2_block *block, 184extern int xfs_dir2_block_to_sf(struct xfs_da_args *args, struct xfs_dabuf *bp,
218 xfs_dir2_sf_hdr_t *sfhp); 185 int size, xfs_dir2_sf_hdr_t *sfhp);
219 186extern int xfs_dir2_sf_addname(struct xfs_da_args *args);
220extern int 187extern int xfs_dir2_sf_create(struct xfs_da_args *args, xfs_ino_t pino);
221 xfs_dir2_block_to_sf(struct xfs_da_args *args, struct xfs_dabuf *bp, 188extern int xfs_dir2_sf_getdents(struct xfs_inode *dp, struct uio *uio,
222 int size, xfs_dir2_sf_hdr_t *sfhp); 189 int *eofp, struct xfs_dirent *dbp,
223 190 xfs_dir2_put_t put);
224extern int 191extern int xfs_dir2_sf_lookup(struct xfs_da_args *args);
225 xfs_dir2_sf_addname(struct xfs_da_args *args); 192extern int xfs_dir2_sf_removename(struct xfs_da_args *args);
226 193extern int xfs_dir2_sf_replace(struct xfs_da_args *args);
227extern int
228 xfs_dir2_sf_create(struct xfs_da_args *args, xfs_ino_t pino);
229
230extern int
231 xfs_dir2_sf_getdents(struct xfs_inode *dp, struct uio *uio, int *eofp,
232 struct xfs_dirent *dbp, xfs_dir2_put_t put);
233
234extern int
235 xfs_dir2_sf_lookup(struct xfs_da_args *args);
236
237extern int
238 xfs_dir2_sf_removename(struct xfs_da_args *args);
239
240extern int
241 xfs_dir2_sf_replace(struct xfs_da_args *args);
242 194
243#endif /* __XFS_DIR2_SF_H__ */ 195#endif /* __XFS_DIR2_SF_H__ */
diff --git a/fs/xfs/xfs_dir2_trace.c b/fs/xfs/xfs_dir2_trace.c
index 9d6417393140..c626943b4112 100644
--- a/fs/xfs/xfs_dir2_trace.c
+++ b/fs/xfs/xfs_dir2_trace.c
@@ -1,52 +1,33 @@
1/* 1/*
2 * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */
32
33/*
34 * xfs_dir2_trace.c
35 * Tracing for xfs v2 directories.
36 */ 17 */
37#include "xfs.h" 18#include "xfs.h"
38 19#include "xfs_fs.h"
39#include "xfs_types.h" 20#include "xfs_types.h"
40#include "xfs_inum.h" 21#include "xfs_inum.h"
41#include "xfs_dir.h" 22#include "xfs_dir.h"
42#include "xfs_dir2.h" 23#include "xfs_dir2.h"
24#include "xfs_da_btree.h"
43#include "xfs_bmap_btree.h" 25#include "xfs_bmap_btree.h"
44#include "xfs_attr_sf.h"
45#include "xfs_dir_sf.h" 26#include "xfs_dir_sf.h"
46#include "xfs_dir2_sf.h" 27#include "xfs_dir2_sf.h"
28#include "xfs_attr_sf.h"
47#include "xfs_dinode.h" 29#include "xfs_dinode.h"
48#include "xfs_inode.h" 30#include "xfs_inode.h"
49#include "xfs_da_btree.h"
50#include "xfs_dir2_trace.h" 31#include "xfs_dir2_trace.h"
51 32
52#ifdef XFS_DIR2_TRACE 33#ifdef XFS_DIR2_TRACE
diff --git a/fs/xfs/xfs_dir2_trace.h b/fs/xfs/xfs_dir2_trace.h
index 0a178bffa806..ca3c754f4822 100644
--- a/fs/xfs/xfs_dir2_trace.h
+++ b/fs/xfs/xfs_dir2_trace.h
@@ -1,33 +1,19 @@
1/* 1/*
2 * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32#ifndef __XFS_DIR2_TRACE_H__ 18#ifndef __XFS_DIR2_TRACE_H__
33#define __XFS_DIR2_TRACE_H__ 19#define __XFS_DIR2_TRACE_H__
diff --git a/fs/xfs/xfs_dir_leaf.c b/fs/xfs/xfs_dir_leaf.c
index c2ea6171fb0e..950df31efc46 100644
--- a/fs/xfs/xfs_dir_leaf.c
+++ b/fs/xfs/xfs_dir_leaf.c
@@ -1,66 +1,44 @@
1/* 1/*
2 * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32
33/*
34 * xfs_dir_leaf.c
35 *
36 * GROT: figure out how to recover gracefully when bmap returns ENOSPC.
37 */
38
39#include "xfs.h" 18#include "xfs.h"
40 19#include "xfs_fs.h"
41#include "xfs_macros.h"
42#include "xfs_types.h" 20#include "xfs_types.h"
43#include "xfs_inum.h"
44#include "xfs_log.h" 21#include "xfs_log.h"
22#include "xfs_inum.h"
45#include "xfs_trans.h" 23#include "xfs_trans.h"
46#include "xfs_sb.h" 24#include "xfs_sb.h"
47#include "xfs_dir.h" 25#include "xfs_dir.h"
48#include "xfs_dir2.h" 26#include "xfs_dir2.h"
49#include "xfs_dmapi.h" 27#include "xfs_dmapi.h"
50#include "xfs_mount.h" 28#include "xfs_mount.h"
51#include "xfs_alloc_btree.h" 29#include "xfs_da_btree.h"
52#include "xfs_bmap_btree.h" 30#include "xfs_bmap_btree.h"
31#include "xfs_alloc_btree.h"
53#include "xfs_ialloc_btree.h" 32#include "xfs_ialloc_btree.h"
54#include "xfs_alloc.h"
55#include "xfs_btree.h"
56#include "xfs_attr_sf.h"
57#include "xfs_dir_sf.h" 33#include "xfs_dir_sf.h"
58#include "xfs_dir2_sf.h" 34#include "xfs_dir2_sf.h"
35#include "xfs_attr_sf.h"
59#include "xfs_dinode.h" 36#include "xfs_dinode.h"
60#include "xfs_inode_item.h"
61#include "xfs_inode.h" 37#include "xfs_inode.h"
38#include "xfs_inode_item.h"
39#include "xfs_alloc.h"
40#include "xfs_btree.h"
62#include "xfs_bmap.h" 41#include "xfs_bmap.h"
63#include "xfs_da_btree.h"
64#include "xfs_dir_leaf.h" 42#include "xfs_dir_leaf.h"
65#include "xfs_error.h" 43#include "xfs_error.h"
66 44
@@ -508,7 +486,7 @@ xfs_dir_shortform_getdents(xfs_inode_t *dp, uio_t *uio, int *eofp,
508 /* 486 /*
509 * Sort the entries on hash then entno. 487 * Sort the entries on hash then entno.
510 */ 488 */
511 qsort(sbuf, nsbuf, sizeof(*sbuf), xfs_dir_shortform_compare); 489 xfs_sort(sbuf, nsbuf, sizeof(*sbuf), xfs_dir_shortform_compare);
512 /* 490 /*
513 * Stuff in last entry. 491 * Stuff in last entry.
514 */ 492 */
@@ -650,7 +628,7 @@ xfs_dir_leaf_to_shortform(xfs_da_args_t *iargs)
650 xfs_dir_leaf_name_t *namest; 628 xfs_dir_leaf_name_t *namest;
651 xfs_da_args_t args; 629 xfs_da_args_t args;
652 xfs_inode_t *dp; 630 xfs_inode_t *dp;
653 xfs_ino_t parent; 631 xfs_ino_t parent = 0;
654 char *tmpbuffer; 632 char *tmpbuffer;
655 int retval, i; 633 int retval, i;
656 xfs_dabuf_t *bp; 634 xfs_dabuf_t *bp;
diff --git a/fs/xfs/xfs_dir_leaf.h b/fs/xfs/xfs_dir_leaf.h
index 480bffc1f29f..ab6b09eef9ab 100644
--- a/fs/xfs/xfs_dir_leaf.h
+++ b/fs/xfs/xfs_dir_leaf.h
@@ -1,33 +1,19 @@
1/* 1/*
2 * Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2001,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32#ifndef __XFS_DIR_LEAF_H__ 18#ifndef __XFS_DIR_LEAF_H__
33#define __XFS_DIR_LEAF_H__ 19#define __XFS_DIR_LEAF_H__
@@ -152,30 +138,26 @@ typedef struct xfs_dir_put_args
152 struct uio *uio; /* uio control structure */ 138 struct uio *uio; /* uio control structure */
153} xfs_dir_put_args_t; 139} xfs_dir_put_args_t;
154 140
155#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR_LEAF_ENTSIZE_BYNAME)
156int xfs_dir_leaf_entsize_byname(int len);
157#define XFS_DIR_LEAF_ENTSIZE_BYNAME(len) xfs_dir_leaf_entsize_byname(len) 141#define XFS_DIR_LEAF_ENTSIZE_BYNAME(len) xfs_dir_leaf_entsize_byname(len)
158#else 142static inline int xfs_dir_leaf_entsize_byname(int len)
159#define XFS_DIR_LEAF_ENTSIZE_BYNAME(len) /* space a name will use */ \ 143{
160 ((uint)sizeof(xfs_dir_leaf_name_t)-1 + len) 144 return (uint)sizeof(xfs_dir_leaf_name_t)-1 + len;
161#endif 145}
162#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR_LEAF_ENTSIZE_BYENTRY) 146
163int xfs_dir_leaf_entsize_byentry(xfs_dir_leaf_entry_t *entry);
164#define XFS_DIR_LEAF_ENTSIZE_BYENTRY(entry) \ 147#define XFS_DIR_LEAF_ENTSIZE_BYENTRY(entry) \
165 xfs_dir_leaf_entsize_byentry(entry) 148 xfs_dir_leaf_entsize_byentry(entry)
166#else 149static inline int xfs_dir_leaf_entsize_byentry(xfs_dir_leaf_entry_t *entry)
167#define XFS_DIR_LEAF_ENTSIZE_BYENTRY(entry) /* space an entry will use */ \ 150{
168 ((uint)sizeof(xfs_dir_leaf_name_t)-1 + (entry)->namelen) 151 return (uint)sizeof(xfs_dir_leaf_name_t)-1 + (entry)->namelen;
169#endif 152}
170#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR_LEAF_NAMESTRUCT) 153
171xfs_dir_leaf_name_t *
172xfs_dir_leaf_namestruct(xfs_dir_leafblock_t *leafp, int offset);
173#define XFS_DIR_LEAF_NAMESTRUCT(leafp,offset) \ 154#define XFS_DIR_LEAF_NAMESTRUCT(leafp,offset) \
174 xfs_dir_leaf_namestruct(leafp,offset) 155 xfs_dir_leaf_namestruct(leafp,offset)
175#else 156static inline xfs_dir_leaf_name_t *
176#define XFS_DIR_LEAF_NAMESTRUCT(leafp,offset) /* point to name struct */ \ 157xfs_dir_leaf_namestruct(xfs_dir_leafblock_t *leafp, int offset)
177 ((xfs_dir_leaf_name_t *)&((char *)(leafp))[offset]) 158{
178#endif 159 return (xfs_dir_leaf_name_t *)&((char *)(leafp))[offset];
160}
179 161
180/*======================================================================== 162/*========================================================================
181 * Function prototypes for the kernel. 163 * Function prototypes for the kernel.
@@ -190,7 +172,7 @@ int xfs_dir_shortform_lookup(struct xfs_da_args *args);
190int xfs_dir_shortform_to_leaf(struct xfs_da_args *args); 172int xfs_dir_shortform_to_leaf(struct xfs_da_args *args);
191int xfs_dir_shortform_removename(struct xfs_da_args *args); 173int xfs_dir_shortform_removename(struct xfs_da_args *args);
192int xfs_dir_shortform_getdents(struct xfs_inode *dp, struct uio *uio, int *eofp, 174int xfs_dir_shortform_getdents(struct xfs_inode *dp, struct uio *uio, int *eofp,
193 struct xfs_dirent *dbp, xfs_dir_put_t put); 175 struct xfs_dirent *dbp, xfs_dir_put_t put);
194int xfs_dir_shortform_replace(struct xfs_da_args *args); 176int xfs_dir_shortform_replace(struct xfs_da_args *args);
195 177
196/* 178/*
@@ -237,7 +219,6 @@ int xfs_dir_put_dirent64_direct(xfs_dir_put_args_t *pa);
237int xfs_dir_put_dirent64_uio(xfs_dir_put_args_t *pa); 219int xfs_dir_put_dirent64_uio(xfs_dir_put_args_t *pa);
238int xfs_dir_ino_validate(struct xfs_mount *mp, xfs_ino_t ino); 220int xfs_dir_ino_validate(struct xfs_mount *mp, xfs_ino_t ino);
239 221
240
241/* 222/*
242 * Global data. 223 * Global data.
243 */ 224 */
diff --git a/fs/xfs/xfs_dir_sf.h b/fs/xfs/xfs_dir_sf.h
index a61bcfc2a87d..fe44c6f4d560 100644
--- a/fs/xfs/xfs_dir_sf.h
+++ b/fs/xfs/xfs_dir_sf.h
@@ -1,33 +1,19 @@
1/* 1/*
2 * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32#ifndef __XFS_DIR_SF_H__ 18#ifndef __XFS_DIR_SF_H__
33#define __XFS_DIR_SF_H__ 19#define __XFS_DIR_SF_H__
@@ -76,49 +62,44 @@ typedef struct xfs_dir_sf_sort {
76 char *name; /* name value, pointer into buffer */ 62 char *name; /* name value, pointer into buffer */
77} xfs_dir_sf_sort_t; 63} xfs_dir_sf_sort_t;
78 64
79#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR_SF_GET_DIRINO) 65#define XFS_DIR_SF_GET_DIRINO(from,to) xfs_dir_sf_get_dirino(from, to)
80void xfs_dir_sf_get_dirino(xfs_dir_ino_t *from, xfs_ino_t *to); 66static inline void xfs_dir_sf_get_dirino(xfs_dir_ino_t *from, xfs_ino_t *to)
81#define XFS_DIR_SF_GET_DIRINO(from,to) xfs_dir_sf_get_dirino(from, to) 67{
82#else 68 *(to) = XFS_GET_DIR_INO8(*from);
83#define XFS_DIR_SF_GET_DIRINO(from,to) (*(to) = XFS_GET_DIR_INO8(*from)) 69}
84#endif 70
85#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR_SF_PUT_DIRINO) 71#define XFS_DIR_SF_PUT_DIRINO(from,to) xfs_dir_sf_put_dirino(from, to)
86void xfs_dir_sf_put_dirino(xfs_ino_t *from, xfs_dir_ino_t *to); 72static inline void xfs_dir_sf_put_dirino(xfs_ino_t *from, xfs_dir_ino_t *to)
87#define XFS_DIR_SF_PUT_DIRINO(from,to) xfs_dir_sf_put_dirino(from, to) 73{
88#else 74 XFS_PUT_DIR_INO8(*(from), *(to));
89#define XFS_DIR_SF_PUT_DIRINO(from,to) XFS_PUT_DIR_INO8(*(from), *(to)) 75}
90#endif 76
91#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR_SF_ENTSIZE_BYNAME) 77#define XFS_DIR_SF_ENTSIZE_BYNAME(len) xfs_dir_sf_entsize_byname(len)
92int xfs_dir_sf_entsize_byname(int len); 78static inline int xfs_dir_sf_entsize_byname(int len)
93#define XFS_DIR_SF_ENTSIZE_BYNAME(len) xfs_dir_sf_entsize_byname(len) 79{
94#else 80 return (uint)sizeof(xfs_dir_sf_entry_t)-1 + (len);
95#define XFS_DIR_SF_ENTSIZE_BYNAME(len) /* space a name uses */ \ 81}
96 ((uint)sizeof(xfs_dir_sf_entry_t)-1 + (len)) 82
97#endif
98#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR_SF_ENTSIZE_BYENTRY)
99int xfs_dir_sf_entsize_byentry(xfs_dir_sf_entry_t *sfep);
100#define XFS_DIR_SF_ENTSIZE_BYENTRY(sfep) xfs_dir_sf_entsize_byentry(sfep) 83#define XFS_DIR_SF_ENTSIZE_BYENTRY(sfep) xfs_dir_sf_entsize_byentry(sfep)
101#else 84static inline int xfs_dir_sf_entsize_byentry(xfs_dir_sf_entry_t *sfep)
102#define XFS_DIR_SF_ENTSIZE_BYENTRY(sfep) /* space an entry uses */ \ 85{
103 ((uint)sizeof(xfs_dir_sf_entry_t)-1 + (sfep)->namelen) 86 return (uint)sizeof(xfs_dir_sf_entry_t)-1 + (sfep)->namelen;
104#endif 87}
105#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR_SF_NEXTENTRY) 88
106xfs_dir_sf_entry_t *xfs_dir_sf_nextentry(xfs_dir_sf_entry_t *sfep);
107#define XFS_DIR_SF_NEXTENTRY(sfep) xfs_dir_sf_nextentry(sfep) 89#define XFS_DIR_SF_NEXTENTRY(sfep) xfs_dir_sf_nextentry(sfep)
108#else 90static inline xfs_dir_sf_entry_t *xfs_dir_sf_nextentry(xfs_dir_sf_entry_t *sfep)
109#define XFS_DIR_SF_NEXTENTRY(sfep) /* next entry in struct */ \ 91{
110 ((xfs_dir_sf_entry_t *) \ 92 return (xfs_dir_sf_entry_t *) \
111 ((char *)(sfep) + XFS_DIR_SF_ENTSIZE_BYENTRY(sfep))) 93 ((char *)(sfep) + XFS_DIR_SF_ENTSIZE_BYENTRY(sfep));
112#endif 94}
113#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR_SF_ALLFIT) 95
114int xfs_dir_sf_allfit(int count, int totallen);
115#define XFS_DIR_SF_ALLFIT(count,totallen) \ 96#define XFS_DIR_SF_ALLFIT(count,totallen) \
116 xfs_dir_sf_allfit(count,totallen) 97 xfs_dir_sf_allfit(count,totallen)
117#else 98static inline int xfs_dir_sf_allfit(int count, int totallen)
118#define XFS_DIR_SF_ALLFIT(count,totallen) /* will all entries fit? */ \ 99{
119 ((uint)sizeof(xfs_dir_sf_hdr_t) + \ 100 return ((uint)sizeof(xfs_dir_sf_hdr_t) + \
120 ((uint)sizeof(xfs_dir_sf_entry_t)-1)*(count) + (totallen)) 101 ((uint)sizeof(xfs_dir_sf_entry_t)-1)*(count) + (totallen));
121#endif 102}
122 103
123#if defined(XFS_DIR_TRACE) 104#if defined(XFS_DIR_TRACE)
124 105
diff --git a/fs/xfs/xfs_dmapi.h b/fs/xfs/xfs_dmapi.h
index 19e872856f6b..5a5c7a63e80b 100644
--- a/fs/xfs/xfs_dmapi.h
+++ b/fs/xfs/xfs_dmapi.h
@@ -1,33 +1,19 @@
1/* 1/*
2 * Copyright (c) 2000-2005 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32#ifndef __XFS_DMAPI_H__ 18#ifndef __XFS_DMAPI_H__
33#define __XFS_DMAPI_H__ 19#define __XFS_DMAPI_H__
diff --git a/fs/xfs/xfs_dmops.c b/fs/xfs/xfs_dmops.c
index cec54ba800eb..629795b3b3d5 100644
--- a/fs/xfs/xfs_dmops.c
+++ b/fs/xfs/xfs_dmops.c
@@ -1,40 +1,25 @@
1/* 1/*
2 * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32#include "xfs.h" 18#include "xfs.h"
33 19#include "xfs_fs.h"
34#include "xfs_macros.h"
35#include "xfs_types.h" 20#include "xfs_types.h"
36#include "xfs_inum.h"
37#include "xfs_log.h" 21#include "xfs_log.h"
22#include "xfs_inum.h"
38#include "xfs_trans.h" 23#include "xfs_trans.h"
39#include "xfs_sb.h" 24#include "xfs_sb.h"
40#include "xfs_ag.h" 25#include "xfs_ag.h"
diff --git a/fs/xfs/xfs_error.c b/fs/xfs/xfs_error.c
index dcd3fdd5c1f7..d7b6b5d16704 100644
--- a/fs/xfs/xfs_error.c
+++ b/fs/xfs/xfs_error.c
@@ -1,51 +1,35 @@
1/* 1/*
2 * Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2001,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32
33#include "xfs.h" 18#include "xfs.h"
34 19#include "xfs_fs.h"
35#include "xfs_macros.h"
36#include "xfs_types.h" 20#include "xfs_types.h"
37#include "xfs_inum.h"
38#include "xfs_log.h" 21#include "xfs_log.h"
39#include "xfs_sb.h" 22#include "xfs_inum.h"
40#include "xfs_trans.h" 23#include "xfs_trans.h"
24#include "xfs_sb.h"
41#include "xfs_dir.h" 25#include "xfs_dir.h"
42#include "xfs_dir2.h" 26#include "xfs_dir2.h"
43#include "xfs_dmapi.h" 27#include "xfs_dmapi.h"
44#include "xfs_mount.h" 28#include "xfs_mount.h"
45#include "xfs_bmap_btree.h" 29#include "xfs_bmap_btree.h"
46#include "xfs_attr_sf.h"
47#include "xfs_dir_sf.h" 30#include "xfs_dir_sf.h"
48#include "xfs_dir2_sf.h" 31#include "xfs_dir2_sf.h"
32#include "xfs_attr_sf.h"
49#include "xfs_dinode.h" 33#include "xfs_dinode.h"
50#include "xfs_inode.h" 34#include "xfs_inode.h"
51#include "xfs_utils.h" 35#include "xfs_utils.h"
diff --git a/fs/xfs/xfs_error.h b/fs/xfs/xfs_error.h
index 52ee2b90b5ed..06d8a8426c16 100644
--- a/fs/xfs/xfs_error.h
+++ b/fs/xfs/xfs_error.h
@@ -1,39 +1,25 @@
1/* 1/*
2 * Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32#ifndef __XFS_ERROR_H__ 18#ifndef __XFS_ERROR_H__
33#define __XFS_ERROR_H__ 19#define __XFS_ERROR_H__
34 20
35#define prdev(fmt,targ,args...) \ 21#define prdev(fmt,targ,args...) \
36 printk("XFS: device %s- " fmt "\n", XFS_BUFTARG_NAME(targ), ## args) 22 printk("XFS: device %s - " fmt "\n", XFS_BUFTARG_NAME(targ), ## args)
37 23
38#define XFS_ERECOVER 1 /* Failure to recover log */ 24#define XFS_ERECOVER 1 /* Failure to recover log */
39#define XFS_ELOGSTAT 2 /* Failure to stat log in user space */ 25#define XFS_ELOGSTAT 2 /* Failure to stat log in user space */
@@ -54,24 +40,10 @@ extern int xfs_error_trap(int);
54 40
55struct xfs_mount; 41struct xfs_mount;
56 42
57extern void 43extern void xfs_error_report(char *tag, int level, struct xfs_mount *mp,
58xfs_error_report( 44 char *fname, int linenum, inst_t *ra);
59 char *tag, 45extern void xfs_corruption_error(char *tag, int level, struct xfs_mount *mp,
60 int level, 46 void *p, char *fname, int linenum, inst_t *ra);
61 struct xfs_mount *mp,
62 char *fname,
63 int linenum,
64 inst_t *ra);
65
66extern void
67xfs_corruption_error(
68 char *tag,
69 int level,
70 struct xfs_mount *mp,
71 void *p,
72 char *fname,
73 int linenum,
74 inst_t *ra);
75 47
76#define XFS_ERROR_REPORT(e, lvl, mp) \ 48#define XFS_ERROR_REPORT(e, lvl, mp) \
77 xfs_error_report(e, lvl, mp, __FILE__, __LINE__, __return_address) 49 xfs_error_report(e, lvl, mp, __FILE__, __LINE__, __return_address)
@@ -84,6 +56,32 @@ xfs_corruption_error(
84#define XFS_ERRLEVEL_HIGH 5 56#define XFS_ERRLEVEL_HIGH 5
85 57
86/* 58/*
59 * Macros to set EFSCORRUPTED & return/branch.
60 */
61#define XFS_WANT_CORRUPTED_GOTO(x,l) \
62 { \
63 int fs_is_ok = (x); \
64 ASSERT(fs_is_ok); \
65 if (unlikely(!fs_is_ok)) { \
66 XFS_ERROR_REPORT("XFS_WANT_CORRUPTED_GOTO", \
67 XFS_ERRLEVEL_LOW, NULL); \
68 error = XFS_ERROR(EFSCORRUPTED); \
69 goto l; \
70 } \
71 }
72
73#define XFS_WANT_CORRUPTED_RETURN(x) \
74 { \
75 int fs_is_ok = (x); \
76 ASSERT(fs_is_ok); \
77 if (unlikely(!fs_is_ok)) { \
78 XFS_ERROR_REPORT("XFS_WANT_CORRUPTED_RETURN", \
79 XFS_ERRLEVEL_LOW, NULL); \
80 return XFS_ERROR(EFSCORRUPTED); \
81 } \
82 }
83
84/*
87 * error injection tags - the labels can be anything you want 85 * error injection tags - the labels can be anything you want
88 * but each tag should have its own unique number 86 * but each tag should have its own unique number
89 */ 87 */
@@ -139,8 +137,8 @@ xfs_corruption_error(
139#define XFS_RANDOM_BMAPIFORMAT XFS_RANDOM_DEFAULT 137#define XFS_RANDOM_BMAPIFORMAT XFS_RANDOM_DEFAULT
140 138
141#if (defined(DEBUG) || defined(INDUCE_IO_ERROR)) 139#if (defined(DEBUG) || defined(INDUCE_IO_ERROR))
142extern int xfs_error_test(int, int *, char *, int, char *, unsigned long); 140extern int xfs_error_test(int, int *, char *, int, char *, unsigned long);
143void xfs_error_test_init(void); 141extern void xfs_error_test_init(void);
144 142
145#define XFS_NUM_INJECT_ERROR 10 143#define XFS_NUM_INJECT_ERROR 10
146 144
@@ -156,12 +154,10 @@ void xfs_error_test_init(void);
156 (rf))) 154 (rf)))
157#endif /* __ANSI_CPP__ */ 155#endif /* __ANSI_CPP__ */
158 156
159int xfs_errortag_add(int error_tag, xfs_mount_t *mp); 157extern int xfs_errortag_add(int error_tag, xfs_mount_t *mp);
160int xfs_errortag_clear(int error_tag, xfs_mount_t *mp); 158extern int xfs_errortag_clear(int error_tag, xfs_mount_t *mp);
161 159extern int xfs_errortag_clearall(xfs_mount_t *mp);
162int xfs_errortag_clearall(xfs_mount_t *mp); 160extern int xfs_errortag_clearall_umount(int64_t fsid, char *fsname, int loud);
163int xfs_errortag_clearall_umount(int64_t fsid, char *fsname,
164 int loud);
165#else 161#else
166#define XFS_TEST_ERROR(expr, mp, tag, rf) (expr) 162#define XFS_TEST_ERROR(expr, mp, tag, rf) (expr)
167#define xfs_errortag_add(tag, mp) (ENOSYS) 163#define xfs_errortag_add(tag, mp) (ENOSYS)
@@ -185,9 +181,9 @@ int xfs_errortag_clearall_umount(int64_t fsid, char *fsname,
185 181
186struct xfs_mount; 182struct xfs_mount;
187/* PRINTFLIKE4 */ 183/* PRINTFLIKE4 */
188void xfs_cmn_err(int panic_tag, int level, struct xfs_mount *mp, 184extern void xfs_cmn_err(int panic_tag, int level, struct xfs_mount *mp,
189 char *fmt, ...); 185 char *fmt, ...);
190/* PRINTFLIKE3 */ 186/* PRINTFLIKE3 */
191void xfs_fs_cmn_err(int level, struct xfs_mount *mp, char *fmt, ...); 187extern void xfs_fs_cmn_err(int level, struct xfs_mount *mp, char *fmt, ...);
192 188
193#endif /* __XFS_ERROR_H__ */ 189#endif /* __XFS_ERROR_H__ */
diff --git a/fs/xfs/xfs_extfree_item.c b/fs/xfs/xfs_extfree_item.c
index cc7d1494a45d..f19282ec8549 100644
--- a/fs/xfs/xfs_extfree_item.c
+++ b/fs/xfs/xfs_extfree_item.c
@@ -1,46 +1,25 @@
1/* 1/*
2 * Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2001,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */
32
33/*
34 * This file contains the implementation of the xfs_efi_log_item
35 * and xfs_efd_log_item items.
36 */ 17 */
37
38#include "xfs.h" 18#include "xfs.h"
39 19#include "xfs_fs.h"
40#include "xfs_macros.h"
41#include "xfs_types.h" 20#include "xfs_types.h"
42#include "xfs_inum.h"
43#include "xfs_log.h" 21#include "xfs_log.h"
22#include "xfs_inum.h"
44#include "xfs_trans.h" 23#include "xfs_trans.h"
45#include "xfs_buf_item.h" 24#include "xfs_buf_item.h"
46#include "xfs_sb.h" 25#include "xfs_sb.h"
diff --git a/fs/xfs/xfs_extfree_item.h b/fs/xfs/xfs_extfree_item.h
index d433bac9f59d..5bf681708fec 100644
--- a/fs/xfs/xfs_extfree_item.h
+++ b/fs/xfs/xfs_extfree_item.h
@@ -1,33 +1,19 @@
1/* 1/*
2 * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32#ifndef __XFS_EXTFREE_ITEM_H__ 18#ifndef __XFS_EXTFREE_ITEM_H__
33#define __XFS_EXTFREE_ITEM_H__ 19#define __XFS_EXTFREE_ITEM_H__
diff --git a/fs/xfs/xfs_fs.h b/fs/xfs/xfs_fs.h
index 095af0a5cff3..ba096f80f48d 100644
--- a/fs/xfs/xfs_fs.h
+++ b/fs/xfs/xfs_fs.h
@@ -1,34 +1,19 @@
1/* 1/*
2 * Copyright (c) 1995-2003 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 1995-2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2.1 of the GNU Lesser General Public License 6 * modify it under the terms of the GNU General Public License as
6 * as published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this program; if not, write the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307,
22 * USA.
23 *
24 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
25 * Mountain View, CA 94043, or:
26 *
27 * http://www.sgi.com
28 *
29 * For further information regarding this notice, see:
30 *
31 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
32 */ 17 */
33#ifndef __XFS_FS_H__ 18#ifndef __XFS_FS_H__
34#define __XFS_FS_H__ 19#define __XFS_FS_H__
@@ -251,6 +236,7 @@ typedef struct xfs_fsop_resblks {
251#define XFS_FSOP_GEOM_FLAGS_DIRV2 0x0080 /* directory version 2 */ 236#define XFS_FSOP_GEOM_FLAGS_DIRV2 0x0080 /* directory version 2 */
252#define XFS_FSOP_GEOM_FLAGS_LOGV2 0x0100 /* log format version 2 */ 237#define XFS_FSOP_GEOM_FLAGS_LOGV2 0x0100 /* log format version 2 */
253#define XFS_FSOP_GEOM_FLAGS_SECTOR 0x0200 /* sector sizes >1BB */ 238#define XFS_FSOP_GEOM_FLAGS_SECTOR 0x0200 /* sector sizes >1BB */
239#define XFS_FSOP_GEOM_FLAGS_ATTR2 0x0400 /* inline attributes rework */
254 240
255 241
256/* 242/*
diff --git a/fs/xfs/xfs_fsops.c b/fs/xfs/xfs_fsops.c
index ca535d613190..7ceabd0e2d9d 100644
--- a/fs/xfs/xfs_fsops.c
+++ b/fs/xfs/xfs_fsops.c
@@ -1,66 +1,51 @@
1/* 1/*
2 * Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32
33#include "xfs.h" 18#include "xfs.h"
34#include "xfs_macros.h" 19#include "xfs_fs.h"
35#include "xfs_types.h" 20#include "xfs_types.h"
21#include "xfs_bit.h"
36#include "xfs_inum.h" 22#include "xfs_inum.h"
37#include "xfs_log.h" 23#include "xfs_log.h"
38#include "xfs_trans.h" 24#include "xfs_trans.h"
39#include "xfs_sb.h" 25#include "xfs_sb.h"
26#include "xfs_ag.h"
40#include "xfs_dir.h" 27#include "xfs_dir.h"
28#include "xfs_dir2.h"
41#include "xfs_dmapi.h" 29#include "xfs_dmapi.h"
42#include "xfs_mount.h" 30#include "xfs_mount.h"
43#include "xfs_ag.h"
44#include "xfs_alloc_btree.h"
45#include "xfs_bmap_btree.h" 31#include "xfs_bmap_btree.h"
32#include "xfs_alloc_btree.h"
46#include "xfs_ialloc_btree.h" 33#include "xfs_ialloc_btree.h"
34#include "xfs_dir_sf.h"
35#include "xfs_dir2_sf.h"
36#include "xfs_attr_sf.h"
37#include "xfs_dinode.h"
38#include "xfs_inode.h"
39#include "xfs_inode_item.h"
47#include "xfs_btree.h" 40#include "xfs_btree.h"
48#include "xfs_error.h" 41#include "xfs_error.h"
49#include "xfs_alloc.h" 42#include "xfs_alloc.h"
50#include "xfs_ialloc.h" 43#include "xfs_ialloc.h"
51#include "xfs_fsops.h" 44#include "xfs_fsops.h"
52#include "xfs_itable.h" 45#include "xfs_itable.h"
53#include "xfs_rw.h"
54#include "xfs_refcache.h"
55#include "xfs_trans_space.h" 46#include "xfs_trans_space.h"
56#include "xfs_rtalloc.h" 47#include "xfs_rtalloc.h"
57#include "xfs_dir2.h" 48#include "xfs_rw.h"
58#include "xfs_attr_sf.h"
59#include "xfs_dir_sf.h"
60#include "xfs_dir2_sf.h"
61#include "xfs_dinode.h"
62#include "xfs_inode.h"
63#include "xfs_inode_item.h"
64 49
65/* 50/*
66 * File system operations 51 * File system operations
@@ -110,7 +95,9 @@ xfs_fs_geometry(
110 (XFS_SB_VERSION_HASDIRV2(&mp->m_sb) ? 95 (XFS_SB_VERSION_HASDIRV2(&mp->m_sb) ?
111 XFS_FSOP_GEOM_FLAGS_DIRV2 : 0) | 96 XFS_FSOP_GEOM_FLAGS_DIRV2 : 0) |
112 (XFS_SB_VERSION_HASSECTOR(&mp->m_sb) ? 97 (XFS_SB_VERSION_HASSECTOR(&mp->m_sb) ?
113 XFS_FSOP_GEOM_FLAGS_SECTOR : 0); 98 XFS_FSOP_GEOM_FLAGS_SECTOR : 0) |
99 (XFS_SB_VERSION_HASATTR2(&mp->m_sb) ?
100 XFS_FSOP_GEOM_FLAGS_ATTR2 : 0);
114 geo->logsectsize = XFS_SB_VERSION_HASSECTOR(&mp->m_sb) ? 101 geo->logsectsize = XFS_SB_VERSION_HASSECTOR(&mp->m_sb) ?
115 mp->m_sb.sb_logsectsize : BBSIZE; 102 mp->m_sb.sb_logsectsize : BBSIZE;
116 geo->rtsectsize = mp->m_sb.sb_blocksize; 103 geo->rtsectsize = mp->m_sb.sb_blocksize;
@@ -184,7 +171,7 @@ xfs_growfs_data_private(
184 memset(&mp->m_perag[oagcount], 0, 171 memset(&mp->m_perag[oagcount], 0,
185 (nagcount - oagcount) * sizeof(xfs_perag_t)); 172 (nagcount - oagcount) * sizeof(xfs_perag_t));
186 mp->m_flags |= XFS_MOUNT_32BITINODES; 173 mp->m_flags |= XFS_MOUNT_32BITINODES;
187 nagimax = xfs_initialize_perag(mp, nagcount); 174 nagimax = xfs_initialize_perag(XFS_MTOVFS(mp), mp, nagcount);
188 up_write(&mp->m_peraglock); 175 up_write(&mp->m_peraglock);
189 } 176 }
190 tp = xfs_trans_alloc(mp, XFS_TRANS_GROWFS); 177 tp = xfs_trans_alloc(mp, XFS_TRANS_GROWFS);
@@ -204,28 +191,26 @@ xfs_growfs_data_private(
204 XFS_FSS_TO_BB(mp, 1), 0); 191 XFS_FSS_TO_BB(mp, 1), 0);
205 agf = XFS_BUF_TO_AGF(bp); 192 agf = XFS_BUF_TO_AGF(bp);
206 memset(agf, 0, mp->m_sb.sb_sectsize); 193 memset(agf, 0, mp->m_sb.sb_sectsize);
207 INT_SET(agf->agf_magicnum, ARCH_CONVERT, XFS_AGF_MAGIC); 194 agf->agf_magicnum = cpu_to_be32(XFS_AGF_MAGIC);
208 INT_SET(agf->agf_versionnum, ARCH_CONVERT, XFS_AGF_VERSION); 195 agf->agf_versionnum = cpu_to_be32(XFS_AGF_VERSION);
209 INT_SET(agf->agf_seqno, ARCH_CONVERT, agno); 196 agf->agf_seqno = cpu_to_be32(agno);
210 if (agno == nagcount - 1) 197 if (agno == nagcount - 1)
211 agsize = 198 agsize =
212 nb - 199 nb -
213 (agno * (xfs_rfsblock_t)mp->m_sb.sb_agblocks); 200 (agno * (xfs_rfsblock_t)mp->m_sb.sb_agblocks);
214 else 201 else
215 agsize = mp->m_sb.sb_agblocks; 202 agsize = mp->m_sb.sb_agblocks;
216 INT_SET(agf->agf_length, ARCH_CONVERT, agsize); 203 agf->agf_length = cpu_to_be32(agsize);
217 INT_SET(agf->agf_roots[XFS_BTNUM_BNOi], ARCH_CONVERT, 204 agf->agf_roots[XFS_BTNUM_BNOi] = cpu_to_be32(XFS_BNO_BLOCK(mp));
218 XFS_BNO_BLOCK(mp)); 205 agf->agf_roots[XFS_BTNUM_CNTi] = cpu_to_be32(XFS_CNT_BLOCK(mp));
219 INT_SET(agf->agf_roots[XFS_BTNUM_CNTi], ARCH_CONVERT, 206 agf->agf_levels[XFS_BTNUM_BNOi] = cpu_to_be32(1);
220 XFS_CNT_BLOCK(mp)); 207 agf->agf_levels[XFS_BTNUM_CNTi] = cpu_to_be32(1);
221 INT_SET(agf->agf_levels[XFS_BTNUM_BNOi], ARCH_CONVERT, 1);
222 INT_SET(agf->agf_levels[XFS_BTNUM_CNTi], ARCH_CONVERT, 1);
223 agf->agf_flfirst = 0; 208 agf->agf_flfirst = 0;
224 INT_SET(agf->agf_fllast, ARCH_CONVERT, XFS_AGFL_SIZE(mp) - 1); 209 agf->agf_fllast = cpu_to_be32(XFS_AGFL_SIZE(mp) - 1);
225 agf->agf_flcount = 0; 210 agf->agf_flcount = 0;
226 tmpsize = agsize - XFS_PREALLOC_BLOCKS(mp); 211 tmpsize = agsize - XFS_PREALLOC_BLOCKS(mp);
227 INT_SET(agf->agf_freeblks, ARCH_CONVERT, tmpsize); 212 agf->agf_freeblks = cpu_to_be32(tmpsize);
228 INT_SET(agf->agf_longest, ARCH_CONVERT, tmpsize); 213 agf->agf_longest = cpu_to_be32(tmpsize);
229 error = xfs_bwrite(mp, bp); 214 error = xfs_bwrite(mp, bp);
230 if (error) { 215 if (error) {
231 goto error0; 216 goto error0;
@@ -238,19 +223,18 @@ xfs_growfs_data_private(
238 XFS_FSS_TO_BB(mp, 1), 0); 223 XFS_FSS_TO_BB(mp, 1), 0);
239 agi = XFS_BUF_TO_AGI(bp); 224 agi = XFS_BUF_TO_AGI(bp);
240 memset(agi, 0, mp->m_sb.sb_sectsize); 225 memset(agi, 0, mp->m_sb.sb_sectsize);
241 INT_SET(agi->agi_magicnum, ARCH_CONVERT, XFS_AGI_MAGIC); 226 agi->agi_magicnum = cpu_to_be32(XFS_AGI_MAGIC);
242 INT_SET(agi->agi_versionnum, ARCH_CONVERT, XFS_AGI_VERSION); 227 agi->agi_versionnum = cpu_to_be32(XFS_AGI_VERSION);
243 INT_SET(agi->agi_seqno, ARCH_CONVERT, agno); 228 agi->agi_seqno = cpu_to_be32(agno);
244 INT_SET(agi->agi_length, ARCH_CONVERT, agsize); 229 agi->agi_length = cpu_to_be32(agsize);
245 agi->agi_count = 0; 230 agi->agi_count = 0;
246 INT_SET(agi->agi_root, ARCH_CONVERT, XFS_IBT_BLOCK(mp)); 231 agi->agi_root = cpu_to_be32(XFS_IBT_BLOCK(mp));
247 INT_SET(agi->agi_level, ARCH_CONVERT, 1); 232 agi->agi_level = cpu_to_be32(1);
248 agi->agi_freecount = 0; 233 agi->agi_freecount = 0;
249 INT_SET(agi->agi_newino, ARCH_CONVERT, NULLAGINO); 234 agi->agi_newino = cpu_to_be32(NULLAGINO);
250 INT_SET(agi->agi_dirino, ARCH_CONVERT, NULLAGINO); 235 agi->agi_dirino = cpu_to_be32(NULLAGINO);
251 for (bucket = 0; bucket < XFS_AGI_UNLINKED_BUCKETS; bucket++) 236 for (bucket = 0; bucket < XFS_AGI_UNLINKED_BUCKETS; bucket++)
252 INT_SET(agi->agi_unlinked[bucket], ARCH_CONVERT, 237 agi->agi_unlinked[bucket] = cpu_to_be32(NULLAGINO);
253 NULLAGINO);
254 error = xfs_bwrite(mp, bp); 238 error = xfs_bwrite(mp, bp);
255 if (error) { 239 if (error) {
256 goto error0; 240 goto error0;
@@ -263,17 +247,16 @@ xfs_growfs_data_private(
263 BTOBB(mp->m_sb.sb_blocksize), 0); 247 BTOBB(mp->m_sb.sb_blocksize), 0);
264 block = XFS_BUF_TO_SBLOCK(bp); 248 block = XFS_BUF_TO_SBLOCK(bp);
265 memset(block, 0, mp->m_sb.sb_blocksize); 249 memset(block, 0, mp->m_sb.sb_blocksize);
266 INT_SET(block->bb_magic, ARCH_CONVERT, XFS_ABTB_MAGIC); 250 block->bb_magic = cpu_to_be32(XFS_ABTB_MAGIC);
267 block->bb_level = 0; 251 block->bb_level = 0;
268 INT_SET(block->bb_numrecs, ARCH_CONVERT, 1); 252 block->bb_numrecs = cpu_to_be16(1);
269 INT_SET(block->bb_leftsib, ARCH_CONVERT, NULLAGBLOCK); 253 block->bb_leftsib = cpu_to_be32(NULLAGBLOCK);
270 INT_SET(block->bb_rightsib, ARCH_CONVERT, NULLAGBLOCK); 254 block->bb_rightsib = cpu_to_be32(NULLAGBLOCK);
271 arec = XFS_BTREE_REC_ADDR(mp->m_sb.sb_blocksize, xfs_alloc, 255 arec = XFS_BTREE_REC_ADDR(mp->m_sb.sb_blocksize, xfs_alloc,
272 block, 1, mp->m_alloc_mxr[0]); 256 block, 1, mp->m_alloc_mxr[0]);
273 INT_SET(arec->ar_startblock, ARCH_CONVERT, 257 arec->ar_startblock = cpu_to_be32(XFS_PREALLOC_BLOCKS(mp));
274 XFS_PREALLOC_BLOCKS(mp)); 258 arec->ar_blockcount = cpu_to_be32(
275 INT_SET(arec->ar_blockcount, ARCH_CONVERT, 259 agsize - be32_to_cpu(arec->ar_startblock));
276 agsize - INT_GET(arec->ar_startblock, ARCH_CONVERT));
277 error = xfs_bwrite(mp, bp); 260 error = xfs_bwrite(mp, bp);
278 if (error) { 261 if (error) {
279 goto error0; 262 goto error0;
@@ -286,18 +269,17 @@ xfs_growfs_data_private(
286 BTOBB(mp->m_sb.sb_blocksize), 0); 269 BTOBB(mp->m_sb.sb_blocksize), 0);
287 block = XFS_BUF_TO_SBLOCK(bp); 270 block = XFS_BUF_TO_SBLOCK(bp);
288 memset(block, 0, mp->m_sb.sb_blocksize); 271 memset(block, 0, mp->m_sb.sb_blocksize);
289 INT_SET(block->bb_magic, ARCH_CONVERT, XFS_ABTC_MAGIC); 272 block->bb_magic = cpu_to_be32(XFS_ABTC_MAGIC);
290 block->bb_level = 0; 273 block->bb_level = 0;
291 INT_SET(block->bb_numrecs, ARCH_CONVERT, 1); 274 block->bb_numrecs = cpu_to_be16(1);
292 INT_SET(block->bb_leftsib, ARCH_CONVERT, NULLAGBLOCK); 275 block->bb_leftsib = cpu_to_be32(NULLAGBLOCK);
293 INT_SET(block->bb_rightsib, ARCH_CONVERT, NULLAGBLOCK); 276 block->bb_rightsib = cpu_to_be32(NULLAGBLOCK);
294 arec = XFS_BTREE_REC_ADDR(mp->m_sb.sb_blocksize, xfs_alloc, 277 arec = XFS_BTREE_REC_ADDR(mp->m_sb.sb_blocksize, xfs_alloc,
295 block, 1, mp->m_alloc_mxr[0]); 278 block, 1, mp->m_alloc_mxr[0]);
296 INT_SET(arec->ar_startblock, ARCH_CONVERT, 279 arec->ar_startblock = cpu_to_be32(XFS_PREALLOC_BLOCKS(mp));
297 XFS_PREALLOC_BLOCKS(mp)); 280 arec->ar_blockcount = cpu_to_be32(
298 INT_SET(arec->ar_blockcount, ARCH_CONVERT, 281 agsize - be32_to_cpu(arec->ar_startblock));
299 agsize - INT_GET(arec->ar_startblock, ARCH_CONVERT)); 282 nfree += be32_to_cpu(arec->ar_blockcount);
300 nfree += INT_GET(arec->ar_blockcount, ARCH_CONVERT);
301 error = xfs_bwrite(mp, bp); 283 error = xfs_bwrite(mp, bp);
302 if (error) { 284 if (error) {
303 goto error0; 285 goto error0;
@@ -310,11 +292,11 @@ xfs_growfs_data_private(
310 BTOBB(mp->m_sb.sb_blocksize), 0); 292 BTOBB(mp->m_sb.sb_blocksize), 0);
311 block = XFS_BUF_TO_SBLOCK(bp); 293 block = XFS_BUF_TO_SBLOCK(bp);
312 memset(block, 0, mp->m_sb.sb_blocksize); 294 memset(block, 0, mp->m_sb.sb_blocksize);
313 INT_SET(block->bb_magic, ARCH_CONVERT, XFS_IBT_MAGIC); 295 block->bb_magic = cpu_to_be32(XFS_IBT_MAGIC);
314 block->bb_level = 0; 296 block->bb_level = 0;
315 block->bb_numrecs = 0; 297 block->bb_numrecs = 0;
316 INT_SET(block->bb_leftsib, ARCH_CONVERT, NULLAGBLOCK); 298 block->bb_leftsib = cpu_to_be32(NULLAGBLOCK);
317 INT_SET(block->bb_rightsib, ARCH_CONVERT, NULLAGBLOCK); 299 block->bb_rightsib = cpu_to_be32(NULLAGBLOCK);
318 error = xfs_bwrite(mp, bp); 300 error = xfs_bwrite(mp, bp);
319 if (error) { 301 if (error) {
320 goto error0; 302 goto error0;
@@ -334,10 +316,9 @@ xfs_growfs_data_private(
334 } 316 }
335 ASSERT(bp); 317 ASSERT(bp);
336 agi = XFS_BUF_TO_AGI(bp); 318 agi = XFS_BUF_TO_AGI(bp);
337 INT_MOD(agi->agi_length, ARCH_CONVERT, new); 319 be32_add(&agi->agi_length, new);
338 ASSERT(nagcount == oagcount || 320 ASSERT(nagcount == oagcount ||
339 INT_GET(agi->agi_length, ARCH_CONVERT) == 321 be32_to_cpu(agi->agi_length) == mp->m_sb.sb_agblocks);
340 mp->m_sb.sb_agblocks);
341 xfs_ialloc_log_agi(tp, bp, XFS_AGI_LENGTH); 322 xfs_ialloc_log_agi(tp, bp, XFS_AGI_LENGTH);
342 /* 323 /*
343 * Change agf length. 324 * Change agf length.
@@ -348,14 +329,14 @@ xfs_growfs_data_private(
348 } 329 }
349 ASSERT(bp); 330 ASSERT(bp);
350 agf = XFS_BUF_TO_AGF(bp); 331 agf = XFS_BUF_TO_AGF(bp);
351 INT_MOD(agf->agf_length, ARCH_CONVERT, new); 332 be32_add(&agf->agf_length, new);
352 ASSERT(INT_GET(agf->agf_length, ARCH_CONVERT) == 333 ASSERT(be32_to_cpu(agf->agf_length) ==
353 INT_GET(agi->agi_length, ARCH_CONVERT)); 334 be32_to_cpu(agi->agi_length));
354 /* 335 /*
355 * Free the new space. 336 * Free the new space.
356 */ 337 */
357 error = xfs_free_extent(tp, XFS_AGB_TO_FSB(mp, agno, 338 error = xfs_free_extent(tp, XFS_AGB_TO_FSB(mp, agno,
358 INT_GET(agf->agf_length, ARCH_CONVERT) - new), new); 339 be32_to_cpu(agf->agf_length) - new), new);
359 if (error) { 340 if (error) {
360 goto error0; 341 goto error0;
361 } 342 }
diff --git a/fs/xfs/xfs_fsops.h b/fs/xfs/xfs_fsops.h
index b61486173a61..f32713f14f9a 100644
--- a/fs/xfs/xfs_fsops.h
+++ b/fs/xfs/xfs_fsops.h
@@ -1,67 +1,29 @@
1/* 1/*
2 * Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2001,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32#ifndef __XFS_FSOPS_H__ 18#ifndef __XFS_FSOPS_H__
33#define __XFS_FSOPS_H__ 19#define __XFS_FSOPS_H__
34 20
35int 21extern int xfs_fs_geometry(xfs_mount_t *mp, xfs_fsop_geom_t *geo, int nversion);
36xfs_fs_geometry( 22extern int xfs_growfs_data(xfs_mount_t *mp, xfs_growfs_data_t *in);
37 xfs_mount_t *mp, 23extern int xfs_growfs_log(xfs_mount_t *mp, xfs_growfs_log_t *in);
38 xfs_fsop_geom_t *geo, 24extern int xfs_fs_counts(xfs_mount_t *mp, xfs_fsop_counts_t *cnt);
39 int new_version); 25extern int xfs_reserve_blocks(xfs_mount_t *mp, __uint64_t *inval,
40 26 xfs_fsop_resblks_t *outval);
41int 27extern int xfs_fs_goingdown(xfs_mount_t *mp, __uint32_t inflags);
42xfs_growfs_data(
43 xfs_mount_t *mp,
44 xfs_growfs_data_t *in);
45
46int
47xfs_growfs_log(
48 xfs_mount_t *mp,
49 xfs_growfs_log_t *in);
50
51int
52xfs_fs_counts(
53 xfs_mount_t *mp,
54 xfs_fsop_counts_t *cnt);
55
56int
57xfs_reserve_blocks(
58 xfs_mount_t *mp,
59 __uint64_t *inval,
60 xfs_fsop_resblks_t *outval);
61
62int
63xfs_fs_goingdown(
64 xfs_mount_t *mp,
65 __uint32_t inflags);
66 28
67#endif /* __XFS_FSOPS_H__ */ 29#endif /* __XFS_FSOPS_H__ */
diff --git a/fs/xfs/xfs_ialloc.c b/fs/xfs/xfs_ialloc.c
index ce5fee9eaec5..8f3fae1aa98a 100644
--- a/fs/xfs/xfs_ialloc.c
+++ b/fs/xfs/xfs_ialloc.c
@@ -1,41 +1,26 @@
1/* 1/*
2 * Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32
33#include "xfs.h" 18#include "xfs.h"
34 19#include "xfs_fs.h"
35#include "xfs_macros.h"
36#include "xfs_types.h" 20#include "xfs_types.h"
37#include "xfs_inum.h" 21#include "xfs_bit.h"
38#include "xfs_log.h" 22#include "xfs_log.h"
23#include "xfs_inum.h"
39#include "xfs_trans.h" 24#include "xfs_trans.h"
40#include "xfs_sb.h" 25#include "xfs_sb.h"
41#include "xfs_ag.h" 26#include "xfs_ag.h"
@@ -43,18 +28,17 @@
43#include "xfs_dir2.h" 28#include "xfs_dir2.h"
44#include "xfs_dmapi.h" 29#include "xfs_dmapi.h"
45#include "xfs_mount.h" 30#include "xfs_mount.h"
46#include "xfs_alloc_btree.h"
47#include "xfs_bmap_btree.h" 31#include "xfs_bmap_btree.h"
32#include "xfs_alloc_btree.h"
48#include "xfs_ialloc_btree.h" 33#include "xfs_ialloc_btree.h"
49#include "xfs_btree.h"
50#include "xfs_ialloc.h"
51#include "xfs_attr_sf.h"
52#include "xfs_dir_sf.h" 34#include "xfs_dir_sf.h"
53#include "xfs_dir2_sf.h" 35#include "xfs_dir2_sf.h"
36#include "xfs_attr_sf.h"
54#include "xfs_dinode.h" 37#include "xfs_dinode.h"
55#include "xfs_inode.h" 38#include "xfs_inode.h"
39#include "xfs_btree.h"
40#include "xfs_ialloc.h"
56#include "xfs_alloc.h" 41#include "xfs_alloc.h"
57#include "xfs_bit.h"
58#include "xfs_rtalloc.h" 42#include "xfs_rtalloc.h"
59#include "xfs_error.h" 43#include "xfs_error.h"
60#include "xfs_bmap.h" 44#include "xfs_bmap.h"
@@ -194,8 +178,8 @@ xfs_ialloc_ag_alloc(
194 * Ideally they should be spaced out through the a.g. 178 * Ideally they should be spaced out through the a.g.
195 * For now, just allocate blocks up front. 179 * For now, just allocate blocks up front.
196 */ 180 */
197 args.agbno = INT_GET(agi->agi_root, ARCH_CONVERT); 181 args.agbno = be32_to_cpu(agi->agi_root);
198 args.fsbno = XFS_AGB_TO_FSB(args.mp, INT_GET(agi->agi_seqno, ARCH_CONVERT), 182 args.fsbno = XFS_AGB_TO_FSB(args.mp, be32_to_cpu(agi->agi_seqno),
199 args.agbno); 183 args.agbno);
200 /* 184 /*
201 * Allocate a fixed-size extent of inodes. 185 * Allocate a fixed-size extent of inodes.
@@ -217,9 +201,9 @@ xfs_ialloc_ag_alloc(
217 */ 201 */
218 if (isaligned && args.fsbno == NULLFSBLOCK) { 202 if (isaligned && args.fsbno == NULLFSBLOCK) {
219 args.type = XFS_ALLOCTYPE_NEAR_BNO; 203 args.type = XFS_ALLOCTYPE_NEAR_BNO;
220 args.agbno = INT_GET(agi->agi_root, ARCH_CONVERT); 204 args.agbno = be32_to_cpu(agi->agi_root);
221 args.fsbno = XFS_AGB_TO_FSB(args.mp, 205 args.fsbno = XFS_AGB_TO_FSB(args.mp,
222 INT_GET(agi->agi_seqno, ARCH_CONVERT), args.agbno); 206 be32_to_cpu(agi->agi_seqno), args.agbno);
223 if (XFS_SB_VERSION_HASALIGN(&args.mp->m_sb) && 207 if (XFS_SB_VERSION_HASALIGN(&args.mp->m_sb) &&
224 args.mp->m_sb.sb_inoalignmt >= 208 args.mp->m_sb.sb_inoalignmt >=
225 XFS_B_TO_FSBT(args.mp, XFS_INODE_CLUSTER_SIZE(args.mp))) 209 XFS_B_TO_FSBT(args.mp, XFS_INODE_CLUSTER_SIZE(args.mp)))
@@ -274,7 +258,7 @@ xfs_ialloc_ag_alloc(
274 /* 258 /*
275 * Get the block. 259 * Get the block.
276 */ 260 */
277 d = XFS_AGB_TO_DADDR(args.mp, INT_GET(agi->agi_seqno, ARCH_CONVERT), 261 d = XFS_AGB_TO_DADDR(args.mp, be32_to_cpu(agi->agi_seqno),
278 args.agbno + (j * blks_per_cluster)); 262 args.agbno + (j * blks_per_cluster));
279 fbuf = xfs_trans_get_buf(tp, args.mp->m_ddev_targp, d, 263 fbuf = xfs_trans_get_buf(tp, args.mp->m_ddev_targp, d,
280 args.mp->m_bsize * blks_per_cluster, 264 args.mp->m_bsize * blks_per_cluster,
@@ -294,17 +278,17 @@ xfs_ialloc_ag_alloc(
294 } 278 }
295 xfs_trans_inode_alloc_buf(tp, fbuf); 279 xfs_trans_inode_alloc_buf(tp, fbuf);
296 } 280 }
297 INT_MOD(agi->agi_count, ARCH_CONVERT, newlen); 281 be32_add(&agi->agi_count, newlen);
298 INT_MOD(agi->agi_freecount, ARCH_CONVERT, newlen); 282 be32_add(&agi->agi_freecount, newlen);
299 down_read(&args.mp->m_peraglock); 283 down_read(&args.mp->m_peraglock);
300 args.mp->m_perag[INT_GET(agi->agi_seqno, ARCH_CONVERT)].pagi_freecount += newlen; 284 args.mp->m_perag[be32_to_cpu(agi->agi_seqno)].pagi_freecount += newlen;
301 up_read(&args.mp->m_peraglock); 285 up_read(&args.mp->m_peraglock);
302 INT_SET(agi->agi_newino, ARCH_CONVERT, newino); 286 agi->agi_newino = cpu_to_be32(newino);
303 /* 287 /*
304 * Insert records describing the new inode chunk into the btree. 288 * Insert records describing the new inode chunk into the btree.
305 */ 289 */
306 cur = xfs_btree_init_cursor(args.mp, tp, agbp, 290 cur = xfs_btree_init_cursor(args.mp, tp, agbp,
307 INT_GET(agi->agi_seqno, ARCH_CONVERT), 291 be32_to_cpu(agi->agi_seqno),
308 XFS_BTNUM_INO, (xfs_inode_t *)0, 0); 292 XFS_BTNUM_INO, (xfs_inode_t *)0, 0);
309 for (thisino = newino; 293 for (thisino = newino;
310 thisino < newino + newlen; 294 thisino < newino + newlen;
@@ -544,7 +528,7 @@ xfs_dialloc(
544 return 0; 528 return 0;
545 } 529 }
546 agi = XFS_BUF_TO_AGI(agbp); 530 agi = XFS_BUF_TO_AGI(agbp);
547 ASSERT(INT_GET(agi->agi_magicnum, ARCH_CONVERT) == XFS_AGI_MAGIC); 531 ASSERT(be32_to_cpu(agi->agi_magicnum) == XFS_AGI_MAGIC);
548 } else { 532 } else {
549 /* 533 /*
550 * Continue where we left off before. In this case, we 534 * Continue where we left off before. In this case, we
@@ -552,12 +536,12 @@ xfs_dialloc(
552 */ 536 */
553 agbp = *IO_agbp; 537 agbp = *IO_agbp;
554 agi = XFS_BUF_TO_AGI(agbp); 538 agi = XFS_BUF_TO_AGI(agbp);
555 ASSERT(INT_GET(agi->agi_magicnum, ARCH_CONVERT) == XFS_AGI_MAGIC); 539 ASSERT(be32_to_cpu(agi->agi_magicnum) == XFS_AGI_MAGIC);
556 ASSERT(INT_GET(agi->agi_freecount, ARCH_CONVERT) > 0); 540 ASSERT(be32_to_cpu(agi->agi_freecount) > 0);
557 } 541 }
558 mp = tp->t_mountp; 542 mp = tp->t_mountp;
559 agcount = mp->m_sb.sb_agcount; 543 agcount = mp->m_sb.sb_agcount;
560 agno = INT_GET(agi->agi_seqno, ARCH_CONVERT); 544 agno = be32_to_cpu(agi->agi_seqno);
561 tagno = agno; 545 tagno = agno;
562 pagno = XFS_INO_TO_AGNO(mp, parent); 546 pagno = XFS_INO_TO_AGNO(mp, parent);
563 pagino = XFS_INO_TO_AGINO(mp, parent); 547 pagino = XFS_INO_TO_AGINO(mp, parent);
@@ -605,7 +589,7 @@ xfs_dialloc(
605 * can commit the current transaction and call 589 * can commit the current transaction and call
606 * us again where we left off. 590 * us again where we left off.
607 */ 591 */
608 ASSERT(INT_GET(agi->agi_freecount, ARCH_CONVERT) > 0); 592 ASSERT(be32_to_cpu(agi->agi_freecount) > 0);
609 *alloc_done = B_TRUE; 593 *alloc_done = B_TRUE;
610 *IO_agbp = agbp; 594 *IO_agbp = agbp;
611 *inop = NULLFSINO; 595 *inop = NULLFSINO;
@@ -636,7 +620,7 @@ nextag:
636 if (error) 620 if (error)
637 goto nextag; 621 goto nextag;
638 agi = XFS_BUF_TO_AGI(agbp); 622 agi = XFS_BUF_TO_AGI(agbp);
639 ASSERT(INT_GET(agi->agi_magicnum, ARCH_CONVERT) == XFS_AGI_MAGIC); 623 ASSERT(be32_to_cpu(agi->agi_magicnum) == XFS_AGI_MAGIC);
640 } 624 }
641 /* 625 /*
642 * Here with an allocation group that has a free inode. 626 * Here with an allocation group that has a free inode.
@@ -645,14 +629,14 @@ nextag:
645 */ 629 */
646 agno = tagno; 630 agno = tagno;
647 *IO_agbp = NULL; 631 *IO_agbp = NULL;
648 cur = xfs_btree_init_cursor(mp, tp, agbp, INT_GET(agi->agi_seqno, ARCH_CONVERT), 632 cur = xfs_btree_init_cursor(mp, tp, agbp, be32_to_cpu(agi->agi_seqno),
649 XFS_BTNUM_INO, (xfs_inode_t *)0, 0); 633 XFS_BTNUM_INO, (xfs_inode_t *)0, 0);
650 /* 634 /*
651 * If pagino is 0 (this is the root inode allocation) use newino. 635 * If pagino is 0 (this is the root inode allocation) use newino.
652 * This must work because we've just allocated some. 636 * This must work because we've just allocated some.
653 */ 637 */
654 if (!pagino) 638 if (!pagino)
655 pagino = INT_GET(agi->agi_newino, ARCH_CONVERT); 639 pagino = be32_to_cpu(agi->agi_newino);
656#ifdef DEBUG 640#ifdef DEBUG
657 if (cur->bc_nlevels == 1) { 641 if (cur->bc_nlevels == 1) {
658 int freecount = 0; 642 int freecount = 0;
@@ -670,7 +654,7 @@ nextag:
670 goto error0; 654 goto error0;
671 } while (i == 1); 655 } while (i == 1);
672 656
673 ASSERT(freecount == INT_GET(agi->agi_freecount, ARCH_CONVERT) || 657 ASSERT(freecount == be32_to_cpu(agi->agi_freecount) ||
674 XFS_FORCED_SHUTDOWN(mp)); 658 XFS_FORCED_SHUTDOWN(mp));
675 } 659 }
676#endif 660#endif
@@ -829,9 +813,9 @@ nextag:
829 * In a different a.g. from the parent. 813 * In a different a.g. from the parent.
830 * See if the most recently allocated block has any free. 814 * See if the most recently allocated block has any free.
831 */ 815 */
832 else if (INT_GET(agi->agi_newino, ARCH_CONVERT) != NULLAGINO) { 816 else if (be32_to_cpu(agi->agi_newino) != NULLAGINO) {
833 if ((error = xfs_inobt_lookup_eq(cur, 817 if ((error = xfs_inobt_lookup_eq(cur,
834 INT_GET(agi->agi_newino, ARCH_CONVERT), 0, 0, &i))) 818 be32_to_cpu(agi->agi_newino), 0, 0, &i)))
835 goto error0; 819 goto error0;
836 if (i == 1 && 820 if (i == 1 &&
837 (error = xfs_inobt_get_rec(cur, &rec.ir_startino, 821 (error = xfs_inobt_get_rec(cur, &rec.ir_startino,
@@ -878,7 +862,7 @@ nextag:
878 if ((error = xfs_inobt_update(cur, rec.ir_startino, rec.ir_freecount, 862 if ((error = xfs_inobt_update(cur, rec.ir_startino, rec.ir_freecount,
879 rec.ir_free))) 863 rec.ir_free)))
880 goto error0; 864 goto error0;
881 INT_MOD(agi->agi_freecount, ARCH_CONVERT, -1); 865 be32_add(&agi->agi_freecount, -1);
882 xfs_ialloc_log_agi(tp, agbp, XFS_AGI_FREECOUNT); 866 xfs_ialloc_log_agi(tp, agbp, XFS_AGI_FREECOUNT);
883 down_read(&mp->m_peraglock); 867 down_read(&mp->m_peraglock);
884 mp->m_perag[tagno].pagi_freecount--; 868 mp->m_perag[tagno].pagi_freecount--;
@@ -898,7 +882,7 @@ nextag:
898 if ((error = xfs_inobt_increment(cur, 0, &i))) 882 if ((error = xfs_inobt_increment(cur, 0, &i)))
899 goto error0; 883 goto error0;
900 } while (i == 1); 884 } while (i == 1);
901 ASSERT(freecount == INT_GET(agi->agi_freecount, ARCH_CONVERT) || 885 ASSERT(freecount == be32_to_cpu(agi->agi_freecount) ||
902 XFS_FORCED_SHUTDOWN(mp)); 886 XFS_FORCED_SHUTDOWN(mp));
903 } 887 }
904#endif 888#endif
@@ -957,8 +941,11 @@ xfs_difree(
957 agino = XFS_INO_TO_AGINO(mp, inode); 941 agino = XFS_INO_TO_AGINO(mp, inode);
958 if (inode != XFS_AGINO_TO_INO(mp, agno, agino)) { 942 if (inode != XFS_AGINO_TO_INO(mp, agno, agino)) {
959 cmn_err(CE_WARN, 943 cmn_err(CE_WARN,
960 "xfs_difree: inode != XFS_AGINO_TO_INO() (%d != %d) on %s. Returning EINVAL.", 944 "xfs_difree: inode != XFS_AGINO_TO_INO() "
961 inode, XFS_AGINO_TO_INO(mp, agno, agino), mp->m_fsname); 945 "(%llu != %llu) on %s. Returning EINVAL.",
946 (unsigned long long)inode,
947 (unsigned long long)XFS_AGINO_TO_INO(mp, agno, agino),
948 mp->m_fsname);
962 ASSERT(0); 949 ASSERT(0);
963 return XFS_ERROR(EINVAL); 950 return XFS_ERROR(EINVAL);
964 } 951 }
@@ -983,8 +970,8 @@ xfs_difree(
983 return error; 970 return error;
984 } 971 }
985 agi = XFS_BUF_TO_AGI(agbp); 972 agi = XFS_BUF_TO_AGI(agbp);
986 ASSERT(INT_GET(agi->agi_magicnum, ARCH_CONVERT) == XFS_AGI_MAGIC); 973 ASSERT(be32_to_cpu(agi->agi_magicnum) == XFS_AGI_MAGIC);
987 ASSERT(agbno < INT_GET(agi->agi_length, ARCH_CONVERT)); 974 ASSERT(agbno < be32_to_cpu(agi->agi_length));
988 /* 975 /*
989 * Initialize the cursor. 976 * Initialize the cursor.
990 */ 977 */
@@ -1006,7 +993,7 @@ xfs_difree(
1006 goto error0; 993 goto error0;
1007 } 994 }
1008 } while (i == 1); 995 } while (i == 1);
1009 ASSERT(freecount == INT_GET(agi->agi_freecount, ARCH_CONVERT) || 996 ASSERT(freecount == be32_to_cpu(agi->agi_freecount) ||
1010 XFS_FORCED_SHUTDOWN(mp)); 997 XFS_FORCED_SHUTDOWN(mp));
1011 } 998 }
1012#endif 999#endif
@@ -1055,8 +1042,8 @@ xfs_difree(
1055 * to be freed when the transaction is committed. 1042 * to be freed when the transaction is committed.
1056 */ 1043 */
1057 ilen = XFS_IALLOC_INODES(mp); 1044 ilen = XFS_IALLOC_INODES(mp);
1058 INT_MOD(agi->agi_count, ARCH_CONVERT, -ilen); 1045 be32_add(&agi->agi_count, -ilen);
1059 INT_MOD(agi->agi_freecount, ARCH_CONVERT, -(ilen - 1)); 1046 be32_add(&agi->agi_freecount, -(ilen - 1));
1060 xfs_ialloc_log_agi(tp, agbp, XFS_AGI_COUNT | XFS_AGI_FREECOUNT); 1047 xfs_ialloc_log_agi(tp, agbp, XFS_AGI_COUNT | XFS_AGI_FREECOUNT);
1061 down_read(&mp->m_peraglock); 1048 down_read(&mp->m_peraglock);
1062 mp->m_perag[agno].pagi_freecount -= ilen - 1; 1049 mp->m_perag[agno].pagi_freecount -= ilen - 1;
@@ -1085,7 +1072,7 @@ xfs_difree(
1085 /* 1072 /*
1086 * Change the inode free counts and log the ag/sb changes. 1073 * Change the inode free counts and log the ag/sb changes.
1087 */ 1074 */
1088 INT_MOD(agi->agi_freecount, ARCH_CONVERT, 1); 1075 be32_add(&agi->agi_freecount, 1);
1089 xfs_ialloc_log_agi(tp, agbp, XFS_AGI_FREECOUNT); 1076 xfs_ialloc_log_agi(tp, agbp, XFS_AGI_FREECOUNT);
1090 down_read(&mp->m_peraglock); 1077 down_read(&mp->m_peraglock);
1091 mp->m_perag[agno].pagi_freecount++; 1078 mp->m_perag[agno].pagi_freecount++;
@@ -1111,7 +1098,7 @@ xfs_difree(
1111 goto error0; 1098 goto error0;
1112 } 1099 }
1113 } while (i == 1); 1100 } while (i == 1);
1114 ASSERT(freecount == INT_GET(agi->agi_freecount, ARCH_CONVERT) || 1101 ASSERT(freecount == be32_to_cpu(agi->agi_freecount) ||
1115 XFS_FORCED_SHUTDOWN(mp)); 1102 XFS_FORCED_SHUTDOWN(mp));
1116 } 1103 }
1117#endif 1104#endif
@@ -1320,7 +1307,7 @@ xfs_ialloc_log_agi(
1320 xfs_agi_t *agi; /* allocation group header */ 1307 xfs_agi_t *agi; /* allocation group header */
1321 1308
1322 agi = XFS_BUF_TO_AGI(bp); 1309 agi = XFS_BUF_TO_AGI(bp);
1323 ASSERT(INT_GET(agi->agi_magicnum, ARCH_CONVERT) == XFS_AGI_MAGIC); 1310 ASSERT(be32_to_cpu(agi->agi_magicnum) == XFS_AGI_MAGIC);
1324#endif 1311#endif
1325 /* 1312 /*
1326 * Compute byte offsets for the first and last fields. 1313 * Compute byte offsets for the first and last fields.
@@ -1362,9 +1349,8 @@ xfs_ialloc_read_agi(
1362 */ 1349 */
1363 agi = XFS_BUF_TO_AGI(bp); 1350 agi = XFS_BUF_TO_AGI(bp);
1364 agi_ok = 1351 agi_ok =
1365 INT_GET(agi->agi_magicnum, ARCH_CONVERT) == XFS_AGI_MAGIC && 1352 be32_to_cpu(agi->agi_magicnum) == XFS_AGI_MAGIC &&
1366 XFS_AGI_GOOD_VERSION( 1353 XFS_AGI_GOOD_VERSION(be32_to_cpu(agi->agi_versionnum));
1367 INT_GET(agi->agi_versionnum, ARCH_CONVERT));
1368 if (unlikely(XFS_TEST_ERROR(!agi_ok, mp, XFS_ERRTAG_IALLOC_READ_AGI, 1354 if (unlikely(XFS_TEST_ERROR(!agi_ok, mp, XFS_ERRTAG_IALLOC_READ_AGI,
1369 XFS_RANDOM_IALLOC_READ_AGI))) { 1355 XFS_RANDOM_IALLOC_READ_AGI))) {
1370 XFS_CORRUPTION_ERROR("xfs_ialloc_read_agi", XFS_ERRLEVEL_LOW, 1356 XFS_CORRUPTION_ERROR("xfs_ialloc_read_agi", XFS_ERRLEVEL_LOW,
@@ -1374,16 +1360,15 @@ xfs_ialloc_read_agi(
1374 } 1360 }
1375 pag = &mp->m_perag[agno]; 1361 pag = &mp->m_perag[agno];
1376 if (!pag->pagi_init) { 1362 if (!pag->pagi_init) {
1377 pag->pagi_freecount = INT_GET(agi->agi_freecount, ARCH_CONVERT); 1363 pag->pagi_freecount = be32_to_cpu(agi->agi_freecount);
1378 pag->pagi_init = 1; 1364 pag->pagi_init = 1;
1379 } else { 1365 } else {
1380 /* 1366 /*
1381 * It's possible for these to be out of sync if 1367 * It's possible for these to be out of sync if
1382 * we are in the middle of a forced shutdown. 1368 * we are in the middle of a forced shutdown.
1383 */ 1369 */
1384 ASSERT(pag->pagi_freecount == 1370 ASSERT(pag->pagi_freecount == be32_to_cpu(agi->agi_freecount) ||
1385 INT_GET(agi->agi_freecount, ARCH_CONVERT) 1371 XFS_FORCED_SHUTDOWN(mp));
1386 || XFS_FORCED_SHUTDOWN(mp));
1387 } 1372 }
1388 1373
1389#ifdef DEBUG 1374#ifdef DEBUG
diff --git a/fs/xfs/xfs_ialloc.h b/fs/xfs/xfs_ialloc.h
index db6d0015cecf..7f5debe1acb6 100644
--- a/fs/xfs/xfs_ialloc.h
+++ b/fs/xfs/xfs_ialloc.h
@@ -1,33 +1,19 @@
1/* 1/*
2 * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32#ifndef __XFS_IALLOC_H__ 18#ifndef __XFS_IALLOC_H__
33#define __XFS_IALLOC_H__ 19#define __XFS_IALLOC_H__
@@ -40,18 +26,8 @@ struct xfs_trans;
40/* 26/*
41 * Allocation parameters for inode allocation. 27 * Allocation parameters for inode allocation.
42 */ 28 */
43#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_IALLOC_INODES) 29#define XFS_IALLOC_INODES(mp) (mp)->m_ialloc_inos
44int xfs_ialloc_inodes(struct xfs_mount *mp); 30#define XFS_IALLOC_BLOCKS(mp) (mp)->m_ialloc_blks
45#define XFS_IALLOC_INODES(mp) xfs_ialloc_inodes(mp)
46#else
47#define XFS_IALLOC_INODES(mp) ((mp)->m_ialloc_inos)
48#endif
49#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_IALLOC_BLOCKS)
50xfs_extlen_t xfs_ialloc_blocks(struct xfs_mount *mp);
51#define XFS_IALLOC_BLOCKS(mp) xfs_ialloc_blocks(mp)
52#else
53#define XFS_IALLOC_BLOCKS(mp) ((mp)->m_ialloc_blks)
54#endif
55 31
56/* 32/*
57 * For small block file systems, move inodes in clusters of this size. 33 * For small block file systems, move inodes in clusters of this size.
@@ -67,31 +43,25 @@ xfs_extlen_t xfs_ialloc_blocks(struct xfs_mount *mp);
67/* 43/*
68 * Make an inode pointer out of the buffer/offset. 44 * Make an inode pointer out of the buffer/offset.
69 */ 45 */
70#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_MAKE_IPTR)
71struct xfs_dinode *xfs_make_iptr(struct xfs_mount *mp, struct xfs_buf *b, int o);
72#define XFS_MAKE_IPTR(mp,b,o) xfs_make_iptr(mp,b,o) 46#define XFS_MAKE_IPTR(mp,b,o) xfs_make_iptr(mp,b,o)
73#else 47static inline struct xfs_dinode *
74#define XFS_MAKE_IPTR(mp,b,o) \ 48xfs_make_iptr(struct xfs_mount *mp, struct xfs_buf *b, int o)
75 ((xfs_dinode_t *)(xfs_buf_offset(b, (o) << (mp)->m_sb.sb_inodelog))) 49{
76#endif 50 return (xfs_dinode_t *)
51 (xfs_buf_offset(b, o << (mp)->m_sb.sb_inodelog));
52}
77 53
78/* 54/*
79 * Find a free (set) bit in the inode bitmask. 55 * Find a free (set) bit in the inode bitmask.
80 */ 56 */
81#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_IALLOC_FIND_FREE)
82int xfs_ialloc_find_free(xfs_inofree_t *fp);
83#define XFS_IALLOC_FIND_FREE(fp) xfs_ialloc_find_free(fp) 57#define XFS_IALLOC_FIND_FREE(fp) xfs_ialloc_find_free(fp)
84#else 58static inline int xfs_ialloc_find_free(xfs_inofree_t *fp)
85#define XFS_IALLOC_FIND_FREE(fp) xfs_lowbit64(*(fp)) 59{
86#endif 60 return xfs_lowbit64(*fp);
61}
87 62
88 63
89#ifdef __KERNEL__ 64#ifdef __KERNEL__
90
91/*
92 * Prototypes for visible xfs_ialloc.c routines.
93 */
94
95/* 65/*
96 * Allocate an inode on disk. 66 * Allocate an inode on disk.
97 * Mode is used to tell whether the new inode will need space, and whether 67 * Mode is used to tell whether the new inode will need space, and whether
diff --git a/fs/xfs/xfs_ialloc_btree.c b/fs/xfs/xfs_ialloc_btree.c
index 2d4daecec990..60c65683462d 100644
--- a/fs/xfs/xfs_ialloc_btree.c
+++ b/fs/xfs/xfs_ialloc_btree.c
@@ -1,63 +1,46 @@
1/* 1/*
2 * Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2001,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32
33#include "xfs.h" 18#include "xfs.h"
34 19#include "xfs_fs.h"
35#include "xfs_macros.h"
36#include "xfs_types.h" 20#include "xfs_types.h"
37#include "xfs_inum.h" 21#include "xfs_bit.h"
38#include "xfs_log.h" 22#include "xfs_log.h"
23#include "xfs_inum.h"
39#include "xfs_trans.h" 24#include "xfs_trans.h"
40#include "xfs_sb.h" 25#include "xfs_sb.h"
41#include "xfs_ag.h" 26#include "xfs_ag.h"
42#include "xfs_dir.h" 27#include "xfs_dir.h"
28#include "xfs_dir2.h"
43#include "xfs_dmapi.h" 29#include "xfs_dmapi.h"
44#include "xfs_mount.h" 30#include "xfs_mount.h"
45#include "xfs_alloc_btree.h"
46#include "xfs_bmap_btree.h" 31#include "xfs_bmap_btree.h"
32#include "xfs_alloc_btree.h"
47#include "xfs_ialloc_btree.h" 33#include "xfs_ialloc_btree.h"
34#include "xfs_dir_sf.h"
35#include "xfs_dir2_sf.h"
36#include "xfs_attr_sf.h"
37#include "xfs_dinode.h"
38#include "xfs_inode.h"
48#include "xfs_btree.h" 39#include "xfs_btree.h"
49#include "xfs_ialloc.h" 40#include "xfs_ialloc.h"
50#include "xfs_alloc.h" 41#include "xfs_alloc.h"
51#include "xfs_error.h" 42#include "xfs_error.h"
52 43
53/*
54 * Inode allocation management for XFS.
55 */
56
57/*
58 * Prototypes for internal functions.
59 */
60
61STATIC void xfs_inobt_log_block(xfs_trans_t *, xfs_buf_t *, int); 44STATIC void xfs_inobt_log_block(xfs_trans_t *, xfs_buf_t *, int);
62STATIC void xfs_inobt_log_keys(xfs_btree_cur_t *, xfs_buf_t *, int, int); 45STATIC void xfs_inobt_log_keys(xfs_btree_cur_t *, xfs_buf_t *, int, int);
63STATIC void xfs_inobt_log_ptrs(xfs_btree_cur_t *, xfs_buf_t *, int, int); 46STATIC void xfs_inobt_log_ptrs(xfs_btree_cur_t *, xfs_buf_t *, int, int);
@@ -70,10 +53,6 @@ STATIC int xfs_inobt_split(xfs_btree_cur_t *, int, xfs_agblock_t *,
70STATIC int xfs_inobt_updkey(xfs_btree_cur_t *, xfs_inobt_key_t *, int); 53STATIC int xfs_inobt_updkey(xfs_btree_cur_t *, xfs_inobt_key_t *, int);
71 54
72/* 55/*
73 * Internal functions.
74 */
75
76/*
77 * Single level of the xfs_inobt_delete record deletion routine. 56 * Single level of the xfs_inobt_delete record deletion routine.
78 * Delete record pointed to by cur/level. 57 * Delete record pointed to by cur/level.
79 * Remove the record from its block then rebalance the tree. 58 * Remove the record from its block then rebalance the tree.
@@ -139,7 +118,7 @@ xfs_inobt_delrec(
139 * Fail if we're off the end of the block. 118 * Fail if we're off the end of the block.
140 */ 119 */
141 120
142 numrecs = INT_GET(block->bb_numrecs, ARCH_CONVERT); 121 numrecs = be16_to_cpu(block->bb_numrecs);
143 if (ptr > numrecs) { 122 if (ptr > numrecs) {
144 *stat = 0; 123 *stat = 0;
145 return 0; 124 return 0;
@@ -154,7 +133,7 @@ xfs_inobt_delrec(
154 pp = XFS_INOBT_PTR_ADDR(block, 1, cur); 133 pp = XFS_INOBT_PTR_ADDR(block, 1, cur);
155#ifdef DEBUG 134#ifdef DEBUG
156 for (i = ptr; i < numrecs; i++) { 135 for (i = ptr; i < numrecs; i++) {
157 if ((error = xfs_btree_check_sptr(cur, INT_GET(pp[i], ARCH_CONVERT), level))) 136 if ((error = xfs_btree_check_sptr(cur, be32_to_cpu(pp[i]), level)))
158 return error; 137 return error;
159 } 138 }
160#endif 139#endif
@@ -191,7 +170,7 @@ xfs_inobt_delrec(
191 * Decrement and log the number of entries in the block. 170 * Decrement and log the number of entries in the block.
192 */ 171 */
193 numrecs--; 172 numrecs--;
194 INT_SET(block->bb_numrecs, ARCH_CONVERT, numrecs); 173 block->bb_numrecs = cpu_to_be16(numrecs);
195 xfs_inobt_log_block(cur->bc_tp, bp, XFS_BB_NUMRECS); 174 xfs_inobt_log_block(cur->bc_tp, bp, XFS_BB_NUMRECS);
196 /* 175 /*
197 * Is this the root level? If so, we're almost done. 176 * Is this the root level? If so, we're almost done.
@@ -210,9 +189,9 @@ xfs_inobt_delrec(
210 * pp is still set to the first pointer in the block. 189 * pp is still set to the first pointer in the block.
211 * Make it the new root of the btree. 190 * Make it the new root of the btree.
212 */ 191 */
213 bno = INT_GET(agi->agi_root, ARCH_CONVERT); 192 bno = be32_to_cpu(agi->agi_root);
214 agi->agi_root = *pp; 193 agi->agi_root = *pp;
215 INT_MOD(agi->agi_level, ARCH_CONVERT, -1); 194 be32_add(&agi->agi_level, -1);
216 /* 195 /*
217 * Free the block. 196 * Free the block.
218 */ 197 */
@@ -255,8 +234,8 @@ xfs_inobt_delrec(
255 * tree balanced. Look at the left and right sibling blocks to 234 * tree balanced. Look at the left and right sibling blocks to
256 * see if we can re-balance by moving only one record. 235 * see if we can re-balance by moving only one record.
257 */ 236 */
258 rbno = INT_GET(block->bb_rightsib, ARCH_CONVERT); 237 rbno = be32_to_cpu(block->bb_rightsib);
259 lbno = INT_GET(block->bb_leftsib, ARCH_CONVERT); 238 lbno = be32_to_cpu(block->bb_leftsib);
260 bno = NULLAGBLOCK; 239 bno = NULLAGBLOCK;
261 ASSERT(rbno != NULLAGBLOCK || lbno != NULLAGBLOCK); 240 ASSERT(rbno != NULLAGBLOCK || lbno != NULLAGBLOCK);
262 /* 241 /*
@@ -293,18 +272,18 @@ xfs_inobt_delrec(
293 /* 272 /*
294 * Grab the current block number, for future use. 273 * Grab the current block number, for future use.
295 */ 274 */
296 bno = INT_GET(right->bb_leftsib, ARCH_CONVERT); 275 bno = be32_to_cpu(right->bb_leftsib);
297 /* 276 /*
298 * If right block is full enough so that removing one entry 277 * If right block is full enough so that removing one entry
299 * won't make it too empty, and left-shifting an entry out 278 * won't make it too empty, and left-shifting an entry out
300 * of right to us works, we're done. 279 * of right to us works, we're done.
301 */ 280 */
302 if (INT_GET(right->bb_numrecs, ARCH_CONVERT) - 1 >= 281 if (be16_to_cpu(right->bb_numrecs) - 1 >=
303 XFS_INOBT_BLOCK_MINRECS(level, cur)) { 282 XFS_INOBT_BLOCK_MINRECS(level, cur)) {
304 if ((error = xfs_inobt_lshift(tcur, level, &i))) 283 if ((error = xfs_inobt_lshift(tcur, level, &i)))
305 goto error0; 284 goto error0;
306 if (i) { 285 if (i) {
307 ASSERT(INT_GET(block->bb_numrecs, ARCH_CONVERT) >= 286 ASSERT(be16_to_cpu(block->bb_numrecs) >=
308 XFS_INOBT_BLOCK_MINRECS(level, cur)); 287 XFS_INOBT_BLOCK_MINRECS(level, cur));
309 xfs_btree_del_cursor(tcur, 288 xfs_btree_del_cursor(tcur,
310 XFS_BTREE_NOERROR); 289 XFS_BTREE_NOERROR);
@@ -321,7 +300,7 @@ xfs_inobt_delrec(
321 * future reference, and fix up the temp cursor to point 300 * future reference, and fix up the temp cursor to point
322 * to our block again (last record). 301 * to our block again (last record).
323 */ 302 */
324 rrecs = INT_GET(right->bb_numrecs, ARCH_CONVERT); 303 rrecs = be16_to_cpu(right->bb_numrecs);
325 if (lbno != NULLAGBLOCK) { 304 if (lbno != NULLAGBLOCK) {
326 xfs_btree_firstrec(tcur, level); 305 xfs_btree_firstrec(tcur, level);
327 if ((error = xfs_inobt_decrement(tcur, level, &i))) 306 if ((error = xfs_inobt_decrement(tcur, level, &i)))
@@ -353,18 +332,18 @@ xfs_inobt_delrec(
353 /* 332 /*
354 * Grab the current block number, for future use. 333 * Grab the current block number, for future use.
355 */ 334 */
356 bno = INT_GET(left->bb_rightsib, ARCH_CONVERT); 335 bno = be32_to_cpu(left->bb_rightsib);
357 /* 336 /*
358 * If left block is full enough so that removing one entry 337 * If left block is full enough so that removing one entry
359 * won't make it too empty, and right-shifting an entry out 338 * won't make it too empty, and right-shifting an entry out
360 * of left to us works, we're done. 339 * of left to us works, we're done.
361 */ 340 */
362 if (INT_GET(left->bb_numrecs, ARCH_CONVERT) - 1 >= 341 if (be16_to_cpu(left->bb_numrecs) - 1 >=
363 XFS_INOBT_BLOCK_MINRECS(level, cur)) { 342 XFS_INOBT_BLOCK_MINRECS(level, cur)) {
364 if ((error = xfs_inobt_rshift(tcur, level, &i))) 343 if ((error = xfs_inobt_rshift(tcur, level, &i)))
365 goto error0; 344 goto error0;
366 if (i) { 345 if (i) {
367 ASSERT(INT_GET(block->bb_numrecs, ARCH_CONVERT) >= 346 ASSERT(be16_to_cpu(block->bb_numrecs) >=
368 XFS_INOBT_BLOCK_MINRECS(level, cur)); 347 XFS_INOBT_BLOCK_MINRECS(level, cur));
369 xfs_btree_del_cursor(tcur, 348 xfs_btree_del_cursor(tcur,
370 XFS_BTREE_NOERROR); 349 XFS_BTREE_NOERROR);
@@ -378,7 +357,7 @@ xfs_inobt_delrec(
378 * Otherwise, grab the number of records in right for 357 * Otherwise, grab the number of records in right for
379 * future reference. 358 * future reference.
380 */ 359 */
381 lrecs = INT_GET(left->bb_numrecs, ARCH_CONVERT); 360 lrecs = be16_to_cpu(left->bb_numrecs);
382 } 361 }
383 /* 362 /*
384 * Delete the temp cursor, we're done with it. 363 * Delete the temp cursor, we're done with it.
@@ -399,14 +378,14 @@ xfs_inobt_delrec(
399 */ 378 */
400 rbno = bno; 379 rbno = bno;
401 right = block; 380 right = block;
402 rrecs = INT_GET(right->bb_numrecs, ARCH_CONVERT); 381 rrecs = be16_to_cpu(right->bb_numrecs);
403 rbp = bp; 382 rbp = bp;
404 if ((error = xfs_btree_read_bufs(mp, cur->bc_tp, 383 if ((error = xfs_btree_read_bufs(mp, cur->bc_tp,
405 cur->bc_private.i.agno, lbno, 0, &lbp, 384 cur->bc_private.i.agno, lbno, 0, &lbp,
406 XFS_INO_BTREE_REF))) 385 XFS_INO_BTREE_REF)))
407 return error; 386 return error;
408 left = XFS_BUF_TO_INOBT_BLOCK(lbp); 387 left = XFS_BUF_TO_INOBT_BLOCK(lbp);
409 lrecs = INT_GET(left->bb_numrecs, ARCH_CONVERT); 388 lrecs = be16_to_cpu(left->bb_numrecs);
410 if ((error = xfs_btree_check_sblock(cur, left, level, lbp))) 389 if ((error = xfs_btree_check_sblock(cur, left, level, lbp)))
411 return error; 390 return error;
412 } 391 }
@@ -421,14 +400,14 @@ xfs_inobt_delrec(
421 */ 400 */
422 lbno = bno; 401 lbno = bno;
423 left = block; 402 left = block;
424 lrecs = INT_GET(left->bb_numrecs, ARCH_CONVERT); 403 lrecs = be16_to_cpu(left->bb_numrecs);
425 lbp = bp; 404 lbp = bp;
426 if ((error = xfs_btree_read_bufs(mp, cur->bc_tp, 405 if ((error = xfs_btree_read_bufs(mp, cur->bc_tp,
427 cur->bc_private.i.agno, rbno, 0, &rbp, 406 cur->bc_private.i.agno, rbno, 0, &rbp,
428 XFS_INO_BTREE_REF))) 407 XFS_INO_BTREE_REF)))
429 return error; 408 return error;
430 right = XFS_BUF_TO_INOBT_BLOCK(rbp); 409 right = XFS_BUF_TO_INOBT_BLOCK(rbp);
431 rrecs = INT_GET(right->bb_numrecs, ARCH_CONVERT); 410 rrecs = be16_to_cpu(right->bb_numrecs);
432 if ((error = xfs_btree_check_sblock(cur, right, level, rbp))) 411 if ((error = xfs_btree_check_sblock(cur, right, level, rbp)))
433 return error; 412 return error;
434 } 413 }
@@ -456,7 +435,7 @@ xfs_inobt_delrec(
456 rpp = XFS_INOBT_PTR_ADDR(right, 1, cur); 435 rpp = XFS_INOBT_PTR_ADDR(right, 1, cur);
457#ifdef DEBUG 436#ifdef DEBUG
458 for (i = 0; i < rrecs; i++) { 437 for (i = 0; i < rrecs; i++) {
459 if ((error = xfs_btree_check_sptr(cur, INT_GET(rpp[i], ARCH_CONVERT), level))) 438 if ((error = xfs_btree_check_sptr(cur, be32_to_cpu(rpp[i]), level)))
460 return error; 439 return error;
461 } 440 }
462#endif 441#endif
@@ -492,7 +471,7 @@ xfs_inobt_delrec(
492 * Fix up the number of records in the surviving block. 471 * Fix up the number of records in the surviving block.
493 */ 472 */
494 lrecs += rrecs; 473 lrecs += rrecs;
495 INT_SET(left->bb_numrecs, ARCH_CONVERT, lrecs); 474 left->bb_numrecs = cpu_to_be16(lrecs);
496 /* 475 /*
497 * Fix up the right block pointer in the surviving block, and log it. 476 * Fix up the right block pointer in the surviving block, and log it.
498 */ 477 */
@@ -502,18 +481,18 @@ xfs_inobt_delrec(
502 * If there is a right sibling now, make it point to the 481 * If there is a right sibling now, make it point to the
503 * remaining block. 482 * remaining block.
504 */ 483 */
505 if (INT_GET(left->bb_rightsib, ARCH_CONVERT) != NULLAGBLOCK) { 484 if (be32_to_cpu(left->bb_rightsib) != NULLAGBLOCK) {
506 xfs_inobt_block_t *rrblock; 485 xfs_inobt_block_t *rrblock;
507 xfs_buf_t *rrbp; 486 xfs_buf_t *rrbp;
508 487
509 if ((error = xfs_btree_read_bufs(mp, cur->bc_tp, 488 if ((error = xfs_btree_read_bufs(mp, cur->bc_tp,
510 cur->bc_private.i.agno, INT_GET(left->bb_rightsib, ARCH_CONVERT), 0, 489 cur->bc_private.i.agno, be32_to_cpu(left->bb_rightsib), 0,
511 &rrbp, XFS_INO_BTREE_REF))) 490 &rrbp, XFS_INO_BTREE_REF)))
512 return error; 491 return error;
513 rrblock = XFS_BUF_TO_INOBT_BLOCK(rrbp); 492 rrblock = XFS_BUF_TO_INOBT_BLOCK(rrbp);
514 if ((error = xfs_btree_check_sblock(cur, rrblock, level, rrbp))) 493 if ((error = xfs_btree_check_sblock(cur, rrblock, level, rrbp)))
515 return error; 494 return error;
516 INT_SET(rrblock->bb_leftsib, ARCH_CONVERT, lbno); 495 rrblock->bb_leftsib = cpu_to_be32(lbno);
517 xfs_inobt_log_block(cur->bc_tp, rrbp, XFS_BB_LEFTSIB); 496 xfs_inobt_log_block(cur->bc_tp, rrbp, XFS_BB_LEFTSIB);
518 } 497 }
519 /* 498 /*
@@ -572,6 +551,13 @@ xfs_inobt_insrec(
572 xfs_inobt_rec_t *rp=NULL; /* pointer to btree records */ 551 xfs_inobt_rec_t *rp=NULL; /* pointer to btree records */
573 552
574 /* 553 /*
554 * GCC doesn't understand the (arguably complex) control flow in
555 * this function and complains about uninitialized structure fields
556 * without this.
557 */
558 memset(&nrec, 0, sizeof(nrec));
559
560 /*
575 * If we made it to the root level, allocate a new root block 561 * If we made it to the root level, allocate a new root block
576 * and we're done. 562 * and we're done.
577 */ 563 */
@@ -598,7 +584,7 @@ xfs_inobt_insrec(
598 */ 584 */
599 bp = cur->bc_bufs[level]; 585 bp = cur->bc_bufs[level];
600 block = XFS_BUF_TO_INOBT_BLOCK(bp); 586 block = XFS_BUF_TO_INOBT_BLOCK(bp);
601 numrecs = INT_GET(block->bb_numrecs, ARCH_CONVERT); 587 numrecs = be16_to_cpu(block->bb_numrecs);
602#ifdef DEBUG 588#ifdef DEBUG
603 if ((error = xfs_btree_check_sblock(cur, block, level, bp))) 589 if ((error = xfs_btree_check_sblock(cur, block, level, bp)))
604 return error; 590 return error;
@@ -672,7 +658,7 @@ xfs_inobt_insrec(
672 * At this point we know there's room for our new entry in the block 658 * At this point we know there's room for our new entry in the block
673 * we're pointing at. 659 * we're pointing at.
674 */ 660 */
675 numrecs = INT_GET(block->bb_numrecs, ARCH_CONVERT); 661 numrecs = be16_to_cpu(block->bb_numrecs);
676 if (level > 0) { 662 if (level > 0) {
677 /* 663 /*
678 * It's a non-leaf entry. Make a hole for the new data 664 * It's a non-leaf entry. Make a hole for the new data
@@ -682,7 +668,7 @@ xfs_inobt_insrec(
682 pp = XFS_INOBT_PTR_ADDR(block, 1, cur); 668 pp = XFS_INOBT_PTR_ADDR(block, 1, cur);
683#ifdef DEBUG 669#ifdef DEBUG
684 for (i = numrecs; i >= ptr; i--) { 670 for (i = numrecs; i >= ptr; i--) {
685 if ((error = xfs_btree_check_sptr(cur, INT_GET(pp[i - 1], ARCH_CONVERT), level))) 671 if ((error = xfs_btree_check_sptr(cur, be32_to_cpu(pp[i - 1]), level)))
686 return error; 672 return error;
687 } 673 }
688#endif 674#endif
@@ -698,9 +684,9 @@ xfs_inobt_insrec(
698 return error; 684 return error;
699#endif 685#endif
700 kp[ptr - 1] = key; /* INT_: struct copy */ 686 kp[ptr - 1] = key; /* INT_: struct copy */
701 INT_SET(pp[ptr - 1], ARCH_CONVERT, *bnop); 687 pp[ptr - 1] = cpu_to_be32(*bnop);
702 numrecs++; 688 numrecs++;
703 INT_SET(block->bb_numrecs, ARCH_CONVERT, numrecs); 689 block->bb_numrecs = cpu_to_be16(numrecs);
704 xfs_inobt_log_keys(cur, bp, ptr, numrecs); 690 xfs_inobt_log_keys(cur, bp, ptr, numrecs);
705 xfs_inobt_log_ptrs(cur, bp, ptr, numrecs); 691 xfs_inobt_log_ptrs(cur, bp, ptr, numrecs);
706 } else { 692 } else {
@@ -716,7 +702,7 @@ xfs_inobt_insrec(
716 */ 702 */
717 rp[ptr - 1] = *recp; /* INT_: struct copy */ 703 rp[ptr - 1] = *recp; /* INT_: struct copy */
718 numrecs++; 704 numrecs++;
719 INT_SET(block->bb_numrecs, ARCH_CONVERT, numrecs); 705 block->bb_numrecs = cpu_to_be16(numrecs);
720 xfs_inobt_log_recs(cur, bp, ptr, numrecs); 706 xfs_inobt_log_recs(cur, bp, ptr, numrecs);
721 } 707 }
722 /* 708 /*
@@ -871,8 +857,8 @@ xfs_inobt_lookup(
871 xfs_agi_t *agi; /* a.g. inode header */ 857 xfs_agi_t *agi; /* a.g. inode header */
872 858
873 agi = XFS_BUF_TO_AGI(cur->bc_private.i.agbp); 859 agi = XFS_BUF_TO_AGI(cur->bc_private.i.agbp);
874 agno = INT_GET(agi->agi_seqno, ARCH_CONVERT); 860 agno = be32_to_cpu(agi->agi_seqno);
875 agbno = INT_GET(agi->agi_root, ARCH_CONVERT); 861 agbno = be32_to_cpu(agi->agi_root);
876 } 862 }
877 /* 863 /*
878 * Iterate over each level in the btree, starting at the root. 864 * Iterate over each level in the btree, starting at the root.
@@ -939,7 +925,7 @@ xfs_inobt_lookup(
939 * Set low and high entry numbers, 1-based. 925 * Set low and high entry numbers, 1-based.
940 */ 926 */
941 low = 1; 927 low = 1;
942 if (!(high = INT_GET(block->bb_numrecs, ARCH_CONVERT))) { 928 if (!(high = be16_to_cpu(block->bb_numrecs))) {
943 /* 929 /*
944 * If the block is empty, the tree must 930 * If the block is empty, the tree must
945 * be an empty leaf. 931 * be an empty leaf.
@@ -1006,7 +992,7 @@ xfs_inobt_lookup(
1006 */ 992 */
1007 if (diff > 0 && --keyno < 1) 993 if (diff > 0 && --keyno < 1)
1008 keyno = 1; 994 keyno = 1;
1009 agbno = INT_GET(*XFS_INOBT_PTR_ADDR(block, keyno, cur), ARCH_CONVERT); 995 agbno = be32_to_cpu(*XFS_INOBT_PTR_ADDR(block, keyno, cur));
1010#ifdef DEBUG 996#ifdef DEBUG
1011 if ((error = xfs_btree_check_sptr(cur, agbno, level))) 997 if ((error = xfs_btree_check_sptr(cur, agbno, level)))
1012 return error; 998 return error;
@@ -1025,8 +1011,8 @@ xfs_inobt_lookup(
1025 * not the last block, we're in the wrong block. 1011 * not the last block, we're in the wrong block.
1026 */ 1012 */
1027 if (dir == XFS_LOOKUP_GE && 1013 if (dir == XFS_LOOKUP_GE &&
1028 keyno > INT_GET(block->bb_numrecs, ARCH_CONVERT) && 1014 keyno > be16_to_cpu(block->bb_numrecs) &&
1029 INT_GET(block->bb_rightsib, ARCH_CONVERT) != NULLAGBLOCK) { 1015 be32_to_cpu(block->bb_rightsib) != NULLAGBLOCK) {
1030 int i; 1016 int i;
1031 1017
1032 cur->bc_ptrs[0] = keyno; 1018 cur->bc_ptrs[0] = keyno;
@@ -1043,7 +1029,7 @@ xfs_inobt_lookup(
1043 /* 1029 /*
1044 * Return if we succeeded or not. 1030 * Return if we succeeded or not.
1045 */ 1031 */
1046 if (keyno == 0 || keyno > INT_GET(block->bb_numrecs, ARCH_CONVERT)) 1032 if (keyno == 0 || keyno > be16_to_cpu(block->bb_numrecs))
1047 *stat = 0; 1033 *stat = 0;
1048 else 1034 else
1049 *stat = ((dir != XFS_LOOKUP_EQ) || (diff == 0)); 1035 *stat = ((dir != XFS_LOOKUP_EQ) || (diff == 0));
@@ -1089,7 +1075,7 @@ xfs_inobt_lshift(
1089 /* 1075 /*
1090 * If we've got no left sibling then we can't shift an entry left. 1076 * If we've got no left sibling then we can't shift an entry left.
1091 */ 1077 */
1092 if (INT_GET(right->bb_leftsib, ARCH_CONVERT) == NULLAGBLOCK) { 1078 if (be32_to_cpu(right->bb_leftsib) == NULLAGBLOCK) {
1093 *stat = 0; 1079 *stat = 0;
1094 return 0; 1080 return 0;
1095 } 1081 }
@@ -1105,8 +1091,8 @@ xfs_inobt_lshift(
1105 * Set up the left neighbor as "left". 1091 * Set up the left neighbor as "left".
1106 */ 1092 */
1107 if ((error = xfs_btree_read_bufs(cur->bc_mp, cur->bc_tp, 1093 if ((error = xfs_btree_read_bufs(cur->bc_mp, cur->bc_tp,
1108 cur->bc_private.i.agno, INT_GET(right->bb_leftsib, ARCH_CONVERT), 0, &lbp, 1094 cur->bc_private.i.agno, be32_to_cpu(right->bb_leftsib),
1109 XFS_INO_BTREE_REF))) 1095 0, &lbp, XFS_INO_BTREE_REF)))
1110 return error; 1096 return error;
1111 left = XFS_BUF_TO_INOBT_BLOCK(lbp); 1097 left = XFS_BUF_TO_INOBT_BLOCK(lbp);
1112 if ((error = xfs_btree_check_sblock(cur, left, level, lbp))) 1098 if ((error = xfs_btree_check_sblock(cur, left, level, lbp)))
@@ -1114,11 +1100,11 @@ xfs_inobt_lshift(
1114 /* 1100 /*
1115 * If it's full, it can't take another entry. 1101 * If it's full, it can't take another entry.
1116 */ 1102 */
1117 if (INT_GET(left->bb_numrecs, ARCH_CONVERT) == XFS_INOBT_BLOCK_MAXRECS(level, cur)) { 1103 if (be16_to_cpu(left->bb_numrecs) == XFS_INOBT_BLOCK_MAXRECS(level, cur)) {
1118 *stat = 0; 1104 *stat = 0;
1119 return 0; 1105 return 0;
1120 } 1106 }
1121 nrec = INT_GET(left->bb_numrecs, ARCH_CONVERT) + 1; 1107 nrec = be16_to_cpu(left->bb_numrecs) + 1;
1122 /* 1108 /*
1123 * If non-leaf, copy a key and a ptr to the left block. 1109 * If non-leaf, copy a key and a ptr to the left block.
1124 */ 1110 */
@@ -1130,7 +1116,7 @@ xfs_inobt_lshift(
1130 lpp = XFS_INOBT_PTR_ADDR(left, nrec, cur); 1116 lpp = XFS_INOBT_PTR_ADDR(left, nrec, cur);
1131 rpp = XFS_INOBT_PTR_ADDR(right, 1, cur); 1117 rpp = XFS_INOBT_PTR_ADDR(right, 1, cur);
1132#ifdef DEBUG 1118#ifdef DEBUG
1133 if ((error = xfs_btree_check_sptr(cur, INT_GET(*rpp, ARCH_CONVERT), level))) 1119 if ((error = xfs_btree_check_sptr(cur, be32_to_cpu(*rpp), level)))
1134 return error; 1120 return error;
1135#endif 1121#endif
1136 *lpp = *rpp; /* INT_: no-change copy */ 1122 *lpp = *rpp; /* INT_: no-change copy */
@@ -1148,7 +1134,7 @@ xfs_inobt_lshift(
1148 /* 1134 /*
1149 * Bump and log left's numrecs, decrement and log right's numrecs. 1135 * Bump and log left's numrecs, decrement and log right's numrecs.
1150 */ 1136 */
1151 INT_MOD(left->bb_numrecs, ARCH_CONVERT, +1); 1137 be16_add(&left->bb_numrecs, 1);
1152 xfs_inobt_log_block(cur->bc_tp, lbp, XFS_BB_NUMRECS); 1138 xfs_inobt_log_block(cur->bc_tp, lbp, XFS_BB_NUMRECS);
1153#ifdef DEBUG 1139#ifdef DEBUG
1154 if (level > 0) 1140 if (level > 0)
@@ -1156,26 +1142,26 @@ xfs_inobt_lshift(
1156 else 1142 else
1157 xfs_btree_check_rec(cur->bc_btnum, lrp - 1, lrp); 1143 xfs_btree_check_rec(cur->bc_btnum, lrp - 1, lrp);
1158#endif 1144#endif
1159 INT_MOD(right->bb_numrecs, ARCH_CONVERT, -1); 1145 be16_add(&right->bb_numrecs, -1);
1160 xfs_inobt_log_block(cur->bc_tp, rbp, XFS_BB_NUMRECS); 1146 xfs_inobt_log_block(cur->bc_tp, rbp, XFS_BB_NUMRECS);
1161 /* 1147 /*
1162 * Slide the contents of right down one entry. 1148 * Slide the contents of right down one entry.
1163 */ 1149 */
1164 if (level > 0) { 1150 if (level > 0) {
1165#ifdef DEBUG 1151#ifdef DEBUG
1166 for (i = 0; i < INT_GET(right->bb_numrecs, ARCH_CONVERT); i++) { 1152 for (i = 0; i < be16_to_cpu(right->bb_numrecs); i++) {
1167 if ((error = xfs_btree_check_sptr(cur, INT_GET(rpp[i + 1], ARCH_CONVERT), 1153 if ((error = xfs_btree_check_sptr(cur, be32_to_cpu(rpp[i + 1]),
1168 level))) 1154 level)))
1169 return error; 1155 return error;
1170 } 1156 }
1171#endif 1157#endif
1172 memmove(rkp, rkp + 1, INT_GET(right->bb_numrecs, ARCH_CONVERT) * sizeof(*rkp)); 1158 memmove(rkp, rkp + 1, be16_to_cpu(right->bb_numrecs) * sizeof(*rkp));
1173 memmove(rpp, rpp + 1, INT_GET(right->bb_numrecs, ARCH_CONVERT) * sizeof(*rpp)); 1159 memmove(rpp, rpp + 1, be16_to_cpu(right->bb_numrecs) * sizeof(*rpp));
1174 xfs_inobt_log_keys(cur, rbp, 1, INT_GET(right->bb_numrecs, ARCH_CONVERT)); 1160 xfs_inobt_log_keys(cur, rbp, 1, be16_to_cpu(right->bb_numrecs));
1175 xfs_inobt_log_ptrs(cur, rbp, 1, INT_GET(right->bb_numrecs, ARCH_CONVERT)); 1161 xfs_inobt_log_ptrs(cur, rbp, 1, be16_to_cpu(right->bb_numrecs));
1176 } else { 1162 } else {
1177 memmove(rrp, rrp + 1, INT_GET(right->bb_numrecs, ARCH_CONVERT) * sizeof(*rrp)); 1163 memmove(rrp, rrp + 1, be16_to_cpu(right->bb_numrecs) * sizeof(*rrp));
1178 xfs_inobt_log_recs(cur, rbp, 1, INT_GET(right->bb_numrecs, ARCH_CONVERT)); 1164 xfs_inobt_log_recs(cur, rbp, 1, be16_to_cpu(right->bb_numrecs));
1179 key.ir_startino = rrp->ir_startino; /* INT_: direct copy */ 1165 key.ir_startino = rrp->ir_startino; /* INT_: direct copy */
1180 rkp = &key; 1166 rkp = &key;
1181 } 1167 }
@@ -1227,7 +1213,7 @@ xfs_inobt_newroot(
1227 args.tp = cur->bc_tp; 1213 args.tp = cur->bc_tp;
1228 args.mp = cur->bc_mp; 1214 args.mp = cur->bc_mp;
1229 args.fsbno = XFS_AGB_TO_FSB(args.mp, cur->bc_private.i.agno, 1215 args.fsbno = XFS_AGB_TO_FSB(args.mp, cur->bc_private.i.agno,
1230 INT_GET(agi->agi_root, ARCH_CONVERT)); 1216 be32_to_cpu(agi->agi_root));
1231 args.mod = args.minleft = args.alignment = args.total = args.wasdel = 1217 args.mod = args.minleft = args.alignment = args.total = args.wasdel =
1232 args.isfl = args.userdata = args.minalignslop = 0; 1218 args.isfl = args.userdata = args.minalignslop = 0;
1233 args.minlen = args.maxlen = args.prod = 1; 1219 args.minlen = args.maxlen = args.prod = 1;
@@ -1247,8 +1233,8 @@ xfs_inobt_newroot(
1247 /* 1233 /*
1248 * Set the root data in the a.g. inode structure. 1234 * Set the root data in the a.g. inode structure.
1249 */ 1235 */
1250 INT_SET(agi->agi_root, ARCH_CONVERT, args.agbno); 1236 agi->agi_root = cpu_to_be32(args.agbno);
1251 INT_MOD(agi->agi_level, ARCH_CONVERT, 1); 1237 be32_add(&agi->agi_level, 1);
1252 xfs_ialloc_log_agi(args.tp, cur->bc_private.i.agbp, 1238 xfs_ialloc_log_agi(args.tp, cur->bc_private.i.agbp,
1253 XFS_AGI_ROOT | XFS_AGI_LEVEL); 1239 XFS_AGI_ROOT | XFS_AGI_LEVEL);
1254 /* 1240 /*
@@ -1263,14 +1249,14 @@ xfs_inobt_newroot(
1263 if ((error = xfs_btree_check_sblock(cur, block, cur->bc_nlevels - 1, bp))) 1249 if ((error = xfs_btree_check_sblock(cur, block, cur->bc_nlevels - 1, bp)))
1264 return error; 1250 return error;
1265#endif 1251#endif
1266 if (INT_GET(block->bb_rightsib, ARCH_CONVERT) != NULLAGBLOCK) { 1252 if (be32_to_cpu(block->bb_rightsib) != NULLAGBLOCK) {
1267 /* 1253 /*
1268 * Our block is left, pick up the right block. 1254 * Our block is left, pick up the right block.
1269 */ 1255 */
1270 lbp = bp; 1256 lbp = bp;
1271 lbno = XFS_DADDR_TO_AGBNO(args.mp, XFS_BUF_ADDR(lbp)); 1257 lbno = XFS_DADDR_TO_AGBNO(args.mp, XFS_BUF_ADDR(lbp));
1272 left = block; 1258 left = block;
1273 rbno = INT_GET(left->bb_rightsib, ARCH_CONVERT); 1259 rbno = be32_to_cpu(left->bb_rightsib);
1274 if ((error = xfs_btree_read_bufs(args.mp, args.tp, args.agno, 1260 if ((error = xfs_btree_read_bufs(args.mp, args.tp, args.agno,
1275 rbno, 0, &rbp, XFS_INO_BTREE_REF))) 1261 rbno, 0, &rbp, XFS_INO_BTREE_REF)))
1276 return error; 1262 return error;
@@ -1287,7 +1273,7 @@ xfs_inobt_newroot(
1287 rbp = bp; 1273 rbp = bp;
1288 rbno = XFS_DADDR_TO_AGBNO(args.mp, XFS_BUF_ADDR(rbp)); 1274 rbno = XFS_DADDR_TO_AGBNO(args.mp, XFS_BUF_ADDR(rbp));
1289 right = block; 1275 right = block;
1290 lbno = INT_GET(right->bb_leftsib, ARCH_CONVERT); 1276 lbno = be32_to_cpu(right->bb_leftsib);
1291 if ((error = xfs_btree_read_bufs(args.mp, args.tp, args.agno, 1277 if ((error = xfs_btree_read_bufs(args.mp, args.tp, args.agno,
1292 lbno, 0, &lbp, XFS_INO_BTREE_REF))) 1278 lbno, 0, &lbp, XFS_INO_BTREE_REF)))
1293 return error; 1279 return error;
@@ -1301,18 +1287,18 @@ xfs_inobt_newroot(
1301 /* 1287 /*
1302 * Fill in the new block's btree header and log it. 1288 * Fill in the new block's btree header and log it.
1303 */ 1289 */
1304 INT_SET(new->bb_magic, ARCH_CONVERT, xfs_magics[cur->bc_btnum]); 1290 new->bb_magic = cpu_to_be32(xfs_magics[cur->bc_btnum]);
1305 INT_SET(new->bb_level, ARCH_CONVERT, (__uint16_t)cur->bc_nlevels); 1291 new->bb_level = cpu_to_be16(cur->bc_nlevels);
1306 INT_SET(new->bb_numrecs, ARCH_CONVERT, 2); 1292 new->bb_numrecs = cpu_to_be16(2);
1307 INT_SET(new->bb_leftsib, ARCH_CONVERT, NULLAGBLOCK); 1293 new->bb_leftsib = cpu_to_be32(NULLAGBLOCK);
1308 INT_SET(new->bb_rightsib, ARCH_CONVERT, NULLAGBLOCK); 1294 new->bb_rightsib = cpu_to_be32(NULLAGBLOCK);
1309 xfs_inobt_log_block(args.tp, nbp, XFS_BB_ALL_BITS); 1295 xfs_inobt_log_block(args.tp, nbp, XFS_BB_ALL_BITS);
1310 ASSERT(lbno != NULLAGBLOCK && rbno != NULLAGBLOCK); 1296 ASSERT(lbno != NULLAGBLOCK && rbno != NULLAGBLOCK);
1311 /* 1297 /*
1312 * Fill in the key data in the new root. 1298 * Fill in the key data in the new root.
1313 */ 1299 */
1314 kp = XFS_INOBT_KEY_ADDR(new, 1, cur); 1300 kp = XFS_INOBT_KEY_ADDR(new, 1, cur);
1315 if (INT_GET(left->bb_level, ARCH_CONVERT) > 0) { 1301 if (be16_to_cpu(left->bb_level) > 0) {
1316 kp[0] = *XFS_INOBT_KEY_ADDR(left, 1, cur); /* INT_: struct copy */ 1302 kp[0] = *XFS_INOBT_KEY_ADDR(left, 1, cur); /* INT_: struct copy */
1317 kp[1] = *XFS_INOBT_KEY_ADDR(right, 1, cur); /* INT_: struct copy */ 1303 kp[1] = *XFS_INOBT_KEY_ADDR(right, 1, cur); /* INT_: struct copy */
1318 } else { 1304 } else {
@@ -1326,8 +1312,8 @@ xfs_inobt_newroot(
1326 * Fill in the pointer data in the new root. 1312 * Fill in the pointer data in the new root.
1327 */ 1313 */
1328 pp = XFS_INOBT_PTR_ADDR(new, 1, cur); 1314 pp = XFS_INOBT_PTR_ADDR(new, 1, cur);
1329 INT_SET(pp[0], ARCH_CONVERT, lbno); 1315 pp[0] = cpu_to_be32(lbno);
1330 INT_SET(pp[1], ARCH_CONVERT, rbno); 1316 pp[1] = cpu_to_be32(rbno);
1331 xfs_inobt_log_ptrs(cur, nbp, 1, 2); 1317 xfs_inobt_log_ptrs(cur, nbp, 1, 2);
1332 /* 1318 /*
1333 * Fix up the cursor. 1319 * Fix up the cursor.
@@ -1376,7 +1362,7 @@ xfs_inobt_rshift(
1376 /* 1362 /*
1377 * If we've got no right sibling then we can't shift an entry right. 1363 * If we've got no right sibling then we can't shift an entry right.
1378 */ 1364 */
1379 if (INT_GET(left->bb_rightsib, ARCH_CONVERT) == NULLAGBLOCK) { 1365 if (be32_to_cpu(left->bb_rightsib) == NULLAGBLOCK) {
1380 *stat = 0; 1366 *stat = 0;
1381 return 0; 1367 return 0;
1382 } 1368 }
@@ -1384,7 +1370,7 @@ xfs_inobt_rshift(
1384 * If the cursor entry is the one that would be moved, don't 1370 * If the cursor entry is the one that would be moved, don't
1385 * do it... it's too complicated. 1371 * do it... it's too complicated.
1386 */ 1372 */
1387 if (cur->bc_ptrs[level] >= INT_GET(left->bb_numrecs, ARCH_CONVERT)) { 1373 if (cur->bc_ptrs[level] >= be16_to_cpu(left->bb_numrecs)) {
1388 *stat = 0; 1374 *stat = 0;
1389 return 0; 1375 return 0;
1390 } 1376 }
@@ -1392,8 +1378,8 @@ xfs_inobt_rshift(
1392 * Set up the right neighbor as "right". 1378 * Set up the right neighbor as "right".
1393 */ 1379 */
1394 if ((error = xfs_btree_read_bufs(cur->bc_mp, cur->bc_tp, 1380 if ((error = xfs_btree_read_bufs(cur->bc_mp, cur->bc_tp,
1395 cur->bc_private.i.agno, INT_GET(left->bb_rightsib, ARCH_CONVERT), 0, &rbp, 1381 cur->bc_private.i.agno, be32_to_cpu(left->bb_rightsib),
1396 XFS_INO_BTREE_REF))) 1382 0, &rbp, XFS_INO_BTREE_REF)))
1397 return error; 1383 return error;
1398 right = XFS_BUF_TO_INOBT_BLOCK(rbp); 1384 right = XFS_BUF_TO_INOBT_BLOCK(rbp);
1399 if ((error = xfs_btree_check_sblock(cur, right, level, rbp))) 1385 if ((error = xfs_btree_check_sblock(cur, right, level, rbp)))
@@ -1401,7 +1387,7 @@ xfs_inobt_rshift(
1401 /* 1387 /*
1402 * If it's full, it can't take another entry. 1388 * If it's full, it can't take another entry.
1403 */ 1389 */
1404 if (INT_GET(right->bb_numrecs, ARCH_CONVERT) == XFS_INOBT_BLOCK_MAXRECS(level, cur)) { 1390 if (be16_to_cpu(right->bb_numrecs) == XFS_INOBT_BLOCK_MAXRECS(level, cur)) {
1405 *stat = 0; 1391 *stat = 0;
1406 return 0; 1392 return 0;
1407 } 1393 }
@@ -1410,41 +1396,41 @@ xfs_inobt_rshift(
1410 * copy the last left block entry to the hole. 1396 * copy the last left block entry to the hole.
1411 */ 1397 */
1412 if (level > 0) { 1398 if (level > 0) {
1413 lkp = XFS_INOBT_KEY_ADDR(left, INT_GET(left->bb_numrecs, ARCH_CONVERT), cur); 1399 lkp = XFS_INOBT_KEY_ADDR(left, be16_to_cpu(left->bb_numrecs), cur);
1414 lpp = XFS_INOBT_PTR_ADDR(left, INT_GET(left->bb_numrecs, ARCH_CONVERT), cur); 1400 lpp = XFS_INOBT_PTR_ADDR(left, be16_to_cpu(left->bb_numrecs), cur);
1415 rkp = XFS_INOBT_KEY_ADDR(right, 1, cur); 1401 rkp = XFS_INOBT_KEY_ADDR(right, 1, cur);
1416 rpp = XFS_INOBT_PTR_ADDR(right, 1, cur); 1402 rpp = XFS_INOBT_PTR_ADDR(right, 1, cur);
1417#ifdef DEBUG 1403#ifdef DEBUG
1418 for (i = INT_GET(right->bb_numrecs, ARCH_CONVERT) - 1; i >= 0; i--) { 1404 for (i = be16_to_cpu(right->bb_numrecs) - 1; i >= 0; i--) {
1419 if ((error = xfs_btree_check_sptr(cur, INT_GET(rpp[i], ARCH_CONVERT), level))) 1405 if ((error = xfs_btree_check_sptr(cur, be32_to_cpu(rpp[i]), level)))
1420 return error; 1406 return error;
1421 } 1407 }
1422#endif 1408#endif
1423 memmove(rkp + 1, rkp, INT_GET(right->bb_numrecs, ARCH_CONVERT) * sizeof(*rkp)); 1409 memmove(rkp + 1, rkp, be16_to_cpu(right->bb_numrecs) * sizeof(*rkp));
1424 memmove(rpp + 1, rpp, INT_GET(right->bb_numrecs, ARCH_CONVERT) * sizeof(*rpp)); 1410 memmove(rpp + 1, rpp, be16_to_cpu(right->bb_numrecs) * sizeof(*rpp));
1425#ifdef DEBUG 1411#ifdef DEBUG
1426 if ((error = xfs_btree_check_sptr(cur, INT_GET(*lpp, ARCH_CONVERT), level))) 1412 if ((error = xfs_btree_check_sptr(cur, be32_to_cpu(*lpp), level)))
1427 return error; 1413 return error;
1428#endif 1414#endif
1429 *rkp = *lkp; /* INT_: no change copy */ 1415 *rkp = *lkp; /* INT_: no change copy */
1430 *rpp = *lpp; /* INT_: no change copy */ 1416 *rpp = *lpp; /* INT_: no change copy */
1431 xfs_inobt_log_keys(cur, rbp, 1, INT_GET(right->bb_numrecs, ARCH_CONVERT) + 1); 1417 xfs_inobt_log_keys(cur, rbp, 1, be16_to_cpu(right->bb_numrecs) + 1);
1432 xfs_inobt_log_ptrs(cur, rbp, 1, INT_GET(right->bb_numrecs, ARCH_CONVERT) + 1); 1418 xfs_inobt_log_ptrs(cur, rbp, 1, be16_to_cpu(right->bb_numrecs) + 1);
1433 } else { 1419 } else {
1434 lrp = XFS_INOBT_REC_ADDR(left, INT_GET(left->bb_numrecs, ARCH_CONVERT), cur); 1420 lrp = XFS_INOBT_REC_ADDR(left, be16_to_cpu(left->bb_numrecs), cur);
1435 rrp = XFS_INOBT_REC_ADDR(right, 1, cur); 1421 rrp = XFS_INOBT_REC_ADDR(right, 1, cur);
1436 memmove(rrp + 1, rrp, INT_GET(right->bb_numrecs, ARCH_CONVERT) * sizeof(*rrp)); 1422 memmove(rrp + 1, rrp, be16_to_cpu(right->bb_numrecs) * sizeof(*rrp));
1437 *rrp = *lrp; 1423 *rrp = *lrp;
1438 xfs_inobt_log_recs(cur, rbp, 1, INT_GET(right->bb_numrecs, ARCH_CONVERT) + 1); 1424 xfs_inobt_log_recs(cur, rbp, 1, be16_to_cpu(right->bb_numrecs) + 1);
1439 key.ir_startino = rrp->ir_startino; /* INT_: direct copy */ 1425 key.ir_startino = rrp->ir_startino; /* INT_: direct copy */
1440 rkp = &key; 1426 rkp = &key;
1441 } 1427 }
1442 /* 1428 /*
1443 * Decrement and log left's numrecs, bump and log right's numrecs. 1429 * Decrement and log left's numrecs, bump and log right's numrecs.
1444 */ 1430 */
1445 INT_MOD(left->bb_numrecs, ARCH_CONVERT, -1); 1431 be16_add(&left->bb_numrecs, -1);
1446 xfs_inobt_log_block(cur->bc_tp, lbp, XFS_BB_NUMRECS); 1432 xfs_inobt_log_block(cur->bc_tp, lbp, XFS_BB_NUMRECS);
1447 INT_MOD(right->bb_numrecs, ARCH_CONVERT, +1); 1433 be16_add(&right->bb_numrecs, 1);
1448#ifdef DEBUG 1434#ifdef DEBUG
1449 if (level > 0) 1435 if (level > 0)
1450 xfs_btree_check_key(cur->bc_btnum, rkp, rkp + 1); 1436 xfs_btree_check_key(cur->bc_btnum, rkp, rkp + 1);
@@ -1536,17 +1522,17 @@ xfs_inobt_split(
1536 /* 1522 /*
1537 * Fill in the btree header for the new block. 1523 * Fill in the btree header for the new block.
1538 */ 1524 */
1539 INT_SET(right->bb_magic, ARCH_CONVERT, xfs_magics[cur->bc_btnum]); 1525 right->bb_magic = cpu_to_be32(xfs_magics[cur->bc_btnum]);
1540 right->bb_level = left->bb_level; /* INT_: direct copy */ 1526 right->bb_level = left->bb_level;
1541 INT_SET(right->bb_numrecs, ARCH_CONVERT, (__uint16_t)(INT_GET(left->bb_numrecs, ARCH_CONVERT) / 2)); 1527 right->bb_numrecs = cpu_to_be16(be16_to_cpu(left->bb_numrecs) / 2);
1542 /* 1528 /*
1543 * Make sure that if there's an odd number of entries now, that 1529 * Make sure that if there's an odd number of entries now, that
1544 * each new block will have the same number of entries. 1530 * each new block will have the same number of entries.
1545 */ 1531 */
1546 if ((INT_GET(left->bb_numrecs, ARCH_CONVERT) & 1) && 1532 if ((be16_to_cpu(left->bb_numrecs) & 1) &&
1547 cur->bc_ptrs[level] <= INT_GET(right->bb_numrecs, ARCH_CONVERT) + 1) 1533 cur->bc_ptrs[level] <= be16_to_cpu(right->bb_numrecs) + 1)
1548 INT_MOD(right->bb_numrecs, ARCH_CONVERT, +1); 1534 be16_add(&right->bb_numrecs, 1);
1549 i = INT_GET(left->bb_numrecs, ARCH_CONVERT) - INT_GET(right->bb_numrecs, ARCH_CONVERT) + 1; 1535 i = be16_to_cpu(left->bb_numrecs) - be16_to_cpu(right->bb_numrecs) + 1;
1550 /* 1536 /*
1551 * For non-leaf blocks, copy keys and addresses over to the new block. 1537 * For non-leaf blocks, copy keys and addresses over to the new block.
1552 */ 1538 */
@@ -1556,15 +1542,15 @@ xfs_inobt_split(
1556 rkp = XFS_INOBT_KEY_ADDR(right, 1, cur); 1542 rkp = XFS_INOBT_KEY_ADDR(right, 1, cur);
1557 rpp = XFS_INOBT_PTR_ADDR(right, 1, cur); 1543 rpp = XFS_INOBT_PTR_ADDR(right, 1, cur);
1558#ifdef DEBUG 1544#ifdef DEBUG
1559 for (i = 0; i < INT_GET(right->bb_numrecs, ARCH_CONVERT); i++) { 1545 for (i = 0; i < be16_to_cpu(right->bb_numrecs); i++) {
1560 if ((error = xfs_btree_check_sptr(cur, INT_GET(lpp[i], ARCH_CONVERT), level))) 1546 if ((error = xfs_btree_check_sptr(cur, be32_to_cpu(lpp[i]), level)))
1561 return error; 1547 return error;
1562 } 1548 }
1563#endif 1549#endif
1564 memcpy(rkp, lkp, INT_GET(right->bb_numrecs, ARCH_CONVERT) * sizeof(*rkp)); 1550 memcpy(rkp, lkp, be16_to_cpu(right->bb_numrecs) * sizeof(*rkp));
1565 memcpy(rpp, lpp, INT_GET(right->bb_numrecs, ARCH_CONVERT) * sizeof(*rpp)); 1551 memcpy(rpp, lpp, be16_to_cpu(right->bb_numrecs) * sizeof(*rpp));
1566 xfs_inobt_log_keys(cur, rbp, 1, INT_GET(right->bb_numrecs, ARCH_CONVERT)); 1552 xfs_inobt_log_keys(cur, rbp, 1, be16_to_cpu(right->bb_numrecs));
1567 xfs_inobt_log_ptrs(cur, rbp, 1, INT_GET(right->bb_numrecs, ARCH_CONVERT)); 1553 xfs_inobt_log_ptrs(cur, rbp, 1, be16_to_cpu(right->bb_numrecs));
1568 *keyp = *rkp; 1554 *keyp = *rkp;
1569 } 1555 }
1570 /* 1556 /*
@@ -1573,36 +1559,36 @@ xfs_inobt_split(
1573 else { 1559 else {
1574 lrp = XFS_INOBT_REC_ADDR(left, i, cur); 1560 lrp = XFS_INOBT_REC_ADDR(left, i, cur);
1575 rrp = XFS_INOBT_REC_ADDR(right, 1, cur); 1561 rrp = XFS_INOBT_REC_ADDR(right, 1, cur);
1576 memcpy(rrp, lrp, INT_GET(right->bb_numrecs, ARCH_CONVERT) * sizeof(*rrp)); 1562 memcpy(rrp, lrp, be16_to_cpu(right->bb_numrecs) * sizeof(*rrp));
1577 xfs_inobt_log_recs(cur, rbp, 1, INT_GET(right->bb_numrecs, ARCH_CONVERT)); 1563 xfs_inobt_log_recs(cur, rbp, 1, be16_to_cpu(right->bb_numrecs));
1578 keyp->ir_startino = rrp->ir_startino; /* INT_: direct copy */ 1564 keyp->ir_startino = rrp->ir_startino; /* INT_: direct copy */
1579 } 1565 }
1580 /* 1566 /*
1581 * Find the left block number by looking in the buffer. 1567 * Find the left block number by looking in the buffer.
1582 * Adjust numrecs, sibling pointers. 1568 * Adjust numrecs, sibling pointers.
1583 */ 1569 */
1584 INT_MOD(left->bb_numrecs, ARCH_CONVERT, -(INT_GET(right->bb_numrecs, ARCH_CONVERT))); 1570 be16_add(&left->bb_numrecs, -(be16_to_cpu(right->bb_numrecs)));
1585 right->bb_rightsib = left->bb_rightsib; /* INT_: direct copy */ 1571 right->bb_rightsib = left->bb_rightsib;
1586 INT_SET(left->bb_rightsib, ARCH_CONVERT, args.agbno); 1572 left->bb_rightsib = cpu_to_be32(args.agbno);
1587 INT_SET(right->bb_leftsib, ARCH_CONVERT, lbno); 1573 right->bb_leftsib = cpu_to_be32(lbno);
1588 xfs_inobt_log_block(args.tp, rbp, XFS_BB_ALL_BITS); 1574 xfs_inobt_log_block(args.tp, rbp, XFS_BB_ALL_BITS);
1589 xfs_inobt_log_block(args.tp, lbp, XFS_BB_NUMRECS | XFS_BB_RIGHTSIB); 1575 xfs_inobt_log_block(args.tp, lbp, XFS_BB_NUMRECS | XFS_BB_RIGHTSIB);
1590 /* 1576 /*
1591 * If there's a block to the new block's right, make that block 1577 * If there's a block to the new block's right, make that block
1592 * point back to right instead of to left. 1578 * point back to right instead of to left.
1593 */ 1579 */
1594 if (INT_GET(right->bb_rightsib, ARCH_CONVERT) != NULLAGBLOCK) { 1580 if (be32_to_cpu(right->bb_rightsib) != NULLAGBLOCK) {
1595 xfs_inobt_block_t *rrblock; /* rr btree block */ 1581 xfs_inobt_block_t *rrblock; /* rr btree block */
1596 xfs_buf_t *rrbp; /* buffer for rrblock */ 1582 xfs_buf_t *rrbp; /* buffer for rrblock */
1597 1583
1598 if ((error = xfs_btree_read_bufs(args.mp, args.tp, args.agno, 1584 if ((error = xfs_btree_read_bufs(args.mp, args.tp, args.agno,
1599 INT_GET(right->bb_rightsib, ARCH_CONVERT), 0, &rrbp, 1585 be32_to_cpu(right->bb_rightsib), 0, &rrbp,
1600 XFS_INO_BTREE_REF))) 1586 XFS_INO_BTREE_REF)))
1601 return error; 1587 return error;
1602 rrblock = XFS_BUF_TO_INOBT_BLOCK(rrbp); 1588 rrblock = XFS_BUF_TO_INOBT_BLOCK(rrbp);
1603 if ((error = xfs_btree_check_sblock(cur, rrblock, level, rrbp))) 1589 if ((error = xfs_btree_check_sblock(cur, rrblock, level, rrbp)))
1604 return error; 1590 return error;
1605 INT_SET(rrblock->bb_leftsib, ARCH_CONVERT, args.agbno); 1591 rrblock->bb_leftsib = cpu_to_be32(args.agbno);
1606 xfs_inobt_log_block(args.tp, rrbp, XFS_BB_LEFTSIB); 1592 xfs_inobt_log_block(args.tp, rrbp, XFS_BB_LEFTSIB);
1607 } 1593 }
1608 /* 1594 /*
@@ -1610,9 +1596,9 @@ xfs_inobt_split(
1610 * If it's just pointing past the last entry in left, then we'll 1596 * If it's just pointing past the last entry in left, then we'll
1611 * insert there, so don't change anything in that case. 1597 * insert there, so don't change anything in that case.
1612 */ 1598 */
1613 if (cur->bc_ptrs[level] > INT_GET(left->bb_numrecs, ARCH_CONVERT) + 1) { 1599 if (cur->bc_ptrs[level] > be16_to_cpu(left->bb_numrecs) + 1) {
1614 xfs_btree_setbuf(cur, level, rbp); 1600 xfs_btree_setbuf(cur, level, rbp);
1615 cur->bc_ptrs[level] -= INT_GET(left->bb_numrecs, ARCH_CONVERT); 1601 cur->bc_ptrs[level] -= be16_to_cpu(left->bb_numrecs);
1616 } 1602 }
1617 /* 1603 /*
1618 * If there are more levels, we'll need another cursor which refers 1604 * If there are more levels, we'll need another cursor which refers
@@ -1710,7 +1696,7 @@ xfs_inobt_decrement(
1710 /* 1696 /*
1711 * If we just went off the left edge of the tree, return failure. 1697 * If we just went off the left edge of the tree, return failure.
1712 */ 1698 */
1713 if (INT_GET(block->bb_leftsib, ARCH_CONVERT) == NULLAGBLOCK) { 1699 if (be32_to_cpu(block->bb_leftsib) == NULLAGBLOCK) {
1714 *stat = 0; 1700 *stat = 0;
1715 return 0; 1701 return 0;
1716 } 1702 }
@@ -1739,7 +1725,7 @@ xfs_inobt_decrement(
1739 xfs_agblock_t agbno; /* block number of btree block */ 1725 xfs_agblock_t agbno; /* block number of btree block */
1740 xfs_buf_t *bp; /* buffer containing btree block */ 1726 xfs_buf_t *bp; /* buffer containing btree block */
1741 1727
1742 agbno = INT_GET(*XFS_INOBT_PTR_ADDR(block, cur->bc_ptrs[lev], cur), ARCH_CONVERT); 1728 agbno = be32_to_cpu(*XFS_INOBT_PTR_ADDR(block, cur->bc_ptrs[lev], cur));
1743 if ((error = xfs_btree_read_bufs(cur->bc_mp, cur->bc_tp, 1729 if ((error = xfs_btree_read_bufs(cur->bc_mp, cur->bc_tp,
1744 cur->bc_private.i.agno, agbno, 0, &bp, 1730 cur->bc_private.i.agno, agbno, 0, &bp,
1745 XFS_INO_BTREE_REF))) 1731 XFS_INO_BTREE_REF)))
@@ -1749,7 +1735,7 @@ xfs_inobt_decrement(
1749 block = XFS_BUF_TO_INOBT_BLOCK(bp); 1735 block = XFS_BUF_TO_INOBT_BLOCK(bp);
1750 if ((error = xfs_btree_check_sblock(cur, block, lev, bp))) 1736 if ((error = xfs_btree_check_sblock(cur, block, lev, bp)))
1751 return error; 1737 return error;
1752 cur->bc_ptrs[lev] = INT_GET(block->bb_numrecs, ARCH_CONVERT); 1738 cur->bc_ptrs[lev] = be16_to_cpu(block->bb_numrecs);
1753 } 1739 }
1754 *stat = 1; 1740 *stat = 1;
1755 return 0; 1741 return 0;
@@ -1821,7 +1807,7 @@ xfs_inobt_get_rec(
1821 /* 1807 /*
1822 * Off the right end or left end, return failure. 1808 * Off the right end or left end, return failure.
1823 */ 1809 */
1824 if (ptr > INT_GET(block->bb_numrecs, ARCH_CONVERT) || ptr <= 0) { 1810 if (ptr > be16_to_cpu(block->bb_numrecs) || ptr <= 0) {
1825 *stat = 0; 1811 *stat = 0;
1826 return 0; 1812 return 0;
1827 } 1813 }
@@ -1869,14 +1855,14 @@ xfs_inobt_increment(
1869 * Increment the ptr at this level. If we're still in the block 1855 * Increment the ptr at this level. If we're still in the block
1870 * then we're done. 1856 * then we're done.
1871 */ 1857 */
1872 if (++cur->bc_ptrs[level] <= INT_GET(block->bb_numrecs, ARCH_CONVERT)) { 1858 if (++cur->bc_ptrs[level] <= be16_to_cpu(block->bb_numrecs)) {
1873 *stat = 1; 1859 *stat = 1;
1874 return 0; 1860 return 0;
1875 } 1861 }
1876 /* 1862 /*
1877 * If we just went off the right edge of the tree, return failure. 1863 * If we just went off the right edge of the tree, return failure.
1878 */ 1864 */
1879 if (INT_GET(block->bb_rightsib, ARCH_CONVERT) == NULLAGBLOCK) { 1865 if (be32_to_cpu(block->bb_rightsib) == NULLAGBLOCK) {
1880 *stat = 0; 1866 *stat = 0;
1881 return 0; 1867 return 0;
1882 } 1868 }
@@ -1891,7 +1877,7 @@ xfs_inobt_increment(
1891 if ((error = xfs_btree_check_sblock(cur, block, lev, bp))) 1877 if ((error = xfs_btree_check_sblock(cur, block, lev, bp)))
1892 return error; 1878 return error;
1893#endif 1879#endif
1894 if (++cur->bc_ptrs[lev] <= INT_GET(block->bb_numrecs, ARCH_CONVERT)) 1880 if (++cur->bc_ptrs[lev] <= be16_to_cpu(block->bb_numrecs))
1895 break; 1881 break;
1896 /* 1882 /*
1897 * Read-ahead the right block, we're going to read it 1883 * Read-ahead the right block, we're going to read it
@@ -1911,7 +1897,7 @@ xfs_inobt_increment(
1911 lev > level; ) { 1897 lev > level; ) {
1912 xfs_agblock_t agbno; /* block number of btree block */ 1898 xfs_agblock_t agbno; /* block number of btree block */
1913 1899
1914 agbno = INT_GET(*XFS_INOBT_PTR_ADDR(block, cur->bc_ptrs[lev], cur), ARCH_CONVERT); 1900 agbno = be32_to_cpu(*XFS_INOBT_PTR_ADDR(block, cur->bc_ptrs[lev], cur));
1915 if ((error = xfs_btree_read_bufs(cur->bc_mp, cur->bc_tp, 1901 if ((error = xfs_btree_read_bufs(cur->bc_mp, cur->bc_tp,
1916 cur->bc_private.i.agno, agbno, 0, &bp, 1902 cur->bc_private.i.agno, agbno, 0, &bp,
1917 XFS_INO_BTREE_REF))) 1903 XFS_INO_BTREE_REF)))
diff --git a/fs/xfs/xfs_ialloc_btree.h b/fs/xfs/xfs_ialloc_btree.h
index 44be188674a6..ae3904cb1ee8 100644
--- a/fs/xfs/xfs_ialloc_btree.h
+++ b/fs/xfs/xfs_ialloc_btree.h
@@ -1,33 +1,19 @@
1/* 1/*
2 * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32#ifndef __XFS_IALLOC_BTREE_H__ 18#ifndef __XFS_IALLOC_BTREE_H__
33#define __XFS_IALLOC_BTREE_H__ 19#define __XFS_IALLOC_BTREE_H__
@@ -51,14 +37,12 @@ typedef __uint64_t xfs_inofree_t;
51#define XFS_INODES_PER_CHUNK_LOG (XFS_NBBYLOG + 3) 37#define XFS_INODES_PER_CHUNK_LOG (XFS_NBBYLOG + 3)
52#define XFS_INOBT_ALL_FREE ((xfs_inofree_t)-1) 38#define XFS_INOBT_ALL_FREE ((xfs_inofree_t)-1)
53 39
54#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_INOBT_MASKN)
55xfs_inofree_t xfs_inobt_maskn(int i, int n);
56#define XFS_INOBT_MASKN(i,n) xfs_inobt_maskn(i,n) 40#define XFS_INOBT_MASKN(i,n) xfs_inobt_maskn(i,n)
57#else 41static inline xfs_inofree_t xfs_inobt_maskn(int i, int n)
58#define XFS_INOBT_MASKN(i,n) \ 42{
59 ((((n) >= XFS_INODES_PER_CHUNK ? \ 43 return (((n) >= XFS_INODES_PER_CHUNK ? \
60 (xfs_inofree_t)0 : ((xfs_inofree_t)1 << (n))) - 1) << (i)) 44 (xfs_inofree_t)0 : ((xfs_inofree_t)1 << (n))) - 1) << (i);
61#endif 45}
62 46
63/* 47/*
64 * Data record structure 48 * Data record structure
@@ -78,241 +62,116 @@ typedef struct xfs_inobt_key
78 xfs_agino_t ir_startino; /* starting inode number */ 62 xfs_agino_t ir_startino; /* starting inode number */
79} xfs_inobt_key_t; 63} xfs_inobt_key_t;
80 64
81typedef xfs_agblock_t xfs_inobt_ptr_t; /* btree pointer type */ 65/* btree pointer type */
82 /* btree block header type */ 66typedef __be32 xfs_inobt_ptr_t;
67
68/* btree block header type */
83typedef struct xfs_btree_sblock xfs_inobt_block_t; 69typedef struct xfs_btree_sblock xfs_inobt_block_t;
84 70
85#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BUF_TO_INOBT_BLOCK) 71#define XFS_BUF_TO_INOBT_BLOCK(bp) ((xfs_inobt_block_t *)XFS_BUF_PTR(bp))
86xfs_inobt_block_t *xfs_buf_to_inobt_block(struct xfs_buf *bp);
87#define XFS_BUF_TO_INOBT_BLOCK(bp) xfs_buf_to_inobt_block(bp)
88#else
89#define XFS_BUF_TO_INOBT_BLOCK(bp) ((xfs_inobt_block_t *)(XFS_BUF_PTR(bp)))
90#endif
91 72
92/* 73/*
93 * Bit manipulations for ir_free. 74 * Bit manipulations for ir_free.
94 */ 75 */
95#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_INOBT_MASK)
96xfs_inofree_t xfs_inobt_mask(int i);
97#define XFS_INOBT_MASK(i) xfs_inobt_mask(i)
98#else
99#define XFS_INOBT_MASK(i) ((xfs_inofree_t)1 << (i)) 76#define XFS_INOBT_MASK(i) ((xfs_inofree_t)1 << (i))
100#endif 77#define XFS_INOBT_IS_FREE(rp,i) \
101#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_INOBT_IS_FREE) 78 (((rp)->ir_free & XFS_INOBT_MASK(i)) != 0)
102int xfs_inobt_is_free(xfs_inobt_rec_t *rp, int i); 79#define XFS_INOBT_IS_FREE_DISK(rp,i) \
103#define XFS_INOBT_IS_FREE(rp,i) xfs_inobt_is_free(rp,i) 80 ((INT_GET((rp)->ir_free,ARCH_CONVERT) & XFS_INOBT_MASK(i)) != 0)
104#define XFS_INOBT_IS_FREE_DISK(rp,i) xfs_inobt_is_free_disk(rp,i)
105#else
106#define XFS_INOBT_IS_FREE(rp,i) \
107 (((rp)->ir_free & XFS_INOBT_MASK(i)) != 0)
108#define XFS_INOBT_IS_FREE_DISK(rp,i) \
109 ((INT_GET((rp)->ir_free, ARCH_CONVERT) & XFS_INOBT_MASK(i)) != 0)
110#endif
111#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_INOBT_SET_FREE)
112void xfs_inobt_set_free(xfs_inobt_rec_t *rp, int i);
113#define XFS_INOBT_SET_FREE(rp,i) xfs_inobt_set_free(rp,i)
114#else
115#define XFS_INOBT_SET_FREE(rp,i) ((rp)->ir_free |= XFS_INOBT_MASK(i)) 81#define XFS_INOBT_SET_FREE(rp,i) ((rp)->ir_free |= XFS_INOBT_MASK(i))
116#endif
117#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_INOBT_CLR_FREE)
118void xfs_inobt_clr_free(xfs_inobt_rec_t *rp, int i);
119#define XFS_INOBT_CLR_FREE(rp,i) xfs_inobt_clr_free(rp,i)
120#else
121#define XFS_INOBT_CLR_FREE(rp,i) ((rp)->ir_free &= ~XFS_INOBT_MASK(i)) 82#define XFS_INOBT_CLR_FREE(rp,i) ((rp)->ir_free &= ~XFS_INOBT_MASK(i))
122#endif
123 83
124/* 84/*
125 * Real block structures have a size equal to the disk block size. 85 * Real block structures have a size equal to the disk block size.
126 */ 86 */
127#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_INOBT_BLOCK_SIZE)
128int xfs_inobt_block_size(int lev, struct xfs_btree_cur *cur);
129#define XFS_INOBT_BLOCK_SIZE(lev,cur) xfs_inobt_block_size(lev,cur)
130#else
131#define XFS_INOBT_BLOCK_SIZE(lev,cur) (1 << (cur)->bc_blocklog) 87#define XFS_INOBT_BLOCK_SIZE(lev,cur) (1 << (cur)->bc_blocklog)
132#endif 88#define XFS_INOBT_BLOCK_MAXRECS(lev,cur) ((cur)->bc_mp->m_inobt_mxr[lev != 0])
133 89#define XFS_INOBT_BLOCK_MINRECS(lev,cur) ((cur)->bc_mp->m_inobt_mnr[lev != 0])
134#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_INOBT_BLOCK_MAXRECS)
135int xfs_inobt_block_maxrecs(int lev, struct xfs_btree_cur *cur);
136#define XFS_INOBT_BLOCK_MAXRECS(lev,cur) xfs_inobt_block_maxrecs(lev,cur)
137#else
138#define XFS_INOBT_BLOCK_MAXRECS(lev,cur) \
139 ((cur)->bc_mp->m_inobt_mxr[lev != 0])
140#endif
141#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_INOBT_BLOCK_MINRECS)
142int xfs_inobt_block_minrecs(int lev, struct xfs_btree_cur *cur);
143#define XFS_INOBT_BLOCK_MINRECS(lev,cur) xfs_inobt_block_minrecs(lev,cur)
144#else
145#define XFS_INOBT_BLOCK_MINRECS(lev,cur) \
146 ((cur)->bc_mp->m_inobt_mnr[lev != 0])
147#endif
148
149#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_INOBT_IS_LAST_REC)
150int xfs_inobt_is_last_rec(struct xfs_btree_cur *cur);
151#define XFS_INOBT_IS_LAST_REC(cur) xfs_inobt_is_last_rec(cur)
152#else
153#define XFS_INOBT_IS_LAST_REC(cur) \ 90#define XFS_INOBT_IS_LAST_REC(cur) \
154 ((cur)->bc_ptrs[0] == \ 91 ((cur)->bc_ptrs[0] == be16_to_cpu(XFS_BUF_TO_INOBT_BLOCK((cur)->bc_bufs[0])->bb_numrecs))
155 INT_GET(XFS_BUF_TO_INOBT_BLOCK((cur)->bc_bufs[0])->bb_numrecs, ARCH_CONVERT))
156#endif
157 92
158/* 93/*
159 * Maximum number of inode btree levels. 94 * Maximum number of inode btree levels.
160 */ 95 */
161#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_IN_MAXLEVELS)
162int xfs_in_maxlevels(struct xfs_mount *mp);
163#define XFS_IN_MAXLEVELS(mp) xfs_in_maxlevels(mp)
164#else
165#define XFS_IN_MAXLEVELS(mp) ((mp)->m_in_maxlevels) 96#define XFS_IN_MAXLEVELS(mp) ((mp)->m_in_maxlevels)
166#endif
167 97
168/* 98/*
169 * block numbers in the AG. 99 * block numbers in the AG.
170 */ 100 */
171#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_IBT_BLOCK) 101#define XFS_IBT_BLOCK(mp) ((xfs_agblock_t)(XFS_CNT_BLOCK(mp) + 1))
172xfs_agblock_t xfs_ibt_block(struct xfs_mount *mp); 102#define XFS_PREALLOC_BLOCKS(mp) ((xfs_agblock_t)(XFS_IBT_BLOCK(mp) + 1))
173#define XFS_IBT_BLOCK(mp) xfs_ibt_block(mp)
174#else
175#define XFS_IBT_BLOCK(mp) ((xfs_agblock_t)(XFS_CNT_BLOCK(mp) + 1))
176#endif
177#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_PREALLOC_BLOCKS)
178xfs_agblock_t xfs_prealloc_blocks(struct xfs_mount *mp);
179#define XFS_PREALLOC_BLOCKS(mp) xfs_prealloc_blocks(mp)
180#else
181#define XFS_PREALLOC_BLOCKS(mp) ((xfs_agblock_t)(XFS_IBT_BLOCK(mp) + 1))
182#endif
183 103
184/* 104/*
185 * Record, key, and pointer address macros for btree blocks. 105 * Record, key, and pointer address macros for btree blocks.
186 */ 106 */
187#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_INOBT_REC_ADDR) 107#define XFS_INOBT_REC_ADDR(bb,i,cur) \
188xfs_inobt_rec_t * 108 (XFS_BTREE_REC_ADDR(XFS_INOBT_BLOCK_SIZE(0,cur), xfs_inobt, bb, \
189xfs_inobt_rec_addr(xfs_inobt_block_t *bb, int i, struct xfs_btree_cur *cur); 109 i, XFS_INOBT_BLOCK_MAXRECS(0, cur)))
190#define XFS_INOBT_REC_ADDR(bb,i,cur) xfs_inobt_rec_addr(bb,i,cur) 110#define XFS_INOBT_KEY_ADDR(bb,i,cur) \
191#else 111 (XFS_BTREE_KEY_ADDR(XFS_INOBT_BLOCK_SIZE(1,cur), xfs_inobt, bb, \
192#define XFS_INOBT_REC_ADDR(bb,i,cur) \ 112 i, XFS_INOBT_BLOCK_MAXRECS(1, cur)))
193 XFS_BTREE_REC_ADDR(XFS_INOBT_BLOCK_SIZE(0,cur), xfs_inobt, bb, i, \
194 XFS_INOBT_BLOCK_MAXRECS(0, cur))
195#endif
196
197#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_INOBT_KEY_ADDR)
198xfs_inobt_key_t *
199xfs_inobt_key_addr(xfs_inobt_block_t *bb, int i, struct xfs_btree_cur *cur);
200#define XFS_INOBT_KEY_ADDR(bb,i,cur) xfs_inobt_key_addr(bb,i,cur)
201#else
202#define XFS_INOBT_KEY_ADDR(bb,i,cur) \
203 XFS_BTREE_KEY_ADDR(XFS_INOBT_BLOCK_SIZE(1,cur), xfs_inobt, bb, i, \
204 XFS_INOBT_BLOCK_MAXRECS(1, cur))
205#endif
206 113
207#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_INOBT_PTR_ADDR) 114#define XFS_INOBT_PTR_ADDR(bb,i,cur) \
208xfs_inobt_ptr_t * 115 (XFS_BTREE_PTR_ADDR(XFS_INOBT_BLOCK_SIZE(1,cur), xfs_inobt, bb, \
209xfs_inobt_ptr_addr(xfs_inobt_block_t *bb, int i, struct xfs_btree_cur *cur); 116 i, XFS_INOBT_BLOCK_MAXRECS(1, cur)))
210#define XFS_INOBT_PTR_ADDR(bb,i,cur) xfs_inobt_ptr_addr(bb,i,cur)
211#else
212#define XFS_INOBT_PTR_ADDR(bb,i,cur) \
213 XFS_BTREE_PTR_ADDR(XFS_INOBT_BLOCK_SIZE(1,cur), xfs_inobt, bb, i, \
214 XFS_INOBT_BLOCK_MAXRECS(1, cur))
215#endif
216
217/*
218 * Prototypes for externally visible routines.
219 */
220 117
221/* 118/*
222 * Decrement cursor by one record at the level. 119 * Decrement cursor by one record at the level.
223 * For nonzero levels the leaf-ward information is untouched. 120 * For nonzero levels the leaf-ward information is untouched.
224 */ 121 */
225int /* error */ 122extern int xfs_inobt_decrement(struct xfs_btree_cur *cur, int level, int *stat);
226xfs_inobt_decrement(
227 struct xfs_btree_cur *cur, /* btree cursor */
228 int level, /* level in btree, 0 is leaf */
229 int *stat); /* success/failure */
230 123
231/* 124/*
232 * Delete the record pointed to by cur. 125 * Delete the record pointed to by cur.
233 * The cursor refers to the place where the record was (could be inserted) 126 * The cursor refers to the place where the record was (could be inserted)
234 * when the operation returns. 127 * when the operation returns.
235 */ 128 */
236int /* error */ 129extern int xfs_inobt_delete(struct xfs_btree_cur *cur, int *stat);
237xfs_inobt_delete(
238 struct xfs_btree_cur *cur, /* btree cursor */
239 int *stat); /* success/failure */
240 130
241/* 131/*
242 * Get the data from the pointed-to record. 132 * Get the data from the pointed-to record.
243 */ 133 */
244int /* error */ 134extern int xfs_inobt_get_rec(struct xfs_btree_cur *cur, xfs_agino_t *ino,
245xfs_inobt_get_rec( 135 __int32_t *fcnt, xfs_inofree_t *free, int *stat);
246 struct xfs_btree_cur *cur, /* btree cursor */
247 xfs_agino_t *ino, /* output: starting inode of chunk */
248 __int32_t *fcnt, /* output: number of free inodes */
249 xfs_inofree_t *free, /* output: free inode mask */
250 int *stat); /* output: success/failure */
251 136
252/* 137/*
253 * Increment cursor by one record at the level. 138 * Increment cursor by one record at the level.
254 * For nonzero levels the leaf-ward information is untouched. 139 * For nonzero levels the leaf-ward information is untouched.
255 */ 140 */
256int /* error */ 141extern int xfs_inobt_increment(struct xfs_btree_cur *cur, int level, int *stat);
257xfs_inobt_increment(
258 struct xfs_btree_cur *cur, /* btree cursor */
259 int level, /* level in btree, 0 is leaf */
260 int *stat); /* success/failure */
261 142
262/* 143/*
263 * Insert the current record at the point referenced by cur. 144 * Insert the current record at the point referenced by cur.
264 * The cursor may be inconsistent on return if splits have been done. 145 * The cursor may be inconsistent on return if splits have been done.
265 */ 146 */
266int /* error */ 147extern int xfs_inobt_insert(struct xfs_btree_cur *cur, int *stat);
267xfs_inobt_insert(
268 struct xfs_btree_cur *cur, /* btree cursor */
269 int *stat); /* success/failure */
270 148
271/* 149/*
272 * Lookup the record equal to ino in the btree given by cur. 150 * Lookup the record equal to ino in the btree given by cur.
273 */ 151 */
274int /* error */ 152extern int xfs_inobt_lookup_eq(struct xfs_btree_cur *cur, xfs_agino_t ino,
275xfs_inobt_lookup_eq( 153 __int32_t fcnt, xfs_inofree_t free, int *stat);
276 struct xfs_btree_cur *cur, /* btree cursor */
277 xfs_agino_t ino, /* starting inode of chunk */
278 __int32_t fcnt, /* free inode count */
279 xfs_inofree_t free, /* free inode mask */
280 int *stat); /* success/failure */
281 154
282/* 155/*
283 * Lookup the first record greater than or equal to ino 156 * Lookup the first record greater than or equal to ino
284 * in the btree given by cur. 157 * in the btree given by cur.
285 */ 158 */
286int /* error */ 159extern int xfs_inobt_lookup_ge(struct xfs_btree_cur *cur, xfs_agino_t ino,
287xfs_inobt_lookup_ge( 160 __int32_t fcnt, xfs_inofree_t free, int *stat);
288 struct xfs_btree_cur *cur, /* btree cursor */
289 xfs_agino_t ino, /* starting inode of chunk */
290 __int32_t fcnt, /* free inode count */
291 xfs_inofree_t free, /* free inode mask */
292 int *stat); /* success/failure */
293 161
294/* 162/*
295 * Lookup the first record less than or equal to ino 163 * Lookup the first record less than or equal to ino
296 * in the btree given by cur. 164 * in the btree given by cur.
297 */ 165 */
298int /* error */ 166extern int xfs_inobt_lookup_le(struct xfs_btree_cur *cur, xfs_agino_t ino,
299xfs_inobt_lookup_le( 167 __int32_t fcnt, xfs_inofree_t free, int *stat);
300 struct xfs_btree_cur *cur, /* btree cursor */
301 xfs_agino_t ino, /* starting inode of chunk */
302 __int32_t fcnt, /* free inode count */
303 xfs_inofree_t free, /* free inode mask */
304 int *stat); /* success/failure */
305 168
306/* 169/*
307 * Update the record referred to by cur, to the value given 170 * Update the record referred to by cur, to the value given
308 * by [ino, fcnt, free]. 171 * by [ino, fcnt, free].
309 * This either works (return 0) or gets an EFSCORRUPTED error. 172 * This either works (return 0) or gets an EFSCORRUPTED error.
310 */ 173 */
311int /* error */ 174extern int xfs_inobt_update(struct xfs_btree_cur *cur, xfs_agino_t ino,
312xfs_inobt_update( 175 __int32_t fcnt, xfs_inofree_t free);
313 struct xfs_btree_cur *cur, /* btree cursor */
314 xfs_agino_t ino, /* starting inode of chunk */
315 __int32_t fcnt, /* free inode count */
316 xfs_inofree_t free); /* free inode mask */
317 176
318#endif /* __XFS_IALLOC_BTREE_H__ */ 177#endif /* __XFS_IALLOC_BTREE_H__ */
diff --git a/fs/xfs/xfs_iget.c b/fs/xfs/xfs_iget.c
index 0d9ae8fb4138..fc19eedbd11b 100644
--- a/fs/xfs/xfs_iget.c
+++ b/fs/xfs/xfs_iget.c
@@ -1,43 +1,26 @@
1/* 1/*
2 * Copyright (c) 2000-2005 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32
33#include <linux/delay.h>
34
35#include "xfs.h" 18#include "xfs.h"
36 19#include "xfs_fs.h"
37#include "xfs_macros.h"
38#include "xfs_types.h" 20#include "xfs_types.h"
39#include "xfs_inum.h" 21#include "xfs_bit.h"
40#include "xfs_log.h" 22#include "xfs_log.h"
23#include "xfs_inum.h"
41#include "xfs_trans.h" 24#include "xfs_trans.h"
42#include "xfs_sb.h" 25#include "xfs_sb.h"
43#include "xfs_ag.h" 26#include "xfs_ag.h"
@@ -45,19 +28,18 @@
45#include "xfs_dir2.h" 28#include "xfs_dir2.h"
46#include "xfs_dmapi.h" 29#include "xfs_dmapi.h"
47#include "xfs_mount.h" 30#include "xfs_mount.h"
48#include "xfs_alloc_btree.h"
49#include "xfs_bmap_btree.h" 31#include "xfs_bmap_btree.h"
32#include "xfs_alloc_btree.h"
50#include "xfs_ialloc_btree.h" 33#include "xfs_ialloc_btree.h"
51#include "xfs_btree.h"
52#include "xfs_ialloc.h"
53#include "xfs_attr_sf.h"
54#include "xfs_dir_sf.h" 34#include "xfs_dir_sf.h"
55#include "xfs_dir2_sf.h" 35#include "xfs_dir2_sf.h"
36#include "xfs_attr_sf.h"
56#include "xfs_dinode.h" 37#include "xfs_dinode.h"
57#include "xfs_inode.h" 38#include "xfs_inode.h"
39#include "xfs_btree.h"
40#include "xfs_ialloc.h"
58#include "xfs_quota.h" 41#include "xfs_quota.h"
59#include "xfs_utils.h" 42#include "xfs_utils.h"
60#include "xfs_bit.h"
61 43
62/* 44/*
63 * Initialize the inode hash table for the newly mounted file system. 45 * Initialize the inode hash table for the newly mounted file system.
diff --git a/fs/xfs/xfs_imap.h b/fs/xfs/xfs_imap.h
index e385064a066a..d36450003983 100644
--- a/fs/xfs/xfs_imap.h
+++ b/fs/xfs/xfs_imap.h
@@ -1,33 +1,19 @@
1/* 1/*
2 * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32#ifndef __XFS_IMAP_H__ 18#ifndef __XFS_IMAP_H__
33#define __XFS_IMAP_H__ 19#define __XFS_IMAP_H__
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index db43308aae93..df0d4572d70a 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -1,40 +1,27 @@
1/* 1/*
2 * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32
33#include "xfs.h" 18#include "xfs.h"
34#include "xfs_macros.h" 19#include "xfs_fs.h"
35#include "xfs_types.h" 20#include "xfs_types.h"
36#include "xfs_inum.h" 21#include "xfs_bit.h"
37#include "xfs_log.h" 22#include "xfs_log.h"
23#include "xfs_inum.h"
24#include "xfs_imap.h"
38#include "xfs_trans.h" 25#include "xfs_trans.h"
39#include "xfs_trans_priv.h" 26#include "xfs_trans_priv.h"
40#include "xfs_sb.h" 27#include "xfs_sb.h"
@@ -43,24 +30,22 @@
43#include "xfs_dir2.h" 30#include "xfs_dir2.h"
44#include "xfs_dmapi.h" 31#include "xfs_dmapi.h"
45#include "xfs_mount.h" 32#include "xfs_mount.h"
46#include "xfs_alloc_btree.h"
47#include "xfs_bmap_btree.h" 33#include "xfs_bmap_btree.h"
34#include "xfs_alloc_btree.h"
48#include "xfs_ialloc_btree.h" 35#include "xfs_ialloc_btree.h"
49#include "xfs_btree.h"
50#include "xfs_imap.h"
51#include "xfs_alloc.h"
52#include "xfs_ialloc.h"
53#include "xfs_attr_sf.h"
54#include "xfs_dir_sf.h" 36#include "xfs_dir_sf.h"
55#include "xfs_dir2_sf.h" 37#include "xfs_dir2_sf.h"
38#include "xfs_attr_sf.h"
56#include "xfs_dinode.h" 39#include "xfs_dinode.h"
57#include "xfs_inode_item.h"
58#include "xfs_inode.h" 40#include "xfs_inode.h"
59#include "xfs_bmap.h"
60#include "xfs_buf_item.h" 41#include "xfs_buf_item.h"
42#include "xfs_inode_item.h"
43#include "xfs_btree.h"
44#include "xfs_alloc.h"
45#include "xfs_ialloc.h"
46#include "xfs_bmap.h"
61#include "xfs_rw.h" 47#include "xfs_rw.h"
62#include "xfs_error.h" 48#include "xfs_error.h"
63#include "xfs_bit.h"
64#include "xfs_utils.h" 49#include "xfs_utils.h"
65#include "xfs_dir2_trace.h" 50#include "xfs_dir2_trace.h"
66#include "xfs_quota.h" 51#include "xfs_quota.h"
@@ -194,9 +179,10 @@ xfs_inotobp(
194 if ((imap.im_blkno + imap.im_len) > 179 if ((imap.im_blkno + imap.im_len) >
195 XFS_FSB_TO_BB(mp, mp->m_sb.sb_dblocks)) { 180 XFS_FSB_TO_BB(mp, mp->m_sb.sb_dblocks)) {
196 cmn_err(CE_WARN, 181 cmn_err(CE_WARN,
197 "xfs_inotobp: inode number (%d + %d) maps to a block outside the bounds " 182 "xfs_inotobp: inode number (%llu + %d) maps to a block outside the bounds "
198 "of the file system %s. Returning EINVAL.", 183 "of the file system %s. Returning EINVAL.",
199 imap.im_blkno, imap.im_len,mp->m_fsname); 184 (unsigned long long)imap.im_blkno,
185 imap.im_len, mp->m_fsname);
200 return XFS_ERROR(EINVAL); 186 return XFS_ERROR(EINVAL);
201 } 187 }
202 188
@@ -1878,8 +1864,8 @@ xfs_iunlink(
1878 */ 1864 */
1879 agi = XFS_BUF_TO_AGI(agibp); 1865 agi = XFS_BUF_TO_AGI(agibp);
1880 agi_ok = 1866 agi_ok =
1881 INT_GET(agi->agi_magicnum, ARCH_CONVERT) == XFS_AGI_MAGIC && 1867 be32_to_cpu(agi->agi_magicnum) == XFS_AGI_MAGIC &&
1882 XFS_AGI_GOOD_VERSION(INT_GET(agi->agi_versionnum, ARCH_CONVERT)); 1868 XFS_AGI_GOOD_VERSION(be32_to_cpu(agi->agi_versionnum));
1883 if (unlikely(XFS_TEST_ERROR(!agi_ok, mp, XFS_ERRTAG_IUNLINK, 1869 if (unlikely(XFS_TEST_ERROR(!agi_ok, mp, XFS_ERRTAG_IUNLINK,
1884 XFS_RANDOM_IUNLINK))) { 1870 XFS_RANDOM_IUNLINK))) {
1885 XFS_CORRUPTION_ERROR("xfs_iunlink", XFS_ERRLEVEL_LOW, mp, agi); 1871 XFS_CORRUPTION_ERROR("xfs_iunlink", XFS_ERRLEVEL_LOW, mp, agi);
@@ -1894,9 +1880,9 @@ xfs_iunlink(
1894 ASSERT(agino != 0); 1880 ASSERT(agino != 0);
1895 bucket_index = agino % XFS_AGI_UNLINKED_BUCKETS; 1881 bucket_index = agino % XFS_AGI_UNLINKED_BUCKETS;
1896 ASSERT(agi->agi_unlinked[bucket_index]); 1882 ASSERT(agi->agi_unlinked[bucket_index]);
1897 ASSERT(INT_GET(agi->agi_unlinked[bucket_index], ARCH_CONVERT) != agino); 1883 ASSERT(be32_to_cpu(agi->agi_unlinked[bucket_index]) != agino);
1898 1884
1899 if (INT_GET(agi->agi_unlinked[bucket_index], ARCH_CONVERT) != NULLAGINO) { 1885 if (be32_to_cpu(agi->agi_unlinked[bucket_index]) != NULLAGINO) {
1900 /* 1886 /*
1901 * There is already another inode in the bucket we need 1887 * There is already another inode in the bucket we need
1902 * to add ourselves to. Add us at the front of the list. 1888 * to add ourselves to. Add us at the front of the list.
@@ -1923,7 +1909,7 @@ xfs_iunlink(
1923 * Point the bucket head pointer at the inode being inserted. 1909 * Point the bucket head pointer at the inode being inserted.
1924 */ 1910 */
1925 ASSERT(agino != 0); 1911 ASSERT(agino != 0);
1926 INT_SET(agi->agi_unlinked[bucket_index], ARCH_CONVERT, agino); 1912 agi->agi_unlinked[bucket_index] = cpu_to_be32(agino);
1927 offset = offsetof(xfs_agi_t, agi_unlinked) + 1913 offset = offsetof(xfs_agi_t, agi_unlinked) +
1928 (sizeof(xfs_agino_t) * bucket_index); 1914 (sizeof(xfs_agino_t) * bucket_index);
1929 xfs_trans_log_buf(tp, agibp, offset, 1915 xfs_trans_log_buf(tp, agibp, offset,
@@ -1981,8 +1967,8 @@ xfs_iunlink_remove(
1981 */ 1967 */
1982 agi = XFS_BUF_TO_AGI(agibp); 1968 agi = XFS_BUF_TO_AGI(agibp);
1983 agi_ok = 1969 agi_ok =
1984 INT_GET(agi->agi_magicnum, ARCH_CONVERT) == XFS_AGI_MAGIC && 1970 be32_to_cpu(agi->agi_magicnum) == XFS_AGI_MAGIC &&
1985 XFS_AGI_GOOD_VERSION(INT_GET(agi->agi_versionnum, ARCH_CONVERT)); 1971 XFS_AGI_GOOD_VERSION(be32_to_cpu(agi->agi_versionnum));
1986 if (unlikely(XFS_TEST_ERROR(!agi_ok, mp, XFS_ERRTAG_IUNLINK_REMOVE, 1972 if (unlikely(XFS_TEST_ERROR(!agi_ok, mp, XFS_ERRTAG_IUNLINK_REMOVE,
1987 XFS_RANDOM_IUNLINK_REMOVE))) { 1973 XFS_RANDOM_IUNLINK_REMOVE))) {
1988 XFS_CORRUPTION_ERROR("xfs_iunlink_remove", XFS_ERRLEVEL_LOW, 1974 XFS_CORRUPTION_ERROR("xfs_iunlink_remove", XFS_ERRLEVEL_LOW,
@@ -2000,10 +1986,10 @@ xfs_iunlink_remove(
2000 agino = XFS_INO_TO_AGINO(mp, ip->i_ino); 1986 agino = XFS_INO_TO_AGINO(mp, ip->i_ino);
2001 ASSERT(agino != 0); 1987 ASSERT(agino != 0);
2002 bucket_index = agino % XFS_AGI_UNLINKED_BUCKETS; 1988 bucket_index = agino % XFS_AGI_UNLINKED_BUCKETS;
2003 ASSERT(INT_GET(agi->agi_unlinked[bucket_index], ARCH_CONVERT) != NULLAGINO); 1989 ASSERT(be32_to_cpu(agi->agi_unlinked[bucket_index]) != NULLAGINO);
2004 ASSERT(agi->agi_unlinked[bucket_index]); 1990 ASSERT(agi->agi_unlinked[bucket_index]);
2005 1991
2006 if (INT_GET(agi->agi_unlinked[bucket_index], ARCH_CONVERT) == agino) { 1992 if (be32_to_cpu(agi->agi_unlinked[bucket_index]) == agino) {
2007 /* 1993 /*
2008 * We're at the head of the list. Get the inode's 1994 * We're at the head of the list. Get the inode's
2009 * on-disk buffer to see if there is anyone after us 1995 * on-disk buffer to see if there is anyone after us
@@ -2037,7 +2023,7 @@ xfs_iunlink_remove(
2037 */ 2023 */
2038 ASSERT(next_agino != 0); 2024 ASSERT(next_agino != 0);
2039 ASSERT(next_agino != agino); 2025 ASSERT(next_agino != agino);
2040 INT_SET(agi->agi_unlinked[bucket_index], ARCH_CONVERT, next_agino); 2026 agi->agi_unlinked[bucket_index] = cpu_to_be32(next_agino);
2041 offset = offsetof(xfs_agi_t, agi_unlinked) + 2027 offset = offsetof(xfs_agi_t, agi_unlinked) +
2042 (sizeof(xfs_agino_t) * bucket_index); 2028 (sizeof(xfs_agino_t) * bucket_index);
2043 xfs_trans_log_buf(tp, agibp, offset, 2029 xfs_trans_log_buf(tp, agibp, offset,
@@ -2046,7 +2032,7 @@ xfs_iunlink_remove(
2046 /* 2032 /*
2047 * We need to search the list for the inode being freed. 2033 * We need to search the list for the inode being freed.
2048 */ 2034 */
2049 next_agino = INT_GET(agi->agi_unlinked[bucket_index], ARCH_CONVERT); 2035 next_agino = be32_to_cpu(agi->agi_unlinked[bucket_index]);
2050 last_ibp = NULL; 2036 last_ibp = NULL;
2051 while (next_agino != agino) { 2037 while (next_agino != agino) {
2052 /* 2038 /*
@@ -3687,73 +3673,6 @@ xfs_iroundup(
3687 return( 0 ); 3673 return( 0 );
3688} 3674}
3689 3675
3690/*
3691 * Change the requested timestamp in the given inode.
3692 * We don't lock across timestamp updates, and we don't log them but
3693 * we do record the fact that there is dirty information in core.
3694 *
3695 * NOTE -- callers MUST combine XFS_ICHGTIME_MOD or XFS_ICHGTIME_CHG
3696 * with XFS_ICHGTIME_ACC to be sure that access time
3697 * update will take. Calling first with XFS_ICHGTIME_ACC
3698 * and then XFS_ICHGTIME_MOD may fail to modify the access
3699 * timestamp if the filesystem is mounted noacctm.
3700 */
3701void
3702xfs_ichgtime(xfs_inode_t *ip,
3703 int flags)
3704{
3705 timespec_t tv;
3706 vnode_t *vp = XFS_ITOV(ip);
3707 struct inode *inode = LINVFS_GET_IP(vp);
3708
3709 /*
3710 * We're not supposed to change timestamps in readonly-mounted
3711 * filesystems. Throw it away if anyone asks us.
3712 */
3713 if (unlikely(vp->v_vfsp->vfs_flag & VFS_RDONLY))
3714 return;
3715
3716 /*
3717 * Don't update access timestamps on reads if mounted "noatime"
3718 * Throw it away if anyone asks us.
3719 */
3720 if ((ip->i_mount->m_flags & XFS_MOUNT_NOATIME || IS_NOATIME(inode)) &&
3721 ((flags & (XFS_ICHGTIME_ACC|XFS_ICHGTIME_MOD|XFS_ICHGTIME_CHG))
3722 == XFS_ICHGTIME_ACC))
3723 return;
3724
3725 nanotime(&tv);
3726 if (flags & XFS_ICHGTIME_MOD) {
3727 VN_MTIMESET(vp, &tv);
3728 ip->i_d.di_mtime.t_sec = (__int32_t)tv.tv_sec;
3729 ip->i_d.di_mtime.t_nsec = (__int32_t)tv.tv_nsec;
3730 }
3731 if (flags & XFS_ICHGTIME_ACC) {
3732 VN_ATIMESET(vp, &tv);
3733 ip->i_d.di_atime.t_sec = (__int32_t)tv.tv_sec;
3734 ip->i_d.di_atime.t_nsec = (__int32_t)tv.tv_nsec;
3735 }
3736 if (flags & XFS_ICHGTIME_CHG) {
3737 VN_CTIMESET(vp, &tv);
3738 ip->i_d.di_ctime.t_sec = (__int32_t)tv.tv_sec;
3739 ip->i_d.di_ctime.t_nsec = (__int32_t)tv.tv_nsec;
3740 }
3741
3742 /*
3743 * We update the i_update_core field _after_ changing
3744 * the timestamps in order to coordinate properly with
3745 * xfs_iflush() so that we don't lose timestamp updates.
3746 * This keeps us from having to hold the inode lock
3747 * while doing this. We use the SYNCHRONIZE macro to
3748 * ensure that the compiler does not reorder the update
3749 * of i_update_core above the timestamp updates above.
3750 */
3751 SYNCHRONIZE();
3752 ip->i_update_core = 1;
3753 if (!(inode->i_state & I_LOCK))
3754 mark_inode_dirty_sync(inode);
3755}
3756
3757#ifdef XFS_ILOCK_TRACE 3676#ifdef XFS_ILOCK_TRACE
3758ktrace_t *xfs_ilock_trace_buf; 3677ktrace_t *xfs_ilock_trace_buf;
3759 3678
diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h
index 54d9e54c7c95..124d30e6143b 100644
--- a/fs/xfs/xfs_inode.h
+++ b/fs/xfs/xfs_inode.h
@@ -1,38 +1,30 @@
1/* 1/*
2 * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32#ifndef __XFS_INODE_H__ 18#ifndef __XFS_INODE_H__
33#define __XFS_INODE_H__ 19#define __XFS_INODE_H__
34 20
35/* 21/*
22 * Fork identifiers.
23 */
24#define XFS_DATA_FORK 0
25#define XFS_ATTR_FORK 1
26
27/*
36 * File incore extent information, present for each of data & attr forks. 28 * File incore extent information, present for each of data & attr forks.
37 */ 29 */
38#define XFS_INLINE_EXTS 2 30#define XFS_INLINE_EXTS 2
@@ -107,24 +99,6 @@ extern void xfs_ilock_trace(struct xfs_inode *, int, unsigned int, inst_t *);
107#define xfs_ilock_trace(i,n,f,ra) 99#define xfs_ilock_trace(i,n,f,ra)
108#endif 100#endif
109 101
110/*
111 * This structure is used to communicate which extents of a file
112 * were holes when a write started from xfs_write_file() to
113 * xfs_strat_read(). This is necessary so that we can know which
114 * blocks need to be zeroed when they are read in in xfs_strat_read()
115 * if they weren\'t allocated when the buffer given to xfs_strat_read()
116 * was mapped.
117 *
118 * We keep a list of these attached to the inode. The list is
119 * protected by the inode lock and the fact that the io lock is
120 * held exclusively by writers.
121 */
122typedef struct xfs_gap {
123 struct xfs_gap *xg_next;
124 xfs_fileoff_t xg_offset_fsb;
125 xfs_extlen_t xg_count_fsb;
126} xfs_gap_t;
127
128typedef struct dm_attrs_s { 102typedef struct dm_attrs_s {
129 __uint32_t da_dmevmask; /* DMIG event mask */ 103 __uint32_t da_dmevmask; /* DMIG event mask */
130 __uint16_t da_dmstate; /* DMIG state info */ 104 __uint16_t da_dmstate; /* DMIG state info */
@@ -311,60 +285,16 @@ typedef struct xfs_inode {
311/* 285/*
312 * Fork handling. 286 * Fork handling.
313 */ 287 */
314#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_IFORK_PTR) 288#define XFS_IFORK_PTR(ip,w) \
315xfs_ifork_t *xfs_ifork_ptr(xfs_inode_t *ip, int w); 289 ((w) == XFS_DATA_FORK ? &(ip)->i_df : (ip)->i_afp)
316#define XFS_IFORK_PTR(ip,w) xfs_ifork_ptr(ip,w)
317#else
318#define XFS_IFORK_PTR(ip,w) ((w) == XFS_DATA_FORK ? &(ip)->i_df : (ip)->i_afp)
319#endif
320#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_IFORK_Q)
321int xfs_ifork_q(xfs_inode_t *ip);
322#define XFS_IFORK_Q(ip) xfs_ifork_q(ip)
323#else
324#define XFS_IFORK_Q(ip) XFS_CFORK_Q(&(ip)->i_d) 290#define XFS_IFORK_Q(ip) XFS_CFORK_Q(&(ip)->i_d)
325#endif
326#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_IFORK_DSIZE)
327int xfs_ifork_dsize(xfs_inode_t *ip);
328#define XFS_IFORK_DSIZE(ip) xfs_ifork_dsize(ip)
329#else
330#define XFS_IFORK_DSIZE(ip) XFS_CFORK_DSIZE(&ip->i_d, ip->i_mount) 291#define XFS_IFORK_DSIZE(ip) XFS_CFORK_DSIZE(&ip->i_d, ip->i_mount)
331#endif
332#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_IFORK_ASIZE)
333int xfs_ifork_asize(xfs_inode_t *ip);
334#define XFS_IFORK_ASIZE(ip) xfs_ifork_asize(ip)
335#else
336#define XFS_IFORK_ASIZE(ip) XFS_CFORK_ASIZE(&ip->i_d, ip->i_mount) 292#define XFS_IFORK_ASIZE(ip) XFS_CFORK_ASIZE(&ip->i_d, ip->i_mount)
337#endif
338#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_IFORK_SIZE)
339int xfs_ifork_size(xfs_inode_t *ip, int w);
340#define XFS_IFORK_SIZE(ip,w) xfs_ifork_size(ip,w)
341#else
342#define XFS_IFORK_SIZE(ip,w) XFS_CFORK_SIZE(&ip->i_d, ip->i_mount, w) 293#define XFS_IFORK_SIZE(ip,w) XFS_CFORK_SIZE(&ip->i_d, ip->i_mount, w)
343#endif
344#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_IFORK_FORMAT)
345int xfs_ifork_format(xfs_inode_t *ip, int w);
346#define XFS_IFORK_FORMAT(ip,w) xfs_ifork_format(ip,w)
347#else
348#define XFS_IFORK_FORMAT(ip,w) XFS_CFORK_FORMAT(&ip->i_d, w) 294#define XFS_IFORK_FORMAT(ip,w) XFS_CFORK_FORMAT(&ip->i_d, w)
349#endif
350#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_IFORK_FMT_SET)
351void xfs_ifork_fmt_set(xfs_inode_t *ip, int w, int n);
352#define XFS_IFORK_FMT_SET(ip,w,n) xfs_ifork_fmt_set(ip,w,n)
353#else
354#define XFS_IFORK_FMT_SET(ip,w,n) XFS_CFORK_FMT_SET(&ip->i_d, w, n) 295#define XFS_IFORK_FMT_SET(ip,w,n) XFS_CFORK_FMT_SET(&ip->i_d, w, n)
355#endif
356#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_IFORK_NEXTENTS)
357int xfs_ifork_nextents(xfs_inode_t *ip, int w);
358#define XFS_IFORK_NEXTENTS(ip,w) xfs_ifork_nextents(ip,w)
359#else
360#define XFS_IFORK_NEXTENTS(ip,w) XFS_CFORK_NEXTENTS(&ip->i_d, w) 296#define XFS_IFORK_NEXTENTS(ip,w) XFS_CFORK_NEXTENTS(&ip->i_d, w)
361#endif
362#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_IFORK_NEXT_SET)
363void xfs_ifork_next_set(xfs_inode_t *ip, int w, int n);
364#define XFS_IFORK_NEXT_SET(ip,w,n) xfs_ifork_next_set(ip,w,n)
365#else
366#define XFS_IFORK_NEXT_SET(ip,w,n) XFS_CFORK_NEXT_SET(&ip->i_d, w, n) 297#define XFS_IFORK_NEXT_SET(ip,w,n) XFS_CFORK_NEXT_SET(&ip->i_d, w, n)
367#endif
368 298
369 299
370#ifdef __KERNEL__ 300#ifdef __KERNEL__
@@ -388,6 +318,7 @@ void xfs_ifork_next_set(xfs_inode_t *ip, int w, int n);
388#define XFS_ILOCK_EXCL 0x004 318#define XFS_ILOCK_EXCL 0x004
389#define XFS_ILOCK_SHARED 0x008 319#define XFS_ILOCK_SHARED 0x008
390#define XFS_IUNLOCK_NONOTIFY 0x010 320#define XFS_IUNLOCK_NONOTIFY 0x010
321/* XFS_IOLOCK_NESTED 0x020 */
391#define XFS_EXTENT_TOKEN_RD 0x040 322#define XFS_EXTENT_TOKEN_RD 0x040
392#define XFS_SIZE_TOKEN_RD 0x080 323#define XFS_SIZE_TOKEN_RD 0x080
393#define XFS_EXTSIZE_RD (XFS_EXTENT_TOKEN_RD|XFS_SIZE_TOKEN_RD) 324#define XFS_EXTSIZE_RD (XFS_EXTENT_TOKEN_RD|XFS_SIZE_TOKEN_RD)
@@ -395,7 +326,7 @@ void xfs_ifork_next_set(xfs_inode_t *ip, int w, int n);
395#define XFS_EXTENT_TOKEN_WR (XFS_EXTENT_TOKEN_RD | XFS_WILLLEND) 326#define XFS_EXTENT_TOKEN_WR (XFS_EXTENT_TOKEN_RD | XFS_WILLLEND)
396#define XFS_SIZE_TOKEN_WR (XFS_SIZE_TOKEN_RD | XFS_WILLLEND) 327#define XFS_SIZE_TOKEN_WR (XFS_SIZE_TOKEN_RD | XFS_WILLLEND)
397#define XFS_EXTSIZE_WR (XFS_EXTSIZE_RD | XFS_WILLLEND) 328#define XFS_EXTSIZE_WR (XFS_EXTSIZE_RD | XFS_WILLLEND)
398 329/* XFS_SIZE_TOKEN_WANT 0x200 */
399 330
400#define XFS_LOCK_MASK \ 331#define XFS_LOCK_MASK \
401 (XFS_IOLOCK_EXCL | XFS_IOLOCK_SHARED | XFS_ILOCK_EXCL | \ 332 (XFS_IOLOCK_EXCL | XFS_IOLOCK_SHARED | XFS_ILOCK_EXCL | \
@@ -417,28 +348,11 @@ void xfs_ifork_next_set(xfs_inode_t *ip, int w, int n);
417#define XFS_ITRUNC_DEFINITE 0x1 348#define XFS_ITRUNC_DEFINITE 0x1
418#define XFS_ITRUNC_MAYBE 0x2 349#define XFS_ITRUNC_MAYBE 0x2
419 350
420#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_ITOV)
421struct vnode *xfs_itov(xfs_inode_t *ip);
422#define XFS_ITOV(ip) xfs_itov(ip)
423#else
424#define XFS_ITOV(ip) BHV_TO_VNODE(XFS_ITOBHV(ip)) 351#define XFS_ITOV(ip) BHV_TO_VNODE(XFS_ITOBHV(ip))
425#endif
426#define XFS_ITOV_NULL(ip) BHV_TO_VNODE_NULL(XFS_ITOBHV(ip)) 352#define XFS_ITOV_NULL(ip) BHV_TO_VNODE_NULL(XFS_ITOBHV(ip))
427#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_ITOBHV)
428struct bhv_desc *xfs_itobhv(xfs_inode_t *ip);
429#define XFS_ITOBHV(ip) xfs_itobhv(ip)
430#else
431#define XFS_ITOBHV(ip) ((struct bhv_desc *)(&((ip)->i_bhv_desc))) 353#define XFS_ITOBHV(ip) ((struct bhv_desc *)(&((ip)->i_bhv_desc)))
432#endif 354#define XFS_BHVTOI(bhvp) ((xfs_inode_t *)((char *)(bhvp) - \
433#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BHVTOI) 355 (char *)&(((xfs_inode_t *)0)->i_bhv_desc)))
434xfs_inode_t *xfs_bhvtoi(struct bhv_desc *bhvp);
435#define XFS_BHVTOI(bhvp) xfs_bhvtoi(bhvp)
436#else
437#define XFS_BHVTOI(bhvp) \
438 ((xfs_inode_t *)((char *)(bhvp) - \
439 (char *)&(((xfs_inode_t *)0)->i_bhv_desc)))
440#endif
441
442#define BHV_IS_XFS(bdp) (BHV_OPS(bdp) == &xfs_vnodeops) 356#define BHV_IS_XFS(bdp) (BHV_OPS(bdp) == &xfs_vnodeops)
443 357
444/* 358/*
diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c
index 50e2cadf9091..7f3363c621e1 100644
--- a/fs/xfs/xfs_inode_item.c
+++ b/fs/xfs/xfs_inode_item.c
@@ -1,66 +1,46 @@
1/* 1/*
2 * Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */
32
33/*
34 * This file contains the implementation of the xfs_inode_log_item.
35 * It contains the item operations used to manipulate the inode log
36 * items as well as utility routines used by the inode specific
37 * transaction routines.
38 */ 17 */
39#include "xfs.h" 18#include "xfs.h"
40#include "xfs_macros.h" 19#include "xfs_fs.h"
41#include "xfs_types.h" 20#include "xfs_types.h"
42#include "xfs_inum.h" 21#include "xfs_bit.h"
43#include "xfs_log.h" 22#include "xfs_log.h"
23#include "xfs_inum.h"
44#include "xfs_trans.h" 24#include "xfs_trans.h"
45#include "xfs_buf_item.h" 25#include "xfs_buf_item.h"
46#include "xfs_sb.h" 26#include "xfs_sb.h"
27#include "xfs_ag.h"
47#include "xfs_dir.h" 28#include "xfs_dir.h"
48#include "xfs_dir2.h" 29#include "xfs_dir2.h"
49#include "xfs_dmapi.h" 30#include "xfs_dmapi.h"
50#include "xfs_mount.h" 31#include "xfs_mount.h"
51#include "xfs_trans_priv.h" 32#include "xfs_trans_priv.h"
52#include "xfs_ag.h"
53#include "xfs_alloc_btree.h"
54#include "xfs_bmap_btree.h" 33#include "xfs_bmap_btree.h"
34#include "xfs_alloc_btree.h"
55#include "xfs_ialloc_btree.h" 35#include "xfs_ialloc_btree.h"
56#include "xfs_btree.h"
57#include "xfs_ialloc.h"
58#include "xfs_attr_sf.h"
59#include "xfs_dir_sf.h" 36#include "xfs_dir_sf.h"
60#include "xfs_dir2_sf.h" 37#include "xfs_dir2_sf.h"
38#include "xfs_attr_sf.h"
61#include "xfs_dinode.h" 39#include "xfs_dinode.h"
62#include "xfs_inode_item.h"
63#include "xfs_inode.h" 40#include "xfs_inode.h"
41#include "xfs_inode_item.h"
42#include "xfs_btree.h"
43#include "xfs_ialloc.h"
64#include "xfs_rw.h" 44#include "xfs_rw.h"
65 45
66 46
diff --git a/fs/xfs/xfs_inode_item.h b/fs/xfs/xfs_inode_item.h
index d8775e0d6291..c5dbf93b6661 100644
--- a/fs/xfs/xfs_inode_item.h
+++ b/fs/xfs/xfs_inode_item.h
@@ -1,33 +1,19 @@
1/* 1/*
2 * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32#ifndef __XFS_INODE_ITEM_H__ 18#ifndef __XFS_INODE_ITEM_H__
33#define __XFS_INODE_ITEM_H__ 19#define __XFS_INODE_ITEM_H__
@@ -159,38 +145,33 @@ typedef struct xfs_inode_log_item {
159} xfs_inode_log_item_t; 145} xfs_inode_log_item_t;
160 146
161 147
162#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_ILOG_FDATA)
163int xfs_ilog_fdata(int w);
164#define XFS_ILOG_FDATA(w) xfs_ilog_fdata(w) 148#define XFS_ILOG_FDATA(w) xfs_ilog_fdata(w)
165#else 149static inline int xfs_ilog_fdata(int w)
166#define XFS_ILOG_FDATA(w) \ 150{
167 ((w) == XFS_DATA_FORK ? XFS_ILOG_DDATA : XFS_ILOG_ADATA) 151 return (w == XFS_DATA_FORK ? XFS_ILOG_DDATA : XFS_ILOG_ADATA);
168#endif 152}
169 153
170#endif /* __KERNEL__ */ 154#endif /* __KERNEL__ */
171 155
172#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_ILOG_FBROOT)
173int xfs_ilog_fbroot(int w);
174#define XFS_ILOG_FBROOT(w) xfs_ilog_fbroot(w) 156#define XFS_ILOG_FBROOT(w) xfs_ilog_fbroot(w)
175#else 157static inline int xfs_ilog_fbroot(int w)
176#define XFS_ILOG_FBROOT(w) \ 158{
177 ((w) == XFS_DATA_FORK ? XFS_ILOG_DBROOT : XFS_ILOG_ABROOT) 159 return (w == XFS_DATA_FORK ? XFS_ILOG_DBROOT : XFS_ILOG_ABROOT);
178#endif 160}
179#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_ILOG_FEXT) 161
180int xfs_ilog_fext(int w);
181#define XFS_ILOG_FEXT(w) xfs_ilog_fext(w) 162#define XFS_ILOG_FEXT(w) xfs_ilog_fext(w)
182#else 163static inline int xfs_ilog_fext(int w)
183#define XFS_ILOG_FEXT(w) \ 164{
184 ((w) == XFS_DATA_FORK ? XFS_ILOG_DEXT : XFS_ILOG_AEXT) 165 return (w == XFS_DATA_FORK ? XFS_ILOG_DEXT : XFS_ILOG_AEXT);
185#endif 166}
186 167
187#ifdef __KERNEL__ 168#ifdef __KERNEL__
188 169
189void xfs_inode_item_init(struct xfs_inode *, struct xfs_mount *); 170extern void xfs_inode_item_init(struct xfs_inode *, struct xfs_mount *);
190void xfs_inode_item_destroy(struct xfs_inode *); 171extern void xfs_inode_item_destroy(struct xfs_inode *);
191void xfs_iflush_done(struct xfs_buf *, xfs_inode_log_item_t *); 172extern void xfs_iflush_done(struct xfs_buf *, xfs_inode_log_item_t *);
192void xfs_istale_done(struct xfs_buf *, xfs_inode_log_item_t *); 173extern void xfs_istale_done(struct xfs_buf *, xfs_inode_log_item_t *);
193void xfs_iflush_abort(struct xfs_inode *); 174extern void xfs_iflush_abort(struct xfs_inode *);
194 175
195#endif /* __KERNEL__ */ 176#endif /* __KERNEL__ */
196 177
diff --git a/fs/xfs/xfs_inum.h b/fs/xfs/xfs_inum.h
index a3af2d5a6eb7..7a28191cb0de 100644
--- a/fs/xfs/xfs_inum.h
+++ b/fs/xfs/xfs_inum.h
@@ -1,33 +1,19 @@
1/* 1/*
2 * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32#ifndef __XFS_INUM_H__ 18#ifndef __XFS_INUM_H__
33#define __XFS_INUM_H__ 19#define __XFS_INUM_H__
@@ -58,109 +44,31 @@ typedef __uint32_t xfs_intino_t;
58 44
59struct xfs_mount; 45struct xfs_mount;
60 46
61#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_INO_MASK) 47#define XFS_INO_MASK(k) (__uint32_t)((1ULL << (k)) - 1)
62__uint32_t xfs_ino_mask(int k); 48#define XFS_INO_OFFSET_BITS(mp) (mp)->m_sb.sb_inopblog
63#define XFS_INO_MASK(k) xfs_ino_mask(k) 49#define XFS_INO_AGBNO_BITS(mp) (mp)->m_sb.sb_agblklog
64#else 50#define XFS_INO_AGINO_BITS(mp) (mp)->m_agino_log
65#define XFS_INO_MASK(k) ((__uint32_t)((1ULL << (k)) - 1)) 51#define XFS_INO_AGNO_BITS(mp) (mp)->m_agno_log
66#endif 52#define XFS_INO_BITS(mp) \
67#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_INO_OFFSET_BITS) 53 XFS_INO_AGNO_BITS(mp) + XFS_INO_AGINO_BITS(mp)
68int xfs_ino_offset_bits(struct xfs_mount *mp); 54#define XFS_INO_TO_AGNO(mp,i) \
69#define XFS_INO_OFFSET_BITS(mp) xfs_ino_offset_bits(mp)
70#else
71#define XFS_INO_OFFSET_BITS(mp) ((mp)->m_sb.sb_inopblog)
72#endif
73#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_INO_AGBNO_BITS)
74int xfs_ino_agbno_bits(struct xfs_mount *mp);
75#define XFS_INO_AGBNO_BITS(mp) xfs_ino_agbno_bits(mp)
76#else
77#define XFS_INO_AGBNO_BITS(mp) ((mp)->m_sb.sb_agblklog)
78#endif
79#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_INO_AGINO_BITS)
80int xfs_ino_agino_bits(struct xfs_mount *mp);
81#define XFS_INO_AGINO_BITS(mp) xfs_ino_agino_bits(mp)
82#else
83#define XFS_INO_AGINO_BITS(mp) ((mp)->m_agino_log)
84#endif
85#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_INO_AGNO_BITS)
86int xfs_ino_agno_bits(struct xfs_mount *mp);
87#define XFS_INO_AGNO_BITS(mp) xfs_ino_agno_bits(mp)
88#else
89#define XFS_INO_AGNO_BITS(mp) ((mp)->m_agno_log)
90#endif
91#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_INO_BITS)
92int xfs_ino_bits(struct xfs_mount *mp);
93#define XFS_INO_BITS(mp) xfs_ino_bits(mp)
94#else
95#define XFS_INO_BITS(mp) (XFS_INO_AGNO_BITS(mp) + XFS_INO_AGINO_BITS(mp))
96#endif
97
98#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_INO_TO_AGNO)
99xfs_agnumber_t xfs_ino_to_agno(struct xfs_mount *mp, xfs_ino_t i);
100#define XFS_INO_TO_AGNO(mp,i) xfs_ino_to_agno(mp,i)
101#else
102#define XFS_INO_TO_AGNO(mp,i) \
103 ((xfs_agnumber_t)((i) >> XFS_INO_AGINO_BITS(mp))) 55 ((xfs_agnumber_t)((i) >> XFS_INO_AGINO_BITS(mp)))
104#endif 56#define XFS_INO_TO_AGINO(mp,i) \
105#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_INO_TO_AGINO)
106xfs_agino_t xfs_ino_to_agino(struct xfs_mount *mp, xfs_ino_t i);
107#define XFS_INO_TO_AGINO(mp,i) xfs_ino_to_agino(mp,i)
108#else
109#define XFS_INO_TO_AGINO(mp,i) \
110 ((xfs_agino_t)(i) & XFS_INO_MASK(XFS_INO_AGINO_BITS(mp))) 57 ((xfs_agino_t)(i) & XFS_INO_MASK(XFS_INO_AGINO_BITS(mp)))
111#endif 58#define XFS_INO_TO_AGBNO(mp,i) \
112#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_INO_TO_AGBNO)
113xfs_agblock_t xfs_ino_to_agbno(struct xfs_mount *mp, xfs_ino_t i);
114#define XFS_INO_TO_AGBNO(mp,i) xfs_ino_to_agbno(mp,i)
115#else
116#define XFS_INO_TO_AGBNO(mp,i) \
117 (((xfs_agblock_t)(i) >> XFS_INO_OFFSET_BITS(mp)) & \ 59 (((xfs_agblock_t)(i) >> XFS_INO_OFFSET_BITS(mp)) & \
118 XFS_INO_MASK(XFS_INO_AGBNO_BITS(mp))) 60 XFS_INO_MASK(XFS_INO_AGBNO_BITS(mp)))
119#endif 61#define XFS_INO_TO_OFFSET(mp,i) \
120#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_INO_TO_OFFSET)
121int xfs_ino_to_offset(struct xfs_mount *mp, xfs_ino_t i);
122#define XFS_INO_TO_OFFSET(mp,i) xfs_ino_to_offset(mp,i)
123#else
124#define XFS_INO_TO_OFFSET(mp,i) \
125 ((int)(i) & XFS_INO_MASK(XFS_INO_OFFSET_BITS(mp))) 62 ((int)(i) & XFS_INO_MASK(XFS_INO_OFFSET_BITS(mp)))
126#endif 63#define XFS_INO_TO_FSB(mp,i) \
127#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_INO_TO_FSB)
128xfs_fsblock_t xfs_ino_to_fsb(struct xfs_mount *mp, xfs_ino_t i);
129#define XFS_INO_TO_FSB(mp,i) xfs_ino_to_fsb(mp,i)
130#else
131#define XFS_INO_TO_FSB(mp,i) \
132 XFS_AGB_TO_FSB(mp, XFS_INO_TO_AGNO(mp,i), XFS_INO_TO_AGBNO(mp,i)) 64 XFS_AGB_TO_FSB(mp, XFS_INO_TO_AGNO(mp,i), XFS_INO_TO_AGBNO(mp,i))
133#endif
134
135#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_AGINO_TO_INO)
136xfs_ino_t
137xfs_agino_to_ino(struct xfs_mount *mp, xfs_agnumber_t a, xfs_agino_t i);
138#define XFS_AGINO_TO_INO(mp,a,i) xfs_agino_to_ino(mp,a,i)
139#else
140#define XFS_AGINO_TO_INO(mp,a,i) \ 65#define XFS_AGINO_TO_INO(mp,a,i) \
141 (((xfs_ino_t)(a) << XFS_INO_AGINO_BITS(mp)) | (i)) 66 (((xfs_ino_t)(a) << XFS_INO_AGINO_BITS(mp)) | (i))
142#endif
143#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_AGINO_TO_AGBNO)
144xfs_agblock_t xfs_agino_to_agbno(struct xfs_mount *mp, xfs_agino_t i);
145#define XFS_AGINO_TO_AGBNO(mp,i) xfs_agino_to_agbno(mp,i)
146#else
147#define XFS_AGINO_TO_AGBNO(mp,i) ((i) >> XFS_INO_OFFSET_BITS(mp)) 67#define XFS_AGINO_TO_AGBNO(mp,i) ((i) >> XFS_INO_OFFSET_BITS(mp))
148#endif
149#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_AGINO_TO_OFFSET)
150int xfs_agino_to_offset(struct xfs_mount *mp, xfs_agino_t i);
151#define XFS_AGINO_TO_OFFSET(mp,i) xfs_agino_to_offset(mp,i)
152#else
153#define XFS_AGINO_TO_OFFSET(mp,i) \ 68#define XFS_AGINO_TO_OFFSET(mp,i) \
154 ((i) & XFS_INO_MASK(XFS_INO_OFFSET_BITS(mp))) 69 ((i) & XFS_INO_MASK(XFS_INO_OFFSET_BITS(mp)))
155#endif
156
157#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_OFFBNO_TO_AGINO)
158xfs_agino_t xfs_offbno_to_agino(struct xfs_mount *mp, xfs_agblock_t b, int o);
159#define XFS_OFFBNO_TO_AGINO(mp,b,o) xfs_offbno_to_agino(mp,b,o)
160#else
161#define XFS_OFFBNO_TO_AGINO(mp,b,o) \ 70#define XFS_OFFBNO_TO_AGINO(mp,b,o) \
162 ((xfs_agino_t)(((b) << XFS_INO_OFFSET_BITS(mp)) | (o))) 71 ((xfs_agino_t)(((b) << XFS_INO_OFFSET_BITS(mp)) | (o)))
163#endif
164 72
165#if XFS_BIG_INUMS 73#if XFS_BIG_INUMS
166#define XFS_MAXINUMBER ((xfs_ino_t)((1ULL << 56) - 1ULL)) 74#define XFS_MAXINUMBER ((xfs_ino_t)((1ULL << 56) - 1ULL))
diff --git a/fs/xfs/xfs_iocore.c b/fs/xfs/xfs_iocore.c
index 414ec496845f..a07815661a8c 100644
--- a/fs/xfs/xfs_iocore.c
+++ b/fs/xfs/xfs_iocore.c
@@ -1,40 +1,26 @@
1/* 1/*
2 * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32
33#include "xfs.h" 18#include "xfs.h"
34#include "xfs_macros.h" 19#include "xfs_fs.h"
35#include "xfs_types.h" 20#include "xfs_types.h"
36#include "xfs_inum.h" 21#include "xfs_bit.h"
37#include "xfs_log.h" 22#include "xfs_log.h"
23#include "xfs_inum.h"
38#include "xfs_trans.h" 24#include "xfs_trans.h"
39#include "xfs_sb.h" 25#include "xfs_sb.h"
40#include "xfs_ag.h" 26#include "xfs_ag.h"
@@ -42,22 +28,21 @@
42#include "xfs_dir2.h" 28#include "xfs_dir2.h"
43#include "xfs_dmapi.h" 29#include "xfs_dmapi.h"
44#include "xfs_mount.h" 30#include "xfs_mount.h"
45#include "xfs_alloc_btree.h"
46#include "xfs_bmap_btree.h" 31#include "xfs_bmap_btree.h"
32#include "xfs_alloc_btree.h"
47#include "xfs_ialloc_btree.h" 33#include "xfs_ialloc_btree.h"
48#include "xfs_itable.h"
49#include "xfs_btree.h"
50#include "xfs_alloc.h"
51#include "xfs_ialloc.h"
52#include "xfs_attr_sf.h"
53#include "xfs_dir_sf.h" 34#include "xfs_dir_sf.h"
54#include "xfs_dir2_sf.h" 35#include "xfs_dir2_sf.h"
36#include "xfs_attr_sf.h"
55#include "xfs_dinode.h" 37#include "xfs_dinode.h"
56#include "xfs_inode_item.h"
57#include "xfs_inode.h" 38#include "xfs_inode.h"
39#include "xfs_inode_item.h"
40#include "xfs_itable.h"
41#include "xfs_btree.h"
42#include "xfs_alloc.h"
43#include "xfs_ialloc.h"
58#include "xfs_bmap.h" 44#include "xfs_bmap.h"
59#include "xfs_error.h" 45#include "xfs_error.h"
60#include "xfs_bit.h"
61#include "xfs_rw.h" 46#include "xfs_rw.h"
62#include "xfs_quota.h" 47#include "xfs_quota.h"
63#include "xfs_trans_space.h" 48#include "xfs_trans_space.h"
diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c
index d0f5be63cddb..45a77a3a6c07 100644
--- a/fs/xfs/xfs_iomap.c
+++ b/fs/xfs/xfs_iomap.c
@@ -1,40 +1,25 @@
1/* 1/*
2 * Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32
33#include "xfs.h" 18#include "xfs.h"
34
35#include "xfs_fs.h" 19#include "xfs_fs.h"
36#include "xfs_inum.h" 20#include "xfs_bit.h"
37#include "xfs_log.h" 21#include "xfs_log.h"
22#include "xfs_inum.h"
38#include "xfs_trans.h" 23#include "xfs_trans.h"
39#include "xfs_sb.h" 24#include "xfs_sb.h"
40#include "xfs_ag.h" 25#include "xfs_ag.h"
@@ -44,16 +29,16 @@
44#include "xfs_dmapi.h" 29#include "xfs_dmapi.h"
45#include "xfs_quota.h" 30#include "xfs_quota.h"
46#include "xfs_mount.h" 31#include "xfs_mount.h"
47#include "xfs_alloc_btree.h"
48#include "xfs_bmap_btree.h" 32#include "xfs_bmap_btree.h"
33#include "xfs_alloc_btree.h"
49#include "xfs_ialloc_btree.h" 34#include "xfs_ialloc_btree.h"
50#include "xfs_btree.h"
51#include "xfs_ialloc.h"
52#include "xfs_attr_sf.h"
53#include "xfs_dir_sf.h" 35#include "xfs_dir_sf.h"
54#include "xfs_dir2_sf.h" 36#include "xfs_dir2_sf.h"
37#include "xfs_attr_sf.h"
55#include "xfs_dinode.h" 38#include "xfs_dinode.h"
56#include "xfs_inode.h" 39#include "xfs_inode.h"
40#include "xfs_ialloc.h"
41#include "xfs_btree.h"
57#include "xfs_bmap.h" 42#include "xfs_bmap.h"
58#include "xfs_bit.h" 43#include "xfs_bit.h"
59#include "xfs_rtalloc.h" 44#include "xfs_rtalloc.h"
@@ -379,17 +364,15 @@ xfs_iomap_write_direct(
379 xfs_fileoff_t offset_fsb; 364 xfs_fileoff_t offset_fsb;
380 xfs_fileoff_t last_fsb; 365 xfs_fileoff_t last_fsb;
381 xfs_filblks_t count_fsb; 366 xfs_filblks_t count_fsb;
382 xfs_fsize_t isize;
383 xfs_fsblock_t firstfsb; 367 xfs_fsblock_t firstfsb;
384 int nimaps, maps; 368 int nimaps;
385 int error; 369 int error;
386 int bmapi_flag; 370 int bmapi_flag;
387 int quota_flag; 371 int quota_flag;
388 int rt; 372 int rt;
389 xfs_trans_t *tp; 373 xfs_trans_t *tp;
390 xfs_bmbt_irec_t imap[XFS_WRITE_IMAPS], *imapp; 374 xfs_bmbt_irec_t imap;
391 xfs_bmap_free_t free_list; 375 xfs_bmap_free_t free_list;
392 int aeof;
393 xfs_filblks_t qblocks, resblks; 376 xfs_filblks_t qblocks, resblks;
394 int committed; 377 int committed;
395 int resrtextents; 378 int resrtextents;
@@ -402,15 +385,6 @@ xfs_iomap_write_direct(
402 if (error) 385 if (error)
403 return XFS_ERROR(error); 386 return XFS_ERROR(error);
404 387
405 maps = min(XFS_WRITE_IMAPS, *nmaps);
406 nimaps = maps;
407
408 isize = ip->i_d.di_size;
409 aeof = (offset + count) > isize;
410
411 if (io->io_new_size > isize)
412 isize = io->io_new_size;
413
414 offset_fsb = XFS_B_TO_FSBT(mp, offset); 388 offset_fsb = XFS_B_TO_FSBT(mp, offset);
415 last_fsb = XFS_B_TO_FSB(mp, ((xfs_ufsize_t)(offset + count))); 389 last_fsb = XFS_B_TO_FSB(mp, ((xfs_ufsize_t)(offset + count)));
416 count_fsb = last_fsb - offset_fsb; 390 count_fsb = last_fsb - offset_fsb;
@@ -479,9 +453,8 @@ xfs_iomap_write_direct(
479 */ 453 */
480 XFS_BMAP_INIT(&free_list, &firstfsb); 454 XFS_BMAP_INIT(&free_list, &firstfsb);
481 nimaps = 1; 455 nimaps = 1;
482 imapp = &imap[0];
483 error = xfs_bmapi(tp, ip, offset_fsb, count_fsb, 456 error = xfs_bmapi(tp, ip, offset_fsb, count_fsb,
484 bmapi_flag, &firstfsb, 0, imapp, &nimaps, &free_list); 457 bmapi_flag, &firstfsb, 0, &imap, &nimaps, &free_list);
485 if (error) 458 if (error)
486 goto error0; 459 goto error0;
487 460
@@ -503,7 +476,7 @@ xfs_iomap_write_direct(
503 goto error_out; 476 goto error_out;
504 } 477 }
505 478
506 *ret_imap = imap[0]; 479 *ret_imap = imap;
507 *nmaps = 1; 480 *nmaps = 1;
508 if ( !(io->io_flags & XFS_IOCORE_RT) && !ret_imap->br_startblock) { 481 if ( !(io->io_flags & XFS_IOCORE_RT) && !ret_imap->br_startblock) {
509 cmn_err(CE_PANIC,"Access to block zero: fs <%s> inode: %lld " 482 cmn_err(CE_PANIC,"Access to block zero: fs <%s> inode: %lld "
diff --git a/fs/xfs/xfs_iomap.h b/fs/xfs/xfs_iomap.h
index 4daaa5212102..fcd6d63bb68b 100644
--- a/fs/xfs/xfs_iomap.h
+++ b/fs/xfs/xfs_iomap.h
@@ -1,33 +1,19 @@
1/* 1/*
2 * Copyright (c) 2003-2005 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2003-2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32#ifndef __XFS_IOMAP_H__ 18#ifndef __XFS_IOMAP_H__
33#define __XFS_IOMAP_H__ 19#define __XFS_IOMAP_H__
diff --git a/fs/xfs/xfs_itable.c b/fs/xfs/xfs_itable.c
index 8fbc8d378188..f63646ead816 100644
--- a/fs/xfs/xfs_itable.c
+++ b/fs/xfs/xfs_itable.c
@@ -1,59 +1,45 @@
1/* 1/*
2 * Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32
33#include "xfs.h" 18#include "xfs.h"
34#include "xfs_macros.h" 19#include "xfs_fs.h"
35#include "xfs_types.h" 20#include "xfs_types.h"
36#include "xfs_inum.h" 21#include "xfs_bit.h"
37#include "xfs_log.h" 22#include "xfs_log.h"
23#include "xfs_inum.h"
38#include "xfs_trans.h" 24#include "xfs_trans.h"
39#include "xfs_sb.h" 25#include "xfs_sb.h"
26#include "xfs_ag.h"
40#include "xfs_dir.h" 27#include "xfs_dir.h"
41#include "xfs_dir2.h" 28#include "xfs_dir2.h"
42#include "xfs_dmapi.h" 29#include "xfs_dmapi.h"
43#include "xfs_mount.h" 30#include "xfs_mount.h"
44#include "xfs_ag.h"
45#include "xfs_alloc_btree.h"
46#include "xfs_bmap_btree.h" 31#include "xfs_bmap_btree.h"
32#include "xfs_alloc_btree.h"
47#include "xfs_ialloc_btree.h" 33#include "xfs_ialloc_btree.h"
48#include "xfs_btree.h"
49#include "xfs_attr_sf.h"
50#include "xfs_dir_sf.h" 34#include "xfs_dir_sf.h"
51#include "xfs_dir2_sf.h" 35#include "xfs_dir2_sf.h"
36#include "xfs_attr_sf.h"
52#include "xfs_dinode.h" 37#include "xfs_dinode.h"
53#include "xfs_inode.h" 38#include "xfs_inode.h"
54#include "xfs_ialloc.h" 39#include "xfs_ialloc.h"
55#include "xfs_itable.h" 40#include "xfs_itable.h"
56#include "xfs_error.h" 41#include "xfs_error.h"
42#include "xfs_btree.h"
57 43
58#ifndef HAVE_USERACC 44#ifndef HAVE_USERACC
59#define useracc(ubuffer, size, flags, foo) (0) 45#define useracc(ubuffer, size, flags, foo) (0)
@@ -462,7 +448,7 @@ xfs_bulkstat(
462 while (error) { 448 while (error) {
463 agino += XFS_INODES_PER_CHUNK; 449 agino += XFS_INODES_PER_CHUNK;
464 if (XFS_AGINO_TO_AGBNO(mp, agino) >= 450 if (XFS_AGINO_TO_AGBNO(mp, agino) >=
465 INT_GET(agi->agi_length, ARCH_CONVERT)) 451 be32_to_cpu(agi->agi_length))
466 break; 452 break;
467 error = xfs_inobt_lookup_ge(cur, agino, 0, 0, 453 error = xfs_inobt_lookup_ge(cur, agino, 0, 0,
468 &tmp); 454 &tmp);
diff --git a/fs/xfs/xfs_itable.h b/fs/xfs/xfs_itable.h
index 2be9d1805ab2..047d834ed210 100644
--- a/fs/xfs/xfs_itable.h
+++ b/fs/xfs/xfs_itable.h
@@ -1,33 +1,18 @@
1/* 1/*
2 * Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved.
3 * 3 *
4 * This program is free software; you can redistribute it and/or modify it 4 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 6 * published by the Free Software Foundation.
7 * 7 *
8 * This program is distributed in the hope that it would be useful, but 8 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
11 * 12 *
12 * Further, this software is distributed without any warranty that it is 13 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 14 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 15 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 16 */
32#ifndef __XFS_ITABLE_H__ 17#ifndef __XFS_ITABLE_H__
33#define __XFS_ITABLE_H__ 18#define __XFS_ITABLE_H__
diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c
index 54a6f1142403..29af51275ca9 100644
--- a/fs/xfs/xfs_log.c
+++ b/fs/xfs/xfs_log.c
@@ -1,58 +1,47 @@
1/* 1/*
2 * Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32
33/*
34 * High level interface routines for log manager
35 */
36
37#include "xfs.h" 18#include "xfs.h"
38#include "xfs_macros.h" 19#include "xfs_fs.h"
39#include "xfs_types.h" 20#include "xfs_types.h"
40#include "xfs_inum.h" 21#include "xfs_bit.h"
41#include "xfs_ag.h"
42#include "xfs_sb.h"
43#include "xfs_log.h" 22#include "xfs_log.h"
23#include "xfs_inum.h"
44#include "xfs_trans.h" 24#include "xfs_trans.h"
25#include "xfs_sb.h"
26#include "xfs_ag.h"
45#include "xfs_dir.h" 27#include "xfs_dir.h"
28#include "xfs_dir2.h"
46#include "xfs_dmapi.h" 29#include "xfs_dmapi.h"
47#include "xfs_mount.h" 30#include "xfs_mount.h"
48#include "xfs_error.h" 31#include "xfs_error.h"
49#include "xfs_log_priv.h" 32#include "xfs_log_priv.h"
50#include "xfs_buf_item.h" 33#include "xfs_buf_item.h"
34#include "xfs_bmap_btree.h"
51#include "xfs_alloc_btree.h" 35#include "xfs_alloc_btree.h"
36#include "xfs_ialloc_btree.h"
52#include "xfs_log_recover.h" 37#include "xfs_log_recover.h"
53#include "xfs_bit.h"
54#include "xfs_rw.h"
55#include "xfs_trans_priv.h" 38#include "xfs_trans_priv.h"
39#include "xfs_dir_sf.h"
40#include "xfs_dir2_sf.h"
41#include "xfs_attr_sf.h"
42#include "xfs_dinode.h"
43#include "xfs_inode.h"
44#include "xfs_rw.h"
56 45
57 46
58#define xlog_write_adv_cnt(ptr, len, off, bytes) \ 47#define xlog_write_adv_cnt(ptr, len, off, bytes) \
@@ -93,8 +82,11 @@ STATIC int xlog_state_release_iclog(xlog_t *log,
93STATIC void xlog_state_switch_iclogs(xlog_t *log, 82STATIC void xlog_state_switch_iclogs(xlog_t *log,
94 xlog_in_core_t *iclog, 83 xlog_in_core_t *iclog,
95 int eventual_size); 84 int eventual_size);
96STATIC int xlog_state_sync(xlog_t *log, xfs_lsn_t lsn, uint flags); 85STATIC int xlog_state_sync(xlog_t *log,
97STATIC int xlog_state_sync_all(xlog_t *log, uint flags); 86 xfs_lsn_t lsn,
87 uint flags,
88 int *log_flushed);
89STATIC int xlog_state_sync_all(xlog_t *log, uint flags, int *log_flushed);
98STATIC void xlog_state_want_sync(xlog_t *log, xlog_in_core_t *iclog); 90STATIC void xlog_state_want_sync(xlog_t *log, xlog_in_core_t *iclog);
99 91
100/* local functions to manipulate grant head */ 92/* local functions to manipulate grant head */
@@ -119,8 +111,7 @@ STATIC xlog_ticket_t *xlog_ticket_get(xlog_t *log,
119 uint flags); 111 uint flags);
120STATIC void xlog_ticket_put(xlog_t *log, xlog_ticket_t *ticket); 112STATIC void xlog_ticket_put(xlog_t *log, xlog_ticket_t *ticket);
121 113
122/* local debug functions */ 114#if defined(DEBUG)
123#if defined(DEBUG) && !defined(XLOG_NOLOG)
124STATIC void xlog_verify_dest_ptr(xlog_t *log, __psint_t ptr); 115STATIC void xlog_verify_dest_ptr(xlog_t *log, __psint_t ptr);
125STATIC void xlog_verify_grant_head(xlog_t *log, int equals); 116STATIC void xlog_verify_grant_head(xlog_t *log, int equals);
126STATIC void xlog_verify_iclog(xlog_t *log, xlog_in_core_t *iclog, 117STATIC void xlog_verify_iclog(xlog_t *log, xlog_in_core_t *iclog,
@@ -136,26 +127,7 @@ STATIC void xlog_verify_tail_lsn(xlog_t *log, xlog_in_core_t *iclog,
136 127
137STATIC int xlog_iclogs_empty(xlog_t *log); 128STATIC int xlog_iclogs_empty(xlog_t *log);
138 129
139#ifdef DEBUG
140int xlog_do_error = 0;
141int xlog_req_num = 0;
142int xlog_error_mod = 33;
143#endif
144
145#define XLOG_FORCED_SHUTDOWN(log) (log->l_flags & XLOG_IO_ERROR)
146
147/*
148 * 0 => disable log manager
149 * 1 => enable log manager
150 * 2 => enable log manager and log debugging
151 */
152#if defined(XLOG_NOLOG) || defined(DEBUG)
153int xlog_debug = 1;
154xfs_buftarg_t *xlog_target;
155#endif
156
157#if defined(XFS_LOG_TRACE) 130#if defined(XFS_LOG_TRACE)
158
159void 131void
160xlog_trace_loggrant(xlog_t *log, xlog_ticket_t *tic, xfs_caddr_t string) 132xlog_trace_loggrant(xlog_t *log, xlog_ticket_t *tic, xfs_caddr_t string)
161{ 133{
@@ -191,31 +163,16 @@ xlog_trace_loggrant(xlog_t *log, xlog_ticket_t *tic, xfs_caddr_t string)
191void 163void
192xlog_trace_iclog(xlog_in_core_t *iclog, uint state) 164xlog_trace_iclog(xlog_in_core_t *iclog, uint state)
193{ 165{
194 pid_t pid;
195
196 pid = current_pid();
197
198 if (!iclog->ic_trace) 166 if (!iclog->ic_trace)
199 iclog->ic_trace = ktrace_alloc(256, KM_SLEEP); 167 iclog->ic_trace = ktrace_alloc(256, KM_SLEEP);
200 ktrace_enter(iclog->ic_trace, 168 ktrace_enter(iclog->ic_trace,
201 (void *)((unsigned long)state), 169 (void *)((unsigned long)state),
202 (void *)((unsigned long)pid), 170 (void *)((unsigned long)current_pid()),
203 (void *)0, 171 (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL,
204 (void *)0, 172 (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL,
205 (void *)0, 173 (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL,
206 (void *)0, 174 (void *)NULL, (void *)NULL);
207 (void *)0,
208 (void *)0,
209 (void *)0,
210 (void *)0,
211 (void *)0,
212 (void *)0,
213 (void *)0,
214 (void *)0,
215 (void *)0,
216 (void *)0);
217} 175}
218
219#else 176#else
220#define xlog_trace_loggrant(log,tic,string) 177#define xlog_trace_loggrant(log,tic,string)
221#define xlog_trace_iclog(iclog,state) 178#define xlog_trace_iclog(iclog,state)
@@ -252,11 +209,6 @@ xfs_log_done(xfs_mount_t *mp,
252 xlog_ticket_t *ticket = (xfs_log_ticket_t) xtic; 209 xlog_ticket_t *ticket = (xfs_log_ticket_t) xtic;
253 xfs_lsn_t lsn = 0; 210 xfs_lsn_t lsn = 0;
254 211
255#if defined(DEBUG) || defined(XLOG_NOLOG)
256 if (!xlog_debug && xlog_target == log->l_targ)
257 return 0;
258#endif
259
260 if (XLOG_FORCED_SHUTDOWN(log) || 212 if (XLOG_FORCED_SHUTDOWN(log) ||
261 /* 213 /*
262 * If nothing was ever written, don't write out commit record. 214 * If nothing was ever written, don't write out commit record.
@@ -312,33 +264,28 @@ xfs_log_done(xfs_mount_t *mp,
312 * semaphore. 264 * semaphore.
313 */ 265 */
314int 266int
315xfs_log_force(xfs_mount_t *mp, 267_xfs_log_force(
316 xfs_lsn_t lsn, 268 xfs_mount_t *mp,
317 uint flags) 269 xfs_lsn_t lsn,
270 uint flags,
271 int *log_flushed)
318{ 272{
319 int rval; 273 xlog_t *log = mp->m_log;
320 xlog_t *log = mp->m_log; 274 int dummy;
321 275
322#if defined(DEBUG) || defined(XLOG_NOLOG) 276 if (!log_flushed)
323 if (!xlog_debug && xlog_target == log->l_targ) 277 log_flushed = &dummy;
324 return 0;
325#endif
326 278
327 ASSERT(flags & XFS_LOG_FORCE); 279 ASSERT(flags & XFS_LOG_FORCE);
328 280
329 XFS_STATS_INC(xs_log_force); 281 XFS_STATS_INC(xs_log_force);
330 282
331 if ((log->l_flags & XLOG_IO_ERROR) == 0) { 283 if (log->l_flags & XLOG_IO_ERROR)
332 if (lsn == 0) 284 return XFS_ERROR(EIO);
333 rval = xlog_state_sync_all(log, flags); 285 if (lsn == 0)
334 else 286 return xlog_state_sync_all(log, flags, log_flushed);
335 rval = xlog_state_sync(log, lsn, flags); 287 else
336 } else { 288 return xlog_state_sync(log, lsn, flags, log_flushed);
337 rval = XFS_ERROR(EIO);
338 }
339
340 return rval;
341
342} /* xfs_log_force */ 289} /* xfs_log_force */
343 290
344/* 291/*
@@ -356,10 +303,6 @@ xfs_log_notify(xfs_mount_t *mp, /* mount of partition */
356 xlog_in_core_t *iclog = (xlog_in_core_t *)iclog_hndl; 303 xlog_in_core_t *iclog = (xlog_in_core_t *)iclog_hndl;
357 int abortflg, spl; 304 int abortflg, spl;
358 305
359#if defined(DEBUG) || defined(XLOG_NOLOG)
360 if (!xlog_debug && xlog_target == log->l_targ)
361 return 0;
362#endif
363 cb->cb_next = NULL; 306 cb->cb_next = NULL;
364 spl = LOG_LOCK(log); 307 spl = LOG_LOCK(log);
365 abortflg = (iclog->ic_state & XLOG_STATE_IOERROR); 308 abortflg = (iclog->ic_state & XLOG_STATE_IOERROR);
@@ -410,13 +353,8 @@ xfs_log_reserve(xfs_mount_t *mp,
410{ 353{
411 xlog_t *log = mp->m_log; 354 xlog_t *log = mp->m_log;
412 xlog_ticket_t *internal_ticket; 355 xlog_ticket_t *internal_ticket;
413 int retval; 356 int retval = 0;
414 357
415#if defined(DEBUG) || defined(XLOG_NOLOG)
416 if (!xlog_debug && xlog_target == log->l_targ)
417 return 0;
418#endif
419 retval = 0;
420 ASSERT(client == XFS_TRANSACTION || client == XFS_LOG); 358 ASSERT(client == XFS_TRANSACTION || client == XFS_LOG);
421 ASSERT((flags & XFS_LOG_NOSLEEP) == 0); 359 ASSERT((flags & XFS_LOG_NOSLEEP) == 0);
422 360
@@ -478,12 +416,6 @@ xfs_log_mount(xfs_mount_t *mp,
478 416
479 mp->m_log = xlog_alloc_log(mp, log_target, blk_offset, num_bblks); 417 mp->m_log = xlog_alloc_log(mp, log_target, blk_offset, num_bblks);
480 418
481#if defined(DEBUG) || defined(XLOG_NOLOG)
482 if (!xlog_debug) {
483 cmn_err(CE_NOTE, "log dev: %s", XFS_BUFTARG_NAME(log_target));
484 return 0;
485 }
486#endif
487 /* 419 /*
488 * skip log recovery on a norecovery mount. pretend it all 420 * skip log recovery on a norecovery mount. pretend it all
489 * just worked. 421 * just worked.
@@ -587,11 +519,6 @@ xfs_log_unmount_write(xfs_mount_t *mp)
587 __uint32_t pad2; /* may as well make it 64 bits */ 519 __uint32_t pad2; /* may as well make it 64 bits */
588 } magic = { XLOG_UNMOUNT_TYPE, 0, 0 }; 520 } magic = { XLOG_UNMOUNT_TYPE, 0, 0 };
589 521
590#if defined(DEBUG) || defined(XLOG_NOLOG)
591 if (!xlog_debug && xlog_target == log->l_targ)
592 return 0;
593#endif
594
595 /* 522 /*
596 * Don't write out unmount record on read-only mounts. 523 * Don't write out unmount record on read-only mounts.
597 * Or, if we are doing a forced umount (typically because of IO errors). 524 * Or, if we are doing a forced umount (typically because of IO errors).
@@ -718,12 +645,6 @@ xfs_log_write(xfs_mount_t * mp,
718 int error; 645 int error;
719 xlog_t *log = mp->m_log; 646 xlog_t *log = mp->m_log;
720 647
721#if defined(DEBUG) || defined(XLOG_NOLOG)
722 if (!xlog_debug && xlog_target == log->l_targ) {
723 *start_lsn = 0;
724 return 0;
725 }
726#endif
727 if (XLOG_FORCED_SHUTDOWN(log)) 648 if (XLOG_FORCED_SHUTDOWN(log))
728 return XFS_ERROR(EIO); 649 return XFS_ERROR(EIO);
729 650
@@ -743,11 +664,6 @@ xfs_log_move_tail(xfs_mount_t *mp,
743 int need_bytes, free_bytes, cycle, bytes; 664 int need_bytes, free_bytes, cycle, bytes;
744 SPLDECL(s); 665 SPLDECL(s);
745 666
746#if defined(DEBUG) || defined(XLOG_NOLOG)
747 if (!xlog_debug && xlog_target == log->l_targ)
748 return;
749#endif
750 /* XXXsup tmp */
751 if (XLOG_FORCED_SHUTDOWN(log)) 667 if (XLOG_FORCED_SHUTDOWN(log))
752 return; 668 return;
753 ASSERT(!XFS_FORCED_SHUTDOWN(mp)); 669 ASSERT(!XFS_FORCED_SHUTDOWN(mp));
@@ -1034,51 +950,22 @@ xlog_get_iclog_buffer_size(xfs_mount_t *mp,
1034 int size; 950 int size;
1035 int xhdrs; 951 int xhdrs;
1036 952
1037#if defined(DEBUG) || defined(XLOG_NOLOG) 953 if (mp->m_logbufs <= 0) {
1038 /* 954 if (xfs_physmem <= btoc(128*1024*1024)) {
1039 * When logbufs == 0, someone has disabled the log from the FSTAB 955 log->l_iclog_bufs = XLOG_MIN_ICLOGS;
1040 * file. This is not a documented feature. We need to set xlog_debug 956 } else if (xfs_physmem <= btoc(400*1024*1024)) {
1041 * to zero (this deactivates the log) and set xlog_target to the 957 log->l_iclog_bufs = XLOG_MED_ICLOGS;
1042 * appropriate device. Only one filesystem may be affected as such 958 } else { /* 256K with 32K bufs */
1043 * since this is just a performance hack to test what we might be able 959 log->l_iclog_bufs = XLOG_MAX_ICLOGS;
1044 * to get if the log were not present.
1045 */
1046 if (mp->m_logbufs == 0) {
1047 xlog_debug = 0;
1048 xlog_target = log->l_targ;
1049 log->l_iclog_bufs = XLOG_MIN_ICLOGS;
1050 } else
1051#endif
1052 {
1053 /*
1054 * This is the normal path. If m_logbufs == -1, then the
1055 * admin has chosen to use the system defaults for logbuffers.
1056 */
1057 if (mp->m_logbufs == -1) {
1058 if (xfs_physmem <= btoc(128*1024*1024)) {
1059 log->l_iclog_bufs = XLOG_MIN_ICLOGS;
1060 } else if (xfs_physmem <= btoc(400*1024*1024)) {
1061 log->l_iclog_bufs = XLOG_MED_ICLOGS;
1062 } else {
1063 /* 256K with 32K bufs */
1064 log->l_iclog_bufs = XLOG_MAX_ICLOGS;
1065 }
1066 } else
1067 log->l_iclog_bufs = mp->m_logbufs;
1068
1069#if defined(DEBUG) || defined(XLOG_NOLOG)
1070 /* We are reactivating a filesystem after it was inactive */
1071 if (log->l_targ == xlog_target) {
1072 xlog_target = NULL;
1073 xlog_debug = 1;
1074 } 960 }
1075#endif 961 } else {
962 log->l_iclog_bufs = mp->m_logbufs;
1076 } 963 }
1077 964
1078 /* 965 /*
1079 * Buffer size passed in from mount system call. 966 * Buffer size passed in from mount system call.
1080 */ 967 */
1081 if (mp->m_logbsize != -1) { 968 if (mp->m_logbsize > 0) {
1082 size = log->l_iclog_size = mp->m_logbsize; 969 size = log->l_iclog_size = mp->m_logbsize;
1083 log->l_iclog_size_log = 0; 970 log->l_iclog_size_log = 0;
1084 while (size != 1) { 971 while (size != 1) {
@@ -1101,7 +988,7 @@ xlog_get_iclog_buffer_size(xfs_mount_t *mp,
1101 log->l_iclog_hsize = BBSIZE; 988 log->l_iclog_hsize = BBSIZE;
1102 log->l_iclog_heads = 1; 989 log->l_iclog_heads = 1;
1103 } 990 }
1104 return; 991 goto done;
1105 } 992 }
1106 993
1107 /* 994 /*
@@ -1128,7 +1015,7 @@ xlog_get_iclog_buffer_size(xfs_mount_t *mp,
1128 if (mp->m_sb.sb_blocksize >= 16*1024) { 1015 if (mp->m_sb.sb_blocksize >= 16*1024) {
1129 log->l_iclog_size = XLOG_BIG_RECORD_BSIZE; 1016 log->l_iclog_size = XLOG_BIG_RECORD_BSIZE;
1130 log->l_iclog_size_log = XLOG_BIG_RECORD_BSHIFT; 1017 log->l_iclog_size_log = XLOG_BIG_RECORD_BSHIFT;
1131 if (mp->m_logbufs == -1) { 1018 if (mp->m_logbufs <= 0) {
1132 switch (mp->m_sb.sb_blocksize) { 1019 switch (mp->m_sb.sb_blocksize) {
1133 case 16*1024: /* 16 KB */ 1020 case 16*1024: /* 16 KB */
1134 log->l_iclog_bufs = 3; 1021 log->l_iclog_bufs = 3;
@@ -1145,6 +1032,12 @@ xlog_get_iclog_buffer_size(xfs_mount_t *mp,
1145 } 1032 }
1146 } 1033 }
1147 } 1034 }
1035
1036done: /* are we being asked to make the sizes selected above visible? */
1037 if (mp->m_logbufs == 0)
1038 mp->m_logbufs = log->l_iclog_bufs;
1039 if (mp->m_logbsize == 0)
1040 mp->m_logbsize = log->l_iclog_size;
1148} /* xlog_get_iclog_buffer_size */ 1041} /* xlog_get_iclog_buffer_size */
1149 1042
1150 1043
@@ -1467,14 +1360,13 @@ xlog_sync(xlog_t *log,
1467 XFS_BUF_BUSY(bp); 1360 XFS_BUF_BUSY(bp);
1468 XFS_BUF_ASYNC(bp); 1361 XFS_BUF_ASYNC(bp);
1469 /* 1362 /*
1470 * Do a disk write cache flush for the log block. 1363 * Do an ordered write for the log block.
1471 * This is a bit of a sledgehammer, it would be better 1364 *
1472 * to use a tag barrier here that just prevents reordering.
1473 * It may not be needed to flush the first split block in the log wrap 1365 * It may not be needed to flush the first split block in the log wrap
1474 * case, but do it anyways to be safe -AK 1366 * case, but do it anyways to be safe -AK
1475 */ 1367 */
1476 if (!(log->l_mp->m_flags & XFS_MOUNT_NOLOGFLUSH)) 1368 if (log->l_mp->m_flags & XFS_MOUNT_BARRIER)
1477 XFS_BUF_FLUSH(bp); 1369 XFS_BUF_ORDERED(bp);
1478 1370
1479 ASSERT(XFS_BUF_ADDR(bp) <= log->l_logBBsize-1); 1371 ASSERT(XFS_BUF_ADDR(bp) <= log->l_logBBsize-1);
1480 ASSERT(XFS_BUF_ADDR(bp) + BTOBB(count) <= log->l_logBBsize); 1372 ASSERT(XFS_BUF_ADDR(bp) + BTOBB(count) <= log->l_logBBsize);
@@ -1505,8 +1397,8 @@ xlog_sync(xlog_t *log,
1505 XFS_BUF_SET_FSPRIVATE(bp, iclog); 1397 XFS_BUF_SET_FSPRIVATE(bp, iclog);
1506 XFS_BUF_BUSY(bp); 1398 XFS_BUF_BUSY(bp);
1507 XFS_BUF_ASYNC(bp); 1399 XFS_BUF_ASYNC(bp);
1508 if (!(log->l_mp->m_flags & XFS_MOUNT_NOLOGFLUSH)) 1400 if (log->l_mp->m_flags & XFS_MOUNT_BARRIER)
1509 XFS_BUF_FLUSH(bp); 1401 XFS_BUF_ORDERED(bp);
1510 dptr = XFS_BUF_PTR(bp); 1402 dptr = XFS_BUF_PTR(bp);
1511 /* 1403 /*
1512 * Bump the cycle numbers at the start of each block 1404 * Bump the cycle numbers at the start of each block
@@ -2951,7 +2843,7 @@ xlog_state_switch_iclogs(xlog_t *log,
2951 * not in the active nor dirty state. 2843 * not in the active nor dirty state.
2952 */ 2844 */
2953STATIC int 2845STATIC int
2954xlog_state_sync_all(xlog_t *log, uint flags) 2846xlog_state_sync_all(xlog_t *log, uint flags, int *log_flushed)
2955{ 2847{
2956 xlog_in_core_t *iclog; 2848 xlog_in_core_t *iclog;
2957 xfs_lsn_t lsn; 2849 xfs_lsn_t lsn;
@@ -3000,6 +2892,7 @@ xlog_state_sync_all(xlog_t *log, uint flags)
3000 2892
3001 if (xlog_state_release_iclog(log, iclog)) 2893 if (xlog_state_release_iclog(log, iclog))
3002 return XFS_ERROR(EIO); 2894 return XFS_ERROR(EIO);
2895 *log_flushed = 1;
3003 s = LOG_LOCK(log); 2896 s = LOG_LOCK(log);
3004 if (INT_GET(iclog->ic_header.h_lsn, ARCH_CONVERT) == lsn && 2897 if (INT_GET(iclog->ic_header.h_lsn, ARCH_CONVERT) == lsn &&
3005 iclog->ic_state != XLOG_STATE_DIRTY) 2898 iclog->ic_state != XLOG_STATE_DIRTY)
@@ -3043,6 +2936,7 @@ maybe_sleep:
3043 */ 2936 */
3044 if (iclog->ic_state & XLOG_STATE_IOERROR) 2937 if (iclog->ic_state & XLOG_STATE_IOERROR)
3045 return XFS_ERROR(EIO); 2938 return XFS_ERROR(EIO);
2939 *log_flushed = 1;
3046 2940
3047 } else { 2941 } else {
3048 2942
@@ -3068,7 +2962,8 @@ no_sleep:
3068int 2962int
3069xlog_state_sync(xlog_t *log, 2963xlog_state_sync(xlog_t *log,
3070 xfs_lsn_t lsn, 2964 xfs_lsn_t lsn,
3071 uint flags) 2965 uint flags,
2966 int *log_flushed)
3072{ 2967{
3073 xlog_in_core_t *iclog; 2968 xlog_in_core_t *iclog;
3074 int already_slept = 0; 2969 int already_slept = 0;
@@ -3120,6 +3015,7 @@ try_again:
3120 XFS_STATS_INC(xs_log_force_sleep); 3015 XFS_STATS_INC(xs_log_force_sleep);
3121 sv_wait(&iclog->ic_prev->ic_writesema, PSWP, 3016 sv_wait(&iclog->ic_prev->ic_writesema, PSWP,
3122 &log->l_icloglock, s); 3017 &log->l_icloglock, s);
3018 *log_flushed = 1;
3123 already_slept = 1; 3019 already_slept = 1;
3124 goto try_again; 3020 goto try_again;
3125 } else { 3021 } else {
@@ -3128,6 +3024,7 @@ try_again:
3128 LOG_UNLOCK(log, s); 3024 LOG_UNLOCK(log, s);
3129 if (xlog_state_release_iclog(log, iclog)) 3025 if (xlog_state_release_iclog(log, iclog))
3130 return XFS_ERROR(EIO); 3026 return XFS_ERROR(EIO);
3027 *log_flushed = 1;
3131 s = LOG_LOCK(log); 3028 s = LOG_LOCK(log);
3132 } 3029 }
3133 } 3030 }
@@ -3152,6 +3049,7 @@ try_again:
3152 */ 3049 */
3153 if (iclog->ic_state & XLOG_STATE_IOERROR) 3050 if (iclog->ic_state & XLOG_STATE_IOERROR)
3154 return XFS_ERROR(EIO); 3051 return XFS_ERROR(EIO);
3052 *log_flushed = 1;
3155 } else { /* just return */ 3053 } else { /* just return */
3156 LOG_UNLOCK(log, s); 3054 LOG_UNLOCK(log, s);
3157 } 3055 }
@@ -3392,7 +3290,7 @@ xlog_ticket_get(xlog_t *log,
3392 * 3290 *
3393 ****************************************************************************** 3291 ******************************************************************************
3394 */ 3292 */
3395#if defined(DEBUG) && !defined(XLOG_NOLOG) 3293#if defined(DEBUG)
3396/* 3294/*
3397 * Make sure that the destination ptr is within the valid data region of 3295 * Make sure that the destination ptr is within the valid data region of
3398 * one of the iclogs. This uses backup pointers stored in a different 3296 * one of the iclogs. This uses backup pointers stored in a different
@@ -3533,7 +3431,9 @@ xlog_verify_iclog(xlog_t *log,
3533 } 3431 }
3534 } 3432 }
3535 if (clientid != XFS_TRANSACTION && clientid != XFS_LOG) 3433 if (clientid != XFS_TRANSACTION && clientid != XFS_LOG)
3536 cmn_err(CE_WARN, "xlog_verify_iclog: invalid clientid %d op 0x%p offset 0x%x", clientid, ophead, field_offset); 3434 cmn_err(CE_WARN, "xlog_verify_iclog: "
3435 "invalid clientid %d op 0x%p offset 0x%lx",
3436 clientid, ophead, (unsigned long)field_offset);
3537 3437
3538 /* check length */ 3438 /* check length */
3539 field_offset = (__psint_t) 3439 field_offset = (__psint_t)
@@ -3554,7 +3454,7 @@ xlog_verify_iclog(xlog_t *log,
3554 ptr += sizeof(xlog_op_header_t) + op_len; 3454 ptr += sizeof(xlog_op_header_t) + op_len;
3555 } 3455 }
3556} /* xlog_verify_iclog */ 3456} /* xlog_verify_iclog */
3557#endif /* DEBUG && !XLOG_NOLOG */ 3457#endif
3558 3458
3559/* 3459/*
3560 * Mark all iclogs IOERROR. LOG_LOCK is held by the caller. 3460 * Mark all iclogs IOERROR. LOG_LOCK is held by the caller.
@@ -3604,6 +3504,7 @@ xfs_log_force_umount(
3604 xlog_ticket_t *tic; 3504 xlog_ticket_t *tic;
3605 xlog_t *log; 3505 xlog_t *log;
3606 int retval; 3506 int retval;
3507 int dummy;
3607 SPLDECL(s); 3508 SPLDECL(s);
3608 SPLDECL(s2); 3509 SPLDECL(s2);
3609 3510
@@ -3682,7 +3583,7 @@ xfs_log_force_umount(
3682 * Force the incore logs to disk before shutting the 3583 * Force the incore logs to disk before shutting the
3683 * log down completely. 3584 * log down completely.
3684 */ 3585 */
3685 xlog_state_sync_all(log, XFS_LOG_FORCE|XFS_LOG_SYNC); 3586 xlog_state_sync_all(log, XFS_LOG_FORCE|XFS_LOG_SYNC, &dummy);
3686 s2 = LOG_LOCK(log); 3587 s2 = LOG_LOCK(log);
3687 retval = xlog_state_ioerror(log); 3588 retval = xlog_state_ioerror(log);
3688 LOG_UNLOCK(log, s2); 3589 LOG_UNLOCK(log, s2);
diff --git a/fs/xfs/xfs_log.h b/fs/xfs/xfs_log.h
index 18961119fc65..158829ca56f6 100644
--- a/fs/xfs/xfs_log.h
+++ b/fs/xfs/xfs_log.h
@@ -1,33 +1,19 @@
1/* 1/*
2 * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32#ifndef __XFS_LOG_H__ 18#ifndef __XFS_LOG_H__
33#define __XFS_LOG_H__ 19#define __XFS_LOG_H__
@@ -174,9 +160,12 @@ xfs_lsn_t xfs_log_done(struct xfs_mount *mp,
174 xfs_log_ticket_t ticket, 160 xfs_log_ticket_t ticket,
175 void **iclog, 161 void **iclog,
176 uint flags); 162 uint flags);
177int xfs_log_force(struct xfs_mount *mp, 163int _xfs_log_force(struct xfs_mount *mp,
178 xfs_lsn_t lsn, 164 xfs_lsn_t lsn,
179 uint flags); 165 uint flags,
166 int *log_forced);
167#define xfs_log_force(mp, lsn, flags) \
168 _xfs_log_force(mp, lsn, flags, NULL);
180int xfs_log_mount(struct xfs_mount *mp, 169int xfs_log_mount(struct xfs_mount *mp,
181 struct xfs_buftarg *log_target, 170 struct xfs_buftarg *log_target,
182 xfs_daddr_t start_block, 171 xfs_daddr_t start_block,
diff --git a/fs/xfs/xfs_log_priv.h b/fs/xfs/xfs_log_priv.h
index a884cea82fca..8f285149681f 100644
--- a/fs/xfs/xfs_log_priv.h
+++ b/fs/xfs/xfs_log_priv.h
@@ -1,33 +1,19 @@
1/* 1/*
2 * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32#ifndef __XFS_LOG_PRIV_H__ 18#ifndef __XFS_LOG_PRIV_H__
33#define __XFS_LOG_PRIV_H__ 19#define __XFS_LOG_PRIV_H__
@@ -35,6 +21,7 @@
35struct xfs_buf; 21struct xfs_buf;
36struct ktrace; 22struct ktrace;
37struct log; 23struct log;
24struct xlog_ticket;
38struct xfs_buf_cancel; 25struct xfs_buf_cancel;
39struct xfs_mount; 26struct xfs_mount;
40 27
@@ -120,77 +107,6 @@ struct xfs_mount;
120 ((i) >> 24) 107 ((i) >> 24)
121#endif 108#endif
122 109
123#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XLOG_GRANT_SUB_SPACE)
124void xlog_grant_sub_space(struct log *log, int bytes, int type);
125#define XLOG_GRANT_SUB_SPACE(log,bytes,type) \
126 xlog_grant_sub_space(log,bytes,type)
127#else
128#define XLOG_GRANT_SUB_SPACE(log,bytes,type) \
129 { \
130 if (type == 'w') { \
131 (log)->l_grant_write_bytes -= (bytes); \
132 if ((log)->l_grant_write_bytes < 0) { \
133 (log)->l_grant_write_bytes += (log)->l_logsize; \
134 (log)->l_grant_write_cycle--; \
135 } \
136 } else { \
137 (log)->l_grant_reserve_bytes -= (bytes); \
138 if ((log)->l_grant_reserve_bytes < 0) { \
139 (log)->l_grant_reserve_bytes += (log)->l_logsize;\
140 (log)->l_grant_reserve_cycle--; \
141 } \
142 } \
143 }
144#endif
145#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XLOG_GRANT_ADD_SPACE)
146void xlog_grant_add_space(struct log *log, int bytes, int type);
147#define XLOG_GRANT_ADD_SPACE(log,bytes,type) \
148 xlog_grant_add_space(log,bytes,type)
149#else
150#define XLOG_GRANT_ADD_SPACE(log,bytes,type) \
151 { \
152 if (type == 'w') { \
153 (log)->l_grant_write_bytes += (bytes); \
154 if ((log)->l_grant_write_bytes > (log)->l_logsize) { \
155 (log)->l_grant_write_bytes -= (log)->l_logsize; \
156 (log)->l_grant_write_cycle++; \
157 } \
158 } else { \
159 (log)->l_grant_reserve_bytes += (bytes); \
160 if ((log)->l_grant_reserve_bytes > (log)->l_logsize) { \
161 (log)->l_grant_reserve_bytes -= (log)->l_logsize;\
162 (log)->l_grant_reserve_cycle++; \
163 } \
164 } \
165 }
166#endif
167#define XLOG_INS_TICKETQ(q,tic) \
168 { \
169 if (q) { \
170 (tic)->t_next = (q); \
171 (tic)->t_prev = (q)->t_prev; \
172 (q)->t_prev->t_next = (tic); \
173 (q)->t_prev = (tic); \
174 } else { \
175 (tic)->t_prev = (tic)->t_next = (tic); \
176 (q) = (tic); \
177 } \
178 (tic)->t_flags |= XLOG_TIC_IN_Q; \
179 }
180#define XLOG_DEL_TICKETQ(q,tic) \
181 { \
182 if ((tic) == (tic)->t_next) { \
183 (q) = NULL; \
184 } else { \
185 (q) = (tic)->t_next; \
186 (tic)->t_next->t_prev = (tic)->t_prev; \
187 (tic)->t_prev->t_next = (tic)->t_next; \
188 } \
189 (tic)->t_next = (tic)->t_prev = NULL; \
190 (tic)->t_flags &= ~XLOG_TIC_IN_Q; \
191 }
192
193
194#define GRANT_LOCK(log) mutex_spinlock(&(log)->l_grant_lock) 110#define GRANT_LOCK(log) mutex_spinlock(&(log)->l_grant_lock)
195#define GRANT_UNLOCK(log, s) mutex_spinunlock(&(log)->l_grant_lock, s) 111#define GRANT_UNLOCK(log, s) mutex_spinunlock(&(log)->l_grant_lock, s)
196#define LOG_LOCK(log) mutex_spinlock(&(log)->l_icloglock) 112#define LOG_LOCK(log) mutex_spinlock(&(log)->l_icloglock)
@@ -576,6 +492,77 @@ typedef struct log {
576 * alignment mask */ 492 * alignment mask */
577} xlog_t; 493} xlog_t;
578 494
495#define XLOG_FORCED_SHUTDOWN(log) ((log)->l_flags & XLOG_IO_ERROR)
496
497#define XLOG_GRANT_SUB_SPACE(log,bytes,type) \
498 xlog_grant_sub_space(log,bytes,type)
499static inline void xlog_grant_sub_space(struct log *log, int bytes, int type)
500{
501 if (type == 'w') { \
502 (log)->l_grant_write_bytes -= (bytes); \
503 if ((log)->l_grant_write_bytes < 0) { \
504 (log)->l_grant_write_bytes += (log)->l_logsize; \
505 (log)->l_grant_write_cycle--; \
506 } \
507 } else { \
508 (log)->l_grant_reserve_bytes -= (bytes); \
509 if ((log)->l_grant_reserve_bytes < 0) { \
510 (log)->l_grant_reserve_bytes += (log)->l_logsize;\
511 (log)->l_grant_reserve_cycle--; \
512 } \
513 } \
514}
515
516#define XLOG_GRANT_ADD_SPACE(log,bytes,type) \
517 xlog_grant_add_space(log,bytes,type)
518static inline void
519xlog_grant_add_space(struct log *log, int bytes, int type)
520{
521 if (type == 'w') { \
522 (log)->l_grant_write_bytes += (bytes); \
523 if ((log)->l_grant_write_bytes > (log)->l_logsize) { \
524 (log)->l_grant_write_bytes -= (log)->l_logsize; \
525 (log)->l_grant_write_cycle++; \
526 } \
527 } else { \
528 (log)->l_grant_reserve_bytes += (bytes); \
529 if ((log)->l_grant_reserve_bytes > (log)->l_logsize) { \
530 (log)->l_grant_reserve_bytes -= (log)->l_logsize;\
531 (log)->l_grant_reserve_cycle++; \
532 } \
533 } \
534}
535
536#define XLOG_INS_TICKETQ(q, tic) xlog_ins_ticketq(q, tic)
537static inline void
538xlog_ins_ticketq(struct xlog_ticket *q, struct xlog_ticket *tic)
539{ \
540 if (q) { \
541 (tic)->t_next = (q); \
542 (tic)->t_prev = (q)->t_prev; \
543 (q)->t_prev->t_next = (tic); \
544 (q)->t_prev = (tic); \
545 } else { \
546 (tic)->t_prev = (tic)->t_next = (tic); \
547 (q) = (tic); \
548 } \
549 (tic)->t_flags |= XLOG_TIC_IN_Q; \
550}
551
552#define XLOG_DEL_TICKETQ(q, tic) xlog_del_ticketq(q, tic)
553static inline void
554xlog_del_ticketq(struct xlog_ticket *q, struct xlog_ticket *tic)
555{ \
556 if ((tic) == (tic)->t_next) { \
557 (q) = NULL; \
558 } else { \
559 (q) = (tic)->t_next; \
560 (tic)->t_next->t_prev = (tic)->t_prev; \
561 (tic)->t_prev->t_next = (tic)->t_next; \
562 } \
563 (tic)->t_next = (tic)->t_prev = NULL; \
564 (tic)->t_flags &= ~XLOG_TIC_IN_Q; \
565}
579 566
580/* common routines */ 567/* common routines */
581extern xfs_lsn_t xlog_assign_tail_lsn(struct xfs_mount *mp); 568extern xfs_lsn_t xlog_assign_tail_lsn(struct xfs_mount *mp);
diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c
index 14faabaabf29..8ab7df768063 100644
--- a/fs/xfs/xfs_log_recover.c
+++ b/fs/xfs/xfs_log_recover.c
@@ -1,66 +1,51 @@
1/* 1/*
2 * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32
33#include "xfs.h" 18#include "xfs.h"
34#include "xfs_macros.h" 19#include "xfs_fs.h"
35#include "xfs_types.h" 20#include "xfs_types.h"
36#include "xfs_inum.h" 21#include "xfs_bit.h"
37#include "xfs_log.h" 22#include "xfs_log.h"
38#include "xfs_ag.h" 23#include "xfs_inum.h"
39#include "xfs_sb.h"
40#include "xfs_trans.h" 24#include "xfs_trans.h"
25#include "xfs_sb.h"
26#include "xfs_ag.h"
41#include "xfs_dir.h" 27#include "xfs_dir.h"
42#include "xfs_dir2.h" 28#include "xfs_dir2.h"
43#include "xfs_dmapi.h" 29#include "xfs_dmapi.h"
44#include "xfs_mount.h" 30#include "xfs_mount.h"
45#include "xfs_error.h" 31#include "xfs_error.h"
46#include "xfs_bmap_btree.h" 32#include "xfs_bmap_btree.h"
47#include "xfs_alloc.h" 33#include "xfs_alloc_btree.h"
48#include "xfs_attr_sf.h" 34#include "xfs_ialloc_btree.h"
49#include "xfs_dir_sf.h" 35#include "xfs_dir_sf.h"
50#include "xfs_dir2_sf.h" 36#include "xfs_dir2_sf.h"
37#include "xfs_attr_sf.h"
51#include "xfs_dinode.h" 38#include "xfs_dinode.h"
52#include "xfs_imap.h"
53#include "xfs_inode_item.h"
54#include "xfs_inode.h" 39#include "xfs_inode.h"
55#include "xfs_ialloc_btree.h" 40#include "xfs_inode_item.h"
41#include "xfs_imap.h"
42#include "xfs_alloc.h"
56#include "xfs_ialloc.h" 43#include "xfs_ialloc.h"
57#include "xfs_log_priv.h" 44#include "xfs_log_priv.h"
58#include "xfs_buf_item.h" 45#include "xfs_buf_item.h"
59#include "xfs_alloc_btree.h"
60#include "xfs_log_recover.h" 46#include "xfs_log_recover.h"
61#include "xfs_extfree_item.h" 47#include "xfs_extfree_item.h"
62#include "xfs_trans_priv.h" 48#include "xfs_trans_priv.h"
63#include "xfs_bit.h"
64#include "xfs_quota.h" 49#include "xfs_quota.h"
65#include "xfs_rw.h" 50#include "xfs_rw.h"
66 51
@@ -2013,79 +1998,74 @@ xfs_qm_dqcheck(
2013 * This is all fine; things are still consistent, and we haven't lost 1998 * This is all fine; things are still consistent, and we haven't lost
2014 * any quota information. Just don't complain about bad dquot blks. 1999 * any quota information. Just don't complain about bad dquot blks.
2015 */ 2000 */
2016 if (INT_GET(ddq->d_magic, ARCH_CONVERT) != XFS_DQUOT_MAGIC) { 2001 if (be16_to_cpu(ddq->d_magic) != XFS_DQUOT_MAGIC) {
2017 if (flags & XFS_QMOPT_DOWARN) 2002 if (flags & XFS_QMOPT_DOWARN)
2018 cmn_err(CE_ALERT, 2003 cmn_err(CE_ALERT,
2019 "%s : XFS dquot ID 0x%x, magic 0x%x != 0x%x", 2004 "%s : XFS dquot ID 0x%x, magic 0x%x != 0x%x",
2020 str, id, 2005 str, id, be16_to_cpu(ddq->d_magic), XFS_DQUOT_MAGIC);
2021 INT_GET(ddq->d_magic, ARCH_CONVERT), XFS_DQUOT_MAGIC);
2022 errs++; 2006 errs++;
2023 } 2007 }
2024 if (INT_GET(ddq->d_version, ARCH_CONVERT) != XFS_DQUOT_VERSION) { 2008 if (ddq->d_version != XFS_DQUOT_VERSION) {
2025 if (flags & XFS_QMOPT_DOWARN) 2009 if (flags & XFS_QMOPT_DOWARN)
2026 cmn_err(CE_ALERT, 2010 cmn_err(CE_ALERT,
2027 "%s : XFS dquot ID 0x%x, version 0x%x != 0x%x", 2011 "%s : XFS dquot ID 0x%x, version 0x%x != 0x%x",
2028 str, id, 2012 str, id, ddq->d_version, XFS_DQUOT_VERSION);
2029 INT_GET(ddq->d_magic, ARCH_CONVERT), XFS_DQUOT_VERSION);
2030 errs++; 2013 errs++;
2031 } 2014 }
2032 2015
2033 if (INT_GET(ddq->d_flags, ARCH_CONVERT) != XFS_DQ_USER && 2016 if (ddq->d_flags != XFS_DQ_USER &&
2034 INT_GET(ddq->d_flags, ARCH_CONVERT) != XFS_DQ_PROJ && 2017 ddq->d_flags != XFS_DQ_PROJ &&
2035 INT_GET(ddq->d_flags, ARCH_CONVERT) != XFS_DQ_GROUP) { 2018 ddq->d_flags != XFS_DQ_GROUP) {
2036 if (flags & XFS_QMOPT_DOWARN) 2019 if (flags & XFS_QMOPT_DOWARN)
2037 cmn_err(CE_ALERT, 2020 cmn_err(CE_ALERT,
2038 "%s : XFS dquot ID 0x%x, unknown flags 0x%x", 2021 "%s : XFS dquot ID 0x%x, unknown flags 0x%x",
2039 str, id, INT_GET(ddq->d_flags, ARCH_CONVERT)); 2022 str, id, ddq->d_flags);
2040 errs++; 2023 errs++;
2041 } 2024 }
2042 2025
2043 if (id != -1 && id != INT_GET(ddq->d_id, ARCH_CONVERT)) { 2026 if (id != -1 && id != be32_to_cpu(ddq->d_id)) {
2044 if (flags & XFS_QMOPT_DOWARN) 2027 if (flags & XFS_QMOPT_DOWARN)
2045 cmn_err(CE_ALERT, 2028 cmn_err(CE_ALERT,
2046 "%s : ondisk-dquot 0x%p, ID mismatch: " 2029 "%s : ondisk-dquot 0x%p, ID mismatch: "
2047 "0x%x expected, found id 0x%x", 2030 "0x%x expected, found id 0x%x",
2048 str, ddq, id, INT_GET(ddq->d_id, ARCH_CONVERT)); 2031 str, ddq, id, be32_to_cpu(ddq->d_id));
2049 errs++; 2032 errs++;
2050 } 2033 }
2051 2034
2052 if (!errs && ddq->d_id) { 2035 if (!errs && ddq->d_id) {
2053 if (INT_GET(ddq->d_blk_softlimit, ARCH_CONVERT) && 2036 if (ddq->d_blk_softlimit &&
2054 INT_GET(ddq->d_bcount, ARCH_CONVERT) >= 2037 be64_to_cpu(ddq->d_bcount) >=
2055 INT_GET(ddq->d_blk_softlimit, ARCH_CONVERT)) { 2038 be64_to_cpu(ddq->d_blk_softlimit)) {
2056 if (!ddq->d_btimer) { 2039 if (!ddq->d_btimer) {
2057 if (flags & XFS_QMOPT_DOWARN) 2040 if (flags & XFS_QMOPT_DOWARN)
2058 cmn_err(CE_ALERT, 2041 cmn_err(CE_ALERT,
2059 "%s : Dquot ID 0x%x (0x%p) " 2042 "%s : Dquot ID 0x%x (0x%p) "
2060 "BLK TIMER NOT STARTED", 2043 "BLK TIMER NOT STARTED",
2061 str, (int) 2044 str, (int)be32_to_cpu(ddq->d_id), ddq);
2062 INT_GET(ddq->d_id, ARCH_CONVERT), ddq);
2063 errs++; 2045 errs++;
2064 } 2046 }
2065 } 2047 }
2066 if (INT_GET(ddq->d_ino_softlimit, ARCH_CONVERT) && 2048 if (ddq->d_ino_softlimit &&
2067 INT_GET(ddq->d_icount, ARCH_CONVERT) >= 2049 be64_to_cpu(ddq->d_icount) >=
2068 INT_GET(ddq->d_ino_softlimit, ARCH_CONVERT)) { 2050 be64_to_cpu(ddq->d_ino_softlimit)) {
2069 if (!ddq->d_itimer) { 2051 if (!ddq->d_itimer) {
2070 if (flags & XFS_QMOPT_DOWARN) 2052 if (flags & XFS_QMOPT_DOWARN)
2071 cmn_err(CE_ALERT, 2053 cmn_err(CE_ALERT,
2072 "%s : Dquot ID 0x%x (0x%p) " 2054 "%s : Dquot ID 0x%x (0x%p) "
2073 "INODE TIMER NOT STARTED", 2055 "INODE TIMER NOT STARTED",
2074 str, (int) 2056 str, (int)be32_to_cpu(ddq->d_id), ddq);
2075 INT_GET(ddq->d_id, ARCH_CONVERT), ddq);
2076 errs++; 2057 errs++;
2077 } 2058 }
2078 } 2059 }
2079 if (INT_GET(ddq->d_rtb_softlimit, ARCH_CONVERT) && 2060 if (ddq->d_rtb_softlimit &&
2080 INT_GET(ddq->d_rtbcount, ARCH_CONVERT) >= 2061 be64_to_cpu(ddq->d_rtbcount) >=
2081 INT_GET(ddq->d_rtb_softlimit, ARCH_CONVERT)) { 2062 be64_to_cpu(ddq->d_rtb_softlimit)) {
2082 if (!ddq->d_rtbtimer) { 2063 if (!ddq->d_rtbtimer) {
2083 if (flags & XFS_QMOPT_DOWARN) 2064 if (flags & XFS_QMOPT_DOWARN)
2084 cmn_err(CE_ALERT, 2065 cmn_err(CE_ALERT,
2085 "%s : Dquot ID 0x%x (0x%p) " 2066 "%s : Dquot ID 0x%x (0x%p) "
2086 "RTBLK TIMER NOT STARTED", 2067 "RTBLK TIMER NOT STARTED",
2087 str, (int) 2068 str, (int)be32_to_cpu(ddq->d_id), ddq);
2088 INT_GET(ddq->d_id, ARCH_CONVERT), ddq);
2089 errs++; 2069 errs++;
2090 } 2070 }
2091 } 2071 }
@@ -2103,10 +2083,11 @@ xfs_qm_dqcheck(
2103 ASSERT(id != -1); 2083 ASSERT(id != -1);
2104 ASSERT(flags & XFS_QMOPT_DQREPAIR); 2084 ASSERT(flags & XFS_QMOPT_DQREPAIR);
2105 memset(d, 0, sizeof(xfs_dqblk_t)); 2085 memset(d, 0, sizeof(xfs_dqblk_t));
2106 INT_SET(d->dd_diskdq.d_magic, ARCH_CONVERT, XFS_DQUOT_MAGIC); 2086
2107 INT_SET(d->dd_diskdq.d_version, ARCH_CONVERT, XFS_DQUOT_VERSION); 2087 d->dd_diskdq.d_magic = cpu_to_be16(XFS_DQUOT_MAGIC);
2108 INT_SET(d->dd_diskdq.d_id, ARCH_CONVERT, id); 2088 d->dd_diskdq.d_version = XFS_DQUOT_VERSION;
2109 INT_SET(d->dd_diskdq.d_flags, ARCH_CONVERT, type); 2089 d->dd_diskdq.d_flags = type;
2090 d->dd_diskdq.d_id = cpu_to_be32(id);
2110 2091
2111 return errs; 2092 return errs;
2112} 2093}
@@ -2226,8 +2207,9 @@ xlog_recover_do_buffer_trans(
2226 break; 2207 break;
2227 default: 2208 default:
2228 xfs_fs_cmn_err(CE_ALERT, log->l_mp, 2209 xfs_fs_cmn_err(CE_ALERT, log->l_mp,
2229 "xfs_log_recover: unknown buffer type 0x%x, dev %s", 2210 "xfs_log_recover: unknown buffer type 0x%x, logdev %s",
2230 buf_f->blf_type, XFS_BUFTARG_NAME(log->l_targ)); 2211 buf_f->blf_type, log->l_mp->m_logname ?
2212 log->l_mp->m_logname : "internal");
2231 XFS_ERROR_REPORT("xlog_recover_do_buffer_trans", 2213 XFS_ERROR_REPORT("xlog_recover_do_buffer_trans",
2232 XFS_ERRLEVEL_LOW, log->l_mp); 2214 XFS_ERRLEVEL_LOW, log->l_mp);
2233 return XFS_ERROR(EFSCORRUPTED); 2215 return XFS_ERROR(EFSCORRUPTED);
@@ -3178,13 +3160,12 @@ xlog_recover_clear_agi_bucket(
3178 } 3160 }
3179 3161
3180 agi = XFS_BUF_TO_AGI(agibp); 3162 agi = XFS_BUF_TO_AGI(agibp);
3181 if (INT_GET(agi->agi_magicnum, ARCH_CONVERT) != XFS_AGI_MAGIC) { 3163 if (be32_to_cpu(agi->agi_magicnum) != XFS_AGI_MAGIC) {
3182 xfs_trans_cancel(tp, XFS_TRANS_ABORT); 3164 xfs_trans_cancel(tp, XFS_TRANS_ABORT);
3183 return; 3165 return;
3184 } 3166 }
3185 ASSERT(INT_GET(agi->agi_magicnum, ARCH_CONVERT) == XFS_AGI_MAGIC);
3186 3167
3187 INT_SET(agi->agi_unlinked[bucket], ARCH_CONVERT, NULLAGINO); 3168 agi->agi_unlinked[bucket] = cpu_to_be32(NULLAGINO);
3188 offset = offsetof(xfs_agi_t, agi_unlinked) + 3169 offset = offsetof(xfs_agi_t, agi_unlinked) +
3189 (sizeof(xfs_agino_t) * bucket); 3170 (sizeof(xfs_agino_t) * bucket);
3190 xfs_trans_log_buf(tp, agibp, offset, 3171 xfs_trans_log_buf(tp, agibp, offset,
@@ -3243,12 +3224,11 @@ xlog_recover_process_iunlinks(
3243 XFS_AG_DADDR(mp, agno, XFS_AGI_DADDR(mp))); 3224 XFS_AG_DADDR(mp, agno, XFS_AGI_DADDR(mp)));
3244 } 3225 }
3245 agi = XFS_BUF_TO_AGI(agibp); 3226 agi = XFS_BUF_TO_AGI(agibp);
3246 ASSERT(XFS_AGI_MAGIC == 3227 ASSERT(XFS_AGI_MAGIC == be32_to_cpu(agi->agi_magicnum));
3247 INT_GET(agi->agi_magicnum, ARCH_CONVERT));
3248 3228
3249 for (bucket = 0; bucket < XFS_AGI_UNLINKED_BUCKETS; bucket++) { 3229 for (bucket = 0; bucket < XFS_AGI_UNLINKED_BUCKETS; bucket++) {
3250 3230
3251 agino = INT_GET(agi->agi_unlinked[bucket], ARCH_CONVERT); 3231 agino = be32_to_cpu(agi->agi_unlinked[bucket]);
3252 while (agino != NULLAGINO) { 3232 while (agino != NULLAGINO) {
3253 3233
3254 /* 3234 /*
@@ -3336,8 +3316,8 @@ xlog_recover_process_iunlinks(
3336 XFS_AGI_DADDR(mp))); 3316 XFS_AGI_DADDR(mp)));
3337 } 3317 }
3338 agi = XFS_BUF_TO_AGI(agibp); 3318 agi = XFS_BUF_TO_AGI(agibp);
3339 ASSERT(XFS_AGI_MAGIC == INT_GET( 3319 ASSERT(XFS_AGI_MAGIC == be32_to_cpu(
3340 agi->agi_magicnum, ARCH_CONVERT)); 3320 agi->agi_magicnum));
3341 } 3321 }
3342 } 3322 }
3343 3323
@@ -3938,8 +3918,9 @@ xlog_recover(
3938 } 3918 }
3939 3919
3940 cmn_err(CE_NOTE, 3920 cmn_err(CE_NOTE,
3941 "Starting XFS recovery on filesystem: %s (dev: %s)", 3921 "Starting XFS recovery on filesystem: %s (logdev: %s)",
3942 log->l_mp->m_fsname, XFS_BUFTARG_NAME(log->l_targ)); 3922 log->l_mp->m_fsname, log->l_mp->m_logname ?
3923 log->l_mp->m_logname : "internal");
3943 3924
3944 error = xlog_do_recover(log, head_blk, tail_blk); 3925 error = xlog_do_recover(log, head_blk, tail_blk);
3945 log->l_flags |= XLOG_RECOVERY_NEEDED; 3926 log->l_flags |= XLOG_RECOVERY_NEEDED;
@@ -3987,8 +3968,9 @@ xlog_recover_finish(
3987 xlog_recover_check_summary(log); 3968 xlog_recover_check_summary(log);
3988 3969
3989 cmn_err(CE_NOTE, 3970 cmn_err(CE_NOTE,
3990 "Ending XFS recovery on filesystem: %s (dev: %s)", 3971 "Ending XFS recovery on filesystem: %s (logdev: %s)",
3991 log->l_mp->m_fsname, XFS_BUFTARG_NAME(log->l_targ)); 3972 log->l_mp->m_fsname, log->l_mp->m_logname ?
3973 log->l_mp->m_logname : "internal");
3992 log->l_flags &= ~XLOG_RECOVERY_NEEDED; 3974 log->l_flags &= ~XLOG_RECOVERY_NEEDED;
3993 } else { 3975 } else {
3994 cmn_err(CE_DEBUG, 3976 cmn_err(CE_DEBUG,
@@ -4038,14 +4020,12 @@ xlog_recover_check_summary(
4038 mp, agfbp, agfdaddr); 4020 mp, agfbp, agfdaddr);
4039 } 4021 }
4040 agfp = XFS_BUF_TO_AGF(agfbp); 4022 agfp = XFS_BUF_TO_AGF(agfbp);
4041 ASSERT(XFS_AGF_MAGIC == 4023 ASSERT(XFS_AGF_MAGIC == be32_to_cpu(agfp->agf_magicnum));
4042 INT_GET(agfp->agf_magicnum, ARCH_CONVERT)); 4024 ASSERT(XFS_AGF_GOOD_VERSION(be32_to_cpu(agfp->agf_versionnum)));
4043 ASSERT(XFS_AGF_GOOD_VERSION( 4025 ASSERT(be32_to_cpu(agfp->agf_seqno) == agno);
4044 INT_GET(agfp->agf_versionnum, ARCH_CONVERT))); 4026
4045 ASSERT(INT_GET(agfp->agf_seqno, ARCH_CONVERT) == agno); 4027 freeblks += be32_to_cpu(agfp->agf_freeblks) +
4046 4028 be32_to_cpu(agfp->agf_flcount);
4047 freeblks += INT_GET(agfp->agf_freeblks, ARCH_CONVERT) +
4048 INT_GET(agfp->agf_flcount, ARCH_CONVERT);
4049 xfs_buf_relse(agfbp); 4029 xfs_buf_relse(agfbp);
4050 4030
4051 agidaddr = XFS_AG_DADDR(mp, agno, XFS_AGI_DADDR(mp)); 4031 agidaddr = XFS_AG_DADDR(mp, agno, XFS_AGI_DADDR(mp));
@@ -4056,14 +4036,12 @@ xlog_recover_check_summary(
4056 mp, agibp, agidaddr); 4036 mp, agibp, agidaddr);
4057 } 4037 }
4058 agip = XFS_BUF_TO_AGI(agibp); 4038 agip = XFS_BUF_TO_AGI(agibp);
4059 ASSERT(XFS_AGI_MAGIC == 4039 ASSERT(XFS_AGI_MAGIC == be32_to_cpu(agip->agi_magicnum));
4060 INT_GET(agip->agi_magicnum, ARCH_CONVERT)); 4040 ASSERT(XFS_AGI_GOOD_VERSION(be32_to_cpu(agip->agi_versionnum)));
4061 ASSERT(XFS_AGI_GOOD_VERSION( 4041 ASSERT(be32_to_cpu(agip->agi_seqno) == agno);
4062 INT_GET(agip->agi_versionnum, ARCH_CONVERT))); 4042
4063 ASSERT(INT_GET(agip->agi_seqno, ARCH_CONVERT) == agno); 4043 itotal += be32_to_cpu(agip->agi_count);
4064 4044 ifree += be32_to_cpu(agip->agi_freecount);
4065 itotal += INT_GET(agip->agi_count, ARCH_CONVERT);
4066 ifree += INT_GET(agip->agi_freecount, ARCH_CONVERT);
4067 xfs_buf_relse(agibp); 4045 xfs_buf_relse(agibp);
4068 } 4046 }
4069 4047
diff --git a/fs/xfs/xfs_log_recover.h b/fs/xfs/xfs_log_recover.h
index 42158b442b55..b22545555301 100644
--- a/fs/xfs/xfs_log_recover.h
+++ b/fs/xfs/xfs_log_recover.h
@@ -1,33 +1,19 @@
1/* 1/*
2 * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32#ifndef __XFS_LOG_RECOVER_H__ 18#ifndef __XFS_LOG_RECOVER_H__
33#define __XFS_LOG_RECOVER_H__ 19#define __XFS_LOG_RECOVER_H__
diff --git a/fs/xfs/xfs_mac.h b/fs/xfs/xfs_mac.h
index 8d59aaffeb8e..18e0e98e03d0 100644
--- a/fs/xfs/xfs_mac.h
+++ b/fs/xfs/xfs_mac.h
@@ -1,33 +1,19 @@
1/* 1/*
2 * Copyright (c) 2001-2002 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2001-2002,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32#ifndef __XFS_MAC_H__ 18#ifndef __XFS_MAC_H__
33#define __XFS_MAC_H__ 19#define __XFS_MAC_H__
diff --git a/fs/xfs/xfs_macros.c b/fs/xfs/xfs_macros.c
deleted file mode 100644
index 698c2cd62858..000000000000
--- a/fs/xfs/xfs_macros.c
+++ /dev/null
@@ -1,2141 +0,0 @@
1/*
2 * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of version 2 of the GNU General Public License as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it would be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 *
12 * Further, this software is distributed without any warranty that it is
13 * free of the rightful claim of any third person regarding infringement
14 * or the like. Any license provided herein, whether implied or
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */
32
33#define XFS_MACRO_C
34
35#include "xfs.h"
36#include "xfs_macros.h"
37#include "xfs_types.h"
38#include "xfs_inum.h"
39#include "xfs_log.h"
40#include "xfs_trans.h"
41#include "xfs_sb.h"
42#include "xfs_ag.h"
43#include "xfs_dir.h"
44#include "xfs_dir2.h"
45#include "xfs_dmapi.h"
46#include "xfs_mount.h"
47#include "xfs_alloc_btree.h"
48#include "xfs_ialloc_btree.h"
49#include "xfs_bmap_btree.h"
50#include "xfs_btree.h"
51#include "xfs_attr_sf.h"
52#include "xfs_dir_sf.h"
53#include "xfs_dir2_sf.h"
54#include "xfs_dinode.h"
55#include "xfs_ialloc.h"
56#include "xfs_inode_item.h"
57#include "xfs_inode.h"
58#include "xfs_bmap.h"
59#include "xfs_rw.h"
60#include "xfs_log_priv.h"
61#include "xfs_da_btree.h"
62#include "xfs_attr_leaf.h"
63#include "xfs_dir_leaf.h"
64#include "xfs_dir2_data.h"
65#include "xfs_dir2_leaf.h"
66#include "xfs_dir2_block.h"
67#include "xfs_dir2_node.h"
68#include "xfs_bit.h"
69
70#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_ISNULLDSTARTBLOCK)
71int
72isnulldstartblock(xfs_dfsbno_t x)
73{
74 return ISNULLDSTARTBLOCK(x);
75}
76#endif
77
78#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_ISNULLSTARTBLOCK)
79int
80isnullstartblock(xfs_fsblock_t x)
81{
82 return ISNULLSTARTBLOCK(x);
83}
84#endif
85
86#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_NULLSTARTBLOCK)
87xfs_fsblock_t
88nullstartblock(int k)
89{
90 return NULLSTARTBLOCK(k);
91}
92#endif
93
94#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_STARTBLOCKVAL)
95xfs_filblks_t
96startblockval(xfs_fsblock_t x)
97{
98 return STARTBLOCKVAL(x);
99}
100#endif
101
102#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_AG_CHECK_DADDR)
103void
104xfs_ag_check_daddr(xfs_mount_t *mp, xfs_daddr_t d, xfs_extlen_t len)
105{
106 XFS_AG_CHECK_DADDR(mp, d, len);
107}
108#endif
109
110#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_AG_DADDR)
111xfs_daddr_t
112xfs_ag_daddr(xfs_mount_t *mp, xfs_agnumber_t agno, xfs_daddr_t d)
113{
114 return XFS_AG_DADDR(mp, agno, d);
115}
116#endif
117
118#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_AG_MAXLEVELS)
119int
120xfs_ag_maxlevels(xfs_mount_t *mp)
121{
122 return XFS_AG_MAXLEVELS(mp);
123}
124#endif
125
126#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_AGB_TO_DADDR)
127xfs_daddr_t
128xfs_agb_to_daddr(xfs_mount_t *mp, xfs_agnumber_t agno, xfs_agblock_t agbno)
129{
130 return XFS_AGB_TO_DADDR(mp, agno, agbno);
131}
132#endif
133
134#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_AGB_TO_FSB)
135xfs_fsblock_t
136xfs_agb_to_fsb(xfs_mount_t *mp, xfs_agnumber_t agno, xfs_agblock_t agbno)
137{
138 return XFS_AGB_TO_FSB(mp, agno, agbno);
139}
140#endif
141
142#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_AGBLOCK_MAX)
143xfs_agblock_t
144xfs_agblock_max(xfs_agblock_t a, xfs_agblock_t b)
145{
146 return XFS_AGBLOCK_MAX(a, b);
147}
148#endif
149
150#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_AGBLOCK_MIN)
151xfs_agblock_t
152xfs_agblock_min(xfs_agblock_t a, xfs_agblock_t b)
153{
154 return XFS_AGBLOCK_MIN(a, b);
155}
156#endif
157
158#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_AGF_BLOCK)
159xfs_agblock_t
160xfs_agf_block(xfs_mount_t *mp)
161{
162 return XFS_AGF_BLOCK(mp);
163}
164#endif
165
166#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_AGF_GOOD_VERSION)
167int
168xfs_agf_good_version(unsigned v)
169{
170 return XFS_AGF_GOOD_VERSION(v);
171}
172#endif
173
174#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_AGFL_BLOCK)
175xfs_agblock_t
176xfs_agfl_block(xfs_mount_t *mp)
177{
178 return XFS_AGFL_BLOCK(mp);
179}
180#endif
181
182#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_AGI_BLOCK)
183xfs_agblock_t
184xfs_agi_block(xfs_mount_t *mp)
185{
186 return XFS_AGI_BLOCK(mp);
187}
188#endif
189
190#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_AGI_GOOD_VERSION)
191int
192xfs_agi_good_version(unsigned v)
193{
194 return XFS_AGI_GOOD_VERSION(v);
195}
196#endif
197
198#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_AGINO_TO_AGBNO)
199xfs_agblock_t
200xfs_agino_to_agbno(xfs_mount_t *mp, xfs_agino_t i)
201{
202 return XFS_AGINO_TO_AGBNO(mp, i);
203}
204#endif
205
206#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_AGINO_TO_INO)
207xfs_ino_t
208xfs_agino_to_ino(xfs_mount_t *mp, xfs_agnumber_t a, xfs_agino_t i)
209{
210 return XFS_AGINO_TO_INO(mp, a, i);
211}
212#endif
213
214#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_AGINO_TO_OFFSET)
215int
216xfs_agino_to_offset(xfs_mount_t *mp, xfs_agino_t i)
217{
218 return XFS_AGINO_TO_OFFSET(mp, i);
219}
220#endif
221
222#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_ALLOC_BLOCK_MAXRECS)
223int
224xfs_alloc_block_maxrecs(int lev, xfs_btree_cur_t *cur)
225{
226 return XFS_ALLOC_BLOCK_MAXRECS(lev, cur);
227}
228#endif
229
230#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_ALLOC_BLOCK_MINRECS)
231int
232xfs_alloc_block_minrecs(int lev, xfs_btree_cur_t *cur)
233{
234 return XFS_ALLOC_BLOCK_MINRECS(lev, cur);
235}
236#endif
237
238#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_ALLOC_BLOCK_SIZE)
239/*ARGSUSED1*/
240int
241xfs_alloc_block_size(int lev, xfs_btree_cur_t *cur)
242{
243 return XFS_ALLOC_BLOCK_SIZE(lev, cur);
244}
245#endif
246
247#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_ALLOC_KEY_ADDR)
248/*ARGSUSED3*/
249xfs_alloc_key_t *
250xfs_alloc_key_addr(xfs_alloc_block_t *bb, int i, xfs_btree_cur_t *cur)
251{
252 return XFS_ALLOC_KEY_ADDR(bb, i, cur);
253}
254#endif
255
256#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_ALLOC_PTR_ADDR)
257xfs_alloc_ptr_t *
258xfs_alloc_ptr_addr(xfs_alloc_block_t *bb, int i, xfs_btree_cur_t *cur)
259{
260 return XFS_ALLOC_PTR_ADDR(bb, i, cur);
261}
262#endif
263
264#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_ALLOC_REC_ADDR)
265/*ARGSUSED3*/
266xfs_alloc_rec_t *
267xfs_alloc_rec_addr(xfs_alloc_block_t *bb, int i, xfs_btree_cur_t *cur)
268{
269 return XFS_ALLOC_REC_ADDR(bb, i, cur);
270}
271#endif
272
273#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_ATTR_LEAF_ENTSIZE_LOCAL)
274int
275xfs_attr_leaf_entsize_local(int nlen, int vlen)
276{
277 return XFS_ATTR_LEAF_ENTSIZE_LOCAL(nlen, vlen);
278}
279#endif
280
281#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_ATTR_LEAF_ENTSIZE_LOCAL_MAX)
282int
283xfs_attr_leaf_entsize_local_max(int bsize)
284{
285 return XFS_ATTR_LEAF_ENTSIZE_LOCAL_MAX(bsize);
286}
287#endif
288
289#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_ATTR_LEAF_ENTSIZE_REMOTE)
290int
291xfs_attr_leaf_entsize_remote(int nlen)
292{
293 return XFS_ATTR_LEAF_ENTSIZE_REMOTE(nlen);
294}
295#endif
296
297#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_ATTR_LEAF_NAME)
298char *
299xfs_attr_leaf_name(xfs_attr_leafblock_t *leafp, int idx)
300{
301 return XFS_ATTR_LEAF_NAME(leafp, idx);
302}
303#endif
304
305#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_ATTR_LEAF_NAME_LOCAL)
306xfs_attr_leaf_name_local_t *
307xfs_attr_leaf_name_local(xfs_attr_leafblock_t *leafp, int idx)
308{
309 return XFS_ATTR_LEAF_NAME_LOCAL(leafp, idx);
310}
311#endif
312
313#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_ATTR_LEAF_NAME_REMOTE)
314xfs_attr_leaf_name_remote_t *
315xfs_attr_leaf_name_remote(xfs_attr_leafblock_t *leafp, int idx)
316{
317 return XFS_ATTR_LEAF_NAME_REMOTE(leafp, idx);
318}
319#endif
320
321#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_ATTR_SF_ENTSIZE)
322int
323xfs_attr_sf_entsize(xfs_attr_sf_entry_t *sfep)
324{
325 return XFS_ATTR_SF_ENTSIZE(sfep);
326}
327#endif
328
329#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_ATTR_SF_ENTSIZE_BYNAME)
330int
331xfs_attr_sf_entsize_byname(int nlen, int vlen)
332{
333 return XFS_ATTR_SF_ENTSIZE_BYNAME(nlen, vlen);
334}
335#endif
336
337#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_ATTR_SF_NEXTENTRY)
338xfs_attr_sf_entry_t *
339xfs_attr_sf_nextentry(xfs_attr_sf_entry_t *sfep)
340{
341 return XFS_ATTR_SF_NEXTENTRY(sfep);
342}
343#endif
344
345#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_ATTR_SF_TOTSIZE)
346int
347xfs_attr_sf_totsize(xfs_inode_t *dp)
348{
349 return XFS_ATTR_SF_TOTSIZE(dp);
350}
351#endif
352
353#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_BHVTOI)
354xfs_inode_t *
355xfs_bhvtoi(bhv_desc_t *bhvp)
356{
357 return XFS_BHVTOI(bhvp);
358}
359#endif
360
361#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_BHVTOM)
362xfs_mount_t *
363xfs_bhvtom(bhv_desc_t *bdp)
364{
365 return XFS_BHVTOM(bdp);
366}
367#endif
368
369#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_VFSTOM)
370xfs_mount_t *
371xfs_vfstom(vfs_t *vfs)
372{
373 return XFS_VFSTOM(vfs);
374}
375#endif
376
377#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_BM_MAXLEVELS)
378int
379xfs_bm_maxlevels(xfs_mount_t *mp, int w)
380{
381 return XFS_BM_MAXLEVELS(mp, w);
382}
383#endif
384
385#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_BMAP_BLOCK_DMAXRECS)
386int
387xfs_bmap_block_dmaxrecs(int lev, xfs_btree_cur_t *cur)
388{
389 return XFS_BMAP_BLOCK_DMAXRECS(lev, cur);
390}
391#endif
392
393#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_BMAP_BLOCK_DMINRECS)
394int
395xfs_bmap_block_dminrecs(int lev, xfs_btree_cur_t *cur)
396{
397 return XFS_BMAP_BLOCK_DMINRECS(lev, cur);
398}
399#endif
400
401#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_BMAP_BLOCK_DSIZE)
402int
403xfs_bmap_block_dsize(int lev, xfs_btree_cur_t *cur)
404{
405 return XFS_BMAP_BLOCK_DSIZE(lev, cur);
406}
407#endif
408
409#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_BMAP_BLOCK_IMAXRECS)
410int
411xfs_bmap_block_imaxrecs(int lev, xfs_btree_cur_t *cur)
412{
413 return XFS_BMAP_BLOCK_IMAXRECS(lev, cur);
414}
415#endif
416
417#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_BMAP_BLOCK_IMINRECS)
418int
419xfs_bmap_block_iminrecs(int lev, xfs_btree_cur_t *cur)
420{
421 return XFS_BMAP_BLOCK_IMINRECS(lev, cur);
422}
423#endif
424
425#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_BMAP_BLOCK_ISIZE)
426int
427xfs_bmap_block_isize(int lev, xfs_btree_cur_t *cur)
428{
429 return XFS_BMAP_BLOCK_ISIZE(lev, cur);
430}
431#endif
432
433#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_BMAP_BROOT_KEY_ADDR)
434/*ARGSUSED3*/
435xfs_bmbt_key_t *
436xfs_bmap_broot_key_addr(xfs_bmbt_block_t *bb, int i, int sz)
437{
438 return XFS_BMAP_BROOT_KEY_ADDR(bb, i, sz);
439}
440#endif
441
442#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_BMAP_BROOT_MAXRECS)
443int
444xfs_bmap_broot_maxrecs(int sz)
445{
446 return XFS_BMAP_BROOT_MAXRECS(sz);
447}
448#endif
449
450#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_BMAP_BROOT_NUMRECS)
451int
452xfs_bmap_broot_numrecs(xfs_bmdr_block_t *bb)
453{
454 return XFS_BMAP_BROOT_NUMRECS(bb);
455}
456#endif
457
458#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_BMAP_BROOT_PTR_ADDR)
459xfs_bmbt_ptr_t *
460xfs_bmap_broot_ptr_addr(xfs_bmbt_block_t *bb, int i, int sz)
461{
462 return XFS_BMAP_BROOT_PTR_ADDR(bb, i, sz);
463}
464#endif
465
466#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_BMAP_BROOT_REC_ADDR)
467/*ARGSUSED3*/
468xfs_bmbt_rec_t *
469xfs_bmap_broot_rec_addr(xfs_bmbt_block_t *bb, int i, int sz)
470{
471 return XFS_BMAP_BROOT_REC_ADDR(bb, i, sz);
472}
473#endif
474
475#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_BMAP_BROOT_SPACE)
476int
477xfs_bmap_broot_space(xfs_bmdr_block_t *bb)
478{
479 return XFS_BMAP_BROOT_SPACE(bb);
480}
481#endif
482
483#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_BMAP_BROOT_SPACE_CALC)
484int
485xfs_bmap_broot_space_calc(int nrecs)
486{
487 return XFS_BMAP_BROOT_SPACE_CALC(nrecs);
488}
489#endif
490
491#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_BMAP_IBLOCK_SIZE)
492/*ARGSUSED1*/
493int
494xfs_bmap_iblock_size(int lev, xfs_btree_cur_t *cur)
495{
496 return XFS_BMAP_IBLOCK_SIZE(lev, cur);
497}
498#endif
499
500#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_BMAP_INIT)
501void
502xfs_bmap_init(xfs_bmap_free_t *flp, xfs_fsblock_t *fbp)
503{
504 XFS_BMAP_INIT(flp, fbp);
505}
506#endif
507
508#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_BMAP_KEY_DADDR)
509/*ARGSUSED3*/
510xfs_bmbt_key_t *
511xfs_bmap_key_daddr(xfs_bmbt_block_t *bb, int i, xfs_btree_cur_t *cur)
512{
513 return XFS_BMAP_KEY_DADDR(bb, i, cur);
514}
515#endif
516
517#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_BMAP_KEY_IADDR)
518/*ARGSUSED3*/
519xfs_bmbt_key_t *
520xfs_bmap_key_iaddr(xfs_bmbt_block_t *bb, int i, xfs_btree_cur_t *cur)
521{
522 return XFS_BMAP_KEY_IADDR(bb, i, cur);
523}
524#endif
525
526#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_BMAP_PTR_DADDR)
527xfs_bmbt_ptr_t *
528xfs_bmap_ptr_daddr(xfs_bmbt_block_t *bb, int i, xfs_btree_cur_t *cur)
529{
530 return XFS_BMAP_PTR_DADDR(bb, i, cur);
531}
532#endif
533
534#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_BMAP_PTR_IADDR)
535xfs_bmbt_ptr_t *
536xfs_bmap_ptr_iaddr(xfs_bmbt_block_t *bb, int i, xfs_btree_cur_t *cur)
537{
538 return XFS_BMAP_PTR_IADDR(bb, i, cur);
539}
540#endif
541
542#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_BMAP_RBLOCK_DSIZE)
543/*ARGSUSED1*/
544int
545xfs_bmap_rblock_dsize(int lev, xfs_btree_cur_t *cur)
546{
547 return XFS_BMAP_RBLOCK_DSIZE(lev, cur);
548}
549#endif
550
551#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_BMAP_RBLOCK_ISIZE)
552/*ARGSUSED1*/
553int
554xfs_bmap_rblock_isize(int lev, xfs_btree_cur_t *cur)
555{
556 return XFS_BMAP_RBLOCK_ISIZE(lev, cur);
557}
558#endif
559
560#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_BMAP_REC_DADDR)
561/*ARGSUSED3*/
562xfs_bmbt_rec_t *
563xfs_bmap_rec_daddr(xfs_bmbt_block_t *bb, int i, xfs_btree_cur_t *cur)
564{
565 return XFS_BMAP_REC_DADDR(bb, i, cur);
566}
567#endif
568
569#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_BMAP_REC_IADDR)
570/*ARGSUSED3*/
571xfs_bmbt_rec_t *
572xfs_bmap_rec_iaddr(xfs_bmbt_block_t *bb, int i, xfs_btree_cur_t *cur)
573{
574 return XFS_BMAP_REC_IADDR(bb, i, cur);
575}
576#endif
577
578#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_BMAP_SANITY_CHECK)
579int
580xfs_bmap_sanity_check(xfs_mount_t *mp, xfs_bmbt_block_t *bb, int level)
581{
582 return XFS_BMAP_SANITY_CHECK(mp, bb, level);
583}
584#endif
585
586#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_BMAPI_AFLAG)
587int
588xfs_bmapi_aflag(int w)
589{
590 return XFS_BMAPI_AFLAG(w);
591}
592#endif
593
594#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_BMDR_SPACE_CALC)
595int
596xfs_bmdr_space_calc(int nrecs)
597{
598 return XFS_BMDR_SPACE_CALC(nrecs);
599}
600#endif
601
602#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_BNO_BLOCK)
603xfs_agblock_t
604xfs_bno_block(xfs_mount_t *mp)
605{
606 return XFS_BNO_BLOCK(mp);
607}
608#endif
609
610#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_BTREE_LONG_PTRS)
611int
612xfs_btree_long_ptrs(xfs_btnum_t btnum)
613{
614 return XFS_BTREE_LONG_PTRS(btnum);
615}
616#endif
617
618#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_BUF_TO_AGF)
619xfs_agf_t *
620xfs_buf_to_agf(xfs_buf_t *bp)
621{
622 return XFS_BUF_TO_AGF(bp);
623}
624#endif
625
626#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_BUF_TO_AGFL)
627xfs_agfl_t *
628xfs_buf_to_agfl(xfs_buf_t *bp)
629{
630 return XFS_BUF_TO_AGFL(bp);
631}
632#endif
633
634#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_BUF_TO_AGI)
635xfs_agi_t *
636xfs_buf_to_agi(xfs_buf_t *bp)
637{
638 return XFS_BUF_TO_AGI(bp);
639}
640#endif
641
642#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_BUF_TO_ALLOC_BLOCK)
643xfs_alloc_block_t *
644xfs_buf_to_alloc_block(xfs_buf_t *bp)
645{
646 return XFS_BUF_TO_ALLOC_BLOCK(bp);
647}
648#endif
649
650#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_BUF_TO_BLOCK)
651xfs_btree_block_t *
652xfs_buf_to_block(xfs_buf_t *bp)
653{
654 return XFS_BUF_TO_BLOCK(bp);
655}
656#endif
657
658#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_BUF_TO_BMBT_BLOCK)
659xfs_bmbt_block_t *
660xfs_buf_to_bmbt_block(xfs_buf_t *bp)
661{
662 return XFS_BUF_TO_BMBT_BLOCK(bp);
663}
664#endif
665
666#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_BUF_TO_DINODE)
667xfs_dinode_t *
668xfs_buf_to_dinode(xfs_buf_t *bp)
669{
670 return XFS_BUF_TO_DINODE(bp);
671}
672#endif
673
674#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_BUF_TO_INOBT_BLOCK)
675xfs_inobt_block_t *
676xfs_buf_to_inobt_block(xfs_buf_t *bp)
677{
678 return XFS_BUF_TO_INOBT_BLOCK(bp);
679}
680#endif
681
682#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_BUF_TO_LBLOCK)
683xfs_btree_lblock_t *
684xfs_buf_to_lblock(xfs_buf_t *bp)
685{
686 return XFS_BUF_TO_LBLOCK(bp);
687}
688#endif
689
690#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_BUF_TO_SBLOCK)
691xfs_btree_sblock_t *
692xfs_buf_to_sblock(xfs_buf_t *bp)
693{
694 return XFS_BUF_TO_SBLOCK(bp);
695}
696#endif
697
698#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_BUF_TO_SBP)
699xfs_sb_t *
700xfs_buf_to_sbp(xfs_buf_t *bp)
701{
702 return XFS_BUF_TO_SBP(bp);
703}
704#endif
705
706#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_CFORK_ASIZE)
707int
708xfs_cfork_asize_disk(xfs_dinode_core_t *dcp, xfs_mount_t *mp)
709{
710 return XFS_CFORK_ASIZE_DISK(dcp, mp);
711}
712int
713xfs_cfork_asize(xfs_dinode_core_t *dcp, xfs_mount_t *mp)
714{
715 return XFS_CFORK_ASIZE(dcp, mp);
716}
717#endif
718
719#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_CFORK_BOFF)
720int
721xfs_cfork_boff_disk(xfs_dinode_core_t *dcp)
722{
723 return XFS_CFORK_BOFF_DISK(dcp);
724}
725int
726xfs_cfork_boff(xfs_dinode_core_t *dcp)
727{
728 return XFS_CFORK_BOFF(dcp);
729}
730#endif
731
732#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_CFORK_DSIZE)
733int
734xfs_cfork_dsize_disk(xfs_dinode_core_t *dcp, xfs_mount_t *mp)
735{
736 return XFS_CFORK_DSIZE_DISK(dcp, mp);
737}
738int
739xfs_cfork_dsize(xfs_dinode_core_t *dcp, xfs_mount_t *mp)
740{
741 return XFS_CFORK_DSIZE(dcp, mp);
742}
743#endif
744
745#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_CFORK_FMT_SET)
746void
747xfs_cfork_fmt_set(xfs_dinode_core_t *dcp, int w, int n)
748{
749 XFS_CFORK_FMT_SET(dcp, w, n);
750}
751#endif
752
753#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_CFORK_FORMAT)
754int
755xfs_cfork_format(xfs_dinode_core_t *dcp, int w)
756{
757 return XFS_CFORK_FORMAT(dcp, w);
758}
759#endif
760
761#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_CFORK_NEXT_SET)
762void
763xfs_cfork_next_set(xfs_dinode_core_t *dcp, int w, int n)
764{
765 XFS_CFORK_NEXT_SET(dcp, w, n);
766}
767#endif
768
769#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_CFORK_NEXTENTS)
770int
771xfs_cfork_nextents_disk(xfs_dinode_core_t *dcp, int w)
772{
773 return XFS_CFORK_NEXTENTS_DISK(dcp, w);
774}
775int
776xfs_cfork_nextents(xfs_dinode_core_t *dcp, int w)
777{
778 return XFS_CFORK_NEXTENTS(dcp, w);
779}
780#endif
781
782#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_CFORK_Q)
783int
784xfs_cfork_q_disk(xfs_dinode_core_t *dcp)
785{
786 return XFS_CFORK_Q_DISK(dcp);
787}
788int
789xfs_cfork_q(xfs_dinode_core_t *dcp)
790{
791 return XFS_CFORK_Q(dcp);
792}
793#endif
794
795#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_CFORK_SIZE)
796int
797xfs_cfork_size_disk(xfs_dinode_core_t *dcp, xfs_mount_t *mp, int w)
798{
799 return XFS_CFORK_SIZE_DISK(dcp, mp, w);
800}
801int
802xfs_cfork_size(xfs_dinode_core_t *dcp, xfs_mount_t *mp, int w)
803{
804 return XFS_CFORK_SIZE(dcp, mp, w);
805}
806#endif
807
808#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_CNT_BLOCK)
809xfs_agblock_t
810xfs_cnt_block(xfs_mount_t *mp)
811{
812 return XFS_CNT_BLOCK(mp);
813}
814#endif
815
816#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DA_COOKIE_BNO)
817xfs_dablk_t
818xfs_da_cookie_bno(xfs_mount_t *mp, xfs_off_t cookie)
819{
820 return XFS_DA_COOKIE_BNO(mp, cookie);
821}
822#endif
823
824#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DA_COOKIE_ENTRY)
825int
826xfs_da_cookie_entry(xfs_mount_t *mp, xfs_off_t cookie)
827{
828 return XFS_DA_COOKIE_ENTRY(mp, cookie);
829}
830#endif
831
832#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DA_COOKIE_HASH)
833/*ARGSUSED1*/
834xfs_dahash_t
835xfs_da_cookie_hash(xfs_mount_t *mp, xfs_off_t cookie)
836{
837 return XFS_DA_COOKIE_HASH(mp, cookie);
838}
839#endif
840
841#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DA_MAKE_BNOENTRY)
842__uint32_t
843xfs_da_make_bnoentry(xfs_mount_t *mp, xfs_dablk_t bno, int entry)
844{
845 return XFS_DA_MAKE_BNOENTRY(mp, bno, entry);
846}
847#endif
848
849#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DA_MAKE_COOKIE)
850xfs_off_t
851xfs_da_make_cookie(xfs_mount_t *mp, xfs_dablk_t bno, int entry,
852 xfs_dahash_t hash)
853{
854 return XFS_DA_MAKE_COOKIE(mp, bno, entry, hash);
855}
856#endif
857
858#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DADDR_TO_AGBNO)
859xfs_agblock_t
860xfs_daddr_to_agbno(xfs_mount_t *mp, xfs_daddr_t d)
861{
862 return XFS_DADDR_TO_AGBNO(mp, d);
863}
864#endif
865
866#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DADDR_TO_AGNO)
867xfs_agnumber_t
868xfs_daddr_to_agno(xfs_mount_t *mp, xfs_daddr_t d)
869{
870 return XFS_DADDR_TO_AGNO(mp, d);
871}
872#endif
873
874#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DADDR_TO_FSB)
875xfs_fsblock_t
876xfs_daddr_to_fsb(xfs_mount_t *mp, xfs_daddr_t d)
877{
878 return XFS_DADDR_TO_FSB(mp, d);
879}
880#endif
881
882#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DFORK_APTR)
883char *
884xfs_dfork_aptr(xfs_dinode_t *dip)
885{
886 return XFS_DFORK_APTR(dip);
887}
888#endif
889
890#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DFORK_ASIZE)
891int
892xfs_dfork_asize(xfs_dinode_t *dip, xfs_mount_t *mp)
893{
894 return XFS_DFORK_ASIZE(dip, mp);
895}
896#endif
897
898#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DFORK_BOFF)
899int
900xfs_dfork_boff(xfs_dinode_t *dip)
901{
902 return XFS_DFORK_BOFF(dip);
903}
904#endif
905
906#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DFORK_DPTR)
907char *
908xfs_dfork_dptr(xfs_dinode_t *dip)
909{
910 return XFS_DFORK_DPTR(dip);
911}
912#endif
913
914#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DFORK_DSIZE)
915int
916xfs_dfork_dsize(xfs_dinode_t *dip, xfs_mount_t *mp)
917{
918 return XFS_DFORK_DSIZE(dip, mp);
919}
920#endif
921
922#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DFORK_NEXTENTS)
923int
924xfs_dfork_nextents(xfs_dinode_t *dip, int w)
925{
926 return XFS_DFORK_NEXTENTS(dip, w);
927}
928#endif
929
930#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DFORK_PTR)
931char *
932xfs_dfork_ptr(xfs_dinode_t *dip, int w)
933{
934 return XFS_DFORK_PTR(dip, w);
935}
936#endif
937
938#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DFORK_Q)
939int
940xfs_dfork_q(xfs_dinode_t *dip)
941{
942 return XFS_DFORK_Q(dip);
943}
944#endif
945
946#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DFORK_SIZE)
947int
948xfs_dfork_size(xfs_dinode_t *dip, xfs_mount_t *mp, int w)
949{
950 return XFS_DFORK_SIZE(dip, mp, w);
951}
952#endif
953
954#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DINODE_GOOD_VERSION)
955int
956xfs_dinode_good_version(int v)
957{
958 return XFS_DINODE_GOOD_VERSION(v);
959}
960#endif
961
962#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DIR_LEAF_ENTSIZE_BYENTRY)
963int
964xfs_dir_leaf_entsize_byentry(xfs_dir_leaf_entry_t *entry)
965{
966 return XFS_DIR_LEAF_ENTSIZE_BYENTRY(entry);
967}
968#endif
969
970#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DIR_LEAF_ENTSIZE_BYNAME)
971int
972xfs_dir_leaf_entsize_byname(int len)
973{
974 return XFS_DIR_LEAF_ENTSIZE_BYNAME(len);
975}
976#endif
977
978#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DIR_LEAF_NAMESTRUCT)
979xfs_dir_leaf_name_t *
980xfs_dir_leaf_namestruct(xfs_dir_leafblock_t *leafp, int offset)
981{
982 return XFS_DIR_LEAF_NAMESTRUCT(leafp, offset);
983}
984#endif
985
986#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DIR_SF_ALLFIT)
987int
988xfs_dir_sf_allfit(int count, int totallen)
989{
990 return XFS_DIR_SF_ALLFIT(count, totallen);
991}
992#endif
993
994#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DIR_SF_ENTSIZE_BYENTRY)
995int
996xfs_dir_sf_entsize_byentry(xfs_dir_sf_entry_t *sfep)
997{
998 return XFS_DIR_SF_ENTSIZE_BYENTRY(sfep);
999}
1000#endif
1001
1002#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DIR_SF_ENTSIZE_BYNAME)
1003int
1004xfs_dir_sf_entsize_byname(int len)
1005{
1006 return XFS_DIR_SF_ENTSIZE_BYNAME(len);
1007}
1008#endif
1009
1010#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DIR_SF_GET_DIRINO)
1011void
1012xfs_dir_sf_get_dirino(xfs_dir_ino_t *from, xfs_ino_t *to)
1013{
1014 XFS_DIR_SF_GET_DIRINO(from, to);
1015}
1016#endif
1017
1018#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DIR_SF_NEXTENTRY)
1019xfs_dir_sf_entry_t *
1020xfs_dir_sf_nextentry(xfs_dir_sf_entry_t *sfep)
1021{
1022 return XFS_DIR_SF_NEXTENTRY(sfep);
1023}
1024#endif
1025
1026#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DIR_SF_PUT_DIRINO)
1027void
1028xfs_dir_sf_put_dirino(xfs_ino_t *from, xfs_dir_ino_t *to)
1029{
1030 XFS_DIR_SF_PUT_DIRINO(from, to);
1031}
1032#endif
1033
1034#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DIR2_BLOCK_LEAF_P)
1035xfs_dir2_leaf_entry_t *
1036xfs_dir2_block_leaf_p(xfs_dir2_block_tail_t *btp)
1037{
1038 return XFS_DIR2_BLOCK_LEAF_P(btp);
1039}
1040#endif
1041
1042#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DIR2_BLOCK_TAIL_P)
1043xfs_dir2_block_tail_t *
1044xfs_dir2_block_tail_p(xfs_mount_t *mp, xfs_dir2_block_t *block)
1045{
1046 return XFS_DIR2_BLOCK_TAIL_P(mp, block);
1047}
1048#endif
1049
1050#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DIR2_BYTE_TO_DA)
1051xfs_dablk_t
1052xfs_dir2_byte_to_da(xfs_mount_t *mp, xfs_dir2_off_t by)
1053{
1054 return XFS_DIR2_BYTE_TO_DA(mp, by);
1055}
1056#endif
1057
1058#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DIR2_BYTE_TO_DATAPTR)
1059/* ARGSUSED */
1060xfs_dir2_dataptr_t
1061xfs_dir2_byte_to_dataptr(xfs_mount_t *mp, xfs_dir2_off_t by)
1062{
1063 return XFS_DIR2_BYTE_TO_DATAPTR(mp, by);
1064}
1065#endif
1066
1067#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DIR2_BYTE_TO_DB)
1068xfs_dir2_db_t
1069xfs_dir2_byte_to_db(xfs_mount_t *mp, xfs_dir2_off_t by)
1070{
1071 return XFS_DIR2_BYTE_TO_DB(mp, by);
1072}
1073#endif
1074
1075#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DIR2_BYTE_TO_OFF)
1076xfs_dir2_data_aoff_t
1077xfs_dir2_byte_to_off(xfs_mount_t *mp, xfs_dir2_off_t by)
1078{
1079 return XFS_DIR2_BYTE_TO_OFF(mp, by);
1080}
1081#endif
1082
1083#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DIR2_DA_TO_BYTE)
1084xfs_dir2_off_t
1085xfs_dir2_da_to_byte(xfs_mount_t *mp, xfs_dablk_t da)
1086{
1087 return XFS_DIR2_DA_TO_BYTE(mp, da);
1088}
1089#endif
1090
1091#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DIR2_DA_TO_DB)
1092xfs_dir2_db_t
1093xfs_dir2_da_to_db(xfs_mount_t *mp, xfs_dablk_t da)
1094{
1095 return XFS_DIR2_DA_TO_DB(mp, da);
1096}
1097#endif
1098
1099#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DIR2_DATA_ENTRY_TAG_P)
1100xfs_dir2_data_off_t *
1101xfs_dir2_data_entry_tag_p(xfs_dir2_data_entry_t *dep)
1102{
1103 return XFS_DIR2_DATA_ENTRY_TAG_P(dep);
1104}
1105#endif
1106
1107#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DIR2_DATA_ENTSIZE)
1108int
1109xfs_dir2_data_entsize(int n)
1110{
1111 return XFS_DIR2_DATA_ENTSIZE(n);
1112}
1113#endif
1114
1115#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DIR2_DATA_UNUSED_TAG_P)
1116xfs_dir2_data_off_t *
1117xfs_dir2_data_unused_tag_p(xfs_dir2_data_unused_t *dup)
1118{
1119 return XFS_DIR2_DATA_UNUSED_TAG_P(dup);
1120}
1121#endif
1122
1123#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DIR2_DATAPTR_TO_BYTE)
1124/* ARGSUSED */
1125xfs_dir2_off_t
1126xfs_dir2_dataptr_to_byte(xfs_mount_t *mp, xfs_dir2_dataptr_t dp)
1127{
1128 return XFS_DIR2_DATAPTR_TO_BYTE(mp, dp);
1129}
1130#endif
1131
1132#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DIR2_DATAPTR_TO_DB)
1133xfs_dir2_db_t
1134xfs_dir2_dataptr_to_db(xfs_mount_t *mp, xfs_dir2_dataptr_t dp)
1135{
1136 return XFS_DIR2_DATAPTR_TO_DB(mp, dp);
1137}
1138#endif
1139
1140#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DIR2_DATAPTR_TO_OFF)
1141xfs_dir2_data_aoff_t
1142xfs_dir2_dataptr_to_off(xfs_mount_t *mp, xfs_dir2_dataptr_t dp)
1143{
1144 return XFS_DIR2_DATAPTR_TO_OFF(mp, dp);
1145}
1146#endif
1147
1148#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DIR2_DB_OFF_TO_BYTE)
1149xfs_dir2_off_t
1150xfs_dir2_db_off_to_byte(xfs_mount_t *mp, xfs_dir2_db_t db,
1151 xfs_dir2_data_aoff_t o)
1152{
1153 return XFS_DIR2_DB_OFF_TO_BYTE(mp, db, o);
1154}
1155#endif
1156
1157#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DIR2_DB_OFF_TO_DATAPTR)
1158xfs_dir2_dataptr_t
1159xfs_dir2_db_off_to_dataptr(xfs_mount_t *mp, xfs_dir2_db_t db,
1160 xfs_dir2_data_aoff_t o)
1161{
1162 return XFS_DIR2_DB_OFF_TO_DATAPTR(mp, db, o);
1163}
1164#endif
1165
1166#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DIR2_DB_TO_DA)
1167xfs_dablk_t
1168xfs_dir2_db_to_da(xfs_mount_t *mp, xfs_dir2_db_t db)
1169{
1170 return XFS_DIR2_DB_TO_DA(mp, db);
1171}
1172#endif
1173
1174#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DIR2_DB_TO_FDB)
1175xfs_dir2_db_t
1176xfs_dir2_db_to_fdb(xfs_mount_t *mp, xfs_dir2_db_t db)
1177{
1178 return XFS_DIR2_DB_TO_FDB(mp, db);
1179}
1180#endif
1181
1182#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DIR2_DB_TO_FDINDEX)
1183int
1184xfs_dir2_db_to_fdindex(xfs_mount_t *mp, xfs_dir2_db_t db)
1185{
1186 return XFS_DIR2_DB_TO_FDINDEX(mp, db);
1187}
1188#endif
1189
1190#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DIR2_LEAF_BESTS_P)
1191xfs_dir2_data_off_t *
1192xfs_dir2_leaf_bests_p(xfs_dir2_leaf_tail_t *ltp)
1193{
1194 return XFS_DIR2_LEAF_BESTS_P(ltp);
1195}
1196#endif
1197
1198#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DIR2_LEAF_TAIL_P)
1199xfs_dir2_leaf_tail_t *
1200xfs_dir2_leaf_tail_p(xfs_mount_t *mp, xfs_dir2_leaf_t *lp)
1201{
1202 return XFS_DIR2_LEAF_TAIL_P(mp, lp);
1203}
1204#endif
1205
1206#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DIR2_MAX_LEAF_ENTS)
1207int
1208xfs_dir2_max_leaf_ents(xfs_mount_t *mp)
1209{
1210 return XFS_DIR2_MAX_LEAF_ENTS(mp);
1211}
1212#endif
1213
1214#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DIR2_SF_ENTSIZE_BYENTRY)
1215int
1216xfs_dir2_sf_entsize_byentry(xfs_dir2_sf_t *sfp, xfs_dir2_sf_entry_t *sfep)
1217{
1218 return XFS_DIR2_SF_ENTSIZE_BYENTRY(sfp, sfep);
1219}
1220#endif
1221
1222#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DIR2_SF_FIRSTENTRY)
1223xfs_dir2_sf_entry_t *
1224xfs_dir2_sf_firstentry(xfs_dir2_sf_t *sfp)
1225{
1226 return XFS_DIR2_SF_FIRSTENTRY(sfp);
1227}
1228#endif
1229
1230#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DIR2_SF_ENTSIZE_BYNAME)
1231int
1232xfs_dir2_sf_entsize_byname(xfs_dir2_sf_t *sfp, int len)
1233{
1234 return XFS_DIR2_SF_ENTSIZE_BYNAME(sfp, len);
1235}
1236#endif
1237
1238#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DIR2_SF_GET_INUMBER)
1239xfs_intino_t
1240xfs_dir2_sf_get_inumber(xfs_dir2_sf_t *sfp, xfs_dir2_inou_t *from)
1241{
1242 return XFS_DIR2_SF_GET_INUMBER(sfp, from);
1243}
1244#endif
1245
1246#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DIR2_SF_GET_OFFSET)
1247xfs_dir2_data_aoff_t
1248xfs_dir2_sf_get_offset(xfs_dir2_sf_entry_t *sfep)
1249{
1250 return XFS_DIR2_SF_GET_OFFSET(sfep);
1251}
1252#endif
1253
1254#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DIR2_SF_HDR_SIZE)
1255int
1256xfs_dir2_sf_hdr_size(int i8count)
1257{
1258 return XFS_DIR2_SF_HDR_SIZE(i8count);
1259}
1260#endif
1261
1262#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DIR2_SF_INUMBERP)
1263xfs_dir2_inou_t *
1264xfs_dir2_sf_inumberp(xfs_dir2_sf_entry_t *sfep)
1265{
1266 return XFS_DIR2_SF_INUMBERP(sfep);
1267}
1268#endif
1269
1270#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DIR2_SF_NEXTENTRY)
1271xfs_dir2_sf_entry_t *
1272xfs_dir2_sf_nextentry(xfs_dir2_sf_t *sfp, xfs_dir2_sf_entry_t *sfep)
1273{
1274 return XFS_DIR2_SF_NEXTENTRY(sfp, sfep);
1275}
1276#endif
1277
1278#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DIR2_SF_PUT_INUMBER)
1279void
1280xfs_dir2_sf_put_inumber(xfs_dir2_sf_t *sfp, xfs_ino_t *from, xfs_dir2_inou_t *to)
1281{
1282 XFS_DIR2_SF_PUT_INUMBER(sfp, from, to);
1283}
1284#endif
1285
1286#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DIR2_SF_PUT_OFFSET)
1287void
1288xfs_dir2_sf_put_offset(xfs_dir2_sf_entry_t *sfep, xfs_dir2_data_aoff_t off)
1289{
1290 XFS_DIR2_SF_PUT_OFFSET(sfep, off);
1291}
1292#endif
1293
1294#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_EXTFMT_INODE )
1295xfs_exntfmt_t
1296xfs_extfmt_inode(struct xfs_inode *ip)
1297{
1298 return XFS_EXTFMT_INODE(ip);
1299}
1300#endif
1301
1302#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_EXTLEN_MAX)
1303xfs_extlen_t
1304xfs_extlen_max(xfs_extlen_t a, xfs_extlen_t b)
1305{
1306 return XFS_EXTLEN_MAX(a, b);
1307}
1308#endif
1309
1310#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_EXTLEN_MIN)
1311xfs_extlen_t
1312xfs_extlen_min(xfs_extlen_t a, xfs_extlen_t b)
1313{
1314 return XFS_EXTLEN_MIN(a, b);
1315}
1316#endif
1317
1318#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_FILBLKS_MAX)
1319xfs_filblks_t
1320xfs_filblks_max(xfs_filblks_t a, xfs_filblks_t b)
1321{
1322 return XFS_FILBLKS_MAX(a, b);
1323}
1324#endif
1325
1326#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_FILBLKS_MIN)
1327xfs_filblks_t
1328xfs_filblks_min(xfs_filblks_t a, xfs_filblks_t b)
1329{
1330 return XFS_FILBLKS_MIN(a, b);
1331}
1332#endif
1333
1334#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_FILEOFF_MAX)
1335xfs_fileoff_t
1336xfs_fileoff_max(xfs_fileoff_t a, xfs_fileoff_t b)
1337{
1338 return XFS_FILEOFF_MAX(a, b);
1339}
1340#endif
1341
1342#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_FILEOFF_MIN)
1343xfs_fileoff_t
1344xfs_fileoff_min(xfs_fileoff_t a, xfs_fileoff_t b)
1345{
1346 return XFS_FILEOFF_MIN(a, b);
1347}
1348#endif
1349
1350#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_FSB_SANITY_CHECK)
1351int
1352xfs_fsb_sanity_check(xfs_mount_t *mp, xfs_fsblock_t fsbno)
1353{
1354 return XFS_FSB_SANITY_CHECK(mp, fsbno);
1355}
1356#endif
1357
1358#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_FSB_TO_AGBNO)
1359xfs_agblock_t
1360xfs_fsb_to_agbno(xfs_mount_t *mp, xfs_fsblock_t fsbno)
1361{
1362 return XFS_FSB_TO_AGBNO(mp, fsbno);
1363}
1364#endif
1365
1366#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_FSB_TO_AGNO)
1367xfs_agnumber_t
1368xfs_fsb_to_agno(xfs_mount_t *mp, xfs_fsblock_t fsbno)
1369{
1370 return XFS_FSB_TO_AGNO(mp, fsbno);
1371}
1372#endif
1373
1374#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_FSB_TO_DADDR)
1375xfs_daddr_t
1376xfs_fsb_to_daddr(xfs_mount_t *mp, xfs_fsblock_t fsbno)
1377{
1378 return XFS_FSB_TO_DADDR(mp, fsbno);
1379}
1380#endif
1381
1382#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_FSB_TO_DB)
1383xfs_daddr_t
1384xfs_fsb_to_db(xfs_inode_t *ip, xfs_fsblock_t fsb)
1385{
1386 return XFS_FSB_TO_DB(ip, fsb);
1387}
1388#endif
1389
1390#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_HDR_BLOCK)
1391xfs_agblock_t
1392xfs_hdr_block(xfs_mount_t *mp, xfs_daddr_t d)
1393{
1394 return XFS_HDR_BLOCK(mp, d);
1395}
1396#endif
1397
1398#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_IALLOC_BLOCKS)
1399xfs_extlen_t
1400xfs_ialloc_blocks(xfs_mount_t *mp)
1401{
1402 return XFS_IALLOC_BLOCKS(mp);
1403}
1404#endif
1405
1406#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_IALLOC_FIND_FREE)
1407int
1408xfs_ialloc_find_free(xfs_inofree_t *fp)
1409{
1410 return XFS_IALLOC_FIND_FREE(fp);
1411}
1412#endif
1413
1414#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_IALLOC_INODES)
1415int
1416xfs_ialloc_inodes(xfs_mount_t *mp)
1417{
1418 return XFS_IALLOC_INODES(mp);
1419}
1420#endif
1421
1422#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_IBT_BLOCK)
1423xfs_agblock_t
1424xfs_ibt_block(xfs_mount_t *mp)
1425{
1426 return XFS_IBT_BLOCK(mp);
1427}
1428#endif
1429
1430#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_IFORK_ASIZE)
1431int
1432xfs_ifork_asize(xfs_inode_t *ip)
1433{
1434 return XFS_IFORK_ASIZE(ip);
1435}
1436#endif
1437
1438#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_IFORK_DSIZE)
1439int
1440xfs_ifork_dsize(xfs_inode_t *ip)
1441{
1442 return XFS_IFORK_DSIZE(ip);
1443}
1444#endif
1445
1446#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_IFORK_FMT_SET)
1447void
1448xfs_ifork_fmt_set(xfs_inode_t *ip, int w, int n)
1449{
1450 XFS_IFORK_FMT_SET(ip, w, n);
1451}
1452#endif
1453
1454#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_IFORK_FORMAT)
1455int
1456xfs_ifork_format(xfs_inode_t *ip, int w)
1457{
1458 return XFS_IFORK_FORMAT(ip, w);
1459}
1460#endif
1461
1462#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_IFORK_NEXT_SET)
1463void
1464xfs_ifork_next_set(xfs_inode_t *ip, int w, int n)
1465{
1466 XFS_IFORK_NEXT_SET(ip, w, n);
1467}
1468#endif
1469
1470#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_IFORK_NEXTENTS)
1471int
1472xfs_ifork_nextents(xfs_inode_t *ip, int w)
1473{
1474 return XFS_IFORK_NEXTENTS(ip, w);
1475}
1476#endif
1477
1478#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_IFORK_PTR)
1479xfs_ifork_t *
1480xfs_ifork_ptr(xfs_inode_t *ip, int w)
1481{
1482 return XFS_IFORK_PTR(ip, w);
1483}
1484#endif
1485
1486#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_IFORK_Q)
1487int
1488xfs_ifork_q(xfs_inode_t *ip)
1489{
1490 return XFS_IFORK_Q(ip);
1491}
1492#endif
1493
1494#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_IFORK_SIZE)
1495int
1496xfs_ifork_size(xfs_inode_t *ip, int w)
1497{
1498 return XFS_IFORK_SIZE(ip, w);
1499}
1500#endif
1501
1502#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_ILOG_FBROOT)
1503int
1504xfs_ilog_fbroot(int w)
1505{
1506 return XFS_ILOG_FBROOT(w);
1507}
1508#endif
1509
1510#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_ILOG_FDATA)
1511int
1512xfs_ilog_fdata(int w)
1513{
1514 return XFS_ILOG_FDATA(w);
1515}
1516#endif
1517
1518#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_ILOG_FEXT)
1519int
1520xfs_ilog_fext(int w)
1521{
1522 return XFS_ILOG_FEXT(w);
1523}
1524#endif
1525
1526#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_IN_MAXLEVELS)
1527int
1528xfs_in_maxlevels(xfs_mount_t *mp)
1529{
1530 return XFS_IN_MAXLEVELS(mp);
1531}
1532#endif
1533
1534#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_INO_AGBNO_BITS)
1535int
1536xfs_ino_agbno_bits(xfs_mount_t *mp)
1537{
1538 return XFS_INO_AGBNO_BITS(mp);
1539}
1540#endif
1541
1542#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_INO_AGINO_BITS)
1543int
1544xfs_ino_agino_bits(xfs_mount_t *mp)
1545{
1546 return XFS_INO_AGINO_BITS(mp);
1547}
1548#endif
1549
1550#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_INO_AGNO_BITS)
1551int
1552xfs_ino_agno_bits(xfs_mount_t *mp)
1553{
1554 return XFS_INO_AGNO_BITS(mp);
1555}
1556#endif
1557
1558#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_INO_BITS)
1559int
1560xfs_ino_bits(xfs_mount_t *mp)
1561{
1562 return XFS_INO_BITS(mp);
1563}
1564#endif
1565
1566#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_INO_MASK)
1567__uint32_t
1568xfs_ino_mask(int k)
1569{
1570 return XFS_INO_MASK(k);
1571}
1572#endif
1573
1574#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_INO_OFFSET_BITS)
1575int
1576xfs_ino_offset_bits(xfs_mount_t *mp)
1577{
1578 return XFS_INO_OFFSET_BITS(mp);
1579}
1580#endif
1581
1582#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_INO_TO_AGBNO)
1583xfs_agblock_t
1584xfs_ino_to_agbno(xfs_mount_t *mp, xfs_ino_t i)
1585{
1586 return XFS_INO_TO_AGBNO(mp, i);
1587}
1588#endif
1589
1590#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_INO_TO_AGINO)
1591xfs_agino_t
1592xfs_ino_to_agino(xfs_mount_t *mp, xfs_ino_t i)
1593{
1594 return XFS_INO_TO_AGINO(mp, i);
1595}
1596#endif
1597
1598#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_INO_TO_AGNO)
1599xfs_agnumber_t
1600xfs_ino_to_agno(xfs_mount_t *mp, xfs_ino_t i)
1601{
1602 return XFS_INO_TO_AGNO(mp, i);
1603}
1604#endif
1605
1606#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_INO_TO_FSB)
1607xfs_fsblock_t
1608xfs_ino_to_fsb(xfs_mount_t *mp, xfs_ino_t i)
1609{
1610 return XFS_INO_TO_FSB(mp, i);
1611}
1612#endif
1613
1614#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_INO_TO_OFFSET)
1615int
1616xfs_ino_to_offset(xfs_mount_t *mp, xfs_ino_t i)
1617{
1618 return XFS_INO_TO_OFFSET(mp, i);
1619}
1620#endif
1621
1622#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_INOBT_BLOCK_MAXRECS)
1623int
1624xfs_inobt_block_maxrecs(int lev, xfs_btree_cur_t *cur)
1625{
1626 return XFS_INOBT_BLOCK_MAXRECS(lev, cur);
1627}
1628#endif
1629
1630#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_INOBT_BLOCK_MINRECS)
1631int
1632xfs_inobt_block_minrecs(int lev, xfs_btree_cur_t *cur)
1633{
1634 return XFS_INOBT_BLOCK_MINRECS(lev, cur);
1635}
1636#endif
1637
1638#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_INOBT_BLOCK_SIZE)
1639/*ARGSUSED1*/
1640int
1641xfs_inobt_block_size(int lev, xfs_btree_cur_t *cur)
1642{
1643 return XFS_INOBT_BLOCK_SIZE(lev, cur);
1644}
1645#endif
1646
1647#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_INOBT_CLR_FREE)
1648void
1649xfs_inobt_clr_free(xfs_inobt_rec_t *rp, int i)
1650{
1651 XFS_INOBT_CLR_FREE(rp, i);
1652}
1653#endif
1654
1655#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_INOBT_IS_FREE)
1656int
1657xfs_inobt_is_free(xfs_inobt_rec_t *rp, int i)
1658{
1659 return XFS_INOBT_IS_FREE(rp, i);
1660}
1661int
1662xfs_inobt_is_free_disk(xfs_inobt_rec_t *rp, int i)
1663{
1664 return XFS_INOBT_IS_FREE_DISK(rp, i);
1665}
1666#endif
1667
1668#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_INOBT_IS_LAST_REC)
1669int
1670xfs_inobt_is_last_rec(xfs_btree_cur_t *cur)
1671{
1672 return XFS_INOBT_IS_LAST_REC(cur);
1673}
1674#endif
1675
1676#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_INOBT_KEY_ADDR)
1677/*ARGSUSED3*/
1678xfs_inobt_key_t *
1679xfs_inobt_key_addr(xfs_inobt_block_t *bb, int i, xfs_btree_cur_t *cur)
1680{
1681 return XFS_INOBT_KEY_ADDR(bb, i, cur);
1682}
1683#endif
1684
1685#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_INOBT_MASK)
1686xfs_inofree_t
1687xfs_inobt_mask(int i)
1688{
1689 return XFS_INOBT_MASK(i);
1690}
1691#endif
1692
1693#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_INOBT_MASKN)
1694xfs_inofree_t
1695xfs_inobt_maskn(int i, int n)
1696{
1697 return XFS_INOBT_MASKN(i, n);
1698}
1699#endif
1700
1701#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_INOBT_PTR_ADDR)
1702xfs_inobt_ptr_t *
1703xfs_inobt_ptr_addr(xfs_inobt_block_t *bb, int i, xfs_btree_cur_t *cur)
1704{
1705 return XFS_INOBT_PTR_ADDR(bb, i, cur);
1706}
1707#endif
1708
1709#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_INOBT_REC_ADDR)
1710/*ARGSUSED3*/
1711xfs_inobt_rec_t *
1712xfs_inobt_rec_addr(xfs_inobt_block_t *bb, int i, xfs_btree_cur_t *cur)
1713{
1714 return XFS_INOBT_REC_ADDR(bb, i, cur);
1715}
1716#endif
1717
1718#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_INOBT_SET_FREE)
1719void
1720xfs_inobt_set_free(xfs_inobt_rec_t *rp, int i)
1721{
1722 XFS_INOBT_SET_FREE(rp, i);
1723}
1724#endif
1725
1726#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_ITOBHV)
1727bhv_desc_t *
1728xfs_itobhv(xfs_inode_t *ip)
1729{
1730 return XFS_ITOBHV(ip);
1731}
1732#endif
1733
1734#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_ITOV)
1735vnode_t *
1736xfs_itov(xfs_inode_t *ip)
1737{
1738 return XFS_ITOV(ip);
1739}
1740#endif
1741
1742#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_LBLOG)
1743int
1744xfs_lblog(xfs_mount_t *mp)
1745{
1746 return XFS_LBLOG(mp);
1747}
1748#endif
1749
1750#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_LBSIZE)
1751int
1752xfs_lbsize(xfs_mount_t *mp)
1753{
1754 return XFS_LBSIZE(mp);
1755}
1756#endif
1757
1758#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_LIC_ALL_FREE)
1759void
1760xfs_lic_all_free(xfs_log_item_chunk_t *cp)
1761{
1762 XFS_LIC_ALL_FREE(cp);
1763}
1764#endif
1765
1766#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_LIC_ARE_ALL_FREE)
1767int
1768xfs_lic_are_all_free(xfs_log_item_chunk_t *cp)
1769{
1770 return XFS_LIC_ARE_ALL_FREE(cp);
1771}
1772#endif
1773
1774#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_LIC_CLAIM)
1775void
1776xfs_lic_claim(xfs_log_item_chunk_t *cp, int slot)
1777{
1778 XFS_LIC_CLAIM(cp, slot);
1779}
1780#endif
1781
1782#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_LIC_DESC_TO_CHUNK)
1783xfs_log_item_chunk_t *
1784xfs_lic_desc_to_chunk(xfs_log_item_desc_t *dp)
1785{
1786 return XFS_LIC_DESC_TO_CHUNK(dp);
1787}
1788#endif
1789
1790#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_LIC_DESC_TO_SLOT)
1791int
1792xfs_lic_desc_to_slot(xfs_log_item_desc_t *dp)
1793{
1794 return XFS_LIC_DESC_TO_SLOT(dp);
1795}
1796#endif
1797
1798#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_LIC_INIT)
1799void
1800xfs_lic_init(xfs_log_item_chunk_t *cp)
1801{
1802 XFS_LIC_INIT(cp);
1803}
1804#endif
1805
1806#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_LIC_INIT_SLOT)
1807void
1808xfs_lic_init_slot(xfs_log_item_chunk_t *cp, int slot)
1809{
1810 XFS_LIC_INIT_SLOT(cp, slot);
1811}
1812#endif
1813
1814#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_LIC_ISFREE)
1815int
1816xfs_lic_isfree(xfs_log_item_chunk_t *cp, int slot)
1817{
1818 return XFS_LIC_ISFREE(cp, slot);
1819}
1820#endif
1821
1822#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_LIC_RELSE)
1823void
1824xfs_lic_relse(xfs_log_item_chunk_t *cp, int slot)
1825{
1826 XFS_LIC_RELSE(cp, slot);
1827}
1828#endif
1829
1830#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_LIC_SLOT)
1831xfs_log_item_desc_t *
1832xfs_lic_slot(xfs_log_item_chunk_t *cp, int slot)
1833{
1834 return XFS_LIC_SLOT(cp, slot);
1835}
1836#endif
1837
1838#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_LIC_VACANCY)
1839int
1840xfs_lic_vacancy(xfs_log_item_chunk_t *cp)
1841{
1842 return XFS_LIC_VACANCY(cp);
1843}
1844#endif
1845
1846#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_LITINO)
1847int
1848xfs_litino(xfs_mount_t *mp)
1849{
1850 return XFS_LITINO(mp);
1851}
1852#endif
1853
1854#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_MAKE_IPTR)
1855xfs_dinode_t *
1856xfs_make_iptr(xfs_mount_t *mp, xfs_buf_t *b, int o)
1857{
1858 return XFS_MAKE_IPTR(mp, b, o);
1859}
1860#endif
1861
1862#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_MASK32HI)
1863__uint32_t
1864xfs_mask32hi(int n)
1865{
1866 return XFS_MASK32HI(n);
1867}
1868#endif
1869
1870#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_MASK32LO)
1871__uint32_t
1872xfs_mask32lo(int n)
1873{
1874 return XFS_MASK32LO(n);
1875}
1876#endif
1877
1878#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_MASK64HI)
1879__uint64_t
1880xfs_mask64hi(int n)
1881{
1882 return XFS_MASK64HI(n);
1883}
1884#endif
1885
1886#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_MASK64LO)
1887__uint64_t
1888xfs_mask64lo(int n)
1889{
1890 return XFS_MASK64LO(n);
1891}
1892#endif
1893
1894#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_MIN_FREELIST)
1895int
1896xfs_min_freelist(xfs_agf_t *a, xfs_mount_t *mp)
1897{
1898 return XFS_MIN_FREELIST(a, mp);
1899}
1900#endif
1901
1902#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_MIN_FREELIST_PAG)
1903int
1904xfs_min_freelist_pag(xfs_perag_t *pag, xfs_mount_t *mp)
1905{
1906 return XFS_MIN_FREELIST_PAG(pag, mp);
1907}
1908#endif
1909
1910#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_MIN_FREELIST_RAW)
1911int
1912xfs_min_freelist_raw(uint bl, uint cl, xfs_mount_t *mp)
1913{
1914 return XFS_MIN_FREELIST_RAW(bl, cl, mp);
1915}
1916#endif
1917
1918#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_MTOVFS)
1919vfs_t *
1920xfs_mtovfs(xfs_mount_t *mp)
1921{
1922 return XFS_MTOVFS(mp);
1923}
1924#endif
1925
1926#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_OFFBNO_TO_AGINO)
1927xfs_agino_t
1928xfs_offbno_to_agino(xfs_mount_t *mp, xfs_agblock_t b, int o)
1929{
1930 return XFS_OFFBNO_TO_AGINO(mp, b, o);
1931}
1932#endif
1933
1934#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_PREALLOC_BLOCKS)
1935xfs_agblock_t
1936xfs_prealloc_blocks(xfs_mount_t *mp)
1937{
1938 return XFS_PREALLOC_BLOCKS(mp);
1939}
1940#endif
1941
1942#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_SB_BLOCK)
1943xfs_agblock_t
1944xfs_sb_block(xfs_mount_t *mp)
1945{
1946 return XFS_SB_BLOCK(mp);
1947}
1948#endif
1949
1950#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_SB_GOOD_VERSION)
1951int
1952xfs_sb_good_version(xfs_sb_t *sbp)
1953{
1954 return XFS_SB_GOOD_VERSION(sbp);
1955}
1956#endif
1957
1958#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_SB_VERSION_ADDATTR)
1959void
1960xfs_sb_version_addattr(xfs_sb_t *sbp)
1961{
1962 XFS_SB_VERSION_ADDATTR(sbp);
1963}
1964#endif
1965
1966#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_SB_VERSION_ADDDALIGN)
1967void
1968xfs_sb_version_adddalign(xfs_sb_t *sbp)
1969{
1970 XFS_SB_VERSION_ADDDALIGN(sbp);
1971}
1972#endif
1973
1974#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_SB_VERSION_ADDNLINK)
1975void
1976xfs_sb_version_addnlink(xfs_sb_t *sbp)
1977{
1978 XFS_SB_VERSION_ADDNLINK(sbp);
1979}
1980#endif
1981
1982#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_SB_VERSION_ADDQUOTA)
1983void
1984xfs_sb_version_addquota(xfs_sb_t *sbp)
1985{
1986 XFS_SB_VERSION_ADDQUOTA(sbp);
1987}
1988#endif
1989
1990#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_SB_VERSION_ADDSHARED)
1991void
1992xfs_sb_version_addshared(xfs_sb_t *sbp)
1993{
1994 XFS_SB_VERSION_ADDSHARED(sbp);
1995}
1996#endif
1997
1998#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_SB_VERSION_HASALIGN)
1999int
2000xfs_sb_version_hasalign(xfs_sb_t *sbp)
2001{
2002 return XFS_SB_VERSION_HASALIGN(sbp);
2003}
2004#endif
2005
2006#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_SB_VERSION_HASATTR)
2007int
2008xfs_sb_version_hasattr(xfs_sb_t *sbp)
2009{
2010 return XFS_SB_VERSION_HASATTR(sbp);
2011}
2012#endif
2013
2014#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_SB_VERSION_HASDALIGN)
2015int
2016xfs_sb_version_hasdalign(xfs_sb_t *sbp)
2017{
2018 return XFS_SB_VERSION_HASDALIGN(sbp);
2019}
2020#endif
2021
2022#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_SB_VERSION_HASDIRV2)
2023int
2024xfs_sb_version_hasdirv2(xfs_sb_t *sbp)
2025{
2026 return XFS_SB_VERSION_HASDIRV2(sbp);
2027}
2028#endif
2029
2030#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_SB_VERSION_HASEXTFLGBIT)
2031int
2032xfs_sb_version_hasextflgbit(xfs_sb_t *sbp)
2033{
2034 return XFS_SB_VERSION_HASEXTFLGBIT(sbp);
2035}
2036#endif
2037
2038#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_SB_VERSION_HASNLINK)
2039int
2040xfs_sb_version_hasnlink(xfs_sb_t *sbp)
2041{
2042 return XFS_SB_VERSION_HASNLINK(sbp);
2043}
2044#endif
2045
2046#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_SB_VERSION_HASQUOTA)
2047int
2048xfs_sb_version_hasquota(xfs_sb_t *sbp)
2049{
2050 return XFS_SB_VERSION_HASQUOTA(sbp);
2051}
2052#endif
2053
2054#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_SB_VERSION_HASSHARED)
2055int
2056xfs_sb_version_hasshared(xfs_sb_t *sbp)
2057{
2058 return XFS_SB_VERSION_HASSHARED(sbp);
2059}
2060#endif
2061
2062#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_SB_VERSION_NUM)
2063int
2064xfs_sb_version_num(xfs_sb_t *sbp)
2065{
2066 return XFS_SB_VERSION_NUM(sbp);
2067}
2068#endif
2069
2070#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_SB_VERSION_SUBALIGN)
2071void
2072xfs_sb_version_subalign(xfs_sb_t *sbp)
2073{
2074 XFS_SB_VERSION_SUBALIGN(sbp);
2075}
2076#endif
2077
2078#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_SB_VERSION_SUBSHARED)
2079void
2080xfs_sb_version_subshared(xfs_sb_t *sbp)
2081{
2082 XFS_SB_VERSION_SUBSHARED(sbp);
2083}
2084#endif
2085
2086#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_SB_VERSION_HASLOGV2)
2087int
2088xfs_sb_version_haslogv2(xfs_sb_t *sbp)
2089{
2090 return XFS_SB_VERSION_HASLOGV2(sbp);
2091}
2092#endif
2093
2094#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_SB_VERSION_HASSECTOR)
2095int
2096xfs_sb_version_hassector(xfs_sb_t *sbp)
2097{
2098 return XFS_SB_VERSION_HASSECTOR(sbp);
2099}
2100#endif
2101
2102#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_SB_VERSION_TONEW)
2103unsigned
2104xfs_sb_version_tonew(unsigned v)
2105{
2106 return XFS_SB_VERSION_TONEW(v);
2107}
2108#endif
2109
2110#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_SB_VERSION_TOOLD)
2111unsigned
2112xfs_sb_version_toold(unsigned v)
2113{
2114 return XFS_SB_VERSION_TOOLD(v);
2115}
2116#endif
2117
2118#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XLOG_GRANT_ADD_SPACE)
2119void
2120xlog_grant_add_space(xlog_t *log, int bytes, int type)
2121{
2122 XLOG_GRANT_ADD_SPACE(log, bytes, type);
2123}
2124#endif
2125
2126#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XLOG_GRANT_SUB_SPACE)
2127void
2128xlog_grant_sub_space(xlog_t *log, int bytes, int type)
2129{
2130 XLOG_GRANT_SUB_SPACE(log, bytes, type);
2131}
2132#endif
2133
2134#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_SB_VERSION_HASMOREBITS)
2135int
2136xfs_sb_version_hasmorebits(xfs_sb_t *sbp)
2137{
2138 return XFS_SB_VERSION_HASMOREBITS(sbp);
2139}
2140#endif
2141
diff --git a/fs/xfs/xfs_macros.h b/fs/xfs/xfs_macros.h
deleted file mode 100644
index 0a9307514a48..000000000000
--- a/fs/xfs/xfs_macros.h
+++ /dev/null
@@ -1,104 +0,0 @@
1/*
2 * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of version 2 of the GNU General Public License as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it would be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 *
12 * Further, this software is distributed without any warranty that it is
13 * free of the rightful claim of any third person regarding infringement
14 * or the like. Any license provided herein, whether implied or
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */
32#ifndef __XFS_MACROS_H__
33#define __XFS_MACROS_H__
34
35/*
36 * Set for debug kernels and simulation
37 * These replacements save space.
38 * Used in xfs_macros.c.
39 */
40#define XFS_WANT_SPACE_C \
41 (!defined(_STANDALONE) && defined(DEBUG))
42
43/*
44 * Set for debug simulation and kernel builds, but not for standalone.
45 * These replacements do not save space.
46 * Used in xfs_macros.c.
47 */
48#define XFS_WANT_FUNCS_C \
49 (!defined(_STANDALONE) && defined(DEBUG))
50
51/*
52 * Corresponding names used in .h files.
53 */
54#define XFS_WANT_SPACE (XFS_WANT_SPACE_C && !defined(XFS_MACRO_C))
55#define XFS_WANT_FUNCS (XFS_WANT_FUNCS_C && !defined(XFS_MACRO_C))
56
57/*
58 * These are the macros that get turned into functions to save space.
59 */
60#define XFSSO_NULLSTARTBLOCK 1
61#define XFSSO_XFS_AGB_TO_DADDR 1
62#define XFSSO_XFS_AGB_TO_FSB 1
63#define XFSSO_XFS_AGINO_TO_INO 1
64#define XFSSO_XFS_ALLOC_BLOCK_MINRECS 1
65#define XFSSO_XFS_ATTR_SF_NEXTENTRY 1
66#define XFSSO_XFS_BMAP_BLOCK_DMAXRECS 1
67#define XFSSO_XFS_BMAP_BLOCK_IMAXRECS 1
68#define XFSSO_XFS_BMAP_BLOCK_IMINRECS 1
69#define XFSSO_XFS_BMAP_INIT 1
70#define XFSSO_XFS_BMAP_PTR_IADDR 1
71#define XFSSO_XFS_BMAP_SANITY_CHECK 1
72#define XFSSO_XFS_BMAPI_AFLAG 1
73#define XFSSO_XFS_CFORK_SIZE 1
74#define XFSSO_XFS_DA_COOKIE_BNO 1
75#define XFSSO_XFS_DA_COOKIE_ENTRY 1
76#define XFSSO_XFS_DADDR_TO_AGBNO 1
77#define XFSSO_XFS_DADDR_TO_FSB 1
78#define XFSSO_XFS_DFORK_PTR 1
79#define XFSSO_XFS_DIR_SF_GET_DIRINO 1
80#define XFSSO_XFS_DIR_SF_NEXTENTRY 1
81#define XFSSO_XFS_DIR_SF_PUT_DIRINO 1
82#define XFSSO_XFS_FILBLKS_MIN 1
83#define XFSSO_XFS_FSB_SANITY_CHECK 1
84#define XFSSO_XFS_FSB_TO_DADDR 1
85#define XFSSO_XFS_FSB_TO_DB 1
86#define XFSSO_XFS_IALLOC_INODES 1
87#define XFSSO_XFS_IFORK_ASIZE 1
88#define XFSSO_XFS_IFORK_DSIZE 1
89#define XFSSO_XFS_IFORK_FORMAT 1
90#define XFSSO_XFS_IFORK_NEXT_SET 1
91#define XFSSO_XFS_IFORK_NEXTENTS 1
92#define XFSSO_XFS_IFORK_PTR 1
93#define XFSSO_XFS_ILOG_FBROOT 1
94#define XFSSO_XFS_ILOG_FEXT 1
95#define XFSSO_XFS_INO_MASK 1
96#define XFSSO_XFS_INO_TO_FSB 1
97#define XFSSO_XFS_INODE_CLEAR_READ_AHEAD 1
98#define XFSSO_XFS_MIN_FREELIST 1
99#define XFSSO_XFS_SB_GOOD_VERSION 1
100#define XFSSO_XFS_SB_VERSION_HASNLINK 1
101#define XFSSO_XLOG_GRANT_ADD_SPACE 1
102#define XFSSO_XLOG_GRANT_SUB_SPACE 1
103
104#endif /* __XFS_MACROS_H__ */
diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c
index 82e1646e6243..541d5dd474be 100644
--- a/fs/xfs/xfs_mount.c
+++ b/fs/xfs/xfs_mount.c
@@ -1,40 +1,26 @@
1/* 1/*
2 * Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32
33#include "xfs.h" 18#include "xfs.h"
34#include "xfs_macros.h" 19#include "xfs_fs.h"
35#include "xfs_types.h" 20#include "xfs_types.h"
36#include "xfs_inum.h" 21#include "xfs_bit.h"
37#include "xfs_log.h" 22#include "xfs_log.h"
23#include "xfs_inum.h"
38#include "xfs_trans.h" 24#include "xfs_trans.h"
39#include "xfs_sb.h" 25#include "xfs_sb.h"
40#include "xfs_ag.h" 26#include "xfs_ag.h"
@@ -42,21 +28,20 @@
42#include "xfs_dir2.h" 28#include "xfs_dir2.h"
43#include "xfs_dmapi.h" 29#include "xfs_dmapi.h"
44#include "xfs_mount.h" 30#include "xfs_mount.h"
45#include "xfs_alloc_btree.h"
46#include "xfs_bmap_btree.h" 31#include "xfs_bmap_btree.h"
32#include "xfs_alloc_btree.h"
47#include "xfs_ialloc_btree.h" 33#include "xfs_ialloc_btree.h"
48#include "xfs_btree.h"
49#include "xfs_ialloc.h"
50#include "xfs_attr_sf.h"
51#include "xfs_dir_sf.h" 34#include "xfs_dir_sf.h"
52#include "xfs_dir2_sf.h" 35#include "xfs_dir2_sf.h"
36#include "xfs_attr_sf.h"
53#include "xfs_dinode.h" 37#include "xfs_dinode.h"
54#include "xfs_inode.h" 38#include "xfs_inode.h"
39#include "xfs_btree.h"
40#include "xfs_ialloc.h"
55#include "xfs_alloc.h" 41#include "xfs_alloc.h"
56#include "xfs_rtalloc.h" 42#include "xfs_rtalloc.h"
57#include "xfs_bmap.h" 43#include "xfs_bmap.h"
58#include "xfs_error.h" 44#include "xfs_error.h"
59#include "xfs_bit.h"
60#include "xfs_rw.h" 45#include "xfs_rw.h"
61#include "xfs_quota.h" 46#include "xfs_quota.h"
62#include "xfs_fsops.h" 47#include "xfs_fsops.h"
@@ -180,6 +165,10 @@ xfs_mount_free(
180 165
181 if (mp->m_fsname != NULL) 166 if (mp->m_fsname != NULL)
182 kmem_free(mp->m_fsname, mp->m_fsname_len); 167 kmem_free(mp->m_fsname, mp->m_fsname_len);
168 if (mp->m_rtname != NULL)
169 kmem_free(mp->m_rtname, strlen(mp->m_rtname) + 1);
170 if (mp->m_logname != NULL)
171 kmem_free(mp->m_logname, strlen(mp->m_logname) + 1);
183 172
184 if (remove_bhv) { 173 if (remove_bhv) {
185 struct vfs *vfsp = XFS_MTOVFS(mp); 174 struct vfs *vfsp = XFS_MTOVFS(mp);
@@ -318,7 +307,7 @@ xfs_mount_validate_sb(
318 "XFS: Attempted to mount file system with blocksize %d bytes", 307 "XFS: Attempted to mount file system with blocksize %d bytes",
319 sbp->sb_blocksize); 308 sbp->sb_blocksize);
320 cmn_err(CE_WARN, 309 cmn_err(CE_WARN,
321 "XFS: Only page-sized (%d) or less blocksizes currently work.", 310 "XFS: Only page-sized (%ld) or less blocksizes currently work.",
322 PAGE_SIZE); 311 PAGE_SIZE);
323 return XFS_ERROR(ENOSYS); 312 return XFS_ERROR(ENOSYS);
324 } 313 }
@@ -327,7 +316,10 @@ xfs_mount_validate_sb(
327} 316}
328 317
329xfs_agnumber_t 318xfs_agnumber_t
330xfs_initialize_perag(xfs_mount_t *mp, xfs_agnumber_t agcount) 319xfs_initialize_perag(
320 struct vfs *vfs,
321 xfs_mount_t *mp,
322 xfs_agnumber_t agcount)
331{ 323{
332 xfs_agnumber_t index, max_metadata; 324 xfs_agnumber_t index, max_metadata;
333 xfs_perag_t *pag; 325 xfs_perag_t *pag;
@@ -343,7 +335,7 @@ xfs_initialize_perag(xfs_mount_t *mp, xfs_agnumber_t agcount)
343 /* Clear the mount flag if no inode can overflow 32 bits 335 /* Clear the mount flag if no inode can overflow 32 bits
344 * on this filesystem, or if specifically requested.. 336 * on this filesystem, or if specifically requested..
345 */ 337 */
346 if ((mp->m_flags & XFS_MOUNT_32BITINOOPT) && ino > max_inum) { 338 if ((vfs->vfs_flag & VFS_32BITINODES) && ino > max_inum) {
347 mp->m_flags |= XFS_MOUNT_32BITINODES; 339 mp->m_flags |= XFS_MOUNT_32BITINODES;
348 } else { 340 } else {
349 mp->m_flags &= ~XFS_MOUNT_32BITINODES; 341 mp->m_flags &= ~XFS_MOUNT_32BITINODES;
@@ -360,7 +352,7 @@ xfs_initialize_perag(xfs_mount_t *mp, xfs_agnumber_t agcount)
360 icount = sbp->sb_dblocks * sbp->sb_imax_pct; 352 icount = sbp->sb_dblocks * sbp->sb_imax_pct;
361 do_div(icount, 100); 353 do_div(icount, 100);
362 icount += sbp->sb_agblocks - 1; 354 icount += sbp->sb_agblocks - 1;
363 do_div(icount, mp->m_ialloc_blks); 355 do_div(icount, sbp->sb_agblocks);
364 max_metadata = icount; 356 max_metadata = icount;
365 } else { 357 } else {
366 max_metadata = agcount; 358 max_metadata = agcount;
@@ -584,12 +576,13 @@ xfs_mount_common(xfs_mount_t *mp, xfs_sb_t *sbp)
584 ASSERT(sbp->sb_inodesize >= 256 && sbp->sb_inodesize <= 2048); 576 ASSERT(sbp->sb_inodesize >= 256 && sbp->sb_inodesize <= 2048);
585 switch (sbp->sb_inodesize) { 577 switch (sbp->sb_inodesize) {
586 case 256: 578 case 256:
587 mp->m_attroffset = XFS_LITINO(mp) - XFS_BMDR_SPACE_CALC(2); 579 mp->m_attroffset = XFS_LITINO(mp) -
580 XFS_BMDR_SPACE_CALC(MINABTPTRS);
588 break; 581 break;
589 case 512: 582 case 512:
590 case 1024: 583 case 1024:
591 case 2048: 584 case 2048:
592 mp->m_attroffset = XFS_BMDR_SPACE_CALC(12); 585 mp->m_attroffset = XFS_BMDR_SPACE_CALC(6 * MINABTPTRS);
593 break; 586 break;
594 default: 587 default:
595 ASSERT(0); 588 ASSERT(0);
@@ -954,7 +947,7 @@ xfs_mountfs(
954 mp->m_perag = 947 mp->m_perag =
955 kmem_zalloc(sbp->sb_agcount * sizeof(xfs_perag_t), KM_SLEEP); 948 kmem_zalloc(sbp->sb_agcount * sizeof(xfs_perag_t), KM_SLEEP);
956 949
957 mp->m_maxagi = xfs_initialize_perag(mp, sbp->sb_agcount); 950 mp->m_maxagi = xfs_initialize_perag(vfsp, mp, sbp->sb_agcount);
958 951
959 /* 952 /*
960 * log's mount-time initialization. Perform 1st part recovery if needed 953 * log's mount-time initialization. Perform 1st part recovery if needed
diff --git a/fs/xfs/xfs_mount.h b/fs/xfs/xfs_mount.h
index 5affba38a577..08b2e0a5d807 100644
--- a/fs/xfs/xfs_mount.h
+++ b/fs/xfs/xfs_mount.h
@@ -1,38 +1,23 @@
1/* 1/*
2 * Copyright (c) 2000-2005 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32#ifndef __XFS_MOUNT_H__ 18#ifndef __XFS_MOUNT_H__
33#define __XFS_MOUNT_H__ 19#define __XFS_MOUNT_H__
34 20
35
36typedef struct xfs_trans_reservations { 21typedef struct xfs_trans_reservations {
37 uint tr_write; /* extent alloc trans */ 22 uint tr_write; /* extent alloc trans */
38 uint tr_itruncate; /* truncate trans */ 23 uint tr_itruncate; /* truncate trans */
@@ -57,7 +42,6 @@ typedef struct xfs_trans_reservations {
57 uint tr_growrtfree; /* grow realtime freeing */ 42 uint tr_growrtfree; /* grow realtime freeing */
58} xfs_trans_reservations_t; 43} xfs_trans_reservations_t;
59 44
60
61#ifndef __KERNEL__ 45#ifndef __KERNEL__
62/* 46/*
63 * Moved here from xfs_ag.h to avoid reordering header files 47 * Moved here from xfs_ag.h to avoid reordering header files
@@ -80,6 +64,9 @@ struct xfs_iocore;
80struct xfs_bmbt_irec; 64struct xfs_bmbt_irec;
81struct xfs_bmap_free; 65struct xfs_bmap_free;
82 66
67extern struct vfsops xfs_vfsops;
68extern struct vnodeops xfs_vnodeops;
69
83#define AIL_LOCK_T lock_t 70#define AIL_LOCK_T lock_t
84#define AIL_LOCKINIT(x,y) spinlock_init(x,y) 71#define AIL_LOCKINIT(x,y) spinlock_init(x,y)
85#define AIL_LOCK_DESTROY(x) spinlock_destroy(x) 72#define AIL_LOCK_DESTROY(x) spinlock_destroy(x)
@@ -292,6 +279,8 @@ typedef struct xfs_mount {
292 struct xfs_buf *m_sb_bp; /* buffer for superblock */ 279 struct xfs_buf *m_sb_bp; /* buffer for superblock */
293 char *m_fsname; /* filesystem name */ 280 char *m_fsname; /* filesystem name */
294 int m_fsname_len; /* strlen of fs name */ 281 int m_fsname_len; /* strlen of fs name */
282 char *m_rtname; /* realtime device name */
283 char *m_logname; /* external log device name */
295 int m_bsize; /* fs logical block size */ 284 int m_bsize; /* fs logical block size */
296 xfs_agnumber_t m_agfrotor; /* last ag where space found */ 285 xfs_agnumber_t m_agfrotor; /* last ag where space found */
297 xfs_agnumber_t m_agirotor; /* last ag dir inode alloced */ 286 xfs_agnumber_t m_agirotor; /* last ag dir inode alloced */
@@ -344,7 +333,7 @@ typedef struct xfs_mount {
344 sema_t m_growlock; /* growfs mutex */ 333 sema_t m_growlock; /* growfs mutex */
345 int m_fixedfsid[2]; /* unchanged for life of FS */ 334 int m_fixedfsid[2]; /* unchanged for life of FS */
346 uint m_dmevmask; /* DMI events for this FS */ 335 uint m_dmevmask; /* DMI events for this FS */
347 uint m_flags; /* global mount flags */ 336 __uint64_t m_flags; /* global mount flags */
348 uint m_attroffset; /* inode attribute offset */ 337 uint m_attroffset; /* inode attribute offset */
349 uint m_dir_node_ents; /* #entries in a dir danode */ 338 uint m_dir_node_ents; /* #entries in a dir danode */
350 uint m_attr_node_ents; /* #entries in attr danode */ 339 uint m_attr_node_ents; /* #entries in attr danode */
@@ -389,38 +378,41 @@ typedef struct xfs_mount {
389/* 378/*
390 * Flags for m_flags. 379 * Flags for m_flags.
391 */ 380 */
392#define XFS_MOUNT_WSYNC 0x00000001 /* for nfs - all metadata ops 381#define XFS_MOUNT_WSYNC (1ULL << 0) /* for nfs - all metadata ops
393 must be synchronous except 382 must be synchronous except
394 for space allocations */ 383 for space allocations */
395#define XFS_MOUNT_INO64 0x00000002 384#define XFS_MOUNT_INO64 (1ULL << 1)
396 /* 0x00000004 -- currently unused */ 385 /* (1ULL << 2) -- currently unused */
397 /* 0x00000008 -- currently unused */ 386 /* (1ULL << 3) -- currently unused */
398#define XFS_MOUNT_FS_SHUTDOWN 0x00000010 /* atomic stop of all filesystem 387#define XFS_MOUNT_FS_SHUTDOWN (1ULL << 4) /* atomic stop of all filesystem
399 operations, typically for 388 operations, typically for
400 disk errors in metadata */ 389 disk errors in metadata */
401#define XFS_MOUNT_NOATIME 0x00000020 /* don't modify inode access 390#define XFS_MOUNT_NOATIME (1ULL << 5) /* don't modify inode access
402 times on reads */ 391 times on reads */
403#define XFS_MOUNT_RETERR 0x00000040 /* return alignment errors to 392#define XFS_MOUNT_RETERR (1ULL << 6) /* return alignment errors to
404 user */ 393 user */
405#define XFS_MOUNT_NOALIGN 0x00000080 /* turn off stripe alignment 394#define XFS_MOUNT_NOALIGN (1ULL << 7) /* turn off stripe alignment
406 allocations */ 395 allocations */
407 /* 0x00000100 -- currently unused */ 396#define XFS_MOUNT_COMPAT_ATTR (1ULL << 8) /* do not use attr2 format */
408 /* 0x00000200 -- currently unused */ 397 /* (1ULL << 9) -- currently unused */
409#define XFS_MOUNT_NORECOVERY 0x00000400 /* no recovery - dirty fs */ 398#define XFS_MOUNT_NORECOVERY (1ULL << 10) /* no recovery - dirty fs */
410#define XFS_MOUNT_SHARED 0x00000800 /* shared mount */ 399#define XFS_MOUNT_SHARED (1ULL << 11) /* shared mount */
411#define XFS_MOUNT_DFLT_IOSIZE 0x00001000 /* set default i/o size */ 400#define XFS_MOUNT_DFLT_IOSIZE (1ULL << 12) /* set default i/o size */
412#define XFS_MOUNT_OSYNCISOSYNC 0x00002000 /* o_sync is REALLY o_sync */ 401#define XFS_MOUNT_OSYNCISOSYNC (1ULL << 13) /* o_sync is REALLY o_sync */
413 /* osyncisdsync is now default*/ 402 /* osyncisdsync is now default*/
414#define XFS_MOUNT_32BITINODES 0x00004000 /* do not create inodes above 403#define XFS_MOUNT_32BITINODES (1ULL << 14) /* do not create inodes above
415 * 32 bits in size */ 404 * 32 bits in size */
416#define XFS_MOUNT_32BITINOOPT 0x00008000 /* saved mount option state */ 405 /* (1ULL << 15) -- currently unused */
417#define XFS_MOUNT_NOUUID 0x00010000 /* ignore uuid during mount */ 406#define XFS_MOUNT_NOUUID (1ULL << 16) /* ignore uuid during mount */
418#define XFS_MOUNT_NOLOGFLUSH 0x00020000 407#define XFS_MOUNT_BARRIER (1ULL << 17)
419#define XFS_MOUNT_IDELETE 0x00040000 /* delete empty inode clusters*/ 408#define XFS_MOUNT_IDELETE (1ULL << 18) /* delete empty inode clusters*/
420#define XFS_MOUNT_SWALLOC 0x00080000 /* turn on stripe width 409#define XFS_MOUNT_SWALLOC (1ULL << 19) /* turn on stripe width
421 * allocation */ 410 * allocation */
422#define XFS_MOUNT_IHASHSIZE 0x00100000 /* inode hash table size */ 411#define XFS_MOUNT_IHASHSIZE (1ULL << 20) /* inode hash table size */
423#define XFS_MOUNT_DIRSYNC 0x00200000 /* synchronous directory ops */ 412#define XFS_MOUNT_DIRSYNC (1ULL << 21) /* synchronous directory ops */
413#define XFS_MOUNT_COMPAT_IOSIZE (1ULL << 22) /* don't report large preferred
414 * I/O size in stat() */
415
424 416
425/* 417/*
426 * Default minimum read and write sizes. 418 * Default minimum read and write sizes.
@@ -442,6 +434,30 @@ typedef struct xfs_mount {
442#define XFS_WSYNC_READIO_LOG 15 /* 32K */ 434#define XFS_WSYNC_READIO_LOG 15 /* 32K */
443#define XFS_WSYNC_WRITEIO_LOG 14 /* 16K */ 435#define XFS_WSYNC_WRITEIO_LOG 14 /* 16K */
444 436
437/*
438 * Allow large block sizes to be reported to userspace programs if the
439 * "largeio" mount option is used.
440 *
441 * If compatibility mode is specified, simply return the basic unit of caching
442 * so that we don't get inefficient read/modify/write I/O from user apps.
443 * Otherwise....
444 *
445 * If the underlying volume is a stripe, then return the stripe width in bytes
446 * as the recommended I/O size. It is not a stripe and we've set a default
447 * buffered I/O size, return that, otherwise return the compat default.
448 */
449static inline unsigned long
450xfs_preferred_iosize(xfs_mount_t *mp)
451{
452 if (mp->m_flags & XFS_MOUNT_COMPAT_IOSIZE)
453 return PAGE_CACHE_SIZE;
454 return (mp->m_swidth ?
455 (mp->m_swidth << mp->m_sb.sb_blocklog) :
456 ((mp->m_flags & XFS_MOUNT_DFLT_IOSIZE) ?
457 (1 << (int)MAX(mp->m_readio_log, mp->m_writeio_log)) :
458 PAGE_CACHE_SIZE));
459}
460
445#define XFS_MAXIOFFSET(mp) ((mp)->m_maxioffset) 461#define XFS_MAXIOFFSET(mp) ((mp)->m_maxioffset)
446 462
447#define XFS_FORCED_SHUTDOWN(mp) ((mp)->m_flags & XFS_MOUNT_FS_SHUTDOWN) 463#define XFS_FORCED_SHUTDOWN(mp) ((mp)->m_flags & XFS_MOUNT_FS_SHUTDOWN)
@@ -474,57 +490,41 @@ typedef struct xfs_mount {
474/* 490/*
475 * Macros for getting from mount to vfs and back. 491 * Macros for getting from mount to vfs and back.
476 */ 492 */
477#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_MTOVFS)
478struct vfs *xfs_mtovfs(xfs_mount_t *mp);
479#define XFS_MTOVFS(mp) xfs_mtovfs(mp) 493#define XFS_MTOVFS(mp) xfs_mtovfs(mp)
480#else 494static inline struct vfs *xfs_mtovfs(xfs_mount_t *mp)
481#define XFS_MTOVFS(mp) (bhvtovfs(&(mp)->m_bhv)) 495{
482#endif 496 return bhvtovfs(&mp->m_bhv);
483#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BHVTOM) 497}
484xfs_mount_t *xfs_bhvtom(bhv_desc_t *bdp);
485#define XFS_BHVTOM(bdp) xfs_bhvtom(bdp)
486#else
487#define XFS_BHVTOM(bdp) ((xfs_mount_t *)BHV_PDATA(bdp))
488#endif
489#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_VFSTOM)
490xfs_mount_t *xfs_vfstom(vfs_t *vfs);
491#define XFS_VFSTOM(vfs) xfs_vfstom(vfs)
492#else
493#define XFS_VFSTOM(vfs) \
494 (XFS_BHVTOM(bhv_lookup(VFS_BHVHEAD(vfs), &xfs_vfsops)))
495#endif
496 498
499#define XFS_BHVTOM(bdp) xfs_bhvtom(bdp)
500static inline xfs_mount_t *xfs_bhvtom(bhv_desc_t *bdp)
501{
502 return (xfs_mount_t *)BHV_PDATA(bdp);
503}
497 504
498/* 505#define XFS_VFSTOM(vfs) xfs_vfstom(vfs)
499 * Moved here from xfs_ag.h to avoid reordering header files 506static inline xfs_mount_t *xfs_vfstom(vfs_t *vfs)
500 */ 507{
508 return XFS_BHVTOM(bhv_lookup(VFS_BHVHEAD(vfs), &xfs_vfsops));
509}
501 510
502#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DADDR_TO_AGNO)
503xfs_agnumber_t xfs_daddr_to_agno(struct xfs_mount *mp, xfs_daddr_t d);
504#define XFS_DADDR_TO_AGNO(mp,d) xfs_daddr_to_agno(mp,d) 511#define XFS_DADDR_TO_AGNO(mp,d) xfs_daddr_to_agno(mp,d)
505#else 512static inline xfs_agnumber_t
506 513xfs_daddr_to_agno(struct xfs_mount *mp, xfs_daddr_t d)
507static inline xfs_agnumber_t XFS_DADDR_TO_AGNO(xfs_mount_t *mp, xfs_daddr_t d)
508{ 514{
509 d = XFS_BB_TO_FSBT(mp, d); 515 xfs_daddr_t ld = XFS_BB_TO_FSBT(mp, d);
510 do_div(d, mp->m_sb.sb_agblocks); 516 do_div(ld, mp->m_sb.sb_agblocks);
511 return (xfs_agnumber_t) d; 517 return (xfs_agnumber_t) ld;
512} 518}
513 519
514#endif
515#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DADDR_TO_AGBNO)
516xfs_agblock_t xfs_daddr_to_agbno(struct xfs_mount *mp, xfs_daddr_t d);
517#define XFS_DADDR_TO_AGBNO(mp,d) xfs_daddr_to_agbno(mp,d) 520#define XFS_DADDR_TO_AGBNO(mp,d) xfs_daddr_to_agbno(mp,d)
518#else 521static inline xfs_agblock_t
519 522xfs_daddr_to_agbno(struct xfs_mount *mp, xfs_daddr_t d)
520static inline xfs_agblock_t XFS_DADDR_TO_AGBNO(xfs_mount_t *mp, xfs_daddr_t d)
521{ 523{
522 d = XFS_BB_TO_FSBT(mp, d); 524 xfs_daddr_t ld = XFS_BB_TO_FSBT(mp, d);
523 return (xfs_agblock_t) do_div(d, mp->m_sb.sb_agblocks); 525 return (xfs_agblock_t) do_div(ld, mp->m_sb.sb_agblocks);
524} 526}
525 527
526#endif
527
528/* 528/*
529 * This structure is for use by the xfs_mod_incore_sb_batch() routine. 529 * This structure is for use by the xfs_mod_incore_sb_batch() routine.
530 */ 530 */
@@ -542,6 +542,7 @@ extern xfs_mount_t *xfs_mount_init(void);
542extern void xfs_mod_sb(xfs_trans_t *, __int64_t); 542extern void xfs_mod_sb(xfs_trans_t *, __int64_t);
543extern void xfs_mount_free(xfs_mount_t *mp, int remove_bhv); 543extern void xfs_mount_free(xfs_mount_t *mp, int remove_bhv);
544extern int xfs_mountfs(struct vfs *, xfs_mount_t *mp, int); 544extern int xfs_mountfs(struct vfs *, xfs_mount_t *mp, int);
545extern void xfs_mountfs_check_barriers(xfs_mount_t *mp);
545 546
546extern int xfs_unmountfs(xfs_mount_t *, struct cred *); 547extern int xfs_unmountfs(xfs_mount_t *, struct cred *);
547extern void xfs_unmountfs_close(xfs_mount_t *, struct cred *); 548extern void xfs_unmountfs_close(xfs_mount_t *, struct cred *);
@@ -555,12 +556,11 @@ extern int xfs_readsb(xfs_mount_t *mp);
555extern void xfs_freesb(xfs_mount_t *); 556extern void xfs_freesb(xfs_mount_t *);
556extern void xfs_do_force_shutdown(bhv_desc_t *, int, char *, int); 557extern void xfs_do_force_shutdown(bhv_desc_t *, int, char *, int);
557extern int xfs_syncsub(xfs_mount_t *, int, int, int *); 558extern int xfs_syncsub(xfs_mount_t *, int, int, int *);
558extern xfs_agnumber_t xfs_initialize_perag(xfs_mount_t *, xfs_agnumber_t); 559extern int xfs_sync_inodes(xfs_mount_t *, int, int, int *);
560extern xfs_agnumber_t xfs_initialize_perag(struct vfs *, xfs_mount_t *,
561 xfs_agnumber_t);
559extern void xfs_xlatesb(void *, struct xfs_sb *, int, __int64_t); 562extern void xfs_xlatesb(void *, struct xfs_sb *, int, __int64_t);
560 563
561extern struct vfsops xfs_vfsops;
562extern struct vnodeops xfs_vnodeops;
563
564extern struct xfs_dmops xfs_dmcore_stub; 564extern struct xfs_dmops xfs_dmcore_stub;
565extern struct xfs_qmops xfs_qmcore_stub; 565extern struct xfs_qmops xfs_qmcore_stub;
566extern struct xfs_ioops xfs_iocore_xfs; 566extern struct xfs_ioops xfs_iocore_xfs;
diff --git a/fs/xfs/xfs_qmops.c b/fs/xfs/xfs_qmops.c
index a6cd6324e946..1408a32eef88 100644
--- a/fs/xfs/xfs_qmops.c
+++ b/fs/xfs/xfs_qmops.c
@@ -1,40 +1,25 @@
1/* 1/*
2 * Copyright (c) 2000-2005 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32#include "xfs.h" 18#include "xfs.h"
33 19#include "xfs_fs.h"
34#include "xfs_macros.h"
35#include "xfs_types.h" 20#include "xfs_types.h"
36#include "xfs_inum.h"
37#include "xfs_log.h" 21#include "xfs_log.h"
22#include "xfs_inum.h"
38#include "xfs_trans.h" 23#include "xfs_trans.h"
39#include "xfs_sb.h" 24#include "xfs_sb.h"
40#include "xfs_ag.h" 25#include "xfs_ag.h"
diff --git a/fs/xfs/xfs_quota.h b/fs/xfs/xfs_quota.h
index 32cb79752d5d..82a08baf437b 100644
--- a/fs/xfs/xfs_quota.h
+++ b/fs/xfs/xfs_quota.h
@@ -1,33 +1,19 @@
1/* 1/*
2 * Copyright (c) 2000-2005 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32#ifndef __XFS_QUOTA_H__ 18#ifndef __XFS_QUOTA_H__
33#define __XFS_QUOTA_H__ 19#define __XFS_QUOTA_H__
@@ -42,7 +28,7 @@
42 * uid_t and gid_t are hard-coded to 32 bits in the inode. 28 * uid_t and gid_t are hard-coded to 32 bits in the inode.
43 * Hence, an 'id' in a dquot is 32 bits.. 29 * Hence, an 'id' in a dquot is 32 bits..
44 */ 30 */
45typedef __int32_t xfs_dqid_t; 31typedef __uint32_t xfs_dqid_t;
46 32
47/* 33/*
48 * Eventhough users may not have quota limits occupying all 64-bits, 34 * Eventhough users may not have quota limits occupying all 64-bits,
@@ -59,28 +45,28 @@ typedef __uint16_t xfs_qwarncnt_t;
59 * to construct the on disk structure. 45 * to construct the on disk structure.
60 */ 46 */
61typedef struct xfs_disk_dquot { 47typedef struct xfs_disk_dquot {
62/*16*/ u_int16_t d_magic; /* dquot magic = XFS_DQUOT_MAGIC */ 48 __be16 d_magic; /* dquot magic = XFS_DQUOT_MAGIC */
63/*8 */ u_int8_t d_version; /* dquot version */ 49 __u8 d_version; /* dquot version */
64/*8 */ u_int8_t d_flags; /* XFS_DQ_USER/PROJ/GROUP */ 50 __u8 d_flags; /* XFS_DQ_USER/PROJ/GROUP */
65/*32*/ xfs_dqid_t d_id; /* user,project,group id */ 51 __be32 d_id; /* user,project,group id */
66/*64*/ xfs_qcnt_t d_blk_hardlimit;/* absolute limit on disk blks */ 52 __be64 d_blk_hardlimit;/* absolute limit on disk blks */
67/*64*/ xfs_qcnt_t d_blk_softlimit;/* preferred limit on disk blks */ 53 __be64 d_blk_softlimit;/* preferred limit on disk blks */
68/*64*/ xfs_qcnt_t d_ino_hardlimit;/* maximum # allocated inodes */ 54 __be64 d_ino_hardlimit;/* maximum # allocated inodes */
69/*64*/ xfs_qcnt_t d_ino_softlimit;/* preferred inode limit */ 55 __be64 d_ino_softlimit;/* preferred inode limit */
70/*64*/ xfs_qcnt_t d_bcount; /* disk blocks owned by the user */ 56 __be64 d_bcount; /* disk blocks owned by the user */
71/*64*/ xfs_qcnt_t d_icount; /* inodes owned by the user */ 57 __be64 d_icount; /* inodes owned by the user */
72/*32*/ __int32_t d_itimer; /* zero if within inode limits if not, 58 __be32 d_itimer; /* zero if within inode limits if not,
73 this is when we refuse service */ 59 this is when we refuse service */
74/*32*/ __int32_t d_btimer; /* similar to above; for disk blocks */ 60 __be32 d_btimer; /* similar to above; for disk blocks */
75/*16*/ xfs_qwarncnt_t d_iwarns; /* warnings issued wrt num inodes */ 61 __be16 d_iwarns; /* warnings issued wrt num inodes */
76/*16*/ xfs_qwarncnt_t d_bwarns; /* warnings issued wrt disk blocks */ 62 __be16 d_bwarns; /* warnings issued wrt disk blocks */
77/*32*/ __int32_t d_pad0; /* 64 bit align */ 63 __be32 d_pad0; /* 64 bit align */
78/*64*/ xfs_qcnt_t d_rtb_hardlimit;/* absolute limit on realtime blks */ 64 __be64 d_rtb_hardlimit;/* absolute limit on realtime blks */
79/*64*/ xfs_qcnt_t d_rtb_softlimit;/* preferred limit on RT disk blks */ 65 __be64 d_rtb_softlimit;/* preferred limit on RT disk blks */
80/*64*/ xfs_qcnt_t d_rtbcount; /* realtime blocks owned */ 66 __be64 d_rtbcount; /* realtime blocks owned */
81/*32*/ __int32_t d_rtbtimer; /* similar to above; for RT disk blocks */ 67 __be32 d_rtbtimer; /* similar to above; for RT disk blocks */
82/*16*/ xfs_qwarncnt_t d_rtbwarns; /* warnings issued wrt RT disk blocks */ 68 __be16 d_rtbwarns; /* warnings issued wrt RT disk blocks */
83/*16*/ __uint16_t d_pad; 69 __be16 d_pad;
84} xfs_disk_dquot_t; 70} xfs_disk_dquot_t;
85 71
86/* 72/*
diff --git a/fs/xfs/xfs_refcache.h b/fs/xfs/xfs_refcache.h
index cd8ddfd35d69..2dec79edb510 100644
--- a/fs/xfs/xfs_refcache.h
+++ b/fs/xfs/xfs_refcache.h
@@ -1,33 +1,19 @@
1/* 1/*
2 * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32#ifndef __XFS_REFCACHE_H__ 18#ifndef __XFS_REFCACHE_H__
33#define __XFS_REFCACHE_H__ 19#define __XFS_REFCACHE_H__
diff --git a/fs/xfs/xfs_rename.c b/fs/xfs/xfs_rename.c
index 23b48ac1cb7e..4d4e8f4e768e 100644
--- a/fs/xfs/xfs_rename.c
+++ b/fs/xfs/xfs_rename.c
@@ -1,60 +1,45 @@
1/* 1/*
2 * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32
33#include "xfs.h" 18#include "xfs.h"
34#include "xfs_macros.h" 19#include "xfs_fs.h"
35#include "xfs_types.h" 20#include "xfs_types.h"
36#include "xfs_inum.h"
37#include "xfs_log.h" 21#include "xfs_log.h"
22#include "xfs_inum.h"
38#include "xfs_trans.h" 23#include "xfs_trans.h"
39#include "xfs_sb.h" 24#include "xfs_sb.h"
40#include "xfs_dir.h" 25#include "xfs_dir.h"
41#include "xfs_dir2.h" 26#include "xfs_dir2.h"
42#include "xfs_dmapi.h" 27#include "xfs_dmapi.h"
43#include "xfs_mount.h" 28#include "xfs_mount.h"
29#include "xfs_da_btree.h"
44#include "xfs_bmap_btree.h" 30#include "xfs_bmap_btree.h"
45#include "xfs_attr_sf.h"
46#include "xfs_dir_sf.h" 31#include "xfs_dir_sf.h"
47#include "xfs_dir2_sf.h" 32#include "xfs_dir2_sf.h"
33#include "xfs_attr_sf.h"
48#include "xfs_dinode.h" 34#include "xfs_dinode.h"
49#include "xfs_inode_item.h"
50#include "xfs_inode.h" 35#include "xfs_inode.h"
36#include "xfs_inode_item.h"
51#include "xfs_bmap.h" 37#include "xfs_bmap.h"
52#include "xfs_error.h" 38#include "xfs_error.h"
53#include "xfs_quota.h" 39#include "xfs_quota.h"
54#include "xfs_refcache.h" 40#include "xfs_refcache.h"
55#include "xfs_utils.h" 41#include "xfs_utils.h"
56#include "xfs_trans_space.h" 42#include "xfs_trans_space.h"
57#include "xfs_da_btree.h"
58#include "xfs_dir_leaf.h" 43#include "xfs_dir_leaf.h"
59 44
60 45
@@ -620,8 +605,6 @@ xfs_rename(
620 IRELE(target_ip); 605 IRELE(target_ip);
621 } 606 }
622 607
623 FSC_NOTIFY_NAME_CHANGED(XFS_ITOV(src_ip));
624
625 IRELE(src_ip); 608 IRELE(src_ip);
626 609
627 /* Fall through to std_return with error = 0 or errno from 610 /* Fall through to std_return with error = 0 or errno from
diff --git a/fs/xfs/xfs_rtalloc.c b/fs/xfs/xfs_rtalloc.c
index 2c37822d1012..06fc061c50fc 100644
--- a/fs/xfs/xfs_rtalloc.c
+++ b/fs/xfs/xfs_rtalloc.c
@@ -1,44 +1,26 @@
1/* 1/*
2 * Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32
33/*
34 * Free realtime space allocation for XFS.
35 */
36
37#include "xfs.h" 18#include "xfs.h"
38#include "xfs_macros.h" 19#include "xfs_fs.h"
39#include "xfs_types.h" 20#include "xfs_types.h"
40#include "xfs_inum.h" 21#include "xfs_bit.h"
41#include "xfs_log.h" 22#include "xfs_log.h"
23#include "xfs_inum.h"
42#include "xfs_trans.h" 24#include "xfs_trans.h"
43#include "xfs_sb.h" 25#include "xfs_sb.h"
44#include "xfs_ag.h" 26#include "xfs_ag.h"
@@ -46,19 +28,18 @@
46#include "xfs_dir2.h" 28#include "xfs_dir2.h"
47#include "xfs_dmapi.h" 29#include "xfs_dmapi.h"
48#include "xfs_mount.h" 30#include "xfs_mount.h"
49#include "xfs_alloc_btree.h"
50#include "xfs_bmap_btree.h" 31#include "xfs_bmap_btree.h"
32#include "xfs_alloc_btree.h"
51#include "xfs_ialloc_btree.h" 33#include "xfs_ialloc_btree.h"
52#include "xfs_btree.h"
53#include "xfs_ialloc.h"
54#include "xfs_attr_sf.h"
55#include "xfs_dir_sf.h" 34#include "xfs_dir_sf.h"
56#include "xfs_dir2_sf.h" 35#include "xfs_dir2_sf.h"
36#include "xfs_attr_sf.h"
57#include "xfs_dinode.h" 37#include "xfs_dinode.h"
58#include "xfs_inode.h" 38#include "xfs_inode.h"
39#include "xfs_btree.h"
40#include "xfs_ialloc.h"
59#include "xfs_alloc.h" 41#include "xfs_alloc.h"
60#include "xfs_bmap.h" 42#include "xfs_bmap.h"
61#include "xfs_bit.h"
62#include "xfs_rtalloc.h" 43#include "xfs_rtalloc.h"
63#include "xfs_fsops.h" 44#include "xfs_fsops.h"
64#include "xfs_error.h" 45#include "xfs_error.h"
diff --git a/fs/xfs/xfs_rtalloc.h b/fs/xfs/xfs_rtalloc.h
index e2710264c054..0e0b4d2ec202 100644
--- a/fs/xfs/xfs_rtalloc.h
+++ b/fs/xfs/xfs_rtalloc.h
@@ -1,33 +1,19 @@
1/* 1/*
2 * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32#ifndef __XFS_RTALLOC_H__ 18#ifndef __XFS_RTALLOC_H__
33#define __XFS_RTALLOC_H__ 19#define __XFS_RTALLOC_H__
diff --git a/fs/xfs/xfs_rw.c b/fs/xfs/xfs_rw.c
index d3ff7aef33ba..c4b20872f07d 100644
--- a/fs/xfs/xfs_rw.c
+++ b/fs/xfs/xfs_rw.c
@@ -1,40 +1,26 @@
1/* 1/*
2 * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32
33#include "xfs.h" 18#include "xfs.h"
34#include "xfs_macros.h" 19#include "xfs_fs.h"
35#include "xfs_types.h" 20#include "xfs_types.h"
36#include "xfs_inum.h" 21#include "xfs_bit.h"
37#include "xfs_log.h" 22#include "xfs_log.h"
23#include "xfs_inum.h"
38#include "xfs_trans.h" 24#include "xfs_trans.h"
39#include "xfs_sb.h" 25#include "xfs_sb.h"
40#include "xfs_ag.h" 26#include "xfs_ag.h"
@@ -42,20 +28,20 @@
42#include "xfs_dir2.h" 28#include "xfs_dir2.h"
43#include "xfs_dmapi.h" 29#include "xfs_dmapi.h"
44#include "xfs_mount.h" 30#include "xfs_mount.h"
45#include "xfs_alloc_btree.h"
46#include "xfs_bmap_btree.h" 31#include "xfs_bmap_btree.h"
32#include "xfs_alloc_btree.h"
47#include "xfs_ialloc_btree.h" 33#include "xfs_ialloc_btree.h"
34#include "xfs_dir_sf.h"
35#include "xfs_dir2_sf.h"
36#include "xfs_attr_sf.h"
37#include "xfs_dinode.h"
38#include "xfs_inode.h"
39#include "xfs_inode_item.h"
48#include "xfs_itable.h" 40#include "xfs_itable.h"
49#include "xfs_btree.h" 41#include "xfs_btree.h"
50#include "xfs_alloc.h" 42#include "xfs_alloc.h"
51#include "xfs_ialloc.h" 43#include "xfs_ialloc.h"
52#include "xfs_attr.h" 44#include "xfs_attr.h"
53#include "xfs_attr_sf.h"
54#include "xfs_dir_sf.h"
55#include "xfs_dir2_sf.h"
56#include "xfs_dinode.h"
57#include "xfs_inode_item.h"
58#include "xfs_inode.h"
59#include "xfs_bmap.h" 45#include "xfs_bmap.h"
60#include "xfs_acl.h" 46#include "xfs_acl.h"
61#include "xfs_mac.h" 47#include "xfs_mac.h"
@@ -264,7 +250,7 @@ xfs_ioerror_alert(
264{ 250{
265 cmn_err(CE_ALERT, 251 cmn_err(CE_ALERT,
266 "I/O error in filesystem (\"%s\") meta-data dev %s block 0x%llx" 252 "I/O error in filesystem (\"%s\") meta-data dev %s block 0x%llx"
267 " (\"%s\") error %d buf count %u", 253 " (\"%s\") error %d buf count %zd",
268 (!mp || !mp->m_fsname) ? "(fs name not set)" : mp->m_fsname, 254 (!mp || !mp->m_fsname) ? "(fs name not set)" : mp->m_fsname,
269 XFS_BUFTARG_NAME(bp->pb_target), 255 XFS_BUFTARG_NAME(bp->pb_target),
270 (__uint64_t)blkno, 256 (__uint64_t)blkno,
diff --git a/fs/xfs/xfs_rw.h b/fs/xfs/xfs_rw.h
index c8b10bf8f530..de85eefb7966 100644
--- a/fs/xfs/xfs_rw.h
+++ b/fs/xfs/xfs_rw.h
@@ -1,33 +1,19 @@
1/* 1/*
2 * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32#ifndef __XFS_RW_H__ 18#ifndef __XFS_RW_H__
33#define __XFS_RW_H__ 19#define __XFS_RW_H__
@@ -68,87 +54,44 @@ struct xfs_mount;
68 * file is a real time file or not, because the bmap code 54 * file is a real time file or not, because the bmap code
69 * does. 55 * does.
70 */ 56 */
71#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_FSB_TO_DB)
72xfs_daddr_t xfs_fsb_to_db(struct xfs_inode *ip, xfs_fsblock_t fsb);
73#define XFS_FSB_TO_DB(ip,fsb) xfs_fsb_to_db(ip,fsb) 57#define XFS_FSB_TO_DB(ip,fsb) xfs_fsb_to_db(ip,fsb)
74#else 58static inline xfs_daddr_t
75#define XFS_FSB_TO_DB(ip,fsb) \ 59xfs_fsb_to_db(struct xfs_inode *ip, xfs_fsblock_t fsb)
76 (((ip)->i_d.di_flags & XFS_DIFLAG_REALTIME) ? \ 60{
61 return (((ip)->i_d.di_flags & XFS_DIFLAG_REALTIME) ? \
77 (xfs_daddr_t)XFS_FSB_TO_BB((ip)->i_mount, (fsb)) : \ 62 (xfs_daddr_t)XFS_FSB_TO_BB((ip)->i_mount, (fsb)) : \
78 XFS_FSB_TO_DADDR((ip)->i_mount, (fsb))) 63 XFS_FSB_TO_DADDR((ip)->i_mount, (fsb)));
79#endif 64}
80 65#define XFS_FSB_TO_DB_IO(io,fsb) xfs_fsb_to_db_io(io,fsb)
81#define XFS_FSB_TO_DB_IO(io,fsb) \ 66static inline xfs_daddr_t
82 (((io)->io_flags & XFS_IOCORE_RT) ? \ 67xfs_fsb_to_db_io(struct xfs_iocore *io, xfs_fsblock_t fsb)
68{
69 return (((io)->io_flags & XFS_IOCORE_RT) ? \
83 XFS_FSB_TO_BB((io)->io_mount, (fsb)) : \ 70 XFS_FSB_TO_BB((io)->io_mount, (fsb)) : \
84 XFS_FSB_TO_DADDR((io)->io_mount, (fsb))) 71 XFS_FSB_TO_DADDR((io)->io_mount, (fsb)));
72}
85 73
86/* 74/*
87 * Prototypes for functions in xfs_rw.c. 75 * Prototypes for functions in xfs_rw.c.
88 */ 76 */
89 77extern int xfs_write_clear_setuid(struct xfs_inode *ip);
90int 78extern int xfs_bwrite(struct xfs_mount *mp, struct xfs_buf *bp);
91xfs_write_clear_setuid( 79extern int xfs_bioerror(struct xfs_buf *bp);
92 struct xfs_inode *ip); 80extern int xfs_bioerror_relse(struct xfs_buf *bp);
93 81extern int xfs_read_buf(struct xfs_mount *mp, xfs_buftarg_t *btp,
94int 82 xfs_daddr_t blkno, int len, uint flags,
95xfs_bwrite( 83 struct xfs_buf **bpp);
96 struct xfs_mount *mp, 84extern void xfs_ioerror_alert(char *func, struct xfs_mount *mp,
97 struct xfs_buf *bp); 85 xfs_buf_t *bp, xfs_daddr_t blkno);
98
99int
100xfs_bioerror(
101 struct xfs_buf *b);
102
103int
104xfs_bioerror_relse(
105 struct xfs_buf *b);
106
107int
108xfs_read_buf(
109 struct xfs_mount *mp,
110 xfs_buftarg_t *target,
111 xfs_daddr_t blkno,
112 int len,
113 uint flags,
114 struct xfs_buf **bpp);
115
116void
117xfs_ioerror_alert(
118 char *func,
119 struct xfs_mount *mp,
120 xfs_buf_t *bp,
121 xfs_daddr_t blkno);
122
123 86
124/* 87/*
125 * Prototypes for functions in xfs_vnodeops.c. 88 * Prototypes for functions in xfs_vnodeops.c.
126 */ 89 */
127 90extern int xfs_rwlock(bhv_desc_t *bdp, vrwlock_t write_lock);
128int 91extern void xfs_rwunlock(bhv_desc_t *bdp, vrwlock_t write_lock);
129xfs_rwlock( 92extern int xfs_change_file_space(bhv_desc_t *bdp, int cmd, xfs_flock64_t *bf,
130 bhv_desc_t *bdp, 93 xfs_off_t offset, cred_t *credp, int flags);
131 vrwlock_t write_lock); 94extern int xfs_set_dmattrs(bhv_desc_t *bdp, u_int evmask, u_int16_t state,
132 95 cred_t *credp);
133void
134xfs_rwunlock(
135 bhv_desc_t *bdp,
136 vrwlock_t write_lock);
137
138int
139xfs_change_file_space(
140 bhv_desc_t *bdp,
141 int cmd,
142 xfs_flock64_t *bf,
143 xfs_off_t offset,
144 cred_t *credp,
145 int flags);
146
147int
148xfs_set_dmattrs(
149 bhv_desc_t *bdp,
150 u_int evmask,
151 u_int16_t state,
152 cred_t *credp);
153 96
154#endif /* __XFS_RW_H__ */ 97#endif /* __XFS_RW_H__ */
diff --git a/fs/xfs/xfs_sb.h b/fs/xfs/xfs_sb.h
index ad090a834ced..4a17d335f897 100644
--- a/fs/xfs/xfs_sb.h
+++ b/fs/xfs/xfs_sb.h
@@ -1,33 +1,19 @@
1/* 1/*
2 * Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32#ifndef __XFS_SB_H__ 18#ifndef __XFS_SB_H__
33#define __XFS_SB_H__ 19#define __XFS_SB_H__
@@ -72,7 +58,8 @@ struct xfs_mount;
72 XFS_SB_VERSION_DALIGNBIT | \ 58 XFS_SB_VERSION_DALIGNBIT | \
73 XFS_SB_VERSION_SHAREDBIT | \ 59 XFS_SB_VERSION_SHAREDBIT | \
74 XFS_SB_VERSION_LOGV2BIT | \ 60 XFS_SB_VERSION_LOGV2BIT | \
75 XFS_SB_VERSION_SECTORBIT) 61 XFS_SB_VERSION_SECTORBIT | \
62 XFS_SB_VERSION_MOREBITSBIT)
76#define XFS_SB_VERSION_OKSASHBITS \ 63#define XFS_SB_VERSION_OKSASHBITS \
77 (XFS_SB_VERSION_NUMBITS | \ 64 (XFS_SB_VERSION_NUMBITS | \
78 XFS_SB_VERSION_REALFBITS | \ 65 XFS_SB_VERSION_REALFBITS | \
@@ -103,12 +90,15 @@ struct xfs_mount;
103 */ 90 */
104#define XFS_SB_VERSION2_REALFBITS 0x00ffffff /* Mask: features */ 91#define XFS_SB_VERSION2_REALFBITS 0x00ffffff /* Mask: features */
105#define XFS_SB_VERSION2_RESERVED1BIT 0x00000001 92#define XFS_SB_VERSION2_RESERVED1BIT 0x00000001
93#define XFS_SB_VERSION2_RESERVED2BIT 0x00000002
94#define XFS_SB_VERSION2_RESERVED4BIT 0x00000004
95#define XFS_SB_VERSION2_ATTR2BIT 0x00000008 /* Inline attr rework */
106#define XFS_SB_VERSION2_SASHFBITS 0xff000000 /* Mask: features that 96#define XFS_SB_VERSION2_SASHFBITS 0xff000000 /* Mask: features that
107 require changing 97 require changing
108 PROM and SASH */ 98 PROM and SASH */
109 99
110#define XFS_SB_VERSION2_OKREALFBITS \ 100#define XFS_SB_VERSION2_OKREALFBITS \
111 (0) 101 (XFS_SB_VERSION2_ATTR2BIT)
112#define XFS_SB_VERSION2_OKSASHFBITS \ 102#define XFS_SB_VERSION2_OKSASHFBITS \
113 (0) 103 (0)
114#define XFS_SB_VERSION2_OKREALBITS \ 104#define XFS_SB_VERSION2_OKREALBITS \
@@ -118,8 +108,7 @@ struct xfs_mount;
118/* 108/*
119 * mkfs macro to set up sb_features2 word 109 * mkfs macro to set up sb_features2 word
120 */ 110 */
121#define XFS_SB_VERSION2_MKFS(xyz) \ 111#define XFS_SB_VERSION2_MKFS(resvd1, sbcntr) 0
122 ((xyz) ? 0 : 0)
123 112
124typedef struct xfs_sb 113typedef struct xfs_sb
125{ 114{
@@ -176,7 +165,7 @@ typedef struct xfs_sb
176 __uint8_t sb_logsectlog; /* log2 of the log sector size */ 165 __uint8_t sb_logsectlog; /* log2 of the log sector size */
177 __uint16_t sb_logsectsize; /* sector size for the log, bytes */ 166 __uint16_t sb_logsectsize; /* sector size for the log, bytes */
178 __uint32_t sb_logsunit; /* stripe unit size for the log */ 167 __uint32_t sb_logsunit; /* stripe unit size for the log */
179 __uint32_t sb_features2; /* additonal feature bits */ 168 __uint32_t sb_features2; /* additional feature bits */
180} xfs_sb_t; 169} xfs_sb_t;
181 170
182/* 171/*
@@ -216,12 +205,15 @@ typedef enum {
216#define XFS_SB_SHARED_VN XFS_SB_MVAL(SHARED_VN) 205#define XFS_SB_SHARED_VN XFS_SB_MVAL(SHARED_VN)
217#define XFS_SB_UNIT XFS_SB_MVAL(UNIT) 206#define XFS_SB_UNIT XFS_SB_MVAL(UNIT)
218#define XFS_SB_WIDTH XFS_SB_MVAL(WIDTH) 207#define XFS_SB_WIDTH XFS_SB_MVAL(WIDTH)
208#define XFS_SB_FEATURES2 XFS_SB_MVAL(FEATURES2)
219#define XFS_SB_NUM_BITS ((int)XFS_SBS_FIELDCOUNT) 209#define XFS_SB_NUM_BITS ((int)XFS_SBS_FIELDCOUNT)
220#define XFS_SB_ALL_BITS ((1LL << XFS_SB_NUM_BITS) - 1) 210#define XFS_SB_ALL_BITS ((1LL << XFS_SB_NUM_BITS) - 1)
221#define XFS_SB_MOD_BITS \ 211#define XFS_SB_MOD_BITS \
222 (XFS_SB_UUID | XFS_SB_ROOTINO | XFS_SB_RBMINO | XFS_SB_RSUMINO | \ 212 (XFS_SB_UUID | XFS_SB_ROOTINO | XFS_SB_RBMINO | XFS_SB_RSUMINO | \
223 XFS_SB_VERSIONNUM | XFS_SB_UQUOTINO | XFS_SB_GQUOTINO | \ 213 XFS_SB_VERSIONNUM | XFS_SB_UQUOTINO | XFS_SB_GQUOTINO | \
224 XFS_SB_QFLAGS | XFS_SB_SHARED_VN | XFS_SB_UNIT | XFS_SB_WIDTH) 214 XFS_SB_QFLAGS | XFS_SB_SHARED_VN | XFS_SB_UNIT | XFS_SB_WIDTH | \
215 XFS_SB_FEATURES2)
216
225 217
226/* 218/*
227 * Misc. Flags - warning - these will be cleared by xfs_repair unless 219 * Misc. Flags - warning - these will be cleared by xfs_repair unless
@@ -235,42 +227,33 @@ typedef enum {
235 */ 227 */
236#define XFS_SB_MAX_SHARED_VN 0 228#define XFS_SB_MAX_SHARED_VN 0
237 229
238#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_SB_VERSION_NUM)
239int xfs_sb_version_num(xfs_sb_t *sbp);
240#define XFS_SB_VERSION_NUM(sbp) xfs_sb_version_num(sbp)
241#else
242#define XFS_SB_VERSION_NUM(sbp) ((sbp)->sb_versionnum & XFS_SB_VERSION_NUMBITS) 230#define XFS_SB_VERSION_NUM(sbp) ((sbp)->sb_versionnum & XFS_SB_VERSION_NUMBITS)
243#endif
244 231
245#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_SB_GOOD_VERSION)
246int xfs_sb_good_version(xfs_sb_t *sbp);
247#define XFS_SB_GOOD_VERSION(sbp) xfs_sb_good_version(sbp) 232#define XFS_SB_GOOD_VERSION(sbp) xfs_sb_good_version(sbp)
248#else
249#define XFS_SB_GOOD_VERSION_INT(sbp) \
250 ((((sbp)->sb_versionnum >= XFS_SB_VERSION_1) && \
251 ((sbp)->sb_versionnum <= XFS_SB_VERSION_3)) || \
252 ((XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \
253 !(((sbp)->sb_versionnum & ~XFS_SB_VERSION_OKREALBITS) || \
254 (((sbp)->sb_versionnum & XFS_SB_VERSION_MOREBITSBIT) && \
255 ((sbp)->sb_features2 & ~XFS_SB_VERSION2_OKREALBITS)))
256
257#ifdef __KERNEL__ 233#ifdef __KERNEL__
258#define XFS_SB_GOOD_VERSION(sbp) \ 234static inline int xfs_sb_good_version(xfs_sb_t *sbp)
259 (XFS_SB_GOOD_VERSION_INT(sbp) && \ 235{
260 (sbp)->sb_shared_vn <= XFS_SB_MAX_SHARED_VN) )) 236 return (((sbp->sb_versionnum >= XFS_SB_VERSION_1) && \
237 (sbp->sb_versionnum <= XFS_SB_VERSION_3)) || \
238 ((XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \
239 !((sbp->sb_versionnum & ~XFS_SB_VERSION_OKREALBITS) || \
240 ((sbp->sb_versionnum & XFS_SB_VERSION_MOREBITSBIT) && \
241 (sbp->sb_features2 & ~XFS_SB_VERSION2_OKREALBITS))) && \
242 (sbp->sb_shared_vn <= XFS_SB_MAX_SHARED_VN)));
243}
261#else 244#else
262/* 245static inline int xfs_sb_good_version(xfs_sb_t *sbp)
263 * extra 2 paren's here (( to unconfuse paren-matching editors 246{
264 * like vi because XFS_SB_GOOD_VERSION_INT is a partial expression 247 return (((sbp->sb_versionnum >= XFS_SB_VERSION_1) && \
265 * and the two XFS_SB_GOOD_VERSION's each 2 more close paren's to 248 (sbp->sb_versionnum <= XFS_SB_VERSION_3)) || \
266 * complete the expression. 249 ((XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \
267 */ 250 !((sbp->sb_versionnum & ~XFS_SB_VERSION_OKREALBITS) || \
268#define XFS_SB_GOOD_VERSION(sbp) \ 251 ((sbp->sb_versionnum & XFS_SB_VERSION_MOREBITSBIT) && \
269 (XFS_SB_GOOD_VERSION_INT(sbp) && \ 252 (sbp->sb_features2 & ~XFS_SB_VERSION2_OKREALBITS))) && \
270 (!((sbp)->sb_versionnum & XFS_SB_VERSION_SHAREDBIT) || \ 253 (!(sbp->sb_versionnum & XFS_SB_VERSION_SHAREDBIT) || \
271 (sbp)->sb_shared_vn <= XFS_SB_MAX_SHARED_VN)) )) 254 (sbp->sb_shared_vn <= XFS_SB_MAX_SHARED_VN))));
255}
272#endif /* __KERNEL__ */ 256#endif /* __KERNEL__ */
273#endif
274 257
275#define XFS_SB_GOOD_SASH_VERSION(sbp) \ 258#define XFS_SB_GOOD_SASH_VERSION(sbp) \
276 ((((sbp)->sb_versionnum >= XFS_SB_VERSION_1) && \ 259 ((((sbp)->sb_versionnum >= XFS_SB_VERSION_1) && \
@@ -278,275 +261,218 @@ int xfs_sb_good_version(xfs_sb_t *sbp);
278 ((XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \ 261 ((XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \
279 !((sbp)->sb_versionnum & ~XFS_SB_VERSION_OKSASHBITS))) 262 !((sbp)->sb_versionnum & ~XFS_SB_VERSION_OKSASHBITS)))
280 263
281#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_SB_VERSION_TONEW)
282unsigned xfs_sb_version_tonew(unsigned v);
283#define XFS_SB_VERSION_TONEW(v) xfs_sb_version_tonew(v) 264#define XFS_SB_VERSION_TONEW(v) xfs_sb_version_tonew(v)
284#else 265static inline unsigned xfs_sb_version_tonew(unsigned v)
285#define XFS_SB_VERSION_TONEW(v) \ 266{
286 ((((v) == XFS_SB_VERSION_1) ? \ 267 return ((((v) == XFS_SB_VERSION_1) ? \
287 0 : \ 268 0 : \
288 (((v) == XFS_SB_VERSION_2) ? \ 269 (((v) == XFS_SB_VERSION_2) ? \
289 XFS_SB_VERSION_ATTRBIT : \ 270 XFS_SB_VERSION_ATTRBIT : \
290 (XFS_SB_VERSION_ATTRBIT | XFS_SB_VERSION_NLINKBIT))) | \ 271 (XFS_SB_VERSION_ATTRBIT | XFS_SB_VERSION_NLINKBIT))) | \
291 XFS_SB_VERSION_4) 272 XFS_SB_VERSION_4);
292#endif 273}
293 274
294#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_SB_VERSION_TOOLD)
295unsigned xfs_sb_version_toold(unsigned v);
296#define XFS_SB_VERSION_TOOLD(v) xfs_sb_version_toold(v) 275#define XFS_SB_VERSION_TOOLD(v) xfs_sb_version_toold(v)
297#else 276static inline unsigned xfs_sb_version_toold(unsigned v)
298#define XFS_SB_VERSION_TOOLD(v) \ 277{
299 (((v) & (XFS_SB_VERSION_QUOTABIT | XFS_SB_VERSION_ALIGNBIT)) ? \ 278 return (((v) & (XFS_SB_VERSION_QUOTABIT | XFS_SB_VERSION_ALIGNBIT)) ? \
300 0 : \ 279 0 : \
301 (((v) & XFS_SB_VERSION_NLINKBIT) ? \ 280 (((v) & XFS_SB_VERSION_NLINKBIT) ? \
302 XFS_SB_VERSION_3 : \ 281 XFS_SB_VERSION_3 : \
303 (((v) & XFS_SB_VERSION_ATTRBIT) ? \ 282 (((v) & XFS_SB_VERSION_ATTRBIT) ? \
304 XFS_SB_VERSION_2 : \ 283 XFS_SB_VERSION_2 : \
305 XFS_SB_VERSION_1))) 284 XFS_SB_VERSION_1)));
306#endif 285}
307 286
308#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_SB_VERSION_HASATTR)
309int xfs_sb_version_hasattr(xfs_sb_t *sbp);
310#define XFS_SB_VERSION_HASATTR(sbp) xfs_sb_version_hasattr(sbp) 287#define XFS_SB_VERSION_HASATTR(sbp) xfs_sb_version_hasattr(sbp)
311#else 288static inline int xfs_sb_version_hasattr(xfs_sb_t *sbp)
312#define XFS_SB_VERSION_HASATTR(sbp) \ 289{
313 (((sbp)->sb_versionnum == XFS_SB_VERSION_2) || \ 290 return ((sbp)->sb_versionnum == XFS_SB_VERSION_2) || \
314 ((sbp)->sb_versionnum == XFS_SB_VERSION_3) || \ 291 ((sbp)->sb_versionnum == XFS_SB_VERSION_3) || \
315 ((XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \ 292 ((XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \
316 ((sbp)->sb_versionnum & XFS_SB_VERSION_ATTRBIT))) 293 ((sbp)->sb_versionnum & XFS_SB_VERSION_ATTRBIT));
317#endif 294}
318 295
319#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_SB_VERSION_ADDATTR)
320void xfs_sb_version_addattr(xfs_sb_t *sbp);
321#define XFS_SB_VERSION_ADDATTR(sbp) xfs_sb_version_addattr(sbp) 296#define XFS_SB_VERSION_ADDATTR(sbp) xfs_sb_version_addattr(sbp)
322#else 297static inline void xfs_sb_version_addattr(xfs_sb_t *sbp)
323#define XFS_SB_VERSION_ADDATTR(sbp) \ 298{
324 ((sbp)->sb_versionnum = \ 299 (sbp)->sb_versionnum = (((sbp)->sb_versionnum == XFS_SB_VERSION_1) ? \
325 (((sbp)->sb_versionnum == XFS_SB_VERSION_1) ? \
326 XFS_SB_VERSION_2 : \ 300 XFS_SB_VERSION_2 : \
327 ((XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) ? \ 301 ((XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) ? \
328 ((sbp)->sb_versionnum | XFS_SB_VERSION_ATTRBIT) : \ 302 ((sbp)->sb_versionnum | XFS_SB_VERSION_ATTRBIT) : \
329 (XFS_SB_VERSION_4 | XFS_SB_VERSION_ATTRBIT)))) 303 (XFS_SB_VERSION_4 | XFS_SB_VERSION_ATTRBIT)));
330#endif 304}
331 305
332#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_SB_VERSION_HASNLINK)
333int xfs_sb_version_hasnlink(xfs_sb_t *sbp);
334#define XFS_SB_VERSION_HASNLINK(sbp) xfs_sb_version_hasnlink(sbp) 306#define XFS_SB_VERSION_HASNLINK(sbp) xfs_sb_version_hasnlink(sbp)
335#else 307static inline int xfs_sb_version_hasnlink(xfs_sb_t *sbp)
336#define XFS_SB_VERSION_HASNLINK(sbp) \ 308{
337 (((sbp)->sb_versionnum == XFS_SB_VERSION_3) || \ 309 return ((sbp)->sb_versionnum == XFS_SB_VERSION_3) || \
338 ((XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \ 310 ((XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \
339 ((sbp)->sb_versionnum & XFS_SB_VERSION_NLINKBIT))) 311 ((sbp)->sb_versionnum & XFS_SB_VERSION_NLINKBIT));
340#endif 312}
341 313
342#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_SB_VERSION_ADDNLINK)
343void xfs_sb_version_addnlink(xfs_sb_t *sbp);
344#define XFS_SB_VERSION_ADDNLINK(sbp) xfs_sb_version_addnlink(sbp) 314#define XFS_SB_VERSION_ADDNLINK(sbp) xfs_sb_version_addnlink(sbp)
345#else 315static inline void xfs_sb_version_addnlink(xfs_sb_t *sbp)
346#define XFS_SB_VERSION_ADDNLINK(sbp) \ 316{
347 ((sbp)->sb_versionnum = \ 317 (sbp)->sb_versionnum = ((sbp)->sb_versionnum <= XFS_SB_VERSION_2 ? \
348 ((sbp)->sb_versionnum <= XFS_SB_VERSION_2 ? \
349 XFS_SB_VERSION_3 : \ 318 XFS_SB_VERSION_3 : \
350 ((sbp)->sb_versionnum | XFS_SB_VERSION_NLINKBIT))) 319 ((sbp)->sb_versionnum | XFS_SB_VERSION_NLINKBIT));
351#endif 320}
352 321
353#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_SB_VERSION_HASQUOTA)
354int xfs_sb_version_hasquota(xfs_sb_t *sbp);
355#define XFS_SB_VERSION_HASQUOTA(sbp) xfs_sb_version_hasquota(sbp) 322#define XFS_SB_VERSION_HASQUOTA(sbp) xfs_sb_version_hasquota(sbp)
356#else 323static inline int xfs_sb_version_hasquota(xfs_sb_t *sbp)
357#define XFS_SB_VERSION_HASQUOTA(sbp) \ 324{
358 ((XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \ 325 return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \
359 ((sbp)->sb_versionnum & XFS_SB_VERSION_QUOTABIT)) 326 ((sbp)->sb_versionnum & XFS_SB_VERSION_QUOTABIT);
360#endif 327}
361 328
362#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_SB_VERSION_ADDQUOTA)
363void xfs_sb_version_addquota(xfs_sb_t *sbp);
364#define XFS_SB_VERSION_ADDQUOTA(sbp) xfs_sb_version_addquota(sbp) 329#define XFS_SB_VERSION_ADDQUOTA(sbp) xfs_sb_version_addquota(sbp)
365#else 330static inline void xfs_sb_version_addquota(xfs_sb_t *sbp)
366#define XFS_SB_VERSION_ADDQUOTA(sbp) \ 331{
367 ((sbp)->sb_versionnum = \ 332 (sbp)->sb_versionnum = \
368 (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4 ? \ 333 (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4 ? \
369 ((sbp)->sb_versionnum | XFS_SB_VERSION_QUOTABIT) : \ 334 ((sbp)->sb_versionnum | XFS_SB_VERSION_QUOTABIT) : \
370 (XFS_SB_VERSION_TONEW((sbp)->sb_versionnum) | \ 335 (XFS_SB_VERSION_TONEW((sbp)->sb_versionnum) | \
371 XFS_SB_VERSION_QUOTABIT))) 336 XFS_SB_VERSION_QUOTABIT));
372#endif 337}
373 338
374#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_SB_VERSION_HASALIGN)
375int xfs_sb_version_hasalign(xfs_sb_t *sbp);
376#define XFS_SB_VERSION_HASALIGN(sbp) xfs_sb_version_hasalign(sbp) 339#define XFS_SB_VERSION_HASALIGN(sbp) xfs_sb_version_hasalign(sbp)
377#else 340static inline int xfs_sb_version_hasalign(xfs_sb_t *sbp)
378#define XFS_SB_VERSION_HASALIGN(sbp) \ 341{
379 ((XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \ 342 return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \
380 ((sbp)->sb_versionnum & XFS_SB_VERSION_ALIGNBIT)) 343 ((sbp)->sb_versionnum & XFS_SB_VERSION_ALIGNBIT);
381#endif 344}
382 345
383#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_SB_VERSION_SUBALIGN)
384void xfs_sb_version_subalign(xfs_sb_t *sbp);
385#define XFS_SB_VERSION_SUBALIGN(sbp) xfs_sb_version_subalign(sbp) 346#define XFS_SB_VERSION_SUBALIGN(sbp) xfs_sb_version_subalign(sbp)
386#else 347static inline void xfs_sb_version_subalign(xfs_sb_t *sbp)
387#define XFS_SB_VERSION_SUBALIGN(sbp) \ 348{
388 ((sbp)->sb_versionnum = \ 349 (sbp)->sb_versionnum = \
389 XFS_SB_VERSION_TOOLD((sbp)->sb_versionnum & ~XFS_SB_VERSION_ALIGNBIT)) 350 XFS_SB_VERSION_TOOLD((sbp)->sb_versionnum & ~XFS_SB_VERSION_ALIGNBIT);
390#endif 351}
391 352
392#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_SB_VERSION_HASDALIGN)
393int xfs_sb_version_hasdalign(xfs_sb_t *sbp);
394#define XFS_SB_VERSION_HASDALIGN(sbp) xfs_sb_version_hasdalign(sbp) 353#define XFS_SB_VERSION_HASDALIGN(sbp) xfs_sb_version_hasdalign(sbp)
395#else 354static inline int xfs_sb_version_hasdalign(xfs_sb_t *sbp)
396#define XFS_SB_VERSION_HASDALIGN(sbp) \ 355{
397 ((XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \ 356 return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \
398 ((sbp)->sb_versionnum & XFS_SB_VERSION_DALIGNBIT)) 357 ((sbp)->sb_versionnum & XFS_SB_VERSION_DALIGNBIT);
399#endif 358}
400 359
401#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_SB_VERSION_ADDDALIGN)
402int xfs_sb_version_adddalign(xfs_sb_t *sbp);
403#define XFS_SB_VERSION_ADDDALIGN(sbp) xfs_sb_version_adddalign(sbp) 360#define XFS_SB_VERSION_ADDDALIGN(sbp) xfs_sb_version_adddalign(sbp)
404#else 361static inline int xfs_sb_version_adddalign(xfs_sb_t *sbp)
405#define XFS_SB_VERSION_ADDDALIGN(sbp) \ 362{
406 ((sbp)->sb_versionnum = \ 363 return (sbp)->sb_versionnum = \
407 ((sbp)->sb_versionnum | XFS_SB_VERSION_DALIGNBIT)) 364 ((sbp)->sb_versionnum | XFS_SB_VERSION_DALIGNBIT);
408#endif 365}
409 366
410#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_SB_VERSION_HASSHARED)
411int xfs_sb_version_hasshared(xfs_sb_t *sbp);
412#define XFS_SB_VERSION_HASSHARED(sbp) xfs_sb_version_hasshared(sbp) 367#define XFS_SB_VERSION_HASSHARED(sbp) xfs_sb_version_hasshared(sbp)
413#else 368static inline int xfs_sb_version_hasshared(xfs_sb_t *sbp)
414#define XFS_SB_VERSION_HASSHARED(sbp) \ 369{
415 ((XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \ 370 return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \
416 ((sbp)->sb_versionnum & XFS_SB_VERSION_SHAREDBIT)) 371 ((sbp)->sb_versionnum & XFS_SB_VERSION_SHAREDBIT);
417#endif 372}
418 373
419#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_SB_VERSION_ADDSHARED)
420int xfs_sb_version_addshared(xfs_sb_t *sbp);
421#define XFS_SB_VERSION_ADDSHARED(sbp) xfs_sb_version_addshared(sbp) 374#define XFS_SB_VERSION_ADDSHARED(sbp) xfs_sb_version_addshared(sbp)
422#else 375static inline int xfs_sb_version_addshared(xfs_sb_t *sbp)
423#define XFS_SB_VERSION_ADDSHARED(sbp) \ 376{
424 ((sbp)->sb_versionnum = \ 377 return (sbp)->sb_versionnum = \
425 ((sbp)->sb_versionnum | XFS_SB_VERSION_SHAREDBIT)) 378 ((sbp)->sb_versionnum | XFS_SB_VERSION_SHAREDBIT);
426#endif 379}
427 380
428#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_SB_VERSION_SUBSHARED)
429int xfs_sb_version_subshared(xfs_sb_t *sbp);
430#define XFS_SB_VERSION_SUBSHARED(sbp) xfs_sb_version_subshared(sbp) 381#define XFS_SB_VERSION_SUBSHARED(sbp) xfs_sb_version_subshared(sbp)
431#else 382static inline int xfs_sb_version_subshared(xfs_sb_t *sbp)
432#define XFS_SB_VERSION_SUBSHARED(sbp) \ 383{
433 ((sbp)->sb_versionnum = \ 384 return (sbp)->sb_versionnum = \
434 ((sbp)->sb_versionnum & ~XFS_SB_VERSION_SHAREDBIT)) 385 ((sbp)->sb_versionnum & ~XFS_SB_VERSION_SHAREDBIT);
435#endif 386}
436 387
437#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_SB_VERSION_HASDIRV2)
438int xfs_sb_version_hasdirv2(xfs_sb_t *sbp);
439#define XFS_SB_VERSION_HASDIRV2(sbp) xfs_sb_version_hasdirv2(sbp) 388#define XFS_SB_VERSION_HASDIRV2(sbp) xfs_sb_version_hasdirv2(sbp)
440#else 389static inline int xfs_sb_version_hasdirv2(xfs_sb_t *sbp)
441#define XFS_SB_VERSION_HASDIRV2(sbp) \ 390{
442 ((XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \ 391 return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \
443 ((sbp)->sb_versionnum & XFS_SB_VERSION_DIRV2BIT)) 392 ((sbp)->sb_versionnum & XFS_SB_VERSION_DIRV2BIT);
444#endif 393}
445 394
446#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_SB_VERSION_HASLOGV2)
447int xfs_sb_version_haslogv2(xfs_sb_t *sbp);
448#define XFS_SB_VERSION_HASLOGV2(sbp) xfs_sb_version_haslogv2(sbp) 395#define XFS_SB_VERSION_HASLOGV2(sbp) xfs_sb_version_haslogv2(sbp)
449#else 396static inline int xfs_sb_version_haslogv2(xfs_sb_t *sbp)
450#define XFS_SB_VERSION_HASLOGV2(sbp) \ 397{
451 ((XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \ 398 return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \
452 ((sbp)->sb_versionnum & XFS_SB_VERSION_LOGV2BIT)) 399 ((sbp)->sb_versionnum & XFS_SB_VERSION_LOGV2BIT);
453#endif 400}
454 401
455#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_SB_VERSION_HASEXTFLGBIT)
456int xfs_sb_version_hasextflgbit(xfs_sb_t *sbp);
457#define XFS_SB_VERSION_HASEXTFLGBIT(sbp) xfs_sb_version_hasextflgbit(sbp) 402#define XFS_SB_VERSION_HASEXTFLGBIT(sbp) xfs_sb_version_hasextflgbit(sbp)
458#else 403static inline int xfs_sb_version_hasextflgbit(xfs_sb_t *sbp)
459#define XFS_SB_VERSION_HASEXTFLGBIT(sbp) \ 404{
460 ((XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \ 405 return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \
461 ((sbp)->sb_versionnum & XFS_SB_VERSION_EXTFLGBIT)) 406 ((sbp)->sb_versionnum & XFS_SB_VERSION_EXTFLGBIT);
462#endif 407}
463 408
464#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_SB_VERSION_ADDEXTFLGBIT)
465int xfs_sb_version_addextflgbit(xfs_sb_t *sbp);
466#define XFS_SB_VERSION_ADDEXTFLGBIT(sbp) xfs_sb_version_addextflgbit(sbp) 409#define XFS_SB_VERSION_ADDEXTFLGBIT(sbp) xfs_sb_version_addextflgbit(sbp)
467#else 410static inline int xfs_sb_version_addextflgbit(xfs_sb_t *sbp)
468#define XFS_SB_VERSION_ADDEXTFLGBIT(sbp) \ 411{
469 ((sbp)->sb_versionnum = \ 412 return (sbp)->sb_versionnum = \
470 ((sbp)->sb_versionnum | XFS_SB_VERSION_EXTFLGBIT)) 413 ((sbp)->sb_versionnum | XFS_SB_VERSION_EXTFLGBIT);
471#endif 414}
472 415
473#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_SB_VERSION_SUBEXTFLGBIT)
474int xfs_sb_version_subextflgbit(xfs_sb_t *sbp);
475#define XFS_SB_VERSION_SUBEXTFLGBIT(sbp) xfs_sb_version_subextflgbit(sbp) 416#define XFS_SB_VERSION_SUBEXTFLGBIT(sbp) xfs_sb_version_subextflgbit(sbp)
476#else 417static inline int xfs_sb_version_subextflgbit(xfs_sb_t *sbp)
477#define XFS_SB_VERSION_SUBEXTFLGBIT(sbp) \ 418{
478 ((sbp)->sb_versionnum = \ 419 return (sbp)->sb_versionnum = \
479 ((sbp)->sb_versionnum & ~XFS_SB_VERSION_EXTFLGBIT)) 420 ((sbp)->sb_versionnum & ~XFS_SB_VERSION_EXTFLGBIT);
480#endif 421}
481 422
482#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_SB_VERSION_HASSECTOR)
483int xfs_sb_version_hassector(xfs_sb_t *sbp);
484#define XFS_SB_VERSION_HASSECTOR(sbp) xfs_sb_version_hassector(sbp) 423#define XFS_SB_VERSION_HASSECTOR(sbp) xfs_sb_version_hassector(sbp)
485#else 424static inline int xfs_sb_version_hassector(xfs_sb_t *sbp)
486#define XFS_SB_VERSION_HASSECTOR(sbp) \ 425{
487 ((XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \ 426 return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \
488 ((sbp)->sb_versionnum & XFS_SB_VERSION_SECTORBIT)) 427 ((sbp)->sb_versionnum & XFS_SB_VERSION_SECTORBIT);
489#endif 428}
490 429
491#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_SB_VERSION_HASMOREBITSBIT)
492int xfs_sb_version_hasmorebits(xfs_sb_t *sbp);
493#define XFS_SB_VERSION_HASMOREBITS(sbp) xfs_sb_version_hasmorebits(sbp) 430#define XFS_SB_VERSION_HASMOREBITS(sbp) xfs_sb_version_hasmorebits(sbp)
494#else 431static inline int xfs_sb_version_hasmorebits(xfs_sb_t *sbp)
495#define XFS_SB_VERSION_HASMOREBITS(sbp) \ 432{
496 ((XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \ 433 return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \
497 ((sbp)->sb_versionnum & XFS_SB_VERSION_MOREBITSBIT)) 434 ((sbp)->sb_versionnum & XFS_SB_VERSION_MOREBITSBIT);
498#endif 435}
499 436
500/* 437/*
501 * sb_features2 bit version macros. 438 * sb_features2 bit version macros.
502 * 439 *
503 * For example, for a bit defined as XFS_SB_VERSION2_YBIT, has a macro: 440 * For example, for a bit defined as XFS_SB_VERSION2_FUNBIT, has a macro:
504 * 441 *
505 * SB_VERSION_HASYBIT(xfs_sb_t *sbp) 442 * SB_VERSION_HASFUNBIT(xfs_sb_t *sbp)
506 * ((XFS_SB_VERSION_HASMOREBITS(sbp) && 443 * ((XFS_SB_VERSION_HASMOREBITS(sbp) &&
507 * ((sbp)->sb_versionnum & XFS_SB_VERSION2_YBIT) 444 * ((sbp)->sb_features2 & XFS_SB_VERSION2_FUNBIT)
508 */ 445 */
509 446
447#define XFS_SB_VERSION_HASATTR2(sbp) xfs_sb_version_hasattr2(sbp)
448static inline int xfs_sb_version_hasattr2(xfs_sb_t *sbp)
449{
450 return (XFS_SB_VERSION_HASMOREBITS(sbp)) && \
451 ((sbp)->sb_features2 & XFS_SB_VERSION2_ATTR2BIT);
452}
453
454#define XFS_SB_VERSION_ADDATTR2(sbp) xfs_sb_version_addattr2(sbp)
455static inline void xfs_sb_version_addattr2(xfs_sb_t *sbp)
456{
457 ((sbp)->sb_versionnum = \
458 ((sbp)->sb_versionnum | XFS_SB_VERSION_MOREBITSBIT), \
459 ((sbp)->sb_features2 = \
460 ((sbp)->sb_features2 | XFS_SB_VERSION2_ATTR2BIT)));
461}
462
510/* 463/*
511 * end of superblock version macros 464 * end of superblock version macros
512 */ 465 */
513 466
514#define XFS_SB_DADDR ((xfs_daddr_t)0) /* daddr in filesystem/ag */ 467#define XFS_SB_DADDR ((xfs_daddr_t)0) /* daddr in filesystem/ag */
515#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_SB_BLOCK)
516xfs_agblock_t xfs_sb_block(struct xfs_mount *mp);
517#define XFS_SB_BLOCK(mp) xfs_sb_block(mp)
518#else
519#define XFS_SB_BLOCK(mp) XFS_HDR_BLOCK(mp, XFS_SB_DADDR) 468#define XFS_SB_BLOCK(mp) XFS_HDR_BLOCK(mp, XFS_SB_DADDR)
520#endif
521
522#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_HDR_BLOCK)
523xfs_agblock_t xfs_hdr_block(struct xfs_mount *mp, xfs_daddr_t d);
524#define XFS_HDR_BLOCK(mp,d) xfs_hdr_block(mp,d)
525#else
526#define XFS_HDR_BLOCK(mp,d) ((xfs_agblock_t)(XFS_BB_TO_FSBT(mp,d)))
527#endif
528#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DADDR_TO_FSB)
529xfs_fsblock_t xfs_daddr_to_fsb(struct xfs_mount *mp, xfs_daddr_t d);
530#define XFS_DADDR_TO_FSB(mp,d) xfs_daddr_to_fsb(mp,d)
531#else
532#define XFS_DADDR_TO_FSB(mp,d) \
533 XFS_AGB_TO_FSB(mp, XFS_DADDR_TO_AGNO(mp,d), XFS_DADDR_TO_AGBNO(mp,d))
534#endif
535#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_FSB_TO_DADDR)
536xfs_daddr_t xfs_fsb_to_daddr(struct xfs_mount *mp, xfs_fsblock_t fsbno);
537#define XFS_FSB_TO_DADDR(mp,fsbno) xfs_fsb_to_daddr(mp,fsbno)
538#else
539#define XFS_FSB_TO_DADDR(mp,fsbno) \
540 XFS_AGB_TO_DADDR(mp, XFS_FSB_TO_AGNO(mp,fsbno), \
541 XFS_FSB_TO_AGBNO(mp,fsbno))
542#endif
543
544#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BUF_TO_SBP)
545xfs_sb_t *xfs_buf_to_sbp(struct xfs_buf *bp);
546#define XFS_BUF_TO_SBP(bp) xfs_buf_to_sbp(bp)
547#else
548#define XFS_BUF_TO_SBP(bp) ((xfs_sb_t *)XFS_BUF_PTR(bp)) 469#define XFS_BUF_TO_SBP(bp) ((xfs_sb_t *)XFS_BUF_PTR(bp))
549#endif 470
471#define XFS_HDR_BLOCK(mp,d) ((xfs_agblock_t)XFS_BB_TO_FSBT(mp,d))
472#define XFS_DADDR_TO_FSB(mp,d) XFS_AGB_TO_FSB(mp, \
473 XFS_DADDR_TO_AGNO(mp,d), XFS_DADDR_TO_AGBNO(mp,d))
474#define XFS_FSB_TO_DADDR(mp,fsbno) XFS_AGB_TO_DADDR(mp, \
475 XFS_FSB_TO_AGNO(mp,fsbno), XFS_FSB_TO_AGBNO(mp,fsbno))
550 476
551/* 477/*
552 * File system sector to basic block conversions. 478 * File system sector to basic block conversions.
diff --git a/fs/xfs/xfs_trans.c b/fs/xfs/xfs_trans.c
index 92efe272b83d..279e043d7323 100644
--- a/fs/xfs/xfs_trans.c
+++ b/fs/xfs/xfs_trans.c
@@ -1,40 +1,26 @@
1/* 1/*
2 * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32
33#include "xfs.h" 18#include "xfs.h"
34#include "xfs_macros.h" 19#include "xfs_fs.h"
35#include "xfs_types.h" 20#include "xfs_types.h"
36#include "xfs_inum.h" 21#include "xfs_bit.h"
37#include "xfs_log.h" 22#include "xfs_log.h"
23#include "xfs_inum.h"
38#include "xfs_trans.h" 24#include "xfs_trans.h"
39#include "xfs_sb.h" 25#include "xfs_sb.h"
40#include "xfs_ag.h" 26#include "xfs_ag.h"
@@ -43,21 +29,21 @@
43#include "xfs_dmapi.h" 29#include "xfs_dmapi.h"
44#include "xfs_mount.h" 30#include "xfs_mount.h"
45#include "xfs_error.h" 31#include "xfs_error.h"
46#include "xfs_trans_priv.h" 32#include "xfs_da_btree.h"
47#include "xfs_alloc_btree.h"
48#include "xfs_bmap_btree.h" 33#include "xfs_bmap_btree.h"
34#include "xfs_alloc_btree.h"
49#include "xfs_ialloc_btree.h" 35#include "xfs_ialloc_btree.h"
50#include "xfs_btree.h"
51#include "xfs_ialloc.h"
52#include "xfs_alloc.h"
53#include "xfs_attr_sf.h"
54#include "xfs_dir_sf.h" 36#include "xfs_dir_sf.h"
55#include "xfs_dir2_sf.h" 37#include "xfs_dir2_sf.h"
38#include "xfs_attr_sf.h"
56#include "xfs_dinode.h" 39#include "xfs_dinode.h"
57#include "xfs_inode.h" 40#include "xfs_inode.h"
41#include "xfs_btree.h"
42#include "xfs_ialloc.h"
43#include "xfs_alloc.h"
58#include "xfs_bmap.h" 44#include "xfs_bmap.h"
59#include "xfs_da_btree.h"
60#include "xfs_quota.h" 45#include "xfs_quota.h"
46#include "xfs_trans_priv.h"
61#include "xfs_trans_space.h" 47#include "xfs_trans_space.h"
62 48
63 49
@@ -190,12 +176,8 @@ xfs_trans_dup(
190 XFS_LBC_INIT(&(ntp->t_busy)); 176 XFS_LBC_INIT(&(ntp->t_busy));
191 177
192 ASSERT(tp->t_flags & XFS_TRANS_PERM_LOG_RES); 178 ASSERT(tp->t_flags & XFS_TRANS_PERM_LOG_RES);
193
194#if defined(XLOG_NOLOG) || defined(DEBUG)
195 ASSERT(!xlog_debug || tp->t_ticket != NULL);
196#else
197 ASSERT(tp->t_ticket != NULL); 179 ASSERT(tp->t_ticket != NULL);
198#endif 180
199 ntp->t_flags = XFS_TRANS_PERM_LOG_RES | (tp->t_flags & XFS_TRANS_RESERVE); 181 ntp->t_flags = XFS_TRANS_PERM_LOG_RES | (tp->t_flags & XFS_TRANS_RESERVE);
200 ntp->t_ticket = tp->t_ticket; 182 ntp->t_ticket = tp->t_ticket;
201 ntp->t_blk_res = tp->t_blk_res - tp->t_blk_res_used; 183 ntp->t_blk_res = tp->t_blk_res - tp->t_blk_res_used;
@@ -661,10 +643,11 @@ xfs_trans_unreserve_and_mod_sb(
661 */ 643 */
662 /*ARGSUSED*/ 644 /*ARGSUSED*/
663int 645int
664xfs_trans_commit( 646_xfs_trans_commit(
665 xfs_trans_t *tp, 647 xfs_trans_t *tp,
666 uint flags, 648 uint flags,
667 xfs_lsn_t *commit_lsn_p) 649 xfs_lsn_t *commit_lsn_p,
650 int *log_flushed)
668{ 651{
669 xfs_log_iovec_t *log_vector; 652 xfs_log_iovec_t *log_vector;
670 int nvec; 653 int nvec;
@@ -676,9 +659,6 @@ xfs_trans_commit(
676 int sync; 659 int sync;
677#define XFS_TRANS_LOGVEC_COUNT 16 660#define XFS_TRANS_LOGVEC_COUNT 16
678 xfs_log_iovec_t log_vector_fast[XFS_TRANS_LOGVEC_COUNT]; 661 xfs_log_iovec_t log_vector_fast[XFS_TRANS_LOGVEC_COUNT];
679#if defined(XLOG_NOLOG) || defined(DEBUG)
680 static xfs_lsn_t trans_lsn = 1;
681#endif
682 void *commit_iclog; 662 void *commit_iclog;
683 int shutdown; 663 int shutdown;
684 664
@@ -729,11 +709,7 @@ shut_us_down:
729 *commit_lsn_p = commit_lsn; 709 *commit_lsn_p = commit_lsn;
730 return (shutdown); 710 return (shutdown);
731 } 711 }
732#if defined(XLOG_NOLOG) || defined(DEBUG)
733 ASSERT(!xlog_debug || tp->t_ticket != NULL);
734#else
735 ASSERT(tp->t_ticket != NULL); 712 ASSERT(tp->t_ticket != NULL);
736#endif
737 713
738 /* 714 /*
739 * If we need to update the superblock, then do it now. 715 * If we need to update the superblock, then do it now.
@@ -750,14 +726,10 @@ shut_us_down:
750 * by using a vector from the stack when it fits. 726 * by using a vector from the stack when it fits.
751 */ 727 */
752 nvec = xfs_trans_count_vecs(tp); 728 nvec = xfs_trans_count_vecs(tp);
753
754 if (nvec == 0) { 729 if (nvec == 0) {
755 xfs_force_shutdown(mp, XFS_LOG_IO_ERROR); 730 xfs_force_shutdown(mp, XFS_LOG_IO_ERROR);
756 goto shut_us_down; 731 goto shut_us_down;
757 } 732 } else if (nvec <= XFS_TRANS_LOGVEC_COUNT) {
758
759
760 if (nvec <= XFS_TRANS_LOGVEC_COUNT) {
761 log_vector = log_vector_fast; 733 log_vector = log_vector_fast;
762 } else { 734 } else {
763 log_vector = (xfs_log_iovec_t *)kmem_alloc(nvec * 735 log_vector = (xfs_log_iovec_t *)kmem_alloc(nvec *
@@ -771,30 +743,14 @@ shut_us_down:
771 */ 743 */
772 xfs_trans_fill_vecs(tp, log_vector); 744 xfs_trans_fill_vecs(tp, log_vector);
773 745
774 /* 746 error = xfs_log_write(mp, log_vector, nvec, tp->t_ticket, &(tp->t_lsn));
775 * Ignore errors here. xfs_log_done would do the right thing.
776 * We need to put the ticket, etc. away.
777 */
778 error = xfs_log_write(mp, log_vector, nvec, tp->t_ticket,
779 &(tp->t_lsn));
780 747
781#if defined(XLOG_NOLOG) || defined(DEBUG)
782 if (xlog_debug) {
783 commit_lsn = xfs_log_done(mp, tp->t_ticket,
784 &commit_iclog, log_flags);
785 } else {
786 commit_lsn = 0;
787 tp->t_lsn = trans_lsn++;
788 }
789#else
790 /* 748 /*
791 * This is the regular case. At this point (after the call finishes), 749 * The transaction is committed incore here, and can go out to disk
792 * the transaction is committed incore and could go out to disk at 750 * at any time after this call. However, all the items associated
793 * any time. However, all the items associated with the transaction 751 * with the transaction are still locked and pinned in memory.
794 * are still locked and pinned in memory.
795 */ 752 */
796 commit_lsn = xfs_log_done(mp, tp->t_ticket, &commit_iclog, log_flags); 753 commit_lsn = xfs_log_done(mp, tp->t_ticket, &commit_iclog, log_flags);
797#endif
798 754
799 tp->t_commit_lsn = commit_lsn; 755 tp->t_commit_lsn = commit_lsn;
800 if (nvec > XFS_TRANS_LOGVEC_COUNT) { 756 if (nvec > XFS_TRANS_LOGVEC_COUNT) {
@@ -893,9 +849,11 @@ shut_us_down:
893 * log out now and wait for it. 849 * log out now and wait for it.
894 */ 850 */
895 if (sync) { 851 if (sync) {
896 if (!error) 852 if (!error) {
897 error = xfs_log_force(mp, commit_lsn, 853 error = _xfs_log_force(mp, commit_lsn,
898 XFS_LOG_FORCE | XFS_LOG_SYNC); 854 XFS_LOG_FORCE | XFS_LOG_SYNC,
855 log_flushed);
856 }
899 XFS_STATS_INC(xs_trans_sync); 857 XFS_STATS_INC(xs_trans_sync);
900 } else { 858 } else {
901 XFS_STATS_INC(xs_trans_async); 859 XFS_STATS_INC(xs_trans_async);
diff --git a/fs/xfs/xfs_trans.h b/fs/xfs/xfs_trans.h
index a263aec8b3a6..a889963fdd14 100644
--- a/fs/xfs/xfs_trans.h
+++ b/fs/xfs/xfs_trans.h
@@ -1,33 +1,19 @@
1/* 1/*
2 * Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32#ifndef __XFS_TRANS_H__ 18#ifndef __XFS_TRANS_H__
33#define __XFS_TRANS_H__ 19#define __XFS_TRANS_H__
@@ -135,19 +121,6 @@ typedef struct xfs_ail_entry {
135 struct xfs_log_item *ail_back; /* AIL back pointer */ 121 struct xfs_log_item *ail_back; /* AIL back pointer */
136} xfs_ail_entry_t; 122} xfs_ail_entry_t;
137 123
138/*
139 * This structure is passed as a parameter to xfs_trans_push_ail()
140 * and is used to track the what LSN the waiting processes are
141 * waiting to become unused.
142 */
143typedef struct xfs_ail_ticket {
144 xfs_lsn_t at_lsn; /* lsn waitin for */
145 struct xfs_ail_ticket *at_forw; /* wait list ptr */
146 struct xfs_ail_ticket *at_back; /* wait list ptr */
147 sv_t at_sema; /* wait sema */
148} xfs_ail_ticket_t;
149
150
151typedef struct xfs_log_item { 124typedef struct xfs_log_item {
152 xfs_ail_entry_t li_ail; /* AIL pointers */ 125 xfs_ail_entry_t li_ail; /* AIL pointers */
153 xfs_lsn_t li_lsn; /* last on-disk lsn */ 126 xfs_lsn_t li_lsn; /* last on-disk lsn */
@@ -247,68 +220,67 @@ typedef struct xfs_log_item_chunk {
247 * lic_unused to the right value (0 matches all free). The 220 * lic_unused to the right value (0 matches all free). The
248 * lic_descs.lid_index values are set up as each desc is allocated. 221 * lic_descs.lid_index values are set up as each desc is allocated.
249 */ 222 */
250#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_LIC_INIT)
251void xfs_lic_init(xfs_log_item_chunk_t *cp);
252#define XFS_LIC_INIT(cp) xfs_lic_init(cp) 223#define XFS_LIC_INIT(cp) xfs_lic_init(cp)
253#else 224static inline void xfs_lic_init(xfs_log_item_chunk_t *cp)
254#define XFS_LIC_INIT(cp) ((cp)->lic_free = XFS_LIC_FREEMASK) 225{
255#endif 226 cp->lic_free = XFS_LIC_FREEMASK;
256#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_LIC_INIT_SLOT) 227}
257void xfs_lic_init_slot(xfs_log_item_chunk_t *cp, int slot); 228
258#define XFS_LIC_INIT_SLOT(cp,slot) xfs_lic_init_slot(cp, slot) 229#define XFS_LIC_INIT_SLOT(cp,slot) xfs_lic_init_slot(cp, slot)
259#else 230static inline void xfs_lic_init_slot(xfs_log_item_chunk_t *cp, int slot)
260#define XFS_LIC_INIT_SLOT(cp,slot) \ 231{
261 ((cp)->lic_descs[slot].lid_index = (unsigned char)(slot)) 232 cp->lic_descs[slot].lid_index = (unsigned char)(slot);
262#endif 233}
263#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_LIC_VACANCY) 234
264int xfs_lic_vacancy(xfs_log_item_chunk_t *cp);
265#define XFS_LIC_VACANCY(cp) xfs_lic_vacancy(cp) 235#define XFS_LIC_VACANCY(cp) xfs_lic_vacancy(cp)
266#else 236static inline int xfs_lic_vacancy(xfs_log_item_chunk_t *cp)
267#define XFS_LIC_VACANCY(cp) (((cp)->lic_free) & XFS_LIC_FREEMASK) 237{
268#endif 238 return cp->lic_free & XFS_LIC_FREEMASK;
269#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_LIC_ALL_FREE) 239}
270void xfs_lic_all_free(xfs_log_item_chunk_t *cp); 240
271#define XFS_LIC_ALL_FREE(cp) xfs_lic_all_free(cp) 241#define XFS_LIC_ALL_FREE(cp) xfs_lic_all_free(cp)
272#else 242static inline void xfs_lic_all_free(xfs_log_item_chunk_t *cp)
273#define XFS_LIC_ALL_FREE(cp) ((cp)->lic_free = XFS_LIC_FREEMASK) 243{
274#endif 244 cp->lic_free = XFS_LIC_FREEMASK;
275#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_LIC_ARE_ALL_FREE) 245}
276int xfs_lic_are_all_free(xfs_log_item_chunk_t *cp); 246
277#define XFS_LIC_ARE_ALL_FREE(cp) xfs_lic_are_all_free(cp) 247#define XFS_LIC_ARE_ALL_FREE(cp) xfs_lic_are_all_free(cp)
278#else 248static inline int xfs_lic_are_all_free(xfs_log_item_chunk_t *cp)
279#define XFS_LIC_ARE_ALL_FREE(cp) (((cp)->lic_free & XFS_LIC_FREEMASK) ==\ 249{
280 XFS_LIC_FREEMASK) 250 return ((cp->lic_free & XFS_LIC_FREEMASK) == XFS_LIC_FREEMASK);
281#endif 251}
282#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_LIC_ISFREE) 252
283int xfs_lic_isfree(xfs_log_item_chunk_t *cp, int slot);
284#define XFS_LIC_ISFREE(cp,slot) xfs_lic_isfree(cp,slot) 253#define XFS_LIC_ISFREE(cp,slot) xfs_lic_isfree(cp,slot)
285#else 254static inline int xfs_lic_isfree(xfs_log_item_chunk_t *cp, int slot)
286#define XFS_LIC_ISFREE(cp,slot) ((cp)->lic_free & (1 << (slot))) 255{
287#endif 256 return (cp->lic_free & (1 << slot));
288#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_LIC_CLAIM) 257}
289void xfs_lic_claim(xfs_log_item_chunk_t *cp, int slot); 258
290#define XFS_LIC_CLAIM(cp,slot) xfs_lic_claim(cp,slot) 259#define XFS_LIC_CLAIM(cp,slot) xfs_lic_claim(cp,slot)
291#else 260static inline void xfs_lic_claim(xfs_log_item_chunk_t *cp, int slot)
292#define XFS_LIC_CLAIM(cp,slot) ((cp)->lic_free &= ~(1 << (slot))) 261{
293#endif 262 cp->lic_free &= ~(1 << slot);
294#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_LIC_RELSE) 263}
295void xfs_lic_relse(xfs_log_item_chunk_t *cp, int slot); 264
296#define XFS_LIC_RELSE(cp,slot) xfs_lic_relse(cp,slot) 265#define XFS_LIC_RELSE(cp,slot) xfs_lic_relse(cp,slot)
297#else 266static inline void xfs_lic_relse(xfs_log_item_chunk_t *cp, int slot)
298#define XFS_LIC_RELSE(cp,slot) ((cp)->lic_free |= 1 << (slot)) 267{
299#endif 268 cp->lic_free |= 1 << slot;
300#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_LIC_SLOT) 269}
301xfs_log_item_desc_t *xfs_lic_slot(xfs_log_item_chunk_t *cp, int slot); 270
302#define XFS_LIC_SLOT(cp,slot) xfs_lic_slot(cp,slot) 271#define XFS_LIC_SLOT(cp,slot) xfs_lic_slot(cp,slot)
303#else 272static inline xfs_log_item_desc_t *
304#define XFS_LIC_SLOT(cp,slot) (&((cp)->lic_descs[slot])) 273xfs_lic_slot(xfs_log_item_chunk_t *cp, int slot)
305#endif 274{
306#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_LIC_DESC_TO_SLOT) 275 return &(cp->lic_descs[slot]);
307int xfs_lic_desc_to_slot(xfs_log_item_desc_t *dp); 276}
277
308#define XFS_LIC_DESC_TO_SLOT(dp) xfs_lic_desc_to_slot(dp) 278#define XFS_LIC_DESC_TO_SLOT(dp) xfs_lic_desc_to_slot(dp)
309#else 279static inline int xfs_lic_desc_to_slot(xfs_log_item_desc_t *dp)
310#define XFS_LIC_DESC_TO_SLOT(dp) ((uint)((dp)->lid_index)) 280{
311#endif 281 return (uint)dp->lid_index;
282}
283
312/* 284/*
313 * Calculate the address of a chunk given a descriptor pointer: 285 * Calculate the address of a chunk given a descriptor pointer:
314 * dp - dp->lid_index give the address of the start of the lic_descs array. 286 * dp - dp->lid_index give the address of the start of the lic_descs array.
@@ -316,15 +288,14 @@ int xfs_lic_desc_to_slot(xfs_log_item_desc_t *dp);
316 * All of this yields the address of the chunk, which is 288 * All of this yields the address of the chunk, which is
317 * cast to a chunk pointer. 289 * cast to a chunk pointer.
318 */ 290 */
319#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_LIC_DESC_TO_CHUNK)
320xfs_log_item_chunk_t *xfs_lic_desc_to_chunk(xfs_log_item_desc_t *dp);
321#define XFS_LIC_DESC_TO_CHUNK(dp) xfs_lic_desc_to_chunk(dp) 291#define XFS_LIC_DESC_TO_CHUNK(dp) xfs_lic_desc_to_chunk(dp)
322#else 292static inline xfs_log_item_chunk_t *
323#define XFS_LIC_DESC_TO_CHUNK(dp) ((xfs_log_item_chunk_t*) \ 293xfs_lic_desc_to_chunk(xfs_log_item_desc_t *dp)
324 (((xfs_caddr_t)((dp) - (dp)->lid_index)) -\ 294{
325 (xfs_caddr_t)(((xfs_log_item_chunk_t*) \ 295 return (xfs_log_item_chunk_t*) \
326 0)->lic_descs))) 296 (((xfs_caddr_t)((dp) - (dp)->lid_index)) - \
327#endif 297 (xfs_caddr_t)(((xfs_log_item_chunk_t*)0)->lic_descs));
298}
328 299
329#ifdef __KERNEL__ 300#ifdef __KERNEL__
330/* 301/*
@@ -341,7 +312,7 @@ typedef struct xfs_log_busy_slot {
341#define XFS_LBC_NUM_SLOTS 31 312#define XFS_LBC_NUM_SLOTS 31
342typedef struct xfs_log_busy_chunk { 313typedef struct xfs_log_busy_chunk {
343 struct xfs_log_busy_chunk *lbc_next; 314 struct xfs_log_busy_chunk *lbc_next;
344 uint lbc_free; /* bitmask of free slots */ 315 uint lbc_free; /* free slots bitmask */
345 ushort lbc_unused; /* first unused */ 316 ushort lbc_unused; /* first unused */
346 xfs_log_busy_slot_t lbc_busy[XFS_LBC_NUM_SLOTS]; 317 xfs_log_busy_slot_t lbc_busy[XFS_LBC_NUM_SLOTS];
347} xfs_log_busy_chunk_t; 318} xfs_log_busy_chunk_t;
@@ -1025,7 +996,12 @@ void xfs_trans_log_efd_extent(xfs_trans_t *,
1025 struct xfs_efd_log_item *, 996 struct xfs_efd_log_item *,
1026 xfs_fsblock_t, 997 xfs_fsblock_t,
1027 xfs_extlen_t); 998 xfs_extlen_t);
1028int xfs_trans_commit(xfs_trans_t *, uint flags, xfs_lsn_t *); 999int _xfs_trans_commit(xfs_trans_t *,
1000 uint flags,
1001 xfs_lsn_t *,
1002 int *);
1003#define xfs_trans_commit(tp, flags, lsn) \
1004 _xfs_trans_commit(tp, flags, lsn, NULL)
1029void xfs_trans_cancel(xfs_trans_t *, int); 1005void xfs_trans_cancel(xfs_trans_t *, int);
1030void xfs_trans_ail_init(struct xfs_mount *); 1006void xfs_trans_ail_init(struct xfs_mount *);
1031xfs_lsn_t xfs_trans_push_ail(struct xfs_mount *, xfs_lsn_t); 1007xfs_lsn_t xfs_trans_push_ail(struct xfs_mount *, xfs_lsn_t);
diff --git a/fs/xfs/xfs_trans_ail.c b/fs/xfs/xfs_trans_ail.c
index 2a71b4f91bfa..19ab24af1c1c 100644
--- a/fs/xfs/xfs_trans_ail.c
+++ b/fs/xfs/xfs_trans_ail.c
@@ -1,40 +1,25 @@
1/* 1/*
2 * Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32
33#include "xfs.h" 18#include "xfs.h"
34#include "xfs_macros.h" 19#include "xfs_fs.h"
35#include "xfs_types.h" 20#include "xfs_types.h"
36#include "xfs_inum.h"
37#include "xfs_log.h" 21#include "xfs_log.h"
22#include "xfs_inum.h"
38#include "xfs_trans.h" 23#include "xfs_trans.h"
39#include "xfs_sb.h" 24#include "xfs_sb.h"
40#include "xfs_dir.h" 25#include "xfs_dir.h"
diff --git a/fs/xfs/xfs_trans_buf.c b/fs/xfs/xfs_trans_buf.c
index e733293dd7f4..c74c31ebc81c 100644
--- a/fs/xfs/xfs_trans_buf.c
+++ b/fs/xfs/xfs_trans_buf.c
@@ -1,47 +1,42 @@
1/* 1/*
2 * Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32
33#include "xfs.h" 18#include "xfs.h"
34#include "xfs_macros.h" 19#include "xfs_fs.h"
35#include "xfs_types.h" 20#include "xfs_types.h"
36#include "xfs_inum.h" 21#include "xfs_bit.h"
37#include "xfs_log.h" 22#include "xfs_log.h"
23#include "xfs_inum.h"
38#include "xfs_trans.h" 24#include "xfs_trans.h"
39#include "xfs_buf_item.h"
40#include "xfs_sb.h" 25#include "xfs_sb.h"
41#include "xfs_ag.h" 26#include "xfs_ag.h"
42#include "xfs_dir.h" 27#include "xfs_dir.h"
28#include "xfs_dir2.h"
43#include "xfs_dmapi.h" 29#include "xfs_dmapi.h"
44#include "xfs_mount.h" 30#include "xfs_mount.h"
31#include "xfs_bmap_btree.h"
32#include "xfs_alloc_btree.h"
33#include "xfs_ialloc_btree.h"
34#include "xfs_dir_sf.h"
35#include "xfs_dir2_sf.h"
36#include "xfs_attr_sf.h"
37#include "xfs_dinode.h"
38#include "xfs_inode.h"
39#include "xfs_buf_item.h"
45#include "xfs_trans_priv.h" 40#include "xfs_trans_priv.h"
46#include "xfs_error.h" 41#include "xfs_error.h"
47#include "xfs_rw.h" 42#include "xfs_rw.h"
diff --git a/fs/xfs/xfs_trans_extfree.c b/fs/xfs/xfs_trans_extfree.c
index 93259a15f983..7d7d627f25df 100644
--- a/fs/xfs/xfs_trans_extfree.c
+++ b/fs/xfs/xfs_trans_extfree.c
@@ -1,40 +1,25 @@
1/* 1/*
2 * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32
33#include "xfs.h" 18#include "xfs.h"
34#include "xfs_macros.h" 19#include "xfs_fs.h"
35#include "xfs_types.h" 20#include "xfs_types.h"
36#include "xfs_inum.h"
37#include "xfs_log.h" 21#include "xfs_log.h"
22#include "xfs_inum.h"
38#include "xfs_trans.h" 23#include "xfs_trans.h"
39#include "xfs_sb.h" 24#include "xfs_sb.h"
40#include "xfs_dir.h" 25#include "xfs_dir.h"
diff --git a/fs/xfs/xfs_trans_inode.c b/fs/xfs/xfs_trans_inode.c
index 7e7631ca4979..e341409172d2 100644
--- a/fs/xfs/xfs_trans_inode.c
+++ b/fs/xfs/xfs_trans_inode.c
@@ -1,40 +1,26 @@
1/* 1/*
2 * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32
33#include "xfs.h" 18#include "xfs.h"
34#include "xfs_macros.h" 19#include "xfs_fs.h"
35#include "xfs_types.h" 20#include "xfs_types.h"
36#include "xfs_inum.h" 21#include "xfs_bit.h"
37#include "xfs_log.h" 22#include "xfs_log.h"
23#include "xfs_inum.h"
38#include "xfs_trans.h" 24#include "xfs_trans.h"
39#include "xfs_sb.h" 25#include "xfs_sb.h"
40#include "xfs_ag.h" 26#include "xfs_ag.h"
@@ -42,18 +28,18 @@
42#include "xfs_dir2.h" 28#include "xfs_dir2.h"
43#include "xfs_dmapi.h" 29#include "xfs_dmapi.h"
44#include "xfs_mount.h" 30#include "xfs_mount.h"
45#include "xfs_trans_priv.h"
46#include "xfs_alloc_btree.h"
47#include "xfs_bmap_btree.h" 31#include "xfs_bmap_btree.h"
32#include "xfs_alloc_btree.h"
48#include "xfs_ialloc_btree.h" 33#include "xfs_ialloc_btree.h"
49#include "xfs_btree.h"
50#include "xfs_ialloc.h"
51#include "xfs_attr_sf.h"
52#include "xfs_dir_sf.h" 34#include "xfs_dir_sf.h"
53#include "xfs_dir2_sf.h" 35#include "xfs_dir2_sf.h"
36#include "xfs_attr_sf.h"
54#include "xfs_dinode.h" 37#include "xfs_dinode.h"
55#include "xfs_inode_item.h"
56#include "xfs_inode.h" 38#include "xfs_inode.h"
39#include "xfs_btree.h"
40#include "xfs_ialloc.h"
41#include "xfs_trans_priv.h"
42#include "xfs_inode_item.h"
57 43
58#ifdef XFS_TRANS_DEBUG 44#ifdef XFS_TRANS_DEBUG
59STATIC void 45STATIC void
diff --git a/fs/xfs/xfs_trans_item.c b/fs/xfs/xfs_trans_item.c
index 1b8a756d80ed..486147ef0e3d 100644
--- a/fs/xfs/xfs_trans_item.c
+++ b/fs/xfs/xfs_trans_item.c
@@ -1,40 +1,25 @@
1/* 1/*
2 * Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32
33#include "xfs.h" 18#include "xfs.h"
34#include "xfs_macros.h" 19#include "xfs_fs.h"
35#include "xfs_types.h" 20#include "xfs_types.h"
36#include "xfs_inum.h"
37#include "xfs_log.h" 21#include "xfs_log.h"
22#include "xfs_inum.h"
38#include "xfs_trans.h" 23#include "xfs_trans.h"
39 24
40STATIC int xfs_trans_unlock_chunk(xfs_log_item_chunk_t *, 25STATIC int xfs_trans_unlock_chunk(xfs_log_item_chunk_t *,
diff --git a/fs/xfs/xfs_trans_priv.h b/fs/xfs/xfs_trans_priv.h
index d4dae7d06afc..13edab8a9e94 100644
--- a/fs/xfs/xfs_trans_priv.h
+++ b/fs/xfs/xfs_trans_priv.h
@@ -1,33 +1,19 @@
1/* 1/*
2 * Copyright (c) 2000, 2002 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000,2002,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32#ifndef __XFS_TRANS_PRIV_H__ 18#ifndef __XFS_TRANS_PRIV_H__
33#define __XFS_TRANS_PRIV_H__ 19#define __XFS_TRANS_PRIV_H__
diff --git a/fs/xfs/xfs_trans_space.h b/fs/xfs/xfs_trans_space.h
index e91d173f4ed3..7fe3792b18df 100644
--- a/fs/xfs/xfs_trans_space.h
+++ b/fs/xfs/xfs_trans_space.h
@@ -1,33 +1,19 @@
1/* 1/*
2 * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32#ifndef __XFS_TRANS_SPACE_H__ 18#ifndef __XFS_TRANS_SPACE_H__
33#define __XFS_TRANS_SPACE_H__ 19#define __XFS_TRANS_SPACE_H__
diff --git a/fs/xfs/xfs_types.h b/fs/xfs/xfs_types.h
index 16f5371ce102..104f64a98790 100644
--- a/fs/xfs/xfs_types.h
+++ b/fs/xfs/xfs_types.h
@@ -1,33 +1,19 @@
1/* 1/*
2 * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32#ifndef __XFS_TYPES_H__ 18#ifndef __XFS_TYPES_H__
33#define __XFS_TYPES_H__ 19#define __XFS_TYPES_H__
@@ -154,6 +140,12 @@ typedef __uint8_t xfs_arch_t; /* architecture of an xfs fs */
154#define MAXAEXTNUM ((xfs_aextnum_t)0x7fff) /* signed short */ 140#define MAXAEXTNUM ((xfs_aextnum_t)0x7fff) /* signed short */
155 141
156/* 142/*
143 * Min numbers of data/attr fork btree root pointers.
144 */
145#define MINDBTPTRS 3
146#define MINABTPTRS 2
147
148/*
157 * MAXNAMELEN is the length (including the terminating null) of 149 * MAXNAMELEN is the length (including the terminating null) of
158 * the longest permissible file (component) name. 150 * the longest permissible file (component) name.
159 */ 151 */
diff --git a/fs/xfs/xfs_utils.c b/fs/xfs/xfs_utils.c
index 11351f08d438..fefe1d60377f 100644
--- a/fs/xfs/xfs_utils.c
+++ b/fs/xfs/xfs_utils.c
@@ -1,53 +1,40 @@
1/* 1/*
2 * Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32
33#include "xfs.h" 18#include "xfs.h"
34#include "xfs_macros.h" 19#include "xfs_fs.h"
35#include "xfs_types.h" 20#include "xfs_types.h"
36#include "xfs_inum.h" 21#include "xfs_bit.h"
37#include "xfs_log.h" 22#include "xfs_log.h"
23#include "xfs_inum.h"
38#include "xfs_trans.h" 24#include "xfs_trans.h"
39#include "xfs_sb.h" 25#include "xfs_sb.h"
26#include "xfs_ag.h"
40#include "xfs_dir.h" 27#include "xfs_dir.h"
41#include "xfs_dir2.h" 28#include "xfs_dir2.h"
42#include "xfs_dmapi.h" 29#include "xfs_dmapi.h"
43#include "xfs_mount.h" 30#include "xfs_mount.h"
44#include "xfs_bmap_btree.h" 31#include "xfs_bmap_btree.h"
45#include "xfs_attr_sf.h"
46#include "xfs_dir_sf.h" 32#include "xfs_dir_sf.h"
47#include "xfs_dir2_sf.h" 33#include "xfs_dir2_sf.h"
34#include "xfs_attr_sf.h"
48#include "xfs_dinode.h" 35#include "xfs_dinode.h"
49#include "xfs_inode_item.h"
50#include "xfs_inode.h" 36#include "xfs_inode.h"
37#include "xfs_inode_item.h"
51#include "xfs_bmap.h" 38#include "xfs_bmap.h"
52#include "xfs_error.h" 39#include "xfs_error.h"
53#include "xfs_quota.h" 40#include "xfs_quota.h"
diff --git a/fs/xfs/xfs_utils.h b/fs/xfs/xfs_utils.h
index 01d98b4b7af7..472661a3b6d8 100644
--- a/fs/xfs/xfs_utils.h
+++ b/fs/xfs/xfs_utils.h
@@ -1,33 +1,19 @@
1/* 1/*
2 * Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32#ifndef __XFS_UTILS_H__ 18#ifndef __XFS_UTILS_H__
33#define __XFS_UTILS_H__ 19#define __XFS_UTILS_H__
diff --git a/fs/xfs/xfs_vfsops.c b/fs/xfs/xfs_vfsops.c
index f1a904e23ade..7bdbd991ab1c 100644
--- a/fs/xfs/xfs_vfsops.c
+++ b/fs/xfs/xfs_vfsops.c
@@ -1,74 +1,58 @@
1/* 1/*
2 * XFS filesystem operations. 2 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * Copyright (c) 2000-2005 Silicon Graphics, Inc. All Rights Reserved. 5 * This program is free software; you can redistribute it and/or
5 * 6 * modify it under the terms of the GNU General Public License as
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of version 2 of the GNU General Public License as
8 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
9 * 8 *
10 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
11 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * 12 * GNU General Public License for more details.
14 * Further, this software is distributed without any warranty that it is
15 * free of the rightful claim of any third person regarding infringement
16 * or the like. Any license provided herein, whether implied or
17 * otherwise, applies only to this software file. Patent licenses, if
18 * any, provided herein do not apply to combinations of this program with
19 * other software, or any other product whatsoever.
20 *
21 * You should have received a copy of the GNU General Public License along
22 * with this program; if not, write the Free Software Foundation, Inc., 59
23 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
24 *
25 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
26 * Mountain View, CA 94043, or:
27 * 13 *
28 * http://www.sgi.com 14 * You should have received a copy of the GNU General Public License
29 * 15 * along with this program; if not, write the Free Software Foundation,
30 * For further information regarding this notice, see: 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
31 *
32 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
33 */ 17 */
34
35#include "xfs.h" 18#include "xfs.h"
36#include "xfs_macros.h" 19#include "xfs_fs.h"
37#include "xfs_types.h" 20#include "xfs_types.h"
38#include "xfs_inum.h" 21#include "xfs_bit.h"
39#include "xfs_log.h" 22#include "xfs_log.h"
23#include "xfs_inum.h"
40#include "xfs_trans.h" 24#include "xfs_trans.h"
41#include "xfs_sb.h" 25#include "xfs_sb.h"
26#include "xfs_ag.h"
42#include "xfs_dir.h" 27#include "xfs_dir.h"
43#include "xfs_dir2.h" 28#include "xfs_dir2.h"
44#include "xfs_dmapi.h" 29#include "xfs_dmapi.h"
45#include "xfs_mount.h" 30#include "xfs_mount.h"
31#include "xfs_da_btree.h"
46#include "xfs_bmap_btree.h" 32#include "xfs_bmap_btree.h"
47#include "xfs_ialloc_btree.h" 33#include "xfs_ialloc_btree.h"
48#include "xfs_alloc_btree.h" 34#include "xfs_alloc_btree.h"
49#include "xfs_btree.h"
50#include "xfs_alloc.h"
51#include "xfs_ialloc.h"
52#include "xfs_attr_sf.h"
53#include "xfs_dir_sf.h" 35#include "xfs_dir_sf.h"
54#include "xfs_dir2_sf.h" 36#include "xfs_dir2_sf.h"
37#include "xfs_attr_sf.h"
55#include "xfs_dinode.h" 38#include "xfs_dinode.h"
56#include "xfs_inode_item.h"
57#include "xfs_inode.h" 39#include "xfs_inode.h"
58#include "xfs_ag.h" 40#include "xfs_inode_item.h"
41#include "xfs_btree.h"
42#include "xfs_alloc.h"
43#include "xfs_ialloc.h"
44#include "xfs_quota.h"
59#include "xfs_error.h" 45#include "xfs_error.h"
60#include "xfs_bmap.h" 46#include "xfs_bmap.h"
61#include "xfs_da_btree.h"
62#include "xfs_rw.h" 47#include "xfs_rw.h"
63#include "xfs_refcache.h" 48#include "xfs_refcache.h"
64#include "xfs_buf_item.h" 49#include "xfs_buf_item.h"
65#include "xfs_extfree_item.h" 50#include "xfs_log_priv.h"
66#include "xfs_quota.h"
67#include "xfs_dir2_trace.h" 51#include "xfs_dir2_trace.h"
52#include "xfs_extfree_item.h"
68#include "xfs_acl.h" 53#include "xfs_acl.h"
69#include "xfs_attr.h" 54#include "xfs_attr.h"
70#include "xfs_clnt.h" 55#include "xfs_clnt.h"
71#include "xfs_log_priv.h"
72 56
73STATIC int xfs_sync(bhv_desc_t *, int, cred_t *); 57STATIC int xfs_sync(bhv_desc_t *, int, cred_t *);
74 58
@@ -230,9 +214,7 @@ xfs_start_flags(
230 } 214 }
231 215
232 if (ap->logbufs != -1 && 216 if (ap->logbufs != -1 &&
233#if defined(DEBUG) || defined(XLOG_NOLOG)
234 ap->logbufs != 0 && 217 ap->logbufs != 0 &&
235#endif
236 (ap->logbufs < XLOG_MIN_ICLOGS || 218 (ap->logbufs < XLOG_MIN_ICLOGS ||
237 ap->logbufs > XLOG_MAX_ICLOGS)) { 219 ap->logbufs > XLOG_MAX_ICLOGS)) {
238 cmn_err(CE_WARN, 220 cmn_err(CE_WARN,
@@ -242,6 +224,7 @@ xfs_start_flags(
242 } 224 }
243 mp->m_logbufs = ap->logbufs; 225 mp->m_logbufs = ap->logbufs;
244 if (ap->logbufsize != -1 && 226 if (ap->logbufsize != -1 &&
227 ap->logbufsize != 0 &&
245 ap->logbufsize != 16 * 1024 && 228 ap->logbufsize != 16 * 1024 &&
246 ap->logbufsize != 32 * 1024 && 229 ap->logbufsize != 32 * 1024 &&
247 ap->logbufsize != 64 * 1024 && 230 ap->logbufsize != 64 * 1024 &&
@@ -257,6 +240,14 @@ xfs_start_flags(
257 mp->m_fsname_len = strlen(ap->fsname) + 1; 240 mp->m_fsname_len = strlen(ap->fsname) + 1;
258 mp->m_fsname = kmem_alloc(mp->m_fsname_len, KM_SLEEP); 241 mp->m_fsname = kmem_alloc(mp->m_fsname_len, KM_SLEEP);
259 strcpy(mp->m_fsname, ap->fsname); 242 strcpy(mp->m_fsname, ap->fsname);
243 if (ap->rtname[0]) {
244 mp->m_rtname = kmem_alloc(strlen(ap->rtname) + 1, KM_SLEEP);
245 strcpy(mp->m_rtname, ap->rtname);
246 }
247 if (ap->logname[0]) {
248 mp->m_logname = kmem_alloc(strlen(ap->logname) + 1, KM_SLEEP);
249 strcpy(mp->m_logname, ap->logname);
250 }
260 251
261 if (ap->flags & XFSMNT_WSYNC) 252 if (ap->flags & XFSMNT_WSYNC)
262 mp->m_flags |= XFS_MOUNT_WSYNC; 253 mp->m_flags |= XFS_MOUNT_WSYNC;
@@ -268,21 +259,16 @@ xfs_start_flags(
268#endif 259#endif
269 if (ap->flags & XFSMNT_NOATIME) 260 if (ap->flags & XFSMNT_NOATIME)
270 mp->m_flags |= XFS_MOUNT_NOATIME; 261 mp->m_flags |= XFS_MOUNT_NOATIME;
271
272 if (ap->flags & XFSMNT_RETERR) 262 if (ap->flags & XFSMNT_RETERR)
273 mp->m_flags |= XFS_MOUNT_RETERR; 263 mp->m_flags |= XFS_MOUNT_RETERR;
274
275 if (ap->flags & XFSMNT_NOALIGN) 264 if (ap->flags & XFSMNT_NOALIGN)
276 mp->m_flags |= XFS_MOUNT_NOALIGN; 265 mp->m_flags |= XFS_MOUNT_NOALIGN;
277
278 if (ap->flags & XFSMNT_SWALLOC) 266 if (ap->flags & XFSMNT_SWALLOC)
279 mp->m_flags |= XFS_MOUNT_SWALLOC; 267 mp->m_flags |= XFS_MOUNT_SWALLOC;
280
281 if (ap->flags & XFSMNT_OSYNCISOSYNC) 268 if (ap->flags & XFSMNT_OSYNCISOSYNC)
282 mp->m_flags |= XFS_MOUNT_OSYNCISOSYNC; 269 mp->m_flags |= XFS_MOUNT_OSYNCISOSYNC;
283
284 if (ap->flags & XFSMNT_32BITINODES) 270 if (ap->flags & XFSMNT_32BITINODES)
285 mp->m_flags |= (XFS_MOUNT_32BITINODES | XFS_MOUNT_32BITINOOPT); 271 mp->m_flags |= XFS_MOUNT_32BITINODES;
286 272
287 if (ap->flags & XFSMNT_IOSIZE) { 273 if (ap->flags & XFSMNT_IOSIZE) {
288 if (ap->iosizelog > XFS_MAX_IO_LOG || 274 if (ap->iosizelog > XFS_MAX_IO_LOG ||
@@ -300,12 +286,15 @@ xfs_start_flags(
300 286
301 if (ap->flags & XFSMNT_IHASHSIZE) 287 if (ap->flags & XFSMNT_IHASHSIZE)
302 mp->m_flags |= XFS_MOUNT_IHASHSIZE; 288 mp->m_flags |= XFS_MOUNT_IHASHSIZE;
303
304 if (ap->flags & XFSMNT_IDELETE) 289 if (ap->flags & XFSMNT_IDELETE)
305 mp->m_flags |= XFS_MOUNT_IDELETE; 290 mp->m_flags |= XFS_MOUNT_IDELETE;
306
307 if (ap->flags & XFSMNT_DIRSYNC) 291 if (ap->flags & XFSMNT_DIRSYNC)
308 mp->m_flags |= XFS_MOUNT_DIRSYNC; 292 mp->m_flags |= XFS_MOUNT_DIRSYNC;
293 if (ap->flags & XFSMNT_COMPAT_ATTR)
294 mp->m_flags |= XFS_MOUNT_COMPAT_ATTR;
295
296 if (ap->flags2 & XFSMNT2_COMPAT_IOSIZE)
297 mp->m_flags |= XFS_MOUNT_COMPAT_IOSIZE;
309 298
310 /* 299 /*
311 * no recovery flag requires a read-only mount 300 * no recovery flag requires a read-only mount
@@ -321,8 +310,8 @@ xfs_start_flags(
321 310
322 if (ap->flags & XFSMNT_NOUUID) 311 if (ap->flags & XFSMNT_NOUUID)
323 mp->m_flags |= XFS_MOUNT_NOUUID; 312 mp->m_flags |= XFS_MOUNT_NOUUID;
324 if (ap->flags & XFSMNT_NOLOGFLUSH) 313 if (ap->flags & XFSMNT_BARRIER)
325 mp->m_flags |= XFS_MOUNT_NOLOGFLUSH; 314 mp->m_flags |= XFS_MOUNT_BARRIER;
326 315
327 return 0; 316 return 0;
328} 317}
@@ -393,6 +382,10 @@ xfs_finish_flags(
393 return XFS_ERROR(EINVAL); 382 return XFS_ERROR(EINVAL);
394 } 383 }
395 384
385 if (XFS_SB_VERSION_HASATTR2(&mp->m_sb)) {
386 mp->m_flags &= ~XFS_MOUNT_COMPAT_ATTR;
387 }
388
396 return 0; 389 return 0;
397} 390}
398 391
@@ -512,8 +505,14 @@ xfs_mount(
512 goto error2; 505 goto error2;
513 506
514 error = XFS_IOINIT(vfsp, args, flags); 507 error = XFS_IOINIT(vfsp, args, flags);
515 if (!error) 508 if (error)
516 return 0; 509 goto error2;
510
511 if ((args->flags & XFSMNT_BARRIER) &&
512 !(XFS_MTOVFS(mp)->vfs_flag & VFS_RDONLY))
513 xfs_mountfs_check_barriers(mp);
514 return 0;
515
517error2: 516error2:
518 if (mp->m_sb_bp) 517 if (mp->m_sb_bp)
519 xfs_freesb(mp); 518 xfs_freesb(mp);
@@ -656,19 +655,24 @@ xfs_mntupdate(
656 else 655 else
657 mp->m_flags &= ~XFS_MOUNT_NOATIME; 656 mp->m_flags &= ~XFS_MOUNT_NOATIME;
658 657
659 if (!(vfsp->vfs_flag & VFS_RDONLY)) { 658 if ((vfsp->vfs_flag & VFS_RDONLY) &&
660 VFS_SYNC(vfsp, SYNC_FSDATA|SYNC_BDFLUSH|SYNC_ATTR, NULL, error); 659 !(*flags & MS_RDONLY)) {
660 vfsp->vfs_flag &= ~VFS_RDONLY;
661
662 if (args->flags & XFSMNT_BARRIER)
663 xfs_mountfs_check_barriers(mp);
661 } 664 }
662 665
663 if (*flags & MS_RDONLY) { 666 if (!(vfsp->vfs_flag & VFS_RDONLY) &&
667 (*flags & MS_RDONLY)) {
668 VFS_SYNC(vfsp, SYNC_FSDATA|SYNC_BDFLUSH|SYNC_ATTR, NULL, error);
669
664 xfs_quiesce_fs(mp); 670 xfs_quiesce_fs(mp);
665 671
666 /* Ok now write out an unmount record */ 672 /* Ok now write out an unmount record */
667 xfs_log_unmount_write(mp); 673 xfs_log_unmount_write(mp);
668 xfs_unmountfs_writesb(mp); 674 xfs_unmountfs_writesb(mp);
669 vfsp->vfs_flag |= VFS_RDONLY; 675 vfsp->vfs_flag |= VFS_RDONLY;
670 } else {
671 vfsp->vfs_flag &= ~VFS_RDONLY;
672 } 676 }
673 677
674 return 0; 678 return 0;
@@ -892,7 +896,7 @@ xfs_sync(
892 * only available by calling this routine. 896 * only available by calling this routine.
893 * 897 *
894 */ 898 */
895STATIC int 899int
896xfs_sync_inodes( 900xfs_sync_inodes(
897 xfs_mount_t *mp, 901 xfs_mount_t *mp,
898 int flags, 902 int flags,
@@ -976,7 +980,7 @@ xfs_sync_inodes(
976 ipointer = (xfs_iptr_t *)kmem_zalloc(sizeof(xfs_iptr_t), KM_SLEEP); 980 ipointer = (xfs_iptr_t *)kmem_zalloc(sizeof(xfs_iptr_t), KM_SLEEP);
977 981
978 fflag = XFS_B_ASYNC; /* default is don't wait */ 982 fflag = XFS_B_ASYNC; /* default is don't wait */
979 if (flags & SYNC_BDFLUSH) 983 if (flags & (SYNC_BDFLUSH | SYNC_DELWRI))
980 fflag = XFS_B_DELWRI; 984 fflag = XFS_B_DELWRI;
981 if (flags & SYNC_WAIT) 985 if (flags & SYNC_WAIT)
982 fflag = 0; /* synchronous overrides all */ 986 fflag = 0; /* synchronous overrides all */
@@ -1628,11 +1632,17 @@ xfs_vget(
1628#define MNTOPT_ALLOCSIZE "allocsize" /* preferred allocation size */ 1632#define MNTOPT_ALLOCSIZE "allocsize" /* preferred allocation size */
1629#define MNTOPT_IHASHSIZE "ihashsize" /* size of inode hash table */ 1633#define MNTOPT_IHASHSIZE "ihashsize" /* size of inode hash table */
1630#define MNTOPT_NORECOVERY "norecovery" /* don't run XFS recovery */ 1634#define MNTOPT_NORECOVERY "norecovery" /* don't run XFS recovery */
1631#define MNTOPT_NOLOGFLUSH "nologflush" /* don't hard flush on log writes */ 1635#define MNTOPT_BARRIER "barrier" /* use writer barriers for log write and
1636 * unwritten extent conversion */
1632#define MNTOPT_OSYNCISOSYNC "osyncisosync" /* o_sync is REALLY o_sync */ 1637#define MNTOPT_OSYNCISOSYNC "osyncisosync" /* o_sync is REALLY o_sync */
1633#define MNTOPT_64BITINODE "inode64" /* inodes can be allocated anywhere */ 1638#define MNTOPT_64BITINODE "inode64" /* inodes can be allocated anywhere */
1634#define MNTOPT_IKEEP "ikeep" /* do not free empty inode clusters */ 1639#define MNTOPT_IKEEP "ikeep" /* do not free empty inode clusters */
1635#define MNTOPT_NOIKEEP "noikeep" /* free empty inode clusters */ 1640#define MNTOPT_NOIKEEP "noikeep" /* free empty inode clusters */
1641#define MNTOPT_LARGEIO "largeio" /* report large I/O sizes in stat() */
1642#define MNTOPT_NOLARGEIO "nolargeio" /* do not report large I/O sizes
1643 * in stat(). */
1644#define MNTOPT_ATTR2 "attr2" /* do use attr2 attribute format */
1645#define MNTOPT_NOATTR2 "noattr2" /* do not use attr2 attribute format */
1636 1646
1637STATIC unsigned long 1647STATIC unsigned long
1638suffix_strtoul(const char *cp, char **endp, unsigned int base) 1648suffix_strtoul(const char *cp, char **endp, unsigned int base)
@@ -1669,12 +1679,15 @@ xfs_parseargs(
1669 int dsunit, dswidth, vol_dsunit, vol_dswidth; 1679 int dsunit, dswidth, vol_dsunit, vol_dswidth;
1670 int iosize; 1680 int iosize;
1671 1681
1682 args->flags2 |= XFSMNT2_COMPAT_IOSIZE;
1683 args->flags |= XFSMNT_COMPAT_ATTR;
1684
1672#if 0 /* XXX: off by default, until some remaining issues ironed out */ 1685#if 0 /* XXX: off by default, until some remaining issues ironed out */
1673 args->flags |= XFSMNT_IDELETE; /* default to on */ 1686 args->flags |= XFSMNT_IDELETE; /* default to on */
1674#endif 1687#endif
1675 1688
1676 if (!options) 1689 if (!options)
1677 return 0; 1690 goto done;
1678 1691
1679 iosize = dsunit = dswidth = vol_dsunit = vol_dswidth = 0; 1692 iosize = dsunit = dswidth = vol_dsunit = vol_dswidth = 0;
1680 1693
@@ -1791,12 +1804,20 @@ xfs_parseargs(
1791#endif 1804#endif
1792 } else if (!strcmp(this_char, MNTOPT_NOUUID)) { 1805 } else if (!strcmp(this_char, MNTOPT_NOUUID)) {
1793 args->flags |= XFSMNT_NOUUID; 1806 args->flags |= XFSMNT_NOUUID;
1794 } else if (!strcmp(this_char, MNTOPT_NOLOGFLUSH)) { 1807 } else if (!strcmp(this_char, MNTOPT_BARRIER)) {
1795 args->flags |= XFSMNT_NOLOGFLUSH; 1808 args->flags |= XFSMNT_BARRIER;
1796 } else if (!strcmp(this_char, MNTOPT_IKEEP)) { 1809 } else if (!strcmp(this_char, MNTOPT_IKEEP)) {
1797 args->flags &= ~XFSMNT_IDELETE; 1810 args->flags &= ~XFSMNT_IDELETE;
1798 } else if (!strcmp(this_char, MNTOPT_NOIKEEP)) { 1811 } else if (!strcmp(this_char, MNTOPT_NOIKEEP)) {
1799 args->flags |= XFSMNT_IDELETE; 1812 args->flags |= XFSMNT_IDELETE;
1813 } else if (!strcmp(this_char, MNTOPT_LARGEIO)) {
1814 args->flags2 &= ~XFSMNT2_COMPAT_IOSIZE;
1815 } else if (!strcmp(this_char, MNTOPT_NOLARGEIO)) {
1816 args->flags2 |= XFSMNT2_COMPAT_IOSIZE;
1817 } else if (!strcmp(this_char, MNTOPT_ATTR2)) {
1818 args->flags &= ~XFSMNT_COMPAT_ATTR;
1819 } else if (!strcmp(this_char, MNTOPT_NOATTR2)) {
1820 args->flags |= XFSMNT_COMPAT_ATTR;
1800 } else if (!strcmp(this_char, "osyncisdsync")) { 1821 } else if (!strcmp(this_char, "osyncisdsync")) {
1801 /* no-op, this is now the default */ 1822 /* no-op, this is now the default */
1802printk("XFS: osyncisdsync is now the default, option is deprecated.\n"); 1823printk("XFS: osyncisdsync is now the default, option is deprecated.\n");
@@ -1846,6 +1867,11 @@ printk("XFS: irixsgid is now a sysctl(2) variable, option is deprecated.\n");
1846 args->sunit = args->swidth = 0; 1867 args->sunit = args->swidth = 0;
1847 } 1868 }
1848 1869
1870done:
1871 if (args->flags & XFSMNT_32BITINODES)
1872 vfsp->vfs_flag |= VFS_32BITINODES;
1873 if (args->flags2)
1874 args->flags |= XFSMNT_FLAGS2;
1849 return 0; 1875 return 0;
1850} 1876}
1851 1877
@@ -1866,7 +1892,7 @@ xfs_showargs(
1866 { XFS_MOUNT_NOUUID, "," MNTOPT_NOUUID }, 1892 { XFS_MOUNT_NOUUID, "," MNTOPT_NOUUID },
1867 { XFS_MOUNT_NORECOVERY, "," MNTOPT_NORECOVERY }, 1893 { XFS_MOUNT_NORECOVERY, "," MNTOPT_NORECOVERY },
1868 { XFS_MOUNT_OSYNCISOSYNC, "," MNTOPT_OSYNCISOSYNC }, 1894 { XFS_MOUNT_OSYNCISOSYNC, "," MNTOPT_OSYNCISOSYNC },
1869 { XFS_MOUNT_NOLOGFLUSH, "," MNTOPT_NOLOGFLUSH }, 1895 { XFS_MOUNT_BARRIER, "," MNTOPT_BARRIER },
1870 { XFS_MOUNT_IDELETE, "," MNTOPT_NOIKEEP }, 1896 { XFS_MOUNT_IDELETE, "," MNTOPT_NOIKEEP },
1871 { 0, NULL } 1897 { 0, NULL }
1872 }; 1898 };
@@ -1883,21 +1909,20 @@ xfs_showargs(
1883 seq_printf(m, "," MNTOPT_IHASHSIZE "=%d", mp->m_ihsize); 1909 seq_printf(m, "," MNTOPT_IHASHSIZE "=%d", mp->m_ihsize);
1884 1910
1885 if (mp->m_flags & XFS_MOUNT_DFLT_IOSIZE) 1911 if (mp->m_flags & XFS_MOUNT_DFLT_IOSIZE)
1886 seq_printf(m, "," MNTOPT_ALLOCSIZE "=%d", 1<<mp->m_writeio_log); 1912 seq_printf(m, "," MNTOPT_ALLOCSIZE "=%dk",
1913 (int)(1 << mp->m_writeio_log) >> 10);
1887 1914
1888 if (mp->m_logbufs > 0) 1915 if (mp->m_logbufs > 0)
1889 seq_printf(m, "," MNTOPT_LOGBUFS "=%d", mp->m_logbufs); 1916 seq_printf(m, "," MNTOPT_LOGBUFS "=%d", mp->m_logbufs);
1890 1917
1891 if (mp->m_logbsize > 0) 1918 if (mp->m_logbsize > 0)
1892 seq_printf(m, "," MNTOPT_LOGBSIZE "=%d", mp->m_logbsize); 1919 seq_printf(m, "," MNTOPT_LOGBSIZE "=%dk", mp->m_logbsize >> 10);
1893 1920
1894 if (mp->m_ddev_targp != mp->m_logdev_targp) 1921 if (mp->m_logname)
1895 seq_printf(m, "," MNTOPT_LOGDEV "=%s", 1922 seq_printf(m, "," MNTOPT_LOGDEV "=%s", mp->m_logname);
1896 XFS_BUFTARG_NAME(mp->m_logdev_targp));
1897 1923
1898 if (mp->m_rtdev_targp && mp->m_ddev_targp != mp->m_rtdev_targp) 1924 if (mp->m_rtname)
1899 seq_printf(m, "," MNTOPT_RTDEV "=%s", 1925 seq_printf(m, "," MNTOPT_RTDEV "=%s", mp->m_rtname);
1900 XFS_BUFTARG_NAME(mp->m_rtdev_targp));
1901 1926
1902 if (mp->m_dalign > 0) 1927 if (mp->m_dalign > 0)
1903 seq_printf(m, "," MNTOPT_SUNIT "=%d", 1928 seq_printf(m, "," MNTOPT_SUNIT "=%d",
@@ -1907,7 +1932,13 @@ xfs_showargs(
1907 seq_printf(m, "," MNTOPT_SWIDTH "=%d", 1932 seq_printf(m, "," MNTOPT_SWIDTH "=%d",
1908 (int)XFS_FSB_TO_BB(mp, mp->m_swidth)); 1933 (int)XFS_FSB_TO_BB(mp, mp->m_swidth));
1909 1934
1910 if (!(mp->m_flags & XFS_MOUNT_32BITINOOPT)) 1935 if (!(mp->m_flags & XFS_MOUNT_COMPAT_ATTR))
1936 seq_printf(m, "," MNTOPT_ATTR2);
1937
1938 if (!(mp->m_flags & XFS_MOUNT_COMPAT_IOSIZE))
1939 seq_printf(m, "," MNTOPT_LARGEIO);
1940
1941 if (!(vfsp->vfs_flag & VFS_32BITINODES))
1911 seq_printf(m, "," MNTOPT_64BITINODE); 1942 seq_printf(m, "," MNTOPT_64BITINODE);
1912 1943
1913 if (vfsp->vfs_flag & VFS_GRPID) 1944 if (vfsp->vfs_flag & VFS_GRPID)
diff --git a/fs/xfs/xfs_vnodeops.c b/fs/xfs/xfs_vnodeops.c
index 58bfe629b933..7c1f74531463 100644
--- a/fs/xfs/xfs_vnodeops.c
+++ b/fs/xfs/xfs_vnodeops.c
@@ -1,40 +1,26 @@
1/* 1/*
2 * Copyright (c) 2000-2005 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32
33#include "xfs.h" 18#include "xfs.h"
34#include "xfs_macros.h" 19#include "xfs_fs.h"
35#include "xfs_types.h" 20#include "xfs_types.h"
36#include "xfs_inum.h" 21#include "xfs_bit.h"
37#include "xfs_log.h" 22#include "xfs_log.h"
23#include "xfs_inum.h"
38#include "xfs_trans.h" 24#include "xfs_trans.h"
39#include "xfs_sb.h" 25#include "xfs_sb.h"
40#include "xfs_ag.h" 26#include "xfs_ag.h"
@@ -42,33 +28,32 @@
42#include "xfs_dir2.h" 28#include "xfs_dir2.h"
43#include "xfs_dmapi.h" 29#include "xfs_dmapi.h"
44#include "xfs_mount.h" 30#include "xfs_mount.h"
45#include "xfs_alloc_btree.h" 31#include "xfs_da_btree.h"
46#include "xfs_bmap_btree.h" 32#include "xfs_bmap_btree.h"
33#include "xfs_alloc_btree.h"
47#include "xfs_ialloc_btree.h" 34#include "xfs_ialloc_btree.h"
48#include "xfs_itable.h"
49#include "xfs_btree.h"
50#include "xfs_ialloc.h"
51#include "xfs_alloc.h"
52#include "xfs_attr_sf.h"
53#include "xfs_dir_sf.h" 35#include "xfs_dir_sf.h"
54#include "xfs_dir2_sf.h" 36#include "xfs_dir2_sf.h"
37#include "xfs_attr_sf.h"
55#include "xfs_dinode.h" 38#include "xfs_dinode.h"
56#include "xfs_inode_item.h"
57#include "xfs_inode.h" 39#include "xfs_inode.h"
40#include "xfs_inode_item.h"
41#include "xfs_dir_leaf.h"
42#include "xfs_itable.h"
43#include "xfs_btree.h"
44#include "xfs_ialloc.h"
45#include "xfs_alloc.h"
58#include "xfs_bmap.h" 46#include "xfs_bmap.h"
59#include "xfs_da_btree.h"
60#include "xfs_attr.h" 47#include "xfs_attr.h"
61#include "xfs_rw.h" 48#include "xfs_rw.h"
62#include "xfs_refcache.h"
63#include "xfs_error.h" 49#include "xfs_error.h"
64#include "xfs_bit.h"
65#include "xfs_rtalloc.h"
66#include "xfs_quota.h" 50#include "xfs_quota.h"
67#include "xfs_utils.h" 51#include "xfs_utils.h"
52#include "xfs_rtalloc.h"
53#include "xfs_refcache.h"
68#include "xfs_trans_space.h" 54#include "xfs_trans_space.h"
69#include "xfs_dir_leaf.h"
70#include "xfs_mac.h"
71#include "xfs_log_priv.h" 55#include "xfs_log_priv.h"
56#include "xfs_mac.h"
72 57
73 58
74/* 59/*
@@ -181,40 +166,7 @@ xfs_getattr(
181 vap->va_rdev = 0; 166 vap->va_rdev = 0;
182 167
183 if (!(ip->i_d.di_flags & XFS_DIFLAG_REALTIME)) { 168 if (!(ip->i_d.di_flags & XFS_DIFLAG_REALTIME)) {
184 169 vap->va_blocksize = xfs_preferred_iosize(mp);
185#if 0
186 /* Large block sizes confuse various
187 * user space programs, so letting the
188 * stripe size through is not a good
189 * idea for now.
190 */
191 vap->va_blocksize = mp->m_swidth ?
192 /*
193 * If the underlying volume is a stripe, then
194 * return the stripe width in bytes as the
195 * recommended I/O size.
196 */
197 (mp->m_swidth << mp->m_sb.sb_blocklog) :
198 /*
199 * Return the largest of the preferred buffer
200 * sizes since doing small I/Os into larger
201 * buffers causes buffers to be decommissioned.
202 * The value returned is in bytes.
203 */
204 (1 << (int)MAX(mp->m_readio_log,
205 mp->m_writeio_log));
206
207#else
208 vap->va_blocksize =
209 /*
210 * Return the largest of the preferred buffer
211 * sizes since doing small I/Os into larger
212 * buffers causes buffers to be decommissioned.
213 * The value returned is in bytes.
214 */
215 1 << (int)MAX(mp->m_readio_log,
216 mp->m_writeio_log);
217#endif
218 } else { 170 } else {
219 171
220 /* 172 /*
@@ -581,8 +533,7 @@ xfs_setattr(
581 /* 533 /*
582 * Can't change extent size if any extents are allocated. 534 * Can't change extent size if any extents are allocated.
583 */ 535 */
584 if ((ip->i_d.di_nextents || ip->i_delayed_blks) && 536 if (ip->i_d.di_nextents && (mask & XFS_AT_EXTSIZE) &&
585 (mask & XFS_AT_EXTSIZE) &&
586 ((ip->i_d.di_extsize << mp->m_sb.sb_blocklog) != 537 ((ip->i_d.di_extsize << mp->m_sb.sb_blocklog) !=
587 vap->va_extsize) ) { 538 vap->va_extsize) ) {
588 code = XFS_ERROR(EINVAL); /* EFBIG? */ 539 code = XFS_ERROR(EINVAL); /* EFBIG? */
@@ -610,7 +561,8 @@ xfs_setattr(
610 /* 561 /*
611 * Can't change realtime flag if any extents are allocated. 562 * Can't change realtime flag if any extents are allocated.
612 */ 563 */
613 if (ip->i_d.di_nextents && (mask & XFS_AT_XFLAGS) && 564 if ((ip->i_d.di_nextents || ip->i_delayed_blks) &&
565 (mask & XFS_AT_XFLAGS) &&
614 (ip->i_d.di_flags & XFS_DIFLAG_REALTIME) != 566 (ip->i_d.di_flags & XFS_DIFLAG_REALTIME) !=
615 (vap->va_xflags & XFS_XFLAG_REALTIME)) { 567 (vap->va_xflags & XFS_XFLAG_REALTIME)) {
616 code = XFS_ERROR(EINVAL); /* EFBIG? */ 568 code = XFS_ERROR(EINVAL); /* EFBIG? */
@@ -674,8 +626,10 @@ xfs_setattr(
674 */ 626 */
675 if (mask & XFS_AT_SIZE) { 627 if (mask & XFS_AT_SIZE) {
676 code = 0; 628 code = 0;
677 if (vap->va_size > ip->i_d.di_size) 629 if ((vap->va_size > ip->i_d.di_size) &&
630 (flags & ATTR_NOSIZETOK) == 0) {
678 code = xfs_igrow_start(ip, vap->va_size, credp); 631 code = xfs_igrow_start(ip, vap->va_size, credp);
632 }
679 xfs_iunlock(ip, XFS_ILOCK_EXCL); 633 xfs_iunlock(ip, XFS_ILOCK_EXCL);
680 if (!code) 634 if (!code)
681 code = xfs_itruncate_data(ip, vap->va_size); 635 code = xfs_itruncate_data(ip, vap->va_size);
@@ -1118,6 +1072,7 @@ xfs_fsync(
1118 xfs_inode_t *ip; 1072 xfs_inode_t *ip;
1119 xfs_trans_t *tp; 1073 xfs_trans_t *tp;
1120 int error; 1074 int error;
1075 int log_flushed = 0, changed = 1;
1121 1076
1122 vn_trace_entry(BHV_TO_VNODE(bdp), 1077 vn_trace_entry(BHV_TO_VNODE(bdp),
1123 __FUNCTION__, (inst_t *)__return_address); 1078 __FUNCTION__, (inst_t *)__return_address);
@@ -1171,10 +1126,18 @@ xfs_fsync(
1171 xfs_iunlock(ip, XFS_ILOCK_SHARED); 1126 xfs_iunlock(ip, XFS_ILOCK_SHARED);
1172 1127
1173 if (xfs_ipincount(ip)) { 1128 if (xfs_ipincount(ip)) {
1174 xfs_log_force(ip->i_mount, (xfs_lsn_t)0, 1129 _xfs_log_force(ip->i_mount, (xfs_lsn_t)0,
1175 XFS_LOG_FORCE | 1130 XFS_LOG_FORCE |
1176 ((flag & FSYNC_WAIT) 1131 ((flag & FSYNC_WAIT)
1177 ? XFS_LOG_SYNC : 0)); 1132 ? XFS_LOG_SYNC : 0),
1133 &log_flushed);
1134 } else {
1135 /*
1136 * If the inode is not pinned and nothing
1137 * has changed we don't need to flush the
1138 * cache.
1139 */
1140 changed = 0;
1178 } 1141 }
1179 error = 0; 1142 error = 0;
1180 } else { 1143 } else {
@@ -1210,10 +1173,27 @@ xfs_fsync(
1210 xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); 1173 xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
1211 if (flag & FSYNC_WAIT) 1174 if (flag & FSYNC_WAIT)
1212 xfs_trans_set_sync(tp); 1175 xfs_trans_set_sync(tp);
1213 error = xfs_trans_commit(tp, 0, NULL); 1176 error = _xfs_trans_commit(tp, 0, NULL, &log_flushed);
1214 1177
1215 xfs_iunlock(ip, XFS_ILOCK_EXCL); 1178 xfs_iunlock(ip, XFS_ILOCK_EXCL);
1216 } 1179 }
1180
1181 if ((ip->i_mount->m_flags & XFS_MOUNT_BARRIER) && changed) {
1182 /*
1183 * If the log write didn't issue an ordered tag we need
1184 * to flush the disk cache for the data device now.
1185 */
1186 if (!log_flushed)
1187 xfs_blkdev_issue_flush(ip->i_mount->m_ddev_targp);
1188
1189 /*
1190 * If this inode is on the RT dev we need to flush that
1191 * cache aswell.
1192 */
1193 if (ip->i_d.di_flags & XFS_DIFLAG_REALTIME)
1194 xfs_blkdev_issue_flush(ip->i_mount->m_rtdev_targp);
1195 }
1196
1217 return error; 1197 return error;
1218} 1198}
1219 1199
diff --git a/include/linux/dqblk_xfs.h b/include/linux/dqblk_xfs.h
index cb31719ee192..2fda1b2aabd9 100644
--- a/include/linux/dqblk_xfs.h
+++ b/include/linux/dqblk_xfs.h
@@ -1,22 +1,18 @@
1/* 1/*
2 * Copyright (c) 1995-2001,2004 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 1995-2001,2004 Silicon Graphics, Inc. All Rights Reserved.
3 * 3 *
4 * This program is free software; you can redistribute it and/or modify it 4 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2.1 of the GNU Lesser General Public License 5 * modify it under the terms of the GNU Lesser General Public License
6 * as published by the Free Software Foundation. 6 * as published by the Free Software Foundation.
7 * 7 *
8 * This program is distributed in the hope that it will be useful, 8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details. 11 * GNU Lesser General Public License for more details.
12 * 12 *
13 * You should have received a copy of the GNU General Public License 13 * You should have received a copy of the GNU Lesset General Public License
14 * along with this program; if not, write to the Free Software 14 * along with this program; if not, write to the Free Software Foundation,
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 15 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
16 * USA
17 *
18 * Contact information: Silicon Graphics, Inc., 1500 Crittenden Lane,
19 * Mountain View, CA 94043, USA, or: http://www.sgi.com
20 */ 16 */
21#ifndef _LINUX_DQBLK_XFS_H 17#ifndef _LINUX_DQBLK_XFS_H
22#define _LINUX_DQBLK_XFS_H 18#define _LINUX_DQBLK_XFS_H
@@ -32,7 +28,8 @@
32 28
33#define XQM_USRQUOTA 0 /* system call user quota type */ 29#define XQM_USRQUOTA 0 /* system call user quota type */
34#define XQM_GRPQUOTA 1 /* system call group quota type */ 30#define XQM_GRPQUOTA 1 /* system call group quota type */
35#define XQM_MAXQUOTAS 2 31#define XQM_PRJQUOTA 2 /* system call project quota type */
32#define XQM_MAXQUOTAS 3
36 33
37#define Q_XQUOTAON XQM_CMD(1) /* enable accounting/enforcement */ 34#define Q_XQUOTAON XQM_CMD(1) /* enable accounting/enforcement */
38#define Q_XQUOTAOFF XQM_CMD(2) /* disable accounting/enforcement */ 35#define Q_XQUOTAOFF XQM_CMD(2) /* disable accounting/enforcement */
@@ -40,6 +37,7 @@
40#define Q_XSETQLIM XQM_CMD(4) /* set disk limits */ 37#define Q_XSETQLIM XQM_CMD(4) /* set disk limits */
41#define Q_XGETQSTAT XQM_CMD(5) /* get quota subsystem status */ 38#define Q_XGETQSTAT XQM_CMD(5) /* get quota subsystem status */
42#define Q_XQUOTARM XQM_CMD(6) /* free disk space used by dquots */ 39#define Q_XQUOTARM XQM_CMD(6) /* free disk space used by dquots */
40#define Q_XQUOTASYNC XQM_CMD(7) /* delalloc flush, updates dquots */
43 41
44/* 42/*
45 * fs_disk_quota structure: 43 * fs_disk_quota structure: