@@ -61,8 +61,8 @@ STATIC void xfs_attr_restore_rmt_blk(struct xfs_da_args *args);
61
61
static int xfs_attr_node_try_addname (struct xfs_attr_item * attr );
62
62
STATIC int xfs_attr_node_addname_find_attr (struct xfs_attr_item * attr );
63
63
STATIC int xfs_attr_node_remove_attr (struct xfs_attr_item * attr );
64
- STATIC int xfs_attr_node_hasname ( xfs_da_args_t * args ,
65
- struct xfs_da_state * * state );
64
+ STATIC int xfs_attr_node_lookup ( struct xfs_da_args * args ,
65
+ struct xfs_da_state * state );
66
66
67
67
int
68
68
xfs_inode_hasattr (
@@ -594,6 +594,19 @@ xfs_attr_leaf_mark_incomplete(
594
594
return xfs_attr3_leaf_setflag (args );
595
595
}
596
596
597
+ /* Ensure the da state of an xattr deferred work item is ready to go. */
598
+ static inline void
599
+ xfs_attr_item_init_da_state (
600
+ struct xfs_attr_item * attr )
601
+ {
602
+ struct xfs_da_args * args = attr -> xattri_da_args ;
603
+
604
+ if (!attr -> xattri_da_state )
605
+ attr -> xattri_da_state = xfs_da_state_alloc (args );
606
+ else
607
+ xfs_da_state_reset (attr -> xattri_da_state , args );
608
+ }
609
+
597
610
/*
598
611
* Initial setup for xfs_attr_node_removename. Make sure the attr is there and
599
612
* the blocks are valid. Attr keys with remote blocks will be marked
@@ -607,7 +620,8 @@ int xfs_attr_node_removename_setup(
607
620
struct xfs_da_state * state ;
608
621
int error ;
609
622
610
- error = xfs_attr_node_hasname (args , & attr -> xattri_da_state );
623
+ xfs_attr_item_init_da_state (attr );
624
+ error = xfs_attr_node_lookup (args , attr -> xattri_da_state );
611
625
if (error != - EEXIST )
612
626
goto out ;
613
627
error = 0 ;
@@ -855,6 +869,7 @@ xfs_attr_lookup(
855
869
{
856
870
struct xfs_inode * dp = args -> dp ;
857
871
struct xfs_buf * bp = NULL ;
872
+ struct xfs_da_state * state ;
858
873
int error ;
859
874
860
875
if (!xfs_inode_hasattr (dp ))
@@ -872,7 +887,10 @@ xfs_attr_lookup(
872
887
return error ;
873
888
}
874
889
875
- return xfs_attr_node_hasname (args , NULL );
890
+ state = xfs_da_state_alloc (args );
891
+ error = xfs_attr_node_lookup (args , state );
892
+ xfs_da_state_free (state );
893
+ return error ;
876
894
}
877
895
878
896
static int
@@ -1387,34 +1405,20 @@ xfs_attr_leaf_get(xfs_da_args_t *args)
1387
1405
return error ;
1388
1406
}
1389
1407
1390
- /*
1391
- * Return EEXIST if attr is found, or ENOATTR if not
1392
- * statep: If not null is set to point at the found state. Caller will
1393
- * be responsible for freeing the state in this case.
1394
- */
1408
+ /* Return EEXIST if attr is found, or ENOATTR if not. */
1395
1409
STATIC int
1396
- xfs_attr_node_hasname (
1410
+ xfs_attr_node_lookup (
1397
1411
struct xfs_da_args * args ,
1398
- struct xfs_da_state * * statep )
1412
+ struct xfs_da_state * state )
1399
1413
{
1400
- struct xfs_da_state * state ;
1401
1414
int retval , error ;
1402
1415
1403
- state = xfs_da_state_alloc (args );
1404
- if (statep != NULL ) {
1405
- ASSERT (* statep == NULL );
1406
- * statep = state ;
1407
- }
1408
-
1409
1416
/*
1410
1417
* Search to see if name exists, and get back a pointer to it.
1411
1418
*/
1412
1419
error = xfs_da3_node_lookup_int (state , & retval );
1413
1420
if (error )
1414
- retval = error ;
1415
-
1416
- if (!statep )
1417
- xfs_da_state_free (state );
1421
+ return error ;
1418
1422
1419
1423
return retval ;
1420
1424
}
@@ -1430,15 +1434,12 @@ xfs_attr_node_addname_find_attr(
1430
1434
struct xfs_da_args * args = attr -> xattri_da_args ;
1431
1435
int error ;
1432
1436
1433
- if (attr -> xattri_da_state )
1434
- xfs_da_state_free (attr -> xattri_da_state );
1435
- attr -> xattri_da_state = NULL ;
1436
-
1437
1437
/*
1438
1438
* Search to see if name already exists, and get back a pointer
1439
1439
* to where it should go.
1440
1440
*/
1441
- error = xfs_attr_node_hasname (args , & attr -> xattri_da_state );
1441
+ xfs_attr_item_init_da_state (attr );
1442
+ error = xfs_attr_node_lookup (args , attr -> xattri_da_state );
1442
1443
switch (error ) {
1443
1444
case - ENOATTR :
1444
1445
if (args -> op_flags & XFS_DA_OP_REPLACE )
@@ -1599,7 +1600,7 @@ STATIC int
1599
1600
xfs_attr_node_get (
1600
1601
struct xfs_da_args * args )
1601
1602
{
1602
- struct xfs_da_state * state = NULL ;
1603
+ struct xfs_da_state * state ;
1603
1604
struct xfs_da_state_blk * blk ;
1604
1605
int i ;
1605
1606
int error ;
@@ -1609,7 +1610,8 @@ xfs_attr_node_get(
1609
1610
/*
1610
1611
* Search to see if name exists, and get back a pointer to it.
1611
1612
*/
1612
- error = xfs_attr_node_hasname (args , & state );
1613
+ state = xfs_da_state_alloc (args );
1614
+ error = xfs_attr_node_lookup (args , state );
1613
1615
if (error != - EEXIST )
1614
1616
goto out_release ;
1615
1617
@@ -1628,8 +1630,7 @@ xfs_attr_node_get(
1628
1630
state -> path .blk [i ].bp = NULL ;
1629
1631
}
1630
1632
1631
- if (state )
1632
- xfs_da_state_free (state );
1633
+ xfs_da_state_free (state );
1633
1634
return error ;
1634
1635
}
1635
1636
0 commit comments