aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Chinner <dchinner@redhat.com>2013-10-29 07:11:52 -0400
committerBen Myers <bpm@sgi.com>2013-10-30 14:47:22 -0400
commit01ba43b873d9e91ba2e0341fe8cb7e89eaa41661 (patch)
tree34b0f2ae40956eaf3a2dc1a693f29ff4200eb845
parent4bceb18f1551c8c047eeb54d48cda9f5453dc12f (diff)
xfs: vectorise encoding/decoding directory headers
Conversion from on-disk structures to in-core header structures currently relies on magic number checks. If the magic number is wrong, but one of the supported values, we do the wrong thing with the encode/decode operation. Split these functions so that there are discrete operations for the specific directory format we are handling. In doing this, move all the header encode/decode functions to xfs_da_format.c as they are directly manipulating the on-disk format. It should be noted that all the growth in binary size is from xfs_da_format.c - the rest of the code actaully shrinks. text data bss dec hex filename 794490 96802 1096 892388 d9de4 fs/xfs/xfs.o.orig 792986 96802 1096 890884 d9804 fs/xfs/xfs.o.p1 792350 96802 1096 890248 d9588 fs/xfs/xfs.o.p2 789293 96802 1096 887191 d8997 fs/xfs/xfs.o.p3 789005 96802 1096 886903 d8997 fs/xfs/xfs.o.p4 789061 96802 1096 886959 d88af fs/xfs/xfs.o.p5 789733 96802 1096 887631 d8b4f fs/xfs/xfs.o.p6 791421 96802 1096 889319 d91e7 fs/xfs/xfs.o.p7 Signed-off-by: Dave Chinner <dchinner@redhat.com> Reviewed-by: Ben Myers <bpm@sgi.com> Signed-off-by: Ben Myers <bpm@sgi.com>
-rw-r--r--fs/xfs/xfs_attr_inactive.c2
-rw-r--r--fs/xfs/xfs_attr_leaf.c4
-rw-r--r--fs/xfs/xfs_attr_list.c2
-rw-r--r--fs/xfs/xfs_da_btree.c141
-rw-r--r--fs/xfs/xfs_da_format.c209
-rw-r--r--fs/xfs/xfs_da_format.h16
-rw-r--r--fs/xfs/xfs_dir2.h13
-rw-r--r--fs/xfs/xfs_dir2_block.c2
-rw-r--r--fs/xfs/xfs_dir2_leaf.c100
-rw-r--r--fs/xfs/xfs_dir2_node.c126
-rw-r--r--fs/xfs/xfs_dir2_priv.h4
11 files changed, 338 insertions, 281 deletions
diff --git a/fs/xfs/xfs_attr_inactive.c b/fs/xfs/xfs_attr_inactive.c
index 4855085f8c6b..09480c57f069 100644
--- a/fs/xfs/xfs_attr_inactive.c
+++ b/fs/xfs/xfs_attr_inactive.c
@@ -231,7 +231,7 @@ xfs_attr3_node_inactive(
231 } 231 }
232 232
233 node = bp->b_addr; 233 node = bp->b_addr;
234 xfs_da3_node_hdr_from_disk(&ichdr, node); 234 dp->d_ops->node_hdr_from_disk(&ichdr, node);
235 parent_blkno = bp->b_bn; 235 parent_blkno = bp->b_bn;
236 if (!ichdr.count) { 236 if (!ichdr.count) {
237 xfs_trans_brelse(*trans, bp); 237 xfs_trans_brelse(*trans, bp);
diff --git a/fs/xfs/xfs_attr_leaf.c b/fs/xfs/xfs_attr_leaf.c
index 82f1354c77b6..fdf9992dcbbc 100644
--- a/fs/xfs/xfs_attr_leaf.c
+++ b/fs/xfs/xfs_attr_leaf.c
@@ -916,7 +916,7 @@ xfs_attr3_leaf_to_node(
916 if (error) 916 if (error)
917 goto out; 917 goto out;
918 node = bp1->b_addr; 918 node = bp1->b_addr;
919 xfs_da3_node_hdr_from_disk(&icnodehdr, node); 919 dp->d_ops->node_hdr_from_disk(&icnodehdr, node);
920 btree = dp->d_ops->node_tree_p(node); 920 btree = dp->d_ops->node_tree_p(node);
921 921
922 leaf = bp2->b_addr; 922 leaf = bp2->b_addr;
@@ -927,7 +927,7 @@ xfs_attr3_leaf_to_node(
927 btree[0].hashval = entries[icleafhdr.count - 1].hashval; 927 btree[0].hashval = entries[icleafhdr.count - 1].hashval;
928 btree[0].before = cpu_to_be32(blkno); 928 btree[0].before = cpu_to_be32(blkno);
929 icnodehdr.count = 1; 929 icnodehdr.count = 1;
930 xfs_da3_node_hdr_to_disk(node, &icnodehdr); 930 dp->d_ops->node_hdr_to_disk(node, &icnodehdr);
931 xfs_trans_log_buf(args->trans, bp1, 0, XFS_LBSIZE(mp) - 1); 931 xfs_trans_log_buf(args->trans, bp1, 0, XFS_LBSIZE(mp) - 1);
932 error = 0; 932 error = 0;
933out: 933out:
diff --git a/fs/xfs/xfs_attr_list.c b/fs/xfs/xfs_attr_list.c
index ea1c4c46c24f..2d174b128153 100644
--- a/fs/xfs/xfs_attr_list.c
+++ b/fs/xfs/xfs_attr_list.c
@@ -311,7 +311,7 @@ xfs_attr_node_list(xfs_attr_list_context_t *context)
311 return XFS_ERROR(EFSCORRUPTED); 311 return XFS_ERROR(EFSCORRUPTED);
312 } 312 }
313 313
314 xfs_da3_node_hdr_from_disk(&nodehdr, node); 314 dp->d_ops->node_hdr_from_disk(&nodehdr, node);
315 btree = dp->d_ops->node_tree_p(node); 315 btree = dp->d_ops->node_tree_p(node);
316 for (i = 0; i < nodehdr.count; btree++, i++) { 316 for (i = 0; i < nodehdr.count; btree++, i++) {
317 if (cursor->hashval 317 if (cursor->hashval
diff --git a/fs/xfs/xfs_da_btree.c b/fs/xfs/xfs_da_btree.c
index 26dfc42a28f9..a51762dae543 100644
--- a/fs/xfs/xfs_da_btree.c
+++ b/fs/xfs/xfs_da_btree.c
@@ -129,56 +129,6 @@ xfs_da_state_free(xfs_da_state_t *state)
129 kmem_zone_free(xfs_da_state_zone, state); 129 kmem_zone_free(xfs_da_state_zone, state);
130} 130}
131 131
132void
133xfs_da3_node_hdr_from_disk(
134 struct xfs_da3_icnode_hdr *to,
135 struct xfs_da_intnode *from)
136{
137 ASSERT(from->hdr.info.magic == cpu_to_be16(XFS_DA_NODE_MAGIC) ||
138 from->hdr.info.magic == cpu_to_be16(XFS_DA3_NODE_MAGIC));
139
140 if (from->hdr.info.magic == cpu_to_be16(XFS_DA3_NODE_MAGIC)) {
141 struct xfs_da3_node_hdr *hdr3 = (struct xfs_da3_node_hdr *)from;
142
143 to->forw = be32_to_cpu(hdr3->info.hdr.forw);
144 to->back = be32_to_cpu(hdr3->info.hdr.back);
145 to->magic = be16_to_cpu(hdr3->info.hdr.magic);
146 to->count = be16_to_cpu(hdr3->__count);
147 to->level = be16_to_cpu(hdr3->__level);
148 return;
149 }
150 to->forw = be32_to_cpu(from->hdr.info.forw);
151 to->back = be32_to_cpu(from->hdr.info.back);
152 to->magic = be16_to_cpu(from->hdr.info.magic);
153 to->count = be16_to_cpu(from->hdr.__count);
154 to->level = be16_to_cpu(from->hdr.__level);
155}
156
157void
158xfs_da3_node_hdr_to_disk(
159 struct xfs_da_intnode *to,
160 struct xfs_da3_icnode_hdr *from)
161{
162 ASSERT(from->magic == XFS_DA_NODE_MAGIC ||
163 from->magic == XFS_DA3_NODE_MAGIC);
164
165 if (from->magic == XFS_DA3_NODE_MAGIC) {
166 struct xfs_da3_node_hdr *hdr3 = (struct xfs_da3_node_hdr *)to;
167
168 hdr3->info.hdr.forw = cpu_to_be32(from->forw);
169 hdr3->info.hdr.back = cpu_to_be32(from->back);
170 hdr3->info.hdr.magic = cpu_to_be16(from->magic);
171 hdr3->__count = cpu_to_be16(from->count);
172 hdr3->__level = cpu_to_be16(from->level);
173 return;
174 }
175 to->hdr.info.forw = cpu_to_be32(from->forw);
176 to->hdr.info.back = cpu_to_be32(from->back);
177 to->hdr.info.magic = cpu_to_be16(from->magic);
178 to->hdr.__count = cpu_to_be16(from->count);
179 to->hdr.__level = cpu_to_be16(from->level);
180}
181
182static bool 132static bool
183xfs_da3_node_verify( 133xfs_da3_node_verify(
184 struct xfs_buf *bp) 134 struct xfs_buf *bp)
@@ -186,8 +136,11 @@ xfs_da3_node_verify(
186 struct xfs_mount *mp = bp->b_target->bt_mount; 136 struct xfs_mount *mp = bp->b_target->bt_mount;
187 struct xfs_da_intnode *hdr = bp->b_addr; 137 struct xfs_da_intnode *hdr = bp->b_addr;
188 struct xfs_da3_icnode_hdr ichdr; 138 struct xfs_da3_icnode_hdr ichdr;
139 const struct xfs_dir_ops *ops;
140
141 ops = xfs_dir_get_ops(mp, NULL);
189 142
190 xfs_da3_node_hdr_from_disk(&ichdr, hdr); 143 ops->node_hdr_from_disk(&ichdr, hdr);
191 144
192 if (xfs_sb_version_hascrc(&mp->m_sb)) { 145 if (xfs_sb_version_hascrc(&mp->m_sb)) {
193 struct xfs_da3_node_hdr *hdr3 = bp->b_addr; 146 struct xfs_da3_node_hdr *hdr3 = bp->b_addr;
@@ -354,11 +307,12 @@ xfs_da3_node_create(
354 struct xfs_da3_icnode_hdr ichdr = {0}; 307 struct xfs_da3_icnode_hdr ichdr = {0};
355 struct xfs_buf *bp; 308 struct xfs_buf *bp;
356 int error; 309 int error;
310 struct xfs_inode *dp = args->dp;
357 311
358 trace_xfs_da_node_create(args); 312 trace_xfs_da_node_create(args);
359 ASSERT(level <= XFS_DA_NODE_MAXDEPTH); 313 ASSERT(level <= XFS_DA_NODE_MAXDEPTH);
360 314
361 error = xfs_da_get_buf(tp, args->dp, blkno, -1, &bp, whichfork); 315 error = xfs_da_get_buf(tp, dp, blkno, -1, &bp, whichfork);
362 if (error) 316 if (error)
363 return(error); 317 return(error);
364 bp->b_ops = &xfs_da3_node_buf_ops; 318 bp->b_ops = &xfs_da3_node_buf_ops;
@@ -377,10 +331,10 @@ xfs_da3_node_create(
377 } 331 }
378 ichdr.level = level; 332 ichdr.level = level;
379 333
380 xfs_da3_node_hdr_to_disk(node, &ichdr); 334 dp->d_ops->node_hdr_to_disk(node, &ichdr);
381 xfs_trans_log_buf(tp, bp, 335 xfs_trans_log_buf(tp, bp,
382 XFS_DA_LOGRANGE(node, &node->hdr, 336 XFS_DA_LOGRANGE(node, &node->hdr,
383 args->dp->d_ops->node_hdr_size())); 337 dp->d_ops->node_hdr_size()));
384 338
385 *bpp = bp; 339 *bpp = bp;
386 return(0); 340 return(0);
@@ -590,7 +544,7 @@ xfs_da3_root_split(
590 oldroot->hdr.info.magic == cpu_to_be16(XFS_DA3_NODE_MAGIC)) { 544 oldroot->hdr.info.magic == cpu_to_be16(XFS_DA3_NODE_MAGIC)) {
591 struct xfs_da3_icnode_hdr nodehdr; 545 struct xfs_da3_icnode_hdr nodehdr;
592 546
593 xfs_da3_node_hdr_from_disk(&nodehdr, oldroot); 547 dp->d_ops->node_hdr_from_disk(&nodehdr, oldroot);
594 btree = dp->d_ops->node_tree_p(oldroot); 548 btree = dp->d_ops->node_tree_p(oldroot);
595 size = (int)((char *)&btree[nodehdr.count] - (char *)oldroot); 549 size = (int)((char *)&btree[nodehdr.count] - (char *)oldroot);
596 level = nodehdr.level; 550 level = nodehdr.level;
@@ -605,7 +559,7 @@ xfs_da3_root_split(
605 struct xfs_dir2_leaf_entry *ents; 559 struct xfs_dir2_leaf_entry *ents;
606 560
607 leaf = (xfs_dir2_leaf_t *)oldroot; 561 leaf = (xfs_dir2_leaf_t *)oldroot;
608 xfs_dir3_leaf_hdr_from_disk(&leafhdr, leaf); 562 dp->d_ops->leaf_hdr_from_disk(&leafhdr, leaf);
609 ents = dp->d_ops->leaf_ents_p(leaf); 563 ents = dp->d_ops->leaf_ents_p(leaf);
610 564
611 ASSERT(leafhdr.magic == XFS_DIR2_LEAFN_MAGIC || 565 ASSERT(leafhdr.magic == XFS_DIR2_LEAFN_MAGIC ||
@@ -650,14 +604,14 @@ xfs_da3_root_split(
650 return error; 604 return error;
651 605
652 node = bp->b_addr; 606 node = bp->b_addr;
653 xfs_da3_node_hdr_from_disk(&nodehdr, node); 607 dp->d_ops->node_hdr_from_disk(&nodehdr, node);
654 btree = dp->d_ops->node_tree_p(node); 608 btree = dp->d_ops->node_tree_p(node);
655 btree[0].hashval = cpu_to_be32(blk1->hashval); 609 btree[0].hashval = cpu_to_be32(blk1->hashval);
656 btree[0].before = cpu_to_be32(blk1->blkno); 610 btree[0].before = cpu_to_be32(blk1->blkno);
657 btree[1].hashval = cpu_to_be32(blk2->hashval); 611 btree[1].hashval = cpu_to_be32(blk2->hashval);
658 btree[1].before = cpu_to_be32(blk2->blkno); 612 btree[1].before = cpu_to_be32(blk2->blkno);
659 nodehdr.count = 2; 613 nodehdr.count = 2;
660 xfs_da3_node_hdr_to_disk(node, &nodehdr); 614 dp->d_ops->node_hdr_to_disk(node, &nodehdr);
661 615
662#ifdef DEBUG 616#ifdef DEBUG
663 if (oldroot->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC) || 617 if (oldroot->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC) ||
@@ -694,11 +648,12 @@ xfs_da3_node_split(
694 int newcount; 648 int newcount;
695 int error; 649 int error;
696 int useextra; 650 int useextra;
651 struct xfs_inode *dp = state->args->dp;
697 652
698 trace_xfs_da_node_split(state->args); 653 trace_xfs_da_node_split(state->args);
699 654
700 node = oldblk->bp->b_addr; 655 node = oldblk->bp->b_addr;
701 xfs_da3_node_hdr_from_disk(&nodehdr, node); 656 dp->d_ops->node_hdr_from_disk(&nodehdr, node);
702 657
703 /* 658 /*
704 * With V2 dirs the extra block is data or freespace. 659 * With V2 dirs the extra block is data or freespace.
@@ -745,7 +700,7 @@ xfs_da3_node_split(
745 * If we had double-split op below us, then add the extra block too. 700 * If we had double-split op below us, then add the extra block too.
746 */ 701 */
747 node = oldblk->bp->b_addr; 702 node = oldblk->bp->b_addr;
748 xfs_da3_node_hdr_from_disk(&nodehdr, node); 703 dp->d_ops->node_hdr_from_disk(&nodehdr, node);
749 if (oldblk->index <= nodehdr.count) { 704 if (oldblk->index <= nodehdr.count) {
750 oldblk->index++; 705 oldblk->index++;
751 xfs_da3_node_add(state, oldblk, addblk); 706 xfs_da3_node_add(state, oldblk, addblk);
@@ -800,8 +755,8 @@ xfs_da3_node_rebalance(
800 755
801 node1 = blk1->bp->b_addr; 756 node1 = blk1->bp->b_addr;
802 node2 = blk2->bp->b_addr; 757 node2 = blk2->bp->b_addr;
803 xfs_da3_node_hdr_from_disk(&nodehdr1, node1); 758 dp->d_ops->node_hdr_from_disk(&nodehdr1, node1);
804 xfs_da3_node_hdr_from_disk(&nodehdr2, node2); 759 dp->d_ops->node_hdr_from_disk(&nodehdr2, node2);
805 btree1 = dp->d_ops->node_tree_p(node1); 760 btree1 = dp->d_ops->node_tree_p(node1);
806 btree2 = dp->d_ops->node_tree_p(node2); 761 btree2 = dp->d_ops->node_tree_p(node2);
807 762
@@ -816,8 +771,8 @@ xfs_da3_node_rebalance(
816 tmpnode = node1; 771 tmpnode = node1;
817 node1 = node2; 772 node1 = node2;
818 node2 = tmpnode; 773 node2 = tmpnode;
819 xfs_da3_node_hdr_from_disk(&nodehdr1, node1); 774 dp->d_ops->node_hdr_from_disk(&nodehdr1, node1);
820 xfs_da3_node_hdr_from_disk(&nodehdr2, node2); 775 dp->d_ops->node_hdr_from_disk(&nodehdr2, node2);
821 btree1 = dp->d_ops->node_tree_p(node1); 776 btree1 = dp->d_ops->node_tree_p(node1);
822 btree2 = dp->d_ops->node_tree_p(node2); 777 btree2 = dp->d_ops->node_tree_p(node2);
823 swap = 1; 778 swap = 1;
@@ -881,12 +836,12 @@ xfs_da3_node_rebalance(
881 /* 836 /*
882 * Log header of node 1 and all current bits of node 2. 837 * Log header of node 1 and all current bits of node 2.
883 */ 838 */
884 xfs_da3_node_hdr_to_disk(node1, &nodehdr1); 839 dp->d_ops->node_hdr_to_disk(node1, &nodehdr1);
885 xfs_trans_log_buf(tp, blk1->bp, 840 xfs_trans_log_buf(tp, blk1->bp,
886 XFS_DA_LOGRANGE(node1, &node1->hdr, 841 XFS_DA_LOGRANGE(node1, &node1->hdr,
887 dp->d_ops->node_hdr_size())); 842 dp->d_ops->node_hdr_size()));
888 843
889 xfs_da3_node_hdr_to_disk(node2, &nodehdr2); 844 dp->d_ops->node_hdr_to_disk(node2, &nodehdr2);
890 xfs_trans_log_buf(tp, blk2->bp, 845 xfs_trans_log_buf(tp, blk2->bp,
891 XFS_DA_LOGRANGE(node2, &node2->hdr, 846 XFS_DA_LOGRANGE(node2, &node2->hdr,
892 dp->d_ops->node_hdr_size() + 847 dp->d_ops->node_hdr_size() +
@@ -899,8 +854,8 @@ xfs_da3_node_rebalance(
899 if (swap) { 854 if (swap) {
900 node1 = blk1->bp->b_addr; 855 node1 = blk1->bp->b_addr;
901 node2 = blk2->bp->b_addr; 856 node2 = blk2->bp->b_addr;
902 xfs_da3_node_hdr_from_disk(&nodehdr1, node1); 857 dp->d_ops->node_hdr_from_disk(&nodehdr1, node1);
903 xfs_da3_node_hdr_from_disk(&nodehdr2, node2); 858 dp->d_ops->node_hdr_from_disk(&nodehdr2, node2);
904 btree1 = dp->d_ops->node_tree_p(node1); 859 btree1 = dp->d_ops->node_tree_p(node1);
905 btree2 = dp->d_ops->node_tree_p(node2); 860 btree2 = dp->d_ops->node_tree_p(node2);
906 } 861 }
@@ -934,7 +889,7 @@ xfs_da3_node_add(
934 trace_xfs_da_node_add(state->args); 889 trace_xfs_da_node_add(state->args);
935 890
936 node = oldblk->bp->b_addr; 891 node = oldblk->bp->b_addr;
937 xfs_da3_node_hdr_from_disk(&nodehdr, node); 892 dp->d_ops->node_hdr_from_disk(&nodehdr, node);
938 btree = dp->d_ops->node_tree_p(node); 893 btree = dp->d_ops->node_tree_p(node);
939 894
940 ASSERT(oldblk->index >= 0 && oldblk->index <= nodehdr.count); 895 ASSERT(oldblk->index >= 0 && oldblk->index <= nodehdr.count);
@@ -958,7 +913,7 @@ xfs_da3_node_add(
958 tmp + sizeof(*btree))); 913 tmp + sizeof(*btree)));
959 914
960 nodehdr.count += 1; 915 nodehdr.count += 1;
961 xfs_da3_node_hdr_to_disk(node, &nodehdr); 916 dp->d_ops->node_hdr_to_disk(node, &nodehdr);
962 xfs_trans_log_buf(state->args->trans, oldblk->bp, 917 xfs_trans_log_buf(state->args->trans, oldblk->bp,
963 XFS_DA_LOGRANGE(node, &node->hdr, dp->d_ops->node_hdr_size())); 918 XFS_DA_LOGRANGE(node, &node->hdr, dp->d_ops->node_hdr_size()));
964 919
@@ -1097,6 +1052,7 @@ xfs_da3_root_join(
1097 struct xfs_da3_icnode_hdr oldroothdr; 1052 struct xfs_da3_icnode_hdr oldroothdr;
1098 struct xfs_da_node_entry *btree; 1053 struct xfs_da_node_entry *btree;
1099 int error; 1054 int error;
1055 struct xfs_inode *dp = state->args->dp;
1100 1056
1101 trace_xfs_da_root_join(state->args); 1057 trace_xfs_da_root_join(state->args);
1102 1058
@@ -1104,7 +1060,7 @@ xfs_da3_root_join(
1104 1060
1105 args = state->args; 1061 args = state->args;
1106 oldroot = root_blk->bp->b_addr; 1062 oldroot = root_blk->bp->b_addr;
1107 xfs_da3_node_hdr_from_disk(&oldroothdr, oldroot); 1063 dp->d_ops->node_hdr_from_disk(&oldroothdr, oldroot);
1108 ASSERT(oldroothdr.forw == 0); 1064 ASSERT(oldroothdr.forw == 0);
1109 ASSERT(oldroothdr.back == 0); 1065 ASSERT(oldroothdr.back == 0);
1110 1066
@@ -1118,10 +1074,10 @@ xfs_da3_root_join(
1118 * Read in the (only) child block, then copy those bytes into 1074 * Read in the (only) child block, then copy those bytes into
1119 * the root block's buffer and free the original child block. 1075 * the root block's buffer and free the original child block.
1120 */ 1076 */
1121 btree = args->dp->d_ops->node_tree_p(oldroot); 1077 btree = dp->d_ops->node_tree_p(oldroot);
1122 child = be32_to_cpu(btree[0].before); 1078 child = be32_to_cpu(btree[0].before);
1123 ASSERT(child != 0); 1079 ASSERT(child != 0);
1124 error = xfs_da3_node_read(args->trans, args->dp, child, -1, &bp, 1080 error = xfs_da3_node_read(args->trans, dp, child, -1, &bp,
1125 args->whichfork); 1081 args->whichfork);
1126 if (error) 1082 if (error)
1127 return error; 1083 return error;
@@ -1171,6 +1127,7 @@ xfs_da3_node_toosmall(
1171 int error; 1127 int error;
1172 int retval; 1128 int retval;
1173 int i; 1129 int i;
1130 struct xfs_inode *dp = state->args->dp;
1174 1131
1175 trace_xfs_da_node_toosmall(state->args); 1132 trace_xfs_da_node_toosmall(state->args);
1176 1133
@@ -1182,7 +1139,7 @@ xfs_da3_node_toosmall(
1182 blk = &state->path.blk[ state->path.active-1 ]; 1139 blk = &state->path.blk[ state->path.active-1 ];
1183 info = blk->bp->b_addr; 1140 info = blk->bp->b_addr;
1184 node = (xfs_da_intnode_t *)info; 1141 node = (xfs_da_intnode_t *)info;
1185 xfs_da3_node_hdr_from_disk(&nodehdr, node); 1142 dp->d_ops->node_hdr_from_disk(&nodehdr, node);
1186 if (nodehdr.count > (state->node_ents >> 1)) { 1143 if (nodehdr.count > (state->node_ents >> 1)) {
1187 *action = 0; /* blk over 50%, don't try to join */ 1144 *action = 0; /* blk over 50%, don't try to join */
1188 return(0); /* blk over 50%, don't try to join */ 1145 return(0); /* blk over 50%, don't try to join */
@@ -1234,13 +1191,13 @@ xfs_da3_node_toosmall(
1234 blkno = nodehdr.back; 1191 blkno = nodehdr.back;
1235 if (blkno == 0) 1192 if (blkno == 0)
1236 continue; 1193 continue;
1237 error = xfs_da3_node_read(state->args->trans, state->args->dp, 1194 error = xfs_da3_node_read(state->args->trans, dp,
1238 blkno, -1, &bp, state->args->whichfork); 1195 blkno, -1, &bp, state->args->whichfork);
1239 if (error) 1196 if (error)
1240 return(error); 1197 return(error);
1241 1198
1242 node = bp->b_addr; 1199 node = bp->b_addr;
1243 xfs_da3_node_hdr_from_disk(&thdr, node); 1200 dp->d_ops->node_hdr_from_disk(&thdr, node);
1244 xfs_trans_brelse(state->args->trans, bp); 1201 xfs_trans_brelse(state->args->trans, bp);
1245 1202
1246 if (count - thdr.count >= 0) 1203 if (count - thdr.count >= 0)
@@ -1287,7 +1244,7 @@ xfs_da3_node_lasthash(
1287 struct xfs_da3_icnode_hdr nodehdr; 1244 struct xfs_da3_icnode_hdr nodehdr;
1288 1245
1289 node = bp->b_addr; 1246 node = bp->b_addr;
1290 xfs_da3_node_hdr_from_disk(&nodehdr, node); 1247 dp->d_ops->node_hdr_from_disk(&nodehdr, node);
1291 if (count) 1248 if (count)
1292 *count = nodehdr.count; 1249 *count = nodehdr.count;
1293 if (!nodehdr.count) 1250 if (!nodehdr.count)
@@ -1338,7 +1295,7 @@ xfs_da3_fixhashpath(
1338 struct xfs_da3_icnode_hdr nodehdr; 1295 struct xfs_da3_icnode_hdr nodehdr;
1339 1296
1340 node = blk->bp->b_addr; 1297 node = blk->bp->b_addr;
1341 xfs_da3_node_hdr_from_disk(&nodehdr, node); 1298 dp->d_ops->node_hdr_from_disk(&nodehdr, node);
1342 btree = dp->d_ops->node_tree_p(node); 1299 btree = dp->d_ops->node_tree_p(node);
1343 if (be32_to_cpu(btree->hashval) == lasthash) 1300 if (be32_to_cpu(btree->hashval) == lasthash)
1344 break; 1301 break;
@@ -1370,7 +1327,7 @@ xfs_da3_node_remove(
1370 trace_xfs_da_node_remove(state->args); 1327 trace_xfs_da_node_remove(state->args);
1371 1328
1372 node = drop_blk->bp->b_addr; 1329 node = drop_blk->bp->b_addr;
1373 xfs_da3_node_hdr_from_disk(&nodehdr, node); 1330 dp->d_ops->node_hdr_from_disk(&nodehdr, node);
1374 ASSERT(drop_blk->index < nodehdr.count); 1331 ASSERT(drop_blk->index < nodehdr.count);
1375 ASSERT(drop_blk->index >= 0); 1332 ASSERT(drop_blk->index >= 0);
1376 1333
@@ -1391,7 +1348,7 @@ xfs_da3_node_remove(
1391 xfs_trans_log_buf(state->args->trans, drop_blk->bp, 1348 xfs_trans_log_buf(state->args->trans, drop_blk->bp,
1392 XFS_DA_LOGRANGE(node, &btree[index], sizeof(btree[index]))); 1349 XFS_DA_LOGRANGE(node, &btree[index], sizeof(btree[index])));
1393 nodehdr.count -= 1; 1350 nodehdr.count -= 1;
1394 xfs_da3_node_hdr_to_disk(node, &nodehdr); 1351 dp->d_ops->node_hdr_to_disk(node, &nodehdr);
1395 xfs_trans_log_buf(state->args->trans, drop_blk->bp, 1352 xfs_trans_log_buf(state->args->trans, drop_blk->bp,
1396 XFS_DA_LOGRANGE(node, &node->hdr, dp->d_ops->node_hdr_size())); 1353 XFS_DA_LOGRANGE(node, &node->hdr, dp->d_ops->node_hdr_size()));
1397 1354
@@ -1426,8 +1383,8 @@ xfs_da3_node_unbalance(
1426 1383
1427 drop_node = drop_blk->bp->b_addr; 1384 drop_node = drop_blk->bp->b_addr;
1428 save_node = save_blk->bp->b_addr; 1385 save_node = save_blk->bp->b_addr;
1429 xfs_da3_node_hdr_from_disk(&drop_hdr, drop_node); 1386 dp->d_ops->node_hdr_from_disk(&drop_hdr, drop_node);
1430 xfs_da3_node_hdr_from_disk(&save_hdr, save_node); 1387 dp->d_ops->node_hdr_from_disk(&save_hdr, save_node);
1431 drop_btree = dp->d_ops->node_tree_p(drop_node); 1388 drop_btree = dp->d_ops->node_tree_p(drop_node);
1432 save_btree = dp->d_ops->node_tree_p(save_node); 1389 save_btree = dp->d_ops->node_tree_p(save_node);
1433 tp = state->args->trans; 1390 tp = state->args->trans;
@@ -1463,7 +1420,7 @@ xfs_da3_node_unbalance(
1463 memcpy(&save_btree[sindex], &drop_btree[0], tmp); 1420 memcpy(&save_btree[sindex], &drop_btree[0], tmp);
1464 save_hdr.count += drop_hdr.count; 1421 save_hdr.count += drop_hdr.count;
1465 1422
1466 xfs_da3_node_hdr_to_disk(save_node, &save_hdr); 1423 dp->d_ops->node_hdr_to_disk(save_node, &save_hdr);
1467 xfs_trans_log_buf(tp, save_blk->bp, 1424 xfs_trans_log_buf(tp, save_blk->bp,
1468 XFS_DA_LOGRANGE(save_node, &save_node->hdr, 1425 XFS_DA_LOGRANGE(save_node, &save_node->hdr,
1469 dp->d_ops->node_hdr_size())); 1426 dp->d_ops->node_hdr_size()));
@@ -1556,7 +1513,7 @@ xfs_da3_node_lookup_int(
1556 * Search an intermediate node for a match. 1513 * Search an intermediate node for a match.
1557 */ 1514 */
1558 node = blk->bp->b_addr; 1515 node = blk->bp->b_addr;
1559 xfs_da3_node_hdr_from_disk(&nodehdr, node); 1516 dp->d_ops->node_hdr_from_disk(&nodehdr, node);
1560 btree = dp->d_ops->node_tree_p(node); 1517 btree = dp->d_ops->node_tree_p(node);
1561 1518
1562 max = nodehdr.count; 1519 max = nodehdr.count;
@@ -1665,8 +1622,8 @@ xfs_da3_node_order(
1665 1622
1666 node1 = node1_bp->b_addr; 1623 node1 = node1_bp->b_addr;
1667 node2 = node2_bp->b_addr; 1624 node2 = node2_bp->b_addr;
1668 xfs_da3_node_hdr_from_disk(&node1hdr, node1); 1625 dp->d_ops->node_hdr_from_disk(&node1hdr, node1);
1669 xfs_da3_node_hdr_from_disk(&node2hdr, node2); 1626 dp->d_ops->node_hdr_from_disk(&node2hdr, node2);
1670 btree1 = dp->d_ops->node_tree_p(node1); 1627 btree1 = dp->d_ops->node_tree_p(node1);
1671 btree2 = dp->d_ops->node_tree_p(node2); 1628 btree2 = dp->d_ops->node_tree_p(node2);
1672 1629
@@ -1888,7 +1845,7 @@ xfs_da3_path_shift(
1888 level = (path->active-1) - 1; /* skip bottom layer in path */ 1845 level = (path->active-1) - 1; /* skip bottom layer in path */
1889 for (blk = &path->blk[level]; level >= 0; blk--, level--) { 1846 for (blk = &path->blk[level]; level >= 0; blk--, level--) {
1890 node = blk->bp->b_addr; 1847 node = blk->bp->b_addr;
1891 xfs_da3_node_hdr_from_disk(&nodehdr, node); 1848 dp->d_ops->node_hdr_from_disk(&nodehdr, node);
1892 btree = dp->d_ops->node_tree_p(node); 1849 btree = dp->d_ops->node_tree_p(node);
1893 1850
1894 if (forward && (blk->index < nodehdr.count - 1)) { 1851 if (forward && (blk->index < nodehdr.count - 1)) {
@@ -1945,7 +1902,7 @@ xfs_da3_path_shift(
1945 case XFS_DA3_NODE_MAGIC: 1902 case XFS_DA3_NODE_MAGIC:
1946 blk->magic = XFS_DA_NODE_MAGIC; 1903 blk->magic = XFS_DA_NODE_MAGIC;
1947 node = (xfs_da_intnode_t *)info; 1904 node = (xfs_da_intnode_t *)info;
1948 xfs_da3_node_hdr_from_disk(&nodehdr, node); 1905 dp->d_ops->node_hdr_from_disk(&nodehdr, node);
1949 btree = dp->d_ops->node_tree_p(node); 1906 btree = dp->d_ops->node_tree_p(node);
1950 blk->hashval = be32_to_cpu(btree[nodehdr.count - 1].hashval); 1907 blk->hashval = be32_to_cpu(btree[nodehdr.count - 1].hashval);
1951 if (forward) 1908 if (forward)
@@ -2233,7 +2190,7 @@ xfs_da3_swap_lastblock(
2233 struct xfs_dir2_leaf_entry *ents; 2190 struct xfs_dir2_leaf_entry *ents;
2234 2191
2235 dead_leaf2 = (xfs_dir2_leaf_t *)dead_info; 2192 dead_leaf2 = (xfs_dir2_leaf_t *)dead_info;
2236 xfs_dir3_leaf_hdr_from_disk(&leafhdr, dead_leaf2); 2193 dp->d_ops->leaf_hdr_from_disk(&leafhdr, dead_leaf2);
2237 ents = dp->d_ops->leaf_ents_p(dead_leaf2); 2194 ents = dp->d_ops->leaf_ents_p(dead_leaf2);
2238 dead_level = 0; 2195 dead_level = 0;
2239 dead_hash = be32_to_cpu(ents[leafhdr.count - 1].hashval); 2196 dead_hash = be32_to_cpu(ents[leafhdr.count - 1].hashval);
@@ -2241,7 +2198,7 @@ xfs_da3_swap_lastblock(
2241 struct xfs_da3_icnode_hdr deadhdr; 2198 struct xfs_da3_icnode_hdr deadhdr;
2242 2199
2243 dead_node = (xfs_da_intnode_t *)dead_info; 2200 dead_node = (xfs_da_intnode_t *)dead_info;
2244 xfs_da3_node_hdr_from_disk(&deadhdr, dead_node); 2201 dp->d_ops->node_hdr_from_disk(&deadhdr, dead_node);
2245 btree = dp->d_ops->node_tree_p(dead_node); 2202 btree = dp->d_ops->node_tree_p(dead_node);
2246 dead_level = deadhdr.level; 2203 dead_level = deadhdr.level;
2247 dead_hash = be32_to_cpu(btree[deadhdr.count - 1].hashval); 2204 dead_hash = be32_to_cpu(btree[deadhdr.count - 1].hashval);
@@ -2301,7 +2258,7 @@ xfs_da3_swap_lastblock(
2301 if (error) 2258 if (error)
2302 goto done; 2259 goto done;
2303 par_node = par_buf->b_addr; 2260 par_node = par_buf->b_addr;
2304 xfs_da3_node_hdr_from_disk(&par_hdr, par_node); 2261 dp->d_ops->node_hdr_from_disk(&par_hdr, par_node);
2305 if (level >= 0 && level != par_hdr.level + 1) { 2262 if (level >= 0 && level != par_hdr.level + 1) {
2306 XFS_ERROR_REPORT("xfs_da_swap_lastblock(4)", 2263 XFS_ERROR_REPORT("xfs_da_swap_lastblock(4)",
2307 XFS_ERRLEVEL_LOW, mp); 2264 XFS_ERRLEVEL_LOW, mp);
@@ -2352,7 +2309,7 @@ xfs_da3_swap_lastblock(
2352 if (error) 2309 if (error)
2353 goto done; 2310 goto done;
2354 par_node = par_buf->b_addr; 2311 par_node = par_buf->b_addr;
2355 xfs_da3_node_hdr_from_disk(&par_hdr, par_node); 2312 dp->d_ops->node_hdr_from_disk(&par_hdr, par_node);
2356 if (par_hdr.level != level) { 2313 if (par_hdr.level != level) {
2357 XFS_ERROR_REPORT("xfs_da_swap_lastblock(7)", 2314 XFS_ERROR_REPORT("xfs_da_swap_lastblock(7)",
2358 XFS_ERRLEVEL_LOW, mp); 2315 XFS_ERRLEVEL_LOW, mp);
diff --git a/fs/xfs/xfs_da_format.c b/fs/xfs/xfs_da_format.c
index 72b48b5ec69a..b232c275791d 100644
--- a/fs/xfs/xfs_da_format.c
+++ b/fs/xfs/xfs_da_format.c
@@ -464,19 +464,84 @@ xfs_dir3_leaf_hdr_size(void)
464 return sizeof(struct xfs_dir3_leaf_hdr); 464 return sizeof(struct xfs_dir3_leaf_hdr);
465} 465}
466 466
467static inline int 467static int
468xfs_dir3_max_leaf_ents(struct xfs_mount *mp) 468xfs_dir3_max_leaf_ents(struct xfs_mount *mp)
469{ 469{
470 return (mp->m_dirblksize - xfs_dir3_leaf_hdr_size()) / 470 return (mp->m_dirblksize - xfs_dir3_leaf_hdr_size()) /
471 (uint)sizeof(struct xfs_dir2_leaf_entry); 471 (uint)sizeof(struct xfs_dir2_leaf_entry);
472} 472}
473 473
474static inline struct xfs_dir2_leaf_entry * 474static struct xfs_dir2_leaf_entry *
475xfs_dir3_leaf_ents_p(struct xfs_dir2_leaf *lp) 475xfs_dir3_leaf_ents_p(struct xfs_dir2_leaf *lp)
476{ 476{
477 return ((struct xfs_dir3_leaf *)lp)->__ents; 477 return ((struct xfs_dir3_leaf *)lp)->__ents;
478} 478}
479 479
480static void
481xfs_dir2_leaf_hdr_from_disk(
482 struct xfs_dir3_icleaf_hdr *to,
483 struct xfs_dir2_leaf *from)
484{
485 to->forw = be32_to_cpu(from->hdr.info.forw);
486 to->back = be32_to_cpu(from->hdr.info.back);
487 to->magic = be16_to_cpu(from->hdr.info.magic);
488 to->count = be16_to_cpu(from->hdr.count);
489 to->stale = be16_to_cpu(from->hdr.stale);
490
491 ASSERT(to->magic == XFS_DIR2_LEAF1_MAGIC ||
492 to->magic == XFS_DIR2_LEAFN_MAGIC);
493}
494
495static void
496xfs_dir2_leaf_hdr_to_disk(
497 struct xfs_dir2_leaf *to,
498 struct xfs_dir3_icleaf_hdr *from)
499{
500 ASSERT(from->magic == XFS_DIR2_LEAF1_MAGIC ||
501 from->magic == XFS_DIR2_LEAFN_MAGIC);
502
503 to->hdr.info.forw = cpu_to_be32(from->forw);
504 to->hdr.info.back = cpu_to_be32(from->back);
505 to->hdr.info.magic = cpu_to_be16(from->magic);
506 to->hdr.count = cpu_to_be16(from->count);
507 to->hdr.stale = cpu_to_be16(from->stale);
508}
509
510static void
511xfs_dir3_leaf_hdr_from_disk(
512 struct xfs_dir3_icleaf_hdr *to,
513 struct xfs_dir2_leaf *from)
514{
515 struct xfs_dir3_leaf_hdr *hdr3 = (struct xfs_dir3_leaf_hdr *)from;
516
517 to->forw = be32_to_cpu(hdr3->info.hdr.forw);
518 to->back = be32_to_cpu(hdr3->info.hdr.back);
519 to->magic = be16_to_cpu(hdr3->info.hdr.magic);
520 to->count = be16_to_cpu(hdr3->count);
521 to->stale = be16_to_cpu(hdr3->stale);
522
523 ASSERT(to->magic == XFS_DIR3_LEAF1_MAGIC ||
524 to->magic == XFS_DIR3_LEAFN_MAGIC);
525}
526
527static void
528xfs_dir3_leaf_hdr_to_disk(
529 struct xfs_dir2_leaf *to,
530 struct xfs_dir3_icleaf_hdr *from)
531{
532 struct xfs_dir3_leaf_hdr *hdr3 = (struct xfs_dir3_leaf_hdr *)to;
533
534 ASSERT(from->magic == XFS_DIR3_LEAF1_MAGIC ||
535 from->magic == XFS_DIR3_LEAFN_MAGIC);
536
537 hdr3->info.hdr.forw = cpu_to_be32(from->forw);
538 hdr3->info.hdr.back = cpu_to_be32(from->back);
539 hdr3->info.hdr.magic = cpu_to_be16(from->magic);
540 hdr3->count = cpu_to_be16(from->count);
541 hdr3->stale = cpu_to_be16(from->stale);
542}
543
544
480/* 545/*
481 * Directory/Attribute Node block operations 546 * Directory/Attribute Node block operations
482 */ 547 */
@@ -504,6 +569,121 @@ xfs_da3_node_tree_p(struct xfs_da_intnode *dap)
504 return ((struct xfs_da3_intnode *)dap)->__btree; 569 return ((struct xfs_da3_intnode *)dap)->__btree;
505} 570}
506 571
572static void
573xfs_da2_node_hdr_from_disk(
574 struct xfs_da3_icnode_hdr *to,
575 struct xfs_da_intnode *from)
576{
577 ASSERT(from->hdr.info.magic == cpu_to_be16(XFS_DA_NODE_MAGIC));
578 to->forw = be32_to_cpu(from->hdr.info.forw);
579 to->back = be32_to_cpu(from->hdr.info.back);
580 to->magic = be16_to_cpu(from->hdr.info.magic);
581 to->count = be16_to_cpu(from->hdr.__count);
582 to->level = be16_to_cpu(from->hdr.__level);
583}
584
585static void
586xfs_da2_node_hdr_to_disk(
587 struct xfs_da_intnode *to,
588 struct xfs_da3_icnode_hdr *from)
589{
590 ASSERT(from->magic == XFS_DA_NODE_MAGIC);
591 to->hdr.info.forw = cpu_to_be32(from->forw);
592 to->hdr.info.back = cpu_to_be32(from->back);
593 to->hdr.info.magic = cpu_to_be16(from->magic);
594 to->hdr.__count = cpu_to_be16(from->count);
595 to->hdr.__level = cpu_to_be16(from->level);
596}
597
598static void
599xfs_da3_node_hdr_from_disk(
600 struct xfs_da3_icnode_hdr *to,
601 struct xfs_da_intnode *from)
602{
603 struct xfs_da3_node_hdr *hdr3 = (struct xfs_da3_node_hdr *)from;
604
605 ASSERT(from->hdr.info.magic == cpu_to_be16(XFS_DA3_NODE_MAGIC));
606 to->forw = be32_to_cpu(hdr3->info.hdr.forw);
607 to->back = be32_to_cpu(hdr3->info.hdr.back);
608 to->magic = be16_to_cpu(hdr3->info.hdr.magic);
609 to->count = be16_to_cpu(hdr3->__count);
610 to->level = be16_to_cpu(hdr3->__level);
611}
612
613static void
614xfs_da3_node_hdr_to_disk(
615 struct xfs_da_intnode *to,
616 struct xfs_da3_icnode_hdr *from)
617{
618 struct xfs_da3_node_hdr *hdr3 = (struct xfs_da3_node_hdr *)to;
619
620 ASSERT(from->magic == XFS_DA3_NODE_MAGIC);
621 hdr3->info.hdr.forw = cpu_to_be32(from->forw);
622 hdr3->info.hdr.back = cpu_to_be32(from->back);
623 hdr3->info.hdr.magic = cpu_to_be16(from->magic);
624 hdr3->__count = cpu_to_be16(from->count);
625 hdr3->__level = cpu_to_be16(from->level);
626}
627
628
629/*
630 * Directory free space block operations
631 */
632static void
633xfs_dir2_free_hdr_from_disk(
634 struct xfs_dir3_icfree_hdr *to,
635 struct xfs_dir2_free *from)
636{
637 to->magic = be32_to_cpu(from->hdr.magic);
638 to->firstdb = be32_to_cpu(from->hdr.firstdb);
639 to->nvalid = be32_to_cpu(from->hdr.nvalid);
640 to->nused = be32_to_cpu(from->hdr.nused);
641 ASSERT(to->magic == XFS_DIR2_FREE_MAGIC);
642}
643
644static void
645xfs_dir2_free_hdr_to_disk(
646 struct xfs_dir2_free *to,
647 struct xfs_dir3_icfree_hdr *from)
648{
649 ASSERT(from->magic == XFS_DIR2_FREE_MAGIC);
650
651 to->hdr.magic = cpu_to_be32(from->magic);
652 to->hdr.firstdb = cpu_to_be32(from->firstdb);
653 to->hdr.nvalid = cpu_to_be32(from->nvalid);
654 to->hdr.nused = cpu_to_be32(from->nused);
655}
656
657static void
658xfs_dir3_free_hdr_from_disk(
659 struct xfs_dir3_icfree_hdr *to,
660 struct xfs_dir2_free *from)
661{
662 struct xfs_dir3_free_hdr *hdr3 = (struct xfs_dir3_free_hdr *)from;
663
664 to->magic = be32_to_cpu(hdr3->hdr.magic);
665 to->firstdb = be32_to_cpu(hdr3->firstdb);
666 to->nvalid = be32_to_cpu(hdr3->nvalid);
667 to->nused = be32_to_cpu(hdr3->nused);
668
669 ASSERT(to->magic == XFS_DIR3_FREE_MAGIC);
670}
671
672static void
673xfs_dir3_free_hdr_to_disk(
674 struct xfs_dir2_free *to,
675 struct xfs_dir3_icfree_hdr *from)
676{
677 struct xfs_dir3_free_hdr *hdr3 = (struct xfs_dir3_free_hdr *)to;
678
679 ASSERT(from->magic == XFS_DIR3_FREE_MAGIC);
680
681 hdr3->hdr.magic = cpu_to_be32(from->magic);
682 hdr3->firstdb = cpu_to_be32(from->firstdb);
683 hdr3->nvalid = cpu_to_be32(from->nvalid);
684 hdr3->nused = cpu_to_be32(from->nused);
685}
686
507const struct xfs_dir_ops xfs_dir2_ops = { 687const struct xfs_dir_ops xfs_dir2_ops = {
508 .sf_entsize = xfs_dir2_sf_entsize, 688 .sf_entsize = xfs_dir2_sf_entsize,
509 .sf_nextentry = xfs_dir2_sf_nextentry, 689 .sf_nextentry = xfs_dir2_sf_nextentry,
@@ -532,11 +712,18 @@ const struct xfs_dir_ops xfs_dir2_ops = {
532 .data_unused_p = xfs_dir2_data_unused_p, 712 .data_unused_p = xfs_dir2_data_unused_p,
533 713
534 .leaf_hdr_size = xfs_dir2_leaf_hdr_size, 714 .leaf_hdr_size = xfs_dir2_leaf_hdr_size,
715 .leaf_hdr_to_disk = xfs_dir2_leaf_hdr_to_disk,
716 .leaf_hdr_from_disk = xfs_dir2_leaf_hdr_from_disk,
535 .leaf_max_ents = xfs_dir2_max_leaf_ents, 717 .leaf_max_ents = xfs_dir2_max_leaf_ents,
536 .leaf_ents_p = xfs_dir2_leaf_ents_p, 718 .leaf_ents_p = xfs_dir2_leaf_ents_p,
537 719
538 .node_hdr_size = xfs_da2_node_hdr_size, 720 .node_hdr_size = xfs_da2_node_hdr_size,
721 .node_hdr_to_disk = xfs_da2_node_hdr_to_disk,
722 .node_hdr_from_disk = xfs_da2_node_hdr_from_disk,
539 .node_tree_p = xfs_da2_node_tree_p, 723 .node_tree_p = xfs_da2_node_tree_p,
724
725 .free_hdr_to_disk = xfs_dir2_free_hdr_to_disk,
726 .free_hdr_from_disk = xfs_dir2_free_hdr_from_disk,
540}; 727};
541 728
542const struct xfs_dir_ops xfs_dir2_ftype_ops = { 729const struct xfs_dir_ops xfs_dir2_ftype_ops = {
@@ -567,11 +754,18 @@ const struct xfs_dir_ops xfs_dir2_ftype_ops = {
567 .data_unused_p = xfs_dir2_data_unused_p, 754 .data_unused_p = xfs_dir2_data_unused_p,
568 755
569 .leaf_hdr_size = xfs_dir2_leaf_hdr_size, 756 .leaf_hdr_size = xfs_dir2_leaf_hdr_size,
757 .leaf_hdr_to_disk = xfs_dir2_leaf_hdr_to_disk,
758 .leaf_hdr_from_disk = xfs_dir2_leaf_hdr_from_disk,
570 .leaf_max_ents = xfs_dir2_max_leaf_ents, 759 .leaf_max_ents = xfs_dir2_max_leaf_ents,
571 .leaf_ents_p = xfs_dir2_leaf_ents_p, 760 .leaf_ents_p = xfs_dir2_leaf_ents_p,
572 761
573 .node_hdr_size = xfs_da2_node_hdr_size, 762 .node_hdr_size = xfs_da2_node_hdr_size,
763 .node_hdr_to_disk = xfs_da2_node_hdr_to_disk,
764 .node_hdr_from_disk = xfs_da2_node_hdr_from_disk,
574 .node_tree_p = xfs_da2_node_tree_p, 765 .node_tree_p = xfs_da2_node_tree_p,
766
767 .free_hdr_to_disk = xfs_dir2_free_hdr_to_disk,
768 .free_hdr_from_disk = xfs_dir2_free_hdr_from_disk,
575}; 769};
576 770
577const struct xfs_dir_ops xfs_dir3_ops = { 771const struct xfs_dir_ops xfs_dir3_ops = {
@@ -602,20 +796,31 @@ const struct xfs_dir_ops xfs_dir3_ops = {
602 .data_unused_p = xfs_dir3_data_unused_p, 796 .data_unused_p = xfs_dir3_data_unused_p,
603 797
604 .leaf_hdr_size = xfs_dir3_leaf_hdr_size, 798 .leaf_hdr_size = xfs_dir3_leaf_hdr_size,
799 .leaf_hdr_to_disk = xfs_dir3_leaf_hdr_to_disk,
800 .leaf_hdr_from_disk = xfs_dir3_leaf_hdr_from_disk,
605 .leaf_max_ents = xfs_dir3_max_leaf_ents, 801 .leaf_max_ents = xfs_dir3_max_leaf_ents,
606 .leaf_ents_p = xfs_dir3_leaf_ents_p, 802 .leaf_ents_p = xfs_dir3_leaf_ents_p,
607 803
608 .node_hdr_size = xfs_da3_node_hdr_size, 804 .node_hdr_size = xfs_da3_node_hdr_size,
805 .node_hdr_to_disk = xfs_da3_node_hdr_to_disk,
806 .node_hdr_from_disk = xfs_da3_node_hdr_from_disk,
609 .node_tree_p = xfs_da3_node_tree_p, 807 .node_tree_p = xfs_da3_node_tree_p,
808
809 .free_hdr_to_disk = xfs_dir3_free_hdr_to_disk,
810 .free_hdr_from_disk = xfs_dir3_free_hdr_from_disk,
610}; 811};
611 812
612const struct xfs_dir_ops xfs_dir2_nondir_ops = { 813const struct xfs_dir_ops xfs_dir2_nondir_ops = {
613 .node_hdr_size = xfs_da2_node_hdr_size, 814 .node_hdr_size = xfs_da2_node_hdr_size,
815 .node_hdr_to_disk = xfs_da2_node_hdr_to_disk,
816 .node_hdr_from_disk = xfs_da2_node_hdr_from_disk,
614 .node_tree_p = xfs_da2_node_tree_p, 817 .node_tree_p = xfs_da2_node_tree_p,
615}; 818};
616 819
617const struct xfs_dir_ops xfs_dir3_nondir_ops = { 820const struct xfs_dir_ops xfs_dir3_nondir_ops = {
618 .node_hdr_size = xfs_da3_node_hdr_size, 821 .node_hdr_size = xfs_da3_node_hdr_size,
822 .node_hdr_to_disk = xfs_da3_node_hdr_to_disk,
823 .node_hdr_from_disk = xfs_da3_node_hdr_from_disk,
619 .node_tree_p = xfs_da3_node_tree_p, 824 .node_tree_p = xfs_da3_node_tree_p,
620}; 825};
621 826
diff --git a/fs/xfs/xfs_da_format.h b/fs/xfs/xfs_da_format.h
index 69b4c6e1c52e..1ff7b9f42097 100644
--- a/fs/xfs/xfs_da_format.h
+++ b/fs/xfs/xfs_da_format.h
@@ -122,16 +122,6 @@ struct xfs_da3_icnode_hdr {
122 __uint16_t level; 122 __uint16_t level;
123}; 123};
124 124
125extern void xfs_da3_node_hdr_from_disk(struct xfs_da3_icnode_hdr *to,
126 struct xfs_da_intnode *from);
127extern void xfs_da3_node_hdr_to_disk(struct xfs_da_intnode *to,
128 struct xfs_da3_icnode_hdr *from);
129
130extern void xfs_da3_intnode_from_disk(struct xfs_da3_icnode_hdr *to,
131 struct xfs_da_intnode *from);
132extern void xfs_da3_intnode_to_disk(struct xfs_da_intnode *to,
133 struct xfs_da3_icnode_hdr *from);
134
135#define XFS_LBSIZE(mp) (mp)->m_sb.sb_blocksize 125#define XFS_LBSIZE(mp) (mp)->m_sb.sb_blocksize
136 126
137/* 127/*
@@ -523,9 +513,6 @@ struct xfs_dir3_leaf {
523 513
524#define XFS_DIR3_LEAF_CRC_OFF offsetof(struct xfs_dir3_leaf_hdr, info.crc) 514#define XFS_DIR3_LEAF_CRC_OFF offsetof(struct xfs_dir3_leaf_hdr, info.crc)
525 515
526extern void xfs_dir3_leaf_hdr_from_disk(struct xfs_dir3_icleaf_hdr *to,
527 struct xfs_dir2_leaf *from);
528
529/* 516/*
530 * Get address of the bestcount field in the single-leaf block. 517 * Get address of the bestcount field in the single-leaf block.
531 */ 518 */
@@ -717,9 +704,6 @@ struct xfs_dir3_icfree_hdr {
717 704
718}; 705};
719 706
720void xfs_dir3_free_hdr_from_disk(struct xfs_dir3_icfree_hdr *to,
721 struct xfs_dir2_free *from);
722
723static inline int 707static inline int
724xfs_dir3_free_hdr_size(struct xfs_mount *mp) 708xfs_dir3_free_hdr_size(struct xfs_mount *mp)
725{ 709{
diff --git a/fs/xfs/xfs_dir2.h b/fs/xfs/xfs_dir2.h
index c5cad9d9239d..61195348f667 100644
--- a/fs/xfs/xfs_dir2.h
+++ b/fs/xfs/xfs_dir2.h
@@ -76,13 +76,26 @@ struct xfs_dir_ops {
76 (*data_unused_p)(struct xfs_dir2_data_hdr *hdr); 76 (*data_unused_p)(struct xfs_dir2_data_hdr *hdr);
77 77
78 int (*leaf_hdr_size)(void); 78 int (*leaf_hdr_size)(void);
79 void (*leaf_hdr_to_disk)(struct xfs_dir2_leaf *to,
80 struct xfs_dir3_icleaf_hdr *from);
81 void (*leaf_hdr_from_disk)(struct xfs_dir3_icleaf_hdr *to,
82 struct xfs_dir2_leaf *from);
79 int (*leaf_max_ents)(struct xfs_mount *mp); 83 int (*leaf_max_ents)(struct xfs_mount *mp);
80 struct xfs_dir2_leaf_entry * 84 struct xfs_dir2_leaf_entry *
81 (*leaf_ents_p)(struct xfs_dir2_leaf *lp); 85 (*leaf_ents_p)(struct xfs_dir2_leaf *lp);
82 86
83 int (*node_hdr_size)(void); 87 int (*node_hdr_size)(void);
88 void (*node_hdr_to_disk)(struct xfs_da_intnode *to,
89 struct xfs_da3_icnode_hdr *from);
90 void (*node_hdr_from_disk)(struct xfs_da3_icnode_hdr *to,
91 struct xfs_da_intnode *from);
84 struct xfs_da_node_entry * 92 struct xfs_da_node_entry *
85 (*node_tree_p)(struct xfs_da_intnode *dap); 93 (*node_tree_p)(struct xfs_da_intnode *dap);
94
95 void (*free_hdr_to_disk)(struct xfs_dir2_free *to,
96 struct xfs_dir3_icfree_hdr *from);
97 void (*free_hdr_from_disk)(struct xfs_dir3_icfree_hdr *to,
98 struct xfs_dir2_free *from);
86}; 99};
87 100
88extern const struct xfs_dir_ops * 101extern const struct xfs_dir_ops *
diff --git a/fs/xfs/xfs_dir2_block.c b/fs/xfs/xfs_dir2_block.c
index 75f815786b97..c1ff552aa7bf 100644
--- a/fs/xfs/xfs_dir2_block.c
+++ b/fs/xfs/xfs_dir2_block.c
@@ -936,7 +936,7 @@ xfs_dir2_leaf_to_block(
936 tp = args->trans; 936 tp = args->trans;
937 mp = dp->i_mount; 937 mp = dp->i_mount;
938 leaf = lbp->b_addr; 938 leaf = lbp->b_addr;
939 xfs_dir3_leaf_hdr_from_disk(&leafhdr, leaf); 939 dp->d_ops->leaf_hdr_from_disk(&leafhdr, leaf);
940 ents = dp->d_ops->leaf_ents_p(leaf); 940 ents = dp->d_ops->leaf_ents_p(leaf);
941 ltp = xfs_dir2_leaf_tail_p(mp, leaf); 941 ltp = xfs_dir2_leaf_tail_p(mp, leaf);
942 942
diff --git a/fs/xfs/xfs_dir2_leaf.c b/fs/xfs/xfs_dir2_leaf.c
index 16fdc0e627a7..2fb8db9fb574 100644
--- a/fs/xfs/xfs_dir2_leaf.c
+++ b/fs/xfs/xfs_dir2_leaf.c
@@ -64,7 +64,7 @@ xfs_dir3_leaf1_check(
64 struct xfs_dir2_leaf *leaf = bp->b_addr; 64 struct xfs_dir2_leaf *leaf = bp->b_addr;
65 struct xfs_dir3_icleaf_hdr leafhdr; 65 struct xfs_dir3_icleaf_hdr leafhdr;
66 66
67 xfs_dir3_leaf_hdr_from_disk(&leafhdr, leaf); 67 dp->d_ops->leaf_hdr_from_disk(&leafhdr, leaf);
68 68
69 if (leafhdr.magic == XFS_DIR3_LEAF1_MAGIC) { 69 if (leafhdr.magic == XFS_DIR3_LEAF1_MAGIC) {
70 struct xfs_dir3_leaf_hdr *leaf3 = bp->b_addr; 70 struct xfs_dir3_leaf_hdr *leaf3 = bp->b_addr;
@@ -79,62 +79,6 @@ xfs_dir3_leaf1_check(
79#define xfs_dir3_leaf_check(dp, bp) 79#define xfs_dir3_leaf_check(dp, bp)
80#endif 80#endif
81 81
82void
83xfs_dir3_leaf_hdr_from_disk(
84 struct xfs_dir3_icleaf_hdr *to,
85 struct xfs_dir2_leaf *from)
86{
87 if (from->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAF1_MAGIC) ||
88 from->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC)) {
89 to->forw = be32_to_cpu(from->hdr.info.forw);
90 to->back = be32_to_cpu(from->hdr.info.back);
91 to->magic = be16_to_cpu(from->hdr.info.magic);
92 to->count = be16_to_cpu(from->hdr.count);
93 to->stale = be16_to_cpu(from->hdr.stale);
94 } else {
95 struct xfs_dir3_leaf_hdr *hdr3 = (struct xfs_dir3_leaf_hdr *)from;
96
97 to->forw = be32_to_cpu(hdr3->info.hdr.forw);
98 to->back = be32_to_cpu(hdr3->info.hdr.back);
99 to->magic = be16_to_cpu(hdr3->info.hdr.magic);
100 to->count = be16_to_cpu(hdr3->count);
101 to->stale = be16_to_cpu(hdr3->stale);
102 }
103
104 ASSERT(to->magic == XFS_DIR2_LEAF1_MAGIC ||
105 to->magic == XFS_DIR3_LEAF1_MAGIC ||
106 to->magic == XFS_DIR2_LEAFN_MAGIC ||
107 to->magic == XFS_DIR3_LEAFN_MAGIC);
108}
109
110void
111xfs_dir3_leaf_hdr_to_disk(
112 struct xfs_dir2_leaf *to,
113 struct xfs_dir3_icleaf_hdr *from)
114{
115 ASSERT(from->magic == XFS_DIR2_LEAF1_MAGIC ||
116 from->magic == XFS_DIR3_LEAF1_MAGIC ||
117 from->magic == XFS_DIR2_LEAFN_MAGIC ||
118 from->magic == XFS_DIR3_LEAFN_MAGIC);
119
120 if (from->magic == XFS_DIR2_LEAF1_MAGIC ||
121 from->magic == XFS_DIR2_LEAFN_MAGIC) {
122 to->hdr.info.forw = cpu_to_be32(from->forw);
123 to->hdr.info.back = cpu_to_be32(from->back);
124 to->hdr.info.magic = cpu_to_be16(from->magic);
125 to->hdr.count = cpu_to_be16(from->count);
126 to->hdr.stale = cpu_to_be16(from->stale);
127 } else {
128 struct xfs_dir3_leaf_hdr *hdr3 = (struct xfs_dir3_leaf_hdr *)to;
129
130 hdr3->info.hdr.forw = cpu_to_be32(from->forw);
131 hdr3->info.hdr.back = cpu_to_be32(from->back);
132 hdr3->info.hdr.magic = cpu_to_be16(from->magic);
133 hdr3->count = cpu_to_be16(from->count);
134 hdr3->stale = cpu_to_be16(from->stale);
135 }
136}
137
138bool 82bool
139xfs_dir3_leaf_check_int( 83xfs_dir3_leaf_check_int(
140 struct xfs_mount *mp, 84 struct xfs_mount *mp,
@@ -147,6 +91,7 @@ xfs_dir3_leaf_check_int(
147 int stale; 91 int stale;
148 int i; 92 int i;
149 const struct xfs_dir_ops *ops; 93 const struct xfs_dir_ops *ops;
94 struct xfs_dir3_icleaf_hdr leafhdr;
150 95
151 /* 96 /*
152 * we can be passed a null dp here from a verifier, so we need to go the 97 * we can be passed a null dp here from a verifier, so we need to go the
@@ -154,6 +99,11 @@ xfs_dir3_leaf_check_int(
154 */ 99 */
155 ops = xfs_dir_get_ops(mp, dp); 100 ops = xfs_dir_get_ops(mp, dp);
156 101
102 if (!hdr) {
103 ops->leaf_hdr_from_disk(&leafhdr, leaf);
104 hdr = &leafhdr;
105 }
106
157 ents = ops->leaf_ents_p(leaf); 107 ents = ops->leaf_ents_p(leaf);
158 ltp = xfs_dir2_leaf_tail_p(mp, leaf); 108 ltp = xfs_dir2_leaf_tail_p(mp, leaf);
159 109
@@ -198,7 +148,6 @@ xfs_dir3_leaf_verify(
198{ 148{
199 struct xfs_mount *mp = bp->b_target->bt_mount; 149 struct xfs_mount *mp = bp->b_target->bt_mount;
200 struct xfs_dir2_leaf *leaf = bp->b_addr; 150 struct xfs_dir2_leaf *leaf = bp->b_addr;
201 struct xfs_dir3_icleaf_hdr leafhdr;
202 151
203 ASSERT(magic == XFS_DIR2_LEAF1_MAGIC || magic == XFS_DIR2_LEAFN_MAGIC); 152 ASSERT(magic == XFS_DIR2_LEAF1_MAGIC || magic == XFS_DIR2_LEAFN_MAGIC);
204 153
@@ -220,8 +169,7 @@ xfs_dir3_leaf_verify(
220 return false; 169 return false;
221 } 170 }
222 171
223 xfs_dir3_leaf_hdr_from_disk(&leafhdr, leaf); 172 return xfs_dir3_leaf_check_int(mp, NULL, NULL, leaf);
224 return xfs_dir3_leaf_check_int(mp, NULL, &leafhdr, leaf);
225} 173}
226 174
227static void 175static void
@@ -474,10 +422,10 @@ xfs_dir2_block_to_leaf(
474 /* 422 /*
475 * Set the counts in the leaf header. 423 * Set the counts in the leaf header.
476 */ 424 */
477 xfs_dir3_leaf_hdr_from_disk(&leafhdr, leaf); 425 dp->d_ops->leaf_hdr_from_disk(&leafhdr, leaf);
478 leafhdr.count = be32_to_cpu(btp->count); 426 leafhdr.count = be32_to_cpu(btp->count);
479 leafhdr.stale = be32_to_cpu(btp->stale); 427 leafhdr.stale = be32_to_cpu(btp->stale);
480 xfs_dir3_leaf_hdr_to_disk(leaf, &leafhdr); 428 dp->d_ops->leaf_hdr_to_disk(leaf, &leafhdr);
481 xfs_dir3_leaf_log_header(tp, dp, lbp); 429 xfs_dir3_leaf_log_header(tp, dp, lbp);
482 430
483 /* 431 /*
@@ -706,7 +654,7 @@ xfs_dir2_leaf_addname(
706 leaf = lbp->b_addr; 654 leaf = lbp->b_addr;
707 ltp = xfs_dir2_leaf_tail_p(mp, leaf); 655 ltp = xfs_dir2_leaf_tail_p(mp, leaf);
708 ents = dp->d_ops->leaf_ents_p(leaf); 656 ents = dp->d_ops->leaf_ents_p(leaf);
709 xfs_dir3_leaf_hdr_from_disk(&leafhdr, leaf); 657 dp->d_ops->leaf_hdr_from_disk(&leafhdr, leaf);
710 bestsp = xfs_dir2_leaf_bests_p(ltp); 658 bestsp = xfs_dir2_leaf_bests_p(ltp);
711 length = dp->d_ops->data_entsize(args->namelen); 659 length = dp->d_ops->data_entsize(args->namelen);
712 660
@@ -945,7 +893,7 @@ xfs_dir2_leaf_addname(
945 /* 893 /*
946 * Log the leaf fields and give up the buffers. 894 * Log the leaf fields and give up the buffers.
947 */ 895 */
948 xfs_dir3_leaf_hdr_to_disk(leaf, &leafhdr); 896 dp->d_ops->leaf_hdr_to_disk(leaf, &leafhdr);
949 xfs_dir3_leaf_log_header(tp, dp, lbp); 897 xfs_dir3_leaf_log_header(tp, dp, lbp);
950 xfs_dir3_leaf_log_ents(tp, dp, lbp, lfloglow, lfloghigh); 898 xfs_dir3_leaf_log_ents(tp, dp, lbp, lfloglow, lfloghigh);
951 xfs_dir3_leaf_check(dp, lbp); 899 xfs_dir3_leaf_check(dp, lbp);
@@ -968,6 +916,7 @@ xfs_dir3_leaf_compact(
968 int loglow; /* first leaf entry to log */ 916 int loglow; /* first leaf entry to log */
969 int to; /* target leaf index */ 917 int to; /* target leaf index */
970 struct xfs_dir2_leaf_entry *ents; 918 struct xfs_dir2_leaf_entry *ents;
919 struct xfs_inode *dp = args->dp;
971 920
972 leaf = bp->b_addr; 921 leaf = bp->b_addr;
973 if (!leafhdr->stale) 922 if (!leafhdr->stale)
@@ -976,7 +925,7 @@ xfs_dir3_leaf_compact(
976 /* 925 /*
977 * Compress out the stale entries in place. 926 * Compress out the stale entries in place.
978 */ 927 */
979 ents = args->dp->d_ops->leaf_ents_p(leaf); 928 ents = dp->d_ops->leaf_ents_p(leaf);
980 for (from = to = 0, loglow = -1; from < leafhdr->count; from++) { 929 for (from = to = 0, loglow = -1; from < leafhdr->count; from++) {
981 if (ents[from].address == cpu_to_be32(XFS_DIR2_NULL_DATAPTR)) 930 if (ents[from].address == cpu_to_be32(XFS_DIR2_NULL_DATAPTR))
982 continue; 931 continue;
@@ -997,11 +946,10 @@ xfs_dir3_leaf_compact(
997 leafhdr->count -= leafhdr->stale; 946 leafhdr->count -= leafhdr->stale;
998 leafhdr->stale = 0; 947 leafhdr->stale = 0;
999 948
1000 xfs_dir3_leaf_hdr_to_disk(leaf, leafhdr); 949 dp->d_ops->leaf_hdr_to_disk(leaf, leafhdr);
1001 xfs_dir3_leaf_log_header(args->trans, args->dp, bp); 950 xfs_dir3_leaf_log_header(args->trans, dp, bp);
1002 if (loglow != -1) 951 if (loglow != -1)
1003 xfs_dir3_leaf_log_ents(args->trans, args->dp, bp, 952 xfs_dir3_leaf_log_ents(args->trans, dp, bp, loglow, to - 1);
1004 loglow, to - 1);
1005} 953}
1006 954
1007/* 955/*
@@ -1290,7 +1238,7 @@ xfs_dir2_leaf_lookup_int(
1290 leaf = lbp->b_addr; 1238 leaf = lbp->b_addr;
1291 xfs_dir3_leaf_check(dp, lbp); 1239 xfs_dir3_leaf_check(dp, lbp);
1292 ents = dp->d_ops->leaf_ents_p(leaf); 1240 ents = dp->d_ops->leaf_ents_p(leaf);
1293 xfs_dir3_leaf_hdr_from_disk(&leafhdr, leaf); 1241 dp->d_ops->leaf_hdr_from_disk(&leafhdr, leaf);
1294 1242
1295 /* 1243 /*
1296 * Look for the first leaf entry with our hash value. 1244 * Look for the first leaf entry with our hash value.
@@ -1425,7 +1373,7 @@ xfs_dir2_leaf_removename(
1425 hdr = dbp->b_addr; 1373 hdr = dbp->b_addr;
1426 xfs_dir3_data_check(dp, dbp); 1374 xfs_dir3_data_check(dp, dbp);
1427 bf = dp->d_ops->data_bestfree_p(hdr); 1375 bf = dp->d_ops->data_bestfree_p(hdr);
1428 xfs_dir3_leaf_hdr_from_disk(&leafhdr, leaf); 1376 dp->d_ops->leaf_hdr_from_disk(&leafhdr, leaf);
1429 ents = dp->d_ops->leaf_ents_p(leaf); 1377 ents = dp->d_ops->leaf_ents_p(leaf);
1430 /* 1378 /*
1431 * Point to the leaf entry, use that to point to the data entry. 1379 * Point to the leaf entry, use that to point to the data entry.
@@ -1449,7 +1397,7 @@ xfs_dir2_leaf_removename(
1449 * We just mark the leaf entry stale by putting a null in it. 1397 * We just mark the leaf entry stale by putting a null in it.
1450 */ 1398 */
1451 leafhdr.stale++; 1399 leafhdr.stale++;
1452 xfs_dir3_leaf_hdr_to_disk(leaf, &leafhdr); 1400 dp->d_ops->leaf_hdr_to_disk(leaf, &leafhdr);
1453 xfs_dir3_leaf_log_header(tp, dp, lbp); 1401 xfs_dir3_leaf_log_header(tp, dp, lbp);
1454 1402
1455 lep->address = cpu_to_be32(XFS_DIR2_NULL_DATAPTR); 1403 lep->address = cpu_to_be32(XFS_DIR2_NULL_DATAPTR);
@@ -1602,7 +1550,7 @@ xfs_dir2_leaf_search_hash(
1602 1550
1603 leaf = lbp->b_addr; 1551 leaf = lbp->b_addr;
1604 ents = args->dp->d_ops->leaf_ents_p(leaf); 1552 ents = args->dp->d_ops->leaf_ents_p(leaf);
1605 xfs_dir3_leaf_hdr_from_disk(&leafhdr, leaf); 1553 args->dp->d_ops->leaf_hdr_from_disk(&leafhdr, leaf);
1606 1554
1607 /* 1555 /*
1608 * Note, the table cannot be empty, so we have to go through the loop. 1556 * Note, the table cannot be empty, so we have to go through the loop.
@@ -1791,7 +1739,7 @@ xfs_dir2_node_to_leaf(
1791 return 0; 1739 return 0;
1792 lbp = state->path.blk[0].bp; 1740 lbp = state->path.blk[0].bp;
1793 leaf = lbp->b_addr; 1741 leaf = lbp->b_addr;
1794 xfs_dir3_leaf_hdr_from_disk(&leafhdr, leaf); 1742 dp->d_ops->leaf_hdr_from_disk(&leafhdr, leaf);
1795 1743
1796 ASSERT(leafhdr.magic == XFS_DIR2_LEAFN_MAGIC || 1744 ASSERT(leafhdr.magic == XFS_DIR2_LEAFN_MAGIC ||
1797 leafhdr.magic == XFS_DIR3_LEAFN_MAGIC); 1745 leafhdr.magic == XFS_DIR3_LEAFN_MAGIC);
@@ -1803,7 +1751,7 @@ xfs_dir2_node_to_leaf(
1803 if (error) 1751 if (error)
1804 return error; 1752 return error;
1805 free = fbp->b_addr; 1753 free = fbp->b_addr;
1806 xfs_dir3_free_hdr_from_disk(&freehdr, free); 1754 dp->d_ops->free_hdr_from_disk(&freehdr, free);
1807 1755
1808 ASSERT(!freehdr.firstdb); 1756 ASSERT(!freehdr.firstdb);
1809 1757
@@ -1840,7 +1788,7 @@ xfs_dir2_node_to_leaf(
1840 memcpy(xfs_dir2_leaf_bests_p(ltp), xfs_dir3_free_bests_p(mp, free), 1788 memcpy(xfs_dir2_leaf_bests_p(ltp), xfs_dir3_free_bests_p(mp, free),
1841 freehdr.nvalid * sizeof(xfs_dir2_data_off_t)); 1789 freehdr.nvalid * sizeof(xfs_dir2_data_off_t));
1842 1790
1843 xfs_dir3_leaf_hdr_to_disk(leaf, &leafhdr); 1791 dp->d_ops->leaf_hdr_to_disk(leaf, &leafhdr);
1844 xfs_dir3_leaf_log_header(tp, dp, lbp); 1792 xfs_dir3_leaf_log_header(tp, dp, lbp);
1845 xfs_dir3_leaf_log_bests(tp, lbp, 0, be32_to_cpu(ltp->bestcount) - 1); 1793 xfs_dir3_leaf_log_bests(tp, lbp, 0, be32_to_cpu(ltp->bestcount) - 1);
1846 xfs_dir3_leaf_log_tail(tp, lbp); 1794 xfs_dir3_leaf_log_tail(tp, lbp);
diff --git a/fs/xfs/xfs_dir2_node.c b/fs/xfs/xfs_dir2_node.c
index 3a426ed9b16e..eaee8c36bcc4 100644
--- a/fs/xfs/xfs_dir2_node.c
+++ b/fs/xfs/xfs_dir2_node.c
@@ -68,7 +68,7 @@ xfs_dir3_leafn_check(
68 struct xfs_dir2_leaf *leaf = bp->b_addr; 68 struct xfs_dir2_leaf *leaf = bp->b_addr;
69 struct xfs_dir3_icleaf_hdr leafhdr; 69 struct xfs_dir3_icleaf_hdr leafhdr;
70 70
71 xfs_dir3_leaf_hdr_from_disk(&leafhdr, leaf); 71 dp->d_ops->leaf_hdr_from_disk(&leafhdr, leaf);
72 72
73 if (leafhdr.magic == XFS_DIR3_LEAFN_MAGIC) { 73 if (leafhdr.magic == XFS_DIR3_LEAFN_MAGIC) {
74 struct xfs_dir3_leaf_hdr *leaf3 = bp->b_addr; 74 struct xfs_dir3_leaf_hdr *leaf3 = bp->b_addr;
@@ -192,53 +192,6 @@ xfs_dir2_free_try_read(
192 return __xfs_dir3_free_read(tp, dp, fbno, -2, bpp); 192 return __xfs_dir3_free_read(tp, dp, fbno, -2, bpp);
193} 193}
194 194
195
196void
197xfs_dir3_free_hdr_from_disk(
198 struct xfs_dir3_icfree_hdr *to,
199 struct xfs_dir2_free *from)
200{
201 if (from->hdr.magic == cpu_to_be32(XFS_DIR2_FREE_MAGIC)) {
202 to->magic = be32_to_cpu(from->hdr.magic);
203 to->firstdb = be32_to_cpu(from->hdr.firstdb);
204 to->nvalid = be32_to_cpu(from->hdr.nvalid);
205 to->nused = be32_to_cpu(from->hdr.nused);
206 } else {
207 struct xfs_dir3_free_hdr *hdr3 = (struct xfs_dir3_free_hdr *)from;
208
209 to->magic = be32_to_cpu(hdr3->hdr.magic);
210 to->firstdb = be32_to_cpu(hdr3->firstdb);
211 to->nvalid = be32_to_cpu(hdr3->nvalid);
212 to->nused = be32_to_cpu(hdr3->nused);
213 }
214
215 ASSERT(to->magic == XFS_DIR2_FREE_MAGIC ||
216 to->magic == XFS_DIR3_FREE_MAGIC);
217}
218
219static void
220xfs_dir3_free_hdr_to_disk(
221 struct xfs_dir2_free *to,
222 struct xfs_dir3_icfree_hdr *from)
223{
224 ASSERT(from->magic == XFS_DIR2_FREE_MAGIC ||
225 from->magic == XFS_DIR3_FREE_MAGIC);
226
227 if (from->magic == XFS_DIR2_FREE_MAGIC) {
228 to->hdr.magic = cpu_to_be32(from->magic);
229 to->hdr.firstdb = cpu_to_be32(from->firstdb);
230 to->hdr.nvalid = cpu_to_be32(from->nvalid);
231 to->hdr.nused = cpu_to_be32(from->nused);
232 } else {
233 struct xfs_dir3_free_hdr *hdr3 = (struct xfs_dir3_free_hdr *)to;
234
235 hdr3->hdr.magic = cpu_to_be32(from->magic);
236 hdr3->firstdb = cpu_to_be32(from->firstdb);
237 hdr3->nvalid = cpu_to_be32(from->nvalid);
238 hdr3->nused = cpu_to_be32(from->nused);
239 }
240}
241
242static int 195static int
243xfs_dir3_free_get_buf( 196xfs_dir3_free_get_buf(
244 struct xfs_trans *tp, 197 struct xfs_trans *tp,
@@ -276,7 +229,7 @@ xfs_dir3_free_get_buf(
276 uuid_copy(&hdr3->hdr.uuid, &mp->m_sb.sb_uuid); 229 uuid_copy(&hdr3->hdr.uuid, &mp->m_sb.sb_uuid);
277 } else 230 } else
278 hdr.magic = XFS_DIR2_FREE_MAGIC; 231 hdr.magic = XFS_DIR2_FREE_MAGIC;
279 xfs_dir3_free_hdr_to_disk(bp->b_addr, &hdr); 232 dp->d_ops->free_hdr_to_disk(bp->b_addr, &hdr);
280 *bpp = bp; 233 *bpp = bp;
281 return 0; 234 return 0;
282} 235}
@@ -368,7 +321,7 @@ xfs_dir2_leaf_to_node(
368 return error; 321 return error;
369 322
370 free = fbp->b_addr; 323 free = fbp->b_addr;
371 xfs_dir3_free_hdr_from_disk(&freehdr, free); 324 dp->d_ops->free_hdr_from_disk(&freehdr, free);
372 leaf = lbp->b_addr; 325 leaf = lbp->b_addr;
373 ltp = xfs_dir2_leaf_tail_p(mp, leaf); 326 ltp = xfs_dir2_leaf_tail_p(mp, leaf);
374 ASSERT(be32_to_cpu(ltp->bestcount) <= 327 ASSERT(be32_to_cpu(ltp->bestcount) <=
@@ -392,7 +345,7 @@ xfs_dir2_leaf_to_node(
392 freehdr.nused = n; 345 freehdr.nused = n;
393 freehdr.nvalid = be32_to_cpu(ltp->bestcount); 346 freehdr.nvalid = be32_to_cpu(ltp->bestcount);
394 347
395 xfs_dir3_free_hdr_to_disk(fbp->b_addr, &freehdr); 348 dp->d_ops->free_hdr_to_disk(fbp->b_addr, &freehdr);
396 xfs_dir2_free_log_bests(tp, fbp, 0, freehdr.nvalid - 1); 349 xfs_dir2_free_log_bests(tp, fbp, 0, freehdr.nvalid - 1);
397 xfs_dir2_free_log_header(tp, fbp); 350 xfs_dir2_free_log_header(tp, fbp);
398 351
@@ -442,7 +395,7 @@ xfs_dir2_leafn_add(
442 mp = dp->i_mount; 395 mp = dp->i_mount;
443 tp = args->trans; 396 tp = args->trans;
444 leaf = bp->b_addr; 397 leaf = bp->b_addr;
445 xfs_dir3_leaf_hdr_from_disk(&leafhdr, leaf); 398 dp->d_ops->leaf_hdr_from_disk(&leafhdr, leaf);
446 ents = dp->d_ops->leaf_ents_p(leaf); 399 ents = dp->d_ops->leaf_ents_p(leaf);
447 400
448 /* 401 /*
@@ -497,7 +450,7 @@ xfs_dir2_leafn_add(
497 lep->address = cpu_to_be32(xfs_dir2_db_off_to_dataptr(mp, 450 lep->address = cpu_to_be32(xfs_dir2_db_off_to_dataptr(mp,
498 args->blkno, args->index)); 451 args->blkno, args->index));
499 452
500 xfs_dir3_leaf_hdr_to_disk(leaf, &leafhdr); 453 dp->d_ops->leaf_hdr_to_disk(leaf, &leafhdr);
501 xfs_dir3_leaf_log_header(tp, dp, bp); 454 xfs_dir3_leaf_log_header(tp, dp, bp);
502 xfs_dir3_leaf_log_ents(tp, dp, bp, lfloglow, lfloghigh); 455 xfs_dir3_leaf_log_ents(tp, dp, bp, lfloglow, lfloghigh);
503 xfs_dir3_leaf_check(dp, bp); 456 xfs_dir3_leaf_check(dp, bp);
@@ -507,20 +460,20 @@ xfs_dir2_leafn_add(
507#ifdef DEBUG 460#ifdef DEBUG
508static void 461static void
509xfs_dir2_free_hdr_check( 462xfs_dir2_free_hdr_check(
510 struct xfs_mount *mp, 463 struct xfs_inode *dp,
511 struct xfs_buf *bp, 464 struct xfs_buf *bp,
512 xfs_dir2_db_t db) 465 xfs_dir2_db_t db)
513{ 466{
514 struct xfs_dir3_icfree_hdr hdr; 467 struct xfs_dir3_icfree_hdr hdr;
515 468
516 xfs_dir3_free_hdr_from_disk(&hdr, bp->b_addr); 469 dp->d_ops->free_hdr_from_disk(&hdr, bp->b_addr);
517 470
518 ASSERT((hdr.firstdb % xfs_dir3_free_max_bests(mp)) == 0); 471 ASSERT((hdr.firstdb % xfs_dir3_free_max_bests(dp->i_mount)) == 0);
519 ASSERT(hdr.firstdb <= db); 472 ASSERT(hdr.firstdb <= db);
520 ASSERT(db < hdr.firstdb + hdr.nvalid); 473 ASSERT(db < hdr.firstdb + hdr.nvalid);
521} 474}
522#else 475#else
523#define xfs_dir2_free_hdr_check(mp, dp, db) 476#define xfs_dir2_free_hdr_check(dp, bp, db)
524#endif /* DEBUG */ 477#endif /* DEBUG */
525 478
526/* 479/*
@@ -537,7 +490,7 @@ xfs_dir2_leafn_lasthash(
537 struct xfs_dir2_leaf_entry *ents; 490 struct xfs_dir2_leaf_entry *ents;
538 struct xfs_dir3_icleaf_hdr leafhdr; 491 struct xfs_dir3_icleaf_hdr leafhdr;
539 492
540 xfs_dir3_leaf_hdr_from_disk(&leafhdr, leaf); 493 dp->d_ops->leaf_hdr_from_disk(&leafhdr, leaf);
541 494
542 ASSERT(leafhdr.magic == XFS_DIR2_LEAFN_MAGIC || 495 ASSERT(leafhdr.magic == XFS_DIR2_LEAFN_MAGIC ||
543 leafhdr.magic == XFS_DIR3_LEAFN_MAGIC); 496 leafhdr.magic == XFS_DIR3_LEAFN_MAGIC);
@@ -584,7 +537,7 @@ xfs_dir2_leafn_lookup_for_addname(
584 tp = args->trans; 537 tp = args->trans;
585 mp = dp->i_mount; 538 mp = dp->i_mount;
586 leaf = bp->b_addr; 539 leaf = bp->b_addr;
587 xfs_dir3_leaf_hdr_from_disk(&leafhdr, leaf); 540 dp->d_ops->leaf_hdr_from_disk(&leafhdr, leaf);
588 ents = dp->d_ops->leaf_ents_p(leaf); 541 ents = dp->d_ops->leaf_ents_p(leaf);
589 542
590 xfs_dir3_leaf_check(dp, bp); 543 xfs_dir3_leaf_check(dp, bp);
@@ -655,7 +608,7 @@ xfs_dir2_leafn_lookup_for_addname(
655 return error; 608 return error;
656 free = curbp->b_addr; 609 free = curbp->b_addr;
657 610
658 xfs_dir2_free_hdr_check(mp, curbp, curdb); 611 xfs_dir2_free_hdr_check(dp, curbp, curdb);
659 } 612 }
660 /* 613 /*
661 * Get the index for our entry. 614 * Get the index for our entry.
@@ -734,7 +687,7 @@ xfs_dir2_leafn_lookup_for_entry(
734 tp = args->trans; 687 tp = args->trans;
735 mp = dp->i_mount; 688 mp = dp->i_mount;
736 leaf = bp->b_addr; 689 leaf = bp->b_addr;
737 xfs_dir3_leaf_hdr_from_disk(&leafhdr, leaf); 690 dp->d_ops->leaf_hdr_from_disk(&leafhdr, leaf);
738 ents = dp->d_ops->leaf_ents_p(leaf); 691 ents = dp->d_ops->leaf_ents_p(leaf);
739 692
740 xfs_dir3_leaf_check(dp, bp); 693 xfs_dir3_leaf_check(dp, bp);
@@ -969,8 +922,8 @@ xfs_dir2_leafn_order(
969 struct xfs_dir3_icleaf_hdr hdr1; 922 struct xfs_dir3_icleaf_hdr hdr1;
970 struct xfs_dir3_icleaf_hdr hdr2; 923 struct xfs_dir3_icleaf_hdr hdr2;
971 924
972 xfs_dir3_leaf_hdr_from_disk(&hdr1, leaf1); 925 dp->d_ops->leaf_hdr_from_disk(&hdr1, leaf1);
973 xfs_dir3_leaf_hdr_from_disk(&hdr2, leaf2); 926 dp->d_ops->leaf_hdr_from_disk(&hdr2, leaf2);
974 ents1 = dp->d_ops->leaf_ents_p(leaf1); 927 ents1 = dp->d_ops->leaf_ents_p(leaf1);
975 ents2 = dp->d_ops->leaf_ents_p(leaf2); 928 ents2 = dp->d_ops->leaf_ents_p(leaf2);
976 929
@@ -1025,8 +978,8 @@ xfs_dir2_leafn_rebalance(
1025 } 978 }
1026 leaf1 = blk1->bp->b_addr; 979 leaf1 = blk1->bp->b_addr;
1027 leaf2 = blk2->bp->b_addr; 980 leaf2 = blk2->bp->b_addr;
1028 xfs_dir3_leaf_hdr_from_disk(&hdr1, leaf1); 981 dp->d_ops->leaf_hdr_from_disk(&hdr1, leaf1);
1029 xfs_dir3_leaf_hdr_from_disk(&hdr2, leaf2); 982 dp->d_ops->leaf_hdr_from_disk(&hdr2, leaf2);
1030 ents1 = dp->d_ops->leaf_ents_p(leaf1); 983 ents1 = dp->d_ops->leaf_ents_p(leaf1);
1031 ents2 = dp->d_ops->leaf_ents_p(leaf2); 984 ents2 = dp->d_ops->leaf_ents_p(leaf2);
1032 985
@@ -1074,8 +1027,8 @@ xfs_dir2_leafn_rebalance(
1074 ASSERT(hdr1.stale + hdr2.stale == oldstale); 1027 ASSERT(hdr1.stale + hdr2.stale == oldstale);
1075 1028
1076 /* log the changes made when moving the entries */ 1029 /* log the changes made when moving the entries */
1077 xfs_dir3_leaf_hdr_to_disk(leaf1, &hdr1); 1030 dp->d_ops->leaf_hdr_to_disk(leaf1, &hdr1);
1078 xfs_dir3_leaf_hdr_to_disk(leaf2, &hdr2); 1031 dp->d_ops->leaf_hdr_to_disk(leaf2, &hdr2);
1079 xfs_dir3_leaf_log_header(args->trans, dp, blk1->bp); 1032 xfs_dir3_leaf_log_header(args->trans, dp, blk1->bp);
1080 xfs_dir3_leaf_log_header(args->trans, dp, blk2->bp); 1033 xfs_dir3_leaf_log_header(args->trans, dp, blk2->bp);
1081 1034
@@ -1124,8 +1077,9 @@ xfs_dir3_data_block_free(
1124 int logfree = 0; 1077 int logfree = 0;
1125 __be16 *bests; 1078 __be16 *bests;
1126 struct xfs_dir3_icfree_hdr freehdr; 1079 struct xfs_dir3_icfree_hdr freehdr;
1080 struct xfs_inode *dp = args->dp;
1127 1081
1128 xfs_dir3_free_hdr_from_disk(&freehdr, free); 1082 dp->d_ops->free_hdr_from_disk(&freehdr, free);
1129 1083
1130 bests = xfs_dir3_free_bests_p(tp->t_mountp, free); 1084 bests = xfs_dir3_free_bests_p(tp->t_mountp, free);
1131 if (hdr) { 1085 if (hdr) {
@@ -1161,7 +1115,7 @@ xfs_dir3_data_block_free(
1161 logfree = 1; 1115 logfree = 1;
1162 } 1116 }
1163 1117
1164 xfs_dir3_free_hdr_to_disk(free, &freehdr); 1118 dp->d_ops->free_hdr_to_disk(free, &freehdr);
1165 xfs_dir2_free_log_header(tp, fbp); 1119 xfs_dir2_free_log_header(tp, fbp);
1166 1120
1167 /* 1121 /*
@@ -1226,7 +1180,7 @@ xfs_dir2_leafn_remove(
1226 tp = args->trans; 1180 tp = args->trans;
1227 mp = dp->i_mount; 1181 mp = dp->i_mount;
1228 leaf = bp->b_addr; 1182 leaf = bp->b_addr;
1229 xfs_dir3_leaf_hdr_from_disk(&leafhdr, leaf); 1183 dp->d_ops->leaf_hdr_from_disk(&leafhdr, leaf);
1230 ents = dp->d_ops->leaf_ents_p(leaf); 1184 ents = dp->d_ops->leaf_ents_p(leaf);
1231 1185
1232 /* 1186 /*
@@ -1247,7 +1201,7 @@ xfs_dir2_leafn_remove(
1247 * Log the leaf block changes. 1201 * Log the leaf block changes.
1248 */ 1202 */
1249 leafhdr.stale++; 1203 leafhdr.stale++;
1250 xfs_dir3_leaf_hdr_to_disk(leaf, &leafhdr); 1204 dp->d_ops->leaf_hdr_to_disk(leaf, &leafhdr);
1251 xfs_dir3_leaf_log_header(tp, dp, bp); 1205 xfs_dir3_leaf_log_header(tp, dp, bp);
1252 1206
1253 lep->address = cpu_to_be32(XFS_DIR2_NULL_DATAPTR); 1207 lep->address = cpu_to_be32(XFS_DIR2_NULL_DATAPTR);
@@ -1298,7 +1252,7 @@ xfs_dir2_leafn_remove(
1298#ifdef DEBUG 1252#ifdef DEBUG
1299 { 1253 {
1300 struct xfs_dir3_icfree_hdr freehdr; 1254 struct xfs_dir3_icfree_hdr freehdr;
1301 xfs_dir3_free_hdr_from_disk(&freehdr, free); 1255 dp->d_ops->free_hdr_from_disk(&freehdr, free);
1302 ASSERT(freehdr.firstdb == xfs_dir3_free_max_bests(mp) * 1256 ASSERT(freehdr.firstdb == xfs_dir3_free_max_bests(mp) *
1303 (fdb - XFS_DIR2_FREE_FIRSTDB(mp))); 1257 (fdb - XFS_DIR2_FREE_FIRSTDB(mp)));
1304 } 1258 }
@@ -1449,7 +1403,7 @@ xfs_dir2_leafn_toosmall(
1449 */ 1403 */
1450 blk = &state->path.blk[state->path.active - 1]; 1404 blk = &state->path.blk[state->path.active - 1];
1451 leaf = blk->bp->b_addr; 1405 leaf = blk->bp->b_addr;
1452 xfs_dir3_leaf_hdr_from_disk(&leafhdr, leaf); 1406 dp->d_ops->leaf_hdr_from_disk(&leafhdr, leaf);
1453 ents = dp->d_ops->leaf_ents_p(leaf); 1407 ents = dp->d_ops->leaf_ents_p(leaf);
1454 xfs_dir3_leaf_check(dp, blk->bp); 1408 xfs_dir3_leaf_check(dp, blk->bp);
1455 1409
@@ -1511,7 +1465,7 @@ xfs_dir2_leafn_toosmall(
1511 bytes = state->blocksize - (state->blocksize >> 2); 1465 bytes = state->blocksize - (state->blocksize >> 2);
1512 1466
1513 leaf = bp->b_addr; 1467 leaf = bp->b_addr;
1514 xfs_dir3_leaf_hdr_from_disk(&hdr2, leaf); 1468 dp->d_ops->leaf_hdr_from_disk(&hdr2, leaf);
1515 ents = dp->d_ops->leaf_ents_p(leaf); 1469 ents = dp->d_ops->leaf_ents_p(leaf);
1516 count += hdr2.count - hdr2.stale; 1470 count += hdr2.count - hdr2.stale;
1517 bytes -= count * sizeof(ents[0]); 1471 bytes -= count * sizeof(ents[0]);
@@ -1574,10 +1528,10 @@ xfs_dir2_leafn_unbalance(
1574 drop_leaf = drop_blk->bp->b_addr; 1528 drop_leaf = drop_blk->bp->b_addr;
1575 save_leaf = save_blk->bp->b_addr; 1529 save_leaf = save_blk->bp->b_addr;
1576 1530
1577 xfs_dir3_leaf_hdr_from_disk(&savehdr, save_leaf); 1531 dp->d_ops->leaf_hdr_from_disk(&savehdr, save_leaf);
1578 xfs_dir3_leaf_hdr_from_disk(&drophdr, drop_leaf); 1532 dp->d_ops->leaf_hdr_from_disk(&drophdr, drop_leaf);
1579 sents = args->dp->d_ops->leaf_ents_p(save_leaf); 1533 sents = dp->d_ops->leaf_ents_p(save_leaf);
1580 dents = args->dp->d_ops->leaf_ents_p(drop_leaf); 1534 dents = dp->d_ops->leaf_ents_p(drop_leaf);
1581 1535
1582 /* 1536 /*
1583 * If there are any stale leaf entries, take this opportunity 1537 * If there are any stale leaf entries, take this opportunity
@@ -1603,8 +1557,8 @@ xfs_dir2_leafn_unbalance(
1603 save_blk->hashval = be32_to_cpu(sents[savehdr.count - 1].hashval); 1557 save_blk->hashval = be32_to_cpu(sents[savehdr.count - 1].hashval);
1604 1558
1605 /* log the changes made when moving the entries */ 1559 /* log the changes made when moving the entries */
1606 xfs_dir3_leaf_hdr_to_disk(save_leaf, &savehdr); 1560 dp->d_ops->leaf_hdr_to_disk(save_leaf, &savehdr);
1607 xfs_dir3_leaf_hdr_to_disk(drop_leaf, &drophdr); 1561 dp->d_ops->leaf_hdr_to_disk(drop_leaf, &drophdr);
1608 xfs_dir3_leaf_log_header(args->trans, dp, save_blk->bp); 1562 xfs_dir3_leaf_log_header(args->trans, dp, save_blk->bp);
1609 xfs_dir3_leaf_log_header(args->trans, dp, drop_blk->bp); 1563 xfs_dir3_leaf_log_header(args->trans, dp, drop_blk->bp);
1610 1564
@@ -1735,7 +1689,7 @@ xfs_dir2_node_addname_int(
1735 free = fbp->b_addr; 1689 free = fbp->b_addr;
1736 findex = fblk->index; 1690 findex = fblk->index;
1737 bests = xfs_dir3_free_bests_p(mp, free); 1691 bests = xfs_dir3_free_bests_p(mp, free);
1738 xfs_dir3_free_hdr_from_disk(&freehdr, free); 1692 dp->d_ops->free_hdr_from_disk(&freehdr, free);
1739 1693
1740 /* 1694 /*
1741 * This means the free entry showed that the data block had 1695 * This means the free entry showed that the data block had
@@ -1828,7 +1782,7 @@ xfs_dir2_node_addname_int(
1828 * there, so we have to do it here to avoid warnings. Blech. 1782 * there, so we have to do it here to avoid warnings. Blech.
1829 */ 1783 */
1830 bests = xfs_dir3_free_bests_p(mp, free); 1784 bests = xfs_dir3_free_bests_p(mp, free);
1831 xfs_dir3_free_hdr_from_disk(&freehdr, free); 1785 dp->d_ops->free_hdr_from_disk(&freehdr, free);
1832 if (be16_to_cpu(bests[findex]) != NULLDATAOFF && 1786 if (be16_to_cpu(bests[findex]) != NULLDATAOFF &&
1833 be16_to_cpu(bests[findex]) >= length) 1787 be16_to_cpu(bests[findex]) >= length)
1834 dbno = freehdr.firstdb + findex; 1788 dbno = freehdr.firstdb + findex;
@@ -1927,7 +1881,7 @@ xfs_dir2_node_addname_int(
1927 return error; 1881 return error;
1928 free = fbp->b_addr; 1882 free = fbp->b_addr;
1929 bests = xfs_dir3_free_bests_p(mp, free); 1883 bests = xfs_dir3_free_bests_p(mp, free);
1930 xfs_dir3_free_hdr_from_disk(&freehdr, free); 1884 dp->d_ops->free_hdr_from_disk(&freehdr, free);
1931 1885
1932 /* 1886 /*
1933 * Remember the first slot as our empty slot. 1887 * Remember the first slot as our empty slot.
@@ -1937,7 +1891,7 @@ xfs_dir2_node_addname_int(
1937 } else { 1891 } else {
1938 free = fbp->b_addr; 1892 free = fbp->b_addr;
1939 bests = xfs_dir3_free_bests_p(mp, free); 1893 bests = xfs_dir3_free_bests_p(mp, free);
1940 xfs_dir3_free_hdr_from_disk(&freehdr, free); 1894 dp->d_ops->free_hdr_from_disk(&freehdr, free);
1941 } 1895 }
1942 1896
1943 /* 1897 /*
@@ -1962,7 +1916,7 @@ xfs_dir2_node_addname_int(
1962 */ 1916 */
1963 if (bests[findex] == cpu_to_be16(NULLDATAOFF)) { 1917 if (bests[findex] == cpu_to_be16(NULLDATAOFF)) {
1964 freehdr.nused++; 1918 freehdr.nused++;
1965 xfs_dir3_free_hdr_to_disk(fbp->b_addr, &freehdr); 1919 dp->d_ops->free_hdr_to_disk(fbp->b_addr, &freehdr);
1966 xfs_dir2_free_log_header(tp, fbp); 1920 xfs_dir2_free_log_header(tp, fbp);
1967 } 1921 }
1968 /* 1922 /*
@@ -2294,7 +2248,7 @@ xfs_dir2_node_trim_free(
2294 if (!bp) 2248 if (!bp)
2295 return 0; 2249 return 0;
2296 free = bp->b_addr; 2250 free = bp->b_addr;
2297 xfs_dir3_free_hdr_from_disk(&freehdr, free); 2251 dp->d_ops->free_hdr_from_disk(&freehdr, free);
2298 2252
2299 /* 2253 /*
2300 * If there are used entries, there's nothing to do. 2254 * If there are used entries, there's nothing to do.
diff --git a/fs/xfs/xfs_dir2_priv.h b/fs/xfs/xfs_dir2_priv.h
index 3e4b5ba7b41f..8b9d2281f85b 100644
--- a/fs/xfs/xfs_dir2_priv.h
+++ b/fs/xfs/xfs_dir2_priv.h
@@ -94,10 +94,6 @@ xfs_dir3_leaf_find_entry(struct xfs_dir3_icleaf_hdr *leafhdr,
94 int lowstale, int highstale, int *lfloglow, int *lfloghigh); 94 int lowstale, int highstale, int *lfloglow, int *lfloghigh);
95extern int xfs_dir2_node_to_leaf(struct xfs_da_state *state); 95extern int xfs_dir2_node_to_leaf(struct xfs_da_state *state);
96 96
97extern void xfs_dir3_leaf_hdr_from_disk(struct xfs_dir3_icleaf_hdr *to,
98 struct xfs_dir2_leaf *from);
99extern void xfs_dir3_leaf_hdr_to_disk(struct xfs_dir2_leaf *to,
100 struct xfs_dir3_icleaf_hdr *from);
101extern bool xfs_dir3_leaf_check_int(struct xfs_mount *mp, struct xfs_inode *dp, 97extern bool xfs_dir3_leaf_check_int(struct xfs_mount *mp, struct xfs_inode *dp,
102 struct xfs_dir3_icleaf_hdr *hdr, struct xfs_dir2_leaf *leaf); 98 struct xfs_dir3_icleaf_hdr *hdr, struct xfs_dir2_leaf *leaf);
103 99