]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blobdiff - libxfs/xfs_attr.c
xfs: remove the ip argument to xfs_defer_finish
[thirdparty/xfsprogs-dev.git] / libxfs / xfs_attr.c
index 9877692a5757bc5d754ef461933df57b89bcb214..8d0abcc120e8877ab073a553a24dbecd074a8239 100644 (file)
@@ -323,13 +323,12 @@ xfs_attr_set(
                 */
                xfs_defer_init(args.dfops, args.firstblock);
                error = xfs_attr_shortform_to_leaf(&args);
-               if (!error)
-                       error = xfs_defer_finish(&args.trans, args.dfops, dp);
-               if (error) {
-                       args.trans = NULL;
-                       xfs_defer_cancel(&dfops);
-                       goto out;
-               }
+               if (error)
+                       goto out_defer_cancel;
+               xfs_defer_ijoin(args.dfops, dp);
+               error = xfs_defer_finish(&args.trans, args.dfops);
+               if (error)
+                       goto out_defer_cancel;
 
                /*
                 * Commit the leaf transformation.  We'll need another (linked)
@@ -368,6 +367,9 @@ xfs_attr_set(
 
        return error;
 
+out_defer_cancel:
+       xfs_defer_cancel(&dfops);
+       args.trans = NULL;
 out:
        if (args.trans)
                xfs_trans_cancel(args.trans);
@@ -588,13 +590,12 @@ xfs_attr_leaf_addname(xfs_da_args_t *args)
                 */
                xfs_defer_init(args->dfops, args->firstblock);
                error = xfs_attr3_leaf_to_node(args);
-               if (!error)
-                       error = xfs_defer_finish(&args->trans, args->dfops, dp);
-               if (error) {
-                       args->trans = NULL;
-                       xfs_defer_cancel(args->dfops);
-                       return error;
-               }
+               if (error)
+                       goto out_defer_cancel;
+               xfs_defer_ijoin(args->dfops, dp);
+               error = xfs_defer_finish(&args->trans, args->dfops);
+               if (error)
+                       goto out_defer_cancel;
 
                /*
                 * Commit the current trans (including the inode) and start
@@ -679,14 +680,12 @@ xfs_attr_leaf_addname(xfs_da_args_t *args)
                        xfs_defer_init(args->dfops, args->firstblock);
                        error = xfs_attr3_leaf_to_shortform(bp, args, forkoff);
                        /* bp is gone due to xfs_da_shrink_inode */
-                       if (!error)
-                               error = xfs_defer_finish(&args->trans,
-                                                       args->dfops, dp);
-                       if (error) {
-                               args->trans = NULL;
-                               xfs_defer_cancel(args->dfops);
-                               return error;
-                       }
+                       if (error)
+                               goto out_defer_cancel;
+                       xfs_defer_ijoin(args->dfops, dp);
+                       error = xfs_defer_finish(&args->trans, args->dfops);
+                       if (error)
+                               goto out_defer_cancel;
                }
 
                /*
@@ -701,6 +700,10 @@ xfs_attr_leaf_addname(xfs_da_args_t *args)
                error = xfs_attr3_leaf_clearflag(args);
        }
        return error;
+out_defer_cancel:
+       xfs_defer_cancel(args->dfops);
+       args->trans = NULL;
+       return error;
 }
 
 /*
@@ -742,15 +745,18 @@ xfs_attr_leaf_removename(xfs_da_args_t *args)
                xfs_defer_init(args->dfops, args->firstblock);
                error = xfs_attr3_leaf_to_shortform(bp, args, forkoff);
                /* bp is gone due to xfs_da_shrink_inode */
-               if (!error)
-                       error = xfs_defer_finish(&args->trans, args->dfops, dp);
-               if (error) {
-                       args->trans = NULL;
-                       xfs_defer_cancel(args->dfops);
-                       return error;
-               }
+               if (error)
+                       goto out_defer_cancel;
+               xfs_defer_ijoin(args->dfops, dp);
+               error = xfs_defer_finish(&args->trans, args->dfops);
+               if (error)
+                       goto out_defer_cancel;
        }
        return 0;
+out_defer_cancel:
+       xfs_defer_cancel(args->dfops);
+       args->trans = NULL;
+       return error;
 }
 
 /*
@@ -867,14 +873,12 @@ restart:
                        state = NULL;
                        xfs_defer_init(args->dfops, args->firstblock);
                        error = xfs_attr3_leaf_to_node(args);
-                       if (!error)
-                               error = xfs_defer_finish(&args->trans,
-                                                       args->dfops, dp);
-                       if (error) {
-                               args->trans = NULL;
-                               xfs_defer_cancel(args->dfops);
-                               goto out;
-                       }
+                       if (error)
+                               goto out_defer_cancel;
+                       xfs_defer_ijoin(args->dfops, dp);
+                       error = xfs_defer_finish(&args->trans, args->dfops);
+                       if (error)
+                               goto out_defer_cancel;
 
                        /*
                         * Commit the node conversion and start the next
@@ -895,13 +899,12 @@ restart:
                 */
                xfs_defer_init(args->dfops, args->firstblock);
                error = xfs_da3_split(state);
-               if (!error)
-                       error = xfs_defer_finish(&args->trans, args->dfops, dp);
-               if (error) {
-                       args->trans = NULL;
-                       xfs_defer_cancel(args->dfops);
-                       goto out;
-               }
+               if (error)
+                       goto out_defer_cancel;
+               xfs_defer_ijoin(args->dfops, dp);
+               error = xfs_defer_finish(&args->trans, args->dfops);
+               if (error)
+                       goto out_defer_cancel;
        } else {
                /*
                 * Addition succeeded, update Btree hashvals.
@@ -994,14 +997,12 @@ restart:
                if (retval && (state->path.active > 1)) {
                        xfs_defer_init(args->dfops, args->firstblock);
                        error = xfs_da3_join(state);
-                       if (!error)
-                               error = xfs_defer_finish(&args->trans,
-                                                       args->dfops, dp);
-                       if (error) {
-                               args->trans = NULL;
-                               xfs_defer_cancel(args->dfops);
-                               goto out;
-                       }
+                       if (error)
+                               goto out_defer_cancel;
+                       xfs_defer_ijoin(args->dfops, dp);
+                       error = xfs_defer_finish(&args->trans, args->dfops);
+                       if (error)
+                               goto out_defer_cancel;
                }
 
                /*
@@ -1027,6 +1028,10 @@ out:
        if (error)
                return error;
        return retval;
+out_defer_cancel:
+       xfs_defer_cancel(args->dfops);
+       args->trans = NULL;
+       goto out;
 }
 
 /*
@@ -1117,13 +1122,12 @@ xfs_attr_node_removename(xfs_da_args_t *args)
        if (retval && (state->path.active > 1)) {
                xfs_defer_init(args->dfops, args->firstblock);
                error = xfs_da3_join(state);
-               if (!error)
-                       error = xfs_defer_finish(&args->trans, args->dfops, dp);
-               if (error) {
-                       args->trans = NULL;
-                       xfs_defer_cancel(args->dfops);
-                       goto out;
-               }
+               if (error)
+                       goto out_defer_cancel;
+               xfs_defer_ijoin(args->dfops, dp);
+               error = xfs_defer_finish(&args->trans, args->dfops);
+               if (error)
+                       goto out_defer_cancel;
                /*
                 * Commit the Btree join operation and start a new trans.
                 */
@@ -1151,14 +1155,12 @@ xfs_attr_node_removename(xfs_da_args_t *args)
                        xfs_defer_init(args->dfops, args->firstblock);
                        error = xfs_attr3_leaf_to_shortform(bp, args, forkoff);
                        /* bp is gone due to xfs_da_shrink_inode */
-                       if (!error)
-                               error = xfs_defer_finish(&args->trans,
-                                                       args->dfops, dp);
-                       if (error) {
-                               args->trans = NULL;
-                               xfs_defer_cancel(args->dfops);
-                               goto out;
-                       }
+                       if (error)
+                               goto out_defer_cancel;
+                       xfs_defer_ijoin(args->dfops, dp);
+                       error = xfs_defer_finish(&args->trans, args->dfops);
+                       if (error)
+                               goto out_defer_cancel;
                } else
                        xfs_trans_brelse(args->trans, bp);
        }
@@ -1167,6 +1169,10 @@ xfs_attr_node_removename(xfs_da_args_t *args)
 out:
        xfs_da_state_free(state);
        return error;
+out_defer_cancel:
+       xfs_defer_cancel(args->dfops);
+       args->trans = NULL;
+       goto out;
 }
 
 /*