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

Replace the ->node_hdr_to_disk dir ops method with a directly called
xfs_da_node_hdr_to_disk helper that takes care of the v4 vs v5
difference.

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>
libxfs/xfs_attr_leaf.c
libxfs/xfs_da_btree.c
libxfs/xfs_da_btree.h
libxfs/xfs_da_format.c
libxfs/xfs_dir2.h

index 4a15a90eed6b0894d9aa8349b6fcd7fd7a3eee23..7fd3436c884acab4bdd01aa20c4610eb0df1498a 100644 (file)
@@ -1192,7 +1192,7 @@ xfs_attr3_leaf_to_node(
        btree[0].hashval = entries[icleafhdr.count - 1].hashval;
        btree[0].before = cpu_to_be32(blkno);
        icnodehdr.count = 1;
-       dp->d_ops->node_hdr_to_disk(node, &icnodehdr);
+       xfs_da3_node_hdr_to_disk(dp->i_mount, node, &icnodehdr);
        xfs_trans_log_buf(args->trans, bp1, 0, args->geo->blksize - 1);
        error = 0;
 out:
index 85d07ec25c6ba9b70b4d788af2119e28d69c420d..15a8218a583415aca6ccd0c118c093237e045e96 100644 (file)
@@ -132,6 +132,31 @@ xfs_da3_node_hdr_from_disk(
        }
 }
 
+void
+xfs_da3_node_hdr_to_disk(
+       struct xfs_mount                *mp,
+       struct xfs_da_intnode           *to,
+       struct xfs_da3_icnode_hdr       *from)
+{
+       if (xfs_sb_version_hascrc(&mp->m_sb)) {
+               struct xfs_da3_intnode  *to3 = (struct xfs_da3_intnode *)to;
+
+               ASSERT(from->magic == XFS_DA3_NODE_MAGIC);
+               to3->hdr.info.hdr.forw = cpu_to_be32(from->forw);
+               to3->hdr.info.hdr.back = cpu_to_be32(from->back);
+               to3->hdr.info.hdr.magic = cpu_to_be16(from->magic);
+               to3->hdr.__count = cpu_to_be16(from->count);
+               to3->hdr.__level = cpu_to_be16(from->level);
+       } else {
+               ASSERT(from->magic == XFS_DA_NODE_MAGIC);
+               to->hdr.info.forw = cpu_to_be32(from->forw);
+               to->hdr.info.back = cpu_to_be32(from->back);
+               to->hdr.info.magic = cpu_to_be16(from->magic);
+               to->hdr.__count = cpu_to_be16(from->count);
+               to->hdr.__level = cpu_to_be16(from->level);
+       }
+}
+
 /*
  * Verify an xfs_da3_blkinfo structure. Note that the da3 fields are only
  * accessible on v5 filesystems. This header format is common across da node,
@@ -382,7 +407,7 @@ xfs_da3_node_create(
        }
        ichdr.level = level;
 
-       dp->d_ops->node_hdr_to_disk(node, &ichdr);
+       xfs_da3_node_hdr_to_disk(dp->i_mount, node, &ichdr);
        xfs_trans_log_buf(tp, bp,
                XFS_DA_LOGRANGE(node, &node->hdr, dp->d_ops->node_hdr_size));
 
@@ -665,7 +690,7 @@ xfs_da3_root_split(
        btree[1].hashval = cpu_to_be32(blk2->hashval);
        btree[1].before = cpu_to_be32(blk2->blkno);
        nodehdr.count = 2;
-       dp->d_ops->node_hdr_to_disk(node, &nodehdr);
+       xfs_da3_node_hdr_to_disk(dp->i_mount, node, &nodehdr);
 
 #ifdef DEBUG
        if (oldroot->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC) ||
@@ -890,11 +915,11 @@ xfs_da3_node_rebalance(
        /*
         * Log header of node 1 and all current bits of node 2.
         */
-       dp->d_ops->node_hdr_to_disk(node1, &nodehdr1);
+       xfs_da3_node_hdr_to_disk(dp->i_mount, node1, &nodehdr1);
        xfs_trans_log_buf(tp, blk1->bp,
                XFS_DA_LOGRANGE(node1, &node1->hdr, dp->d_ops->node_hdr_size));
 
-       dp->d_ops->node_hdr_to_disk(node2, &nodehdr2);
+       xfs_da3_node_hdr_to_disk(dp->i_mount, node2, &nodehdr2);
        xfs_trans_log_buf(tp, blk2->bp,
                XFS_DA_LOGRANGE(node2, &node2->hdr,
                                dp->d_ops->node_hdr_size +
@@ -966,7 +991,7 @@ xfs_da3_node_add(
                                tmp + sizeof(*btree)));
 
        nodehdr.count += 1;
-       dp->d_ops->node_hdr_to_disk(node, &nodehdr);
+       xfs_da3_node_hdr_to_disk(dp->i_mount, node, &nodehdr);
        xfs_trans_log_buf(state->args->trans, oldblk->bp,
                XFS_DA_LOGRANGE(node, &node->hdr, dp->d_ops->node_hdr_size));
 
@@ -1402,7 +1427,7 @@ xfs_da3_node_remove(
        xfs_trans_log_buf(state->args->trans, drop_blk->bp,
            XFS_DA_LOGRANGE(node, &btree[index], sizeof(btree[index])));
        nodehdr.count -= 1;
-       dp->d_ops->node_hdr_to_disk(node, &nodehdr);
+       xfs_da3_node_hdr_to_disk(dp->i_mount, node, &nodehdr);
        xfs_trans_log_buf(state->args->trans, drop_blk->bp,
            XFS_DA_LOGRANGE(node, &node->hdr, dp->d_ops->node_hdr_size));
 
@@ -1474,7 +1499,7 @@ xfs_da3_node_unbalance(
        memcpy(&save_btree[sindex], &drop_btree[0], tmp);
        save_hdr.count += drop_hdr.count;
 
-       dp->d_ops->node_hdr_to_disk(save_node, &save_hdr);
+       xfs_da3_node_hdr_to_disk(dp->i_mount, save_node, &save_hdr);
        xfs_trans_log_buf(tp, save_blk->bp,
                XFS_DA_LOGRANGE(save_node, &save_node->hdr,
                                dp->d_ops->node_hdr_size));
index 21dc03c818e9b1f177e1caa9f582c7645b1cc131..932f3ba6a81345caccff6684645f863df9a2fb45 100644 (file)
@@ -217,6 +217,8 @@ void xfs_da_state_free(xfs_da_state_t *state);
 
 void   xfs_da3_node_hdr_from_disk(struct xfs_mount *mp,
                struct xfs_da3_icnode_hdr *to, struct xfs_da_intnode *from);
+void   xfs_da3_node_hdr_to_disk(struct xfs_mount *mp,
+               struct xfs_da_intnode *to, struct xfs_da3_icnode_hdr *from);
 
 extern struct kmem_zone *xfs_da_state_zone;
 extern const struct xfs_nameops xfs_default_nameops;
index bc29147ae639c0b207e64b64d14efa4cd6a5310e..dc056f3b9de31f05a90dae1c7097f96f3e74ef38 100644 (file)
@@ -510,35 +510,6 @@ xfs_da3_node_tree_p(struct xfs_da_intnode *dap)
        return ((struct xfs_da3_intnode *)dap)->__btree;
 }
 
-static void
-xfs_da2_node_hdr_to_disk(
-       struct xfs_da_intnode           *to,
-       struct xfs_da3_icnode_hdr       *from)
-{
-       ASSERT(from->magic == XFS_DA_NODE_MAGIC);
-       to->hdr.info.forw = cpu_to_be32(from->forw);
-       to->hdr.info.back = cpu_to_be32(from->back);
-       to->hdr.info.magic = cpu_to_be16(from->magic);
-       to->hdr.__count = cpu_to_be16(from->count);
-       to->hdr.__level = cpu_to_be16(from->level);
-}
-
-static void
-xfs_da3_node_hdr_to_disk(
-       struct xfs_da_intnode           *to,
-       struct xfs_da3_icnode_hdr       *from)
-{
-       struct xfs_da3_node_hdr *hdr3 = (struct xfs_da3_node_hdr *)to;
-
-       ASSERT(from->magic == XFS_DA3_NODE_MAGIC);
-       hdr3->info.hdr.forw = cpu_to_be32(from->forw);
-       hdr3->info.hdr.back = cpu_to_be32(from->back);
-       hdr3->info.hdr.magic = cpu_to_be16(from->magic);
-       hdr3->__count = cpu_to_be16(from->count);
-       hdr3->__level = cpu_to_be16(from->level);
-}
-
-
 /*
  * Directory free space block operations
  */
@@ -698,7 +669,6 @@ static const struct xfs_dir_ops xfs_dir2_ops = {
        .leaf_ents_p = xfs_dir2_leaf_ents_p,
 
        .node_hdr_size = sizeof(struct xfs_da_node_hdr),
-       .node_hdr_to_disk = xfs_da2_node_hdr_to_disk,
        .node_tree_p = xfs_da2_node_tree_p,
 
        .free_hdr_size = sizeof(struct xfs_dir2_free_hdr),
@@ -747,7 +717,6 @@ static const struct xfs_dir_ops xfs_dir2_ftype_ops = {
        .leaf_ents_p = xfs_dir2_leaf_ents_p,
 
        .node_hdr_size = sizeof(struct xfs_da_node_hdr),
-       .node_hdr_to_disk = xfs_da2_node_hdr_to_disk,
        .node_tree_p = xfs_da2_node_tree_p,
 
        .free_hdr_size = sizeof(struct xfs_dir2_free_hdr),
@@ -796,7 +765,6 @@ static const struct xfs_dir_ops xfs_dir3_ops = {
        .leaf_ents_p = xfs_dir3_leaf_ents_p,
 
        .node_hdr_size = sizeof(struct xfs_da3_node_hdr),
-       .node_hdr_to_disk = xfs_da3_node_hdr_to_disk,
        .node_tree_p = xfs_da3_node_tree_p,
 
        .free_hdr_size = sizeof(struct xfs_dir3_free_hdr),
@@ -810,13 +778,11 @@ static const struct xfs_dir_ops xfs_dir3_ops = {
 
 static const struct xfs_dir_ops xfs_dir2_nondir_ops = {
        .node_hdr_size = sizeof(struct xfs_da_node_hdr),
-       .node_hdr_to_disk = xfs_da2_node_hdr_to_disk,
        .node_tree_p = xfs_da2_node_tree_p,
 };
 
 static const struct xfs_dir_ops xfs_dir3_nondir_ops = {
        .node_hdr_size = sizeof(struct xfs_da3_node_hdr),
-       .node_hdr_to_disk = xfs_da3_node_hdr_to_disk,
        .node_tree_p = xfs_da3_node_tree_p,
 };
 
index 573043f59c85fb87847fd6bf5da5369cbf4e7b15..c16efeae0f2be4766aa875f34de71603f523be7f 100644 (file)
@@ -82,8 +82,6 @@ struct xfs_dir_ops {
                (*leaf_ents_p)(struct xfs_dir2_leaf *lp);
 
        int     node_hdr_size;
-       void    (*node_hdr_to_disk)(struct xfs_da_intnode *to,
-                                   struct xfs_da3_icnode_hdr *from);
        struct xfs_da_node_entry *
                (*node_tree_p)(struct xfs_da_intnode *dap);