]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: pass an initialized xfs_da_args to xfs_attr_get
authorChristoph Hellwig <hch@lst.de>
Fri, 1 May 2020 21:01:32 +0000 (17:01 -0400)
committerEric Sandeen <sandeen@redhat.com>
Fri, 1 May 2020 21:01:32 +0000 (17:01 -0400)
Source kernel commit: e5171d7e989479fe6298f8aedbd94e0aec23f5fc

Instead of converting from one style of arguments to another in
xfs_attr_set, pass the structure from higher up in the call chain.

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>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
libxfs/xfs_attr.c
libxfs/xfs_attr.h

index e42a80339a37cf972736b0953eb2539e8a09ed81..6fa88ed883652629b9f4d1970f09708a42c33c2c 100644 (file)
@@ -56,26 +56,6 @@ STATIC int xfs_attr_node_removename(xfs_da_args_t *args);
 STATIC int xfs_attr_fillstate(xfs_da_state_t *state);
 STATIC int xfs_attr_refillstate(xfs_da_state_t *state);
 
-
-STATIC int
-xfs_attr_args_init(
-       struct xfs_da_args      *args,
-       struct xfs_inode        *dp,
-       const unsigned char     *name,
-       size_t                  namelen,
-       int                     flags)
-{
-       memset(args, 0, sizeof(*args));
-       args->geo = dp->i_mount->m_attr_geo;
-       args->whichfork = XFS_ATTR_FORK;
-       args->dp = dp;
-       args->flags = flags;
-       args->name = name;
-       args->namelen = namelen;
-       args->hashval = xfs_da_hashname(args->name, args->namelen);
-       return 0;
-}
-
 int
 xfs_inode_hasattr(
        struct xfs_inode        *ip)
@@ -115,15 +95,15 @@ xfs_attr_get_ilocked(
 /*
  * Retrieve an extended attribute by name, and its value if requested.
  *
- * If ATTR_KERNOVAL is set in @flags, then the caller does not want the value,
- * just an indication whether the attribute exists and the size of the value if
- * it exists. The size is returned in @valuelenp,
+ * If ATTR_KERNOVAL is set in args->flags, then the caller does not want the
+ * value, just an indication whether the attribute exists and the size of the
+ * value if it exists. The size is returned in args.valuelen.
  *
  * If the attribute is found, but exceeds the size limit set by the caller in
- * @valuelenp, return -ERANGE with the size of the attribute that was found in
- * @valuelenp.
+ * args->valuelen, return -ERANGE with the size of the attribute that was found
+ * in args->valuelen.
  *
- * If ATTR_ALLOC is set in @flags, allocate the buffer for the value after
+ * If ATTR_ALLOC is set in args->flags, allocate the buffer for the value after
  * existence of the attribute has been determined. On success, return that
  * buffer to the caller and leave them to free it. On failure, free any
  * allocated buffer and ensure the buffer pointer returned to the caller is
@@ -131,51 +111,37 @@ xfs_attr_get_ilocked(
  */
 int
 xfs_attr_get(
-       struct xfs_inode        *ip,
-       const unsigned char     *name,
-       size_t                  namelen,
-       unsigned char           **value,
-       int                     *valuelenp,
-       int                     flags)
+       struct xfs_da_args      *args)
 {
-       struct xfs_da_args      args;
        uint                    lock_mode;
        int                     error;
 
-       ASSERT((flags & (ATTR_ALLOC | ATTR_KERNOVAL)) || *value);
+       ASSERT((args->flags & (ATTR_ALLOC | ATTR_KERNOVAL)) || args->value);
 
-       XFS_STATS_INC(ip->i_mount, xs_attr_get);
+       XFS_STATS_INC(args->dp->i_mount, xs_attr_get);
 
-       if (XFS_FORCED_SHUTDOWN(ip->i_mount))
+       if (XFS_FORCED_SHUTDOWN(args->dp->i_mount))
                return -EIO;
 
-       error = xfs_attr_args_init(&args, ip, name, namelen, flags);
-       if (error)
-               return error;
+       args->geo = args->dp->i_mount->m_attr_geo;
+       args->whichfork = XFS_ATTR_FORK;
+       args->hashval = xfs_da_hashname(args->name, args->namelen);
 
        /* Entirely possible to look up a name which doesn't exist */
-       args.op_flags = XFS_DA_OP_OKNOENT;
-       if (flags & ATTR_ALLOC)
-               args.op_flags |= XFS_DA_OP_ALLOCVAL;
-       else
-               args.value = *value;
-       args.valuelen = *valuelenp;
+       args->op_flags = XFS_DA_OP_OKNOENT;
+       if (args->flags & ATTR_ALLOC)
+               args->op_flags |= XFS_DA_OP_ALLOCVAL;
 
-       lock_mode = xfs_ilock_attr_map_shared(ip);
-       error = xfs_attr_get_ilocked(ip, &args);
-       xfs_iunlock(ip, lock_mode);
-       *valuelenp = args.valuelen;
+       lock_mode = xfs_ilock_attr_map_shared(args->dp);
+       error = xfs_attr_get_ilocked(args->dp, args);
+       xfs_iunlock(args->dp, lock_mode);
 
        /* on error, we have to clean up allocated value buffers */
-       if (error) {
-               if (flags & ATTR_ALLOC) {
-                       kmem_free(args.value);
-                       *value = NULL;
-               }
-               return error;
+       if (error && (args->flags & ATTR_ALLOC)) {
+               kmem_free(args->value);
+               args->value = NULL;
        }
-       *value = args.value;
-       return 0;
+       return error;
 }
 
 /*
index 07ca543db831f14fc8c82ea4c21209cffffcf34a..be77d13a290243c486e97e75929ffc6cf2ed165a 100644 (file)
@@ -146,9 +146,7 @@ int xfs_attr_list_int_ilocked(struct xfs_attr_list_context *);
 int xfs_attr_list_int(struct xfs_attr_list_context *);
 int xfs_inode_hasattr(struct xfs_inode *ip);
 int xfs_attr_get_ilocked(struct xfs_inode *ip, struct xfs_da_args *args);
-int xfs_attr_get(struct xfs_inode *ip, const unsigned char *name,
-                size_t namelen, unsigned char **value, int *valuelenp,
-                int flags);
+int xfs_attr_get(struct xfs_da_args *args);
 int xfs_attr_set(struct xfs_da_args *args);
 int xfs_attr_set_args(struct xfs_da_args *args);
 int xfs_attr_remove_args(struct xfs_da_args *args);