All of lore.kernel.org
 help / color / mirror / Atom feed
From: Allison Henderson <allison.henderson@oracle.com>
To: linux-xfs@vger.kernel.org
Subject: [PATCH 10/18] xfsprogs: Add xfs_attr_set_deferred and xfs_attr_remove_deferred
Date: Tue, 17 May 2022 17:12:19 -0700	[thread overview]
Message-ID: <20220518001227.1779324-11-allison.henderson@oracle.com> (raw)
In-Reply-To: <20220518001227.1779324-1-allison.henderson@oracle.com>

Source kernel commit: f3f36c893f260275eb9229cdc3dabb4c79650591

These routines set up and queue a new deferred attribute operations.
These functions are meant to be called by any routine needing to
initiate a deferred attribute operation as opposed to the existing
inline operations. New helper function xfs_attr_item_init also added.

Finally enable delayed attributes in xfs_attr_set and xfs_attr_remove.

Signed-off-by: Allison Henderson <allison.henderson@oracle.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Chandan Babu R <chandanrlinux@gmail.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
Signed-off-by: Allison Henderson <allison.henderson@oracle.com>
---
 libxfs/libxfs_priv.h |  4 +++
 libxfs/xfs_attr.c    | 69 ++++++++++++++++++++++++++++++++++++++++++--
 libxfs/xfs_attr.h    |  2 ++
 3 files changed, 72 insertions(+), 3 deletions(-)

diff --git a/libxfs/libxfs_priv.h b/libxfs/libxfs_priv.h
index 12028efbf802..718fecf72614 100644
--- a/libxfs/libxfs_priv.h
+++ b/libxfs/libxfs_priv.h
@@ -601,9 +601,13 @@ typedef int (*xfs_rtalloc_query_range_fn)(
 int libxfs_zero_extent(struct xfs_inode *ip, xfs_fsblock_t start_fsb,
                         xfs_off_t count_fsb);
 
+/* xfs_log.c */
+struct xlog;
 
 bool xfs_log_check_lsn(struct xfs_mount *, xfs_lsn_t);
 void xfs_log_item_init(struct xfs_mount *, struct xfs_log_item *, int);
+int xfs_attr_use_log_assist(struct xfs_mount *mp);
+void xlog_drop_incompat_feat(struct xlog *log);
 #define xfs_log_in_recovery(mp)	(false)
 
 /* xfs_icache.c */
diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c
index 6cda61adaca3..4550e0278d06 100644
--- a/libxfs/xfs_attr.c
+++ b/libxfs/xfs_attr.c
@@ -725,6 +725,7 @@ xfs_attr_set(
 	int			error, local;
 	int			rmt_blks = 0;
 	unsigned int		total;
+	int			delayed	= xfs_has_larp(mp);
 
 	if (xfs_is_shutdown(dp->i_mount))
 		return -EIO;
@@ -781,13 +782,19 @@ xfs_attr_set(
 		rmt_blks = xfs_attr3_rmt_blocks(mp, XFS_XATTR_SIZE_MAX);
 	}
 
+	if (delayed) {
+		error = xfs_attr_use_log_assist(mp);
+		if (error)
+			return error;
+	}
+
 	/*
 	 * Root fork attributes can use reserved data blocks for this
 	 * operation if necessary
 	 */
 	error = xfs_trans_alloc_inode(dp, &tres, total, 0, rsvd, &args->trans);
 	if (error)
-		return error;
+		goto drop_incompat;
 
 	if (args->value || xfs_inode_hasattr(dp)) {
 		error = xfs_iext_count_may_overflow(dp, XFS_ATTR_FORK,
@@ -805,9 +812,10 @@ xfs_attr_set(
 		if (error != -ENOATTR && error != -EEXIST)
 			goto out_trans_cancel;
 
-		error = xfs_attr_set_args(args);
+		error = xfs_attr_set_deferred(args);
 		if (error)
 			goto out_trans_cancel;
+
 		/* shortform attribute has already been committed */
 		if (!args->trans)
 			goto out_unlock;
@@ -815,7 +823,7 @@ xfs_attr_set(
 		if (error != -EEXIST)
 			goto out_trans_cancel;
 
-		error = xfs_attr_remove_args(args);
+		error = xfs_attr_remove_deferred(args);
 		if (error)
 			goto out_trans_cancel;
 	}
@@ -837,6 +845,9 @@ xfs_attr_set(
 	error = xfs_trans_commit(args->trans);
 out_unlock:
 	xfs_iunlock(dp, XFS_ILOCK_EXCL);
+drop_incompat:
+	if (delayed)
+		xlog_drop_incompat_feat(mp->m_log);
 	return error;
 
 out_trans_cancel:
@@ -845,6 +856,58 @@ out_trans_cancel:
 	goto out_unlock;
 }
 
+STATIC int
+xfs_attr_item_init(
+	struct xfs_da_args	*args,
+	unsigned int		op_flags,	/* op flag (set or remove) */
+	struct xfs_attr_item	**attr)		/* new xfs_attr_item */
+{
+
+	struct xfs_attr_item	*new;
+
+	new = kmem_zalloc(sizeof(struct xfs_attr_item), KM_NOFS);
+	new->xattri_op_flags = op_flags;
+	new->xattri_dac.da_args = args;
+
+	*attr = new;
+	return 0;
+}
+
+/* Sets an attribute for an inode as a deferred operation */
+int
+xfs_attr_set_deferred(
+	struct xfs_da_args	*args)
+{
+	struct xfs_attr_item	*new;
+	int			error = 0;
+
+	error = xfs_attr_item_init(args, XFS_ATTR_OP_FLAGS_SET, &new);
+	if (error)
+		return error;
+
+	xfs_defer_add(args->trans, XFS_DEFER_OPS_TYPE_ATTR, &new->xattri_list);
+
+	return 0;
+}
+
+/* Removes an attribute for an inode as a deferred operation */
+int
+xfs_attr_remove_deferred(
+	struct xfs_da_args	*args)
+{
+
+	struct xfs_attr_item	*new;
+	int			error;
+
+	error  = xfs_attr_item_init(args, XFS_ATTR_OP_FLAGS_REMOVE, &new);
+	if (error)
+		return error;
+
+	xfs_defer_add(args->trans, XFS_DEFER_OPS_TYPE_ATTR, &new->xattri_list);
+
+	return 0;
+}
+
 /*========================================================================
  * External routines when attribute list is inside the inode
  *========================================================================*/
diff --git a/libxfs/xfs_attr.h b/libxfs/xfs_attr.h
index b8897f0dd810..8eb1da085a13 100644
--- a/libxfs/xfs_attr.h
+++ b/libxfs/xfs_attr.h
@@ -525,5 +525,7 @@ bool xfs_attr_namecheck(const void *name, size_t length);
 void xfs_delattr_context_init(struct xfs_delattr_context *dac,
 			      struct xfs_da_args *args);
 int xfs_attr_calc_size(struct xfs_da_args *args, int *local);
+int xfs_attr_set_deferred(struct xfs_da_args *args);
+int xfs_attr_remove_deferred(struct xfs_da_args *args);
 
 #endif	/* __XFS_ATTR_H__ */
-- 
2.25.1


  parent reply	other threads:[~2022-05-18  0:12 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-18  0:12 [PATCH 00/18] xfsprogs: Port larp, enable injects and log print for attri/d Allison Henderson
2022-05-18  0:12 ` [PATCH 01/18] xfsprogs: zero inode fork buffer at allocation Allison Henderson
2022-05-18  0:12 ` [PATCH 02/18] xfsprogs: hide log iovec alignment constraints Allison Henderson
2022-05-18  0:12 ` [PATCH 03/18] xfsprogs: don't commit the first deferred transaction without intents Allison Henderson
2022-05-18  0:12 ` [PATCH 04/18] xfsprogs: tag transactions that contain intent done items Allison Henderson
2022-05-18  0:12 ` [PATCH 05/18] xfsprogs: Fix double unlock in defer capture code Allison Henderson
2022-05-18  0:12 ` [PATCH 06/18] xfsprogs: Return from xfs_attr_set_iter if there are no more rmtblks to process Allison Henderson
2022-05-18  0:12 ` [PATCH 07/18] xfsprogs: Set up infrastructure for log attribute replay Allison Henderson
2022-05-18  0:12 ` [PATCH 08/18] xfsprogs: Implement attr logging and replay Allison Henderson
2022-05-18  0:31   ` Darrick J. Wong
2022-05-18 16:38     ` Alli
2022-05-18 17:00       ` Darrick J. Wong
2022-05-19 23:11         ` Alli
2022-05-19 23:17           ` Darrick J. Wong
2022-05-18  0:12 ` [PATCH 09/18] xfsprogs: Skip flip flags for delayed attrs Allison Henderson
2022-05-18  0:12 ` Allison Henderson [this message]
2022-05-18  0:12 ` [PATCH 11/18] xfsprogs: Remove unused xfs_attr_*_args Allison Henderson
2022-05-18  0:12 ` [PATCH 12/18] xfsprogs: Add log attribute error tag Allison Henderson
2022-05-18  0:12 ` [PATCH 13/18] xfsprogs: Merge xfs_delattr_context into xfs_attr_item Allison Henderson
2022-05-18  0:12 ` [PATCH 14/18] xfsprogs: Add helper function xfs_attr_leaf_addname Allison Henderson
2022-05-18  0:12 ` [PATCH 15/18] xfsprogs: Add helper function xfs_init_attr_trans Allison Henderson
2022-05-18  0:12 ` [PATCH 16/18] xfsprogs: add leaf split error tag Allison Henderson
2022-05-18  0:12 ` [PATCH 17/18] xfsprogs: add leaf to node " Allison Henderson
2022-05-18  0:12 ` [PATCH 18/18] xfsprogs: Add log item printing for ATTRI and ATTRD Allison Henderson
2022-05-18  1:02   ` Darrick J. Wong
2022-05-18 16:38     ` Alli

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220518001227.1779324-11-allison.henderson@oracle.com \
    --to=allison.henderson@oracle.com \
    --cc=linux-xfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.