Commit d68c51e9 authored by Allison Henderson's avatar Allison Henderson Committed by Dave Chinner

xfs: Merge xfs_delattr_context into xfs_attr_item

This is a clean up patch that merges xfs_delattr_context into
xfs_attr_item.  Now that the refactoring is complete and the delayed
operation infrastructure is in place, we can combine these to eliminate
the extra struct
Signed-off-by: default avatarAllison Henderson <allison.henderson@oracle.com>
Reviewed-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: default avatarChandan Babu R <chandanrlinux@gmail.com>
Signed-off-by: default avatarDave Chinner <david@fromorbit.com>
parent 535e2f75
...@@ -58,10 +58,9 @@ STATIC int xfs_attr_leaf_try_add(struct xfs_da_args *args, struct xfs_buf *bp); ...@@ -58,10 +58,9 @@ STATIC int xfs_attr_leaf_try_add(struct xfs_da_args *args, struct xfs_buf *bp);
*/ */
STATIC int xfs_attr_node_get(xfs_da_args_t *args); STATIC int xfs_attr_node_get(xfs_da_args_t *args);
STATIC void xfs_attr_restore_rmt_blk(struct xfs_da_args *args); STATIC void xfs_attr_restore_rmt_blk(struct xfs_da_args *args);
STATIC int xfs_attr_node_addname(struct xfs_delattr_context *dac); STATIC int xfs_attr_node_addname(struct xfs_attr_item *attr);
STATIC int xfs_attr_node_addname_find_attr(struct xfs_delattr_context *dac); STATIC int xfs_attr_node_addname_find_attr(struct xfs_attr_item *attr);
STATIC int xfs_attr_node_addname_clear_incomplete( STATIC int xfs_attr_node_addname_clear_incomplete(struct xfs_attr_item *attr);
struct xfs_delattr_context *dac);
STATIC int xfs_attr_node_hasname(xfs_da_args_t *args, STATIC int xfs_attr_node_hasname(xfs_da_args_t *args,
struct xfs_da_state **state); struct xfs_da_state **state);
STATIC int xfs_attr_fillstate(xfs_da_state_t *state); STATIC int xfs_attr_fillstate(xfs_da_state_t *state);
...@@ -248,9 +247,9 @@ xfs_attr_is_shortform( ...@@ -248,9 +247,9 @@ xfs_attr_is_shortform(
STATIC int STATIC int
xfs_attr_sf_addname( xfs_attr_sf_addname(
struct xfs_delattr_context *dac) struct xfs_attr_item *attr)
{ {
struct xfs_da_args *args = dac->da_args; struct xfs_da_args *args = attr->xattri_da_args;
struct xfs_inode *dp = args->dp; struct xfs_inode *dp = args->dp;
int error = 0; int error = 0;
...@@ -267,7 +266,7 @@ xfs_attr_sf_addname( ...@@ -267,7 +266,7 @@ xfs_attr_sf_addname(
* It won't fit in the shortform, transform to a leaf block. GROT: * It won't fit in the shortform, transform to a leaf block. GROT:
* another possible req'mt for a double-split btree op. * another possible req'mt for a double-split btree op.
*/ */
error = xfs_attr_shortform_to_leaf(args, &dac->leaf_bp); error = xfs_attr_shortform_to_leaf(args, &attr->xattri_leaf_bp);
if (error) if (error)
return error; return error;
...@@ -276,7 +275,7 @@ xfs_attr_sf_addname( ...@@ -276,7 +275,7 @@ xfs_attr_sf_addname(
* push cannot grab the half-baked leaf buffer and run into problems * push cannot grab the half-baked leaf buffer and run into problems
* with the write verifier. * with the write verifier.
*/ */
xfs_trans_bhold(args->trans, dac->leaf_bp); xfs_trans_bhold(args->trans, attr->xattri_leaf_bp);
/* /*
* We're still in XFS_DAS_UNINIT state here. We've converted * We're still in XFS_DAS_UNINIT state here. We've converted
...@@ -296,16 +295,16 @@ xfs_attr_sf_addname( ...@@ -296,16 +295,16 @@ xfs_attr_sf_addname(
*/ */
int int
xfs_attr_set_iter( xfs_attr_set_iter(
struct xfs_delattr_context *dac) struct xfs_attr_item *attr)
{ {
struct xfs_da_args *args = dac->da_args; struct xfs_da_args *args = attr->xattri_da_args;
struct xfs_inode *dp = args->dp; struct xfs_inode *dp = args->dp;
struct xfs_buf *bp = NULL; struct xfs_buf *bp = NULL;
int forkoff, error = 0; int forkoff, error = 0;
struct xfs_mount *mp = args->dp->i_mount; struct xfs_mount *mp = args->dp->i_mount;
/* State machine switch */ /* State machine switch */
switch (dac->dela_state) { switch (attr->xattri_dela_state) {
case XFS_DAS_UNINIT: case XFS_DAS_UNINIT:
/* /*
* If the fork is shortform, attempt to add the attr. If there * If the fork is shortform, attempt to add the attr. If there
...@@ -315,14 +314,16 @@ xfs_attr_set_iter( ...@@ -315,14 +314,16 @@ xfs_attr_set_iter(
* release the hold once we return with a clean transaction. * release the hold once we return with a clean transaction.
*/ */
if (xfs_attr_is_shortform(dp)) if (xfs_attr_is_shortform(dp))
return xfs_attr_sf_addname(dac); return xfs_attr_sf_addname(attr);
if (dac->leaf_bp != NULL) { if (attr->xattri_leaf_bp != NULL) {
xfs_trans_bhold_release(args->trans, dac->leaf_bp); xfs_trans_bhold_release(args->trans,
dac->leaf_bp = NULL; attr->xattri_leaf_bp);
attr->xattri_leaf_bp = NULL;
} }
if (xfs_attr_is_leaf(dp)) { if (xfs_attr_is_leaf(dp)) {
error = xfs_attr_leaf_try_add(args, dac->leaf_bp); error = xfs_attr_leaf_try_add(args,
attr->xattri_leaf_bp);
if (error == -ENOSPC) { if (error == -ENOSPC) {
error = xfs_attr3_leaf_to_node(args); error = xfs_attr3_leaf_to_node(args);
if (error) if (error)
...@@ -342,19 +343,19 @@ xfs_attr_set_iter( ...@@ -342,19 +343,19 @@ xfs_attr_set_iter(
* handling code below * handling code below
*/ */
trace_xfs_attr_set_iter_return( trace_xfs_attr_set_iter_return(
dac->dela_state, args->dp); attr->xattri_dela_state, args->dp);
return -EAGAIN; return -EAGAIN;
} else if (error) { } else if (error) {
return error; return error;
} }
dac->dela_state = XFS_DAS_FOUND_LBLK; attr->xattri_dela_state = XFS_DAS_FOUND_LBLK;
} else { } else {
error = xfs_attr_node_addname_find_attr(dac); error = xfs_attr_node_addname_find_attr(attr);
if (error) if (error)
return error; return error;
error = xfs_attr_node_addname(dac); error = xfs_attr_node_addname(attr);
if (error) if (error)
return error; return error;
...@@ -366,9 +367,10 @@ xfs_attr_set_iter( ...@@ -366,9 +367,10 @@ xfs_attr_set_iter(
!(args->op_flags & XFS_DA_OP_RENAME)) !(args->op_flags & XFS_DA_OP_RENAME))
return 0; return 0;
dac->dela_state = XFS_DAS_FOUND_NBLK; attr->xattri_dela_state = XFS_DAS_FOUND_NBLK;
} }
trace_xfs_attr_set_iter_return(dac->dela_state, args->dp); trace_xfs_attr_set_iter_return(attr->xattri_dela_state,
args->dp);
return -EAGAIN; return -EAGAIN;
case XFS_DAS_FOUND_LBLK: case XFS_DAS_FOUND_LBLK:
/* /*
...@@ -379,10 +381,10 @@ xfs_attr_set_iter( ...@@ -379,10 +381,10 @@ xfs_attr_set_iter(
*/ */
/* Open coded xfs_attr_rmtval_set without trans handling */ /* Open coded xfs_attr_rmtval_set without trans handling */
if ((dac->flags & XFS_DAC_LEAF_ADDNAME_INIT) == 0) { if ((attr->xattri_flags & XFS_DAC_LEAF_ADDNAME_INIT) == 0) {
dac->flags |= XFS_DAC_LEAF_ADDNAME_INIT; attr->xattri_flags |= XFS_DAC_LEAF_ADDNAME_INIT;
if (args->rmtblkno > 0) { if (args->rmtblkno > 0) {
error = xfs_attr_rmtval_find_space(dac); error = xfs_attr_rmtval_find_space(attr);
if (error) if (error)
return error; return error;
} }
...@@ -392,11 +394,11 @@ xfs_attr_set_iter( ...@@ -392,11 +394,11 @@ xfs_attr_set_iter(
* Repeat allocating remote blocks for the attr value until * Repeat allocating remote blocks for the attr value until
* blkcnt drops to zero. * blkcnt drops to zero.
*/ */
if (dac->blkcnt > 0) { if (attr->xattri_blkcnt > 0) {
error = xfs_attr_rmtval_set_blk(dac); error = xfs_attr_rmtval_set_blk(attr);
if (error) if (error)
return error; return error;
trace_xfs_attr_set_iter_return(dac->dela_state, trace_xfs_attr_set_iter_return(attr->xattri_dela_state,
args->dp); args->dp);
return -EAGAIN; return -EAGAIN;
} }
...@@ -432,8 +434,8 @@ xfs_attr_set_iter( ...@@ -432,8 +434,8 @@ xfs_attr_set_iter(
* Commit the flag value change and start the next trans * Commit the flag value change and start the next trans
* in series. * in series.
*/ */
dac->dela_state = XFS_DAS_FLIP_LFLAG; attr->xattri_dela_state = XFS_DAS_FLIP_LFLAG;
trace_xfs_attr_set_iter_return(dac->dela_state, trace_xfs_attr_set_iter_return(attr->xattri_dela_state,
args->dp); args->dp);
return -EAGAIN; return -EAGAIN;
} }
...@@ -452,17 +454,18 @@ xfs_attr_set_iter( ...@@ -452,17 +454,18 @@ xfs_attr_set_iter(
fallthrough; fallthrough;
case XFS_DAS_RM_LBLK: case XFS_DAS_RM_LBLK:
/* Set state in case xfs_attr_rmtval_remove returns -EAGAIN */ /* Set state in case xfs_attr_rmtval_remove returns -EAGAIN */
dac->dela_state = XFS_DAS_RM_LBLK; attr->xattri_dela_state = XFS_DAS_RM_LBLK;
if (args->rmtblkno) { if (args->rmtblkno) {
error = xfs_attr_rmtval_remove(dac); error = xfs_attr_rmtval_remove(attr);
if (error == -EAGAIN) if (error == -EAGAIN)
trace_xfs_attr_set_iter_return( trace_xfs_attr_set_iter_return(
dac->dela_state, args->dp); attr->xattri_dela_state, args->dp);
if (error) if (error)
return error; return error;
dac->dela_state = XFS_DAS_RD_LEAF; attr->xattri_dela_state = XFS_DAS_RD_LEAF;
trace_xfs_attr_set_iter_return(dac->dela_state, args->dp); trace_xfs_attr_set_iter_return(attr->xattri_dela_state,
args->dp);
return -EAGAIN; return -EAGAIN;
} }
...@@ -493,7 +496,7 @@ xfs_attr_set_iter( ...@@ -493,7 +496,7 @@ xfs_attr_set_iter(
* state. * state.
*/ */
if (args->rmtblkno > 0) { if (args->rmtblkno > 0) {
error = xfs_attr_rmtval_find_space(dac); error = xfs_attr_rmtval_find_space(attr);
if (error) if (error)
return error; return error;
} }
...@@ -506,14 +509,14 @@ xfs_attr_set_iter( ...@@ -506,14 +509,14 @@ xfs_attr_set_iter(
* after we create the attribute so that we don't overflow the * after we create the attribute so that we don't overflow the
* maximum size of a transaction and/or hit a deadlock. * maximum size of a transaction and/or hit a deadlock.
*/ */
dac->dela_state = XFS_DAS_ALLOC_NODE; attr->xattri_dela_state = XFS_DAS_ALLOC_NODE;
if (args->rmtblkno > 0) { if (args->rmtblkno > 0) {
if (dac->blkcnt > 0) { if (attr->xattri_blkcnt > 0) {
error = xfs_attr_rmtval_set_blk(dac); error = xfs_attr_rmtval_set_blk(attr);
if (error) if (error)
return error; return error;
trace_xfs_attr_set_iter_return( trace_xfs_attr_set_iter_return(
dac->dela_state, args->dp); attr->xattri_dela_state, args->dp);
return -EAGAIN; return -EAGAIN;
} }
...@@ -549,8 +552,8 @@ xfs_attr_set_iter( ...@@ -549,8 +552,8 @@ xfs_attr_set_iter(
* Commit the flag value change and start the next trans * Commit the flag value change and start the next trans
* in series * in series
*/ */
dac->dela_state = XFS_DAS_FLIP_NFLAG; attr->xattri_dela_state = XFS_DAS_FLIP_NFLAG;
trace_xfs_attr_set_iter_return(dac->dela_state, trace_xfs_attr_set_iter_return(attr->xattri_dela_state,
args->dp); args->dp);
return -EAGAIN; return -EAGAIN;
} }
...@@ -570,18 +573,19 @@ xfs_attr_set_iter( ...@@ -570,18 +573,19 @@ xfs_attr_set_iter(
fallthrough; fallthrough;
case XFS_DAS_RM_NBLK: case XFS_DAS_RM_NBLK:
/* Set state in case xfs_attr_rmtval_remove returns -EAGAIN */ /* Set state in case xfs_attr_rmtval_remove returns -EAGAIN */
dac->dela_state = XFS_DAS_RM_NBLK; attr->xattri_dela_state = XFS_DAS_RM_NBLK;
if (args->rmtblkno) { if (args->rmtblkno) {
error = xfs_attr_rmtval_remove(dac); error = xfs_attr_rmtval_remove(attr);
if (error == -EAGAIN) if (error == -EAGAIN)
trace_xfs_attr_set_iter_return( trace_xfs_attr_set_iter_return(
dac->dela_state, args->dp); attr->xattri_dela_state, args->dp);
if (error) if (error)
return error; return error;
dac->dela_state = XFS_DAS_CLR_FLAG; attr->xattri_dela_state = XFS_DAS_CLR_FLAG;
trace_xfs_attr_set_iter_return(dac->dela_state, args->dp); trace_xfs_attr_set_iter_return(attr->xattri_dela_state,
args->dp);
return -EAGAIN; return -EAGAIN;
} }
...@@ -591,7 +595,7 @@ xfs_attr_set_iter( ...@@ -591,7 +595,7 @@ xfs_attr_set_iter(
* The last state for node format. Look up the old attr and * The last state for node format. Look up the old attr and
* remove it. * remove it.
*/ */
error = xfs_attr_node_addname_clear_incomplete(dac); error = xfs_attr_node_addname_clear_incomplete(attr);
break; break;
default: default:
ASSERT(0); ASSERT(0);
...@@ -825,7 +829,7 @@ xfs_attr_item_init( ...@@ -825,7 +829,7 @@ xfs_attr_item_init(
new = kmem_zalloc(sizeof(struct xfs_attr_item), KM_NOFS); new = kmem_zalloc(sizeof(struct xfs_attr_item), KM_NOFS);
new->xattri_op_flags = op_flags; new->xattri_op_flags = op_flags;
new->xattri_dac.da_args = args; new->xattri_da_args = args;
*attr = new; *attr = new;
return 0; return 0;
...@@ -1135,16 +1139,16 @@ xfs_attr_node_hasname( ...@@ -1135,16 +1139,16 @@ xfs_attr_node_hasname(
STATIC int STATIC int
xfs_attr_node_addname_find_attr( xfs_attr_node_addname_find_attr(
struct xfs_delattr_context *dac) struct xfs_attr_item *attr)
{ {
struct xfs_da_args *args = dac->da_args; struct xfs_da_args *args = attr->xattri_da_args;
int retval; int retval;
/* /*
* Search to see if name already exists, and get back a pointer * Search to see if name already exists, and get back a pointer
* to where it should go. * to where it should go.
*/ */
retval = xfs_attr_node_hasname(args, &dac->da_state); retval = xfs_attr_node_hasname(args, &attr->xattri_da_state);
if (retval != -ENOATTR && retval != -EEXIST) if (retval != -ENOATTR && retval != -EEXIST)
goto error; goto error;
...@@ -1172,8 +1176,8 @@ xfs_attr_node_addname_find_attr( ...@@ -1172,8 +1176,8 @@ xfs_attr_node_addname_find_attr(
return 0; return 0;
error: error:
if (dac->da_state) if (attr->xattri_da_state)
xfs_da_state_free(dac->da_state); xfs_da_state_free(attr->xattri_da_state);
return retval; return retval;
} }
...@@ -1194,10 +1198,10 @@ xfs_attr_node_addname_find_attr( ...@@ -1194,10 +1198,10 @@ xfs_attr_node_addname_find_attr(
*/ */
STATIC int STATIC int
xfs_attr_node_addname( xfs_attr_node_addname(
struct xfs_delattr_context *dac) struct xfs_attr_item *attr)
{ {
struct xfs_da_args *args = dac->da_args; struct xfs_da_args *args = attr->xattri_da_args;
struct xfs_da_state *state = dac->da_state; struct xfs_da_state *state = attr->xattri_da_state;
struct xfs_da_state_blk *blk; struct xfs_da_state_blk *blk;
int error; int error;
...@@ -1228,7 +1232,7 @@ xfs_attr_node_addname( ...@@ -1228,7 +1232,7 @@ xfs_attr_node_addname(
* this point. * this point.
*/ */
trace_xfs_attr_node_addname_return( trace_xfs_attr_node_addname_return(
dac->dela_state, args->dp); attr->xattri_dela_state, args->dp);
return -EAGAIN; return -EAGAIN;
} }
...@@ -1257,9 +1261,9 @@ xfs_attr_node_addname( ...@@ -1257,9 +1261,9 @@ xfs_attr_node_addname(
STATIC int STATIC int
xfs_attr_node_addname_clear_incomplete( xfs_attr_node_addname_clear_incomplete(
struct xfs_delattr_context *dac) struct xfs_attr_item *attr)
{ {
struct xfs_da_args *args = dac->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; struct xfs_mount *mp = args->dp->i_mount;
int retval = 0; int retval = 0;
...@@ -1363,10 +1367,10 @@ xfs_attr_leaf_mark_incomplete( ...@@ -1363,10 +1367,10 @@ xfs_attr_leaf_mark_incomplete(
*/ */
STATIC STATIC
int xfs_attr_node_removename_setup( int xfs_attr_node_removename_setup(
struct xfs_delattr_context *dac) struct xfs_attr_item *attr)
{ {
struct xfs_da_args *args = dac->da_args; struct xfs_da_args *args = attr->xattri_da_args;
struct xfs_da_state **state = &dac->da_state; struct xfs_da_state **state = &attr->xattri_da_state;
int error; int error;
error = xfs_attr_node_hasname(args, state); error = xfs_attr_node_hasname(args, state);
...@@ -1425,16 +1429,16 @@ xfs_attr_node_removename( ...@@ -1425,16 +1429,16 @@ xfs_attr_node_removename(
*/ */
int int
xfs_attr_remove_iter( xfs_attr_remove_iter(
struct xfs_delattr_context *dac) struct xfs_attr_item *attr)
{ {
struct xfs_da_args *args = dac->da_args; struct xfs_da_args *args = attr->xattri_da_args;
struct xfs_da_state *state = dac->da_state; struct xfs_da_state *state = attr->xattri_da_state;
int retval, error = 0; int retval, error = 0;
struct xfs_inode *dp = args->dp; struct xfs_inode *dp = args->dp;
trace_xfs_attr_node_removename(args); trace_xfs_attr_node_removename(args);
switch (dac->dela_state) { switch (attr->xattri_dela_state) {
case XFS_DAS_UNINIT: case XFS_DAS_UNINIT:
if (!xfs_inode_hasattr(dp)) if (!xfs_inode_hasattr(dp))
return -ENOATTR; return -ENOATTR;
...@@ -1453,16 +1457,16 @@ xfs_attr_remove_iter( ...@@ -1453,16 +1457,16 @@ xfs_attr_remove_iter(
* Node format may require transaction rolls. Set up the * Node format may require transaction rolls. Set up the
* state context and fall into the state machine. * state context and fall into the state machine.
*/ */
if (!dac->da_state) { if (!attr->xattri_da_state) {
error = xfs_attr_node_removename_setup(dac); error = xfs_attr_node_removename_setup(attr);
if (error) if (error)
return error; return error;
state = dac->da_state; state = attr->xattri_da_state;
} }
fallthrough; fallthrough;
case XFS_DAS_RMTBLK: case XFS_DAS_RMTBLK:
dac->dela_state = XFS_DAS_RMTBLK; attr->xattri_dela_state = XFS_DAS_RMTBLK;
/* /*
* If there is an out-of-line value, de-allocate the blocks. * If there is an out-of-line value, de-allocate the blocks.
...@@ -1475,10 +1479,10 @@ xfs_attr_remove_iter( ...@@ -1475,10 +1479,10 @@ xfs_attr_remove_iter(
* May return -EAGAIN. Roll and repeat until all remote * May return -EAGAIN. Roll and repeat until all remote
* blocks are removed. * blocks are removed.
*/ */
error = xfs_attr_rmtval_remove(dac); error = xfs_attr_rmtval_remove(attr);
if (error == -EAGAIN) { if (error == -EAGAIN) {
trace_xfs_attr_remove_iter_return( trace_xfs_attr_remove_iter_return(
dac->dela_state, args->dp); attr->xattri_dela_state, args->dp);
return error; return error;
} else if (error) { } else if (error) {
goto out; goto out;
...@@ -1493,8 +1497,10 @@ xfs_attr_remove_iter( ...@@ -1493,8 +1497,10 @@ xfs_attr_remove_iter(
error = xfs_attr_refillstate(state); error = xfs_attr_refillstate(state);
if (error) if (error)
goto out; goto out;
dac->dela_state = XFS_DAS_RM_NAME;
trace_xfs_attr_remove_iter_return(dac->dela_state, args->dp); attr->xattri_dela_state = XFS_DAS_RM_NAME;
trace_xfs_attr_remove_iter_return(
attr->xattri_dela_state, args->dp);
return -EAGAIN; return -EAGAIN;
} }
...@@ -1504,7 +1510,7 @@ xfs_attr_remove_iter( ...@@ -1504,7 +1510,7 @@ xfs_attr_remove_iter(
* If we came here fresh from a transaction roll, reattach all * If we came here fresh from a transaction roll, reattach all
* the buffers to the current transaction. * the buffers to the current transaction.
*/ */
if (dac->dela_state == XFS_DAS_RM_NAME) { if (attr->xattri_dela_state == XFS_DAS_RM_NAME) {
error = xfs_attr_refillstate(state); error = xfs_attr_refillstate(state);
if (error) if (error)
goto out; goto out;
...@@ -1521,9 +1527,9 @@ xfs_attr_remove_iter( ...@@ -1521,9 +1527,9 @@ xfs_attr_remove_iter(
if (error) if (error)
goto out; goto out;
dac->dela_state = XFS_DAS_RM_SHRINK; attr->xattri_dela_state = XFS_DAS_RM_SHRINK;
trace_xfs_attr_remove_iter_return( trace_xfs_attr_remove_iter_return(
dac->dela_state, args->dp); attr->xattri_dela_state, args->dp);
return -EAGAIN; return -EAGAIN;
} }
......
...@@ -434,7 +434,7 @@ struct xfs_attr_list_context { ...@@ -434,7 +434,7 @@ struct xfs_attr_list_context {
*/ */
/* /*
* Enum values for xfs_delattr_context.da_state * Enum values for xfs_attr_item.xattri_da_state
* *
* These values are used by delayed attribute operations to keep track of where * These values are used by delayed attribute operations to keep track of where
* they were before they returned -EAGAIN. A return code of -EAGAIN signals the * they were before they returned -EAGAIN. A return code of -EAGAIN signals the
...@@ -459,39 +459,32 @@ enum xfs_delattr_state { ...@@ -459,39 +459,32 @@ enum xfs_delattr_state {
}; };
/* /*
* Defines for xfs_delattr_context.flags * Defines for xfs_attr_item.xattri_flags
*/ */
#define XFS_DAC_LEAF_ADDNAME_INIT 0x01 /* xfs_attr_leaf_addname init*/ #define XFS_DAC_LEAF_ADDNAME_INIT 0x01 /* xfs_attr_leaf_addname init*/
/* /*
* Context used for keeping track of delayed attribute operations * Context used for keeping track of delayed attribute operations
*/ */
struct xfs_delattr_context { struct xfs_attr_item {
struct xfs_da_args *da_args; struct xfs_da_args *xattri_da_args;
/* /*
* Used by xfs_attr_set to hold a leaf buffer across a transaction roll * Used by xfs_attr_set to hold a leaf buffer across a transaction roll
*/ */
struct xfs_buf *leaf_bp; struct xfs_buf *xattri_leaf_bp;
/* Used in xfs_attr_rmtval_set_blk to roll through allocating blocks */ /* Used in xfs_attr_rmtval_set_blk to roll through allocating blocks */
struct xfs_bmbt_irec map; struct xfs_bmbt_irec xattri_map;
xfs_dablk_t lblkno; xfs_dablk_t xattri_lblkno;
int blkcnt; int xattri_blkcnt;
/* Used in xfs_attr_node_removename to roll through removing blocks */ /* Used in xfs_attr_node_removename to roll through removing blocks */
struct xfs_da_state *da_state; struct xfs_da_state *xattri_da_state;
/* Used to keep track of current state of delayed operation */ /* Used to keep track of current state of delayed operation */
unsigned int flags; unsigned int xattri_flags;
enum xfs_delattr_state dela_state; enum xfs_delattr_state xattri_dela_state;
};
/*
* List of attrs to commit later.
*/
struct xfs_attr_item {
struct xfs_delattr_context xattri_dac;
/* /*
* Indicates if the attr operation is a set or a remove * Indicates if the attr operation is a set or a remove
...@@ -499,7 +492,10 @@ struct xfs_attr_item { ...@@ -499,7 +492,10 @@ struct xfs_attr_item {
*/ */
unsigned int xattri_op_flags; unsigned int xattri_op_flags;
/* used to log this item to an intent */ /*
* used to log this item to an intent containing a list of attrs to
* commit later
*/
struct list_head xattri_list; struct list_head xattri_list;
}; };
...@@ -519,11 +515,9 @@ bool xfs_attr_is_leaf(struct xfs_inode *ip); ...@@ -519,11 +515,9 @@ bool xfs_attr_is_leaf(struct xfs_inode *ip);
int xfs_attr_get_ilocked(struct xfs_da_args *args); int xfs_attr_get_ilocked(struct xfs_da_args *args);
int xfs_attr_get(struct xfs_da_args *args); int xfs_attr_get(struct xfs_da_args *args);
int xfs_attr_set(struct xfs_da_args *args); int xfs_attr_set(struct xfs_da_args *args);
int xfs_attr_set_iter(struct xfs_delattr_context *dac); int xfs_attr_set_iter(struct xfs_attr_item *attr);
int xfs_attr_remove_iter(struct xfs_delattr_context *dac); int xfs_attr_remove_iter(struct xfs_attr_item *attr);
bool xfs_attr_namecheck(const void *name, size_t length); bool xfs_attr_namecheck(const void *name, size_t length);
void xfs_delattr_context_init(struct xfs_delattr_context *dac,
struct xfs_da_args *args);
int xfs_attr_calc_size(struct xfs_da_args *args, int *local); int xfs_attr_calc_size(struct xfs_da_args *args, int *local);
int xfs_attr_set_deferred(struct xfs_da_args *args); int xfs_attr_set_deferred(struct xfs_da_args *args);
int xfs_attr_remove_deferred(struct xfs_da_args *args); int xfs_attr_remove_deferred(struct xfs_da_args *args);
......
...@@ -568,14 +568,14 @@ xfs_attr_rmtval_stale( ...@@ -568,14 +568,14 @@ xfs_attr_rmtval_stale(
*/ */
int int
xfs_attr_rmtval_find_space( xfs_attr_rmtval_find_space(
struct xfs_delattr_context *dac) struct xfs_attr_item *attr)
{ {
struct xfs_da_args *args = dac->da_args; struct xfs_da_args *args = attr->xattri_da_args;
struct xfs_bmbt_irec *map = &dac->map; struct xfs_bmbt_irec *map = &attr->xattri_map;
int error; int error;
dac->lblkno = 0; attr->xattri_lblkno = 0;
dac->blkcnt = 0; attr->xattri_blkcnt = 0;
args->rmtblkcnt = 0; args->rmtblkcnt = 0;
args->rmtblkno = 0; args->rmtblkno = 0;
memset(map, 0, sizeof(struct xfs_bmbt_irec)); memset(map, 0, sizeof(struct xfs_bmbt_irec));
...@@ -584,8 +584,8 @@ xfs_attr_rmtval_find_space( ...@@ -584,8 +584,8 @@ xfs_attr_rmtval_find_space(
if (error) if (error)
return error; return error;
dac->blkcnt = args->rmtblkcnt; attr->xattri_blkcnt = args->rmtblkcnt;
dac->lblkno = args->rmtblkno; attr->xattri_lblkno = args->rmtblkno;
return 0; return 0;
} }
...@@ -598,17 +598,18 @@ xfs_attr_rmtval_find_space( ...@@ -598,17 +598,18 @@ xfs_attr_rmtval_find_space(
*/ */
int int
xfs_attr_rmtval_set_blk( xfs_attr_rmtval_set_blk(
struct xfs_delattr_context *dac) struct xfs_attr_item *attr)
{ {
struct xfs_da_args *args = dac->da_args; struct xfs_da_args *args = attr->xattri_da_args;
struct xfs_inode *dp = args->dp; struct xfs_inode *dp = args->dp;
struct xfs_bmbt_irec *map = &dac->map; struct xfs_bmbt_irec *map = &attr->xattri_map;
int nmap; int nmap;
int error; int error;
nmap = 1; nmap = 1;
error = xfs_bmapi_write(args->trans, dp, (xfs_fileoff_t)dac->lblkno, error = xfs_bmapi_write(args->trans, dp,
dac->blkcnt, XFS_BMAPI_ATTRFORK, args->total, (xfs_fileoff_t)attr->xattri_lblkno,
attr->xattri_blkcnt, XFS_BMAPI_ATTRFORK, args->total,
map, &nmap); map, &nmap);
if (error) if (error)
return error; return error;
...@@ -618,8 +619,8 @@ xfs_attr_rmtval_set_blk( ...@@ -618,8 +619,8 @@ xfs_attr_rmtval_set_blk(
(map->br_startblock != HOLESTARTBLOCK)); (map->br_startblock != HOLESTARTBLOCK));
/* roll attribute extent map forwards */ /* roll attribute extent map forwards */
dac->lblkno += map->br_blockcount; attr->xattri_lblkno += map->br_blockcount;
dac->blkcnt -= map->br_blockcount; attr->xattri_blkcnt -= map->br_blockcount;
return 0; return 0;
} }
...@@ -673,9 +674,9 @@ xfs_attr_rmtval_invalidate( ...@@ -673,9 +674,9 @@ xfs_attr_rmtval_invalidate(
*/ */
int int
xfs_attr_rmtval_remove( xfs_attr_rmtval_remove(
struct xfs_delattr_context *dac) struct xfs_attr_item *attr)
{ {
struct xfs_da_args *args = dac->da_args; struct xfs_da_args *args = attr->xattri_da_args;
int error, done; int error, done;
/* /*
...@@ -695,7 +696,8 @@ xfs_attr_rmtval_remove( ...@@ -695,7 +696,8 @@ xfs_attr_rmtval_remove(
* the parent * the parent
*/ */
if (!done) { if (!done) {
trace_xfs_attr_rmtval_remove_return(dac->dela_state, args->dp); trace_xfs_attr_rmtval_remove_return(attr->xattri_dela_state,
args->dp);
return -EAGAIN; return -EAGAIN;
} }
......
...@@ -12,9 +12,9 @@ int xfs_attr_rmtval_get(struct xfs_da_args *args); ...@@ -12,9 +12,9 @@ int xfs_attr_rmtval_get(struct xfs_da_args *args);
int xfs_attr_rmtval_stale(struct xfs_inode *ip, struct xfs_bmbt_irec *map, int xfs_attr_rmtval_stale(struct xfs_inode *ip, struct xfs_bmbt_irec *map,
xfs_buf_flags_t incore_flags); xfs_buf_flags_t incore_flags);
int xfs_attr_rmtval_invalidate(struct xfs_da_args *args); int xfs_attr_rmtval_invalidate(struct xfs_da_args *args);
int xfs_attr_rmtval_remove(struct xfs_delattr_context *dac); int xfs_attr_rmtval_remove(struct xfs_attr_item *attr);
int xfs_attr_rmt_find_hole(struct xfs_da_args *args); int xfs_attr_rmt_find_hole(struct xfs_da_args *args);
int xfs_attr_rmtval_set_value(struct xfs_da_args *args); int xfs_attr_rmtval_set_value(struct xfs_da_args *args);
int xfs_attr_rmtval_set_blk(struct xfs_delattr_context *dac); int xfs_attr_rmtval_set_blk(struct xfs_attr_item *attr);
int xfs_attr_rmtval_find_space(struct xfs_delattr_context *dac); int xfs_attr_rmtval_find_space(struct xfs_attr_item *attr);
#endif /* __XFS_ATTR_REMOTE_H__ */ #endif /* __XFS_ATTR_REMOTE_H__ */
...@@ -302,11 +302,11 @@ xfs_attrd_item_intent( ...@@ -302,11 +302,11 @@ xfs_attrd_item_intent(
*/ */
STATIC int STATIC int
xfs_xattri_finish_update( xfs_xattri_finish_update(
struct xfs_delattr_context *dac, struct xfs_attr_item *attr,
struct xfs_attrd_log_item *attrdp, struct xfs_attrd_log_item *attrdp,
uint32_t op_flags) uint32_t op_flags)
{ {
struct xfs_da_args *args = dac->da_args; struct xfs_da_args *args = attr->xattri_da_args;
unsigned int op = op_flags & unsigned int op = op_flags &
XFS_ATTR_OP_FLAGS_TYPE_MASK; XFS_ATTR_OP_FLAGS_TYPE_MASK;
int error; int error;
...@@ -318,11 +318,11 @@ xfs_xattri_finish_update( ...@@ -318,11 +318,11 @@ xfs_xattri_finish_update(
switch (op) { switch (op) {
case XFS_ATTR_OP_FLAGS_SET: case XFS_ATTR_OP_FLAGS_SET:
error = xfs_attr_set_iter(dac); error = xfs_attr_set_iter(attr);
break; break;
case XFS_ATTR_OP_FLAGS_REMOVE: case XFS_ATTR_OP_FLAGS_REMOVE:
ASSERT(XFS_IFORK_Q(args->dp)); ASSERT(XFS_IFORK_Q(args->dp));
error = xfs_attr_remove_iter(dac); error = xfs_attr_remove_iter(attr);
break; break;
default: default:
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
...@@ -366,18 +366,18 @@ xfs_attr_log_item( ...@@ -366,18 +366,18 @@ xfs_attr_log_item(
* structure with fields from this xfs_attr_item * structure with fields from this xfs_attr_item
*/ */
attrp = &attrip->attri_format; attrp = &attrip->attri_format;
attrp->alfi_ino = attr->xattri_dac.da_args->dp->i_ino; attrp->alfi_ino = attr->xattri_da_args->dp->i_ino;
attrp->alfi_op_flags = attr->xattri_op_flags; attrp->alfi_op_flags = attr->xattri_op_flags;
attrp->alfi_value_len = attr->xattri_dac.da_args->valuelen; attrp->alfi_value_len = attr->xattri_da_args->valuelen;
attrp->alfi_name_len = attr->xattri_dac.da_args->namelen; attrp->alfi_name_len = attr->xattri_da_args->namelen;
attrp->alfi_attr_flags = attr->xattri_dac.da_args->attr_filter; attrp->alfi_attr_flags = attr->xattri_da_args->attr_filter;
memcpy(attrip->attri_name, attr->xattri_dac.da_args->name, memcpy(attrip->attri_name, attr->xattri_da_args->name,
attr->xattri_dac.da_args->namelen); attr->xattri_da_args->namelen);
memcpy(attrip->attri_value, attr->xattri_dac.da_args->value, memcpy(attrip->attri_value, attr->xattri_da_args->value,
attr->xattri_dac.da_args->valuelen); attr->xattri_da_args->valuelen);
attrip->attri_name_len = attr->xattri_dac.da_args->namelen; attrip->attri_name_len = attr->xattri_da_args->namelen;
attrip->attri_value_len = attr->xattri_dac.da_args->valuelen; attrip->attri_value_len = attr->xattri_da_args->valuelen;
} }
/* Get an ATTRI. */ /* Get an ATTRI. */
...@@ -402,8 +402,8 @@ xfs_attr_create_intent( ...@@ -402,8 +402,8 @@ xfs_attr_create_intent(
* this is a list of one * this is a list of one
*/ */
list_for_each_entry(attr, items, xattri_list) { list_for_each_entry(attr, items, xattri_list) {
attrip = xfs_attri_init(mp, attr->xattri_dac.da_args->namelen, attrip = xfs_attri_init(mp, attr->xattri_da_args->namelen,
attr->xattri_dac.da_args->valuelen); attr->xattri_da_args->valuelen);
if (attrip == NULL) if (attrip == NULL)
return NULL; return NULL;
...@@ -425,10 +425,8 @@ xfs_attr_finish_item( ...@@ -425,10 +425,8 @@ xfs_attr_finish_item(
struct xfs_attr_item *attr; struct xfs_attr_item *attr;
struct xfs_attrd_log_item *done_item = NULL; struct xfs_attrd_log_item *done_item = NULL;
int error; int error;
struct xfs_delattr_context *dac;
attr = container_of(item, struct xfs_attr_item, xattri_list); attr = container_of(item, struct xfs_attr_item, xattri_list);
dac = &attr->xattri_dac;
if (done) if (done)
done_item = ATTRD_ITEM(done); done_item = ATTRD_ITEM(done);
...@@ -436,9 +434,10 @@ xfs_attr_finish_item( ...@@ -436,9 +434,10 @@ xfs_attr_finish_item(
* Always reset trans after EAGAIN cycle * Always reset trans after EAGAIN cycle
* since the transaction is new * since the transaction is new
*/ */
dac->da_args->trans = tp; attr->xattri_da_args->trans = tp;
error = xfs_xattri_finish_update(dac, done_item, attr->xattri_op_flags); error = xfs_xattri_finish_update(attr, done_item,
attr->xattri_op_flags);
if (error != -EAGAIN) if (error != -EAGAIN)
kmem_free(attr); kmem_free(attr);
...@@ -560,7 +559,7 @@ xfs_attri_item_recover( ...@@ -560,7 +559,7 @@ xfs_attri_item_recover(
sizeof(struct xfs_da_args), KM_NOFS); sizeof(struct xfs_da_args), KM_NOFS);
args = (struct xfs_da_args *)(attr + 1); args = (struct xfs_da_args *)(attr + 1);
attr->xattri_dac.da_args = args; attr->xattri_da_args = args;
attr->xattri_op_flags = attrp->alfi_op_flags; attr->xattri_op_flags = attrp->alfi_op_flags;
args->dp = ip; args->dp = ip;
...@@ -596,8 +595,7 @@ xfs_attri_item_recover( ...@@ -596,8 +595,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->xattri_dac, done_item, ret = xfs_xattri_finish_update(attr, done_item, attrp->alfi_op_flags);
attrp->alfi_op_flags);
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);
...@@ -612,8 +610,8 @@ xfs_attri_item_recover( ...@@ -612,8 +610,8 @@ xfs_attri_item_recover(
error = xfs_defer_ops_capture_and_commit(tp, capture_list); error = xfs_defer_ops_capture_and_commit(tp, capture_list);
out_unlock: out_unlock:
if (attr->xattri_dac.leaf_bp) if (attr->xattri_leaf_bp)
xfs_buf_relse(attr->xattri_dac.leaf_bp); xfs_buf_relse(attr->xattri_leaf_bp);
xfs_iunlock(ip, XFS_ILOCK_EXCL); xfs_iunlock(ip, XFS_ILOCK_EXCL);
xfs_irele(ip); xfs_irele(ip);
......
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