static int xfs_attr_node_try_addname(struct xfs_attr_item *attr);
 STATIC int xfs_attr_node_addname_find_attr(struct xfs_attr_item *attr);
 STATIC int xfs_attr_node_remove_attr(struct xfs_attr_item *attr);
-STATIC int xfs_attr_node_hasname(xfs_da_args_t *args,
-                                struct xfs_da_state **state);
+STATIC int xfs_attr_node_lookup(struct xfs_da_args *args,
+               struct xfs_da_state *state);
 
 int
 xfs_inode_hasattr(
        return xfs_attr3_leaf_setflag(args);
 }
 
+/* Ensure the da state of an xattr deferred work item is ready to go. */
+static inline void
+xfs_attr_item_init_da_state(
+       struct xfs_attr_item    *attr)
+{
+       struct xfs_da_args      *args = attr->xattri_da_args;
+
+       if (!attr->xattri_da_state)
+               attr->xattri_da_state = xfs_da_state_alloc(args);
+       else
+               xfs_da_state_reset(attr->xattri_da_state, args);
+}
+
 /*
  * Initial setup for xfs_attr_node_removename.  Make sure the attr is there and
  * the blocks are valid.  Attr keys with remote blocks will be marked
        struct xfs_da_state             *state;
        int                             error;
 
-       error = xfs_attr_node_hasname(args, &attr->xattri_da_state);
+       xfs_attr_item_init_da_state(attr);
+       error = xfs_attr_node_lookup(args, attr->xattri_da_state);
        if (error != -EEXIST)
                goto out;
        error = 0;
 {
        struct xfs_inode        *dp = args->dp;
        struct xfs_buf          *bp = NULL;
+       struct xfs_da_state     *state;
        int                     error;
 
        if (!xfs_inode_hasattr(dp))
                return error;
        }
 
-       return xfs_attr_node_hasname(args, NULL);
+       state = xfs_da_state_alloc(args);
+       error = xfs_attr_node_lookup(args, state);
+       xfs_da_state_free(state);
+       return error;
 }
 
 static int
        return error;
 }
 
-/*
- * Return EEXIST if attr is found, or ENOATTR if not
- * statep: If not null is set to point at the found state.  Caller will
- *         be responsible for freeing the state in this case.
- */
+/* Return EEXIST if attr is found, or ENOATTR if not. */
 STATIC int
-xfs_attr_node_hasname(
+xfs_attr_node_lookup(
        struct xfs_da_args      *args,
-       struct xfs_da_state     **statep)
+       struct xfs_da_state     *state)
 {
-       struct xfs_da_state     *state;
        int                     retval, error;
 
-       state = xfs_da_state_alloc(args);
-       if (statep != NULL) {
-               ASSERT(*statep == NULL);
-               *statep = state;
-       }
-
        /*
         * Search to see if name exists, and get back a pointer to it.
         */
        error = xfs_da3_node_lookup_int(state, &retval);
        if (error)
-               retval = error;
-
-       if (!statep)
-               xfs_da_state_free(state);
+               return error;
 
        return retval;
 }
        struct xfs_da_args      *args = attr->xattri_da_args;
        int                     error;
 
-       if (attr->xattri_da_state)
-               xfs_da_state_free(attr->xattri_da_state);
-       attr->xattri_da_state = NULL;
-
        /*
         * Search to see if name already exists, and get back a pointer
         * to where it should go.
         */
-       error = xfs_attr_node_hasname(args, &attr->xattri_da_state);
+       xfs_attr_item_init_da_state(attr);
+       error = xfs_attr_node_lookup(args, attr->xattri_da_state);
        switch (error) {
        case -ENOATTR:
                if (args->op_flags & XFS_DA_OP_REPLACE)
 xfs_attr_node_get(
        struct xfs_da_args      *args)
 {
-       struct xfs_da_state     *state = NULL;
+       struct xfs_da_state     *state;
        struct xfs_da_state_blk *blk;
        int                     i;
        int                     error;
        /*
         * Search to see if name exists, and get back a pointer to it.
         */
-       error = xfs_attr_node_hasname(args, &state);
+       state = xfs_da_state_alloc(args);
+       error = xfs_attr_node_lookup(args, state);
        if (error != -EEXIST)
                goto out_release;
 
                state->path.blk[i].bp = NULL;
        }
 
-       if (state)
-               xfs_da_state_free(state);
+       xfs_da_state_free(state);
        return error;
 }