diff -Nru a/Makefile b/Makefile
--- a/Makefile	Mon Apr  7 09:42:21 2003
+++ b/Makefile	Tue Apr  8 04:25:10 2003
@@ -1,7 +1,7 @@
 VERSION = 2
 PATCHLEVEL = 5
 SUBLEVEL = 67
-EXTRAVERSION =
+EXTRAVERSION = -bk1
 
 # *DOCUMENTATION*
 # To see a list of typical targets execute "make help"
diff -Nru a/fs/xfs/linux/xfs_aops.c b/fs/xfs/linux/xfs_aops.c
--- a/fs/xfs/linux/xfs_aops.c	Wed Mar 26 10:25:07 2003
+++ b/fs/xfs/linux/xfs_aops.c	Mon Apr  7 12:05:42 2003
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000-2002 Silicon Graphics, Inc.  All Rights Reserved.
+ * Copyright (c) 2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of version 2 of the GNU General Public License as
@@ -48,8 +48,11 @@
 	clear_buffer_unwritten(bh);
 	if (!uptodate)
 		pagebuf_ioerror(pb, -EIO);
-	if (atomic_dec_and_test(&pb->pb_io_remaining) == 1)
+	if (atomic_dec_and_test(&pb->pb_io_remaining) == 1) {
 		pagebuf_iodone(pb, 1, 1);
+		pb->pb_flags &= ~_PBF_LOCKABLE;
+		pagebuf_rele(pb);
+	}
 	end_buffer_async_write(bh, uptodate);
 }
 
@@ -160,7 +163,7 @@
 	delta -= mp->pbm_offset;
 	delta >>= block_bits;
 
-	sector_shift = block_bits - 9;
+	sector_shift = block_bits - BBSHIFT;
 	bn = mp->pbm_bn >> sector_shift;
 	bn += delta;
 	ASSERT((bn << sector_shift) >= mp->pbm_bn);
@@ -282,7 +285,7 @@
 		total += bh->b_size;
 	} while ((bh = bh->b_this_page) != head);
 
-	/* if we reached the end of the page, sum forwards in
+	/* If we reached the end of the page, sum forwards in
 	 * following pages.
 	 */
 	if (bh == head) {
@@ -438,8 +441,11 @@
 	XFS_BUF_SET_FSPRIVATE(pb, LINVFS_GET_VP(inode)->v_fbhv);
 	XFS_BUF_SET_IODONE_FUNC(pb, xfs_unwritten_conv);
 
-	if (atomic_dec_and_test(&pb->pb_io_remaining) == 1)
+	if (atomic_dec_and_test(&pb->pb_io_remaining) == 1) {
 		pagebuf_iodone(pb, 1, 1);
+		pb->pb_flags &= ~_PBF_LOCKABLE;
+		pagebuf_rele(pb);
+	}
 
 	return 0;
 }
@@ -729,8 +735,8 @@
 					page_dirty = 0;
 				}
 			} else if (startio) {
-				if (buffer_uptodate(bh)) {
-					lock_buffer(bh);
+				if (buffer_uptodate(bh) &&
+				    !test_and_set_bit(BH_Lock, &bh->b_state)) {
 					bh_arr[cnt++] = bh;
 					page_dirty = 0;
 				}
@@ -753,8 +759,7 @@
 	}
 
 	if (mp) {
-		cluster_write(inode, page->index + 1, mp,
-				startio, unmapped);
+		cluster_write(inode, page->index + 1, mp, startio, unmapped);
 	}
 
 	return page_dirty;
@@ -763,7 +768,7 @@
 	for (i = 0; i < cnt; i++) {
 		unlock_buffer(bh_arr[i]);
 	}
-	
+
 	/*
 	 * If it's delalloc and we have nowhere to put it,
 	 * throw it away, unless the lower layers told
@@ -806,8 +811,7 @@
 		size = 1 << inode->i_blkbits;
 
 	VOP_BMAP(vp, offset, size,
-		create ? flags : PBF_READ,
-		(struct page_buf_bmap_s *)&pbmap, &retpbbm, error);
+		create ? flags : PBF_READ, &pbmap, &retpbbm, error);
 	if (error)
 		return -error;
 
@@ -825,7 +829,7 @@
 			delta = offset - pbmap.pbm_offset;
 			delta >>= inode->i_blkbits;
 
-			bn = pbmap.pbm_bn >> (inode->i_blkbits - 9);
+			bn = pbmap.pbm_bn >> (inode->i_blkbits - BBSHIFT);
 			bn += delta;
 
 			bh_result->b_blocknr = bn;
diff -Nru a/fs/xfs/linux/xfs_file.c b/fs/xfs/linux/xfs_file.c
--- a/fs/xfs/linux/xfs_file.c	Wed Mar 26 10:04:08 2003
+++ b/fs/xfs/linux/xfs_file.c	Mon Apr  7 12:05:42 2003
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000-2002 Silicon Graphics, Inc.  All Rights Reserved.
+ * Copyright (c) 2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of version 2 of the GNU General Public License as
@@ -136,6 +136,7 @@
 	return linvfs_writev(iocb->ki_filp, &iov, 1, &iocb->ki_pos);
 }
 
+
 STATIC ssize_t
 linvfs_sendfile(
 	struct file		*filp,
@@ -199,9 +200,7 @@
 		flags |= FSYNC_DATA;
 
 	ASSERT(vp);
-
 	VOP_FSYNC(vp, flags, NULL, (xfs_off_t)0, (xfs_off_t)-1, error);
-
 	return -error;
 }
 
@@ -287,6 +286,7 @@
 	kfree(read_buf);
 	return -error;
 }
+
 
 STATIC int
 linvfs_file_mmap(
diff -Nru a/fs/xfs/linux/xfs_globals.c b/fs/xfs/linux/xfs_globals.c
--- a/fs/xfs/linux/xfs_globals.c	Wed Mar 26 10:11:41 2003
+++ b/fs/xfs/linux/xfs_globals.c	Mon Apr  7 10:36:06 2003
@@ -49,11 +49,6 @@
 xfs_param_t xfs_params = { 0, 1, 0, 0, 0, 3 };
 
 /*
- * Used to serialize atomicIncWithWrap.
- */
-spinlock_t xfs_atomic_spin = SPIN_LOCK_UNLOCKED;
-
-/*
  * Global system credential structure.
  */
 cred_t sys_cred_val, *sys_cred = &sys_cred_val;
diff -Nru a/fs/xfs/linux/xfs_globals.h b/fs/xfs/linux/xfs_globals.h
--- a/fs/xfs/linux/xfs_globals.h	Wed Mar 26 10:11:41 2003
+++ b/fs/xfs/linux/xfs_globals.h	Mon Apr  7 10:36:06 2003
@@ -38,11 +38,7 @@
  */
 
 extern uint64_t xfs_panic_mask;		/* set to cause more panics */
-
 extern unsigned long xfs_physmem;
-
-extern spinlock_t xfs_atomic_spin;
-
 extern struct cred *sys_cred;
 
 #endif	/* __XFS_GLOBALS_H__ */
diff -Nru a/fs/xfs/linux/xfs_ioctl.c b/fs/xfs/linux/xfs_ioctl.c
--- a/fs/xfs/linux/xfs_ioctl.c	Tue Mar 25 13:39:31 2003
+++ b/fs/xfs/linux/xfs_ioctl.c	Mon Apr  7 12:05:43 2003
@@ -39,11 +39,6 @@
 #include <linux/pagemap.h>
 
 
-extern int xfs_change_file_space(bhv_desc_t *, int,
-			xfs_flock64_t *, xfs_off_t, cred_t *, int);
-extern int xfs_set_dmattrs(bhv_desc_t *, u_int, u_int16_t, cred_t *);
-
-
 /*
  * xfs_find_handle maps from userspace xfs_fsop_handlereq structure to
  * a file or fs handle.
diff -Nru a/fs/xfs/linux/xfs_lrw.c b/fs/xfs/linux/xfs_lrw.c
--- a/fs/xfs/linux/xfs_lrw.c	Wed Mar 26 10:04:08 2003
+++ b/fs/xfs/linux/xfs_lrw.c	Mon Apr  7 12:05:43 2003
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000-2002 Silicon Graphics, Inc.  All Rights Reserved.
+ * Copyright (c) 2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of version 2 of the GNU General Public License as
diff -Nru a/fs/xfs/linux/xfs_lrw.h b/fs/xfs/linux/xfs_lrw.h
--- a/fs/xfs/linux/xfs_lrw.h	Mon Mar 17 14:05:46 2003
+++ b/fs/xfs/linux/xfs_lrw.h	Mon Apr  7 12:05:43 2003
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000-2002 Silicon Graphics, Inc.  All Rights Reserved.
+ * Copyright (c) 2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of version 2 of the GNU General Public License as
diff -Nru a/fs/xfs/linux/xfs_super.c b/fs/xfs/linux/xfs_super.c
--- a/fs/xfs/linux/xfs_super.c	Wed Mar 26 10:04:08 2003
+++ b/fs/xfs/linux/xfs_super.c	Mon Apr  7 12:05:43 2003
@@ -257,7 +257,7 @@
 	};
 	struct proc_xfs_info	*xfs_infop;
 	struct xfs_mount	*mp = XFS_BHVTOM(bhv);
-	char b[BDEVNAME_SIZE];
+	char			b[BDEVNAME_SIZE];
 
 	for (xfs_infop = xfs_info; xfs_infop->flag; xfs_infop++) {
 		if (mp->m_flags & xfs_infop->flag)
diff -Nru a/fs/xfs/support/atomic.h b/fs/xfs/support/atomic.h
--- a/fs/xfs/support/atomic.h	Wed Mar 26 10:11:41 2003
+++ /dev/null	Wed Dec 31 16:00:00 1969
@@ -1,63 +0,0 @@
-/*
- * Copyright (c) 2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it is
- * free of the rightful claim of any third person regarding infringement
- * or the like.	 Any license provided herein, whether implied or
- * otherwise, applies only to this software file.  Patent licenses, if
- * any, provided herein do not apply to combinations of this program with
- * other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc., 59
- * Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
- * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
- * Mountain View, CA  94043, or:
- *
- * http://www.sgi.com
- *
- * For further information regarding this notice, see:
- *
- * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
- */
-#ifndef __XFS_SUPPORT_ATOMIC_H__
-#define __XFS_SUPPORT_ATOMIC_H__
-
-#include <linux/version.h>
-#include <linux/time.h>
-#include <linux/wait.h>
-#include <linux/sched.h>
-#include <asm/atomic.h>
-#include <asm/semaphore.h>
-
-/*
- * This is used for two variables in XFS, one of which is a debug trace
- * buffer index. They are not accessed via any other atomic operations
- * so this is safe. All other atomic increments and decrements in XFS
- * now use the Linux built-in functions.
- */
-
-extern spinlock_t xfs_atomic_spin;
-
-static __inline__ int atomicIncWithWrap(int *ip, int val)
-{
-	unsigned long flags;
-	int ret;
-	spin_lock_irqsave(&xfs_atomic_spin, flags);
-	ret = *ip;
-	(*ip)++;
-	if (*ip == val) *ip = 0;
-	spin_unlock_irqrestore(&xfs_atomic_spin, flags);
-	return ret;
-}
-
-#endif /* __XFS_SUPPORT_ATOMIC_H__ */
diff -Nru a/fs/xfs/support/ktrace.c b/fs/xfs/support/ktrace.c
--- a/fs/xfs/support/ktrace.c	Wed Sep 11 11:12:13 2002
+++ b/fs/xfs/support/ktrace.c	Mon Apr  7 10:36:06 2003
@@ -37,7 +37,6 @@
 #include "kmem.h"
 #include "spin.h"
 #include "debug.h"
-#include "atomic.h"
 #include "ktrace.h"
 
 #if	(defined(DEBUG) || defined(CONFIG_XFS_VNODE_TRACING))
@@ -181,6 +180,7 @@
 	void		*val14,
 	void		*val15)
 {
+	static lock_t   wrap_lock = SPIN_LOCK_UNLOCKED;
 	int		index;
 	ktrace_entry_t	*ktep;
 
@@ -189,7 +189,11 @@
 	/*
 	 * Grab an entry by pushing the index up to the next one.
 	 */
-	index = atomicIncWithWrap(&ktp->kt_index, ktp->kt_nentries);
+	spin_lock(&wrap_lock);
+	index = ktp->kt_index;
+	if (++ktp->kt_index == ktp->kt_nentries)
+		ktp->kt_index = 0;
+	spin_unlock(&wrap_lock);
 
 	if (!ktp->kt_rollover && index == ktp->kt_nentries - 1)
 		ktp->kt_rollover = 1;
diff -Nru a/fs/xfs/xfs.h b/fs/xfs/xfs.h
--- a/fs/xfs/xfs.h	Wed Mar 26 10:04:08 2003
+++ b/fs/xfs/xfs.h	Mon Apr  7 10:36:06 2003
@@ -46,7 +46,6 @@
 #include <support/ktrace.h>
 #include <support/mutex.h>
 #include <support/sema.h>
-#include <support/atomic.h>
 #include <support/debug.h>
 #include <support/move.h>
 #include <support/uuid.h>
diff -Nru a/fs/xfs/xfs_bmap_btree.h b/fs/xfs/xfs_bmap_btree.h
--- a/fs/xfs/xfs_bmap_btree.h	Mon Mar 17 12:00:45 2003
+++ b/fs/xfs/xfs_bmap_btree.h	Mon Apr  7 10:33:39 2003
@@ -459,6 +459,8 @@
 #endif
 
 
+#ifdef __KERNEL__
+
 /*
  * Prototypes for xfs_bmap.c to call.
  */
@@ -706,5 +708,6 @@
 	xfs_bmbt_irec_t *,
 	xfs_bmbt_irec_t *);
 
+#endif	/* __KERNEL__ */
 
 #endif	/* __XFS_BMAP_BTREE_H__ */
diff -Nru a/fs/xfs/xfs_dmapi.h b/fs/xfs/xfs_dmapi.h
--- a/fs/xfs/xfs_dmapi.h	Wed Mar 26 10:23:03 2003
+++ b/fs/xfs/xfs_dmapi.h	Mon Apr  7 12:05:43 2003
@@ -186,7 +186,7 @@
 
 extern struct bhv_vfsops xfs_dmops;
 
-extern void xfs_dm_init(void);
-extern void xfs_dm_exit(void);
+extern int dmapi_init(void);
+extern void dmapi_uninit(void);
 
 #endif	/* __XFS_DMAPI_H__ */
diff -Nru a/fs/xfs/xfs_fs.h b/fs/xfs/xfs_fs.h
--- a/fs/xfs/xfs_fs.h	Tue Dec  3 13:14:52 2002
+++ b/fs/xfs/xfs_fs.h	Mon Apr  7 10:33:39 2003
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995-2002 Silicon Graphics, Inc.  All Rights Reserved.
+ * Copyright (c) 1995-2003 Silicon Graphics, Inc.  All Rights Reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of version 2.1 of the GNU Lesser General Public License
@@ -44,21 +44,25 @@
  * d_miniosz is the min xfer size, xfer size multiple and file seek offset
  * alignment.
  */
+#ifndef HAVE_DIOATTR
 struct dioattr {
 	__u32		d_mem;		/* data buffer memory alignment */
 	__u32		d_miniosz;	/* min xfer size		*/
 	__u32		d_maxiosz;	/* max xfer size		*/
 };
+#endif
 
 /*
  * Structure for XFS_IOC_FSGETXATTR[A] and XFS_IOC_FSSETXATTR.
  */
+#ifndef HAVE_FSXATTR
 struct fsxattr {
 	__u32		fsx_xflags;	/* xflags field value (get/set) */
 	__u32		fsx_extsize;	/* extsize field value (get/set)*/
 	__u32		fsx_nextents;	/* nextents field value (get)	*/
 	unsigned char	fsx_pad[16];
 };
+#endif
 
 /*
  * Flags for the bs_xflags/fsx_xflags field
@@ -79,6 +83,7 @@
  * number of array elements given.  The first structure is updated on
  * return to give the offset and length for the next call.
  */
+#ifndef HAVE_GETBMAP
 struct getbmap {
 	__s64		bmv_offset;	/* file offset of segment in blocks */
 	__s64		bmv_block;	/* starting block (64-bit daddr_t)  */
@@ -86,6 +91,7 @@
 	__s32		bmv_count;	/* # of entries in array incl. 1st  */
 	__s32		bmv_entries;	/* # of entries filled in (output)  */
 };
+#endif
 
 /*
  *	Structure for XFS_IOC_GETBMAPX.	 Fields bmv_offset through bmv_entries
@@ -96,6 +102,7 @@
  *	in by the XFS_IOC_GETBMAPX command for each returned structure after
  *	the first.
  */
+#ifndef HAVE_GETBMAPX
 struct getbmapx {
 	__s64		bmv_offset;	/* file offset of segment in blocks */
 	__s64		bmv_block;	/* starting block (64-bit daddr_t)  */
@@ -107,6 +114,7 @@
 	__s32		bmv_unused1;	/* future use			    */
 	__s32		bmv_unused2;	/* future use			    */
 };
+#endif
 
 /*	bmv_iflags values - set by XFS_IOC_GETBMAPX caller.	*/
 #define BMV_IF_ATTRFORK		0x1	/* return attr fork rather than data */
@@ -136,11 +144,13 @@
  * only values previously obtained via xfs_bulkstat!  (Specifically the
  * xfs_bstat_t fields bs_dmevmask and bs_dmstate.)
  */
+#ifndef HAVE_FSDMIDATA
 struct fsdmidata {
 	__u32		fsd_dmevmask;	/* corresponds to di_dmevmask */
 	__u16		fsd_padding;
 	__u16		fsd_dmstate;	/* corresponds to di_dmstate  */
 };
+#endif
 
 /*
  * File segment locking set data type for 64 bit access.
@@ -391,7 +401,7 @@
  * This is typically called by a stateless file server in order to generate
  * "file handles".
  */
-#ifndef MAXFIDSZ
+#ifndef HAVE_FID
 #define MAXFIDSZ	46
 typedef struct fid {
 	__u16		fid_len;		/* length of data in bytes */
@@ -472,7 +482,7 @@
 #define XFS_IOC_FSGROWFSLOG	     _IOW ('X', 111, struct xfs_growfs_log)
 #define XFS_IOC_FSGROWFSRT	     _IOW ('X', 112, struct xfs_growfs_rt)
 #define XFS_IOC_FSCOUNTS	     _IOR ('X', 113, struct xfs_fsop_counts)
-#define XFS_IOC_SET_RESBLKS	     _IOR ('X', 114, struct xfs_fsop_resblks)
+#define XFS_IOC_SET_RESBLKS	     _IOWR('X', 114, struct xfs_fsop_resblks)
 #define XFS_IOC_GET_RESBLKS	     _IOR ('X', 115, struct xfs_fsop_resblks)
 #define XFS_IOC_ERROR_INJECTION	     _IOW ('X', 116, struct xfs_error_injection)
 #define XFS_IOC_ERROR_CLEARALL	     _IOW ('X', 117, struct xfs_error_injection)
@@ -486,6 +496,7 @@
 /*	XFS_IOC_GETFSUUID ---------- deprecated 140	 */
 
 
+#ifndef HAVE_BBMACROS
 /*
  * Block I/O parameterization.	A basic block (BB) is the lowest size of
  * filesystem allocation, and must equal 512.  Length units given to bio
@@ -497,5 +508,6 @@
 #define BTOBB(bytes)	(((__u64)(bytes) + BBSIZE - 1) >> BBSHIFT)
 #define BTOBBT(bytes)	((__u64)(bytes) >> BBSHIFT)
 #define BBTOB(bbs)	((bbs) << BBSHIFT)
+#endif
 
 #endif	/* __XFS_FS_H__ */
diff -Nru a/fs/xfs/xfs_ialloc.c b/fs/xfs/xfs_ialloc.c
--- a/fs/xfs/xfs_ialloc.c	Mon Mar 17 12:19:20 2003
+++ b/fs/xfs/xfs_ialloc.c	Mon Apr  7 10:36:06 2003
@@ -336,6 +336,21 @@
 	return 0;
 }
 
+STATIC __inline xfs_agnumber_t
+xfs_ialloc_next_ag(
+	xfs_mount_t	*mp)
+{
+	xfs_agnumber_t	agno;
+
+	spin_lock(&mp->m_agirotor_lock);
+	agno = mp->m_agirotor;
+	if (++mp->m_agirotor == mp->m_maxagi)
+		mp->m_agirotor = 0;
+	spin_unlock(&mp->m_agirotor_lock);
+
+	return agno;
+}
+
 /*
  * Select an allocation group to look for a free inode in, based on the parent
  * inode and then mode.	 Return the allocation group buffer.
@@ -366,7 +381,7 @@
 	mp = tp->t_mountp;
 	agcount = mp->m_maxagi;
 	if (S_ISDIR(mode))
-		pagno = atomicIncWithWrap((int *)&mp->m_agirotor, agcount);
+		pagno = xfs_ialloc_next_ag(mp);
 	else {
 		pagno = XFS_INO_TO_AGNO(mp, parent);
 		if (pagno >= agcount)
@@ -394,7 +409,7 @@
 			agbp = NULL;
 
 		if (!pag->pagi_inodeok) {
-			atomicIncWithWrap((int *)&mp->m_agirotor, agcount);
+			xfs_ialloc_next_ag(mp);
 			goto unlock_nextag;
 		}
 
diff -Nru a/fs/xfs/xfs_iget.c b/fs/xfs/xfs_iget.c
--- a/fs/xfs/xfs_iget.c	Wed Mar 26 10:11:41 2003
+++ b/fs/xfs/xfs_iget.c	Mon Apr  7 12:05:43 2003
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000-2002 Silicon Graphics, Inc.  All Rights Reserved.
+ * Copyright (c) 2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of version 2 of the GNU General Public License as
diff -Nru a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
--- a/fs/xfs/xfs_inode.c	Wed Mar 26 10:27:23 2003
+++ b/fs/xfs/xfs_inode.c	Mon Apr  7 10:17:06 2003
@@ -3608,31 +3608,6 @@
 	ip->i_update_core = 1;
 }
 
-/*
- * xfs_ibusy_check -- Checks whether inode reference count allows unmount
- *
- * The value returned is one if the reference count would prevent an unmount.
- */
-int
-xfs_ibusy_check(
-	xfs_inode_t	*ip,
-	int		refs)
-{
-	xfs_mount_t	*mp = ip->i_mount;
-
-	if ((refs == 1) && (ip == mp->m_rootip))
-		return (0);
-	if ((refs == 1) && (ip == mp->m_rbmip))
-		return (0);
-	if ((refs == 1) && (ip == mp->m_rsumip))
-		return (0);
-	if (mp->m_quotainfo && ip->i_ino == mp->m_sb.sb_uquotino)
-		return (0);
-	if (mp->m_quotainfo && ip->i_ino == mp->m_sb.sb_gquotino)
-		return (0);
-	return (1);
-}
-
 #ifdef XFS_ILOCK_TRACE
 void
 xfs_ilock_trace(xfs_inode_t *ip, int lock, unsigned int lockflags, inst_t *ra)
diff -Nru a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h
--- a/fs/xfs/xfs_inode.h	Wed Mar 26 10:11:41 2003
+++ b/fs/xfs/xfs_inode.h	Mon Apr  7 10:17:06 2003
@@ -516,7 +516,6 @@
 int		xfs_iextents_copy(xfs_inode_t *, xfs_bmbt_rec_t *, int);
 int		xfs_iflush(xfs_inode_t *, uint);
 int		xfs_iflush_all(struct xfs_mount *, int);
-int		xfs_ibusy_check(xfs_inode_t *, int);
 int		xfs_iaccess(xfs_inode_t *, mode_t, cred_t *);
 uint		xfs_iroundup(uint);
 void		xfs_ichgtime(xfs_inode_t *, int);
diff -Nru a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c
--- a/fs/xfs/xfs_mount.c	Wed Mar 26 10:04:09 2003
+++ b/fs/xfs/xfs_mount.c	Mon Apr  7 10:36:06 2003
@@ -509,6 +509,7 @@
 	int	i;
 
 	mp->m_agfrotor = mp->m_agirotor = 0;
+	spinlock_init(&mp->m_agirotor_lock, "m_agirotor_lock");
 	mp->m_maxagi = mp->m_sb.sb_agcount;
 	mp->m_blkbit_log = sbp->sb_blocklog + XFS_NBBYLOG;
 	mp->m_blkbb_log = sbp->sb_blocklog - BBSHIFT;
diff -Nru a/fs/xfs/xfs_mount.h b/fs/xfs/xfs_mount.h
--- a/fs/xfs/xfs_mount.h	Wed Mar 26 10:04:09 2003
+++ b/fs/xfs/xfs_mount.h	Mon Apr  7 10:36:06 2003
@@ -291,6 +291,7 @@
 	int			m_bsize;	/* fs logical block size */
 	xfs_agnumber_t		m_agfrotor;	/* last ag where space found */
 	xfs_agnumber_t		m_agirotor;	/* last ag dir inode alloced */
+	lock_t			m_agirotor_lock;/* .. and lock protecting it */
 	xfs_agnumber_t		m_maxagi;	/* highest inode alloc group */
 	int			m_ihsize;	/* size of next field */
 	struct xfs_ihash	*m_ihash;	/* fs private inode hash table*/
diff -Nru a/fs/xfs/xfs_rw.h b/fs/xfs/xfs_rw.h
--- a/fs/xfs/xfs_rw.h	Wed Nov  6 11:26:10 2002
+++ b/fs/xfs/xfs_rw.h	Mon Apr  7 12:05:43 2003
@@ -153,39 +153,55 @@
 xfs_bioerror(
 	struct xfs_buf		*b);
 
-/*
- * XFS I/O core functions
- */
-extern int xfs_bioerror_relse(struct xfs_buf *);
+int
+xfs_bioerror_relse(
+	struct xfs_buf		*b);
+
+int
+xfs_read_buf(
+	struct xfs_mount	*mp,
+	xfs_buftarg_t		*target,
+	xfs_daddr_t		blkno,
+	int			len,
+	uint			flags,
+	struct xfs_buf		**bpp);
+
+void
+xfs_ioerror_alert(
+	char			*func,
+	struct xfs_mount	*mp,
+	xfs_buf_t		*bp,
+	xfs_daddr_t		blkno);
 
 
 /*
- * Needed by xfs_rw.c
+ * Prototypes for functions in xfs_vnodeops.c.
  */
+
 int
 xfs_rwlock(
-	bhv_desc_t	*bdp,
-	vrwlock_t	write_lock);
+	bhv_desc_t		*bdp,
+	vrwlock_t		write_lock);
 
 void
 xfs_rwunlock(
-	bhv_desc_t	*bdp,
-	vrwlock_t	write_lock);
+	bhv_desc_t		*bdp,
+	vrwlock_t		write_lock);
 
 int
-xfs_read_buf(
-	struct xfs_mount *mp,
-	xfs_buftarg_t	 *target,
-	xfs_daddr_t	 blkno,
-	int		 len,
-	uint		 flags,
-	struct xfs_buf	 **bpp);
+xfs_change_file_space(
+	bhv_desc_t		*bdp,
+	int			cmd,
+	xfs_flock64_t		*bf,
+	xfs_off_t		offset,
+	cred_t			*credp,
+	int			flags);
 
-void
-xfs_ioerror_alert(
-	char			*func,
-	struct xfs_mount	*mp,
-	xfs_buf_t		*bp,
-	xfs_daddr_t		blkno);
+int
+xfs_set_dmattrs(
+	bhv_desc_t		*bdp,
+	u_int			evmask,
+	u_int16_t		state,
+	cred_t			*credp);
 
 #endif /* __XFS_RW_H__ */
diff -Nru a/fs/xfs/xfs_vfsops.c b/fs/xfs/xfs_vfsops.c
--- a/fs/xfs/xfs_vfsops.c	Wed Mar 26 10:04:09 2003
+++ b/fs/xfs/xfs_vfsops.c	Mon Apr  7 10:17:06 2003
@@ -34,9 +34,7 @@
 
 #include <xfs.h>
 
-STATIC int xfs_ibusy(xfs_mount_t *);
 STATIC int xfs_sync(bhv_desc_t *, int, cred_t *);
-STATIC int xfs_unmount(bhv_desc_t *, int, cred_t *);
 
 int
 xfs_init(void)
@@ -485,59 +483,6 @@
 	return error;
 }
 
-/*
- * xfs_ibusy searches for a busy inode in the mounted file system.
- *
- * Return 0 if there are no active inodes otherwise return 1.
- */
-STATIC int
-xfs_ibusy(
-	xfs_mount_t	*mp)
-{
-	xfs_inode_t	*ip;
-	vnode_t		*vp;
-	int		busy;
-
-	busy = 0;
-
-	XFS_MOUNT_ILOCK(mp);
-
-	ip = mp->m_inodes;
-	if (ip == NULL) {
-		XFS_MOUNT_IUNLOCK(mp);
-		return busy;
-	}
-
-	do {
-		/* Skip markers inserted by xfs_sync */
-		if (ip->i_mount == NULL) {
-			ip = ip->i_mnext;
-			continue;
-		}
-
-		vp = XFS_ITOV_NULL(ip);
-
-		if (vp && vn_count(vp) != 0) {
-			if (xfs_ibusy_check(ip, vn_count(vp)) == 0) {
-				ip = ip->i_mnext;
-				continue;
-			}
-#ifdef DEBUG
-			cmn_err(CE_WARN, "%s: busy vp=0x%p ip=0x%p "
-					 "inum %Ld count=%d",
-				__FUNCTION__, vp, ip, ip->i_ino, vn_count(vp));
-#endif
-			busy++;
-		}
-		ip = ip->i_mnext;
-	} while ((ip != mp->m_inodes) && !busy);
-
-	XFS_MOUNT_IUNLOCK(mp);
-
-	return busy;
-}
-
-
 STATIC int
 xfs_unmount(
 	bhv_desc_t	*bdp,
@@ -570,16 +515,6 @@
 		unmount_event_wanted = 1;
 		unmount_event_flags = (mp->m_dmevmask & (1<<DM_EVENT_UNMOUNT))?
 					0 : DM_FLAGS_UNWANTED;
-	}
-
-	/*
-	 * Make sure there are no active users.
-	 */
-	if (xfs_ibusy(mp)) {
-		error = XFS_ERROR(EBUSY);
-		cmn_err(CE_ALERT, "%s: xfs_ibusy failed -- error code %d",
-			__FUNCTION__, error);
-		goto out;
 	}
 
 	XFS_bflush(mp->m_ddev_targp);
