aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs
diff options
context:
space:
mode:
Diffstat (limited to 'fs/xfs')
-rw-r--r--fs/xfs/Kconfig1
-rw-r--r--fs/xfs/linux-2.6/xfs_aops.h2
-rw-r--r--fs/xfs/linux-2.6/xfs_buf.c79
-rw-r--r--fs/xfs/linux-2.6/xfs_export.c23
-rw-r--r--fs/xfs/linux-2.6/xfs_ioctl.c320
-rw-r--r--fs/xfs/linux-2.6/xfs_ioctl.h15
-rw-r--r--fs/xfs/linux-2.6/xfs_ioctl32.c186
-rw-r--r--fs/xfs/linux-2.6/xfs_super.c27
-rw-r--r--fs/xfs/linux-2.6/xfs_sync.c6
-rw-r--r--fs/xfs/quota/xfs_dquot.c38
-rw-r--r--fs/xfs/quota/xfs_dquot.h10
-rw-r--r--fs/xfs/quota/xfs_qm.c9
-rw-r--r--fs/xfs/xfs_acl.h1
-rw-r--r--fs/xfs/xfs_ag.h8
-rw-r--r--fs/xfs/xfs_alloc_btree.c2
-rw-r--r--fs/xfs/xfs_attr.c26
-rw-r--r--fs/xfs/xfs_attr_leaf.c72
-rw-r--r--fs/xfs/xfs_attr_leaf.h12
-rw-r--r--fs/xfs/xfs_bit.h10
-rw-r--r--fs/xfs/xfs_bmap.c166
-rw-r--r--fs/xfs/xfs_bmap.h2
-rw-r--r--fs/xfs/xfs_bmap_btree.c94
-rw-r--r--fs/xfs/xfs_bmap_btree.h4
-rw-r--r--fs/xfs/xfs_btree.c20
-rw-r--r--fs/xfs/xfs_da_btree.c8
-rw-r--r--fs/xfs/xfs_dfrag.c10
-rw-r--r--fs/xfs/xfs_dir2_block.c7
-rw-r--r--fs/xfs/xfs_dir2_leaf.c6
-rw-r--r--fs/xfs/xfs_dir2_sf.c15
-rw-r--r--fs/xfs/xfs_fs.h4
-rw-r--r--fs/xfs/xfs_fsops.c11
-rw-r--r--fs/xfs/xfs_fsops.h2
-rw-r--r--fs/xfs/xfs_ialloc.c6
-rw-r--r--fs/xfs/xfs_ialloc.h2
-rw-r--r--fs/xfs/xfs_ialloc_btree.h1
-rw-r--r--fs/xfs/xfs_inode.c19
-rw-r--r--fs/xfs/xfs_inode_item.h4
-rw-r--r--fs/xfs/xfs_iomap.c10
-rw-r--r--fs/xfs/xfs_itable.c6
-rw-r--r--fs/xfs/xfs_log_recover.c31
-rw-r--r--fs/xfs/xfs_mount.c26
-rw-r--r--fs/xfs/xfs_mount.h9
-rw-r--r--fs/xfs/xfs_rename.c2
-rw-r--r--fs/xfs/xfs_rtalloc.c2
-rw-r--r--fs/xfs/xfs_rw.h1
-rw-r--r--fs/xfs/xfs_sb.h2
-rw-r--r--fs/xfs/xfs_types.h4
-rw-r--r--fs/xfs/xfs_vnodeops.c20
48 files changed, 607 insertions, 734 deletions
diff --git a/fs/xfs/Kconfig b/fs/xfs/Kconfig
index 3f53dd101f99..29228f5899cd 100644
--- a/fs/xfs/Kconfig
+++ b/fs/xfs/Kconfig
@@ -1,6 +1,7 @@
1config XFS_FS 1config XFS_FS
2 tristate "XFS filesystem support" 2 tristate "XFS filesystem support"
3 depends on BLOCK 3 depends on BLOCK
4 select EXPORTFS
4 help 5 help
5 XFS is a high performance journaling filesystem which originated 6 XFS is a high performance journaling filesystem which originated
6 on the SGI IRIX platform. It is completely multi-threaded, can 7 on the SGI IRIX platform. It is completely multi-threaded, can
diff --git a/fs/xfs/linux-2.6/xfs_aops.h b/fs/xfs/linux-2.6/xfs_aops.h
index 7b26f5ff9692..1dd528849755 100644
--- a/fs/xfs/linux-2.6/xfs_aops.h
+++ b/fs/xfs/linux-2.6/xfs_aops.h
@@ -21,8 +21,6 @@
21extern struct workqueue_struct *xfsdatad_workqueue; 21extern struct workqueue_struct *xfsdatad_workqueue;
22extern mempool_t *xfs_ioend_pool; 22extern mempool_t *xfs_ioend_pool;
23 23
24typedef void (*xfs_ioend_func_t)(void *);
25
26/* 24/*
27 * xfs_ioend struct manages large extent writes for XFS. 25 * xfs_ioend struct manages large extent writes for XFS.
28 * It can manage several multi-page bio's at once. 26 * It can manage several multi-page bio's at once.
diff --git a/fs/xfs/linux-2.6/xfs_buf.c b/fs/xfs/linux-2.6/xfs_buf.c
index cb329edc925b..d71dc44e21ed 100644
--- a/fs/xfs/linux-2.6/xfs_buf.c
+++ b/fs/xfs/linux-2.6/xfs_buf.c
@@ -166,75 +166,6 @@ test_page_region(
166} 166}
167 167
168/* 168/*
169 * Mapping of multi-page buffers into contiguous virtual space
170 */
171
172typedef struct a_list {
173 void *vm_addr;
174 struct a_list *next;
175} a_list_t;
176
177static a_list_t *as_free_head;
178static int as_list_len;
179static DEFINE_SPINLOCK(as_lock);
180
181/*
182 * Try to batch vunmaps because they are costly.
183 */
184STATIC void
185free_address(
186 void *addr)
187{
188 a_list_t *aentry;
189
190#ifdef CONFIG_XEN
191 /*
192 * Xen needs to be able to make sure it can get an exclusive
193 * RO mapping of pages it wants to turn into a pagetable. If
194 * a newly allocated page is also still being vmap()ed by xfs,
195 * it will cause pagetable construction to fail. This is a
196 * quick workaround to always eagerly unmap pages so that Xen
197 * is happy.
198 */
199 vunmap(addr);
200 return;
201#endif
202
203 aentry = kmalloc(sizeof(a_list_t), GFP_NOWAIT);
204 if (likely(aentry)) {
205 spin_lock(&as_lock);
206 aentry->next = as_free_head;
207 aentry->vm_addr = addr;
208 as_free_head = aentry;
209 as_list_len++;
210 spin_unlock(&as_lock);
211 } else {
212 vunmap(addr);
213 }
214}
215
216STATIC void
217purge_addresses(void)
218{
219 a_list_t *aentry, *old;
220
221 if (as_free_head == NULL)
222 return;
223
224 spin_lock(&as_lock);
225 aentry = as_free_head;
226 as_free_head = NULL;
227 as_list_len = 0;
228 spin_unlock(&as_lock);
229
230 while ((old = aentry) != NULL) {
231 vunmap(aentry->vm_addr);
232 aentry = aentry->next;
233 kfree(old);
234 }
235}
236
237/*
238 * Internal xfs_buf_t object manipulation 169 * Internal xfs_buf_t object manipulation
239 */ 170 */
240 171
@@ -333,7 +264,7 @@ xfs_buf_free(
333 uint i; 264 uint i;
334 265
335 if ((bp->b_flags & XBF_MAPPED) && (bp->b_page_count > 1)) 266 if ((bp->b_flags & XBF_MAPPED) && (bp->b_page_count > 1))
336 free_address(bp->b_addr - bp->b_offset); 267 vm_unmap_ram(bp->b_addr - bp->b_offset, bp->b_page_count);
337 268
338 for (i = 0; i < bp->b_page_count; i++) { 269 for (i = 0; i < bp->b_page_count; i++) {
339 struct page *page = bp->b_pages[i]; 270 struct page *page = bp->b_pages[i];
@@ -455,10 +386,8 @@ _xfs_buf_map_pages(
455 bp->b_addr = page_address(bp->b_pages[0]) + bp->b_offset; 386 bp->b_addr = page_address(bp->b_pages[0]) + bp->b_offset;
456 bp->b_flags |= XBF_MAPPED; 387 bp->b_flags |= XBF_MAPPED;
457 } else if (flags & XBF_MAPPED) { 388 } else if (flags & XBF_MAPPED) {
458 if (as_list_len > 64) 389 bp->b_addr = vm_map_ram(bp->b_pages, bp->b_page_count,
459 purge_addresses(); 390 -1, PAGE_KERNEL);
460 bp->b_addr = vmap(bp->b_pages, bp->b_page_count,
461 VM_MAP, PAGE_KERNEL);
462 if (unlikely(bp->b_addr == NULL)) 391 if (unlikely(bp->b_addr == NULL))
463 return -ENOMEM; 392 return -ENOMEM;
464 bp->b_addr += bp->b_offset; 393 bp->b_addr += bp->b_offset;
@@ -1743,8 +1672,6 @@ xfsbufd(
1743 count++; 1672 count++;
1744 } 1673 }
1745 1674
1746 if (as_list_len > 0)
1747 purge_addresses();
1748 if (count) 1675 if (count)
1749 blk_run_address_space(target->bt_mapping); 1676 blk_run_address_space(target->bt_mapping);
1750 1677
diff --git a/fs/xfs/linux-2.6/xfs_export.c b/fs/xfs/linux-2.6/xfs_export.c
index 595751f78350..87b8cbd23d4b 100644
--- a/fs/xfs/linux-2.6/xfs_export.c
+++ b/fs/xfs/linux-2.6/xfs_export.c
@@ -126,11 +126,26 @@ xfs_nfs_get_inode(
126 if (ino == 0) 126 if (ino == 0)
127 return ERR_PTR(-ESTALE); 127 return ERR_PTR(-ESTALE);
128 128
129 error = xfs_iget(mp, NULL, ino, 0, XFS_ILOCK_SHARED, &ip, 0); 129 /*
130 if (error) 130 * The XFS_IGET_BULKSTAT means that an invalid inode number is just
131 * fine and not an indication of a corrupted filesystem. Because
132 * clients can send any kind of invalid file handle, e.g. after
133 * a restore on the server we have to deal with this case gracefully.
134 */
135 error = xfs_iget(mp, NULL, ino, XFS_IGET_BULKSTAT,
136 XFS_ILOCK_SHARED, &ip, 0);
137 if (error) {
138 /*
139 * EINVAL means the inode cluster doesn't exist anymore.
140 * This implies the filehandle is stale, so we should
141 * translate it here.
142 * We don't use ESTALE directly down the chain to not
143 * confuse applications using bulkstat that expect EINVAL.
144 */
145 if (error == EINVAL)
146 error = ESTALE;
131 return ERR_PTR(-error); 147 return ERR_PTR(-error);
132 if (!ip) 148 }
133 return ERR_PTR(-EIO);
134 149
135 if (ip->i_d.di_gen != generation) { 150 if (ip->i_d.di_gen != generation) {
136 xfs_iput_new(ip, XFS_ILOCK_SHARED); 151 xfs_iput_new(ip, XFS_ILOCK_SHARED);
diff --git a/fs/xfs/linux-2.6/xfs_ioctl.c b/fs/xfs/linux-2.6/xfs_ioctl.c
index 67205f6198ba..4bd112313f33 100644
--- a/fs/xfs/linux-2.6/xfs_ioctl.c
+++ b/fs/xfs/linux-2.6/xfs_ioctl.c
@@ -50,12 +50,14 @@
50#include "xfs_vnodeops.h" 50#include "xfs_vnodeops.h"
51#include "xfs_quota.h" 51#include "xfs_quota.h"
52#include "xfs_inode_item.h" 52#include "xfs_inode_item.h"
53#include "xfs_export.h"
53 54
54#include <linux/capability.h> 55#include <linux/capability.h>
55#include <linux/dcache.h> 56#include <linux/dcache.h>
56#include <linux/mount.h> 57#include <linux/mount.h>
57#include <linux/namei.h> 58#include <linux/namei.h>
58#include <linux/pagemap.h> 59#include <linux/pagemap.h>
60#include <linux/exportfs.h>
59 61
60/* 62/*
61 * xfs_find_handle maps from userspace xfs_fsop_handlereq structure to 63 * xfs_find_handle maps from userspace xfs_fsop_handlereq structure to
@@ -164,97 +166,69 @@ xfs_find_handle(
164 return 0; 166 return 0;
165} 167}
166 168
167
168/* 169/*
169 * Convert userspace handle data into inode. 170 * No need to do permission checks on the various pathname components
170 * 171 * as the handle operations are privileged.
171 * We use the fact that all the fsop_handlereq ioctl calls have a data
172 * structure argument whose first component is always a xfs_fsop_handlereq_t,
173 * so we can pass that sub structure into this handy, shared routine.
174 *
175 * If no error, caller must always iput the returned inode.
176 */ 172 */
177STATIC int 173STATIC int
178xfs_vget_fsop_handlereq( 174xfs_handle_acceptable(
179 xfs_mount_t *mp, 175 void *context,
180 struct inode *parinode, /* parent inode pointer */ 176 struct dentry *dentry)
181 xfs_fsop_handlereq_t *hreq, 177{
182 struct inode **inode) 178 return 1;
179}
180
181/*
182 * Convert userspace handle data into a dentry.
183 */
184struct dentry *
185xfs_handle_to_dentry(
186 struct file *parfilp,
187 void __user *uhandle,
188 u32 hlen)
183{ 189{
184 void __user *hanp;
185 size_t hlen;
186 xfs_fid_t *xfid;
187 xfs_handle_t *handlep;
188 xfs_handle_t handle; 190 xfs_handle_t handle;
189 xfs_inode_t *ip; 191 struct xfs_fid64 fid;
190 xfs_ino_t ino;
191 __u32 igen;
192 int error;
193 192
194 /* 193 /*
195 * Only allow handle opens under a directory. 194 * Only allow handle opens under a directory.
196 */ 195 */
197 if (!S_ISDIR(parinode->i_mode)) 196 if (!S_ISDIR(parfilp->f_path.dentry->d_inode->i_mode))
198 return XFS_ERROR(ENOTDIR); 197 return ERR_PTR(-ENOTDIR);
199 198
200 hanp = hreq->ihandle; 199 if (hlen != sizeof(xfs_handle_t))
201 hlen = hreq->ihandlen; 200 return ERR_PTR(-EINVAL);
202 handlep = &handle; 201 if (copy_from_user(&handle, uhandle, hlen))
203 202 return ERR_PTR(-EFAULT);
204 if (hlen < sizeof(handlep->ha_fsid) || hlen > sizeof(*handlep)) 203 if (handle.ha_fid.fid_len !=
205 return XFS_ERROR(EINVAL); 204 sizeof(handle.ha_fid) - sizeof(handle.ha_fid.fid_len))
206 if (copy_from_user(handlep, hanp, hlen)) 205 return ERR_PTR(-EINVAL);
207 return XFS_ERROR(EFAULT); 206
208 if (hlen < sizeof(*handlep)) 207 memset(&fid, 0, sizeof(struct fid));
209 memset(((char *)handlep) + hlen, 0, sizeof(*handlep) - hlen); 208 fid.ino = handle.ha_fid.fid_ino;
210 if (hlen > sizeof(handlep->ha_fsid)) { 209 fid.gen = handle.ha_fid.fid_gen;
211 if (handlep->ha_fid.fid_len != 210
212 (hlen - sizeof(handlep->ha_fsid) - 211 return exportfs_decode_fh(parfilp->f_path.mnt, (struct fid *)&fid, 3,
213 sizeof(handlep->ha_fid.fid_len)) || 212 FILEID_INO32_GEN | XFS_FILEID_TYPE_64FLAG,
214 handlep->ha_fid.fid_pad) 213 xfs_handle_acceptable, NULL);
215 return XFS_ERROR(EINVAL); 214}
216 }
217
218 /*
219 * Crack the handle, obtain the inode # & generation #
220 */
221 xfid = (struct xfs_fid *)&handlep->ha_fid;
222 if (xfid->fid_len == sizeof(*xfid) - sizeof(xfid->fid_len)) {
223 ino = xfid->fid_ino;
224 igen = xfid->fid_gen;
225 } else {
226 return XFS_ERROR(EINVAL);
227 }
228
229 /*
230 * Get the XFS inode, building a Linux inode to go with it.
231 */
232 error = xfs_iget(mp, NULL, ino, 0, XFS_ILOCK_SHARED, &ip, 0);
233 if (error)
234 return error;
235 if (ip == NULL)
236 return XFS_ERROR(EIO);
237 if (ip->i_d.di_gen != igen) {
238 xfs_iput_new(ip, XFS_ILOCK_SHARED);
239 return XFS_ERROR(ENOENT);
240 }
241
242 xfs_iunlock(ip, XFS_ILOCK_SHARED);
243 215
244 *inode = VFS_I(ip); 216STATIC struct dentry *
245 return 0; 217xfs_handlereq_to_dentry(
218 struct file *parfilp,
219 xfs_fsop_handlereq_t *hreq)
220{
221 return xfs_handle_to_dentry(parfilp, hreq->ihandle, hreq->ihandlen);
246} 222}
247 223
248int 224int
249xfs_open_by_handle( 225xfs_open_by_handle(
250 xfs_mount_t *mp,
251 xfs_fsop_handlereq_t *hreq,
252 struct file *parfilp, 226 struct file *parfilp,
253 struct inode *parinode) 227 xfs_fsop_handlereq_t *hreq)
254{ 228{
255 const struct cred *cred = current_cred(); 229 const struct cred *cred = current_cred();
256 int error; 230 int error;
257 int new_fd; 231 int fd;
258 int permflag; 232 int permflag;
259 struct file *filp; 233 struct file *filp;
260 struct inode *inode; 234 struct inode *inode;
@@ -263,19 +237,21 @@ xfs_open_by_handle(
263 if (!capable(CAP_SYS_ADMIN)) 237 if (!capable(CAP_SYS_ADMIN))
264 return -XFS_ERROR(EPERM); 238 return -XFS_ERROR(EPERM);
265 239
266 error = xfs_vget_fsop_handlereq(mp, parinode, hreq, &inode); 240 dentry = xfs_handlereq_to_dentry(parfilp, hreq);
267 if (error) 241 if (IS_ERR(dentry))
268 return -error; 242 return PTR_ERR(dentry);
243 inode = dentry->d_inode;
269 244
270 /* Restrict xfs_open_by_handle to directories & regular files. */ 245 /* Restrict xfs_open_by_handle to directories & regular files. */
271 if (!(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode))) { 246 if (!(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode))) {
272 iput(inode); 247 error = -XFS_ERROR(EPERM);
273 return -XFS_ERROR(EINVAL); 248 goto out_dput;
274 } 249 }
275 250
276#if BITS_PER_LONG != 32 251#if BITS_PER_LONG != 32
277 hreq->oflags |= O_LARGEFILE; 252 hreq->oflags |= O_LARGEFILE;
278#endif 253#endif
254
279 /* Put open permission in namei format. */ 255 /* Put open permission in namei format. */
280 permflag = hreq->oflags; 256 permflag = hreq->oflags;
281 if ((permflag+1) & O_ACCMODE) 257 if ((permflag+1) & O_ACCMODE)
@@ -285,50 +261,45 @@ xfs_open_by_handle(
285 261
286 if ((!(permflag & O_APPEND) || (permflag & O_TRUNC)) && 262 if ((!(permflag & O_APPEND) || (permflag & O_TRUNC)) &&
287 (permflag & FMODE_WRITE) && IS_APPEND(inode)) { 263 (permflag & FMODE_WRITE) && IS_APPEND(inode)) {
288 iput(inode); 264 error = -XFS_ERROR(EPERM);
289 return -XFS_ERROR(EPERM); 265 goto out_dput;
290 } 266 }
291 267
292 if ((permflag & FMODE_WRITE) && IS_IMMUTABLE(inode)) { 268 if ((permflag & FMODE_WRITE) && IS_IMMUTABLE(inode)) {
293 iput(inode); 269 error = -XFS_ERROR(EACCES);
294 return -XFS_ERROR(EACCES); 270 goto out_dput;
295 } 271 }
296 272
297 /* Can't write directories. */ 273 /* Can't write directories. */
298 if ( S_ISDIR(inode->i_mode) && (permflag & FMODE_WRITE)) { 274 if (S_ISDIR(inode->i_mode) && (permflag & FMODE_WRITE)) {
299 iput(inode); 275 error = -XFS_ERROR(EISDIR);
300 return -XFS_ERROR(EISDIR); 276 goto out_dput;
301 }
302
303 if ((new_fd = get_unused_fd()) < 0) {
304 iput(inode);
305 return new_fd;
306 } 277 }
307 278
308 dentry = d_obtain_alias(inode); 279 fd = get_unused_fd();
309 if (IS_ERR(dentry)) { 280 if (fd < 0) {
310 put_unused_fd(new_fd); 281 error = fd;
311 return PTR_ERR(dentry); 282 goto out_dput;
312 } 283 }
313 284
314 /* Ensure umount returns EBUSY on umounts while this file is open. */ 285 filp = dentry_open(dentry, mntget(parfilp->f_path.mnt),
315 mntget(parfilp->f_path.mnt); 286 hreq->oflags, cred);
316
317 /* Create file pointer. */
318 filp = dentry_open(dentry, parfilp->f_path.mnt, hreq->oflags, cred);
319 if (IS_ERR(filp)) { 287 if (IS_ERR(filp)) {
320 put_unused_fd(new_fd); 288 put_unused_fd(fd);
321 return -XFS_ERROR(-PTR_ERR(filp)); 289 return PTR_ERR(filp);
322 } 290 }
323 291
324 if (inode->i_mode & S_IFREG) { 292 if (inode->i_mode & S_IFREG) {
325 /* invisible operation should not change atime */
326 filp->f_flags |= O_NOATIME; 293 filp->f_flags |= O_NOATIME;
327 filp->f_mode |= FMODE_NOCMTIME; 294 filp->f_mode |= FMODE_NOCMTIME;
328 } 295 }
329 296
330 fd_install(new_fd, filp); 297 fd_install(fd, filp);
331 return new_fd; 298 return fd;
299
300 out_dput:
301 dput(dentry);
302 return error;
332} 303}
333 304
334/* 305/*
@@ -359,11 +330,10 @@ do_readlink(
359 330
360int 331int
361xfs_readlink_by_handle( 332xfs_readlink_by_handle(
362 xfs_mount_t *mp, 333 struct file *parfilp,
363 xfs_fsop_handlereq_t *hreq, 334 xfs_fsop_handlereq_t *hreq)
364 struct inode *parinode)
365{ 335{
366 struct inode *inode; 336 struct dentry *dentry;
367 __u32 olen; 337 __u32 olen;
368 void *link; 338 void *link;
369 int error; 339 int error;
@@ -371,26 +341,28 @@ xfs_readlink_by_handle(
371 if (!capable(CAP_SYS_ADMIN)) 341 if (!capable(CAP_SYS_ADMIN))
372 return -XFS_ERROR(EPERM); 342 return -XFS_ERROR(EPERM);
373 343
374 error = xfs_vget_fsop_handlereq(mp, parinode, hreq, &inode); 344 dentry = xfs_handlereq_to_dentry(parfilp, hreq);
375 if (error) 345 if (IS_ERR(dentry))
376 return -error; 346 return PTR_ERR(dentry);
377 347
378 /* Restrict this handle operation to symlinks only. */ 348 /* Restrict this handle operation to symlinks only. */
379 if (!S_ISLNK(inode->i_mode)) { 349 if (!S_ISLNK(dentry->d_inode->i_mode)) {
380 error = -XFS_ERROR(EINVAL); 350 error = -XFS_ERROR(EINVAL);
381 goto out_iput; 351 goto out_dput;
382 } 352 }
383 353
384 if (copy_from_user(&olen, hreq->ohandlen, sizeof(__u32))) { 354 if (copy_from_user(&olen, hreq->ohandlen, sizeof(__u32))) {
385 error = -XFS_ERROR(EFAULT); 355 error = -XFS_ERROR(EFAULT);
386 goto out_iput; 356 goto out_dput;
387 } 357 }
388 358
389 link = kmalloc(MAXPATHLEN+1, GFP_KERNEL); 359 link = kmalloc(MAXPATHLEN+1, GFP_KERNEL);
390 if (!link) 360 if (!link) {
391 goto out_iput; 361 error = -XFS_ERROR(ENOMEM);
362 goto out_dput;
363 }
392 364
393 error = -xfs_readlink(XFS_I(inode), link); 365 error = -xfs_readlink(XFS_I(dentry->d_inode), link);
394 if (error) 366 if (error)
395 goto out_kfree; 367 goto out_kfree;
396 error = do_readlink(hreq->ohandle, olen, link); 368 error = do_readlink(hreq->ohandle, olen, link);
@@ -399,32 +371,31 @@ xfs_readlink_by_handle(
399 371
400 out_kfree: 372 out_kfree:
401 kfree(link); 373 kfree(link);
402 out_iput: 374 out_dput:
403 iput(inode); 375 dput(dentry);
404 return error; 376 return error;
405} 377}
406 378
407STATIC int 379STATIC int
408xfs_fssetdm_by_handle( 380xfs_fssetdm_by_handle(
409 xfs_mount_t *mp, 381 struct file *parfilp,
410 void __user *arg, 382 void __user *arg)
411 struct inode *parinode)
412{ 383{
413 int error; 384 int error;
414 struct fsdmidata fsd; 385 struct fsdmidata fsd;
415 xfs_fsop_setdm_handlereq_t dmhreq; 386 xfs_fsop_setdm_handlereq_t dmhreq;
416 struct inode *inode; 387 struct dentry *dentry;
417 388
418 if (!capable(CAP_MKNOD)) 389 if (!capable(CAP_MKNOD))
419 return -XFS_ERROR(EPERM); 390 return -XFS_ERROR(EPERM);
420 if (copy_from_user(&dmhreq, arg, sizeof(xfs_fsop_setdm_handlereq_t))) 391 if (copy_from_user(&dmhreq, arg, sizeof(xfs_fsop_setdm_handlereq_t)))
421 return -XFS_ERROR(EFAULT); 392 return -XFS_ERROR(EFAULT);
422 393
423 error = xfs_vget_fsop_handlereq(mp, parinode, &dmhreq.hreq, &inode); 394 dentry = xfs_handlereq_to_dentry(parfilp, &dmhreq.hreq);
424 if (error) 395 if (IS_ERR(dentry))
425 return -error; 396 return PTR_ERR(dentry);
426 397
427 if (IS_IMMUTABLE(inode) || IS_APPEND(inode)) { 398 if (IS_IMMUTABLE(dentry->d_inode) || IS_APPEND(dentry->d_inode)) {
428 error = -XFS_ERROR(EPERM); 399 error = -XFS_ERROR(EPERM);
429 goto out; 400 goto out;
430 } 401 }
@@ -434,24 +405,23 @@ xfs_fssetdm_by_handle(
434 goto out; 405 goto out;
435 } 406 }
436 407
437 error = -xfs_set_dmattrs(XFS_I(inode), fsd.fsd_dmevmask, 408 error = -xfs_set_dmattrs(XFS_I(dentry->d_inode), fsd.fsd_dmevmask,
438 fsd.fsd_dmstate); 409 fsd.fsd_dmstate);
439 410
440 out: 411 out:
441 iput(inode); 412 dput(dentry);
442 return error; 413 return error;
443} 414}
444 415
445STATIC int 416STATIC int
446xfs_attrlist_by_handle( 417xfs_attrlist_by_handle(
447 xfs_mount_t *mp, 418 struct file *parfilp,
448 void __user *arg, 419 void __user *arg)
449 struct inode *parinode)
450{ 420{
451 int error; 421 int error = -ENOMEM;
452 attrlist_cursor_kern_t *cursor; 422 attrlist_cursor_kern_t *cursor;
453 xfs_fsop_attrlist_handlereq_t al_hreq; 423 xfs_fsop_attrlist_handlereq_t al_hreq;
454 struct inode *inode; 424 struct dentry *dentry;
455 char *kbuf; 425 char *kbuf;
456 426
457 if (!capable(CAP_SYS_ADMIN)) 427 if (!capable(CAP_SYS_ADMIN))
@@ -467,16 +437,16 @@ xfs_attrlist_by_handle(
467 if (al_hreq.flags & ~(ATTR_ROOT | ATTR_SECURE)) 437 if (al_hreq.flags & ~(ATTR_ROOT | ATTR_SECURE))
468 return -XFS_ERROR(EINVAL); 438 return -XFS_ERROR(EINVAL);
469 439
470 error = xfs_vget_fsop_handlereq(mp, parinode, &al_hreq.hreq, &inode); 440 dentry = xfs_handlereq_to_dentry(parfilp, &al_hreq.hreq);
471 if (error) 441 if (IS_ERR(dentry))
472 goto out; 442 return PTR_ERR(dentry);
473 443
474 kbuf = kmalloc(al_hreq.buflen, GFP_KERNEL); 444 kbuf = kmalloc(al_hreq.buflen, GFP_KERNEL);
475 if (!kbuf) 445 if (!kbuf)
476 goto out_vn_rele; 446 goto out_dput;
477 447
478 cursor = (attrlist_cursor_kern_t *)&al_hreq.pos; 448 cursor = (attrlist_cursor_kern_t *)&al_hreq.pos;
479 error = xfs_attr_list(XFS_I(inode), kbuf, al_hreq.buflen, 449 error = -xfs_attr_list(XFS_I(dentry->d_inode), kbuf, al_hreq.buflen,
480 al_hreq.flags, cursor); 450 al_hreq.flags, cursor);
481 if (error) 451 if (error)
482 goto out_kfree; 452 goto out_kfree;
@@ -486,10 +456,9 @@ xfs_attrlist_by_handle(
486 456
487 out_kfree: 457 out_kfree:
488 kfree(kbuf); 458 kfree(kbuf);
489 out_vn_rele: 459 out_dput:
490 iput(inode); 460 dput(dentry);
491 out: 461 return error;
492 return -error;
493} 462}
494 463
495int 464int
@@ -564,15 +533,13 @@ xfs_attrmulti_attr_remove(
564 533
565STATIC int 534STATIC int
566xfs_attrmulti_by_handle( 535xfs_attrmulti_by_handle(
567 xfs_mount_t *mp,
568 void __user *arg,
569 struct file *parfilp, 536 struct file *parfilp,
570 struct inode *parinode) 537 void __user *arg)
571{ 538{
572 int error; 539 int error;
573 xfs_attr_multiop_t *ops; 540 xfs_attr_multiop_t *ops;
574 xfs_fsop_attrmulti_handlereq_t am_hreq; 541 xfs_fsop_attrmulti_handlereq_t am_hreq;
575 struct inode *inode; 542 struct dentry *dentry;
576 unsigned int i, size; 543 unsigned int i, size;
577 char *attr_name; 544 char *attr_name;
578 545
@@ -581,19 +548,19 @@ xfs_attrmulti_by_handle(
581 if (copy_from_user(&am_hreq, arg, sizeof(xfs_fsop_attrmulti_handlereq_t))) 548 if (copy_from_user(&am_hreq, arg, sizeof(xfs_fsop_attrmulti_handlereq_t)))
582 return -XFS_ERROR(EFAULT); 549 return -XFS_ERROR(EFAULT);
583 550
584 error = xfs_vget_fsop_handlereq(mp, parinode, &am_hreq.hreq, &inode); 551 dentry = xfs_handlereq_to_dentry(parfilp, &am_hreq.hreq);
585 if (error) 552 if (IS_ERR(dentry))
586 goto out; 553 return PTR_ERR(dentry);
587 554
588 error = E2BIG; 555 error = E2BIG;
589 size = am_hreq.opcount * sizeof(xfs_attr_multiop_t); 556 size = am_hreq.opcount * sizeof(xfs_attr_multiop_t);
590 if (!size || size > 16 * PAGE_SIZE) 557 if (!size || size > 16 * PAGE_SIZE)
591 goto out_vn_rele; 558 goto out_dput;
592 559
593 error = ENOMEM; 560 error = ENOMEM;
594 ops = kmalloc(size, GFP_KERNEL); 561 ops = kmalloc(size, GFP_KERNEL);
595 if (!ops) 562 if (!ops)
596 goto out_vn_rele; 563 goto out_dput;
597 564
598 error = EFAULT; 565 error = EFAULT;
599 if (copy_from_user(ops, am_hreq.ops, size)) 566 if (copy_from_user(ops, am_hreq.ops, size))
@@ -615,25 +582,28 @@ xfs_attrmulti_by_handle(
615 582
616 switch (ops[i].am_opcode) { 583 switch (ops[i].am_opcode) {
617 case ATTR_OP_GET: 584 case ATTR_OP_GET:
618 ops[i].am_error = xfs_attrmulti_attr_get(inode, 585 ops[i].am_error = xfs_attrmulti_attr_get(
619 attr_name, ops[i].am_attrvalue, 586 dentry->d_inode, attr_name,
620 &ops[i].am_length, ops[i].am_flags); 587 ops[i].am_attrvalue, &ops[i].am_length,
588 ops[i].am_flags);
621 break; 589 break;
622 case ATTR_OP_SET: 590 case ATTR_OP_SET:
623 ops[i].am_error = mnt_want_write(parfilp->f_path.mnt); 591 ops[i].am_error = mnt_want_write(parfilp->f_path.mnt);
624 if (ops[i].am_error) 592 if (ops[i].am_error)
625 break; 593 break;
626 ops[i].am_error = xfs_attrmulti_attr_set(inode, 594 ops[i].am_error = xfs_attrmulti_attr_set(
627 attr_name, ops[i].am_attrvalue, 595 dentry->d_inode, attr_name,
628 ops[i].am_length, ops[i].am_flags); 596 ops[i].am_attrvalue, ops[i].am_length,
597 ops[i].am_flags);
629 mnt_drop_write(parfilp->f_path.mnt); 598 mnt_drop_write(parfilp->f_path.mnt);
630 break; 599 break;
631 case ATTR_OP_REMOVE: 600 case ATTR_OP_REMOVE:
632 ops[i].am_error = mnt_want_write(parfilp->f_path.mnt); 601 ops[i].am_error = mnt_want_write(parfilp->f_path.mnt);
633 if (ops[i].am_error) 602 if (ops[i].am_error)
634 break; 603 break;
635 ops[i].am_error = xfs_attrmulti_attr_remove(inode, 604 ops[i].am_error = xfs_attrmulti_attr_remove(
636 attr_name, ops[i].am_flags); 605 dentry->d_inode, attr_name,
606 ops[i].am_flags);
637 mnt_drop_write(parfilp->f_path.mnt); 607 mnt_drop_write(parfilp->f_path.mnt);
638 break; 608 break;
639 default: 609 default:
@@ -647,9 +617,8 @@ xfs_attrmulti_by_handle(
647 kfree(attr_name); 617 kfree(attr_name);
648 out_kfree_ops: 618 out_kfree_ops:
649 kfree(ops); 619 kfree(ops);
650 out_vn_rele: 620 out_dput:
651 iput(inode); 621 dput(dentry);
652 out:
653 return -error; 622 return -error;
654} 623}
655 624
@@ -1440,23 +1409,23 @@ xfs_file_ioctl(
1440 1409
1441 if (copy_from_user(&hreq, arg, sizeof(xfs_fsop_handlereq_t))) 1410 if (copy_from_user(&hreq, arg, sizeof(xfs_fsop_handlereq_t)))
1442 return -XFS_ERROR(EFAULT); 1411 return -XFS_ERROR(EFAULT);
1443 return xfs_open_by_handle(mp, &hreq, filp, inode); 1412 return xfs_open_by_handle(filp, &hreq);
1444 } 1413 }
1445 case XFS_IOC_FSSETDM_BY_HANDLE: 1414 case XFS_IOC_FSSETDM_BY_HANDLE:
1446 return xfs_fssetdm_by_handle(mp, arg, inode); 1415 return xfs_fssetdm_by_handle(filp, arg);
1447 1416
1448 case XFS_IOC_READLINK_BY_HANDLE: { 1417 case XFS_IOC_READLINK_BY_HANDLE: {
1449 xfs_fsop_handlereq_t hreq; 1418 xfs_fsop_handlereq_t hreq;
1450 1419
1451 if (copy_from_user(&hreq, arg, sizeof(xfs_fsop_handlereq_t))) 1420 if (copy_from_user(&hreq, arg, sizeof(xfs_fsop_handlereq_t)))
1452 return -XFS_ERROR(EFAULT); 1421 return -XFS_ERROR(EFAULT);
1453 return xfs_readlink_by_handle(mp, &hreq, inode); 1422 return xfs_readlink_by_handle(filp, &hreq);
1454 } 1423 }
1455 case XFS_IOC_ATTRLIST_BY_HANDLE: 1424 case XFS_IOC_ATTRLIST_BY_HANDLE:
1456 return xfs_attrlist_by_handle(mp, arg, inode); 1425 return xfs_attrlist_by_handle(filp, arg);
1457 1426
1458 case XFS_IOC_ATTRMULTI_BY_HANDLE: 1427 case XFS_IOC_ATTRMULTI_BY_HANDLE:
1459 return xfs_attrmulti_by_handle(mp, arg, filp, inode); 1428 return xfs_attrmulti_by_handle(filp, arg);
1460 1429
1461 case XFS_IOC_SWAPEXT: { 1430 case XFS_IOC_SWAPEXT: {
1462 struct xfs_swapext sxp; 1431 struct xfs_swapext sxp;
@@ -1546,21 +1515,6 @@ xfs_file_ioctl(
1546 return -error; 1515 return -error;
1547 } 1516 }
1548 1517
1549 case XFS_IOC_FREEZE:
1550 if (!capable(CAP_SYS_ADMIN))
1551 return -EPERM;
1552
1553 if (inode->i_sb->s_frozen == SB_UNFROZEN)
1554 freeze_bdev(inode->i_sb->s_bdev);
1555 return 0;
1556
1557 case XFS_IOC_THAW:
1558 if (!capable(CAP_SYS_ADMIN))
1559 return -EPERM;
1560 if (inode->i_sb->s_frozen != SB_UNFROZEN)
1561 thaw_bdev(inode->i_sb->s_bdev, inode->i_sb);
1562 return 0;
1563
1564 case XFS_IOC_GOINGDOWN: { 1518 case XFS_IOC_GOINGDOWN: {
1565 __uint32_t in; 1519 __uint32_t in;
1566 1520
diff --git a/fs/xfs/linux-2.6/xfs_ioctl.h b/fs/xfs/linux-2.6/xfs_ioctl.h
index 8c16bf2d7e03..7bd7c6afc1eb 100644
--- a/fs/xfs/linux-2.6/xfs_ioctl.h
+++ b/fs/xfs/linux-2.6/xfs_ioctl.h
@@ -34,16 +34,13 @@ xfs_find_handle(
34 34
35extern int 35extern int
36xfs_open_by_handle( 36xfs_open_by_handle(
37 xfs_mount_t *mp,
38 xfs_fsop_handlereq_t *hreq,
39 struct file *parfilp, 37 struct file *parfilp,
40 struct inode *parinode); 38 xfs_fsop_handlereq_t *hreq);
41 39
42extern int 40extern int
43xfs_readlink_by_handle( 41xfs_readlink_by_handle(
44 xfs_mount_t *mp, 42 struct file *parfilp,
45 xfs_fsop_handlereq_t *hreq, 43 xfs_fsop_handlereq_t *hreq);
46 struct inode *parinode);
47 44
48extern int 45extern int
49xfs_attrmulti_attr_get( 46xfs_attrmulti_attr_get(
@@ -67,6 +64,12 @@ xfs_attrmulti_attr_remove(
67 char *name, 64 char *name,
68 __uint32_t flags); 65 __uint32_t flags);
69 66
67extern struct dentry *
68xfs_handle_to_dentry(
69 struct file *parfilp,
70 void __user *uhandle,
71 u32 hlen);
72
70extern long 73extern long
71xfs_file_ioctl( 74xfs_file_ioctl(
72 struct file *filp, 75 struct file *filp,
diff --git a/fs/xfs/linux-2.6/xfs_ioctl32.c b/fs/xfs/linux-2.6/xfs_ioctl32.c
index 0504cece9f66..c70c4e3db790 100644
--- a/fs/xfs/linux-2.6/xfs_ioctl32.c
+++ b/fs/xfs/linux-2.6/xfs_ioctl32.c
@@ -17,6 +17,7 @@
17 */ 17 */
18#include <linux/compat.h> 18#include <linux/compat.h>
19#include <linux/ioctl.h> 19#include <linux/ioctl.h>
20#include <linux/mount.h>
20#include <asm/uaccess.h> 21#include <asm/uaccess.h>
21#include "xfs.h" 22#include "xfs.h"
22#include "xfs_fs.h" 23#include "xfs_fs.h"
@@ -340,96 +341,24 @@ xfs_compat_handlereq_copyin(
340 return 0; 341 return 0;
341} 342}
342 343
343/* 344STATIC struct dentry *
344 * Convert userspace handle data into inode. 345xfs_compat_handlereq_to_dentry(
345 * 346 struct file *parfilp,
346 * We use the fact that all the fsop_handlereq ioctl calls have a data 347 compat_xfs_fsop_handlereq_t *hreq)
347 * structure argument whose first component is always a xfs_fsop_handlereq_t,
348 * so we can pass that sub structure into this handy, shared routine.
349 *
350 * If no error, caller must always iput the returned inode.
351 */
352STATIC int
353xfs_vget_fsop_handlereq_compat(
354 xfs_mount_t *mp,
355 struct inode *parinode, /* parent inode pointer */
356 compat_xfs_fsop_handlereq_t *hreq,
357 struct inode **inode)
358{ 348{
359 void __user *hanp; 349 return xfs_handle_to_dentry(parfilp,
360 size_t hlen; 350 compat_ptr(hreq->ihandle), hreq->ihandlen);
361 xfs_fid_t *xfid;
362 xfs_handle_t *handlep;
363 xfs_handle_t handle;
364 xfs_inode_t *ip;
365 xfs_ino_t ino;
366 __u32 igen;
367 int error;
368
369 /*
370 * Only allow handle opens under a directory.
371 */
372 if (!S_ISDIR(parinode->i_mode))
373 return XFS_ERROR(ENOTDIR);
374
375 hanp = compat_ptr(hreq->ihandle);
376 hlen = hreq->ihandlen;
377 handlep = &handle;
378
379 if (hlen < sizeof(handlep->ha_fsid) || hlen > sizeof(*handlep))
380 return XFS_ERROR(EINVAL);
381 if (copy_from_user(handlep, hanp, hlen))
382 return XFS_ERROR(EFAULT);
383 if (hlen < sizeof(*handlep))
384 memset(((char *)handlep) + hlen, 0, sizeof(*handlep) - hlen);
385 if (hlen > sizeof(handlep->ha_fsid)) {
386 if (handlep->ha_fid.fid_len !=
387 (hlen - sizeof(handlep->ha_fsid) -
388 sizeof(handlep->ha_fid.fid_len)) ||
389 handlep->ha_fid.fid_pad)
390 return XFS_ERROR(EINVAL);
391 }
392
393 /*
394 * Crack the handle, obtain the inode # & generation #
395 */
396 xfid = (struct xfs_fid *)&handlep->ha_fid;
397 if (xfid->fid_len == sizeof(*xfid) - sizeof(xfid->fid_len)) {
398 ino = xfid->fid_ino;
399 igen = xfid->fid_gen;
400 } else {
401 return XFS_ERROR(EINVAL);
402 }
403
404 /*
405 * Get the XFS inode, building a Linux inode to go with it.
406 */
407 error = xfs_iget(mp, NULL, ino, 0, XFS_ILOCK_SHARED, &ip, 0);
408 if (error)
409 return error;
410 if (ip == NULL)
411 return XFS_ERROR(EIO);
412 if (ip->i_d.di_gen != igen) {
413 xfs_iput_new(ip, XFS_ILOCK_SHARED);
414 return XFS_ERROR(ENOENT);
415 }
416
417 xfs_iunlock(ip, XFS_ILOCK_SHARED);
418
419 *inode = VFS_I(ip);
420 return 0;
421} 351}
422 352
423STATIC int 353STATIC int
424xfs_compat_attrlist_by_handle( 354xfs_compat_attrlist_by_handle(
425 xfs_mount_t *mp, 355 struct file *parfilp,
426 void __user *arg, 356 void __user *arg)
427 struct inode *parinode)
428{ 357{
429 int error; 358 int error;
430 attrlist_cursor_kern_t *cursor; 359 attrlist_cursor_kern_t *cursor;
431 compat_xfs_fsop_attrlist_handlereq_t al_hreq; 360 compat_xfs_fsop_attrlist_handlereq_t al_hreq;
432 struct inode *inode; 361 struct dentry *dentry;
433 char *kbuf; 362 char *kbuf;
434 363
435 if (!capable(CAP_SYS_ADMIN)) 364 if (!capable(CAP_SYS_ADMIN))
@@ -446,17 +375,17 @@ xfs_compat_attrlist_by_handle(
446 if (al_hreq.flags & ~(ATTR_ROOT | ATTR_SECURE)) 375 if (al_hreq.flags & ~(ATTR_ROOT | ATTR_SECURE))
447 return -XFS_ERROR(EINVAL); 376 return -XFS_ERROR(EINVAL);
448 377
449 error = xfs_vget_fsop_handlereq_compat(mp, parinode, &al_hreq.hreq, 378 dentry = xfs_compat_handlereq_to_dentry(parfilp, &al_hreq.hreq);
450 &inode); 379 if (IS_ERR(dentry))
451 if (error) 380 return PTR_ERR(dentry);
452 goto out;
453 381
382 error = -ENOMEM;
454 kbuf = kmalloc(al_hreq.buflen, GFP_KERNEL); 383 kbuf = kmalloc(al_hreq.buflen, GFP_KERNEL);
455 if (!kbuf) 384 if (!kbuf)
456 goto out_vn_rele; 385 goto out_dput;
457 386
458 cursor = (attrlist_cursor_kern_t *)&al_hreq.pos; 387 cursor = (attrlist_cursor_kern_t *)&al_hreq.pos;
459 error = xfs_attr_list(XFS_I(inode), kbuf, al_hreq.buflen, 388 error = -xfs_attr_list(XFS_I(dentry->d_inode), kbuf, al_hreq.buflen,
460 al_hreq.flags, cursor); 389 al_hreq.flags, cursor);
461 if (error) 390 if (error)
462 goto out_kfree; 391 goto out_kfree;
@@ -466,22 +395,20 @@ xfs_compat_attrlist_by_handle(
466 395
467 out_kfree: 396 out_kfree:
468 kfree(kbuf); 397 kfree(kbuf);
469 out_vn_rele: 398 out_dput:
470 iput(inode); 399 dput(dentry);
471 out: 400 return error;
472 return -error;
473} 401}
474 402
475STATIC int 403STATIC int
476xfs_compat_attrmulti_by_handle( 404xfs_compat_attrmulti_by_handle(
477 xfs_mount_t *mp, 405 struct file *parfilp,
478 void __user *arg, 406 void __user *arg)
479 struct inode *parinode)
480{ 407{
481 int error; 408 int error;
482 compat_xfs_attr_multiop_t *ops; 409 compat_xfs_attr_multiop_t *ops;
483 compat_xfs_fsop_attrmulti_handlereq_t am_hreq; 410 compat_xfs_fsop_attrmulti_handlereq_t am_hreq;
484 struct inode *inode; 411 struct dentry *dentry;
485 unsigned int i, size; 412 unsigned int i, size;
486 char *attr_name; 413 char *attr_name;
487 414
@@ -491,20 +418,19 @@ xfs_compat_attrmulti_by_handle(
491 sizeof(compat_xfs_fsop_attrmulti_handlereq_t))) 418 sizeof(compat_xfs_fsop_attrmulti_handlereq_t)))
492 return -XFS_ERROR(EFAULT); 419 return -XFS_ERROR(EFAULT);
493 420
494 error = xfs_vget_fsop_handlereq_compat(mp, parinode, &am_hreq.hreq, 421 dentry = xfs_compat_handlereq_to_dentry(parfilp, &am_hreq.hreq);
495 &inode); 422 if (IS_ERR(dentry))
496 if (error) 423 return PTR_ERR(dentry);
497 goto out;
498 424
499 error = E2BIG; 425 error = E2BIG;
500 size = am_hreq.opcount * sizeof(compat_xfs_attr_multiop_t); 426 size = am_hreq.opcount * sizeof(compat_xfs_attr_multiop_t);
501 if (!size || size > 16 * PAGE_SIZE) 427 if (!size || size > 16 * PAGE_SIZE)
502 goto out_vn_rele; 428 goto out_dput;
503 429
504 error = ENOMEM; 430 error = ENOMEM;
505 ops = kmalloc(size, GFP_KERNEL); 431 ops = kmalloc(size, GFP_KERNEL);
506 if (!ops) 432 if (!ops)
507 goto out_vn_rele; 433 goto out_dput;
508 434
509 error = EFAULT; 435 error = EFAULT;
510 if (copy_from_user(ops, compat_ptr(am_hreq.ops), size)) 436 if (copy_from_user(ops, compat_ptr(am_hreq.ops), size))
@@ -527,20 +453,29 @@ xfs_compat_attrmulti_by_handle(
527 453
528 switch (ops[i].am_opcode) { 454 switch (ops[i].am_opcode) {
529 case ATTR_OP_GET: 455 case ATTR_OP_GET:
530 ops[i].am_error = xfs_attrmulti_attr_get(inode, 456 ops[i].am_error = xfs_attrmulti_attr_get(
531 attr_name, 457 dentry->d_inode, attr_name,
532 compat_ptr(ops[i].am_attrvalue), 458 compat_ptr(ops[i].am_attrvalue),
533 &ops[i].am_length, ops[i].am_flags); 459 &ops[i].am_length, ops[i].am_flags);
534 break; 460 break;
535 case ATTR_OP_SET: 461 case ATTR_OP_SET:
536 ops[i].am_error = xfs_attrmulti_attr_set(inode, 462 ops[i].am_error = mnt_want_write(parfilp->f_path.mnt);
537 attr_name, 463 if (ops[i].am_error)
464 break;
465 ops[i].am_error = xfs_attrmulti_attr_set(
466 dentry->d_inode, attr_name,
538 compat_ptr(ops[i].am_attrvalue), 467 compat_ptr(ops[i].am_attrvalue),
539 ops[i].am_length, ops[i].am_flags); 468 ops[i].am_length, ops[i].am_flags);
469 mnt_drop_write(parfilp->f_path.mnt);
540 break; 470 break;
541 case ATTR_OP_REMOVE: 471 case ATTR_OP_REMOVE:
542 ops[i].am_error = xfs_attrmulti_attr_remove(inode, 472 ops[i].am_error = mnt_want_write(parfilp->f_path.mnt);
543 attr_name, ops[i].am_flags); 473 if (ops[i].am_error)
474 break;
475 ops[i].am_error = xfs_attrmulti_attr_remove(
476 dentry->d_inode, attr_name,
477 ops[i].am_flags);
478 mnt_drop_write(parfilp->f_path.mnt);
544 break; 479 break;
545 default: 480 default:
546 ops[i].am_error = EINVAL; 481 ops[i].am_error = EINVAL;
@@ -553,22 +488,20 @@ xfs_compat_attrmulti_by_handle(
553 kfree(attr_name); 488 kfree(attr_name);
554 out_kfree_ops: 489 out_kfree_ops:
555 kfree(ops); 490 kfree(ops);
556 out_vn_rele: 491 out_dput:
557 iput(inode); 492 dput(dentry);
558 out:
559 return -error; 493 return -error;
560} 494}
561 495
562STATIC int 496STATIC int
563xfs_compat_fssetdm_by_handle( 497xfs_compat_fssetdm_by_handle(
564 xfs_mount_t *mp, 498 struct file *parfilp,
565 void __user *arg, 499 void __user *arg)
566 struct inode *parinode)
567{ 500{
568 int error; 501 int error;
569 struct fsdmidata fsd; 502 struct fsdmidata fsd;
570 compat_xfs_fsop_setdm_handlereq_t dmhreq; 503 compat_xfs_fsop_setdm_handlereq_t dmhreq;
571 struct inode *inode; 504 struct dentry *dentry;
572 505
573 if (!capable(CAP_MKNOD)) 506 if (!capable(CAP_MKNOD))
574 return -XFS_ERROR(EPERM); 507 return -XFS_ERROR(EPERM);
@@ -576,12 +509,11 @@ xfs_compat_fssetdm_by_handle(
576 sizeof(compat_xfs_fsop_setdm_handlereq_t))) 509 sizeof(compat_xfs_fsop_setdm_handlereq_t)))
577 return -XFS_ERROR(EFAULT); 510 return -XFS_ERROR(EFAULT);
578 511
579 error = xfs_vget_fsop_handlereq_compat(mp, parinode, &dmhreq.hreq, 512 dentry = xfs_compat_handlereq_to_dentry(parfilp, &dmhreq.hreq);
580 &inode); 513 if (IS_ERR(dentry))
581 if (error) 514 return PTR_ERR(dentry);
582 return -error;
583 515
584 if (IS_IMMUTABLE(inode) || IS_APPEND(inode)) { 516 if (IS_IMMUTABLE(dentry->d_inode) || IS_APPEND(dentry->d_inode)) {
585 error = -XFS_ERROR(EPERM); 517 error = -XFS_ERROR(EPERM);
586 goto out; 518 goto out;
587 } 519 }
@@ -591,11 +523,11 @@ xfs_compat_fssetdm_by_handle(
591 goto out; 523 goto out;
592 } 524 }
593 525
594 error = -xfs_set_dmattrs(XFS_I(inode), fsd.fsd_dmevmask, 526 error = -xfs_set_dmattrs(XFS_I(dentry->d_inode), fsd.fsd_dmevmask,
595 fsd.fsd_dmstate); 527 fsd.fsd_dmstate);
596 528
597out: 529out:
598 iput(inode); 530 dput(dentry);
599 return error; 531 return error;
600} 532}
601 533
@@ -632,8 +564,6 @@ xfs_file_compat_ioctl(
632 case XFS_IOC_SET_RESBLKS: 564 case XFS_IOC_SET_RESBLKS:
633 case XFS_IOC_GET_RESBLKS: 565 case XFS_IOC_GET_RESBLKS:
634 case XFS_IOC_FSGROWFSLOG: 566 case XFS_IOC_FSGROWFSLOG:
635 case XFS_IOC_FREEZE:
636 case XFS_IOC_THAW:
637 case XFS_IOC_GOINGDOWN: 567 case XFS_IOC_GOINGDOWN:
638 case XFS_IOC_ERROR_INJECTION: 568 case XFS_IOC_ERROR_INJECTION:
639 case XFS_IOC_ERROR_CLEARALL: 569 case XFS_IOC_ERROR_CLEARALL:
@@ -724,21 +654,21 @@ xfs_file_compat_ioctl(
724 654
725 if (xfs_compat_handlereq_copyin(&hreq, arg)) 655 if (xfs_compat_handlereq_copyin(&hreq, arg))
726 return -XFS_ERROR(EFAULT); 656 return -XFS_ERROR(EFAULT);
727 return xfs_open_by_handle(mp, &hreq, filp, inode); 657 return xfs_open_by_handle(filp, &hreq);
728 } 658 }
729 case XFS_IOC_READLINK_BY_HANDLE_32: { 659 case XFS_IOC_READLINK_BY_HANDLE_32: {
730 struct xfs_fsop_handlereq hreq; 660 struct xfs_fsop_handlereq hreq;
731 661
732 if (xfs_compat_handlereq_copyin(&hreq, arg)) 662 if (xfs_compat_handlereq_copyin(&hreq, arg))
733 return -XFS_ERROR(EFAULT); 663 return -XFS_ERROR(EFAULT);
734 return xfs_readlink_by_handle(mp, &hreq, inode); 664 return xfs_readlink_by_handle(filp, &hreq);
735 } 665 }
736 case XFS_IOC_ATTRLIST_BY_HANDLE_32: 666 case XFS_IOC_ATTRLIST_BY_HANDLE_32:
737 return xfs_compat_attrlist_by_handle(mp, arg, inode); 667 return xfs_compat_attrlist_by_handle(filp, arg);
738 case XFS_IOC_ATTRMULTI_BY_HANDLE_32: 668 case XFS_IOC_ATTRMULTI_BY_HANDLE_32:
739 return xfs_compat_attrmulti_by_handle(mp, arg, inode); 669 return xfs_compat_attrmulti_by_handle(filp, arg);
740 case XFS_IOC_FSSETDM_BY_HANDLE_32: 670 case XFS_IOC_FSSETDM_BY_HANDLE_32:
741 return xfs_compat_fssetdm_by_handle(mp, arg, inode); 671 return xfs_compat_fssetdm_by_handle(filp, arg);
742 default: 672 default:
743 return -XFS_ERROR(ENOIOCTLCMD); 673 return -XFS_ERROR(ENOIOCTLCMD);
744 } 674 }
diff --git a/fs/xfs/linux-2.6/xfs_super.c b/fs/xfs/linux-2.6/xfs_super.c
index 36f6cc703ef2..c71e226da7f5 100644
--- a/fs/xfs/linux-2.6/xfs_super.c
+++ b/fs/xfs/linux-2.6/xfs_super.c
@@ -1197,6 +1197,7 @@ xfs_fs_remount(
1197 struct xfs_mount *mp = XFS_M(sb); 1197 struct xfs_mount *mp = XFS_M(sb);
1198 substring_t args[MAX_OPT_ARGS]; 1198 substring_t args[MAX_OPT_ARGS];
1199 char *p; 1199 char *p;
1200 int error;
1200 1201
1201 while ((p = strsep(&options, ",")) != NULL) { 1202 while ((p = strsep(&options, ",")) != NULL) {
1202 int token; 1203 int token;
@@ -1247,11 +1248,25 @@ xfs_fs_remount(
1247 } 1248 }
1248 } 1249 }
1249 1250
1250 /* rw/ro -> rw */ 1251 /* ro -> rw */
1251 if ((mp->m_flags & XFS_MOUNT_RDONLY) && !(*flags & MS_RDONLY)) { 1252 if ((mp->m_flags & XFS_MOUNT_RDONLY) && !(*flags & MS_RDONLY)) {
1252 mp->m_flags &= ~XFS_MOUNT_RDONLY; 1253 mp->m_flags &= ~XFS_MOUNT_RDONLY;
1253 if (mp->m_flags & XFS_MOUNT_BARRIER) 1254 if (mp->m_flags & XFS_MOUNT_BARRIER)
1254 xfs_mountfs_check_barriers(mp); 1255 xfs_mountfs_check_barriers(mp);
1256
1257 /*
1258 * If this is the first remount to writeable state we
1259 * might have some superblock changes to update.
1260 */
1261 if (mp->m_update_flags) {
1262 error = xfs_mount_log_sb(mp, mp->m_update_flags);
1263 if (error) {
1264 cmn_err(CE_WARN,
1265 "XFS: failed to write sb changes");
1266 return error;
1267 }
1268 mp->m_update_flags = 0;
1269 }
1255 } 1270 }
1256 1271
1257 /* rw -> ro */ 1272 /* rw -> ro */
@@ -1269,14 +1284,14 @@ xfs_fs_remount(
1269 * need to take care of the metadata. Once that's done write a dummy 1284 * need to take care of the metadata. Once that's done write a dummy
1270 * record to dirty the log in case of a crash while frozen. 1285 * record to dirty the log in case of a crash while frozen.
1271 */ 1286 */
1272STATIC void 1287STATIC int
1273xfs_fs_lockfs( 1288xfs_fs_freeze(
1274 struct super_block *sb) 1289 struct super_block *sb)
1275{ 1290{
1276 struct xfs_mount *mp = XFS_M(sb); 1291 struct xfs_mount *mp = XFS_M(sb);
1277 1292
1278 xfs_quiesce_attr(mp); 1293 xfs_quiesce_attr(mp);
1279 xfs_fs_log_dummy(mp); 1294 return -xfs_fs_log_dummy(mp);
1280} 1295}
1281 1296
1282STATIC int 1297STATIC int
@@ -1348,7 +1363,7 @@ xfs_finish_flags(
1348{ 1363{
1349 int ronly = (mp->m_flags & XFS_MOUNT_RDONLY); 1364 int ronly = (mp->m_flags & XFS_MOUNT_RDONLY);
1350 1365
1351 /* Fail a mount where the logbuf is smaller then the log stripe */ 1366 /* Fail a mount where the logbuf is smaller than the log stripe */
1352 if (xfs_sb_version_haslogv2(&mp->m_sb)) { 1367 if (xfs_sb_version_haslogv2(&mp->m_sb)) {
1353 if (mp->m_logbsize <= 0 && 1368 if (mp->m_logbsize <= 0 &&
1354 mp->m_sb.sb_logsunit > XLOG_BIG_RECORD_BSIZE) { 1369 mp->m_sb.sb_logsunit > XLOG_BIG_RECORD_BSIZE) {
@@ -1557,7 +1572,7 @@ static struct super_operations xfs_super_operations = {
1557 .put_super = xfs_fs_put_super, 1572 .put_super = xfs_fs_put_super,
1558 .write_super = xfs_fs_write_super, 1573 .write_super = xfs_fs_write_super,
1559 .sync_fs = xfs_fs_sync_super, 1574 .sync_fs = xfs_fs_sync_super,
1560 .write_super_lockfs = xfs_fs_lockfs, 1575 .freeze_fs = xfs_fs_freeze,
1561 .statfs = xfs_fs_statfs, 1576 .statfs = xfs_fs_statfs,
1562 .remount_fs = xfs_fs_remount, 1577 .remount_fs = xfs_fs_remount,
1563 .show_options = xfs_fs_show_options, 1578 .show_options = xfs_fs_show_options,
diff --git a/fs/xfs/linux-2.6/xfs_sync.c b/fs/xfs/linux-2.6/xfs_sync.c
index 2ed035354c26..a608e72fa405 100644
--- a/fs/xfs/linux-2.6/xfs_sync.c
+++ b/fs/xfs/linux-2.6/xfs_sync.c
@@ -371,7 +371,11 @@ xfs_quiesce_attr(
371 /* flush inodes and push all remaining buffers out to disk */ 371 /* flush inodes and push all remaining buffers out to disk */
372 xfs_quiesce_fs(mp); 372 xfs_quiesce_fs(mp);
373 373
374 ASSERT_ALWAYS(atomic_read(&mp->m_active_trans) == 0); 374 /*
375 * Just warn here till VFS can correctly support
376 * read-only remount without racing.
377 */
378 WARN_ON(atomic_read(&mp->m_active_trans) != 0);
375 379
376 /* Push the superblock and write an unmount record */ 380 /* Push the superblock and write an unmount record */
377 error = xfs_log_sbcount(mp, 1); 381 error = xfs_log_sbcount(mp, 1);
diff --git a/fs/xfs/quota/xfs_dquot.c b/fs/xfs/quota/xfs_dquot.c
index 591ca6602bfb..6543c0b29753 100644
--- a/fs/xfs/quota/xfs_dquot.c
+++ b/fs/xfs/quota/xfs_dquot.c
@@ -73,6 +73,8 @@ int xfs_dqreq_num;
73int xfs_dqerror_mod = 33; 73int xfs_dqerror_mod = 33;
74#endif 74#endif
75 75
76static struct lock_class_key xfs_dquot_other_class;
77
76/* 78/*
77 * Allocate and initialize a dquot. We don't always allocate fresh memory; 79 * Allocate and initialize a dquot. We don't always allocate fresh memory;
78 * we try to reclaim a free dquot if the number of incore dquots are above 80 * we try to reclaim a free dquot if the number of incore dquots are above
@@ -139,7 +141,15 @@ xfs_qm_dqinit(
139 ASSERT(dqp->q_trace); 141 ASSERT(dqp->q_trace);
140 xfs_dqtrace_entry(dqp, "DQRECLAIMED_INIT"); 142 xfs_dqtrace_entry(dqp, "DQRECLAIMED_INIT");
141#endif 143#endif
142 } 144 }
145
146 /*
147 * In either case we need to make sure group quotas have a different
148 * lock class than user quotas, to make sure lockdep knows we can
149 * locks of one of each at the same time.
150 */
151 if (!(type & XFS_DQ_USER))
152 lockdep_set_class(&dqp->q_qlock, &xfs_dquot_other_class);
143 153
144 /* 154 /*
145 * log item gets initialized later 155 * log item gets initialized later
@@ -421,7 +431,7 @@ xfs_qm_dqalloc(
421 /* 431 /*
422 * Initialize the bmap freelist prior to calling bmapi code. 432 * Initialize the bmap freelist prior to calling bmapi code.
423 */ 433 */
424 XFS_BMAP_INIT(&flist, &firstblock); 434 xfs_bmap_init(&flist, &firstblock);
425 xfs_ilock(quotip, XFS_ILOCK_EXCL); 435 xfs_ilock(quotip, XFS_ILOCK_EXCL);
426 /* 436 /*
427 * Return if this type of quotas is turned off while we didn't 437 * Return if this type of quotas is turned off while we didn't
@@ -1383,6 +1393,12 @@ xfs_dqunlock_nonotify(
1383 mutex_unlock(&(dqp->q_qlock)); 1393 mutex_unlock(&(dqp->q_qlock));
1384} 1394}
1385 1395
1396/*
1397 * Lock two xfs_dquot structures.
1398 *
1399 * To avoid deadlocks we always lock the quota structure with
1400 * the lowerd id first.
1401 */
1386void 1402void
1387xfs_dqlock2( 1403xfs_dqlock2(
1388 xfs_dquot_t *d1, 1404 xfs_dquot_t *d1,
@@ -1392,18 +1408,16 @@ xfs_dqlock2(
1392 ASSERT(d1 != d2); 1408 ASSERT(d1 != d2);
1393 if (be32_to_cpu(d1->q_core.d_id) > 1409 if (be32_to_cpu(d1->q_core.d_id) >
1394 be32_to_cpu(d2->q_core.d_id)) { 1410 be32_to_cpu(d2->q_core.d_id)) {
1395 xfs_dqlock(d2); 1411 mutex_lock(&d2->q_qlock);
1396 xfs_dqlock(d1); 1412 mutex_lock_nested(&d1->q_qlock, XFS_QLOCK_NESTED);
1397 } else { 1413 } else {
1398 xfs_dqlock(d1); 1414 mutex_lock(&d1->q_qlock);
1399 xfs_dqlock(d2); 1415 mutex_lock_nested(&d2->q_qlock, XFS_QLOCK_NESTED);
1400 }
1401 } else {
1402 if (d1) {
1403 xfs_dqlock(d1);
1404 } else if (d2) {
1405 xfs_dqlock(d2);
1406 } 1416 }
1417 } else if (d1) {
1418 mutex_lock(&d1->q_qlock);
1419 } else if (d2) {
1420 mutex_lock(&d2->q_qlock);
1407 } 1421 }
1408} 1422}
1409 1423
diff --git a/fs/xfs/quota/xfs_dquot.h b/fs/xfs/quota/xfs_dquot.h
index 7e455337e2ba..d443e93b4331 100644
--- a/fs/xfs/quota/xfs_dquot.h
+++ b/fs/xfs/quota/xfs_dquot.h
@@ -97,6 +97,16 @@ typedef struct xfs_dquot {
97#define dq_hashlist q_lists.dqm_hashlist 97#define dq_hashlist q_lists.dqm_hashlist
98#define dq_flags q_lists.dqm_flags 98#define dq_flags q_lists.dqm_flags
99 99
100/*
101 * Lock hierachy for q_qlock:
102 * XFS_QLOCK_NORMAL is the implicit default,
103 * XFS_QLOCK_NESTED is the dquot with the higher id in xfs_dqlock2
104 */
105enum {
106 XFS_QLOCK_NORMAL = 0,
107 XFS_QLOCK_NESTED,
108};
109
100#define XFS_DQHOLD(dqp) ((dqp)->q_nrefs++) 110#define XFS_DQHOLD(dqp) ((dqp)->q_nrefs++)
101 111
102#ifdef DEBUG 112#ifdef DEBUG
diff --git a/fs/xfs/quota/xfs_qm.c b/fs/xfs/quota/xfs_qm.c
index 6b13960cf318..7a2beb64314f 100644
--- a/fs/xfs/quota/xfs_qm.c
+++ b/fs/xfs/quota/xfs_qm.c
@@ -1070,6 +1070,13 @@ xfs_qm_sync(
1070 return 0; 1070 return 0;
1071} 1071}
1072 1072
1073/*
1074 * The hash chains and the mplist use the same xfs_dqhash structure as
1075 * their list head, but we can take the mplist qh_lock and one of the
1076 * hash qh_locks at the same time without any problem as they aren't
1077 * related.
1078 */
1079static struct lock_class_key xfs_quota_mplist_class;
1073 1080
1074/* 1081/*
1075 * This initializes all the quota information that's kept in the 1082 * This initializes all the quota information that's kept in the
@@ -1105,6 +1112,8 @@ xfs_qm_init_quotainfo(
1105 } 1112 }
1106 1113
1107 xfs_qm_list_init(&qinf->qi_dqlist, "mpdqlist", 0); 1114 xfs_qm_list_init(&qinf->qi_dqlist, "mpdqlist", 0);
1115 lockdep_set_class(&qinf->qi_dqlist.qh_lock, &xfs_quota_mplist_class);
1116
1108 qinf->qi_dqreclaims = 0; 1117 qinf->qi_dqreclaims = 0;
1109 1118
1110 /* mutex used to serialize quotaoffs */ 1119 /* mutex used to serialize quotaoffs */
diff --git a/fs/xfs/xfs_acl.h b/fs/xfs/xfs_acl.h
index a4e293b93efa..642f1db4def4 100644
--- a/fs/xfs/xfs_acl.h
+++ b/fs/xfs/xfs_acl.h
@@ -22,7 +22,6 @@
22 * Access Control Lists 22 * Access Control Lists
23 */ 23 */
24typedef __uint16_t xfs_acl_perm_t; 24typedef __uint16_t xfs_acl_perm_t;
25typedef __int32_t xfs_acl_type_t;
26typedef __int32_t xfs_acl_tag_t; 25typedef __int32_t xfs_acl_tag_t;
27typedef __int32_t xfs_acl_id_t; 26typedef __int32_t xfs_acl_id_t;
28 27
diff --git a/fs/xfs/xfs_ag.h b/fs/xfs/xfs_ag.h
index f2e21817a226..143d63ecb20a 100644
--- a/fs/xfs/xfs_ag.h
+++ b/fs/xfs/xfs_ag.h
@@ -231,7 +231,7 @@ typedef struct xfs_perag
231#define XFS_FSB_TO_AGNO(mp,fsbno) \ 231#define XFS_FSB_TO_AGNO(mp,fsbno) \
232 ((xfs_agnumber_t)((fsbno) >> (mp)->m_sb.sb_agblklog)) 232 ((xfs_agnumber_t)((fsbno) >> (mp)->m_sb.sb_agblklog))
233#define XFS_FSB_TO_AGBNO(mp,fsbno) \ 233#define XFS_FSB_TO_AGBNO(mp,fsbno) \
234 ((xfs_agblock_t)((fsbno) & XFS_MASK32LO((mp)->m_sb.sb_agblklog))) 234 ((xfs_agblock_t)((fsbno) & xfs_mask32lo((mp)->m_sb.sb_agblklog)))
235#define XFS_AGB_TO_DADDR(mp,agno,agbno) \ 235#define XFS_AGB_TO_DADDR(mp,agno,agbno) \
236 ((xfs_daddr_t)XFS_FSB_TO_BB(mp, \ 236 ((xfs_daddr_t)XFS_FSB_TO_BB(mp, \
237 (xfs_fsblock_t)(agno) * (mp)->m_sb.sb_agblocks + (agbno))) 237 (xfs_fsblock_t)(agno) * (mp)->m_sb.sb_agblocks + (agbno)))
@@ -244,8 +244,8 @@ typedef struct xfs_perag
244#define XFS_AG_CHECK_DADDR(mp,d,len) \ 244#define XFS_AG_CHECK_DADDR(mp,d,len) \
245 ((len) == 1 ? \ 245 ((len) == 1 ? \
246 ASSERT((d) == XFS_SB_DADDR || \ 246 ASSERT((d) == XFS_SB_DADDR || \
247 XFS_DADDR_TO_AGBNO(mp, d) != XFS_SB_DADDR) : \ 247 xfs_daddr_to_agbno(mp, d) != XFS_SB_DADDR) : \
248 ASSERT(XFS_DADDR_TO_AGNO(mp, d) == \ 248 ASSERT(xfs_daddr_to_agno(mp, d) == \
249 XFS_DADDR_TO_AGNO(mp, (d) + (len) - 1))) 249 xfs_daddr_to_agno(mp, (d) + (len) - 1)))
250 250
251#endif /* __XFS_AG_H__ */ 251#endif /* __XFS_AG_H__ */
diff --git a/fs/xfs/xfs_alloc_btree.c b/fs/xfs/xfs_alloc_btree.c
index 733cb75a8c5d..c10c3a292d30 100644
--- a/fs/xfs/xfs_alloc_btree.c
+++ b/fs/xfs/xfs_alloc_btree.c
@@ -115,7 +115,7 @@ xfs_allocbt_free_block(
115 xfs_agblock_t bno; 115 xfs_agblock_t bno;
116 int error; 116 int error;
117 117
118 bno = XFS_DADDR_TO_AGBNO(cur->bc_mp, XFS_BUF_ADDR(bp)); 118 bno = xfs_daddr_to_agbno(cur->bc_mp, XFS_BUF_ADDR(bp));
119 error = xfs_alloc_put_freelist(cur->bc_tp, agbp, NULL, bno, 1); 119 error = xfs_alloc_put_freelist(cur->bc_tp, agbp, NULL, bno, 1);
120 if (error) 120 if (error)
121 return error; 121 return error;
diff --git a/fs/xfs/xfs_attr.c b/fs/xfs/xfs_attr.c
index f7cdc28aff41..5fde1654b430 100644
--- a/fs/xfs/xfs_attr.c
+++ b/fs/xfs/xfs_attr.c
@@ -374,7 +374,7 @@ xfs_attr_set_int(xfs_inode_t *dp, struct xfs_name *name,
374 * It won't fit in the shortform, transform to a leaf block. 374 * It won't fit in the shortform, transform to a leaf block.
375 * GROT: another possible req'mt for a double-split btree op. 375 * GROT: another possible req'mt for a double-split btree op.
376 */ 376 */
377 XFS_BMAP_INIT(args.flist, args.firstblock); 377 xfs_bmap_init(args.flist, args.firstblock);
378 error = xfs_attr_shortform_to_leaf(&args); 378 error = xfs_attr_shortform_to_leaf(&args);
379 if (!error) { 379 if (!error) {
380 error = xfs_bmap_finish(&args.trans, args.flist, 380 error = xfs_bmap_finish(&args.trans, args.flist,
@@ -956,7 +956,7 @@ xfs_attr_leaf_addname(xfs_da_args_t *args)
956 * Commit that transaction so that the node_addname() call 956 * Commit that transaction so that the node_addname() call
957 * can manage its own transactions. 957 * can manage its own transactions.
958 */ 958 */
959 XFS_BMAP_INIT(args->flist, args->firstblock); 959 xfs_bmap_init(args->flist, args->firstblock);
960 error = xfs_attr_leaf_to_node(args); 960 error = xfs_attr_leaf_to_node(args);
961 if (!error) { 961 if (!error) {
962 error = xfs_bmap_finish(&args->trans, args->flist, 962 error = xfs_bmap_finish(&args->trans, args->flist,
@@ -1057,7 +1057,7 @@ xfs_attr_leaf_addname(xfs_da_args_t *args)
1057 * If the result is small enough, shrink it all into the inode. 1057 * If the result is small enough, shrink it all into the inode.
1058 */ 1058 */
1059 if ((forkoff = xfs_attr_shortform_allfit(bp, dp))) { 1059 if ((forkoff = xfs_attr_shortform_allfit(bp, dp))) {
1060 XFS_BMAP_INIT(args->flist, args->firstblock); 1060 xfs_bmap_init(args->flist, args->firstblock);
1061 error = xfs_attr_leaf_to_shortform(bp, args, forkoff); 1061 error = xfs_attr_leaf_to_shortform(bp, args, forkoff);
1062 /* bp is gone due to xfs_da_shrink_inode */ 1062 /* bp is gone due to xfs_da_shrink_inode */
1063 if (!error) { 1063 if (!error) {
@@ -1135,7 +1135,7 @@ xfs_attr_leaf_removename(xfs_da_args_t *args)
1135 * If the result is small enough, shrink it all into the inode. 1135 * If the result is small enough, shrink it all into the inode.
1136 */ 1136 */
1137 if ((forkoff = xfs_attr_shortform_allfit(bp, dp))) { 1137 if ((forkoff = xfs_attr_shortform_allfit(bp, dp))) {
1138 XFS_BMAP_INIT(args->flist, args->firstblock); 1138 xfs_bmap_init(args->flist, args->firstblock);
1139 error = xfs_attr_leaf_to_shortform(bp, args, forkoff); 1139 error = xfs_attr_leaf_to_shortform(bp, args, forkoff);
1140 /* bp is gone due to xfs_da_shrink_inode */ 1140 /* bp is gone due to xfs_da_shrink_inode */
1141 if (!error) { 1141 if (!error) {
@@ -1290,7 +1290,7 @@ restart:
1290 * have been a b-tree. 1290 * have been a b-tree.
1291 */ 1291 */
1292 xfs_da_state_free(state); 1292 xfs_da_state_free(state);
1293 XFS_BMAP_INIT(args->flist, args->firstblock); 1293 xfs_bmap_init(args->flist, args->firstblock);
1294 error = xfs_attr_leaf_to_node(args); 1294 error = xfs_attr_leaf_to_node(args);
1295 if (!error) { 1295 if (!error) {
1296 error = xfs_bmap_finish(&args->trans, 1296 error = xfs_bmap_finish(&args->trans,
@@ -1331,7 +1331,7 @@ restart:
1331 * in the index/blkno/rmtblkno/rmtblkcnt fields and 1331 * in the index/blkno/rmtblkno/rmtblkcnt fields and
1332 * in the index2/blkno2/rmtblkno2/rmtblkcnt2 fields. 1332 * in the index2/blkno2/rmtblkno2/rmtblkcnt2 fields.
1333 */ 1333 */
1334 XFS_BMAP_INIT(args->flist, args->firstblock); 1334 xfs_bmap_init(args->flist, args->firstblock);
1335 error = xfs_da_split(state); 1335 error = xfs_da_split(state);
1336 if (!error) { 1336 if (!error) {
1337 error = xfs_bmap_finish(&args->trans, args->flist, 1337 error = xfs_bmap_finish(&args->trans, args->flist,
@@ -1443,7 +1443,7 @@ restart:
1443 * Check to see if the tree needs to be collapsed. 1443 * Check to see if the tree needs to be collapsed.
1444 */ 1444 */
1445 if (retval && (state->path.active > 1)) { 1445 if (retval && (state->path.active > 1)) {
1446 XFS_BMAP_INIT(args->flist, args->firstblock); 1446 xfs_bmap_init(args->flist, args->firstblock);
1447 error = xfs_da_join(state); 1447 error = xfs_da_join(state);
1448 if (!error) { 1448 if (!error) {
1449 error = xfs_bmap_finish(&args->trans, 1449 error = xfs_bmap_finish(&args->trans,
@@ -1579,7 +1579,7 @@ xfs_attr_node_removename(xfs_da_args_t *args)
1579 * Check to see if the tree needs to be collapsed. 1579 * Check to see if the tree needs to be collapsed.
1580 */ 1580 */
1581 if (retval && (state->path.active > 1)) { 1581 if (retval && (state->path.active > 1)) {
1582 XFS_BMAP_INIT(args->flist, args->firstblock); 1582 xfs_bmap_init(args->flist, args->firstblock);
1583 error = xfs_da_join(state); 1583 error = xfs_da_join(state);
1584 if (!error) { 1584 if (!error) {
1585 error = xfs_bmap_finish(&args->trans, args->flist, 1585 error = xfs_bmap_finish(&args->trans, args->flist,
@@ -1630,7 +1630,7 @@ xfs_attr_node_removename(xfs_da_args_t *args)
1630 == XFS_ATTR_LEAF_MAGIC); 1630 == XFS_ATTR_LEAF_MAGIC);
1631 1631
1632 if ((forkoff = xfs_attr_shortform_allfit(bp, dp))) { 1632 if ((forkoff = xfs_attr_shortform_allfit(bp, dp))) {
1633 XFS_BMAP_INIT(args->flist, args->firstblock); 1633 xfs_bmap_init(args->flist, args->firstblock);
1634 error = xfs_attr_leaf_to_shortform(bp, args, forkoff); 1634 error = xfs_attr_leaf_to_shortform(bp, args, forkoff);
1635 /* bp is gone due to xfs_da_shrink_inode */ 1635 /* bp is gone due to xfs_da_shrink_inode */
1636 if (!error) { 1636 if (!error) {
@@ -2069,7 +2069,7 @@ xfs_attr_rmtval_set(xfs_da_args_t *args)
2069 /* 2069 /*
2070 * Allocate a single extent, up to the size of the value. 2070 * Allocate a single extent, up to the size of the value.
2071 */ 2071 */
2072 XFS_BMAP_INIT(args->flist, args->firstblock); 2072 xfs_bmap_init(args->flist, args->firstblock);
2073 nmap = 1; 2073 nmap = 1;
2074 error = xfs_bmapi(args->trans, dp, (xfs_fileoff_t)lblkno, 2074 error = xfs_bmapi(args->trans, dp, (xfs_fileoff_t)lblkno,
2075 blkcnt, 2075 blkcnt,
@@ -2123,7 +2123,7 @@ xfs_attr_rmtval_set(xfs_da_args_t *args)
2123 /* 2123 /*
2124 * Try to remember where we decided to put the value. 2124 * Try to remember where we decided to put the value.
2125 */ 2125 */
2126 XFS_BMAP_INIT(args->flist, args->firstblock); 2126 xfs_bmap_init(args->flist, args->firstblock);
2127 nmap = 1; 2127 nmap = 1;
2128 error = xfs_bmapi(NULL, dp, (xfs_fileoff_t)lblkno, 2128 error = xfs_bmapi(NULL, dp, (xfs_fileoff_t)lblkno,
2129 args->rmtblkcnt, 2129 args->rmtblkcnt,
@@ -2188,7 +2188,7 @@ xfs_attr_rmtval_remove(xfs_da_args_t *args)
2188 /* 2188 /*
2189 * Try to remember where we decided to put the value. 2189 * Try to remember where we decided to put the value.
2190 */ 2190 */
2191 XFS_BMAP_INIT(args->flist, args->firstblock); 2191 xfs_bmap_init(args->flist, args->firstblock);
2192 nmap = 1; 2192 nmap = 1;
2193 error = xfs_bmapi(NULL, args->dp, (xfs_fileoff_t)lblkno, 2193 error = xfs_bmapi(NULL, args->dp, (xfs_fileoff_t)lblkno,
2194 args->rmtblkcnt, 2194 args->rmtblkcnt,
@@ -2229,7 +2229,7 @@ xfs_attr_rmtval_remove(xfs_da_args_t *args)
2229 blkcnt = args->rmtblkcnt; 2229 blkcnt = args->rmtblkcnt;
2230 done = 0; 2230 done = 0;
2231 while (!done) { 2231 while (!done) {
2232 XFS_BMAP_INIT(args->flist, args->firstblock); 2232 xfs_bmap_init(args->flist, args->firstblock);
2233 error = xfs_bunmapi(args->trans, args->dp, lblkno, blkcnt, 2233 error = xfs_bunmapi(args->trans, args->dp, lblkno, blkcnt,
2234 XFS_BMAPI_ATTRFORK | XFS_BMAPI_METADATA, 2234 XFS_BMAPI_ATTRFORK | XFS_BMAPI_METADATA,
2235 1, args->firstblock, args->flist, 2235 1, args->firstblock, args->flist,
diff --git a/fs/xfs/xfs_attr_leaf.c b/fs/xfs/xfs_attr_leaf.c
index 79da6b2ea99e..6c323f8a4cd1 100644
--- a/fs/xfs/xfs_attr_leaf.c
+++ b/fs/xfs/xfs_attr_leaf.c
@@ -736,7 +736,7 @@ xfs_attr_shortform_allfit(xfs_dabuf_t *bp, xfs_inode_t *dp)
736 continue; /* don't copy partial entries */ 736 continue; /* don't copy partial entries */
737 if (!(entry->flags & XFS_ATTR_LOCAL)) 737 if (!(entry->flags & XFS_ATTR_LOCAL))
738 return(0); 738 return(0);
739 name_loc = XFS_ATTR_LEAF_NAME_LOCAL(leaf, i); 739 name_loc = xfs_attr_leaf_name_local(leaf, i);
740 if (name_loc->namelen >= XFS_ATTR_SF_ENTSIZE_MAX) 740 if (name_loc->namelen >= XFS_ATTR_SF_ENTSIZE_MAX)
741 return(0); 741 return(0);
742 if (be16_to_cpu(name_loc->valuelen) >= XFS_ATTR_SF_ENTSIZE_MAX) 742 if (be16_to_cpu(name_loc->valuelen) >= XFS_ATTR_SF_ENTSIZE_MAX)
@@ -823,7 +823,7 @@ xfs_attr_leaf_to_shortform(xfs_dabuf_t *bp, xfs_da_args_t *args, int forkoff)
823 if (!entry->nameidx) 823 if (!entry->nameidx)
824 continue; 824 continue;
825 ASSERT(entry->flags & XFS_ATTR_LOCAL); 825 ASSERT(entry->flags & XFS_ATTR_LOCAL);
826 name_loc = XFS_ATTR_LEAF_NAME_LOCAL(leaf, i); 826 name_loc = xfs_attr_leaf_name_local(leaf, i);
827 nargs.name = (char *)name_loc->nameval; 827 nargs.name = (char *)name_loc->nameval;
828 nargs.namelen = name_loc->namelen; 828 nargs.namelen = name_loc->namelen;
829 nargs.value = (char *)&name_loc->nameval[nargs.namelen]; 829 nargs.value = (char *)&name_loc->nameval[nargs.namelen];
@@ -1141,14 +1141,14 @@ xfs_attr_leaf_add_work(xfs_dabuf_t *bp, xfs_da_args_t *args, int mapindex)
1141 * as part of this transaction (a split operation for example). 1141 * as part of this transaction (a split operation for example).
1142 */ 1142 */
1143 if (entry->flags & XFS_ATTR_LOCAL) { 1143 if (entry->flags & XFS_ATTR_LOCAL) {
1144 name_loc = XFS_ATTR_LEAF_NAME_LOCAL(leaf, args->index); 1144 name_loc = xfs_attr_leaf_name_local(leaf, args->index);
1145 name_loc->namelen = args->namelen; 1145 name_loc->namelen = args->namelen;
1146 name_loc->valuelen = cpu_to_be16(args->valuelen); 1146 name_loc->valuelen = cpu_to_be16(args->valuelen);
1147 memcpy((char *)name_loc->nameval, args->name, args->namelen); 1147 memcpy((char *)name_loc->nameval, args->name, args->namelen);
1148 memcpy((char *)&name_loc->nameval[args->namelen], args->value, 1148 memcpy((char *)&name_loc->nameval[args->namelen], args->value,
1149 be16_to_cpu(name_loc->valuelen)); 1149 be16_to_cpu(name_loc->valuelen));
1150 } else { 1150 } else {
1151 name_rmt = XFS_ATTR_LEAF_NAME_REMOTE(leaf, args->index); 1151 name_rmt = xfs_attr_leaf_name_remote(leaf, args->index);
1152 name_rmt->namelen = args->namelen; 1152 name_rmt->namelen = args->namelen;
1153 memcpy((char *)name_rmt->name, args->name, args->namelen); 1153 memcpy((char *)name_rmt->name, args->name, args->namelen);
1154 entry->flags |= XFS_ATTR_INCOMPLETE; 1154 entry->flags |= XFS_ATTR_INCOMPLETE;
@@ -1159,7 +1159,7 @@ xfs_attr_leaf_add_work(xfs_dabuf_t *bp, xfs_da_args_t *args, int mapindex)
1159 args->rmtblkcnt = XFS_B_TO_FSB(mp, args->valuelen); 1159 args->rmtblkcnt = XFS_B_TO_FSB(mp, args->valuelen);
1160 } 1160 }
1161 xfs_da_log_buf(args->trans, bp, 1161 xfs_da_log_buf(args->trans, bp,
1162 XFS_DA_LOGRANGE(leaf, XFS_ATTR_LEAF_NAME(leaf, args->index), 1162 XFS_DA_LOGRANGE(leaf, xfs_attr_leaf_name(leaf, args->index),
1163 xfs_attr_leaf_entsize(leaf, args->index))); 1163 xfs_attr_leaf_entsize(leaf, args->index)));
1164 1164
1165 /* 1165 /*
@@ -1749,10 +1749,10 @@ xfs_attr_leaf_remove(xfs_dabuf_t *bp, xfs_da_args_t *args)
1749 /* 1749 /*
1750 * Compress the remaining entries and zero out the removed stuff. 1750 * Compress the remaining entries and zero out the removed stuff.
1751 */ 1751 */
1752 memset(XFS_ATTR_LEAF_NAME(leaf, args->index), 0, entsize); 1752 memset(xfs_attr_leaf_name(leaf, args->index), 0, entsize);
1753 be16_add_cpu(&hdr->usedbytes, -entsize); 1753 be16_add_cpu(&hdr->usedbytes, -entsize);
1754 xfs_da_log_buf(args->trans, bp, 1754 xfs_da_log_buf(args->trans, bp,
1755 XFS_DA_LOGRANGE(leaf, XFS_ATTR_LEAF_NAME(leaf, args->index), 1755 XFS_DA_LOGRANGE(leaf, xfs_attr_leaf_name(leaf, args->index),
1756 entsize)); 1756 entsize));
1757 1757
1758 tmp = (be16_to_cpu(hdr->count) - args->index) 1758 tmp = (be16_to_cpu(hdr->count) - args->index)
@@ -1985,7 +1985,7 @@ xfs_attr_leaf_lookup_int(xfs_dabuf_t *bp, xfs_da_args_t *args)
1985 continue; 1985 continue;
1986 } 1986 }
1987 if (entry->flags & XFS_ATTR_LOCAL) { 1987 if (entry->flags & XFS_ATTR_LOCAL) {
1988 name_loc = XFS_ATTR_LEAF_NAME_LOCAL(leaf, probe); 1988 name_loc = xfs_attr_leaf_name_local(leaf, probe);
1989 if (name_loc->namelen != args->namelen) 1989 if (name_loc->namelen != args->namelen)
1990 continue; 1990 continue;
1991 if (memcmp(args->name, (char *)name_loc->nameval, args->namelen) != 0) 1991 if (memcmp(args->name, (char *)name_loc->nameval, args->namelen) != 0)
@@ -1995,7 +1995,7 @@ xfs_attr_leaf_lookup_int(xfs_dabuf_t *bp, xfs_da_args_t *args)
1995 args->index = probe; 1995 args->index = probe;
1996 return(XFS_ERROR(EEXIST)); 1996 return(XFS_ERROR(EEXIST));
1997 } else { 1997 } else {
1998 name_rmt = XFS_ATTR_LEAF_NAME_REMOTE(leaf, probe); 1998 name_rmt = xfs_attr_leaf_name_remote(leaf, probe);
1999 if (name_rmt->namelen != args->namelen) 1999 if (name_rmt->namelen != args->namelen)
2000 continue; 2000 continue;
2001 if (memcmp(args->name, (char *)name_rmt->name, 2001 if (memcmp(args->name, (char *)name_rmt->name,
@@ -2035,7 +2035,7 @@ xfs_attr_leaf_getvalue(xfs_dabuf_t *bp, xfs_da_args_t *args)
2035 2035
2036 entry = &leaf->entries[args->index]; 2036 entry = &leaf->entries[args->index];
2037 if (entry->flags & XFS_ATTR_LOCAL) { 2037 if (entry->flags & XFS_ATTR_LOCAL) {
2038 name_loc = XFS_ATTR_LEAF_NAME_LOCAL(leaf, args->index); 2038 name_loc = xfs_attr_leaf_name_local(leaf, args->index);
2039 ASSERT(name_loc->namelen == args->namelen); 2039 ASSERT(name_loc->namelen == args->namelen);
2040 ASSERT(memcmp(args->name, name_loc->nameval, args->namelen) == 0); 2040 ASSERT(memcmp(args->name, name_loc->nameval, args->namelen) == 0);
2041 valuelen = be16_to_cpu(name_loc->valuelen); 2041 valuelen = be16_to_cpu(name_loc->valuelen);
@@ -2050,7 +2050,7 @@ xfs_attr_leaf_getvalue(xfs_dabuf_t *bp, xfs_da_args_t *args)
2050 args->valuelen = valuelen; 2050 args->valuelen = valuelen;
2051 memcpy(args->value, &name_loc->nameval[args->namelen], valuelen); 2051 memcpy(args->value, &name_loc->nameval[args->namelen], valuelen);
2052 } else { 2052 } else {
2053 name_rmt = XFS_ATTR_LEAF_NAME_REMOTE(leaf, args->index); 2053 name_rmt = xfs_attr_leaf_name_remote(leaf, args->index);
2054 ASSERT(name_rmt->namelen == args->namelen); 2054 ASSERT(name_rmt->namelen == args->namelen);
2055 ASSERT(memcmp(args->name, name_rmt->name, args->namelen) == 0); 2055 ASSERT(memcmp(args->name, name_rmt->name, args->namelen) == 0);
2056 valuelen = be32_to_cpu(name_rmt->valuelen); 2056 valuelen = be32_to_cpu(name_rmt->valuelen);
@@ -2143,7 +2143,7 @@ xfs_attr_leaf_moveents(xfs_attr_leafblock_t *leaf_s, int start_s,
2143 * off for 6.2, should be revisited later. 2143 * off for 6.2, should be revisited later.
2144 */ 2144 */
2145 if (entry_s->flags & XFS_ATTR_INCOMPLETE) { /* skip partials? */ 2145 if (entry_s->flags & XFS_ATTR_INCOMPLETE) { /* skip partials? */
2146 memset(XFS_ATTR_LEAF_NAME(leaf_s, start_s + i), 0, tmp); 2146 memset(xfs_attr_leaf_name(leaf_s, start_s + i), 0, tmp);
2147 be16_add_cpu(&hdr_s->usedbytes, -tmp); 2147 be16_add_cpu(&hdr_s->usedbytes, -tmp);
2148 be16_add_cpu(&hdr_s->count, -1); 2148 be16_add_cpu(&hdr_s->count, -1);
2149 entry_d--; /* to compensate for ++ in loop hdr */ 2149 entry_d--; /* to compensate for ++ in loop hdr */
@@ -2160,11 +2160,11 @@ xfs_attr_leaf_moveents(xfs_attr_leafblock_t *leaf_s, int start_s,
2160 entry_d->flags = entry_s->flags; 2160 entry_d->flags = entry_s->flags;
2161 ASSERT(be16_to_cpu(entry_d->nameidx) + tmp 2161 ASSERT(be16_to_cpu(entry_d->nameidx) + tmp
2162 <= XFS_LBSIZE(mp)); 2162 <= XFS_LBSIZE(mp));
2163 memmove(XFS_ATTR_LEAF_NAME(leaf_d, desti), 2163 memmove(xfs_attr_leaf_name(leaf_d, desti),
2164 XFS_ATTR_LEAF_NAME(leaf_s, start_s + i), tmp); 2164 xfs_attr_leaf_name(leaf_s, start_s + i), tmp);
2165 ASSERT(be16_to_cpu(entry_s->nameidx) + tmp 2165 ASSERT(be16_to_cpu(entry_s->nameidx) + tmp
2166 <= XFS_LBSIZE(mp)); 2166 <= XFS_LBSIZE(mp));
2167 memset(XFS_ATTR_LEAF_NAME(leaf_s, start_s + i), 0, tmp); 2167 memset(xfs_attr_leaf_name(leaf_s, start_s + i), 0, tmp);
2168 be16_add_cpu(&hdr_s->usedbytes, -tmp); 2168 be16_add_cpu(&hdr_s->usedbytes, -tmp);
2169 be16_add_cpu(&hdr_d->usedbytes, tmp); 2169 be16_add_cpu(&hdr_d->usedbytes, tmp);
2170 be16_add_cpu(&hdr_s->count, -1); 2170 be16_add_cpu(&hdr_s->count, -1);
@@ -2276,12 +2276,12 @@ xfs_attr_leaf_entsize(xfs_attr_leafblock_t *leaf, int index)
2276 2276
2277 ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC); 2277 ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC);
2278 if (leaf->entries[index].flags & XFS_ATTR_LOCAL) { 2278 if (leaf->entries[index].flags & XFS_ATTR_LOCAL) {
2279 name_loc = XFS_ATTR_LEAF_NAME_LOCAL(leaf, index); 2279 name_loc = xfs_attr_leaf_name_local(leaf, index);
2280 size = XFS_ATTR_LEAF_ENTSIZE_LOCAL(name_loc->namelen, 2280 size = xfs_attr_leaf_entsize_local(name_loc->namelen,
2281 be16_to_cpu(name_loc->valuelen)); 2281 be16_to_cpu(name_loc->valuelen));
2282 } else { 2282 } else {
2283 name_rmt = XFS_ATTR_LEAF_NAME_REMOTE(leaf, index); 2283 name_rmt = xfs_attr_leaf_name_remote(leaf, index);
2284 size = XFS_ATTR_LEAF_ENTSIZE_REMOTE(name_rmt->namelen); 2284 size = xfs_attr_leaf_entsize_remote(name_rmt->namelen);
2285 } 2285 }
2286 return(size); 2286 return(size);
2287} 2287}
@@ -2297,13 +2297,13 @@ xfs_attr_leaf_newentsize(int namelen, int valuelen, int blocksize, int *local)
2297{ 2297{
2298 int size; 2298 int size;
2299 2299
2300 size = XFS_ATTR_LEAF_ENTSIZE_LOCAL(namelen, valuelen); 2300 size = xfs_attr_leaf_entsize_local(namelen, valuelen);
2301 if (size < XFS_ATTR_LEAF_ENTSIZE_LOCAL_MAX(blocksize)) { 2301 if (size < xfs_attr_leaf_entsize_local_max(blocksize)) {
2302 if (local) { 2302 if (local) {
2303 *local = 1; 2303 *local = 1;
2304 } 2304 }
2305 } else { 2305 } else {
2306 size = XFS_ATTR_LEAF_ENTSIZE_REMOTE(namelen); 2306 size = xfs_attr_leaf_entsize_remote(namelen);
2307 if (local) { 2307 if (local) {
2308 *local = 0; 2308 *local = 0;
2309 } 2309 }
@@ -2372,7 +2372,7 @@ xfs_attr_leaf_list_int(xfs_dabuf_t *bp, xfs_attr_list_context_t *context)
2372 2372
2373 if (entry->flags & XFS_ATTR_LOCAL) { 2373 if (entry->flags & XFS_ATTR_LOCAL) {
2374 xfs_attr_leaf_name_local_t *name_loc = 2374 xfs_attr_leaf_name_local_t *name_loc =
2375 XFS_ATTR_LEAF_NAME_LOCAL(leaf, i); 2375 xfs_attr_leaf_name_local(leaf, i);
2376 2376
2377 retval = context->put_listent(context, 2377 retval = context->put_listent(context,
2378 entry->flags, 2378 entry->flags,
@@ -2384,7 +2384,7 @@ xfs_attr_leaf_list_int(xfs_dabuf_t *bp, xfs_attr_list_context_t *context)
2384 return retval; 2384 return retval;
2385 } else { 2385 } else {
2386 xfs_attr_leaf_name_remote_t *name_rmt = 2386 xfs_attr_leaf_name_remote_t *name_rmt =
2387 XFS_ATTR_LEAF_NAME_REMOTE(leaf, i); 2387 xfs_attr_leaf_name_remote(leaf, i);
2388 2388
2389 int valuelen = be32_to_cpu(name_rmt->valuelen); 2389 int valuelen = be32_to_cpu(name_rmt->valuelen);
2390 2390
@@ -2468,11 +2468,11 @@ xfs_attr_leaf_clearflag(xfs_da_args_t *args)
2468 2468
2469#ifdef DEBUG 2469#ifdef DEBUG
2470 if (entry->flags & XFS_ATTR_LOCAL) { 2470 if (entry->flags & XFS_ATTR_LOCAL) {
2471 name_loc = XFS_ATTR_LEAF_NAME_LOCAL(leaf, args->index); 2471 name_loc = xfs_attr_leaf_name_local(leaf, args->index);
2472 namelen = name_loc->namelen; 2472 namelen = name_loc->namelen;
2473 name = (char *)name_loc->nameval; 2473 name = (char *)name_loc->nameval;
2474 } else { 2474 } else {
2475 name_rmt = XFS_ATTR_LEAF_NAME_REMOTE(leaf, args->index); 2475 name_rmt = xfs_attr_leaf_name_remote(leaf, args->index);
2476 namelen = name_rmt->namelen; 2476 namelen = name_rmt->namelen;
2477 name = (char *)name_rmt->name; 2477 name = (char *)name_rmt->name;
2478 } 2478 }
@@ -2487,7 +2487,7 @@ xfs_attr_leaf_clearflag(xfs_da_args_t *args)
2487 2487
2488 if (args->rmtblkno) { 2488 if (args->rmtblkno) {
2489 ASSERT((entry->flags & XFS_ATTR_LOCAL) == 0); 2489 ASSERT((entry->flags & XFS_ATTR_LOCAL) == 0);
2490 name_rmt = XFS_ATTR_LEAF_NAME_REMOTE(leaf, args->index); 2490 name_rmt = xfs_attr_leaf_name_remote(leaf, args->index);
2491 name_rmt->valueblk = cpu_to_be32(args->rmtblkno); 2491 name_rmt->valueblk = cpu_to_be32(args->rmtblkno);
2492 name_rmt->valuelen = cpu_to_be32(args->valuelen); 2492 name_rmt->valuelen = cpu_to_be32(args->valuelen);
2493 xfs_da_log_buf(args->trans, bp, 2493 xfs_da_log_buf(args->trans, bp,
@@ -2534,7 +2534,7 @@ xfs_attr_leaf_setflag(xfs_da_args_t *args)
2534 xfs_da_log_buf(args->trans, bp, 2534 xfs_da_log_buf(args->trans, bp,
2535 XFS_DA_LOGRANGE(leaf, entry, sizeof(*entry))); 2535 XFS_DA_LOGRANGE(leaf, entry, sizeof(*entry)));
2536 if ((entry->flags & XFS_ATTR_LOCAL) == 0) { 2536 if ((entry->flags & XFS_ATTR_LOCAL) == 0) {
2537 name_rmt = XFS_ATTR_LEAF_NAME_REMOTE(leaf, args->index); 2537 name_rmt = xfs_attr_leaf_name_remote(leaf, args->index);
2538 name_rmt->valueblk = 0; 2538 name_rmt->valueblk = 0;
2539 name_rmt->valuelen = 0; 2539 name_rmt->valuelen = 0;
2540 xfs_da_log_buf(args->trans, bp, 2540 xfs_da_log_buf(args->trans, bp,
@@ -2607,20 +2607,20 @@ xfs_attr_leaf_flipflags(xfs_da_args_t *args)
2607 2607
2608#ifdef DEBUG 2608#ifdef DEBUG
2609 if (entry1->flags & XFS_ATTR_LOCAL) { 2609 if (entry1->flags & XFS_ATTR_LOCAL) {
2610 name_loc = XFS_ATTR_LEAF_NAME_LOCAL(leaf1, args->index); 2610 name_loc = xfs_attr_leaf_name_local(leaf1, args->index);
2611 namelen1 = name_loc->namelen; 2611 namelen1 = name_loc->namelen;
2612 name1 = (char *)name_loc->nameval; 2612 name1 = (char *)name_loc->nameval;
2613 } else { 2613 } else {
2614 name_rmt = XFS_ATTR_LEAF_NAME_REMOTE(leaf1, args->index); 2614 name_rmt = xfs_attr_leaf_name_remote(leaf1, args->index);
2615 namelen1 = name_rmt->namelen; 2615 namelen1 = name_rmt->namelen;
2616 name1 = (char *)name_rmt->name; 2616 name1 = (char *)name_rmt->name;
2617 } 2617 }
2618 if (entry2->flags & XFS_ATTR_LOCAL) { 2618 if (entry2->flags & XFS_ATTR_LOCAL) {
2619 name_loc = XFS_ATTR_LEAF_NAME_LOCAL(leaf2, args->index2); 2619 name_loc = xfs_attr_leaf_name_local(leaf2, args->index2);
2620 namelen2 = name_loc->namelen; 2620 namelen2 = name_loc->namelen;
2621 name2 = (char *)name_loc->nameval; 2621 name2 = (char *)name_loc->nameval;
2622 } else { 2622 } else {
2623 name_rmt = XFS_ATTR_LEAF_NAME_REMOTE(leaf2, args->index2); 2623 name_rmt = xfs_attr_leaf_name_remote(leaf2, args->index2);
2624 namelen2 = name_rmt->namelen; 2624 namelen2 = name_rmt->namelen;
2625 name2 = (char *)name_rmt->name; 2625 name2 = (char *)name_rmt->name;
2626 } 2626 }
@@ -2637,7 +2637,7 @@ xfs_attr_leaf_flipflags(xfs_da_args_t *args)
2637 XFS_DA_LOGRANGE(leaf1, entry1, sizeof(*entry1))); 2637 XFS_DA_LOGRANGE(leaf1, entry1, sizeof(*entry1)));
2638 if (args->rmtblkno) { 2638 if (args->rmtblkno) {
2639 ASSERT((entry1->flags & XFS_ATTR_LOCAL) == 0); 2639 ASSERT((entry1->flags & XFS_ATTR_LOCAL) == 0);
2640 name_rmt = XFS_ATTR_LEAF_NAME_REMOTE(leaf1, args->index); 2640 name_rmt = xfs_attr_leaf_name_remote(leaf1, args->index);
2641 name_rmt->valueblk = cpu_to_be32(args->rmtblkno); 2641 name_rmt->valueblk = cpu_to_be32(args->rmtblkno);
2642 name_rmt->valuelen = cpu_to_be32(args->valuelen); 2642 name_rmt->valuelen = cpu_to_be32(args->valuelen);
2643 xfs_da_log_buf(args->trans, bp1, 2643 xfs_da_log_buf(args->trans, bp1,
@@ -2648,7 +2648,7 @@ xfs_attr_leaf_flipflags(xfs_da_args_t *args)
2648 xfs_da_log_buf(args->trans, bp2, 2648 xfs_da_log_buf(args->trans, bp2,
2649 XFS_DA_LOGRANGE(leaf2, entry2, sizeof(*entry2))); 2649 XFS_DA_LOGRANGE(leaf2, entry2, sizeof(*entry2)));
2650 if ((entry2->flags & XFS_ATTR_LOCAL) == 0) { 2650 if ((entry2->flags & XFS_ATTR_LOCAL) == 0) {
2651 name_rmt = XFS_ATTR_LEAF_NAME_REMOTE(leaf2, args->index2); 2651 name_rmt = xfs_attr_leaf_name_remote(leaf2, args->index2);
2652 name_rmt->valueblk = 0; 2652 name_rmt->valueblk = 0;
2653 name_rmt->valuelen = 0; 2653 name_rmt->valuelen = 0;
2654 xfs_da_log_buf(args->trans, bp2, 2654 xfs_da_log_buf(args->trans, bp2,
@@ -2855,7 +2855,7 @@ xfs_attr_leaf_inactive(xfs_trans_t **trans, xfs_inode_t *dp, xfs_dabuf_t *bp)
2855 for (i = 0; i < be16_to_cpu(leaf->hdr.count); entry++, i++) { 2855 for (i = 0; i < be16_to_cpu(leaf->hdr.count); entry++, i++) {
2856 if (be16_to_cpu(entry->nameidx) && 2856 if (be16_to_cpu(entry->nameidx) &&
2857 ((entry->flags & XFS_ATTR_LOCAL) == 0)) { 2857 ((entry->flags & XFS_ATTR_LOCAL) == 0)) {
2858 name_rmt = XFS_ATTR_LEAF_NAME_REMOTE(leaf, i); 2858 name_rmt = xfs_attr_leaf_name_remote(leaf, i);
2859 if (name_rmt->valueblk) 2859 if (name_rmt->valueblk)
2860 count++; 2860 count++;
2861 } 2861 }
@@ -2883,7 +2883,7 @@ xfs_attr_leaf_inactive(xfs_trans_t **trans, xfs_inode_t *dp, xfs_dabuf_t *bp)
2883 for (i = 0; i < be16_to_cpu(leaf->hdr.count); entry++, i++) { 2883 for (i = 0; i < be16_to_cpu(leaf->hdr.count); entry++, i++) {
2884 if (be16_to_cpu(entry->nameidx) && 2884 if (be16_to_cpu(entry->nameidx) &&
2885 ((entry->flags & XFS_ATTR_LOCAL) == 0)) { 2885 ((entry->flags & XFS_ATTR_LOCAL) == 0)) {
2886 name_rmt = XFS_ATTR_LEAF_NAME_REMOTE(leaf, i); 2886 name_rmt = xfs_attr_leaf_name_remote(leaf, i);
2887 if (name_rmt->valueblk) { 2887 if (name_rmt->valueblk) {
2888 lp->valueblk = be32_to_cpu(name_rmt->valueblk); 2888 lp->valueblk = be32_to_cpu(name_rmt->valueblk);
2889 lp->valuelen = XFS_B_TO_FSB(dp->i_mount, 2889 lp->valuelen = XFS_B_TO_FSB(dp->i_mount,
diff --git a/fs/xfs/xfs_attr_leaf.h b/fs/xfs/xfs_attr_leaf.h
index 83e9af417ca2..9c7d22fdcf4d 100644
--- a/fs/xfs/xfs_attr_leaf.h
+++ b/fs/xfs/xfs_attr_leaf.h
@@ -151,8 +151,6 @@ typedef struct xfs_attr_leafblock {
151/* 151/*
152 * Cast typed pointers for "local" and "remote" name/value structs. 152 * Cast typed pointers for "local" and "remote" name/value structs.
153 */ 153 */
154#define XFS_ATTR_LEAF_NAME_REMOTE(leafp,idx) \
155 xfs_attr_leaf_name_remote(leafp,idx)
156static inline xfs_attr_leaf_name_remote_t * 154static inline xfs_attr_leaf_name_remote_t *
157xfs_attr_leaf_name_remote(xfs_attr_leafblock_t *leafp, int idx) 155xfs_attr_leaf_name_remote(xfs_attr_leafblock_t *leafp, int idx)
158{ 156{
@@ -160,8 +158,6 @@ xfs_attr_leaf_name_remote(xfs_attr_leafblock_t *leafp, int idx)
160 &((char *)leafp)[be16_to_cpu(leafp->entries[idx].nameidx)]; 158 &((char *)leafp)[be16_to_cpu(leafp->entries[idx].nameidx)];
161} 159}
162 160
163#define XFS_ATTR_LEAF_NAME_LOCAL(leafp,idx) \
164 xfs_attr_leaf_name_local(leafp,idx)
165static inline xfs_attr_leaf_name_local_t * 161static inline xfs_attr_leaf_name_local_t *
166xfs_attr_leaf_name_local(xfs_attr_leafblock_t *leafp, int idx) 162xfs_attr_leaf_name_local(xfs_attr_leafblock_t *leafp, int idx)
167{ 163{
@@ -169,8 +165,6 @@ xfs_attr_leaf_name_local(xfs_attr_leafblock_t *leafp, int idx)
169 &((char *)leafp)[be16_to_cpu(leafp->entries[idx].nameidx)]; 165 &((char *)leafp)[be16_to_cpu(leafp->entries[idx].nameidx)];
170} 166}
171 167
172#define XFS_ATTR_LEAF_NAME(leafp,idx) \
173 xfs_attr_leaf_name(leafp,idx)
174static inline char *xfs_attr_leaf_name(xfs_attr_leafblock_t *leafp, int idx) 168static inline char *xfs_attr_leaf_name(xfs_attr_leafblock_t *leafp, int idx)
175{ 169{
176 return &((char *)leafp)[be16_to_cpu(leafp->entries[idx].nameidx)]; 170 return &((char *)leafp)[be16_to_cpu(leafp->entries[idx].nameidx)];
@@ -181,24 +175,18 @@ static inline char *xfs_attr_leaf_name(xfs_attr_leafblock_t *leafp, int idx)
181 * a "local" name/value structure, a "remote" name/value structure, and 175 * a "local" name/value structure, a "remote" name/value structure, and
182 * a pointer which might be either. 176 * a pointer which might be either.
183 */ 177 */
184#define XFS_ATTR_LEAF_ENTSIZE_REMOTE(nlen) \
185 xfs_attr_leaf_entsize_remote(nlen)
186static inline int xfs_attr_leaf_entsize_remote(int nlen) 178static inline int xfs_attr_leaf_entsize_remote(int nlen)
187{ 179{
188 return ((uint)sizeof(xfs_attr_leaf_name_remote_t) - 1 + (nlen) + \ 180 return ((uint)sizeof(xfs_attr_leaf_name_remote_t) - 1 + (nlen) + \
189 XFS_ATTR_LEAF_NAME_ALIGN - 1) & ~(XFS_ATTR_LEAF_NAME_ALIGN - 1); 181 XFS_ATTR_LEAF_NAME_ALIGN - 1) & ~(XFS_ATTR_LEAF_NAME_ALIGN - 1);
190} 182}
191 183
192#define XFS_ATTR_LEAF_ENTSIZE_LOCAL(nlen,vlen) \
193 xfs_attr_leaf_entsize_local(nlen,vlen)
194static inline int xfs_attr_leaf_entsize_local(int nlen, int vlen) 184static inline int xfs_attr_leaf_entsize_local(int nlen, int vlen)
195{ 185{
196 return ((uint)sizeof(xfs_attr_leaf_name_local_t) - 1 + (nlen) + (vlen) + 186 return ((uint)sizeof(xfs_attr_leaf_name_local_t) - 1 + (nlen) + (vlen) +
197 XFS_ATTR_LEAF_NAME_ALIGN - 1) & ~(XFS_ATTR_LEAF_NAME_ALIGN - 1); 187 XFS_ATTR_LEAF_NAME_ALIGN - 1) & ~(XFS_ATTR_LEAF_NAME_ALIGN - 1);
198} 188}
199 189
200#define XFS_ATTR_LEAF_ENTSIZE_LOCAL_MAX(bsize) \
201 xfs_attr_leaf_entsize_local_max(bsize)
202static inline int xfs_attr_leaf_entsize_local_max(int bsize) 190static inline int xfs_attr_leaf_entsize_local_max(int bsize)
203{ 191{
204 return (((bsize) >> 1) + ((bsize) >> 2)); 192 return (((bsize) >> 1) + ((bsize) >> 2));
diff --git a/fs/xfs/xfs_bit.h b/fs/xfs/xfs_bit.h
index bca7b243c319..f1e3c907044d 100644
--- a/fs/xfs/xfs_bit.h
+++ b/fs/xfs/xfs_bit.h
@@ -23,24 +23,16 @@
23 */ 23 */
24 24
25/* 25/*
26 * masks with n high/low bits set, 32-bit values & 64-bit values 26 * masks with n high/low bits set, 64-bit values
27 */ 27 */
28#define XFS_MASK32HI(n) xfs_mask32hi(n)
29static inline __uint32_t xfs_mask32hi(int n)
30{
31 return (__uint32_t)-1 << (32 - (n));
32}
33#define XFS_MASK64HI(n) xfs_mask64hi(n)
34static inline __uint64_t xfs_mask64hi(int n) 28static inline __uint64_t xfs_mask64hi(int n)
35{ 29{
36 return (__uint64_t)-1 << (64 - (n)); 30 return (__uint64_t)-1 << (64 - (n));
37} 31}
38#define XFS_MASK32LO(n) xfs_mask32lo(n)
39static inline __uint32_t xfs_mask32lo(int n) 32static inline __uint32_t xfs_mask32lo(int n)
40{ 33{
41 return ((__uint32_t)1 << (n)) - 1; 34 return ((__uint32_t)1 << (n)) - 1;
42} 35}
43#define XFS_MASK64LO(n) xfs_mask64lo(n)
44static inline __uint64_t xfs_mask64lo(int n) 36static inline __uint64_t xfs_mask64lo(int n)
45{ 37{
46 return ((__uint64_t)1 << (n)) - 1; 38 return ((__uint64_t)1 << (n)) - 1;
diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c
index 138308e70d14..c852cd65aaea 100644
--- a/fs/xfs/xfs_bmap.c
+++ b/fs/xfs/xfs_bmap.c
@@ -595,9 +595,9 @@ xfs_bmap_add_extent(
595 xfs_iext_insert(ifp, 0, 1, new); 595 xfs_iext_insert(ifp, 0, 1, new);
596 ASSERT(cur == NULL); 596 ASSERT(cur == NULL);
597 ifp->if_lastex = 0; 597 ifp->if_lastex = 0;
598 if (!ISNULLSTARTBLOCK(new->br_startblock)) { 598 if (!isnullstartblock(new->br_startblock)) {
599 XFS_IFORK_NEXT_SET(ip, whichfork, 1); 599 XFS_IFORK_NEXT_SET(ip, whichfork, 1);
600 logflags = XFS_ILOG_CORE | XFS_ILOG_FEXT(whichfork); 600 logflags = XFS_ILOG_CORE | xfs_ilog_fext(whichfork);
601 } else 601 } else
602 logflags = 0; 602 logflags = 0;
603 /* DELTA: single new extent */ 603 /* DELTA: single new extent */
@@ -613,7 +613,7 @@ xfs_bmap_add_extent(
613 /* 613 /*
614 * Any kind of new delayed allocation goes here. 614 * Any kind of new delayed allocation goes here.
615 */ 615 */
616 else if (ISNULLSTARTBLOCK(new->br_startblock)) { 616 else if (isnullstartblock(new->br_startblock)) {
617 if (cur) 617 if (cur)
618 ASSERT((cur->bc_private.b.flags & 618 ASSERT((cur->bc_private.b.flags &
619 XFS_BTCUR_BPRV_WASDEL) == 0); 619 XFS_BTCUR_BPRV_WASDEL) == 0);
@@ -644,11 +644,11 @@ xfs_bmap_add_extent(
644 * in a delayed or unwritten allocation with a real one, or 644 * in a delayed or unwritten allocation with a real one, or
645 * converting real back to unwritten. 645 * converting real back to unwritten.
646 */ 646 */
647 if (!ISNULLSTARTBLOCK(new->br_startblock) && 647 if (!isnullstartblock(new->br_startblock) &&
648 new->br_startoff + new->br_blockcount > prev.br_startoff) { 648 new->br_startoff + new->br_blockcount > prev.br_startoff) {
649 if (prev.br_state != XFS_EXT_UNWRITTEN && 649 if (prev.br_state != XFS_EXT_UNWRITTEN &&
650 ISNULLSTARTBLOCK(prev.br_startblock)) { 650 isnullstartblock(prev.br_startblock)) {
651 da_old = STARTBLOCKVAL(prev.br_startblock); 651 da_old = startblockval(prev.br_startblock);
652 if (cur) 652 if (cur)
653 ASSERT(cur->bc_private.b.flags & 653 ASSERT(cur->bc_private.b.flags &
654 XFS_BTCUR_BPRV_WASDEL); 654 XFS_BTCUR_BPRV_WASDEL);
@@ -803,7 +803,7 @@ xfs_bmap_add_extent_delay_real(
803 */ 803 */
804 if (STATE_SET_TEST(LEFT_VALID, idx > 0)) { 804 if (STATE_SET_TEST(LEFT_VALID, idx > 0)) {
805 xfs_bmbt_get_all(xfs_iext_get_ext(ifp, idx - 1), &LEFT); 805 xfs_bmbt_get_all(xfs_iext_get_ext(ifp, idx - 1), &LEFT);
806 STATE_SET(LEFT_DELAY, ISNULLSTARTBLOCK(LEFT.br_startblock)); 806 STATE_SET(LEFT_DELAY, isnullstartblock(LEFT.br_startblock));
807 } 807 }
808 STATE_SET(LEFT_CONTIG, 808 STATE_SET(LEFT_CONTIG,
809 STATE_TEST(LEFT_VALID) && !STATE_TEST(LEFT_DELAY) && 809 STATE_TEST(LEFT_VALID) && !STATE_TEST(LEFT_DELAY) &&
@@ -820,7 +820,7 @@ xfs_bmap_add_extent_delay_real(
820 idx < 820 idx <
821 ip->i_df.if_bytes / (uint)sizeof(xfs_bmbt_rec_t) - 1)) { 821 ip->i_df.if_bytes / (uint)sizeof(xfs_bmbt_rec_t) - 1)) {
822 xfs_bmbt_get_all(xfs_iext_get_ext(ifp, idx + 1), &RIGHT); 822 xfs_bmbt_get_all(xfs_iext_get_ext(ifp, idx + 1), &RIGHT);
823 STATE_SET(RIGHT_DELAY, ISNULLSTARTBLOCK(RIGHT.br_startblock)); 823 STATE_SET(RIGHT_DELAY, isnullstartblock(RIGHT.br_startblock));
824 } 824 }
825 STATE_SET(RIGHT_CONTIG, 825 STATE_SET(RIGHT_CONTIG,
826 STATE_TEST(RIGHT_VALID) && !STATE_TEST(RIGHT_DELAY) && 826 STATE_TEST(RIGHT_VALID) && !STATE_TEST(RIGHT_DELAY) &&
@@ -1019,8 +1019,8 @@ xfs_bmap_add_extent_delay_real(
1019 goto done; 1019 goto done;
1020 } 1020 }
1021 temp = XFS_FILBLKS_MIN(xfs_bmap_worst_indlen(ip, temp), 1021 temp = XFS_FILBLKS_MIN(xfs_bmap_worst_indlen(ip, temp),
1022 STARTBLOCKVAL(PREV.br_startblock)); 1022 startblockval(PREV.br_startblock));
1023 xfs_bmbt_set_startblock(ep, NULLSTARTBLOCK((int)temp)); 1023 xfs_bmbt_set_startblock(ep, nullstartblock((int)temp));
1024 XFS_BMAP_TRACE_POST_UPDATE("LF|LC", ip, idx, XFS_DATA_FORK); 1024 XFS_BMAP_TRACE_POST_UPDATE("LF|LC", ip, idx, XFS_DATA_FORK);
1025 *dnew = temp; 1025 *dnew = temp;
1026 /* DELTA: The boundary between two in-core extents moved. */ 1026 /* DELTA: The boundary between two in-core extents moved. */
@@ -1067,10 +1067,10 @@ xfs_bmap_add_extent_delay_real(
1067 goto done; 1067 goto done;
1068 } 1068 }
1069 temp = XFS_FILBLKS_MIN(xfs_bmap_worst_indlen(ip, temp), 1069 temp = XFS_FILBLKS_MIN(xfs_bmap_worst_indlen(ip, temp),
1070 STARTBLOCKVAL(PREV.br_startblock) - 1070 startblockval(PREV.br_startblock) -
1071 (cur ? cur->bc_private.b.allocated : 0)); 1071 (cur ? cur->bc_private.b.allocated : 0));
1072 ep = xfs_iext_get_ext(ifp, idx + 1); 1072 ep = xfs_iext_get_ext(ifp, idx + 1);
1073 xfs_bmbt_set_startblock(ep, NULLSTARTBLOCK((int)temp)); 1073 xfs_bmbt_set_startblock(ep, nullstartblock((int)temp));
1074 XFS_BMAP_TRACE_POST_UPDATE("LF", ip, idx + 1, XFS_DATA_FORK); 1074 XFS_BMAP_TRACE_POST_UPDATE("LF", ip, idx + 1, XFS_DATA_FORK);
1075 *dnew = temp; 1075 *dnew = temp;
1076 /* DELTA: One in-core extent is split in two. */ 1076 /* DELTA: One in-core extent is split in two. */
@@ -1110,8 +1110,8 @@ xfs_bmap_add_extent_delay_real(
1110 goto done; 1110 goto done;
1111 } 1111 }
1112 temp = XFS_FILBLKS_MIN(xfs_bmap_worst_indlen(ip, temp), 1112 temp = XFS_FILBLKS_MIN(xfs_bmap_worst_indlen(ip, temp),
1113 STARTBLOCKVAL(PREV.br_startblock)); 1113 startblockval(PREV.br_startblock));
1114 xfs_bmbt_set_startblock(ep, NULLSTARTBLOCK((int)temp)); 1114 xfs_bmbt_set_startblock(ep, nullstartblock((int)temp));
1115 XFS_BMAP_TRACE_POST_UPDATE("RF|RC", ip, idx, XFS_DATA_FORK); 1115 XFS_BMAP_TRACE_POST_UPDATE("RF|RC", ip, idx, XFS_DATA_FORK);
1116 *dnew = temp; 1116 *dnew = temp;
1117 /* DELTA: The boundary between two in-core extents moved. */ 1117 /* DELTA: The boundary between two in-core extents moved. */
@@ -1157,10 +1157,10 @@ xfs_bmap_add_extent_delay_real(
1157 goto done; 1157 goto done;
1158 } 1158 }
1159 temp = XFS_FILBLKS_MIN(xfs_bmap_worst_indlen(ip, temp), 1159 temp = XFS_FILBLKS_MIN(xfs_bmap_worst_indlen(ip, temp),
1160 STARTBLOCKVAL(PREV.br_startblock) - 1160 startblockval(PREV.br_startblock) -
1161 (cur ? cur->bc_private.b.allocated : 0)); 1161 (cur ? cur->bc_private.b.allocated : 0));
1162 ep = xfs_iext_get_ext(ifp, idx); 1162 ep = xfs_iext_get_ext(ifp, idx);
1163 xfs_bmbt_set_startblock(ep, NULLSTARTBLOCK((int)temp)); 1163 xfs_bmbt_set_startblock(ep, nullstartblock((int)temp));
1164 XFS_BMAP_TRACE_POST_UPDATE("RF", ip, idx, XFS_DATA_FORK); 1164 XFS_BMAP_TRACE_POST_UPDATE("RF", ip, idx, XFS_DATA_FORK);
1165 *dnew = temp; 1165 *dnew = temp;
1166 /* DELTA: One in-core extent is split in two. */ 1166 /* DELTA: One in-core extent is split in two. */
@@ -1213,7 +1213,7 @@ xfs_bmap_add_extent_delay_real(
1213 } 1213 }
1214 temp = xfs_bmap_worst_indlen(ip, temp); 1214 temp = xfs_bmap_worst_indlen(ip, temp);
1215 temp2 = xfs_bmap_worst_indlen(ip, temp2); 1215 temp2 = xfs_bmap_worst_indlen(ip, temp2);
1216 diff = (int)(temp + temp2 - STARTBLOCKVAL(PREV.br_startblock) - 1216 diff = (int)(temp + temp2 - startblockval(PREV.br_startblock) -
1217 (cur ? cur->bc_private.b.allocated : 0)); 1217 (cur ? cur->bc_private.b.allocated : 0));
1218 if (diff > 0 && 1218 if (diff > 0 &&
1219 xfs_mod_incore_sb(ip->i_mount, XFS_SBS_FDBLOCKS, -((int64_t)diff), rsvd)) { 1219 xfs_mod_incore_sb(ip->i_mount, XFS_SBS_FDBLOCKS, -((int64_t)diff), rsvd)) {
@@ -1241,11 +1241,11 @@ xfs_bmap_add_extent_delay_real(
1241 } 1241 }
1242 } 1242 }
1243 ep = xfs_iext_get_ext(ifp, idx); 1243 ep = xfs_iext_get_ext(ifp, idx);
1244 xfs_bmbt_set_startblock(ep, NULLSTARTBLOCK((int)temp)); 1244 xfs_bmbt_set_startblock(ep, nullstartblock((int)temp));
1245 XFS_BMAP_TRACE_POST_UPDATE("0", ip, idx, XFS_DATA_FORK); 1245 XFS_BMAP_TRACE_POST_UPDATE("0", ip, idx, XFS_DATA_FORK);
1246 XFS_BMAP_TRACE_PRE_UPDATE("0", ip, idx + 2, XFS_DATA_FORK); 1246 XFS_BMAP_TRACE_PRE_UPDATE("0", ip, idx + 2, XFS_DATA_FORK);
1247 xfs_bmbt_set_startblock(xfs_iext_get_ext(ifp, idx + 2), 1247 xfs_bmbt_set_startblock(xfs_iext_get_ext(ifp, idx + 2),
1248 NULLSTARTBLOCK((int)temp2)); 1248 nullstartblock((int)temp2));
1249 XFS_BMAP_TRACE_POST_UPDATE("0", ip, idx + 2, XFS_DATA_FORK); 1249 XFS_BMAP_TRACE_POST_UPDATE("0", ip, idx + 2, XFS_DATA_FORK);
1250 *dnew = temp + temp2; 1250 *dnew = temp + temp2;
1251 /* DELTA: One in-core extent is split in three. */ 1251 /* DELTA: One in-core extent is split in three. */
@@ -1365,7 +1365,7 @@ xfs_bmap_add_extent_unwritten_real(
1365 */ 1365 */
1366 if (STATE_SET_TEST(LEFT_VALID, idx > 0)) { 1366 if (STATE_SET_TEST(LEFT_VALID, idx > 0)) {
1367 xfs_bmbt_get_all(xfs_iext_get_ext(ifp, idx - 1), &LEFT); 1367 xfs_bmbt_get_all(xfs_iext_get_ext(ifp, idx - 1), &LEFT);
1368 STATE_SET(LEFT_DELAY, ISNULLSTARTBLOCK(LEFT.br_startblock)); 1368 STATE_SET(LEFT_DELAY, isnullstartblock(LEFT.br_startblock));
1369 } 1369 }
1370 STATE_SET(LEFT_CONTIG, 1370 STATE_SET(LEFT_CONTIG,
1371 STATE_TEST(LEFT_VALID) && !STATE_TEST(LEFT_DELAY) && 1371 STATE_TEST(LEFT_VALID) && !STATE_TEST(LEFT_DELAY) &&
@@ -1382,7 +1382,7 @@ xfs_bmap_add_extent_unwritten_real(
1382 idx < 1382 idx <
1383 ip->i_df.if_bytes / (uint)sizeof(xfs_bmbt_rec_t) - 1)) { 1383 ip->i_df.if_bytes / (uint)sizeof(xfs_bmbt_rec_t) - 1)) {
1384 xfs_bmbt_get_all(xfs_iext_get_ext(ifp, idx + 1), &RIGHT); 1384 xfs_bmbt_get_all(xfs_iext_get_ext(ifp, idx + 1), &RIGHT);
1385 STATE_SET(RIGHT_DELAY, ISNULLSTARTBLOCK(RIGHT.br_startblock)); 1385 STATE_SET(RIGHT_DELAY, isnullstartblock(RIGHT.br_startblock));
1386 } 1386 }
1387 STATE_SET(RIGHT_CONTIG, 1387 STATE_SET(RIGHT_CONTIG,
1388 STATE_TEST(RIGHT_VALID) && !STATE_TEST(RIGHT_DELAY) && 1388 STATE_TEST(RIGHT_VALID) && !STATE_TEST(RIGHT_DELAY) &&
@@ -1889,13 +1889,13 @@ xfs_bmap_add_extent_hole_delay(
1889 ifp = XFS_IFORK_PTR(ip, XFS_DATA_FORK); 1889 ifp = XFS_IFORK_PTR(ip, XFS_DATA_FORK);
1890 ep = xfs_iext_get_ext(ifp, idx); 1890 ep = xfs_iext_get_ext(ifp, idx);
1891 state = 0; 1891 state = 0;
1892 ASSERT(ISNULLSTARTBLOCK(new->br_startblock)); 1892 ASSERT(isnullstartblock(new->br_startblock));
1893 /* 1893 /*
1894 * Check and set flags if this segment has a left neighbor 1894 * Check and set flags if this segment has a left neighbor
1895 */ 1895 */
1896 if (STATE_SET_TEST(LEFT_VALID, idx > 0)) { 1896 if (STATE_SET_TEST(LEFT_VALID, idx > 0)) {
1897 xfs_bmbt_get_all(xfs_iext_get_ext(ifp, idx - 1), &left); 1897 xfs_bmbt_get_all(xfs_iext_get_ext(ifp, idx - 1), &left);
1898 STATE_SET(LEFT_DELAY, ISNULLSTARTBLOCK(left.br_startblock)); 1898 STATE_SET(LEFT_DELAY, isnullstartblock(left.br_startblock));
1899 } 1899 }
1900 /* 1900 /*
1901 * Check and set flags if the current (right) segment exists. 1901 * Check and set flags if the current (right) segment exists.
@@ -1905,7 +1905,7 @@ xfs_bmap_add_extent_hole_delay(
1905 idx < 1905 idx <
1906 ip->i_df.if_bytes / (uint)sizeof(xfs_bmbt_rec_t))) { 1906 ip->i_df.if_bytes / (uint)sizeof(xfs_bmbt_rec_t))) {
1907 xfs_bmbt_get_all(ep, &right); 1907 xfs_bmbt_get_all(ep, &right);
1908 STATE_SET(RIGHT_DELAY, ISNULLSTARTBLOCK(right.br_startblock)); 1908 STATE_SET(RIGHT_DELAY, isnullstartblock(right.br_startblock));
1909 } 1909 }
1910 /* 1910 /*
1911 * Set contiguity flags on the left and right neighbors. 1911 * Set contiguity flags on the left and right neighbors.
@@ -1938,12 +1938,12 @@ xfs_bmap_add_extent_hole_delay(
1938 XFS_BMAP_TRACE_PRE_UPDATE("LC|RC", ip, idx - 1, 1938 XFS_BMAP_TRACE_PRE_UPDATE("LC|RC", ip, idx - 1,
1939 XFS_DATA_FORK); 1939 XFS_DATA_FORK);
1940 xfs_bmbt_set_blockcount(xfs_iext_get_ext(ifp, idx - 1), temp); 1940 xfs_bmbt_set_blockcount(xfs_iext_get_ext(ifp, idx - 1), temp);
1941 oldlen = STARTBLOCKVAL(left.br_startblock) + 1941 oldlen = startblockval(left.br_startblock) +
1942 STARTBLOCKVAL(new->br_startblock) + 1942 startblockval(new->br_startblock) +
1943 STARTBLOCKVAL(right.br_startblock); 1943 startblockval(right.br_startblock);
1944 newlen = xfs_bmap_worst_indlen(ip, temp); 1944 newlen = xfs_bmap_worst_indlen(ip, temp);
1945 xfs_bmbt_set_startblock(xfs_iext_get_ext(ifp, idx - 1), 1945 xfs_bmbt_set_startblock(xfs_iext_get_ext(ifp, idx - 1),
1946 NULLSTARTBLOCK((int)newlen)); 1946 nullstartblock((int)newlen));
1947 XFS_BMAP_TRACE_POST_UPDATE("LC|RC", ip, idx - 1, 1947 XFS_BMAP_TRACE_POST_UPDATE("LC|RC", ip, idx - 1,
1948 XFS_DATA_FORK); 1948 XFS_DATA_FORK);
1949 XFS_BMAP_TRACE_DELETE("LC|RC", ip, idx, 1, XFS_DATA_FORK); 1949 XFS_BMAP_TRACE_DELETE("LC|RC", ip, idx, 1, XFS_DATA_FORK);
@@ -1964,11 +1964,11 @@ xfs_bmap_add_extent_hole_delay(
1964 XFS_BMAP_TRACE_PRE_UPDATE("LC", ip, idx - 1, 1964 XFS_BMAP_TRACE_PRE_UPDATE("LC", ip, idx - 1,
1965 XFS_DATA_FORK); 1965 XFS_DATA_FORK);
1966 xfs_bmbt_set_blockcount(xfs_iext_get_ext(ifp, idx - 1), temp); 1966 xfs_bmbt_set_blockcount(xfs_iext_get_ext(ifp, idx - 1), temp);
1967 oldlen = STARTBLOCKVAL(left.br_startblock) + 1967 oldlen = startblockval(left.br_startblock) +
1968 STARTBLOCKVAL(new->br_startblock); 1968 startblockval(new->br_startblock);
1969 newlen = xfs_bmap_worst_indlen(ip, temp); 1969 newlen = xfs_bmap_worst_indlen(ip, temp);
1970 xfs_bmbt_set_startblock(xfs_iext_get_ext(ifp, idx - 1), 1970 xfs_bmbt_set_startblock(xfs_iext_get_ext(ifp, idx - 1),
1971 NULLSTARTBLOCK((int)newlen)); 1971 nullstartblock((int)newlen));
1972 XFS_BMAP_TRACE_POST_UPDATE("LC", ip, idx - 1, 1972 XFS_BMAP_TRACE_POST_UPDATE("LC", ip, idx - 1,
1973 XFS_DATA_FORK); 1973 XFS_DATA_FORK);
1974 ip->i_df.if_lastex = idx - 1; 1974 ip->i_df.if_lastex = idx - 1;
@@ -1985,11 +1985,11 @@ xfs_bmap_add_extent_hole_delay(
1985 */ 1985 */
1986 XFS_BMAP_TRACE_PRE_UPDATE("RC", ip, idx, XFS_DATA_FORK); 1986 XFS_BMAP_TRACE_PRE_UPDATE("RC", ip, idx, XFS_DATA_FORK);
1987 temp = new->br_blockcount + right.br_blockcount; 1987 temp = new->br_blockcount + right.br_blockcount;
1988 oldlen = STARTBLOCKVAL(new->br_startblock) + 1988 oldlen = startblockval(new->br_startblock) +
1989 STARTBLOCKVAL(right.br_startblock); 1989 startblockval(right.br_startblock);
1990 newlen = xfs_bmap_worst_indlen(ip, temp); 1990 newlen = xfs_bmap_worst_indlen(ip, temp);
1991 xfs_bmbt_set_allf(ep, new->br_startoff, 1991 xfs_bmbt_set_allf(ep, new->br_startoff,
1992 NULLSTARTBLOCK((int)newlen), temp, right.br_state); 1992 nullstartblock((int)newlen), temp, right.br_state);
1993 XFS_BMAP_TRACE_POST_UPDATE("RC", ip, idx, XFS_DATA_FORK); 1993 XFS_BMAP_TRACE_POST_UPDATE("RC", ip, idx, XFS_DATA_FORK);
1994 ip->i_df.if_lastex = idx; 1994 ip->i_df.if_lastex = idx;
1995 /* DELTA: One in-core extent grew into a hole. */ 1995 /* DELTA: One in-core extent grew into a hole. */
@@ -2085,7 +2085,7 @@ xfs_bmap_add_extent_hole_real(
2085 */ 2085 */
2086 if (STATE_SET_TEST(LEFT_VALID, idx > 0)) { 2086 if (STATE_SET_TEST(LEFT_VALID, idx > 0)) {
2087 xfs_bmbt_get_all(xfs_iext_get_ext(ifp, idx - 1), &left); 2087 xfs_bmbt_get_all(xfs_iext_get_ext(ifp, idx - 1), &left);
2088 STATE_SET(LEFT_DELAY, ISNULLSTARTBLOCK(left.br_startblock)); 2088 STATE_SET(LEFT_DELAY, isnullstartblock(left.br_startblock));
2089 } 2089 }
2090 /* 2090 /*
2091 * Check and set flags if this segment has a current value. 2091 * Check and set flags if this segment has a current value.
@@ -2095,7 +2095,7 @@ xfs_bmap_add_extent_hole_real(
2095 idx < 2095 idx <
2096 ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t))) { 2096 ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t))) {
2097 xfs_bmbt_get_all(ep, &right); 2097 xfs_bmbt_get_all(ep, &right);
2098 STATE_SET(RIGHT_DELAY, ISNULLSTARTBLOCK(right.br_startblock)); 2098 STATE_SET(RIGHT_DELAY, isnullstartblock(right.br_startblock));
2099 } 2099 }
2100 /* 2100 /*
2101 * We're inserting a real allocation between "left" and "right". 2101 * We're inserting a real allocation between "left" and "right".
@@ -2143,7 +2143,7 @@ xfs_bmap_add_extent_hole_real(
2143 XFS_IFORK_NEXT_SET(ip, whichfork, 2143 XFS_IFORK_NEXT_SET(ip, whichfork,
2144 XFS_IFORK_NEXTENTS(ip, whichfork) - 1); 2144 XFS_IFORK_NEXTENTS(ip, whichfork) - 1);
2145 if (cur == NULL) { 2145 if (cur == NULL) {
2146 rval = XFS_ILOG_CORE | XFS_ILOG_FEXT(whichfork); 2146 rval = XFS_ILOG_CORE | xfs_ilog_fext(whichfork);
2147 } else { 2147 } else {
2148 rval = XFS_ILOG_CORE; 2148 rval = XFS_ILOG_CORE;
2149 if ((error = xfs_bmbt_lookup_eq(cur, 2149 if ((error = xfs_bmbt_lookup_eq(cur,
@@ -2185,7 +2185,7 @@ xfs_bmap_add_extent_hole_real(
2185 XFS_BMAP_TRACE_POST_UPDATE("LC", ip, idx - 1, whichfork); 2185 XFS_BMAP_TRACE_POST_UPDATE("LC", ip, idx - 1, whichfork);
2186 ifp->if_lastex = idx - 1; 2186 ifp->if_lastex = idx - 1;
2187 if (cur == NULL) { 2187 if (cur == NULL) {
2188 rval = XFS_ILOG_FEXT(whichfork); 2188 rval = xfs_ilog_fext(whichfork);
2189 } else { 2189 } else {
2190 rval = 0; 2190 rval = 0;
2191 if ((error = xfs_bmbt_lookup_eq(cur, 2191 if ((error = xfs_bmbt_lookup_eq(cur,
@@ -2220,7 +2220,7 @@ xfs_bmap_add_extent_hole_real(
2220 XFS_BMAP_TRACE_POST_UPDATE("RC", ip, idx, whichfork); 2220 XFS_BMAP_TRACE_POST_UPDATE("RC", ip, idx, whichfork);
2221 ifp->if_lastex = idx; 2221 ifp->if_lastex = idx;
2222 if (cur == NULL) { 2222 if (cur == NULL) {
2223 rval = XFS_ILOG_FEXT(whichfork); 2223 rval = xfs_ilog_fext(whichfork);
2224 } else { 2224 } else {
2225 rval = 0; 2225 rval = 0;
2226 if ((error = xfs_bmbt_lookup_eq(cur, 2226 if ((error = xfs_bmbt_lookup_eq(cur,
@@ -2254,7 +2254,7 @@ xfs_bmap_add_extent_hole_real(
2254 XFS_IFORK_NEXT_SET(ip, whichfork, 2254 XFS_IFORK_NEXT_SET(ip, whichfork,
2255 XFS_IFORK_NEXTENTS(ip, whichfork) + 1); 2255 XFS_IFORK_NEXTENTS(ip, whichfork) + 1);
2256 if (cur == NULL) { 2256 if (cur == NULL) {
2257 rval = XFS_ILOG_CORE | XFS_ILOG_FEXT(whichfork); 2257 rval = XFS_ILOG_CORE | xfs_ilog_fext(whichfork);
2258 } else { 2258 } else {
2259 rval = XFS_ILOG_CORE; 2259 rval = XFS_ILOG_CORE;
2260 if ((error = xfs_bmbt_lookup_eq(cur, 2260 if ((error = xfs_bmbt_lookup_eq(cur,
@@ -2482,7 +2482,7 @@ xfs_bmap_adjacent(
2482 * try to use it's last block as our starting point. 2482 * try to use it's last block as our starting point.
2483 */ 2483 */
2484 if (ap->eof && ap->prevp->br_startoff != NULLFILEOFF && 2484 if (ap->eof && ap->prevp->br_startoff != NULLFILEOFF &&
2485 !ISNULLSTARTBLOCK(ap->prevp->br_startblock) && 2485 !isnullstartblock(ap->prevp->br_startblock) &&
2486 ISVALID(ap->prevp->br_startblock + ap->prevp->br_blockcount, 2486 ISVALID(ap->prevp->br_startblock + ap->prevp->br_blockcount,
2487 ap->prevp->br_startblock)) { 2487 ap->prevp->br_startblock)) {
2488 ap->rval = ap->prevp->br_startblock + ap->prevp->br_blockcount; 2488 ap->rval = ap->prevp->br_startblock + ap->prevp->br_blockcount;
@@ -2511,7 +2511,7 @@ xfs_bmap_adjacent(
2511 * start block based on it. 2511 * start block based on it.
2512 */ 2512 */
2513 if (ap->prevp->br_startoff != NULLFILEOFF && 2513 if (ap->prevp->br_startoff != NULLFILEOFF &&
2514 !ISNULLSTARTBLOCK(ap->prevp->br_startblock) && 2514 !isnullstartblock(ap->prevp->br_startblock) &&
2515 (prevbno = ap->prevp->br_startblock + 2515 (prevbno = ap->prevp->br_startblock +
2516 ap->prevp->br_blockcount) && 2516 ap->prevp->br_blockcount) &&
2517 ISVALID(prevbno, ap->prevp->br_startblock)) { 2517 ISVALID(prevbno, ap->prevp->br_startblock)) {
@@ -2552,7 +2552,7 @@ xfs_bmap_adjacent(
2552 * If there's a following (right) block, select a requested 2552 * If there's a following (right) block, select a requested
2553 * start block based on it. 2553 * start block based on it.
2554 */ 2554 */
2555 if (!ISNULLSTARTBLOCK(ap->gotp->br_startblock)) { 2555 if (!isnullstartblock(ap->gotp->br_startblock)) {
2556 /* 2556 /*
2557 * Calculate gap to start of next block. 2557 * Calculate gap to start of next block.
2558 */ 2558 */
@@ -3082,7 +3082,7 @@ xfs_bmap_btree_to_extents(
3082 ASSERT(ifp->if_broot == NULL); 3082 ASSERT(ifp->if_broot == NULL);
3083 ASSERT((ifp->if_flags & XFS_IFBROOT) == 0); 3083 ASSERT((ifp->if_flags & XFS_IFBROOT) == 0);
3084 XFS_IFORK_FMT_SET(ip, whichfork, XFS_DINODE_FMT_EXTENTS); 3084 XFS_IFORK_FMT_SET(ip, whichfork, XFS_DINODE_FMT_EXTENTS);
3085 *logflagsp = XFS_ILOG_CORE | XFS_ILOG_FEXT(whichfork); 3085 *logflagsp = XFS_ILOG_CORE | xfs_ilog_fext(whichfork);
3086 return 0; 3086 return 0;
3087} 3087}
3088 3088
@@ -3136,8 +3136,8 @@ xfs_bmap_del_extent(
3136 del_endoff = del->br_startoff + del->br_blockcount; 3136 del_endoff = del->br_startoff + del->br_blockcount;
3137 got_endoff = got.br_startoff + got.br_blockcount; 3137 got_endoff = got.br_startoff + got.br_blockcount;
3138 ASSERT(got_endoff >= del_endoff); 3138 ASSERT(got_endoff >= del_endoff);
3139 delay = ISNULLSTARTBLOCK(got.br_startblock); 3139 delay = isnullstartblock(got.br_startblock);
3140 ASSERT(ISNULLSTARTBLOCK(del->br_startblock) == delay); 3140 ASSERT(isnullstartblock(del->br_startblock) == delay);
3141 flags = 0; 3141 flags = 0;
3142 qfield = 0; 3142 qfield = 0;
3143 error = 0; 3143 error = 0;
@@ -3189,7 +3189,7 @@ xfs_bmap_del_extent(
3189 } 3189 }
3190 da_old = da_new = 0; 3190 da_old = da_new = 0;
3191 } else { 3191 } else {
3192 da_old = STARTBLOCKVAL(got.br_startblock); 3192 da_old = startblockval(got.br_startblock);
3193 da_new = 0; 3193 da_new = 0;
3194 nblks = 0; 3194 nblks = 0;
3195 do_fx = 0; 3195 do_fx = 0;
@@ -3213,7 +3213,7 @@ xfs_bmap_del_extent(
3213 XFS_IFORK_NEXTENTS(ip, whichfork) - 1); 3213 XFS_IFORK_NEXTENTS(ip, whichfork) - 1);
3214 flags |= XFS_ILOG_CORE; 3214 flags |= XFS_ILOG_CORE;
3215 if (!cur) { 3215 if (!cur) {
3216 flags |= XFS_ILOG_FEXT(whichfork); 3216 flags |= xfs_ilog_fext(whichfork);
3217 break; 3217 break;
3218 } 3218 }
3219 if ((error = xfs_btree_delete(cur, &i))) 3219 if ((error = xfs_btree_delete(cur, &i)))
@@ -3233,7 +3233,7 @@ xfs_bmap_del_extent(
3233 if (delay) { 3233 if (delay) {
3234 temp = XFS_FILBLKS_MIN(xfs_bmap_worst_indlen(ip, temp), 3234 temp = XFS_FILBLKS_MIN(xfs_bmap_worst_indlen(ip, temp),
3235 da_old); 3235 da_old);
3236 xfs_bmbt_set_startblock(ep, NULLSTARTBLOCK((int)temp)); 3236 xfs_bmbt_set_startblock(ep, nullstartblock((int)temp));
3237 XFS_BMAP_TRACE_POST_UPDATE("2", ip, idx, 3237 XFS_BMAP_TRACE_POST_UPDATE("2", ip, idx,
3238 whichfork); 3238 whichfork);
3239 da_new = temp; 3239 da_new = temp;
@@ -3242,7 +3242,7 @@ xfs_bmap_del_extent(
3242 xfs_bmbt_set_startblock(ep, del_endblock); 3242 xfs_bmbt_set_startblock(ep, del_endblock);
3243 XFS_BMAP_TRACE_POST_UPDATE("2", ip, idx, whichfork); 3243 XFS_BMAP_TRACE_POST_UPDATE("2", ip, idx, whichfork);
3244 if (!cur) { 3244 if (!cur) {
3245 flags |= XFS_ILOG_FEXT(whichfork); 3245 flags |= xfs_ilog_fext(whichfork);
3246 break; 3246 break;
3247 } 3247 }
3248 if ((error = xfs_bmbt_update(cur, del_endoff, del_endblock, 3248 if ((error = xfs_bmbt_update(cur, del_endoff, del_endblock,
@@ -3262,7 +3262,7 @@ xfs_bmap_del_extent(
3262 if (delay) { 3262 if (delay) {
3263 temp = XFS_FILBLKS_MIN(xfs_bmap_worst_indlen(ip, temp), 3263 temp = XFS_FILBLKS_MIN(xfs_bmap_worst_indlen(ip, temp),
3264 da_old); 3264 da_old);
3265 xfs_bmbt_set_startblock(ep, NULLSTARTBLOCK((int)temp)); 3265 xfs_bmbt_set_startblock(ep, nullstartblock((int)temp));
3266 XFS_BMAP_TRACE_POST_UPDATE("1", ip, idx, 3266 XFS_BMAP_TRACE_POST_UPDATE("1", ip, idx,
3267 whichfork); 3267 whichfork);
3268 da_new = temp; 3268 da_new = temp;
@@ -3270,7 +3270,7 @@ xfs_bmap_del_extent(
3270 } 3270 }
3271 XFS_BMAP_TRACE_POST_UPDATE("1", ip, idx, whichfork); 3271 XFS_BMAP_TRACE_POST_UPDATE("1", ip, idx, whichfork);
3272 if (!cur) { 3272 if (!cur) {
3273 flags |= XFS_ILOG_FEXT(whichfork); 3273 flags |= xfs_ilog_fext(whichfork);
3274 break; 3274 break;
3275 } 3275 }
3276 if ((error = xfs_bmbt_update(cur, got.br_startoff, 3276 if ((error = xfs_bmbt_update(cur, got.br_startoff,
@@ -3345,22 +3345,22 @@ xfs_bmap_del_extent(
3345 } 3345 }
3346 XFS_WANT_CORRUPTED_GOTO(i == 1, done); 3346 XFS_WANT_CORRUPTED_GOTO(i == 1, done);
3347 } else 3347 } else
3348 flags |= XFS_ILOG_FEXT(whichfork); 3348 flags |= xfs_ilog_fext(whichfork);
3349 XFS_IFORK_NEXT_SET(ip, whichfork, 3349 XFS_IFORK_NEXT_SET(ip, whichfork,
3350 XFS_IFORK_NEXTENTS(ip, whichfork) + 1); 3350 XFS_IFORK_NEXTENTS(ip, whichfork) + 1);
3351 } else { 3351 } else {
3352 ASSERT(whichfork == XFS_DATA_FORK); 3352 ASSERT(whichfork == XFS_DATA_FORK);
3353 temp = xfs_bmap_worst_indlen(ip, temp); 3353 temp = xfs_bmap_worst_indlen(ip, temp);
3354 xfs_bmbt_set_startblock(ep, NULLSTARTBLOCK((int)temp)); 3354 xfs_bmbt_set_startblock(ep, nullstartblock((int)temp));
3355 temp2 = xfs_bmap_worst_indlen(ip, temp2); 3355 temp2 = xfs_bmap_worst_indlen(ip, temp2);
3356 new.br_startblock = NULLSTARTBLOCK((int)temp2); 3356 new.br_startblock = nullstartblock((int)temp2);
3357 da_new = temp + temp2; 3357 da_new = temp + temp2;
3358 while (da_new > da_old) { 3358 while (da_new > da_old) {
3359 if (temp) { 3359 if (temp) {
3360 temp--; 3360 temp--;
3361 da_new--; 3361 da_new--;
3362 xfs_bmbt_set_startblock(ep, 3362 xfs_bmbt_set_startblock(ep,
3363 NULLSTARTBLOCK((int)temp)); 3363 nullstartblock((int)temp));
3364 } 3364 }
3365 if (da_new == da_old) 3365 if (da_new == da_old)
3366 break; 3366 break;
@@ -3368,7 +3368,7 @@ xfs_bmap_del_extent(
3368 temp2--; 3368 temp2--;
3369 da_new--; 3369 da_new--;
3370 new.br_startblock = 3370 new.br_startblock =
3371 NULLSTARTBLOCK((int)temp2); 3371 nullstartblock((int)temp2);
3372 } 3372 }
3373 } 3373 }
3374 } 3374 }
@@ -3545,7 +3545,7 @@ xfs_bmap_extents_to_btree(
3545 nextents = ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t); 3545 nextents = ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t);
3546 for (cnt = i = 0; i < nextents; i++) { 3546 for (cnt = i = 0; i < nextents; i++) {
3547 ep = xfs_iext_get_ext(ifp, i); 3547 ep = xfs_iext_get_ext(ifp, i);
3548 if (!ISNULLSTARTBLOCK(xfs_bmbt_get_startblock(ep))) { 3548 if (!isnullstartblock(xfs_bmbt_get_startblock(ep))) {
3549 arp->l0 = cpu_to_be64(ep->l0); 3549 arp->l0 = cpu_to_be64(ep->l0);
3550 arp->l1 = cpu_to_be64(ep->l1); 3550 arp->l1 = cpu_to_be64(ep->l1);
3551 arp++; cnt++; 3551 arp++; cnt++;
@@ -3572,7 +3572,7 @@ xfs_bmap_extents_to_btree(
3572 xfs_btree_log_recs(cur, abp, 1, be16_to_cpu(ablock->bb_numrecs)); 3572 xfs_btree_log_recs(cur, abp, 1, be16_to_cpu(ablock->bb_numrecs));
3573 ASSERT(*curp == NULL); 3573 ASSERT(*curp == NULL);
3574 *curp = cur; 3574 *curp = cur;
3575 *logflagsp = XFS_ILOG_CORE | XFS_ILOG_FBROOT(whichfork); 3575 *logflagsp = XFS_ILOG_CORE | xfs_ilog_fbroot(whichfork);
3576 return 0; 3576 return 0;
3577} 3577}
3578 3578
@@ -3676,7 +3676,7 @@ xfs_bmap_local_to_extents(
3676 ip->i_d.di_nblocks = 1; 3676 ip->i_d.di_nblocks = 1;
3677 XFS_TRANS_MOD_DQUOT_BYINO(args.mp, tp, ip, 3677 XFS_TRANS_MOD_DQUOT_BYINO(args.mp, tp, ip,
3678 XFS_TRANS_DQ_BCOUNT, 1L); 3678 XFS_TRANS_DQ_BCOUNT, 1L);
3679 flags |= XFS_ILOG_FEXT(whichfork); 3679 flags |= xfs_ilog_fext(whichfork);
3680 } else { 3680 } else {
3681 ASSERT(XFS_IFORK_NEXTENTS(ip, whichfork) == 0); 3681 ASSERT(XFS_IFORK_NEXTENTS(ip, whichfork) == 0);
3682 xfs_bmap_forkoff_reset(ip->i_mount, ip, whichfork); 3682 xfs_bmap_forkoff_reset(ip->i_mount, ip, whichfork);
@@ -4082,7 +4082,7 @@ xfs_bmap_add_attrfork(
4082 XFS_IFORK_ASIZE(ip) / (uint)sizeof(xfs_bmbt_rec_t); 4082 XFS_IFORK_ASIZE(ip) / (uint)sizeof(xfs_bmbt_rec_t);
4083 ip->i_afp->if_flags = XFS_IFEXTENTS; 4083 ip->i_afp->if_flags = XFS_IFEXTENTS;
4084 logflags = 0; 4084 logflags = 0;
4085 XFS_BMAP_INIT(&flist, &firstblock); 4085 xfs_bmap_init(&flist, &firstblock);
4086 switch (ip->i_d.di_format) { 4086 switch (ip->i_d.di_format) {
4087 case XFS_DINODE_FMT_LOCAL: 4087 case XFS_DINODE_FMT_LOCAL:
4088 error = xfs_bmap_add_attrfork_local(tp, ip, &firstblock, &flist, 4088 error = xfs_bmap_add_attrfork_local(tp, ip, &firstblock, &flist,
@@ -4162,7 +4162,7 @@ xfs_bmap_add_free(
4162 ASSERT(bno != NULLFSBLOCK); 4162 ASSERT(bno != NULLFSBLOCK);
4163 ASSERT(len > 0); 4163 ASSERT(len > 0);
4164 ASSERT(len <= MAXEXTLEN); 4164 ASSERT(len <= MAXEXTLEN);
4165 ASSERT(!ISNULLSTARTBLOCK(bno)); 4165 ASSERT(!isnullstartblock(bno));
4166 agno = XFS_FSB_TO_AGNO(mp, bno); 4166 agno = XFS_FSB_TO_AGNO(mp, bno);
4167 agbno = XFS_FSB_TO_AGBNO(mp, bno); 4167 agbno = XFS_FSB_TO_AGBNO(mp, bno);
4168 ASSERT(agno < mp->m_sb.sb_agcount); 4168 ASSERT(agno < mp->m_sb.sb_agcount);
@@ -4909,7 +4909,7 @@ xfs_bmapi(
4909 got.br_startoff = end; 4909 got.br_startoff = end;
4910 inhole = eof || got.br_startoff > bno; 4910 inhole = eof || got.br_startoff > bno;
4911 wasdelay = wr && !inhole && !(flags & XFS_BMAPI_DELAY) && 4911 wasdelay = wr && !inhole && !(flags & XFS_BMAPI_DELAY) &&
4912 ISNULLSTARTBLOCK(got.br_startblock); 4912 isnullstartblock(got.br_startblock);
4913 /* 4913 /*
4914 * First, deal with the hole before the allocated space 4914 * First, deal with the hole before the allocated space
4915 * that we found, if any. 4915 * that we found, if any.
@@ -5028,7 +5028,7 @@ xfs_bmapi(
5028 } 5028 }
5029 5029
5030 ip->i_delayed_blks += alen; 5030 ip->i_delayed_blks += alen;
5031 abno = NULLSTARTBLOCK(indlen); 5031 abno = nullstartblock(indlen);
5032 } else { 5032 } else {
5033 /* 5033 /*
5034 * If first time, allocate and fill in 5034 * If first time, allocate and fill in
@@ -5144,8 +5144,8 @@ xfs_bmapi(
5144 aoff + alen); 5144 aoff + alen);
5145#ifdef DEBUG 5145#ifdef DEBUG
5146 if (flags & XFS_BMAPI_DELAY) { 5146 if (flags & XFS_BMAPI_DELAY) {
5147 ASSERT(ISNULLSTARTBLOCK(got.br_startblock)); 5147 ASSERT(isnullstartblock(got.br_startblock));
5148 ASSERT(STARTBLOCKVAL(got.br_startblock) > 0); 5148 ASSERT(startblockval(got.br_startblock) > 0);
5149 } 5149 }
5150 ASSERT(got.br_state == XFS_EXT_NORM || 5150 ASSERT(got.br_state == XFS_EXT_NORM ||
5151 got.br_state == XFS_EXT_UNWRITTEN); 5151 got.br_state == XFS_EXT_UNWRITTEN);
@@ -5179,7 +5179,7 @@ xfs_bmapi(
5179 ASSERT((bno >= obno) || (n == 0)); 5179 ASSERT((bno >= obno) || (n == 0));
5180 ASSERT(bno < end); 5180 ASSERT(bno < end);
5181 mval->br_startoff = bno; 5181 mval->br_startoff = bno;
5182 if (ISNULLSTARTBLOCK(got.br_startblock)) { 5182 if (isnullstartblock(got.br_startblock)) {
5183 ASSERT(!wr || (flags & XFS_BMAPI_DELAY)); 5183 ASSERT(!wr || (flags & XFS_BMAPI_DELAY));
5184 mval->br_startblock = DELAYSTARTBLOCK; 5184 mval->br_startblock = DELAYSTARTBLOCK;
5185 } else 5185 } else
@@ -5201,7 +5201,7 @@ xfs_bmapi(
5201 ASSERT(mval->br_blockcount <= len); 5201 ASSERT(mval->br_blockcount <= len);
5202 } else { 5202 } else {
5203 *mval = got; 5203 *mval = got;
5204 if (ISNULLSTARTBLOCK(mval->br_startblock)) { 5204 if (isnullstartblock(mval->br_startblock)) {
5205 ASSERT(!wr || (flags & XFS_BMAPI_DELAY)); 5205 ASSERT(!wr || (flags & XFS_BMAPI_DELAY));
5206 mval->br_startblock = DELAYSTARTBLOCK; 5206 mval->br_startblock = DELAYSTARTBLOCK;
5207 } 5207 }
@@ -5329,12 +5329,12 @@ error0:
5329 * Log everything. Do this after conversion, there's no point in 5329 * Log everything. Do this after conversion, there's no point in
5330 * logging the extent records if we've converted to btree format. 5330 * logging the extent records if we've converted to btree format.
5331 */ 5331 */
5332 if ((logflags & XFS_ILOG_FEXT(whichfork)) && 5332 if ((logflags & xfs_ilog_fext(whichfork)) &&
5333 XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_EXTENTS) 5333 XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_EXTENTS)
5334 logflags &= ~XFS_ILOG_FEXT(whichfork); 5334 logflags &= ~xfs_ilog_fext(whichfork);
5335 else if ((logflags & XFS_ILOG_FBROOT(whichfork)) && 5335 else if ((logflags & xfs_ilog_fbroot(whichfork)) &&
5336 XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_BTREE) 5336 XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_BTREE)
5337 logflags &= ~XFS_ILOG_FBROOT(whichfork); 5337 logflags &= ~xfs_ilog_fbroot(whichfork);
5338 /* 5338 /*
5339 * Log whatever the flags say, even if error. Otherwise we might miss 5339 * Log whatever the flags say, even if error. Otherwise we might miss
5340 * detecting a case where the data is changed, there's an error, 5340 * detecting a case where the data is changed, there's an error,
@@ -5411,7 +5411,7 @@ xfs_bmapi_single(
5411 *fsb = NULLFSBLOCK; 5411 *fsb = NULLFSBLOCK;
5412 return 0; 5412 return 0;
5413 } 5413 }
5414 ASSERT(!ISNULLSTARTBLOCK(got.br_startblock)); 5414 ASSERT(!isnullstartblock(got.br_startblock));
5415 ASSERT(bno < got.br_startoff + got.br_blockcount); 5415 ASSERT(bno < got.br_startoff + got.br_blockcount);
5416 *fsb = got.br_startblock + (bno - got.br_startoff); 5416 *fsb = got.br_startblock + (bno - got.br_startoff);
5417 ifp->if_lastex = lastx; 5417 ifp->if_lastex = lastx;
@@ -5543,7 +5543,7 @@ xfs_bunmapi(
5543 */ 5543 */
5544 ASSERT(ep != NULL); 5544 ASSERT(ep != NULL);
5545 del = got; 5545 del = got;
5546 wasdel = ISNULLSTARTBLOCK(del.br_startblock); 5546 wasdel = isnullstartblock(del.br_startblock);
5547 if (got.br_startoff < start) { 5547 if (got.br_startoff < start) {
5548 del.br_startoff = start; 5548 del.br_startoff = start;
5549 del.br_blockcount -= start - got.br_startoff; 5549 del.br_blockcount -= start - got.br_startoff;
@@ -5638,7 +5638,7 @@ xfs_bunmapi(
5638 xfs_bmbt_get_all(xfs_iext_get_ext(ifp, 5638 xfs_bmbt_get_all(xfs_iext_get_ext(ifp,
5639 lastx - 1), &prev); 5639 lastx - 1), &prev);
5640 ASSERT(prev.br_state == XFS_EXT_NORM); 5640 ASSERT(prev.br_state == XFS_EXT_NORM);
5641 ASSERT(!ISNULLSTARTBLOCK(prev.br_startblock)); 5641 ASSERT(!isnullstartblock(prev.br_startblock));
5642 ASSERT(del.br_startblock == 5642 ASSERT(del.br_startblock ==
5643 prev.br_startblock + prev.br_blockcount); 5643 prev.br_startblock + prev.br_blockcount);
5644 if (prev.br_startoff < start) { 5644 if (prev.br_startoff < start) {
@@ -5666,7 +5666,7 @@ xfs_bunmapi(
5666 } 5666 }
5667 } 5667 }
5668 if (wasdel) { 5668 if (wasdel) {
5669 ASSERT(STARTBLOCKVAL(del.br_startblock) > 0); 5669 ASSERT(startblockval(del.br_startblock) > 0);
5670 /* Update realtime/data freespace, unreserve quota */ 5670 /* Update realtime/data freespace, unreserve quota */
5671 if (isrt) { 5671 if (isrt) {
5672 xfs_filblks_t rtexts; 5672 xfs_filblks_t rtexts;
@@ -5782,12 +5782,12 @@ error0:
5782 * Log everything. Do this after conversion, there's no point in 5782 * Log everything. Do this after conversion, there's no point in
5783 * logging the extent records if we've converted to btree format. 5783 * logging the extent records if we've converted to btree format.
5784 */ 5784 */
5785 if ((logflags & XFS_ILOG_FEXT(whichfork)) && 5785 if ((logflags & xfs_ilog_fext(whichfork)) &&
5786 XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_EXTENTS) 5786 XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_EXTENTS)
5787 logflags &= ~XFS_ILOG_FEXT(whichfork); 5787 logflags &= ~xfs_ilog_fext(whichfork);
5788 else if ((logflags & XFS_ILOG_FBROOT(whichfork)) && 5788 else if ((logflags & xfs_ilog_fbroot(whichfork)) &&
5789 XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_BTREE) 5789 XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_BTREE)
5790 logflags &= ~XFS_ILOG_FBROOT(whichfork); 5790 logflags &= ~xfs_ilog_fbroot(whichfork);
5791 /* 5791 /*
5792 * Log inode even in the error case, if the transaction 5792 * Log inode even in the error case, if the transaction
5793 * is dirty we'll need to shut down the filesystem. 5793 * is dirty we'll need to shut down the filesystem.
@@ -5838,7 +5838,7 @@ xfs_getbmapx_fix_eof_hole(
5838 if (startblock == DELAYSTARTBLOCK) 5838 if (startblock == DELAYSTARTBLOCK)
5839 out->bmv_block = -2; 5839 out->bmv_block = -2;
5840 else 5840 else
5841 out->bmv_block = XFS_FSB_TO_DB(ip, startblock); 5841 out->bmv_block = xfs_fsb_to_db(ip, startblock);
5842 fileblock = XFS_BB_TO_FSB(ip->i_mount, out->bmv_offset); 5842 fileblock = XFS_BB_TO_FSB(ip->i_mount, out->bmv_offset);
5843 ifp = XFS_IFORK_PTR(ip, XFS_DATA_FORK); 5843 ifp = XFS_IFORK_PTR(ip, XFS_DATA_FORK);
5844 if (xfs_iext_bno_to_ext(ifp, fileblock, &lastx) && 5844 if (xfs_iext_bno_to_ext(ifp, fileblock, &lastx) &&
@@ -5979,7 +5979,7 @@ xfs_getbmap(
5979 if (nex > XFS_IFORK_NEXTENTS(ip, whichfork) * 2 + 1) 5979 if (nex > XFS_IFORK_NEXTENTS(ip, whichfork) * 2 + 1)
5980 nex = XFS_IFORK_NEXTENTS(ip, whichfork) * 2 + 1; 5980 nex = XFS_IFORK_NEXTENTS(ip, whichfork) * 2 + 1;
5981 5981
5982 bmapi_flags = XFS_BMAPI_AFLAG(whichfork) | 5982 bmapi_flags = xfs_bmapi_aflag(whichfork) |
5983 ((iflags & BMV_IF_PREALLOC) ? 0 : XFS_BMAPI_IGSTATE); 5983 ((iflags & BMV_IF_PREALLOC) ? 0 : XFS_BMAPI_IGSTATE);
5984 5984
5985 /* 5985 /*
@@ -6098,7 +6098,7 @@ xfs_bmap_isaeof(
6098 */ 6098 */
6099 *aeof = (off >= s.br_startoff && 6099 *aeof = (off >= s.br_startoff &&
6100 off < s.br_startoff + s.br_blockcount && 6100 off < s.br_startoff + s.br_blockcount &&
6101 ISNULLSTARTBLOCK(s.br_startblock)) || 6101 isnullstartblock(s.br_startblock)) ||
6102 off >= s.br_startoff + s.br_blockcount; 6102 off >= s.br_startoff + s.br_blockcount;
6103 return 0; 6103 return 0;
6104} 6104}
diff --git a/fs/xfs/xfs_bmap.h b/fs/xfs/xfs_bmap.h
index 284571c05ed0..be2979d88d32 100644
--- a/fs/xfs/xfs_bmap.h
+++ b/fs/xfs/xfs_bmap.h
@@ -95,7 +95,6 @@ typedef struct xfs_bmap_free
95 /* need write cache flushing and no */ 95 /* need write cache flushing and no */
96 /* additional allocation alignments */ 96 /* additional allocation alignments */
97 97
98#define XFS_BMAPI_AFLAG(w) xfs_bmapi_aflag(w)
99static inline int xfs_bmapi_aflag(int w) 98static inline int xfs_bmapi_aflag(int w)
100{ 99{
101 return (w == XFS_ATTR_FORK ? XFS_BMAPI_ATTRFORK : 0); 100 return (w == XFS_ATTR_FORK ? XFS_BMAPI_ATTRFORK : 0);
@@ -107,7 +106,6 @@ static inline int xfs_bmapi_aflag(int w)
107#define DELAYSTARTBLOCK ((xfs_fsblock_t)-1LL) 106#define DELAYSTARTBLOCK ((xfs_fsblock_t)-1LL)
108#define HOLESTARTBLOCK ((xfs_fsblock_t)-2LL) 107#define HOLESTARTBLOCK ((xfs_fsblock_t)-2LL)
109 108
110#define XFS_BMAP_INIT(flp,fbp) xfs_bmap_init(flp,fbp)
111static inline void xfs_bmap_init(xfs_bmap_free_t *flp, xfs_fsblock_t *fbp) 109static inline void xfs_bmap_init(xfs_bmap_free_t *flp, xfs_fsblock_t *fbp)
112{ 110{
113 ((flp)->xbf_first = NULL, (flp)->xbf_count = 0, \ 111 ((flp)->xbf_first = NULL, (flp)->xbf_count = 0, \
diff --git a/fs/xfs/xfs_bmap_btree.c b/fs/xfs/xfs_bmap_btree.c
index 8f1ec73725d3..0760d352586f 100644
--- a/fs/xfs/xfs_bmap_btree.c
+++ b/fs/xfs/xfs_bmap_btree.c
@@ -110,25 +110,25 @@ __xfs_bmbt_get_all(
110 110
111 ext_flag = (int)(l0 >> (64 - BMBT_EXNTFLAG_BITLEN)); 111 ext_flag = (int)(l0 >> (64 - BMBT_EXNTFLAG_BITLEN));
112 s->br_startoff = ((xfs_fileoff_t)l0 & 112 s->br_startoff = ((xfs_fileoff_t)l0 &
113 XFS_MASK64LO(64 - BMBT_EXNTFLAG_BITLEN)) >> 9; 113 xfs_mask64lo(64 - BMBT_EXNTFLAG_BITLEN)) >> 9;
114#if XFS_BIG_BLKNOS 114#if XFS_BIG_BLKNOS
115 s->br_startblock = (((xfs_fsblock_t)l0 & XFS_MASK64LO(9)) << 43) | 115 s->br_startblock = (((xfs_fsblock_t)l0 & xfs_mask64lo(9)) << 43) |
116 (((xfs_fsblock_t)l1) >> 21); 116 (((xfs_fsblock_t)l1) >> 21);
117#else 117#else
118#ifdef DEBUG 118#ifdef DEBUG
119 { 119 {
120 xfs_dfsbno_t b; 120 xfs_dfsbno_t b;
121 121
122 b = (((xfs_dfsbno_t)l0 & XFS_MASK64LO(9)) << 43) | 122 b = (((xfs_dfsbno_t)l0 & xfs_mask64lo(9)) << 43) |
123 (((xfs_dfsbno_t)l1) >> 21); 123 (((xfs_dfsbno_t)l1) >> 21);
124 ASSERT((b >> 32) == 0 || ISNULLDSTARTBLOCK(b)); 124 ASSERT((b >> 32) == 0 || isnulldstartblock(b));
125 s->br_startblock = (xfs_fsblock_t)b; 125 s->br_startblock = (xfs_fsblock_t)b;
126 } 126 }
127#else /* !DEBUG */ 127#else /* !DEBUG */
128 s->br_startblock = (xfs_fsblock_t)(((xfs_dfsbno_t)l1) >> 21); 128 s->br_startblock = (xfs_fsblock_t)(((xfs_dfsbno_t)l1) >> 21);
129#endif /* DEBUG */ 129#endif /* DEBUG */
130#endif /* XFS_BIG_BLKNOS */ 130#endif /* XFS_BIG_BLKNOS */
131 s->br_blockcount = (xfs_filblks_t)(l1 & XFS_MASK64LO(21)); 131 s->br_blockcount = (xfs_filblks_t)(l1 & xfs_mask64lo(21));
132 /* This is xfs_extent_state() in-line */ 132 /* This is xfs_extent_state() in-line */
133 if (ext_flag) { 133 if (ext_flag) {
134 ASSERT(s->br_blockcount != 0); /* saved for DMIG */ 134 ASSERT(s->br_blockcount != 0); /* saved for DMIG */
@@ -153,7 +153,7 @@ xfs_filblks_t
153xfs_bmbt_get_blockcount( 153xfs_bmbt_get_blockcount(
154 xfs_bmbt_rec_host_t *r) 154 xfs_bmbt_rec_host_t *r)
155{ 155{
156 return (xfs_filblks_t)(r->l1 & XFS_MASK64LO(21)); 156 return (xfs_filblks_t)(r->l1 & xfs_mask64lo(21));
157} 157}
158 158
159/* 159/*
@@ -164,15 +164,15 @@ xfs_bmbt_get_startblock(
164 xfs_bmbt_rec_host_t *r) 164 xfs_bmbt_rec_host_t *r)
165{ 165{
166#if XFS_BIG_BLKNOS 166#if XFS_BIG_BLKNOS
167 return (((xfs_fsblock_t)r->l0 & XFS_MASK64LO(9)) << 43) | 167 return (((xfs_fsblock_t)r->l0 & xfs_mask64lo(9)) << 43) |
168 (((xfs_fsblock_t)r->l1) >> 21); 168 (((xfs_fsblock_t)r->l1) >> 21);
169#else 169#else
170#ifdef DEBUG 170#ifdef DEBUG
171 xfs_dfsbno_t b; 171 xfs_dfsbno_t b;
172 172
173 b = (((xfs_dfsbno_t)r->l0 & XFS_MASK64LO(9)) << 43) | 173 b = (((xfs_dfsbno_t)r->l0 & xfs_mask64lo(9)) << 43) |
174 (((xfs_dfsbno_t)r->l1) >> 21); 174 (((xfs_dfsbno_t)r->l1) >> 21);
175 ASSERT((b >> 32) == 0 || ISNULLDSTARTBLOCK(b)); 175 ASSERT((b >> 32) == 0 || isnulldstartblock(b));
176 return (xfs_fsblock_t)b; 176 return (xfs_fsblock_t)b;
177#else /* !DEBUG */ 177#else /* !DEBUG */
178 return (xfs_fsblock_t)(((xfs_dfsbno_t)r->l1) >> 21); 178 return (xfs_fsblock_t)(((xfs_dfsbno_t)r->l1) >> 21);
@@ -188,7 +188,7 @@ xfs_bmbt_get_startoff(
188 xfs_bmbt_rec_host_t *r) 188 xfs_bmbt_rec_host_t *r)
189{ 189{
190 return ((xfs_fileoff_t)r->l0 & 190 return ((xfs_fileoff_t)r->l0 &
191 XFS_MASK64LO(64 - BMBT_EXNTFLAG_BITLEN)) >> 9; 191 xfs_mask64lo(64 - BMBT_EXNTFLAG_BITLEN)) >> 9;
192} 192}
193 193
194xfs_exntst_t 194xfs_exntst_t
@@ -219,7 +219,7 @@ xfs_filblks_t
219xfs_bmbt_disk_get_blockcount( 219xfs_bmbt_disk_get_blockcount(
220 xfs_bmbt_rec_t *r) 220 xfs_bmbt_rec_t *r)
221{ 221{
222 return (xfs_filblks_t)(be64_to_cpu(r->l1) & XFS_MASK64LO(21)); 222 return (xfs_filblks_t)(be64_to_cpu(r->l1) & xfs_mask64lo(21));
223} 223}
224 224
225/* 225/*
@@ -230,7 +230,7 @@ xfs_bmbt_disk_get_startoff(
230 xfs_bmbt_rec_t *r) 230 xfs_bmbt_rec_t *r)
231{ 231{
232 return ((xfs_fileoff_t)be64_to_cpu(r->l0) & 232 return ((xfs_fileoff_t)be64_to_cpu(r->l0) &
233 XFS_MASK64LO(64 - BMBT_EXNTFLAG_BITLEN)) >> 9; 233 xfs_mask64lo(64 - BMBT_EXNTFLAG_BITLEN)) >> 9;
234} 234}
235 235
236 236
@@ -248,33 +248,33 @@ xfs_bmbt_set_allf(
248 int extent_flag = (state == XFS_EXT_NORM) ? 0 : 1; 248 int extent_flag = (state == XFS_EXT_NORM) ? 0 : 1;
249 249
250 ASSERT(state == XFS_EXT_NORM || state == XFS_EXT_UNWRITTEN); 250 ASSERT(state == XFS_EXT_NORM || state == XFS_EXT_UNWRITTEN);
251 ASSERT((startoff & XFS_MASK64HI(64-BMBT_STARTOFF_BITLEN)) == 0); 251 ASSERT((startoff & xfs_mask64hi(64-BMBT_STARTOFF_BITLEN)) == 0);
252 ASSERT((blockcount & XFS_MASK64HI(64-BMBT_BLOCKCOUNT_BITLEN)) == 0); 252 ASSERT((blockcount & xfs_mask64hi(64-BMBT_BLOCKCOUNT_BITLEN)) == 0);
253 253
254#if XFS_BIG_BLKNOS 254#if XFS_BIG_BLKNOS
255 ASSERT((startblock & XFS_MASK64HI(64-BMBT_STARTBLOCK_BITLEN)) == 0); 255 ASSERT((startblock & xfs_mask64hi(64-BMBT_STARTBLOCK_BITLEN)) == 0);
256 256
257 r->l0 = ((xfs_bmbt_rec_base_t)extent_flag << 63) | 257 r->l0 = ((xfs_bmbt_rec_base_t)extent_flag << 63) |
258 ((xfs_bmbt_rec_base_t)startoff << 9) | 258 ((xfs_bmbt_rec_base_t)startoff << 9) |
259 ((xfs_bmbt_rec_base_t)startblock >> 43); 259 ((xfs_bmbt_rec_base_t)startblock >> 43);
260 r->l1 = ((xfs_bmbt_rec_base_t)startblock << 21) | 260 r->l1 = ((xfs_bmbt_rec_base_t)startblock << 21) |
261 ((xfs_bmbt_rec_base_t)blockcount & 261 ((xfs_bmbt_rec_base_t)blockcount &
262 (xfs_bmbt_rec_base_t)XFS_MASK64LO(21)); 262 (xfs_bmbt_rec_base_t)xfs_mask64lo(21));
263#else /* !XFS_BIG_BLKNOS */ 263#else /* !XFS_BIG_BLKNOS */
264 if (ISNULLSTARTBLOCK(startblock)) { 264 if (isnullstartblock(startblock)) {
265 r->l0 = ((xfs_bmbt_rec_base_t)extent_flag << 63) | 265 r->l0 = ((xfs_bmbt_rec_base_t)extent_flag << 63) |
266 ((xfs_bmbt_rec_base_t)startoff << 9) | 266 ((xfs_bmbt_rec_base_t)startoff << 9) |
267 (xfs_bmbt_rec_base_t)XFS_MASK64LO(9); 267 (xfs_bmbt_rec_base_t)xfs_mask64lo(9);
268 r->l1 = XFS_MASK64HI(11) | 268 r->l1 = xfs_mask64hi(11) |
269 ((xfs_bmbt_rec_base_t)startblock << 21) | 269 ((xfs_bmbt_rec_base_t)startblock << 21) |
270 ((xfs_bmbt_rec_base_t)blockcount & 270 ((xfs_bmbt_rec_base_t)blockcount &
271 (xfs_bmbt_rec_base_t)XFS_MASK64LO(21)); 271 (xfs_bmbt_rec_base_t)xfs_mask64lo(21));
272 } else { 272 } else {
273 r->l0 = ((xfs_bmbt_rec_base_t)extent_flag << 63) | 273 r->l0 = ((xfs_bmbt_rec_base_t)extent_flag << 63) |
274 ((xfs_bmbt_rec_base_t)startoff << 9); 274 ((xfs_bmbt_rec_base_t)startoff << 9);
275 r->l1 = ((xfs_bmbt_rec_base_t)startblock << 21) | 275 r->l1 = ((xfs_bmbt_rec_base_t)startblock << 21) |
276 ((xfs_bmbt_rec_base_t)blockcount & 276 ((xfs_bmbt_rec_base_t)blockcount &
277 (xfs_bmbt_rec_base_t)XFS_MASK64LO(21)); 277 (xfs_bmbt_rec_base_t)xfs_mask64lo(21));
278 } 278 }
279#endif /* XFS_BIG_BLKNOS */ 279#endif /* XFS_BIG_BLKNOS */
280} 280}
@@ -306,11 +306,11 @@ xfs_bmbt_disk_set_allf(
306 int extent_flag = (state == XFS_EXT_NORM) ? 0 : 1; 306 int extent_flag = (state == XFS_EXT_NORM) ? 0 : 1;
307 307
308 ASSERT(state == XFS_EXT_NORM || state == XFS_EXT_UNWRITTEN); 308 ASSERT(state == XFS_EXT_NORM || state == XFS_EXT_UNWRITTEN);
309 ASSERT((startoff & XFS_MASK64HI(64-BMBT_STARTOFF_BITLEN)) == 0); 309 ASSERT((startoff & xfs_mask64hi(64-BMBT_STARTOFF_BITLEN)) == 0);
310 ASSERT((blockcount & XFS_MASK64HI(64-BMBT_BLOCKCOUNT_BITLEN)) == 0); 310 ASSERT((blockcount & xfs_mask64hi(64-BMBT_BLOCKCOUNT_BITLEN)) == 0);
311 311
312#if XFS_BIG_BLKNOS 312#if XFS_BIG_BLKNOS
313 ASSERT((startblock & XFS_MASK64HI(64-BMBT_STARTBLOCK_BITLEN)) == 0); 313 ASSERT((startblock & xfs_mask64hi(64-BMBT_STARTBLOCK_BITLEN)) == 0);
314 314
315 r->l0 = cpu_to_be64( 315 r->l0 = cpu_to_be64(
316 ((xfs_bmbt_rec_base_t)extent_flag << 63) | 316 ((xfs_bmbt_rec_base_t)extent_flag << 63) |
@@ -319,17 +319,17 @@ xfs_bmbt_disk_set_allf(
319 r->l1 = cpu_to_be64( 319 r->l1 = cpu_to_be64(
320 ((xfs_bmbt_rec_base_t)startblock << 21) | 320 ((xfs_bmbt_rec_base_t)startblock << 21) |
321 ((xfs_bmbt_rec_base_t)blockcount & 321 ((xfs_bmbt_rec_base_t)blockcount &
322 (xfs_bmbt_rec_base_t)XFS_MASK64LO(21))); 322 (xfs_bmbt_rec_base_t)xfs_mask64lo(21)));
323#else /* !XFS_BIG_BLKNOS */ 323#else /* !XFS_BIG_BLKNOS */
324 if (ISNULLSTARTBLOCK(startblock)) { 324 if (isnullstartblock(startblock)) {
325 r->l0 = cpu_to_be64( 325 r->l0 = cpu_to_be64(
326 ((xfs_bmbt_rec_base_t)extent_flag << 63) | 326 ((xfs_bmbt_rec_base_t)extent_flag << 63) |
327 ((xfs_bmbt_rec_base_t)startoff << 9) | 327 ((xfs_bmbt_rec_base_t)startoff << 9) |
328 (xfs_bmbt_rec_base_t)XFS_MASK64LO(9)); 328 (xfs_bmbt_rec_base_t)xfs_mask64lo(9));
329 r->l1 = cpu_to_be64(XFS_MASK64HI(11) | 329 r->l1 = cpu_to_be64(xfs_mask64hi(11) |
330 ((xfs_bmbt_rec_base_t)startblock << 21) | 330 ((xfs_bmbt_rec_base_t)startblock << 21) |
331 ((xfs_bmbt_rec_base_t)blockcount & 331 ((xfs_bmbt_rec_base_t)blockcount &
332 (xfs_bmbt_rec_base_t)XFS_MASK64LO(21))); 332 (xfs_bmbt_rec_base_t)xfs_mask64lo(21)));
333 } else { 333 } else {
334 r->l0 = cpu_to_be64( 334 r->l0 = cpu_to_be64(
335 ((xfs_bmbt_rec_base_t)extent_flag << 63) | 335 ((xfs_bmbt_rec_base_t)extent_flag << 63) |
@@ -337,7 +337,7 @@ xfs_bmbt_disk_set_allf(
337 r->l1 = cpu_to_be64( 337 r->l1 = cpu_to_be64(
338 ((xfs_bmbt_rec_base_t)startblock << 21) | 338 ((xfs_bmbt_rec_base_t)startblock << 21) |
339 ((xfs_bmbt_rec_base_t)blockcount & 339 ((xfs_bmbt_rec_base_t)blockcount &
340 (xfs_bmbt_rec_base_t)XFS_MASK64LO(21))); 340 (xfs_bmbt_rec_base_t)xfs_mask64lo(21)));
341 } 341 }
342#endif /* XFS_BIG_BLKNOS */ 342#endif /* XFS_BIG_BLKNOS */
343} 343}
@@ -362,9 +362,9 @@ xfs_bmbt_set_blockcount(
362 xfs_bmbt_rec_host_t *r, 362 xfs_bmbt_rec_host_t *r,
363 xfs_filblks_t v) 363 xfs_filblks_t v)
364{ 364{
365 ASSERT((v & XFS_MASK64HI(43)) == 0); 365 ASSERT((v & xfs_mask64hi(43)) == 0);
366 r->l1 = (r->l1 & (xfs_bmbt_rec_base_t)XFS_MASK64HI(43)) | 366 r->l1 = (r->l1 & (xfs_bmbt_rec_base_t)xfs_mask64hi(43)) |
367 (xfs_bmbt_rec_base_t)(v & XFS_MASK64LO(21)); 367 (xfs_bmbt_rec_base_t)(v & xfs_mask64lo(21));
368} 368}
369 369
370/* 370/*
@@ -376,21 +376,21 @@ xfs_bmbt_set_startblock(
376 xfs_fsblock_t v) 376 xfs_fsblock_t v)
377{ 377{
378#if XFS_BIG_BLKNOS 378#if XFS_BIG_BLKNOS
379 ASSERT((v & XFS_MASK64HI(12)) == 0); 379 ASSERT((v & xfs_mask64hi(12)) == 0);
380 r->l0 = (r->l0 & (xfs_bmbt_rec_base_t)XFS_MASK64HI(55)) | 380 r->l0 = (r->l0 & (xfs_bmbt_rec_base_t)xfs_mask64hi(55)) |
381 (xfs_bmbt_rec_base_t)(v >> 43); 381 (xfs_bmbt_rec_base_t)(v >> 43);
382 r->l1 = (r->l1 & (xfs_bmbt_rec_base_t)XFS_MASK64LO(21)) | 382 r->l1 = (r->l1 & (xfs_bmbt_rec_base_t)xfs_mask64lo(21)) |
383 (xfs_bmbt_rec_base_t)(v << 21); 383 (xfs_bmbt_rec_base_t)(v << 21);
384#else /* !XFS_BIG_BLKNOS */ 384#else /* !XFS_BIG_BLKNOS */
385 if (ISNULLSTARTBLOCK(v)) { 385 if (isnullstartblock(v)) {
386 r->l0 |= (xfs_bmbt_rec_base_t)XFS_MASK64LO(9); 386 r->l0 |= (xfs_bmbt_rec_base_t)xfs_mask64lo(9);
387 r->l1 = (xfs_bmbt_rec_base_t)XFS_MASK64HI(11) | 387 r->l1 = (xfs_bmbt_rec_base_t)xfs_mask64hi(11) |
388 ((xfs_bmbt_rec_base_t)v << 21) | 388 ((xfs_bmbt_rec_base_t)v << 21) |
389 (r->l1 & (xfs_bmbt_rec_base_t)XFS_MASK64LO(21)); 389 (r->l1 & (xfs_bmbt_rec_base_t)xfs_mask64lo(21));
390 } else { 390 } else {
391 r->l0 &= ~(xfs_bmbt_rec_base_t)XFS_MASK64LO(9); 391 r->l0 &= ~(xfs_bmbt_rec_base_t)xfs_mask64lo(9);
392 r->l1 = ((xfs_bmbt_rec_base_t)v << 21) | 392 r->l1 = ((xfs_bmbt_rec_base_t)v << 21) |
393 (r->l1 & (xfs_bmbt_rec_base_t)XFS_MASK64LO(21)); 393 (r->l1 & (xfs_bmbt_rec_base_t)xfs_mask64lo(21));
394 } 394 }
395#endif /* XFS_BIG_BLKNOS */ 395#endif /* XFS_BIG_BLKNOS */
396} 396}
@@ -403,10 +403,10 @@ xfs_bmbt_set_startoff(
403 xfs_bmbt_rec_host_t *r, 403 xfs_bmbt_rec_host_t *r,
404 xfs_fileoff_t v) 404 xfs_fileoff_t v)
405{ 405{
406 ASSERT((v & XFS_MASK64HI(9)) == 0); 406 ASSERT((v & xfs_mask64hi(9)) == 0);
407 r->l0 = (r->l0 & (xfs_bmbt_rec_base_t) XFS_MASK64HI(1)) | 407 r->l0 = (r->l0 & (xfs_bmbt_rec_base_t) xfs_mask64hi(1)) |
408 ((xfs_bmbt_rec_base_t)v << 9) | 408 ((xfs_bmbt_rec_base_t)v << 9) |
409 (r->l0 & (xfs_bmbt_rec_base_t)XFS_MASK64LO(9)); 409 (r->l0 & (xfs_bmbt_rec_base_t)xfs_mask64lo(9));
410} 410}
411 411
412/* 412/*
@@ -419,9 +419,9 @@ xfs_bmbt_set_state(
419{ 419{
420 ASSERT(v == XFS_EXT_NORM || v == XFS_EXT_UNWRITTEN); 420 ASSERT(v == XFS_EXT_NORM || v == XFS_EXT_UNWRITTEN);
421 if (v == XFS_EXT_NORM) 421 if (v == XFS_EXT_NORM)
422 r->l0 &= XFS_MASK64LO(64 - BMBT_EXNTFLAG_BITLEN); 422 r->l0 &= xfs_mask64lo(64 - BMBT_EXNTFLAG_BITLEN);
423 else 423 else
424 r->l0 |= XFS_MASK64HI(BMBT_EXNTFLAG_BITLEN); 424 r->l0 |= xfs_mask64hi(BMBT_EXNTFLAG_BITLEN);
425} 425}
426 426
427/* 427/*
diff --git a/fs/xfs/xfs_bmap_btree.h b/fs/xfs/xfs_bmap_btree.h
index a4555abb6622..0e8df007615e 100644
--- a/fs/xfs/xfs_bmap_btree.h
+++ b/fs/xfs/xfs_bmap_btree.h
@@ -76,26 +76,22 @@ typedef struct xfs_bmbt_rec_host {
76#define DSTARTBLOCKMASK \ 76#define DSTARTBLOCKMASK \
77 (((((xfs_dfsbno_t)1) << DSTARTBLOCKMASKBITS) - 1) << STARTBLOCKVALBITS) 77 (((((xfs_dfsbno_t)1) << DSTARTBLOCKMASKBITS) - 1) << STARTBLOCKVALBITS)
78 78
79#define ISNULLSTARTBLOCK(x) isnullstartblock(x)
80static inline int isnullstartblock(xfs_fsblock_t x) 79static inline int isnullstartblock(xfs_fsblock_t x)
81{ 80{
82 return ((x) & STARTBLOCKMASK) == STARTBLOCKMASK; 81 return ((x) & STARTBLOCKMASK) == STARTBLOCKMASK;
83} 82}
84 83
85#define ISNULLDSTARTBLOCK(x) isnulldstartblock(x)
86static inline int isnulldstartblock(xfs_dfsbno_t x) 84static inline int isnulldstartblock(xfs_dfsbno_t x)
87{ 85{
88 return ((x) & DSTARTBLOCKMASK) == DSTARTBLOCKMASK; 86 return ((x) & DSTARTBLOCKMASK) == DSTARTBLOCKMASK;
89} 87}
90 88
91#define NULLSTARTBLOCK(k) nullstartblock(k)
92static inline xfs_fsblock_t nullstartblock(int k) 89static inline xfs_fsblock_t nullstartblock(int k)
93{ 90{
94 ASSERT(k < (1 << STARTBLOCKVALBITS)); 91 ASSERT(k < (1 << STARTBLOCKVALBITS));
95 return STARTBLOCKMASK | (k); 92 return STARTBLOCKMASK | (k);
96} 93}
97 94
98#define STARTBLOCKVAL(x) startblockval(x)
99static inline xfs_filblks_t startblockval(xfs_fsblock_t x) 95static inline xfs_filblks_t startblockval(xfs_fsblock_t x)
100{ 96{
101 return (xfs_filblks_t)((x) & ~STARTBLOCKMASK); 97 return (xfs_filblks_t)((x) & ~STARTBLOCKMASK);
diff --git a/fs/xfs/xfs_btree.c b/fs/xfs/xfs_btree.c
index 7ed59267420d..e73c332eb23f 100644
--- a/fs/xfs/xfs_btree.c
+++ b/fs/xfs/xfs_btree.c
@@ -730,8 +730,8 @@ xfs_btree_readahead_lblock(
730 struct xfs_btree_block *block) 730 struct xfs_btree_block *block)
731{ 731{
732 int rval = 0; 732 int rval = 0;
733 xfs_fsblock_t left = be64_to_cpu(block->bb_u.l.bb_leftsib); 733 xfs_dfsbno_t left = be64_to_cpu(block->bb_u.l.bb_leftsib);
734 xfs_fsblock_t right = be64_to_cpu(block->bb_u.l.bb_rightsib); 734 xfs_dfsbno_t right = be64_to_cpu(block->bb_u.l.bb_rightsib);
735 735
736 if ((lr & XFS_BTCUR_LEFTRA) && left != NULLDFSBNO) { 736 if ((lr & XFS_BTCUR_LEFTRA) && left != NULLDFSBNO) {
737 xfs_btree_reada_bufl(cur->bc_mp, left, 1); 737 xfs_btree_reada_bufl(cur->bc_mp, left, 1);
@@ -843,7 +843,7 @@ xfs_btree_ptr_is_null(
843 union xfs_btree_ptr *ptr) 843 union xfs_btree_ptr *ptr)
844{ 844{
845 if (cur->bc_flags & XFS_BTREE_LONG_PTRS) 845 if (cur->bc_flags & XFS_BTREE_LONG_PTRS)
846 return be64_to_cpu(ptr->l) == NULLFSBLOCK; 846 return be64_to_cpu(ptr->l) == NULLDFSBNO;
847 else 847 else
848 return be32_to_cpu(ptr->s) == NULLAGBLOCK; 848 return be32_to_cpu(ptr->s) == NULLAGBLOCK;
849} 849}
@@ -854,7 +854,7 @@ xfs_btree_set_ptr_null(
854 union xfs_btree_ptr *ptr) 854 union xfs_btree_ptr *ptr)
855{ 855{
856 if (cur->bc_flags & XFS_BTREE_LONG_PTRS) 856 if (cur->bc_flags & XFS_BTREE_LONG_PTRS)
857 ptr->l = cpu_to_be64(NULLFSBLOCK); 857 ptr->l = cpu_to_be64(NULLDFSBNO);
858 else 858 else
859 ptr->s = cpu_to_be32(NULLAGBLOCK); 859 ptr->s = cpu_to_be32(NULLAGBLOCK);
860} 860}
@@ -918,8 +918,8 @@ xfs_btree_init_block(
918 new->bb_numrecs = cpu_to_be16(numrecs); 918 new->bb_numrecs = cpu_to_be16(numrecs);
919 919
920 if (cur->bc_flags & XFS_BTREE_LONG_PTRS) { 920 if (cur->bc_flags & XFS_BTREE_LONG_PTRS) {
921 new->bb_u.l.bb_leftsib = cpu_to_be64(NULLFSBLOCK); 921 new->bb_u.l.bb_leftsib = cpu_to_be64(NULLDFSBNO);
922 new->bb_u.l.bb_rightsib = cpu_to_be64(NULLFSBLOCK); 922 new->bb_u.l.bb_rightsib = cpu_to_be64(NULLDFSBNO);
923 } else { 923 } else {
924 new->bb_u.s.bb_leftsib = cpu_to_be32(NULLAGBLOCK); 924 new->bb_u.s.bb_leftsib = cpu_to_be32(NULLAGBLOCK);
925 new->bb_u.s.bb_rightsib = cpu_to_be32(NULLAGBLOCK); 925 new->bb_u.s.bb_rightsib = cpu_to_be32(NULLAGBLOCK);
@@ -960,7 +960,7 @@ xfs_btree_buf_to_ptr(
960 ptr->l = cpu_to_be64(XFS_DADDR_TO_FSB(cur->bc_mp, 960 ptr->l = cpu_to_be64(XFS_DADDR_TO_FSB(cur->bc_mp,
961 XFS_BUF_ADDR(bp))); 961 XFS_BUF_ADDR(bp)));
962 else { 962 else {
963 ptr->s = cpu_to_be32(XFS_DADDR_TO_AGBNO(cur->bc_mp, 963 ptr->s = cpu_to_be32(xfs_daddr_to_agbno(cur->bc_mp,
964 XFS_BUF_ADDR(bp))); 964 XFS_BUF_ADDR(bp)));
965 } 965 }
966} 966}
@@ -971,7 +971,7 @@ xfs_btree_ptr_to_daddr(
971 union xfs_btree_ptr *ptr) 971 union xfs_btree_ptr *ptr)
972{ 972{
973 if (cur->bc_flags & XFS_BTREE_LONG_PTRS) { 973 if (cur->bc_flags & XFS_BTREE_LONG_PTRS) {
974 ASSERT(be64_to_cpu(ptr->l) != NULLFSBLOCK); 974 ASSERT(be64_to_cpu(ptr->l) != NULLDFSBNO);
975 975
976 return XFS_FSB_TO_DADDR(cur->bc_mp, be64_to_cpu(ptr->l)); 976 return XFS_FSB_TO_DADDR(cur->bc_mp, be64_to_cpu(ptr->l));
977 } else { 977 } else {
@@ -2454,7 +2454,7 @@ xfs_btree_new_iroot(
2454 xfs_btree_log_ptrs(cur, cbp, 1, be16_to_cpu(cblock->bb_numrecs)); 2454 xfs_btree_log_ptrs(cur, cbp, 1, be16_to_cpu(cblock->bb_numrecs));
2455 2455
2456 *logflags |= 2456 *logflags |=
2457 XFS_ILOG_CORE | XFS_ILOG_FBROOT(cur->bc_private.b.whichfork); 2457 XFS_ILOG_CORE | xfs_ilog_fbroot(cur->bc_private.b.whichfork);
2458 *stat = 1; 2458 *stat = 1;
2459 XFS_BTREE_TRACE_CURSOR(cur, XBT_EXIT); 2459 XFS_BTREE_TRACE_CURSOR(cur, XBT_EXIT);
2460 return 0; 2460 return 0;
@@ -3048,7 +3048,7 @@ xfs_btree_kill_iroot(
3048 cur->bc_bufs[level - 1] = NULL; 3048 cur->bc_bufs[level - 1] = NULL;
3049 be16_add_cpu(&block->bb_level, -1); 3049 be16_add_cpu(&block->bb_level, -1);
3050 xfs_trans_log_inode(cur->bc_tp, ip, 3050 xfs_trans_log_inode(cur->bc_tp, ip,
3051 XFS_ILOG_CORE | XFS_ILOG_FBROOT(cur->bc_private.b.whichfork)); 3051 XFS_ILOG_CORE | xfs_ilog_fbroot(cur->bc_private.b.whichfork));
3052 cur->bc_nlevels--; 3052 cur->bc_nlevels--;
3053out0: 3053out0:
3054 XFS_BTREE_TRACE_CURSOR(cur, XBT_EXIT); 3054 XFS_BTREE_TRACE_CURSOR(cur, XBT_EXIT);
diff --git a/fs/xfs/xfs_da_btree.c b/fs/xfs/xfs_da_btree.c
index a11a8390bf6c..c45f74ff1a5b 100644
--- a/fs/xfs/xfs_da_btree.c
+++ b/fs/xfs/xfs_da_btree.c
@@ -1597,7 +1597,7 @@ xfs_da_grow_inode(xfs_da_args_t *args, xfs_dablk_t *new_blkno)
1597 nmap = 1; 1597 nmap = 1;
1598 ASSERT(args->firstblock != NULL); 1598 ASSERT(args->firstblock != NULL);
1599 if ((error = xfs_bmapi(tp, dp, bno, count, 1599 if ((error = xfs_bmapi(tp, dp, bno, count,
1600 XFS_BMAPI_AFLAG(w)|XFS_BMAPI_WRITE|XFS_BMAPI_METADATA| 1600 xfs_bmapi_aflag(w)|XFS_BMAPI_WRITE|XFS_BMAPI_METADATA|
1601 XFS_BMAPI_CONTIG, 1601 XFS_BMAPI_CONTIG,
1602 args->firstblock, args->total, &map, &nmap, 1602 args->firstblock, args->total, &map, &nmap,
1603 args->flist, NULL))) { 1603 args->flist, NULL))) {
@@ -1618,7 +1618,7 @@ xfs_da_grow_inode(xfs_da_args_t *args, xfs_dablk_t *new_blkno)
1618 nmap = MIN(XFS_BMAP_MAX_NMAP, count); 1618 nmap = MIN(XFS_BMAP_MAX_NMAP, count);
1619 c = (int)(bno + count - b); 1619 c = (int)(bno + count - b);
1620 if ((error = xfs_bmapi(tp, dp, b, c, 1620 if ((error = xfs_bmapi(tp, dp, b, c,
1621 XFS_BMAPI_AFLAG(w)|XFS_BMAPI_WRITE| 1621 xfs_bmapi_aflag(w)|XFS_BMAPI_WRITE|
1622 XFS_BMAPI_METADATA, 1622 XFS_BMAPI_METADATA,
1623 args->firstblock, args->total, 1623 args->firstblock, args->total,
1624 &mapp[mapi], &nmap, args->flist, 1624 &mapp[mapi], &nmap, args->flist,
@@ -1882,7 +1882,7 @@ xfs_da_shrink_inode(xfs_da_args_t *args, xfs_dablk_t dead_blkno,
1882 * the last block to the place we want to kill. 1882 * the last block to the place we want to kill.
1883 */ 1883 */
1884 if ((error = xfs_bunmapi(tp, dp, dead_blkno, count, 1884 if ((error = xfs_bunmapi(tp, dp, dead_blkno, count,
1885 XFS_BMAPI_AFLAG(w)|XFS_BMAPI_METADATA, 1885 xfs_bmapi_aflag(w)|XFS_BMAPI_METADATA,
1886 0, args->firstblock, args->flist, NULL, 1886 0, args->firstblock, args->flist, NULL,
1887 &done)) == ENOSPC) { 1887 &done)) == ENOSPC) {
1888 if (w != XFS_DATA_FORK) 1888 if (w != XFS_DATA_FORK)
@@ -1987,7 +1987,7 @@ xfs_da_do_buf(
1987 if ((error = xfs_bmapi(trans, dp, (xfs_fileoff_t)bno, 1987 if ((error = xfs_bmapi(trans, dp, (xfs_fileoff_t)bno,
1988 nfsb, 1988 nfsb,
1989 XFS_BMAPI_METADATA | 1989 XFS_BMAPI_METADATA |
1990 XFS_BMAPI_AFLAG(whichfork), 1990 xfs_bmapi_aflag(whichfork),
1991 NULL, 0, mapp, &nmap, NULL, NULL))) 1991 NULL, 0, mapp, &nmap, NULL, NULL)))
1992 goto exit0; 1992 goto exit0;
1993 } 1993 }
diff --git a/fs/xfs/xfs_dfrag.c b/fs/xfs/xfs_dfrag.c
index b4c1ee713492..f8278cfcc1d3 100644
--- a/fs/xfs/xfs_dfrag.c
+++ b/fs/xfs/xfs_dfrag.c
@@ -55,17 +55,11 @@ xfs_swapext(
55 struct file *file, *target_file; 55 struct file *file, *target_file;
56 int error = 0; 56 int error = 0;
57 57
58 sxp = kmem_alloc(sizeof(xfs_swapext_t), KM_MAYFAIL);
59 if (!sxp) {
60 error = XFS_ERROR(ENOMEM);
61 goto out;
62 }
63
64 /* Pull information for the target fd */ 58 /* Pull information for the target fd */
65 file = fget((int)sxp->sx_fdtarget); 59 file = fget((int)sxp->sx_fdtarget);
66 if (!file) { 60 if (!file) {
67 error = XFS_ERROR(EINVAL); 61 error = XFS_ERROR(EINVAL);
68 goto out_free_sxp; 62 goto out;
69 } 63 }
70 64
71 if (!(file->f_mode & FMODE_WRITE) || (file->f_flags & O_APPEND)) { 65 if (!(file->f_mode & FMODE_WRITE) || (file->f_flags & O_APPEND)) {
@@ -109,8 +103,6 @@ xfs_swapext(
109 fput(target_file); 103 fput(target_file);
110 out_put_file: 104 out_put_file:
111 fput(file); 105 fput(file);
112 out_free_sxp:
113 kmem_free(sxp);
114 out: 106 out:
115 return error; 107 return error;
116} 108}
diff --git a/fs/xfs/xfs_dir2_block.c b/fs/xfs/xfs_dir2_block.c
index e2fa0a1d8e96..e1f0a06aaf04 100644
--- a/fs/xfs/xfs_dir2_block.c
+++ b/fs/xfs/xfs_dir2_block.c
@@ -517,9 +517,9 @@ xfs_dir2_block_getdents(
517 /* 517 /*
518 * If it didn't fit, set the final offset to here & return. 518 * If it didn't fit, set the final offset to here & return.
519 */ 519 */
520 if (filldir(dirent, dep->name, dep->namelen, cook, 520 if (filldir(dirent, dep->name, dep->namelen, cook & 0x7fffffff,
521 ino, DT_UNKNOWN)) { 521 ino, DT_UNKNOWN)) {
522 *offset = cook; 522 *offset = cook & 0x7fffffff;
523 xfs_da_brelse(NULL, bp); 523 xfs_da_brelse(NULL, bp);
524 return 0; 524 return 0;
525 } 525 }
@@ -529,7 +529,8 @@ xfs_dir2_block_getdents(
529 * Reached the end of the block. 529 * Reached the end of the block.
530 * Set the offset to a non-existent block 1 and return. 530 * Set the offset to a non-existent block 1 and return.
531 */ 531 */
532 *offset = xfs_dir2_db_off_to_dataptr(mp, mp->m_dirdatablk + 1, 0); 532 *offset = xfs_dir2_db_off_to_dataptr(mp, mp->m_dirdatablk + 1, 0) &
533 0x7fffffff;
533 xfs_da_brelse(NULL, bp); 534 xfs_da_brelse(NULL, bp);
534 return 0; 535 return 0;
535} 536}
diff --git a/fs/xfs/xfs_dir2_leaf.c b/fs/xfs/xfs_dir2_leaf.c
index 93535992cb60..ef805a374eec 100644
--- a/fs/xfs/xfs_dir2_leaf.c
+++ b/fs/xfs/xfs_dir2_leaf.c
@@ -1092,7 +1092,7 @@ xfs_dir2_leaf_getdents(
1092 * Won't fit. Return to caller. 1092 * Won't fit. Return to caller.
1093 */ 1093 */
1094 if (filldir(dirent, dep->name, dep->namelen, 1094 if (filldir(dirent, dep->name, dep->namelen,
1095 xfs_dir2_byte_to_dataptr(mp, curoff), 1095 xfs_dir2_byte_to_dataptr(mp, curoff) & 0x7fffffff,
1096 ino, DT_UNKNOWN)) 1096 ino, DT_UNKNOWN))
1097 break; 1097 break;
1098 1098
@@ -1108,9 +1108,9 @@ xfs_dir2_leaf_getdents(
1108 * All done. Set output offset value to current offset. 1108 * All done. Set output offset value to current offset.
1109 */ 1109 */
1110 if (curoff > xfs_dir2_dataptr_to_byte(mp, XFS_DIR2_MAX_DATAPTR)) 1110 if (curoff > xfs_dir2_dataptr_to_byte(mp, XFS_DIR2_MAX_DATAPTR))
1111 *offset = XFS_DIR2_MAX_DATAPTR; 1111 *offset = XFS_DIR2_MAX_DATAPTR & 0x7fffffff;
1112 else 1112 else
1113 *offset = xfs_dir2_byte_to_dataptr(mp, curoff); 1113 *offset = xfs_dir2_byte_to_dataptr(mp, curoff) & 0x7fffffff;
1114 kmem_free(map); 1114 kmem_free(map);
1115 if (bp) 1115 if (bp)
1116 xfs_da_brelse(NULL, bp); 1116 xfs_da_brelse(NULL, bp);
diff --git a/fs/xfs/xfs_dir2_sf.c b/fs/xfs/xfs_dir2_sf.c
index b46af0013ec9..a8a8a6efad5b 100644
--- a/fs/xfs/xfs_dir2_sf.c
+++ b/fs/xfs/xfs_dir2_sf.c
@@ -752,8 +752,8 @@ xfs_dir2_sf_getdents(
752#if XFS_BIG_INUMS 752#if XFS_BIG_INUMS
753 ino += mp->m_inoadd; 753 ino += mp->m_inoadd;
754#endif 754#endif
755 if (filldir(dirent, ".", 1, dot_offset, ino, DT_DIR)) { 755 if (filldir(dirent, ".", 1, dot_offset & 0x7fffffff, ino, DT_DIR)) {
756 *offset = dot_offset; 756 *offset = dot_offset & 0x7fffffff;
757 return 0; 757 return 0;
758 } 758 }
759 } 759 }
@@ -766,8 +766,8 @@ xfs_dir2_sf_getdents(
766#if XFS_BIG_INUMS 766#if XFS_BIG_INUMS
767 ino += mp->m_inoadd; 767 ino += mp->m_inoadd;
768#endif 768#endif
769 if (filldir(dirent, "..", 2, dotdot_offset, ino, DT_DIR)) { 769 if (filldir(dirent, "..", 2, dotdot_offset & 0x7fffffff, ino, DT_DIR)) {
770 *offset = dotdot_offset; 770 *offset = dotdot_offset & 0x7fffffff;
771 return 0; 771 return 0;
772 } 772 }
773 } 773 }
@@ -791,14 +791,15 @@ xfs_dir2_sf_getdents(
791#endif 791#endif
792 792
793 if (filldir(dirent, sfep->name, sfep->namelen, 793 if (filldir(dirent, sfep->name, sfep->namelen,
794 off, ino, DT_UNKNOWN)) { 794 off & 0x7fffffff, ino, DT_UNKNOWN)) {
795 *offset = off; 795 *offset = off & 0x7fffffff;
796 return 0; 796 return 0;
797 } 797 }
798 sfep = xfs_dir2_sf_nextentry(sfp, sfep); 798 sfep = xfs_dir2_sf_nextentry(sfp, sfep);
799 } 799 }
800 800
801 *offset = xfs_dir2_db_off_to_dataptr(mp, mp->m_dirdatablk + 1, 0); 801 *offset = xfs_dir2_db_off_to_dataptr(mp, mp->m_dirdatablk + 1, 0) &
802 0x7fffffff;
802 return 0; 803 return 0;
803} 804}
804 805
diff --git a/fs/xfs/xfs_fs.h b/fs/xfs/xfs_fs.h
index 589c41c38446..f7c06fac8229 100644
--- a/fs/xfs/xfs_fs.h
+++ b/fs/xfs/xfs_fs.h
@@ -465,8 +465,8 @@ typedef struct xfs_handle {
465#define XFS_IOC_ERROR_INJECTION _IOW ('X', 116, struct xfs_error_injection) 465#define XFS_IOC_ERROR_INJECTION _IOW ('X', 116, struct xfs_error_injection)
466#define XFS_IOC_ERROR_CLEARALL _IOW ('X', 117, struct xfs_error_injection) 466#define XFS_IOC_ERROR_CLEARALL _IOW ('X', 117, struct xfs_error_injection)
467/* XFS_IOC_ATTRCTL_BY_HANDLE -- deprecated 118 */ 467/* XFS_IOC_ATTRCTL_BY_HANDLE -- deprecated 118 */
468#define XFS_IOC_FREEZE _IOWR('X', 119, int) 468/* XFS_IOC_FREEZE -- FIFREEZE 119 */
469#define XFS_IOC_THAW _IOWR('X', 120, int) 469/* XFS_IOC_THAW -- FITHAW 120 */
470#define XFS_IOC_FSSETDM_BY_HANDLE _IOW ('X', 121, struct xfs_fsop_setdm_handlereq) 470#define XFS_IOC_FSSETDM_BY_HANDLE _IOW ('X', 121, struct xfs_fsop_setdm_handlereq)
471#define XFS_IOC_ATTRLIST_BY_HANDLE _IOW ('X', 122, struct xfs_fsop_attrlist_handlereq) 471#define XFS_IOC_ATTRLIST_BY_HANDLE _IOW ('X', 122, struct xfs_fsop_attrlist_handlereq)
472#define XFS_IOC_ATTRMULTI_BY_HANDLE _IOW ('X', 123, struct xfs_fsop_attrmulti_handlereq) 472#define XFS_IOC_ATTRMULTI_BY_HANDLE _IOW ('X', 123, struct xfs_fsop_attrmulti_handlereq)
diff --git a/fs/xfs/xfs_fsops.c b/fs/xfs/xfs_fsops.c
index 852b6d32e8d0..680d0e0ec932 100644
--- a/fs/xfs/xfs_fsops.c
+++ b/fs/xfs/xfs_fsops.c
@@ -595,17 +595,19 @@ out:
595 return 0; 595 return 0;
596} 596}
597 597
598void 598int
599xfs_fs_log_dummy( 599xfs_fs_log_dummy(
600 xfs_mount_t *mp) 600 xfs_mount_t *mp)
601{ 601{
602 xfs_trans_t *tp; 602 xfs_trans_t *tp;
603 xfs_inode_t *ip; 603 xfs_inode_t *ip;
604 int error;
604 605
605 tp = _xfs_trans_alloc(mp, XFS_TRANS_DUMMY1); 606 tp = _xfs_trans_alloc(mp, XFS_TRANS_DUMMY1);
606 if (xfs_trans_reserve(tp, 0, XFS_ICHANGE_LOG_RES(mp), 0, 0, 0)) { 607 error = xfs_trans_reserve(tp, 0, XFS_ICHANGE_LOG_RES(mp), 0, 0, 0);
608 if (error) {
607 xfs_trans_cancel(tp, 0); 609 xfs_trans_cancel(tp, 0);
608 return; 610 return error;
609 } 611 }
610 612
611 ip = mp->m_rootip; 613 ip = mp->m_rootip;
@@ -615,9 +617,10 @@ xfs_fs_log_dummy(
615 xfs_trans_ihold(tp, ip); 617 xfs_trans_ihold(tp, ip);
616 xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); 618 xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
617 xfs_trans_set_sync(tp); 619 xfs_trans_set_sync(tp);
618 xfs_trans_commit(tp, 0); 620 error = xfs_trans_commit(tp, 0);
619 621
620 xfs_iunlock(ip, XFS_ILOCK_EXCL); 622 xfs_iunlock(ip, XFS_ILOCK_EXCL);
623 return error;
621} 624}
622 625
623int 626int
diff --git a/fs/xfs/xfs_fsops.h b/fs/xfs/xfs_fsops.h
index 300d0c9d61ad..88435e0a77c9 100644
--- a/fs/xfs/xfs_fsops.h
+++ b/fs/xfs/xfs_fsops.h
@@ -25,6 +25,6 @@ extern int xfs_fs_counts(xfs_mount_t *mp, xfs_fsop_counts_t *cnt);
25extern int xfs_reserve_blocks(xfs_mount_t *mp, __uint64_t *inval, 25extern int xfs_reserve_blocks(xfs_mount_t *mp, __uint64_t *inval,
26 xfs_fsop_resblks_t *outval); 26 xfs_fsop_resblks_t *outval);
27extern int xfs_fs_goingdown(xfs_mount_t *mp, __uint32_t inflags); 27extern int xfs_fs_goingdown(xfs_mount_t *mp, __uint32_t inflags);
28extern void xfs_fs_log_dummy(xfs_mount_t *mp); 28extern int xfs_fs_log_dummy(xfs_mount_t *mp);
29 29
30#endif /* __XFS_FSOPS_H__ */ 30#endif /* __XFS_FSOPS_H__ */
diff --git a/fs/xfs/xfs_ialloc.c b/fs/xfs/xfs_ialloc.c
index e6ebbaeb4dc6..ab016e5ae7be 100644
--- a/fs/xfs/xfs_ialloc.c
+++ b/fs/xfs/xfs_ialloc.c
@@ -357,7 +357,7 @@ xfs_ialloc_ag_alloc(
357 int ioffset = i << args.mp->m_sb.sb_inodelog; 357 int ioffset = i << args.mp->m_sb.sb_inodelog;
358 uint isize = sizeof(struct xfs_dinode); 358 uint isize = sizeof(struct xfs_dinode);
359 359
360 free = XFS_MAKE_IPTR(args.mp, fbuf, i); 360 free = xfs_make_iptr(args.mp, fbuf, i);
361 free->di_magic = cpu_to_be16(XFS_DINODE_MAGIC); 361 free->di_magic = cpu_to_be16(XFS_DINODE_MAGIC);
362 free->di_version = version; 362 free->di_version = version;
363 free->di_gen = cpu_to_be32(gen); 363 free->di_gen = cpu_to_be32(gen);
@@ -937,7 +937,7 @@ nextag:
937 } 937 }
938 } 938 }
939 } 939 }
940 offset = XFS_IALLOC_FIND_FREE(&rec.ir_free); 940 offset = xfs_ialloc_find_free(&rec.ir_free);
941 ASSERT(offset >= 0); 941 ASSERT(offset >= 0);
942 ASSERT(offset < XFS_INODES_PER_CHUNK); 942 ASSERT(offset < XFS_INODES_PER_CHUNK);
943 ASSERT((XFS_AGINO_TO_OFFSET(mp, rec.ir_startino) % 943 ASSERT((XFS_AGINO_TO_OFFSET(mp, rec.ir_startino) %
@@ -1279,7 +1279,7 @@ xfs_imap(
1279 offset = XFS_INO_TO_OFFSET(mp, ino); 1279 offset = XFS_INO_TO_OFFSET(mp, ino);
1280 ASSERT(offset < mp->m_sb.sb_inopblock); 1280 ASSERT(offset < mp->m_sb.sb_inopblock);
1281 1281
1282 cluster_agbno = XFS_DADDR_TO_AGBNO(mp, imap->im_blkno); 1282 cluster_agbno = xfs_daddr_to_agbno(mp, imap->im_blkno);
1283 offset += (agbno - cluster_agbno) * mp->m_sb.sb_inopblock; 1283 offset += (agbno - cluster_agbno) * mp->m_sb.sb_inopblock;
1284 1284
1285 imap->im_len = XFS_FSB_TO_BB(mp, blks_per_cluster); 1285 imap->im_len = XFS_FSB_TO_BB(mp, blks_per_cluster);
diff --git a/fs/xfs/xfs_ialloc.h b/fs/xfs/xfs_ialloc.h
index 50f558a4e0a8..aeee8278f92c 100644
--- a/fs/xfs/xfs_ialloc.h
+++ b/fs/xfs/xfs_ialloc.h
@@ -39,7 +39,6 @@ struct xfs_trans;
39/* 39/*
40 * Make an inode pointer out of the buffer/offset. 40 * Make an inode pointer out of the buffer/offset.
41 */ 41 */
42#define XFS_MAKE_IPTR(mp,b,o) xfs_make_iptr(mp,b,o)
43static inline struct xfs_dinode * 42static inline struct xfs_dinode *
44xfs_make_iptr(struct xfs_mount *mp, struct xfs_buf *b, int o) 43xfs_make_iptr(struct xfs_mount *mp, struct xfs_buf *b, int o)
45{ 44{
@@ -50,7 +49,6 @@ xfs_make_iptr(struct xfs_mount *mp, struct xfs_buf *b, int o)
50/* 49/*
51 * Find a free (set) bit in the inode bitmask. 50 * Find a free (set) bit in the inode bitmask.
52 */ 51 */
53#define XFS_IALLOC_FIND_FREE(fp) xfs_ialloc_find_free(fp)
54static inline int xfs_ialloc_find_free(xfs_inofree_t *fp) 52static inline int xfs_ialloc_find_free(xfs_inofree_t *fp)
55{ 53{
56 return xfs_lowbit64(*fp); 54 return xfs_lowbit64(*fp);
diff --git a/fs/xfs/xfs_ialloc_btree.h b/fs/xfs/xfs_ialloc_btree.h
index 37e5dd01a577..5580e255ff06 100644
--- a/fs/xfs/xfs_ialloc_btree.h
+++ b/fs/xfs/xfs_ialloc_btree.h
@@ -36,7 +36,6 @@ typedef __uint64_t xfs_inofree_t;
36#define XFS_INODES_PER_CHUNK_LOG (XFS_NBBYLOG + 3) 36#define XFS_INODES_PER_CHUNK_LOG (XFS_NBBYLOG + 3)
37#define XFS_INOBT_ALL_FREE ((xfs_inofree_t)-1) 37#define XFS_INOBT_ALL_FREE ((xfs_inofree_t)-1)
38 38
39#define XFS_INOBT_MASKN(i,n) xfs_inobt_maskn(i,n)
40static inline xfs_inofree_t xfs_inobt_maskn(int i, int n) 39static inline xfs_inofree_t xfs_inobt_maskn(int i, int n)
41{ 40{
42 return (((n) >= XFS_INODES_PER_CHUNK ? \ 41 return (((n) >= XFS_INODES_PER_CHUNK ? \
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index 5a5e035e5d38..e7ae08d1df48 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -424,6 +424,19 @@ xfs_iformat(
424 case XFS_DINODE_FMT_LOCAL: 424 case XFS_DINODE_FMT_LOCAL:
425 atp = (xfs_attr_shortform_t *)XFS_DFORK_APTR(dip); 425 atp = (xfs_attr_shortform_t *)XFS_DFORK_APTR(dip);
426 size = be16_to_cpu(atp->hdr.totsize); 426 size = be16_to_cpu(atp->hdr.totsize);
427
428 if (unlikely(size < sizeof(struct xfs_attr_sf_hdr))) {
429 xfs_fs_repair_cmn_err(CE_WARN, ip->i_mount,
430 "corrupt inode %Lu "
431 "(bad attr fork size %Ld).",
432 (unsigned long long) ip->i_ino,
433 (long long) size);
434 XFS_CORRUPTION_ERROR("xfs_iformat(8)",
435 XFS_ERRLEVEL_LOW,
436 ip->i_mount, dip);
437 return XFS_ERROR(EFSCORRUPTED);
438 }
439
427 error = xfs_iformat_local(ip, dip, XFS_ATTR_FORK, size); 440 error = xfs_iformat_local(ip, dip, XFS_ATTR_FORK, size);
428 break; 441 break;
429 case XFS_DINODE_FMT_EXTENTS: 442 case XFS_DINODE_FMT_EXTENTS:
@@ -1601,10 +1614,10 @@ xfs_itruncate_finish(
1601 * in this file with garbage in them once recovery 1614 * in this file with garbage in them once recovery
1602 * runs. 1615 * runs.
1603 */ 1616 */
1604 XFS_BMAP_INIT(&free_list, &first_block); 1617 xfs_bmap_init(&free_list, &first_block);
1605 error = xfs_bunmapi(ntp, ip, 1618 error = xfs_bunmapi(ntp, ip,
1606 first_unmap_block, unmap_len, 1619 first_unmap_block, unmap_len,
1607 XFS_BMAPI_AFLAG(fork) | 1620 xfs_bmapi_aflag(fork) |
1608 (sync ? 0 : XFS_BMAPI_ASYNC), 1621 (sync ? 0 : XFS_BMAPI_ASYNC),
1609 XFS_ITRUNC_MAX_EXTENTS, 1622 XFS_ITRUNC_MAX_EXTENTS,
1610 &first_block, &free_list, 1623 &first_block, &free_list,
@@ -2557,7 +2570,7 @@ xfs_iextents_copy(
2557 for (i = 0; i < nrecs; i++) { 2570 for (i = 0; i < nrecs; i++) {
2558 xfs_bmbt_rec_host_t *ep = xfs_iext_get_ext(ifp, i); 2571 xfs_bmbt_rec_host_t *ep = xfs_iext_get_ext(ifp, i);
2559 start_block = xfs_bmbt_get_startblock(ep); 2572 start_block = xfs_bmbt_get_startblock(ep);
2560 if (ISNULLSTARTBLOCK(start_block)) { 2573 if (isnullstartblock(start_block)) {
2561 /* 2574 /*
2562 * It's a delayed allocation extent, so skip it. 2575 * It's a delayed allocation extent, so skip it.
2563 */ 2576 */
diff --git a/fs/xfs/xfs_inode_item.h b/fs/xfs/xfs_inode_item.h
index 1ff04cc323ad..9957d0602d54 100644
--- a/fs/xfs/xfs_inode_item.h
+++ b/fs/xfs/xfs_inode_item.h
@@ -111,20 +111,16 @@ typedef struct xfs_inode_log_format_64 {
111 111
112#define XFS_ILI_IOLOCKED_ANY (XFS_ILI_IOLOCKED_EXCL | XFS_ILI_IOLOCKED_SHARED) 112#define XFS_ILI_IOLOCKED_ANY (XFS_ILI_IOLOCKED_EXCL | XFS_ILI_IOLOCKED_SHARED)
113 113
114
115#define XFS_ILOG_FBROOT(w) xfs_ilog_fbroot(w)
116static inline int xfs_ilog_fbroot(int w) 114static inline int xfs_ilog_fbroot(int w)
117{ 115{
118 return (w == XFS_DATA_FORK ? XFS_ILOG_DBROOT : XFS_ILOG_ABROOT); 116 return (w == XFS_DATA_FORK ? XFS_ILOG_DBROOT : XFS_ILOG_ABROOT);
119} 117}
120 118
121#define XFS_ILOG_FEXT(w) xfs_ilog_fext(w)
122static inline int xfs_ilog_fext(int w) 119static inline int xfs_ilog_fext(int w)
123{ 120{
124 return (w == XFS_DATA_FORK ? XFS_ILOG_DEXT : XFS_ILOG_AEXT); 121 return (w == XFS_DATA_FORK ? XFS_ILOG_DEXT : XFS_ILOG_AEXT);
125} 122}
126 123
127#define XFS_ILOG_FDATA(w) xfs_ilog_fdata(w)
128static inline int xfs_ilog_fdata(int w) 124static inline int xfs_ilog_fdata(int w)
129{ 125{
130 return (w == XFS_DATA_FORK ? XFS_ILOG_DDATA : XFS_ILOG_ADATA); 126 return (w == XFS_DATA_FORK ? XFS_ILOG_DDATA : XFS_ILOG_ADATA);
diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c
index 911062cf73a6..08ce72316bfe 100644
--- a/fs/xfs/xfs_iomap.c
+++ b/fs/xfs/xfs_iomap.c
@@ -155,7 +155,7 @@ xfs_imap_to_bmap(
155 iomapp->iomap_bn = IOMAP_DADDR_NULL; 155 iomapp->iomap_bn = IOMAP_DADDR_NULL;
156 iomapp->iomap_flags |= IOMAP_DELAY; 156 iomapp->iomap_flags |= IOMAP_DELAY;
157 } else { 157 } else {
158 iomapp->iomap_bn = XFS_FSB_TO_DB(ip, start_block); 158 iomapp->iomap_bn = xfs_fsb_to_db(ip, start_block);
159 if (ISUNWRITTEN(imap)) 159 if (ISUNWRITTEN(imap))
160 iomapp->iomap_flags |= IOMAP_UNWRITTEN; 160 iomapp->iomap_flags |= IOMAP_UNWRITTEN;
161 } 161 }
@@ -261,7 +261,7 @@ xfs_iomap(
261 xfs_iunlock(ip, lockmode); 261 xfs_iunlock(ip, lockmode);
262 lockmode = 0; 262 lockmode = 0;
263 263
264 if (nimaps && !ISNULLSTARTBLOCK(imap.br_startblock)) { 264 if (nimaps && !isnullstartblock(imap.br_startblock)) {
265 xfs_iomap_map_trace(XFS_IOMAP_WRITE_MAP, ip, 265 xfs_iomap_map_trace(XFS_IOMAP_WRITE_MAP, ip,
266 offset, count, iomapp, &imap, flags); 266 offset, count, iomapp, &imap, flags);
267 break; 267 break;
@@ -491,7 +491,7 @@ xfs_iomap_write_direct(
491 /* 491 /*
492 * Issue the xfs_bmapi() call to allocate the blocks 492 * Issue the xfs_bmapi() call to allocate the blocks
493 */ 493 */
494 XFS_BMAP_INIT(&free_list, &firstfsb); 494 xfs_bmap_init(&free_list, &firstfsb);
495 nimaps = 1; 495 nimaps = 1;
496 error = xfs_bmapi(tp, ip, offset_fsb, count_fsb, bmapi_flag, 496 error = xfs_bmapi(tp, ip, offset_fsb, count_fsb, bmapi_flag,
497 &firstfsb, 0, &imap, &nimaps, &free_list, NULL); 497 &firstfsb, 0, &imap, &nimaps, &free_list, NULL);
@@ -751,7 +751,7 @@ xfs_iomap_write_allocate(
751 xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL); 751 xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);
752 xfs_trans_ihold(tp, ip); 752 xfs_trans_ihold(tp, ip);
753 753
754 XFS_BMAP_INIT(&free_list, &first_block); 754 xfs_bmap_init(&free_list, &first_block);
755 755
756 /* 756 /*
757 * it is possible that the extents have changed since 757 * it is possible that the extents have changed since
@@ -911,7 +911,7 @@ xfs_iomap_write_unwritten(
911 /* 911 /*
912 * Modify the unwritten extent state of the buffer. 912 * Modify the unwritten extent state of the buffer.
913 */ 913 */
914 XFS_BMAP_INIT(&free_list, &firstfsb); 914 xfs_bmap_init(&free_list, &firstfsb);
915 nimaps = 1; 915 nimaps = 1;
916 error = xfs_bmapi(tp, ip, offset_fsb, count_fsb, 916 error = xfs_bmapi(tp, ip, offset_fsb, count_fsb,
917 XFS_BMAPI_WRITE|XFS_BMAPI_CONVERT, &firstfsb, 917 XFS_BMAPI_WRITE|XFS_BMAPI_CONVERT, &firstfsb,
diff --git a/fs/xfs/xfs_itable.c b/fs/xfs/xfs_itable.c
index e19d0a8d5618..cf98a805ec90 100644
--- a/fs/xfs/xfs_itable.c
+++ b/fs/xfs/xfs_itable.c
@@ -453,7 +453,7 @@ xfs_bulkstat(
453 (chunkidx = agino - gino + 1) < 453 (chunkidx = agino - gino + 1) <
454 XFS_INODES_PER_CHUNK && 454 XFS_INODES_PER_CHUNK &&
455 /* there are some left allocated */ 455 /* there are some left allocated */
456 XFS_INOBT_MASKN(chunkidx, 456 xfs_inobt_maskn(chunkidx,
457 XFS_INODES_PER_CHUNK - chunkidx) & ~gfree) { 457 XFS_INODES_PER_CHUNK - chunkidx) & ~gfree) {
458 /* 458 /*
459 * Grab the chunk record. Mark all the 459 * Grab the chunk record. Mark all the
@@ -464,7 +464,7 @@ xfs_bulkstat(
464 if (XFS_INOBT_MASK(i) & ~gfree) 464 if (XFS_INOBT_MASK(i) & ~gfree)
465 gcnt++; 465 gcnt++;
466 } 466 }
467 gfree |= XFS_INOBT_MASKN(0, chunkidx); 467 gfree |= xfs_inobt_maskn(0, chunkidx);
468 irbp->ir_startino = gino; 468 irbp->ir_startino = gino;
469 irbp->ir_freecount = gcnt; 469 irbp->ir_freecount = gcnt;
470 irbp->ir_free = gfree; 470 irbp->ir_free = gfree;
@@ -535,7 +535,7 @@ xfs_bulkstat(
535 chunkidx < XFS_INODES_PER_CHUNK; 535 chunkidx < XFS_INODES_PER_CHUNK;
536 chunkidx += nicluster, 536 chunkidx += nicluster,
537 agbno += nbcluster) { 537 agbno += nbcluster) {
538 if (XFS_INOBT_MASKN(chunkidx, 538 if (xfs_inobt_maskn(chunkidx,
539 nicluster) & ~gfree) 539 nicluster) & ~gfree)
540 xfs_btree_reada_bufs(mp, agno, 540 xfs_btree_reada_bufs(mp, agno,
541 agbno, nbcluster); 541 agbno, nbcluster);
diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c
index 35cca98bd94c..b1047de2fffd 100644
--- a/fs/xfs/xfs_log_recover.c
+++ b/fs/xfs/xfs_log_recover.c
@@ -70,16 +70,21 @@ STATIC void xlog_recover_check_summary(xlog_t *);
70xfs_buf_t * 70xfs_buf_t *
71xlog_get_bp( 71xlog_get_bp(
72 xlog_t *log, 72 xlog_t *log,
73 int num_bblks) 73 int nbblks)
74{ 74{
75 ASSERT(num_bblks > 0); 75 if (nbblks <= 0 || nbblks > log->l_logBBsize) {
76 xlog_warn("XFS: Invalid block length (0x%x) given for buffer", nbblks);
77 XFS_ERROR_REPORT("xlog_get_bp(1)",
78 XFS_ERRLEVEL_HIGH, log->l_mp);
79 return NULL;
80 }
76 81
77 if (log->l_sectbb_log) { 82 if (log->l_sectbb_log) {
78 if (num_bblks > 1) 83 if (nbblks > 1)
79 num_bblks += XLOG_SECTOR_ROUNDUP_BBCOUNT(log, 1); 84 nbblks += XLOG_SECTOR_ROUNDUP_BBCOUNT(log, 1);
80 num_bblks = XLOG_SECTOR_ROUNDUP_BBCOUNT(log, num_bblks); 85 nbblks = XLOG_SECTOR_ROUNDUP_BBCOUNT(log, nbblks);
81 } 86 }
82 return xfs_buf_get_noaddr(BBTOB(num_bblks), log->l_mp->m_logdev_targp); 87 return xfs_buf_get_noaddr(BBTOB(nbblks), log->l_mp->m_logdev_targp);
83} 88}
84 89
85void 90void
@@ -102,6 +107,13 @@ xlog_bread(
102{ 107{
103 int error; 108 int error;
104 109
110 if (nbblks <= 0 || nbblks > log->l_logBBsize) {
111 xlog_warn("XFS: Invalid block length (0x%x) given for buffer", nbblks);
112 XFS_ERROR_REPORT("xlog_bread(1)",
113 XFS_ERRLEVEL_HIGH, log->l_mp);
114 return EFSCORRUPTED;
115 }
116
105 if (log->l_sectbb_log) { 117 if (log->l_sectbb_log) {
106 blk_no = XLOG_SECTOR_ROUNDDOWN_BLKNO(log, blk_no); 118 blk_no = XLOG_SECTOR_ROUNDDOWN_BLKNO(log, blk_no);
107 nbblks = XLOG_SECTOR_ROUNDUP_BBCOUNT(log, nbblks); 119 nbblks = XLOG_SECTOR_ROUNDUP_BBCOUNT(log, nbblks);
@@ -139,6 +151,13 @@ xlog_bwrite(
139{ 151{
140 int error; 152 int error;
141 153
154 if (nbblks <= 0 || nbblks > log->l_logBBsize) {
155 xlog_warn("XFS: Invalid block length (0x%x) given for buffer", nbblks);
156 XFS_ERROR_REPORT("xlog_bwrite(1)",
157 XFS_ERRLEVEL_HIGH, log->l_mp);
158 return EFSCORRUPTED;
159 }
160
142 if (log->l_sectbb_log) { 161 if (log->l_sectbb_log) {
143 blk_no = XLOG_SECTOR_ROUNDDOWN_BLKNO(log, blk_no); 162 blk_no = XLOG_SECTOR_ROUNDDOWN_BLKNO(log, blk_no);
144 nbblks = XLOG_SECTOR_ROUNDUP_BBCOUNT(log, nbblks); 163 nbblks = XLOG_SECTOR_ROUNDUP_BBCOUNT(log, nbblks);
diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c
index 3c97c6463a4e..35300250e86d 100644
--- a/fs/xfs/xfs_mount.c
+++ b/fs/xfs/xfs_mount.c
@@ -45,7 +45,6 @@
45#include "xfs_fsops.h" 45#include "xfs_fsops.h"
46#include "xfs_utils.h" 46#include "xfs_utils.h"
47 47
48STATIC int xfs_mount_log_sb(xfs_mount_t *, __int64_t);
49STATIC int xfs_uuid_mount(xfs_mount_t *); 48STATIC int xfs_uuid_mount(xfs_mount_t *);
50STATIC void xfs_unmountfs_wait(xfs_mount_t *); 49STATIC void xfs_unmountfs_wait(xfs_mount_t *);
51 50
@@ -682,7 +681,7 @@ xfs_initialize_perag_data(xfs_mount_t *mp, xfs_agnumber_t agcount)
682 * Update alignment values based on mount options and sb values 681 * Update alignment values based on mount options and sb values
683 */ 682 */
684STATIC int 683STATIC int
685xfs_update_alignment(xfs_mount_t *mp, __uint64_t *update_flags) 684xfs_update_alignment(xfs_mount_t *mp)
686{ 685{
687 xfs_sb_t *sbp = &(mp->m_sb); 686 xfs_sb_t *sbp = &(mp->m_sb);
688 687
@@ -736,11 +735,11 @@ xfs_update_alignment(xfs_mount_t *mp, __uint64_t *update_flags)
736 if (xfs_sb_version_hasdalign(sbp)) { 735 if (xfs_sb_version_hasdalign(sbp)) {
737 if (sbp->sb_unit != mp->m_dalign) { 736 if (sbp->sb_unit != mp->m_dalign) {
738 sbp->sb_unit = mp->m_dalign; 737 sbp->sb_unit = mp->m_dalign;
739 *update_flags |= XFS_SB_UNIT; 738 mp->m_update_flags |= XFS_SB_UNIT;
740 } 739 }
741 if (sbp->sb_width != mp->m_swidth) { 740 if (sbp->sb_width != mp->m_swidth) {
742 sbp->sb_width = mp->m_swidth; 741 sbp->sb_width = mp->m_swidth;
743 *update_flags |= XFS_SB_WIDTH; 742 mp->m_update_flags |= XFS_SB_WIDTH;
744 } 743 }
745 } 744 }
746 } else if ((mp->m_flags & XFS_MOUNT_NOALIGN) != XFS_MOUNT_NOALIGN && 745 } else if ((mp->m_flags & XFS_MOUNT_NOALIGN) != XFS_MOUNT_NOALIGN &&
@@ -905,7 +904,6 @@ xfs_mountfs(
905 xfs_sb_t *sbp = &(mp->m_sb); 904 xfs_sb_t *sbp = &(mp->m_sb);
906 xfs_inode_t *rip; 905 xfs_inode_t *rip;
907 __uint64_t resblks; 906 __uint64_t resblks;
908 __int64_t update_flags = 0LL;
909 uint quotamount, quotaflags; 907 uint quotamount, quotaflags;
910 int uuid_mounted = 0; 908 int uuid_mounted = 0;
911 int error = 0; 909 int error = 0;
@@ -933,7 +931,7 @@ xfs_mountfs(
933 "XFS: correcting sb_features alignment problem"); 931 "XFS: correcting sb_features alignment problem");
934 sbp->sb_features2 |= sbp->sb_bad_features2; 932 sbp->sb_features2 |= sbp->sb_bad_features2;
935 sbp->sb_bad_features2 = sbp->sb_features2; 933 sbp->sb_bad_features2 = sbp->sb_features2;
936 update_flags |= XFS_SB_FEATURES2 | XFS_SB_BAD_FEATURES2; 934 mp->m_update_flags |= XFS_SB_FEATURES2 | XFS_SB_BAD_FEATURES2;
937 935
938 /* 936 /*
939 * Re-check for ATTR2 in case it was found in bad_features2 937 * Re-check for ATTR2 in case it was found in bad_features2
@@ -947,11 +945,11 @@ xfs_mountfs(
947 if (xfs_sb_version_hasattr2(&mp->m_sb) && 945 if (xfs_sb_version_hasattr2(&mp->m_sb) &&
948 (mp->m_flags & XFS_MOUNT_NOATTR2)) { 946 (mp->m_flags & XFS_MOUNT_NOATTR2)) {
949 xfs_sb_version_removeattr2(&mp->m_sb); 947 xfs_sb_version_removeattr2(&mp->m_sb);
950 update_flags |= XFS_SB_FEATURES2; 948 mp->m_update_flags |= XFS_SB_FEATURES2;
951 949
952 /* update sb_versionnum for the clearing of the morebits */ 950 /* update sb_versionnum for the clearing of the morebits */
953 if (!sbp->sb_features2) 951 if (!sbp->sb_features2)
954 update_flags |= XFS_SB_VERSIONNUM; 952 mp->m_update_flags |= XFS_SB_VERSIONNUM;
955 } 953 }
956 954
957 /* 955 /*
@@ -960,7 +958,7 @@ xfs_mountfs(
960 * allocator alignment is within an ag, therefore ag has 958 * allocator alignment is within an ag, therefore ag has
961 * to be aligned at stripe boundary. 959 * to be aligned at stripe boundary.
962 */ 960 */
963 error = xfs_update_alignment(mp, &update_flags); 961 error = xfs_update_alignment(mp);
964 if (error) 962 if (error)
965 goto error1; 963 goto error1;
966 964
@@ -1137,10 +1135,12 @@ xfs_mountfs(
1137 } 1135 }
1138 1136
1139 /* 1137 /*
1140 * If fs is not mounted readonly, then update the superblock changes. 1138 * If this is a read-only mount defer the superblock updates until
1139 * the next remount into writeable mode. Otherwise we would never
1140 * perform the update e.g. for the root filesystem.
1141 */ 1141 */
1142 if (update_flags && !(mp->m_flags & XFS_MOUNT_RDONLY)) { 1142 if (mp->m_update_flags && !(mp->m_flags & XFS_MOUNT_RDONLY)) {
1143 error = xfs_mount_log_sb(mp, update_flags); 1143 error = xfs_mount_log_sb(mp, mp->m_update_flags);
1144 if (error) { 1144 if (error) {
1145 cmn_err(CE_WARN, "XFS: failed to write sb changes"); 1145 cmn_err(CE_WARN, "XFS: failed to write sb changes");
1146 goto error4; 1146 goto error4;
@@ -1820,7 +1820,7 @@ xfs_uuid_mount(
1820 * be altered by the mount options, as well as any potential sb_features2 1820 * be altered by the mount options, as well as any potential sb_features2
1821 * fixup. Only the first superblock is updated. 1821 * fixup. Only the first superblock is updated.
1822 */ 1822 */
1823STATIC int 1823int
1824xfs_mount_log_sb( 1824xfs_mount_log_sb(
1825 xfs_mount_t *mp, 1825 xfs_mount_t *mp,
1826 __int64_t fields) 1826 __int64_t fields)
diff --git a/fs/xfs/xfs_mount.h b/fs/xfs/xfs_mount.h
index c1e028467327..f5e9937f9bdb 100644
--- a/fs/xfs/xfs_mount.h
+++ b/fs/xfs/xfs_mount.h
@@ -44,9 +44,9 @@ typedef struct xfs_trans_reservations {
44 44
45#ifndef __KERNEL__ 45#ifndef __KERNEL__
46 46
47#define XFS_DADDR_TO_AGNO(mp,d) \ 47#define xfs_daddr_to_agno(mp,d) \
48 ((xfs_agnumber_t)(XFS_BB_TO_FSBT(mp, d) / (mp)->m_sb.sb_agblocks)) 48 ((xfs_agnumber_t)(XFS_BB_TO_FSBT(mp, d) / (mp)->m_sb.sb_agblocks))
49#define XFS_DADDR_TO_AGBNO(mp,d) \ 49#define xfs_daddr_to_agbno(mp,d) \
50 ((xfs_agblock_t)(XFS_BB_TO_FSBT(mp, d) % (mp)->m_sb.sb_agblocks)) 50 ((xfs_agblock_t)(XFS_BB_TO_FSBT(mp, d) % (mp)->m_sb.sb_agblocks))
51 51
52#else /* __KERNEL__ */ 52#else /* __KERNEL__ */
@@ -327,6 +327,8 @@ typedef struct xfs_mount {
327 spinlock_t m_sync_lock; /* work item list lock */ 327 spinlock_t m_sync_lock; /* work item list lock */
328 int m_sync_seq; /* sync thread generation no. */ 328 int m_sync_seq; /* sync thread generation no. */
329 wait_queue_head_t m_wait_single_sync_task; 329 wait_queue_head_t m_wait_single_sync_task;
330 __int64_t m_update_flags; /* sb flags we need to update
331 on the next remount,rw */
330} xfs_mount_t; 332} xfs_mount_t;
331 333
332/* 334/*
@@ -439,7 +441,6 @@ void xfs_do_force_shutdown(struct xfs_mount *mp, int flags, char *fname,
439 */ 441 */
440#define XFS_MFSI_QUIET 0x40 /* Be silent if mount errors found */ 442#define XFS_MFSI_QUIET 0x40 /* Be silent if mount errors found */
441 443
442#define XFS_DADDR_TO_AGNO(mp,d) xfs_daddr_to_agno(mp,d)
443static inline xfs_agnumber_t 444static inline xfs_agnumber_t
444xfs_daddr_to_agno(struct xfs_mount *mp, xfs_daddr_t d) 445xfs_daddr_to_agno(struct xfs_mount *mp, xfs_daddr_t d)
445{ 446{
@@ -448,7 +449,6 @@ xfs_daddr_to_agno(struct xfs_mount *mp, xfs_daddr_t d)
448 return (xfs_agnumber_t) ld; 449 return (xfs_agnumber_t) ld;
449} 450}
450 451
451#define XFS_DADDR_TO_AGBNO(mp,d) xfs_daddr_to_agbno(mp,d)
452static inline xfs_agblock_t 452static inline xfs_agblock_t
453xfs_daddr_to_agbno(struct xfs_mount *mp, xfs_daddr_t d) 453xfs_daddr_to_agbno(struct xfs_mount *mp, xfs_daddr_t d)
454{ 454{
@@ -514,6 +514,7 @@ extern int xfs_mod_incore_sb_unlocked(xfs_mount_t *, xfs_sb_field_t,
514 int64_t, int); 514 int64_t, int);
515extern int xfs_mod_incore_sb_batch(xfs_mount_t *, xfs_mod_sb_t *, 515extern int xfs_mod_incore_sb_batch(xfs_mount_t *, xfs_mod_sb_t *,
516 uint, int); 516 uint, int);
517extern int xfs_mount_log_sb(xfs_mount_t *, __int64_t);
517extern struct xfs_buf *xfs_getsb(xfs_mount_t *, int); 518extern struct xfs_buf *xfs_getsb(xfs_mount_t *, int);
518extern int xfs_readsb(xfs_mount_t *, int); 519extern int xfs_readsb(xfs_mount_t *, int);
519extern void xfs_freesb(xfs_mount_t *); 520extern void xfs_freesb(xfs_mount_t *);
diff --git a/fs/xfs/xfs_rename.c b/fs/xfs/xfs_rename.c
index 86471bb40fd4..58f85e9cd11d 100644
--- a/fs/xfs/xfs_rename.c
+++ b/fs/xfs/xfs_rename.c
@@ -147,7 +147,7 @@ xfs_rename(
147 xfs_sort_for_rename(src_dp, target_dp, src_ip, target_ip, 147 xfs_sort_for_rename(src_dp, target_dp, src_ip, target_ip,
148 inodes, &num_inodes); 148 inodes, &num_inodes);
149 149
150 XFS_BMAP_INIT(&free_list, &first_block); 150 xfs_bmap_init(&free_list, &first_block);
151 tp = xfs_trans_alloc(mp, XFS_TRANS_RENAME); 151 tp = xfs_trans_alloc(mp, XFS_TRANS_RENAME);
152 cancel_flags = XFS_TRANS_RELEASE_LOG_RES; 152 cancel_flags = XFS_TRANS_RELEASE_LOG_RES;
153 spaceres = XFS_RENAME_SPACE_RES(mp, target_name->len); 153 spaceres = XFS_RENAME_SPACE_RES(mp, target_name->len);
diff --git a/fs/xfs/xfs_rtalloc.c b/fs/xfs/xfs_rtalloc.c
index edf12c7b834c..c5bb86f3ec05 100644
--- a/fs/xfs/xfs_rtalloc.c
+++ b/fs/xfs/xfs_rtalloc.c
@@ -120,7 +120,7 @@ xfs_growfs_rt_alloc(
120 if ((error = xfs_trans_iget(mp, tp, ino, 0, 120 if ((error = xfs_trans_iget(mp, tp, ino, 0,
121 XFS_ILOCK_EXCL, &ip))) 121 XFS_ILOCK_EXCL, &ip)))
122 goto error_cancel; 122 goto error_cancel;
123 XFS_BMAP_INIT(&flist, &firstblock); 123 xfs_bmap_init(&flist, &firstblock);
124 /* 124 /*
125 * Allocate blocks to the bitmap file. 125 * Allocate blocks to the bitmap file.
126 */ 126 */
diff --git a/fs/xfs/xfs_rw.h b/fs/xfs/xfs_rw.h
index f87db5344ce6..f76c003ec55d 100644
--- a/fs/xfs/xfs_rw.h
+++ b/fs/xfs/xfs_rw.h
@@ -28,7 +28,6 @@ struct xfs_mount;
28 * file is a real time file or not, because the bmap code 28 * file is a real time file or not, because the bmap code
29 * does. 29 * does.
30 */ 30 */
31#define XFS_FSB_TO_DB(ip,fsb) xfs_fsb_to_db(ip,fsb)
32static inline xfs_daddr_t 31static inline xfs_daddr_t
33xfs_fsb_to_db(struct xfs_inode *ip, xfs_fsblock_t fsb) 32xfs_fsb_to_db(struct xfs_inode *ip, xfs_fsblock_t fsb)
34{ 33{
diff --git a/fs/xfs/xfs_sb.h b/fs/xfs/xfs_sb.h
index 1ed71916e4c9..1b017c657494 100644
--- a/fs/xfs/xfs_sb.h
+++ b/fs/xfs/xfs_sb.h
@@ -505,7 +505,7 @@ static inline void xfs_sb_version_removeattr2(xfs_sb_t *sbp)
505 505
506#define XFS_HDR_BLOCK(mp,d) ((xfs_agblock_t)XFS_BB_TO_FSBT(mp,d)) 506#define XFS_HDR_BLOCK(mp,d) ((xfs_agblock_t)XFS_BB_TO_FSBT(mp,d))
507#define XFS_DADDR_TO_FSB(mp,d) XFS_AGB_TO_FSB(mp, \ 507#define XFS_DADDR_TO_FSB(mp,d) XFS_AGB_TO_FSB(mp, \
508 XFS_DADDR_TO_AGNO(mp,d), XFS_DADDR_TO_AGBNO(mp,d)) 508 xfs_daddr_to_agno(mp,d), xfs_daddr_to_agbno(mp,d))
509#define XFS_FSB_TO_DADDR(mp,fsbno) XFS_AGB_TO_DADDR(mp, \ 509#define XFS_FSB_TO_DADDR(mp,fsbno) XFS_AGB_TO_DADDR(mp, \
510 XFS_FSB_TO_AGNO(mp,fsbno), XFS_FSB_TO_AGBNO(mp,fsbno)) 510 XFS_FSB_TO_AGNO(mp,fsbno), XFS_FSB_TO_AGBNO(mp,fsbno))
511 511
diff --git a/fs/xfs/xfs_types.h b/fs/xfs/xfs_types.h
index 0f5191644ab2..b2f724502f1b 100644
--- a/fs/xfs/xfs_types.h
+++ b/fs/xfs/xfs_types.h
@@ -45,7 +45,7 @@ typedef __uint32_t prid_t; /* project ID */
45typedef __uint32_t inst_t; /* an instruction */ 45typedef __uint32_t inst_t; /* an instruction */
46 46
47typedef __s64 xfs_off_t; /* <file offset> type */ 47typedef __s64 xfs_off_t; /* <file offset> type */
48typedef __u64 xfs_ino_t; /* <inode> type */ 48typedef unsigned long long xfs_ino_t; /* <inode> type */
49typedef __s64 xfs_daddr_t; /* <disk address> type */ 49typedef __s64 xfs_daddr_t; /* <disk address> type */
50typedef char * xfs_caddr_t; /* <core address> type */ 50typedef char * xfs_caddr_t; /* <core address> type */
51typedef __u32 xfs_dev_t; 51typedef __u32 xfs_dev_t;
@@ -111,8 +111,6 @@ typedef __uint64_t xfs_fileoff_t; /* block number in a file */
111typedef __int64_t xfs_sfiloff_t; /* signed block number in a file */ 111typedef __int64_t xfs_sfiloff_t; /* signed block number in a file */
112typedef __uint64_t xfs_filblks_t; /* number of blocks in a file */ 112typedef __uint64_t xfs_filblks_t; /* number of blocks in a file */
113 113
114typedef __uint8_t xfs_arch_t; /* architecture of an xfs fs */
115
116/* 114/*
117 * Null values for the types. 115 * Null values for the types.
118 */ 116 */
diff --git a/fs/xfs/xfs_vnodeops.c b/fs/xfs/xfs_vnodeops.c
index f07bf8768c3a..0e55c5d7db5f 100644
--- a/fs/xfs/xfs_vnodeops.c
+++ b/fs/xfs/xfs_vnodeops.c
@@ -862,7 +862,7 @@ xfs_inactive_symlink_rmt(
862 * Find the block(s) so we can inval and unmap them. 862 * Find the block(s) so we can inval and unmap them.
863 */ 863 */
864 done = 0; 864 done = 0;
865 XFS_BMAP_INIT(&free_list, &first_block); 865 xfs_bmap_init(&free_list, &first_block);
866 nmaps = ARRAY_SIZE(mval); 866 nmaps = ARRAY_SIZE(mval);
867 if ((error = xfs_bmapi(tp, ip, 0, XFS_B_TO_FSB(mp, size), 867 if ((error = xfs_bmapi(tp, ip, 0, XFS_B_TO_FSB(mp, size),
868 XFS_BMAPI_METADATA, &first_block, 0, mval, &nmaps, 868 XFS_BMAPI_METADATA, &first_block, 0, mval, &nmaps,
@@ -1288,7 +1288,7 @@ xfs_inactive(
1288 /* 1288 /*
1289 * Free the inode. 1289 * Free the inode.
1290 */ 1290 */
1291 XFS_BMAP_INIT(&free_list, &first_block); 1291 xfs_bmap_init(&free_list, &first_block);
1292 error = xfs_ifree(tp, ip, &free_list); 1292 error = xfs_ifree(tp, ip, &free_list);
1293 if (error) { 1293 if (error) {
1294 /* 1294 /*
@@ -1461,7 +1461,7 @@ xfs_create(
1461 xfs_ilock(dp, XFS_ILOCK_EXCL | XFS_ILOCK_PARENT); 1461 xfs_ilock(dp, XFS_ILOCK_EXCL | XFS_ILOCK_PARENT);
1462 unlock_dp_on_error = B_TRUE; 1462 unlock_dp_on_error = B_TRUE;
1463 1463
1464 XFS_BMAP_INIT(&free_list, &first_block); 1464 xfs_bmap_init(&free_list, &first_block);
1465 1465
1466 ASSERT(ip == NULL); 1466 ASSERT(ip == NULL);
1467 1467
@@ -1879,7 +1879,7 @@ xfs_remove(
1879 } 1879 }
1880 } 1880 }
1881 1881
1882 XFS_BMAP_INIT(&free_list, &first_block); 1882 xfs_bmap_init(&free_list, &first_block);
1883 error = xfs_dir_removename(tp, dp, name, ip->i_ino, 1883 error = xfs_dir_removename(tp, dp, name, ip->i_ino,
1884 &first_block, &free_list, resblks); 1884 &first_block, &free_list, resblks);
1885 if (error) { 1885 if (error) {
@@ -2059,7 +2059,7 @@ xfs_link(
2059 if (error) 2059 if (error)
2060 goto error_return; 2060 goto error_return;
2061 2061
2062 XFS_BMAP_INIT(&free_list, &first_block); 2062 xfs_bmap_init(&free_list, &first_block);
2063 2063
2064 error = xfs_dir_createname(tp, tdp, target_name, sip->i_ino, 2064 error = xfs_dir_createname(tp, tdp, target_name, sip->i_ino,
2065 &first_block, &free_list, resblks); 2065 &first_block, &free_list, resblks);
@@ -2231,7 +2231,7 @@ xfs_mkdir(
2231 xfs_trans_ijoin(tp, dp, XFS_ILOCK_EXCL); 2231 xfs_trans_ijoin(tp, dp, XFS_ILOCK_EXCL);
2232 unlock_dp_on_error = B_FALSE; 2232 unlock_dp_on_error = B_FALSE;
2233 2233
2234 XFS_BMAP_INIT(&free_list, &first_block); 2234 xfs_bmap_init(&free_list, &first_block);
2235 2235
2236 error = xfs_dir_createname(tp, dp, dir_name, cdp->i_ino, 2236 error = xfs_dir_createname(tp, dp, dir_name, cdp->i_ino,
2237 &first_block, &free_list, resblks ? 2237 &first_block, &free_list, resblks ?
@@ -2438,7 +2438,7 @@ xfs_symlink(
2438 * Initialize the bmap freelist prior to calling either 2438 * Initialize the bmap freelist prior to calling either
2439 * bmapi or the directory create code. 2439 * bmapi or the directory create code.
2440 */ 2440 */
2441 XFS_BMAP_INIT(&free_list, &first_block); 2441 xfs_bmap_init(&free_list, &first_block);
2442 2442
2443 /* 2443 /*
2444 * Allocate an inode for the symlink. 2444 * Allocate an inode for the symlink.
@@ -2860,7 +2860,7 @@ retry:
2860 /* 2860 /*
2861 * Issue the xfs_bmapi() call to allocate the blocks 2861 * Issue the xfs_bmapi() call to allocate the blocks
2862 */ 2862 */
2863 XFS_BMAP_INIT(&free_list, &firstfsb); 2863 xfs_bmap_init(&free_list, &firstfsb);
2864 error = xfs_bmapi(tp, ip, startoffset_fsb, 2864 error = xfs_bmapi(tp, ip, startoffset_fsb,
2865 allocatesize_fsb, bmapi_flag, 2865 allocatesize_fsb, bmapi_flag,
2866 &firstfsb, 0, imapp, &nimaps, 2866 &firstfsb, 0, imapp, &nimaps,
@@ -2980,7 +2980,7 @@ xfs_zero_remaining_bytes(
2980 XFS_BUF_UNDONE(bp); 2980 XFS_BUF_UNDONE(bp);
2981 XFS_BUF_UNWRITE(bp); 2981 XFS_BUF_UNWRITE(bp);
2982 XFS_BUF_READ(bp); 2982 XFS_BUF_READ(bp);
2983 XFS_BUF_SET_ADDR(bp, XFS_FSB_TO_DB(ip, imap.br_startblock)); 2983 XFS_BUF_SET_ADDR(bp, xfs_fsb_to_db(ip, imap.br_startblock));
2984 xfsbdstrat(mp, bp); 2984 xfsbdstrat(mp, bp);
2985 error = xfs_iowait(bp); 2985 error = xfs_iowait(bp);
2986 if (error) { 2986 if (error) {
@@ -3186,7 +3186,7 @@ xfs_free_file_space(
3186 /* 3186 /*
3187 * issue the bunmapi() call to free the blocks 3187 * issue the bunmapi() call to free the blocks
3188 */ 3188 */
3189 XFS_BMAP_INIT(&free_list, &firstfsb); 3189 xfs_bmap_init(&free_list, &firstfsb);
3190 error = xfs_bunmapi(tp, ip, startoffset_fsb, 3190 error = xfs_bunmapi(tp, ip, startoffset_fsb,
3191 endoffset_fsb - startoffset_fsb, 3191 endoffset_fsb - startoffset_fsb,
3192 0, 2, &firstfsb, &free_list, NULL, &done); 3192 0, 2, &firstfsb, &free_list, NULL, &done);