return nblks;
}
+STATIC int
+xfs_attr_try_sf_addname(
+ struct xfs_inode *dp,
+ struct xfs_da_args *args)
+{
+
+ struct xfs_mount *mp = dp->i_mount;
+ int error, error2;
+
+ error = xfs_attr_shortform_addname(args);
+ if (error == -ENOSPC)
+ return error;
+
+ /*
+ * Commit the shortform mods, and we're done.
+ * NOTE: this is also the error path (EEXIST, etc).
+ */
+ if (!error && (args->flags & ATTR_KERNOTIME) == 0)
+ xfs_trans_ichgtime(args->trans, dp, XFS_ICHGTIME_CHG);
+
+ if (mp->m_flags & XFS_MOUNT_WSYNC)
+ xfs_trans_set_sync(args->trans);
+
+ error2 = xfs_trans_commit(args->trans);
+ return error ? error : error2;
+}
+
int
xfs_attr_set(
struct xfs_inode *dp,
struct xfs_da_args args;
struct xfs_trans_res tres;
int rsvd = (flags & ATTR_ROOT) != 0;
- int error, err2, local;
+ int error, local;
XFS_STATS_INC(mp, xs_attr_set);
* Try to add the attr to the attribute list in
* the inode.
*/
- error = xfs_attr_shortform_addname(&args);
+ error = xfs_attr_try_sf_addname(dp, &args);
if (error != -ENOSPC) {
- /*
- * Commit the shortform mods, and we're done.
- * NOTE: this is also the error path (EEXIST, etc).
- */
- ASSERT(args.trans != NULL);
-
- /*
- * If this is a synchronous mount, make sure that
- * the transaction goes to disk before returning
- * to the user.
- */
- if (mp->m_flags & XFS_MOUNT_WSYNC)
- xfs_trans_set_sync(args.trans);
-
- if (!error && (flags & ATTR_KERNOTIME) == 0) {
- xfs_trans_ichgtime(args.trans, dp,
- XFS_ICHGTIME_CHG);
- }
- err2 = xfs_trans_commit(args.trans);
xfs_iunlock(dp, XFS_ILOCK_EXCL);
-
- return error ? error : err2;
+ return error;
}
/*
* buffer and run into problems with the write verifier.
*/
xfs_trans_bhold(args.trans, leaf_bp);
- xfs_defer_bjoin(args.trans->t_dfops, leaf_bp);
- xfs_defer_ijoin(args.trans->t_dfops, dp);
- error = xfs_defer_finish(&args.trans, args.trans->t_dfops);
+ error = xfs_defer_finish(&args.trans);
if (error)
goto out;
* Commit that transaction so that the node_addname() call
* can manage its own transactions.
*/
- xfs_defer_init(args->trans, args->trans->t_dfops);
error = xfs_attr3_leaf_to_node(args);
if (error)
- goto out_defer_cancel;
- xfs_defer_ijoin(args->trans->t_dfops, dp);
- error = xfs_defer_finish(&args->trans, args->trans->t_dfops);
+ return error;
+ error = xfs_defer_finish(&args->trans);
if (error)
- goto out_defer_cancel;
+ return error;
/*
* Commit the current trans (including the inode) and start
* If the result is small enough, shrink it all into the inode.
*/
if ((forkoff = xfs_attr_shortform_allfit(bp, dp))) {
- xfs_defer_init(args->trans, args->trans->t_dfops);
error = xfs_attr3_leaf_to_shortform(bp, args, forkoff);
/* bp is gone due to xfs_da_shrink_inode */
if (error)
- goto out_defer_cancel;
- xfs_defer_ijoin(args->trans->t_dfops, dp);
- error = xfs_defer_finish(&args->trans, args->trans->t_dfops);
+ return error;
+ error = xfs_defer_finish(&args->trans);
if (error)
- goto out_defer_cancel;
+ return error;
}
/*
error = xfs_attr3_leaf_clearflag(args);
}
return error;
-out_defer_cancel:
- xfs_defer_cancel(args->trans->t_dfops);
- return error;
}
/*
* If the result is small enough, shrink it all into the inode.
*/
if ((forkoff = xfs_attr_shortform_allfit(bp, dp))) {
- xfs_defer_init(args->trans, args->trans->t_dfops);
error = xfs_attr3_leaf_to_shortform(bp, args, forkoff);
/* bp is gone due to xfs_da_shrink_inode */
if (error)
- goto out_defer_cancel;
- xfs_defer_ijoin(args->trans->t_dfops, dp);
- error = xfs_defer_finish(&args->trans, args->trans->t_dfops);
+ return error;
+ error = xfs_defer_finish(&args->trans);
if (error)
- goto out_defer_cancel;
+ return error;
}
return 0;
-out_defer_cancel:
- xfs_defer_cancel(args->trans->t_dfops);
- return error;
}
/*
*/
xfs_da_state_free(state);
state = NULL;
- xfs_defer_init(args->trans, args->trans->t_dfops);
error = xfs_attr3_leaf_to_node(args);
if (error)
- goto out_defer_cancel;
- xfs_defer_ijoin(args->trans->t_dfops, dp);
- error = xfs_defer_finish(&args->trans,
- args->trans->t_dfops);
+ goto out;
+ error = xfs_defer_finish(&args->trans);
if (error)
- goto out_defer_cancel;
+ goto out;
/*
* Commit the node conversion and start the next
* in the index/blkno/rmtblkno/rmtblkcnt fields and
* in the index2/blkno2/rmtblkno2/rmtblkcnt2 fields.
*/
- xfs_defer_init(args->trans, args->trans->t_dfops);
error = xfs_da3_split(state);
if (error)
- goto out_defer_cancel;
- xfs_defer_ijoin(args->trans->t_dfops, dp);
- error = xfs_defer_finish(&args->trans, args->trans->t_dfops);
+ goto out;
+ error = xfs_defer_finish(&args->trans);
if (error)
- goto out_defer_cancel;
+ goto out;
} else {
/*
* Addition succeeded, update Btree hashvals.
* Check to see if the tree needs to be collapsed.
*/
if (retval && (state->path.active > 1)) {
- xfs_defer_init(args->trans, args->trans->t_dfops);
error = xfs_da3_join(state);
if (error)
- goto out_defer_cancel;
- xfs_defer_ijoin(args->trans->t_dfops, dp);
- error = xfs_defer_finish(&args->trans, args->trans->t_dfops);
+ goto out;
+ error = xfs_defer_finish(&args->trans);
if (error)
- goto out_defer_cancel;
+ goto out;
}
/*
if (error)
return error;
return retval;
-out_defer_cancel:
- xfs_defer_cancel(args->trans->t_dfops);
- goto out;
}
/*
* Check to see if the tree needs to be collapsed.
*/
if (retval && (state->path.active > 1)) {
- xfs_defer_init(args->trans, args->trans->t_dfops);
error = xfs_da3_join(state);
if (error)
- goto out_defer_cancel;
- xfs_defer_ijoin(args->trans->t_dfops, dp);
- error = xfs_defer_finish(&args->trans, args->trans->t_dfops);
+ goto out;
+ error = xfs_defer_finish(&args->trans);
if (error)
- goto out_defer_cancel;
+ goto out;
/*
* Commit the Btree join operation and start a new trans.
*/
goto out;
if ((forkoff = xfs_attr_shortform_allfit(bp, dp))) {
- xfs_defer_init(args->trans, args->trans->t_dfops);
error = xfs_attr3_leaf_to_shortform(bp, args, forkoff);
/* bp is gone due to xfs_da_shrink_inode */
if (error)
- goto out_defer_cancel;
- xfs_defer_ijoin(args->trans->t_dfops, dp);
- error = xfs_defer_finish(&args->trans, args->trans->t_dfops);
+ goto out;
+ error = xfs_defer_finish(&args->trans);
if (error)
- goto out_defer_cancel;
+ goto out;
} else
xfs_trans_brelse(args->trans, bp);
}
out:
xfs_da_state_free(state);
return error;
-out_defer_cancel:
- xfs_defer_cancel(args->trans->t_dfops);
- goto out;
}
/*