Skip to content

Commit 4b9879b

Browse files
Dave Chinnerdchinner
authored andcommitted
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: Dave Chinner <[email protected]> Reviewed-by: Allison Henderson <[email protected]> Reviewed-by: Darrick J. Wong <[email protected]> Signed-off-by: Dave Chinner <[email protected]>
1 parent e5d5596 commit 4b9879b

File tree

3 files changed

+26
-36
lines changed

3 files changed

+26
-36
lines changed

fs/xfs/libxfs/xfs_attr.c

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -498,13 +498,11 @@ int xfs_attr_node_removename_setup(
498498
ASSERT((*state)->path.blk[(*state)->path.active - 1].magic ==
499499
XFS_ATTR_LEAF_MAGIC);
500500

501-
if (args->rmtblkno > 0) {
502-
error = xfs_attr_leaf_mark_incomplete(args, *state);
503-
if (error)
504-
goto out;
505-
501+
error = xfs_attr_leaf_mark_incomplete(args, *state);
502+
if (error)
503+
goto out;
504+
if (args->rmtblkno > 0)
506505
error = xfs_attr_rmtval_invalidate(args);
507-
}
508506
out:
509507
if (error)
510508
xfs_da_state_free(*state);
@@ -820,7 +818,7 @@ xfs_attr_defer_remove(
820818
if (error)
821819
return error;
822820

823-
new->xattri_dela_state = XFS_DAS_UNINIT;
821+
new->xattri_dela_state = xfs_attr_init_remove_state(args);
824822
xfs_defer_add(args->trans, XFS_DEFER_OPS_TYPE_ATTR, &new->xattri_list);
825823
trace_xfs_attr_defer_remove(new->xattri_dela_state, args->dp);
826824

@@ -1388,16 +1386,15 @@ xfs_attr_node_remove_attr(
13881386
{
13891387
struct xfs_da_args *args = attr->xattri_da_args;
13901388
struct xfs_da_state *state = NULL;
1391-
struct xfs_mount *mp = args->dp->i_mount;
13921389
int retval = 0;
13931390
int error = 0;
13941391

13951392
/*
1396-
* Re-find the "old" attribute entry after any split ops. The INCOMPLETE
1397-
* flag means that we will find the "old" attr, not the "new" one.
1393+
* The attr we are removing has already been marked incomplete, so
1394+
* we need to set the filter appropriately to re-find the "old"
1395+
* attribute entry after any split ops.
13981396
*/
1399-
if (!xfs_has_larp(mp))
1400-
args->attr_filter |= XFS_ATTR_INCOMPLETE;
1397+
args->attr_filter |= XFS_ATTR_INCOMPLETE;
14011398
state = xfs_da_state_alloc(args);
14021399
state->inleaf = 0;
14031400
error = xfs_da3_node_lookup_int(state, &retval);

fs/xfs/libxfs/xfs_attr.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,16 @@ xfs_attr_init_add_state(struct xfs_da_args *args)
602602
return XFS_DAS_NODE_ADD;
603603
}
604604

605+
static inline enum xfs_delattr_state
606+
xfs_attr_init_remove_state(struct xfs_da_args *args)
607+
{
608+
if (xfs_attr_is_shortform(args->dp))
609+
return XFS_DAS_SF_REMOVE;
610+
if (xfs_attr_is_leaf(args->dp))
611+
return XFS_DAS_LEAF_REMOVE;
612+
return XFS_DAS_NODE_REMOVE;
613+
}
614+
605615
static inline enum xfs_delattr_state
606616
xfs_attr_init_replace_state(struct xfs_da_args *args)
607617
{

fs/xfs/xfs_attr_item.c

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -303,35 +303,19 @@ xfs_attrd_item_intent(
303303
STATIC int
304304
xfs_xattri_finish_update(
305305
struct xfs_attr_item *attr,
306-
struct xfs_attrd_log_item *attrdp,
307-
uint32_t op_flags)
306+
struct xfs_attrd_log_item *attrdp)
308307
{
309308
struct xfs_da_args *args = attr->xattri_da_args;
310-
unsigned int op = op_flags &
311-
XFS_ATTR_OP_FLAGS_TYPE_MASK;
312309
int error;
313310

314311
if (XFS_TEST_ERROR(false, args->dp->i_mount, XFS_ERRTAG_LARP)) {
315312
error = -EIO;
316313
goto out;
317314
}
318315

319-
switch (op) {
320-
case XFS_ATTR_OP_FLAGS_SET:
321-
case XFS_ATTR_OP_FLAGS_REPLACE:
322-
error = xfs_attr_set_iter(attr);
323-
if (!error && attr->xattri_dela_state != XFS_DAS_DONE)
324-
error = -EAGAIN;
325-
break;
326-
case XFS_ATTR_OP_FLAGS_REMOVE:
327-
ASSERT(XFS_IFORK_Q(args->dp));
328-
error = xfs_attr_remove_iter(attr);
329-
break;
330-
default:
331-
error = -EFSCORRUPTED;
332-
break;
333-
}
334-
316+
error = xfs_attr_set_iter(attr);
317+
if (!error && attr->xattri_dela_state != XFS_DAS_DONE)
318+
error = -EAGAIN;
335319
out:
336320
/*
337321
* Mark the transaction dirty, even on error. This ensures the
@@ -439,8 +423,7 @@ xfs_attr_finish_item(
439423
*/
440424
attr->xattri_da_args->trans = tp;
441425

442-
error = xfs_xattri_finish_update(attr, done_item,
443-
attr->xattri_op_flags);
426+
error = xfs_xattri_finish_update(attr, done_item);
444427
if (error != -EAGAIN)
445428
kmem_free(attr);
446429

@@ -588,7 +571,7 @@ xfs_attri_item_recover(
588571
attr->xattri_dela_state = xfs_attr_init_add_state(args);
589572
break;
590573
case XFS_ATTR_OP_FLAGS_REMOVE:
591-
attr->xattri_dela_state = XFS_DAS_UNINIT;
574+
attr->xattri_dela_state = xfs_attr_init_remove_state(args);
592575
break;
593576
default:
594577
ASSERT(0);
@@ -607,7 +590,7 @@ xfs_attri_item_recover(
607590
xfs_ilock(ip, XFS_ILOCK_EXCL);
608591
xfs_trans_ijoin(tp, ip, 0);
609592

610-
ret = xfs_xattri_finish_update(attr, done_item, attrp->alfi_op_flags);
593+
ret = xfs_xattri_finish_update(attr, done_item);
611594
if (ret == -EAGAIN) {
612595
/* There's more work to do, so add it to this transaction */
613596
xfs_defer_add(tp, XFS_DEFER_OPS_TYPE_ATTR, &attr->xattri_list);

0 commit comments

Comments
 (0)