]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: remove the ->data_unused_p method
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: ee641d5af5e638d53d9bcde459836b1cb90f12e2

Replace the two users of the ->data_unused_p dir ops method with a
direct calculation using ->data_entry_offset, and clean them up a bit.
xfs_dir2_sf_to_block already had an offset variable containing the
value of ->data_entry_offset, which we are now reusing to make it
clear that the initial freespace entry is at the same place that
we later fill in the 1 entry, and in xfs_dir3_data_init the function
is cleaned up a bit to keep the initialization of fields of a given
structure close to each other, and to avoid a local variable.

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>
db/check.c
db/dir2.c
db/metadump.c
libxfs/xfs_da_format.c
libxfs/xfs_dir2.h
libxfs/xfs_dir2_block.c
libxfs/xfs_dir2_data.c

index 7098defabb5033394447206a83cb617b9c0c6867..cb55d3a6ddce51869babf02b15fcbf2bb4bfb398 100644 (file)
@@ -2316,7 +2316,7 @@ process_data_dir_v2(
        }
        db = xfs_dir2_da_to_db(mp->m_dir_geo, dabno);
        bf = M_DIROPS(mp)->data_bestfree_p(data);
-       ptr = (char *)M_DIROPS(mp)->data_unused_p(data);
+       ptr = (char *)data + mp->m_dir_inode_ops->data_entry_offset;
        if (be32_to_cpu(block->magic) == XFS_DIR2_BLOCK_MAGIC ||
            be32_to_cpu(block->magic) == XFS_DIR3_BLOCK_MAGIC) {
                btp = xfs_dir2_block_tail_p(mp->m_dir_geo, block);
index 0c36e59ad6912e64ac81f6c8e66ecc1f92d83652..bd1a3edbf7d9856594ccb57d03c08c43c027e64c 100644 (file)
--- a/db/dir2.c
+++ b/db/dir2.c
@@ -350,7 +350,7 @@ dir2_block_u_count(
 
        btp = xfs_dir2_block_tail_p(mp->m_dir_geo, block);
        return __dir2_data_entries_count(
-                       (char *)M_DIROPS(mp)->data_unused_p(block),
+                       (char *)obj + mp->m_dir_inode_ops->data_entry_offset,
                        (char *)xfs_dir2_block_leaf_p(btp));
 }
 
@@ -369,7 +369,7 @@ dir2_block_u_offset(
               be32_to_cpu(block->magic) == XFS_DIR3_BLOCK_MAGIC);
        btp = xfs_dir2_block_tail_p(mp->m_dir_geo, block);
        ptr = __dir2_data_entry_offset(
-                       (char *)M_DIROPS(mp)->data_unused_p(block),
+                       (char *)obj + mp->m_dir_inode_ops->data_entry_offset,
                        (char *)xfs_dir2_block_leaf_p(btp), idx);
        return bitize((int)(ptr - (char *)block));
 }
@@ -547,7 +547,7 @@ dir2_data_u_count(
                return 0;
 
        return __dir2_data_entries_count(
-                               (char *)M_DIROPS(mp)->data_unused_p(data),
+                               (char *)data + mp->m_dir_inode_ops->data_entry_offset,
                                (char *)data + mp->m_dir_geo->blksize);
 }
 
@@ -564,7 +564,7 @@ dir2_data_u_offset(
        ASSERT(be32_to_cpu(data->magic) == XFS_DIR2_DATA_MAGIC ||
               be32_to_cpu(data->magic) == XFS_DIR3_DATA_MAGIC);
        ptr = __dir2_data_entry_offset(
-                               (char *)M_DIROPS(mp)->data_unused_p(data),
+                               (char *)data + mp->m_dir_inode_ops->data_entry_offset,
                                (char *)data + mp->m_dir_geo->blksize, idx);
        return bitize((int)(ptr - (char *)data));
 }
index 01518377d4c94bedb8d7414dd4bdab162e04e874..43f7ee94f3542d060fe05b681df66d055855e41f 100644 (file)
@@ -1556,7 +1556,7 @@ process_dir_data_block(
                return;
        }
 
-       dir_offset = M_DIROPS(mp)->data_entry_offset;
+       dir_offset = mp->m_dir_inode_ops->data_entry_offset;
        ptr = block + dir_offset;
        endptr = block + mp->m_dir_geo->blksize;
 
index df16ea76cb659a04dfb759efbef43d382d5f0867..335819538d864b3f7113cd0b60ee9e157b984f1d 100644 (file)
@@ -130,13 +130,6 @@ xfs_dir2_data_entry_p(struct xfs_dir2_data_hdr *hdr)
                ((char *)hdr + sizeof(struct xfs_dir2_data_hdr));
 }
 
-static struct xfs_dir2_data_unused *
-xfs_dir2_data_unused_p(struct xfs_dir2_data_hdr *hdr)
-{
-       return (struct xfs_dir2_data_unused *)
-               ((char *)hdr + sizeof(struct xfs_dir2_data_hdr));
-}
-
 static struct xfs_dir2_data_entry *
 xfs_dir3_data_entry_p(struct xfs_dir2_data_hdr *hdr)
 {
@@ -144,13 +137,6 @@ xfs_dir3_data_entry_p(struct xfs_dir2_data_hdr *hdr)
                ((char *)hdr + sizeof(struct xfs_dir3_data_hdr));
 }
 
-static struct xfs_dir2_data_unused *
-xfs_dir3_data_unused_p(struct xfs_dir2_data_hdr *hdr)
-{
-       return (struct xfs_dir2_data_unused *)
-               ((char *)hdr + sizeof(struct xfs_dir3_data_hdr));
-}
-
 static const struct xfs_dir_ops xfs_dir2_ops = {
        .data_entsize = xfs_dir2_data_entsize,
        .data_get_ftype = xfs_dir2_data_get_ftype,
@@ -164,7 +150,6 @@ static const struct xfs_dir_ops xfs_dir2_ops = {
        .data_entry_offset = sizeof(struct xfs_dir2_data_hdr),
 
        .data_entry_p = xfs_dir2_data_entry_p,
-       .data_unused_p = xfs_dir2_data_unused_p,
 };
 
 static const struct xfs_dir_ops xfs_dir2_ftype_ops = {
@@ -180,7 +165,6 @@ static const struct xfs_dir_ops xfs_dir2_ftype_ops = {
        .data_entry_offset = sizeof(struct xfs_dir2_data_hdr),
 
        .data_entry_p = xfs_dir2_data_entry_p,
-       .data_unused_p = xfs_dir2_data_unused_p,
 };
 
 static const struct xfs_dir_ops xfs_dir3_ops = {
@@ -196,7 +180,6 @@ static const struct xfs_dir_ops xfs_dir3_ops = {
        .data_entry_offset = sizeof(struct xfs_dir3_data_hdr),
 
        .data_entry_p = xfs_dir3_data_entry_p,
-       .data_unused_p = xfs_dir3_data_unused_p,
 };
 
 /*
index 8bfcf4c1b9c4ff9535ee834105d6dd0f3389c605..75aec05aae1024f701a702a263180d4ae7bbdca5 100644 (file)
@@ -45,8 +45,6 @@ struct xfs_dir_ops {
 
        struct xfs_dir2_data_entry *
                (*data_entry_p)(struct xfs_dir2_data_hdr *hdr);
-       struct xfs_dir2_data_unused *
-               (*data_unused_p)(struct xfs_dir2_data_hdr *hdr);
 };
 
 extern const struct xfs_dir_ops *
index 474debd17335d6fe853f438c4b4f4ac887c30172..aa8142c5c25ce5c84298a52ceab1789b4e5691d3 100644 (file)
@@ -1109,7 +1109,7 @@ xfs_dir2_sf_to_block(
         * The whole thing is initialized to free by the init routine.
         * Say we're using the leaf and tail area.
         */
-       dup = dp->d_ops->data_unused_p(hdr);
+       dup = bp->b_addr + offset;
        needlog = needscan = 0;
        error = xfs_dir2_data_use_free(args, bp, dup, args->geo->blksize - i,
                        i, &needlog, &needscan);
index 68da426e48dc7197fded09880e1f493afcfbf58b..35ba893e43792f09da87dff07c8036359e8c82cb 100644 (file)
@@ -628,24 +628,20 @@ xfs_dir2_data_freescan(
  */
 int                                            /* error */
 xfs_dir3_data_init(
-       xfs_da_args_t           *args,          /* directory operation args */
-       xfs_dir2_db_t           blkno,          /* logical dir block number */
-       struct xfs_buf          **bpp)          /* output block buffer */
+       struct xfs_da_args              *args,  /* directory operation args */
+       xfs_dir2_db_t                   blkno,  /* logical dir block number */
+       struct xfs_buf                  **bpp)  /* output block buffer */
 {
-       struct xfs_buf          *bp;            /* block buffer */
-       xfs_dir2_data_hdr_t     *hdr;           /* data block header */
-       xfs_inode_t             *dp;            /* incore directory inode */
-       xfs_dir2_data_unused_t  *dup;           /* unused entry pointer */
-       struct xfs_dir2_data_free *bf;
-       int                     error;          /* error return value */
-       int                     i;              /* bestfree index */
-       xfs_mount_t             *mp;            /* filesystem mount point */
-       xfs_trans_t             *tp;            /* transaction pointer */
-       int                     t;              /* temp */
-
-       dp = args->dp;
-       mp = dp->i_mount;
-       tp = args->trans;
+       struct xfs_trans                *tp = args->trans;
+       struct xfs_inode                *dp = args->dp;
+       struct xfs_mount                *mp = dp->i_mount;
+       struct xfs_buf                  *bp;
+       struct xfs_dir2_data_hdr        *hdr;
+       struct xfs_dir2_data_unused     *dup;
+       struct xfs_dir2_data_free       *bf;
+       int                             error;
+       int                             i;
+
        /*
         * Get the buffer set up for the block.
         */
@@ -674,6 +670,8 @@ xfs_dir3_data_init(
 
        bf = dp->d_ops->data_bestfree_p(hdr);
        bf[0].offset = cpu_to_be16(dp->d_ops->data_entry_offset);
+       bf[0].length =
+               cpu_to_be16(args->geo->blksize - dp->d_ops->data_entry_offset);
        for (i = 1; i < XFS_DIR2_DATA_FD_COUNT; i++) {
                bf[i].length = 0;
                bf[i].offset = 0;
@@ -682,13 +680,11 @@ xfs_dir3_data_init(
        /*
         * Set up an unused entry for the block's body.
         */
-       dup = dp->d_ops->data_unused_p(hdr);
+       dup = bp->b_addr + dp->d_ops->data_entry_offset;
        dup->freetag = cpu_to_be16(XFS_DIR2_DATA_FREE_TAG);
-
-       t = args->geo->blksize - (uint)dp->d_ops->data_entry_offset;
-       bf[0].length = cpu_to_be16(t);
-       dup->length = cpu_to_be16(t);
+       dup->length = bf[0].length;
        *xfs_dir2_data_unused_tag_p(dup) = cpu_to_be16((char *)dup - (char *)hdr);
+
        /*
         * Log it and return it.
         */