@@ -289,7 +289,6 @@ xfs_attr_sf_addname(
289289 */
290290 xfs_trans_bhold (args -> trans , attr -> xattri_leaf_bp );
291291 attr -> xattri_dela_state = XFS_DAS_LEAF_ADD ;
292- error = - EAGAIN ;
293292out :
294293 trace_xfs_attr_sf_addname_return (attr -> xattri_dela_state , args -> dp );
295294 return error ;
@@ -342,7 +341,6 @@ xfs_attr_leaf_addname(
342341 * retry the add to the newly allocated node block.
343342 */
344343 attr -> xattri_dela_state = XFS_DAS_NODE_ADD ;
345- error = - EAGAIN ;
346344 goto out ;
347345 }
348346 if (error )
@@ -353,20 +351,24 @@ xfs_attr_leaf_addname(
353351 * or perform more xattr manipulations. Otherwise there is nothing more
354352 * to do and we can return success.
355353 */
356- if (args -> rmtblkno ) {
354+ if (args -> rmtblkno )
357355 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 )
360357 xfs_attr_dela_state_set_replace (attr , XFS_DAS_LEAF_REPLACE );
361- error = - EAGAIN ;
362- } else {
358+ else
363359 attr -> xattri_dela_state = XFS_DAS_DONE ;
364- }
365360out :
366361 trace_xfs_attr_leaf_addname_return (attr -> xattri_dela_state , args -> dp );
367362 return error ;
368363}
369364
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+ */
370372static int
371373xfs_attr_node_addname (
372374 struct xfs_attr_item * attr )
@@ -381,19 +383,26 @@ xfs_attr_node_addname(
381383 return error ;
382384
383385 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+ }
384396 if (error )
385397 return error ;
386398
387- if (args -> rmtblkno ) {
399+ if (args -> rmtblkno )
388400 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 )
391402 xfs_attr_dela_state_set_replace (attr , XFS_DAS_NODE_REPLACE );
392- error = - EAGAIN ;
393- } else {
403+ else
394404 attr -> xattri_dela_state = XFS_DAS_DONE ;
395- }
396-
405+ out :
397406 trace_xfs_attr_node_addname_return (attr -> xattri_dela_state , args -> dp );
398407 return error ;
399408}
@@ -416,10 +425,8 @@ xfs_attr_rmtval_alloc(
416425 if (error )
417426 return error ;
418427 /* 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 )
421429 goto out ;
422- }
423430 }
424431
425432 error = xfs_attr_rmtval_set_value (args );
@@ -515,11 +522,12 @@ xfs_attr_leaf_shrink(
515522}
516523
517524/*
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.
523531 */
524532int
525533xfs_attr_set_iter (
@@ -572,7 +580,6 @@ xfs_attr_set_iter(
572580 * We must commit the flag value change now to make it atomic
573581 * and then we can start the next trans in series at REMOVE_OLD.
574582 */
575- error = - EAGAIN ;
576583 attr -> xattri_dela_state ++ ;
577584 break ;
578585
@@ -600,8 +607,10 @@ xfs_attr_set_iter(
600607 case XFS_DAS_LEAF_REMOVE_RMT :
601608 case XFS_DAS_NODE_REMOVE_RMT :
602609 error = xfs_attr_rmtval_remove (attr );
603- if (error == - EAGAIN )
610+ if (error == - EAGAIN ) {
611+ error = 0 ;
604612 break ;
613+ }
605614 if (error )
606615 return error ;
607616
@@ -613,7 +622,6 @@ xfs_attr_set_iter(
613622 * can't do that in the same transaction where we removed the
614623 * remote attr blocks.
615624 */
616- error = - EAGAIN ;
617625 attr -> xattri_dela_state ++ ;
618626 break ;
619627
@@ -1249,14 +1257,6 @@ xfs_attr_node_addname_find_attr(
12491257 * This will involve walking down the Btree, and may involve splitting
12501258 * leaf nodes and even splitting intermediate nodes up to and including
12511259 * 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.
12601260 */
12611261static int
12621262xfs_attr_node_try_addname (
@@ -1278,24 +1278,9 @@ xfs_attr_node_try_addname(
12781278 /*
12791279 * Its really a single leaf node, but it had
12801280 * 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.
12951282 */
1296- trace_xfs_attr_node_addname_return (
1297- attr -> xattri_dela_state , args -> dp );
1298- return - EAGAIN ;
1283+ goto out ;
12991284 }
13001285
13011286 /*
@@ -1315,8 +1300,7 @@ xfs_attr_node_try_addname(
13151300 }
13161301
13171302out :
1318- if (state )
1319- xfs_da_state_free (state );
1303+ xfs_da_state_free (state );
13201304 return error ;
13211305}
13221306
0 commit comments