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