]> err.no Git - linux-2.6/blobdiff - fs/xfs/xfs_attr_leaf.c
Merge HEAD from oss.sgi.com:/oss/git/linux-2.6.git
[linux-2.6] / fs / xfs / xfs_attr_leaf.c
index 50598b121683e09e5321768dd0152d48520fe4ef..fe91eac4e2a7b1919228ec9f063a2946e37ec908 100644 (file)
@@ -1,46 +1,26 @@
 /*
- * 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/
- */
-/*
- * xfs_attr_leaf.c
- *
- * GROT: figure out how to recover gracefully when bmap returns ENOSPC.
+ * 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_bit.h"
 #include "xfs_log.h"
+#include "xfs_inum.h"
 #include "xfs_trans.h"
 #include "xfs_sb.h"
 #include "xfs_ag.h"
 #include "xfs_dir2.h"
 #include "xfs_dmapi.h"
 #include "xfs_mount.h"
-#include "xfs_alloc_btree.h"
+#include "xfs_da_btree.h"
 #include "xfs_bmap_btree.h"
+#include "xfs_alloc_btree.h"
 #include "xfs_ialloc_btree.h"
 #include "xfs_alloc.h"
 #include "xfs_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_item.h"
 #include "xfs_inode.h"
+#include "xfs_inode_item.h"
 #include "xfs_bmap.h"
-#include "xfs_da_btree.h"
 #include "xfs_attr.h"
 #include "xfs_attr_leaf.h"
 #include "xfs_error.h"
-#include "xfs_bit.h"
 
 /*
  * xfs_attr_leaf.c
@@ -138,12 +117,6 @@ xfs_attr_shortform_bytesfit(xfs_inode_t *dp, int bytes)
        int maxforkoff; /* upper limit on valid forkoff locations */
        xfs_mount_t *mp = dp->i_mount;
 
-       if (unlikely(mp->m_flags & XFS_MOUNT_COMPAT_ATTR)) {
-               if (bytes <= XFS_IFORK_ASIZE(dp))
-                       return mp->m_attroffset >> 3;
-               return 0;
-       }
-
        offset = (XFS_LITINO(mp) - bytes) >> 3; /* rounded down */
 
        switch (dp->i_d.di_format) {
@@ -155,6 +128,12 @@ xfs_attr_shortform_bytesfit(xfs_inode_t *dp, int bytes)
                return (offset >= minforkoff) ? minforkoff : 0;
        }
 
+       if (!(mp->m_flags & XFS_MOUNT_ATTR2)) {
+               if (bytes <= XFS_IFORK_ASIZE(dp))
+                       return mp->m_attroffset >> 3;
+               return 0;
+       }
+
        /* data fork btree root can have at least this many key/ptr pairs */
        minforkoff = MAX(dp->i_df.if_bytes, XFS_BMDR_SPACE_CALC(MINDBTPTRS));
        minforkoff = roundup(minforkoff, 8) >> 3;
@@ -178,7 +157,7 @@ xfs_sbversion_add_attr2(xfs_mount_t *mp, xfs_trans_t *tp)
 {
        unsigned long s;
 
-       if (!(mp->m_flags & XFS_MOUNT_COMPAT_ATTR) &&
+       if ((mp->m_flags & XFS_MOUNT_ATTR2) &&
            !(XFS_SB_VERSION_HASATTR2(&mp->m_sb))) {
                s = XFS_SB_LOCK(mp);
                if (!XFS_SB_VERSION_HASATTR2(&mp->m_sb)) {
@@ -331,7 +310,8 @@ xfs_attr_shortform_remove(xfs_da_args_t *args)
         * Fix up the start offset of the attribute fork
         */
        totsize -= size;
-       if (totsize == sizeof(xfs_attr_sf_hdr_t) && !args->addname) {
+       if (totsize == sizeof(xfs_attr_sf_hdr_t) && !args->addname &&
+           (mp->m_flags & XFS_MOUNT_ATTR2)) {
                /*
                 * Last attribute now removed, revert to original
                 * inode format making all literal area available
@@ -349,7 +329,8 @@ xfs_attr_shortform_remove(xfs_da_args_t *args)
                xfs_idata_realloc(dp, -size, XFS_ATTR_FORK);
                dp->i_d.di_forkoff = xfs_attr_shortform_bytesfit(dp, totsize);
                ASSERT(dp->i_d.di_forkoff);
-               ASSERT(totsize > sizeof(xfs_attr_sf_hdr_t) || args->addname);
+               ASSERT(totsize > sizeof(xfs_attr_sf_hdr_t) || args->addname ||
+                       !(mp->m_flags & XFS_MOUNT_ATTR2));
                dp->i_afp->if_ext_max =
                        XFS_IFORK_ASIZE(dp) / (uint)sizeof(xfs_bmbt_rec_t);
                dp->i_df.if_ext_max =
@@ -670,7 +651,7 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context)
        /*
         * Sort the entries on hash then entno.
         */
-       qsort(sbuf, nsbuf, sizeof(*sbuf), xfs_attr_shortform_compare);
+       xfs_sort(sbuf, nsbuf, sizeof(*sbuf), xfs_attr_shortform_compare);
 
        /*
         * Re-find our place IN THE SORTED LIST.
@@ -758,7 +739,8 @@ xfs_attr_shortform_allfit(xfs_dabuf_t *bp, xfs_inode_t *dp)
                                + name_loc->namelen
                                + INT_GET(name_loc->valuelen, ARCH_CONVERT);
        }
-       if (bytes == sizeof(struct xfs_attr_sf_hdr))
+       if ((dp->i_mount->m_flags & XFS_MOUNT_ATTR2) &&
+           (bytes == sizeof(struct xfs_attr_sf_hdr)))
                return(-1);
        return(xfs_attr_shortform_bytesfit(dp, bytes));
 }
@@ -796,6 +778,8 @@ xfs_attr_leaf_to_shortform(xfs_dabuf_t *bp, xfs_da_args_t *args, int forkoff)
                goto out;
 
        if (forkoff == -1) {
+               ASSERT(dp->i_mount->m_flags & XFS_MOUNT_ATTR2);
+
                /*
                 * Last attribute was removed, revert to original
                 * inode format making all literal area available