diff options
author | Dave Chinner <dchinner@redhat.com> | 2014-06-06 01:04:05 -0400 |
---|---|---|
committer | Dave Chinner <david@fromorbit.com> | 2014-06-06 01:04:05 -0400 |
commit | 892e3f342f9888066f1ce56f3683572f0ca9b8e9 (patch) | |
tree | 508f81ba0ec6727315dd4bd91e4754668ca7589c | |
parent | 0650b55497ef583c43d6afc80e11a39e92d9a525 (diff) |
xfs: move directory block translatiosn to xfs_dir2_priv.h
Because they aren't actually part of the on-disk format, and so
shouldn't be in xfs_da_format.h.
Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
-rw-r--r-- | fs/xfs/xfs_da_format.c | 2 | ||||
-rw-r--r-- | fs/xfs/xfs_da_format.h | 138 | ||||
-rw-r--r-- | fs/xfs/xfs_dir2_priv.h | 137 |
3 files changed, 139 insertions, 138 deletions
diff --git a/fs/xfs/xfs_da_format.c b/fs/xfs/xfs_da_format.c index e6c83e1fbc8a..f4a783b0359c 100644 --- a/fs/xfs/xfs_da_format.c +++ b/fs/xfs/xfs_da_format.c | |||
@@ -26,8 +26,10 @@ | |||
26 | #include "xfs_ag.h" | 26 | #include "xfs_ag.h" |
27 | #include "xfs_mount.h" | 27 | #include "xfs_mount.h" |
28 | #include "xfs_da_format.h" | 28 | #include "xfs_da_format.h" |
29 | #include "xfs_da_btree.h" | ||
29 | #include "xfs_inode.h" | 30 | #include "xfs_inode.h" |
30 | #include "xfs_dir2.h" | 31 | #include "xfs_dir2.h" |
32 | #include "xfs_dir2_priv.h" | ||
31 | 33 | ||
32 | /* | 34 | /* |
33 | * Shortform directory ops | 35 | * Shortform directory ops |
diff --git a/fs/xfs/xfs_da_format.h b/fs/xfs/xfs_da_format.h index 1432b576b4a7..32b415ce7798 100644 --- a/fs/xfs/xfs_da_format.h +++ b/fs/xfs/xfs_da_format.h | |||
@@ -514,17 +514,6 @@ struct xfs_dir3_leaf { | |||
514 | #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) |
515 | 515 | ||
516 | /* | 516 | /* |
517 | * Get address of the bestcount field in the single-leaf block. | ||
518 | */ | ||
519 | static inline struct xfs_dir2_leaf_tail * | ||
520 | xfs_dir2_leaf_tail_p(struct xfs_mount *mp, struct xfs_dir2_leaf *lp) | ||
521 | { | ||
522 | return (struct xfs_dir2_leaf_tail *) | ||
523 | ((char *)lp + mp->m_dirblksize - | ||
524 | sizeof(struct xfs_dir2_leaf_tail)); | ||
525 | } | ||
526 | |||
527 | /* | ||
528 | * Get address of the bests array in the single-leaf block. | 517 | * Get address of the bests array in the single-leaf block. |
529 | */ | 518 | */ |
530 | static inline __be16 * | 519 | static inline __be16 * |
@@ -534,123 +523,6 @@ xfs_dir2_leaf_bests_p(struct xfs_dir2_leaf_tail *ltp) | |||
534 | } | 523 | } |
535 | 524 | ||
536 | /* | 525 | /* |
537 | * DB blocks here are logical directory block numbers, not filesystem blocks. | ||
538 | */ | ||
539 | |||
540 | /* | ||
541 | * Convert dataptr to byte in file space | ||
542 | */ | ||
543 | static inline xfs_dir2_off_t | ||
544 | xfs_dir2_dataptr_to_byte(xfs_dir2_dataptr_t dp) | ||
545 | { | ||
546 | return (xfs_dir2_off_t)dp << XFS_DIR2_DATA_ALIGN_LOG; | ||
547 | } | ||
548 | |||
549 | /* | ||
550 | * Convert byte in file space to dataptr. It had better be aligned. | ||
551 | */ | ||
552 | static inline xfs_dir2_dataptr_t | ||
553 | xfs_dir2_byte_to_dataptr(xfs_dir2_off_t by) | ||
554 | { | ||
555 | return (xfs_dir2_dataptr_t)(by >> XFS_DIR2_DATA_ALIGN_LOG); | ||
556 | } | ||
557 | |||
558 | /* | ||
559 | * Convert byte in space to (DB) block | ||
560 | */ | ||
561 | static inline xfs_dir2_db_t | ||
562 | xfs_dir2_byte_to_db(struct xfs_mount *mp, xfs_dir2_off_t by) | ||
563 | { | ||
564 | return (xfs_dir2_db_t) | ||
565 | (by >> (mp->m_sb.sb_blocklog + mp->m_sb.sb_dirblklog)); | ||
566 | } | ||
567 | |||
568 | /* | ||
569 | * Convert dataptr to a block number | ||
570 | */ | ||
571 | static inline xfs_dir2_db_t | ||
572 | xfs_dir2_dataptr_to_db(struct xfs_mount *mp, xfs_dir2_dataptr_t dp) | ||
573 | { | ||
574 | return xfs_dir2_byte_to_db(mp, xfs_dir2_dataptr_to_byte(dp)); | ||
575 | } | ||
576 | |||
577 | /* | ||
578 | * Convert byte in space to offset in a block | ||
579 | */ | ||
580 | static inline xfs_dir2_data_aoff_t | ||
581 | xfs_dir2_byte_to_off(struct xfs_mount *mp, xfs_dir2_off_t by) | ||
582 | { | ||
583 | return (xfs_dir2_data_aoff_t)(by & | ||
584 | ((1 << (mp->m_sb.sb_blocklog + mp->m_sb.sb_dirblklog)) - 1)); | ||
585 | } | ||
586 | |||
587 | /* | ||
588 | * Convert dataptr to a byte offset in a block | ||
589 | */ | ||
590 | static inline xfs_dir2_data_aoff_t | ||
591 | xfs_dir2_dataptr_to_off(struct xfs_mount *mp, xfs_dir2_dataptr_t dp) | ||
592 | { | ||
593 | return xfs_dir2_byte_to_off(mp, xfs_dir2_dataptr_to_byte(dp)); | ||
594 | } | ||
595 | |||
596 | /* | ||
597 | * Convert block and offset to byte in space | ||
598 | */ | ||
599 | static inline xfs_dir2_off_t | ||
600 | xfs_dir2_db_off_to_byte(struct xfs_mount *mp, xfs_dir2_db_t db, | ||
601 | xfs_dir2_data_aoff_t o) | ||
602 | { | ||
603 | return ((xfs_dir2_off_t)db << | ||
604 | (mp->m_sb.sb_blocklog + mp->m_sb.sb_dirblklog)) + o; | ||
605 | } | ||
606 | |||
607 | /* | ||
608 | * Convert block (DB) to block (dablk) | ||
609 | */ | ||
610 | static inline xfs_dablk_t | ||
611 | xfs_dir2_db_to_da(struct xfs_mount *mp, xfs_dir2_db_t db) | ||
612 | { | ||
613 | return (xfs_dablk_t)(db << mp->m_sb.sb_dirblklog); | ||
614 | } | ||
615 | |||
616 | /* | ||
617 | * Convert byte in space to (DA) block | ||
618 | */ | ||
619 | static inline xfs_dablk_t | ||
620 | xfs_dir2_byte_to_da(struct xfs_mount *mp, xfs_dir2_off_t by) | ||
621 | { | ||
622 | return xfs_dir2_db_to_da(mp, xfs_dir2_byte_to_db(mp, by)); | ||
623 | } | ||
624 | |||
625 | /* | ||
626 | * Convert block and offset to dataptr | ||
627 | */ | ||
628 | static inline xfs_dir2_dataptr_t | ||
629 | xfs_dir2_db_off_to_dataptr(struct xfs_mount *mp, xfs_dir2_db_t db, | ||
630 | xfs_dir2_data_aoff_t o) | ||
631 | { | ||
632 | return xfs_dir2_byte_to_dataptr(xfs_dir2_db_off_to_byte(mp, db, o)); | ||
633 | } | ||
634 | |||
635 | /* | ||
636 | * Convert block (dablk) to block (DB) | ||
637 | */ | ||
638 | static inline xfs_dir2_db_t | ||
639 | xfs_dir2_da_to_db(struct xfs_mount *mp, xfs_dablk_t da) | ||
640 | { | ||
641 | return (xfs_dir2_db_t)(da >> mp->m_sb.sb_dirblklog); | ||
642 | } | ||
643 | |||
644 | /* | ||
645 | * Convert block (dablk) to byte offset in space | ||
646 | */ | ||
647 | static inline xfs_dir2_off_t | ||
648 | xfs_dir2_da_to_byte(struct xfs_mount *mp, xfs_dablk_t da) | ||
649 | { | ||
650 | return xfs_dir2_db_off_to_byte(mp, xfs_dir2_da_to_db(mp, da), 0); | ||
651 | } | ||
652 | |||
653 | /* | ||
654 | * Free space block defintions for the node format. | 526 | * Free space block defintions for the node format. |
655 | */ | 527 | */ |
656 | 528 | ||
@@ -736,16 +608,6 @@ typedef struct xfs_dir2_block_tail { | |||
736 | } xfs_dir2_block_tail_t; | 608 | } xfs_dir2_block_tail_t; |
737 | 609 | ||
738 | /* | 610 | /* |
739 | * Pointer to the leaf header embedded in a data block (1-block format) | ||
740 | */ | ||
741 | static inline struct xfs_dir2_block_tail * | ||
742 | xfs_dir2_block_tail_p(struct xfs_mount *mp, struct xfs_dir2_data_hdr *hdr) | ||
743 | { | ||
744 | return ((struct xfs_dir2_block_tail *) | ||
745 | ((char *)hdr + mp->m_dirblksize)) - 1; | ||
746 | } | ||
747 | |||
748 | /* | ||
749 | * Pointer to the leaf entries embedded in a data block (1-block format) | 611 | * Pointer to the leaf entries embedded in a data block (1-block format) |
750 | */ | 612 | */ |
751 | static inline struct xfs_dir2_leaf_entry * | 613 | static inline struct xfs_dir2_leaf_entry * |
diff --git a/fs/xfs/xfs_dir2_priv.h b/fs/xfs/xfs_dir2_priv.h index 2429960739e9..492edb6e07a7 100644 --- a/fs/xfs/xfs_dir2_priv.h +++ b/fs/xfs/xfs_dir2_priv.h | |||
@@ -20,6 +20,143 @@ | |||
20 | 20 | ||
21 | struct dir_context; | 21 | struct dir_context; |
22 | 22 | ||
23 | /* | ||
24 | * Directory offset/block conversion functions. | ||
25 | * | ||
26 | * DB blocks here are logical directory block numbers, not filesystem blocks. | ||
27 | */ | ||
28 | |||
29 | /* | ||
30 | * Convert dataptr to byte in file space | ||
31 | */ | ||
32 | static inline xfs_dir2_off_t | ||
33 | xfs_dir2_dataptr_to_byte(xfs_dir2_dataptr_t dp) | ||
34 | { | ||
35 | return (xfs_dir2_off_t)dp << XFS_DIR2_DATA_ALIGN_LOG; | ||
36 | } | ||
37 | |||
38 | /* | ||
39 | * Convert byte in file space to dataptr. It had better be aligned. | ||
40 | */ | ||
41 | static inline xfs_dir2_dataptr_t | ||
42 | xfs_dir2_byte_to_dataptr(xfs_dir2_off_t by) | ||
43 | { | ||
44 | return (xfs_dir2_dataptr_t)(by >> XFS_DIR2_DATA_ALIGN_LOG); | ||
45 | } | ||
46 | |||
47 | /* | ||
48 | * Convert byte in space to (DB) block | ||
49 | */ | ||
50 | static inline xfs_dir2_db_t | ||
51 | xfs_dir2_byte_to_db(struct xfs_mount *mp, xfs_dir2_off_t by) | ||
52 | { | ||
53 | return (xfs_dir2_db_t) | ||
54 | (by >> (mp->m_sb.sb_blocklog + mp->m_sb.sb_dirblklog)); | ||
55 | } | ||
56 | |||
57 | /* | ||
58 | * Convert dataptr to a block number | ||
59 | */ | ||
60 | static inline xfs_dir2_db_t | ||
61 | xfs_dir2_dataptr_to_db(struct xfs_mount *mp, xfs_dir2_dataptr_t dp) | ||
62 | { | ||
63 | return xfs_dir2_byte_to_db(mp, xfs_dir2_dataptr_to_byte(dp)); | ||
64 | } | ||
65 | |||
66 | /* | ||
67 | * Convert byte in space to offset in a block | ||
68 | */ | ||
69 | static inline xfs_dir2_data_aoff_t | ||
70 | xfs_dir2_byte_to_off(struct xfs_mount *mp, xfs_dir2_off_t by) | ||
71 | { | ||
72 | return (xfs_dir2_data_aoff_t)(by & | ||
73 | ((1 << (mp->m_sb.sb_blocklog + mp->m_sb.sb_dirblklog)) - 1)); | ||
74 | } | ||
75 | |||
76 | /* | ||
77 | * Convert dataptr to a byte offset in a block | ||
78 | */ | ||
79 | static inline xfs_dir2_data_aoff_t | ||
80 | xfs_dir2_dataptr_to_off(struct xfs_mount *mp, xfs_dir2_dataptr_t dp) | ||
81 | { | ||
82 | return xfs_dir2_byte_to_off(mp, xfs_dir2_dataptr_to_byte(dp)); | ||
83 | } | ||
84 | |||
85 | /* | ||
86 | * Convert block and offset to byte in space | ||
87 | */ | ||
88 | static inline xfs_dir2_off_t | ||
89 | xfs_dir2_db_off_to_byte(struct xfs_mount *mp, xfs_dir2_db_t db, | ||
90 | xfs_dir2_data_aoff_t o) | ||
91 | { | ||
92 | return ((xfs_dir2_off_t)db << | ||
93 | (mp->m_sb.sb_blocklog + mp->m_sb.sb_dirblklog)) + o; | ||
94 | } | ||
95 | |||
96 | /* | ||
97 | * Convert block (DB) to block (dablk) | ||
98 | */ | ||
99 | static inline xfs_dablk_t | ||
100 | xfs_dir2_db_to_da(struct xfs_mount *mp, xfs_dir2_db_t db) | ||
101 | { | ||
102 | return (xfs_dablk_t)(db << mp->m_sb.sb_dirblklog); | ||
103 | } | ||
104 | |||
105 | /* | ||
106 | * Convert byte in space to (DA) block | ||
107 | */ | ||
108 | static inline xfs_dablk_t | ||
109 | xfs_dir2_byte_to_da(struct xfs_mount *mp, xfs_dir2_off_t by) | ||
110 | { | ||
111 | return xfs_dir2_db_to_da(mp, xfs_dir2_byte_to_db(mp, by)); | ||
112 | } | ||
113 | |||
114 | /* | ||
115 | * Convert block and offset to dataptr | ||
116 | */ | ||
117 | static inline xfs_dir2_dataptr_t | ||
118 | xfs_dir2_db_off_to_dataptr(struct xfs_mount *mp, xfs_dir2_db_t db, | ||
119 | xfs_dir2_data_aoff_t o) | ||
120 | { | ||
121 | return xfs_dir2_byte_to_dataptr(xfs_dir2_db_off_to_byte(mp, db, o)); | ||
122 | } | ||
123 | |||
124 | /* | ||
125 | * Convert block (dablk) to block (DB) | ||
126 | */ | ||
127 | static inline xfs_dir2_db_t | ||
128 | xfs_dir2_da_to_db(struct xfs_mount *mp, xfs_dablk_t da) | ||
129 | { | ||
130 | return (xfs_dir2_db_t)(da >> mp->m_sb.sb_dirblklog); | ||
131 | } | ||
132 | |||
133 | /* | ||
134 | * Convert block (dablk) to byte offset in space | ||
135 | */ | ||
136 | static inline xfs_dir2_off_t | ||
137 | xfs_dir2_da_to_byte(struct xfs_mount *mp, xfs_dablk_t da) | ||
138 | { | ||
139 | return xfs_dir2_db_off_to_byte(mp, xfs_dir2_da_to_db(mp, da), 0); | ||
140 | } | ||
141 | |||
142 | /* | ||
143 | * Directory tail pointer accessor functions. Based on block geometry. | ||
144 | */ | ||
145 | static inline struct xfs_dir2_block_tail * | ||
146 | xfs_dir2_block_tail_p(struct xfs_mount *mp, struct xfs_dir2_data_hdr *hdr) | ||
147 | { | ||
148 | return ((struct xfs_dir2_block_tail *) | ||
149 | ((char *)hdr + mp->m_dirblksize)) - 1; | ||
150 | } | ||
151 | |||
152 | static inline struct xfs_dir2_leaf_tail * | ||
153 | xfs_dir2_leaf_tail_p(struct xfs_mount *mp, struct xfs_dir2_leaf *lp) | ||
154 | { | ||
155 | return (struct xfs_dir2_leaf_tail *) | ||
156 | ((char *)lp + mp->m_dirblksize - | ||
157 | sizeof(struct xfs_dir2_leaf_tail)); | ||
158 | } | ||
159 | |||
23 | /* xfs_dir2.c */ | 160 | /* xfs_dir2.c */ |
24 | extern int xfs_dir_ino_validate(struct xfs_mount *mp, xfs_ino_t ino); | 161 | extern int xfs_dir_ino_validate(struct xfs_mount *mp, xfs_ino_t ino); |
25 | extern int xfs_dir2_grow_inode(struct xfs_da_args *args, int space, | 162 | extern int xfs_dir2_grow_inode(struct xfs_da_args *args, int space, |