1
2
3
4
5
6
7#ifndef __XFS_DA_BTREE_H__
8#define __XFS_DA_BTREE_H__
9
10struct xfs_inode;
11struct xfs_trans;
12struct zone;
13
14
15
16
17
18
19struct xfs_da_geometry {
20 unsigned int blksize;
21 unsigned int fsbcount;
22 uint8_t fsblog;
23 uint8_t blklog;
24 unsigned int node_hdr_size;
25 unsigned int node_ents;
26 unsigned int magicpct;
27 xfs_dablk_t datablk;
28 unsigned int leaf_hdr_size;
29 unsigned int leaf_max_ents;
30 xfs_dablk_t leafblk;
31 unsigned int free_hdr_size;
32 unsigned int free_max_bests;
33 xfs_dablk_t freeblk;
34
35 xfs_dir2_data_aoff_t data_first_offset;
36 size_t data_entry_offset;
37};
38
39
40
41
42
43
44
45
46enum xfs_dacmp {
47 XFS_CMP_DIFFERENT,
48 XFS_CMP_EXACT,
49 XFS_CMP_CASE
50};
51
52
53
54
55typedef struct xfs_da_args {
56 struct xfs_da_geometry *geo;
57 const uint8_t *name;
58 int namelen;
59 uint8_t filetype;
60 uint8_t *value;
61 int valuelen;
62 int flags;
63 xfs_dahash_t hashval;
64 xfs_ino_t inumber;
65 struct xfs_inode *dp;
66 struct xfs_trans *trans;
67 xfs_extlen_t total;
68 int whichfork;
69 xfs_dablk_t blkno;
70 int index;
71 xfs_dablk_t rmtblkno;
72 int rmtblkcnt;
73 int rmtvaluelen;
74 xfs_dablk_t blkno2;
75 int index2;
76 xfs_dablk_t rmtblkno2;
77 int rmtblkcnt2;
78 int rmtvaluelen2;
79 int op_flags;
80 enum xfs_dacmp cmpresult;
81} xfs_da_args_t;
82
83
84
85
86#define XFS_DA_OP_JUSTCHECK 0x0001
87#define XFS_DA_OP_RENAME 0x0002
88#define XFS_DA_OP_ADDNAME 0x0004
89#define XFS_DA_OP_OKNOENT 0x0008
90#define XFS_DA_OP_CILOOKUP 0x0010
91#define XFS_DA_OP_ALLOCVAL 0x0020
92#define XFS_DA_OP_INCOMPLETE 0x0040
93
94#define XFS_DA_OP_FLAGS \
95 { XFS_DA_OP_JUSTCHECK, "JUSTCHECK" }, \
96 { XFS_DA_OP_RENAME, "RENAME" }, \
97 { XFS_DA_OP_ADDNAME, "ADDNAME" }, \
98 { XFS_DA_OP_OKNOENT, "OKNOENT" }, \
99 { XFS_DA_OP_CILOOKUP, "CILOOKUP" }, \
100 { XFS_DA_OP_ALLOCVAL, "ALLOCVAL" }, \
101 { XFS_DA_OP_INCOMPLETE, "INCOMPLETE" }
102
103
104
105
106
107
108
109
110typedef struct xfs_da_state_blk {
111 struct xfs_buf *bp;
112 xfs_dablk_t blkno;
113 xfs_daddr_t disk_blkno;
114 int index;
115 xfs_dahash_t hashval;
116 int magic;
117} xfs_da_state_blk_t;
118
119typedef struct xfs_da_state_path {
120 int active;
121 xfs_da_state_blk_t blk[XFS_DA_NODE_MAXDEPTH];
122} xfs_da_state_path_t;
123
124typedef struct xfs_da_state {
125 xfs_da_args_t *args;
126 struct xfs_mount *mp;
127 xfs_da_state_path_t path;
128 xfs_da_state_path_t altpath;
129 unsigned char inleaf;
130 unsigned char extravalid;
131 unsigned char extraafter;
132 xfs_da_state_blk_t extrablk;
133
134} xfs_da_state_t;
135
136
137
138
139
140
141struct xfs_da3_icnode_hdr {
142 uint32_t forw;
143 uint32_t back;
144 uint16_t magic;
145 uint16_t count;
146 uint16_t level;
147
148
149
150
151
152 struct xfs_da_node_entry *btree;
153};
154
155
156
157
158#define XFS_DA_LOGOFF(BASE, ADDR) ((char *)(ADDR) - (char *)(BASE))
159#define XFS_DA_LOGRANGE(BASE, ADDR, SIZE) \
160 (uint)(XFS_DA_LOGOFF(BASE, ADDR)), \
161 (uint)(XFS_DA_LOGOFF(BASE, ADDR)+(SIZE)-1)
162
163
164
165
166
167
168
169
170int xfs_da3_node_create(struct xfs_da_args *args, xfs_dablk_t blkno,
171 int level, struct xfs_buf **bpp, int whichfork);
172int xfs_da3_split(xfs_da_state_t *state);
173
174
175
176
177int xfs_da3_join(xfs_da_state_t *state);
178void xfs_da3_fixhashpath(struct xfs_da_state *state,
179 struct xfs_da_state_path *path_to_to_fix);
180
181
182
183
184int xfs_da3_node_lookup_int(xfs_da_state_t *state, int *result);
185int xfs_da3_path_shift(xfs_da_state_t *state, xfs_da_state_path_t *path,
186 int forward, int release, int *result);
187
188
189
190int xfs_da3_blk_link(xfs_da_state_t *state, xfs_da_state_blk_t *old_blk,
191 xfs_da_state_blk_t *new_blk);
192int xfs_da3_node_read(struct xfs_trans *tp, struct xfs_inode *dp,
193 xfs_dablk_t bno, struct xfs_buf **bpp, int whichfork);
194int xfs_da3_node_read_mapped(struct xfs_trans *tp, struct xfs_inode *dp,
195 xfs_daddr_t mappedbno, struct xfs_buf **bpp,
196 int whichfork);
197
198
199
200
201
202#define XFS_DABUF_MAP_HOLE_OK (1 << 0)
203
204int xfs_da_grow_inode(xfs_da_args_t *args, xfs_dablk_t *new_blkno);
205int xfs_da_grow_inode_int(struct xfs_da_args *args, xfs_fileoff_t *bno,
206 int count);
207int xfs_da_get_buf(struct xfs_trans *trans, struct xfs_inode *dp,
208 xfs_dablk_t bno, struct xfs_buf **bp, int whichfork);
209int xfs_da_read_buf(struct xfs_trans *trans, struct xfs_inode *dp,
210 xfs_dablk_t bno, unsigned int flags, struct xfs_buf **bpp,
211 int whichfork, const struct xfs_buf_ops *ops);
212int xfs_da_reada_buf(struct xfs_inode *dp, xfs_dablk_t bno,
213 unsigned int flags, int whichfork,
214 const struct xfs_buf_ops *ops);
215int xfs_da_shrink_inode(xfs_da_args_t *args, xfs_dablk_t dead_blkno,
216 struct xfs_buf *dead_buf);
217
218uint xfs_da_hashname(const uint8_t *name_string, int name_length);
219enum xfs_dacmp xfs_da_compname(struct xfs_da_args *args,
220 const unsigned char *name, int len);
221
222
223xfs_da_state_t *xfs_da_state_alloc(void);
224void xfs_da_state_free(xfs_da_state_t *state);
225
226void xfs_da3_node_hdr_from_disk(struct xfs_mount *mp,
227 struct xfs_da3_icnode_hdr *to, struct xfs_da_intnode *from);
228void xfs_da3_node_hdr_to_disk(struct xfs_mount *mp,
229 struct xfs_da_intnode *to, struct xfs_da3_icnode_hdr *from);
230
231extern struct kmem_zone *xfs_da_state_zone;
232
233#endif
234