mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-26 16:41:25 +00:00
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: Christoph Hellwig <hch@lst.de> Reviewed-by: Dave Chinner <dchinner@redhat.com> Reviewed-by: Chandan Rajendra <chandanrlinux@gmail.com> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
This commit is contained in:
parent
377f16ac67
commit
a9c8c69b49
4 changed files with 54 additions and 53 deletions
|
@ -99,28 +99,28 @@ typedef struct attrlist_cursor_kern {
|
||||||
typedef void (*put_listent_func_t)(struct xfs_attr_list_context *, int,
|
typedef void (*put_listent_func_t)(struct xfs_attr_list_context *, int,
|
||||||
unsigned char *, int, int);
|
unsigned char *, int, int);
|
||||||
|
|
||||||
typedef struct xfs_attr_list_context {
|
struct xfs_attr_list_context {
|
||||||
struct xfs_trans *tp;
|
struct xfs_trans *tp;
|
||||||
struct xfs_inode *dp; /* inode */
|
struct xfs_inode *dp; /* inode */
|
||||||
struct attrlist_cursor_kern *cursor; /* position in list */
|
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
|
* Abort attribute list iteration if non-zero. Can be used to pass
|
||||||
* error values to the xfs_attr_list caller.
|
* error values to the xfs_attr_list caller.
|
||||||
*/
|
*/
|
||||||
int seen_enough;
|
int seen_enough;
|
||||||
bool allow_incomplete;
|
bool allow_incomplete;
|
||||||
|
|
||||||
ssize_t count; /* num used entries */
|
ssize_t count; /* num used entries */
|
||||||
int dupcnt; /* count dup hashvals seen */
|
int dupcnt; /* count dup hashvals seen */
|
||||||
int bufsize; /* total buffer size */
|
int bufsize; /* total buffer size */
|
||||||
int firstu; /* first used byte in buffer */
|
int firstu; /* first used byte in buffer */
|
||||||
int flags; /* from VOP call */
|
int flags; /* from VOP call */
|
||||||
int resynch; /* T/F: resynch with cursor */
|
int resynch; /* T/F: resynch with cursor */
|
||||||
put_listent_func_t put_listent; /* list output fmt function */
|
put_listent_func_t put_listent; /* list output fmt function */
|
||||||
int index; /* index into output buffer */
|
int index; /* index into output buffer */
|
||||||
} xfs_attr_list_context_t;
|
};
|
||||||
|
|
||||||
|
|
||||||
/*========================================================================
|
/*========================================================================
|
||||||
|
|
|
@ -488,10 +488,11 @@ xfs_attr3_leaf_list_int(
|
||||||
* Copy out attribute entries for attr_list(), for leaf attribute lists.
|
* Copy out attribute entries for attr_list(), for leaf attribute lists.
|
||||||
*/
|
*/
|
||||||
STATIC int
|
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;
|
||||||
struct xfs_buf *bp;
|
int error;
|
||||||
|
|
||||||
trace_xfs_attr_leaf_list(context);
|
trace_xfs_attr_leaf_list(context);
|
||||||
|
|
||||||
|
@ -527,11 +528,11 @@ xfs_attr_list_int_ilocked(
|
||||||
|
|
||||||
int
|
int
|
||||||
xfs_attr_list_int(
|
xfs_attr_list_int(
|
||||||
xfs_attr_list_context_t *context)
|
struct xfs_attr_list_context *context)
|
||||||
{
|
{
|
||||||
int error;
|
struct xfs_inode *dp = context->dp;
|
||||||
xfs_inode_t *dp = context->dp;
|
uint lock_mode;
|
||||||
uint lock_mode;
|
int error;
|
||||||
|
|
||||||
XFS_STATS_INC(dp->i_mount, xs_attr_list);
|
XFS_STATS_INC(dp->i_mount, xs_attr_list);
|
||||||
|
|
||||||
|
@ -557,15 +558,15 @@ xfs_attr_list_int(
|
||||||
*/
|
*/
|
||||||
STATIC void
|
STATIC void
|
||||||
xfs_attr_put_listent(
|
xfs_attr_put_listent(
|
||||||
xfs_attr_list_context_t *context,
|
struct xfs_attr_list_context *context,
|
||||||
int flags,
|
int flags,
|
||||||
unsigned char *name,
|
unsigned char *name,
|
||||||
int namelen,
|
int namelen,
|
||||||
int valuelen)
|
int valuelen)
|
||||||
{
|
{
|
||||||
struct attrlist *alist = (struct attrlist *)context->alist;
|
struct attrlist *alist = context->buffer;
|
||||||
attrlist_ent_t *aep;
|
struct attrlist_ent *aep;
|
||||||
int arraytop;
|
int arraytop;
|
||||||
|
|
||||||
ASSERT(!context->seen_enough);
|
ASSERT(!context->seen_enough);
|
||||||
ASSERT(context->count >= 0);
|
ASSERT(context->count >= 0);
|
||||||
|
@ -593,7 +594,7 @@ xfs_attr_put_listent(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
aep = (attrlist_ent_t *)&context->alist[context->firstu];
|
aep = context->buffer + context->firstu;
|
||||||
aep->a_valuelen = valuelen;
|
aep->a_valuelen = valuelen;
|
||||||
memcpy(aep->a_name, name, namelen);
|
memcpy(aep->a_name, name, namelen);
|
||||||
aep->a_name[namelen] = 0;
|
aep->a_name[namelen] = 0;
|
||||||
|
@ -612,15 +613,15 @@ xfs_attr_put_listent(
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
xfs_attr_list(
|
xfs_attr_list(
|
||||||
xfs_inode_t *dp,
|
struct xfs_inode *dp,
|
||||||
char *buffer,
|
char *buffer,
|
||||||
int bufsize,
|
int bufsize,
|
||||||
int flags,
|
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;
|
struct attrlist *alist;
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Validate the cursor.
|
* Validate the cursor.
|
||||||
|
@ -645,12 +646,12 @@ xfs_attr_list(
|
||||||
context.cursor = cursor;
|
context.cursor = cursor;
|
||||||
context.resynch = 1;
|
context.resynch = 1;
|
||||||
context.flags = flags;
|
context.flags = flags;
|
||||||
context.alist = buffer;
|
context.buffer = buffer;
|
||||||
context.bufsize = (bufsize & ~(sizeof(int)-1)); /* align */
|
context.bufsize = (bufsize & ~(sizeof(int)-1)); /* align */
|
||||||
context.firstu = context.bufsize;
|
context.firstu = context.bufsize;
|
||||||
context.put_listent = xfs_attr_put_listent;
|
context.put_listent = xfs_attr_put_listent;
|
||||||
|
|
||||||
alist = (struct attrlist *)context.alist;
|
alist = context.buffer;
|
||||||
alist->al_count = 0;
|
alist->al_count = 0;
|
||||||
alist->al_more = 0;
|
alist->al_more = 0;
|
||||||
alist->al_offset[0] = context.bufsize;
|
alist->al_offset[0] = context.bufsize;
|
||||||
|
|
|
@ -45,7 +45,7 @@ DECLARE_EVENT_CLASS(xfs_attr_list_class,
|
||||||
__field(u32, hashval)
|
__field(u32, hashval)
|
||||||
__field(u32, blkno)
|
__field(u32, blkno)
|
||||||
__field(u32, offset)
|
__field(u32, offset)
|
||||||
__field(void *, alist)
|
__field(void *, buffer)
|
||||||
__field(int, bufsize)
|
__field(int, bufsize)
|
||||||
__field(int, count)
|
__field(int, count)
|
||||||
__field(int, firstu)
|
__field(int, firstu)
|
||||||
|
@ -58,21 +58,21 @@ DECLARE_EVENT_CLASS(xfs_attr_list_class,
|
||||||
__entry->hashval = ctx->cursor->hashval;
|
__entry->hashval = ctx->cursor->hashval;
|
||||||
__entry->blkno = ctx->cursor->blkno;
|
__entry->blkno = ctx->cursor->blkno;
|
||||||
__entry->offset = ctx->cursor->offset;
|
__entry->offset = ctx->cursor->offset;
|
||||||
__entry->alist = ctx->alist;
|
__entry->buffer = ctx->buffer;
|
||||||
__entry->bufsize = ctx->bufsize;
|
__entry->bufsize = ctx->bufsize;
|
||||||
__entry->count = ctx->count;
|
__entry->count = ctx->count;
|
||||||
__entry->firstu = ctx->firstu;
|
__entry->firstu = ctx->firstu;
|
||||||
__entry->flags = ctx->flags;
|
__entry->flags = ctx->flags;
|
||||||
),
|
),
|
||||||
TP_printk("dev %d:%d ino 0x%llx cursor h/b/o 0x%x/0x%x/%u dupcnt %u "
|
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),
|
MAJOR(__entry->dev), MINOR(__entry->dev),
|
||||||
__entry->ino,
|
__entry->ino,
|
||||||
__entry->hashval,
|
__entry->hashval,
|
||||||
__entry->blkno,
|
__entry->blkno,
|
||||||
__entry->offset,
|
__entry->offset,
|
||||||
__entry->dupcnt,
|
__entry->dupcnt,
|
||||||
__entry->alist,
|
__entry->buffer,
|
||||||
__entry->bufsize,
|
__entry->bufsize,
|
||||||
__entry->count,
|
__entry->count,
|
||||||
__entry->firstu,
|
__entry->firstu,
|
||||||
|
@ -169,7 +169,7 @@ TRACE_EVENT(xfs_attr_list_node_descend,
|
||||||
__field(u32, hashval)
|
__field(u32, hashval)
|
||||||
__field(u32, blkno)
|
__field(u32, blkno)
|
||||||
__field(u32, offset)
|
__field(u32, offset)
|
||||||
__field(void *, alist)
|
__field(void *, buffer)
|
||||||
__field(int, bufsize)
|
__field(int, bufsize)
|
||||||
__field(int, count)
|
__field(int, count)
|
||||||
__field(int, firstu)
|
__field(int, firstu)
|
||||||
|
@ -184,7 +184,7 @@ TRACE_EVENT(xfs_attr_list_node_descend,
|
||||||
__entry->hashval = ctx->cursor->hashval;
|
__entry->hashval = ctx->cursor->hashval;
|
||||||
__entry->blkno = ctx->cursor->blkno;
|
__entry->blkno = ctx->cursor->blkno;
|
||||||
__entry->offset = ctx->cursor->offset;
|
__entry->offset = ctx->cursor->offset;
|
||||||
__entry->alist = ctx->alist;
|
__entry->buffer = ctx->buffer;
|
||||||
__entry->bufsize = ctx->bufsize;
|
__entry->bufsize = ctx->bufsize;
|
||||||
__entry->count = ctx->count;
|
__entry->count = ctx->count;
|
||||||
__entry->firstu = ctx->firstu;
|
__entry->firstu = ctx->firstu;
|
||||||
|
@ -193,7 +193,7 @@ TRACE_EVENT(xfs_attr_list_node_descend,
|
||||||
__entry->bt_before = be32_to_cpu(btree->before);
|
__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 "
|
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",
|
"node hashval %u, node before %u",
|
||||||
MAJOR(__entry->dev), MINOR(__entry->dev),
|
MAJOR(__entry->dev), MINOR(__entry->dev),
|
||||||
__entry->ino,
|
__entry->ino,
|
||||||
|
@ -201,7 +201,7 @@ TRACE_EVENT(xfs_attr_list_node_descend,
|
||||||
__entry->blkno,
|
__entry->blkno,
|
||||||
__entry->offset,
|
__entry->offset,
|
||||||
__entry->dupcnt,
|
__entry->dupcnt,
|
||||||
__entry->alist,
|
__entry->buffer,
|
||||||
__entry->bufsize,
|
__entry->bufsize,
|
||||||
__entry->count,
|
__entry->count,
|
||||||
__entry->firstu,
|
__entry->firstu,
|
||||||
|
|
|
@ -134,7 +134,7 @@ __xfs_xattr_put_listent(
|
||||||
if (context->count < 0 || context->seen_enough)
|
if (context->count < 0 || context->seen_enough)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!context->alist)
|
if (!context->buffer)
|
||||||
goto compute_size;
|
goto compute_size;
|
||||||
|
|
||||||
arraytop = context->count + prefix_len + namelen + 1;
|
arraytop = context->count + prefix_len + namelen + 1;
|
||||||
|
@ -143,7 +143,7 @@ __xfs_xattr_put_listent(
|
||||||
context->seen_enough = 1;
|
context->seen_enough = 1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
offset = (char *)context->alist + context->count;
|
offset = context->buffer + context->count;
|
||||||
strncpy(offset, prefix, prefix_len);
|
strncpy(offset, prefix, prefix_len);
|
||||||
offset += prefix_len;
|
offset += prefix_len;
|
||||||
strncpy(offset, (char *)name, namelen); /* real name */
|
strncpy(offset, (char *)name, namelen); /* real name */
|
||||||
|
@ -229,7 +229,7 @@ xfs_vn_listxattr(
|
||||||
context.dp = XFS_I(inode);
|
context.dp = XFS_I(inode);
|
||||||
context.cursor = &cursor;
|
context.cursor = &cursor;
|
||||||
context.resynch = 1;
|
context.resynch = 1;
|
||||||
context.alist = size ? data : NULL;
|
context.buffer = size ? data : NULL;
|
||||||
context.bufsize = size;
|
context.bufsize = size;
|
||||||
context.firstu = context.bufsize;
|
context.firstu = context.bufsize;
|
||||||
context.put_listent = xfs_xattr_put_listent;
|
context.put_listent = xfs_xattr_put_listent;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue