hammer2 - flush sequencing part 3 - add snapshots
[dragonfly.git] / sys / vfs / hammer2 / hammer2.h
1 /*
2  * Copyright (c) 2011-2013 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 #include <sys/dmsg.h>
67
68 #include "hammer2_disk.h"
69 #include "hammer2_mount.h"
70 #include "hammer2_ioctl.h"
71 #include "hammer2_ccms.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 the root
83  * volume.  These consist of indirect blocks, inodes, and eventually the
84  * volume header itself.
85  *
86  * In situations where a duplicate is needed to represent different snapshots
87  * or flush points a new chain will be allocated but associated with the
88  * same shared chain_core.  The RBTREE is contained in the shared chain_core
89  * and entries in the RBTREE are versioned.
90  *
91  * Duplication can occur whenever a chain must be modified.  Note that
92  * a deletion is not considered a modification.
93  *
94  *      (a) General modifications at data leafs
95  *      (b) When a chain is resized
96  *      (c) When a chain's blockref array is updated
97  *      (d) When a chain is renamed
98  *      (e) When a chain is moved (when an indirect block is split)
99  *
100  * Advantages:
101  *
102  *      (1) Fully coherent snapshots can be taken without requiring
103  *          a pre-flush, resulting in extremely fast (sub-millisecond)
104  *          snapshots.
105  *
106  *      (2) Multiple synchronization points can be in-flight at the same
107  *          time, representing multiple snapshots or flushes.
108  *
109  *      (3) The algorithms needed to keep track of everything are actually
110  *          not that complex.
111  *
112  * Special Considerations:
113  *
114  *      A chain is ref-counted on a per-chain basis, but the chain's lock
115  *      is associated with the shared chain_core and is not per-chain.
116  *
117  *      Each chain is representative of a filesystem topology.  Even
118  *      though the shared chain_core's are effectively multi-homed, the
119  *      chain structure is not.
120  *
121  *      chain->parent is a stable pointer and can be iterated without locking
122  *      as long as either the chain or *any* deep child under the chain
123  *      is held.
124  */
125 RB_HEAD(hammer2_chain_tree, hammer2_chain);
126 TAILQ_HEAD(flush_deferral_list, hammer2_chain);
127
128 struct hammer2_chain_core {
129         struct ccms_cst cst;
130         u_int           sharecnt;
131         struct hammer2_chain_tree rbtree;
132 };
133
134 typedef struct hammer2_chain_core hammer2_chain_core_t;
135
136 struct hammer2_chain {
137         RB_ENTRY(hammer2_chain) rbnode;
138         hammer2_blockref_t      bref;
139         hammer2_chain_core_t    *core;
140         struct hammer2_chain    *parent;
141         struct hammer2_state    *state;         /* if active cache msg */
142         struct hammer2_mount    *hmp;
143         struct hammer2_chain    *duplink;       /* duplication link */
144
145         hammer2_tid_t   modify_tid;             /* snapshot/flush filter */
146         hammer2_tid_t   delete_tid;
147         struct buf      *bp;                    /* physical data buffer */
148         u_int           bytes;                  /* physical data size */
149         int             index;                  /* blockref index in parent */
150         u_int           flags;
151         u_int           refs;
152         hammer2_media_data_t *data;             /* data pointer shortcut */
153         TAILQ_ENTRY(hammer2_chain) flush_node;  /* flush deferral list */
154 };
155
156 typedef struct hammer2_chain hammer2_chain_t;
157
158 int hammer2_chain_cmp(hammer2_chain_t *chain1, hammer2_chain_t *chain2);
159 RB_PROTOTYPE(hammer2_chain_tree, hammer2_chain, rbnode, hammer2_chain_cmp);
160
161 #define HAMMER2_CHAIN_MODIFIED          0x00000001      /* dirty chain data */
162 #define HAMMER2_CHAIN_ALLOCATED         0x00000002      /* kmalloc'd chain */
163 #define HAMMER2_CHAIN_DIRTYBP           0x00000004      /* dirty on unlock */
164 #define HAMMER2_CHAIN_SUBMODIFIED       0x00000008      /* 1+ subs modified */
165 #define HAMMER2_CHAIN_DELETED           0x00000010      /* deleted chain */
166 #define HAMMER2_CHAIN_INITIAL           0x00000020      /* initial create */
167 #define HAMMER2_CHAIN_FLUSHED           0x00000040      /* flush on unlock */
168 #define HAMMER2_CHAIN_MOVED             0x00000080      /* bref changed */
169 #define HAMMER2_CHAIN_IOFLUSH           0x00000100      /* bawrite on put */
170 #define HAMMER2_CHAIN_DEFERRED          0x00000200      /* on a deferral list */
171 #define HAMMER2_CHAIN_DESTROYED         0x00000400      /* destroying inode */
172 #define HAMMER2_CHAIN_VOLUMESYNC        0x00000800      /* needs volume sync */
173 #define HAMMER2_CHAIN_RECYCLE           0x00001000      /* force recycle */
174 #define HAMMER2_CHAIN_MOUNTED           0x00002000      /* PFS is mounted */
175 #define HAMMER2_CHAIN_ONRBTREE          0x00004000      /* on parent RB tree */
176
177 /*
178  * Flags passed to hammer2_chain_lookup() and hammer2_chain_next()
179  */
180 #define HAMMER2_LOOKUP_NOLOCK           0x00000001      /* ref only */
181 #define HAMMER2_LOOKUP_NODATA           0x00000002      /* data left NULL */
182 #define HAMMER2_LOOKUP_SHARED           0x00000100
183
184 /*
185  * Flags passed to hammer2_chain_modify() and hammer2_chain_resize()
186  *
187  * NOTE: OPTDATA allows us to avoid instantiating buffers for INDIRECT
188  *       blocks in the INITIAL-create state.
189  */
190 #define HAMMER2_MODIFY_NOSUB            0x00000001      /* do not set SUBMOD */
191 #define HAMMER2_MODIFY_OPTDATA          0x00000002      /* data can be NULL */
192 #define HAMMER2_MODIFY_NO_MODIFY_TID    0x00000004
193 #define HAMMER2_MODIFY_ASSERTNOCOPY     0x00000008
194
195 /*
196  * Flags passed to hammer2_chain_lock()
197  */
198 #define HAMMER2_RESOLVE_NEVER           1
199 #define HAMMER2_RESOLVE_MAYBE           2
200 #define HAMMER2_RESOLVE_ALWAYS          3
201 #define HAMMER2_RESOLVE_MASK            0x0F
202
203 #define HAMMER2_RESOLVE_SHARED          0x10
204 #define HAMMER2_RESOLVE_NOREF           0x20
205
206 /*
207  * Cluster different types of storage together for allocations
208  */
209 #define HAMMER2_FREECACHE_INODE         0
210 #define HAMMER2_FREECACHE_INDIR         1
211 #define HAMMER2_FREECACHE_DATA          2
212 #define HAMMER2_FREECACHE_UNUSED3       3
213 #define HAMMER2_FREECACHE_TYPES         4
214
215 /*
216  * BMAP read-ahead maximum parameters
217  */
218 #define HAMMER2_BMAP_COUNT              16      /* max bmap read-ahead */
219 #define HAMMER2_BMAP_BYTES              (HAMMER2_PBUFSIZE * HAMMER2_BMAP_COUNT)
220
221 /*
222  * Misc
223  */
224 #define HAMMER2_FLUSH_DEPTH_LIMIT       40      /* stack recursion limit */
225
226 /*
227  * HAMMER2 IN-MEMORY CACHE OF MEDIA STRUCTURES
228  *
229  * There is an in-memory representation of all on-media data structure.
230  *
231  * When accessed read-only the data will be mapped to the related buffer
232  * cache buffer.
233  *
234  * When accessed read-write (marked modified) a kmalloc()'d copy of the
235  * is created which can then be modified.  The copy is destroyed when a
236  * filesystem block is allocated to replace it.
237  *
238  * Active inodes (those with vnodes attached) will maintain the kmalloc()'d
239  * copy for both the read-only and the read-write case.  The combination of
240  * (bp) and (data) determines whether (data) was allocated or not.
241  *
242  * The in-memory representation may remain cached (for example in order to
243  * placemark clustering locks) even after the related data has been
244  * detached.
245  */
246
247 RB_HEAD(hammer2_inode_tree, hammer2_inode);
248
249 /*
250  * A hammer2 inode.
251  *
252  * NOTE: The inode's attribute CST which is also used to lock the inode
253  *       is embedded in the chain (chain.cst) and aliased w/ attr_cst.
254  */
255 struct hammer2_inode {
256         RB_ENTRY(hammer2_inode) rbnode;         /* inumber lookup (HL) */
257         ccms_cst_t              topo_cst;       /* directory topology cst */
258         struct hammer2_mount    *hmp;           /* Global mount */
259         struct hammer2_pfsmount *pmp;           /* PFS mount */
260         struct hammer2_inode    *pip;           /* parent inode */
261         struct vnode            *vp;
262         hammer2_chain_t         *chain;         /* NOTE: rehomed on rename */
263         struct lockf            advlock;
264         hammer2_tid_t           inum;
265         u_int                   flags;
266         u_int                   refs;           /* +vpref, +flushref */
267 };
268
269 typedef struct hammer2_inode hammer2_inode_t;
270
271 #define HAMMER2_INODE_MODIFIED          0x0001
272 #define HAMMER2_INODE_DIRTYEMBED        0x0002
273 #define HAMMER2_INODE_RENAME_INPROG     0x0004
274 #define HAMMER2_INODE_ONRBTREE          0x0008
275
276 int hammer2_inode_cmp(hammer2_inode_t *ip1, hammer2_inode_t *ip2);
277 RB_PROTOTYPE2(hammer2_inode_tree, hammer2_inode, rbnode, hammer2_inode_cmp,
278                 hammer2_tid_t);
279
280 /*
281  * A hammer2 transaction and flush sequencing structure.
282  *
283  * This global structure is tied into hammer2_mount and is used
284  * to sequence modifying operations and flushes.
285  *
286  * (a) Any modifying operations with sync_tid >= flush_tid will stall until
287  *     all modifying operating with sync_tid < flush_tid complete.
288  *
289  *     The flush related to flush_tid stalls until all modifying operations
290  *     with sync_tid < flush_tid complete.
291  *
292  * (b) Once unstalled, modifying operations with sync_tid > flush_tid are
293  *     allowed to run.  All modifications cause modify/duplicate operations
294  *     to occur on the related chains.  Note that most INDIRECT blocks will
295  *     be unaffected because the modifications just overload the RBTREE
296  *     structurally instead of actually modifying the indirect blocks.
297  *
298  * (c) The actual flush unstalls and RUNS CONCURRENTLY with (b), but only
299  *     utilizes the chain structures with sync_tid <= flush_tid.  The
300  *     flush will modify related indirect blocks and inodes in-place
301  *     (rather than duplicate) since the adjustments are compatible with
302  *     (b)'s RBTREE overloading
303  *
304  *     SPECIAL NOTE:  Inode modifications have to also propagate along any
305  *                    modify/duplicate chains.  File writes detect the flush
306  *                    and force out the conflicting buffer cache buffer(s)
307  *                    before reusing them.
308  *
309  * (d) Snapshots can be made instantly but must be flushed and disconnected
310  *     from their duplicative source before they can be mounted.  This is
311  *     because while H2's on-media structure supports forks, its in-memory
312  *     structure only supports very simple forking for background flushing
313  *     purposes.
314  *
315  * TODO: Flush merging.  When fsync() is called on multiple discrete files
316  *       concurrently there is no reason to stall the second fsync.
317  *       The final flush that reaches to root can cover both fsync()s.
318  *
319  *     The chains typically terminate as they fly onto the disk.  The flush
320  *     ultimately reaches the volume header.
321  */
322 struct hammer2_trans {
323         TAILQ_ENTRY(hammer2_trans) entry;
324         struct hammer2_mount    *hmp;
325         hammer2_tid_t           sync_tid;
326         thread_t                td;
327         int                     flags;
328         int                     blocked;
329         uint8_t                 inodes_created;
330         uint8_t                 dummy[7];
331 };
332
333 typedef struct hammer2_trans hammer2_trans_t;
334
335 #define HAMMER2_TRANS_ISFLUSH           0x0001
336 #define HAMMER2_TRANS_RESTRICTED        0x0002  /* snapshot flush restrict */
337
338 /*
339  * XXX
340  */
341 struct hammer2_freecache {
342         hammer2_off_t   bulk;
343         hammer2_off_t   single;
344 };
345
346 typedef struct hammer2_freecache hammer2_freecache_t;
347
348 /*
349  * Global (per device) mount structure for device (aka vp->v_mount->hmp)
350  */
351 TAILQ_HEAD(hammer2_trans_queue, hammer2_trans);
352
353 struct hammer2_mount {
354         struct vnode    *devvp;         /* device vnode */
355         int             ronly;          /* read-only mount */
356         int             pmp_count;      /* PFS mounts backed by us */
357         TAILQ_ENTRY(hammer2_mount) mntentry; /* hammer2_mntlist */
358
359         struct malloc_type *minode;
360         int             ninodes;
361         int             maxinodes;
362
363         struct malloc_type *mchain;
364         int             nipstacks;
365         int             maxipstacks;
366         hammer2_chain_t vchain;         /* anchor chain */
367         hammer2_chain_t *schain;        /* super-root */
368         hammer2_inode_t *sroot;         /* super-root inode */
369         struct lock     alloclk;        /* lockmgr lock */
370         struct lock     voldatalk;      /* lockmgr lock */
371         struct hammer2_trans_queue transq; /* all in-progress transactions */
372         hammer2_trans_t *curflush;      /* current flush in progress */
373         hammer2_tid_t   flush_tid;      /* currently synchronizing flush pt */
374         int             flushcnt;       /* #of flush trans on the list */
375
376         int             volhdrno;       /* last volhdrno written */
377         hammer2_volume_data_t voldata;
378         hammer2_volume_data_t volsync;  /* synchronized voldata */
379         hammer2_freecache_t freecache[HAMMER2_FREECACHE_TYPES]
380                                      [HAMMER2_MAX_RADIX+1];
381 };
382
383 typedef struct hammer2_mount hammer2_mount_t;
384
385 /*
386  * Per-PFS mount structure for device (aka vp->v_mount)
387  */
388 struct hammer2_pfsmount {
389         struct mount            *mp;            /* kernel mount */
390         struct hammer2_mount    *hmp;           /* device global mount */
391         hammer2_chain_t         *rchain;        /* PFS root chain */
392         hammer2_inode_t         *iroot;         /* PFS root inode */
393         hammer2_off_t           inode_count;    /* copy of inode_count */
394         ccms_domain_t           ccms_dom;
395         struct netexport        export;         /* nfs export */
396         int                     ronly;          /* read-only mount */
397         struct malloc_type      *mmsg;
398         kdmsg_iocom_t           iocom;
399         struct spinlock         inum_spin;      /* inumber lookup */
400         struct hammer2_inode_tree inum_tree;
401 };
402
403 typedef struct hammer2_pfsmount hammer2_pfsmount_t;
404
405 #if defined(_KERNEL)
406
407 MALLOC_DECLARE(M_HAMMER2);
408
409 #define VTOI(vp)        ((hammer2_inode_t *)(vp)->v_data)
410 #define ITOV(ip)        ((ip)->vp)
411
412 static __inline
413 hammer2_pfsmount_t *
414 MPTOPMP(struct mount *mp)
415 {
416         return ((hammer2_pfsmount_t *)mp->mnt_data);
417 }
418
419 static __inline
420 hammer2_mount_t *
421 MPTOHMP(struct mount *mp)
422 {
423         return (((hammer2_pfsmount_t *)mp->mnt_data)->hmp);
424 }
425
426 extern struct vop_ops hammer2_vnode_vops;
427 extern struct vop_ops hammer2_spec_vops;
428 extern struct vop_ops hammer2_fifo_vops;
429
430 extern int hammer2_debug;
431 extern int hammer2_cluster_enable;
432 extern int hammer2_hardlink_enable;
433 extern long hammer2_iod_file_read;
434 extern long hammer2_iod_meta_read;
435 extern long hammer2_iod_indr_read;
436 extern long hammer2_iod_file_write;
437 extern long hammer2_iod_meta_write;
438 extern long hammer2_iod_indr_write;
439 extern long hammer2_iod_fmap_write;
440 extern long hammer2_iod_volu_write;
441 extern long hammer2_ioa_file_read;
442 extern long hammer2_ioa_meta_read;
443 extern long hammer2_ioa_indr_read;
444 extern long hammer2_ioa_file_write;
445 extern long hammer2_ioa_meta_write;
446 extern long hammer2_ioa_indr_write;
447 extern long hammer2_ioa_fmap_write;
448 extern long hammer2_ioa_volu_write;
449
450 /*
451  * hammer2_subr.c
452  */
453 #define hammer2_icrc32(buf, size)       iscsi_crc32((buf), (size))
454 #define hammer2_icrc32c(buf, size, crc) iscsi_crc32_ext((buf), (size), (crc))
455
456 void hammer2_inode_lock_ex(hammer2_inode_t *ip);
457 void hammer2_inode_lock_sh(hammer2_inode_t *ip);
458 void hammer2_inode_unlock_ex(hammer2_inode_t *ip);
459 void hammer2_inode_unlock_sh(hammer2_inode_t *ip);
460 void hammer2_voldata_lock(hammer2_mount_t *hmp);
461 void hammer2_voldata_unlock(hammer2_mount_t *hmp, int modify);
462 ccms_state_t hammer2_inode_lock_temp_release(hammer2_inode_t *ip);
463 void hammer2_inode_lock_temp_restore(hammer2_inode_t *ip, ccms_state_t ostate);
464 ccms_state_t hammer2_inode_lock_upgrade(hammer2_inode_t *ip);
465 void hammer2_inode_lock_downgrade(hammer2_inode_t *ip, ccms_state_t ostate);
466
467 void hammer2_mount_exlock(hammer2_mount_t *hmp);
468 void hammer2_mount_shlock(hammer2_mount_t *hmp);
469 void hammer2_mount_unlock(hammer2_mount_t *hmp);
470
471 int hammer2_get_dtype(hammer2_chain_t *chain);
472 int hammer2_get_vtype(hammer2_chain_t *chain);
473 u_int8_t hammer2_get_obj_type(enum vtype vtype);
474 void hammer2_time_to_timespec(u_int64_t xtime, struct timespec *ts);
475 u_int64_t hammer2_timespec_to_time(struct timespec *ts);
476 u_int32_t hammer2_to_unix_xid(uuid_t *uuid);
477 void hammer2_guid_to_uuid(uuid_t *uuid, u_int32_t guid);
478
479 hammer2_key_t hammer2_dirhash(const unsigned char *name, size_t len);
480 int hammer2_allocsize(size_t bytes);
481
482 int hammer2_calc_logical(hammer2_inode_t *ip, hammer2_off_t uoff,
483                          hammer2_key_t *lbasep, hammer2_key_t *leofp);
484 void hammer2_update_time(uint64_t *timep);
485
486 /*
487  * hammer2_inode.c
488  */
489 struct vnode *hammer2_igetv(hammer2_inode_t *ip, int *errorp);
490
491 void hammer2_inode_lock_nlinks(hammer2_inode_t *ip);
492 void hammer2_inode_unlock_nlinks(hammer2_inode_t *ip);
493 hammer2_inode_t *hammer2_inode_lookup(hammer2_pfsmount_t *pmp,
494                         hammer2_tid_t inum);
495 hammer2_inode_t *hammer2_inode_get(hammer2_mount_t *hmp,
496                         hammer2_pfsmount_t *pmp, hammer2_inode_t *dip,
497                         hammer2_chain_t *chain);
498 void hammer2_inode_put(hammer2_inode_t *ip);
499 void hammer2_inode_free(hammer2_inode_t *ip);
500 void hammer2_inode_ref(hammer2_inode_t *ip);
501 void hammer2_inode_drop(hammer2_inode_t *ip);
502 void hammer2_inode_repoint(hammer2_inode_t *ip, hammer2_inode_t *pip,
503                         hammer2_chain_t *chain);
504 int hammer2_inode_calc_alloc(hammer2_key_t filesize);
505
506 hammer2_inode_t *hammer2_inode_create(hammer2_trans_t *trans,
507                         hammer2_inode_t *dip,
508                         struct vattr *vap, struct ucred *cred,
509                         const uint8_t *name, size_t name_len,
510                         int *errorp);
511 int hammer2_inode_connect(hammer2_trans_t *trans, int hlink,
512                         hammer2_inode_t *dip, hammer2_chain_t **chainp,
513                         const uint8_t *name, size_t name_len);
514 hammer2_inode_t *hammer2_inode_common_parent(hammer2_inode_t *fdip,
515                         hammer2_inode_t *tdip);
516
517 int hammer2_unlink_file(hammer2_trans_t *trans, hammer2_inode_t *dip,
518                         const uint8_t *name, size_t name_len, int isdir,
519                         int *hlinkp);
520 int hammer2_hardlink_consolidate(hammer2_trans_t *trans, hammer2_inode_t *ip,
521                         hammer2_chain_t **chainp,
522                         hammer2_inode_t *tdip, int linkcnt);
523 int hammer2_hardlink_deconsolidate(hammer2_trans_t *trans, hammer2_inode_t *dip,
524                         hammer2_chain_t **chainp, hammer2_chain_t **ochainp);
525 int hammer2_hardlink_find(hammer2_inode_t *dip,
526                         hammer2_chain_t **chainp, hammer2_chain_t **ochainp);
527
528 /*
529  * hammer2_chain.c
530  */
531 void hammer2_modify_volume(hammer2_mount_t *hmp);
532 hammer2_chain_t *hammer2_chain_alloc(hammer2_mount_t *hmp,
533                                 hammer2_blockref_t *bref);
534 void hammer2_chain_core_alloc(hammer2_chain_t *chain,
535                                 hammer2_chain_core_t *core);
536 void hammer2_chain_free(hammer2_chain_t *chain);
537 void hammer2_chain_ref(hammer2_chain_t *chain);
538 void hammer2_chain_drop(hammer2_chain_t *chain);
539 int hammer2_chain_lock(hammer2_chain_t *chain, int how);
540 void hammer2_chain_moved(hammer2_chain_t *chain);
541 void hammer2_chain_modify(hammer2_trans_t *trans,
542                                 hammer2_chain_t **chainp, int flags);
543 hammer2_inode_data_t *hammer2_chain_modify_ip(hammer2_trans_t *trans,
544                                 hammer2_inode_t *ip, int flags);
545 void hammer2_chain_resize(hammer2_trans_t *trans, hammer2_inode_t *ip,
546                                 struct buf *bp,
547                                 hammer2_chain_t *parent,
548                                 hammer2_chain_t **chainp,
549                                 int nradix, int flags);
550 void hammer2_chain_unlock(hammer2_chain_t *chain);
551 void hammer2_chain_wait(hammer2_chain_t *chain);
552 hammer2_chain_t *hammer2_chain_find(hammer2_chain_t *parent, int index);
553 hammer2_chain_t *hammer2_chain_get(hammer2_chain_t *parent, int index,
554                                 int flags);
555 hammer2_chain_t *hammer2_chain_lookup_init(hammer2_chain_t *parent, int flags);
556 void hammer2_chain_lookup_done(hammer2_chain_t *parent);
557 hammer2_chain_t *hammer2_chain_lookup(hammer2_chain_t **parentp,
558                                 hammer2_key_t key_beg, hammer2_key_t key_end,
559                                 int flags);
560 hammer2_chain_t *hammer2_chain_next(hammer2_chain_t **parentp,
561                                 hammer2_chain_t *chain,
562                                 hammer2_key_t key_beg, hammer2_key_t key_end,
563                                 int flags);
564 int hammer2_chain_create(hammer2_trans_t *trans,
565                                 hammer2_chain_t **parentp,
566                                 hammer2_chain_t **chainp,
567                                 hammer2_key_t key, int keybits,
568                                 int type, size_t bytes);
569 void hammer2_chain_duplicate(hammer2_trans_t *trans, hammer2_chain_t *parent,
570                                 int i,
571                                 hammer2_chain_t **chainp,
572                                 hammer2_blockref_t *bref);
573 int hammer2_chain_snapshot(hammer2_trans_t *trans, hammer2_inode_t *ip,
574                                 hammer2_ioc_pfs_t *pfs);
575 void hammer2_chain_delete(hammer2_trans_t *trans, hammer2_chain_t *parent,
576                                 hammer2_chain_t *chain);
577 void hammer2_chain_flush(hammer2_trans_t *trans, hammer2_chain_t *chain);
578 void hammer2_chain_commit(hammer2_trans_t *trans, hammer2_chain_t *chain);
579 void hammer2_chain_parent_setsubmod(hammer2_trans_t *trans,
580                                 hammer2_chain_t *chain);
581
582 /*
583  * hammer2_trans.c
584  */
585 void hammer2_trans_init(hammer2_mount_t *hmp, hammer2_trans_t *trans,
586                                 int flags);
587 void hammer2_trans_done(hammer2_trans_t *trans);
588
589 /*
590  * hammer2_ioctl.c
591  */
592 int hammer2_ioctl(hammer2_inode_t *ip, u_long com, void *data,
593                                 int fflag, struct ucred *cred);
594
595 /*
596  * hammer2_msgops.c
597  */
598 int hammer2_msg_dbg_rcvmsg(kdmsg_msg_t *msg);
599 int hammer2_msg_adhoc_input(kdmsg_msg_t *msg);
600
601 /*
602  * hammer2_vfsops.c
603  */
604 void hammer2_clusterctl_wakeup(kdmsg_iocom_t *iocom);
605 void hammer2_volconf_update(hammer2_pfsmount_t *pmp, int index);
606 void hammer2_cluster_reconnect(hammer2_pfsmount_t *pmp, struct file *fp);
607 void hammer2_dump_chain(hammer2_chain_t *chain, int tab, int *countp);
608
609 /*
610  * hammer2_freemap.c
611  */
612 hammer2_off_t hammer2_freemap_alloc(hammer2_mount_t *hmp,
613                                 int type, size_t bytes);
614 void hammer2_freemap_free(hammer2_mount_t *hmp, hammer2_off_t data_off,
615                                 int type);
616
617 #endif /* !_KERNEL */
618 #endif /* !_VFS_HAMMER2_HAMMER2_H_ */