Merge git://oss.sgi.com:8090/oss/git/xfs-2.6
authorLinus Torvalds <torvalds@g5.osdl.org>
Thu, 23 Mar 2006 23:28:51 +0000 (15:28 -0800)
committerLinus Torvalds <torvalds@g5.osdl.org>
Thu, 23 Mar 2006 23:28:51 +0000 (15:28 -0800)
* git://oss.sgi.com:8090/oss/git/xfs-2.6: (71 commits)
  [XFS] Sync up one/two other minor changes missed in previous merges.
  [XFS] Reenable the noikeep (delete inode cluster space) option by default.
  [XFS] Check that a page has dirty buffers before finding it acceptable for
  [XFS] Fixup naming inconsistencies found by Pekka Enberg and one from Jan
  [XFS] Explain the race closed by the addition of vn_iowait() to the start
  [XFS] Fixing the error caused by the conflict between DIO Write's
  [XFS] Fixing KDB's xrwtrc command, also added the current process id into
  [XFS] Fix compiler warning from xfs_file_compat_invis_ioctl prototype.
  [XFS] remove bogus INT_GET for u8 variables in xfs_dir_leaf.c
  [XFS] endianess annotations for xfs_da_node_hdr_t
  [XFS] endianess annotations for xfs_da_node_entry_t
  [XFS] store xfs_attr_inactive_list_t in native endian
  [XFS] store xfs_attr_sf_sort in native endian
  [XFS] endianess annotations for xfs_attr_shortform_t
  [XFS] endianess annotations for xfs_attr_leaf_name_remote_t
  [XFS] endianess annotations for xfs_attr_leaf_name_local_t
  [XFS] endianess annotations for xfs_attr_leaf_entry_t
  [XFS] endianess annotations for xfs_attr_leaf_hdr_t
  [XFS] remove bogus INT_GET on u8 variables in xfs_dir2_block.c
  [XFS] endianess annotations for xfs_da_blkinfo_t
  ...

68 files changed:
fs/xfs/Makefile-linux-2.6
fs/xfs/linux-2.6/kmem.h
fs/xfs/linux-2.6/xfs_aops.c
fs/xfs/linux-2.6/xfs_aops.h
fs/xfs/linux-2.6/xfs_buf.c
fs/xfs/linux-2.6/xfs_export.c
fs/xfs/linux-2.6/xfs_file.c
fs/xfs/linux-2.6/xfs_fs_subr.c
fs/xfs/linux-2.6/xfs_ioctl.c
fs/xfs/linux-2.6/xfs_ioctl32.c
fs/xfs/linux-2.6/xfs_ioctl32.h
fs/xfs/linux-2.6/xfs_iops.c
fs/xfs/linux-2.6/xfs_iops.h
fs/xfs/linux-2.6/xfs_linux.h
fs/xfs/linux-2.6/xfs_lrw.c
fs/xfs/linux-2.6/xfs_super.c
fs/xfs/linux-2.6/xfs_super.h
fs/xfs/linux-2.6/xfs_vfs.c
fs/xfs/linux-2.6/xfs_vfs.h
fs/xfs/linux-2.6/xfs_vnode.c
fs/xfs/linux-2.6/xfs_vnode.h
fs/xfs/quota/xfs_dquot_item.c
fs/xfs/quota/xfs_qm.c
fs/xfs/quota/xfs_qm_bhv.c
fs/xfs/support/ktrace.c
fs/xfs/support/uuid.c
fs/xfs/xfs_acl.h
fs/xfs/xfs_attr.c
fs/xfs/xfs_attr_leaf.c
fs/xfs/xfs_attr_leaf.h
fs/xfs/xfs_attr_sf.h
fs/xfs/xfs_bmap.c
fs/xfs/xfs_bmap.h
fs/xfs/xfs_bmap_btree.c
fs/xfs/xfs_bmap_btree.h
fs/xfs/xfs_clnt.h
fs/xfs/xfs_da_btree.c
fs/xfs/xfs_da_btree.h
fs/xfs/xfs_dfrag.c
fs/xfs/xfs_dir.c
fs/xfs/xfs_dir2.h
fs/xfs/xfs_dir2_block.c
fs/xfs/xfs_dir2_block.h
fs/xfs/xfs_dir2_data.c
fs/xfs/xfs_dir2_data.h
fs/xfs/xfs_dir2_leaf.c
fs/xfs/xfs_dir2_leaf.h
fs/xfs/xfs_dir2_node.c
fs/xfs/xfs_dir2_node.h
fs/xfs/xfs_dir2_sf.c
fs/xfs/xfs_dir_leaf.c
fs/xfs/xfs_dir_sf.h
fs/xfs/xfs_dmapi.h
fs/xfs/xfs_fsops.c
fs/xfs/xfs_ialloc.c
fs/xfs/xfs_iget.c
fs/xfs/xfs_inode.c
fs/xfs/xfs_inode.h
fs/xfs/xfs_iomap.c
fs/xfs/xfs_itable.c
fs/xfs/xfs_log_recover.c
fs/xfs/xfs_mount.c
fs/xfs/xfs_mount.h
fs/xfs/xfs_rw.h
fs/xfs/xfs_trans.c
fs/xfs/xfs_trans.h
fs/xfs/xfs_vfsops.c
fs/xfs/xfs_vnodeops.c

index 97bd4743b461d73f8c124294bbd769b505eafd51..5d73eaa1971fbb3679f480cda5d0e616e723d27b 100644 (file)
@@ -1,33 +1,19 @@
 #
-# Copyright (c) 2000-2005 Silicon Graphics, Inc.  All Rights Reserved.
+# Copyright (c) 2000-2005 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
+# This program is free software; you can redistribute it and/or
+# modify it under the terms 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.
+# 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.  See the
+# GNU General Public License for more details.
 #
-# 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/
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
 EXTRA_CFLAGS +=         -Ifs/xfs -Ifs/xfs/linux-2.6 -funsigned-char
@@ -36,7 +22,7 @@ XFS_LINUX := linux-2.6
 
 ifeq ($(CONFIG_XFS_DEBUG),y)
        EXTRA_CFLAGS += -g -DSTATIC="" -DDEBUG
-       EXTRA_CFLAGS += -DPAGEBUF_LOCK_TRACKING
+       EXTRA_CFLAGS += -DXFS_BUF_LOCK_TRACKING
 endif
 ifeq ($(CONFIG_XFS_TRACE),y)
        EXTRA_CFLAGS += -DXFS_ALLOC_TRACE
@@ -50,7 +36,7 @@ ifeq ($(CONFIG_XFS_TRACE),y)
        EXTRA_CFLAGS += -DXFS_ILOCK_TRACE
        EXTRA_CFLAGS += -DXFS_LOG_TRACE
        EXTRA_CFLAGS += -DXFS_RW_TRACE
-       EXTRA_CFLAGS += -DPAGEBUF_TRACE
+       EXTRA_CFLAGS += -DXFS_BUF_TRACE
        EXTRA_CFLAGS += -DXFS_VNODE_TRACE
 endif
 
index c64a29cdfff3446835da2e29ed3774840a551b97..f0268a84e6fd8dcb38b2cbf1bf3b3792a54563b8 100644 (file)
 #include <linux/mm.h>
 
 /*
- * memory management routines
+ * Process flags handling
  */
-#define KM_SLEEP       0x0001u
-#define KM_NOSLEEP     0x0002u
-#define KM_NOFS                0x0004u
-#define KM_MAYFAIL     0x0008u
-
-#define        kmem_zone       kmem_cache
-#define kmem_zone_t    struct kmem_cache
-
-typedef unsigned long xfs_pflags_t;
 
 #define PFLAGS_TEST_NOIO()              (current->flags & PF_NOIO)
 #define PFLAGS_TEST_FSTRANS()           (current->flags & PF_FSTRANS)
@@ -67,74 +58,102 @@ typedef unsigned long xfs_pflags_t;
        *(NSTATEP) = *(OSTATEP);        \
 } while (0)
 
-static __inline gfp_t kmem_flags_convert(unsigned int __nocast flags)
+/*
+ * General memory allocation interfaces
+ */
+
+#define KM_SLEEP       0x0001u
+#define KM_NOSLEEP     0x0002u
+#define KM_NOFS                0x0004u
+#define KM_MAYFAIL     0x0008u
+
+/*
+ * We use a special process flag to avoid recursive callbacks into
+ * the filesystem during transactions.  We will also issue our own
+ * warnings, so we explicitly skip any generic ones (silly of us).
+ */
+static inline gfp_t
+kmem_flags_convert(unsigned int __nocast flags)
 {
-       gfp_t   lflags = __GFP_NOWARN;  /* we'll report problems, if need be */
+       gfp_t   lflags;
 
-#ifdef DEBUG
-       if (unlikely(flags & ~(KM_SLEEP|KM_NOSLEEP|KM_NOFS|KM_MAYFAIL))) {
-               printk(KERN_WARNING
-                   "XFS: memory allocation with wrong flags (%x)\n", flags);
-               BUG();
-       }
-#endif
+       BUG_ON(flags & ~(KM_SLEEP|KM_NOSLEEP|KM_NOFS|KM_MAYFAIL));
 
        if (flags & KM_NOSLEEP) {
-               lflags |= GFP_ATOMIC;
+               lflags = GFP_ATOMIC | __GFP_NOWARN;
        } else {
-               lflags |= GFP_KERNEL;
-
-               /* avoid recusive callbacks to filesystem during transactions */
+               lflags = GFP_KERNEL | __GFP_NOWARN;
                if (PFLAGS_TEST_FSTRANS() || (flags & KM_NOFS))
                        lflags &= ~__GFP_FS;
        }
-
-        return lflags;
+       return lflags;
 }
 
-static __inline kmem_zone_t *
+extern void *kmem_alloc(size_t, unsigned int __nocast);
+extern void *kmem_realloc(void *, size_t, size_t, unsigned int __nocast);
+extern void *kmem_zalloc(size_t, unsigned int __nocast);
+extern void  kmem_free(void *, size_t);
+
+/*
+ * Zone interfaces
+ */
+
+#define KM_ZONE_HWALIGN        SLAB_HWCACHE_ALIGN
+#define KM_ZONE_RECLAIM        SLAB_RECLAIM_ACCOUNT
+#define KM_ZONE_SPREAD 0
+
+#define kmem_zone      kmem_cache
+#define kmem_zone_t    struct kmem_cache
+
+static inline kmem_zone_t *
 kmem_zone_init(int size, char *zone_name)
 {
        return kmem_cache_create(zone_name, size, 0, 0, NULL, NULL);
 }
 
-static __inline void
+static inline kmem_zone_t *
+kmem_zone_init_flags(int size, char *zone_name, unsigned long flags,
+                    void (*construct)(void *, kmem_zone_t *, unsigned long))
+{
+       return kmem_cache_create(zone_name, size, 0, flags, construct, NULL);
+}
+
+static inline void
 kmem_zone_free(kmem_zone_t *zone, void *ptr)
 {
        kmem_cache_free(zone, ptr);
 }
 
-static __inline void
+static inline void
 kmem_zone_destroy(kmem_zone_t *zone)
 {
        if (zone && kmem_cache_destroy(zone))
                BUG();
 }
 
-extern void *kmem_zone_zalloc(kmem_zone_t *, unsigned int __nocast);
 extern void *kmem_zone_alloc(kmem_zone_t *, unsigned int __nocast);
+extern void *kmem_zone_zalloc(kmem_zone_t *, unsigned int __nocast);
 
-extern void *kmem_alloc(size_t, unsigned int __nocast);
-extern void *kmem_realloc(void *, size_t, size_t, unsigned int __nocast);
-extern void *kmem_zalloc(size_t, unsigned int __nocast);
-extern void  kmem_free(void *, size_t);
+/*
+ * Low memory cache shrinkers
+ */
 
 typedef struct shrinker *kmem_shaker_t;
 typedef int (*kmem_shake_func_t)(int, gfp_t);
 
-static __inline kmem_shaker_t
+static inline kmem_shaker_t
 kmem_shake_register(kmem_shake_func_t sfunc)
 {
        return set_shrinker(DEFAULT_SEEKS, sfunc);
 }
 
-static __inline void
+static inline void
 kmem_shake_deregister(kmem_shaker_t shrinker)
 {
        remove_shrinker(shrinker);
 }
 
-static __inline int
+static inline int
 kmem_shake_allow(gfp_t gfp_mask)
 {
        return (gfp_mask & __GFP_WAIT);
index 74d8be87f983d4995c32bc87ebcc89ff33b577bb..97fc056130ebe981ec119964dd0be95e4523643b 100644 (file)
 #include <linux/pagevec.h>
 #include <linux/writeback.h>
 
-STATIC void xfs_count_page_state(struct page *, int *, int *, int *);
+STATIC void
+xfs_count_page_state(
+       struct page             *page,
+       int                     *delalloc,
+       int                     *unmapped,
+       int                     *unwritten)
+{
+       struct buffer_head      *bh, *head;
+
+       *delalloc = *unmapped = *unwritten = 0;
+
+       bh = head = page_buffers(page);
+       do {
+               if (buffer_uptodate(bh) && !buffer_mapped(bh))
+                       (*unmapped) = 1;
+               else if (buffer_unwritten(bh) && !buffer_delay(bh))
+                       clear_buffer_unwritten(bh);
+               else if (buffer_unwritten(bh))
+                       (*unwritten) = 1;
+               else if (buffer_delay(bh))
+                       (*delalloc) = 1;
+       } while ((bh = bh->b_this_page) != head);
+}
 
 #if defined(XFS_RW_TRACE)
 void
@@ -54,7 +76,7 @@ xfs_page_trace(
        int             mask)
 {
        xfs_inode_t     *ip;
-       vnode_t         *vp = LINVFS_GET_VP(inode);
+       vnode_t         *vp = vn_from_inode(inode);
        loff_t          isize = i_size_read(inode);
        loff_t          offset = page_offset(page);
        int             delalloc = -1, unmapped = -1, unwritten = -1;
@@ -81,7 +103,7 @@ xfs_page_trace(
                (void *)((unsigned long)delalloc),
                (void *)((unsigned long)unmapped),
                (void *)((unsigned long)unwritten),
-               (void *)NULL,
+               (void *)((unsigned long)current_pid()),
                (void *)NULL);
 }
 #else
@@ -192,7 +214,7 @@ xfs_alloc_ioend(
        ioend->io_uptodate = 1; /* cleared if any I/O fails */
        ioend->io_list = NULL;
        ioend->io_type = type;
-       ioend->io_vnode = LINVFS_GET_VP(inode);
+       ioend->io_vnode = vn_from_inode(inode);
        ioend->io_buffer_head = NULL;
        ioend->io_buffer_tail = NULL;
        atomic_inc(&ioend->io_vnode->v_iocount);
@@ -217,7 +239,7 @@ xfs_map_blocks(
        xfs_iomap_t             *mapp,
        int                     flags)
 {
-       vnode_t                 *vp = LINVFS_GET_VP(inode);
+       vnode_t                 *vp = vn_from_inode(inode);
        int                     error, nmaps = 1;
 
        VOP_BMAP(vp, offset, count, flags, mapp, &nmaps, error);
@@ -461,6 +483,26 @@ xfs_add_to_ioend(
        ioend->io_size += bh->b_size;
 }
 
+STATIC void
+xfs_map_buffer(
+       struct buffer_head      *bh,
+       xfs_iomap_t             *mp,
+       xfs_off_t               offset,
+       uint                    block_bits)
+{
+       sector_t                bn;
+
+       ASSERT(mp->iomap_bn != IOMAP_DADDR_NULL);
+
+       bn = (mp->iomap_bn >> (block_bits - BBSHIFT)) +
+             ((offset - mp->iomap_offset) >> block_bits);
+
+       ASSERT(bn || (mp->iomap_flags & IOMAP_REALTIME));
+
+       bh->b_blocknr = bn;
+       set_buffer_mapped(bh);
+}
+
 STATIC void
 xfs_map_at_offset(
        struct buffer_head      *bh,
@@ -468,22 +510,11 @@ xfs_map_at_offset(
        int                     block_bits,
        xfs_iomap_t             *iomapp)
 {
-       xfs_daddr_t             bn;
-       int                     sector_shift;
-
        ASSERT(!(iomapp->iomap_flags & IOMAP_HOLE));
        ASSERT(!(iomapp->iomap_flags & IOMAP_DELAY));
-       ASSERT(iomapp->iomap_bn != IOMAP_DADDR_NULL);
-
-       sector_shift = block_bits - BBSHIFT;
-       bn = (iomapp->iomap_bn >> sector_shift) +
-             ((offset - iomapp->iomap_offset) >> block_bits);
-
-       ASSERT(bn || (iomapp->iomap_flags & IOMAP_REALTIME));
-       ASSERT((bn << sector_shift) >= iomapp->iomap_bn);
 
        lock_buffer(bh);
-       bh->b_blocknr = bn;
+       xfs_map_buffer(bh, iomapp, offset, block_bits);
        bh->b_bdev = iomapp->iomap_target->bt_bdev;
        set_buffer_mapped(bh);
        clear_buffer_delay(bh);
@@ -616,7 +647,7 @@ xfs_is_delayed_page(
                                acceptable = (type == IOMAP_UNWRITTEN);
                        else if (buffer_delay(bh))
                                acceptable = (type == IOMAP_DELAY);
-                       else if (buffer_mapped(bh))
+                       else if (buffer_dirty(bh) && buffer_mapped(bh))
                                acceptable = (type == 0);
                        else
                                break;
@@ -1040,8 +1071,159 @@ error:
        return err;
 }
 
+/*
+ * writepage: Called from one of two places:
+ *
+ * 1. we are flushing a delalloc buffer head.
+ *
+ * 2. we are writing out a dirty page. Typically the page dirty
+ *    state is cleared before we get here. In this case is it
+ *    conceivable we have no buffer heads.
+ *
+ * For delalloc space on the page we need to allocate space and
+ * flush it. For unmapped buffer heads on the page we should
+ * allocate space if the page is uptodate. For any other dirty
+ * buffer heads on the page we should flush them.
+ *
+ * If we detect that a transaction would be required to flush
+ * the page, we have to check the process flags first, if we
+ * are already in a transaction or disk I/O during allocations
+ * is off, we need to fail the writepage and redirty the page.
+ */
+
+STATIC int
+xfs_vm_writepage(
+       struct page             *page,
+       struct writeback_control *wbc)
+{
+       int                     error;
+       int                     need_trans;
+       int                     delalloc, unmapped, unwritten;
+       struct inode            *inode = page->mapping->host;
+
+       xfs_page_trace(XFS_WRITEPAGE_ENTER, inode, page, 0);
+
+       /*
+        * We need a transaction if:
+        *  1. There are delalloc buffers on the page
+        *  2. The page is uptodate and we have unmapped buffers
+        *  3. The page is uptodate and we have no buffers
+        *  4. There are unwritten buffers on the page
+        */
+
+       if (!page_has_buffers(page)) {
+               unmapped = 1;
+               need_trans = 1;
+       } else {
+               xfs_count_page_state(page, &delalloc, &unmapped, &unwritten);
+               if (!PageUptodate(page))
+                       unmapped = 0;
+               need_trans = delalloc + unmapped + unwritten;
+       }
+
+       /*
+        * If we need a transaction and the process flags say
+        * we are already in a transaction, or no IO is allowed
+        * then mark the page dirty again and leave the page
+        * as is.
+        */
+       if (PFLAGS_TEST_FSTRANS() && need_trans)
+               goto out_fail;
+
+       /*
+        * Delay hooking up buffer heads until we have
+        * made our go/no-go decision.
+        */
+       if (!page_has_buffers(page))
+               create_empty_buffers(page, 1 << inode->i_blkbits, 0);
+
+       /*
+        * Convert delayed allocate, unwritten or unmapped space
+        * to real space and flush out to disk.
+        */
+       error = xfs_page_state_convert(inode, page, wbc, 1, unmapped);
+       if (error == -EAGAIN)
+               goto out_fail;
+       if (unlikely(error < 0))
+               goto out_unlock;
+
+       return 0;
+
+out_fail:
+       redirty_page_for_writepage(wbc, page);
+       unlock_page(page);
+       return 0;
+out_unlock:
+       unlock_page(page);
+       return error;
+}
+
+/*
+ * Called to move a page into cleanable state - and from there
+ * to be released. Possibly the page is already clean. We always
+ * have buffer heads in this call.
+ *
+ * Returns 0 if the page is ok to release, 1 otherwise.
+ *
+ * Possible scenarios are:
+ *
+ * 1. We are being called to release a page which has been written
+ *    to via regular I/O. buffer heads will be dirty and possibly
+ *    delalloc. If no delalloc buffer heads in this case then we
+ *    can just return zero.
+ *
+ * 2. We are called to release a page which has been written via
+ *    mmap, all we need to do is ensure there is no delalloc
+ *    state in the buffer heads, if not we can let the caller
+ *    free them and we should come back later via writepage.
+ */
 STATIC int
-__linvfs_get_block(
+xfs_vm_releasepage(
+       struct page             *page,
+       gfp_t                   gfp_mask)
+{
+       struct inode            *inode = page->mapping->host;
+       int                     dirty, delalloc, unmapped, unwritten;
+       struct writeback_control wbc = {
+               .sync_mode = WB_SYNC_ALL,
+               .nr_to_write = 1,
+       };
+
+       xfs_page_trace(XFS_RELEASEPAGE_ENTER, inode, page, gfp_mask);
+
+       if (!page_has_buffers(page))
+               return 0;
+
+       xfs_count_page_state(page, &delalloc, &unmapped, &unwritten);
+       if (!delalloc && !unwritten)
+               goto free_buffers;
+
+       if (!(gfp_mask & __GFP_FS))
+               return 0;
+
+       /* If we are already inside a transaction or the thread cannot
+        * do I/O, we cannot release this page.
+        */
+       if (PFLAGS_TEST_FSTRANS())
+               return 0;
+
+       /*
+        * Convert delalloc space to real space, do not flush the
+        * data out to disk, that will be done by the caller.
+        * Never need to allocate space here - we will always
+        * come back to writepage in that case.
+        */
+       dirty = xfs_page_state_convert(inode, page, &wbc, 0, 0);
+       if (dirty == 0 && !unwritten)
+               goto free_buffers;
+       return 0;
+
+free_buffers:
+       return try_to_free_buffers(page);
+}
+
+STATIC int
+__xfs_get_block(
        struct inode            *inode,
        sector_t                iblock,
        unsigned long           blocks,
@@ -1050,7 +1232,7 @@ __linvfs_get_block(
        int                     direct,
        bmapi_flags_t           flags)
 {
-       vnode_t                 *vp = LINVFS_GET_VP(inode);
+       vnode_t                 *vp = vn_from_inode(inode);
        xfs_iomap_t             iomap;
        xfs_off_t               offset;
        ssize_t                 size;
@@ -1073,21 +1255,13 @@ __linvfs_get_block(
                return 0;
 
        if (iomap.iomap_bn != IOMAP_DADDR_NULL) {
-               xfs_daddr_t     bn;
-               xfs_off_t       delta;
-
-               /* For unwritten extents do not report a disk address on
+               /*
+                * For unwritten extents do not report a disk address on
                 * the read case (treat as if we're reading into a hole).
                 */
                if (create || !(iomap.iomap_flags & IOMAP_UNWRITTEN)) {
-                       delta = offset - iomap.iomap_offset;
-                       delta >>= inode->i_blkbits;
-
-                       bn = iomap.iomap_bn >> (inode->i_blkbits - BBSHIFT);
-                       bn += delta;
-                       BUG_ON(!bn && !(iomap.iomap_flags & IOMAP_REALTIME));
-                       bh_result->b_blocknr = bn;
-                       set_buffer_mapped(bh_result);
+                       xfs_map_buffer(bh_result, &iomap, offset,
+                                      inode->i_blkbits);
                }
                if (create && (iomap.iomap_flags & IOMAP_UNWRITTEN)) {
                        if (direct)
@@ -1130,30 +1304,30 @@ __linvfs_get_block(
 }
 
 int
-linvfs_get_block(
+xfs_get_block(
        struct inode            *inode,
        sector_t                iblock,
        struct buffer_head      *bh_result,
        int                     create)
 {
-       return __linvfs_get_block(inode, iblock, 0, bh_result,
+       return __xfs_get_block(inode, iblock, 0, bh_result,
                                        create, 0, BMAPI_WRITE);
 }
 
 STATIC int
-linvfs_get_blocks_direct(
+xfs_get_blocks_direct(
        struct inode            *inode,
        sector_t                iblock,
        unsigned long           max_blocks,
        struct buffer_head      *bh_result,
        int                     create)
 {
-       return __linvfs_get_block(inode, iblock, max_blocks, bh_result,
+       return __xfs_get_block(inode, iblock, max_blocks, bh_result,
                                        create, 1, BMAPI_WRITE|BMAPI_DIRECT);
 }
 
 STATIC void
-linvfs_end_io_direct(
+xfs_end_io_direct(
        struct kiocb    *iocb,
        loff_t          offset,
        ssize_t         size,
@@ -1191,7 +1365,7 @@ linvfs_end_io_direct(
 }
 
 STATIC ssize_t
-linvfs_direct_IO(
+xfs_vm_direct_IO(
        int                     rw,
        struct kiocb            *iocb,
        const struct iovec      *iov,
@@ -1200,7 +1374,7 @@ linvfs_direct_IO(
 {
        struct file     *file = iocb->ki_filp;
        struct inode    *inode = file->f_mapping->host;
-       vnode_t         *vp = LINVFS_GET_VP(inode);
+       vnode_t         *vp = vn_from_inode(inode);
        xfs_iomap_t     iomap;
        int             maps = 1;
        int             error;
@@ -1215,164 +1389,61 @@ linvfs_direct_IO(
        ret = blockdev_direct_IO_own_locking(rw, iocb, inode,
                iomap.iomap_target->bt_bdev,
                iov, offset, nr_segs,
-               linvfs_get_blocks_direct,
-               linvfs_end_io_direct);
+               xfs_get_blocks_direct,
+               xfs_end_io_direct);
 
        if (unlikely(ret <= 0 && iocb->private))
                xfs_destroy_ioend(iocb->private);
        return ret;
 }
 
+STATIC int
+xfs_vm_prepare_write(
+       struct file             *file,
+       struct page             *page,
+       unsigned int            from,
+       unsigned int            to)
+{
+       return block_prepare_write(page, from, to, xfs_get_block);
+}
 
 STATIC sector_t
-linvfs_bmap(
+xfs_vm_bmap(
        struct address_space    *mapping,
        sector_t                block)
 {
        struct inode            *inode = (struct inode *)mapping->host;
-       vnode_t                 *vp = LINVFS_GET_VP(inode);
+       vnode_t                 *vp = vn_from_inode(inode);
        int                     error;
 
-       vn_trace_entry(vp, "linvfs_bmap", (inst_t *)__return_address);
+       vn_trace_entry(vp, __FUNCTION__, (inst_t *)__return_address);
 
        VOP_RWLOCK(vp, VRWLOCK_READ);
        VOP_FLUSH_PAGES(vp, (xfs_off_t)0, -1, 0, FI_REMAPF, error);
        VOP_RWUNLOCK(vp, VRWLOCK_READ);
-       return generic_block_bmap(mapping, block, linvfs_get_block);
+       return generic_block_bmap(mapping, block, xfs_get_block);
 }
 
 STATIC int
-linvfs_readpage(
+xfs_vm_readpage(
        struct file             *unused,
        struct page             *page)
 {
-       return mpage_readpage(page, linvfs_get_block);
+       return mpage_readpage(page, xfs_get_block);
 }
 
 STATIC int
-linvfs_readpages(
+xfs_vm_readpages(
        struct file             *unused,
        struct address_space    *mapping,
        struct list_head        *pages,
        unsigned                nr_pages)
 {
-       return mpage_readpages(mapping, pages, nr_pages, linvfs_get_block);
-}
-
-STATIC void
-xfs_count_page_state(
-       struct page             *page,
-       int                     *delalloc,
-       int                     *unmapped,
-       int                     *unwritten)
-{
-       struct buffer_head      *bh, *head;
-
-       *delalloc = *unmapped = *unwritten = 0;
-
-       bh = head = page_buffers(page);
-       do {
-               if (buffer_uptodate(bh) && !buffer_mapped(bh))
-                       (*unmapped) = 1;
-               else if (buffer_unwritten(bh) && !buffer_delay(bh))
-                       clear_buffer_unwritten(bh);
-               else if (buffer_unwritten(bh))
-                       (*unwritten) = 1;
-               else if (buffer_delay(bh))
-                       (*delalloc) = 1;
-       } while ((bh = bh->b_this_page) != head);
+       return mpage_readpages(mapping, pages, nr_pages, xfs_get_block);
 }
 
-
-/*
- * writepage: Called from one of two places:
- *
- * 1. we are flushing a delalloc buffer head.
- *
- * 2. we are writing out a dirty page. Typically the page dirty
- *    state is cleared before we get here. In this case is it
- *    conceivable we have no buffer heads.
- *
- * For delalloc space on the page we need to allocate space and
- * flush it. For unmapped buffer heads on the page we should
- * allocate space if the page is uptodate. For any other dirty
- * buffer heads on the page we should flush them.
- *
- * If we detect that a transaction would be required to flush
- * the page, we have to check the process flags first, if we
- * are already in a transaction or disk I/O during allocations
- * is off, we need to fail the writepage and redirty the page.
- */
-
 STATIC int
-linvfs_writepage(
-       struct page             *page,
-       struct writeback_control *wbc)
-{
-       int                     error;
-       int                     need_trans;
-       int                     delalloc, unmapped, unwritten;
-       struct inode            *inode = page->mapping->host;
-
-       xfs_page_trace(XFS_WRITEPAGE_ENTER, inode, page, 0);
-
-       /*
-        * We need a transaction if:
-        *  1. There are delalloc buffers on the page
-        *  2. The page is uptodate and we have unmapped buffers
-        *  3. The page is uptodate and we have no buffers
-        *  4. There are unwritten buffers on the page
-        */
-
-       if (!page_has_buffers(page)) {
-               unmapped = 1;
-               need_trans = 1;
-       } else {
-               xfs_count_page_state(page, &delalloc, &unmapped, &unwritten);
-               if (!PageUptodate(page))
-                       unmapped = 0;
-               need_trans = delalloc + unmapped + unwritten;
-       }
-
-       /*
-        * If we need a transaction and the process flags say
-        * we are already in a transaction, or no IO is allowed
-        * then mark the page dirty again and leave the page
-        * as is.
-        */
-       if (PFLAGS_TEST_FSTRANS() && need_trans)
-               goto out_fail;
-
-       /*
-        * Delay hooking up buffer heads until we have
-        * made our go/no-go decision.
-        */
-       if (!page_has_buffers(page))
-               create_empty_buffers(page, 1 << inode->i_blkbits, 0);
-
-       /*
-        * Convert delayed allocate, unwritten or unmapped space
-        * to real space and flush out to disk.
-        */
-       error = xfs_page_state_convert(inode, page, wbc, 1, unmapped);
-       if (error == -EAGAIN)
-               goto out_fail;
-       if (unlikely(error < 0))
-               goto out_unlock;
-
-       return 0;
-
-out_fail:
-       redirty_page_for_writepage(wbc, page);
-       unlock_page(page);
-       return 0;
-out_unlock:
-       unlock_page(page);
-       return error;
-}
-
-STATIC int
-linvfs_invalidate_page(
+xfs_vm_invalidatepage(
        struct page             *page,
        unsigned long           offset)
 {
@@ -1381,87 +1452,16 @@ linvfs_invalidate_page(
        return block_invalidatepage(page, offset);
 }
 
-/*
- * Called to move a page into cleanable state - and from there
- * to be released. Possibly the page is already clean. We always
- * have buffer heads in this call.
- *
- * Returns 0 if the page is ok to release, 1 otherwise.
- *
- * Possible scenarios are:
- *
- * 1. We are being called to release a page which has been written
- *    to via regular I/O. buffer heads will be dirty and possibly
- *    delalloc. If no delalloc buffer heads in this case then we
- *    can just return zero.
- *
- * 2. We are called to release a page which has been written via
- *    mmap, all we need to do is ensure there is no delalloc
- *    state in the buffer heads, if not we can let the caller
- *    free them and we should come back later via writepage.
- */
-STATIC int
-linvfs_release_page(
-       struct page             *page,
-       gfp_t                   gfp_mask)
-{
-       struct inode            *inode = page->mapping->host;
-       int                     dirty, delalloc, unmapped, unwritten;
-       struct writeback_control wbc = {
-               .sync_mode = WB_SYNC_ALL,
-               .nr_to_write = 1,
-       };
-
-       xfs_page_trace(XFS_RELEASEPAGE_ENTER, inode, page, gfp_mask);
-
-       xfs_count_page_state(page, &delalloc, &unmapped, &unwritten);
-       if (!delalloc && !unwritten)
-               goto free_buffers;
-
-       if (!(gfp_mask & __GFP_FS))
-               return 0;
-
-       /* If we are already inside a transaction or the thread cannot
-        * do I/O, we cannot release this page.
-        */
-       if (PFLAGS_TEST_FSTRANS())
-               return 0;
-
-       /*
-        * Convert delalloc space to real space, do not flush the
-        * data out to disk, that will be done by the caller.
-        * Never need to allocate space here - we will always
-        * come back to writepage in that case.
-        */
-       dirty = xfs_page_state_convert(inode, page, &wbc, 0, 0);
-       if (dirty == 0 && !unwritten)
-               goto free_buffers;
-       return 0;
-
-free_buffers:
-       return try_to_free_buffers(page);
-}
-
-STATIC int
-linvfs_prepare_write(
-       struct file             *file,
-       struct page             *page,
-       unsigned int            from,
-       unsigned int            to)
-{
-       return block_prepare_write(page, from, to, linvfs_get_block);
-}
-
-struct address_space_operations linvfs_aops = {
-       .readpage               = linvfs_readpage,
-       .readpages              = linvfs_readpages,
-       .writepage              = linvfs_writepage,
+struct address_space_operations xfs_address_space_operations = {
+       .readpage               = xfs_vm_readpage,
+       .readpages              = xfs_vm_readpages,
+       .writepage              = xfs_vm_writepage,
        .sync_page              = block_sync_page,
-       .releasepage            = linvfs_release_page,
-       .invalidatepage         = linvfs_invalidate_page,
-       .prepare_write          = linvfs_prepare_write,
+       .releasepage            = xfs_vm_releasepage,
+       .invalidatepage         = xfs_vm_invalidatepage,
+       .prepare_write          = xfs_vm_prepare_write,
        .commit_write           = generic_commit_write,
-       .bmap                   = linvfs_bmap,
-       .direct_IO              = linvfs_direct_IO,
+       .bmap                   = xfs_vm_bmap,
+       .direct_IO              = xfs_vm_direct_IO,
        .migratepage            = buffer_migrate_page,
 };
index 55339dd5a30dd196b19e99a55a27deed61eac73d..795699f121d26d455d3798b8a30f5149e112d133 100644 (file)
@@ -40,7 +40,7 @@ typedef struct xfs_ioend {
        struct work_struct      io_work;        /* xfsdatad work queue */
 } xfs_ioend_t;
 
-extern struct address_space_operations linvfs_aops;
-extern int linvfs_get_block(struct inode *, sector_t, struct buffer_head *, int);
+extern struct address_space_operations xfs_address_space_operations;
+extern int xfs_get_block(struct inode *, sector_t, struct buffer_head *, int);
 
 #endif /* __XFS_IOPS_H__ */
index 8cdfa41516599f1f7889691e67107bb208fe1d66..9fb0312665caacd41872527e101f8c19706ceaa1 100644 (file)
@@ -1806,13 +1806,12 @@ xfs_flush_buftarg(
 int __init
 xfs_buf_init(void)
 {
-       int             error = -ENOMEM;
-
 #ifdef XFS_BUF_TRACE
        xfs_buf_trace_buf = ktrace_alloc(XFS_BUF_TRACE_SIZE, KM_SLEEP);
 #endif
 
-       xfs_buf_zone = kmem_zone_init(sizeof(xfs_buf_t), "xfs_buf");
+       xfs_buf_zone = kmem_zone_init_flags(sizeof(xfs_buf_t), "xfs_buf",
+                                               KM_ZONE_HWALIGN, NULL);
        if (!xfs_buf_zone)
                goto out_free_trace_buf;
 
@@ -1840,7 +1839,7 @@ xfs_buf_init(void)
 #ifdef XFS_BUF_TRACE
        ktrace_free(xfs_buf_trace_buf);
 #endif
-       return error;
+       return -ENOMEM;
 }
 
 void
index 80eb249f2fa0ae83a192d6721d2d48e76665951d..b768ea910bbe00e3741ca9cec61b21cb06a3d9e5 100644 (file)
@@ -25,6 +25,8 @@
 #include "xfs_mount.h"
 #include "xfs_export.h"
 
+STATIC struct dentry dotdot = { .d_name.name = "..", .d_name.len = 2, };
+
 /*
  * XFS encodes and decodes the fileid portion of NFS filehandles
  * itself instead of letting the generic NFS code do it.  This
@@ -37,7 +39,7 @@
  */
 
 STATIC struct dentry *
-linvfs_decode_fh(
+xfs_fs_decode_fh(
        struct super_block      *sb,
        __u32                   *fh,
        int                     fh_len,
@@ -78,12 +80,12 @@ linvfs_decode_fh(
        }
 
        fh = (__u32 *)&ifid;
-       return find_exported_dentry(sb, fh, parent, acceptable, context);
+       return sb->s_export_op->find_exported_dentry(sb, fh, parent, acceptable, context);
 }
 
 
 STATIC int
-linvfs_encode_fh(
+xfs_fs_encode_fh(
        struct dentry           *dentry,
        __u32                   *fh,
        int                     *max_len,
@@ -95,7 +97,7 @@ linvfs_encode_fh(
        int                     len;
        int                     is64 = 0;
 #if XFS_BIG_INUMS
-       vfs_t                   *vfs = LINVFS_GET_VFS(inode->i_sb);
+       vfs_t                   *vfs = vfs_from_sb(inode->i_sb);
 
        if (!(vfs->vfs_flag & VFS_32BITINODES)) {
                /* filesystem may contain 64bit inode numbers */
@@ -130,21 +132,21 @@ linvfs_encode_fh(
 }
 
 STATIC struct dentry *
-linvfs_get_dentry(
+xfs_fs_get_dentry(
        struct super_block      *sb,
        void                    *data)
 {
        vnode_t                 *vp;
        struct inode            *inode;
        struct dentry           *result;
-       vfs_t                   *vfsp = LINVFS_GET_VFS(sb);
+       vfs_t                   *vfsp = vfs_from_sb(sb);
        int                     error;
 
        VFS_VGET(vfsp, &vp, (fid_t *)data, error);
        if (error || vp == NULL)
                return ERR_PTR(-ESTALE) ;
 
-       inode = LINVFS_GET_IP(vp);
+       inode = vn_to_inode(vp);
        result = d_alloc_anon(inode);
         if (!result) {
                iput(inode);
@@ -154,25 +156,20 @@ linvfs_get_dentry(
 }
 
 STATIC struct dentry *
-linvfs_get_parent(
+xfs_fs_get_parent(
        struct dentry           *child)
 {
        int                     error;
        vnode_t                 *vp, *cvp;
        struct dentry           *parent;
-       struct dentry           dotdot;
-
-       dotdot.d_name.name = "..";
-       dotdot.d_name.len = 2;
-       dotdot.d_inode = NULL;
 
        cvp = NULL;
-       vp = LINVFS_GET_VP(child->d_inode);
+       vp = vn_from_inode(child->d_inode);
        VOP_LOOKUP(vp, &dotdot, &cvp, 0, NULL, NULL, error);
        if (unlikely(error))
                return ERR_PTR(-error);
 
-       parent = d_alloc_anon(LINVFS_GET_IP(cvp));
+       parent = d_alloc_anon(vn_to_inode(cvp));
        if (unlikely(!parent)) {
                VN_RELE(cvp);
                return ERR_PTR(-ENOMEM);
@@ -180,9 +177,9 @@ linvfs_get_parent(
        return parent;
 }
 
-struct export_operations linvfs_export_ops = {
-       .decode_fh              = linvfs_decode_fh,
-       .encode_fh              = linvfs_encode_fh,
-       .get_parent             = linvfs_get_parent,
-       .get_dentry             = linvfs_get_dentry,
+struct export_operations xfs_export_operations = {
+       .decode_fh              = xfs_fs_decode_fh,
+       .encode_fh              = xfs_fs_encode_fh,
+       .get_parent             = xfs_fs_get_parent,
+       .get_dentry             = xfs_fs_get_dentry,
 };
index ced4404339c7efd214255aed73ba6110d33d0eaf..185567a6a56118cb47dcf6da77b7df8de98f5af5 100644 (file)
 #include <linux/dcache.h>
 #include <linux/smp_lock.h>
 
-static struct vm_operations_struct linvfs_file_vm_ops;
+static struct vm_operations_struct xfs_file_vm_ops;
 #ifdef CONFIG_XFS_DMAPI
-static struct vm_operations_struct linvfs_dmapi_file_vm_ops;
+static struct vm_operations_struct xfs_dmapi_file_vm_ops;
 #endif
 
 STATIC inline ssize_t
-__linvfs_read(
+__xfs_file_read(
        struct kiocb            *iocb,
        char                    __user *buf,
        int                     ioflags,
@@ -58,7 +58,7 @@ __linvfs_read(
 {
        struct iovec            iov = {buf, count};
        struct file             *file = iocb->ki_filp;
-       vnode_t                 *vp = LINVFS_GET_VP(file->f_dentry->d_inode);
+       vnode_t                 *vp = vn_from_inode(file->f_dentry->d_inode);
        ssize_t                 rval;
 
        BUG_ON(iocb->ki_pos != pos);
@@ -71,28 +71,28 @@ __linvfs_read(
 
 
 STATIC ssize_t
-linvfs_aio_read(
+xfs_file_aio_read(
        struct kiocb            *iocb,
        char                    __user *buf,
        size_t                  count,
        loff_t                  pos)
 {
-       return __linvfs_read(iocb, buf, IO_ISAIO, count, pos);
+       return __xfs_file_read(iocb, buf, IO_ISAIO, count, pos);
 }
 
 STATIC ssize_t
-linvfs_aio_read_invis(
+xfs_file_aio_read_invis(
        struct kiocb            *iocb,
        char                    __user *buf,
        size_t                  count,
        loff_t                  pos)
 {
-       return __linvfs_read(iocb, buf, IO_ISAIO|IO_INVIS, count, pos);
+       return __xfs_file_read(iocb, buf, IO_ISAIO|IO_INVIS, count, pos);
 }
 
 
 STATIC inline ssize_t
-__linvfs_write(
+__xfs_file_write(
        struct kiocb    *iocb,
        const char      __user *buf,
        int             ioflags,
@@ -102,7 +102,7 @@ __linvfs_write(
        struct iovec    iov = {(void __user *)buf, count};
        struct file     *file = iocb->ki_filp;
        struct inode    *inode = file->f_mapping->host;
-       vnode_t         *vp = LINVFS_GET_VP(inode);
+       vnode_t         *vp = vn_from_inode(inode);
        ssize_t         rval;
 
        BUG_ON(iocb->ki_pos != pos);
@@ -115,28 +115,28 @@ __linvfs_write(
 
 
 STATIC ssize_t
-linvfs_aio_write(
+xfs_file_aio_write(
        struct kiocb            *iocb,
        const char              __user *buf,
        size_t                  count,
        loff_t                  pos)
 {
-       return __linvfs_write(iocb, buf, IO_ISAIO, count, pos);
+       return __xfs_file_write(iocb, buf, IO_ISAIO, count, pos);
 }
 
 STATIC ssize_t
-linvfs_aio_write_invis(
+xfs_file_aio_write_invis(
        struct kiocb            *iocb,
        const char              __user *buf,
        size_t                  count,
        loff_t                  pos)
 {
-       return __linvfs_write(iocb, buf, IO_ISAIO|IO_INVIS, count, pos);
+       return __xfs_file_write(iocb, buf, IO_ISAIO|IO_INVIS, count, pos);
 }
 
 
 STATIC inline ssize_t
-__linvfs_readv(
+__xfs_file_readv(
        struct file             *file,
        const struct iovec      *iov,
        int                     ioflags,
@@ -144,8 +144,8 @@ __linvfs_readv(
        loff_t                  *ppos)
 {
        struct inode    *inode = file->f_mapping->host;
-       vnode_t         *vp = LINVFS_GET_VP(inode);
-       struct          kiocb kiocb;
+       vnode_t         *vp = vn_from_inode(inode);
+       struct kiocb    kiocb;
        ssize_t         rval;
 
        init_sync_kiocb(&kiocb, file);
@@ -160,28 +160,28 @@ __linvfs_readv(
 }
 
 STATIC ssize_t
-linvfs_readv(
+xfs_file_readv(
        struct file             *file,
        const struct iovec      *iov,
        unsigned long           nr_segs,
        loff_t                  *ppos)
 {
-       return __linvfs_readv(file, iov, 0, nr_segs, ppos);
+       return __xfs_file_readv(file, iov, 0, nr_segs, ppos);
 }
 
 STATIC ssize_t
-linvfs_readv_invis(
+xfs_file_readv_invis(
        struct file             *file,
        const struct iovec      *iov,
        unsigned long           nr_segs,
        loff_t                  *ppos)
 {
-       return __linvfs_readv(file, iov, IO_INVIS, nr_segs, ppos);
+       return __xfs_file_readv(file, iov, IO_INVIS, nr_segs, ppos);
 }
 
 
 STATIC inline ssize_t
-__linvfs_writev(
+__xfs_file_writev(
        struct file             *file,
        const struct iovec      *iov,
        int                     ioflags,
@@ -189,8 +189,8 @@ __linvfs_writev(
        loff_t                  *ppos)
 {
        struct inode    *inode = file->f_mapping->host;
-       vnode_t         *vp = LINVFS_GET_VP(inode);
-       struct          kiocb kiocb;
+       vnode_t         *vp = vn_from_inode(inode);
+       struct kiocb    kiocb;
        ssize_t         rval;
 
        init_sync_kiocb(&kiocb, file);
@@ -206,34 +206,34 @@ __linvfs_writev(
 
 
 STATIC ssize_t
-linvfs_writev(
+xfs_file_writev(
        struct file             *file,
        const struct iovec      *iov,
        unsigned long           nr_segs,
        loff_t                  *ppos)
 {
-       return __linvfs_writev(file, iov, 0, nr_segs, ppos);
+       return __xfs_file_writev(file, iov, 0, nr_segs, ppos);
 }
 
 STATIC ssize_t
-linvfs_writev_invis(
+xfs_file_writev_invis(
        struct file             *file,
        const struct iovec      *iov,
        unsigned long           nr_segs,
        loff_t                  *ppos)
 {
-       return __linvfs_writev(file, iov, IO_INVIS, nr_segs, ppos);
+       return __xfs_file_writev(file, iov, IO_INVIS, nr_segs, ppos);
 }
 
 STATIC ssize_t
-linvfs_sendfile(
+xfs_file_sendfile(
        struct file             *filp,
        loff_t                  *ppos,
        size_t                  count,
        read_actor_t            actor,
        void                    *target)
 {
-       vnode_t                 *vp = LINVFS_GET_VP(filp->f_dentry->d_inode);
+       vnode_t                 *vp = vn_from_inode(filp->f_dentry->d_inode);
        ssize_t                 rval;
 
        VOP_SENDFILE(vp, filp, ppos, 0, count, actor, target, NULL, rval);
@@ -242,11 +242,11 @@ linvfs_sendfile(
 
 
 STATIC int
-linvfs_open(
+xfs_file_open(
        struct inode    *inode,
        struct file     *filp)
 {
-       vnode_t         *vp = LINVFS_GET_VP(inode);
+       vnode_t         *vp = vn_from_inode(inode);
        int             error;
 
        if (!(filp->f_flags & O_LARGEFILE) && i_size_read(inode) > MAX_NON_LFS)
@@ -259,11 +259,11 @@ linvfs_open(
 
 
 STATIC int
-linvfs_release(
+xfs_file_release(
        struct inode    *inode,
        struct file     *filp)
 {
-       vnode_t         *vp = LINVFS_GET_VP(inode);
+       vnode_t         *vp = vn_from_inode(inode);
        int             error = 0;
 
        if (vp)
@@ -273,13 +273,13 @@ linvfs_release(
 
 
 STATIC int
-linvfs_fsync(
+xfs_file_fsync(
        struct file     *filp,
        struct dentry   *dentry,
        int             datasync)
 {
        struct inode    *inode = dentry->d_inode;
-       vnode_t         *vp = LINVFS_GET_VP(inode);
+       vnode_t         *vp = vn_from_inode(inode);
        int             error;
        int             flags = FSYNC_WAIT;
 
@@ -292,7 +292,7 @@ linvfs_fsync(
 }
 
 /*
- * linvfs_readdir maps to VOP_READDIR().
+ * xfs_file_readdir maps to VOP_READDIR().
  * We need to build a uio, cred, ...
  */
 
@@ -301,13 +301,13 @@ linvfs_fsync(
 #ifdef CONFIG_XFS_DMAPI
 
 STATIC struct page *
-linvfs_filemap_nopage(
+xfs_vm_nopage(
        struct vm_area_struct   *area,
        unsigned long           address,
        int                     *type)
 {
        struct inode    *inode = area->vm_file->f_dentry->d_inode;
-       vnode_t         *vp = LINVFS_GET_VP(inode);
+       vnode_t         *vp = vn_from_inode(inode);
        xfs_mount_t     *mp = XFS_VFSTOM(vp->v_vfsp);
        int             error;
 
@@ -324,7 +324,7 @@ linvfs_filemap_nopage(
 
 
 STATIC int
-linvfs_readdir(
+xfs_file_readdir(
        struct file     *filp,
        void            *dirent,
        filldir_t       filldir)
@@ -340,7 +340,7 @@ linvfs_readdir(
        xfs_off_t       start_offset, curr_offset;
        xfs_dirent_t    *dbp = NULL;
 
-       vp = LINVFS_GET_VP(filp->f_dentry->d_inode);
+       vp = vn_from_inode(filp->f_dentry->d_inode);
        ASSERT(vp);
 
        /* Try fairly hard to get memory */
@@ -404,39 +404,40 @@ done:
 
 
 STATIC int
-linvfs_file_mmap(
+xfs_file_mmap(
        struct file     *filp,
        struct vm_area_struct *vma)
 {
        struct inode    *ip = filp->f_dentry->d_inode;
-       vnode_t         *vp = LINVFS_GET_VP(ip);
-       vattr_t         va = { .va_mask = XFS_AT_UPDATIME };
+       vnode_t         *vp = vn_from_inode(ip);
+       vattr_t         vattr;
        int             error;
 
-       vma->vm_ops = &linvfs_file_vm_ops;
+       vma->vm_ops = &xfs_file_vm_ops;
 
 #ifdef CONFIG_XFS_DMAPI
        if (vp->v_vfsp->vfs_flag & VFS_DMI) {
-               vma->vm_ops = &linvfs_dmapi_file_vm_ops;
+               vma->vm_ops = &xfs_dmapi_file_vm_ops;
        }
 #endif /* CONFIG_XFS_DMAPI */
 
-       VOP_SETATTR(vp, &va, XFS_AT_UPDATIME, NULL, error);
-       if (!error)
-               vn_revalidate(vp);      /* update Linux inode flags */
+       vattr.va_mask = XFS_AT_UPDATIME;
+       VOP_SETATTR(vp, &vattr, XFS_AT_UPDATIME, NULL, error);
+       if (likely(!error))
+               __vn_revalidate(vp, &vattr);    /* update flags */
        return 0;
 }
 
 
 STATIC long
-linvfs_ioctl(
+xfs_file_ioctl(
        struct file     *filp,
        unsigned int    cmd,
        unsigned long   arg)
 {
        int             error;
-       struct inode *inode = filp->f_dentry->d_inode;
-       vnode_t         *vp = LINVFS_GET_VP(inode);
+       struct inode    *inode = filp->f_dentry->d_inode;
+       vnode_t         *vp = vn_from_inode(inode);
 
        VOP_IOCTL(vp, inode, filp, 0, cmd, (void __user *)arg, error);
        VMODIFY(vp);
@@ -451,14 +452,14 @@ linvfs_ioctl(
 }
 
 STATIC long
-linvfs_ioctl_invis(
+xfs_file_ioctl_invis(
        struct file     *filp,
        unsigned int    cmd,
        unsigned long   arg)
 {
        int             error;
-       struct inode *inode = filp->f_dentry->d_inode;
-       vnode_t         *vp = LINVFS_GET_VP(inode);
+       struct inode    *inode = filp->f_dentry->d_inode;
+       vnode_t         *vp = vn_from_inode(inode);
 
        ASSERT(vp);
        VOP_IOCTL(vp, inode, filp, IO_INVIS, cmd, (void __user *)arg, error);
@@ -476,11 +477,11 @@ linvfs_ioctl_invis(
 #ifdef CONFIG_XFS_DMAPI
 #ifdef HAVE_VMOP_MPROTECT
 STATIC int
-linvfs_mprotect(
+xfs_vm_mprotect(
        struct vm_area_struct *vma,
        unsigned int    newflags)
 {
-       vnode_t         *vp = LINVFS_GET_VP(vma->vm_file->f_dentry->d_inode);
+       vnode_t         *vp = vn_from_inode(vma->vm_file->f_dentry->d_inode);
        int             error = 0;
 
        if (vp->v_vfsp->vfs_flag & VFS_DMI) {
@@ -503,10 +504,10 @@ linvfs_mprotect(
  * it back online.
  */
 STATIC int
-linvfs_open_exec(
+xfs_file_open_exec(
        struct inode    *inode)
 {
-       vnode_t         *vp = LINVFS_GET_VP(inode);
+       vnode_t         *vp = vn_from_inode(inode);
        xfs_mount_t     *mp = XFS_VFSTOM(vp->v_vfsp);
        int             error = 0;
        xfs_inode_t     *ip;
@@ -527,69 +528,69 @@ open_exec_out:
 }
 #endif /* HAVE_FOP_OPEN_EXEC */
 
-struct file_operations linvfs_file_operations = {
+struct file_operations xfs_file_operations = {
        .llseek         = generic_file_llseek,
        .read           = do_sync_read,
        .write          = do_sync_write,
-       .readv          = linvfs_readv,
-       .writev         = linvfs_writev,
-       .aio_read       = linvfs_aio_read,
-       .aio_write      = linvfs_aio_write,
-       .sendfile       = linvfs_sendfile,
-       .unlocked_ioctl = linvfs_ioctl,
+       .readv          = xfs_file_readv,
+       .writev         = xfs_file_writev,
+       .aio_read       = xfs_file_aio_read,
+       .aio_write      = xfs_file_aio_write,
+       .sendfile       = xfs_file_sendfile,
+       .unlocked_ioctl = xfs_file_ioctl,
 #ifdef CONFIG_COMPAT
-       .compat_ioctl   = linvfs_compat_ioctl,
+       .compat_ioctl   = xfs_file_compat_ioctl,
 #endif
-       .mmap           = linvfs_file_mmap,
-       .open           = linvfs_open,
-       .release        = linvfs_release,
-       .fsync          = linvfs_fsync,
+       .mmap           = xfs_file_mmap,
+       .open           = xfs_file_open,
+       .release        = xfs_file_release,
+       .fsync          = xfs_file_fsync,
 #ifdef HAVE_FOP_OPEN_EXEC
-       .open_exec      = linvfs_open_exec,
+       .open_exec      = xfs_file_open_exec,
 #endif
 };
 
-struct file_operations linvfs_invis_file_operations = {
+struct file_operations xfs_invis_file_operations = {
        .llseek         = generic_file_llseek,
        .read           = do_sync_read,
        .write          = do_sync_write,
-       .readv          = linvfs_readv_invis,
-       .writev         = linvfs_writev_invis,
-       .aio_read       = linvfs_aio_read_invis,
-       .aio_write      = linvfs_aio_write_invis,
-       .sendfile       = linvfs_sendfile,
-       .unlocked_ioctl = linvfs_ioctl_invis,
+       .readv          = xfs_file_readv_invis,
+       .writev         = xfs_file_writev_invis,
+       .aio_read       = xfs_file_aio_read_invis,
+       .aio_write      = xfs_file_aio_write_invis,
+       .sendfile       = xfs_file_sendfile,
+       .unlocked_ioctl = xfs_file_ioctl_invis,
 #ifdef CONFIG_COMPAT
-       .compat_ioctl   = linvfs_compat_invis_ioctl,
+       .compat_ioctl   = xfs_file_compat_invis_ioctl,
 #endif
-       .mmap           = linvfs_file_mmap,
-       .open           = linvfs_open,
-       .release        = linvfs_release,
-       .fsync          = linvfs_fsync,
+       .mmap           = xfs_file_mmap,
+       .open           = xfs_file_open,
+       .release        = xfs_file_release,
+       .fsync          = xfs_file_fsync,
 };
 
 
-struct file_operations linvfs_dir_operations = {
+struct file_operations xfs_dir_file_operations = {
        .read           = generic_read_dir,
-       .readdir        = linvfs_readdir,
-       .unlocked_ioctl = linvfs_ioctl,
+       .readdir        = xfs_file_readdir,
+       .unlocked_ioctl = xfs_file_ioctl,
 #ifdef CONFIG_COMPAT
-       .compat_ioctl   = linvfs_compat_ioctl,
+       .compat_ioctl   = xfs_file_compat_ioctl,
 #endif
-       .fsync          = linvfs_fsync,
+       .fsync          = xfs_file_fsync,
 };
 
-static struct vm_operations_struct linvfs_file_vm_ops = {
+static struct vm_operations_struct xfs_file_vm_ops = {
        .nopage         = filemap_nopage,
        .populate       = filemap_populate,
 };
 
 #ifdef CONFIG_XFS_DMAPI
-static struct vm_operations_struct linvfs_dmapi_file_vm_ops = {
-       .nopage         = linvfs_filemap_nopage,
+static struct vm_operations_struct xfs_dmapi_file_vm_ops = {
+       .nopage         = xfs_vm_nopage,
        .populate       = filemap_populate,
 #ifdef HAVE_VMOP_MPROTECT
-       .mprotect       = linvfs_mprotect,
+       .mprotect       = xfs_vm_mprotect,
 #endif
 };
 #endif /* CONFIG_XFS_DMAPI */
index 4fa4b1a5187e095fbe9a3dfb9d324d9aad9c4d5b..575f2a790f315e9ff84530ea39d4659c1135756e 100644 (file)
@@ -57,7 +57,7 @@ fs_tosspages(
        int             fiopt)
 {
        vnode_t         *vp = BHV_TO_VNODE(bdp);
-       struct inode    *ip = LINVFS_GET_IP(vp);
+       struct inode    *ip = vn_to_inode(vp);
 
        if (VN_CACHED(vp))
                truncate_inode_pages(ip->i_mapping, first);
@@ -76,7 +76,7 @@ fs_flushinval_pages(
        int             fiopt)
 {
        vnode_t         *vp = BHV_TO_VNODE(bdp);
-       struct inode    *ip = LINVFS_GET_IP(vp);
+       struct inode    *ip = vn_to_inode(vp);
 
        if (VN_CACHED(vp)) {
                filemap_write_and_wait(ip->i_mapping);
@@ -98,7 +98,7 @@ fs_flush_pages(
        int             fiopt)
 {
        vnode_t         *vp = BHV_TO_VNODE(bdp);
-       struct inode    *ip = LINVFS_GET_IP(vp);
+       struct inode    *ip = vn_to_inode(vp);
 
        if (VN_CACHED(vp)) {
                filemap_fdatawrite(ip->i_mapping);
index 4db47790415c86f5fb043bf866f20a665a54e2b6..84478491609b8e8566cbab3779cd38c1306f7130 100644 (file)
@@ -138,7 +138,7 @@ xfs_find_handle(
        }
 
        /* we need the vnode */
-       vp = LINVFS_GET_VP(inode);
+       vp = vn_from_inode(inode);
 
        /* now we can grab the fsid */
        memcpy(&handle.ha_fsid, vp->v_vfsp->vfs_altfsid, sizeof(xfs_fsid_t));
@@ -256,7 +256,7 @@ xfs_vget_fsop_handlereq(
        }
 
        vpp = XFS_ITOV(ip);
-       inodep = LINVFS_GET_IP(vpp);
+       inodep = vn_to_inode(vpp);
        xfs_iunlock(ip, XFS_ILOCK_SHARED);
 
        *vp = vpp;
@@ -344,7 +344,7 @@ xfs_open_by_handle(
                return -XFS_ERROR(-PTR_ERR(filp));
        }
        if (inode->i_mode & S_IFREG)
-               filp->f_op = &linvfs_invis_file_operations;
+               filp->f_op = &xfs_invis_file_operations;
 
        fd_install(new_fd, filp);
        return new_fd;
@@ -715,7 +715,7 @@ xfs_ioctl(
        xfs_inode_t             *ip;
        xfs_mount_t             *mp;
 
-       vp = LINVFS_GET_VP(inode);
+       vp = vn_from_inode(inode);
 
        vn_trace_entry(vp, "xfs_ioctl", (inst_t *)__return_address);
 
@@ -1160,105 +1160,129 @@ xfs_ioc_xattr(
        void                    __user *arg)
 {
        struct fsxattr          fa;
-       vattr_t                 va;
-       int                     error;
+       struct vattr            *vattr;
+       int                     error = 0;
        int                     attr_flags;
        unsigned int            flags;
 
+       vattr = kmalloc(sizeof(*vattr), GFP_KERNEL);
+       if (unlikely(!vattr))
+               return -ENOMEM;
+
        switch (cmd) {
        case XFS_IOC_FSGETXATTR: {
-               va.va_mask = XFS_AT_XFLAGS | XFS_AT_EXTSIZE | \
-                            XFS_AT_NEXTENTS | XFS_AT_PROJID;
-               VOP_GETATTR(vp, &va, 0, NULL, error);
-               if (error)
-                       return -error;
+               vattr->va_mask = XFS_AT_XFLAGS | XFS_AT_EXTSIZE | \
+                                XFS_AT_NEXTENTS | XFS_AT_PROJID;
+               VOP_GETATTR(vp, vattr, 0, NULL, error);
+               if (unlikely(error)) {
+                       error = -error;
+                       break;
+               }
 
-               fa.fsx_xflags   = va.va_xflags;
-               fa.fsx_extsize  = va.va_extsize;
-               fa.fsx_nextents = va.va_nextents;
-               fa.fsx_projid   = va.va_projid;
+               fa.fsx_xflags   = vattr->va_xflags;
+               fa.fsx_extsize  = vattr->va_extsize;
+               fa.fsx_nextents = vattr->va_nextents;
+               fa.fsx_projid   = vattr->va_projid;
 
-               if (copy_to_user(arg, &fa, sizeof(fa)))
-                       return -XFS_ERROR(EFAULT);
-               return 0;
+               if (copy_to_user(arg, &fa, sizeof(fa))) {
+                       error = -EFAULT;
+                       break;
+               }
+               break;
        }
 
        case XFS_IOC_FSSETXATTR: {
-               if (copy_from_user(&fa, arg, sizeof(fa)))
-                       return -XFS_ERROR(EFAULT);
+               if (copy_from_user(&fa, arg, sizeof(fa))) {
+                       error = -EFAULT;
+                       break;
+               }
 
                attr_flags = 0;
                if (filp->f_flags & (O_NDELAY|O_NONBLOCK))
                        attr_flags |= ATTR_NONBLOCK;
 
-               va.va_mask = XFS_AT_XFLAGS | XFS_AT_EXTSIZE | XFS_AT_PROJID;
-               va.va_xflags  = fa.fsx_xflags;
-               va.va_extsize = fa.fsx_extsize;
-               va.va_projid  = fa.fsx_projid;
+               vattr->va_mask = XFS_AT_XFLAGS | XFS_AT_EXTSIZE | XFS_AT_PROJID;
+               vattr->va_xflags  = fa.fsx_xflags;
+               vattr->va_extsize = fa.fsx_extsize;
+               vattr->va_projid  = fa.fsx_projid;
 
-               VOP_SETATTR(vp, &va, attr_flags, NULL, error);
-               if (!error)
-                       vn_revalidate(vp);      /* update Linux inode flags */
-               return -error;
+               VOP_SETATTR(vp, vattr, attr_flags, NULL, error);
+               if (likely(!error))
+                       __vn_revalidate(vp, vattr);     /* update flags */
+               error = -error;
+               break;
        }
 
        case XFS_IOC_FSGETXATTRA: {
-               va.va_mask = XFS_AT_XFLAGS | XFS_AT_EXTSIZE | \
-                            XFS_AT_ANEXTENTS | XFS_AT_PROJID;
-               VOP_GETATTR(vp, &va, 0, NULL, error);
-               if (error)
-                       return -error;
+               vattr->va_mask = XFS_AT_XFLAGS | XFS_AT_EXTSIZE | \
+                                XFS_AT_ANEXTENTS | XFS_AT_PROJID;
+               VOP_GETATTR(vp, vattr, 0, NULL, error);
+               if (unlikely(error)) {
+                       error = -error;
+                       break;
+               }
 
-               fa.fsx_xflags   = va.va_xflags;
-               fa.fsx_extsize  = va.va_extsize;
-               fa.fsx_nextents = va.va_anextents;
-               fa.fsx_projid   = va.va_projid;
+               fa.fsx_xflags   = vattr->va_xflags;
+               fa.fsx_extsize  = vattr->va_extsize;
+               fa.fsx_nextents = vattr->va_anextents;
+               fa.fsx_projid   = vattr->va_projid;
 
-               if (copy_to_user(arg, &fa, sizeof(fa)))
-                       return -XFS_ERROR(EFAULT);
-               return 0;
+               if (copy_to_user(arg, &fa, sizeof(fa))) {
+                       error = -EFAULT;
+                       break;
+               }
+               break;
        }
 
        case XFS_IOC_GETXFLAGS: {
                flags = xfs_di2lxflags(ip->i_d.di_flags);
                if (copy_to_user(arg, &flags, sizeof(flags)))
-                       return -XFS_ERROR(EFAULT);
-               return 0;
+                       error = -EFAULT;
+               break;
        }
 
        case XFS_IOC_SETXFLAGS: {
-               if (copy_from_user(&flags, arg, sizeof(flags)))
-                       return -XFS_ERROR(EFAULT);
+               if (copy_from_user(&flags, arg, sizeof(flags))) {
+                       error = -EFAULT;
+                       break;
+               }
 
                if (flags & ~(LINUX_XFLAG_IMMUTABLE | LINUX_XFLAG_APPEND | \
                              LINUX_XFLAG_NOATIME | LINUX_XFLAG_NODUMP | \
-                             LINUX_XFLAG_SYNC))
-                       return -XFS_ERROR(EOPNOTSUPP);
+                             LINUX_XFLAG_SYNC)) {
+                       error = -EOPNOTSUPP;
+                       break;
+               }
 
                attr_flags = 0;
                if (filp->f_flags & (O_NDELAY|O_NONBLOCK))
                        attr_flags |= ATTR_NONBLOCK;
 
-               va.va_mask = XFS_AT_XFLAGS;
-               va.va_xflags = xfs_merge_ioc_xflags(flags,
-                               xfs_ip2xflags(ip));
+               vattr->va_mask = XFS_AT_XFLAGS;
+               vattr->va_xflags = xfs_merge_ioc_xflags(flags,
+                                                       xfs_ip2xflags(ip));
 
-               VOP_SETATTR(vp, &va, attr_flags, NULL, error);
-               if (!error)
-                       vn_revalidate(vp);      /* update Linux inode flags */
-               return -error;
+               VOP_SETATTR(vp, vattr, attr_flags, NULL, error);
+               if (likely(!error))
+                       __vn_revalidate(vp, vattr);     /* update flags */
+               error = -error;
+               break;
        }
 
        case XFS_IOC_GETVERSION: {
-               flags = LINVFS_GET_IP(vp)->i_generation;
+               flags = vn_to_inode(vp)->i_generation;
                if (copy_to_user(arg, &flags, sizeof(flags)))
-                       return -XFS_ERROR(EFAULT);
-               return 0;
+                       error = -EFAULT;
+               break;
        }
 
        default:
-               return -ENOTTY;
+               error = -ENOTTY;
+               break;
        }
+
+       kfree(vattr);
+       return error;
 }
 
 STATIC int
index a7c9ba1a9f7b86ac34ef0c626927d42b68be3935..b6321abd9a81364d609cab9e43f53831cac07377 100644 (file)
@@ -107,11 +107,11 @@ xfs_ioctl32_bulkstat(
 #endif
 
 STATIC long
-__linvfs_compat_ioctl(int mode, struct file *f, unsigned cmd, unsigned long arg)
+xfs_compat_ioctl(int mode, struct file *f, unsigned cmd, unsigned long arg)
 {
        int             error;
        struct          inode *inode = f->f_dentry->d_inode;
-       vnode_t         *vp = LINVFS_GET_VP(inode);
+       vnode_t         *vp = vn_to_inode(inode);
 
        switch (cmd) {
        case XFS_IOC_DIOINFO:
@@ -196,19 +196,19 @@ __linvfs_compat_ioctl(int mode, struct file *f, unsigned cmd, unsigned long arg)
 }
 
 long
-linvfs_compat_ioctl(
+xfs_file_compat_ioctl(
        struct file             *f,
        unsigned                cmd,
        unsigned long           arg)
 {
-       return __linvfs_compat_ioctl(0, f, cmd, arg);
+       return xfs_compat_ioctl(0, f, cmd, arg);
 }
 
 long
-linvfs_compat_invis_ioctl(
+xfs_file_compat_invis_ioctl(
        struct file             *f,
        unsigned                cmd,
        unsigned long           arg)
 {
-       return __linvfs_compat_ioctl(IO_INVIS, f, cmd, arg);
+       return xfs_compat_ioctl(IO_INVIS, f, cmd, arg);
 }
index 011c273bec50fdbeff9ebb2ddf543b2d3fc60e35..02de6e62ee370aaef2ef9aca30d16b1f5e3af47f 100644 (file)
@@ -18,7 +18,7 @@
 #ifndef __XFS_IOCTL32_H__
 #define __XFS_IOCTL32_H__
 
-extern long linvfs_compat_ioctl(struct file *, unsigned, unsigned long);
-extern long linvfs_compat_invis_ioctl(struct file *f, unsigned, unsigned long);
+extern long xfs_file_compat_ioctl(struct file *, unsigned, unsigned long);
+extern long xfs_file_compat_invis_ioctl(struct file *, unsigned, unsigned long);
 
 #endif /* __XFS_IOCTL32_H__ */
index d7f6f2d8ac8ec1c3b8f3185d3e18e958f8dc65a6..af487437bd7e7e6c0de33b94389a567e0ce93b7f 100644 (file)
@@ -106,7 +106,7 @@ xfs_ichgtime(
        xfs_inode_t     *ip,
        int             flags)
 {
-       struct inode    *inode = LINVFS_GET_IP(XFS_ITOV(ip));
+       struct inode    *inode = vn_to_inode(XFS_ITOV(ip));
        timespec_t      tv;
 
        nanotime(&tv);
@@ -198,22 +198,22 @@ xfs_ichgtime_fast(
  * Pull the link count and size up from the xfs inode to the linux inode
  */
 STATIC void
-validate_fields(
-       struct inode    *ip)
+xfs_validate_fields(
+       struct inode    *ip,
+       struct vattr    *vattr)
 {
-       vnode_t         *vp = LINVFS_GET_VP(ip);
-       vattr_t         va;
+       vnode_t         *vp = vn_from_inode(ip);
        int             error;
 
-       va.va_mask = XFS_AT_NLINK|XFS_AT_SIZE|XFS_AT_NBLOCKS;
-       VOP_GETATTR(vp, &va, ATTR_LAZY, NULL, error);
-       if (likely(!error)) {
-               ip->i_nlink = va.va_nlink;
-               ip->i_blocks = va.va_nblocks;
+       vattr->va_mask = XFS_AT_NLINK|XFS_AT_SIZE|XFS_AT_NBLOCKS;
+       VOP_GETATTR(vp, vattr, ATTR_LAZY, NULL, error);
+       if (likely(!error)) {
+               ip->i_nlink = vattr->va_nlink;
+               ip->i_blocks = vattr->va_nblocks;
 
-               /* we're under i_mutex so i_size can't change under us */
-               if (i_size_read(ip) != va.va_size)
-                       i_size_write(ip, va.va_size);
+               /* we're under i_sem so i_size can't change under us */
+               if (i_size_read(ip) != vattr->va_size)
+                       i_size_write(ip, vattr->va_size);
        }
 }
 
@@ -224,11 +224,11 @@ validate_fields(
  * inode, of course, such that log replay can't cause these to be lost).
  */
 STATIC int
-linvfs_init_security(
+xfs_init_security(
        struct vnode    *vp,
        struct inode    *dir)
 {
-       struct inode    *ip = LINVFS_GET_IP(vp);
+       struct inode    *ip = vn_to_inode(vp);
        size_t          length;
        void            *value;
        char            *name;
@@ -257,46 +257,46 @@ linvfs_init_security(
  * XXX(hch):  nfsd is broken, better fix it instead.
  */
 STATIC inline int
-has_fs_struct(struct task_struct *task)
+xfs_has_fs_struct(struct task_struct *task)
 {
        return (task->fs != init_task.fs);
 }
 
 STATIC inline void
-cleanup_inode(
+xfs_cleanup_inode(
        vnode_t         *dvp,
        vnode_t         *vp,
-       struct dentry   *dentry,        
+       struct dentry   *dentry,
        int             mode)
 {
        struct dentry   teardown = {};
-       int             err2;
+       int             error;
 
        /* Oh, the horror.
-        * If we can't add the ACL or we fail in 
-        * linvfs_init_security we must back out.
+        * If we can't add the ACL or we fail in
+        * xfs_init_security we must back out.
         * ENOSPC can hit here, among other things.
         */
-       teardown.d_inode = LINVFS_GET_IP(vp);
+       teardown.d_inode = vn_to_inode(vp);
        teardown.d_name = dentry->d_name;
 
        if (S_ISDIR(mode))
-               VOP_RMDIR(dvp, &teardown, NULL, err2);
+               VOP_RMDIR(dvp, &teardown, NULL, error);
        else
-               VOP_REMOVE(dvp, &teardown, NULL, err2);
+               VOP_REMOVE(dvp, &teardown, NULL, error);
        VN_RELE(vp);
 }
 
 STATIC int
-linvfs_mknod(
+xfs_vn_mknod(
        struct inode    *dir,
        struct dentry   *dentry,
        int             mode,
        dev_t           rdev)
 {
        struct inode    *ip;
-       vattr_t         va;
-       vnode_t         *vp = NULL, *dvp = LINVFS_GET_VP(dir);
+       vattr_t         vattr = { 0 };
+       vnode_t         *vp = NULL, *dvp = vn_from_inode(dir);
        xfs_acl_t       *default_acl = NULL;
        attrexists_t    test_default_acl = _ACL_DEFAULT_EXISTS;
        int             error;
@@ -305,99 +305,98 @@ linvfs_mknod(
         * Irix uses Missed'em'V split, but doesn't want to see
         * the upper 5 bits of (14bit) major.
         */
-       if (!sysv_valid_dev(rdev) || MAJOR(rdev) & ~0x1ff)
+       if (unlikely(!sysv_valid_dev(rdev) || MAJOR(rdev) & ~0x1ff))
                return -EINVAL;
 
-       if (test_default_acl && test_default_acl(dvp)) {
-               if (!_ACL_ALLOC(default_acl))
+       if (unlikely(test_default_acl && test_default_acl(dvp))) {
+               if (!_ACL_ALLOC(default_acl)) {
                        return -ENOMEM;
+               }
                if (!_ACL_GET_DEFAULT(dvp, default_acl)) {
                        _ACL_FREE(default_acl);
                        default_acl = NULL;
                }
        }
 
-       if (IS_POSIXACL(dir) && !default_acl && has_fs_struct(current))
+       if (IS_POSIXACL(dir) && !default_acl && xfs_has_fs_struct(current))
                mode &= ~current->fs->umask;
 
-       memset(&va, 0, sizeof(va));
-       va.va_mask = XFS_AT_TYPE|XFS_AT_MODE;
-       va.va_mode = mode;
+       vattr.va_mask = XFS_AT_TYPE|XFS_AT_MODE;
+       vattr.va_mode = mode;
 
        switch (mode & S_IFMT) {
        case S_IFCHR: case S_IFBLK: case S_IFIFO: case S_IFSOCK:
-               va.va_rdev = sysv_encode_dev(rdev);
-               va.va_mask |= XFS_AT_RDEV;
+               vattr.va_rdev = sysv_encode_dev(rdev);
+               vattr.va_mask |= XFS_AT_RDEV;
                /*FALLTHROUGH*/
        case S_IFREG:
-               VOP_CREATE(dvp, dentry, &va, &vp, NULL, error);
+               VOP_CREATE(dvp, dentry, &vattr, &vp, NULL, error);
                break;
        case S_IFDIR:
-               VOP_MKDIR(dvp, dentry, &va, &vp, NULL, error);
+               VOP_MKDIR(dvp, dentry, &vattr, &vp, NULL, error);
                break;
        default:
                error = EINVAL;
                break;
        }
 
-       if (!error)
-       {
-               error = linvfs_init_security(vp, dir);
+       if (unlikely(!error)) {
+               error = xfs_init_security(vp, dir);
                if (error)
-                       cleanup_inode(dvp, vp, dentry, mode);
+                       xfs_cleanup_inode(dvp, vp, dentry, mode);
        }
 
-       if (default_acl) {
+       if (unlikely(default_acl)) {
                if (!error) {
-                       error = _ACL_INHERIT(vp, &va, default_acl);
-                       if (!error) 
+                       error = _ACL_INHERIT(vp, &vattr, default_acl);
+                       if (!error)
                                VMODIFY(vp);
                        else
-                               cleanup_inode(dvp, vp, dentry, mode);
+                               xfs_cleanup_inode(dvp, vp, dentry, mode);
                }
                _ACL_FREE(default_acl);
        }
 
-       if (!error) {
+       if (likely(!error)) {
                ASSERT(vp);
-               ip = LINVFS_GET_IP(vp);
+               ip = vn_to_inode(vp);
 
                if (S_ISCHR(mode) || S_ISBLK(mode))
                        ip->i_rdev = rdev;
                else if (S_ISDIR(mode))
-                       validate_fields(ip);
+                       xfs_validate_fields(ip, &vattr);
                d_instantiate(dentry, ip);
-               validate_fields(dir);
+               xfs_validate_fields(dir, &vattr);
        }
        return -error;
 }
 
 STATIC int
-linvfs_create(
+xfs_vn_create(
        struct inode    *dir,
        struct dentry   *dentry,
        int             mode,
        struct nameidata *nd)
 {
-       return linvfs_mknod(dir, dentry, mode, 0);
+       return xfs_vn_mknod(dir, dentry, mode, 0);
 }
 
 STATIC int
-linvfs_mkdir(
+xfs_vn_mkdir(
        struct inode    *dir,
        struct dentry   *dentry,
        int             mode)
 {
-       return linvfs_mknod(dir, dentry, mode|S_IFDIR, 0);
+       return xfs_vn_mknod(dir, dentry, mode|S_IFDIR, 0);
 }
 
 STATIC struct dentry *
-linvfs_lookup(
+xfs_vn_lookup(
        struct inode    *dir,
        struct dentry   *dentry,
        struct nameidata *nd)
 {
-       struct vnode    *vp = LINVFS_GET_VP(dir), *cvp;
+       struct vnode    *vp = vn_from_inode(dir), *cvp;
        int             error;
 
        if (dentry->d_name.len >= MAXNAMELEN)
@@ -411,11 +410,11 @@ linvfs_lookup(
                return NULL;
        }
 
-       return d_splice_alias(LINVFS_GET_IP(cvp), dentry);
+       return d_splice_alias(vn_to_inode(cvp), dentry);
 }
 
 STATIC int
-linvfs_link(
+xfs_vn_link(
        struct dentry   *old_dentry,
        struct inode    *dir,
        struct dentry   *dentry)
@@ -423,99 +422,102 @@ linvfs_link(
        struct inode    *ip;    /* inode of guy being linked to */
        vnode_t         *tdvp;  /* target directory for new name/link */
        vnode_t         *vp;    /* vp of name being linked */
+       vattr_t         vattr;
        int             error;
 
        ip = old_dentry->d_inode;       /* inode being linked to */
        if (S_ISDIR(ip->i_mode))
                return -EPERM;
 
-       tdvp = LINVFS_GET_VP(dir);
-       vp = LINVFS_GET_VP(ip);
+       tdvp = vn_from_inode(dir);
+       vp = vn_from_inode(ip);
 
        VOP_LINK(tdvp, vp, dentry, NULL, error);
-       if (!error) {
+       if (likely(!error)) {
                VMODIFY(tdvp);
                VN_HOLD(vp);
-               validate_fields(ip);
+               xfs_validate_fields(ip, &vattr);
                d_instantiate(dentry, ip);
        }
        return -error;
 }
 
 STATIC int
-linvfs_unlink(
+xfs_vn_unlink(
        struct inode    *dir,
        struct dentry   *dentry)
 {
        struct inode    *inode;
        vnode_t         *dvp;   /* directory containing name to remove */
+       vattr_t         vattr;
        int             error;
 
        inode = dentry->d_inode;
-       dvp = LINVFS_GET_VP(dir);
+       dvp = vn_from_inode(dir);
 
        VOP_REMOVE(dvp, dentry, NULL, error);
-       if (!error) {
-               validate_fields(dir);   /* For size only */
-               validate_fields(inode);
+       if (likely(!error)) {
+               xfs_validate_fields(dir, &vattr);       /* size needs update */
+               xfs_validate_fields(inode, &vattr);
        }
-
        return -error;
 }
 
 STATIC int
-linvfs_symlink(
+xfs_vn_symlink(
        struct inode    *dir,
        struct dentry   *dentry,
        const char      *symname)
 {
        struct inode    *ip;
-       vattr_t         va;
+       vattr_t         vattr = { 0 };
        vnode_t         *dvp;   /* directory containing name of symlink */
        vnode_t         *cvp;   /* used to lookup symlink to put in dentry */
        int             error;
 
-       dvp = LINVFS_GET_VP(dir);
+       dvp = vn_from_inode(dir);
        cvp = NULL;
 
-       memset(&va, 0, sizeof(va));
-       va.va_mode = S_IFLNK |
+       vattr.va_mode = S_IFLNK |
                (irix_symlink_mode ? 0777 & ~current->fs->umask : S_IRWXUGO);
-       va.va_mask = XFS_AT_TYPE|XFS_AT_MODE;
+       vattr.va_mask = XFS_AT_TYPE|XFS_AT_MODE;
 
        error = 0;
-       VOP_SYMLINK(dvp, dentry, &va, (char *)symname, &cvp, NULL, error);
+       VOP_SYMLINK(dvp, dentry, &vattr, (char *)symname, &cvp, NULL, error);
        if (likely(!error && cvp)) {
-               error = linvfs_init_security(cvp, dir);
+               error = xfs_init_security(cvp, dir);
                if (likely(!error)) {
-                       ip = LINVFS_GET_IP(cvp);
+                       ip = vn_to_inode(cvp);
                        d_instantiate(dentry, ip);
-                       validate_fields(dir);
-                       validate_fields(ip);
+                       xfs_validate_fields(dir, &vattr);
+                       xfs_validate_fields(ip, &vattr);
+               } else {
+                       xfs_cleanup_inode(dvp, cvp, dentry, 0);
                }
        }
        return -error;
 }
 
 STATIC int
-linvfs_rmdir(
+xfs_vn_rmdir(
        struct inode    *dir,
        struct dentry   *dentry)
 {
        struct inode    *inode = dentry->d_inode;
-       vnode_t         *dvp = LINVFS_GET_VP(dir);
+       vnode_t         *dvp = vn_from_inode(dir);
+       vattr_t         vattr;
        int             error;
 
        VOP_RMDIR(dvp, dentry, NULL, error);
-       if (!error) {
-               validate_fields(inode);
-               validate_fields(dir);
+       if (likely(!error)) {
+               xfs_validate_fields(inode, &vattr);
+               xfs_validate_fields(dir, &vattr);
        }
        return -error;
 }
 
 STATIC int
-linvfs_rename(
+xfs_vn_rename(
        struct inode    *odir,
        struct dentry   *odentry,
        struct inode    *ndir,
@@ -524,22 +526,21 @@ linvfs_rename(
        struct inode    *new_inode = ndentry->d_inode;
        vnode_t         *fvp;   /* from directory */
        vnode_t         *tvp;   /* target directory */
+       vattr_t         vattr;
        int             error;
 
-       fvp = LINVFS_GET_VP(odir);
-       tvp = LINVFS_GET_VP(ndir);
+       fvp = vn_from_inode(odir);
+       tvp = vn_from_inode(ndir);
 
        VOP_RENAME(fvp, odentry, tvp, ndentry, NULL, error);
-       if (error)
-               return -error;
-
-       if (new_inode)
-               validate_fields(new_inode);
-
-       validate_fields(odir);
-       if (ndir != odir)
-               validate_fields(ndir);
-       return 0;
+       if (likely(!error)) {
+               if (new_inode)
+                       xfs_validate_fields(new_inode, &vattr);
+               xfs_validate_fields(odir, &vattr);
+               if (ndir != odir)
+                       xfs_validate_fields(ndir, &vattr);
+       }
+       return -error;
 }
 
 /*
@@ -548,7 +549,7 @@ linvfs_rename(
  * uio is kmalloced for this reason...
  */
 STATIC void *
-linvfs_follow_link(
+xfs_vn_follow_link(
        struct dentry           *dentry,
        struct nameidata        *nd)
 {
@@ -574,7 +575,7 @@ linvfs_follow_link(
                return NULL;
        }
 
-       vp = LINVFS_GET_VP(dentry->d_inode);
+       vp = vn_from_inode(dentry->d_inode);
 
        iov.iov_base = link;
        iov.iov_len = MAXPATHLEN;
@@ -599,7 +600,7 @@ linvfs_follow_link(
 }
 
 STATIC void
-linvfs_put_link(
+xfs_vn_put_link(
        struct dentry   *dentry,
        struct nameidata *nd,
        void            *p)
@@ -612,12 +613,12 @@ linvfs_put_link(
 
 #ifdef CONFIG_XFS_POSIX_ACL
 STATIC int
-linvfs_permission(
+xfs_vn_permission(
        struct inode    *inode,
        int             mode,
        struct nameidata *nd)
 {
-       vnode_t         *vp = LINVFS_GET_VP(inode);
+       vnode_t         *vp = vn_from_inode(inode);
        int             error;
 
        mode <<= 6;             /* convert from linux to vnode access bits */
@@ -625,17 +626,17 @@ linvfs_permission(
        return -error;
 }
 #else
-#define linvfs_permission NULL
+#define xfs_vn_permission NULL
 #endif
 
 STATIC int
-linvfs_getattr(
+xfs_vn_getattr(
        struct vfsmount *mnt,
        struct dentry   *dentry,
        struct kstat    *stat)
 {
        struct inode    *inode = dentry->d_inode;
-       vnode_t         *vp = LINVFS_GET_VP(inode);
+       vnode_t         *vp = vn_from_inode(inode);
        int             error = 0;
 
        if (unlikely(vp->v_flag & VMODIFIED))
@@ -646,18 +647,17 @@ linvfs_getattr(
 }
 
 STATIC int
-linvfs_setattr(
+xfs_vn_setattr(
        struct dentry   *dentry,
        struct iattr    *attr)
 {
        struct inode    *inode = dentry->d_inode;
        unsigned int    ia_valid = attr->ia_valid;
-       vnode_t         *vp = LINVFS_GET_VP(inode);
-       vattr_t         vattr;
+       vnode_t         *vp = vn_from_inode(inode);
+       vattr_t         vattr = { 0 };
        int             flags = 0;
        int             error;
 
-       memset(&vattr, 0, sizeof(vattr_t));
        if (ia_valid & ATTR_UID) {
                vattr.va_mask |= XFS_AT_UID;
                vattr.va_uid = attr->ia_uid;
@@ -699,28 +699,27 @@ linvfs_setattr(
 #endif
 
        VOP_SETATTR(vp, &vattr, flags, NULL, error);
-       if (error)
-               return -error;
-       vn_revalidate(vp);
-       return error;
+       if (likely(!error))
+               __vn_revalidate(vp, &vattr);
+       return -error;
 }
 
 STATIC void
-linvfs_truncate(
+xfs_vn_truncate(
        struct inode    *inode)
 {
-       block_truncate_page(inode->i_mapping, inode->i_size, linvfs_get_block);
+       block_truncate_page(inode->i_mapping, inode->i_size, xfs_get_block);
 }
 
 STATIC int
-linvfs_setxattr(
+xfs_vn_setxattr(
        struct dentry   *dentry,
        const char      *name,
        const void      *data,
        size_t          size,
        int             flags)
 {
-       vnode_t         *vp = LINVFS_GET_VP(dentry->d_inode);
+       vnode_t         *vp = vn_from_inode(dentry->d_inode);
        char            *attr = (char *)name;
        attrnames_t     *namesp;
        int             xflags = 0;
@@ -744,13 +743,13 @@ linvfs_setxattr(
 }
 
 STATIC ssize_t
-linvfs_getxattr(
+xfs_vn_getxattr(
        struct dentry   *dentry,
        const char      *name,
        void            *data,
        size_t          size)
 {
-       vnode_t         *vp = LINVFS_GET_VP(dentry->d_inode);
+       vnode_t         *vp = vn_from_inode(dentry->d_inode);
        char            *attr = (char *)name;
        attrnames_t     *namesp;
        int             xflags = 0;
@@ -774,12 +773,12 @@ linvfs_getxattr(
 }
 
 STATIC ssize_t
-linvfs_listxattr(
+xfs_vn_listxattr(
        struct dentry           *dentry,
        char                    *data,
        size_t                  size)
 {
-       vnode_t                 *vp = LINVFS_GET_VP(dentry->d_inode);
+       vnode_t                 *vp = vn_from_inode(dentry->d_inode);
        int                     error, xflags = ATTR_KERNAMELS;
        ssize_t                 result;
 
@@ -794,11 +793,11 @@ linvfs_listxattr(
 }
 
 STATIC int
-linvfs_removexattr(
+xfs_vn_removexattr(
        struct dentry   *dentry,
        const char      *name)
 {
-       vnode_t         *vp = LINVFS_GET_VP(dentry->d_inode);
+       vnode_t         *vp = vn_from_inode(dentry->d_inode);
        char            *attr = (char *)name;
        attrnames_t     *namesp;
        int             xflags = 0;
@@ -816,45 +815,45 @@ linvfs_removexattr(
 }
 
 
-struct inode_operations linvfs_file_inode_operations = {
-       .permission             = linvfs_permission,
-       .truncate               = linvfs_truncate,
-       .getattr                = linvfs_getattr,
-       .setattr                = linvfs_setattr,
-       .setxattr               = linvfs_setxattr,
-       .getxattr               = linvfs_getxattr,
-       .listxattr              = linvfs_listxattr,
-       .removexattr            = linvfs_removexattr,
+struct inode_operations xfs_inode_operations = {
+       .permission             = xfs_vn_permission,
+       .truncate               = xfs_vn_truncate,
+       .getattr                = xfs_vn_getattr,
+       .setattr                = xfs_vn_setattr,
+       .setxattr               = xfs_vn_setxattr,
+       .getxattr               = xfs_vn_getxattr,
+       .listxattr              = xfs_vn_listxattr,
+       .removexattr            = xfs_vn_removexattr,
 };
 
-struct inode_operations linvfs_dir_inode_operations = {
-       .create                 = linvfs_create,
-       .lookup                 = linvfs_lookup,
-       .link                   = linvfs_link,
-       .unlink                 = linvfs_unlink,
-       .symlink                = linvfs_symlink,
-       .mkdir                  = linvfs_mkdir,
-       .rmdir                  = linvfs_rmdir,
-       .mknod                  = linvfs_mknod,
-       .rename                 = linvfs_rename,
-       .permission             = linvfs_permission,
-       .getattr                = linvfs_getattr,
-       .setattr                = linvfs_setattr,
-       .setxattr               = linvfs_setxattr,
-       .getxattr               = linvfs_getxattr,
-       .listxattr              = linvfs_listxattr,
-       .removexattr            = linvfs_removexattr,
+struct inode_operations xfs_dir_inode_operations = {
+       .create                 = xfs_vn_create,
+       .lookup                 = xfs_vn_lookup,
+       .link                   = xfs_vn_link,
+       .unlink                 = xfs_vn_unlink,
+       .symlink                = xfs_vn_symlink,
+       .mkdir                  = xfs_vn_mkdir,
+       .rmdir                  = xfs_vn_rmdir,
+       .mknod                  = xfs_vn_mknod,
+       .rename                 = xfs_vn_rename,
+       .permission             = xfs_vn_permission,
+       .getattr                = xfs_vn_getattr,
+       .setattr                = xfs_vn_setattr,
+       .setxattr               = xfs_vn_setxattr,
+       .getxattr               = xfs_vn_getxattr,
+       .listxattr              = xfs_vn_listxattr,
+       .removexattr            = xfs_vn_removexattr,
 };
 
-struct inode_operations linvfs_symlink_inode_operations = {
+struct inode_operations xfs_symlink_inode_operations = {
        .readlink               = generic_readlink,
-       .follow_link            = linvfs_follow_link,
-       .put_link               = linvfs_put_link,
-       .permission             = linvfs_permission,
-       .getattr                = linvfs_getattr,
-       .setattr                = linvfs_setattr,
-       .setxattr               = linvfs_setxattr,
-       .getxattr               = linvfs_getxattr,
-       .listxattr              = linvfs_listxattr,
-       .removexattr            = linvfs_removexattr,
+       .follow_link            = xfs_vn_follow_link,
+       .put_link               = xfs_vn_put_link,
+       .permission             = xfs_vn_permission,
+       .getattr                = xfs_vn_getattr,
+       .setattr                = xfs_vn_setattr,
+       .setxattr               = xfs_vn_setxattr,
+       .getxattr               = xfs_vn_getxattr,
+       .listxattr              = xfs_vn_listxattr,
+       .removexattr            = xfs_vn_removexattr,
 };
index 6899a6b4a50acb0fc7428b209bf397f7291b8c64..a8417d7af5f9dcffc7b4ab6350a219c7f76935e8 100644 (file)
 #ifndef __XFS_IOPS_H__
 #define __XFS_IOPS_H__
 
-extern struct inode_operations linvfs_file_inode_operations;
-extern struct inode_operations linvfs_dir_inode_operations;
-extern struct inode_operations linvfs_symlink_inode_operations;
+extern struct inode_operations xfs_inode_operations;
+extern struct inode_operations xfs_dir_inode_operations;
+extern struct inode_operations xfs_symlink_inode_operations;
 
-extern struct file_operations linvfs_file_operations;
-extern struct file_operations linvfs_invis_file_operations;
-extern struct file_operations linvfs_dir_operations;
+extern struct file_operations xfs_file_operations;
+extern struct file_operations xfs_dir_file_operations;
+extern struct file_operations xfs_invis_file_operations;
 
 extern int xfs_ioctl(struct bhv_desc *, struct inode *, struct file *,
                         int, unsigned int, void __user *);
index 67389b745526d1e5e4928738623bcbccf83e44ea..1fe09f2d65194db07c33e204b4a53dce89365323 100644 (file)
@@ -73,6 +73,9 @@
 #include <linux/list.h>
 #include <linux/proc_fs.h>
 #include <linux/sort.h>
+#include <linux/cpu.h>
+#include <linux/notifier.h>
+#include <linux/delay.h>
 
 #include <asm/page.h>
 #include <asm/div64.h>
  */
 #undef  HAVE_REFCACHE  /* reference cache not needed for NFS in 2.6 */
 #define HAVE_SENDFILE  /* sendfile(2) exists in 2.6, but not in 2.4 */
+#ifdef CONFIG_SMP
+#define HAVE_PERCPU_SB /* per cpu superblock counters are a 2.6 feature */
+#else
+#undef  HAVE_PERCPU_SB /* per cpu superblock counters are a 2.6 feature */
+#endif
 
 /*
  * State flag for unwritten extent buffers.
@@ -226,7 +234,7 @@ BUFFER_FNS(PrivateStart, unwritten);
 #define xfs_sort(a,n,s,fn)     sort(a,n,s,fn,NULL)
 #define xfs_stack_trace()      dump_stack()
 #define xfs_itruncate_data(ip, off)    \
-       (-vmtruncate(LINVFS_GET_IP(XFS_ITOV(ip)), (off)))
+       (-vmtruncate(vn_to_inode(XFS_ITOV(ip)), (off)))
 #define xfs_statvfs_fsid(statp, mp)    \
        ({ u64 id = huge_encode_dev((mp)->m_ddev_targp->bt_dev); \
           __kernel_fsid_t *fsid = &(statp)->f_fsid;    \
index e0ab45fbfebd4e0cbe6fbc2b5c992ae9deeb952b..0169360475c411825249e65aa3e318bca38615ac 100644 (file)
@@ -83,7 +83,7 @@ xfs_rw_enter_trace(
                (void *)((unsigned long)ioflags),
                (void *)((unsigned long)((io->io_new_size >> 32) & 0xffffffff)),
                (void *)((unsigned long)(io->io_new_size & 0xffffffff)),
-               (void *)NULL,
+               (void *)((unsigned long)current_pid()),
                (void *)NULL,
                (void *)NULL,
                (void *)NULL,
@@ -113,7 +113,7 @@ xfs_inval_cached_trace(
                (void *)((unsigned long)(first & 0xffffffff)),
                (void *)((unsigned long)((last >> 32) & 0xffffffff)),
                (void *)((unsigned long)(last & 0xffffffff)),
-               (void *)NULL,
+               (void *)((unsigned long)current_pid()),
                (void *)NULL,
                (void *)NULL,
                (void *)NULL,
@@ -249,9 +249,8 @@ xfs_read(
        if (n < size)
                size = n;
 
-       if (XFS_FORCED_SHUTDOWN(mp)) {
+       if (XFS_FORCED_SHUTDOWN(mp))
                return -EIO;
-       }
 
        if (unlikely(ioflags & IO_ISDIRECT))
                mutex_lock(&inode->i_mutex);
@@ -267,10 +266,14 @@ xfs_read(
                                        dmflags, &locktype);
                if (ret) {
                        xfs_iunlock(ip, XFS_IOLOCK_SHARED);
-                       goto unlock_isem;
+                       goto unlock_mutex;
                }
        }
 
+       if (unlikely((ioflags & IO_ISDIRECT) && VN_CACHED(vp)))
+               VOP_FLUSHINVAL_PAGES(vp, ctooff(offtoct(*offset)),
+                                               -1, FI_REMAPF_LOCKED);
+
        xfs_rw_enter_trace(XFS_READ_ENTER, &ip->i_iocore,
                                (void *)iovp, segs, *offset, ioflags);
        ret = __generic_file_aio_read(iocb, iovp, segs, offset);
@@ -281,7 +284,7 @@ xfs_read(
 
        xfs_iunlock(ip, XFS_IOLOCK_SHARED);
 
-unlock_isem:
+unlock_mutex:
        if (unlikely(ioflags & IO_ISDIRECT))
                mutex_unlock(&inode->i_mutex);
        return ret;
@@ -432,7 +435,7 @@ xfs_zero_eof(
        xfs_fsize_t     isize,          /* current inode size */
        xfs_fsize_t     end_size)       /* terminal inode size */
 {
-       struct inode    *ip = LINVFS_GET_IP(vp);
+       struct inode    *ip = vn_to_inode(vp);
        xfs_fileoff_t   start_zero_fsb;
        xfs_fileoff_t   end_zero_fsb;
        xfs_fileoff_t   zero_count_fsb;
@@ -573,7 +576,7 @@ xfs_write(
        vrwlock_t               locktype;
        size_t                  ocount = 0, count;
        loff_t                  pos;
-       int                     need_isem = 1, need_flush = 0;
+       int                     need_i_mutex = 1, need_flush = 0;
 
        XFS_STATS_INC(xs_write_calls);
 
@@ -622,14 +625,14 @@ xfs_write(
                        return XFS_ERROR(-EINVAL);
 
                if (!VN_CACHED(vp) && pos < i_size_read(inode))
-                       need_isem = 0;
+                       need_i_mutex = 0;
 
                if (VN_CACHED(vp))
                        need_flush = 1;
        }
 
 relock:
-       if (need_isem) {
+       if (need_i_mutex) {
                iolock = XFS_IOLOCK_EXCL;
                locktype = VRWLOCK_WRITE;
 
@@ -651,7 +654,7 @@ start:
                                        S_ISBLK(inode->i_mode));
        if (error) {
                xfs_iunlock(xip, XFS_ILOCK_EXCL|iolock);
-               goto out_unlock_isem;
+               goto out_unlock_mutex;
        }
 
        new_size = pos + count;
@@ -663,7 +666,7 @@ start:
                loff_t          savedsize = pos;
                int             dmflags = FILP_DELAY_FLAG(file);
 
-               if (need_isem)
+               if (need_i_mutex)
                        dmflags |= DM_FLAGS_IMUX;
 
                xfs_iunlock(xip, XFS_ILOCK_EXCL);
@@ -672,7 +675,7 @@ start:
                                      dmflags, &locktype);
                if (error) {
                        xfs_iunlock(xip, iolock);
-                       goto out_unlock_isem;
+                       goto out_unlock_mutex;
                }
                xfs_ilock(xip, XFS_ILOCK_EXCL);
                eventsent = 1;
@@ -710,7 +713,7 @@ start:
                                        isize, pos + count);
                if (error) {
                        xfs_iunlock(xip, XFS_ILOCK_EXCL|iolock);
-                       goto out_unlock_isem;
+                       goto out_unlock_mutex;
                }
        }
        xfs_iunlock(xip, XFS_ILOCK_EXCL);
@@ -731,7 +734,7 @@ start:
                        error = -remove_suid(file->f_dentry);
                if (unlikely(error)) {
                        xfs_iunlock(xip, iolock);
-                       goto out_unlock_isem;
+                       goto out_unlock_mutex;
                }
        }
 
@@ -747,14 +750,14 @@ retry:
                                        -1, FI_REMAPF_LOCKED);
                }
 
-               if (need_isem) {
+               if (need_i_mutex) {
                        /* demote the lock now the cached pages are gone */
                        XFS_ILOCK_DEMOTE(mp, io, XFS_IOLOCK_EXCL);
                        mutex_unlock(&inode->i_mutex);
 
                        iolock = XFS_IOLOCK_SHARED;
                        locktype = VRWLOCK_WRITE_DIRECT;
-                       need_isem = 0;
+                       need_i_mutex = 0;
                }
 
                xfs_rw_enter_trace(XFS_DIOWR_ENTER, io, (void *)iovp, segs,
@@ -772,7 +775,7 @@ retry:
                        pos += ret;
                        count -= ret;
 
-                       need_isem = 1;
+                       need_i_mutex = 1;
                        ioflags &= ~IO_ISDIRECT;
                        xfs_iunlock(xip, iolock);
                        goto relock;
@@ -794,14 +797,14 @@ retry:
            !(ioflags & IO_INVIS)) {
 
                xfs_rwunlock(bdp, locktype);
-               if (need_isem)
+               if (need_i_mutex)
                        mutex_unlock(&inode->i_mutex);
                error = XFS_SEND_NAMESP(xip->i_mount, DM_EVENT_NOSPACE, vp,
                                DM_RIGHT_NULL, vp, DM_RIGHT_NULL, NULL, NULL,
                                0, 0, 0); /* Delay flag intentionally  unused */
                if (error)
                        goto out_nounlocks;
-               if (need_isem)
+               if (need_i_mutex)
                        mutex_lock(&inode->i_mutex);
                xfs_rwlock(bdp, locktype);
                pos = xip->i_d.di_size;
@@ -905,9 +908,9 @@ retry:
                        if (error)
                                goto out_unlock_internal;
                }
-       
+
                xfs_rwunlock(bdp, locktype);
-               if (need_isem)
+               if (need_i_mutex)
                        mutex_unlock(&inode->i_mutex);
 
                error = sync_page_range(inode, mapping, pos, ret);
@@ -918,8 +921,8 @@ retry:
 
  out_unlock_internal:
        xfs_rwunlock(bdp, locktype);
- out_unlock_isem:
-       if (need_isem)
+ out_unlock_mutex:
+       if (need_i_mutex)
                mutex_unlock(&inode->i_mutex);
  out_nounlocks:
        return -error;
index f22e426d9e4293731be1bdecf43c015c88e7bbdd..8355faf8ffded885d3557322b48b0ffd2f9b28fe 100644 (file)
@@ -59,8 +59,8 @@
 #include <linux/writeback.h>
 #include <linux/kthread.h>
 
-STATIC struct quotactl_ops linvfs_qops;
-STATIC struct super_operations linvfs_sops;
+STATIC struct quotactl_ops xfs_quotactl_operations;
+STATIC struct super_operations xfs_super_operations;
 STATIC kmem_zone_t *xfs_vnode_zone;
 STATIC kmem_zone_t *xfs_ioend_zone;
 mempool_t *xfs_ioend_pool;
@@ -76,8 +76,6 @@ xfs_args_allocate(
        strncpy(args->fsname, sb->s_id, MAXNAMELEN);
 
        /* Copy the already-parsed mount(2) flags we're interested in */
-       if (sb->s_flags & MS_NOATIME)
-               args->flags |= XFSMNT_NOATIME;
        if (sb->s_flags & MS_DIRSYNC)
                args->flags |= XFSMNT_DIRSYNC;
        if (sb->s_flags & MS_SYNCHRONOUS)
@@ -129,21 +127,21 @@ xfs_set_inodeops(
 {
        switch (inode->i_mode & S_IFMT) {
        case S_IFREG:
-               inode->i_op = &linvfs_file_inode_operations;
-               inode->i_fop = &linvfs_file_operations;
-               inode->i_mapping->a_ops = &linvfs_aops;
+               inode->i_op = &xfs_inode_operations;
+               inode->i_fop = &xfs_file_operations;
+               inode->i_mapping->a_ops = &xfs_address_space_operations;
                break;
        case S_IFDIR:
-               inode->i_op = &linvfs_dir_inode_operations;
-               inode->i_fop = &linvfs_dir_operations;
+               inode->i_op = &xfs_dir_inode_operations;
+               inode->i_fop = &xfs_dir_file_operations;
                break;
        case S_IFLNK:
-               inode->i_op = &linvfs_symlink_inode_operations;
+               inode->i_op = &xfs_symlink_inode_operations;
                if (inode->i_blocks)
-                       inode->i_mapping->a_ops = &linvfs_aops;
+                       inode->i_mapping->a_ops = &xfs_address_space_operations;
                break;
        default:
-               inode->i_op = &linvfs_file_inode_operations;
+               inode->i_op = &xfs_inode_operations;
                init_special_inode(inode, inode->i_mode, inode->i_rdev);
                break;
        }
@@ -155,7 +153,7 @@ xfs_revalidate_inode(
        vnode_t                 *vp,
        xfs_inode_t             *ip)
 {
-       struct inode            *inode = LINVFS_GET_IP(vp);
+       struct inode            *inode = vn_to_inode(vp);
 
        inode->i_mode   = ip->i_d.di_mode;
        inode->i_nlink  = ip->i_d.di_nlink;
@@ -212,7 +210,7 @@ xfs_initialize_vnode(
        int                     unlock)
 {
        xfs_inode_t             *ip = XFS_BHVTOI(inode_bhv);
-       struct inode            *inode = LINVFS_GET_IP(vp);
+       struct inode            *inode = vn_to_inode(vp);
 
        if (!inode_bhv->bd_vobj) {
                vp->v_vfsp = bhvtovfs(bdp);
@@ -230,7 +228,7 @@ xfs_initialize_vnode(
        if (ip->i_d.di_mode != 0 && unlock && (inode->i_state & I_NEW)) {
                xfs_revalidate_inode(XFS_BHVTOM(bdp), vp, ip);
                xfs_set_inodeops(inode);
-       
+
                ip->i_flags &= ~XFS_INEW;
                barrier();
 
@@ -334,43 +332,42 @@ xfs_blkdev_issue_flush(
 }
 
 STATIC struct inode *
-linvfs_alloc_inode(
+xfs_fs_alloc_inode(
        struct super_block      *sb)
 {
        vnode_t                 *vp;
 
-       vp = kmem_cache_alloc(xfs_vnode_zone, kmem_flags_convert(KM_SLEEP));
-       if (!vp)
+       vp = kmem_zone_alloc(xfs_vnode_zone, KM_SLEEP);
+       if (unlikely(!vp))
                return NULL;
-       return LINVFS_GET_IP(vp);
+       return vn_to_inode(vp);
 }
 
 STATIC void
-linvfs_destroy_inode(
+xfs_fs_destroy_inode(
        struct inode            *inode)
 {
-       kmem_zone_free(xfs_vnode_zone, LINVFS_GET_VP(inode));
+       kmem_zone_free(xfs_vnode_zone, vn_from_inode(inode));
 }
 
 STATIC void
-linvfs_inode_init_once(
-       void                    *data,
-       kmem_cache_t            *cachep,
+xfs_fs_inode_init_once(
+       void                    *vnode,
+       kmem_zone_t             *zonep,
        unsigned long           flags)
 {
-       vnode_t                 *vp = (vnode_t *)data;
-
        if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) ==
-           SLAB_CTOR_CONSTRUCTOR)
-               inode_init_once(LINVFS_GET_IP(vp));
+                     SLAB_CTOR_CONSTRUCTOR)
+               inode_init_once(vn_to_inode((vnode_t *)vnode));
 }
 
 STATIC int
-linvfs_init_zones(void)
+xfs_init_zones(void)
 {
-       xfs_vnode_zone = kmem_cache_create("xfs_vnode",
-                               sizeof(vnode_t), 0, SLAB_RECLAIM_ACCOUNT,
-                               linvfs_inode_init_once, NULL);
+       xfs_vnode_zone = kmem_zone_init_flags(sizeof(vnode_t), "xfs_vnode_t",
+                                       KM_ZONE_HWALIGN | KM_ZONE_RECLAIM |
+                                       KM_ZONE_SPREAD,
+                                       xfs_fs_inode_init_once);
        if (!xfs_vnode_zone)
                goto out;
 
@@ -379,14 +376,12 @@ linvfs_init_zones(void)
                goto out_destroy_vnode_zone;
 
        xfs_ioend_pool = mempool_create(4 * MAX_BUF_PER_PAGE,
-                       mempool_alloc_slab, mempool_free_slab,
-                       xfs_ioend_zone);
+                                       mempool_alloc_slab, mempool_free_slab,
+                                       xfs_ioend_zone);
        if (!xfs_ioend_pool)
                goto out_free_ioend_zone;
-
        return 0;
 
-
  out_free_ioend_zone:
        kmem_zone_destroy(xfs_ioend_zone);
  out_destroy_vnode_zone:
@@ -396,7 +391,7 @@ linvfs_init_zones(void)
 }
 
 STATIC void
-linvfs_destroy_zones(void)
+xfs_destroy_zones(void)
 {
        mempool_destroy(xfs_ioend_pool);
        kmem_zone_destroy(xfs_vnode_zone);
@@ -407,14 +402,14 @@ linvfs_destroy_zones(void)
  * Attempt to flush the inode, this will actually fail
  * if the inode is pinned, but we dirty the inode again
  * at the point when it is unpinned after a log write,
- * since this is when the inode itself becomes flushable. 
+ * since this is when the inode itself becomes flushable.
  */
 STATIC int
-linvfs_write_inode(
+xfs_fs_write_inode(
        struct inode            *inode,
        int                     sync)
 {
-       vnode_t                 *vp = LINVFS_GET_VP(inode);
+       vnode_t                 *vp = vn_from_inode(inode);
        int                     error = 0, flags = FLUSH_INODE;
 
        if (vp) {
@@ -434,13 +429,13 @@ linvfs_write_inode(
 }
 
 STATIC void
-linvfs_clear_inode(
+xfs_fs_clear_inode(
        struct inode            *inode)
 {
-       vnode_t                 *vp = LINVFS_GET_VP(inode);
+       vnode_t                 *vp = vn_from_inode(inode);
        int                     error, cache;
 
-       vn_trace_entry(vp, "clear_inode", (inst_t *)__return_address);
+       vn_trace_entry(vp, __FUNCTION__, (inst_t *)__return_address);
 
        XFS_STATS_INC(vn_rele);
        XFS_STATS_INC(vn_remove);
@@ -516,7 +511,7 @@ void
 xfs_flush_inode(
        xfs_inode_t     *ip)
 {
-       struct inode    *inode = LINVFS_GET_IP(XFS_ITOV(ip));
+       struct inode    *inode = vn_to_inode(XFS_ITOV(ip));
        struct vfs      *vfs = XFS_MTOVFS(ip->i_mount);
 
        igrab(inode);
@@ -541,7 +536,7 @@ void
 xfs_flush_device(
        xfs_inode_t     *ip)
 {
-       struct inode    *inode = LINVFS_GET_IP(XFS_ITOV(ip));
+       struct inode    *inode = vn_to_inode(XFS_ITOV(ip));
        struct vfs      *vfs = XFS_MTOVFS(ip->i_mount);
 
        igrab(inode);
@@ -550,7 +545,7 @@ xfs_flush_device(
        xfs_log_force(ip->i_mount, (xfs_lsn_t)0, XFS_LOG_FORCE|XFS_LOG_SYNC);
 }
 
-#define SYNCD_FLAGS    (SYNC_FSDATA|SYNC_BDFLUSH|SYNC_ATTR)
+#define SYNCD_FLAGS    (SYNC_FSDATA|SYNC_BDFLUSH|SYNC_ATTR|SYNC_REFCACHE)
 STATIC void
 vfs_sync_worker(
        vfs_t           *vfsp,
@@ -613,7 +608,7 @@ xfssyncd(
 }
 
 STATIC int
-linvfs_start_syncd(
+xfs_fs_start_syncd(
        vfs_t                   *vfsp)
 {
        vfsp->vfs_sync_work.w_syncer = vfs_sync_worker;
@@ -625,20 +620,20 @@ linvfs_start_syncd(
 }
 
 STATIC void
-linvfs_stop_syncd(
+xfs_fs_stop_syncd(
        vfs_t                   *vfsp)
 {
        kthread_stop(vfsp->vfs_sync_task);
 }
 
 STATIC void
-linvfs_put_super(
+xfs_fs_put_super(
        struct super_block      *sb)
 {
-       vfs_t                   *vfsp = LINVFS_GET_VFS(sb);
+       vfs_t                   *vfsp = vfs_from_sb(sb);
        int                     error;
 
-       linvfs_stop_syncd(vfsp);
+       xfs_fs_stop_syncd(vfsp);
        VFS_SYNC(vfsp, SYNC_ATTR|SYNC_DELWRI, NULL, error);
        if (!error)
                VFS_UNMOUNT(vfsp, 0, NULL, error);
@@ -652,10 +647,10 @@ linvfs_put_super(
 }
 
 STATIC void
-linvfs_write_super(
+xfs_fs_write_super(
        struct super_block      *sb)
 {
-       vfs_t                   *vfsp = LINVFS_GET_VFS(sb);
+       vfs_t                   *vfsp = vfs_from_sb(sb);
        int                     error;
 
        if (sb->s_flags & MS_RDONLY) {
@@ -668,11 +663,11 @@ linvfs_write_super(
 }
 
 STATIC int
-linvfs_sync_super(
+xfs_fs_sync_super(
        struct super_block      *sb,
        int                     wait)
 {
-       vfs_t           *vfsp = LINVFS_GET_VFS(sb);
+       vfs_t           *vfsp = vfs_from_sb(sb);
        int             error;
        int             flags = SYNC_FSDATA;
 
@@ -707,11 +702,11 @@ linvfs_sync_super(
 }
 
 STATIC int
-linvfs_statfs(
+xfs_fs_statfs(
        struct super_block      *sb,
        struct kstatfs          *statp)
 {
-       vfs_t                   *vfsp = LINVFS_GET_VFS(sb);
+       vfs_t                   *vfsp = vfs_from_sb(sb);
        int                     error;
 
        VFS_STATVFS(vfsp, statp, NULL, error);
@@ -719,12 +714,12 @@ linvfs_statfs(
 }
 
 STATIC int
-linvfs_remount(
+xfs_fs_remount(
        struct super_block      *sb,
        int                     *flags,
        char                    *options)
 {
-       vfs_t                   *vfsp = LINVFS_GET_VFS(sb);
+       vfs_t                   *vfsp = vfs_from_sb(sb);
        struct xfs_mount_args   *args = xfs_args_allocate(sb);
        int                     error;
 
@@ -736,18 +731,18 @@ linvfs_remount(
 }
 
 STATIC void
-linvfs_freeze_fs(
+xfs_fs_lockfs(
        struct super_block      *sb)
 {
-       VFS_FREEZE(LINVFS_GET_VFS(sb));
+       VFS_FREEZE(vfs_from_sb(sb));
 }
 
 STATIC int
-linvfs_show_options(
+xfs_fs_show_options(
        struct seq_file         *m,
        struct vfsmount         *mnt)
 {
-       struct vfs              *vfsp = LINVFS_GET_VFS(mnt->mnt_sb);
+       struct vfs              *vfsp = vfs_from_sb(mnt->mnt_sb);
        int                     error;
 
        VFS_SHOWARGS(vfsp, m, error);
@@ -755,11 +750,11 @@ linvfs_show_options(
 }
 
 STATIC int
-linvfs_quotasync(
+xfs_fs_quotasync(
        struct super_block      *sb,
        int                     type)
 {
-       struct vfs              *vfsp = LINVFS_GET_VFS(sb);
+       struct vfs              *vfsp = vfs_from_sb(sb);
        int                     error;
 
        VFS_QUOTACTL(vfsp, Q_XQUOTASYNC, 0, (caddr_t)NULL, error);
@@ -767,11 +762,11 @@ linvfs_quotasync(
 }
 
 STATIC int
-linvfs_getxstate(
+xfs_fs_getxstate(
        struct super_block      *sb,
        struct fs_quota_stat    *fqs)
 {
-       struct vfs              *vfsp = LINVFS_GET_VFS(sb);
+       struct vfs              *vfsp = vfs_from_sb(sb);
        int                     error;
 
        VFS_QUOTACTL(vfsp, Q_XGETQSTAT, 0, (caddr_t)fqs, error);
@@ -779,12 +774,12 @@ linvfs_getxstate(
 }
 
 STATIC int
-linvfs_setxstate(
+xfs_fs_setxstate(
        struct super_block      *sb,
        unsigned int            flags,
        int                     op)
 {
-       struct vfs              *vfsp = LINVFS_GET_VFS(sb);
+       struct vfs              *vfsp = vfs_from_sb(sb);
        int                     error;
 
        VFS_QUOTACTL(vfsp, op, 0, (caddr_t)&flags, error);
@@ -792,13 +787,13 @@ linvfs_setxstate(
 }
 
 STATIC int
-linvfs_getxquota(
+xfs_fs_getxquota(
        struct super_block      *sb,
        int                     type,
        qid_t                   id,
        struct fs_disk_quota    *fdq)
 {
-       struct vfs              *vfsp = LINVFS_GET_VFS(sb);
+       struct vfs              *vfsp = vfs_from_sb(sb);
        int                     error, getmode;
 
        getmode = (type == USRQUOTA) ? Q_XGETQUOTA :
@@ -808,13 +803,13 @@ linvfs_getxquota(
 }
 
 STATIC int
-linvfs_setxquota(
+xfs_fs_setxquota(
        struct super_block      *sb,
        int                     type,
        qid_t                   id,
        struct fs_disk_quota    *fdq)
 {
-       struct vfs              *vfsp = LINVFS_GET_VFS(sb);
+       struct vfs              *vfsp = vfs_from_sb(sb);
        int                     error, setmode;
 
        setmode = (type == USRQUOTA) ? Q_XSETQLIM :
@@ -824,21 +819,17 @@ linvfs_setxquota(
 }
 
 STATIC int
-linvfs_fill_super(
+xfs_fs_fill_super(
        struct super_block      *sb,
        void                    *data,
        int                     silent)
 {
        vnode_t                 *rootvp;
-       struct vfs              *vfsp = vfs_allocate();
+       struct vfs              *vfsp = vfs_allocate(sb);
        struct xfs_mount_args   *args = xfs_args_allocate(sb);
        struct kstatfs          statvfs;
        int                     error, error2;
 
-       vfsp->vfs_super = sb;
-       LINVFS_SET_VFS(sb, vfsp);
-       if (sb->s_flags & MS_RDONLY)
-               vfsp->vfs_flag |= VFS_RDONLY;
        bhv_insert_all_vfsops(vfsp);
 
        VFS_PARSEARGS(vfsp, (char *)data, args, 0, error);
@@ -849,10 +840,10 @@ linvfs_fill_super(
 
        sb_min_blocksize(sb, BBSIZE);
 #ifdef CONFIG_XFS_EXPORT
-       sb->s_export_op = &linvfs_export_ops;
+       sb->s_export_op = &xfs_export_operations;
 #endif
-       sb->s_qcop = &linvfs_qops;
-       sb->s_op = &linvfs_sops;
+       sb->s_qcop = &xfs_quotactl_operations;
+       sb->s_op = &xfs_super_operations;
 
        VFS_MOUNT(vfsp, args, NULL, error);
        if (error) {
@@ -876,7 +867,7 @@ linvfs_fill_super(
        if (error)
                goto fail_unmount;
 
-       sb->s_root = d_alloc_root(LINVFS_GET_IP(rootvp));
+       sb->s_root = d_alloc_root(vn_to_inode(rootvp));
        if (!sb->s_root) {
                error = ENOMEM;
                goto fail_vnrele;
@@ -885,7 +876,7 @@ linvfs_fill_super(
                error = EINVAL;
                goto fail_vnrele;
        }
-       if ((error = linvfs_start_syncd(vfsp)))
+       if ((error = xfs_fs_start_syncd(vfsp)))
                goto fail_vnrele;
        vn_trace_exit(rootvp, __FUNCTION__, (inst_t *)__return_address);
 
@@ -910,41 +901,41 @@ fail_vfsop:
 }
 
 STATIC struct super_block *
-linvfs_get_sb(
+xfs_fs_get_sb(
        struct file_system_type *fs_type,
        int                     flags,
        const char              *dev_name,
        void                    *data)
 {
-       return get_sb_bdev(fs_type, flags, dev_name, data, linvfs_fill_super);
-}
-
-STATIC struct super_operations linvfs_sops = {
-       .alloc_inode            = linvfs_alloc_inode,
-       .destroy_inode          = linvfs_destroy_inode,
-       .write_inode            = linvfs_write_inode,
-       .clear_inode            = linvfs_clear_inode,
-       .put_super              = linvfs_put_super,
-       .write_super            = linvfs_write_super,
-       .sync_fs                = linvfs_sync_super,
-       .write_super_lockfs     = linvfs_freeze_fs,
-       .statfs                 = linvfs_statfs,
-       .remount_fs             = linvfs_remount,
-       .show_options           = linvfs_show_options,
+       return get_sb_bdev(fs_type, flags, dev_name, data, xfs_fs_fill_super);
+}
+
+STATIC struct super_operations xfs_super_operations = {
+       .alloc_inode            = xfs_fs_alloc_inode,
+       .destroy_inode          = xfs_fs_destroy_inode,
+       .write_inode            = xfs_fs_write_inode,
+       .clear_inode            = xfs_fs_clear_inode,
+       .put_super              = xfs_fs_put_super,
+       .write_super            = xfs_fs_write_super,
+       .sync_fs                = xfs_fs_sync_super,
+       .write_super_lockfs     = xfs_fs_lockfs,
+       .statfs                 = xfs_fs_statfs,
+       .remount_fs             = xfs_fs_remount,
+       .show_options           = xfs_fs_show_options,
 };
 
-STATIC struct quotactl_ops linvfs_qops = {
-       .quota_sync             = linvfs_quotasync,
-       .get_xstate             = linvfs_getxstate,
-       .set_xstate             = linvfs_setxstate,
-       .get_xquota             = linvfs_getxquota,
-       .set_xquota             = linvfs_setxquota,
+STATIC struct quotactl_ops xfs_quotactl_operations = {
+       .quota_sync             = xfs_fs_quotasync,
+       .get_xstate             = xfs_fs_getxstate,
+       .set_xstate             = xfs_fs_setxstate,
+       .get_xquota             = xfs_fs_getxquota,
+       .set_xquota             = xfs_fs_setxquota,
 };
 
 STATIC struct file_system_type xfs_fs_type = {
        .owner                  = THIS_MODULE,
        .name                   = "xfs",
-       .get_sb                 = linvfs_get_sb,
+       .get_sb                 = xfs_fs_get_sb,
        .kill_sb                = kill_block_super,
        .fs_flags               = FS_REQUIRES_DEV,
 };
@@ -965,7 +956,7 @@ init_xfs_fs( void )
 
        ktrace_init(64);
 
-       error = linvfs_init_zones();
+       error = xfs_init_zones();
        if (error < 0)
                goto undo_zones;
 
@@ -981,14 +972,13 @@ init_xfs_fs( void )
        error = register_filesystem(&xfs_fs_type);
        if (error)
                goto undo_register;
-       XFS_DM_INIT(&xfs_fs_type);
        return 0;
 
 undo_register:
        xfs_buf_terminate();
 
 undo_buffers:
-       linvfs_destroy_zones();
+       xfs_destroy_zones();
 
 undo_zones:
        return error;
@@ -998,11 +988,10 @@ STATIC void __exit
 exit_xfs_fs( void )
 {
        vfs_exitquota();
-       XFS_DM_EXIT(&xfs_fs_type);
        unregister_filesystem(&xfs_fs_type);
        xfs_cleanup();
        xfs_buf_terminate();
-       linvfs_destroy_zones();
+       xfs_destroy_zones();
        ktrace_uninit();
 }
 
index df59408dca06963afc0c5cbafca3009a694dd33a..376b96cb513a782d413b096b1e7e0b0962d285f1 100644 (file)
@@ -98,11 +98,6 @@ extern void xfs_qm_exit(void);
                                XFS_DMAPI_STRING \
                                XFS_DBG_STRING /* DBG must be last */
 
-#define LINVFS_GET_VFS(s) \
-       (vfs_t *)((s)->s_fs_info)
-#define LINVFS_SET_VFS(s, vfsp) \
-       ((s)->s_fs_info = vfsp)
-
 struct xfs_inode;
 struct xfs_mount;
 struct xfs_buftarg;
@@ -120,6 +115,6 @@ extern int  xfs_blkdev_get(struct xfs_mount *, const char *,
 extern void xfs_blkdev_put(struct block_device *);
 extern void xfs_blkdev_issue_flush(struct xfs_buftarg *);
 
-extern struct export_operations linvfs_export_ops;
+extern struct export_operations xfs_export_operations;
 
 #endif /* __XFS_SUPER_H__ */
index c855d62e53440323998bfafe1a7de416431a8a1e..6f7c9f7a86246ee1f3e822b5e706417718f77406 100644 (file)
@@ -227,7 +227,8 @@ vfs_freeze(
 }
 
 vfs_t *
-vfs_allocate( void )
+vfs_allocate(
+       struct super_block      *sb)
 {
        struct vfs              *vfsp;
 
@@ -236,9 +237,23 @@ vfs_allocate( void )
        INIT_LIST_HEAD(&vfsp->vfs_sync_list);
        spin_lock_init(&vfsp->vfs_sync_lock);
        init_waitqueue_head(&vfsp->vfs_wait_single_sync_task);
+
+       vfsp->vfs_super = sb;
+       sb->s_fs_info = vfsp;
+
+       if (sb->s_flags & MS_RDONLY)
+               vfsp->vfs_flag |= VFS_RDONLY;
+
        return vfsp;
 }
 
+vfs_t *
+vfs_from_sb(
+       struct super_block      *sb)
+{
+       return (vfs_t *)sb->s_fs_info;
+}
+
 void
 vfs_deallocate(
        struct vfs              *vfsp)
@@ -295,7 +310,7 @@ bhv_remove_all_vfsops(
        bhv_remove_vfsops(vfsp, VFS_POSITION_DM);
        if (!freebase)
                return;
-       mp = XFS_BHVTOM(bhv_lookup(VFS_BHVHEAD(vfsp), &xfs_vfsops));
+       mp = XFS_VFSTOM(vfsp);
        VFS_REMOVEBHV(vfsp, &mp->m_bhv);
        xfs_mount_free(mp, 0);
 }
index 57caf9eddee002f02c29075749bcda75dce6777d..8fed356db055a5c10246f7e9a4cf2058dcd3fbae 100644 (file)
@@ -193,7 +193,8 @@ typedef struct bhv_vfsops {
 #define vfs_bhv_set_custom(b,o)        ( (b)->bhv_custom = (void *)(o))
 #define vfs_bhv_clr_custom(b)  ( (b)->bhv_custom = NULL )
 
-extern vfs_t *vfs_allocate(void);
+extern vfs_t *vfs_allocate(struct super_block *);
+extern vfs_t *vfs_from_sb(struct super_block *);
 extern void vfs_deallocate(vfs_t *);
 extern void vfs_insertops(vfs_t *, bhv_vfsops_t *);
 extern void vfs_insertbhv(vfs_t *, bhv_desc_t *, vfsops_t *, void *);
index 260dd8415dd7dc78716895340fa4e0b76b1ae058..d27c25b27ccd4aec1e4f8c8d235e7f41b07034dd 100644 (file)
@@ -58,7 +58,7 @@ struct vnode *
 vn_initialize(
        struct inode    *inode)
 {
-       struct vnode    *vp = LINVFS_GET_VP(inode);
+       struct vnode    *vp = vn_from_inode(inode);
 
        XFS_STATS_INC(vn_active);
        XFS_STATS_INC(vn_alloc);
@@ -83,7 +83,7 @@ vn_initialize(
        vp->v_trace = ktrace_alloc(VNODE_TRACE_SIZE, KM_SLEEP);
 #endif /* XFS_VNODE_TRACE */
 
-       vn_trace_exit(vp, "vn_initialize", (inst_t *)__return_address);
+       vn_trace_exit(vp, __FUNCTION__, (inst_t *)__return_address);
        return vp;
 }
 
@@ -97,7 +97,7 @@ vn_revalidate_core(
        struct vnode    *vp,
        vattr_t         *vap)
 {
-       struct inode    *inode = LINVFS_GET_IP(vp);
+       struct inode    *inode = vn_to_inode(vp);
 
        inode->i_mode       = vap->va_mode;
        inode->i_nlink      = vap->va_nlink;
@@ -129,24 +129,31 @@ vn_revalidate_core(
  * Revalidate the Linux inode from the vnode.
  */
 int
-vn_revalidate(
-       struct vnode    *vp)
+__vn_revalidate(
+       struct vnode    *vp,
+       struct vattr    *vattr)
 {
-       vattr_t         va;
        int             error;
 
-       vn_trace_entry(vp, "vn_revalidate", (inst_t *)__return_address);
-       ASSERT(vp->v_fbhv != NULL);
-
-       va.va_mask = XFS_AT_STAT|XFS_AT_XFLAGS;
-       VOP_GETATTR(vp, &va, 0, NULL, error);
-       if (!error) {
-               vn_revalidate_core(vp, &va);
+       vn_trace_entry(vp, __FUNCTION__, (inst_t *)__return_address);
+       vattr->va_mask = XFS_AT_STAT | XFS_AT_XFLAGS;
+       VOP_GETATTR(vp, vattr, 0, NULL, error);
+       if (likely(!error)) {
+               vn_revalidate_core(vp, vattr);
                VUNMODIFY(vp);
        }
        return -error;
 }
 
+int
+vn_revalidate(
+       struct vnode    *vp)
+{
+       vattr_t         vattr;
+
+       return __vn_revalidate(vp, &vattr);
+}
+
 /*
  * Add a reference to a referenced vnode.
  */
@@ -159,7 +166,7 @@ vn_hold(
        XFS_STATS_INC(vn_hold);
 
        VN_LOCK(vp);
-       inode = igrab(LINVFS_GET_IP(vp));
+       inode = igrab(vn_to_inode(vp));
        ASSERT(inode);
        VN_UNLOCK(vp, 0);
 
index 0fe2419461d69021f3858dd2e9e2e8268f11bc98..06f5845e9568eeeaf00be12a185c18f26a40db00 100644 (file)
@@ -116,8 +116,14 @@ typedef enum {
 /*
  * Vnode to Linux inode mapping.
  */
-#define LINVFS_GET_VP(inode)   ((vnode_t *)list_entry(inode, vnode_t, v_inode))
-#define LINVFS_GET_IP(vp)      (&(vp)->v_inode)
+static inline struct vnode *vn_from_inode(struct inode *inode)
+{
+       return (vnode_t *)list_entry(inode, vnode_t, v_inode);
+}
+static inline struct inode *vn_to_inode(struct vnode *vnode)
+{
+       return &vnode->v_inode;
+}
 
 /*
  * Vnode flags.
@@ -490,6 +496,7 @@ typedef struct vnode_map {
                         (vmap).v_ino    = (vp)->v_inode.i_ino; }
 
 extern int     vn_revalidate(struct vnode *);
+extern int     __vn_revalidate(struct vnode *, vattr_t *);
 extern void    vn_revalidate_core(struct vnode *, vattr_t *);
 
 extern void    vn_iowait(struct vnode *vp);
@@ -497,7 +504,7 @@ extern void vn_iowake(struct vnode *vp);
 
 static inline int vn_count(struct vnode *vp)
 {
-       return atomic_read(&LINVFS_GET_IP(vp)->i_count);
+       return atomic_read(&vn_to_inode(vp)->i_count);
 }
 
 /*
@@ -511,16 +518,16 @@ extern vnode_t    *vn_hold(struct vnode *);
          vn_trace_hold(vp, __FILE__, __LINE__, (inst_t *)__return_address))
 #define VN_RELE(vp)            \
          (vn_trace_rele(vp, __FILE__, __LINE__, (inst_t *)__return_address), \
-          iput(LINVFS_GET_IP(vp)))
+          iput(vn_to_inode(vp)))
 #else
 #define VN_HOLD(vp)            ((void)vn_hold(vp))
-#define VN_RELE(vp)            (iput(LINVFS_GET_IP(vp)))
+#define VN_RELE(vp)            (iput(vn_to_inode(vp)))
 #endif
 
 static inline struct vnode *vn_grab(struct vnode *vp)
 {
-       struct inode *inode = igrab(LINVFS_GET_IP(vp));
-       return inode ? LINVFS_GET_VP(inode) : NULL;
+       struct inode *inode = igrab(vn_to_inode(vp));
+       return inode ? vn_from_inode(inode) : NULL;
 }
 
 /*
@@ -528,7 +535,7 @@ static inline struct vnode *vn_grab(struct vnode *vp)
  */
 #define VNAME(dentry)          ((char *) (dentry)->d_name.name)
 #define VNAMELEN(dentry)       ((dentry)->d_name.len)
-#define VNAME_TO_VNODE(dentry) (LINVFS_GET_VP((dentry)->d_inode))
+#define VNAME_TO_VNODE(dentry) (vn_from_inode((dentry)->d_inode))
 
 /*
  * Vnode spinlock manipulation.
@@ -557,12 +564,12 @@ static __inline__ void vn_flagclr(struct vnode *vp, uint flag)
  */
 static inline void vn_mark_bad(struct vnode *vp)
 {
-       make_bad_inode(LINVFS_GET_IP(vp));
+       make_bad_inode(vn_to_inode(vp));
 }
 
 static inline int VN_BAD(struct vnode *vp)
 {
-       return is_bad_inode(LINVFS_GET_IP(vp));
+       return is_bad_inode(vn_to_inode(vp));
 }
 
 /*
@@ -587,9 +594,9 @@ static inline void vn_atime_to_time_t(struct vnode *vp, time_t *tt)
 /*
  * Some useful predicates.
  */
-#define VN_MAPPED(vp)  mapping_mapped(LINVFS_GET_IP(vp)->i_mapping)
-#define VN_CACHED(vp)  (LINVFS_GET_IP(vp)->i_mapping->nrpages)
-#define VN_DIRTY(vp)   mapping_tagged(LINVFS_GET_IP(vp)->i_mapping, \
+#define VN_MAPPED(vp)  mapping_mapped(vn_to_inode(vp)->i_mapping)
+#define VN_CACHED(vp)  (vn_to_inode(vp)->i_mapping->nrpages)
+#define VN_DIRTY(vp)   mapping_tagged(vn_to_inode(vp)->i_mapping, \
                                        PAGECACHE_TAG_DIRTY)
 #define VMODIFY(vp)    VN_FLAGSET(vp, VMODIFIED)
 #define VUNMODIFY(vp)  VN_FLAGCLR(vp, VMODIFIED)
index 2ec6b441849ccde4cd463b4a721142f506c3252d..e4e5f05b841ba934a1d06a74355681d036444f79 100644 (file)
@@ -79,9 +79,11 @@ xfs_qm_dquot_logitem_format(
 
        logvec->i_addr = (xfs_caddr_t)&logitem->qli_format;
        logvec->i_len  = sizeof(xfs_dq_logformat_t);
+       XLOG_VEC_SET_TYPE(logvec, XLOG_REG_TYPE_QFORMAT);
        logvec++;
        logvec->i_addr = (xfs_caddr_t)&logitem->qli_dquot->q_core;
        logvec->i_len  = sizeof(xfs_disk_dquot_t);
+       XLOG_VEC_SET_TYPE(logvec, XLOG_REG_TYPE_DQUOT);
 
        ASSERT(2 == logitem->qli_item.li_desc->lid_size);
        logitem->qli_format.qlf_size = 2;
index 7c0e39dc618983a356c551a71a6c44fd39eaf23f..1fb757ef3f41935e7b30fdcdd16f2181950b21b2 100644 (file)
@@ -1704,9 +1704,9 @@ xfs_qm_get_rtblks(
        xfs_qcnt_t      *O_rtblks)
 {
        xfs_filblks_t   rtblks;                 /* total rt blks */
+       xfs_extnum_t    idx;                    /* extent record index */
        xfs_ifork_t     *ifp;                   /* inode fork pointer */
        xfs_extnum_t    nextents;               /* number of extent entries */
-       xfs_bmbt_rec_t  *base;                  /* base of extent array */
        xfs_bmbt_rec_t  *ep;                    /* pointer to an extent entry */
        int             error;
 
@@ -1717,10 +1717,11 @@ xfs_qm_get_rtblks(
                        return error;
        }
        rtblks = 0;
-       nextents = ifp->if_bytes / sizeof(xfs_bmbt_rec_t);
-       base = &ifp->if_u1.if_extents[0];
-       for (ep = base; ep < &base[nextents]; ep++)
+       nextents = ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t);
+       for (idx = 0; idx < nextents; idx++) {
+               ep = xfs_iext_get_ext(ifp, idx);
                rtblks += xfs_bmbt_get_blockcount(ep);
+       }
        *O_rtblks = (xfs_qcnt_t)rtblks;
        return 0;
 }
@@ -2788,9 +2789,7 @@ xfs_qm_freelist_destroy(xfs_frlist_t *ql)
                xfs_qm_dqdestroy(dqp);
                dqp = nextdqp;
        }
-       /*
-        * Don't bother about unlocking.
-        */
+       mutex_unlock(&ql->qh_lock);
        mutex_destroy(&ql->qh_lock);
 
        ASSERT(ql->qh_nelems == 0);
index 90402a1c39838423e8ddfe409ffcaa7a13b7abe1..6838b36d95a9bc283850aef2a12a1d680a8ea6f1 100644 (file)
@@ -374,7 +374,7 @@ xfs_qm_exit(void)
        vfs_bhv_clr_custom(&xfs_qmops);
        xfs_qm_cleanup_procfs();
        if (qm_dqzone)
-               kmem_cache_destroy(qm_dqzone);
+               kmem_zone_destroy(qm_dqzone);
        if (qm_dqtrxzone)
-               kmem_cache_destroy(qm_dqtrxzone);
+               kmem_zone_destroy(qm_dqtrxzone);
 }
index 841aa4c15b8a205627ed7e6d2f30cbb2059abaf3..addf5a7ea06c40f879d40d1e8117c15cf01e21c5 100644 (file)
@@ -39,8 +39,8 @@ ktrace_init(int zentries)
 void
 ktrace_uninit(void)
 {
-       kmem_cache_destroy(ktrace_hdr_zone);
-       kmem_cache_destroy(ktrace_ent_zone);
+       kmem_zone_destroy(ktrace_hdr_zone);
+       kmem_zone_destroy(ktrace_ent_zone);
 }
 
 /*
index a3d565a67734e0df236b42fd933d24f1a90393e9..e157015c70ffcad4ed7ee0e989e4714fb55db526 100644 (file)
@@ -21,13 +21,6 @@ static mutex_t       uuid_monitor;
 static int     uuid_table_size;
 static uuid_t  *uuid_table;
 
-void
-uuid_init(void)
-{
-       mutex_init(&uuid_monitor);
-}
-
-
 /* IRIX interpretation of an uuid_t */
 typedef struct {
        __be32  uu_timelow;
@@ -50,7 +43,7 @@ uuid_getnodeuniq(uuid_t *uuid, int fsid [2])
 
        fsid[0] = (be16_to_cpu(uup->uu_clockseq) << 16) |
                   be16_to_cpu(uup->uu_timemid);
-       fsid[1] = be16_to_cpu(uup->uu_timelow);
+       fsid[1] = be32_to_cpu(uup->uu_timelow);
 }
 
 void
@@ -139,3 +132,9 @@ uuid_table_remove(uuid_t *uuid)
        ASSERT(i < uuid_table_size);
        mutex_unlock(&uuid_monitor);
 }
+
+void
+uuid_init(void)
+{
+       mutex_init(&uuid_monitor);
+}
index f9315bc960cb9784bd38a2efc8c119d4bbd0bebd..538d0d65b04c720bf032ceee18a7ed485d517f6f 100644 (file)
@@ -55,8 +55,8 @@ struct xfs_inode;
 
 extern struct kmem_zone *xfs_acl_zone;
 #define xfs_acl_zone_init(zone, name)  \
-               (zone) = kmem_zone_init(sizeof(xfs_acl_t), name)
-#define xfs_acl_zone_destroy(zone)     kmem_cache_destroy(zone)
+               (zone) = kmem_zone_init(sizeof(xfs_acl_t), (name))
+#define xfs_acl_zone_destroy(zone)     kmem_zone_destroy(zone)
 
 extern int xfs_acl_inherit(struct vnode *, struct vattr *, xfs_acl_t *);
 extern int xfs_acl_iaccess(struct xfs_inode *, mode_t, cred_t *);
index e5e91e9c7e898d9f65299813115b8373c22e4c26..093fac476bda039101908a8e9748f241a962fdff 100644 (file)
@@ -1127,8 +1127,7 @@ xfs_attr_leaf_list(xfs_attr_list_context_t *context)
                return(error);
        ASSERT(bp != NULL);
        leaf = bp->data;
-       if (unlikely(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT)
-                                               != XFS_ATTR_LEAF_MAGIC)) {
+       if (unlikely(be16_to_cpu(leaf->hdr.info.magic) != XFS_ATTR_LEAF_MAGIC)) {
                XFS_CORRUPTION_ERROR("xfs_attr_leaf_list", XFS_ERRLEVEL_LOW,
                                     context->dp->i_mount, leaf);
                xfs_da_brelse(NULL, bp);
@@ -1541,8 +1540,8 @@ xfs_attr_node_removename(xfs_da_args_t *args)
                                                     XFS_ATTR_FORK);
                if (error)
                        goto out;
-               ASSERT(INT_GET(((xfs_attr_leafblock_t *)
-                                     bp->data)->hdr.info.magic, ARCH_CONVERT)
+               ASSERT(be16_to_cpu(((xfs_attr_leafblock_t *)
+                                     bp->data)->hdr.info.magic)
                                                       == XFS_ATTR_LEAF_MAGIC);
 
                if ((forkoff = xfs_attr_shortform_allfit(bp, dp))) {
@@ -1763,7 +1762,7 @@ xfs_attr_node_list(xfs_attr_list_context_t *context)
                        return(error);
                if (bp) {
                        node = bp->data;
-                       switch (INT_GET(node->hdr.info.magic, ARCH_CONVERT)) {
+                       switch (be16_to_cpu(node->hdr.info.magic)) {
                        case XFS_DA_NODE_MAGIC:
                                xfs_attr_trace_l_cn("wrong blk", context, node);
                                xfs_da_brelse(NULL, bp);
@@ -1771,18 +1770,14 @@ xfs_attr_node_list(xfs_attr_list_context_t *context)
                                break;
                        case XFS_ATTR_LEAF_MAGIC:
                                leaf = bp->data;
-                               if (cursor->hashval >
-                                   INT_GET(leaf->entries[
-                                        INT_GET(leaf->hdr.count,
-                                               ARCH_CONVERT)-1].hashval,
-                                                       ARCH_CONVERT)) {
+                               if (cursor->hashval > be32_to_cpu(leaf->entries[
+                                   be16_to_cpu(leaf->hdr.count)-1].hashval)) {
                                        xfs_attr_trace_l_cl("wrong blk",
                                                           context, leaf);
                                        xfs_da_brelse(NULL, bp);
                                        bp = NULL;
                                } else if (cursor->hashval <=
-                                            INT_GET(leaf->entries[0].hashval,
-                                                       ARCH_CONVERT)) {
+                                            be32_to_cpu(leaf->entries[0].hashval)) {
                                        xfs_attr_trace_l_cl("maybe wrong blk",
                                                           context, leaf);
                                        xfs_da_brelse(NULL, bp);
@@ -1817,10 +1812,10 @@ xfs_attr_node_list(xfs_attr_list_context_t *context)
                                return(XFS_ERROR(EFSCORRUPTED));
                        }
                        node = bp->data;
-                       if (INT_GET(node->hdr.info.magic, ARCH_CONVERT)
+                       if (be16_to_cpu(node->hdr.info.magic)
                                                        == XFS_ATTR_LEAF_MAGIC)
                                break;
-                       if (unlikely(INT_GET(node->hdr.info.magic, ARCH_CONVERT)
+                       if (unlikely(be16_to_cpu(node->hdr.info.magic)
                                                        != XFS_DA_NODE_MAGIC)) {
                                XFS_CORRUPTION_ERROR("xfs_attr_node_list(3)",
                                                     XFS_ERRLEVEL_LOW,
@@ -1830,19 +1825,17 @@ xfs_attr_node_list(xfs_attr_list_context_t *context)
                                return(XFS_ERROR(EFSCORRUPTED));
                        }
                        btree = node->btree;
-                       for (i = 0;
-                               i < INT_GET(node->hdr.count, ARCH_CONVERT);
+                       for (i = 0; i < be16_to_cpu(node->hdr.count);
                                                                btree++, i++) {
                                if (cursor->hashval
-                                               <= INT_GET(btree->hashval,
-                                                           ARCH_CONVERT)) {
-                                       cursor->blkno = INT_GET(btree->before, ARCH_CONVERT);
+                                               <= be32_to_cpu(btree->hashval)) {
+                                       cursor->blkno = be32_to_cpu(btree->before);
                                        xfs_attr_trace_l_cb("descending",
                                                            context, btree);
                                        break;
                                }
                        }
-                       if (i == INT_GET(node->hdr.count, ARCH_CONVERT)) {
+                       if (i == be16_to_cpu(node->hdr.count)) {
                                xfs_da_brelse(NULL, bp);
                                return(0);
                        }
@@ -1858,7 +1851,7 @@ xfs_attr_node_list(xfs_attr_list_context_t *context)
         */
        for (;;) {
                leaf = bp->data;
-               if (unlikely(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT)
+               if (unlikely(be16_to_cpu(leaf->hdr.info.magic)
                                                != XFS_ATTR_LEAF_MAGIC)) {
                        XFS_CORRUPTION_ERROR("xfs_attr_node_list(4)",
                                             XFS_ERRLEVEL_LOW,
@@ -1869,7 +1862,7 @@ xfs_attr_node_list(xfs_attr_list_context_t *context)
                error = xfs_attr_leaf_list_int(bp, context);
                if (error || !leaf->hdr.info.forw)
                        break;  /* not really an error, buffer full or EOF */
-               cursor->blkno = INT_GET(leaf->hdr.info.forw, ARCH_CONVERT);
+               cursor->blkno = be32_to_cpu(leaf->hdr.info.forw);
                xfs_da_brelse(NULL, bp);
                error = xfs_da_read_buf(NULL, context->dp, cursor->blkno, -1,
                                              &bp, XFS_ATTR_FORK);
@@ -2232,9 +2225,10 @@ xfs_attr_trace_l_cn(char *where, struct xfs_attr_list_context *context,
                                : 0,
                (__psunsigned_t)context->dupcnt,
                (__psunsigned_t)context->flags,
-               (__psunsigned_t)INT_GET(node->hdr.count, ARCH_CONVERT),
-               (__psunsigned_t)INT_GET(node->btree[0].hashval, ARCH_CONVERT),
-               (__psunsigned_t)INT_GET(node->btree[INT_GET(node->hdr.count, ARCH_CONVERT)-1].hashval, ARCH_CONVERT));
+               (__psunsigned_t)be16_to_cpu(node->hdr.count),
+               (__psunsigned_t)be32_to_cpu(node->btree[0].hashval),
+               (__psunsigned_t)be32_to_cpu(node->btree[
+                                   be16_to_cpu(node->hdr.count)-1].hashval));
 }
 
 /*
@@ -2261,8 +2255,8 @@ xfs_attr_trace_l_cb(char *where, struct xfs_attr_list_context *context,
                                : 0,
                (__psunsigned_t)context->dupcnt,
                (__psunsigned_t)context->flags,
-               (__psunsigned_t)INT_GET(btree->hashval, ARCH_CONVERT),
-               (__psunsigned_t)INT_GET(btree->before, ARCH_CONVERT),
+               (__psunsigned_t)be32_to_cpu(btree->hashval),
+               (__psunsigned_t)be32_to_cpu(btree->before),
                (__psunsigned_t)NULL);
 }
 
@@ -2290,9 +2284,10 @@ xfs_attr_trace_l_cl(char *where, struct xfs_attr_list_context *context,
                                : 0,
                (__psunsigned_t)context->dupcnt,
                (__psunsigned_t)context->flags,
-               (__psunsigned_t)INT_GET(leaf->hdr.count, ARCH_CONVERT),
-               (__psunsigned_t)INT_GET(leaf->entries[0].hashval, ARCH_CONVERT),
-               (__psunsigned_t)INT_GET(leaf->entries[INT_GET(leaf->hdr.count, ARCH_CONVERT)-1].hashval, ARCH_CONVERT));
+               (__psunsigned_t)be16_to_cpu(leaf->hdr.count),
+               (__psunsigned_t)be32_to_cpu(leaf->entries[0].hashval),
+               (__psunsigned_t)be32_to_cpu(leaf->entries[
+                               be16_to_cpu(leaf->hdr.count)-1].hashval));
 }
 
 /*
@@ -2522,7 +2517,7 @@ attr_user_capable(
        struct vnode    *vp,
        cred_t          *cred)
 {
-       struct inode    *inode = LINVFS_GET_IP(vp);
+       struct inode    *inode = vn_to_inode(vp);
 
        if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
                return -EPERM;
@@ -2540,7 +2535,7 @@ attr_trusted_capable(
        struct vnode    *vp,
        cred_t          *cred)
 {
-       struct inode    *inode = LINVFS_GET_IP(vp);
+       struct inode    *inode = vn_to_inode(vp);
 
        if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
                return -EPERM;
index fe91eac4e2a7b1919228ec9f063a2946e37ec908..717682747bd20eab2214967371df1b73b86c536a 100644 (file)
@@ -194,7 +194,7 @@ xfs_attr_shortform_create(xfs_da_args_t *args)
        xfs_idata_realloc(dp, sizeof(*hdr), XFS_ATTR_FORK);
        hdr = (xfs_attr_sf_hdr_t *)ifp->if_u1.if_data;
        hdr->count = 0;
-       INT_SET(hdr->totsize, ARCH_CONVERT, sizeof(*hdr));
+       hdr->totsize = cpu_to_be16(sizeof(*hdr));
        xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_ADATA);
 }
 
@@ -224,8 +224,7 @@ xfs_attr_shortform_add(xfs_da_args_t *args, int forkoff)
        ASSERT(ifp->if_flags & XFS_IFINLINE);
        sf = (xfs_attr_shortform_t *)ifp->if_u1.if_data;
        sfe = &sf->list[0];
-       for (i = 0; i < INT_GET(sf->hdr.count, ARCH_CONVERT);
-                               sfe = XFS_ATTR_SF_NEXTENTRY(sfe), i++) {
+       for (i = 0; i < sf->hdr.count; sfe = XFS_ATTR_SF_NEXTENTRY(sfe), i++) {
 #ifdef DEBUG
                if (sfe->namelen != args->namelen)
                        continue;
@@ -248,13 +247,13 @@ xfs_attr_shortform_add(xfs_da_args_t *args, int forkoff)
        sfe = (xfs_attr_sf_entry_t *)((char *)sf + offset);
 
        sfe->namelen = args->namelen;
-       INT_SET(sfe->valuelen, ARCH_CONVERT, args->valuelen);
+       sfe->valuelen = args->valuelen;
        sfe->flags = (args->flags & ATTR_SECURE) ? XFS_ATTR_SECURE :
                        ((args->flags & ATTR_ROOT) ? XFS_ATTR_ROOT : 0);
        memcpy(sfe->nameval, args->name, args->namelen);
        memcpy(&sfe->nameval[args->namelen], args->value, args->valuelen);
-       INT_MOD(sf->hdr.count, ARCH_CONVERT, 1);
-       INT_MOD(sf->hdr.totsize, ARCH_CONVERT, size);
+       sf->hdr.count++;
+       be16_add(&sf->hdr.totsize, size);
        xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_ADATA);
 
        xfs_sbversion_add_attr2(mp, args->trans);
@@ -277,7 +276,7 @@ xfs_attr_shortform_remove(xfs_da_args_t *args)
        base = sizeof(xfs_attr_sf_hdr_t);
        sf = (xfs_attr_shortform_t *)dp->i_afp->if_u1.if_data;
        sfe = &sf->list[0];
-       end = INT_GET(sf->hdr.count, ARCH_CONVERT);
+       end = sf->hdr.count;
        for (i = 0; i < end; sfe = XFS_ATTR_SF_NEXTENTRY(sfe),
                                        base += size, i++) {
                size = XFS_ATTR_SF_ENTSIZE(sfe);
@@ -300,11 +299,11 @@ xfs_attr_shortform_remove(xfs_da_args_t *args)
         * Fix up the attribute fork data, covering the hole
         */
        end = base + size;
-       totsize = INT_GET(sf->hdr.totsize, ARCH_CONVERT);
+       totsize = be16_to_cpu(sf->hdr.totsize);
        if (end != totsize)
                memmove(&((char *)sf)[base], &((char *)sf)[end], totsize - end);
-       INT_MOD(sf->hdr.count, ARCH_CONVERT, -1);
-       INT_MOD(sf->hdr.totsize, ARCH_CONVERT, -size);
+       sf->hdr.count--;
+       be16_add(&sf->hdr.totsize, -size);
 
        /*
         * Fix up the start offset of the attribute fork
@@ -360,7 +359,7 @@ xfs_attr_shortform_lookup(xfs_da_args_t *args)
        ASSERT(ifp->if_flags & XFS_IFINLINE);
        sf = (xfs_attr_shortform_t *)ifp->if_u1.if_data;
        sfe = &sf->list[0];
-       for (i = 0; i < INT_GET(sf->hdr.count, ARCH_CONVERT);
+       for (i = 0; i < sf->hdr.count;
                                sfe = XFS_ATTR_SF_NEXTENTRY(sfe), i++) {
                if (sfe->namelen != args->namelen)
                        continue;
@@ -391,7 +390,7 @@ xfs_attr_shortform_getvalue(xfs_da_args_t *args)
        ASSERT(args->dp->i_d.di_aformat == XFS_IFINLINE);
        sf = (xfs_attr_shortform_t *)args->dp->i_afp->if_u1.if_data;
        sfe = &sf->list[0];
-       for (i = 0; i < INT_GET(sf->hdr.count, ARCH_CONVERT);
+       for (i = 0; i < sf->hdr.count;
                                sfe = XFS_ATTR_SF_NEXTENTRY(sfe), i++) {
                if (sfe->namelen != args->namelen)
                        continue;
@@ -404,14 +403,14 @@ xfs_attr_shortform_getvalue(xfs_da_args_t *args)
                    ((sfe->flags & XFS_ATTR_ROOT) != 0))
                        continue;
                if (args->flags & ATTR_KERNOVAL) {
-                       args->valuelen = INT_GET(sfe->valuelen, ARCH_CONVERT);
+                       args->valuelen = sfe->valuelen;
                        return(XFS_ERROR(EEXIST));
                }
-               if (args->valuelen < INT_GET(sfe->valuelen, ARCH_CONVERT)) {
-                       args->valuelen = INT_GET(sfe->valuelen, ARCH_CONVERT);
+               if (args->valuelen < sfe->valuelen) {
+                       args->valuelen = sfe->valuelen;
                        return(XFS_ERROR(ERANGE));
                }
-               args->valuelen = INT_GET(sfe->valuelen, ARCH_CONVERT);
+               args->valuelen = sfe->valuelen;
                memcpy(args->value, &sfe->nameval[args->namelen],
                                                    args->valuelen);
                return(XFS_ERROR(EEXIST));
@@ -438,7 +437,7 @@ xfs_attr_shortform_to_leaf(xfs_da_args_t *args)
        dp = args->dp;
        ifp = dp->i_afp;
        sf = (xfs_attr_shortform_t *)ifp->if_u1.if_data;
-       size = INT_GET(sf->hdr.totsize, ARCH_CONVERT);
+       size = be16_to_cpu(sf->hdr.totsize);
        tmpbuffer = kmem_alloc(size, KM_SLEEP);
        ASSERT(tmpbuffer != NULL);
        memcpy(tmpbuffer, ifp->if_u1.if_data, size);
@@ -481,11 +480,11 @@ xfs_attr_shortform_to_leaf(xfs_da_args_t *args)
        nargs.oknoent = 1;
 
        sfe = &sf->list[0];
-       for (i = 0; i < INT_GET(sf->hdr.count, ARCH_CONVERT); i++) {
+       for (i = 0; i < sf->hdr.count; i++) {
                nargs.name = (char *)sfe->nameval;
                nargs.namelen = sfe->namelen;
                nargs.value = (char *)&sfe->nameval[nargs.namelen];
-               nargs.valuelen = INT_GET(sfe->valuelen, ARCH_CONVERT);
+               nargs.valuelen = sfe->valuelen;
                nargs.hashval = xfs_da_hashname((char *)sfe->nameval,
                                                sfe->namelen);
                nargs.flags = (sfe->flags & XFS_ATTR_SECURE) ? ATTR_SECURE :
@@ -514,11 +513,9 @@ xfs_attr_shortform_compare(const void *a, const void *b)
 
        sa = (xfs_attr_sf_sort_t *)a;
        sb = (xfs_attr_sf_sort_t *)b;
-       if (INT_GET(sa->hash, ARCH_CONVERT)
-                               < INT_GET(sb->hash, ARCH_CONVERT)) {
+       if (sa->hash < sb->hash) {
                return(-1);
-       } else if (INT_GET(sa->hash, ARCH_CONVERT)
-                               > INT_GET(sb->hash, ARCH_CONVERT)) {
+       } else if (sa->hash > sb->hash) {
                return(1);
        } else {
                return(sa->entno - sb->entno);
@@ -560,10 +557,8 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context)
         * If the buffer is large enough, do not bother with sorting.
         * Note the generous fudge factor of 16 overhead bytes per entry.
         */
-       if ((dp->i_afp->if_bytes + INT_GET(sf->hdr.count, ARCH_CONVERT) * 16)
-                                                       < context->bufsize) {
-               for (i = 0, sfe = &sf->list[0];
-                               i < INT_GET(sf->hdr.count, ARCH_CONVERT); i++) {
+       if ((dp->i_afp->if_bytes + sf->hdr.count * 16) < context->bufsize) {
+               for (i = 0, sfe = &sf->list[0]; i < sf->hdr.count; i++) {
                        attrnames_t     *namesp;
 
                        if (((context->flags & ATTR_SECURE) != 0) !=
@@ -584,14 +579,13 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context)
                        if (context->flags & ATTR_KERNOVAL) {
                                ASSERT(context->flags & ATTR_KERNAMELS);
                                context->count += namesp->attr_namelen +
-                                       INT_GET(sfe->namelen, ARCH_CONVERT) + 1;
+                                       sfe->namelen + 1;
                        }
                        else {
                                if (xfs_attr_put_listent(context, namesp,
                                                   (char *)sfe->nameval,
                                                   (int)sfe->namelen,
-                                                  (int)INT_GET(sfe->valuelen,
-                                                               ARCH_CONVERT)))
+                                                  (int)sfe->valuelen))
                                        break;
                        }
                        sfe = XFS_ATTR_SF_NEXTENTRY(sfe);
@@ -603,7 +597,7 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context)
        /*
         * It didn't all fit, so we have to sort everything on hashval.
         */
-       sbsize = INT_GET(sf->hdr.count, ARCH_CONVERT) * sizeof(*sbuf);
+       sbsize = sf->hdr.count * sizeof(*sbuf);
        sbp = sbuf = kmem_alloc(sbsize, KM_SLEEP);
 
        /*
@@ -611,8 +605,7 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context)
         * the relevant info from only those that match into a buffer.
         */
        nsbuf = 0;
-       for (i = 0, sfe = &sf->list[0];
-                       i < INT_GET(sf->hdr.count, ARCH_CONVERT); i++) {
+       for (i = 0, sfe = &sf->list[0]; i < sf->hdr.count; i++) {
                if (unlikely(
                    ((char *)sfe < (char *)sf) ||
                    ((char *)sfe >= ((char *)sf + dp->i_afp->if_bytes)))) {
@@ -636,8 +629,7 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context)
                        continue;
                }
                sbp->entno = i;
-               INT_SET(sbp->hash, ARCH_CONVERT,
-                       xfs_da_hashname((char *)sfe->nameval, sfe->namelen));
+               sbp->hash = xfs_da_hashname((char *)sfe->nameval, sfe->namelen);
                sbp->name = (char *)sfe->nameval;
                sbp->namelen = sfe->namelen;
                /* These are bytes, and both on-disk, don't endian-flip */
@@ -660,12 +652,12 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context)
        cursor->initted = 1;
        cursor->blkno = 0;
        for (sbp = sbuf, i = 0; i < nsbuf; i++, sbp++) {
-               if (INT_GET(sbp->hash, ARCH_CONVERT) == cursor->hashval) {
+               if (sbp->hash == cursor->hashval) {
                        if (cursor->offset == count) {
                                break;
                        }
                        count++;
-               } else if (INT_GET(sbp->hash, ARCH_CONVERT) > cursor->hashval) {
+               } else if (sbp->hash > cursor->hashval) {
                        break;
                }
        }
@@ -685,8 +677,8 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context)
                        ((sbp->flags & XFS_ATTR_ROOT) ? &attr_trusted :
                          &attr_user);
 
-               if (cursor->hashval != INT_GET(sbp->hash, ARCH_CONVERT)) {
-                       cursor->hashval = INT_GET(sbp->hash, ARCH_CONVERT);
+               if (cursor->hashval != sbp->hash) {
+                       cursor->hashval = sbp->hash;
                        cursor->offset = 0;
                }
                if (context->flags & ATTR_KERNOVAL) {
@@ -696,7 +688,7 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context)
                } else {
                        if (xfs_attr_put_listent(context, namesp,
                                        sbp->name, sbp->namelen,
-                                       INT_GET(sbp->valuelen, ARCH_CONVERT)))
+                                       sbp->valuelen))
                                break;
                }
                cursor->offset++;
@@ -720,12 +712,11 @@ xfs_attr_shortform_allfit(xfs_dabuf_t *bp, xfs_inode_t *dp)
        int bytes, i;
 
        leaf = bp->data;
-       ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT)
-                                               == XFS_ATTR_LEAF_MAGIC);
+       ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC);
 
        entry = &leaf->entries[0];
        bytes = sizeof(struct xfs_attr_sf_hdr);
-       for (i = 0; i < INT_GET(leaf->hdr.count, ARCH_CONVERT); entry++, i++) {
+       for (i = 0; i < be16_to_cpu(leaf->hdr.count); entry++, i++) {
                if (entry->flags & XFS_ATTR_INCOMPLETE)
                        continue;               /* don't copy partial entries */
                if (!(entry->flags & XFS_ATTR_LOCAL))
@@ -733,11 +724,11 @@ xfs_attr_shortform_allfit(xfs_dabuf_t *bp, xfs_inode_t *dp)
                name_loc = XFS_ATTR_LEAF_NAME_LOCAL(leaf, i);
                if (name_loc->namelen >= XFS_ATTR_SF_ENTSIZE_MAX)
                        return(0);
-               if (INT_GET(name_loc->valuelen, ARCH_CONVERT) >= XFS_ATTR_SF_ENTSIZE_MAX)
+               if (be16_to_cpu(name_loc->valuelen) >= XFS_ATTR_SF_ENTSIZE_MAX)
                        return(0);
                bytes += sizeof(struct xfs_attr_sf_entry)-1
                                + name_loc->namelen
-                               + INT_GET(name_loc->valuelen, ARCH_CONVERT);
+                               + be16_to_cpu(name_loc->valuelen);
        }
        if ((dp->i_mount->m_flags & XFS_MOUNT_ATTR2) &&
            (bytes == sizeof(struct xfs_attr_sf_hdr)))
@@ -766,8 +757,7 @@ xfs_attr_leaf_to_shortform(xfs_dabuf_t *bp, xfs_da_args_t *args, int forkoff)
        ASSERT(bp != NULL);
        memcpy(tmpbuffer, bp->data, XFS_LBSIZE(dp->i_mount));
        leaf = (xfs_attr_leafblock_t *)tmpbuffer;
-       ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT)
-                                               == XFS_ATTR_LEAF_MAGIC);
+       ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC);
        memset(bp->data, 0, XFS_LBSIZE(dp->i_mount));
 
        /*
@@ -810,7 +800,7 @@ xfs_attr_leaf_to_shortform(xfs_dabuf_t *bp, xfs_da_args_t *args, int forkoff)
        nargs.trans = args->trans;
        nargs.oknoent = 1;
        entry = &leaf->entries[0];
-       for (i = 0; i < INT_GET(leaf->hdr.count, ARCH_CONVERT); entry++, i++) {
+       for (i = 0; i < be16_to_cpu(leaf->hdr.count); entry++, i++) {
                if (entry->flags & XFS_ATTR_INCOMPLETE)
                        continue;       /* don't copy partial entries */
                if (!entry->nameidx)
@@ -820,8 +810,8 @@ xfs_attr_leaf_to_shortform(xfs_dabuf_t *bp, xfs_da_args_t *args, int forkoff)
                nargs.name = (char *)name_loc->nameval;
                nargs.namelen = name_loc->namelen;
                nargs.value = (char *)&name_loc->nameval[nargs.namelen];
-               nargs.valuelen = INT_GET(name_loc->valuelen, ARCH_CONVERT);
-               nargs.hashval = INT_GET(entry->hashval, ARCH_CONVERT);
+               nargs.valuelen = be16_to_cpu(name_loc->valuelen);
+               nargs.hashval = be32_to_cpu(entry->hashval);
                nargs.flags = (entry->flags & XFS_ATTR_SECURE) ? ATTR_SECURE :
                              ((entry->flags & XFS_ATTR_ROOT) ? ATTR_ROOT : 0);
                xfs_attr_shortform_add(&nargs, forkoff);
@@ -875,13 +865,12 @@ xfs_attr_leaf_to_node(xfs_da_args_t *args)
                goto out;
        node = bp1->data;
        leaf = bp2->data;
-       ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT)
-                                               == XFS_ATTR_LEAF_MAGIC);
+       ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC);
        /* both on-disk, don't endian-flip twice */
        node->btree[0].hashval =
-               leaf->entries[INT_GET(leaf->hdr.count, ARCH_CONVERT)-1 ].hashval;
-       INT_SET(node->btree[0].before, ARCH_CONVERT, blkno);
-       INT_SET(node->hdr.count, ARCH_CONVERT, 1);
+               leaf->entries[be16_to_cpu(leaf->hdr.count)-1 ].hashval;
+       node->btree[0].before = cpu_to_be32(blkno);
+       node->hdr.count = cpu_to_be16(1);
        xfs_da_log_buf(args->trans, bp1, 0, XFS_LBSIZE(dp->i_mount) - 1);
        error = 0;
 out:
@@ -920,19 +909,16 @@ xfs_attr_leaf_create(xfs_da_args_t *args, xfs_dablk_t blkno, xfs_dabuf_t **bpp)
        leaf = bp->data;
        memset((char *)leaf, 0, XFS_LBSIZE(dp->i_mount));
        hdr = &leaf->hdr;
-       INT_SET(hdr->info.magic, ARCH_CONVERT, XFS_ATTR_LEAF_MAGIC);
-       INT_SET(hdr->firstused, ARCH_CONVERT, XFS_LBSIZE(dp->i_mount));
+       hdr->info.magic = cpu_to_be16(XFS_ATTR_LEAF_MAGIC);
+       hdr->firstused = cpu_to_be16(XFS_LBSIZE(dp->i_mount));
        if (!hdr->firstused) {
-               INT_SET(hdr->firstused, ARCH_CONVERT,
+               hdr->firstused = cpu_to_be16(
                        XFS_LBSIZE(dp->i_mount) - XFS_ATTR_LEAF_NAME_ALIGN);
        }
 
-       INT_SET(hdr->freemap[0].base, ARCH_CONVERT,
-                                               sizeof(xfs_attr_leaf_hdr_t));
-       INT_SET(hdr->freemap[0].size, ARCH_CONVERT,
-                                         INT_GET(hdr->firstused, ARCH_CONVERT)
-                                       - INT_GET(hdr->freemap[0].base,
-                                                               ARCH_CONVERT));
+       hdr->freemap[0].base = cpu_to_be16(sizeof(xfs_attr_leaf_hdr_t));
+       hdr->freemap[0].size = cpu_to_be16(be16_to_cpu(hdr->firstused) -
+                                          sizeof(xfs_attr_leaf_hdr_t));
 
        xfs_da_log_buf(args->trans, bp, 0, XFS_LBSIZE(dp->i_mount) - 1);
 
@@ -1004,10 +990,9 @@ xfs_attr_leaf_add(xfs_dabuf_t *bp, xfs_da_args_t *args)
        int tablesize, entsize, sum, tmp, i;
 
        leaf = bp->data;
-       ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT)
-                                               == XFS_ATTR_LEAF_MAGIC);
+       ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC);
        ASSERT((args->index >= 0)
-               && (args->index <= INT_GET(leaf->hdr.count, ARCH_CONVERT)));
+               && (args->index <= be16_to_cpu(leaf->hdr.count)));
        hdr = &leaf->hdr;
        entsize = xfs_attr_leaf_newentsize(args->namelen, args->valuelen,
                           args->trans->t_mountp->m_sb.sb_blocksize, NULL);
@@ -1016,26 +1001,25 @@ xfs_attr_leaf_add(xfs_dabuf_t *bp, xfs_da_args_t *args)
         * Search through freemap for first-fit on new name length.
         * (may need to figure in size of entry struct too)
         */
-       tablesize = (INT_GET(hdr->count, ARCH_CONVERT) + 1)
+       tablesize = (be16_to_cpu(hdr->count) + 1)
                                        * sizeof(xfs_attr_leaf_entry_t)
                                        + sizeof(xfs_attr_leaf_hdr_t);
        map = &hdr->freemap[XFS_ATTR_LEAF_MAPSIZE-1];
        for (sum = 0, i = XFS_ATTR_LEAF_MAPSIZE-1; i >= 0; map--, i--) {
-               if (tablesize > INT_GET(hdr->firstused, ARCH_CONVERT)) {
-                       sum += INT_GET(map->size, ARCH_CONVERT);
+               if (tablesize > be16_to_cpu(hdr->firstused)) {
+                       sum += be16_to_cpu(map->size);
                        continue;
                }
                if (!map->size)
                        continue;       /* no space in this map */
                tmp = entsize;
-               if (INT_GET(map->base, ARCH_CONVERT)
-                               < INT_GET(hdr->firstused, ARCH_CONVERT))
+               if (be16_to_cpu(map->base) < be16_to_cpu(hdr->firstused))
                        tmp += sizeof(xfs_attr_leaf_entry_t);
-               if (INT_GET(map->size, ARCH_CONVERT) >= tmp) {
+               if (be16_to_cpu(map->size) >= tmp) {
                        tmp = xfs_attr_leaf_add_work(bp, args, i);
                        return(tmp);
                }
-               sum += INT_GET(map->size, ARCH_CONVERT);
+               sum += be16_to_cpu(map->size);
        }
 
        /*
@@ -1056,7 +1040,7 @@ xfs_attr_leaf_add(xfs_dabuf_t *bp, xfs_da_args_t *args)
         * After compaction, the block is guaranteed to have only one
         * free region, in freemap[0].  If it is not big enough, give up.
         */
-       if (INT_GET(hdr->freemap[0].size, ARCH_CONVERT)
+       if (be16_to_cpu(hdr->freemap[0].size)
                                < (entsize + sizeof(xfs_attr_leaf_entry_t)))
                return(XFS_ERROR(ENOSPC));
 
@@ -1079,45 +1063,42 @@ xfs_attr_leaf_add_work(xfs_dabuf_t *bp, xfs_da_args_t *args, int mapindex)
        int tmp, i;
 
        leaf = bp->data;
-       ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT)
-                                               == XFS_ATTR_LEAF_MAGIC);
+       ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC);
        hdr = &leaf->hdr;
        ASSERT((mapindex >= 0) && (mapindex < XFS_ATTR_LEAF_MAPSIZE));
-       ASSERT((args->index >= 0)
-               && (args->index <= INT_GET(hdr->count, ARCH_CONVERT)));
+       ASSERT((args->index >= 0) && (args->index <= be16_to_cpu(hdr->count)));
 
        /*
         * Force open some space in the entry array and fill it in.
         */
        entry = &leaf->entries[args->index];
-       if (args->index < INT_GET(hdr->count, ARCH_CONVERT)) {
-               tmp  = INT_GET(hdr->count, ARCH_CONVERT) - args->index;
+       if (args->index < be16_to_cpu(hdr->count)) {
+               tmp  = be16_to_cpu(hdr->count) - args->index;
                tmp *= sizeof(xfs_attr_leaf_entry_t);
                memmove((char *)(entry+1), (char *)entry, tmp);
                xfs_da_log_buf(args->trans, bp,
                    XFS_DA_LOGRANGE(leaf, entry, tmp + sizeof(*entry)));
        }
-       INT_MOD(hdr->count, ARCH_CONVERT, 1);
+       be16_add(&hdr->count, 1);
 
        /*
         * Allocate space for the new string (at the end of the run).
         */
        map = &hdr->freemap[mapindex];
        mp = args->trans->t_mountp;
-       ASSERT(INT_GET(map->base, ARCH_CONVERT) < XFS_LBSIZE(mp));
-       ASSERT((INT_GET(map->base, ARCH_CONVERT) & 0x3) == 0);
-       ASSERT(INT_GET(map->size, ARCH_CONVERT) >=
+       ASSERT(be16_to_cpu(map->base) < XFS_LBSIZE(mp));
+       ASSERT((be16_to_cpu(map->base) & 0x3) == 0);
+       ASSERT(be16_to_cpu(map->size) >=
                xfs_attr_leaf_newentsize(args->namelen, args->valuelen,
                                         mp->m_sb.sb_blocksize, NULL));
-       ASSERT(INT_GET(map->size, ARCH_CONVERT) < XFS_LBSIZE(mp));
-       ASSERT((INT_GET(map->size, ARCH_CONVERT) & 0x3) == 0);
-       INT_MOD(map->size, ARCH_CONVERT,
+       ASSERT(be16_to_cpu(map->size) < XFS_LBSIZE(mp));
+       ASSERT((be16_to_cpu(map->size) & 0x3) == 0);
+       be16_add(&map->size,
                -xfs_attr_leaf_newentsize(args->namelen, args->valuelen,
                                          mp->m_sb.sb_blocksize, &tmp));
-       INT_SET(entry->nameidx, ARCH_CONVERT,
-                                       INT_GET(map->base, ARCH_CONVERT)
-                                     + INT_GET(map->size, ARCH_CONVERT));
-       INT_SET(entry->hashval, ARCH_CONVERT, args->hashval);
+       entry->nameidx = cpu_to_be16(be16_to_cpu(map->base) +
+                                    be16_to_cpu(map->size));
+       entry->hashval = cpu_to_be32(args->hashval);
        entry->flags = tmp ? XFS_ATTR_LOCAL : 0;
        entry->flags |= (args->flags & ATTR_SECURE) ? XFS_ATTR_SECURE :
                        ((args->flags & ATTR_ROOT) ? XFS_ATTR_ROOT : 0);
@@ -1130,12 +1111,10 @@ xfs_attr_leaf_add_work(xfs_dabuf_t *bp, xfs_da_args_t *args, int mapindex)
        }
        xfs_da_log_buf(args->trans, bp,
                          XFS_DA_LOGRANGE(leaf, entry, sizeof(*entry)));
-       ASSERT((args->index == 0) || (INT_GET(entry->hashval, ARCH_CONVERT)
-                                               >= INT_GET((entry-1)->hashval,
-                                                           ARCH_CONVERT)));
-       ASSERT((args->index == INT_GET(hdr->count, ARCH_CONVERT)-1) ||
-              (INT_GET(entry->hashval, ARCH_CONVERT)
-                           <= (INT_GET((entry+1)->hashval, ARCH_CONVERT))));
+       ASSERT((args->index == 0) ||
+              (be32_to_cpu(entry->hashval) >= be32_to_cpu((entry-1)->hashval)));
+       ASSERT((args->index == be16_to_cpu(hdr->count)-1) ||
+              (be32_to_cpu(entry->hashval) <= be32_to_cpu((entry+1)->hashval)));
 
        /*
         * Copy the attribute name and value into the new space.
@@ -1149,10 +1128,10 @@ xfs_attr_leaf_add_work(xfs_dabuf_t *bp, xfs_da_args_t *args, int mapindex)
        if (entry->flags & XFS_ATTR_LOCAL) {
                name_loc = XFS_ATTR_LEAF_NAME_LOCAL(leaf, args->index);
                name_loc->namelen = args->namelen;
-               INT_SET(name_loc->valuelen, ARCH_CONVERT, args->valuelen);
+               name_loc->valuelen = cpu_to_be16(args->valuelen);
                memcpy((char *)name_loc->nameval, args->name, args->namelen);
                memcpy((char *)&name_loc->nameval[args->namelen], args->value,
-                                  INT_GET(name_loc->valuelen, ARCH_CONVERT));
+                                  be16_to_cpu(name_loc->valuelen));
        } else {
                name_rmt = XFS_ATTR_LEAF_NAME_REMOTE(leaf, args->index);
                name_rmt->namelen = args->namelen;
@@ -1171,28 +1150,23 @@ xfs_attr_leaf_add_work(xfs_dabuf_t *bp, xfs_da_args_t *args, int mapindex)
        /*
         * Update the control info for this leaf node
         */
-       if (INT_GET(entry->nameidx, ARCH_CONVERT)
-                               < INT_GET(hdr->firstused, ARCH_CONVERT)) {
+       if (be16_to_cpu(entry->nameidx) < be16_to_cpu(hdr->firstused)) {
                /* both on-disk, don't endian-flip twice */
                hdr->firstused = entry->nameidx;
        }
-       ASSERT(INT_GET(hdr->firstused, ARCH_CONVERT)
-                               >= ((INT_GET(hdr->count, ARCH_CONVERT)
-                                       * sizeof(*entry))+sizeof(*hdr)));
-       tmp = (INT_GET(hdr->count, ARCH_CONVERT)-1)
-                                       * sizeof(xfs_attr_leaf_entry_t)
+       ASSERT(be16_to_cpu(hdr->firstused) >=
+              ((be16_to_cpu(hdr->count) * sizeof(*entry)) + sizeof(*hdr)));
+       tmp = (be16_to_cpu(hdr->count)-1) * sizeof(xfs_attr_leaf_entry_t)
                                        + sizeof(xfs_attr_leaf_hdr_t);
        map = &hdr->freemap[0];
        for (i = 0; i < XFS_ATTR_LEAF_MAPSIZE; map++, i++) {
-               if (INT_GET(map->base, ARCH_CONVERT) == tmp) {
-                       INT_MOD(map->base, ARCH_CONVERT,
-                                       sizeof(xfs_attr_leaf_entry_t));
-                       INT_MOD(map->size, ARCH_CONVERT,
-                                       -sizeof(xfs_attr_leaf_entry_t));
+               if (be16_to_cpu(map->base) == tmp) {
+                       be16_add(&map->base, sizeof(xfs_attr_leaf_entry_t));
+                       be16_add(&map->size,
+                                -((int)sizeof(xfs_attr_leaf_entry_t)));
                }
        }
-       INT_MOD(hdr->usedbytes, ARCH_CONVERT,
-                               xfs_attr_leaf_entsize(leaf, args->index));
+       be16_add(&hdr->usedbytes, xfs_attr_leaf_entsize(leaf, args->index));
        xfs_da_log_buf(args->trans, bp,
                XFS_DA_LOGRANGE(leaf, hdr, sizeof(*hdr)));
        return(0);
@@ -1223,28 +1197,25 @@ xfs_attr_leaf_compact(xfs_trans_t *trans, xfs_dabuf_t *bp)
        hdr_s = &leaf_s->hdr;
        hdr_d = &leaf_d->hdr;
        hdr_d->info = hdr_s->info;      /* struct copy */
-       INT_SET(hdr_d->firstused, ARCH_CONVERT, XFS_LBSIZE(mp));
+       hdr_d->firstused = cpu_to_be16(XFS_LBSIZE(mp));
        /* handle truncation gracefully */
        if (!hdr_d->firstused) {
-               INT_SET(hdr_d->firstused, ARCH_CONVERT,
+               hdr_d->firstused = cpu_to_be16(
                                XFS_LBSIZE(mp) - XFS_ATTR_LEAF_NAME_ALIGN);
        }
        hdr_d->usedbytes = 0;
        hdr_d->count = 0;
        hdr_d->holes = 0;
-       INT_SET(hdr_d->freemap[0].base, ARCH_CONVERT,
-                                       sizeof(xfs_attr_leaf_hdr_t));
-       INT_SET(hdr_d->freemap[0].size, ARCH_CONVERT,
-                               INT_GET(hdr_d->firstused, ARCH_CONVERT)
-                             - INT_GET(hdr_d->freemap[0].base, ARCH_CONVERT));
+       hdr_d->freemap[0].base = cpu_to_be16(sizeof(xfs_attr_leaf_hdr_t));
+       hdr_d->freemap[0].size = cpu_to_be16(be16_to_cpu(hdr_d->firstused) -
+                                            sizeof(xfs_attr_leaf_hdr_t));
 
        /*
         * Copy all entry's in the same (sorted) order,
         * but allocate name/value pairs packed and in sequence.
         */
        xfs_attr_leaf_moveents(leaf_s, 0, leaf_d, 0,
-                               (int)INT_GET(hdr_s->count, ARCH_CONVERT), mp);
-
+                               be16_to_cpu(hdr_s->count), mp);
        xfs_da_log_buf(trans, bp, 0, XFS_LBSIZE(mp) - 1);
 
        kmem_free(tmpbuffer, XFS_LBSIZE(mp));
@@ -1279,10 +1250,8 @@ xfs_attr_leaf_rebalance(xfs_da_state_t *state, xfs_da_state_blk_t *blk1,
        ASSERT(blk2->magic == XFS_ATTR_LEAF_MAGIC);
        leaf1 = blk1->bp->data;
        leaf2 = blk2->bp->data;
-       ASSERT(INT_GET(leaf1->hdr.info.magic, ARCH_CONVERT)
-                                               == XFS_ATTR_LEAF_MAGIC);
-       ASSERT(INT_GET(leaf2->hdr.info.magic, ARCH_CONVERT)
-                                               == XFS_ATTR_LEAF_MAGIC);
+       ASSERT(be16_to_cpu(leaf1->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC);
+       ASSERT(be16_to_cpu(leaf2->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC);
        args = state->args;
 
        /*
@@ -1319,22 +1288,21 @@ xfs_attr_leaf_rebalance(xfs_da_state_t *state, xfs_da_state_blk_t *blk1,
        /*
         * Move any entries required from leaf to leaf:
         */
-       if (count < INT_GET(hdr1->count, ARCH_CONVERT)) {
+       if (count < be16_to_cpu(hdr1->count)) {
                /*
                 * Figure the total bytes to be added to the destination leaf.
                 */
                /* number entries being moved */
-               count = INT_GET(hdr1->count, ARCH_CONVERT) - count;
-               space  = INT_GET(hdr1->usedbytes, ARCH_CONVERT) - totallen;
+               count = be16_to_cpu(hdr1->count) - count;
+               space  = be16_to_cpu(hdr1->usedbytes) - totallen;
                space += count * sizeof(xfs_attr_leaf_entry_t);
 
                /*
                 * leaf2 is the destination, compact it if it looks tight.
                 */
-               max  = INT_GET(hdr2->firstused, ARCH_CONVERT)
+               max  = be16_to_cpu(hdr2->firstused)
                                                - sizeof(xfs_attr_leaf_hdr_t);
-               max -= INT_GET(hdr2->count, ARCH_CONVERT)
-                                       * sizeof(xfs_attr_leaf_entry_t);
+               max -= be16_to_cpu(hdr2->count) * sizeof(xfs_attr_leaf_entry_t);
                if (space > max) {
                        xfs_attr_leaf_compact(args->trans, blk2->bp);
                }
@@ -1342,13 +1310,12 @@ xfs_attr_leaf_rebalance(xfs_da_state_t *state, xfs_da_state_blk_t *blk1,
                /*
                 * Move high entries from leaf1 to low end of leaf2.
                 */
-               xfs_attr_leaf_moveents(leaf1,
-                               INT_GET(hdr1->count, ARCH_CONVERT)-count,
+               xfs_attr_leaf_moveents(leaf1, be16_to_cpu(hdr1->count) - count,
                                leaf2, 0, count, state->mp);
 
                xfs_da_log_buf(args->trans, blk1->bp, 0, state->blocksize-1);
                xfs_da_log_buf(args->trans, blk2->bp, 0, state->blocksize-1);
-       } else if (count > INT_GET(hdr1->count, ARCH_CONVERT)) {
+       } else if (count > be16_to_cpu(hdr1->count)) {
                /*
                 * I assert that since all callers pass in an empty
                 * second buffer, this code should never execute.
@@ -1358,17 +1325,16 @@ xfs_attr_leaf_rebalance(xfs_da_state_t *state, xfs_da_state_blk_t *blk1,
                 * Figure the total bytes to be added to the destination leaf.
                 */
                /* number entries being moved */
-               count -= INT_GET(hdr1->count, ARCH_CONVERT);
-               space  = totallen - INT_GET(hdr1->usedbytes, ARCH_CONVERT);
+               count -= be16_to_cpu(hdr1->count);
+               space  = totallen - be16_to_cpu(hdr1->usedbytes);
                space += count * sizeof(xfs_attr_leaf_entry_t);
 
                /*
                 * leaf1 is the destination, compact it if it looks tight.
                 */
-               max  = INT_GET(hdr1->firstused, ARCH_CONVERT)
+               max  = be16_to_cpu(hdr1->firstused)
                                                - sizeof(xfs_attr_leaf_hdr_t);
-               max -= INT_GET(hdr1->count, ARCH_CONVERT)
-                                       * sizeof(xfs_attr_leaf_entry_t);
+               max -= be16_to_cpu(hdr1->count) * sizeof(xfs_attr_leaf_entry_t);
                if (space > max) {
                        xfs_attr_leaf_compact(args->trans, blk1->bp);
                }
@@ -1377,8 +1343,7 @@ xfs_attr_leaf_rebalance(xfs_da_state_t *state, xfs_da_state_blk_t *blk1,
                 * Move low entries from leaf2 to high end of leaf1.
                 */
                xfs_attr_leaf_moveents(leaf2, 0, leaf1,
-                               (int)INT_GET(hdr1->count, ARCH_CONVERT), count,
-                               state->mp);
+                               be16_to_cpu(hdr1->count), count, state->mp);
 
                xfs_da_log_buf(args->trans, blk1->bp, 0, state->blocksize-1);
                xfs_da_log_buf(args->trans, blk2->bp, 0, state->blocksize-1);
@@ -1387,12 +1352,10 @@ xfs_attr_leaf_rebalance(xfs_da_state_t *state, xfs_da_state_blk_t *blk1,
        /*
         * Copy out last hashval in each block for B-tree code.
         */
-       blk1->hashval =
-           INT_GET(leaf1->entries[INT_GET(leaf1->hdr.count,
-                                   ARCH_CONVERT)-1].hashval, ARCH_CONVERT);
-       blk2->hashval =
-           INT_GET(leaf2->entries[INT_GET(leaf2->hdr.count,
-                                   ARCH_CONVERT)-1].hashval, ARCH_CONVERT);
+       blk1->hashval = be32_to_cpu(
+               leaf1->entries[be16_to_cpu(leaf1->hdr.count)-1].hashval);
+       blk2->hashval = be32_to_cpu(
+               leaf2->entries[be16_to_cpu(leaf2->hdr.count)-1].hashval);
 
        /*
         * Adjust the expected index for insertion.
@@ -1406,13 +1369,12 @@ xfs_attr_leaf_rebalance(xfs_da_state_t *state, xfs_da_state_blk_t *blk1,
         * inserting.  The index/blkno fields refer to the "old" entry,
         * while the index2/blkno2 fields refer to the "new" entry.
         */
-       if (blk1->index > INT_GET(leaf1->hdr.count, ARCH_CONVERT)) {
+       if (blk1->index > be16_to_cpu(leaf1->hdr.count)) {
                ASSERT(state->inleaf == 0);
-               blk2->index = blk1->index
-                               - INT_GET(leaf1->hdr.count, ARCH_CONVERT);
+               blk2->index = blk1->index - be16_to_cpu(leaf1->hdr.count);
                args->index = args->index2 = blk2->index;
                args->blkno = args->blkno2 = blk2->blkno;
-       } else if (blk1->index == INT_GET(leaf1->hdr.count, ARCH_CONVERT)) {
+       } else if (blk1->index == be16_to_cpu(leaf1->hdr.count)) {
                if (state->inleaf) {
                        args->index = blk1->index;
                        args->blkno = blk1->blkno;
@@ -1420,7 +1382,7 @@ xfs_attr_leaf_rebalance(xfs_da_state_t *state, xfs_da_state_blk_t *blk1,
                        args->blkno2 = blk2->blkno;
                } else {
                        blk2->index = blk1->index
-                                   - INT_GET(leaf1->hdr.count, ARCH_CONVERT);
+                                   - be16_to_cpu(leaf1->hdr.count);
                        args->index = args->index2 = blk2->index;
                        args->blkno = args->blkno2 = blk2->blkno;
                }
@@ -1464,15 +1426,14 @@ xfs_attr_leaf_figure_balance(xfs_da_state_t *state,
         * Examine entries until we reduce the absolute difference in
         * byte usage between the two blocks to a minimum.
         */
-       max = INT_GET(hdr1->count, ARCH_CONVERT)
-                       + INT_GET(hdr2->count, ARCH_CONVERT);
+       max = be16_to_cpu(hdr1->count) + be16_to_cpu(hdr2->count);
        half  = (max+1) * sizeof(*entry);
-       half += INT_GET(hdr1->usedbytes, ARCH_CONVERT)
-                               + INT_GET(hdr2->usedbytes, ARCH_CONVERT)
-                               + xfs_attr_leaf_newentsize(
-                                               state->args->namelen,
-                                               state->args->valuelen,
-                                               state->blocksize, NULL);
+       half += be16_to_cpu(hdr1->usedbytes) +
+               be16_to_cpu(hdr2->usedbytes) +
+               xfs_attr_leaf_newentsize(
+                               state->args->namelen,
+                               state->args->valuelen,
+                               state->blocksize, NULL);
        half /= 2;
        lastdelta = state->blocksize;
        entry = &leaf1->entries[0];
@@ -1498,7 +1459,7 @@ xfs_attr_leaf_figure_balance(xfs_da_state_t *state,
                /*
                 * Wrap around into the second block if necessary.
                 */
-               if (count == INT_GET(hdr1->count, ARCH_CONVERT)) {
+               if (count == be16_to_cpu(hdr1->count)) {
                        leaf1 = leaf2;
                        entry = &leaf1->entries[0];
                        index = 0;
@@ -1566,12 +1527,12 @@ xfs_attr_leaf_toosmall(xfs_da_state_t *state, int *action)
         */
        blk = &state->path.blk[ state->path.active-1 ];
        info = blk->bp->data;
-       ASSERT(INT_GET(info->magic, ARCH_CONVERT) == XFS_ATTR_LEAF_MAGIC);
+       ASSERT(be16_to_cpu(info->magic) == XFS_ATTR_LEAF_MAGIC);
        leaf = (xfs_attr_leafblock_t *)info;
-       count = INT_GET(leaf->hdr.count, ARCH_CONVERT);
+       count = be16_to_cpu(leaf->hdr.count);
        bytes = sizeof(xfs_attr_leaf_hdr_t) +
                count * sizeof(xfs_attr_leaf_entry_t) +
-               INT_GET(leaf->hdr.usedbytes, ARCH_CONVERT);
+               be16_to_cpu(leaf->hdr.usedbytes);
        if (bytes > (state->blocksize >> 1)) {
                *action = 0;    /* blk over 50%, don't try to join */
                return(0);
@@ -1588,7 +1549,7 @@ xfs_attr_leaf_toosmall(xfs_da_state_t *state, int *action)
                 * Make altpath point to the block we want to keep and
                 * path point to the block we want to drop (this one).
                 */
-               forward = info->forw;
+               forward = (info->forw != 0);
                memcpy(&state->altpath, &state->path, sizeof(state->path));
                error = xfs_da_path_shift(state, &state->altpath, forward,
                                                 0, &retval);
@@ -1610,13 +1571,12 @@ xfs_attr_leaf_toosmall(xfs_da_state_t *state, int *action)
         * to shrink an attribute list over time.
         */
        /* start with smaller blk num */
-       forward = (INT_GET(info->forw, ARCH_CONVERT)
-                                       < INT_GET(info->back, ARCH_CONVERT));
+       forward = (be32_to_cpu(info->forw) < be32_to_cpu(info->back));
        for (i = 0; i < 2; forward = !forward, i++) {
                if (forward)
-                       blkno = INT_GET(info->forw, ARCH_CONVERT);
+                       blkno = be32_to_cpu(info->forw);
                else
-                       blkno = INT_GET(info->back, ARCH_CONVERT);
+                       blkno = be32_to_cpu(info->back);
                if (blkno == 0)
                        continue;
                error = xfs_da_read_buf(state->args->trans, state->args->dp,
@@ -1626,14 +1586,13 @@ xfs_attr_leaf_toosmall(xfs_da_state_t *state, int *action)
                ASSERT(bp != NULL);
 
                leaf = (xfs_attr_leafblock_t *)info;
-               count  = INT_GET(leaf->hdr.count, ARCH_CONVERT);
+               count  = be16_to_cpu(leaf->hdr.count);
                bytes  = state->blocksize - (state->blocksize>>2);
-               bytes -= INT_GET(leaf->hdr.usedbytes, ARCH_CONVERT);
+               bytes -= be16_to_cpu(leaf->hdr.usedbytes);
                leaf = bp->data;
-               ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT)
-                                               == XFS_ATTR_LEAF_MAGIC);
-               count += INT_GET(leaf->hdr.count, ARCH_CONVERT);
-               bytes -= INT_GET(leaf->hdr.usedbytes, ARCH_CONVERT);
+               ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC);
+               count += be16_to_cpu(leaf->hdr.count);
+               bytes -= be16_to_cpu(leaf->hdr.usedbytes);
                bytes -= count * sizeof(xfs_attr_leaf_entry_t);
                bytes -= sizeof(xfs_attr_leaf_hdr_t);
                xfs_da_brelse(state->args->trans, bp);
@@ -1685,21 +1644,18 @@ xfs_attr_leaf_remove(xfs_dabuf_t *bp, xfs_da_args_t *args)
        xfs_mount_t *mp;
 
        leaf = bp->data;
-       ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT)
-                                               == XFS_ATTR_LEAF_MAGIC);
+       ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC);
        hdr = &leaf->hdr;
        mp = args->trans->t_mountp;
-       ASSERT((INT_GET(hdr->count, ARCH_CONVERT) > 0)
-               && (INT_GET(hdr->count, ARCH_CONVERT) < (XFS_LBSIZE(mp)/8)));
+       ASSERT((be16_to_cpu(hdr->count) > 0)
+               && (be16_to_cpu(hdr->count) < (XFS_LBSIZE(mp)/8)));
        ASSERT((args->index >= 0)
-               && (args->index < INT_GET(hdr->count, ARCH_CONVERT)));
-       ASSERT(INT_GET(hdr->firstused, ARCH_CONVERT)
-                               >= ((INT_GET(hdr->count, ARCH_CONVERT)
-                                       * sizeof(*entry))+sizeof(*hdr)));
+               && (args->index < be16_to_cpu(hdr->count)));
+       ASSERT(be16_to_cpu(hdr->firstused) >=
+              ((be16_to_cpu(hdr->count) * sizeof(*entry)) + sizeof(*hdr)));
        entry = &leaf->entries[args->index];
-       ASSERT(INT_GET(entry->nameidx, ARCH_CONVERT)
-                               >= INT_GET(hdr->firstused, ARCH_CONVERT));
-       ASSERT(INT_GET(entry->nameidx, ARCH_CONVERT) < XFS_LBSIZE(mp));
+       ASSERT(be16_to_cpu(entry->nameidx) >= be16_to_cpu(hdr->firstused));
+       ASSERT(be16_to_cpu(entry->nameidx) < XFS_LBSIZE(mp));
 
        /*
         * Scan through free region table:
@@ -1707,33 +1663,30 @@ xfs_attr_leaf_remove(xfs_dabuf_t *bp, xfs_da_args_t *args)
         *    find smallest free region in case we need to replace it,
         *    adjust any map that borders the entry table,
         */
-       tablesize = INT_GET(hdr->count, ARCH_CONVERT)
-                                       * sizeof(xfs_attr_leaf_entry_t)
+       tablesize = be16_to_cpu(hdr->count) * sizeof(xfs_attr_leaf_entry_t)
                                        + sizeof(xfs_attr_leaf_hdr_t);
        map = &hdr->freemap[0];
-       tmp = INT_GET(map->size, ARCH_CONVERT);
+       tmp = be16_to_cpu(map->size);
        before = after = -1;
        smallest = XFS_ATTR_LEAF_MAPSIZE - 1;
        entsize = xfs_attr_leaf_entsize(leaf, args->index);
        for (i = 0; i < XFS_ATTR_LEAF_MAPSIZE; map++, i++) {
-               ASSERT(INT_GET(map->base, ARCH_CONVERT) < XFS_LBSIZE(mp));
-               ASSERT(INT_GET(map->size, ARCH_CONVERT) < XFS_LBSIZE(mp));
-               if (INT_GET(map->base, ARCH_CONVERT) == tablesize) {
-                       INT_MOD(map->base, ARCH_CONVERT,
-                                       -sizeof(xfs_attr_leaf_entry_t));
-                       INT_MOD(map->size, ARCH_CONVERT,
-                                       sizeof(xfs_attr_leaf_entry_t));
+               ASSERT(be16_to_cpu(map->base) < XFS_LBSIZE(mp));
+               ASSERT(be16_to_cpu(map->size) < XFS_LBSIZE(mp));
+               if (be16_to_cpu(map->base) == tablesize) {
+                       be16_add(&map->base,
+                                -((int)sizeof(xfs_attr_leaf_entry_t)));
+                       be16_add(&map->size, sizeof(xfs_attr_leaf_entry_t));
                }
 
-               if ((INT_GET(map->base, ARCH_CONVERT)
-                                       + INT_GET(map->size, ARCH_CONVERT))
-                               == INT_GET(entry->nameidx, ARCH_CONVERT)) {
+               if ((be16_to_cpu(map->base) + be16_to_cpu(map->size))
+                               == be16_to_cpu(entry->nameidx)) {
                        before = i;
-               } else if (INT_GET(map->base, ARCH_CONVERT)
-                       == (INT_GET(entry->nameidx, ARCH_CONVERT) + entsize)) {
+               } else if (be16_to_cpu(map->base)
+                       == (be16_to_cpu(entry->nameidx) + entsize)) {
                        after = i;
-               } else if (INT_GET(map->size, ARCH_CONVERT) < tmp) {
-                       tmp = INT_GET(map->size, ARCH_CONVERT);
+               } else if (be16_to_cpu(map->size) < tmp) {
+                       tmp = be16_to_cpu(map->size);
                        smallest = i;
                }
        }
@@ -1745,38 +1698,35 @@ xfs_attr_leaf_remove(xfs_dabuf_t *bp, xfs_da_args_t *args)
        if ((before >= 0) || (after >= 0)) {
                if ((before >= 0) && (after >= 0)) {
                        map = &hdr->freemap[before];
-                       INT_MOD(map->size, ARCH_CONVERT, entsize);
-                       INT_MOD(map->size, ARCH_CONVERT,
-                               INT_GET(hdr->freemap[after].size,
-                                                       ARCH_CONVERT));
+                       be16_add(&map->size, entsize);
+                       be16_add(&map->size,
+                                be16_to_cpu(hdr->freemap[after].size));
                        hdr->freemap[after].base = 0;
                        hdr->freemap[after].size = 0;
                } else if (before >= 0) {
                        map = &hdr->freemap[before];
-                       INT_MOD(map->size, ARCH_CONVERT, entsize);
+                       be16_add(&map->size, entsize);
                } else {
                        map = &hdr->freemap[after];
                        /* both on-disk, don't endian flip twice */
                        map->base = entry->nameidx;
-                       INT_MOD(map->size, ARCH_CONVERT, entsize);
+                       be16_add(&map->size, entsize);
                }
        } else {
                /*
                 * Replace smallest region (if it is smaller than free'd entry)
                 */
                map = &hdr->freemap[smallest];
-               if (INT_GET(map->size, ARCH_CONVERT) < entsize) {
-                       INT_SET(map->base, ARCH_CONVERT,
-                                       INT_GET(entry->nameidx, ARCH_CONVERT));
-                       INT_SET(map->size, ARCH_CONVERT, entsize);
+               if (be16_to_cpu(map->size) < entsize) {
+                       map->base = cpu_to_be16(be16_to_cpu(entry->nameidx));
+                       map->size = cpu_to_be16(entsize);
                }
        }
 
        /*
         * Did we remove the first entry?
         */
-       if (INT_GET(entry->nameidx, ARCH_CONVERT)
-                               == INT_GET(hdr->firstused, ARCH_CONVERT))
+       if (be16_to_cpu(entry->nameidx) == be16_to_cpu(hdr->firstused))
                smallest = 1;
        else
                smallest = 0;
@@ -1785,18 +1735,18 @@ xfs_attr_leaf_remove(xfs_dabuf_t *bp, xfs_da_args_t *args)
         * Compress the remaining entries and zero out the removed stuff.
         */
        memset(XFS_ATTR_LEAF_NAME(leaf, args->index), 0, entsize);
-       INT_MOD(hdr->usedbytes, ARCH_CONVERT, -entsize);
+       be16_add(&hdr->usedbytes, -entsize);
        xfs_da_log_buf(args->trans, bp,
             XFS_DA_LOGRANGE(leaf, XFS_ATTR_LEAF_NAME(leaf, args->index),
                                   entsize));
 
-       tmp = (INT_GET(hdr->count, ARCH_CONVERT) - args->index)
+       tmp = (be16_to_cpu(hdr->count) - args->index)
                                        * sizeof(xfs_attr_leaf_entry_t);
        memmove((char *)entry, (char *)(entry+1), tmp);
-       INT_MOD(hdr->count, ARCH_CONVERT, -1);
+       be16_add(&hdr->count, -1);
        xfs_da_log_buf(args->trans, bp,
            XFS_DA_LOGRANGE(leaf, entry, tmp + sizeof(*entry)));
-       entry = &leaf->entries[INT_GET(hdr->count, ARCH_CONVERT)];
+       entry = &leaf->entries[be16_to_cpu(hdr->count)];
        memset((char *)entry, 0, sizeof(xfs_attr_leaf_entry_t));
 
        /*
@@ -1808,18 +1758,17 @@ xfs_attr_leaf_remove(xfs_dabuf_t *bp, xfs_da_args_t *args)
        if (smallest) {
                tmp = XFS_LBSIZE(mp);
                entry = &leaf->entries[0];
-               for (i = INT_GET(hdr->count, ARCH_CONVERT)-1;
-                                               i >= 0; entry++, i--) {
-                       ASSERT(INT_GET(entry->nameidx, ARCH_CONVERT)
-                               >= INT_GET(hdr->firstused, ARCH_CONVERT));
-                       ASSERT(INT_GET(entry->nameidx, ARCH_CONVERT)
-                                                       < XFS_LBSIZE(mp));
-                       if (INT_GET(entry->nameidx, ARCH_CONVERT) < tmp)
-                               tmp = INT_GET(entry->nameidx, ARCH_CONVERT);
+               for (i = be16_to_cpu(hdr->count)-1; i >= 0; entry++, i--) {
+                       ASSERT(be16_to_cpu(entry->nameidx) >=
+                              be16_to_cpu(hdr->firstused));
+                       ASSERT(be16_to_cpu(entry->nameidx) < XFS_LBSIZE(mp));
+
+                       if (be16_to_cpu(entry->nameidx) < tmp)
+                               tmp = be16_to_cpu(entry->nameidx);
                }
-               INT_SET(hdr->firstused, ARCH_CONVERT, tmp);
+               hdr->firstused = cpu_to_be16(tmp);
                if (!hdr->firstused) {
-                       INT_SET(hdr->firstused, ARCH_CONVERT,
+                       hdr->firstused = cpu_to_be16(
                                        tmp - XFS_ATTR_LEAF_NAME_ALIGN);
                }
        } else {
@@ -1833,9 +1782,8 @@ xfs_attr_leaf_remove(xfs_dabuf_t *bp, xfs_da_args_t *args)
         * "join" the leaf with a sibling if so.
         */
        tmp  = sizeof(xfs_attr_leaf_hdr_t);
-       tmp += INT_GET(leaf->hdr.count, ARCH_CONVERT)
-                                       * sizeof(xfs_attr_leaf_entry_t);
-       tmp += INT_GET(leaf->hdr.usedbytes, ARCH_CONVERT);
+       tmp += be16_to_cpu(leaf->hdr.count) * sizeof(xfs_attr_leaf_entry_t);
+       tmp += be16_to_cpu(leaf->hdr.usedbytes);
        return(tmp < mp->m_attr_magicpct); /* leaf is < 37% full */
 }
 
@@ -1859,20 +1807,16 @@ xfs_attr_leaf_unbalance(xfs_da_state_t *state, xfs_da_state_blk_t *drop_blk,
        ASSERT(save_blk->magic == XFS_ATTR_LEAF_MAGIC);
        drop_leaf = drop_blk->bp->data;
        save_leaf = save_blk->bp->data;
-       ASSERT(INT_GET(drop_leaf->hdr.info.magic, ARCH_CONVERT)
-                                               == XFS_ATTR_LEAF_MAGIC);
-       ASSERT(INT_GET(save_leaf->hdr.info.magic, ARCH_CONVERT)
-                                               == XFS_ATTR_LEAF_MAGIC);
+       ASSERT(be16_to_cpu(drop_leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC);
+       ASSERT(be16_to_cpu(save_leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC);
        drop_hdr = &drop_leaf->hdr;
        save_hdr = &save_leaf->hdr;
 
        /*
         * Save last hashval from dying block for later Btree fixup.
         */
-       drop_blk->hashval =
-               INT_GET(drop_leaf->entries[INT_GET(drop_leaf->hdr.count,
-                                               ARCH_CONVERT)-1].hashval,
-                                                               ARCH_CONVERT);
+       drop_blk->hashval = be32_to_cpu(
+               drop_leaf->entries[be16_to_cpu(drop_leaf->hdr.count)-1].hashval);
 
        /*
         * Check if we need a temp buffer, or can we do it in place.
@@ -1886,12 +1830,11 @@ xfs_attr_leaf_unbalance(xfs_da_state_t *state, xfs_da_state_blk_t *drop_blk,
                 */
                if (xfs_attr_leaf_order(save_blk->bp, drop_blk->bp)) {
                        xfs_attr_leaf_moveents(drop_leaf, 0, save_leaf, 0,
-                            (int)INT_GET(drop_hdr->count, ARCH_CONVERT), mp);
+                            be16_to_cpu(drop_hdr->count), mp);
                } else {
                        xfs_attr_leaf_moveents(drop_leaf, 0, save_leaf,
-                                 INT_GET(save_hdr->count, ARCH_CONVERT),
-                                 (int)INT_GET(drop_hdr->count, ARCH_CONVERT),
-                                 mp);
+                                 be16_to_cpu(save_hdr->count),
+                                 be16_to_cpu(drop_hdr->count), mp);
                }
        } else {
                /*
@@ -1905,28 +1848,24 @@ xfs_attr_leaf_unbalance(xfs_da_state_t *state, xfs_da_state_blk_t *drop_blk,
                tmp_hdr = &tmp_leaf->hdr;
                tmp_hdr->info = save_hdr->info; /* struct copy */
                tmp_hdr->count = 0;
-               INT_SET(tmp_hdr->firstused, ARCH_CONVERT, state->blocksize);
+               tmp_hdr->firstused = cpu_to_be16(state->blocksize);
                if (!tmp_hdr->firstused) {
-                       INT_SET(tmp_hdr->firstused, ARCH_CONVERT,
+                       tmp_hdr->firstused = cpu_to_be16(
                                state->blocksize - XFS_ATTR_LEAF_NAME_ALIGN);
                }
                tmp_hdr->usedbytes = 0;
                if (xfs_attr_leaf_order(save_blk->bp, drop_blk->bp)) {
                        xfs_attr_leaf_moveents(drop_leaf, 0, tmp_leaf, 0,
-                               (int)INT_GET(drop_hdr->count, ARCH_CONVERT),
-                               mp);
+                               be16_to_cpu(drop_hdr->count), mp);
                        xfs_attr_leaf_moveents(save_leaf, 0, tmp_leaf,
-                                 INT_GET(tmp_leaf->hdr.count, ARCH_CONVERT),
-                                (int)INT_GET(save_hdr->count, ARCH_CONVERT),
-                                mp);
+                                 be16_to_cpu(tmp_leaf->hdr.count),
+                                 be16_to_cpu(save_hdr->count), mp);
                } else {
                        xfs_attr_leaf_moveents(save_leaf, 0, tmp_leaf, 0,
-                               (int)INT_GET(save_hdr->count, ARCH_CONVERT),
-                               mp);
+                               be16_to_cpu(save_hdr->count), mp);
                        xfs_attr_leaf_moveents(drop_leaf, 0, tmp_leaf,
-                               INT_GET(tmp_leaf->hdr.count, ARCH_CONVERT),
-                               (int)INT_GET(drop_hdr->count, ARCH_CONVERT),
-                               mp);
+                               be16_to_cpu(tmp_leaf->hdr.count),
+                               be16_to_cpu(drop_hdr->count), mp);
                }
                memcpy((char *)save_leaf, (char *)tmp_leaf, state->blocksize);
                kmem_free(tmpbuffer, state->blocksize);
@@ -1938,10 +1877,8 @@ xfs_attr_leaf_unbalance(xfs_da_state_t *state, xfs_da_state_blk_t *drop_blk,
        /*
         * Copy out last hashval in each block for B-tree code.
         */
-       save_blk->hashval =
-               INT_GET(save_leaf->entries[INT_GET(save_leaf->hdr.count,
-                                               ARCH_CONVERT)-1].hashval,
-                                                               ARCH_CONVERT);
+       save_blk->hashval = be32_to_cpu(
+               save_leaf->entries[be16_to_cpu(save_leaf->hdr.count)-1].hashval);
 }
 
 /*========================================================================
@@ -1972,48 +1909,45 @@ xfs_attr_leaf_lookup_int(xfs_dabuf_t *bp, xfs_da_args_t *args)
        xfs_dahash_t hashval;
 
        leaf = bp->data;
-       ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT)
-                                               == XFS_ATTR_LEAF_MAGIC);
-       ASSERT(INT_GET(leaf->hdr.count, ARCH_CONVERT)
+       ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC);
+       ASSERT(be16_to_cpu(leaf->hdr.count)
                                        < (XFS_LBSIZE(args->dp->i_mount)/8));
 
        /*
         * Binary search.  (note: small blocks will skip this loop)
         */
        hashval = args->hashval;
-       probe = span = INT_GET(leaf->hdr.count, ARCH_CONVERT) / 2;
+       probe = span = be16_to_cpu(leaf->hdr.count) / 2;
        for (entry = &leaf->entries[probe]; span > 4;
                   entry = &leaf->entries[probe]) {
                span /= 2;
-               if (INT_GET(entry->hashval, ARCH_CONVERT) < hashval)
+               if (be32_to_cpu(entry->hashval) < hashval)
                        probe += span;
-               else if (INT_GET(entry->hashval, ARCH_CONVERT) > hashval)
+               else if (be32_to_cpu(entry->hashval) > hashval)
                        probe -= span;
                else
                        break;
        }
        ASSERT((probe >= 0) && 
               (!leaf->hdr.count
-              || (probe < INT_GET(leaf->hdr.count, ARCH_CONVERT))));
-       ASSERT((span <= 4) || (INT_GET(entry->hashval, ARCH_CONVERT)
-                                                       == hashval));
+              || (probe < be16_to_cpu(leaf->hdr.count))));
+       ASSERT((span <= 4) || (be32_to_cpu(entry->hashval) == hashval));
 
        /*
         * Since we may have duplicate hashval's, find the first matching
         * hashval in the leaf.
         */
-       while ((probe > 0) && (INT_GET(entry->hashval, ARCH_CONVERT)
-                                                       >= hashval)) {
+       while ((probe > 0) && (be32_to_cpu(entry->hashval) >= hashval)) {
                entry--;
                probe--;
        }
-       while ((probe < INT_GET(leaf->hdr.count, ARCH_CONVERT))
-               && (INT_GET(entry->hashval, ARCH_CONVERT) < hashval)) {
+       while ((probe < be16_to_cpu(leaf->hdr.count)) &&
+              (be32_to_cpu(entry->hashval) < hashval)) {
                entry++;
                probe++;
        }
-       if ((probe == INT_GET(leaf->hdr.count, ARCH_CONVERT))
-                   || (INT_GET(entry->hashval, ARCH_CONVERT) != hashval)) {
+       if ((probe == be16_to_cpu(leaf->hdr.count)) ||
+           (be32_to_cpu(entry->hashval) != hashval)) {
                args->index = probe;
                return(XFS_ERROR(ENOATTR));
        }
@@ -2021,8 +1955,8 @@ xfs_attr_leaf_lookup_int(xfs_dabuf_t *bp, xfs_da_args_t *args)
        /*
         * Duplicate keys may be present, so search all of them for a match.
         */
-       for (  ; (probe < INT_GET(leaf->hdr.count, ARCH_CONVERT))
-                       && (INT_GET(entry->hashval, ARCH_CONVERT) == hashval);
+       for (  ; (probe < be16_to_cpu(leaf->hdr.count)) &&
+                       (be32_to_cpu(entry->hashval) == hashval);
                        entry++, probe++) {
 /*
  * GROT: Add code to remove incomplete entries.
@@ -2064,11 +1998,9 @@ xfs_attr_leaf_lookup_int(xfs_dabuf_t *bp, xfs_da_args_t *args)
                            ((entry->flags & XFS_ATTR_ROOT) != 0))
                                continue;
                        args->index = probe;
-                       args->rmtblkno
-                                 = INT_GET(name_rmt->valueblk, ARCH_CONVERT);
+                       args->rmtblkno = be32_to_cpu(name_rmt->valueblk);
                        args->rmtblkcnt = XFS_B_TO_FSB(args->dp->i_mount,
-                                                  INT_GET(name_rmt->valuelen,
-                                                               ARCH_CONVERT));
+                                                  be32_to_cpu(name_rmt->valuelen));
                        return(XFS_ERROR(EEXIST));
                }
        }
@@ -2090,18 +2022,17 @@ xfs_attr_leaf_getvalue(xfs_dabuf_t *bp, xfs_da_args_t *args)
        xfs_attr_leaf_name_remote_t *name_rmt;
 
        leaf = bp->data;
-       ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT)
-                                               == XFS_ATTR_LEAF_MAGIC);
-       ASSERT(INT_GET(leaf->hdr.count, ARCH_CONVERT)
+       ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC);
+       ASSERT(be16_to_cpu(leaf->hdr.count)
                                        < (XFS_LBSIZE(args->dp->i_mount)/8));
-       ASSERT(args->index < ((int)INT_GET(leaf->hdr.count, ARCH_CONVERT)));
+       ASSERT(args->index < be16_to_cpu(leaf->hdr.count));
 
        entry = &leaf->entries[args->index];
        if (entry->flags & XFS_ATTR_LOCAL) {
                name_loc = XFS_ATTR_LEAF_NAME_LOCAL(leaf, args->index);
                ASSERT(name_loc->namelen == args->namelen);
                ASSERT(memcmp(args->name, name_loc->nameval, args->namelen) == 0);
-               valuelen = INT_GET(name_loc->valuelen, ARCH_CONVERT);
+               valuelen = be16_to_cpu(name_loc->valuelen);
                if (args->flags & ATTR_KERNOVAL) {
                        args->valuelen = valuelen;
                        return(0);
@@ -2116,8 +2047,8 @@ xfs_attr_leaf_getvalue(xfs_dabuf_t *bp, xfs_da_args_t *args)
                name_rmt = XFS_ATTR_LEAF_NAME_REMOTE(leaf, args->index);
                ASSERT(name_rmt->namelen == args->namelen);
                ASSERT(memcmp(args->name, name_rmt->name, args->namelen) == 0);
-               valuelen = INT_GET(name_rmt->valuelen, ARCH_CONVERT);
-               args->rmtblkno = INT_GET(name_rmt->valueblk, ARCH_CONVERT);
+               valuelen = be32_to_cpu(name_rmt->valuelen);
+               args->rmtblkno = be32_to_cpu(name_rmt->valueblk);
                args->rmtblkcnt = XFS_B_TO_FSB(args->dp->i_mount, valuelen);
                if (args->flags & ATTR_KERNOVAL) {
                        args->valuelen = valuelen;
@@ -2159,32 +2090,29 @@ xfs_attr_leaf_moveents(xfs_attr_leafblock_t *leaf_s, int start_s,
        /*
         * Set up environment.
         */
-       ASSERT(INT_GET(leaf_s->hdr.info.magic, ARCH_CONVERT)
-                                               == XFS_ATTR_LEAF_MAGIC);
-       ASSERT(INT_GET(leaf_d->hdr.info.magic, ARCH_CONVERT)
-                                               == XFS_ATTR_LEAF_MAGIC);
+       ASSERT(be16_to_cpu(leaf_s->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC);
+       ASSERT(be16_to_cpu(leaf_d->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC);
        hdr_s = &leaf_s->hdr;
        hdr_d = &leaf_d->hdr;
-       ASSERT((INT_GET(hdr_s->count, ARCH_CONVERT) > 0)
-                               && (INT_GET(hdr_s->count, ARCH_CONVERT)
-                                               < (XFS_LBSIZE(mp)/8)));
-       ASSERT(INT_GET(hdr_s->firstused, ARCH_CONVERT) >=
-               ((INT_GET(hdr_s->count, ARCH_CONVERT)
+       ASSERT((be16_to_cpu(hdr_s->count) > 0) &&
+              (be16_to_cpu(hdr_s->count) < (XFS_LBSIZE(mp)/8)));
+       ASSERT(be16_to_cpu(hdr_s->firstused) >=
+               ((be16_to_cpu(hdr_s->count)
                                        * sizeof(*entry_s))+sizeof(*hdr_s)));
-       ASSERT(INT_GET(hdr_d->count, ARCH_CONVERT) < (XFS_LBSIZE(mp)/8));
-       ASSERT(INT_GET(hdr_d->firstused, ARCH_CONVERT) >=
-               ((INT_GET(hdr_d->count, ARCH_CONVERT)
+       ASSERT(be16_to_cpu(hdr_d->count) < (XFS_LBSIZE(mp)/8));
+       ASSERT(be16_to_cpu(hdr_d->firstused) >=
+               ((be16_to_cpu(hdr_d->count)
                                        * sizeof(*entry_d))+sizeof(*hdr_d)));
 
-       ASSERT(start_s < INT_GET(hdr_s->count, ARCH_CONVERT));
-       ASSERT(start_d <= INT_GET(hdr_d->count, ARCH_CONVERT));
-       ASSERT(count <= INT_GET(hdr_s->count, ARCH_CONVERT));
+       ASSERT(start_s < be16_to_cpu(hdr_s->count));
+       ASSERT(start_d <= be16_to_cpu(hdr_d->count));
+       ASSERT(count <= be16_to_cpu(hdr_s->count));
 
        /*
         * Move the entries in the destination leaf up to make a hole?
         */
-       if (start_d < INT_GET(hdr_d->count, ARCH_CONVERT)) {
-               tmp  = INT_GET(hdr_d->count, ARCH_CONVERT) - start_d;
+       if (start_d < be16_to_cpu(hdr_d->count)) {
+               tmp  = be16_to_cpu(hdr_d->count) - start_d;
                tmp *= sizeof(xfs_attr_leaf_entry_t);
                entry_s = &leaf_d->entries[start_d];
                entry_d = &leaf_d->entries[start_d + count];
@@ -2199,8 +2127,8 @@ xfs_attr_leaf_moveents(xfs_attr_leafblock_t *leaf_s, int start_s,
        entry_d = &leaf_d->entries[start_d];
        desti = start_d;
        for (i = 0; i < count; entry_s++, entry_d++, desti++, i++) {
-               ASSERT(INT_GET(entry_s->nameidx, ARCH_CONVERT)
-                               >= INT_GET(hdr_s->firstused, ARCH_CONVERT));
+               ASSERT(be16_to_cpu(entry_s->nameidx)
+                               >= be16_to_cpu(hdr_s->firstused));
                tmp = xfs_attr_leaf_entsize(leaf_s, start_s + i);
 #ifdef GROT
                /*
@@ -2210,35 +2138,35 @@ xfs_attr_leaf_moveents(xfs_attr_leafblock_t *leaf_s, int start_s,
                 */
                if (entry_s->flags & XFS_ATTR_INCOMPLETE) { /* skip partials? */
                        memset(XFS_ATTR_LEAF_NAME(leaf_s, start_s + i), 0, tmp);
-                       INT_MOD(hdr_s->usedbytes, ARCH_CONVERT, -tmp);
-                       INT_MOD(hdr_s->count, ARCH_CONVERT, -1);
+                       be16_add(&hdr_s->usedbytes, -tmp);
+                       be16_add(&hdr_s->count, -1);
                        entry_d--;      /* to compensate for ++ in loop hdr */
                        desti--;
                        if ((start_s + i) < offset)
                                result++;       /* insertion index adjustment */
                } else {
 #endif /* GROT */
-                       INT_MOD(hdr_d->firstused, ARCH_CONVERT, -tmp);
+                       be16_add(&hdr_d->firstused, -tmp);
                        /* both on-disk, don't endian flip twice */
                        entry_d->hashval = entry_s->hashval;
                        /* both on-disk, don't endian flip twice */
                        entry_d->nameidx = hdr_d->firstused;
                        entry_d->flags = entry_s->flags;
-                       ASSERT(INT_GET(entry_d->nameidx, ARCH_CONVERT) + tmp
+                       ASSERT(be16_to_cpu(entry_d->nameidx) + tmp
                                                        <= XFS_LBSIZE(mp));
                        memmove(XFS_ATTR_LEAF_NAME(leaf_d, desti),
                                XFS_ATTR_LEAF_NAME(leaf_s, start_s + i), tmp);
-                       ASSERT(INT_GET(entry_s->nameidx, ARCH_CONVERT) + tmp
+                       ASSERT(be16_to_cpu(entry_s->nameidx) + tmp
                                                        <= XFS_LBSIZE(mp));
                        memset(XFS_ATTR_LEAF_NAME(leaf_s, start_s + i), 0, tmp);
-                       INT_MOD(hdr_s->usedbytes, ARCH_CONVERT, -tmp);
-                       INT_MOD(hdr_d->usedbytes, ARCH_CONVERT, tmp);
-                       INT_MOD(hdr_s->count, ARCH_CONVERT, -1);
-                       INT_MOD(hdr_d->count, ARCH_CONVERT, 1);
-                       tmp = INT_GET(hdr_d->count, ARCH_CONVERT)
+                       be16_add(&hdr_s->usedbytes, -tmp);
+                       be16_add(&hdr_d->usedbytes, tmp);
+                       be16_add(&hdr_s->count, -1);
+                       be16_add(&hdr_d->count, 1);
+                       tmp = be16_to_cpu(hdr_d->count)
                                                * sizeof(xfs_attr_leaf_entry_t)
                                                + sizeof(xfs_attr_leaf_hdr_t);
-                       ASSERT(INT_GET(hdr_d->firstused, ARCH_CONVERT) >= tmp);
+                       ASSERT(be16_to_cpu(hdr_d->firstused) >= tmp);
 #ifdef GROT
                }
 #endif /* GROT */
@@ -2247,7 +2175,7 @@ xfs_attr_leaf_moveents(xfs_attr_leafblock_t *leaf_s, int start_s,
        /*
         * Zero out the entries we just copied.
         */
-       if (start_s == INT_GET(hdr_s->count, ARCH_CONVERT)) {
+       if (start_s == be16_to_cpu(hdr_s->count)) {
                tmp = count * sizeof(xfs_attr_leaf_entry_t);
                entry_s = &leaf_s->entries[start_s];
                ASSERT(((char *)entry_s + tmp) <=
@@ -2258,15 +2186,14 @@ xfs_attr_leaf_moveents(xfs_attr_leafblock_t *leaf_s, int start_s,
                 * Move the remaining entries down to fill the hole,
                 * then zero the entries at the top.
                 */
-               tmp  = INT_GET(hdr_s->count, ARCH_CONVERT) - count;
+               tmp  = be16_to_cpu(hdr_s->count) - count;
                tmp *= sizeof(xfs_attr_leaf_entry_t);
                entry_s = &leaf_s->entries[start_s + count];
                entry_d = &leaf_s->entries[start_s];
                memmove((char *)entry_d, (char *)entry_s, tmp);
 
                tmp = count * sizeof(xfs_attr_leaf_entry_t);
-               entry_s = &leaf_s->entries[INT_GET(hdr_s->count,
-                                                       ARCH_CONVERT)];
+               entry_s = &leaf_s->entries[be16_to_cpu(hdr_s->count)];
                ASSERT(((char *)entry_s + tmp) <=
                       ((char *)leaf_s + XFS_LBSIZE(mp)));
                memset((char *)entry_s, 0, tmp);
@@ -2275,14 +2202,11 @@ xfs_attr_leaf_moveents(xfs_attr_leafblock_t *leaf_s, int start_s,
        /*
         * Fill in the freemap information
         */
-       INT_SET(hdr_d->freemap[0].base, ARCH_CONVERT,
-                                       sizeof(xfs_attr_leaf_hdr_t));
-       INT_MOD(hdr_d->freemap[0].base, ARCH_CONVERT,
-                               INT_GET(hdr_d->count, ARCH_CONVERT)
-                                       * sizeof(xfs_attr_leaf_entry_t));
-       INT_SET(hdr_d->freemap[0].size, ARCH_CONVERT,
-                               INT_GET(hdr_d->firstused, ARCH_CONVERT)
-                             - INT_GET(hdr_d->freemap[0].base, ARCH_CONVERT));
+       hdr_d->freemap[0].base = cpu_to_be16(sizeof(xfs_attr_leaf_hdr_t));
+       be16_add(&hdr_d->freemap[0].base, be16_to_cpu(hdr_d->count) *
+                       sizeof(xfs_attr_leaf_entry_t));
+       hdr_d->freemap[0].size = cpu_to_be16(be16_to_cpu(hdr_d->firstused)
+                             - be16_to_cpu(hdr_d->freemap[0].base));
        hdr_d->freemap[1].base = 0;
        hdr_d->freemap[2].base = 0;
        hdr_d->freemap[1].size = 0;
@@ -2301,18 +2225,16 @@ xfs_attr_leaf_order(xfs_dabuf_t *leaf1_bp, xfs_dabuf_t *leaf2_bp)
 
        leaf1 = leaf1_bp->data;
        leaf2 = leaf2_bp->data;
-       ASSERT((INT_GET(leaf1->hdr.info.magic, ARCH_CONVERT)
-                                               == XFS_ATTR_LEAF_MAGIC) &&
-              (INT_GET(leaf2->hdr.info.magic, ARCH_CONVERT)
-                                               == XFS_ATTR_LEAF_MAGIC));
-       if (   (INT_GET(leaf1->hdr.count, ARCH_CONVERT) > 0)
-           && (INT_GET(leaf2->hdr.count, ARCH_CONVERT) > 0)
-           && (   (INT_GET(leaf2->entries[ 0 ].hashval, ARCH_CONVERT) <
-                     INT_GET(leaf1->entries[ 0 ].hashval, ARCH_CONVERT))
-               || (INT_GET(leaf2->entries[INT_GET(leaf2->hdr.count,
-                               ARCH_CONVERT)-1].hashval, ARCH_CONVERT) <
-                     INT_GET(leaf1->entries[INT_GET(leaf1->hdr.count,
-                               ARCH_CONVERT)-1].hashval, ARCH_CONVERT))) ) {
+       ASSERT((be16_to_cpu(leaf1->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC) &&
+              (be16_to_cpu(leaf2->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC));
+       if ((be16_to_cpu(leaf1->hdr.count) > 0) &&
+           (be16_to_cpu(leaf2->hdr.count) > 0) &&
+           ((be32_to_cpu(leaf2->entries[0].hashval) <
+             be32_to_cpu(leaf1->entries[0].hashval)) ||
+            (be32_to_cpu(leaf2->entries[
+                       be16_to_cpu(leaf2->hdr.count)-1].hashval) <
+             be32_to_cpu(leaf1->entries[
+                       be16_to_cpu(leaf1->hdr.count)-1].hashval)))) {
                return(1);
        }
        return(0);
@@ -2327,14 +2249,12 @@ xfs_attr_leaf_lasthash(xfs_dabuf_t *bp, int *count)
        xfs_attr_leafblock_t *leaf;
 
        leaf = bp->data;
-       ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT)
-                                               == XFS_ATTR_LEAF_MAGIC);
+       ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC);
        if (count)
-               *count = INT_GET(leaf->hdr.count, ARCH_CONVERT);
+               *count = be16_to_cpu(leaf->hdr.count);
        if (!leaf->hdr.count)
                return(0);
-       return(INT_GET(leaf->entries[INT_GET(leaf->hdr.count,
-                               ARCH_CONVERT)-1].hashval, ARCH_CONVERT));
+       return be32_to_cpu(leaf->entries[be16_to_cpu(leaf->hdr.count)-1].hashval);
 }
 
 /*
@@ -2348,13 +2268,11 @@ xfs_attr_leaf_entsize(xfs_attr_leafblock_t *leaf, int index)
        xfs_attr_leaf_name_remote_t *name_rmt;
        int size;
 
-       ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT)
-                                               == XFS_ATTR_LEAF_MAGIC);
+       ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC);
        if (leaf->entries[index].flags & XFS_ATTR_LOCAL) {
                name_loc = XFS_ATTR_LEAF_NAME_LOCAL(leaf, index);
                size = XFS_ATTR_LEAF_ENTSIZE_LOCAL(name_loc->namelen,
-                                                  INT_GET(name_loc->valuelen,
-                                                               ARCH_CONVERT));
+                                                  be16_to_cpu(name_loc->valuelen));
        } else {
                name_rmt = XFS_ATTR_LEAF_NAME_REMOTE(leaf, index);
                size = XFS_ATTR_LEAF_ENTSIZE_REMOTE(name_rmt->namelen);
@@ -2412,22 +2330,20 @@ xfs_attr_leaf_list_int(xfs_dabuf_t *bp, xfs_attr_list_context_t *context)
         */
        if (context->resynch) {
                entry = &leaf->entries[0];
-               for (i = 0; i < INT_GET(leaf->hdr.count, ARCH_CONVERT);
-                                                       entry++, i++) {
-                       if (INT_GET(entry->hashval, ARCH_CONVERT)
-                                                       == cursor->hashval) {
+               for (i = 0; i < be16_to_cpu(leaf->hdr.count); entry++, i++) {
+                       if (be32_to_cpu(entry->hashval) == cursor->hashval) {
                                if (cursor->offset == context->dupcnt) {
                                        context->dupcnt = 0;
                                        break;
                                }
                                context->dupcnt++;
-                       } else if (INT_GET(entry->hashval, ARCH_CONVERT)
-                                                       > cursor->hashval) {
+                       } else if (be32_to_cpu(entry->hashval) >
+                                       cursor->hashval) {
                                context->dupcnt = 0;
                                break;
                        }
                }
-               if (i == INT_GET(leaf->hdr.count, ARCH_CONVERT)) {
+               if (i == be16_to_cpu(leaf->hdr.count)) {
                        xfs_attr_trace_l_c("not found", context);
                        return(0);
                }
@@ -2441,12 +2357,12 @@ xfs_attr_leaf_list_int(xfs_dabuf_t *bp, xfs_attr_list_context_t *context)
         * We have found our place, start copying out the new attributes.
         */
        retval = 0;
-       for (  ; (i < INT_GET(leaf->hdr.count, ARCH_CONVERT))
+       for (  ; (i < be16_to_cpu(leaf->hdr.count))
             && (retval == 0); entry++, i++) {
                attrnames_t     *namesp;
 
-               if (INT_GET(entry->hashval, ARCH_CONVERT) != cursor->hashval) {
-                       cursor->hashval = INT_GET(entry->hashval, ARCH_CONVERT);
+               if (be32_to_cpu(entry->hashval) != cursor->hashval) {
+                       cursor->hashval = be32_to_cpu(entry->hashval);
                        cursor->offset = 0;
                }
 
@@ -2475,8 +2391,7 @@ xfs_attr_leaf_list_int(xfs_dabuf_t *bp, xfs_attr_list_context_t *context)
                                retval = xfs_attr_put_listent(context, namesp,
                                        (char *)name_loc->nameval,
                                        (int)name_loc->namelen,
-                                       (int)INT_GET(name_loc->valuelen,
-                                                               ARCH_CONVERT));
+                                       be16_to_cpu(name_loc->valuelen));
                        }
                } else {
                        name_rmt = XFS_ATTR_LEAF_NAME_REMOTE(leaf, i);
@@ -2488,8 +2403,7 @@ xfs_attr_leaf_list_int(xfs_dabuf_t *bp, xfs_attr_list_context_t *context)
                                retval = xfs_attr_put_listent(context, namesp,
                                        (char *)name_rmt->name,
                                        (int)name_rmt->namelen,
-                                       (int)INT_GET(name_rmt->valuelen,
-                                                               ARCH_CONVERT));
+                                       be32_to_cpu(name_rmt->valuelen));
                        }
                }
                if (retval == 0) {
@@ -2596,9 +2510,8 @@ xfs_attr_leaf_clearflag(xfs_da_args_t *args)
        ASSERT(bp != NULL);
 
        leaf = bp->data;
-       ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT)
-                                               == XFS_ATTR_LEAF_MAGIC);
-       ASSERT(args->index < INT_GET(leaf->hdr.count, ARCH_CONVERT));
+       ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC);
+       ASSERT(args->index < be16_to_cpu(leaf->hdr.count));
        ASSERT(args->index >= 0);
        entry = &leaf->entries[ args->index ];
        ASSERT(entry->flags & XFS_ATTR_INCOMPLETE);
@@ -2613,7 +2526,7 @@ xfs_attr_leaf_clearflag(xfs_da_args_t *args)
                namelen = name_rmt->namelen;
                name = (char *)name_rmt->name;
        }
-       ASSERT(INT_GET(entry->hashval, ARCH_CONVERT) == args->hashval);
+       ASSERT(be32_to_cpu(entry->hashval) == args->hashval);
        ASSERT(namelen == args->namelen);
        ASSERT(memcmp(name, args->name, namelen) == 0);
 #endif /* DEBUG */
@@ -2625,8 +2538,8 @@ xfs_attr_leaf_clearflag(xfs_da_args_t *args)
        if (args->rmtblkno) {
                ASSERT((entry->flags & XFS_ATTR_LOCAL) == 0);
                name_rmt = XFS_ATTR_LEAF_NAME_REMOTE(leaf, args->index);
-               INT_SET(name_rmt->valueblk, ARCH_CONVERT, args->rmtblkno);
-               INT_SET(name_rmt->valuelen, ARCH_CONVERT, args->valuelen);
+               name_rmt->valueblk = cpu_to_be32(args->rmtblkno);
+               name_rmt->valuelen = cpu_to_be32(args->valuelen);
                xfs_da_log_buf(args->trans, bp,
                         XFS_DA_LOGRANGE(leaf, name_rmt, sizeof(*name_rmt)));
        }
@@ -2663,9 +2576,8 @@ xfs_attr_leaf_setflag(xfs_da_args_t *args)
        ASSERT(bp != NULL);
 
        leaf = bp->data;
-       ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT)
-                                               == XFS_ATTR_LEAF_MAGIC);
-       ASSERT(args->index < INT_GET(leaf->hdr.count, ARCH_CONVERT));
+       ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC);
+       ASSERT(args->index < be16_to_cpu(leaf->hdr.count));
        ASSERT(args->index >= 0);
        entry = &leaf->entries[ args->index ];
 
@@ -2736,16 +2648,14 @@ xfs_attr_leaf_flipflags(xfs_da_args_t *args)
        }
 
        leaf1 = bp1->data;
-       ASSERT(INT_GET(leaf1->hdr.info.magic, ARCH_CONVERT)
-                                               == XFS_ATTR_LEAF_MAGIC);
-       ASSERT(args->index < INT_GET(leaf1->hdr.count, ARCH_CONVERT));
+       ASSERT(be16_to_cpu(leaf1->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC);
+       ASSERT(args->index < be16_to_cpu(leaf1->hdr.count));
        ASSERT(args->index >= 0);
        entry1 = &leaf1->entries[ args->index ];
 
        leaf2 = bp2->data;
-       ASSERT(INT_GET(leaf2->hdr.info.magic, ARCH_CONVERT)
-                                               == XFS_ATTR_LEAF_MAGIC);
-       ASSERT(args->index2 < INT_GET(leaf2->hdr.count, ARCH_CONVERT));
+       ASSERT(be16_to_cpu(leaf2->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC);
+       ASSERT(args->index2 < be16_to_cpu(leaf2->hdr.count));
        ASSERT(args->index2 >= 0);
        entry2 = &leaf2->entries[ args->index2 ];
 
@@ -2768,7 +2678,7 @@ xfs_attr_leaf_flipflags(xfs_da_args_t *args)
                namelen2 = name_rmt->namelen;
                name2 = (char *)name_rmt->name;
        }
-       ASSERT(INT_GET(entry1->hashval, ARCH_CONVERT) == INT_GET(entry2->hashval, ARCH_CONVERT));
+       ASSERT(be32_to_cpu(entry1->hashval) == be32_to_cpu(entry2->hashval));
        ASSERT(namelen1 == namelen2);
        ASSERT(memcmp(name1, name2, namelen1) == 0);
 #endif /* DEBUG */
@@ -2782,8 +2692,8 @@ xfs_attr_leaf_flipflags(xfs_da_args_t *args)
        if (args->rmtblkno) {
                ASSERT((entry1->flags & XFS_ATTR_LOCAL) == 0);
                name_rmt = XFS_ATTR_LEAF_NAME_REMOTE(leaf1, args->index);
-               INT_SET(name_rmt->valueblk, ARCH_CONVERT, args->rmtblkno);
-               INT_SET(name_rmt->valuelen, ARCH_CONVERT, args->valuelen);
+               name_rmt->valueblk = cpu_to_be32(args->rmtblkno);
+               name_rmt->valuelen = cpu_to_be32(args->valuelen);
                xfs_da_log_buf(args->trans, bp1,
                         XFS_DA_LOGRANGE(leaf1, name_rmt, sizeof(*name_rmt)));
        }
@@ -2842,9 +2752,9 @@ xfs_attr_root_inactive(xfs_trans_t **trans, xfs_inode_t *dp)
         * This is a depth-first traversal!
         */
        info = bp->data;
-       if (INT_GET(info->magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC) {
+       if (be16_to_cpu(info->magic) == XFS_DA_NODE_MAGIC) {
                error = xfs_attr_node_inactive(trans, dp, bp, 1);
-       } else if (INT_GET(info->magic, ARCH_CONVERT) == XFS_ATTR_LEAF_MAGIC) {
+       } else if (be16_to_cpu(info->magic) == XFS_ATTR_LEAF_MAGIC) {
                error = xfs_attr_leaf_inactive(trans, dp, bp);
        } else {
                error = XFS_ERROR(EIO);
@@ -2892,15 +2802,14 @@ xfs_attr_node_inactive(xfs_trans_t **trans, xfs_inode_t *dp, xfs_dabuf_t *bp,
        }
 
        node = bp->data;
-       ASSERT(INT_GET(node->hdr.info.magic, ARCH_CONVERT)
-                                               == XFS_DA_NODE_MAGIC);
+       ASSERT(be16_to_cpu(node->hdr.info.magic) == XFS_DA_NODE_MAGIC);
        parent_blkno = xfs_da_blkno(bp);        /* save for re-read later */
-       count = INT_GET(node->hdr.count, ARCH_CONVERT);
+       count = be16_to_cpu(node->hdr.count);
        if (!count) {
                xfs_da_brelse(*trans, bp);
                return(0);
        }
-       child_fsb = INT_GET(node->btree[0].before, ARCH_CONVERT);
+       child_fsb = be32_to_cpu(node->btree[0].before);
        xfs_da_brelse(*trans, bp);      /* no locks for later trans */
 
        /*
@@ -2927,12 +2836,10 @@ xfs_attr_node_inactive(xfs_trans_t **trans, xfs_inode_t *dp, xfs_dabuf_t *bp,
                         * Invalidate the subtree, however we have to.
                         */
                        info = child_bp->data;
-                       if (INT_GET(info->magic, ARCH_CONVERT)
-                                                       == XFS_DA_NODE_MAGIC) {
+                       if (be16_to_cpu(info->magic) == XFS_DA_NODE_MAGIC) {
                                error = xfs_attr_node_inactive(trans, dp,
                                                child_bp, level+1);
-                       } else if (INT_GET(info->magic, ARCH_CONVERT)
-                                               == XFS_ATTR_LEAF_MAGIC) {
+                       } else if (be16_to_cpu(info->magic) == XFS_ATTR_LEAF_MAGIC) {
                                error = xfs_attr_leaf_inactive(trans, dp,
                                                child_bp);
                        } else {
@@ -2962,7 +2869,7 @@ xfs_attr_node_inactive(xfs_trans_t **trans, xfs_inode_t *dp, xfs_dabuf_t *bp,
                                &bp, XFS_ATTR_FORK);
                        if (error)
                                return(error);
-                       child_fsb = INT_GET(node->btree[i+1].before, ARCH_CONVERT);
+                       child_fsb = be32_to_cpu(node->btree[i+1].before);
                        xfs_da_brelse(*trans, bp);
                }
                /*
@@ -2991,17 +2898,16 @@ xfs_attr_leaf_inactive(xfs_trans_t **trans, xfs_inode_t *dp, xfs_dabuf_t *bp)
        int error, count, size, tmp, i;
 
        leaf = bp->data;
-       ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT)
-                                               == XFS_ATTR_LEAF_MAGIC);
+       ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC);
 
        /*
         * Count the number of "remote" value extents.
         */
        count = 0;
        entry = &leaf->entries[0];
-       for (i = 0; i < INT_GET(leaf->hdr.count, ARCH_CONVERT); entry++, i++) {
-               if (   INT_GET(entry->nameidx, ARCH_CONVERT)
-                   && ((entry->flags & XFS_ATTR_LOCAL) == 0)) {
+       for (i = 0; i < be16_to_cpu(leaf->hdr.count); entry++, i++) {
+               if (be16_to_cpu(entry->nameidx) &&
+                   ((entry->flags & XFS_ATTR_LOCAL) == 0)) {
                        name_rmt = XFS_ATTR_LEAF_NAME_REMOTE(leaf, i);
                        if (name_rmt->valueblk)
                                count++;
@@ -3027,17 +2933,14 @@ xfs_attr_leaf_inactive(xfs_trans_t **trans, xfs_inode_t *dp, xfs_dabuf_t *bp)
         */
        lp = list;
        entry = &leaf->entries[0];
-       for (i = 0; i < INT_GET(leaf->hdr.count, ARCH_CONVERT); entry++, i++) {
-               if (   INT_GET(entry->nameidx, ARCH_CONVERT)
-                   && ((entry->flags & XFS_ATTR_LOCAL) == 0)) {
+       for (i = 0; i < be16_to_cpu(leaf->hdr.count); entry++, i++) {
+               if (be16_to_cpu(entry->nameidx) &&
+                   ((entry->flags & XFS_ATTR_LOCAL) == 0)) {
                        name_rmt = XFS_ATTR_LEAF_NAME_REMOTE(leaf, i);
                        if (name_rmt->valueblk) {
-                               /* both on-disk, don't endian flip twice */
-                               lp->valueblk = name_rmt->valueblk;
-                               INT_SET(lp->valuelen, ARCH_CONVERT,
-                                               XFS_B_TO_FSB(dp->i_mount,
-                                                   INT_GET(name_rmt->valuelen,
-                                                             ARCH_CONVERT)));
+                               lp->valueblk = be32_to_cpu(name_rmt->valueblk);
+                               lp->valuelen = XFS_B_TO_FSB(dp->i_mount,
+                                                   be32_to_cpu(name_rmt->valuelen));
                                lp++;
                        }
                }
@@ -3050,10 +2953,8 @@ xfs_attr_leaf_inactive(xfs_trans_t **trans, xfs_inode_t *dp, xfs_dabuf_t *bp)
        error = 0;
        for (lp = list, i = 0; i < count; i++, lp++) {
                tmp = xfs_attr_leaf_freextent(trans, dp,
-                                                    INT_GET(lp->valueblk,
-                                                               ARCH_CONVERT),
-                                                    INT_GET(lp->valuelen,
-                                                               ARCH_CONVERT));
+                               lp->valueblk, lp->valuelen);
+
                if (error == 0)
                        error = tmp;    /* save only the 1st errno */
        }
index 541e34109bb9834158d0204ef4763f74211553df..51c3ee156b2fdf787399710ce5b280007ff0655c 100644 (file)
@@ -73,39 +73,39 @@ struct xfs_trans;
 #define XFS_ATTR_LEAF_MAPSIZE  3       /* how many freespace slots */
 
 typedef struct xfs_attr_leaf_map {     /* RLE map of free bytes */
-       __uint16_t      base;           /* base of free region */
-       __uint16_t      size;           /* length of free region */
+       __be16  base;                     /* base of free region */
+       __be16  size;                     /* length of free region */
 } xfs_attr_leaf_map_t;
 
 typedef struct xfs_attr_leaf_hdr {     /* constant-structure header block */
        xfs_da_blkinfo_t info;          /* block type, links, etc. */
-       __uint16_t      count;          /* count of active leaf_entry's */
-       __uint16_t      usedbytes;      /* num bytes of names/values stored */
-       __uint16_t      firstused;      /* first used byte in name area */
-       __uint8_t       holes;          /* != 0 if blk needs compaction */
-       __uint8_t       pad1;
+       __be16  count;                  /* count of active leaf_entry's */
+       __be16  usedbytes;              /* num bytes of names/values stored */
+       __be16  firstused;              /* first used byte in name area */
+       __u8    holes;                  /* != 0 if blk needs compaction */
+       __u8    pad1;
        xfs_attr_leaf_map_t freemap[XFS_ATTR_LEAF_MAPSIZE];
                                        /* N largest free regions */
 } xfs_attr_leaf_hdr_t;
 
 typedef struct xfs_attr_leaf_entry {   /* sorted on key, not name */
-       xfs_dahash_t    hashval;        /* hash value of name */
-       __uint16_t      nameidx;        /* index into buffer of name/value */
-       __uint8_t       flags;          /* LOCAL/ROOT/SECURE/INCOMPLETE flag */
-       __uint8_t       pad2;           /* unused pad byte */
+       __be32  hashval;                /* hash value of name */
+       __be16  nameidx;                /* index into buffer of name/value */
+       __u8    flags;                  /* LOCAL/ROOT/SECURE/INCOMPLETE flag */
+       __u8    pad2;                   /* unused pad byte */
 } xfs_attr_leaf_entry_t;
 
 typedef struct xfs_attr_leaf_name_local {
-       __uint16_t      valuelen;       /* number of bytes in value */
-       __uint8_t       namelen;        /* length of name bytes */
-       __uint8_t       nameval[1];     /* name/value bytes */
+       __be16  valuelen;               /* number of bytes in value */
+       __u8    namelen;                /* length of name bytes */
+       __u8    nameval[1];             /* name/value bytes */
 } xfs_attr_leaf_name_local_t;
 
 typedef struct xfs_attr_leaf_name_remote {
-       xfs_dablk_t     valueblk;       /* block number of value bytes */
-       __uint32_t      valuelen;       /* number of bytes in value */
-       __uint8_t       namelen;        /* length of name bytes */
-       __uint8_t       name[1];        /* name bytes */
+       __be32  valueblk;               /* block number of value bytes */
+       __be32  valuelen;               /* number of bytes in value */
+       __u8    namelen;                /* length of name bytes */
+       __u8    name[1];                /* name bytes */
 } xfs_attr_leaf_name_remote_t;
 
 typedef struct xfs_attr_leafblock {
@@ -143,8 +143,8 @@ typedef struct xfs_attr_leafblock {
 static inline xfs_attr_leaf_name_remote_t *
 xfs_attr_leaf_name_remote(xfs_attr_leafblock_t *leafp, int idx)
 {
-       return (xfs_attr_leaf_name_remote_t *) &((char *)
-               (leafp))[INT_GET((leafp)->entries[idx].nameidx, ARCH_CONVERT)];
+       return (xfs_attr_leaf_name_remote_t *)
+               &((char *)leafp)[be16_to_cpu(leafp->entries[idx].nameidx)];
 }
 
 #define XFS_ATTR_LEAF_NAME_LOCAL(leafp,idx)    \
@@ -152,16 +152,15 @@ xfs_attr_leaf_name_remote(xfs_attr_leafblock_t *leafp, int idx)
 static inline xfs_attr_leaf_name_local_t *
 xfs_attr_leaf_name_local(xfs_attr_leafblock_t *leafp, int idx)
 {
-       return (xfs_attr_leaf_name_local_t *) &((char *)
-               (leafp))[INT_GET((leafp)->entries[idx].nameidx, ARCH_CONVERT)];
+       return (xfs_attr_leaf_name_local_t *)
+               &((char *)leafp)[be16_to_cpu(leafp->entries[idx].nameidx)];
 }
 
 #define XFS_ATTR_LEAF_NAME(leafp,idx)          \
        xfs_attr_leaf_name(leafp,idx)
 static inline char *xfs_attr_leaf_name(xfs_attr_leafblock_t *leafp, int idx)
 {
-       return (&((char *)
-               (leafp))[INT_GET((leafp)->entries[idx].nameidx, ARCH_CONVERT)]);
+       return &((char *)leafp)[be16_to_cpu(leafp->entries[idx].nameidx)];
 }
 
 /*
index ffed6ca81a52a9b2152ee147952f17e6a47c1a43..f67f917803b1d2d5efdb764647f9e9be6026ec04 100644 (file)
@@ -32,8 +32,8 @@ struct xfs_inode;
  */
 typedef struct xfs_attr_shortform {
        struct xfs_attr_sf_hdr {        /* constant-structure header block */
-               __uint16_t totsize;     /* total bytes in shortform list */
-               __uint8_t count;        /* count of active entries */
+               __be16  totsize;        /* total bytes in shortform list */
+               __u8    count;  /* count of active entries */
        } hdr;
        struct xfs_attr_sf_entry {
                __uint8_t namelen;      /* actual length of name (no NULL) */
@@ -66,8 +66,8 @@ typedef struct xfs_attr_sf_sort {
 #define XFS_ATTR_SF_NEXTENTRY(sfep)            /* next entry in struct */ \
        ((xfs_attr_sf_entry_t *)((char *)(sfep) + XFS_ATTR_SF_ENTSIZE(sfep)))
 #define XFS_ATTR_SF_TOTSIZE(dp)                        /* total space in use */ \
-       (INT_GET(((xfs_attr_shortform_t *)      \
-               ((dp)->i_afp->if_u1.if_data))->hdr.totsize, ARCH_CONVERT))
+       (be16_to_cpu(((xfs_attr_shortform_t *)  \
+               ((dp)->i_afp->if_u1.if_data))->hdr.totsize))
 
 #if defined(XFS_ATTR_TRACE)
 /*
index 70625e577c70b7421ad18a7e180f02962c679952..2d702e4a74a359235cc622c08d8ff64477d7a60c 100644 (file)
@@ -89,7 +89,7 @@ xfs_bmap_add_attrfork_local(
        int                     *flags);        /* inode logging flags */
 
 /*
- * Called by xfs_bmapi to update extent list structure and the btree
+ * Called by xfs_bmapi to update file extent records and the btree
  * after allocating space (or doing a delayed allocation).
  */
 STATIC int                             /* error */
@@ -97,7 +97,7 @@ xfs_bmap_add_extent(
        xfs_inode_t             *ip,    /* incore inode pointer */
        xfs_extnum_t            idx,    /* extent number to update/insert */
        xfs_btree_cur_t         **curp, /* if *curp is null, not a btree */
-       xfs_bmbt_irec_t         *new,   /* new data to put in extent list */
+       xfs_bmbt_irec_t         *new,   /* new data to add to file extents */
        xfs_fsblock_t           *first, /* pointer to firstblock variable */
        xfs_bmap_free_t         *flist, /* list of extents to be freed */
        int                     *logflagsp, /* inode logging flags */
@@ -113,7 +113,7 @@ xfs_bmap_add_extent_delay_real(
        xfs_inode_t             *ip,    /* incore inode pointer */
        xfs_extnum_t            idx,    /* extent number to update/insert */
        xfs_btree_cur_t         **curp, /* if *curp is null, not a btree */
-       xfs_bmbt_irec_t         *new,   /* new data to put in extent list */
+       xfs_bmbt_irec_t         *new,   /* new data to add to file extents */
        xfs_filblks_t           *dnew,  /* new delayed-alloc indirect blocks */
        xfs_fsblock_t           *first, /* pointer to firstblock variable */
        xfs_bmap_free_t         *flist, /* list of extents to be freed */
@@ -129,7 +129,7 @@ xfs_bmap_add_extent_hole_delay(
        xfs_inode_t             *ip,    /* incore inode pointer */
        xfs_extnum_t            idx,    /* extent number to update/insert */
        xfs_btree_cur_t         *cur,   /* if null, not a btree */
-       xfs_bmbt_irec_t         *new,   /* new data to put in extent list */
+       xfs_bmbt_irec_t         *new,   /* new data to add to file extents */
        int                     *logflagsp,/* inode logging flags */
        int                     rsvd);  /* OK to allocate reserved blocks */
 
@@ -142,7 +142,7 @@ xfs_bmap_add_extent_hole_real(
        xfs_inode_t             *ip,    /* incore inode pointer */
        xfs_extnum_t            idx,    /* extent number to update/insert */
        xfs_btree_cur_t         *cur,   /* if null, not a btree */
-       xfs_bmbt_irec_t         *new,   /* new data to put in extent list */
+       xfs_bmbt_irec_t         *new,   /* new data to add to file extents */
        int                     *logflagsp, /* inode logging flags */
        int                     whichfork); /* data or attr fork */
 
@@ -155,7 +155,7 @@ xfs_bmap_add_extent_unwritten_real(
        xfs_inode_t             *ip,    /* incore inode pointer */
        xfs_extnum_t            idx,    /* extent number to update/insert */
        xfs_btree_cur_t         **curp, /* if *curp is null, not a btree */
-       xfs_bmbt_irec_t         *new,   /* new data to put in extent list */
+       xfs_bmbt_irec_t         *new,   /* new data to add to file extents */
        int                     *logflagsp); /* inode logging flags */
 
 /*
@@ -169,7 +169,7 @@ xfs_bmap_alloc(
 /*
  * Transform a btree format file with only one leaf node, where the
  * extents list will fit in the inode, into an extents format file.
- * Since the extent list is already in-core, all we have to do is
+ * Since the file extents are already in-core, all we have to do is
  * give up the space for the btree root and pitch the leaf block.
  */
 STATIC int                             /* error */
@@ -191,7 +191,7 @@ xfs_bmap_check_extents(
 #endif
 
 /*
- * Called by xfs_bmapi to update extent list structure and the btree
+ * Called by xfs_bmapi to update file extent records and the btree
  * after removing space (or undoing a delayed allocation).
  */
 STATIC int                             /* error */
@@ -201,7 +201,7 @@ xfs_bmap_del_extent(
        xfs_extnum_t            idx,    /* extent number to update/insert */
        xfs_bmap_free_t         *flist, /* list of extents to be freed */
        xfs_btree_cur_t         *cur,   /* if null, not a btree */
-       xfs_bmbt_irec_t         *new,   /* new data to put in extent list */
+       xfs_bmbt_irec_t         *new,   /* new data to add to file extents */
        int                     *logflagsp,/* inode logging flags */
        int                     whichfork, /* data or attr fork */
        int                     rsvd);   /* OK to allocate reserved blocks */
@@ -216,18 +216,6 @@ xfs_bmap_del_free(
        xfs_bmap_free_item_t    *prev,  /* previous item on list, if any */
        xfs_bmap_free_item_t    *free); /* list item to be freed */
 
-/*
- * Remove count entries from the extents array for inode "ip", starting
- * at index "idx".  Copies the remaining items down over the deleted ones,
- * and gives back the excess memory.
- */
-STATIC void
-xfs_bmap_delete_exlist(
-       xfs_inode_t     *ip,            /* incode inode pointer */
-       xfs_extnum_t    idx,            /* starting delete index */
-       xfs_extnum_t    count,          /* count of items to delete */
-       int             whichfork);     /* data or attr fork */
-
 /*
  * Convert an extents-format file into a btree-format file.
  * The new file will have a root block (in the inode) and a single child block.
@@ -243,18 +231,6 @@ xfs_bmap_extents_to_btree(
        int                     *logflagsp,     /* inode logging flags */
        int                     whichfork);     /* data or attr fork */
 
-/*
- * Insert new item(s) in the extent list for inode "ip".
- * Count new items are inserted at offset idx.
- */
-STATIC void
-xfs_bmap_insert_exlist(
-       xfs_inode_t     *ip,            /* incore inode pointer */
-       xfs_extnum_t    idx,            /* starting index of new items */
-       xfs_extnum_t    count,          /* number of inserted items */
-       xfs_bmbt_irec_t *new,           /* items to insert */
-       int             whichfork);     /* data or attr fork */
-
 /*
  * Convert a local file to an extents file.
  * This code is sort of bogus, since the file data needs to get
@@ -316,7 +292,7 @@ xfs_bmap_trace_addentry(
        int             whichfork);     /* data or attr fork */
 
 /*
- * Add bmap trace entry prior to a call to xfs_bmap_delete_exlist.
+ * Add bmap trace entry prior to a call to xfs_iext_remove.
  */
 STATIC void
 xfs_bmap_trace_delete(
@@ -328,7 +304,7 @@ xfs_bmap_trace_delete(
        int             whichfork);     /* data or attr fork */
 
 /*
- * Add bmap trace entry prior to a call to xfs_bmap_insert_exlist, or
+ * Add bmap trace entry prior to a call to xfs_iext_insert, or
  * reading in the extents list from the disk (in the btree).
  */
 STATIC void
@@ -343,7 +319,7 @@ xfs_bmap_trace_insert(
        int             whichfork);     /* data or attr fork */
 
 /*
- * Add bmap trace entry after updating an extent list entry in place.
+ * Add bmap trace entry after updating an extent record in place.
  */
 STATIC void
 xfs_bmap_trace_post_update(
@@ -354,7 +330,7 @@ xfs_bmap_trace_post_update(
        int             whichfork);     /* data or attr fork */
 
 /*
- * Add bmap trace entry prior to updating an extent list entry in place.
+ * Add bmap trace entry prior to updating an extent record in place.
  */
 STATIC void
 xfs_bmap_trace_pre_update(
@@ -413,19 +389,24 @@ STATIC int
 xfs_bmap_count_tree(
        xfs_mount_t     *mp,
        xfs_trans_t     *tp,
+       xfs_ifork_t     *ifp,
        xfs_fsblock_t   blockno,
        int             levelin,
        int             *count);
 
 STATIC int
 xfs_bmap_count_leaves(
-       xfs_bmbt_rec_t          *frp,
+       xfs_ifork_t             *ifp,
+       xfs_extnum_t            idx,
        int                     numrecs,
        int                     *count);
 
 STATIC int
 xfs_bmap_disk_count_leaves(
-       xfs_bmbt_rec_t          *frp,
+       xfs_ifork_t             *ifp,
+       xfs_mount_t             *mp,
+       xfs_extnum_t            idx,
+       xfs_bmbt_block_t        *block,
        int                     numrecs,
        int                     *count);
 
@@ -537,7 +518,7 @@ xfs_bmap_add_attrfork_local(
 }
 
 /*
- * Called by xfs_bmapi to update extent list structure and the btree
+ * Called by xfs_bmapi to update file extent records and the btree
  * after allocating space (or doing a delayed allocation).
  */
 STATIC int                             /* error */
@@ -545,7 +526,7 @@ xfs_bmap_add_extent(
        xfs_inode_t             *ip,    /* incore inode pointer */
        xfs_extnum_t            idx,    /* extent number to update/insert */
        xfs_btree_cur_t         **curp, /* if *curp is null, not a btree */
-       xfs_bmbt_irec_t         *new,   /* new data to put in extent list */
+       xfs_bmbt_irec_t         *new,   /* new data to add to file extents */
        xfs_fsblock_t           *first, /* pointer to&n