Commit a9c8c69b authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Darrick J. Wong
Browse files

xfs: cleanup struct xfs_attr_list_context



Replace the alist char pointer with a void buffer given that different
callers use it in different ways.  Use the chance to remove the typedef
and reduce the indentation of the struct definition so that it doesn't
overflow 80 char lines all over.

Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarDave Chinner <dchinner@redhat.com>
Reviewed-by: default avatarChandan Rajendra <chandanrlinux@gmail.com>
Reviewed-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
parent 377f16ac
Loading
Loading
Loading
Loading
+17 −17
Original line number Diff line number Diff line
@@ -99,11 +99,11 @@ typedef struct attrlist_cursor_kern {
typedef void (*put_listent_func_t)(struct xfs_attr_list_context *, int,
			      unsigned char *, int, int);

typedef struct xfs_attr_list_context {
struct xfs_attr_list_context {
	struct xfs_trans	*tp;
	struct xfs_inode	*dp;		/* inode */
	struct attrlist_cursor_kern *cursor;	/* position in list */
	char				*alist;		/* output buffer */
	void			*buffer;	/* output buffer */

	/*
	 * Abort attribute list iteration if non-zero.  Can be used to pass
@@ -120,7 +120,7 @@ typedef struct xfs_attr_list_context {
	int			resynch;	/* T/F: resynch with cursor */
	put_listent_func_t	put_listent;	/* list output fmt function */
	int			index;		/* index into output buffer */
} xfs_attr_list_context_t;
};


/*========================================================================
+27 −26
Original line number Diff line number Diff line
@@ -488,10 +488,11 @@ xfs_attr3_leaf_list_int(
 * Copy out attribute entries for attr_list(), for leaf attribute lists.
 */
STATIC int
xfs_attr_leaf_list(xfs_attr_list_context_t *context)
xfs_attr_leaf_list(
	struct xfs_attr_list_context	*context)
{
	int error;
	struct xfs_buf			*bp;
	int				error;

	trace_xfs_attr_leaf_list(context);

@@ -527,11 +528,11 @@ xfs_attr_list_int_ilocked(

int
xfs_attr_list_int(
	xfs_attr_list_context_t *context)
	struct xfs_attr_list_context	*context)
{
	int error;
	xfs_inode_t *dp = context->dp;
	struct xfs_inode		*dp = context->dp;
	uint				lock_mode;
	int				error;

	XFS_STATS_INC(dp->i_mount, xs_attr_list);

@@ -557,14 +558,14 @@ xfs_attr_list_int(
 */
STATIC void
xfs_attr_put_listent(
	xfs_attr_list_context_t *context,
	struct xfs_attr_list_context	*context,
	int			flags,
	unsigned char		*name,
	int			namelen,
	int			valuelen)
{
	struct attrlist *alist = (struct attrlist *)context->alist;
	attrlist_ent_t *aep;
	struct attrlist		*alist = context->buffer;
	struct attrlist_ent	*aep;
	int			arraytop;

	ASSERT(!context->seen_enough);
@@ -593,7 +594,7 @@ xfs_attr_put_listent(
		return;
	}

	aep = (attrlist_ent_t *)&context->alist[context->firstu];
	aep = context->buffer + context->firstu;
	aep->a_valuelen = valuelen;
	memcpy(aep->a_name, name, namelen);
	aep->a_name[namelen] = 0;
@@ -612,13 +613,13 @@ xfs_attr_put_listent(
 */
int
xfs_attr_list(
	xfs_inode_t	*dp,
	struct xfs_inode		*dp,
	char				*buffer,
	int				bufsize,
	int				flags,
	attrlist_cursor_kern_t *cursor)
	struct attrlist_cursor_kern	*cursor)
{
	xfs_attr_list_context_t context;
	struct xfs_attr_list_context	context;
	struct attrlist			*alist;
	int				error;

@@ -645,12 +646,12 @@ xfs_attr_list(
	context.cursor = cursor;
	context.resynch = 1;
	context.flags = flags;
	context.alist = buffer;
	context.buffer = buffer;
	context.bufsize = (bufsize & ~(sizeof(int)-1));  /* align */
	context.firstu = context.bufsize;
	context.put_listent = xfs_attr_put_listent;

	alist = (struct attrlist *)context.alist;
	alist = context.buffer;
	alist->al_count = 0;
	alist->al_more = 0;
	alist->al_offset[0] = context.bufsize;
+8 −8
Original line number Diff line number Diff line
@@ -45,7 +45,7 @@ DECLARE_EVENT_CLASS(xfs_attr_list_class,
		__field(u32, hashval)
		__field(u32, blkno)
		__field(u32, offset)
		__field(void *, alist)
		__field(void *, buffer)
		__field(int, bufsize)
		__field(int, count)
		__field(int, firstu)
@@ -58,21 +58,21 @@ DECLARE_EVENT_CLASS(xfs_attr_list_class,
		__entry->hashval = ctx->cursor->hashval;
		__entry->blkno = ctx->cursor->blkno;
		__entry->offset = ctx->cursor->offset;
		__entry->alist = ctx->alist;
		__entry->buffer = ctx->buffer;
		__entry->bufsize = ctx->bufsize;
		__entry->count = ctx->count;
		__entry->firstu = ctx->firstu;
		__entry->flags = ctx->flags;
	),
	TP_printk("dev %d:%d ino 0x%llx cursor h/b/o 0x%x/0x%x/%u dupcnt %u "
		  "alist %p size %u count %u firstu %u flags %d %s",
		  "buffer %p size %u count %u firstu %u flags %d %s",
		  MAJOR(__entry->dev), MINOR(__entry->dev),
		   __entry->ino,
		   __entry->hashval,
		   __entry->blkno,
		   __entry->offset,
		   __entry->dupcnt,
		   __entry->alist,
		   __entry->buffer,
		   __entry->bufsize,
		   __entry->count,
		   __entry->firstu,
@@ -169,7 +169,7 @@ TRACE_EVENT(xfs_attr_list_node_descend,
		__field(u32, hashval)
		__field(u32, blkno)
		__field(u32, offset)
		__field(void *, alist)
		__field(void *, buffer)
		__field(int, bufsize)
		__field(int, count)
		__field(int, firstu)
@@ -184,7 +184,7 @@ TRACE_EVENT(xfs_attr_list_node_descend,
		__entry->hashval = ctx->cursor->hashval;
		__entry->blkno = ctx->cursor->blkno;
		__entry->offset = ctx->cursor->offset;
		__entry->alist = ctx->alist;
		__entry->buffer = ctx->buffer;
		__entry->bufsize = ctx->bufsize;
		__entry->count = ctx->count;
		__entry->firstu = ctx->firstu;
@@ -193,7 +193,7 @@ TRACE_EVENT(xfs_attr_list_node_descend,
		__entry->bt_before = be32_to_cpu(btree->before);
	),
	TP_printk("dev %d:%d ino 0x%llx cursor h/b/o 0x%x/0x%x/%u dupcnt %u "
		  "alist %p size %u count %u firstu %u flags %d %s "
		  "buffer %p size %u count %u firstu %u flags %d %s "
		  "node hashval %u, node before %u",
		  MAJOR(__entry->dev), MINOR(__entry->dev),
		   __entry->ino,
@@ -201,7 +201,7 @@ TRACE_EVENT(xfs_attr_list_node_descend,
		   __entry->blkno,
		   __entry->offset,
		   __entry->dupcnt,
		   __entry->alist,
		   __entry->buffer,
		   __entry->bufsize,
		   __entry->count,
		   __entry->firstu,
+3 −3
Original line number Diff line number Diff line
@@ -134,7 +134,7 @@ __xfs_xattr_put_listent(
	if (context->count < 0 || context->seen_enough)
		return;

	if (!context->alist)
	if (!context->buffer)
		goto compute_size;

	arraytop = context->count + prefix_len + namelen + 1;
@@ -143,7 +143,7 @@ __xfs_xattr_put_listent(
		context->seen_enough = 1;
		return;
	}
	offset = (char *)context->alist + context->count;
	offset = context->buffer + context->count;
	strncpy(offset, prefix, prefix_len);
	offset += prefix_len;
	strncpy(offset, (char *)name, namelen);			/* real name */
@@ -229,7 +229,7 @@ xfs_vn_listxattr(
	context.dp = XFS_I(inode);
	context.cursor = &cursor;
	context.resynch = 1;
	context.alist = size ? data : NULL;
	context.buffer = size ? data : NULL;
	context.bufsize = size;
	context.firstu = context.bufsize;
	context.put_listent = xfs_xattr_put_listent;