]> www.infradead.org Git - users/hch/xfsprogs.git/commitdiff
xfs: devirtualize ->sf_entsize and ->sf_nextentry
authorChristoph Hellwig <hch@lst.de>
Wed, 22 Jan 2020 16:29:42 +0000 (11:29 -0500)
committerEric Sandeen <sandeen@redhat.com>
Wed, 22 Jan 2020 16:29:42 +0000 (11:29 -0500)
Source kernel commit: 50f6bb6b7aea8177110e55355c455f18912a7a73

Just check for file-type enabled directories directly.

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>
12 files changed:
db/check.c
db/dir2sf.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_priv.h
libxfs/xfs_dir2_sf.c
logprint/log_misc.c
repair/dir2.c
repair/phase6.c

index 0971accc51c8b52a28eb5faef0d2a41e3d924c29..35e4bea471cfad9d21b33fe0f616a369264c397d 100644 (file)
@@ -3628,7 +3628,8 @@ process_sf_dir_v2(
        sfe = xfs_dir2_sf_firstentry(sf);
        offset = M_DIROPS(mp)->data_first_offset;
        for (i = sf->count - 1, i8 = 0; i >= 0; i--) {
-               if ((intptr_t)sfe + M_DIROPS(mp)->sf_entsize(sf, sfe->namelen) -
+               if ((intptr_t)sfe +
+                   libxfs_dir2_sf_entsize(mp, sf, sfe->namelen) -
                    (intptr_t)sf > be64_to_cpu(dip->di_size)) {
                        if (!sflag)
                                dbprintf(_("dir %llu bad size in entry at %d\n"),
@@ -3667,8 +3668,8 @@ process_sf_dir_v2(
                }
                offset =
                        xfs_dir2_sf_get_offset(sfe) +
-                       M_DIROPS(mp)->sf_entsize(sf, sfe->namelen);
-               sfe = M_DIROPS(mp)->sf_nextentry(sf, sfe);
+                       libxfs_dir2_sf_entsize(mp, sf, sfe->namelen);
+               sfe = libxfs_dir2_sf_nextentry(mp, sf, sfe);
        }
        if (i < 0 && (intptr_t)sfe - (intptr_t)sf !=
                                        be64_to_cpu(dip->di_size)) {
index 5737f2a31fab78fd0f464464c5872678c8178fa4..8165b79bc57d303987cce929216507209a797b37 100644 (file)
@@ -167,8 +167,8 @@ dir2_sf_entry_size(
        sf = (struct xfs_dir2_sf_hdr *)((char *)obj + byteize(startoff));
        e = xfs_dir2_sf_firstentry(sf);
        for (i = 0; i < idx; i++)
-               e = M_DIROPS(mp)->sf_nextentry(sf, e);
-       return bitize((int)M_DIROPS(mp)->sf_entsize(sf, e->namelen));
+               e = libxfs_dir2_sf_nextentry(mp, sf, e);
+       return bitize((int)libxfs_dir2_sf_entsize(mp, sf, e->namelen));
 }
 
 /*ARGSUSED*/
@@ -212,7 +212,7 @@ dir2_sf_list_offset(
        sf = (struct xfs_dir2_sf_hdr *)((char *)obj + byteize(startoff));
        e = xfs_dir2_sf_firstentry(sf);
        for (i = 0; i < idx; i++)
-               e = M_DIROPS(mp)->sf_nextentry(sf, e);
+               e = libxfs_dir2_sf_nextentry(mp, sf, e);
        return bitize((int)((char *)e - (char *)sf));
 }
 
@@ -232,7 +232,7 @@ dir2sf_size(
        sf = (struct xfs_dir2_sf_hdr *)((char *)obj + byteize(startoff));
        e = xfs_dir2_sf_firstentry(sf);
        for (i = 0; i < sf->count; i++)
-               e = M_DIROPS(mp)->sf_nextentry(sf, e);
+               e = libxfs_dir2_sf_nextentry(mp, sf, e);
        return bitize((int)((char *)e - (char *)sf));
 }
 
index 88a242ea625cb59725238d86a2872a302dc8c5bf..324647275f90cd6e4d1377dfced8dd8ef22c1ec1 100644 (file)
@@ -1269,7 +1269,7 @@ process_sf_dir(
                        namelen = ino_dir_size - ((char *)&sfep->name[0] -
                                         (char *)sfp);
                } else if ((char *)sfep - (char *)sfp +
-                               M_DIROPS(mp)->sf_entsize(sfp, sfep->namelen) >
+                               libxfs_dir2_sf_entsize(mp, sfp, sfep->namelen) >
                                ino_dir_size) {
                        if (show_warnings)
                                print_warning("entry length in dir inode %llu "
@@ -1286,7 +1286,7 @@ process_sf_dir(
                                         namelen, &sfep->name[0]);
 
                sfep = (xfs_dir2_sf_entry_t *)((char *)sfep +
-                               M_DIROPS(mp)->sf_entsize(sfp, namelen));
+                               libxfs_dir2_sf_entsize(mp, sfp, namelen));
        }
 
        /* zero stale data in rest of space in data fork, if any */
index 5a3307657446ff68f15ad5b5b6ff244c27a9681d..443e0ec86d6c388daf58e116bbcbf6def730da8c 100644 (file)
@@ -87,6 +87,8 @@
 #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
+#define xfs_dir2_sf_entsize            libxfs_dir2_sf_entsize
+#define xfs_dir2_sf_nextentry          libxfs_dir2_sf_nextentry
 #define xfs_dir2_namecheck             libxfs_dir2_namecheck
 #define xfs_da_get_buf                 libxfs_da_get_buf
 
index c6b2cad22250297e20a430cb310c2044f758b854..fe93f5405e62d936bbb8bea0b1aa96f5847caeb6 100644 (file)
 #include "xfs_dir2.h"
 #include "xfs_dir2_priv.h"
 
-/*
- * Shortform directory ops
- */
-static int
-xfs_dir2_sf_entsize(
-       struct xfs_dir2_sf_hdr  *hdr,
-       int                     len)
-{
-       int count = sizeof(struct xfs_dir2_sf_entry);   /* namelen + offset */
-
-       count += len;                                   /* name */
-       count += hdr->i8count ? XFS_INO64_SIZE : XFS_INO32_SIZE; /* ino # */
-       return count;
-}
-
-static int
-xfs_dir3_sf_entsize(
-       struct xfs_dir2_sf_hdr  *hdr,
-       int                     len)
-{
-       return xfs_dir2_sf_entsize(hdr, len) + sizeof(uint8_t);
-}
-
-static struct xfs_dir2_sf_entry *
-xfs_dir2_sf_nextentry(
-       struct xfs_dir2_sf_hdr  *hdr,
-       struct xfs_dir2_sf_entry *sfep)
-{
-       return (struct xfs_dir2_sf_entry *)
-               ((char *)sfep + xfs_dir2_sf_entsize(hdr, sfep->namelen));
-}
-
-static struct xfs_dir2_sf_entry *
-xfs_dir3_sf_nextentry(
-       struct xfs_dir2_sf_hdr  *hdr,
-       struct xfs_dir2_sf_entry *sfep)
-{
-       return (struct xfs_dir2_sf_entry *)
-               ((char *)sfep + xfs_dir3_sf_entsize(hdr, sfep->namelen));
-}
-
-
 /*
  * For filetype enabled shortform directories, the file type field is stored at
  * the end of the name.  Because it's only a single byte, endian conversion is
@@ -401,8 +359,6 @@ xfs_dir3_data_unused_p(struct xfs_dir2_data_hdr *hdr)
 }
 
 static const struct xfs_dir_ops xfs_dir2_ops = {
-       .sf_entsize = xfs_dir2_sf_entsize,
-       .sf_nextentry = xfs_dir2_sf_nextentry,
        .sf_get_ftype = xfs_dir2_sfe_get_ftype,
        .sf_put_ftype = xfs_dir2_sfe_put_ftype,
        .sf_get_ino = xfs_dir2_sfe_get_ino,
@@ -430,8 +386,6 @@ static const struct xfs_dir_ops xfs_dir2_ops = {
 };
 
 static const struct xfs_dir_ops xfs_dir2_ftype_ops = {
-       .sf_entsize = xfs_dir3_sf_entsize,
-       .sf_nextentry = xfs_dir3_sf_nextentry,
        .sf_get_ftype = xfs_dir3_sfe_get_ftype,
        .sf_put_ftype = xfs_dir3_sfe_put_ftype,
        .sf_get_ino = xfs_dir3_sfe_get_ino,
@@ -459,8 +413,6 @@ static const struct xfs_dir_ops xfs_dir2_ftype_ops = {
 };
 
 static const struct xfs_dir_ops xfs_dir3_ops = {
-       .sf_entsize = xfs_dir3_sf_entsize,
-       .sf_nextentry = xfs_dir3_sf_nextentry,
        .sf_get_ftype = xfs_dir3_sfe_get_ftype,
        .sf_put_ftype = xfs_dir3_sfe_put_ftype,
        .sf_get_ino = xfs_dir3_sfe_get_ino,
index d3a0b8daab5ff55d666c18c837f6ecd493b76aff..c99f0ad6607aad1ac96f93c79c41e26fd0cbc3dc 100644 (file)
@@ -32,10 +32,6 @@ extern unsigned char xfs_mode_to_ftype(int mode);
  * directory operations vector for encode/decode routines
  */
 struct xfs_dir_ops {
-       int     (*sf_entsize)(struct xfs_dir2_sf_hdr *hdr, int len);
-       struct xfs_dir2_sf_entry *
-               (*sf_nextentry)(struct xfs_dir2_sf_hdr *hdr,
-                               struct xfs_dir2_sf_entry *sfep);
        uint8_t (*sf_get_ftype)(struct xfs_dir2_sf_entry *sfep);
        void    (*sf_put_ftype)(struct xfs_dir2_sf_entry *sfep,
                                uint8_t ftype);
index d4246e220b94be8a1f719b3b133de87f1b66af37..e5599e767337bcc8ef6cfc231821f9acbf2cf41f 100644 (file)
@@ -1222,7 +1222,7 @@ xfs_dir2_sf_to_block(
                if (++i == sfp->count)
                        sfep = NULL;
                else
-                       sfep = dp->d_ops->sf_nextentry(sfp, sfep);
+                       sfep = xfs_dir2_sf_nextentry(mp, sfp, sfep);
        }
        /* Done with the temporary buffer */
        kmem_free(sfp);
index bb50853d09880b1d547fe438feaf093240923d16..4631ebb9d8e584178d26da71615c08276fc8ad5c 100644 (file)
@@ -147,6 +147,10 @@ extern int xfs_dir2_free_read(struct xfs_trans *tp, struct xfs_inode *dp,
 /* xfs_dir2_sf.c */
 xfs_ino_t xfs_dir2_sf_get_parent_ino(struct xfs_dir2_sf_hdr *hdr);
 void xfs_dir2_sf_put_parent_ino(struct xfs_dir2_sf_hdr *hdr, xfs_ino_t ino);
+struct xfs_dir2_sf_entry *xfs_dir2_sf_nextentry(struct xfs_mount *mp,
+               struct xfs_dir2_sf_hdr *hdr, struct xfs_dir2_sf_entry *sfep);
+int xfs_dir2_sf_entsize(struct xfs_mount *mp,
+               struct xfs_dir2_sf_hdr *hdr, int len);
 extern int xfs_dir2_block_sfsize(struct xfs_inode *dp,
                struct xfs_dir2_data_hdr *block, struct xfs_dir2_sf_hdr *sfhp);
 extern int xfs_dir2_block_to_sf(struct xfs_da_args *args, struct xfs_buf *bp,
index 6913c7d4a7be221e9550d316769b6b6e9505ddb4..bf5c65492577b2312b3ba4a8c2968f246082ad4c 100644 (file)
@@ -37,6 +37,31 @@ static void xfs_dir2_sf_check(xfs_da_args_t *args);
 static void xfs_dir2_sf_toino4(xfs_da_args_t *args);
 static void xfs_dir2_sf_toino8(xfs_da_args_t *args);
 
+int
+xfs_dir2_sf_entsize(
+       struct xfs_mount        *mp,
+       struct xfs_dir2_sf_hdr  *hdr,
+       int                     len)
+{
+       int                     count = len;
+
+       count += sizeof(struct xfs_dir2_sf_entry);      /* namelen + offset */
+       count += hdr->i8count ? XFS_INO64_SIZE : XFS_INO32_SIZE; /* ino # */
+
+       if (xfs_sb_version_hasftype(&mp->m_sb))
+               count += sizeof(uint8_t);
+       return count;
+}
+
+struct xfs_dir2_sf_entry *
+xfs_dir2_sf_nextentry(
+       struct xfs_mount        *mp,
+       struct xfs_dir2_sf_hdr  *hdr,
+       struct xfs_dir2_sf_entry *sfep)
+{
+       return (void *)sfep + xfs_dir2_sf_entsize(mp, hdr, sfep->namelen);
+}
+
 /*
  * Given a block directory (dp/block), calculate its size as a shortform (sf)
  * directory and a header for the sf directory, if it will fit it the
@@ -219,7 +244,7 @@ xfs_dir2_block_to_sf(
                        dp->d_ops->sf_put_ftype(sfep,
                                        dp->d_ops->data_get_ftype(dep));
 
-                       sfep = dp->d_ops->sf_nextentry(sfp, sfep);
+                       sfep = xfs_dir2_sf_nextentry(mp, sfp, sfep);
                }
                ptr += dp->d_ops->data_entsize(dep->namelen);
        }
@@ -285,7 +310,7 @@ xfs_dir2_sf_addname(
        /*
         * Compute entry (and change in) size.
         */
-       incr_isize = dp->d_ops->sf_entsize(sfp, args->namelen);
+       incr_isize = xfs_dir2_sf_entsize(dp->i_mount, sfp, args->namelen);
        objchange = 0;
 
        /*
@@ -358,18 +383,17 @@ xfs_dir2_sf_addname_easy(
        xfs_dir2_data_aoff_t    offset,         /* offset to use for new ent */
        int                     new_isize)      /* new directory size */
 {
+       struct xfs_inode        *dp = args->dp;
+       struct xfs_mount        *mp = dp->i_mount;
        int                     byteoff;        /* byte offset in sf dir */
-       xfs_inode_t             *dp;            /* incore directory inode */
        xfs_dir2_sf_hdr_t       *sfp;           /* shortform structure */
 
-       dp = args->dp;
-
        sfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data;
        byteoff = (int)((char *)sfep - (char *)sfp);
        /*
         * Grow the in-inode space.
         */
-       xfs_idata_realloc(dp, dp->d_ops->sf_entsize(sfp, args->namelen),
+       xfs_idata_realloc(dp, xfs_dir2_sf_entsize(mp, sfp, args->namelen),
                          XFS_DATA_FORK);
        /*
         * Need to set up again due to realloc of the inode data.
@@ -410,9 +434,10 @@ xfs_dir2_sf_addname_hard(
        int                     objchange,      /* changing inode number size */
        int                     new_isize)      /* new directory size */
 {
+       struct xfs_inode        *dp = args->dp;
+       struct xfs_mount        *mp = dp->i_mount;
        int                     add_datasize;   /* data size need for new ent */
        char                    *buf;           /* buffer for old */
-       xfs_inode_t             *dp;            /* incore directory inode */
        int                     eof;            /* reached end of old dir */
        int                     nbytes;         /* temp for byte copies */
        xfs_dir2_data_aoff_t    new_offset;     /* next offset value */
@@ -426,8 +451,6 @@ xfs_dir2_sf_addname_hard(
        /*
         * Copy the old directory to the stack buffer.
         */
-       dp = args->dp;
-
        sfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data;
        old_isize = (int)dp->i_d.di_size;
        buf = kmem_alloc(old_isize, 0);
@@ -444,7 +467,7 @@ xfs_dir2_sf_addname_hard(
              eof = (char *)oldsfep == &buf[old_isize];
             !eof;
             offset = new_offset + dp->d_ops->data_entsize(oldsfep->namelen),
-             oldsfep = dp->d_ops->sf_nextentry(oldsfp, oldsfep),
+             oldsfep = xfs_dir2_sf_nextentry(mp, oldsfp, oldsfep),
              eof = (char *)oldsfep == &buf[old_isize]) {
                new_offset = xfs_dir2_sf_get_offset(oldsfep);
                if (offset + add_datasize <= new_offset)
@@ -482,7 +505,7 @@ xfs_dir2_sf_addname_hard(
         * If there's more left to copy, do that.
         */
        if (!eof) {
-               sfep = dp->d_ops->sf_nextentry(sfp, sfep);
+               sfep = xfs_dir2_sf_nextentry(mp, sfp, sfep);
                memcpy(sfep, oldsfep, old_isize - nbytes);
        }
        kmem_free(buf);
@@ -504,7 +527,8 @@ xfs_dir2_sf_addname_pick(
        xfs_dir2_sf_entry_t     **sfepp,        /* out(1): new entry ptr */
        xfs_dir2_data_aoff_t    *offsetp)       /* out(1): new offset */
 {
-       xfs_inode_t             *dp;            /* incore directory inode */
+       struct xfs_inode        *dp = args->dp;
+       struct xfs_mount        *mp = dp->i_mount;
        int                     holefit;        /* found hole it will fit in */
        int                     i;              /* entry number */
        xfs_dir2_data_aoff_t    offset;         /* data block offset */
@@ -513,8 +537,6 @@ xfs_dir2_sf_addname_pick(
        int                     size;           /* entry's data size */
        int                     used;           /* data bytes used */
 
-       dp = args->dp;
-
        sfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data;
        size = dp->d_ops->data_entsize(args->namelen);
        offset = dp->d_ops->data_first_offset;
@@ -530,7 +552,7 @@ xfs_dir2_sf_addname_pick(
                        holefit = offset + size <= xfs_dir2_sf_get_offset(sfep);
                offset = xfs_dir2_sf_get_offset(sfep) +
                         dp->d_ops->data_entsize(sfep->namelen);
-               sfep = dp->d_ops->sf_nextentry(sfp, sfep);
+               sfep = xfs_dir2_sf_nextentry(mp, sfp, sfep);
        }
        /*
         * Calculate data bytes used excluding the new entry, if this
@@ -589,7 +611,7 @@ xfs_dir2_sf_check(
 
        for (i = 0, sfep = xfs_dir2_sf_firstentry(sfp);
             i < sfp->count;
-            i++, sfep = dp->d_ops->sf_nextentry(sfp, sfep)) {
+            i++, sfep = xfs_dir2_sf_nextentry(dp->i_mount, sfp, sfep)) {
                ASSERT(xfs_dir2_sf_get_offset(sfep) >= offset);
                ino = dp->d_ops->sf_get_ino(sfp, sfep);
                i8count += ino > XFS_DIR2_MAX_SHORT_INUM;
@@ -674,7 +696,7 @@ xfs_dir2_sf_verify(
                 * within the data buffer.  The next entry starts after the
                 * name component, so nextentry is an acceptable test.
                 */
-               next_sfep = dops->sf_nextentry(sfp, sfep);
+               next_sfep = xfs_dir2_sf_nextentry(mp, sfp, sfep);
                if (endp < (char *)next_sfep)
                        return __this_address;
 
@@ -773,7 +795,8 @@ int                                         /* error */
 xfs_dir2_sf_lookup(
        xfs_da_args_t           *args)          /* operation arguments */
 {
-       xfs_inode_t             *dp;            /* incore directory inode */
+       struct xfs_inode        *dp = args->dp;
+       struct xfs_mount        *mp = dp->i_mount;
        int                     i;              /* entry index */
        int                     error;
        xfs_dir2_sf_entry_t     *sfep;          /* shortform directory entry */
@@ -784,7 +807,6 @@ xfs_dir2_sf_lookup(
        trace_xfs_dir2_sf_lookup(args);
 
        xfs_dir2_sf_check(args);
-       dp = args->dp;
 
        ASSERT(dp->i_df.if_flags & XFS_IFINLINE);
        ASSERT(dp->i_d.di_size >= offsetof(struct xfs_dir2_sf_hdr, parent));
@@ -816,7 +838,7 @@ xfs_dir2_sf_lookup(
         */
        ci_sfep = NULL;
        for (i = 0, sfep = xfs_dir2_sf_firstentry(sfp); i < sfp->count;
-            i++, sfep = dp->d_ops->sf_nextentry(sfp, sfep)) {
+            i++, sfep = xfs_dir2_sf_nextentry(mp, sfp, sfep)) {
                /*
                 * Compare name and if it's an exact match, return the inode
                 * number. If it's the first case-insensitive match, store the
@@ -852,8 +874,9 @@ int                                         /* error */
 xfs_dir2_sf_removename(
        xfs_da_args_t           *args)
 {
+       struct xfs_inode        *dp = args->dp;
+       struct xfs_mount        *mp = dp->i_mount;
        int                     byteoff;        /* offset of removed entry */
-       xfs_inode_t             *dp;            /* incore directory inode */
        int                     entsize;        /* this entry's size */
        int                     i;              /* shortform entry index */
        int                     newsize;        /* new inode size */
@@ -863,8 +886,6 @@ xfs_dir2_sf_removename(
 
        trace_xfs_dir2_sf_removename(args);
 
-       dp = args->dp;
-
        ASSERT(dp->i_df.if_flags & XFS_IFINLINE);
        oldsize = (int)dp->i_d.di_size;
        ASSERT(oldsize >= offsetof(struct xfs_dir2_sf_hdr, parent));
@@ -877,7 +898,7 @@ xfs_dir2_sf_removename(
         * Find the one we're deleting.
         */
        for (i = 0, sfep = xfs_dir2_sf_firstentry(sfp); i < sfp->count;
-            i++, sfep = dp->d_ops->sf_nextentry(sfp, sfep)) {
+            i++, sfep = xfs_dir2_sf_nextentry(mp, sfp, sfep)) {
                if (xfs_da_compname(args, sfep->name, sfep->namelen) ==
                                                                XFS_CMP_EXACT) {
                        ASSERT(dp->d_ops->sf_get_ino(sfp, sfep) ==
@@ -894,7 +915,7 @@ xfs_dir2_sf_removename(
         * Calculate sizes.
         */
        byteoff = (int)((char *)sfep - (char *)sfp);
-       entsize = dp->d_ops->sf_entsize(sfp, args->namelen);
+       entsize = xfs_dir2_sf_entsize(mp, sfp, args->namelen);
        newsize = oldsize - entsize;
        /*
         * Copy the part if any after the removed entry, sliding it down.
@@ -933,7 +954,8 @@ int                                         /* error */
 xfs_dir2_sf_replace(
        xfs_da_args_t           *args)          /* operation arguments */
 {
-       xfs_inode_t             *dp;            /* incore directory inode */
+       struct xfs_inode        *dp = args->dp;
+       struct xfs_mount        *mp = dp->i_mount;
        int                     i;              /* entry index */
        xfs_ino_t               ino=0;          /* entry old inode number */
        int                     i8elevated;     /* sf_toino8 set i8count=1 */
@@ -942,8 +964,6 @@ xfs_dir2_sf_replace(
 
        trace_xfs_dir2_sf_replace(args);
 
-       dp = args->dp;
-
        ASSERT(dp->i_df.if_flags & XFS_IFINLINE);
        ASSERT(dp->i_d.di_size >= offsetof(struct xfs_dir2_sf_hdr, parent));
        ASSERT(dp->i_df.if_bytes == dp->i_d.di_size);
@@ -993,7 +1013,7 @@ xfs_dir2_sf_replace(
         */
        else {
                for (i = 0, sfep = xfs_dir2_sf_firstentry(sfp); i < sfp->count;
-                    i++, sfep = dp->d_ops->sf_nextentry(sfp, sfep)) {
+                    i++, sfep = xfs_dir2_sf_nextentry(mp, sfp, sfep)) {
                        if (xfs_da_compname(args, sfep->name, sfep->namelen) ==
                                                                XFS_CMP_EXACT) {
                                ino = dp->d_ops->sf_get_ino(sfp, sfep);
@@ -1052,8 +1072,9 @@ static void
 xfs_dir2_sf_toino4(
        xfs_da_args_t           *args)          /* operation arguments */
 {
+       struct xfs_inode        *dp = args->dp;
+       struct xfs_mount        *mp = dp->i_mount;
        char                    *buf;           /* old dir's buffer */
-       xfs_inode_t             *dp;            /* incore directory inode */
        int                     i;              /* entry index */
        int                     newsize;        /* new inode size */
        xfs_dir2_sf_entry_t     *oldsfep;       /* old sf entry */
@@ -1064,8 +1085,6 @@ xfs_dir2_sf_toino4(
 
        trace_xfs_dir2_sf_toino4(args);
 
-       dp = args->dp;
-
        /*
         * Copy the old directory to the buffer.
         * Then nuke it from the inode, and add the new buffer to the inode.
@@ -1099,8 +1118,8 @@ xfs_dir2_sf_toino4(
        for (i = 0, sfep = xfs_dir2_sf_firstentry(sfp),
                    oldsfep = xfs_dir2_sf_firstentry(oldsfp);
             i < sfp->count;
-            i++, sfep = dp->d_ops->sf_nextentry(sfp, sfep),
-                 oldsfep = dp->d_ops->sf_nextentry(oldsfp, oldsfep)) {
+            i++, sfep = xfs_dir2_sf_nextentry(mp, sfp, sfep),
+                 oldsfep = xfs_dir2_sf_nextentry(mp, oldsfp, oldsfep)) {
                sfep->namelen = oldsfep->namelen;
                memcpy(sfep->offset, oldsfep->offset, sizeof(sfep->offset));
                memcpy(sfep->name, oldsfep->name, sfep->namelen);
@@ -1125,8 +1144,9 @@ static void
 xfs_dir2_sf_toino8(
        xfs_da_args_t           *args)          /* operation arguments */
 {
+       struct xfs_inode        *dp = args->dp;
+       struct xfs_mount        *mp = dp->i_mount;
        char                    *buf;           /* old dir's buffer */
-       xfs_inode_t             *dp;            /* incore directory inode */
        int                     i;              /* entry index */
        int                     newsize;        /* new inode size */
        xfs_dir2_sf_entry_t     *oldsfep;       /* old sf entry */
@@ -1137,8 +1157,6 @@ xfs_dir2_sf_toino8(
 
        trace_xfs_dir2_sf_toino8(args);
 
-       dp = args->dp;
-
        /*
         * Copy the old directory to the buffer.
         * Then nuke it from the inode, and add the new buffer to the inode.
@@ -1172,8 +1190,8 @@ xfs_dir2_sf_toino8(
        for (i = 0, sfep = xfs_dir2_sf_firstentry(sfp),
                    oldsfep = xfs_dir2_sf_firstentry(oldsfp);
             i < sfp->count;
-            i++, sfep = dp->d_ops->sf_nextentry(sfp, sfep),
-                 oldsfep = dp->d_ops->sf_nextentry(oldsfp, oldsfep)) {
+            i++, sfep = xfs_dir2_sf_nextentry(mp, sfp, sfep),
+                 oldsfep = xfs_dir2_sf_nextentry(mp, oldsfp, oldsfep)) {
                sfep->namelen = oldsfep->namelen;
                memcpy(sfep->offset, oldsfep->offset, sizeof(sfep->offset));
                memcpy(sfep->name, oldsfep->name, sfep->namelen);
index c325f046069af178029a869642134bb519bf84fb..149f5bf30c0b9d5ca155e11ffec53007f7a0e1af 100644 (file)
@@ -494,7 +494,7 @@ xlog_print_dir2_sf(
                namebuf[sfep->namelen] = '\0';
                printf(_("%s ino 0x%llx namelen %d\n"),
                       namebuf, (unsigned long long)ino, sfep->namelen);
-               sfep = M_DIROPS(log->l_mp)->sf_nextentry(sfp, sfep);
+               sfep = libxfs_dir2_sf_nextentry(log->l_mp, sfp, sfep);
        }
 }
 
index 3ae912ff12f6886d8112d5aa32afb35a4b48ffa4..2679f190c5c0636e9c8001a437d348d9e3571bc6 100644 (file)
@@ -95,8 +95,8 @@ process_sf_dir2_fixi8(
                memmove(newsfep->name, oldsfep->name, newsfep->namelen);
                ino = M_DIROPS(mp)->sf_get_ino(oldsfp, oldsfep);
                M_DIROPS(mp)->sf_put_ino(newsfp, newsfep, ino);
-               oldsfep = M_DIROPS(mp)->sf_nextentry(oldsfp, oldsfep);
-               newsfep = M_DIROPS(mp)->sf_nextentry(newsfp, newsfep);
+               oldsfep = libxfs_dir2_sf_nextentry(mp, oldsfp, oldsfep);
+               newsfep = libxfs_dir2_sf_nextentry(mp, newsfp, newsfep);
        }
        *next_sfep = newsfep;
        free(oldsfp);
@@ -122,7 +122,7 @@ process_sf_dir2_fixoff(
        for (i = 0; i < sfp->count; i++) {
                xfs_dir2_sf_put_offset(sfep, offset);
                offset += M_DIROPS(mp)->data_entsize(sfep->namelen);
-               sfep = M_DIROPS(mp)->sf_nextentry(sfp, sfep);
+               sfep = libxfs_dir2_sf_nextentry(mp, sfp, sfep);
        }
 }
 
@@ -184,7 +184,7 @@ process_sf_dir2(
        /*
         * check for bad entry count
         */
-       if (num_entries * M_DIROPS(mp)->sf_entsize(sfp, 1) +
+       if (num_entries * libxfs_dir2_sf_entsize(mp, sfp, 1) +
                    xfs_dir2_sf_hdr_size(0) > max_size || num_entries == 0)
                num_entries = 0xFF;
 
@@ -281,7 +281,7 @@ _("entry \"%*.*s\" in shortform directory %" PRIu64 " references %s inode %" PRI
                        junkreason = _("is zero length");
                        bad_sfnamelen = 1;
                } else if ((intptr_t) sfep - (intptr_t) sfp +
-                               M_DIROPS(mp)->sf_entsize(sfp, sfep->namelen)
+                               libxfs_dir2_sf_entsize(mp, sfp, sfep->namelen)
                                                        > ino_dir_size)  {
                        junkreason = _("extends past end of dir");
                        bad_sfnamelen = 1;
@@ -344,7 +344,7 @@ _("entry contains offset out of order in shortform dir %" PRIu64 "\n"),
                        name[namelen] = '\0';
 
                        if (!no_modify)  {
-                               tmp_elen = M_DIROPS(mp)->sf_entsize(sfp,
+                               tmp_elen = libxfs_dir2_sf_entsize(mp, sfp,
                                                                sfep->namelen);
                                be64_add_cpu(&dip->di_size, -tmp_elen);
                                ino_dir_size -= tmp_elen;
@@ -398,8 +398,8 @@ _("would have junked entry \"%s\" in directory inode %" PRIu64 "\n"),
                next_sfep = (tmp_sfep == NULL)
                        ? (xfs_dir2_sf_entry_t *) ((intptr_t) sfep
                                                        + ((!bad_sfnamelen)
-                               ? M_DIROPS(mp)->sf_entsize(sfp, sfep->namelen)
-                               : M_DIROPS(mp)->sf_entsize(sfp, namelen)))
+                               ? libxfs_dir2_sf_entsize(mp, sfp, sfep->namelen)
+                               : libxfs_dir2_sf_entsize(mp, sfp, namelen)))
                        : tmp_sfep;
        }
 
index 62ad8ffbf2bf8b61b437cda5a234d32d6dacd4ab..12a00a3bd69eb3125761ed5e2ac78c573d4b7821 100644 (file)
@@ -2473,8 +2473,8 @@ shortform_dir2_junk(
        if (lino == orphanage_ino)
                orphanage_ino = 0;
 
-       next_elen = M_DIROPS(mp)->sf_entsize(sfp, sfep->namelen);
-       next_sfep = M_DIROPS(mp)->sf_nextentry(sfp, sfep);
+       next_elen = libxfs_dir2_sf_entsize(mp, sfp, sfep->namelen);
+       next_sfep = libxfs_dir2_sf_nextentry(mp, sfp, sfep);
 
        /*
         * if we are just checking, simply return the pointer to the next entry
@@ -2617,7 +2617,7 @@ shortform_dir2_entry_check(xfs_mount_t    *mp,
                                break;
                        }
                } else if (no_modify && (intptr_t) sfep - (intptr_t) sfp +
-                               + M_DIROPS(mp)->sf_entsize(sfp, sfep->namelen)
+                               + libxfs_dir2_sf_entsize(mp, sfp, sfep->namelen)
                                > ip->i_d.di_size)  {
                        bad_sfnamelen = 1;
 
@@ -2646,7 +2646,7 @@ shortform_dir2_entry_check(xfs_mount_t    *mp,
                 */
 
                if (no_modify && verify_inum(mp, lino))  {
-                       next_sfep = M_DIROPS(mp)->sf_nextentry(sfp, sfep);
+                       next_sfep = libxfs_dir2_sf_nextentry(mp, sfp, sfep);
                        continue;
                }
 
@@ -2808,8 +2808,8 @@ _("entry \"%s\" (ino %" PRIu64 ") in dir %" PRIu64 " is a duplicate name"),
                ASSERT(no_modify || bad_sfnamelen == 0);
                next_sfep = (struct xfs_dir2_sf_entry *)((intptr_t)sfep +
                              (bad_sfnamelen
-                               ? M_DIROPS(mp)->sf_entsize(sfp, namelen)
-                               : M_DIROPS(mp)->sf_entsize(sfp, sfep->namelen)));
+                               ? libxfs_dir2_sf_entsize(mp, sfp, namelen)
+                               : libxfs_dir2_sf_entsize(mp, sfp, sfep->namelen)));
        }
 
        if (sfp->i8count != i8) {