]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: devirtualize ->data_entry_tag_p
authorChristoph Hellwig <hch@lst.de>
Wed, 22 Jan 2020 16:29:43 +0000 (11:29 -0500)
committerEric Sandeen <sandeen@redhat.com>
Wed, 22 Jan 2020 16:29:43 +0000 (11:29 -0500)
Source kernel commit: 7e8ae7bd1c5d806316e6b6403ac2dd0be7a1f82b

Replace the ->data_entry_tag_p dir ops method with a directly called
xfs_dir2_data_entry_tag_p helper that takes care of the differences
between the directory format with and without the file type field.

Signed-off-by: Christoph Hellwig <hch@lst.de>
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>
13 files changed:
db/check.c
db/dir2.c
db/metadump.c
libxfs/libxfs_api_defs.h
libxfs/xfs_da_format.c
libxfs/xfs_dir2.h
libxfs/xfs_dir2_block.c
libxfs/xfs_dir2_data.c
libxfs/xfs_dir2_leaf.c
libxfs/xfs_dir2_node.c
libxfs/xfs_dir2_priv.h
repair/dir2.c
repair/phase6.c

index c0665abe197d4d726995443c117073cee0d58015..3d370ba96044de37407c65c6a616f181b44828ea 100644 (file)
@@ -2401,7 +2401,7 @@ process_data_dir_v2(
                                        (int)((char *)dep - (char *)data));
                        error++;
                }
-               tagp = M_DIROPS(mp)->data_entry_tag_p(dep);
+               tagp = libxfs_dir2_data_entry_tag_p(mp, dep);
                if ((char *)tagp >= endptr) {
                        if (!sflag || v)
                                dbprintf(_("dir %lld block %d bad entry at %d\n"),
index 58f75b3956e8328d75b1a1cb5f74534a65a9f04c..80f8991f498807ead72a7526efe4754e9309c40b 100644 (file)
--- a/db/dir2.c
+++ b/db/dir2.c
@@ -486,7 +486,7 @@ dir2_data_union_tag_count(
                end = (char *)&dep->namelen + sizeof(dep->namelen);
                if (end > (char *)obj + mp->m_dir_geo->blksize)
                        return 0;
-               tagp = M_DIROPS(mp)->data_entry_tag_p(dep);
+               tagp = libxfs_dir2_data_entry_tag_p(mp, dep);
        }
        end = (char *)tagp + sizeof(*tagp);
        return end <= (char *)obj + mp->m_dir_geo->blksize;
@@ -508,7 +508,7 @@ dir2_data_union_tag_offset(
                return bitize((int)((char *)xfs_dir2_data_unused_tag_p(dup) -
                                    (char *)dup));
        dep = (xfs_dir2_data_entry_t *)dup;
-       return bitize((int)((char *)M_DIROPS(mp)->data_entry_tag_p(dep) -
+       return bitize((int)((char *)libxfs_dir2_data_entry_tag_p(mp, dep) -
                            (char *)dep));
 }
 
index 77e3b4ba4cfead13e21f75a01456218ad52e5d16..104477920d01b659344b8491b197fe2723ea580b 100644 (file)
@@ -1612,7 +1612,7 @@ process_dir_data_block(
                                        (long long)cur_ino);
                        return;
                }
-               if (be16_to_cpu(*M_DIROPS(mp)->data_entry_tag_p(dep)) !=
+               if (be16_to_cpu(*libxfs_dir2_data_entry_tag_p(mp, dep)) !=
                                dir_offset)
                        return;
 
@@ -1625,7 +1625,7 @@ process_dir_data_block(
                if (zero_stale_data) {
                        /* 1 byte for ftype; don't bother with conditional */
                        int zlen =
-                               (char *)M_DIROPS(mp)->data_entry_tag_p(dep) -
+                               (char *)libxfs_dir2_data_entry_tag_p(mp, dep) -
                                (char *)&dep->name[dep->namelen] - 1;
                        if (zlen > 0) {
                                memset(&dep->name[dep->namelen] + 1, 0, zlen);
index 208db077aa66b75f5de579018f24f246fdad7040..e095b7d603b7e0bb7ffff53feb7e312750920a9f 100644 (file)
@@ -85,6 +85,7 @@
 #define xfs_dir2_data_make_free                libxfs_dir2_data_make_free
 #define xfs_dir2_data_use_free         libxfs_dir2_data_use_free
 #define xfs_dir2_data_entsize          libxfs_dir2_data_entsize
+#define xfs_dir2_data_entry_tag_p      libxfs_dir2_data_entry_tag_p
 #define xfs_dir2_shrink_inode          libxfs_dir2_shrink_inode
 #define xfs_dir2_sf_get_parent_ino     libxfs_dir2_sf_get_parent_ino
 #define xfs_dir2_sf_put_parent_ino     libxfs_dir2_sf_put_parent_ino
index d54d6e2888150967ae8fdfb647fd07915c7ecbb0..a731dc97cbbab2a026a5b18c4263731cb909b41d 100644 (file)
@@ -89,25 +89,6 @@ xfs_dir3_data_put_ftype(
        dep->name[dep->namelen] = type;
 }
 
-/*
- * Pointer to an entry's tag word.
- */
-static __be16 *
-xfs_dir2_data_entry_tag_p(
-       struct xfs_dir2_data_entry *dep)
-{
-       return (__be16 *)((char *)dep +
-               XFS_DIR2_DATA_ENTSIZE(dep->namelen) - sizeof(__be16));
-}
-
-static __be16 *
-xfs_dir3_data_entry_tag_p(
-       struct xfs_dir2_data_entry *dep)
-{
-       return (__be16 *)((char *)dep +
-               XFS_DIR3_DATA_ENTSIZE(dep->namelen) - sizeof(__be16));
-}
-
 static struct xfs_dir2_data_free *
 xfs_dir2_data_bestfree_p(struct xfs_dir2_data_hdr *hdr)
 {
@@ -123,7 +104,6 @@ xfs_dir3_data_bestfree_p(struct xfs_dir2_data_hdr *hdr)
 static const struct xfs_dir_ops xfs_dir2_ops = {
        .data_get_ftype = xfs_dir2_data_get_ftype,
        .data_put_ftype = xfs_dir2_data_put_ftype,
-       .data_entry_tag_p = xfs_dir2_data_entry_tag_p,
        .data_bestfree_p = xfs_dir2_data_bestfree_p,
 
        .data_first_offset =  sizeof(struct xfs_dir2_data_hdr) +
@@ -135,7 +115,6 @@ static const struct xfs_dir_ops xfs_dir2_ops = {
 static const struct xfs_dir_ops xfs_dir2_ftype_ops = {
        .data_get_ftype = xfs_dir3_data_get_ftype,
        .data_put_ftype = xfs_dir3_data_put_ftype,
-       .data_entry_tag_p = xfs_dir3_data_entry_tag_p,
        .data_bestfree_p = xfs_dir2_data_bestfree_p,
 
        .data_first_offset =  sizeof(struct xfs_dir2_data_hdr) +
@@ -147,7 +126,6 @@ static const struct xfs_dir_ops xfs_dir2_ftype_ops = {
 static const struct xfs_dir_ops xfs_dir3_ops = {
        .data_get_ftype = xfs_dir3_data_get_ftype,
        .data_put_ftype = xfs_dir3_data_put_ftype,
-       .data_entry_tag_p = xfs_dir3_data_entry_tag_p,
        .data_bestfree_p = xfs_dir3_data_bestfree_p,
 
        .data_first_offset =  sizeof(struct xfs_dir3_data_hdr) +
index f717b1cdb208376fd14e38414a59b328e5019bdb..3f46954e93700576bdb0e7c8f52f4f03ffe018a1 100644 (file)
@@ -35,7 +35,6 @@ struct xfs_dir_ops {
        uint8_t (*data_get_ftype)(struct xfs_dir2_data_entry *dep);
        void    (*data_put_ftype)(struct xfs_dir2_data_entry *dep,
                                uint8_t ftype);
-       __be16 * (*data_entry_tag_p)(struct xfs_dir2_data_entry *dep);
        struct xfs_dir2_data_free *
                (*data_bestfree_p)(struct xfs_dir2_data_hdr *hdr);
 
index 8d2354ead62c99cf791274319089a1e8464fd801..8a1739b263824bd6df308fc7c2fe06a767a93fa9 100644 (file)
@@ -539,7 +539,7 @@ xfs_dir2_block_addname(
        dep->namelen = args->namelen;
        memcpy(dep->name, args->name, args->namelen);
        dp->d_ops->data_put_ftype(dep, args->filetype);
-       tagp = dp->d_ops->data_entry_tag_p(dep);
+       tagp = xfs_dir2_data_entry_tag_p(dp->i_mount, dep);
        *tagp = cpu_to_be16((char *)dep - (char *)hdr);
        /*
         * Clean up the bestfree array and log the header, tail, and entry.
@@ -1142,7 +1142,7 @@ xfs_dir2_sf_to_block(
        dep->namelen = 1;
        dep->name[0] = '.';
        dp->d_ops->data_put_ftype(dep, XFS_DIR3_FT_DIR);
-       tagp = dp->d_ops->data_entry_tag_p(dep);
+       tagp = xfs_dir2_data_entry_tag_p(mp, dep);
        *tagp = cpu_to_be16(offset);
        xfs_dir2_data_log_entry(args, bp, dep);
        blp[0].hashval = cpu_to_be32(xfs_dir_hash_dot);
@@ -1157,7 +1157,7 @@ xfs_dir2_sf_to_block(
        dep->namelen = 2;
        dep->name[0] = dep->name[1] = '.';
        dp->d_ops->data_put_ftype(dep, XFS_DIR3_FT_DIR);
-       tagp = dp->d_ops->data_entry_tag_p(dep);
+       tagp = xfs_dir2_data_entry_tag_p(mp, dep);
        *tagp = cpu_to_be16(offset);
        xfs_dir2_data_log_entry(args, bp, dep);
        blp[1].hashval = cpu_to_be32(xfs_dir_hash_dotdot);
@@ -1208,7 +1208,7 @@ xfs_dir2_sf_to_block(
                dep->namelen = sfep->namelen;
                dp->d_ops->data_put_ftype(dep, xfs_dir2_sf_get_ftype(mp, sfep));
                memcpy(dep->name, sfep->name, dep->namelen);
-               tagp = dp->d_ops->data_entry_tag_p(dep);
+               tagp = xfs_dir2_data_entry_tag_p(mp, dep);
                *tagp = cpu_to_be16(newoffset);
                xfs_dir2_data_log_entry(args, bp, dep);
                name.name = sfep->name;
index b18b736701b2103ef610ea39bceeb505a4c99a82..ea493c4947642a00af44cfc4ee9f85cd56bbe278 100644 (file)
@@ -14,6 +14,7 @@
 #include "xfs_inode.h"
 #include "xfs_dir2.h"
 #include "xfs_dir2_priv.h"
+#include "xfs_dir2_priv.h"
 #include "xfs_trans.h"
 
 static xfs_failaddr_t xfs_dir2_data_freefind_verify(
@@ -21,6 +22,18 @@ static xfs_failaddr_t xfs_dir2_data_freefind_verify(
                struct xfs_dir2_data_unused *dup,
                struct xfs_dir2_data_free **bf_ent);
 
+/*
+ * Pointer to an entry's tag word.
+ */
+__be16 *
+xfs_dir2_data_entry_tag_p(
+       struct xfs_mount                *mp,
+       struct xfs_dir2_data_entry      *dep)
+{
+       return (__be16 *)((char *)dep +
+               xfs_dir2_data_entsize(mp, dep->namelen) - sizeof(__be16));
+}
+
 /*
  * The number of leaf entries is limited by the size of the block and the amount
  * of space used by the data entries.  We don't know how much space is used by
@@ -179,7 +192,7 @@ __xfs_dir3_data_check(
                        return __this_address;
                if (offset + xfs_dir2_data_entsize(mp, dep->namelen) > end)
                        return __this_address;
-               if (be16_to_cpu(*ops->data_entry_tag_p(dep)) != offset)
+               if (be16_to_cpu(*xfs_dir2_data_entry_tag_p(mp, dep)) != offset)
                        return __this_address;
                if (ops->data_get_ftype(dep) >= XFS_DIR3_FT_MAX)
                        return __this_address;
@@ -605,7 +618,8 @@ xfs_dir2_data_freescan_int(
                /*
                 * For active entries, check their tags and skip them.
                 */
-               ASSERT(offset == be16_to_cpu(*ops->data_entry_tag_p(dep)));
+               ASSERT(offset ==
+                      be16_to_cpu(*xfs_dir2_data_entry_tag_p(mp, dep)));
                offset += xfs_dir2_data_entsize(mp, dep->namelen);
        }
 }
@@ -700,6 +714,7 @@ xfs_dir2_data_log_entry(
        struct xfs_buf          *bp,
        xfs_dir2_data_entry_t   *dep)           /* data entry pointer */
 {
+       struct xfs_mount        *mp = bp->b_mount;
        struct xfs_dir2_data_hdr *hdr = bp->b_addr;
 
        ASSERT(hdr->magic == cpu_to_be32(XFS_DIR2_DATA_MAGIC) ||
@@ -708,7 +723,7 @@ xfs_dir2_data_log_entry(
               hdr->magic == cpu_to_be32(XFS_DIR3_BLOCK_MAGIC));
 
        xfs_trans_log_buf(args->trans, bp, (uint)((char *)dep - (char *)hdr),
-               (uint)((char *)(args->dp->d_ops->data_entry_tag_p(dep) + 1) -
+               (uint)((char *)(xfs_dir2_data_entry_tag_p(mp, dep) + 1) -
                       (char *)hdr - 1));
 }
 
index a0cd60f3efae1840b467819d866456a5b4f46246..fa201d1521963ba3f5c83f056b032343c47da57c 100644 (file)
@@ -864,7 +864,7 @@ xfs_dir2_leaf_addname(
        dep->namelen = args->namelen;
        memcpy(dep->name, args->name, dep->namelen);
        dp->d_ops->data_put_ftype(dep, args->filetype);
-       tagp = dp->d_ops->data_entry_tag_p(dep);
+       tagp = xfs_dir2_data_entry_tag_p(dp->i_mount, dep);
        *tagp = cpu_to_be16((char *)dep - (char *)hdr);
        /*
         * Need to scan fix up the bestfree table.
index b446bed7cb4bbc063f1f4b01a171cc7a6b14c1d4..9ed02ab6b3a3f5971734e108bb5f9417d0fcbe2b 100644 (file)
@@ -1969,7 +1969,7 @@ xfs_dir2_node_addname_int(
        dep->namelen = args->namelen;
        memcpy(dep->name, args->name, dep->namelen);
        dp->d_ops->data_put_ftype(dep, args->filetype);
-       tagp = dp->d_ops->data_entry_tag_p(dep);
+       tagp = xfs_dir2_data_entry_tag_p(dp->i_mount, dep);
        *tagp = cpu_to_be16((char *)dep - (char *)hdr);
        xfs_dir2_data_log_entry(args, dbp, dep);
 
index b97718eef8c67393ca9736f244d66c239f807703..ca92a41027d8ec46a66463eb926e10d9e5916790 100644 (file)
@@ -58,6 +58,8 @@ extern int xfs_dir2_leaf_to_block(struct xfs_da_args *args,
 
 /* xfs_dir2_data.c */
 int xfs_dir2_data_entsize(struct xfs_mount *mp, int n);
+__be16 *xfs_dir2_data_entry_tag_p(struct xfs_mount *mp,
+               struct xfs_dir2_data_entry *dep);
 
 #ifdef DEBUG
 extern void xfs_dir3_data_check(struct xfs_inode *dp, struct xfs_buf *bp);
index c15e8754c949b070a4b626e872d63066897fdbc7..398176d98cb454a45c90ed32ba5d6a0bb203f085 100644 (file)
@@ -627,7 +627,7 @@ process_dir2_data(
                dep = (xfs_dir2_data_entry_t *)ptr;
                if (ptr + libxfs_dir2_data_entsize(mp, dep->namelen) > endptr)
                        break;
-               if (be16_to_cpu(*M_DIROPS(mp)->data_entry_tag_p(dep)) !=
+               if (be16_to_cpu(*libxfs_dir2_data_entry_tag_p(mp, dep)) !=
                                                (char *)dep - (char *)d)
                        break;
                ptr += libxfs_dir2_data_entsize(mp, dep->namelen);
index 4c74d6f2d4846fdb767895d96f92aceb20e207b6..88fc23318faca3afb3bf8a6af91866784152a004 100644 (file)
@@ -1604,7 +1604,7 @@ longform_dir2_entry_check_data(
                dep = (xfs_dir2_data_entry_t *)ptr;
                if (ptr + libxfs_dir2_data_entsize(mp, dep->namelen) > endptr)
                        break;
-               if (be16_to_cpu(*M_DIROPS(mp)->data_entry_tag_p(dep)) !=
+               if (be16_to_cpu(*libxfs_dir2_data_entry_tag_p(mp, dep)) !=
                                                (char *)dep - (char *)d)
                        break;
                ptr += libxfs_dir2_data_entsize(mp, dep->namelen);