]> git.apps.os.sepia.ceph.com Git - xfsprogs-dev.git/commitdiff
xfs: remove xfs_attr_shortform_lookup
authorChristoph Hellwig <hch@lst.de>
Mon, 15 Apr 2024 23:07:43 +0000 (16:07 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Wed, 17 Apr 2024 21:06:26 +0000 (14:06 -0700)
Source kernel commit: 22b7b1f597a6a21fb7b3791a55f3a7ae54d2dfe4

xfs_attr_shortform_lookup is only used by xfs_attr_shortform_addname,
which is much better served by calling xfs_attr_sf_findname.  Switch
it over and remove xfs_attr_shortform_lookup.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Chandan Babu R <chandanbabu@kernel.org>
Reviewed-by: Bill O'Donnell <bodonnel@redhat.com>
libxfs/xfs_attr.c
libxfs/xfs_attr_leaf.c
libxfs/xfs_attr_leaf.h

index d5a5ae6e219fb4b79b33a3670e65e17a8b2fccef..a383024dbd7f93d8681ce631443c0571d6055782 100644 (file)
@@ -1064,19 +1064,14 @@ xfs_attr_shortform_addname(
        struct xfs_da_args      *args)
 {
        int                     newsize, forkoff;
-       int                     error;
 
        trace_xfs_attr_sf_addname(args);
 
-       error = xfs_attr_shortform_lookup(args);
-       switch (error) {
-       case -ENOATTR:
-               if (args->op_flags & XFS_DA_OP_REPLACE)
-                       return error;
-               break;
-       case -EEXIST:
+       if (xfs_attr_sf_findname(args)) {
+               int             error;
+
                if (!(args->op_flags & XFS_DA_OP_REPLACE))
-                       return error;
+                       return -EEXIST;
 
                error = xfs_attr_sf_removename(args);
                if (error)
@@ -1089,11 +1084,9 @@ xfs_attr_shortform_addname(
                 * around.
                 */
                args->op_flags &= ~XFS_DA_OP_REPLACE;
-               break;
-       case 0:
-               break;
-       default:
-               return error;
+       } else {
+               if (args->op_flags & XFS_DA_OP_REPLACE)
+                       return -ENOATTR;
        }
 
        if (args->namelen >= XFS_ATTR_SF_ENTSIZE_MAX ||
index 6ea364059a4e5d97f5249f1114acbb6bc7e39af6..8f1678d296a7932770d5d2ca316f6d13261e52ee 100644 (file)
@@ -834,30 +834,6 @@ xfs_attr_sf_removename(
        return 0;
 }
 
-/*
- * Look up a name in a shortform attribute list structure.
- */
-/*ARGSUSED*/
-int
-xfs_attr_shortform_lookup(
-       struct xfs_da_args              *args)
-{
-       struct xfs_ifork                *ifp = &args->dp->i_af;
-       struct xfs_attr_shortform       *sf = ifp->if_data;
-       struct xfs_attr_sf_entry        *sfe;
-       int                             i;
-
-       ASSERT(ifp->if_format == XFS_DINODE_FMT_LOCAL);
-       sfe = &sf->list[0];
-       for (i = 0; i < sf->hdr.count;
-                               sfe = xfs_attr_sf_nextentry(sfe), i++) {
-               if (xfs_attr_match(args, sfe->namelen, sfe->nameval,
-                               sfe->flags))
-                       return -EEXIST;
-       }
-       return -ENOATTR;
-}
-
 /*
  * Retrieve the attribute value and length.
  *
index 56fcd689eedfe7b1778638bf81d0678c8bb935de..35e668ae744fb14bef8d39a6e051b0b4c014762f 100644 (file)
@@ -47,7 +47,6 @@ struct xfs_attr3_icleaf_hdr {
  */
 void   xfs_attr_shortform_create(struct xfs_da_args *args);
 void   xfs_attr_shortform_add(struct xfs_da_args *args, int forkoff);
-int    xfs_attr_shortform_lookup(struct xfs_da_args *args);
 int    xfs_attr_shortform_getvalue(struct xfs_da_args *args);
 int    xfs_attr_shortform_to_leaf(struct xfs_da_args *args);
 int    xfs_attr_sf_removename(struct xfs_da_args *args);