diff options
author | Nathan Scott <nathans@sgi.com> | 2006-06-19 23:04:51 -0400 |
---|---|---|
committer | Nathan Scott <nathans@sgi.com> | 2006-06-19 23:04:51 -0400 |
commit | f6c2d1fa6310a71b1c2e05fc6d9ff9b91489fa0e (patch) | |
tree | 8541585188bfb903fc5198ea349122bf52d8ec96 /fs/xfs/xfs_da_btree.c | |
parent | da2f4d679c8070ba5b6a920281e495917b293aa0 (diff) |
[XFS] Remove version 1 directory code. Never functioned on Linux, just
pure bloat.
SGI-PV: 952969
SGI-Modid: xfs-linux-melb:xfs-kern:26251a
Signed-off-by: Nathan Scott <nathans@sgi.com>
Diffstat (limited to 'fs/xfs/xfs_da_btree.c')
-rw-r--r-- | fs/xfs/xfs_da_btree.c | 185 |
1 files changed, 28 insertions, 157 deletions
diff --git a/fs/xfs/xfs_da_btree.c b/fs/xfs/xfs_da_btree.c index 260c3d770c02..32ab61d17ace 100644 --- a/fs/xfs/xfs_da_btree.c +++ b/fs/xfs/xfs_da_btree.c | |||
@@ -24,7 +24,6 @@ | |||
24 | #include "xfs_trans.h" | 24 | #include "xfs_trans.h" |
25 | #include "xfs_sb.h" | 25 | #include "xfs_sb.h" |
26 | #include "xfs_ag.h" | 26 | #include "xfs_ag.h" |
27 | #include "xfs_dir.h" | ||
28 | #include "xfs_dir2.h" | 27 | #include "xfs_dir2.h" |
29 | #include "xfs_dmapi.h" | 28 | #include "xfs_dmapi.h" |
30 | #include "xfs_mount.h" | 29 | #include "xfs_mount.h" |
@@ -32,7 +31,6 @@ | |||
32 | #include "xfs_bmap_btree.h" | 31 | #include "xfs_bmap_btree.h" |
33 | #include "xfs_alloc_btree.h" | 32 | #include "xfs_alloc_btree.h" |
34 | #include "xfs_ialloc_btree.h" | 33 | #include "xfs_ialloc_btree.h" |
35 | #include "xfs_dir_sf.h" | ||
36 | #include "xfs_dir2_sf.h" | 34 | #include "xfs_dir2_sf.h" |
37 | #include "xfs_attr_sf.h" | 35 | #include "xfs_attr_sf.h" |
38 | #include "xfs_dinode.h" | 36 | #include "xfs_dinode.h" |
@@ -43,7 +41,6 @@ | |||
43 | #include "xfs_bmap.h" | 41 | #include "xfs_bmap.h" |
44 | #include "xfs_attr.h" | 42 | #include "xfs_attr.h" |
45 | #include "xfs_attr_leaf.h" | 43 | #include "xfs_attr_leaf.h" |
46 | #include "xfs_dir_leaf.h" | ||
47 | #include "xfs_dir2_data.h" | 44 | #include "xfs_dir2_data.h" |
48 | #include "xfs_dir2_leaf.h" | 45 | #include "xfs_dir2_leaf.h" |
49 | #include "xfs_dir2_block.h" | 46 | #include "xfs_dir2_block.h" |
@@ -159,7 +156,7 @@ xfs_da_split(xfs_da_state_t *state) | |||
159 | max = state->path.active - 1; | 156 | max = state->path.active - 1; |
160 | ASSERT((max >= 0) && (max < XFS_DA_NODE_MAXDEPTH)); | 157 | ASSERT((max >= 0) && (max < XFS_DA_NODE_MAXDEPTH)); |
161 | ASSERT(state->path.blk[max].magic == XFS_ATTR_LEAF_MAGIC || | 158 | ASSERT(state->path.blk[max].magic == XFS_ATTR_LEAF_MAGIC || |
162 | state->path.blk[max].magic == XFS_DIRX_LEAF_MAGIC(state->mp)); | 159 | state->path.blk[max].magic == XFS_DIR2_LEAFN_MAGIC); |
163 | 160 | ||
164 | addblk = &state->path.blk[max]; /* initial dummy value */ | 161 | addblk = &state->path.blk[max]; /* initial dummy value */ |
165 | for (i = max; (i >= 0) && addblk; state->path.active--, i--) { | 162 | for (i = max; (i >= 0) && addblk; state->path.active--, i--) { |
@@ -199,38 +196,7 @@ xfs_da_split(xfs_da_state_t *state) | |||
199 | return(error); /* GROT: attr inconsistent */ | 196 | return(error); /* GROT: attr inconsistent */ |
200 | addblk = newblk; | 197 | addblk = newblk; |
201 | break; | 198 | break; |
202 | case XFS_DIR_LEAF_MAGIC: | ||
203 | ASSERT(XFS_DIR_IS_V1(state->mp)); | ||
204 | error = xfs_dir_leaf_split(state, oldblk, newblk); | ||
205 | if ((error != 0) && (error != ENOSPC)) { | ||
206 | return(error); /* GROT: dir is inconsistent */ | ||
207 | } | ||
208 | if (!error) { | ||
209 | addblk = newblk; | ||
210 | break; | ||
211 | } | ||
212 | /* | ||
213 | * Entry wouldn't fit, split the leaf again. | ||
214 | */ | ||
215 | state->extravalid = 1; | ||
216 | if (state->inleaf) { | ||
217 | state->extraafter = 0; /* before newblk */ | ||
218 | error = xfs_dir_leaf_split(state, oldblk, | ||
219 | &state->extrablk); | ||
220 | if (error) | ||
221 | return(error); /* GROT: dir incon. */ | ||
222 | addblk = newblk; | ||
223 | } else { | ||
224 | state->extraafter = 1; /* after newblk */ | ||
225 | error = xfs_dir_leaf_split(state, newblk, | ||
226 | &state->extrablk); | ||
227 | if (error) | ||
228 | return(error); /* GROT: dir incon. */ | ||
229 | addblk = newblk; | ||
230 | } | ||
231 | break; | ||
232 | case XFS_DIR2_LEAFN_MAGIC: | 199 | case XFS_DIR2_LEAFN_MAGIC: |
233 | ASSERT(XFS_DIR_IS_V2(state->mp)); | ||
234 | error = xfs_dir2_leafn_split(state, oldblk, newblk); | 200 | error = xfs_dir2_leafn_split(state, oldblk, newblk); |
235 | if (error) | 201 | if (error) |
236 | return error; | 202 | return error; |
@@ -363,7 +329,6 @@ xfs_da_root_split(xfs_da_state_t *state, xfs_da_state_blk_t *blk1, | |||
363 | size = (int)((char *)&oldroot->btree[be16_to_cpu(oldroot->hdr.count)] - | 329 | size = (int)((char *)&oldroot->btree[be16_to_cpu(oldroot->hdr.count)] - |
364 | (char *)oldroot); | 330 | (char *)oldroot); |
365 | } else { | 331 | } else { |
366 | ASSERT(XFS_DIR_IS_V2(mp)); | ||
367 | ASSERT(be16_to_cpu(oldroot->hdr.info.magic) == XFS_DIR2_LEAFN_MAGIC); | 332 | ASSERT(be16_to_cpu(oldroot->hdr.info.magic) == XFS_DIR2_LEAFN_MAGIC); |
368 | leaf = (xfs_dir2_leaf_t *)oldroot; | 333 | leaf = (xfs_dir2_leaf_t *)oldroot; |
369 | size = (int)((char *)&leaf->ents[be16_to_cpu(leaf->hdr.count)] - | 334 | size = (int)((char *)&leaf->ents[be16_to_cpu(leaf->hdr.count)] - |
@@ -379,8 +344,7 @@ xfs_da_root_split(xfs_da_state_t *state, xfs_da_state_blk_t *blk1, | |||
379 | * Set up the new root node. | 344 | * Set up the new root node. |
380 | */ | 345 | */ |
381 | error = xfs_da_node_create(args, | 346 | error = xfs_da_node_create(args, |
382 | args->whichfork == XFS_DATA_FORK && | 347 | (args->whichfork == XFS_DATA_FORK) ? mp->m_dirleafblk : 0, |
383 | XFS_DIR_IS_V2(mp) ? mp->m_dirleafblk : 0, | ||
384 | be16_to_cpu(node->hdr.level) + 1, &bp, args->whichfork); | 348 | be16_to_cpu(node->hdr.level) + 1, &bp, args->whichfork); |
385 | if (error) | 349 | if (error) |
386 | return(error); | 350 | return(error); |
@@ -427,10 +391,9 @@ xfs_da_node_split(xfs_da_state_t *state, xfs_da_state_blk_t *oldblk, | |||
427 | ASSERT(be16_to_cpu(node->hdr.info.magic) == XFS_DA_NODE_MAGIC); | 391 | ASSERT(be16_to_cpu(node->hdr.info.magic) == XFS_DA_NODE_MAGIC); |
428 | 392 | ||
429 | /* | 393 | /* |
430 | * With V2 the extra block is data or freespace. | 394 | * With V2 dirs the extra block is data or freespace. |
431 | */ | 395 | */ |
432 | useextra = state->extravalid && (XFS_DIR_IS_V1(state->mp) || | 396 | useextra = state->extravalid && state->args->whichfork == XFS_ATTR_FORK; |
433 | state->args->whichfork == XFS_ATTR_FORK); | ||
434 | newcount = 1 + useextra; | 397 | newcount = 1 + useextra; |
435 | /* | 398 | /* |
436 | * Do we have to split the node? | 399 | * Do we have to split the node? |
@@ -624,7 +587,7 @@ xfs_da_node_add(xfs_da_state_t *state, xfs_da_state_blk_t *oldblk, | |||
624 | ASSERT(be16_to_cpu(node->hdr.info.magic) == XFS_DA_NODE_MAGIC); | 587 | ASSERT(be16_to_cpu(node->hdr.info.magic) == XFS_DA_NODE_MAGIC); |
625 | ASSERT((oldblk->index >= 0) && (oldblk->index <= be16_to_cpu(node->hdr.count))); | 588 | ASSERT((oldblk->index >= 0) && (oldblk->index <= be16_to_cpu(node->hdr.count))); |
626 | ASSERT(newblk->blkno != 0); | 589 | ASSERT(newblk->blkno != 0); |
627 | if (state->args->whichfork == XFS_DATA_FORK && XFS_DIR_IS_V2(mp)) | 590 | if (state->args->whichfork == XFS_DATA_FORK) |
628 | ASSERT(newblk->blkno >= mp->m_dirleafblk && | 591 | ASSERT(newblk->blkno >= mp->m_dirleafblk && |
629 | newblk->blkno < mp->m_dirfreeblk); | 592 | newblk->blkno < mp->m_dirfreeblk); |
630 | 593 | ||
@@ -670,7 +633,7 @@ xfs_da_join(xfs_da_state_t *state) | |||
670 | save_blk = &state->altpath.blk[ state->path.active-1 ]; | 633 | save_blk = &state->altpath.blk[ state->path.active-1 ]; |
671 | ASSERT(state->path.blk[0].magic == XFS_DA_NODE_MAGIC); | 634 | ASSERT(state->path.blk[0].magic == XFS_DA_NODE_MAGIC); |
672 | ASSERT(drop_blk->magic == XFS_ATTR_LEAF_MAGIC || | 635 | ASSERT(drop_blk->magic == XFS_ATTR_LEAF_MAGIC || |
673 | drop_blk->magic == XFS_DIRX_LEAF_MAGIC(state->mp)); | 636 | drop_blk->magic == XFS_DIR2_LEAFN_MAGIC); |
674 | 637 | ||
675 | /* | 638 | /* |
676 | * Walk back up the tree joining/deallocating as necessary. | 639 | * Walk back up the tree joining/deallocating as necessary. |
@@ -693,17 +656,7 @@ xfs_da_join(xfs_da_state_t *state) | |||
693 | return(0); | 656 | return(0); |
694 | xfs_attr_leaf_unbalance(state, drop_blk, save_blk); | 657 | xfs_attr_leaf_unbalance(state, drop_blk, save_blk); |
695 | break; | 658 | break; |
696 | case XFS_DIR_LEAF_MAGIC: | ||
697 | ASSERT(XFS_DIR_IS_V1(state->mp)); | ||
698 | error = xfs_dir_leaf_toosmall(state, &action); | ||
699 | if (error) | ||
700 | return(error); | ||
701 | if (action == 0) | ||
702 | return(0); | ||
703 | xfs_dir_leaf_unbalance(state, drop_blk, save_blk); | ||
704 | break; | ||
705 | case XFS_DIR2_LEAFN_MAGIC: | 659 | case XFS_DIR2_LEAFN_MAGIC: |
706 | ASSERT(XFS_DIR_IS_V2(state->mp)); | ||
707 | error = xfs_dir2_leafn_toosmall(state, &action); | 660 | error = xfs_dir2_leafn_toosmall(state, &action); |
708 | if (error) | 661 | if (error) |
709 | return error; | 662 | return error; |
@@ -790,7 +743,7 @@ xfs_da_root_join(xfs_da_state_t *state, xfs_da_state_blk_t *root_blk) | |||
790 | ASSERT(bp != NULL); | 743 | ASSERT(bp != NULL); |
791 | blkinfo = bp->data; | 744 | blkinfo = bp->data; |
792 | if (be16_to_cpu(oldroot->hdr.level) == 1) { | 745 | if (be16_to_cpu(oldroot->hdr.level) == 1) { |
793 | ASSERT(be16_to_cpu(blkinfo->magic) == XFS_DIRX_LEAF_MAGIC(state->mp) || | 746 | ASSERT(be16_to_cpu(blkinfo->magic) == XFS_DIR2_LEAFN_MAGIC || |
794 | be16_to_cpu(blkinfo->magic) == XFS_ATTR_LEAF_MAGIC); | 747 | be16_to_cpu(blkinfo->magic) == XFS_ATTR_LEAF_MAGIC); |
795 | } else { | 748 | } else { |
796 | ASSERT(be16_to_cpu(blkinfo->magic) == XFS_DA_NODE_MAGIC); | 749 | ASSERT(be16_to_cpu(blkinfo->magic) == XFS_DA_NODE_MAGIC); |
@@ -951,14 +904,7 @@ xfs_da_fixhashpath(xfs_da_state_t *state, xfs_da_state_path_t *path) | |||
951 | if (count == 0) | 904 | if (count == 0) |
952 | return; | 905 | return; |
953 | break; | 906 | break; |
954 | case XFS_DIR_LEAF_MAGIC: | ||
955 | ASSERT(XFS_DIR_IS_V1(state->mp)); | ||
956 | lasthash = xfs_dir_leaf_lasthash(blk->bp, &count); | ||
957 | if (count == 0) | ||
958 | return; | ||
959 | break; | ||
960 | case XFS_DIR2_LEAFN_MAGIC: | 907 | case XFS_DIR2_LEAFN_MAGIC: |
961 | ASSERT(XFS_DIR_IS_V2(state->mp)); | ||
962 | lasthash = xfs_dir2_leafn_lasthash(blk->bp, &count); | 908 | lasthash = xfs_dir2_leafn_lasthash(blk->bp, &count); |
963 | if (count == 0) | 909 | if (count == 0) |
964 | return; | 910 | return; |
@@ -1117,10 +1063,7 @@ xfs_da_node_lookup_int(xfs_da_state_t *state, int *result) | |||
1117 | * Descend thru the B-tree searching each level for the right | 1063 | * Descend thru the B-tree searching each level for the right |
1118 | * node to use, until the right hashval is found. | 1064 | * node to use, until the right hashval is found. |
1119 | */ | 1065 | */ |
1120 | if (args->whichfork == XFS_DATA_FORK && XFS_DIR_IS_V2(state->mp)) | 1066 | blkno = (args->whichfork == XFS_DATA_FORK)? state->mp->m_dirleafblk : 0; |
1121 | blkno = state->mp->m_dirleafblk; | ||
1122 | else | ||
1123 | blkno = 0; | ||
1124 | for (blk = &state->path.blk[0], state->path.active = 1; | 1067 | for (blk = &state->path.blk[0], state->path.active = 1; |
1125 | state->path.active <= XFS_DA_NODE_MAXDEPTH; | 1068 | state->path.active <= XFS_DA_NODE_MAXDEPTH; |
1126 | blk++, state->path.active++) { | 1069 | blk++, state->path.active++) { |
@@ -1137,7 +1080,7 @@ xfs_da_node_lookup_int(xfs_da_state_t *state, int *result) | |||
1137 | } | 1080 | } |
1138 | curr = blk->bp->data; | 1081 | curr = blk->bp->data; |
1139 | ASSERT(be16_to_cpu(curr->magic) == XFS_DA_NODE_MAGIC || | 1082 | ASSERT(be16_to_cpu(curr->magic) == XFS_DA_NODE_MAGIC || |
1140 | be16_to_cpu(curr->magic) == XFS_DIRX_LEAF_MAGIC(state->mp) || | 1083 | be16_to_cpu(curr->magic) == XFS_DIR2_LEAFN_MAGIC || |
1141 | be16_to_cpu(curr->magic) == XFS_ATTR_LEAF_MAGIC); | 1084 | be16_to_cpu(curr->magic) == XFS_ATTR_LEAF_MAGIC); |
1142 | 1085 | ||
1143 | /* | 1086 | /* |
@@ -1190,16 +1133,10 @@ xfs_da_node_lookup_int(xfs_da_state_t *state, int *result) | |||
1190 | blk->index = probe; | 1133 | blk->index = probe; |
1191 | blkno = be32_to_cpu(btree->before); | 1134 | blkno = be32_to_cpu(btree->before); |
1192 | } | 1135 | } |
1193 | } | 1136 | } else if (be16_to_cpu(curr->magic) == XFS_ATTR_LEAF_MAGIC) { |
1194 | else if (be16_to_cpu(curr->magic) == XFS_ATTR_LEAF_MAGIC) { | ||
1195 | blk->hashval = xfs_attr_leaf_lasthash(blk->bp, NULL); | 1137 | blk->hashval = xfs_attr_leaf_lasthash(blk->bp, NULL); |
1196 | break; | 1138 | break; |
1197 | } | 1139 | } else if (be16_to_cpu(curr->magic) == XFS_DIR2_LEAFN_MAGIC) { |
1198 | else if (be16_to_cpu(curr->magic) == XFS_DIR_LEAF_MAGIC) { | ||
1199 | blk->hashval = xfs_dir_leaf_lasthash(blk->bp, NULL); | ||
1200 | break; | ||
1201 | } | ||
1202 | else if (be16_to_cpu(curr->magic) == XFS_DIR2_LEAFN_MAGIC) { | ||
1203 | blk->hashval = xfs_dir2_leafn_lasthash(blk->bp, NULL); | 1140 | blk->hashval = xfs_dir2_leafn_lasthash(blk->bp, NULL); |
1204 | break; | 1141 | break; |
1205 | } | 1142 | } |
@@ -1212,12 +1149,7 @@ xfs_da_node_lookup_int(xfs_da_state_t *state, int *result) | |||
1212 | * next leaf and keep searching. | 1149 | * next leaf and keep searching. |
1213 | */ | 1150 | */ |
1214 | for (;;) { | 1151 | for (;;) { |
1215 | if (blk->magic == XFS_DIR_LEAF_MAGIC) { | 1152 | if (blk->magic == XFS_DIR2_LEAFN_MAGIC) { |
1216 | ASSERT(XFS_DIR_IS_V1(state->mp)); | ||
1217 | retval = xfs_dir_leaf_lookup_int(blk->bp, args, | ||
1218 | &blk->index); | ||
1219 | } else if (blk->magic == XFS_DIR2_LEAFN_MAGIC) { | ||
1220 | ASSERT(XFS_DIR_IS_V2(state->mp)); | ||
1221 | retval = xfs_dir2_leafn_lookup_int(blk->bp, args, | 1153 | retval = xfs_dir2_leafn_lookup_int(blk->bp, args, |
1222 | &blk->index, state); | 1154 | &blk->index, state); |
1223 | } | 1155 | } |
@@ -1270,7 +1202,7 @@ xfs_da_blk_link(xfs_da_state_t *state, xfs_da_state_blk_t *old_blk, | |||
1270 | old_info = old_blk->bp->data; | 1202 | old_info = old_blk->bp->data; |
1271 | new_info = new_blk->bp->data; | 1203 | new_info = new_blk->bp->data; |
1272 | ASSERT(old_blk->magic == XFS_DA_NODE_MAGIC || | 1204 | ASSERT(old_blk->magic == XFS_DA_NODE_MAGIC || |
1273 | old_blk->magic == XFS_DIRX_LEAF_MAGIC(state->mp) || | 1205 | old_blk->magic == XFS_DIR2_LEAFN_MAGIC || |
1274 | old_blk->magic == XFS_ATTR_LEAF_MAGIC); | 1206 | old_blk->magic == XFS_ATTR_LEAF_MAGIC); |
1275 | ASSERT(old_blk->magic == be16_to_cpu(old_info->magic)); | 1207 | ASSERT(old_blk->magic == be16_to_cpu(old_info->magic)); |
1276 | ASSERT(new_blk->magic == be16_to_cpu(new_info->magic)); | 1208 | ASSERT(new_blk->magic == be16_to_cpu(new_info->magic)); |
@@ -1280,12 +1212,7 @@ xfs_da_blk_link(xfs_da_state_t *state, xfs_da_state_blk_t *old_blk, | |||
1280 | case XFS_ATTR_LEAF_MAGIC: | 1212 | case XFS_ATTR_LEAF_MAGIC: |
1281 | before = xfs_attr_leaf_order(old_blk->bp, new_blk->bp); | 1213 | before = xfs_attr_leaf_order(old_blk->bp, new_blk->bp); |
1282 | break; | 1214 | break; |
1283 | case XFS_DIR_LEAF_MAGIC: | ||
1284 | ASSERT(XFS_DIR_IS_V1(state->mp)); | ||
1285 | before = xfs_dir_leaf_order(old_blk->bp, new_blk->bp); | ||
1286 | break; | ||
1287 | case XFS_DIR2_LEAFN_MAGIC: | 1215 | case XFS_DIR2_LEAFN_MAGIC: |
1288 | ASSERT(XFS_DIR_IS_V2(state->mp)); | ||
1289 | before = xfs_dir2_leafn_order(old_blk->bp, new_blk->bp); | 1216 | before = xfs_dir2_leafn_order(old_blk->bp, new_blk->bp); |
1290 | break; | 1217 | break; |
1291 | case XFS_DA_NODE_MAGIC: | 1218 | case XFS_DA_NODE_MAGIC: |
@@ -1404,7 +1331,7 @@ xfs_da_blk_unlink(xfs_da_state_t *state, xfs_da_state_blk_t *drop_blk, | |||
1404 | save_info = save_blk->bp->data; | 1331 | save_info = save_blk->bp->data; |
1405 | drop_info = drop_blk->bp->data; | 1332 | drop_info = drop_blk->bp->data; |
1406 | ASSERT(save_blk->magic == XFS_DA_NODE_MAGIC || | 1333 | ASSERT(save_blk->magic == XFS_DA_NODE_MAGIC || |
1407 | save_blk->magic == XFS_DIRX_LEAF_MAGIC(state->mp) || | 1334 | save_blk->magic == XFS_DIR2_LEAFN_MAGIC || |
1408 | save_blk->magic == XFS_ATTR_LEAF_MAGIC); | 1335 | save_blk->magic == XFS_ATTR_LEAF_MAGIC); |
1409 | ASSERT(save_blk->magic == be16_to_cpu(save_info->magic)); | 1336 | ASSERT(save_blk->magic == be16_to_cpu(save_info->magic)); |
1410 | ASSERT(drop_blk->magic == be16_to_cpu(drop_info->magic)); | 1337 | ASSERT(drop_blk->magic == be16_to_cpu(drop_info->magic)); |
@@ -1529,7 +1456,7 @@ xfs_da_path_shift(xfs_da_state_t *state, xfs_da_state_path_t *path, | |||
1529 | ASSERT(blk->bp != NULL); | 1456 | ASSERT(blk->bp != NULL); |
1530 | info = blk->bp->data; | 1457 | info = blk->bp->data; |
1531 | ASSERT(be16_to_cpu(info->magic) == XFS_DA_NODE_MAGIC || | 1458 | ASSERT(be16_to_cpu(info->magic) == XFS_DA_NODE_MAGIC || |
1532 | be16_to_cpu(info->magic) == XFS_DIRX_LEAF_MAGIC(state->mp) || | 1459 | be16_to_cpu(info->magic) == XFS_DIR2_LEAFN_MAGIC || |
1533 | be16_to_cpu(info->magic) == XFS_ATTR_LEAF_MAGIC); | 1460 | be16_to_cpu(info->magic) == XFS_ATTR_LEAF_MAGIC); |
1534 | blk->magic = be16_to_cpu(info->magic); | 1461 | blk->magic = be16_to_cpu(info->magic); |
1535 | if (blk->magic == XFS_DA_NODE_MAGIC) { | 1462 | if (blk->magic == XFS_DA_NODE_MAGIC) { |
@@ -1548,20 +1475,13 @@ xfs_da_path_shift(xfs_da_state_t *state, xfs_da_state_path_t *path, | |||
1548 | blk->hashval = xfs_attr_leaf_lasthash(blk->bp, | 1475 | blk->hashval = xfs_attr_leaf_lasthash(blk->bp, |
1549 | NULL); | 1476 | NULL); |
1550 | break; | 1477 | break; |
1551 | case XFS_DIR_LEAF_MAGIC: | ||
1552 | ASSERT(XFS_DIR_IS_V1(state->mp)); | ||
1553 | blk->hashval = xfs_dir_leaf_lasthash(blk->bp, | ||
1554 | NULL); | ||
1555 | break; | ||
1556 | case XFS_DIR2_LEAFN_MAGIC: | 1478 | case XFS_DIR2_LEAFN_MAGIC: |
1557 | ASSERT(XFS_DIR_IS_V2(state->mp)); | ||
1558 | blk->hashval = xfs_dir2_leafn_lasthash(blk->bp, | 1479 | blk->hashval = xfs_dir2_leafn_lasthash(blk->bp, |
1559 | NULL); | 1480 | NULL); |
1560 | break; | 1481 | break; |
1561 | default: | 1482 | default: |
1562 | ASSERT(blk->magic == XFS_ATTR_LEAF_MAGIC || | 1483 | ASSERT(blk->magic == XFS_ATTR_LEAF_MAGIC || |
1563 | blk->magic == | 1484 | blk->magic == XFS_DIR2_LEAFN_MAGIC); |
1564 | XFS_DIRX_LEAF_MAGIC(state->mp)); | ||
1565 | break; | 1485 | break; |
1566 | } | 1486 | } |
1567 | } | 1487 | } |
@@ -1620,7 +1540,6 @@ xfs_da_grow_inode(xfs_da_args_t *args, xfs_dablk_t *new_blkno) | |||
1620 | xfs_bmbt_irec_t *mapp; | 1540 | xfs_bmbt_irec_t *mapp; |
1621 | xfs_inode_t *dp; | 1541 | xfs_inode_t *dp; |
1622 | int nmap, error, w, count, c, got, i, mapi; | 1542 | int nmap, error, w, count, c, got, i, mapi; |
1623 | xfs_fsize_t size; | ||
1624 | xfs_trans_t *tp; | 1543 | xfs_trans_t *tp; |
1625 | xfs_mount_t *mp; | 1544 | xfs_mount_t *mp; |
1626 | 1545 | ||
@@ -1631,7 +1550,7 @@ xfs_da_grow_inode(xfs_da_args_t *args, xfs_dablk_t *new_blkno) | |||
1631 | /* | 1550 | /* |
1632 | * For new directories adjust the file offset and block count. | 1551 | * For new directories adjust the file offset and block count. |
1633 | */ | 1552 | */ |
1634 | if (w == XFS_DATA_FORK && XFS_DIR_IS_V2(mp)) { | 1553 | if (w == XFS_DATA_FORK) { |
1635 | bno = mp->m_dirleafblk; | 1554 | bno = mp->m_dirleafblk; |
1636 | count = mp->m_dirblkfsbs; | 1555 | count = mp->m_dirblkfsbs; |
1637 | } else { | 1556 | } else { |
@@ -1641,10 +1560,9 @@ xfs_da_grow_inode(xfs_da_args_t *args, xfs_dablk_t *new_blkno) | |||
1641 | /* | 1560 | /* |
1642 | * Find a spot in the file space to put the new block. | 1561 | * Find a spot in the file space to put the new block. |
1643 | */ | 1562 | */ |
1644 | if ((error = xfs_bmap_first_unused(tp, dp, count, &bno, w))) { | 1563 | if ((error = xfs_bmap_first_unused(tp, dp, count, &bno, w))) |
1645 | return error; | 1564 | return error; |
1646 | } | 1565 | if (w == XFS_DATA_FORK) |
1647 | if (w == XFS_DATA_FORK && XFS_DIR_IS_V2(mp)) | ||
1648 | ASSERT(bno >= mp->m_dirleafblk && bno < mp->m_dirfreeblk); | 1566 | ASSERT(bno >= mp->m_dirleafblk && bno < mp->m_dirfreeblk); |
1649 | /* | 1567 | /* |
1650 | * Try mapping it in one filesystem block. | 1568 | * Try mapping it in one filesystem block. |
@@ -1706,19 +1624,6 @@ xfs_da_grow_inode(xfs_da_args_t *args, xfs_dablk_t *new_blkno) | |||
1706 | if (mapp != &map) | 1624 | if (mapp != &map) |
1707 | kmem_free(mapp, sizeof(*mapp) * count); | 1625 | kmem_free(mapp, sizeof(*mapp) * count); |
1708 | *new_blkno = (xfs_dablk_t)bno; | 1626 | *new_blkno = (xfs_dablk_t)bno; |
1709 | /* | ||
1710 | * For version 1 directories, adjust the file size if it changed. | ||
1711 | */ | ||
1712 | if (w == XFS_DATA_FORK && XFS_DIR_IS_V1(mp)) { | ||
1713 | ASSERT(mapi == 1); | ||
1714 | if ((error = xfs_bmap_last_offset(tp, dp, &bno, w))) | ||
1715 | return error; | ||
1716 | size = XFS_FSB_TO_B(mp, bno); | ||
1717 | if (size != dp->i_d.di_size) { | ||
1718 | dp->i_d.di_size = size; | ||
1719 | xfs_trans_log_inode(tp, dp, XFS_ILOG_CORE); | ||
1720 | } | ||
1721 | } | ||
1722 | return 0; | 1627 | return 0; |
1723 | } | 1628 | } |
1724 | 1629 | ||
@@ -1743,7 +1648,6 @@ xfs_da_swap_lastblock(xfs_da_args_t *args, xfs_dablk_t *dead_blknop, | |||
1743 | int error, w, entno, level, dead_level; | 1648 | int error, w, entno, level, dead_level; |
1744 | xfs_da_blkinfo_t *dead_info, *sib_info; | 1649 | xfs_da_blkinfo_t *dead_info, *sib_info; |
1745 | xfs_da_intnode_t *par_node, *dead_node; | 1650 | xfs_da_intnode_t *par_node, *dead_node; |
1746 | xfs_dir_leafblock_t *dead_leaf; | ||
1747 | xfs_dir2_leaf_t *dead_leaf2; | 1651 | xfs_dir2_leaf_t *dead_leaf2; |
1748 | xfs_dahash_t dead_hash; | 1652 | xfs_dahash_t dead_hash; |
1749 | 1653 | ||
@@ -1754,11 +1658,8 @@ xfs_da_swap_lastblock(xfs_da_args_t *args, xfs_dablk_t *dead_blknop, | |||
1754 | w = args->whichfork; | 1658 | w = args->whichfork; |
1755 | ASSERT(w == XFS_DATA_FORK); | 1659 | ASSERT(w == XFS_DATA_FORK); |
1756 | mp = ip->i_mount; | 1660 | mp = ip->i_mount; |
1757 | if (XFS_DIR_IS_V2(mp)) { | 1661 | lastoff = mp->m_dirfreeblk; |
1758 | lastoff = mp->m_dirfreeblk; | 1662 | error = xfs_bmap_last_before(tp, ip, &lastoff, w); |
1759 | error = xfs_bmap_last_before(tp, ip, &lastoff, w); | ||
1760 | } else | ||
1761 | error = xfs_bmap_last_offset(tp, ip, &lastoff, w); | ||
1762 | if (error) | 1663 | if (error) |
1763 | return error; | 1664 | return error; |
1764 | if (unlikely(lastoff == 0)) { | 1665 | if (unlikely(lastoff == 0)) { |
@@ -1781,14 +1682,7 @@ xfs_da_swap_lastblock(xfs_da_args_t *args, xfs_dablk_t *dead_blknop, | |||
1781 | /* | 1682 | /* |
1782 | * Get values from the moved block. | 1683 | * Get values from the moved block. |
1783 | */ | 1684 | */ |
1784 | if (be16_to_cpu(dead_info->magic) == XFS_DIR_LEAF_MAGIC) { | 1685 | if (be16_to_cpu(dead_info->magic) == XFS_DIR2_LEAFN_MAGIC) { |
1785 | ASSERT(XFS_DIR_IS_V1(mp)); | ||
1786 | dead_leaf = (xfs_dir_leafblock_t *)dead_info; | ||
1787 | dead_level = 0; | ||
1788 | dead_hash = be32_to_cpu(dead_leaf->entries[ | ||
1789 | be16_to_cpu(dead_leaf->hdr.count) - 1].hashval); | ||
1790 | } else if (be16_to_cpu(dead_info->magic) == XFS_DIR2_LEAFN_MAGIC) { | ||
1791 | ASSERT(XFS_DIR_IS_V2(mp)); | ||
1792 | dead_leaf2 = (xfs_dir2_leaf_t *)dead_info; | 1686 | dead_leaf2 = (xfs_dir2_leaf_t *)dead_info; |
1793 | dead_level = 0; | 1687 | dead_level = 0; |
1794 | dead_hash = be32_to_cpu(dead_leaf2->ents[be16_to_cpu(dead_leaf2->hdr.count) - 1].hashval); | 1688 | dead_hash = be32_to_cpu(dead_leaf2->ents[be16_to_cpu(dead_leaf2->hdr.count) - 1].hashval); |
@@ -1843,7 +1737,7 @@ xfs_da_swap_lastblock(xfs_da_args_t *args, xfs_dablk_t *dead_blknop, | |||
1843 | xfs_da_buf_done(sib_buf); | 1737 | xfs_da_buf_done(sib_buf); |
1844 | sib_buf = NULL; | 1738 | sib_buf = NULL; |
1845 | } | 1739 | } |
1846 | par_blkno = XFS_DIR_IS_V1(mp) ? 0 : mp->m_dirleafblk; | 1740 | par_blkno = mp->m_dirleafblk; |
1847 | level = -1; | 1741 | level = -1; |
1848 | /* | 1742 | /* |
1849 | * Walk down the tree looking for the parent of the moved block. | 1743 | * Walk down the tree looking for the parent of the moved block. |
@@ -1942,8 +1836,6 @@ xfs_da_shrink_inode(xfs_da_args_t *args, xfs_dablk_t dead_blkno, | |||
1942 | { | 1836 | { |
1943 | xfs_inode_t *dp; | 1837 | xfs_inode_t *dp; |
1944 | int done, error, w, count; | 1838 | int done, error, w, count; |
1945 | xfs_fileoff_t bno; | ||
1946 | xfs_fsize_t size; | ||
1947 | xfs_trans_t *tp; | 1839 | xfs_trans_t *tp; |
1948 | xfs_mount_t *mp; | 1840 | xfs_mount_t *mp; |
1949 | 1841 | ||
@@ -1951,7 +1843,7 @@ xfs_da_shrink_inode(xfs_da_args_t *args, xfs_dablk_t dead_blkno, | |||
1951 | w = args->whichfork; | 1843 | w = args->whichfork; |
1952 | tp = args->trans; | 1844 | tp = args->trans; |
1953 | mp = dp->i_mount; | 1845 | mp = dp->i_mount; |
1954 | if (w == XFS_DATA_FORK && XFS_DIR_IS_V2(mp)) | 1846 | if (w == XFS_DATA_FORK) |
1955 | count = mp->m_dirblkfsbs; | 1847 | count = mp->m_dirblkfsbs; |
1956 | else | 1848 | else |
1957 | count = 1; | 1849 | count = 1; |
@@ -1965,31 +1857,14 @@ xfs_da_shrink_inode(xfs_da_args_t *args, xfs_dablk_t dead_blkno, | |||
1965 | 0, args->firstblock, args->flist, NULL, | 1857 | 0, args->firstblock, args->flist, NULL, |
1966 | &done)) == ENOSPC) { | 1858 | &done)) == ENOSPC) { |
1967 | if (w != XFS_DATA_FORK) | 1859 | if (w != XFS_DATA_FORK) |
1968 | goto done; | 1860 | break; |
1969 | if ((error = xfs_da_swap_lastblock(args, &dead_blkno, | 1861 | if ((error = xfs_da_swap_lastblock(args, &dead_blkno, |
1970 | &dead_buf))) | 1862 | &dead_buf))) |
1971 | goto done; | 1863 | break; |
1972 | } else if (error) | 1864 | } else { |
1973 | goto done; | ||
1974 | else | ||
1975 | break; | 1865 | break; |
1976 | } | ||
1977 | ASSERT(done); | ||
1978 | xfs_da_binval(tp, dead_buf); | ||
1979 | /* | ||
1980 | * Adjust the directory size for version 1. | ||
1981 | */ | ||
1982 | if (w == XFS_DATA_FORK && XFS_DIR_IS_V1(mp)) { | ||
1983 | if ((error = xfs_bmap_last_offset(tp, dp, &bno, w))) | ||
1984 | return error; | ||
1985 | size = XFS_FSB_TO_B(dp->i_mount, bno); | ||
1986 | if (size != dp->i_d.di_size) { | ||
1987 | dp->i_d.di_size = size; | ||
1988 | xfs_trans_log_inode(tp, dp, XFS_ILOG_CORE); | ||
1989 | } | 1866 | } |
1990 | } | 1867 | } |
1991 | return 0; | ||
1992 | done: | ||
1993 | xfs_da_binval(tp, dead_buf); | 1868 | xfs_da_binval(tp, dead_buf); |
1994 | return error; | 1869 | return error; |
1995 | } | 1870 | } |
@@ -2050,10 +1925,7 @@ xfs_da_do_buf( | |||
2050 | xfs_dabuf_t *rbp; | 1925 | xfs_dabuf_t *rbp; |
2051 | 1926 | ||
2052 | mp = dp->i_mount; | 1927 | mp = dp->i_mount; |
2053 | if (whichfork == XFS_DATA_FORK && XFS_DIR_IS_V2(mp)) | 1928 | nfsb = (whichfork == XFS_DATA_FORK) ? mp->m_dirblkfsbs : 1; |
2054 | nfsb = mp->m_dirblkfsbs; | ||
2055 | else | ||
2056 | nfsb = 1; | ||
2057 | mappedbno = *mappedbnop; | 1929 | mappedbno = *mappedbnop; |
2058 | /* | 1930 | /* |
2059 | * Caller doesn't have a mapping. -2 means don't complain | 1931 | * Caller doesn't have a mapping. -2 means don't complain |
@@ -2199,7 +2071,6 @@ xfs_da_do_buf( | |||
2199 | magic1 = be32_to_cpu(data->hdr.magic); | 2071 | magic1 = be32_to_cpu(data->hdr.magic); |
2200 | if (unlikely( | 2072 | if (unlikely( |
2201 | XFS_TEST_ERROR((magic != XFS_DA_NODE_MAGIC) && | 2073 | XFS_TEST_ERROR((magic != XFS_DA_NODE_MAGIC) && |
2202 | (magic != XFS_DIR_LEAF_MAGIC) && | ||
2203 | (magic != XFS_ATTR_LEAF_MAGIC) && | 2074 | (magic != XFS_ATTR_LEAF_MAGIC) && |
2204 | (magic != XFS_DIR2_LEAF1_MAGIC) && | 2075 | (magic != XFS_DIR2_LEAF1_MAGIC) && |
2205 | (magic != XFS_DIR2_LEAFN_MAGIC) && | 2076 | (magic != XFS_DIR2_LEAFN_MAGIC) && |