linux 2.6.16.38 w/ vs2.0.3-rc1
[linux-2.6.git] / fs / xfs / xfs_dir2_node.c
index ec42931..641f863 100644 (file)
@@ -1,61 +1,39 @@
 /*
- * Copyright (c) 2000-2004 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/
- */
-
-/*
- * xfs_dir2_node.c
- * XFS directory implementation, version 2, node form files
- * See data structures in xfs_dir2_node.h and xfs_da_btree.h.
+ * 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
  */
-
 #include "xfs.h"
-
-#include "xfs_macros.h"
+#include "xfs_fs.h"
 #include "xfs_types.h"
-#include "xfs_inum.h"
 #include "xfs_log.h"
+#include "xfs_inum.h"
 #include "xfs_trans.h"
 #include "xfs_sb.h"
 #include "xfs_dir.h"
 #include "xfs_dir2.h"
 #include "xfs_dmapi.h"
 #include "xfs_mount.h"
+#include "xfs_da_btree.h"
 #include "xfs_bmap_btree.h"
-#include "xfs_attr_sf.h"
 #include "xfs_dir_sf.h"
 #include "xfs_dir2_sf.h"
+#include "xfs_attr_sf.h"
 #include "xfs_dinode.h"
 #include "xfs_inode.h"
 #include "xfs_bmap.h"
-#include "xfs_da_btree.h"
 #include "xfs_dir2_data.h"
 #include "xfs_dir2_leaf.h"
 #include "xfs_dir2_block.h"
@@ -172,14 +150,14 @@ xfs_dir2_leaf_to_node(
         * Initialize the freespace block header.
         */
        INT_SET(free->hdr.magic, ARCH_CONVERT, XFS_DIR2_FREE_MAGIC);
-       INT_ZERO(free->hdr.firstdb, ARCH_CONVERT);
+       free->hdr.firstdb = 0;
        ASSERT(INT_GET(ltp->bestcount, ARCH_CONVERT) <= (uint)dp->i_d.di_size / mp->m_dirblksize);
        INT_COPY(free->hdr.nvalid, ltp->bestcount, ARCH_CONVERT);
        /*
         * Copy freespace entries from the leaf block to the new block.
         * Count active entries.
         */
-       for (i = n = 0, from = XFS_DIR2_LEAF_BESTS_P_ARCH(ltp, ARCH_CONVERT), to = free->bests;
+       for (i = n = 0, from = XFS_DIR2_LEAF_BESTS_P(ltp), to = free->bests;
             i < INT_GET(ltp->bestcount, ARCH_CONVERT); i++, from++, to++) {
                if ((off = INT_GET(*from, ARCH_CONVERT)) != NULLDATAOFF)
                        n++;
@@ -240,7 +218,7 @@ xfs_dir2_leafn_add(
         */
 
        if (INT_GET(leaf->hdr.count, ARCH_CONVERT) == XFS_DIR2_MAX_LEAF_ENTS(mp)) {
-               if (INT_ISZERO(leaf->hdr.stale, ARCH_CONVERT))
+               if (!leaf->hdr.stale)
                        return XFS_ERROR(ENOSPC);
                compact = INT_GET(leaf->hdr.stale, ARCH_CONVERT) > 1;
        } else
@@ -263,14 +241,14 @@ xfs_dir2_leafn_add(
        /*
         * Set impossible logging indices for this case.
         */
-       else if (!INT_ISZERO(leaf->hdr.stale, ARCH_CONVERT)) {
+       else if (leaf->hdr.stale) {
                lfloglow = INT_GET(leaf->hdr.count, ARCH_CONVERT);
                lfloghigh = -1;
        }
        /*
         * No stale entries, just insert a space for the new entry.
         */
-       if (INT_ISZERO(leaf->hdr.stale, ARCH_CONVERT)) {
+       if (!leaf->hdr.stale) {
                lep = &leaf->ents[index];
                if (index < INT_GET(leaf->hdr.count, ARCH_CONVERT))
                        memmove(lep + 1, lep,
@@ -403,7 +381,7 @@ xfs_dir2_leafn_lasthash(
        ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC);
        if (count)
                *count = INT_GET(leaf->hdr.count, ARCH_CONVERT);
-       if (INT_ISZERO(leaf->hdr.count, ARCH_CONVERT))
+       if (!leaf->hdr.count)
                return 0;
        return INT_GET(leaf->ents[INT_GET(leaf->hdr.count, ARCH_CONVERT) - 1].hashval, ARCH_CONVERT);
 }
@@ -690,7 +668,7 @@ xfs_dir2_leafn_moveents(
         * If the source has stale leaves, count the ones in the copy range
         * so we can update the header correctly.
         */
-       if (!INT_ISZERO(leaf_s->hdr.stale, ARCH_CONVERT)) {
+       if (leaf_s->hdr.stale) {
                int     i;                      /* temp leaf index */
 
                for (i = start_s, stale = 0; i < start_s + count; i++) {
@@ -1020,7 +998,7 @@ xfs_dir2_leafn_remove(
                         * If there are no useful entries left in the block,
                         * get rid of the block if we can.
                         */
-                       if (INT_ISZERO(free->hdr.nused, ARCH_CONVERT)) {
+                       if (!free->hdr.nused) {
                                error = xfs_dir2_shrink_inode(args, fdb, fbp);
                                if (error == 0) {
                                        fbp = NULL;
@@ -1182,7 +1160,7 @@ xfs_dir2_leafn_toosmall(
                 * Make altpath point to the block we want to keep and
                 * path point to the block we want to drop (this one).
                 */
-               forward = !INT_ISZERO(info->forw, ARCH_CONVERT);
+               forward = info->forw;
                memcpy(&state->altpath, &state->path, sizeof(state->path));
                error = xfs_da_path_shift(state, &state->altpath, forward, 0,
                        &rval);
@@ -1634,8 +1612,8 @@ xfs_dir2_node_addname_int(
                        INT_SET(free->hdr.firstdb, ARCH_CONVERT,
                                (fbno - XFS_DIR2_FREE_FIRSTDB(mp)) *
                                XFS_DIR2_MAX_FREE_BESTS(mp));
-                       INT_ZERO(free->hdr.nvalid, ARCH_CONVERT);
-                       INT_ZERO(free->hdr.nused, ARCH_CONVERT);
+                       free->hdr.nvalid = 0;
+                       free->hdr.nused = 0;
                } else {
                        free = fbp->data;
                        ASSERT(INT_GET(free->hdr.magic, ARCH_CONVERT) == XFS_DIR2_FREE_MAGIC);