Skip to content

Commit e53bcff

Browse files
author
Darrick J. Wong
committed
xfs: don't hold xattr leaf buffers across transaction rolls
Now that we've established (again!) that empty xattr leaf buffers are ok, we no longer need to bhold them to transactions when we're creating new leaf blocks. Get rid of the entire mechanism, which should simplify the xattr code quite a bit. The original justification for using bhold here was to prevent the AIL from trying to write the empty leaf block into the fs during the brief time that we release the buffer lock. The reason for /that/ was to prevent recovery from tripping over the empty ondisk block. Reviewed-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Darrick J. Wong <djwong@kernel.org>
1 parent 7be3bd8 commit e53bcff

File tree

5 files changed

+12
-65
lines changed

5 files changed

+12
-65
lines changed

fs/xfs/libxfs/xfs_attr.c

Lines changed: 9 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ STATIC int xfs_attr_shortform_addname(xfs_da_args_t *args);
5050
STATIC int xfs_attr_leaf_get(xfs_da_args_t *args);
5151
STATIC int xfs_attr_leaf_removename(xfs_da_args_t *args);
5252
STATIC int xfs_attr_leaf_hasname(struct xfs_da_args *args, struct xfs_buf **bp);
53-
STATIC int xfs_attr_leaf_try_add(struct xfs_da_args *args, struct xfs_buf *bp);
53+
STATIC int xfs_attr_leaf_try_add(struct xfs_da_args *args);
5454

5555
/*
5656
* Internal routines when attribute list is more than one block.
@@ -393,16 +393,10 @@ xfs_attr_sf_addname(
393393
* It won't fit in the shortform, transform to a leaf block. GROT:
394394
* another possible req'mt for a double-split btree op.
395395
*/
396-
error = xfs_attr_shortform_to_leaf(args, &attr->xattri_leaf_bp);
396+
error = xfs_attr_shortform_to_leaf(args);
397397
if (error)
398398
return error;
399399

400-
/*
401-
* Prevent the leaf buffer from being unlocked so that a concurrent AIL
402-
* push cannot grab the half-baked leaf buffer and run into problems
403-
* with the write verifier.
404-
*/
405-
xfs_trans_bhold(args->trans, attr->xattri_leaf_bp);
406400
attr->xattri_dela_state = XFS_DAS_LEAF_ADD;
407401
out:
408402
trace_xfs_attr_sf_addname_return(attr->xattri_dela_state, args->dp);
@@ -447,11 +441,9 @@ xfs_attr_leaf_addname(
447441

448442
/*
449443
* Use the leaf buffer we may already hold locked as a result of
450-
* a sf-to-leaf conversion. The held buffer is no longer valid
451-
* after this call, regardless of the result.
444+
* a sf-to-leaf conversion.
452445
*/
453-
error = xfs_attr_leaf_try_add(args, attr->xattri_leaf_bp);
454-
attr->xattri_leaf_bp = NULL;
446+
error = xfs_attr_leaf_try_add(args);
455447

456448
if (error == -ENOSPC) {
457449
error = xfs_attr3_leaf_to_node(args);
@@ -497,8 +489,6 @@ xfs_attr_node_addname(
497489
struct xfs_da_args *args = attr->xattri_da_args;
498490
int error;
499491

500-
ASSERT(!attr->xattri_leaf_bp);
501-
502492
error = xfs_attr_node_addname_find_attr(attr);
503493
if (error)
504494
return error;
@@ -1215,24 +1205,14 @@ xfs_attr_restore_rmt_blk(
12151205
*/
12161206
STATIC int
12171207
xfs_attr_leaf_try_add(
1218-
struct xfs_da_args *args,
1219-
struct xfs_buf *bp)
1208+
struct xfs_da_args *args)
12201209
{
1210+
struct xfs_buf *bp;
12211211
int error;
12221212

1223-
/*
1224-
* If the caller provided a buffer to us, it is locked and held in
1225-
* the transaction because it just did a shortform to leaf conversion.
1226-
* Hence we don't need to read it again. Otherwise read in the leaf
1227-
* buffer.
1228-
*/
1229-
if (bp) {
1230-
xfs_trans_bhold_release(args->trans, bp);
1231-
} else {
1232-
error = xfs_attr3_leaf_read(args->trans, args->dp, 0, &bp);
1233-
if (error)
1234-
return error;
1235-
}
1213+
error = xfs_attr3_leaf_read(args->trans, args->dp, 0, &bp);
1214+
if (error)
1215+
return error;
12361216

12371217
/*
12381218
* Look up the xattr name to set the insertion point for the new xattr.

fs/xfs/libxfs/xfs_attr.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -515,11 +515,6 @@ struct xfs_attr_intent {
515515
*/
516516
struct xfs_attri_log_nameval *xattri_nameval;
517517

518-
/*
519-
* Used by xfs_attr_set to hold a leaf buffer across a transaction roll
520-
*/
521-
struct xfs_buf *xattri_leaf_bp;
522-
523518
/* Used to keep track of current state of delayed operation */
524519
enum xfs_delattr_state xattri_dela_state;
525520

fs/xfs/libxfs/xfs_attr_leaf.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -930,14 +930,10 @@ xfs_attr_shortform_getvalue(
930930
return -ENOATTR;
931931
}
932932

933-
/*
934-
* Convert from using the shortform to the leaf. On success, return the
935-
* buffer so that we can keep it locked until we're totally done with it.
936-
*/
933+
/* Convert from using the shortform to the leaf format. */
937934
int
938935
xfs_attr_shortform_to_leaf(
939-
struct xfs_da_args *args,
940-
struct xfs_buf **leaf_bp)
936+
struct xfs_da_args *args)
941937
{
942938
struct xfs_inode *dp;
943939
struct xfs_attr_shortform *sf;
@@ -999,7 +995,6 @@ xfs_attr_shortform_to_leaf(
999995
sfe = xfs_attr_sf_nextentry(sfe);
1000996
}
1001997
error = 0;
1002-
*leaf_bp = bp;
1003998
out:
1004999
kmem_free(tmpbuffer);
10051000
return error;

fs/xfs/libxfs/xfs_attr_leaf.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,7 @@ void xfs_attr_shortform_create(struct xfs_da_args *args);
4949
void xfs_attr_shortform_add(struct xfs_da_args *args, int forkoff);
5050
int xfs_attr_shortform_lookup(struct xfs_da_args *args);
5151
int xfs_attr_shortform_getvalue(struct xfs_da_args *args);
52-
int xfs_attr_shortform_to_leaf(struct xfs_da_args *args,
53-
struct xfs_buf **leaf_bp);
52+
int xfs_attr_shortform_to_leaf(struct xfs_da_args *args);
5453
int xfs_attr_sf_removename(struct xfs_da_args *args);
5554
int xfs_attr_sf_findname(struct xfs_da_args *args,
5655
struct xfs_attr_sf_entry **sfep,

fs/xfs/xfs_attr_item.c

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -455,8 +455,6 @@ static inline void
455455
xfs_attr_free_item(
456456
struct xfs_attr_intent *attr)
457457
{
458-
ASSERT(attr->xattri_leaf_bp == NULL);
459-
460458
if (attr->xattri_da_state)
461459
xfs_da_state_free(attr->xattri_da_state);
462460
xfs_attri_log_nameval_put(attr->xattri_nameval);
@@ -511,10 +509,6 @@ xfs_attr_cancel_item(
511509
struct xfs_attr_intent *attr;
512510

513511
attr = container_of(item, struct xfs_attr_intent, xattri_list);
514-
if (attr->xattri_leaf_bp) {
515-
xfs_buf_relse(attr->xattri_leaf_bp);
516-
attr->xattri_leaf_bp = NULL;
517-
}
518512
xfs_attr_free_item(attr);
519513
}
520514

@@ -672,16 +666,6 @@ xfs_attri_item_recover(
672666
if (error)
673667
goto out_unlock;
674668

675-
/*
676-
* The defer capture structure took its own reference to the
677-
* attr leaf buffer and will give that to the continuation
678-
* transaction. The attr intent struct drives the continuation
679-
* work, so release our refcount on the attr leaf buffer but
680-
* retain the pointer in the intent structure.
681-
*/
682-
if (attr->xattri_leaf_bp)
683-
xfs_buf_relse(attr->xattri_leaf_bp);
684-
685669
xfs_iunlock(ip, XFS_ILOCK_EXCL);
686670
xfs_irele(ip);
687671
return 0;
@@ -692,13 +676,7 @@ xfs_attri_item_recover(
692676
}
693677

694678
error = xfs_defer_ops_capture_and_commit(tp, capture_list);
695-
696679
out_unlock:
697-
if (attr->xattri_leaf_bp) {
698-
xfs_buf_relse(attr->xattri_leaf_bp);
699-
attr->xattri_leaf_bp = NULL;
700-
}
701-
702680
xfs_iunlock(ip, XFS_ILOCK_EXCL);
703681
xfs_irele(ip);
704682
out:

0 commit comments

Comments
 (0)