3000763af0f856064788273a69635793762105a2
[dragonfly.git] / sys / vfs / hammer2 / hammer2.h
1 /*
2  * Copyright (c) 2011-2012 The DragonFly Project.  All rights reserved.
3  *
4  * This code is derived from software contributed to The DragonFly Project
5  * by Matthew Dillon <dillon@dragonflybsd.org>
6  * by Venkatesh Srinivas <vsrinivas@dragonflybsd.org>
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * 1. Redistributions of source code must retain the above copyright
13  *    notice, this list of conditions and the following disclaimer.
14  * 2. Redistributions in binary form must reproduce the above copyright
15  *    notice, this list of conditions and the following disclaimer in
16  *    the documentation and/or other materials provided with the
17  *    distribution.
18  * 3. Neither the name of The DragonFly Project nor the names of its
19  *    contributors may be used to endorse or promote products derived
20  *    from this software without specific, prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
26  * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27  * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
28  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
30  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
31  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
32  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33  * SUCH DAMAGE.
34  */
35
36 /*
37  * This header file contains structures used internally by the HAMMER2
38  * implementation.  See hammer2_disk.h for on-disk structures.
39  */
40
41 #ifndef _VFS_HAMMER2_HAMMER2_H_
42 #define _VFS_HAMMER2_HAMMER2_H_
43
44 #include <sys/param.h>
45 #include <sys/types.h>
46 #include <sys/kernel.h>
47 #include <sys/conf.h>
48 #include <sys/systm.h>
49 #include <sys/tree.h>
50 #include <sys/malloc.h>
51 #include <sys/mount.h>
52 #include <sys/vnode.h>
53 #include <sys/proc.h>
54 #include <sys/mountctl.h>
55 #include <sys/priv.h>
56 #include <sys/stat.h>
57 #include <sys/thread.h>
58 #include <sys/globaldata.h>
59 #include <sys/lockf.h>
60 #include <sys/buf.h>
61 #include <sys/queue.h>
62 #include <sys/limits.h>
63 #include <sys/buf2.h>
64 #include <sys/signal2.h>
65 #include <sys/tree.h>
66
67 #include "hammer2_disk.h"
68 #include "hammer2_mount.h"
69 #include "hammer2_ioctl.h"
70 #include "hammer2_ccms.h"
71 #include "hammer2_network.h"
72
73 struct hammer2_chain;
74 struct hammer2_inode;
75 struct hammer2_mount;
76 struct hammer2_pfsmount;
77 struct hammer2_span;
78 struct hammer2_state;
79 struct hammer2_msg;
80
81 /*
82  * The chain structure tracks blockref recursions all the way to
83  * the root volume.  These consist of indirect blocks, inodes,
84  * and eventually the volume header.
85  *
86  * The chain structure is embedded in the hammer2_mount, hammer2_inode,
87  * and other system memory structures.  The chain structure typically
88  * implements the reference count and busy flag for the larger structure.
89  *
90  * It is always possible to track a chain element all the way back to the
91  * root by following the (parent) links.  (index) is a type-dependent index
92  * in the parent indicating where in the parent the chain element resides.
93  *
94  * When a blockref is added or deleted the related chain element is marked
95  * modified and all of its parents are marked SUBMODIFIED (the parent
96  * recursion can stop once we hit a node that is already marked SUBMODIFIED).
97  * A deleted chain element must remain intact until synchronized against
98  * its parent.
99  *
100  * The blockref at (parent, index) is not adjusted until the modified chain
101  * element is flushed and unmarked.  Until then the child's blockref may
102  * not match the blockref at (parent, index).
103  */
104 RB_HEAD(hammer2_chain_tree, hammer2_chain);
105 RB_HEAD(hammer2_state_tree, hammer2_state);
106 TAILQ_HEAD(flush_deferral_list, hammer2_chain);
107
108 struct hammer2_chain {
109         ccms_cst_t      cst;                    /* attr or data cst */
110         struct hammer2_blockref bref;
111         struct hammer2_blockref bref_flush;     /* synchronized w/MOVED bit */
112         struct hammer2_chain    *parent;        /* return chain to root */
113         struct hammer2_chain_tree rbhead;
114         struct hammer2_state    *state;         /* if active cache msg */
115         RB_ENTRY(hammer2_chain) rbnode;
116         TAILQ_ENTRY(hammer2_chain) flush_node;  /* flush deferral list */
117         union {
118                 struct hammer2_inode *ip;
119                 struct hammer2_indblock *np;
120                 struct hammer2_data *dp;
121                 void *mem;
122         } u;
123
124         struct buf      *bp;            /* buffer cache (ro) */
125         hammer2_media_data_t *data;     /* modified copy of data (rw) */
126         u_int           bytes;          /* physical size of data */
127         int             index;          /* index in parent */
128         u_int           refs;
129         u_int           flags;
130 };
131
132 typedef struct hammer2_chain hammer2_chain_t;
133
134 int hammer2_chain_cmp(hammer2_chain_t *chain1, hammer2_chain_t *chain2);
135 RB_PROTOTYPE(hammer2_chain_tree, hammer2_chain, rbnode, hammer2_chain_cmp);
136
137 /*
138  * MOVED - This bit is set during the flush when the MODIFIED bit is cleared,
139  *         indicating that the parent's blocktable must inherit a change to
140  *         the bref (typically a block reallocation)
141  *
142  *         It must also be set in situations where a chain is not MODIFIED
143  *         but whos bref has changed (typically due to fields other than
144  *         a block reallocation).
145  */
146 #define HAMMER2_CHAIN_MODIFIED          0x00000001      /* active mods */
147 #define HAMMER2_CHAIN_DIRTYEMBED        0x00000002      /* inode embedded */
148 #define HAMMER2_CHAIN_DIRTYBP           0x00000004      /* dirty on unlock */
149 #define HAMMER2_CHAIN_SUBMODIFIED       0x00000008      /* 1+ subs modified */
150 #define HAMMER2_CHAIN_DELETED           0x00000010
151 #define HAMMER2_CHAIN_INITIAL           0x00000020      /* initial create */
152 #define HAMMER2_CHAIN_FLUSHED           0x00000040      /* flush on unlock */
153 #define HAMMER2_CHAIN_MOVED             0x00000080      /* bref changed */
154 #define HAMMER2_CHAIN_IOFLUSH           0x00000100      /* bawrite on put */
155 #define HAMMER2_CHAIN_DEFERRED          0x00000200      /* on a deferral list*/
156 #define HAMMER2_CHAIN_DESTROYED         0x00000400      /* destroying */
157 #define HAMMER2_CHAIN_MODIFIED_AUX      0x00000800      /* hmp->vchain only */
158 #define HAMMER2_CHAIN_MODIFY_TID        0x00001000      /* mod updates field */
159 #define HAMMER2_CHAIN_MOUNTED           0x00002000      /* PFS is mounted */
160
161 /*
162  * Flags passed to hammer2_chain_lookup() and hammer2_chain_next()
163  */
164 #define HAMMER2_LOOKUP_NOLOCK           0x00000001      /* ref only */
165 #define HAMMER2_LOOKUP_NODATA           0x00000002      /* data left NULL */
166 #define HAMMER2_LOOKUP_SHARED           0x00000100
167
168 /*
169  * Flags passed to hammer2_chain_modify() and hammer2_chain_resize()
170  *
171  * NOTE: OPTDATA allows us to avoid instantiating buffers for INDIRECT
172  *       blocks in the INITIAL-create state.
173  *
174  * NOTE: NO_MODIFY_TID tells the function to not set HAMMER2_CHAIN_MODIFY_TID
175  *       when marking the chain modified (used when a sub-chain modification
176  *       propagates upward).
177  */
178 #define HAMMER2_MODIFY_NOSUB            0x00000001      /* do not set SUBMOD */
179 #define HAMMER2_MODIFY_OPTDATA          0x00000002      /* data can be NULL */
180 #define HAMMER2_MODIFY_NO_MODIFY_TID    0x00000004
181
182 /*
183  * Flags passed to hammer2_chain_lock()
184  */
185 #define HAMMER2_RESOLVE_NEVER           1
186 #define HAMMER2_RESOLVE_MAYBE           2
187 #define HAMMER2_RESOLVE_ALWAYS          3
188 #define HAMMER2_RESOLVE_MASK            0x0F
189
190 #define HAMMER2_RESOLVE_SHARED          0x10
191
192 /*
193  * Cluster different types of storage together for allocations
194  */
195 #define HAMMER2_FREECACHE_INODE         0
196 #define HAMMER2_FREECACHE_INDIR         1
197 #define HAMMER2_FREECACHE_DATA          2
198 #define HAMMER2_FREECACHE_UNUSED3       3
199 #define HAMMER2_FREECACHE_TYPES         4
200
201 /*
202  * BMAP read-ahead maximum parameters
203  */
204 #define HAMMER2_BMAP_COUNT              16      /* max bmap read-ahead */
205 #define HAMMER2_BMAP_BYTES              (HAMMER2_PBUFSIZE * HAMMER2_BMAP_COUNT)
206
207 /*
208  * Misc
209  */
210 #define HAMMER2_FLUSH_DEPTH_LIMIT       40      /* stack recursion limit */
211
212 /*
213  * HAMMER2 IN-MEMORY CACHE OF MEDIA STRUCTURES
214  *
215  * There is an in-memory representation of all on-media data structure.
216  *
217  * When accessed read-only the data will be mapped to the related buffer
218  * cache buffer.
219  *
220  * When accessed read-write (marked modified) a kmalloc()'d copy of the
221  * is created which can then be modified.  The copy is destroyed when a
222  * filesystem block is allocated to replace it.
223  *
224  * Active inodes (those with vnodes attached) will maintain the kmalloc()'d
225  * copy for both the read-only and the read-write case.  The combination of
226  * (bp) and (data) determines whether (data) was allocated or not.
227  *
228  * The in-memory representation may remain cached (for example in order to
229  * placemark clustering locks) even after the related data has been
230  * detached.
231  */
232
233 /*
234  * A hammer2 inode.
235  *
236  * NOTE: The inode's attribute CST which is also used to lock the inode
237  *       is embedded in the chain (chain.cst) and aliased w/ attr_cst.
238  */
239 struct hammer2_inode {
240         struct hammer2_mount    *hmp;           /* Global mount */
241         struct hammer2_pfsmount *pmp;           /* PFS mount */
242         struct hammer2_inode    *pip;           /* parent inode */
243         struct vnode            *vp;
244         ccms_cst_t              topo_cst;       /* directory topology cst */
245         hammer2_chain_t         chain;
246         struct hammer2_inode_data ip_data;
247         struct lockf            advlock;
248         u_int                   depth;          /* directory depth */
249         hammer2_off_t           delta_dcount;   /* adjust data_count */
250         hammer2_off_t           delta_icount;   /* adjust inode_count */
251 };
252
253 typedef struct hammer2_inode hammer2_inode_t;
254
255 /*
256  * A hammer2 indirect block
257  */
258 struct hammer2_indblock {
259         hammer2_chain_t         chain;
260 };
261
262 typedef struct hammer2_indblock hammer2_indblock_t;
263
264 /*
265  * A hammer2 data block
266  */
267 struct hammer2_data {
268         hammer2_chain_t         chain;
269 };
270
271 typedef struct hammer2_data hammer2_data_t;
272
273 struct hammer2_freecache {
274         hammer2_off_t   bulk;
275         hammer2_off_t   single;
276 };
277
278 typedef struct hammer2_freecache hammer2_freecache_t;
279
280 /*
281  * Structure used to represent a virtual circuit for a messaging
282  * route.  Typically associated from hammer2_state but the hammer2_pfsmount
283  * structure also has one to represent the point-to-point link.
284  */
285 struct hammer2_router {
286         struct hammer2_pfsmount *pmp;
287         struct hammer2_state    *state;         /* received LNK_SPAN state */
288         uint64_t                target;         /* target */
289 };
290
291 typedef struct hammer2_router hammer2_router_t;
292
293 /*
294  * Global (per device) mount structure for device (aka vp->v_mount->hmp)
295  */
296 struct hammer2_mount {
297         struct vnode    *devvp;         /* device vnode */
298         int             ronly;          /* read-only mount */
299         int             pmp_count;      /* PFS mounts backed by us */
300         TAILQ_ENTRY(hammer2_mount) mntentry; /* hammer2_mntlist */
301
302         struct malloc_type *minode;
303         int             ninodes;
304         int             maxinodes;
305
306         struct malloc_type *mchain;
307         int             nipstacks;
308         int             maxipstacks;
309         hammer2_chain_t vchain;         /* anchor chain */
310         hammer2_chain_t *schain;        /* super-root */
311         struct lock     alloclk;        /* lockmgr lock */
312         struct lock     voldatalk;      /* lockmgr lock */
313
314         hammer2_volume_data_t voldata;
315         hammer2_freecache_t freecache[HAMMER2_FREECACHE_TYPES]
316                                      [HAMMER2_MAX_RADIX+1];
317 };
318
319 typedef struct hammer2_mount hammer2_mount_t;
320
321 /*
322  * Per-PFS mount structure for device (aka vp->v_mount)
323  */
324 struct hammer2_pfsmount {
325         struct mount            *mp;            /* kernel mount */
326         struct hammer2_mount    *hmp;           /* device global mount */
327         hammer2_chain_t         *rchain;        /* PFS root chain */
328         hammer2_inode_t         *iroot;         /* PFS root inode */
329         struct malloc_type      *mmsg;
330         ccms_domain_t           ccms_dom;
331         struct netexport        export;         /* nfs export */
332         int                     ronly;          /* read-only mount */
333         struct file             *msg_fp;        /* cluster pipe->userland */
334         thread_t                msgrd_td;       /* cluster thread */
335         thread_t                msgwr_td;       /* cluster thread */
336         int                     msg_ctl;        /* wakeup flags */
337         int                     msg_seq;        /* cluster msg sequence id */
338         uint32_t                msgid_iterator;
339         struct lock             msglk;          /* lockmgr lock */
340         TAILQ_HEAD(, hammer2_msg) msgq;         /* transmit queue */
341         struct hammer2_state    *conn_state;    /* active LNK_CONN state */
342         struct hammer2_state    *freerd_state;  /* allocation cache */
343         struct hammer2_state    *freewr_state;  /* allocation cache */
344         struct hammer2_state_tree staterd_tree; /* active messages */
345         struct hammer2_state_tree statewr_tree; /* active messages */
346         struct hammer2_router   router;
347 };
348
349 typedef struct hammer2_pfsmount hammer2_pfsmount_t;
350
351 /*
352  * msg_ctl flags (atomic)
353  */
354 #define HAMMER2_CLUSTERCTL_KILL         0x00000001
355 #define HAMMER2_CLUSTERCTL_SLEEPING     0x00000002 /* interlocked w/msglk */
356
357 /*
358  * Transactional state structure, representing an open transaction.  The
359  * transaction might represent a cache state (and thus have a chain
360  * association), or a VOP op, LNK_SPAN, or other things.
361  */
362 struct hammer2_state {
363         RB_ENTRY(hammer2_state) rbnode;         /* indexed by msgid */
364         struct hammer2_pfsmount *pmp;
365         struct hammer2_router *router;          /* related LNK_SPAN route */
366         uint32_t        txcmd;                  /* mostly for CMDF flags */
367         uint32_t        rxcmd;                  /* mostly for CMDF flags */
368         uint64_t        msgid;                  /* {spanid,msgid} uniq */
369         int             flags;
370         int             error;
371         struct hammer2_chain *chain;            /* msg associated w/chain */
372         struct hammer2_msg *msg;
373         int (*func)(struct hammer2_state *, struct hammer2_msg *);
374         union {
375                 void *any;
376                 hammer2_pfsmount_t *pmp;
377         } any;
378 };
379
380 #define HAMMER2_STATE_INSERTED  0x0001
381 #define HAMMER2_STATE_DYNAMIC   0x0002
382
383 struct hammer2_msg {
384         TAILQ_ENTRY(hammer2_msg) qentry;        /* serialized queue */
385         struct hammer2_router *router;
386         struct hammer2_state *state;
387         size_t          hdr_size;
388         size_t          aux_size;
389         char            *aux_data;
390         hammer2_msg_any_t any;
391 };
392
393 typedef struct hammer2_link hammer2_link_t;
394 typedef struct hammer2_state hammer2_state_t;
395 typedef struct hammer2_msg hammer2_msg_t;
396
397 int hammer2_state_cmp(hammer2_state_t *state1, hammer2_state_t *state2);
398 RB_PROTOTYPE(hammer2_state_tree, hammer2_state, rbnode, hammer2_state_cmp);
399
400
401 #if defined(_KERNEL)
402
403 MALLOC_DECLARE(M_HAMMER2);
404
405 #define VTOI(vp)        ((hammer2_inode_t *)(vp)->v_data)
406 #define ITOV(ip)        ((ip)->vp)
407
408 static __inline
409 hammer2_pfsmount_t *
410 MPTOPMP(struct mount *mp)
411 {
412         return ((hammer2_pfsmount_t *)mp->mnt_data);
413 }
414
415 static __inline
416 hammer2_mount_t *
417 MPTOHMP(struct mount *mp)
418 {
419         return (((hammer2_pfsmount_t *)mp->mnt_data)->hmp);
420 }
421
422 extern struct vop_ops hammer2_vnode_vops;
423 extern struct vop_ops hammer2_spec_vops;
424 extern struct vop_ops hammer2_fifo_vops;
425
426 extern int hammer2_debug;
427 extern int hammer2_cluster_enable;
428 extern int hammer2_hardlink_enable;
429 extern long hammer2_iod_file_read;
430 extern long hammer2_iod_meta_read;
431 extern long hammer2_iod_indr_read;
432 extern long hammer2_iod_file_write;
433 extern long hammer2_iod_meta_write;
434 extern long hammer2_iod_indr_write;
435 extern long hammer2_iod_volu_write;
436 extern long hammer2_ioa_file_read;
437 extern long hammer2_ioa_meta_read;
438 extern long hammer2_ioa_indr_read;
439 extern long hammer2_ioa_file_write;
440 extern long hammer2_ioa_meta_write;
441 extern long hammer2_ioa_indr_write;
442 extern long hammer2_ioa_volu_write;
443
444 /*
445  * hammer2_subr.c
446  */
447 void hammer2_inode_lock_ex(hammer2_inode_t *ip);
448 void hammer2_inode_unlock_ex(hammer2_inode_t *ip);
449 void hammer2_inode_lock_sh(hammer2_inode_t *ip);
450 void hammer2_inode_unlock_sh(hammer2_inode_t *ip);
451 void hammer2_inode_busy(hammer2_inode_t *ip);
452 void hammer2_inode_unbusy(hammer2_inode_t *ip);
453 void hammer2_voldata_lock(hammer2_mount_t *hmp);
454 void hammer2_voldata_unlock(hammer2_mount_t *hmp);
455
456 void hammer2_mount_exlock(hammer2_mount_t *hmp);
457 void hammer2_mount_shlock(hammer2_mount_t *hmp);
458 void hammer2_mount_unlock(hammer2_mount_t *hmp);
459
460 int hammer2_get_dtype(hammer2_inode_t *ip);
461 int hammer2_get_vtype(hammer2_inode_t *ip);
462 u_int8_t hammer2_get_obj_type(enum vtype vtype);
463 void hammer2_time_to_timespec(u_int64_t xtime, struct timespec *ts);
464 u_int64_t hammer2_timespec_to_time(struct timespec *ts);
465 u_int32_t hammer2_to_unix_xid(uuid_t *uuid);
466 void hammer2_guid_to_uuid(uuid_t *uuid, u_int32_t guid);
467
468 hammer2_key_t hammer2_dirhash(const unsigned char *name, size_t len);
469 int hammer2_bytes_to_radix(size_t bytes);
470
471 int hammer2_calc_logical(hammer2_inode_t *ip, hammer2_off_t uoff,
472                          hammer2_key_t *lbasep, hammer2_key_t *leofp);
473 void hammer2_update_time(uint64_t *timep);
474
475 /*
476  * hammer2_inode.c
477  */
478 struct vnode *hammer2_igetv(hammer2_inode_t *ip, int *errorp);
479
480 void hammer2_inode_lock_nlinks(hammer2_inode_t *ip);
481 void hammer2_inode_unlock_nlinks(hammer2_inode_t *ip);
482 hammer2_inode_t *hammer2_inode_alloc(hammer2_pfsmount_t *pmp, void *data);
483 void hammer2_inode_free(hammer2_inode_t *ip);
484 void hammer2_inode_ref(hammer2_inode_t *ip);
485 void hammer2_inode_drop(hammer2_inode_t *ip);
486 int hammer2_inode_calc_alloc(hammer2_key_t filesize);
487
488 int hammer2_inode_create(hammer2_inode_t *dip,
489                         struct vattr *vap, struct ucred *cred,
490                         const uint8_t *name, size_t name_len,
491                         hammer2_inode_t **nipp);
492
493 int hammer2_inode_duplicate(hammer2_inode_t *dip,
494                         hammer2_inode_t *oip, hammer2_inode_t **nipp,
495                         const uint8_t *name, size_t name_len);
496 int hammer2_inode_connect(hammer2_inode_t *dip, hammer2_inode_t *oip,
497                         const uint8_t *name, size_t name_len);
498
499 int hammer2_unlink_file(hammer2_inode_t *dip,
500                         const uint8_t *name, size_t name_len,
501                         int isdir, hammer2_inode_t *retain_ip);
502 int hammer2_hardlink_consolidate(hammer2_inode_t **ipp, hammer2_inode_t *tdip);
503 int hammer2_hardlink_deconsolidate(hammer2_inode_t *dip,
504                         hammer2_chain_t **chainp, hammer2_inode_t **ipp);
505 int hammer2_hardlink_find(hammer2_inode_t *dip, hammer2_chain_t **chainp,
506                         hammer2_inode_t **ipp);
507
508 /*
509  * hammer2_chain.c
510  */
511 void hammer2_modify_volume(hammer2_mount_t *hmp);
512 hammer2_chain_t *hammer2_chain_alloc(hammer2_mount_t *hmp,
513                                 hammer2_blockref_t *bref);
514 void hammer2_chain_free(hammer2_mount_t *hmp, hammer2_chain_t *chain);
515 void hammer2_chain_ref(hammer2_mount_t *hmp, hammer2_chain_t *chain);
516 void hammer2_chain_drop(hammer2_mount_t *hmp, hammer2_chain_t *chain);
517 int hammer2_chain_lock(hammer2_mount_t *hmp, hammer2_chain_t *chain, int how);
518 void hammer2_chain_moved(hammer2_mount_t *hmp, hammer2_chain_t *chain);
519 void hammer2_chain_modify(hammer2_mount_t *hmp, hammer2_chain_t *chain,
520                                 int flags);
521 void hammer2_chain_resize(hammer2_inode_t *ip, hammer2_chain_t *chain,
522                                 int nradix, int flags);
523 void hammer2_chain_unlock(hammer2_mount_t *hmp, hammer2_chain_t *chain);
524 hammer2_chain_t *hammer2_chain_find(hammer2_mount_t *hmp,
525                                 hammer2_chain_t *parent, int index);
526 hammer2_chain_t *hammer2_chain_get(hammer2_mount_t *hmp,
527                                 hammer2_chain_t *parent,
528                                 int index, int flags);
529 hammer2_chain_t *hammer2_chain_lookup(hammer2_mount_t *hmp,
530                                 hammer2_chain_t **parentp,
531                                 hammer2_key_t key_beg, hammer2_key_t key_end,
532                                 int flags);
533 hammer2_chain_t *hammer2_chain_next(hammer2_mount_t *hmp,
534                                 hammer2_chain_t **parentp,
535                                 hammer2_chain_t *chain,
536                                 hammer2_key_t key_beg, hammer2_key_t key_end,
537                                 int flags);
538 hammer2_chain_t *hammer2_chain_create(hammer2_mount_t *hmp,
539                                 hammer2_chain_t *parent,
540                                 hammer2_chain_t *chain,
541                                 hammer2_key_t key, int keybits,
542                                 int type, size_t bytes);
543 void hammer2_chain_delete(hammer2_mount_t *hmp, hammer2_chain_t *parent,
544                                 hammer2_chain_t *chain, int retain);
545 void hammer2_chain_flush(hammer2_mount_t *hmp, hammer2_chain_t *chain,
546                                 hammer2_tid_t modify_tid);
547 void hammer2_chain_commit(hammer2_mount_t *hmp, hammer2_chain_t *chain);
548
549 /*
550  * hammer2_ioctl.c
551  */
552 int hammer2_ioctl(hammer2_inode_t *ip, u_long com, void *data,
553                                 int fflag, struct ucred *cred);
554
555 /*
556  * hammer2_msg.c
557  */
558 int hammer2_state_msgrx(hammer2_msg_t *msg);
559 int hammer2_state_msgtx(hammer2_msg_t *msg);
560 void hammer2_state_cleanuprx(hammer2_msg_t *msg);
561 void hammer2_state_cleanuptx(hammer2_msg_t *msg);
562 int hammer2_msg_execute(hammer2_msg_t *msg);
563 void hammer2_state_free(hammer2_state_t *state);
564 void hammer2_msg_free(hammer2_msg_t *msg);
565 hammer2_msg_t *hammer2_msg_alloc(hammer2_router_t *router, uint32_t cmd,
566                                 int (*func)(hammer2_state_t *, hammer2_msg_t *),
567                                 void *data);
568 void hammer2_msg_write(hammer2_msg_t *msg);
569 void hammer2_msg_reply(hammer2_msg_t *msg, uint32_t error);
570 void hammer2_msg_result(hammer2_msg_t *msg, uint32_t error);
571
572 /*
573  * hammer2_msgops.c
574  */
575 int hammer2_msg_dbg_rcvmsg(hammer2_msg_t *msg);
576 int hammer2_msg_adhoc_input(hammer2_msg_t *msg);
577
578 /*
579  * hammer2_vfsops.c
580  */
581 void hammer2_clusterctl_wakeup(hammer2_pfsmount_t *pmp);
582 void hammer2_volconf_update(hammer2_pfsmount_t *pmp, int index);
583 void hammer2_cluster_reconnect(hammer2_pfsmount_t *pmp, struct file *fp);
584
585 /*
586  * hammer2_freemap.c
587  */
588 hammer2_off_t hammer2_freemap_alloc(hammer2_mount_t *hmp,
589                                 int type, size_t bytes);
590 void hammer2_freemap_free(hammer2_mount_t *hmp, hammer2_off_t data_off,
591                                 int type);
592
593 #endif /* !_KERNEL */
594 #endif /* !_VFS_HAMMER2_HAMMER2_H_ */