diff options
-rw-r--r-- | fs/xfs/xfs_da_btree.c | 19 | ||||
-rw-r--r-- | fs/xfs/xfs_da_format.c | 75 | ||||
-rw-r--r-- | fs/xfs/xfs_da_format.h | 30 | ||||
-rw-r--r-- | fs/xfs/xfs_dir2.c | 7 | ||||
-rw-r--r-- | fs/xfs/xfs_dir2.h | 10 | ||||
-rw-r--r-- | fs/xfs/xfs_dir2_block.c | 2 | ||||
-rw-r--r-- | fs/xfs/xfs_dir2_data.c | 13 | ||||
-rw-r--r-- | fs/xfs/xfs_dir2_leaf.c | 91 | ||||
-rw-r--r-- | fs/xfs/xfs_dir2_node.c | 117 | ||||
-rw-r--r-- | fs/xfs/xfs_dir2_priv.h | 13 |
10 files changed, 218 insertions, 159 deletions
diff --git a/fs/xfs/xfs_da_btree.c b/fs/xfs/xfs_da_btree.c index eb65c546ffd8..df3759c51470 100644 --- a/fs/xfs/xfs_da_btree.c +++ b/fs/xfs/xfs_da_btree.c | |||
@@ -605,7 +605,7 @@ xfs_da3_root_split( | |||
605 | 605 | ||
606 | leaf = (xfs_dir2_leaf_t *)oldroot; | 606 | leaf = (xfs_dir2_leaf_t *)oldroot; |
607 | xfs_dir3_leaf_hdr_from_disk(&leafhdr, leaf); | 607 | xfs_dir3_leaf_hdr_from_disk(&leafhdr, leaf); |
608 | ents = xfs_dir3_leaf_ents_p(leaf); | 608 | ents = dp->d_ops->leaf_ents_p(leaf); |
609 | 609 | ||
610 | ASSERT(leafhdr.magic == XFS_DIR2_LEAFN_MAGIC || | 610 | ASSERT(leafhdr.magic == XFS_DIR2_LEAFN_MAGIC || |
611 | leafhdr.magic == XFS_DIR3_LEAFN_MAGIC); | 611 | leafhdr.magic == XFS_DIR3_LEAFN_MAGIC); |
@@ -1319,7 +1319,8 @@ xfs_da3_fixhashpath( | |||
1319 | return; | 1319 | return; |
1320 | break; | 1320 | break; |
1321 | case XFS_DIR2_LEAFN_MAGIC: | 1321 | case XFS_DIR2_LEAFN_MAGIC: |
1322 | lasthash = xfs_dir2_leafn_lasthash(blk->bp, &count); | 1322 | lasthash = xfs_dir2_leafn_lasthash(state->args->dp, |
1323 | blk->bp, &count); | ||
1323 | if (count == 0) | 1324 | if (count == 0) |
1324 | return; | 1325 | return; |
1325 | break; | 1326 | break; |
@@ -1536,7 +1537,8 @@ xfs_da3_node_lookup_int( | |||
1536 | if (blk->magic == XFS_DIR2_LEAFN_MAGIC || | 1537 | if (blk->magic == XFS_DIR2_LEAFN_MAGIC || |
1537 | blk->magic == XFS_DIR3_LEAFN_MAGIC) { | 1538 | blk->magic == XFS_DIR3_LEAFN_MAGIC) { |
1538 | blk->magic = XFS_DIR2_LEAFN_MAGIC; | 1539 | blk->magic = XFS_DIR2_LEAFN_MAGIC; |
1539 | blk->hashval = xfs_dir2_leafn_lasthash(blk->bp, NULL); | 1540 | blk->hashval = xfs_dir2_leafn_lasthash(args->dp, |
1541 | blk->bp, NULL); | ||
1540 | break; | 1542 | break; |
1541 | } | 1543 | } |
1542 | 1544 | ||
@@ -1702,7 +1704,7 @@ xfs_da3_blk_link( | |||
1702 | before = xfs_attr_leaf_order(old_blk->bp, new_blk->bp); | 1704 | before = xfs_attr_leaf_order(old_blk->bp, new_blk->bp); |
1703 | break; | 1705 | break; |
1704 | case XFS_DIR2_LEAFN_MAGIC: | 1706 | case XFS_DIR2_LEAFN_MAGIC: |
1705 | before = xfs_dir2_leafn_order(old_blk->bp, new_blk->bp); | 1707 | before = xfs_dir2_leafn_order(args->dp, old_blk->bp, new_blk->bp); |
1706 | break; | 1708 | break; |
1707 | case XFS_DA_NODE_MAGIC: | 1709 | case XFS_DA_NODE_MAGIC: |
1708 | before = xfs_da3_node_order(old_blk->bp, new_blk->bp); | 1710 | before = xfs_da3_node_order(old_blk->bp, new_blk->bp); |
@@ -1947,16 +1949,15 @@ xfs_da3_path_shift( | |||
1947 | blk->magic = XFS_ATTR_LEAF_MAGIC; | 1949 | blk->magic = XFS_ATTR_LEAF_MAGIC; |
1948 | ASSERT(level == path->active-1); | 1950 | ASSERT(level == path->active-1); |
1949 | blk->index = 0; | 1951 | blk->index = 0; |
1950 | blk->hashval = xfs_attr_leaf_lasthash(blk->bp, | 1952 | blk->hashval = xfs_attr_leaf_lasthash(blk->bp, NULL); |
1951 | NULL); | ||
1952 | break; | 1953 | break; |
1953 | case XFS_DIR2_LEAFN_MAGIC: | 1954 | case XFS_DIR2_LEAFN_MAGIC: |
1954 | case XFS_DIR3_LEAFN_MAGIC: | 1955 | case XFS_DIR3_LEAFN_MAGIC: |
1955 | blk->magic = XFS_DIR2_LEAFN_MAGIC; | 1956 | blk->magic = XFS_DIR2_LEAFN_MAGIC; |
1956 | ASSERT(level == path->active-1); | 1957 | ASSERT(level == path->active-1); |
1957 | blk->index = 0; | 1958 | blk->index = 0; |
1958 | blk->hashval = xfs_dir2_leafn_lasthash(blk->bp, | 1959 | blk->hashval = xfs_dir2_leafn_lasthash(args->dp, |
1959 | NULL); | 1960 | blk->bp, NULL); |
1960 | break; | 1961 | break; |
1961 | default: | 1962 | default: |
1962 | ASSERT(0); | 1963 | ASSERT(0); |
@@ -2223,7 +2224,7 @@ xfs_da3_swap_lastblock( | |||
2223 | 2224 | ||
2224 | dead_leaf2 = (xfs_dir2_leaf_t *)dead_info; | 2225 | dead_leaf2 = (xfs_dir2_leaf_t *)dead_info; |
2225 | xfs_dir3_leaf_hdr_from_disk(&leafhdr, dead_leaf2); | 2226 | xfs_dir3_leaf_hdr_from_disk(&leafhdr, dead_leaf2); |
2226 | ents = xfs_dir3_leaf_ents_p(dead_leaf2); | 2227 | ents = ip->d_ops->leaf_ents_p(dead_leaf2); |
2227 | dead_level = 0; | 2228 | dead_level = 0; |
2228 | dead_hash = be32_to_cpu(ents[leafhdr.count - 1].hashval); | 2229 | dead_hash = be32_to_cpu(ents[leafhdr.count - 1].hashval); |
2229 | } else { | 2230 | } else { |
diff --git a/fs/xfs/xfs_da_format.c b/fs/xfs/xfs_da_format.c index 1e92a241fd52..ff8b50368c94 100644 --- a/fs/xfs/xfs_da_format.c +++ b/fs/xfs/xfs_da_format.c | |||
@@ -435,6 +435,48 @@ xfs_dir3_data_unused_p(struct xfs_dir2_data_hdr *hdr) | |||
435 | ((char *)hdr + xfs_dir3_data_entry_offset()); | 435 | ((char *)hdr + xfs_dir3_data_entry_offset()); |
436 | } | 436 | } |
437 | 437 | ||
438 | |||
439 | /* | ||
440 | * Directory Leaf block operations | ||
441 | */ | ||
442 | static int | ||
443 | xfs_dir2_leaf_hdr_size(void) | ||
444 | { | ||
445 | return sizeof(struct xfs_dir2_leaf_hdr); | ||
446 | } | ||
447 | |||
448 | static int | ||
449 | xfs_dir2_max_leaf_ents(struct xfs_mount *mp) | ||
450 | { | ||
451 | return (mp->m_dirblksize - xfs_dir2_leaf_hdr_size()) / | ||
452 | (uint)sizeof(struct xfs_dir2_leaf_entry); | ||
453 | } | ||
454 | |||
455 | static struct xfs_dir2_leaf_entry * | ||
456 | xfs_dir2_leaf_ents_p(struct xfs_dir2_leaf *lp) | ||
457 | { | ||
458 | return lp->__ents; | ||
459 | } | ||
460 | |||
461 | static int | ||
462 | xfs_dir3_leaf_hdr_size(void) | ||
463 | { | ||
464 | return sizeof(struct xfs_dir3_leaf_hdr); | ||
465 | } | ||
466 | |||
467 | static inline int | ||
468 | xfs_dir3_max_leaf_ents(struct xfs_mount *mp) | ||
469 | { | ||
470 | return (mp->m_dirblksize - xfs_dir3_leaf_hdr_size()) / | ||
471 | (uint)sizeof(struct xfs_dir2_leaf_entry); | ||
472 | } | ||
473 | |||
474 | static inline struct xfs_dir2_leaf_entry * | ||
475 | xfs_dir3_leaf_ents_p(struct xfs_dir2_leaf *lp) | ||
476 | { | ||
477 | return ((struct xfs_dir3_leaf *)lp)->__ents; | ||
478 | } | ||
479 | |||
438 | const struct xfs_dir_ops xfs_dir2_ops = { | 480 | const struct xfs_dir_ops xfs_dir2_ops = { |
439 | .sf_entsize = xfs_dir2_sf_entsize, | 481 | .sf_entsize = xfs_dir2_sf_entsize, |
440 | .sf_nextentry = xfs_dir2_sf_nextentry, | 482 | .sf_nextentry = xfs_dir2_sf_nextentry, |
@@ -462,6 +504,10 @@ const struct xfs_dir_ops xfs_dir2_ops = { | |||
462 | .data_entry_p = xfs_dir2_data_entry_p, | 504 | .data_entry_p = xfs_dir2_data_entry_p, |
463 | .data_unused_p = xfs_dir2_data_unused_p, | 505 | .data_unused_p = xfs_dir2_data_unused_p, |
464 | 506 | ||
507 | .leaf_hdr_size = xfs_dir2_leaf_hdr_size, | ||
508 | .leaf_max_ents = xfs_dir2_max_leaf_ents, | ||
509 | .leaf_ents_p = xfs_dir2_leaf_ents_p, | ||
510 | |||
465 | }; | 511 | }; |
466 | 512 | ||
467 | const struct xfs_dir_ops xfs_dir2_ftype_ops = { | 513 | const struct xfs_dir_ops xfs_dir2_ftype_ops = { |
@@ -490,6 +536,10 @@ const struct xfs_dir_ops xfs_dir2_ftype_ops = { | |||
490 | .data_first_entry_p = xfs_dir2_data_first_entry_p, | 536 | .data_first_entry_p = xfs_dir2_data_first_entry_p, |
491 | .data_entry_p = xfs_dir2_data_entry_p, | 537 | .data_entry_p = xfs_dir2_data_entry_p, |
492 | .data_unused_p = xfs_dir2_data_unused_p, | 538 | .data_unused_p = xfs_dir2_data_unused_p, |
539 | |||
540 | .leaf_hdr_size = xfs_dir2_leaf_hdr_size, | ||
541 | .leaf_max_ents = xfs_dir2_max_leaf_ents, | ||
542 | .leaf_ents_p = xfs_dir2_leaf_ents_p, | ||
493 | }; | 543 | }; |
494 | 544 | ||
495 | const struct xfs_dir_ops xfs_dir3_ops = { | 545 | const struct xfs_dir_ops xfs_dir3_ops = { |
@@ -518,4 +568,29 @@ const struct xfs_dir_ops xfs_dir3_ops = { | |||
518 | .data_first_entry_p = xfs_dir3_data_first_entry_p, | 568 | .data_first_entry_p = xfs_dir3_data_first_entry_p, |
519 | .data_entry_p = xfs_dir3_data_entry_p, | 569 | .data_entry_p = xfs_dir3_data_entry_p, |
520 | .data_unused_p = xfs_dir3_data_unused_p, | 570 | .data_unused_p = xfs_dir3_data_unused_p, |
571 | |||
572 | .leaf_hdr_size = xfs_dir3_leaf_hdr_size, | ||
573 | .leaf_max_ents = xfs_dir3_max_leaf_ents, | ||
574 | .leaf_ents_p = xfs_dir3_leaf_ents_p, | ||
521 | }; | 575 | }; |
576 | |||
577 | /* | ||
578 | * Return the ops structure according to the current config. If we are passed | ||
579 | * an inode, then that overrides the default config we use which is based on | ||
580 | * feature bits. | ||
581 | */ | ||
582 | const struct xfs_dir_ops * | ||
583 | xfs_dir_get_ops( | ||
584 | struct xfs_mount *mp, | ||
585 | struct xfs_inode *dp) | ||
586 | { | ||
587 | if (dp) | ||
588 | return dp->d_ops; | ||
589 | if (mp->m_dir_inode_ops) | ||
590 | return mp->m_dir_inode_ops; | ||
591 | if (xfs_sb_version_hascrc(&mp->m_sb)) | ||
592 | return &xfs_dir3_ops; | ||
593 | if (xfs_sb_version_hasftype(&mp->m_sb)) | ||
594 | return &xfs_dir2_ftype_ops; | ||
595 | return &xfs_dir2_ops; | ||
596 | } | ||
diff --git a/fs/xfs/xfs_da_format.h b/fs/xfs/xfs_da_format.h index aeca0038a013..0a567e25cf59 100644 --- a/fs/xfs/xfs_da_format.h +++ b/fs/xfs/xfs_da_format.h | |||
@@ -551,36 +551,6 @@ struct xfs_dir3_leaf { | |||
551 | extern void xfs_dir3_leaf_hdr_from_disk(struct xfs_dir3_icleaf_hdr *to, | 551 | extern void xfs_dir3_leaf_hdr_from_disk(struct xfs_dir3_icleaf_hdr *to, |
552 | struct xfs_dir2_leaf *from); | 552 | struct xfs_dir2_leaf *from); |
553 | 553 | ||
554 | static inline int | ||
555 | xfs_dir3_leaf_hdr_size(struct xfs_dir2_leaf *lp) | ||
556 | { | ||
557 | if (lp->hdr.info.magic == cpu_to_be16(XFS_DIR3_LEAF1_MAGIC) || | ||
558 | lp->hdr.info.magic == cpu_to_be16(XFS_DIR3_LEAFN_MAGIC)) | ||
559 | return sizeof(struct xfs_dir3_leaf_hdr); | ||
560 | return sizeof(struct xfs_dir2_leaf_hdr); | ||
561 | } | ||
562 | |||
563 | static inline int | ||
564 | xfs_dir3_max_leaf_ents(struct xfs_mount *mp, struct xfs_dir2_leaf *lp) | ||
565 | { | ||
566 | return (mp->m_dirblksize - xfs_dir3_leaf_hdr_size(lp)) / | ||
567 | (uint)sizeof(struct xfs_dir2_leaf_entry); | ||
568 | } | ||
569 | |||
570 | /* | ||
571 | * Get address of the bestcount field in the single-leaf block. | ||
572 | */ | ||
573 | static inline struct xfs_dir2_leaf_entry * | ||
574 | xfs_dir3_leaf_ents_p(struct xfs_dir2_leaf *lp) | ||
575 | { | ||
576 | if (lp->hdr.info.magic == cpu_to_be16(XFS_DIR3_LEAF1_MAGIC) || | ||
577 | lp->hdr.info.magic == cpu_to_be16(XFS_DIR3_LEAFN_MAGIC)) { | ||
578 | struct xfs_dir3_leaf *lp3 = (struct xfs_dir3_leaf *)lp; | ||
579 | return lp3->__ents; | ||
580 | } | ||
581 | return lp->__ents; | ||
582 | } | ||
583 | |||
584 | /* | 554 | /* |
585 | * Get address of the bestcount field in the single-leaf block. | 555 | * Get address of the bestcount field in the single-leaf block. |
586 | */ | 556 | */ |
diff --git a/fs/xfs/xfs_dir2.c b/fs/xfs/xfs_dir2.c index 7911136453cd..2b98a33ca383 100644 --- a/fs/xfs/xfs_dir2.c +++ b/fs/xfs/xfs_dir2.c | |||
@@ -113,12 +113,7 @@ xfs_dir_mount( | |||
113 | else | 113 | else |
114 | mp->m_dirnameops = &xfs_default_nameops; | 114 | mp->m_dirnameops = &xfs_default_nameops; |
115 | 115 | ||
116 | if (xfs_sb_version_hascrc(&mp->m_sb)) | 116 | mp->m_dir_inode_ops = xfs_dir_get_ops(mp, NULL); |
117 | mp->m_dir_inode_ops = &xfs_dir3_ops; | ||
118 | else if (xfs_sb_version_hasftype(&mp->m_sb)) | ||
119 | mp->m_dir_inode_ops = &xfs_dir2_ftype_ops; | ||
120 | else | ||
121 | mp->m_dir_inode_ops = &xfs_dir2_ops; | ||
122 | } | 117 | } |
123 | 118 | ||
124 | /* | 119 | /* |
diff --git a/fs/xfs/xfs_dir2.h b/fs/xfs/xfs_dir2.h index 076010a1376a..9ba9db731990 100644 --- a/fs/xfs/xfs_dir2.h +++ b/fs/xfs/xfs_dir2.h | |||
@@ -74,11 +74,15 @@ struct xfs_dir_ops { | |||
74 | (*data_entry_p)(struct xfs_dir2_data_hdr *hdr); | 74 | (*data_entry_p)(struct xfs_dir2_data_hdr *hdr); |
75 | struct xfs_dir2_data_unused * | 75 | struct xfs_dir2_data_unused * |
76 | (*data_unused_p)(struct xfs_dir2_data_hdr *hdr); | 76 | (*data_unused_p)(struct xfs_dir2_data_hdr *hdr); |
77 | |||
78 | int (*leaf_hdr_size)(void); | ||
79 | int (*leaf_max_ents)(struct xfs_mount *mp); | ||
80 | struct xfs_dir2_leaf_entry * | ||
81 | (*leaf_ents_p)(struct xfs_dir2_leaf *lp); | ||
77 | }; | 82 | }; |
78 | 83 | ||
79 | extern const struct xfs_dir_ops xfs_dir2_ops; | 84 | extern const struct xfs_dir_ops * |
80 | extern const struct xfs_dir_ops xfs_dir2_ftype_ops; | 85 | xfs_dir_get_ops(struct xfs_mount *mp, struct xfs_inode *dp); |
81 | extern const struct xfs_dir_ops xfs_dir3_ops; | ||
82 | 86 | ||
83 | /* | 87 | /* |
84 | * Generic directory interface routines | 88 | * Generic directory interface routines |
diff --git a/fs/xfs/xfs_dir2_block.c b/fs/xfs/xfs_dir2_block.c index f92ca5699342..75f815786b97 100644 --- a/fs/xfs/xfs_dir2_block.c +++ b/fs/xfs/xfs_dir2_block.c | |||
@@ -937,7 +937,7 @@ xfs_dir2_leaf_to_block( | |||
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 | xfs_dir3_leaf_hdr_from_disk(&leafhdr, leaf); |
940 | ents = xfs_dir3_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 | ||
943 | ASSERT(leafhdr.magic == XFS_DIR2_LEAF1_MAGIC || | 943 | ASSERT(leafhdr.magic == XFS_DIR2_LEAF1_MAGIC || |
diff --git a/fs/xfs/xfs_dir2_data.c b/fs/xfs/xfs_dir2_data.c index 13fa0d6b4ff7..32d657fbe6a4 100644 --- a/fs/xfs/xfs_dir2_data.c +++ b/fs/xfs/xfs_dir2_data.c | |||
@@ -68,17 +68,10 @@ __xfs_dir3_data_check( | |||
68 | hdr = bp->b_addr; | 68 | hdr = bp->b_addr; |
69 | 69 | ||
70 | /* | 70 | /* |
71 | * We can be passed a null dp here from a verifier, so manually | 71 | * We can be passed a null dp here from a verifier, so we need to go the |
72 | * configure the ops here in that case. | 72 | * hard way to get them. |
73 | */ | 73 | */ |
74 | if (dp) | 74 | ops = xfs_dir_get_ops(mp, dp); |
75 | ops = dp->d_ops; | ||
76 | else if (xfs_sb_version_hascrc(&mp->m_sb)) | ||
77 | ops = &xfs_dir3_ops; | ||
78 | else if (xfs_sb_version_hasftype(&mp->m_sb)) | ||
79 | ops = &xfs_dir2_ftype_ops; | ||
80 | else | ||
81 | ops = &xfs_dir2_ops; | ||
82 | 75 | ||
83 | switch (hdr->magic) { | 76 | switch (hdr->magic) { |
84 | case cpu_to_be32(XFS_DIR3_BLOCK_MAGIC): | 77 | case cpu_to_be32(XFS_DIR3_BLOCK_MAGIC): |
diff --git a/fs/xfs/xfs_dir2_leaf.c b/fs/xfs/xfs_dir2_leaf.c index f35b3942c1a6..16fdc0e627a7 100644 --- a/fs/xfs/xfs_dir2_leaf.c +++ b/fs/xfs/xfs_dir2_leaf.c | |||
@@ -50,15 +50,15 @@ static void xfs_dir3_leaf_log_tail(struct xfs_trans *tp, struct xfs_buf *bp); | |||
50 | * Pop an assert if something is wrong. | 50 | * Pop an assert if something is wrong. |
51 | */ | 51 | */ |
52 | #ifdef DEBUG | 52 | #ifdef DEBUG |
53 | #define xfs_dir3_leaf_check(mp, bp) \ | 53 | #define xfs_dir3_leaf_check(dp, bp) \ |
54 | do { \ | 54 | do { \ |
55 | if (!xfs_dir3_leaf1_check((mp), (bp))) \ | 55 | if (!xfs_dir3_leaf1_check((dp), (bp))) \ |
56 | ASSERT(0); \ | 56 | ASSERT(0); \ |
57 | } while (0); | 57 | } while (0); |
58 | 58 | ||
59 | STATIC bool | 59 | STATIC bool |
60 | xfs_dir3_leaf1_check( | 60 | xfs_dir3_leaf1_check( |
61 | struct xfs_mount *mp, | 61 | struct xfs_inode *dp, |
62 | struct xfs_buf *bp) | 62 | struct xfs_buf *bp) |
63 | { | 63 | { |
64 | struct xfs_dir2_leaf *leaf = bp->b_addr; | 64 | struct xfs_dir2_leaf *leaf = bp->b_addr; |
@@ -73,10 +73,10 @@ xfs_dir3_leaf1_check( | |||
73 | } else if (leafhdr.magic != XFS_DIR2_LEAF1_MAGIC) | 73 | } else if (leafhdr.magic != XFS_DIR2_LEAF1_MAGIC) |
74 | return false; | 74 | return false; |
75 | 75 | ||
76 | return xfs_dir3_leaf_check_int(mp, &leafhdr, leaf); | 76 | return xfs_dir3_leaf_check_int(dp->i_mount, dp, &leafhdr, leaf); |
77 | } | 77 | } |
78 | #else | 78 | #else |
79 | #define xfs_dir3_leaf_check(mp, bp) | 79 | #define xfs_dir3_leaf_check(dp, bp) |
80 | #endif | 80 | #endif |
81 | 81 | ||
82 | void | 82 | void |
@@ -138,6 +138,7 @@ xfs_dir3_leaf_hdr_to_disk( | |||
138 | bool | 138 | bool |
139 | xfs_dir3_leaf_check_int( | 139 | xfs_dir3_leaf_check_int( |
140 | struct xfs_mount *mp, | 140 | struct xfs_mount *mp, |
141 | struct xfs_inode *dp, | ||
141 | struct xfs_dir3_icleaf_hdr *hdr, | 142 | struct xfs_dir3_icleaf_hdr *hdr, |
142 | struct xfs_dir2_leaf *leaf) | 143 | struct xfs_dir2_leaf *leaf) |
143 | { | 144 | { |
@@ -145,8 +146,15 @@ xfs_dir3_leaf_check_int( | |||
145 | xfs_dir2_leaf_tail_t *ltp; | 146 | xfs_dir2_leaf_tail_t *ltp; |
146 | int stale; | 147 | int stale; |
147 | int i; | 148 | int i; |
149 | const struct xfs_dir_ops *ops; | ||
148 | 150 | ||
149 | ents = xfs_dir3_leaf_ents_p(leaf); | 151 | /* |
152 | * we can be passed a null dp here from a verifier, so we need to go the | ||
153 | * hard way to get them. | ||
154 | */ | ||
155 | ops = xfs_dir_get_ops(mp, dp); | ||
156 | |||
157 | ents = ops->leaf_ents_p(leaf); | ||
150 | ltp = xfs_dir2_leaf_tail_p(mp, leaf); | 158 | ltp = xfs_dir2_leaf_tail_p(mp, leaf); |
151 | 159 | ||
152 | /* | 160 | /* |
@@ -154,7 +162,7 @@ xfs_dir3_leaf_check_int( | |||
154 | * Should factor in the size of the bests table as well. | 162 | * Should factor in the size of the bests table as well. |
155 | * We can deduce a value for that from di_size. | 163 | * We can deduce a value for that from di_size. |
156 | */ | 164 | */ |
157 | if (hdr->count > xfs_dir3_max_leaf_ents(mp, leaf)) | 165 | if (hdr->count > ops->leaf_max_ents(mp)) |
158 | return false; | 166 | return false; |
159 | 167 | ||
160 | /* Leaves and bests don't overlap in leaf format. */ | 168 | /* Leaves and bests don't overlap in leaf format. */ |
@@ -213,7 +221,7 @@ xfs_dir3_leaf_verify( | |||
213 | } | 221 | } |
214 | 222 | ||
215 | xfs_dir3_leaf_hdr_from_disk(&leafhdr, leaf); | 223 | xfs_dir3_leaf_hdr_from_disk(&leafhdr, leaf); |
216 | return xfs_dir3_leaf_check_int(mp, &leafhdr, leaf); | 224 | return xfs_dir3_leaf_check_int(mp, NULL, &leafhdr, leaf); |
217 | } | 225 | } |
218 | 226 | ||
219 | static void | 227 | static void |
@@ -399,7 +407,7 @@ xfs_dir3_leaf_get_buf( | |||
399 | return error; | 407 | return error; |
400 | 408 | ||
401 | xfs_dir3_leaf_init(mp, tp, bp, dp->i_ino, magic); | 409 | xfs_dir3_leaf_init(mp, tp, bp, dp->i_ino, magic); |
402 | xfs_dir3_leaf_log_header(tp, bp); | 410 | xfs_dir3_leaf_log_header(tp, dp, bp); |
403 | if (magic == XFS_DIR2_LEAF1_MAGIC) | 411 | if (magic == XFS_DIR2_LEAF1_MAGIC) |
404 | xfs_dir3_leaf_log_tail(tp, bp); | 412 | xfs_dir3_leaf_log_tail(tp, bp); |
405 | *bpp = bp; | 413 | *bpp = bp; |
@@ -461,7 +469,7 @@ xfs_dir2_block_to_leaf( | |||
461 | btp = xfs_dir2_block_tail_p(mp, hdr); | 469 | btp = xfs_dir2_block_tail_p(mp, hdr); |
462 | blp = xfs_dir2_block_leaf_p(btp); | 470 | blp = xfs_dir2_block_leaf_p(btp); |
463 | bf = dp->d_ops->data_bestfree_p(hdr); | 471 | bf = dp->d_ops->data_bestfree_p(hdr); |
464 | ents = xfs_dir3_leaf_ents_p(leaf); | 472 | ents = dp->d_ops->leaf_ents_p(leaf); |
465 | 473 | ||
466 | /* | 474 | /* |
467 | * Set the counts in the leaf header. | 475 | * Set the counts in the leaf header. |
@@ -470,14 +478,14 @@ xfs_dir2_block_to_leaf( | |||
470 | leafhdr.count = be32_to_cpu(btp->count); | 478 | leafhdr.count = be32_to_cpu(btp->count); |
471 | leafhdr.stale = be32_to_cpu(btp->stale); | 479 | leafhdr.stale = be32_to_cpu(btp->stale); |
472 | xfs_dir3_leaf_hdr_to_disk(leaf, &leafhdr); | 480 | xfs_dir3_leaf_hdr_to_disk(leaf, &leafhdr); |
473 | xfs_dir3_leaf_log_header(tp, lbp); | 481 | xfs_dir3_leaf_log_header(tp, dp, lbp); |
474 | 482 | ||
475 | /* | 483 | /* |
476 | * Could compact these but I think we always do the conversion | 484 | * Could compact these but I think we always do the conversion |
477 | * after squeezing out stale entries. | 485 | * after squeezing out stale entries. |
478 | */ | 486 | */ |
479 | memcpy(ents, blp, be32_to_cpu(btp->count) * sizeof(xfs_dir2_leaf_entry_t)); | 487 | memcpy(ents, blp, be32_to_cpu(btp->count) * sizeof(xfs_dir2_leaf_entry_t)); |
480 | xfs_dir3_leaf_log_ents(tp, lbp, 0, leafhdr.count - 1); | 488 | xfs_dir3_leaf_log_ents(tp, dp, lbp, 0, leafhdr.count - 1); |
481 | needscan = 0; | 489 | needscan = 0; |
482 | needlog = 1; | 490 | needlog = 1; |
483 | /* | 491 | /* |
@@ -513,7 +521,7 @@ xfs_dir2_block_to_leaf( | |||
513 | */ | 521 | */ |
514 | if (needlog) | 522 | if (needlog) |
515 | xfs_dir2_data_log_header(tp, dp, dbp); | 523 | xfs_dir2_data_log_header(tp, dp, dbp); |
516 | xfs_dir3_leaf_check(mp, lbp); | 524 | xfs_dir3_leaf_check(dp, lbp); |
517 | xfs_dir3_data_check(dp, dbp); | 525 | xfs_dir3_data_check(dp, dbp); |
518 | xfs_dir3_leaf_log_bests(tp, lbp, 0, 0); | 526 | xfs_dir3_leaf_log_bests(tp, lbp, 0, 0); |
519 | return 0; | 527 | return 0; |
@@ -697,7 +705,7 @@ xfs_dir2_leaf_addname( | |||
697 | index = xfs_dir2_leaf_search_hash(args, lbp); | 705 | index = xfs_dir2_leaf_search_hash(args, lbp); |
698 | leaf = lbp->b_addr; | 706 | leaf = lbp->b_addr; |
699 | ltp = xfs_dir2_leaf_tail_p(mp, leaf); | 707 | ltp = xfs_dir2_leaf_tail_p(mp, leaf); |
700 | ents = xfs_dir3_leaf_ents_p(leaf); | 708 | ents = dp->d_ops->leaf_ents_p(leaf); |
701 | xfs_dir3_leaf_hdr_from_disk(&leafhdr, leaf); | 709 | xfs_dir3_leaf_hdr_from_disk(&leafhdr, leaf); |
702 | bestsp = xfs_dir2_leaf_bests_p(ltp); | 710 | bestsp = xfs_dir2_leaf_bests_p(ltp); |
703 | length = dp->d_ops->data_entsize(args->namelen); | 711 | length = dp->d_ops->data_entsize(args->namelen); |
@@ -938,9 +946,9 @@ xfs_dir2_leaf_addname( | |||
938 | * Log the leaf fields and give up the buffers. | 946 | * Log the leaf fields and give up the buffers. |
939 | */ | 947 | */ |
940 | xfs_dir3_leaf_hdr_to_disk(leaf, &leafhdr); | 948 | xfs_dir3_leaf_hdr_to_disk(leaf, &leafhdr); |
941 | xfs_dir3_leaf_log_header(tp, lbp); | 949 | xfs_dir3_leaf_log_header(tp, dp, lbp); |
942 | xfs_dir3_leaf_log_ents(tp, lbp, lfloglow, lfloghigh); | 950 | xfs_dir3_leaf_log_ents(tp, dp, lbp, lfloglow, lfloghigh); |
943 | xfs_dir3_leaf_check(mp, lbp); | 951 | xfs_dir3_leaf_check(dp, lbp); |
944 | xfs_dir3_data_check(dp, dbp); | 952 | xfs_dir3_data_check(dp, dbp); |
945 | return 0; | 953 | return 0; |
946 | } | 954 | } |
@@ -968,7 +976,7 @@ xfs_dir3_leaf_compact( | |||
968 | /* | 976 | /* |
969 | * Compress out the stale entries in place. | 977 | * Compress out the stale entries in place. |
970 | */ | 978 | */ |
971 | ents = xfs_dir3_leaf_ents_p(leaf); | 979 | ents = args->dp->d_ops->leaf_ents_p(leaf); |
972 | for (from = to = 0, loglow = -1; from < leafhdr->count; from++) { | 980 | for (from = to = 0, loglow = -1; from < leafhdr->count; from++) { |
973 | if (ents[from].address == cpu_to_be32(XFS_DIR2_NULL_DATAPTR)) | 981 | if (ents[from].address == cpu_to_be32(XFS_DIR2_NULL_DATAPTR)) |
974 | continue; | 982 | continue; |
@@ -990,9 +998,10 @@ xfs_dir3_leaf_compact( | |||
990 | leafhdr->stale = 0; | 998 | leafhdr->stale = 0; |
991 | 999 | ||
992 | xfs_dir3_leaf_hdr_to_disk(leaf, leafhdr); | 1000 | xfs_dir3_leaf_hdr_to_disk(leaf, leafhdr); |
993 | xfs_dir3_leaf_log_header(args->trans, bp); | 1001 | xfs_dir3_leaf_log_header(args->trans, args->dp, bp); |
994 | if (loglow != -1) | 1002 | if (loglow != -1) |
995 | xfs_dir3_leaf_log_ents(args->trans, bp, loglow, to - 1); | 1003 | xfs_dir3_leaf_log_ents(args->trans, args->dp, bp, |
1004 | loglow, to - 1); | ||
996 | } | 1005 | } |
997 | 1006 | ||
998 | /* | 1007 | /* |
@@ -1119,10 +1128,11 @@ xfs_dir3_leaf_log_bests( | |||
1119 | */ | 1128 | */ |
1120 | void | 1129 | void |
1121 | xfs_dir3_leaf_log_ents( | 1130 | xfs_dir3_leaf_log_ents( |
1122 | xfs_trans_t *tp, /* transaction pointer */ | 1131 | struct xfs_trans *tp, |
1123 | struct xfs_buf *bp, /* leaf buffer */ | 1132 | struct xfs_inode *dp, |
1124 | int first, /* first entry to log */ | 1133 | struct xfs_buf *bp, |
1125 | int last) /* last entry to log */ | 1134 | int first, |
1135 | int last) | ||
1126 | { | 1136 | { |
1127 | xfs_dir2_leaf_entry_t *firstlep; /* pointer to first entry */ | 1137 | xfs_dir2_leaf_entry_t *firstlep; /* pointer to first entry */ |
1128 | xfs_dir2_leaf_entry_t *lastlep; /* pointer to last entry */ | 1138 | xfs_dir2_leaf_entry_t *lastlep; /* pointer to last entry */ |
@@ -1134,7 +1144,7 @@ xfs_dir3_leaf_log_ents( | |||
1134 | leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC) || | 1144 | leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC) || |
1135 | leaf->hdr.info.magic == cpu_to_be16(XFS_DIR3_LEAFN_MAGIC)); | 1145 | leaf->hdr.info.magic == cpu_to_be16(XFS_DIR3_LEAFN_MAGIC)); |
1136 | 1146 | ||
1137 | ents = xfs_dir3_leaf_ents_p(leaf); | 1147 | ents = dp->d_ops->leaf_ents_p(leaf); |
1138 | firstlep = &ents[first]; | 1148 | firstlep = &ents[first]; |
1139 | lastlep = &ents[last]; | 1149 | lastlep = &ents[last]; |
1140 | xfs_trans_log_buf(tp, bp, (uint)((char *)firstlep - (char *)leaf), | 1150 | xfs_trans_log_buf(tp, bp, (uint)((char *)firstlep - (char *)leaf), |
@@ -1147,6 +1157,7 @@ xfs_dir3_leaf_log_ents( | |||
1147 | void | 1157 | void |
1148 | xfs_dir3_leaf_log_header( | 1158 | xfs_dir3_leaf_log_header( |
1149 | struct xfs_trans *tp, | 1159 | struct xfs_trans *tp, |
1160 | struct xfs_inode *dp, | ||
1150 | struct xfs_buf *bp) | 1161 | struct xfs_buf *bp) |
1151 | { | 1162 | { |
1152 | struct xfs_dir2_leaf *leaf = bp->b_addr; | 1163 | struct xfs_dir2_leaf *leaf = bp->b_addr; |
@@ -1157,7 +1168,7 @@ xfs_dir3_leaf_log_header( | |||
1157 | leaf->hdr.info.magic == cpu_to_be16(XFS_DIR3_LEAFN_MAGIC)); | 1168 | leaf->hdr.info.magic == cpu_to_be16(XFS_DIR3_LEAFN_MAGIC)); |
1158 | 1169 | ||
1159 | xfs_trans_log_buf(tp, bp, (uint)((char *)&leaf->hdr - (char *)leaf), | 1170 | xfs_trans_log_buf(tp, bp, (uint)((char *)&leaf->hdr - (char *)leaf), |
1160 | xfs_dir3_leaf_hdr_size(leaf) - 1); | 1171 | dp->d_ops->leaf_hdr_size() - 1); |
1161 | } | 1172 | } |
1162 | 1173 | ||
1163 | /* | 1174 | /* |
@@ -1212,9 +1223,9 @@ xfs_dir2_leaf_lookup( | |||
1212 | } | 1223 | } |
1213 | tp = args->trans; | 1224 | tp = args->trans; |
1214 | dp = args->dp; | 1225 | dp = args->dp; |
1215 | xfs_dir3_leaf_check(dp->i_mount, lbp); | 1226 | xfs_dir3_leaf_check(dp, lbp); |
1216 | leaf = lbp->b_addr; | 1227 | leaf = lbp->b_addr; |
1217 | ents = xfs_dir3_leaf_ents_p(leaf); | 1228 | ents = dp->d_ops->leaf_ents_p(leaf); |
1218 | /* | 1229 | /* |
1219 | * Get to the leaf entry and contained data entry address. | 1230 | * Get to the leaf entry and contained data entry address. |
1220 | */ | 1231 | */ |
@@ -1277,8 +1288,8 @@ xfs_dir2_leaf_lookup_int( | |||
1277 | 1288 | ||
1278 | *lbpp = lbp; | 1289 | *lbpp = lbp; |
1279 | leaf = lbp->b_addr; | 1290 | leaf = lbp->b_addr; |
1280 | xfs_dir3_leaf_check(mp, lbp); | 1291 | xfs_dir3_leaf_check(dp, lbp); |
1281 | ents = xfs_dir3_leaf_ents_p(leaf); | 1292 | ents = dp->d_ops->leaf_ents_p(leaf); |
1282 | xfs_dir3_leaf_hdr_from_disk(&leafhdr, leaf); | 1293 | xfs_dir3_leaf_hdr_from_disk(&leafhdr, leaf); |
1283 | 1294 | ||
1284 | /* | 1295 | /* |
@@ -1415,7 +1426,7 @@ xfs_dir2_leaf_removename( | |||
1415 | xfs_dir3_data_check(dp, dbp); | 1426 | xfs_dir3_data_check(dp, dbp); |
1416 | bf = dp->d_ops->data_bestfree_p(hdr); | 1427 | bf = dp->d_ops->data_bestfree_p(hdr); |
1417 | xfs_dir3_leaf_hdr_from_disk(&leafhdr, leaf); | 1428 | xfs_dir3_leaf_hdr_from_disk(&leafhdr, leaf); |
1418 | ents = xfs_dir3_leaf_ents_p(leaf); | 1429 | ents = dp->d_ops->leaf_ents_p(leaf); |
1419 | /* | 1430 | /* |
1420 | * Point to the leaf entry, use that to point to the data entry. | 1431 | * Point to the leaf entry, use that to point to the data entry. |
1421 | */ | 1432 | */ |
@@ -1439,10 +1450,10 @@ xfs_dir2_leaf_removename( | |||
1439 | */ | 1450 | */ |
1440 | leafhdr.stale++; | 1451 | leafhdr.stale++; |
1441 | xfs_dir3_leaf_hdr_to_disk(leaf, &leafhdr); | 1452 | xfs_dir3_leaf_hdr_to_disk(leaf, &leafhdr); |
1442 | xfs_dir3_leaf_log_header(tp, lbp); | 1453 | xfs_dir3_leaf_log_header(tp, dp, lbp); |
1443 | 1454 | ||
1444 | lep->address = cpu_to_be32(XFS_DIR2_NULL_DATAPTR); | 1455 | lep->address = cpu_to_be32(XFS_DIR2_NULL_DATAPTR); |
1445 | xfs_dir3_leaf_log_ents(tp, lbp, index, index); | 1456 | xfs_dir3_leaf_log_ents(tp, dp, lbp, index, index); |
1446 | 1457 | ||
1447 | /* | 1458 | /* |
1448 | * Scan the freespace in the data block again if necessary, | 1459 | * Scan the freespace in the data block again if necessary, |
@@ -1476,7 +1487,7 @@ xfs_dir2_leaf_removename( | |||
1476 | */ | 1487 | */ |
1477 | if (error == ENOSPC && args->total == 0) | 1488 | if (error == ENOSPC && args->total == 0) |
1478 | error = 0; | 1489 | error = 0; |
1479 | xfs_dir3_leaf_check(mp, lbp); | 1490 | xfs_dir3_leaf_check(dp, lbp); |
1480 | return error; | 1491 | return error; |
1481 | } | 1492 | } |
1482 | dbp = NULL; | 1493 | dbp = NULL; |
@@ -1510,7 +1521,7 @@ xfs_dir2_leaf_removename( | |||
1510 | else if (db != mp->m_dirdatablk) | 1521 | else if (db != mp->m_dirdatablk) |
1511 | dbp = NULL; | 1522 | dbp = NULL; |
1512 | 1523 | ||
1513 | xfs_dir3_leaf_check(mp, lbp); | 1524 | xfs_dir3_leaf_check(dp, lbp); |
1514 | /* | 1525 | /* |
1515 | * See if we can convert to block form. | 1526 | * See if we can convert to block form. |
1516 | */ | 1527 | */ |
@@ -1545,7 +1556,7 @@ xfs_dir2_leaf_replace( | |||
1545 | } | 1556 | } |
1546 | dp = args->dp; | 1557 | dp = args->dp; |
1547 | leaf = lbp->b_addr; | 1558 | leaf = lbp->b_addr; |
1548 | ents = xfs_dir3_leaf_ents_p(leaf); | 1559 | ents = dp->d_ops->leaf_ents_p(leaf); |
1549 | /* | 1560 | /* |
1550 | * Point to the leaf entry, get data address from it. | 1561 | * Point to the leaf entry, get data address from it. |
1551 | */ | 1562 | */ |
@@ -1564,7 +1575,7 @@ xfs_dir2_leaf_replace( | |||
1564 | dp->d_ops->data_put_ftype(dep, args->filetype); | 1575 | dp->d_ops->data_put_ftype(dep, args->filetype); |
1565 | tp = args->trans; | 1576 | tp = args->trans; |
1566 | xfs_dir2_data_log_entry(tp, dp, dbp, dep); | 1577 | xfs_dir2_data_log_entry(tp, dp, dbp, dep); |
1567 | xfs_dir3_leaf_check(dp->i_mount, lbp); | 1578 | xfs_dir3_leaf_check(dp, lbp); |
1568 | xfs_trans_brelse(tp, lbp); | 1579 | xfs_trans_brelse(tp, lbp); |
1569 | return 0; | 1580 | return 0; |
1570 | } | 1581 | } |
@@ -1590,7 +1601,7 @@ xfs_dir2_leaf_search_hash( | |||
1590 | struct xfs_dir3_icleaf_hdr leafhdr; | 1601 | struct xfs_dir3_icleaf_hdr leafhdr; |
1591 | 1602 | ||
1592 | leaf = lbp->b_addr; | 1603 | leaf = lbp->b_addr; |
1593 | ents = xfs_dir3_leaf_ents_p(leaf); | 1604 | ents = args->dp->d_ops->leaf_ents_p(leaf); |
1594 | xfs_dir3_leaf_hdr_from_disk(&leafhdr, leaf); | 1605 | xfs_dir3_leaf_hdr_from_disk(&leafhdr, leaf); |
1595 | 1606 | ||
1596 | /* | 1607 | /* |
@@ -1830,10 +1841,10 @@ xfs_dir2_node_to_leaf( | |||
1830 | freehdr.nvalid * sizeof(xfs_dir2_data_off_t)); | 1841 | freehdr.nvalid * sizeof(xfs_dir2_data_off_t)); |
1831 | 1842 | ||
1832 | xfs_dir3_leaf_hdr_to_disk(leaf, &leafhdr); | 1843 | xfs_dir3_leaf_hdr_to_disk(leaf, &leafhdr); |
1833 | xfs_dir3_leaf_log_header(tp, lbp); | 1844 | xfs_dir3_leaf_log_header(tp, dp, lbp); |
1834 | xfs_dir3_leaf_log_bests(tp, lbp, 0, be32_to_cpu(ltp->bestcount) - 1); | 1845 | xfs_dir3_leaf_log_bests(tp, lbp, 0, be32_to_cpu(ltp->bestcount) - 1); |
1835 | xfs_dir3_leaf_log_tail(tp, lbp); | 1846 | xfs_dir3_leaf_log_tail(tp, lbp); |
1836 | xfs_dir3_leaf_check(mp, lbp); | 1847 | xfs_dir3_leaf_check(dp, lbp); |
1837 | 1848 | ||
1838 | /* | 1849 | /* |
1839 | * Get rid of the freespace block. | 1850 | * Get rid of the freespace block. |
diff --git a/fs/xfs/xfs_dir2_node.c b/fs/xfs/xfs_dir2_node.c index 9cfc00323b19..3a426ed9b16e 100644 --- a/fs/xfs/xfs_dir2_node.c +++ b/fs/xfs/xfs_dir2_node.c | |||
@@ -54,15 +54,15 @@ static int xfs_dir2_node_addname_int(xfs_da_args_t *args, | |||
54 | * Check internal consistency of a leafn block. | 54 | * Check internal consistency of a leafn block. |
55 | */ | 55 | */ |
56 | #ifdef DEBUG | 56 | #ifdef DEBUG |
57 | #define xfs_dir3_leaf_check(mp, bp) \ | 57 | #define xfs_dir3_leaf_check(dp, bp) \ |
58 | do { \ | 58 | do { \ |
59 | if (!xfs_dir3_leafn_check((mp), (bp))) \ | 59 | if (!xfs_dir3_leafn_check((dp), (bp))) \ |
60 | ASSERT(0); \ | 60 | ASSERT(0); \ |
61 | } while (0); | 61 | } while (0); |
62 | 62 | ||
63 | static bool | 63 | static bool |
64 | xfs_dir3_leafn_check( | 64 | xfs_dir3_leafn_check( |
65 | struct xfs_mount *mp, | 65 | struct xfs_inode *dp, |
66 | struct xfs_buf *bp) | 66 | struct xfs_buf *bp) |
67 | { | 67 | { |
68 | struct xfs_dir2_leaf *leaf = bp->b_addr; | 68 | struct xfs_dir2_leaf *leaf = bp->b_addr; |
@@ -77,10 +77,10 @@ xfs_dir3_leafn_check( | |||
77 | } else if (leafhdr.magic != XFS_DIR2_LEAFN_MAGIC) | 77 | } else if (leafhdr.magic != XFS_DIR2_LEAFN_MAGIC) |
78 | return false; | 78 | return false; |
79 | 79 | ||
80 | return xfs_dir3_leaf_check_int(mp, &leafhdr, leaf); | 80 | return xfs_dir3_leaf_check_int(dp->i_mount, dp, &leafhdr, leaf); |
81 | } | 81 | } |
82 | #else | 82 | #else |
83 | #define xfs_dir3_leaf_check(mp, bp) | 83 | #define xfs_dir3_leaf_check(dp, bp) |
84 | #endif | 84 | #endif |
85 | 85 | ||
86 | static bool | 86 | static bool |
@@ -408,8 +408,8 @@ xfs_dir2_leaf_to_node( | |||
408 | leaf->hdr.info.magic = cpu_to_be16(XFS_DIR3_LEAFN_MAGIC); | 408 | leaf->hdr.info.magic = cpu_to_be16(XFS_DIR3_LEAFN_MAGIC); |
409 | lbp->b_ops = &xfs_dir3_leafn_buf_ops; | 409 | lbp->b_ops = &xfs_dir3_leafn_buf_ops; |
410 | xfs_trans_buf_set_type(tp, lbp, XFS_BLFT_DIR_LEAFN_BUF); | 410 | xfs_trans_buf_set_type(tp, lbp, XFS_BLFT_DIR_LEAFN_BUF); |
411 | xfs_dir3_leaf_log_header(tp, lbp); | 411 | xfs_dir3_leaf_log_header(tp, dp, lbp); |
412 | xfs_dir3_leaf_check(mp, lbp); | 412 | xfs_dir3_leaf_check(dp, lbp); |
413 | return 0; | 413 | return 0; |
414 | } | 414 | } |
415 | 415 | ||
@@ -443,7 +443,7 @@ xfs_dir2_leafn_add( | |||
443 | tp = args->trans; | 443 | tp = args->trans; |
444 | leaf = bp->b_addr; | 444 | leaf = bp->b_addr; |
445 | xfs_dir3_leaf_hdr_from_disk(&leafhdr, leaf); | 445 | xfs_dir3_leaf_hdr_from_disk(&leafhdr, leaf); |
446 | ents = xfs_dir3_leaf_ents_p(leaf); | 446 | ents = dp->d_ops->leaf_ents_p(leaf); |
447 | 447 | ||
448 | /* | 448 | /* |
449 | * Quick check just to make sure we are not going to index | 449 | * Quick check just to make sure we are not going to index |
@@ -459,7 +459,7 @@ xfs_dir2_leafn_add( | |||
459 | * a compact. | 459 | * a compact. |
460 | */ | 460 | */ |
461 | 461 | ||
462 | if (leafhdr.count == xfs_dir3_max_leaf_ents(mp, leaf)) { | 462 | if (leafhdr.count == dp->d_ops->leaf_max_ents(mp)) { |
463 | if (!leafhdr.stale) | 463 | if (!leafhdr.stale) |
464 | return XFS_ERROR(ENOSPC); | 464 | return XFS_ERROR(ENOSPC); |
465 | compact = leafhdr.stale > 1; | 465 | compact = leafhdr.stale > 1; |
@@ -498,9 +498,9 @@ xfs_dir2_leafn_add( | |||
498 | args->blkno, args->index)); | 498 | args->blkno, args->index)); |
499 | 499 | ||
500 | xfs_dir3_leaf_hdr_to_disk(leaf, &leafhdr); | 500 | xfs_dir3_leaf_hdr_to_disk(leaf, &leafhdr); |
501 | xfs_dir3_leaf_log_header(tp, bp); | 501 | xfs_dir3_leaf_log_header(tp, dp, bp); |
502 | xfs_dir3_leaf_log_ents(tp, bp, lfloglow, lfloghigh); | 502 | xfs_dir3_leaf_log_ents(tp, dp, bp, lfloglow, lfloghigh); |
503 | xfs_dir3_leaf_check(mp, bp); | 503 | xfs_dir3_leaf_check(dp, bp); |
504 | return 0; | 504 | return 0; |
505 | } | 505 | } |
506 | 506 | ||
@@ -529,6 +529,7 @@ xfs_dir2_free_hdr_check( | |||
529 | */ | 529 | */ |
530 | xfs_dahash_t /* hash value */ | 530 | xfs_dahash_t /* hash value */ |
531 | xfs_dir2_leafn_lasthash( | 531 | xfs_dir2_leafn_lasthash( |
532 | struct xfs_inode *dp, | ||
532 | struct xfs_buf *bp, /* leaf buffer */ | 533 | struct xfs_buf *bp, /* leaf buffer */ |
533 | int *count) /* count of entries in leaf */ | 534 | int *count) /* count of entries in leaf */ |
534 | { | 535 | { |
@@ -546,7 +547,7 @@ xfs_dir2_leafn_lasthash( | |||
546 | if (!leafhdr.count) | 547 | if (!leafhdr.count) |
547 | return 0; | 548 | return 0; |
548 | 549 | ||
549 | ents = xfs_dir3_leaf_ents_p(leaf); | 550 | ents = dp->d_ops->leaf_ents_p(leaf); |
550 | return be32_to_cpu(ents[leafhdr.count - 1].hashval); | 551 | return be32_to_cpu(ents[leafhdr.count - 1].hashval); |
551 | } | 552 | } |
552 | 553 | ||
@@ -584,9 +585,9 @@ xfs_dir2_leafn_lookup_for_addname( | |||
584 | mp = dp->i_mount; | 585 | mp = dp->i_mount; |
585 | leaf = bp->b_addr; | 586 | leaf = bp->b_addr; |
586 | xfs_dir3_leaf_hdr_from_disk(&leafhdr, leaf); | 587 | xfs_dir3_leaf_hdr_from_disk(&leafhdr, leaf); |
587 | ents = xfs_dir3_leaf_ents_p(leaf); | 588 | ents = dp->d_ops->leaf_ents_p(leaf); |
588 | 589 | ||
589 | xfs_dir3_leaf_check(mp, bp); | 590 | xfs_dir3_leaf_check(dp, bp); |
590 | ASSERT(leafhdr.count > 0); | 591 | ASSERT(leafhdr.count > 0); |
591 | 592 | ||
592 | /* | 593 | /* |
@@ -734,9 +735,9 @@ xfs_dir2_leafn_lookup_for_entry( | |||
734 | mp = dp->i_mount; | 735 | mp = dp->i_mount; |
735 | leaf = bp->b_addr; | 736 | leaf = bp->b_addr; |
736 | xfs_dir3_leaf_hdr_from_disk(&leafhdr, leaf); | 737 | xfs_dir3_leaf_hdr_from_disk(&leafhdr, leaf); |
737 | ents = xfs_dir3_leaf_ents_p(leaf); | 738 | ents = dp->d_ops->leaf_ents_p(leaf); |
738 | 739 | ||
739 | xfs_dir3_leaf_check(mp, bp); | 740 | xfs_dir3_leaf_check(dp, bp); |
740 | ASSERT(leafhdr.count > 0); | 741 | ASSERT(leafhdr.count > 0); |
741 | 742 | ||
742 | /* | 743 | /* |
@@ -906,7 +907,7 @@ xfs_dir3_leafn_moveents( | |||
906 | if (start_d < dhdr->count) { | 907 | if (start_d < dhdr->count) { |
907 | memmove(&dents[start_d + count], &dents[start_d], | 908 | memmove(&dents[start_d + count], &dents[start_d], |
908 | (dhdr->count - start_d) * sizeof(xfs_dir2_leaf_entry_t)); | 909 | (dhdr->count - start_d) * sizeof(xfs_dir2_leaf_entry_t)); |
909 | xfs_dir3_leaf_log_ents(tp, bp_d, start_d + count, | 910 | xfs_dir3_leaf_log_ents(tp, args->dp, bp_d, start_d + count, |
910 | count + dhdr->count - 1); | 911 | count + dhdr->count - 1); |
911 | } | 912 | } |
912 | /* | 913 | /* |
@@ -928,7 +929,8 @@ xfs_dir3_leafn_moveents( | |||
928 | */ | 929 | */ |
929 | memcpy(&dents[start_d], &sents[start_s], | 930 | memcpy(&dents[start_d], &sents[start_s], |
930 | count * sizeof(xfs_dir2_leaf_entry_t)); | 931 | count * sizeof(xfs_dir2_leaf_entry_t)); |
931 | xfs_dir3_leaf_log_ents(tp, bp_d, start_d, start_d + count - 1); | 932 | xfs_dir3_leaf_log_ents(tp, args->dp, bp_d, |
933 | start_d, start_d + count - 1); | ||
932 | 934 | ||
933 | /* | 935 | /* |
934 | * If there are source entries after the ones we copied, | 936 | * If there are source entries after the ones we copied, |
@@ -937,7 +939,8 @@ xfs_dir3_leafn_moveents( | |||
937 | if (start_s + count < shdr->count) { | 939 | if (start_s + count < shdr->count) { |
938 | memmove(&sents[start_s], &sents[start_s + count], | 940 | memmove(&sents[start_s], &sents[start_s + count], |
939 | count * sizeof(xfs_dir2_leaf_entry_t)); | 941 | count * sizeof(xfs_dir2_leaf_entry_t)); |
940 | xfs_dir3_leaf_log_ents(tp, bp_s, start_s, start_s + count - 1); | 942 | xfs_dir3_leaf_log_ents(tp, args->dp, bp_s, |
943 | start_s, start_s + count - 1); | ||
941 | } | 944 | } |
942 | 945 | ||
943 | /* | 946 | /* |
@@ -955,6 +958,7 @@ xfs_dir3_leafn_moveents( | |||
955 | */ | 958 | */ |
956 | int /* sort order */ | 959 | int /* sort order */ |
957 | xfs_dir2_leafn_order( | 960 | xfs_dir2_leafn_order( |
961 | struct xfs_inode *dp, | ||
958 | struct xfs_buf *leaf1_bp, /* leaf1 buffer */ | 962 | struct xfs_buf *leaf1_bp, /* leaf1 buffer */ |
959 | struct xfs_buf *leaf2_bp) /* leaf2 buffer */ | 963 | struct xfs_buf *leaf2_bp) /* leaf2 buffer */ |
960 | { | 964 | { |
@@ -967,8 +971,8 @@ xfs_dir2_leafn_order( | |||
967 | 971 | ||
968 | xfs_dir3_leaf_hdr_from_disk(&hdr1, leaf1); | 972 | xfs_dir3_leaf_hdr_from_disk(&hdr1, leaf1); |
969 | xfs_dir3_leaf_hdr_from_disk(&hdr2, leaf2); | 973 | xfs_dir3_leaf_hdr_from_disk(&hdr2, leaf2); |
970 | ents1 = xfs_dir3_leaf_ents_p(leaf1); | 974 | ents1 = dp->d_ops->leaf_ents_p(leaf1); |
971 | ents2 = xfs_dir3_leaf_ents_p(leaf2); | 975 | ents2 = dp->d_ops->leaf_ents_p(leaf2); |
972 | 976 | ||
973 | if (hdr1.count > 0 && hdr2.count > 0 && | 977 | if (hdr1.count > 0 && hdr2.count > 0 && |
974 | (be32_to_cpu(ents2[0].hashval) < be32_to_cpu(ents1[0].hashval) || | 978 | (be32_to_cpu(ents2[0].hashval) < be32_to_cpu(ents1[0].hashval) || |
@@ -1006,12 +1010,13 @@ xfs_dir2_leafn_rebalance( | |||
1006 | struct xfs_dir2_leaf_entry *ents2; | 1010 | struct xfs_dir2_leaf_entry *ents2; |
1007 | struct xfs_dir3_icleaf_hdr hdr1; | 1011 | struct xfs_dir3_icleaf_hdr hdr1; |
1008 | struct xfs_dir3_icleaf_hdr hdr2; | 1012 | struct xfs_dir3_icleaf_hdr hdr2; |
1013 | struct xfs_inode *dp = state->args->dp; | ||
1009 | 1014 | ||
1010 | args = state->args; | 1015 | args = state->args; |
1011 | /* | 1016 | /* |
1012 | * If the block order is wrong, swap the arguments. | 1017 | * If the block order is wrong, swap the arguments. |
1013 | */ | 1018 | */ |
1014 | if ((swap = xfs_dir2_leafn_order(blk1->bp, blk2->bp))) { | 1019 | if ((swap = xfs_dir2_leafn_order(dp, blk1->bp, blk2->bp))) { |
1015 | xfs_da_state_blk_t *tmp; /* temp for block swap */ | 1020 | xfs_da_state_blk_t *tmp; /* temp for block swap */ |
1016 | 1021 | ||
1017 | tmp = blk1; | 1022 | tmp = blk1; |
@@ -1022,8 +1027,8 @@ xfs_dir2_leafn_rebalance( | |||
1022 | leaf2 = blk2->bp->b_addr; | 1027 | leaf2 = blk2->bp->b_addr; |
1023 | xfs_dir3_leaf_hdr_from_disk(&hdr1, leaf1); | 1028 | xfs_dir3_leaf_hdr_from_disk(&hdr1, leaf1); |
1024 | xfs_dir3_leaf_hdr_from_disk(&hdr2, leaf2); | 1029 | xfs_dir3_leaf_hdr_from_disk(&hdr2, leaf2); |
1025 | ents1 = xfs_dir3_leaf_ents_p(leaf1); | 1030 | ents1 = dp->d_ops->leaf_ents_p(leaf1); |
1026 | ents2 = xfs_dir3_leaf_ents_p(leaf2); | 1031 | ents2 = dp->d_ops->leaf_ents_p(leaf2); |
1027 | 1032 | ||
1028 | oldsum = hdr1.count + hdr2.count; | 1033 | oldsum = hdr1.count + hdr2.count; |
1029 | #if defined(DEBUG) || defined(XFS_WARN) | 1034 | #if defined(DEBUG) || defined(XFS_WARN) |
@@ -1071,11 +1076,11 @@ xfs_dir2_leafn_rebalance( | |||
1071 | /* log the changes made when moving the entries */ | 1076 | /* log the changes made when moving the entries */ |
1072 | xfs_dir3_leaf_hdr_to_disk(leaf1, &hdr1); | 1077 | xfs_dir3_leaf_hdr_to_disk(leaf1, &hdr1); |
1073 | xfs_dir3_leaf_hdr_to_disk(leaf2, &hdr2); | 1078 | xfs_dir3_leaf_hdr_to_disk(leaf2, &hdr2); |
1074 | xfs_dir3_leaf_log_header(args->trans, blk1->bp); | 1079 | xfs_dir3_leaf_log_header(args->trans, dp, blk1->bp); |
1075 | xfs_dir3_leaf_log_header(args->trans, blk2->bp); | 1080 | xfs_dir3_leaf_log_header(args->trans, dp, blk2->bp); |
1076 | 1081 | ||
1077 | xfs_dir3_leaf_check(args->dp->i_mount, blk1->bp); | 1082 | xfs_dir3_leaf_check(dp, blk1->bp); |
1078 | xfs_dir3_leaf_check(args->dp->i_mount, blk2->bp); | 1083 | xfs_dir3_leaf_check(dp, blk2->bp); |
1079 | 1084 | ||
1080 | /* | 1085 | /* |
1081 | * Mark whether we're inserting into the old or new leaf. | 1086 | * Mark whether we're inserting into the old or new leaf. |
@@ -1096,10 +1101,10 @@ xfs_dir2_leafn_rebalance( | |||
1096 | * Finally sanity check just to make sure we are not returning a | 1101 | * Finally sanity check just to make sure we are not returning a |
1097 | * negative index | 1102 | * negative index |
1098 | */ | 1103 | */ |
1099 | if(blk2->index < 0) { | 1104 | if (blk2->index < 0) { |
1100 | state->inleaf = 1; | 1105 | state->inleaf = 1; |
1101 | blk2->index = 0; | 1106 | blk2->index = 0; |
1102 | xfs_alert(args->dp->i_mount, | 1107 | xfs_alert(dp->i_mount, |
1103 | "%s: picked the wrong leaf? reverting original leaf: blk1->index %d", | 1108 | "%s: picked the wrong leaf? reverting original leaf: blk1->index %d", |
1104 | __func__, blk1->index); | 1109 | __func__, blk1->index); |
1105 | } | 1110 | } |
@@ -1222,7 +1227,7 @@ xfs_dir2_leafn_remove( | |||
1222 | mp = dp->i_mount; | 1227 | mp = dp->i_mount; |
1223 | leaf = bp->b_addr; | 1228 | leaf = bp->b_addr; |
1224 | xfs_dir3_leaf_hdr_from_disk(&leafhdr, leaf); | 1229 | xfs_dir3_leaf_hdr_from_disk(&leafhdr, leaf); |
1225 | ents = xfs_dir3_leaf_ents_p(leaf); | 1230 | ents = dp->d_ops->leaf_ents_p(leaf); |
1226 | 1231 | ||
1227 | /* | 1232 | /* |
1228 | * Point to the entry we're removing. | 1233 | * Point to the entry we're removing. |
@@ -1243,10 +1248,10 @@ xfs_dir2_leafn_remove( | |||
1243 | */ | 1248 | */ |
1244 | leafhdr.stale++; | 1249 | leafhdr.stale++; |
1245 | xfs_dir3_leaf_hdr_to_disk(leaf, &leafhdr); | 1250 | xfs_dir3_leaf_hdr_to_disk(leaf, &leafhdr); |
1246 | xfs_dir3_leaf_log_header(tp, bp); | 1251 | xfs_dir3_leaf_log_header(tp, dp, bp); |
1247 | 1252 | ||
1248 | lep->address = cpu_to_be32(XFS_DIR2_NULL_DATAPTR); | 1253 | lep->address = cpu_to_be32(XFS_DIR2_NULL_DATAPTR); |
1249 | xfs_dir3_leaf_log_ents(tp, bp, index, index); | 1254 | xfs_dir3_leaf_log_ents(tp, dp, bp, index, index); |
1250 | 1255 | ||
1251 | /* | 1256 | /* |
1252 | * Make the data entry free. Keep track of the longest freespace | 1257 | * Make the data entry free. Keep track of the longest freespace |
@@ -1335,12 +1340,12 @@ xfs_dir2_leafn_remove( | |||
1335 | return error; | 1340 | return error; |
1336 | } | 1341 | } |
1337 | 1342 | ||
1338 | xfs_dir3_leaf_check(mp, bp); | 1343 | xfs_dir3_leaf_check(dp, bp); |
1339 | /* | 1344 | /* |
1340 | * Return indication of whether this leaf block is empty enough | 1345 | * Return indication of whether this leaf block is empty enough |
1341 | * to justify trying to join it with a neighbor. | 1346 | * to justify trying to join it with a neighbor. |
1342 | */ | 1347 | */ |
1343 | *rval = (xfs_dir3_leaf_hdr_size(leaf) + | 1348 | *rval = (dp->d_ops->leaf_hdr_size() + |
1344 | (uint)sizeof(ents[0]) * (leafhdr.count - leafhdr.stale)) < | 1349 | (uint)sizeof(ents[0]) * (leafhdr.count - leafhdr.stale)) < |
1345 | mp->m_dir_magicpct; | 1350 | mp->m_dir_magicpct; |
1346 | return 0; | 1351 | return 0; |
@@ -1359,12 +1364,14 @@ xfs_dir2_leafn_split( | |||
1359 | xfs_dablk_t blkno; /* new leaf block number */ | 1364 | xfs_dablk_t blkno; /* new leaf block number */ |
1360 | int error; /* error return value */ | 1365 | int error; /* error return value */ |
1361 | xfs_mount_t *mp; /* filesystem mount point */ | 1366 | xfs_mount_t *mp; /* filesystem mount point */ |
1367 | struct xfs_inode *dp; | ||
1362 | 1368 | ||
1363 | /* | 1369 | /* |
1364 | * Allocate space for a new leaf node. | 1370 | * Allocate space for a new leaf node. |
1365 | */ | 1371 | */ |
1366 | args = state->args; | 1372 | args = state->args; |
1367 | mp = args->dp->i_mount; | 1373 | dp = args->dp; |
1374 | mp = dp->i_mount; | ||
1368 | ASSERT(args != NULL); | 1375 | ASSERT(args != NULL); |
1369 | ASSERT(oldblk->magic == XFS_DIR2_LEAFN_MAGIC); | 1376 | ASSERT(oldblk->magic == XFS_DIR2_LEAFN_MAGIC); |
1370 | error = xfs_da_grow_inode(args, &blkno); | 1377 | error = xfs_da_grow_inode(args, &blkno); |
@@ -1400,10 +1407,10 @@ xfs_dir2_leafn_split( | |||
1400 | /* | 1407 | /* |
1401 | * Update last hashval in each block since we added the name. | 1408 | * Update last hashval in each block since we added the name. |
1402 | */ | 1409 | */ |
1403 | oldblk->hashval = xfs_dir2_leafn_lasthash(oldblk->bp, NULL); | 1410 | oldblk->hashval = xfs_dir2_leafn_lasthash(dp, oldblk->bp, NULL); |
1404 | newblk->hashval = xfs_dir2_leafn_lasthash(newblk->bp, NULL); | 1411 | newblk->hashval = xfs_dir2_leafn_lasthash(dp, newblk->bp, NULL); |
1405 | xfs_dir3_leaf_check(mp, oldblk->bp); | 1412 | xfs_dir3_leaf_check(dp, oldblk->bp); |
1406 | xfs_dir3_leaf_check(mp, newblk->bp); | 1413 | xfs_dir3_leaf_check(dp, newblk->bp); |
1407 | return error; | 1414 | return error; |
1408 | } | 1415 | } |
1409 | 1416 | ||
@@ -1433,6 +1440,7 @@ xfs_dir2_leafn_toosmall( | |||
1433 | int rval; /* result from path_shift */ | 1440 | int rval; /* result from path_shift */ |
1434 | struct xfs_dir3_icleaf_hdr leafhdr; | 1441 | struct xfs_dir3_icleaf_hdr leafhdr; |
1435 | struct xfs_dir2_leaf_entry *ents; | 1442 | struct xfs_dir2_leaf_entry *ents; |
1443 | struct xfs_inode *dp = state->args->dp; | ||
1436 | 1444 | ||
1437 | /* | 1445 | /* |
1438 | * Check for the degenerate case of the block being over 50% full. | 1446 | * Check for the degenerate case of the block being over 50% full. |
@@ -1442,11 +1450,11 @@ xfs_dir2_leafn_toosmall( | |||
1442 | blk = &state->path.blk[state->path.active - 1]; | 1450 | blk = &state->path.blk[state->path.active - 1]; |
1443 | leaf = blk->bp->b_addr; | 1451 | leaf = blk->bp->b_addr; |
1444 | xfs_dir3_leaf_hdr_from_disk(&leafhdr, leaf); | 1452 | xfs_dir3_leaf_hdr_from_disk(&leafhdr, leaf); |
1445 | ents = xfs_dir3_leaf_ents_p(leaf); | 1453 | ents = dp->d_ops->leaf_ents_p(leaf); |
1446 | xfs_dir3_leaf_check(state->args->dp->i_mount, blk->bp); | 1454 | xfs_dir3_leaf_check(dp, blk->bp); |
1447 | 1455 | ||
1448 | count = leafhdr.count - leafhdr.stale; | 1456 | count = leafhdr.count - leafhdr.stale; |
1449 | bytes = xfs_dir3_leaf_hdr_size(leaf) + count * sizeof(ents[0]); | 1457 | bytes = dp->d_ops->leaf_hdr_size() + count * sizeof(ents[0]); |
1450 | if (bytes > (state->blocksize >> 1)) { | 1458 | if (bytes > (state->blocksize >> 1)) { |
1451 | /* | 1459 | /* |
1452 | * Blk over 50%, don't try to join. | 1460 | * Blk over 50%, don't try to join. |
@@ -1491,7 +1499,7 @@ xfs_dir2_leafn_toosmall( | |||
1491 | /* | 1499 | /* |
1492 | * Read the sibling leaf block. | 1500 | * Read the sibling leaf block. |
1493 | */ | 1501 | */ |
1494 | error = xfs_dir3_leafn_read(state->args->trans, state->args->dp, | 1502 | error = xfs_dir3_leafn_read(state->args->trans, dp, |
1495 | blkno, -1, &bp); | 1503 | blkno, -1, &bp); |
1496 | if (error) | 1504 | if (error) |
1497 | return error; | 1505 | return error; |
@@ -1504,7 +1512,7 @@ xfs_dir2_leafn_toosmall( | |||
1504 | 1512 | ||
1505 | leaf = bp->b_addr; | 1513 | leaf = bp->b_addr; |
1506 | xfs_dir3_leaf_hdr_from_disk(&hdr2, leaf); | 1514 | xfs_dir3_leaf_hdr_from_disk(&hdr2, leaf); |
1507 | ents = xfs_dir3_leaf_ents_p(leaf); | 1515 | ents = dp->d_ops->leaf_ents_p(leaf); |
1508 | count += hdr2.count - hdr2.stale; | 1516 | count += hdr2.count - hdr2.stale; |
1509 | bytes -= count * sizeof(ents[0]); | 1517 | bytes -= count * sizeof(ents[0]); |
1510 | 1518 | ||
@@ -1558,6 +1566,7 @@ xfs_dir2_leafn_unbalance( | |||
1558 | struct xfs_dir3_icleaf_hdr drophdr; | 1566 | struct xfs_dir3_icleaf_hdr drophdr; |
1559 | struct xfs_dir2_leaf_entry *sents; | 1567 | struct xfs_dir2_leaf_entry *sents; |
1560 | struct xfs_dir2_leaf_entry *dents; | 1568 | struct xfs_dir2_leaf_entry *dents; |
1569 | struct xfs_inode *dp = state->args->dp; | ||
1561 | 1570 | ||
1562 | args = state->args; | 1571 | args = state->args; |
1563 | ASSERT(drop_blk->magic == XFS_DIR2_LEAFN_MAGIC); | 1572 | ASSERT(drop_blk->magic == XFS_DIR2_LEAFN_MAGIC); |
@@ -1567,8 +1576,8 @@ xfs_dir2_leafn_unbalance( | |||
1567 | 1576 | ||
1568 | xfs_dir3_leaf_hdr_from_disk(&savehdr, save_leaf); | 1577 | xfs_dir3_leaf_hdr_from_disk(&savehdr, save_leaf); |
1569 | xfs_dir3_leaf_hdr_from_disk(&drophdr, drop_leaf); | 1578 | xfs_dir3_leaf_hdr_from_disk(&drophdr, drop_leaf); |
1570 | sents = xfs_dir3_leaf_ents_p(save_leaf); | 1579 | sents = args->dp->d_ops->leaf_ents_p(save_leaf); |
1571 | dents = xfs_dir3_leaf_ents_p(drop_leaf); | 1580 | dents = args->dp->d_ops->leaf_ents_p(drop_leaf); |
1572 | 1581 | ||
1573 | /* | 1582 | /* |
1574 | * If there are any stale leaf entries, take this opportunity | 1583 | * If there are any stale leaf entries, take this opportunity |
@@ -1583,7 +1592,7 @@ xfs_dir2_leafn_unbalance( | |||
1583 | * Move the entries from drop to the appropriate end of save. | 1592 | * Move the entries from drop to the appropriate end of save. |
1584 | */ | 1593 | */ |
1585 | drop_blk->hashval = be32_to_cpu(dents[drophdr.count - 1].hashval); | 1594 | drop_blk->hashval = be32_to_cpu(dents[drophdr.count - 1].hashval); |
1586 | if (xfs_dir2_leafn_order(save_blk->bp, drop_blk->bp)) | 1595 | if (xfs_dir2_leafn_order(dp, save_blk->bp, drop_blk->bp)) |
1587 | xfs_dir3_leafn_moveents(args, drop_blk->bp, &drophdr, dents, 0, | 1596 | xfs_dir3_leafn_moveents(args, drop_blk->bp, &drophdr, dents, 0, |
1588 | save_blk->bp, &savehdr, sents, 0, | 1597 | save_blk->bp, &savehdr, sents, 0, |
1589 | drophdr.count); | 1598 | drophdr.count); |
@@ -1596,11 +1605,11 @@ xfs_dir2_leafn_unbalance( | |||
1596 | /* log the changes made when moving the entries */ | 1605 | /* log the changes made when moving the entries */ |
1597 | xfs_dir3_leaf_hdr_to_disk(save_leaf, &savehdr); | 1606 | xfs_dir3_leaf_hdr_to_disk(save_leaf, &savehdr); |
1598 | xfs_dir3_leaf_hdr_to_disk(drop_leaf, &drophdr); | 1607 | xfs_dir3_leaf_hdr_to_disk(drop_leaf, &drophdr); |
1599 | xfs_dir3_leaf_log_header(args->trans, save_blk->bp); | 1608 | xfs_dir3_leaf_log_header(args->trans, dp, save_blk->bp); |
1600 | xfs_dir3_leaf_log_header(args->trans, drop_blk->bp); | 1609 | xfs_dir3_leaf_log_header(args->trans, dp, drop_blk->bp); |
1601 | 1610 | ||
1602 | xfs_dir3_leaf_check(args->dp->i_mount, save_blk->bp); | 1611 | xfs_dir3_leaf_check(dp, save_blk->bp); |
1603 | xfs_dir3_leaf_check(args->dp->i_mount, drop_blk->bp); | 1612 | xfs_dir3_leaf_check(dp, drop_blk->bp); |
1604 | } | 1613 | } |
1605 | 1614 | ||
1606 | /* | 1615 | /* |
@@ -2211,7 +2220,7 @@ xfs_dir2_node_replace( | |||
2211 | blk = &state->path.blk[state->path.active - 1]; | 2220 | blk = &state->path.blk[state->path.active - 1]; |
2212 | ASSERT(blk->magic == XFS_DIR2_LEAFN_MAGIC); | 2221 | ASSERT(blk->magic == XFS_DIR2_LEAFN_MAGIC); |
2213 | leaf = blk->bp->b_addr; | 2222 | leaf = blk->bp->b_addr; |
2214 | ents = xfs_dir3_leaf_ents_p(leaf); | 2223 | ents = args->dp->d_ops->leaf_ents_p(leaf); |
2215 | lep = &ents[blk->index]; | 2224 | lep = &ents[blk->index]; |
2216 | ASSERT(state->extravalid); | 2225 | ASSERT(state->extravalid); |
2217 | /* | 2226 | /* |
diff --git a/fs/xfs/xfs_dir2_priv.h b/fs/xfs/xfs_dir2_priv.h index 9a69f206daf9..3e4b5ba7b41f 100644 --- a/fs/xfs/xfs_dir2_priv.h +++ b/fs/xfs/xfs_dir2_priv.h | |||
@@ -77,9 +77,9 @@ extern void xfs_dir3_leaf_compact_x1(struct xfs_dir3_icleaf_hdr *leafhdr, | |||
77 | int *lowstalep, int *highstalep, int *lowlogp, int *highlogp); | 77 | int *lowstalep, int *highstalep, int *lowlogp, int *highlogp); |
78 | extern int xfs_dir3_leaf_get_buf(struct xfs_da_args *args, xfs_dir2_db_t bno, | 78 | extern int xfs_dir3_leaf_get_buf(struct xfs_da_args *args, xfs_dir2_db_t bno, |
79 | struct xfs_buf **bpp, __uint16_t magic); | 79 | struct xfs_buf **bpp, __uint16_t magic); |
80 | extern void xfs_dir3_leaf_log_ents(struct xfs_trans *tp, struct xfs_buf *bp, | 80 | extern void xfs_dir3_leaf_log_ents(struct xfs_trans *tp, struct xfs_inode *dp, |
81 | int first, int last); | 81 | struct xfs_buf *bp, int first, int last); |
82 | extern void xfs_dir3_leaf_log_header(struct xfs_trans *tp, | 82 | extern void xfs_dir3_leaf_log_header(struct xfs_trans *tp, struct xfs_inode *dp, |
83 | struct xfs_buf *bp); | 83 | struct xfs_buf *bp); |
84 | extern int xfs_dir2_leaf_lookup(struct xfs_da_args *args); | 84 | extern int xfs_dir2_leaf_lookup(struct xfs_da_args *args); |
85 | extern int xfs_dir2_leaf_removename(struct xfs_da_args *args); | 85 | extern int xfs_dir2_leaf_removename(struct xfs_da_args *args); |
@@ -98,17 +98,18 @@ extern void xfs_dir3_leaf_hdr_from_disk(struct xfs_dir3_icleaf_hdr *to, | |||
98 | struct xfs_dir2_leaf *from); | 98 | struct xfs_dir2_leaf *from); |
99 | extern void xfs_dir3_leaf_hdr_to_disk(struct xfs_dir2_leaf *to, | 99 | extern void xfs_dir3_leaf_hdr_to_disk(struct xfs_dir2_leaf *to, |
100 | struct xfs_dir3_icleaf_hdr *from); | 100 | struct xfs_dir3_icleaf_hdr *from); |
101 | extern bool xfs_dir3_leaf_check_int(struct xfs_mount *mp, | 101 | extern 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); | 102 | struct xfs_dir3_icleaf_hdr *hdr, struct xfs_dir2_leaf *leaf); |
103 | 103 | ||
104 | /* xfs_dir2_node.c */ | 104 | /* xfs_dir2_node.c */ |
105 | extern int xfs_dir2_leaf_to_node(struct xfs_da_args *args, | 105 | extern int xfs_dir2_leaf_to_node(struct xfs_da_args *args, |
106 | struct xfs_buf *lbp); | 106 | struct xfs_buf *lbp); |
107 | extern xfs_dahash_t xfs_dir2_leafn_lasthash(struct xfs_buf *bp, int *count); | 107 | extern xfs_dahash_t xfs_dir2_leafn_lasthash(struct xfs_inode *dp, |
108 | struct xfs_buf *bp, int *count); | ||
108 | extern int xfs_dir2_leafn_lookup_int(struct xfs_buf *bp, | 109 | extern int xfs_dir2_leafn_lookup_int(struct xfs_buf *bp, |
109 | struct xfs_da_args *args, int *indexp, | 110 | struct xfs_da_args *args, int *indexp, |
110 | struct xfs_da_state *state); | 111 | struct xfs_da_state *state); |
111 | extern int xfs_dir2_leafn_order(struct xfs_buf *leaf1_bp, | 112 | extern int xfs_dir2_leafn_order(struct xfs_inode *dp, struct xfs_buf *leaf1_bp, |
112 | struct xfs_buf *leaf2_bp); | 113 | struct xfs_buf *leaf2_bp); |
113 | extern int xfs_dir2_leafn_split(struct xfs_da_state *state, | 114 | extern int xfs_dir2_leafn_split(struct xfs_da_state *state, |
114 | struct xfs_da_state_blk *oldblk, struct xfs_da_state_blk *newblk); | 115 | struct xfs_da_state_blk *oldblk, struct xfs_da_state_blk *newblk); |