From: Allison Henderson <allison.henderson@oracle.com>
To: linux-xfs@vger.kernel.org
Subject: [PATCH v2 17/18] xfs: Add helper function xfs_attr_list_context_init
Date: Mon, 18 Jul 2022 13:20:21 -0700 [thread overview]
Message-ID: <20220718202022.6598-18-allison.henderson@oracle.com> (raw)
In-Reply-To: <20220718202022.6598-1-allison.henderson@oracle.com>
This patch adds a helper function xfs_attr_list_context_init used by
xfs_attr_list. This function initializes the xfs_attr_list_context
structure passed to xfs_attr_list_int. We will need this later to call
xfs_attr_list_int_ilocked when the node is already locked.
Signed-off-by: Allison Henderson <allison.henderson@oracle.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
---
fs/xfs/xfs_file.c | 1 +
fs/xfs/xfs_ioctl.c | 54 ++++++++++++++++++++++++++++++++--------------
fs/xfs/xfs_ioctl.h | 2 ++
3 files changed, 41 insertions(+), 16 deletions(-)
diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c
index 5a171c0b244b..7a54887cc37c 100644
--- a/fs/xfs/xfs_file.c
+++ b/fs/xfs/xfs_file.c
@@ -17,6 +17,7 @@
#include "xfs_bmap_util.h"
#include "xfs_dir2.h"
#include "xfs_dir2_priv.h"
+#include "xfs_attr.h"
#include "xfs_ioctl.h"
#include "xfs_trace.h"
#include "xfs_log.h"
diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
index 1f783e979629..5b600d3f7981 100644
--- a/fs/xfs/xfs_ioctl.c
+++ b/fs/xfs/xfs_ioctl.c
@@ -369,6 +369,40 @@ xfs_attr_flags(
return 0;
}
+/*
+ * Initializes an xfs_attr_list_context suitable for
+ * use by xfs_attr_list
+ */
+int
+xfs_ioc_attr_list_context_init(
+ struct xfs_inode *dp,
+ char *buffer,
+ int bufsize,
+ int flags,
+ struct xfs_attr_list_context *context)
+{
+ struct xfs_attrlist *alist;
+
+ /*
+ * Initialize the output buffer.
+ */
+ context->dp = dp;
+ context->resynch = 1;
+ context->attr_filter = xfs_attr_filter(flags);
+ context->buffer = buffer;
+ context->bufsize = round_down(bufsize, sizeof(uint32_t));
+ context->firstu = context->bufsize;
+ context->put_listent = xfs_ioc_attr_put_listent;
+
+ alist = context->buffer;
+ alist->al_count = 0;
+ alist->al_more = 0;
+ alist->al_offset[0] = context->bufsize;
+
+ return 0;
+}
+
+
int
xfs_ioc_attr_list(
struct xfs_inode *dp,
@@ -378,7 +412,6 @@ xfs_ioc_attr_list(
struct xfs_attrlist_cursor __user *ucursor)
{
struct xfs_attr_list_context context = { };
- struct xfs_attrlist *alist;
void *buffer;
int error;
@@ -410,21 +443,10 @@ xfs_ioc_attr_list(
if (!buffer)
return -ENOMEM;
- /*
- * Initialize the output buffer.
- */
- context.dp = dp;
- context.resynch = 1;
- context.attr_filter = xfs_attr_filter(flags);
- context.buffer = buffer;
- context.bufsize = round_down(bufsize, sizeof(uint32_t));
- context.firstu = context.bufsize;
- context.put_listent = xfs_ioc_attr_put_listent;
-
- alist = context.buffer;
- alist->al_count = 0;
- alist->al_more = 0;
- alist->al_offset[0] = context.bufsize;
+ error = xfs_ioc_attr_list_context_init(dp, buffer, bufsize, flags,
+ &context);
+ if (error)
+ return error;
error = xfs_attr_list(&context);
if (error)
diff --git a/fs/xfs/xfs_ioctl.h b/fs/xfs/xfs_ioctl.h
index d4abba2c13c1..ca60e1c427a3 100644
--- a/fs/xfs/xfs_ioctl.h
+++ b/fs/xfs/xfs_ioctl.h
@@ -35,6 +35,8 @@ int xfs_ioc_attrmulti_one(struct file *parfilp, struct inode *inode,
int xfs_ioc_attr_list(struct xfs_inode *dp, void __user *ubuf,
size_t bufsize, int flags,
struct xfs_attrlist_cursor __user *ucursor);
+int xfs_ioc_attr_list_context_init(struct xfs_inode *dp, char *buffer,
+ int bufsize, int flags, struct xfs_attr_list_context *context);
extern struct dentry *
xfs_handle_to_dentry(
--
2.25.1
next prev parent reply other threads:[~2022-07-18 20:20 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-18 20:20 [PATCH v2 00/18] Parent Pointers Allison Henderson
2022-07-18 20:20 ` [PATCH v2 01/18] xfs: Fix multi-transaction larp replay Allison Henderson
2022-07-18 20:20 ` [PATCH v2 02/18] xfs: Increase XFS_DEFER_OPS_NR_INODES to 5 Allison Henderson
2022-07-18 20:20 ` [PATCH v2 03/18] xfs: Hold inode locks in xfs_ialloc Allison Henderson
2022-07-18 20:20 ` [PATCH v2 04/18] xfs: Hold inode locks in xfs_trans_alloc_dir Allison Henderson
2022-07-18 20:20 ` [PATCH v2 05/18] xfs: get directory offset when adding directory name Allison Henderson
2022-07-18 20:20 ` [PATCH v2 06/18] xfs: get directory offset when removing " Allison Henderson
2022-07-18 20:20 ` [PATCH v2 07/18] xfs: get directory offset when replacing a " Allison Henderson
2022-07-18 20:20 ` [PATCH v2 08/18] xfs: add parent pointer support to attribute code Allison Henderson
2022-07-18 20:20 ` [PATCH v2 09/18] xfs: define parent pointer xattr format Allison Henderson
2022-07-18 20:20 ` [PATCH v2 10/18] xfs: Add xfs_verify_pptr Allison Henderson
2022-07-18 20:20 ` [PATCH v2 11/18] xfs: extend transaction reservations for parent attributes Allison Henderson
2022-07-18 20:20 ` [PATCH v2 12/18] xfs: parent pointer attribute creation Allison Henderson
2022-07-18 20:20 ` [PATCH v2 13/18] xfs: add parent attributes to link Allison Henderson
2022-07-18 20:20 ` [PATCH v2 14/18] xfs: remove parent pointers in unlink Allison Henderson
2022-07-18 20:20 ` [PATCH v2 15/18] xfs: Add parent pointers to rename Allison Henderson
2022-07-18 20:20 ` [PATCH v2 16/18] xfs: Add the parent pointer support to the superblock version 5 Allison Henderson
2022-07-18 20:20 ` Allison Henderson [this message]
2022-07-18 20:20 ` [PATCH v2 18/18] xfs: Add parent pointer ioctl Allison Henderson
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=20220718202022.6598-18-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox