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