Commit 4b9879b1 authored by Dave Chinner's avatar Dave Chinner Committed by Dave Chinner

xfs: switch attr remove to xfs_attri_set_iter

Now that xfs_attri_set_iter() has initial states for removing
attributes, switch the pure attribute removal code over to using it.
This requires attrs being removed to always be marked as INCOMPLETE
before we start the removal due to the fact we look up the attr to
remove again in xfs_attr_node_remove_attr().

Note: this drops the fillstate/refillstate optimisations from
the remove path that avoid having to look up the path again after
setting the incomplete flag and removing remote attrs. Restoring
that optimisation to this path is future Dave's problem.
Signed-off-by: default avatarDave Chinner <dchinner@redhat.com>
Reviewed-by: default avatarAllison Henderson <allison.henderson@oracle.com>
Reviewed-by: default avatarDarrick J. Wong <djwong@kernel.org>
Signed-off-by: default avatarDave Chinner <david@fromorbit.com>
parent e5d5596a
...@@ -498,13 +498,11 @@ int xfs_attr_node_removename_setup( ...@@ -498,13 +498,11 @@ int xfs_attr_node_removename_setup(
ASSERT((*state)->path.blk[(*state)->path.active - 1].magic == ASSERT((*state)->path.blk[(*state)->path.active - 1].magic ==
XFS_ATTR_LEAF_MAGIC); XFS_ATTR_LEAF_MAGIC);
if (args->rmtblkno > 0) { error = xfs_attr_leaf_mark_incomplete(args, *state);
error = xfs_attr_leaf_mark_incomplete(args, *state); if (error)
if (error) goto out;
goto out; if (args->rmtblkno > 0)
error = xfs_attr_rmtval_invalidate(args); error = xfs_attr_rmtval_invalidate(args);
}
out: out:
if (error) if (error)
xfs_da_state_free(*state); xfs_da_state_free(*state);
...@@ -820,7 +818,7 @@ xfs_attr_defer_remove( ...@@ -820,7 +818,7 @@ xfs_attr_defer_remove(
if (error) if (error)
return error; return error;
new->xattri_dela_state = XFS_DAS_UNINIT; new->xattri_dela_state = xfs_attr_init_remove_state(args);
xfs_defer_add(args->trans, XFS_DEFER_OPS_TYPE_ATTR, &new->xattri_list); xfs_defer_add(args->trans, XFS_DEFER_OPS_TYPE_ATTR, &new->xattri_list);
trace_xfs_attr_defer_remove(new->xattri_dela_state, args->dp); trace_xfs_attr_defer_remove(new->xattri_dela_state, args->dp);
...@@ -1388,16 +1386,15 @@ xfs_attr_node_remove_attr( ...@@ -1388,16 +1386,15 @@ xfs_attr_node_remove_attr(
{ {
struct xfs_da_args *args = attr->xattri_da_args; struct xfs_da_args *args = attr->xattri_da_args;
struct xfs_da_state *state = NULL; struct xfs_da_state *state = NULL;
struct xfs_mount *mp = args->dp->i_mount;
int retval = 0; int retval = 0;
int error = 0; int error = 0;
/* /*
* Re-find the "old" attribute entry after any split ops. The INCOMPLETE * The attr we are removing has already been marked incomplete, so
* flag means that we will find the "old" attr, not the "new" one. * we need to set the filter appropriately to re-find the "old"
* attribute entry after any split ops.
*/ */
if (!xfs_has_larp(mp)) args->attr_filter |= XFS_ATTR_INCOMPLETE;
args->attr_filter |= XFS_ATTR_INCOMPLETE;
state = xfs_da_state_alloc(args); state = xfs_da_state_alloc(args);
state->inleaf = 0; state->inleaf = 0;
error = xfs_da3_node_lookup_int(state, &retval); error = xfs_da3_node_lookup_int(state, &retval);
......
...@@ -602,6 +602,16 @@ xfs_attr_init_add_state(struct xfs_da_args *args) ...@@ -602,6 +602,16 @@ xfs_attr_init_add_state(struct xfs_da_args *args)
return XFS_DAS_NODE_ADD; return XFS_DAS_NODE_ADD;
} }
static inline enum xfs_delattr_state
xfs_attr_init_remove_state(struct xfs_da_args *args)
{
if (xfs_attr_is_shortform(args->dp))
return XFS_DAS_SF_REMOVE;
if (xfs_attr_is_leaf(args->dp))
return XFS_DAS_LEAF_REMOVE;
return XFS_DAS_NODE_REMOVE;
}
static inline enum xfs_delattr_state static inline enum xfs_delattr_state
xfs_attr_init_replace_state(struct xfs_da_args *args) xfs_attr_init_replace_state(struct xfs_da_args *args)
{ {
......
...@@ -303,12 +303,9 @@ xfs_attrd_item_intent( ...@@ -303,12 +303,9 @@ xfs_attrd_item_intent(
STATIC int STATIC int
xfs_xattri_finish_update( xfs_xattri_finish_update(
struct xfs_attr_item *attr, struct xfs_attr_item *attr,
struct xfs_attrd_log_item *attrdp, struct xfs_attrd_log_item *attrdp)
uint32_t op_flags)
{ {
struct xfs_da_args *args = attr->xattri_da_args; struct xfs_da_args *args = attr->xattri_da_args;
unsigned int op = op_flags &
XFS_ATTR_OP_FLAGS_TYPE_MASK;
int error; int error;
if (XFS_TEST_ERROR(false, args->dp->i_mount, XFS_ERRTAG_LARP)) { if (XFS_TEST_ERROR(false, args->dp->i_mount, XFS_ERRTAG_LARP)) {
...@@ -316,22 +313,9 @@ xfs_xattri_finish_update( ...@@ -316,22 +313,9 @@ xfs_xattri_finish_update(
goto out; goto out;
} }
switch (op) { error = xfs_attr_set_iter(attr);
case XFS_ATTR_OP_FLAGS_SET: if (!error && attr->xattri_dela_state != XFS_DAS_DONE)
case XFS_ATTR_OP_FLAGS_REPLACE: error = -EAGAIN;
error = xfs_attr_set_iter(attr);
if (!error && attr->xattri_dela_state != XFS_DAS_DONE)
error = -EAGAIN;
break;
case XFS_ATTR_OP_FLAGS_REMOVE:
ASSERT(XFS_IFORK_Q(args->dp));
error = xfs_attr_remove_iter(attr);
break;
default:
error = -EFSCORRUPTED;
break;
}
out: out:
/* /*
* Mark the transaction dirty, even on error. This ensures the * Mark the transaction dirty, even on error. This ensures the
...@@ -439,8 +423,7 @@ xfs_attr_finish_item( ...@@ -439,8 +423,7 @@ xfs_attr_finish_item(
*/ */
attr->xattri_da_args->trans = tp; attr->xattri_da_args->trans = tp;
error = xfs_xattri_finish_update(attr, done_item, error = xfs_xattri_finish_update(attr, done_item);
attr->xattri_op_flags);
if (error != -EAGAIN) if (error != -EAGAIN)
kmem_free(attr); kmem_free(attr);
...@@ -588,7 +571,7 @@ xfs_attri_item_recover( ...@@ -588,7 +571,7 @@ xfs_attri_item_recover(
attr->xattri_dela_state = xfs_attr_init_add_state(args); attr->xattri_dela_state = xfs_attr_init_add_state(args);
break; break;
case XFS_ATTR_OP_FLAGS_REMOVE: case XFS_ATTR_OP_FLAGS_REMOVE:
attr->xattri_dela_state = XFS_DAS_UNINIT; attr->xattri_dela_state = xfs_attr_init_remove_state(args);
break; break;
default: default:
ASSERT(0); ASSERT(0);
...@@ -607,7 +590,7 @@ xfs_attri_item_recover( ...@@ -607,7 +590,7 @@ xfs_attri_item_recover(
xfs_ilock(ip, XFS_ILOCK_EXCL); xfs_ilock(ip, XFS_ILOCK_EXCL);
xfs_trans_ijoin(tp, ip, 0); xfs_trans_ijoin(tp, ip, 0);
ret = xfs_xattri_finish_update(attr, done_item, attrp->alfi_op_flags); ret = xfs_xattri_finish_update(attr, done_item);
if (ret == -EAGAIN) { if (ret == -EAGAIN) {
/* There's more work to do, so add it to this transaction */ /* There's more work to do, so add it to this transaction */
xfs_defer_add(tp, XFS_DEFER_OPS_TYPE_ATTR, &attr->xattri_list); xfs_defer_add(tp, XFS_DEFER_OPS_TYPE_ATTR, &attr->xattri_list);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment