xfs: suppress spurious uninitialised var warning in xfs_bmapi()
[safe/jmp/linux-2.6] / fs / xfs / xfs_attr_leaf.c
index 6c323f8..52519a2 100644 (file)
@@ -42,6 +42,7 @@
 #include "xfs_attr.h"
 #include "xfs_attr_leaf.h"
 #include "xfs_error.h"
+#include "xfs_trace.h"
 
 /*
  * xfs_attr_leaf.c
@@ -98,7 +99,7 @@ STATIC int xfs_attr_leaf_entsize(xfs_attr_leafblock_t *leaf, int index);
  * If namespace bits don't match return 0.
  * If all match then return 1.
  */
-STATIC_INLINE int
+STATIC int
 xfs_attr_namesp_match(int arg_flags, int ondisk_flags)
 {
        return XFS_ATTR_NSP_ONDISK(ondisk_flags) == XFS_ATTR_NSP_ARGS_TO_ONDISK(arg_flags);
@@ -155,7 +156,8 @@ xfs_attr_shortform_bytesfit(xfs_inode_t *dp, int bytes)
                 * minimum offset only needs to be the space required for 
                 * the btree root.
                 */ 
-               if (!dp->i_d.di_forkoff && dp->i_df.if_bytes > mp->m_attroffset)
+               if (!dp->i_d.di_forkoff && dp->i_df.if_bytes >
+                   xfs_default_attroffset(dp))
                        dsize = XFS_BMDR_SPACE_CALC(MINDBTPTRS);
                break;
                
@@ -298,6 +300,26 @@ xfs_attr_shortform_add(xfs_da_args_t *args, int forkoff)
 }
 
 /*
+ * After the last attribute is removed revert to original inode format,
+ * making all literal area available to the data fork once more.
+ */
+STATIC void
+xfs_attr_fork_reset(
+       struct xfs_inode        *ip,
+       struct xfs_trans        *tp)
+{
+       xfs_idestroy_fork(ip, XFS_ATTR_FORK);
+       ip->i_d.di_forkoff = 0;
+       ip->i_d.di_aformat = XFS_DINODE_FMT_EXTENTS;
+
+       ASSERT(ip->i_d.di_anextents == 0);
+       ASSERT(ip->i_afp == NULL);
+
+       ip->i_df.if_ext_max = XFS_IFORK_DSIZE(ip) / sizeof(xfs_bmbt_rec_t);
+       xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
+}
+
+/*
  * Remove an attribute from the shortform attribute list structure.
  */
 int
@@ -344,22 +366,10 @@ xfs_attr_shortform_remove(xfs_da_args_t *args)
         */
        totsize -= size;
        if (totsize == sizeof(xfs_attr_sf_hdr_t) &&
-                               !(args->op_flags & XFS_DA_OP_ADDNAME) &&
-                               (mp->m_flags & XFS_MOUNT_ATTR2) &&
-                               (dp->i_d.di_format != XFS_DINODE_FMT_BTREE)) {
-               /*
-                * Last attribute now removed, revert to original
-                * inode format making all literal area available
-                * to the data fork once more.
-                */
-               xfs_idestroy_fork(dp, XFS_ATTR_FORK);
-               dp->i_d.di_forkoff = 0;
-               dp->i_d.di_aformat = XFS_DINODE_FMT_EXTENTS;
-               ASSERT(dp->i_d.di_anextents == 0);
-               ASSERT(dp->i_afp == NULL);
-               dp->i_df.if_ext_max =
-                       XFS_IFORK_DSIZE(dp) / (uint)sizeof(xfs_bmbt_rec_t);
-               xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE);
+           (mp->m_flags & XFS_MOUNT_ATTR2) &&
+           (dp->i_d.di_format != XFS_DINODE_FMT_BTREE) &&
+           !(args->op_flags & XFS_DA_OP_ADDNAME)) {
+               xfs_attr_fork_reset(dp, args->trans);
        } else {
                xfs_idata_realloc(dp, -size, XFS_ATTR_FORK);
                dp->i_d.di_forkoff = xfs_attr_shortform_bytesfit(dp, totsize);
@@ -511,11 +521,11 @@ xfs_attr_shortform_to_leaf(xfs_da_args_t *args)
 
        sfe = &sf->list[0];
        for (i = 0; i < sf->hdr.count; i++) {
-               nargs.name = (char *)sfe->nameval;
+               nargs.name = sfe->nameval;
                nargs.namelen = sfe->namelen;
-               nargs.value = (char *)&sfe->nameval[nargs.namelen];
+               nargs.value = &sfe->nameval[nargs.namelen];
                nargs.valuelen = sfe->valuelen;
-               nargs.hashval = xfs_da_hashname((char *)sfe->nameval,
+               nargs.hashval = xfs_da_hashname(sfe->nameval,
                                                sfe->namelen);
                nargs.flags = XFS_ATTR_NSP_ONDISK_TO_ARGS(sfe->flags);
                error = xfs_attr_leaf_lookup_int(bp, &nargs); /* set a->index */
@@ -585,7 +595,7 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context)
        cursor = context->cursor;
        ASSERT(cursor != NULL);
 
-       xfs_attr_trace_l_c("sf start", context);
+       trace_xfs_attr_list_sf(context);
 
        /*
         * If the buffer is large enough and the cursor is at the start,
@@ -602,10 +612,10 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context)
                for (i = 0, sfe = &sf->list[0]; i < sf->hdr.count; i++) {
                        error = context->put_listent(context,
                                           sfe->flags,
-                                          (char *)sfe->nameval,
+                                          sfe->nameval,
                                           (int)sfe->namelen,
                                           (int)sfe->valuelen,
-                                          (char*)&sfe->nameval[sfe->namelen]);
+                                          &sfe->nameval[sfe->namelen]);
 
                        /*
                         * Either search callback finished early or
@@ -618,7 +628,7 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context)
                                return error;
                        sfe = XFS_ATTR_SF_NEXTENTRY(sfe);
                }
-               xfs_attr_trace_l_c("sf big-gulp", context);
+               trace_xfs_attr_list_sf_all(context);
                return(0);
        }
 
@@ -644,14 +654,13 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context)
                        XFS_CORRUPTION_ERROR("xfs_attr_shortform_list",
                                             XFS_ERRLEVEL_LOW,
                                             context->dp->i_mount, sfe);
-                       xfs_attr_trace_l_c("sf corrupted", context);
                        kmem_free(sbuf);
                        return XFS_ERROR(EFSCORRUPTED);
                }
 
                sbp->entno = i;
-               sbp->hash = xfs_da_hashname((char *)sfe->nameval, sfe->namelen);
-               sbp->name = (char *)sfe->nameval;
+               sbp->hash = xfs_da_hashname(sfe->nameval, sfe->namelen);
+               sbp->name = sfe->nameval;
                sbp->namelen = sfe->namelen;
                /* These are bytes, and both on-disk, don't endian-flip */
                sbp->valuelen = sfe->valuelen;
@@ -684,7 +693,6 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context)
        }
        if (i == nsbuf) {
                kmem_free(sbuf);
-               xfs_attr_trace_l_c("blk end", context);
                return(0);
        }
 
@@ -710,7 +718,6 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context)
        }
 
        kmem_free(sbuf);
-       xfs_attr_trace_l_c("sf E-O-F", context);
        return(0);
 }
 
@@ -786,20 +793,7 @@ xfs_attr_leaf_to_shortform(xfs_dabuf_t *bp, xfs_da_args_t *args, int forkoff)
        if (forkoff == -1) {
                ASSERT(dp->i_mount->m_flags & XFS_MOUNT_ATTR2);
                ASSERT(dp->i_d.di_format != XFS_DINODE_FMT_BTREE);
-
-               /*
-                * Last attribute was removed, revert to original
-                * inode format making all literal area available
-                * to the data fork once more.
-                */
-               xfs_idestroy_fork(dp, XFS_ATTR_FORK);
-               dp->i_d.di_forkoff = 0;
-               dp->i_d.di_aformat = XFS_DINODE_FMT_EXTENTS;
-               ASSERT(dp->i_d.di_anextents == 0);
-               ASSERT(dp->i_afp == NULL);
-               dp->i_df.if_ext_max =
-                       XFS_IFORK_DSIZE(dp) / (uint)sizeof(xfs_bmbt_rec_t);
-               xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE);
+               xfs_attr_fork_reset(dp, args->trans);
                goto out;
        }
 
@@ -824,9 +818,9 @@ xfs_attr_leaf_to_shortform(xfs_dabuf_t *bp, xfs_da_args_t *args, int forkoff)
                        continue;
                ASSERT(entry->flags & XFS_ATTR_LOCAL);
                name_loc = xfs_attr_leaf_name_local(leaf, i);
-               nargs.name = (char *)name_loc->nameval;
+               nargs.name = name_loc->nameval;
                nargs.namelen = name_loc->namelen;
-               nargs.value = (char *)&name_loc->nameval[nargs.namelen];
+               nargs.value = &name_loc->nameval[nargs.namelen];
                nargs.valuelen = be16_to_cpu(name_loc->valuelen);
                nargs.hashval = be32_to_cpu(entry->hashval);
                nargs.flags = XFS_ATTR_NSP_ONDISK_TO_ARGS(entry->flags);
@@ -2327,7 +2321,7 @@ xfs_attr_leaf_list_int(xfs_dabuf_t *bp, xfs_attr_list_context_t *context)
        cursor = context->cursor;
        cursor->initted = 1;
 
-       xfs_attr_trace_l_cl("blk start", context, leaf);
+       trace_xfs_attr_list_leaf(context);
 
        /*
         * Re-find our place in the leaf block if this is a new syscall.
@@ -2348,7 +2342,7 @@ xfs_attr_leaf_list_int(xfs_dabuf_t *bp, xfs_attr_list_context_t *context)
                        }
                }
                if (i == be16_to_cpu(leaf->hdr.count)) {
-                       xfs_attr_trace_l_c("not found", context);
+                       trace_xfs_attr_list_notfound(context);
                        return(0);
                }
        } else {
@@ -2376,10 +2370,10 @@ xfs_attr_leaf_list_int(xfs_dabuf_t *bp, xfs_attr_list_context_t *context)
 
                        retval = context->put_listent(context,
                                                entry->flags,
-                                               (char *)name_loc->nameval,
+                                               name_loc->nameval,
                                                (int)name_loc->namelen,
                                                be16_to_cpu(name_loc->valuelen),
-                                               (char *)&name_loc->nameval[name_loc->namelen]);
+                                               &name_loc->nameval[name_loc->namelen]);
                        if (retval)
                                return retval;
                } else {
@@ -2403,15 +2397,15 @@ xfs_attr_leaf_list_int(xfs_dabuf_t *bp, xfs_attr_list_context_t *context)
                                        return retval;
                                retval = context->put_listent(context,
                                                entry->flags,
-                                               (char *)name_rmt->name,
+                                               name_rmt->name,
                                                (int)name_rmt->namelen,
                                                valuelen,
-                                               (char*)args.value);
+                                               args.value);
                                kmem_free(args.value);
                        } else {
                                retval = context->put_listent(context,
                                                entry->flags,
-                                               (char *)name_rmt->name,
+                                               name_rmt->name,
                                                (int)name_rmt->namelen,
                                                valuelen,
                                                NULL);
@@ -2423,7 +2417,7 @@ xfs_attr_leaf_list_int(xfs_dabuf_t *bp, xfs_attr_list_context_t *context)
                        break;
                cursor->offset++;
        }
-       xfs_attr_trace_l_cl("blk end", context, leaf);
+       trace_xfs_attr_list_leaf_end(context);
        return(retval);
 }