aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Chinner <dchinner@redhat.com>2014-06-06 01:04:05 -0400
committerDave Chinner <david@fromorbit.com>2014-06-06 01:04:05 -0400
commit892e3f342f9888066f1ce56f3683572f0ca9b8e9 (patch)
tree508f81ba0ec6727315dd4bd91e4754668ca7589c
parent0650b55497ef583c43d6afc80e11a39e92d9a525 (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.c2
-rw-r--r--fs/xfs/xfs_da_format.h138
-rw-r--r--fs/xfs/xfs_dir2_priv.h137
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 */
519static inline struct xfs_dir2_leaf_tail *
520xfs_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 */
530static inline __be16 * 519static 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 */
543static inline xfs_dir2_off_t
544xfs_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 */
552static inline xfs_dir2_dataptr_t
553xfs_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 */
561static inline xfs_dir2_db_t
562xfs_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 */
571static inline xfs_dir2_db_t
572xfs_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 */
580static inline xfs_dir2_data_aoff_t
581xfs_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 */
590static inline xfs_dir2_data_aoff_t
591xfs_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 */
599static inline xfs_dir2_off_t
600xfs_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 */
610static inline xfs_dablk_t
611xfs_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 */
619static inline xfs_dablk_t
620xfs_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 */
628static inline xfs_dir2_dataptr_t
629xfs_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 */
638static inline xfs_dir2_db_t
639xfs_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 */
647static inline xfs_dir2_off_t
648xfs_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 */
741static inline struct xfs_dir2_block_tail *
742xfs_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 */
751static inline struct xfs_dir2_leaf_entry * 613static 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
21struct dir_context; 21struct 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 */
32static inline xfs_dir2_off_t
33xfs_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 */
41static inline xfs_dir2_dataptr_t
42xfs_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 */
50static inline xfs_dir2_db_t
51xfs_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 */
60static inline xfs_dir2_db_t
61xfs_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 */
69static inline xfs_dir2_data_aoff_t
70xfs_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 */
79static inline xfs_dir2_data_aoff_t
80xfs_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 */
88static inline xfs_dir2_off_t
89xfs_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 */
99static inline xfs_dablk_t
100xfs_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 */
108static inline xfs_dablk_t
109xfs_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 */
117static inline xfs_dir2_dataptr_t
118xfs_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 */
127static inline xfs_dir2_db_t
128xfs_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 */
136static inline xfs_dir2_off_t
137xfs_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 */
145static inline struct xfs_dir2_block_tail *
146xfs_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
152static inline struct xfs_dir2_leaf_tail *
153xfs_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 */
24extern int xfs_dir_ino_validate(struct xfs_mount *mp, xfs_ino_t ino); 161extern int xfs_dir_ino_validate(struct xfs_mount *mp, xfs_ino_t ino);
25extern int xfs_dir2_grow_inode(struct xfs_da_args *args, int space, 162extern int xfs_dir2_grow_inode(struct xfs_da_args *args, int space,