Skip to content

Commit 2e7ef21

Browse files
Dave Chinnerdchinner
authored andcommitted
xfs: remote xattr removal in xfs_attr_set_iter() is conditional
We may not have a remote value for the old xattr we have to remove, so skip over the remote value removal states and go straight to the xattr name removal in the leaf/node block. 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 411b434 commit 2e7ef21

File tree

3 files changed

+36
-35
lines changed

3 files changed

+36
-35
lines changed

fs/xfs/libxfs/xfs_attr.c

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -494,15 +494,14 @@ xfs_attr_set_iter(
494494
/*
495495
* We must "flip" the incomplete flags on the "new" and "old"
496496
* attribute/value pairs so that one disappears and one appears
497-
* atomically. Then we must remove the "old" attribute/value
498-
* pair.
497+
* atomically.
499498
*/
500499
error = xfs_attr3_leaf_flipflags(args);
501500
if (error)
502501
return error;
503502
/*
504-
* Commit the flag value change and start the next trans
505-
* in series at REMOVE_OLD.
503+
* We must commit the flag value change now to make it atomic
504+
* and then we can start the next trans in series at REMOVE_OLD.
506505
*/
507506
error = -EAGAIN;
508507
attr->xattri_dela_state++;
@@ -511,41 +510,43 @@ xfs_attr_set_iter(
511510
case XFS_DAS_LEAF_REMOVE_OLD:
512511
case XFS_DAS_NODE_REMOVE_OLD:
513512
/*
514-
* Dismantle the "old" attribute/value pair by removing a
515-
* "remote" value (if it exists).
513+
* If we have a remote attr, start the process of removing it
514+
* by invalidating any cached buffers.
515+
*
516+
* If we don't have a remote attr, we skip the remote block
517+
* removal state altogether with a second state increment.
516518
*/
517519
xfs_attr_restore_rmt_blk(args);
518-
error = xfs_attr_rmtval_invalidate(args);
519-
if (error)
520-
return error;
521-
522-
attr->xattri_dela_state++;
523-
fallthrough;
524-
case XFS_DAS_RM_LBLK:
525-
case XFS_DAS_RM_NBLK:
526520
if (args->rmtblkno) {
527-
error = xfs_attr_rmtval_remove(attr);
528-
if (error == -EAGAIN)
529-
trace_xfs_attr_set_iter_return(
530-
attr->xattri_dela_state, args->dp);
521+
error = xfs_attr_rmtval_invalidate(args);
531522
if (error)
532523
return error;
533-
534-
attr->xattri_dela_state = XFS_DAS_RD_LEAF;
535-
trace_xfs_attr_set_iter_return(attr->xattri_dela_state,
536-
args->dp);
537-
return -EAGAIN;
524+
} else {
525+
attr->xattri_dela_state++;
538526
}
539527

528+
attr->xattri_dela_state++;
529+
goto next_state;
530+
531+
case XFS_DAS_LEAF_REMOVE_RMT:
532+
case XFS_DAS_NODE_REMOVE_RMT:
533+
error = xfs_attr_rmtval_remove(attr);
534+
if (error == -EAGAIN)
535+
break;
536+
if (error)
537+
return error;
538+
540539
/*
541-
* This is the end of the shared leaf/node sequence. We need
542-
* to continue at the next state in the sequence, but we can't
543-
* easily just fall through. So we increment to the next state
544-
* and then jump back to switch statement to evaluate the next
545-
* state correctly.
540+
* We've finished removing the remote attr blocks, so commit the
541+
* transaction and move on to removing the attr name from the
542+
* leaf/node block. Removing the attr might require a full
543+
* transaction reservation for btree block freeing, so we
544+
* can't do that in the same transaction where we removed the
545+
* remote attr blocks.
546546
*/
547+
error = -EAGAIN;
547548
attr->xattri_dela_state++;
548-
goto next_state;
549+
break;
549550

550551
case XFS_DAS_RD_LEAF:
551552
/*

fs/xfs/libxfs/xfs_attr.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -456,15 +456,15 @@ enum xfs_delattr_state {
456456
XFS_DAS_LEAF_ALLOC_RMT, /* We are allocating remote blocks */
457457
XFS_DAS_LEAF_REPLACE, /* Perform replace ops on a leaf */
458458
XFS_DAS_LEAF_REMOVE_OLD, /* Start removing old attr from leaf */
459-
XFS_DAS_RM_LBLK, /* A rename is removing leaf blocks */
459+
XFS_DAS_LEAF_REMOVE_RMT, /* A rename is removing remote blocks */
460460
XFS_DAS_RD_LEAF, /* Read in the new leaf */
461461

462462
/* Node state set sequence, must match leaf state above */
463463
XFS_DAS_NODE_SET_RMT, /* set a remote xattr from a node */
464464
XFS_DAS_NODE_ALLOC_RMT, /* We are allocating remote blocks */
465465
XFS_DAS_NODE_REPLACE, /* Perform replace ops on a node */
466466
XFS_DAS_NODE_REMOVE_OLD, /* Start removing old attr from node */
467-
XFS_DAS_RM_NBLK, /* A rename is removing node blocks */
467+
XFS_DAS_NODE_REMOVE_RMT, /* A rename is removing remote blocks */
468468
XFS_DAS_CLR_FLAG, /* Clear incomplete flag */
469469

470470
XFS_DAS_DONE, /* finished operation */
@@ -482,13 +482,13 @@ enum xfs_delattr_state {
482482
{ XFS_DAS_LEAF_ALLOC_RMT, "XFS_DAS_LEAF_ALLOC_RMT" }, \
483483
{ XFS_DAS_LEAF_REPLACE, "XFS_DAS_LEAF_REPLACE" }, \
484484
{ XFS_DAS_LEAF_REMOVE_OLD, "XFS_DAS_LEAF_REMOVE_OLD" }, \
485-
{ XFS_DAS_RM_LBLK, "XFS_DAS_RM_LBLK" }, \
485+
{ XFS_DAS_LEAF_REMOVE_RMT, "XFS_DAS_LEAF_REMOVE_RMT" }, \
486486
{ XFS_DAS_RD_LEAF, "XFS_DAS_RD_LEAF" }, \
487487
{ XFS_DAS_NODE_SET_RMT, "XFS_DAS_NODE_SET_RMT" }, \
488488
{ XFS_DAS_NODE_ALLOC_RMT, "XFS_DAS_NODE_ALLOC_RMT" }, \
489489
{ XFS_DAS_NODE_REPLACE, "XFS_DAS_NODE_REPLACE" }, \
490490
{ XFS_DAS_NODE_REMOVE_OLD, "XFS_DAS_NODE_REMOVE_OLD" }, \
491-
{ XFS_DAS_RM_NBLK, "XFS_DAS_RM_NBLK" }, \
491+
{ XFS_DAS_NODE_REMOVE_RMT, "XFS_DAS_NODE_REMOVE_RMT" }, \
492492
{ XFS_DAS_CLR_FLAG, "XFS_DAS_CLR_FLAG" }, \
493493
{ XFS_DAS_DONE, "XFS_DAS_DONE" }
494494

fs/xfs/xfs_trace.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4140,13 +4140,13 @@ TRACE_DEFINE_ENUM(XFS_DAS_LEAF_SET_RMT);
41404140
TRACE_DEFINE_ENUM(XFS_DAS_LEAF_ALLOC_RMT);
41414141
TRACE_DEFINE_ENUM(XFS_DAS_LEAF_REPLACE);
41424142
TRACE_DEFINE_ENUM(XFS_DAS_LEAF_REMOVE_OLD);
4143-
TRACE_DEFINE_ENUM(XFS_DAS_RM_LBLK);
4143+
TRACE_DEFINE_ENUM(XFS_DAS_LEAF_REMOVE_RMT);
41444144
TRACE_DEFINE_ENUM(XFS_DAS_RD_LEAF);
41454145
TRACE_DEFINE_ENUM(XFS_DAS_NODE_SET_RMT);
41464146
TRACE_DEFINE_ENUM(XFS_DAS_NODE_ALLOC_RMT);
41474147
TRACE_DEFINE_ENUM(XFS_DAS_NODE_REPLACE);
41484148
TRACE_DEFINE_ENUM(XFS_DAS_NODE_REMOVE_OLD);
4149-
TRACE_DEFINE_ENUM(XFS_DAS_RM_NBLK);
4149+
TRACE_DEFINE_ENUM(XFS_DAS_NODE_REMOVE_RMT);
41504150
TRACE_DEFINE_ENUM(XFS_DAS_CLR_FLAG);
41514151

41524152
DECLARE_EVENT_CLASS(xfs_das_state_class,

0 commit comments

Comments
 (0)