@@ -947,6 +947,16 @@ xfs_attr_lookup(
return error;
}
+/*
+ * Make a change to the xattr structure.
+ *
+ * The caller must have initialized @args, attached dquots, and must not hold
+ * any ILOCKs.
+ *
+ * Returns -EEXIST for XFS_ATTRUPDATE_CREATE if the name already exists.
+ * Returns -ENOATTR for XFS_ATTRUPDATE_REMOVE if the name does not exist.
+ * Returns 0 on success, or a negative errno if something else went wrong.
+ */
int
xfs_attr_set(
struct xfs_da_args *args,
@@ -960,27 +970,7 @@ xfs_attr_set(
int rmt_blks = 0;
unsigned int total;
- if (xfs_is_shutdown(dp->i_mount))
- return -EIO;
-
- error = xfs_qm_dqattach(dp);
- if (error)
- return error;
-
- if (!args->owner)
- args->owner = args->dp->i_ino;
- args->geo = mp->m_attr_geo;
- args->whichfork = XFS_ATTR_FORK;
- xfs_attr_sethash(args);
-
- /*
- * We have no control over the attribute names that userspace passes us
- * to remove, so we have to allow the name lookup prior to attribute
- * removal to fail as well. Preserve the logged flag, since we need
- * to pass that through to the logging code.
- */
- args->op_flags = XFS_DA_OP_OKNOENT |
- (args->op_flags & XFS_DA_OP_LOGGED);
+ ASSERT(!args->trans);
switch (op) {
case XFS_ATTRUPDATE_UPSERT:
@@ -1075,6 +1065,7 @@ xfs_attr_set(
error = xfs_trans_commit(args->trans);
out_unlock:
xfs_iunlock(dp, XFS_ILOCK_EXCL);
+ args->trans = NULL;
return error;
out_trans_cancel: