@@ -289,7 +289,6 @@ xfs_attr_sf_addname(
289
289
*/
290
290
xfs_trans_bhold (args -> trans , attr -> xattri_leaf_bp );
291
291
attr -> xattri_dela_state = XFS_DAS_LEAF_ADD ;
292
- error = - EAGAIN ;
293
292
out :
294
293
trace_xfs_attr_sf_addname_return (attr -> xattri_dela_state , args -> dp );
295
294
return error ;
@@ -342,7 +341,6 @@ xfs_attr_leaf_addname(
342
341
* retry the add to the newly allocated node block.
343
342
*/
344
343
attr -> xattri_dela_state = XFS_DAS_NODE_ADD ;
345
- error = - EAGAIN ;
346
344
goto out ;
347
345
}
348
346
if (error )
@@ -353,20 +351,24 @@ xfs_attr_leaf_addname(
353
351
* or perform more xattr manipulations. Otherwise there is nothing more
354
352
* to do and we can return success.
355
353
*/
356
- if (args -> rmtblkno ) {
354
+ if (args -> rmtblkno )
357
355
attr -> xattri_dela_state = XFS_DAS_LEAF_SET_RMT ;
358
- error = - EAGAIN ;
359
- } else if (args -> op_flags & XFS_DA_OP_RENAME ) {
356
+ else if (args -> op_flags & XFS_DA_OP_RENAME )
360
357
xfs_attr_dela_state_set_replace (attr , XFS_DAS_LEAF_REPLACE );
361
- error = - EAGAIN ;
362
- } else {
358
+ else
363
359
attr -> xattri_dela_state = XFS_DAS_DONE ;
364
- }
365
360
out :
366
361
trace_xfs_attr_leaf_addname_return (attr -> xattri_dela_state , args -> dp );
367
362
return error ;
368
363
}
369
364
365
+ /*
366
+ * Add an entry to a node format attr tree.
367
+ *
368
+ * Note that we might still have a leaf here - xfs_attr_is_leaf() cannot tell
369
+ * the difference between leaf + remote attr blocks and a node format tree,
370
+ * so we may still end up having to convert from leaf to node format here.
371
+ */
370
372
static int
371
373
xfs_attr_node_addname (
372
374
struct xfs_attr_item * attr )
@@ -381,19 +383,26 @@ xfs_attr_node_addname(
381
383
return error ;
382
384
383
385
error = xfs_attr_node_try_addname (attr );
386
+ if (error == - ENOSPC ) {
387
+ error = xfs_attr3_leaf_to_node (args );
388
+ if (error )
389
+ return error ;
390
+ /*
391
+ * No state change, we really are in node form now
392
+ * but we need the transaction rolled to continue.
393
+ */
394
+ goto out ;
395
+ }
384
396
if (error )
385
397
return error ;
386
398
387
- if (args -> rmtblkno ) {
399
+ if (args -> rmtblkno )
388
400
attr -> xattri_dela_state = XFS_DAS_NODE_SET_RMT ;
389
- error = - EAGAIN ;
390
- } else if (args -> op_flags & XFS_DA_OP_RENAME ) {
401
+ else if (args -> op_flags & XFS_DA_OP_RENAME )
391
402
xfs_attr_dela_state_set_replace (attr , XFS_DAS_NODE_REPLACE );
392
- error = - EAGAIN ;
393
- } else {
403
+ else
394
404
attr -> xattri_dela_state = XFS_DAS_DONE ;
395
- }
396
-
405
+ out :
397
406
trace_xfs_attr_node_addname_return (attr -> xattri_dela_state , args -> dp );
398
407
return error ;
399
408
}
@@ -416,10 +425,8 @@ xfs_attr_rmtval_alloc(
416
425
if (error )
417
426
return error ;
418
427
/* Roll the transaction only if there is more to allocate. */
419
- if (attr -> xattri_blkcnt > 0 ) {
420
- error = - EAGAIN ;
428
+ if (attr -> xattri_blkcnt > 0 )
421
429
goto out ;
422
- }
423
430
}
424
431
425
432
error = xfs_attr_rmtval_set_value (args );
@@ -515,11 +522,12 @@ xfs_attr_leaf_shrink(
515
522
}
516
523
517
524
/*
518
- * Set the attribute specified in @args.
519
- * This routine is meant to function as a delayed operation, and may return
520
- * -EAGAIN when the transaction needs to be rolled. Calling functions will need
521
- * to handle this, and recall the function until a successful error code is
522
- * returned.
525
+ * Run the attribute operation specified in @attr.
526
+ *
527
+ * This routine is meant to function as a delayed operation and will set the
528
+ * state to XFS_DAS_DONE when the operation is complete. Calling functions will
529
+ * need to handle this, and recall the function until either an error or
530
+ * XFS_DAS_DONE is detected.
523
531
*/
524
532
int
525
533
xfs_attr_set_iter (
@@ -572,7 +580,6 @@ xfs_attr_set_iter(
572
580
* We must commit the flag value change now to make it atomic
573
581
* and then we can start the next trans in series at REMOVE_OLD.
574
582
*/
575
- error = - EAGAIN ;
576
583
attr -> xattri_dela_state ++ ;
577
584
break ;
578
585
@@ -600,8 +607,10 @@ xfs_attr_set_iter(
600
607
case XFS_DAS_LEAF_REMOVE_RMT :
601
608
case XFS_DAS_NODE_REMOVE_RMT :
602
609
error = xfs_attr_rmtval_remove (attr );
603
- if (error == - EAGAIN )
610
+ if (error == - EAGAIN ) {
611
+ error = 0 ;
604
612
break ;
613
+ }
605
614
if (error )
606
615
return error ;
607
616
@@ -613,7 +622,6 @@ xfs_attr_set_iter(
613
622
* can't do that in the same transaction where we removed the
614
623
* remote attr blocks.
615
624
*/
616
- error = - EAGAIN ;
617
625
attr -> xattri_dela_state ++ ;
618
626
break ;
619
627
@@ -1249,14 +1257,6 @@ xfs_attr_node_addname_find_attr(
1249
1257
* This will involve walking down the Btree, and may involve splitting
1250
1258
* leaf nodes and even splitting intermediate nodes up to and including
1251
1259
* the root node (a special case of an intermediate node).
1252
- *
1253
- * "Remote" attribute values confuse the issue and atomic rename operations
1254
- * add a whole extra layer of confusion on top of that.
1255
- *
1256
- * This routine is meant to function as a delayed operation, and may return
1257
- * -EAGAIN when the transaction needs to be rolled. Calling functions will need
1258
- * to handle this, and recall the function until a successful error code is
1259
- *returned.
1260
1260
*/
1261
1261
static int
1262
1262
xfs_attr_node_try_addname (
@@ -1278,24 +1278,9 @@ xfs_attr_node_try_addname(
1278
1278
/*
1279
1279
* Its really a single leaf node, but it had
1280
1280
* out-of-line values so it looked like it *might*
1281
- * have been a b-tree.
1282
- */
1283
- xfs_da_state_free (state );
1284
- state = NULL ;
1285
- error = xfs_attr3_leaf_to_node (args );
1286
- if (error )
1287
- goto out ;
1288
-
1289
- /*
1290
- * Now that we have converted the leaf to a node, we can
1291
- * roll the transaction, and try xfs_attr3_leaf_add
1292
- * again on re-entry. No need to set dela_state to do
1293
- * this. dela_state is still unset by this function at
1294
- * this point.
1281
+ * have been a b-tree. Let the caller deal with this.
1295
1282
*/
1296
- trace_xfs_attr_node_addname_return (
1297
- attr -> xattri_dela_state , args -> dp );
1298
- return - EAGAIN ;
1283
+ goto out ;
1299
1284
}
1300
1285
1301
1286
/*
@@ -1315,8 +1300,7 @@ xfs_attr_node_try_addname(
1315
1300
}
1316
1301
1317
1302
out :
1318
- if (state )
1319
- xfs_da_state_free (state );
1303
+ xfs_da_state_free (state );
1320
1304
return error ;
1321
1305
}
1322
1306
0 commit comments