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
This diff is collapsed.
......@@ -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
* they were before they returned -EAGAIN. A return code of -EAGAIN signals the
......@@ -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*/
/*
* Context used for keeping track of delayed attribute operations
*/
struct xfs_delattr_context {
struct xfs_da_args *da_args;
struct xfs_attr_item {
struct xfs_da_args *xattri_da_args;
/*
* 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 */
struct xfs_bmbt_irec map;
xfs_dablk_t lblkno;
int blkcnt;
struct xfs_bmbt_irec xattri_map;
xfs_dablk_t xattri_lblkno;
int xattri_blkcnt;
/* 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 */
unsigned int flags;
enum xfs_delattr_state dela_state;
};
/*
* List of attrs to commit later.
*/
struct xfs_attr_item {
struct xfs_delattr_context xattri_dac;
unsigned int xattri_flags;
enum xfs_delattr_state xattri_dela_state;
/*
* Indicates if the attr operation is a set or a remove
......@@ -499,7 +492,10 @@ struct xfs_attr_item {
*/
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;
};
......@@ -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(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_remove_iter(struct xfs_delattr_context *dac);
int xfs_attr_set_iter(struct xfs_attr_item *attr);
int xfs_attr_remove_iter(struct xfs_attr_item *attr);
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_set_deferred(struct xfs_da_args *args);
int xfs_attr_remove_deferred(struct xfs_da_args *args);
......
......@@ -568,14 +568,14 @@ xfs_attr_rmtval_stale(
*/
int
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_bmbt_irec *map = &dac->map;
struct xfs_da_args *args = attr->xattri_da_args;
struct xfs_bmbt_irec *map = &attr->xattri_map;
int error;
dac->lblkno = 0;
dac->blkcnt = 0;
attr->xattri_lblkno = 0;
attr->xattri_blkcnt = 0;
args->rmtblkcnt = 0;
args->rmtblkno = 0;
memset(map, 0, sizeof(struct xfs_bmbt_irec));
......@@ -584,8 +584,8 @@ xfs_attr_rmtval_find_space(
if (error)
return error;
dac->blkcnt = args->rmtblkcnt;
dac->lblkno = args->rmtblkno;
attr->xattri_blkcnt = args->rmtblkcnt;
attr->xattri_lblkno = args->rmtblkno;
return 0;
}
......@@ -598,17 +598,18 @@ xfs_attr_rmtval_find_space(
*/
int
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_bmbt_irec *map = &dac->map;
struct xfs_bmbt_irec *map = &attr->xattri_map;
int nmap;
int error;
nmap = 1;
error = xfs_bmapi_write(args->trans, dp, (xfs_fileoff_t)dac->lblkno,
dac->blkcnt, XFS_BMAPI_ATTRFORK, args->total,
error = xfs_bmapi_write(args->trans, dp,
(xfs_fileoff_t)attr->xattri_lblkno,
attr->xattri_blkcnt, XFS_BMAPI_ATTRFORK, args->total,
map, &nmap);
if (error)
return error;
......@@ -618,8 +619,8 @@ xfs_attr_rmtval_set_blk(
(map->br_startblock != HOLESTARTBLOCK));
/* roll attribute extent map forwards */
dac->lblkno += map->br_blockcount;
dac->blkcnt -= map->br_blockcount;
attr->xattri_lblkno += map->br_blockcount;
attr->xattri_blkcnt -= map->br_blockcount;
return 0;
}
......@@ -673,9 +674,9 @@ xfs_attr_rmtval_invalidate(
*/
int
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;
/*
......@@ -695,7 +696,8 @@ xfs_attr_rmtval_remove(
* the parent
*/
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;
}
......
......@@ -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,
xfs_buf_flags_t incore_flags);
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_rmtval_set_value(struct xfs_da_args *args);
int xfs_attr_rmtval_set_blk(struct xfs_delattr_context *dac);
int xfs_attr_rmtval_find_space(struct xfs_delattr_context *dac);
int xfs_attr_rmtval_set_blk(struct xfs_attr_item *attr);
int xfs_attr_rmtval_find_space(struct xfs_attr_item *attr);
#endif /* __XFS_ATTR_REMOTE_H__ */
......@@ -302,11 +302,11 @@ xfs_attrd_item_intent(
*/
STATIC int
xfs_xattri_finish_update(
struct xfs_delattr_context *dac,
struct xfs_attr_item *attr,
struct xfs_attrd_log_item *attrdp,
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 &
XFS_ATTR_OP_FLAGS_TYPE_MASK;
int error;
......@@ -318,11 +318,11 @@ xfs_xattri_finish_update(
switch (op) {
case XFS_ATTR_OP_FLAGS_SET:
error = xfs_attr_set_iter(dac);
error = xfs_attr_set_iter(attr);
break;
case XFS_ATTR_OP_FLAGS_REMOVE:
ASSERT(XFS_IFORK_Q(args->dp));
error = xfs_attr_remove_iter(dac);
error = xfs_attr_remove_iter(attr);
break;
default:
error = -EFSCORRUPTED;
......@@ -366,18 +366,18 @@ xfs_attr_log_item(
* structure with fields from this xfs_attr_item
*/
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_value_len = attr->xattri_dac.da_args->valuelen;
attrp->alfi_name_len = attr->xattri_dac.da_args->namelen;
attrp->alfi_attr_flags = attr->xattri_dac.da_args->attr_filter;
memcpy(attrip->attri_name, attr->xattri_dac.da_args->name,
attr->xattri_dac.da_args->namelen);
memcpy(attrip->attri_value, attr->xattri_dac.da_args->value,
attr->xattri_dac.da_args->valuelen);
attrip->attri_name_len = attr->xattri_dac.da_args->namelen;
attrip->attri_value_len = attr->xattri_dac.da_args->valuelen;
attrp->alfi_value_len = attr->xattri_da_args->valuelen;
attrp->alfi_name_len = attr->xattri_da_args->namelen;
attrp->alfi_attr_flags = attr->xattri_da_args->attr_filter;
memcpy(attrip->attri_name, attr->xattri_da_args->name,
attr->xattri_da_args->namelen);
memcpy(attrip->attri_value, attr->xattri_da_args->value,
attr->xattri_da_args->valuelen);
attrip->attri_name_len = attr->xattri_da_args->namelen;
attrip->attri_value_len = attr->xattri_da_args->valuelen;
}
/* Get an ATTRI. */
......@@ -402,8 +402,8 @@ xfs_attr_create_intent(
* this is a list of one
*/
list_for_each_entry(attr, items, xattri_list) {
attrip = xfs_attri_init(mp, attr->xattri_dac.da_args->namelen,
attr->xattri_dac.da_args->valuelen);
attrip = xfs_attri_init(mp, attr->xattri_da_args->namelen,
attr->xattri_da_args->valuelen);
if (attrip == NULL)
return NULL;
......@@ -425,10 +425,8 @@ xfs_attr_finish_item(
struct xfs_attr_item *attr;
struct xfs_attrd_log_item *done_item = NULL;
int error;
struct xfs_delattr_context *dac;
attr = container_of(item, struct xfs_attr_item, xattri_list);
dac = &attr->xattri_dac;
if (done)
done_item = ATTRD_ITEM(done);
......@@ -436,9 +434,10 @@ xfs_attr_finish_item(
* Always reset trans after EAGAIN cycle
* 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)
kmem_free(attr);
......@@ -560,7 +559,7 @@ xfs_attri_item_recover(
sizeof(struct xfs_da_args), KM_NOFS);
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;
args->dp = ip;
......@@ -596,8 +595,7 @@ xfs_attri_item_recover(
xfs_ilock(ip, XFS_ILOCK_EXCL);
xfs_trans_ijoin(tp, ip, 0);
ret = xfs_xattri_finish_update(&attr->xattri_dac, done_item,
attrp->alfi_op_flags);
ret = xfs_xattri_finish_update(attr, done_item, attrp->alfi_op_flags);
if (ret == -EAGAIN) {
/* There's more work to do, so add it to this transaction */
xfs_defer_add(tp, XFS_DEFER_OPS_TYPE_ATTR, &attr->xattri_list);
......@@ -612,8 +610,8 @@ xfs_attri_item_recover(
error = xfs_defer_ops_capture_and_commit(tp, capture_list);
out_unlock:
if (attr->xattri_dac.leaf_bp)
xfs_buf_relse(attr->xattri_dac.leaf_bp);
if (attr->xattri_leaf_bp)
xfs_buf_relse(attr->xattri_leaf_bp);
xfs_iunlock(ip, XFS_ILOCK_EXCL);
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