hammer2 - Revamp flush and xopq mechanism, stabilization
[dragonfly.git] / sys / vfs / hammer2 / hammer2.h
blob15821a29f1ce8719418d0dfb14929fbc854e0505
1 /*
2 * Copyright (c) 2011-2016 The DragonFly Project. All rights reserved.
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>
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
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.
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.
37 * HAMMER2 IN-MEMORY CACHE OF MEDIA STRUCTURES
39 * This header file contains structures used internally by the HAMMER2
40 * implementation. See hammer2_disk.h for on-disk structures.
42 * There is an in-memory representation of all on-media data structure.
43 * Almost everything is represented by a hammer2_chain structure in-memory.
44 * Other higher-level structures typically map to chains.
46 * A great deal of data is accessed simply via its buffer cache buffer,
47 * which is mapped for the duration of the chain's lock. Hammer2 must
48 * implement its own buffer cache layer on top of the system layer to
49 * allow for different threads to lock different sub-block-sized buffers.
51 * When modifications are made to a chain a new filesystem block must be
52 * allocated. Multiple modifications do not typically allocate new blocks
53 * until the current block has been flushed. Flushes do not block the
54 * front-end unless the front-end operation crosses the current inode being
55 * flushed.
57 * The in-memory representation may remain cached (for example in order to
58 * placemark clustering locks) even after the related data has been
59 * detached.
62 #ifndef _VFS_HAMMER2_HAMMER2_H_
63 #define _VFS_HAMMER2_HAMMER2_H_
65 #include <sys/param.h>
66 #include <sys/types.h>
67 #include <sys/kernel.h>
68 #include <sys/conf.h>
69 #include <sys/systm.h>
70 #include <sys/tree.h>
71 #include <sys/malloc.h>
72 #include <sys/mount.h>
73 #include <sys/vnode.h>
74 #include <sys/proc.h>
75 #include <sys/mountctl.h>
76 #include <sys/priv.h>
77 #include <sys/stat.h>
78 #include <sys/thread.h>
79 #include <sys/globaldata.h>
80 #include <sys/lockf.h>
81 #include <sys/buf.h>
82 #include <sys/queue.h>
83 #include <sys/limits.h>
84 #include <sys/dmsg.h>
85 #include <sys/mutex.h>
86 #include <sys/kern_syscall.h>
88 #include <sys/signal2.h>
89 #include <sys/buf2.h>
90 #include <sys/mutex2.h>
91 #include <sys/thread2.h>
93 #include "hammer2_xxhash.h"
94 #include "hammer2_disk.h"
95 #include "hammer2_mount.h"
96 #include "hammer2_ioctl.h"
98 struct hammer2_io;
99 struct hammer2_iocb;
100 struct hammer2_chain;
101 struct hammer2_cluster;
102 struct hammer2_inode;
103 struct hammer2_dev;
104 struct hammer2_pfs;
105 struct hammer2_span;
106 struct hammer2_state;
107 struct hammer2_msg;
108 struct hammer2_thread;
109 union hammer2_xop;
112 * Mutex and lock shims. Hammer2 requires support for asynchronous and
113 * abortable locks, and both exclusive and shared spinlocks. Normal
114 * synchronous non-abortable locks can be substituted for spinlocks.
116 typedef mtx_t hammer2_mtx_t;
117 typedef mtx_link_t hammer2_mtx_link_t;
118 typedef mtx_state_t hammer2_mtx_state_t;
120 typedef struct spinlock hammer2_spin_t;
122 #define hammer2_mtx_ex mtx_lock_ex_quick
123 #define hammer2_mtx_sh mtx_lock_sh_quick
124 #define hammer2_mtx_sh_again mtx_lock_sh_again
125 #define hammer2_mtx_unlock mtx_unlock
126 #define hammer2_mtx_downgrade mtx_downgrade
127 #define hammer2_mtx_owned mtx_owned
128 #define hammer2_mtx_init mtx_init
129 #define hammer2_mtx_temp_release mtx_lock_temp_release
130 #define hammer2_mtx_temp_restore mtx_lock_temp_restore
131 #define hammer2_mtx_refs mtx_lockrefs
133 #define hammer2_spin_init spin_init
134 #define hammer2_spin_sh spin_lock_shared
135 #define hammer2_spin_ex spin_lock
136 #define hammer2_spin_unsh spin_unlock_shared
137 #define hammer2_spin_unex spin_unlock
139 TAILQ_HEAD(hammer2_xop_list, hammer2_xop_head);
140 TAILQ_HEAD(hammer2_chain_list, hammer2_chain);
142 typedef struct hammer2_xop_list hammer2_xop_list_t;
146 * General lock support
148 static __inline
150 hammer2_mtx_upgrade_try(hammer2_mtx_t *mtx)
152 return mtx_upgrade_try(mtx);
156 * The xid tracks internal transactional updates.
158 * XXX fix-me, really needs to be 64-bits
160 typedef uint32_t hammer2_xid_t;
162 #define HAMMER2_XID_MIN 0x00000000U
163 #define HAMMER2_XID_MAX 0x7FFFFFFFU
165 #define HAMMER2_LIMIT_DIRTY_CHAINS (65536)
168 * The chain structure tracks a portion of the media topology from the
169 * root (volume) down. Chains represent volumes, inodes, indirect blocks,
170 * data blocks, and freemap nodes and leafs.
172 * The chain structure utilizes a simple singly-homed topology and the
173 * chain's in-memory topology will move around as the chains do, due mainly
174 * to renames and indirect block creation.
176 * Block Table Updates
178 * Block table updates for insertions and updates are delayed until the
179 * flush. This allows us to avoid having to modify the parent chain
180 * all the way to the root.
182 * Block table deletions are performed immediately (modifying the parent
183 * in the process) because the flush code uses the chain structure to
184 * track delayed updates and the chain will be (likely) gone or moved to
185 * another location in the topology after a deletion.
187 * A prior iteration of the code tried to keep the relationship intact
188 * on deletes by doing a delete-duplicate operation on the chain, but
189 * it added way too much complexity to the codebase.
191 * Flush Synchronization
193 * The flush code must flush modified chains bottom-up. Because chain
194 * structures can shift around and are NOT topologically stable,
195 * modified chains are independently indexed for the flush. As the flush
196 * runs it modifies (or further modifies) and updates the parents,
197 * propagating the flush all the way to the volume root.
199 * Modifying front-end operations can occur during a flush but will block
200 * in two cases: (1) when the front-end tries to operate on the inode
201 * currently in the midst of being flushed and (2) if the front-end
202 * crosses an inode currently being flushed (such as during a rename).
203 * So, for example, if you rename directory "x" to "a/b/c/d/e/f/g/x" and
204 * the flusher is currently working on "a/b/c", the rename will block
205 * temporarily in order to ensure that "x" exists in one place or the
206 * other.
208 * Meta-data statistics are updated by the flusher. The front-end will
209 * make estimates but meta-data must be fully synchronized only during a
210 * flush in order to ensure that it remains correct across a crash.
212 * Multiple flush synchronizations can theoretically be in-flight at the
213 * same time but the implementation is not coded to handle the case and
214 * currently serializes them.
216 * Snapshots:
218 * Snapshots currently require the subdirectory tree being snapshotted
219 * to be flushed. The snapshot then creates a new super-root inode which
220 * copies the flushed blockdata of the directory or file that was
221 * snapshotted.
223 * RBTREE NOTES:
225 * - Note that the radix tree runs in powers of 2 only so sub-trees
226 * cannot straddle edges.
228 RB_HEAD(hammer2_chain_tree, hammer2_chain);
229 TAILQ_HEAD(h2_flush_list, hammer2_chain);
230 TAILQ_HEAD(h2_core_list, hammer2_chain);
231 TAILQ_HEAD(h2_iocb_list, hammer2_iocb);
233 #define CHAIN_CORE_DELETE_BMAP_ENTRIES \
234 (HAMMER2_PBUFSIZE / sizeof(hammer2_blockref_t) / sizeof(uint32_t))
237 * Core topology for chain (embedded in chain). Protected by a spinlock.
239 struct hammer2_chain_core {
240 hammer2_spin_t spin;
241 struct hammer2_chain_tree rbtree; /* sub-chains */
242 int live_zero; /* blockref array opt */
243 u_int live_count; /* live (not deleted) chains in tree */
244 u_int chain_count; /* live + deleted chains under core */
245 int generation; /* generation number (inserts only) */
248 typedef struct hammer2_chain_core hammer2_chain_core_t;
250 RB_HEAD(hammer2_io_tree, hammer2_io);
253 * IOCB - IO callback (into chain, cluster, or manual request)
255 struct hammer2_iocb {
256 TAILQ_ENTRY(hammer2_iocb) entry;
257 void (*callback)(struct hammer2_iocb *iocb);
258 struct hammer2_io *dio;
259 struct hammer2_cluster *cluster;
260 struct hammer2_chain *chain;
261 void *ptr;
262 off_t lbase;
263 int lsize;
264 uint32_t flags;
265 int error;
266 int btype;
269 typedef struct hammer2_iocb hammer2_iocb_t;
271 #define HAMMER2_IOCB_INTERLOCK 0x00000001
272 #define HAMMER2_IOCB_ONQ 0x00000002
273 #define HAMMER2_IOCB_DONE 0x00000004
274 #define HAMMER2_IOCB_INPROG 0x00000008
275 #define HAMMER2_IOCB_UNUSED10 0x00000010
276 #define HAMMER2_IOCB_QUICK 0x00010000
277 #define HAMMER2_IOCB_ZERO 0x00020000
278 #define HAMMER2_IOCB_READ 0x00040000
279 #define HAMMER2_IOCB_WAKEUP 0x00080000
282 * DIO - Management structure wrapping system buffer cache.
284 * Used for multiple purposes including concurrent management
285 * if small requests by chains into larger DIOs.
287 struct hammer2_io {
288 RB_ENTRY(hammer2_io) rbnode; /* indexed by device offset */
289 struct h2_iocb_list iocbq;
290 struct spinlock spin;
291 struct hammer2_dev *hmp;
292 struct buf *bp;
293 off_t pbase;
294 uint64_t refs;
295 int psize;
296 int act; /* activity */
297 int btype; /* approximate BREF_TYPE_* */
298 int unused01;
301 typedef struct hammer2_io hammer2_io_t;
303 #define HAMMER2_DIO_INPROG 0x8000000000000000LLU /* bio in progress */
304 #define HAMMER2_DIO_GOOD 0x4000000000000000LLU /* dio->bp is stable */
305 #define HAMMER2_DIO_WAITING 0x2000000000000000LLU /* wait on INPROG */
306 #define HAMMER2_DIO_DIRTY 0x1000000000000000LLU /* flush last drop */
307 #define HAMMER2_DIO_INVALOK 0x0800000000000000LLU /* ok to inval */
308 #define HAMMER2_DIO_INVAL 0x0400000000000000LLU /* inval request */
310 #define HAMMER2_DIO_MASK 0x00FFFFFFFFFFFFFFLLU
312 #define HAMMER2_DIO_INVALBITS (HAMMER2_DIO_INVAL | HAMMER2_DIO_INVALOK)
315 * Primary chain structure keeps track of the topology in-memory.
317 struct hammer2_chain {
318 hammer2_mtx_t lock;
319 hammer2_chain_core_t core;
320 RB_ENTRY(hammer2_chain) rbnode; /* live chain(s) */
321 hammer2_blockref_t bref;
322 struct hammer2_chain *parent;
323 struct hammer2_state *state; /* if active cache msg */
324 struct hammer2_dev *hmp;
325 struct hammer2_pfs *pmp; /* A PFS or super-root (spmp) */
327 hammer2_io_t *dio; /* physical data buffer */
328 u_int bytes; /* physical data size */
329 u_int flags;
330 u_int refs;
331 u_int lockcnt;
332 int error; /* on-lock data error state */
333 int persist_refs; /* (aka ip->cluster) */
335 hammer2_media_data_t *data; /* data pointer shortcut */
336 TAILQ_ENTRY(hammer2_chain) flush_node; /* flush list */
337 TAILQ_ENTRY(hammer2_chain) lru_node; /* 0-refs LRU */
340 typedef struct hammer2_chain hammer2_chain_t;
342 int hammer2_chain_cmp(hammer2_chain_t *chain1, hammer2_chain_t *chain2);
343 RB_PROTOTYPE(hammer2_chain_tree, hammer2_chain, rbnode, hammer2_chain_cmp);
346 * Special notes on flags:
348 * INITIAL - This flag allows a chain to be created and for storage to
349 * be allocated without having to immediately instantiate the
350 * related buffer. The data is assumed to be all-zeros. It
351 * is primarily used for indirect blocks.
353 * MODIFIED - The chain's media data has been modified. Prevents chain
354 * free on lastdrop if still in the topology.
356 * UPDATE - Chain might not be modified but parent blocktable needs
357 * an update. Prevents chain free on lastdrop if still in
358 * the topology.
360 * FICTITIOUS - Faked chain as a placeholder for an error condition. This
361 * chain is unsuitable for I/O.
363 * BMAPPED - Indicates that the chain is present in the parent blockmap.
365 * BMAPUPD - Indicates that the chain is present but needs to be updated
366 * in the parent blockmap.
368 #define HAMMER2_CHAIN_MODIFIED 0x00000001 /* dirty chain data */
369 #define HAMMER2_CHAIN_ALLOCATED 0x00000002 /* kmalloc'd chain */
370 #define HAMMER2_CHAIN_DESTROY 0x00000004
371 #define HAMMER2_CHAIN_DEDUP 0x00000008 /* recorded for dedup */
372 #define HAMMER2_CHAIN_DELETED 0x00000010 /* deleted chain */
373 #define HAMMER2_CHAIN_INITIAL 0x00000020 /* initial create */
374 #define HAMMER2_CHAIN_UPDATE 0x00000040 /* need parent update */
375 #define HAMMER2_CHAIN_DEFERRED 0x00000080 /* flush depth defer */
376 #define HAMMER2_CHAIN_TESTEDGOOD 0x00000100 /* crc tested good */
377 #define HAMMER2_CHAIN_ONFLUSH 0x00000200 /* on a flush list */
378 #define HAMMER2_CHAIN_FICTITIOUS 0x00000400 /* unsuitable for I/O */
379 #define HAMMER2_CHAIN_VOLUMESYNC 0x00000800 /* needs volume sync */
380 #define HAMMER2_CHAIN_DELAYED 0x00001000 /* delayed flush */
381 #define HAMMER2_CHAIN_COUNTEDBREFS 0x00002000 /* block table stats */
382 #define HAMMER2_CHAIN_ONRBTREE 0x00004000 /* on parent RB tree */
383 #define HAMMER2_CHAIN_ONLRU 0x00008000 /* on LRU list */
384 #define HAMMER2_CHAIN_EMBEDDED 0x00010000 /* embedded data */
385 #define HAMMER2_CHAIN_RELEASE 0x00020000 /* don't keep around */
386 #define HAMMER2_CHAIN_BMAPPED 0x00040000 /* present in blkmap */
387 #define HAMMER2_CHAIN_BMAPUPD 0x00080000 /* +needs updating */
388 #define HAMMER2_CHAIN_IOINPROG 0x00100000 /* I/O interlock */
389 #define HAMMER2_CHAIN_IOSIGNAL 0x00200000 /* I/O interlock */
390 #define HAMMER2_CHAIN_PFSBOUNDARY 0x00400000 /* super->pfs inode */
392 #define HAMMER2_CHAIN_FLUSH_MASK (HAMMER2_CHAIN_MODIFIED | \
393 HAMMER2_CHAIN_UPDATE | \
394 HAMMER2_CHAIN_ONFLUSH | \
395 HAMMER2_CHAIN_DESTROY)
398 * Hammer2 error codes, used by chain->error and cluster->error. The error
399 * code is typically set on-lock unless no I/O was requested, and set on
400 * I/O otherwise. If set for a cluster it generally means that the cluster
401 * code could not find a valid copy to present.
403 * IO - An I/O error occurred
404 * CHECK - I/O succeeded but did not match the check code
405 * INCOMPLETE - A cluster is not complete enough to use, or
406 * a chain cannot be loaded because its parent has an error.
408 * NOTE: API allows callers to check zero/non-zero to determine if an error
409 * condition exists.
411 * NOTE: Chain's data field is usually NULL on an IO error but not necessarily
412 * NULL on other errors. Check chain->error, not chain->data.
414 #define HAMMER2_ERROR_NONE 0
415 #define HAMMER2_ERROR_IO 1 /* device I/O error */
416 #define HAMMER2_ERROR_CHECK 2 /* check code mismatch */
417 #define HAMMER2_ERROR_INCOMPLETE 3 /* incomplete cluster */
418 #define HAMMER2_ERROR_DEPTH 4 /* temporary depth limit */
421 * Flags passed to hammer2_chain_lookup() and hammer2_chain_next()
423 * NOTES:
424 * NOLOCK - Input and output chains are referenced only and not
425 * locked. Output chain might be temporarily locked
426 * internally.
428 * NODATA - Asks that the chain->data not be resolved in order
429 * to avoid I/O.
431 * NODIRECT - Prevents a lookup of offset 0 in an inode from returning
432 * the inode itself if the inode is in DIRECTDATA mode
433 * (i.e. file is <= 512 bytes). Used by the synchronization
434 * code to prevent confusion.
436 * SHARED - The input chain is expected to be locked shared,
437 * and the output chain is locked shared.
439 * MATCHIND - Allows an indirect block / freemap node to be returned
440 * when the passed key range matches the radix. Remember
441 * that key_end is inclusive (e.g. {0x000,0xFFF},
442 * not {0x000,0x1000}).
444 * (Cannot be used for remote or cluster ops).
446 * ALLNODES - Allows NULL focus.
448 * ALWAYS - Always resolve the data. If ALWAYS and NODATA are both
449 * missing, bulk file data is not resolved but inodes and
450 * other meta-data will.
452 * NOUNLOCK - Used by hammer2_chain_next() to leave the lock on
453 * the input chain intact. The chain is still dropped.
454 * This allows the caller to add a reference to the chain
455 * and retain it in a locked state (used by the
456 * XOP/feed/collect code).
458 #define HAMMER2_LOOKUP_NOLOCK 0x00000001 /* ref only */
459 #define HAMMER2_LOOKUP_NODATA 0x00000002 /* data left NULL */
460 #define HAMMER2_LOOKUP_NODIRECT 0x00000004 /* no offset=0 DD */
461 #define HAMMER2_LOOKUP_SHARED 0x00000100
462 #define HAMMER2_LOOKUP_MATCHIND 0x00000200 /* return all chains */
463 #define HAMMER2_LOOKUP_ALLNODES 0x00000400 /* allow NULL focus */
464 #define HAMMER2_LOOKUP_ALWAYS 0x00000800 /* resolve data */
465 #define HAMMER2_LOOKUP_NOUNLOCK 0x00001000 /* leave lock intact */
468 * Flags passed to hammer2_chain_modify() and hammer2_chain_resize()
470 * NOTE: OPTDATA allows us to avoid instantiating buffers for INDIRECT
471 * blocks in the INITIAL-create state.
473 #define HAMMER2_MODIFY_OPTDATA 0x00000002 /* data can be NULL */
474 #define HAMMER2_MODIFY_NO_MODIFY_TID 0x00000004
475 #define HAMMER2_MODIFY_UNUSED0008 0x00000008
478 * Flags passed to hammer2_chain_lock()
480 * NOTE: RDONLY is set to optimize cluster operations when *no* modifications
481 * will be made to either the cluster being locked or any underlying
482 * cluster. It allows the cluster to lock and access data for a subset
483 * of available nodes instead of all available nodes.
485 #define HAMMER2_RESOLVE_NEVER 1
486 #define HAMMER2_RESOLVE_MAYBE 2
487 #define HAMMER2_RESOLVE_ALWAYS 3
488 #define HAMMER2_RESOLVE_MASK 0x0F
490 #define HAMMER2_RESOLVE_SHARED 0x10 /* request shared lock */
491 #define HAMMER2_RESOLVE_LOCKAGAIN 0x20 /* another shared lock */
492 #define HAMMER2_RESOLVE_RDONLY 0x40 /* higher level op flag */
495 * Flags passed to hammer2_chain_delete()
497 #define HAMMER2_DELETE_PERMANENT 0x0001
500 * Flags passed to hammer2_chain_insert() or hammer2_chain_rename()
502 #define HAMMER2_INSERT_PFSROOT 0x0004
505 * Flags passed to hammer2_chain_delete_duplicate()
507 #define HAMMER2_DELDUP_RECORE 0x0001
510 * Cluster different types of storage together for allocations
512 #define HAMMER2_FREECACHE_INODE 0
513 #define HAMMER2_FREECACHE_INDIR 1
514 #define HAMMER2_FREECACHE_DATA 2
515 #define HAMMER2_FREECACHE_UNUSED3 3
516 #define HAMMER2_FREECACHE_TYPES 4
519 * hammer2_freemap_alloc() block preference
521 #define HAMMER2_OFF_NOPREF ((hammer2_off_t)-1)
524 * BMAP read-ahead maximum parameters
526 #define HAMMER2_BMAP_COUNT 16 /* max bmap read-ahead */
527 #define HAMMER2_BMAP_BYTES (HAMMER2_PBUFSIZE * HAMMER2_BMAP_COUNT)
530 * hammer2_freemap_adjust()
532 #define HAMMER2_FREEMAP_DORECOVER 1
533 #define HAMMER2_FREEMAP_DOMAYFREE 2
534 #define HAMMER2_FREEMAP_DOREALFREE 3
537 * HAMMER2 cluster - A set of chains representing the same entity.
539 * hammer2_cluster typically represents a temporary set of representitive
540 * chains. The one exception is that a hammer2_cluster is embedded in
541 * hammer2_inode. This embedded cluster is ONLY used to track the
542 * representitive chains and cannot be directly locked.
544 * A cluster is usually temporary (and thus per-thread) for locking purposes,
545 * allowing us to embed the asynchronous storage required for cluster
546 * operations in the cluster itself and adjust the state and status without
547 * having to worry too much about SMP issues.
549 * The exception is the cluster embedded in the hammer2_inode structure.
550 * This is used to cache the cluster state on an inode-by-inode basis.
551 * Individual hammer2_chain structures not incorporated into clusters might
552 * also stick around to cache miscellanious elements.
554 * Because the cluster is a 'working copy' and is usually subject to cluster
555 * quorum rules, it is quite possible for us to end up with an insufficient
556 * number of live chains to execute an operation. If an insufficient number
557 * of chains remain in a working copy, the operation may have to be
558 * downgraded, retried, stall until the requisit number of chains are
559 * available, or possibly even error out depending on the mount type.
561 * A cluster's focus is set when it is locked. The focus can only be set
562 * to a chain still part of the synchronized set.
564 #define HAMMER2_MAXCLUSTER 8
565 #define HAMMER2_XOPMASK_CLUSTER ((1U << HAMMER2_MAXCLUSTER) - 1)
566 #define HAMMER2_XOPFIFO 16
567 #define HAMMER2_XOPFIFO_MASK (HAMMER2_XOPFIFO - 1)
568 #define HAMMER2_XOPGROUPS 32
569 #define HAMMER2_XOPGROUPS_MASK (HAMMER2_XOPGROUPS - 1)
570 #define HAMMER2_XOPMASK_VOP 0x80000000U
571 #define HAMMER2_XOPMASK_FIFOW 0x40000000U
573 #define HAMMER2_XOPMASK_ALLDONE (HAMMER2_XOPMASK_VOP | HAMMER2_XOPMASK_CLUSTER)
575 #define HAMMER2_SPECTHREADS 1 /* sync */
577 struct hammer2_cluster_item {
578 hammer2_chain_t *chain;
579 int cache_index;
580 int error;
581 uint32_t flags;
584 typedef struct hammer2_cluster_item hammer2_cluster_item_t;
587 * INVALID - Invalid for focus, i.e. not part of synchronized set.
588 * Once set, this bit is sticky across operations.
590 * FEMOD - Indicates that front-end modifying operations can
591 * mess with this entry and MODSYNC will copy also
592 * effect it.
594 #define HAMMER2_CITEM_INVALID 0x00000001
595 #define HAMMER2_CITEM_FEMOD 0x00000002
596 #define HAMMER2_CITEM_NULL 0x00000004
598 struct hammer2_cluster {
599 int refs; /* track for deallocation */
600 int ddflag;
601 struct hammer2_pfs *pmp;
602 uint32_t flags;
603 int nchains;
604 int error; /* error code valid on lock */
605 int focus_index;
606 hammer2_iocb_t iocb;
607 hammer2_chain_t *focus; /* current focus (or mod) */
608 hammer2_cluster_item_t array[HAMMER2_MAXCLUSTER];
611 typedef struct hammer2_cluster hammer2_cluster_t;
614 * WRHARD - Hard mounts can write fully synchronized
615 * RDHARD - Hard mounts can read fully synchronized
616 * UNHARD - Unsynchronized masters present
617 * NOHARD - No masters visible
618 * WRSOFT - Soft mounts can write to at least the SOFT_MASTER
619 * RDSOFT - Soft mounts can read from at least a SOFT_SLAVE
620 * UNSOFT - Unsynchronized slaves present
621 * NOSOFT - No slaves visible
622 * RDSLAVE - slaves are accessible (possibly unsynchronized or remote).
623 * MSYNCED - All masters are fully synchronized
624 * SSYNCED - All known local slaves are fully synchronized to masters
626 * All available masters are always incorporated. All PFSs belonging to a
627 * cluster (master, slave, copy, whatever) always try to synchronize the
628 * total number of known masters in the PFSs root inode.
630 * A cluster might have access to many slaves, copies, or caches, but we
631 * have a limited number of cluster slots. Any such elements which are
632 * directly mounted from block device(s) will always be incorporated. Note
633 * that SSYNCED only applies to such elements which are directly mounted,
634 * not to any remote slaves, copies, or caches that could be available. These
635 * bits are used to monitor and drive our synchronization threads.
637 * When asking the question 'is any data accessible at all', then a simple
638 * test against (RDHARD|RDSOFT|RDSLAVE) gives you the answer. If any of
639 * these bits are set the object can be read with certain caveats:
640 * RDHARD - no caveats. RDSOFT - authoritative but might not be synchronized.
641 * and RDSLAVE - not authoritative, has some data but it could be old or
642 * incomplete.
644 * When both soft and hard mounts are available, data will be read and written
645 * via the soft mount only. But all might be in the cluster because
646 * background synchronization threads still need to do their work.
648 #define HAMMER2_CLUSTER_INODE 0x00000001 /* embedded in inode struct */
649 #define HAMMER2_CLUSTER_UNUSED2 0x00000002
650 #define HAMMER2_CLUSTER_LOCKED 0x00000004 /* cluster lks not recursive */
651 #define HAMMER2_CLUSTER_WRHARD 0x00000100 /* hard-mount can write */
652 #define HAMMER2_CLUSTER_RDHARD 0x00000200 /* hard-mount can read */
653 #define HAMMER2_CLUSTER_UNHARD 0x00000400 /* unsynchronized masters */
654 #define HAMMER2_CLUSTER_NOHARD 0x00000800 /* no masters visible */
655 #define HAMMER2_CLUSTER_WRSOFT 0x00001000 /* soft-mount can write */
656 #define HAMMER2_CLUSTER_RDSOFT 0x00002000 /* soft-mount can read */
657 #define HAMMER2_CLUSTER_UNSOFT 0x00004000 /* unsynchronized slaves */
658 #define HAMMER2_CLUSTER_NOSOFT 0x00008000 /* no slaves visible */
659 #define HAMMER2_CLUSTER_MSYNCED 0x00010000 /* all masters synchronized */
660 #define HAMMER2_CLUSTER_SSYNCED 0x00020000 /* known slaves synchronized */
662 #define HAMMER2_CLUSTER_ANYDATA ( HAMMER2_CLUSTER_RDHARD | \
663 HAMMER2_CLUSTER_RDSOFT | \
664 HAMMER2_CLUSTER_RDSLAVE)
666 #define HAMMER2_CLUSTER_RDOK ( HAMMER2_CLUSTER_RDHARD | \
667 HAMMER2_CLUSTER_RDSOFT)
669 #define HAMMER2_CLUSTER_WROK ( HAMMER2_CLUSTER_WRHARD | \
670 HAMMER2_CLUSTER_WRSOFT)
672 #define HAMMER2_CLUSTER_ZFLAGS ( HAMMER2_CLUSTER_WRHARD | \
673 HAMMER2_CLUSTER_RDHARD | \
674 HAMMER2_CLUSTER_WRSOFT | \
675 HAMMER2_CLUSTER_RDSOFT | \
676 HAMMER2_CLUSTER_MSYNCED | \
677 HAMMER2_CLUSTER_SSYNCED)
680 * Helper functions (cluster must be locked for flags to be valid).
682 static __inline
684 hammer2_cluster_rdok(hammer2_cluster_t *cluster)
686 return (cluster->flags & HAMMER2_CLUSTER_RDOK);
689 static __inline
691 hammer2_cluster_wrok(hammer2_cluster_t *cluster)
693 return (cluster->flags & HAMMER2_CLUSTER_WROK);
696 RB_HEAD(hammer2_inode_tree, hammer2_inode);
699 * A hammer2 inode.
701 * NOTE: The inode-embedded cluster is never used directly for I/O (since
702 * it may be shared). Instead it will be replicated-in and synchronized
703 * back out if changed.
705 struct hammer2_inode {
706 RB_ENTRY(hammer2_inode) rbnode; /* inumber lookup (HL) */
707 hammer2_mtx_t lock; /* inode lock */
708 hammer2_mtx_t truncate_lock; /* prevent truncates */
709 struct hammer2_pfs *pmp; /* PFS mount */
710 struct vnode *vp;
711 struct spinlock cluster_spin; /* update cluster */
712 hammer2_cluster_t cluster;
713 struct lockf advlock;
714 u_int flags;
715 u_int refs; /* +vpref, +flushref */
716 uint8_t comp_heuristic;
717 hammer2_inode_meta_t meta; /* copy of meta-data */
718 hammer2_off_t osize;
719 hammer2_cluster_t *cluster_cache;
722 typedef struct hammer2_inode hammer2_inode_t;
725 * MODIFIED - Inode is in a modified state, ip->meta may have changes.
726 * RESIZED - Inode truncated (any) or inode extended beyond
727 * EMBEDDED_BYTES.
729 #define HAMMER2_INODE_MODIFIED 0x0001
730 #define HAMMER2_INODE_SROOT 0x0002 /* kmalloc special case */
731 #define HAMMER2_INODE_RENAME_INPROG 0x0004
732 #define HAMMER2_INODE_ONRBTREE 0x0008
733 #define HAMMER2_INODE_RESIZED 0x0010 /* requires inode_fsync */
734 #define HAMMER2_INODE_ISDELETED 0x0020 /* deleted */
735 #define HAMMER2_INODE_ISUNLINKED 0x0040
736 #define HAMMER2_INODE_METAGOOD 0x0080 /* inode meta-data good */
737 #define HAMMER2_INODE_ONSIDEQ 0x0100 /* on side processing queue */
739 int hammer2_inode_cmp(hammer2_inode_t *ip1, hammer2_inode_t *ip2);
740 RB_PROTOTYPE2(hammer2_inode_tree, hammer2_inode, rbnode, hammer2_inode_cmp,
741 hammer2_tid_t);
744 * inode-unlink side-structure
746 struct hammer2_inode_sideq {
747 TAILQ_ENTRY(hammer2_inode_sideq) entry;
748 hammer2_inode_t *ip;
750 TAILQ_HEAD(h2_sideq_list, hammer2_inode_sideq);
752 typedef struct hammer2_inode_sideq hammer2_inode_sideq_t;
755 * Transaction management sub-structure under hammer2_pfs
757 struct hammer2_trans {
758 uint32_t flags;
759 uint32_t sync_wait;
762 typedef struct hammer2_trans hammer2_trans_t;
764 #define HAMMER2_TRANS_ISFLUSH 0x80000000 /* flush code */
765 #define HAMMER2_TRANS_BUFCACHE 0x40000000 /* bio strategy */
766 #define HAMMER2_TRANS_UNUSED20 0x20000000
767 #define HAMMER2_TRANS_FPENDING 0x10000000 /* flush pending */
768 #define HAMMER2_TRANS_WAITING 0x08000000 /* someone waiting */
769 #define HAMMER2_TRANS_MASK 0x00FFFFFF /* count mask */
771 #define HAMMER2_FREEMAP_HEUR_NRADIX 4 /* pwr 2 PBUFRADIX-MINIORADIX */
772 #define HAMMER2_FREEMAP_HEUR_TYPES 8
773 #define HAMMER2_FREEMAP_HEUR_SIZE (HAMMER2_FREEMAP_HEUR_NRADIX * \
774 HAMMER2_FREEMAP_HEUR_TYPES)
776 #define HAMMER2_DEDUP_HEUR_SIZE 65536
777 #define HAMMER2_DEDUP_HEUR_MASK (HAMMER2_DEDUP_HEUR_SIZE - 1)
779 #define HAMMER2_FLUSH_TOP 0x0001
780 #define HAMMER2_FLUSH_ALL 0x0002
784 * Hammer2 support thread element.
786 * Potentially many support threads can hang off of hammer2, primarily
787 * off the hammer2_pfs structure. Typically:
789 * td x Nodes A synchronization thread for each node.
790 * td x Nodes x workers Worker threads for frontend operations.
791 * td x 1 Bioq thread for logical buffer writes.
793 * In addition, the synchronization thread(s) associated with the
794 * super-root PFS (spmp) for a node is responsible for automatic bulkfree
795 * and dedup scans.
797 struct hammer2_thread {
798 struct hammer2_pfs *pmp;
799 hammer2_xop_list_t xopq;
800 thread_t td;
801 uint32_t flags;
802 int depth;
803 int clindex; /* cluster element index */
804 int repidx;
807 typedef struct hammer2_thread hammer2_thread_t;
809 #define HAMMER2_THREAD_UNMOUNTING 0x0001 /* unmount request */
810 #define HAMMER2_THREAD_DEV 0x0002 /* related to dev, not pfs */
811 #define HAMMER2_THREAD_WAITING 0x0004 /* thread in idle tsleep */
812 #define HAMMER2_THREAD_REMASTER 0x0008 /* remaster request */
813 #define HAMMER2_THREAD_STOP 0x0010 /* exit request */
814 #define HAMMER2_THREAD_FREEZE 0x0020 /* force idle */
815 #define HAMMER2_THREAD_FROZEN 0x0040 /* thread is frozen */
816 #define HAMMER2_THREAD_XOPQ 0x0080 /* work pending */
817 #define HAMMER2_THREAD_STOPPED 0x0100 /* thread has stopped */
818 #define HAMMER2_THREAD_UNFREEZE 0x0200
819 #define HAMMER2_THREAD_CLIENTWAIT 0x0400
821 #define HAMMER2_THREAD_WAKEUP_MASK (HAMMER2_THREAD_UNMOUNTING | \
822 HAMMER2_THREAD_REMASTER | \
823 HAMMER2_THREAD_STOP | \
824 HAMMER2_THREAD_FREEZE | \
825 HAMMER2_THREAD_XOPQ)
828 * Support structure for dedup heuristic.
830 struct hammer2_dedup {
831 hammer2_off_t data_off;
832 uint64_t data_crc;
833 uint32_t ticks;
834 uint32_t unused03;
837 typedef struct hammer2_dedup hammer2_dedup_t;
840 * hammer2_xop - container for VOP/XOP operation (allocated, not on stack).
842 * This structure is used to distribute a VOP operation across multiple
843 * nodes. It provides a rendezvous for concurrent node execution and
844 * can be detached from the frontend operation to allow the frontend to
845 * return early.
847 * This structure also sequences operations on up to three inodes.
849 typedef void (*hammer2_xop_func_t)(union hammer2_xop *xop, int clidx);
851 struct hammer2_xop_fifo {
852 TAILQ_ENTRY(hammer2_xop_head) entry;
853 hammer2_chain_t *array[HAMMER2_XOPFIFO];
854 int errors[HAMMER2_XOPFIFO];
855 int ri;
856 int wi;
857 int flags;
860 typedef struct hammer2_xop_fifo hammer2_xop_fifo_t;
862 #define HAMMER2_XOP_FIFO_RUN 0x0001
863 #define HAMMER2_XOP_FIFO_STALL 0x0002
865 struct hammer2_xop_head {
866 hammer2_xop_func_t func;
867 hammer2_tid_t mtid;
868 struct hammer2_inode *ip1;
869 struct hammer2_inode *ip2;
870 struct hammer2_inode *ip3;
871 uint32_t check_counter;
872 uint32_t run_mask;
873 uint32_t chk_mask;
874 int flags;
875 int state;
876 int error;
877 hammer2_key_t collect_key;
878 char *name1;
879 size_t name1_len;
880 char *name2;
881 size_t name2_len;
882 hammer2_xop_fifo_t collect[HAMMER2_MAXCLUSTER];
883 hammer2_cluster_t cluster; /* help collections */
886 typedef struct hammer2_xop_head hammer2_xop_head_t;
888 #define HAMMER2_XOP_CHKWAIT 0x00000001U
889 #define HAMMER2_XOP_CHKINC 0x00000002U
891 struct hammer2_xop_ipcluster {
892 hammer2_xop_head_t head;
895 struct hammer2_xop_strategy {
896 hammer2_xop_head_t head;
897 hammer2_key_t lbase;
898 int finished;
899 hammer2_mtx_t lock;
900 struct bio *bio;
903 struct hammer2_xop_readdir {
904 hammer2_xop_head_t head;
905 hammer2_key_t lkey;
908 struct hammer2_xop_nresolve {
909 hammer2_xop_head_t head;
910 hammer2_key_t lhc; /* if name is NULL used lhc */
913 struct hammer2_xop_nlink {
914 hammer2_xop_head_t head;
915 int nlinks_delta;
918 struct hammer2_xop_unlink {
919 hammer2_xop_head_t head;
920 int isdir;
921 int dopermanent;
924 struct hammer2_xop_nrename {
925 hammer2_xop_head_t head;
926 hammer2_tid_t lhc;
927 int ip_key;
930 struct hammer2_xop_scanlhc {
931 hammer2_xop_head_t head;
932 hammer2_key_t lhc;
935 struct hammer2_xop_scanall {
936 hammer2_xop_head_t head;
937 hammer2_key_t key_beg; /* inclusive */
938 hammer2_key_t key_end; /* inclusive */
939 int resolve_flags;
940 int lookup_flags;
943 struct hammer2_xop_lookup {
944 hammer2_xop_head_t head;
945 hammer2_key_t lhc;
948 struct hammer2_xop_create {
949 hammer2_xop_head_t head;
950 hammer2_inode_meta_t meta; /* initial metadata */
951 hammer2_key_t lhc;
952 int flags;
955 struct hammer2_xop_destroy {
956 hammer2_xop_head_t head;
959 struct hammer2_xop_fsync {
960 hammer2_xop_head_t head;
961 hammer2_inode_meta_t meta;
962 hammer2_off_t osize;
963 u_int ipflags;
964 int clear_directdata;
967 struct hammer2_xop_unlinkall {
968 hammer2_xop_head_t head;
969 hammer2_key_t key_beg;
970 hammer2_key_t key_end;
973 struct hammer2_xop_connect {
974 hammer2_xop_head_t head;
975 hammer2_key_t lhc;
978 struct hammer2_xop_flush {
979 hammer2_xop_head_t head;
982 typedef struct hammer2_xop_readdir hammer2_xop_readdir_t;
983 typedef struct hammer2_xop_nresolve hammer2_xop_nresolve_t;
984 typedef struct hammer2_xop_nlink hammer2_xop_nlink_t;
985 typedef struct hammer2_xop_unlink hammer2_xop_unlink_t;
986 typedef struct hammer2_xop_nrename hammer2_xop_nrename_t;
987 typedef struct hammer2_xop_ipcluster hammer2_xop_ipcluster_t;
988 typedef struct hammer2_xop_strategy hammer2_xop_strategy_t;
989 typedef struct hammer2_xop_create hammer2_xop_create_t;
990 typedef struct hammer2_xop_destroy hammer2_xop_destroy_t;
991 typedef struct hammer2_xop_fsync hammer2_xop_fsync_t;
992 typedef struct hammer2_xop_unlinkall hammer2_xop_unlinkall_t;
993 typedef struct hammer2_xop_scanlhc hammer2_xop_scanlhc_t;
994 typedef struct hammer2_xop_scanall hammer2_xop_scanall_t;
995 typedef struct hammer2_xop_lookup hammer2_xop_lookup_t;
996 typedef struct hammer2_xop_connect hammer2_xop_connect_t;
997 typedef struct hammer2_xop_flush hammer2_xop_flush_t;
999 union hammer2_xop {
1000 hammer2_xop_head_t head;
1001 hammer2_xop_ipcluster_t xop_ipcluster;
1002 hammer2_xop_readdir_t xop_readdir;
1003 hammer2_xop_nresolve_t xop_nresolve;
1004 hammer2_xop_nlink_t xop_nlink;
1005 hammer2_xop_unlink_t xop_unlink;
1006 hammer2_xop_nrename_t xop_nrename;
1007 hammer2_xop_strategy_t xop_strategy;
1008 hammer2_xop_create_t xop_create;
1009 hammer2_xop_destroy_t xop_destroy;
1010 hammer2_xop_fsync_t xop_fsync;
1011 hammer2_xop_unlinkall_t xop_unlinkall;
1012 hammer2_xop_scanlhc_t xop_scanlhc;
1013 hammer2_xop_scanall_t xop_scanall;
1014 hammer2_xop_lookup_t xop_lookup;
1015 hammer2_xop_flush_t xop_flush;
1016 hammer2_xop_connect_t xop_connect;
1019 typedef union hammer2_xop hammer2_xop_t;
1022 * hammer2_xop_group - Manage XOP support threads.
1024 struct hammer2_xop_group {
1025 hammer2_thread_t thrs[HAMMER2_MAXCLUSTER];
1028 typedef struct hammer2_xop_group hammer2_xop_group_t;
1031 * flags to hammer2_xop_collect()
1033 #define HAMMER2_XOP_COLLECT_NOWAIT 0x00000001
1034 #define HAMMER2_XOP_COLLECT_WAITALL 0x00000002
1037 * flags to hammer2_xop_alloc()
1039 * MODIFYING - This is a modifying transaction, allocate a mtid.
1041 #define HAMMER2_XOP_MODIFYING 0x00000001
1042 #define HAMMER2_XOP_STRATEGY 0x00000002
1045 * Global (per partition) management structure, represents a hard block
1046 * device. Typically referenced by hammer2_chain structures when applicable.
1047 * Typically not used for network-managed elements.
1049 * Note that a single hammer2_dev can be indirectly tied to multiple system
1050 * mount points. There is no direct relationship. System mounts are
1051 * per-cluster-id, not per-block-device, and a single hard mount might contain
1052 * many PFSs and those PFSs might combine together in various ways to form
1053 * the set of available clusters.
1055 struct hammer2_dev {
1056 struct vnode *devvp; /* device vnode */
1057 int ronly; /* read-only mount */
1058 int mount_count; /* number of actively mounted PFSs */
1059 TAILQ_ENTRY(hammer2_dev) mntentry; /* hammer2_mntlist */
1061 struct malloc_type *mchain;
1062 int nipstacks;
1063 int maxipstacks;
1064 kdmsg_iocom_t iocom; /* volume-level dmsg interface */
1065 struct spinlock io_spin; /* iotree access */
1066 struct hammer2_io_tree iotree;
1067 int iofree_count;
1068 hammer2_chain_t vchain; /* anchor chain (topology) */
1069 hammer2_chain_t fchain; /* anchor chain (freemap) */
1070 struct spinlock list_spin;
1071 struct h2_flush_list flushq; /* flush seeds */
1072 struct hammer2_pfs *spmp; /* super-root pmp for transactions */
1073 struct lock bulklk; /* bulkfree lock */
1074 struct lock vollk; /* lockmgr lock */
1075 hammer2_off_t heur_freemap[HAMMER2_FREEMAP_HEUR_SIZE];
1076 hammer2_dedup_t heur_dedup[HAMMER2_DEDUP_HEUR_SIZE];
1077 int volhdrno; /* last volhdrno written */
1078 int hflags; /* HMNT2 flags applicable to device */
1079 char devrepname[64]; /* for kprintf */
1080 hammer2_volume_data_t voldata;
1081 hammer2_volume_data_t volsync; /* synchronized voldata */
1084 typedef struct hammer2_dev hammer2_dev_t;
1087 * Helper functions (cluster must be locked for flags to be valid).
1089 static __inline
1091 hammer2_chain_rdok(hammer2_chain_t *chain)
1093 return (chain->error == 0);
1096 static __inline
1098 hammer2_chain_wrok(hammer2_chain_t *chain)
1100 return (chain->error == 0 && chain->hmp->ronly == 0);
1104 * Per-cluster management structure. This structure will be tied to a
1105 * system mount point if the system is mounting the PFS, but is also used
1106 * to manage clusters encountered during the super-root scan or received
1107 * via LNK_SPANs that might not be mounted.
1109 * This structure is also used to represent the super-root that hangs off
1110 * of a hard mount point. The super-root is not really a cluster element.
1111 * In this case the spmp_hmp field will be non-NULL. It's just easier to do
1112 * this than to special case super-root manipulation in the hammer2_chain*
1113 * code as being only hammer2_dev-related.
1115 * pfs_mode and pfs_nmasters are rollup fields which critically describes
1116 * how elements of the cluster act on the cluster. pfs_mode is only applicable
1117 * when a PFS is mounted by the system. pfs_nmasters is our best guess as to
1118 * how many masters have been configured for a cluster and is always
1119 * applicable. pfs_types[] is an array with 1:1 correspondance to the
1120 * iroot cluster and describes the PFS types of the nodes making up the
1121 * cluster.
1123 * WARNING! Portions of this structure have deferred initialization. In
1124 * particular, if not mounted there will be no wthread.
1125 * umounted network PFSs will also be missing iroot and numerous
1126 * other fields will not be initialized prior to mount.
1128 * Synchronization threads are chain-specific and only applicable
1129 * to local hard PFS entries. A hammer2_pfs structure may contain
1130 * more than one when multiple hard PFSs are present on the local
1131 * machine which require synchronization monitoring. Most PFSs
1132 * (such as snapshots) are 1xMASTER PFSs which do not need a
1133 * synchronization thread.
1135 * WARNING! The chains making up pfs->iroot's cluster are accounted for in
1136 * hammer2_dev->mount_count when the pfs is associated with a mount
1137 * point.
1139 struct hammer2_pfs {
1140 struct mount *mp;
1141 TAILQ_ENTRY(hammer2_pfs) mntentry; /* hammer2_pfslist */
1142 uuid_t pfs_clid;
1143 hammer2_dev_t *spmp_hmp; /* only if super-root pmp */
1144 hammer2_dev_t *force_local; /* only if 'local' mount */
1145 hammer2_inode_t *iroot; /* PFS root inode */
1146 uint8_t pfs_types[HAMMER2_MAXCLUSTER];
1147 char *pfs_names[HAMMER2_MAXCLUSTER];
1148 hammer2_dev_t *pfs_hmps[HAMMER2_MAXCLUSTER];
1149 hammer2_trans_t trans;
1150 struct lock lock; /* PFS lock for certain ops */
1151 struct lock lock_nlink; /* rename and nlink lock */
1152 struct netexport export; /* nfs export */
1153 int ronly; /* read-only mount */
1154 int hflags; /* pfs-specific mount flags */
1155 struct malloc_type *minode;
1156 struct malloc_type *mmsg;
1157 struct spinlock inum_spin; /* inumber lookup */
1158 struct hammer2_inode_tree inum_tree; /* (not applicable to spmp) */
1159 struct spinlock lru_spin; /* inumber lookup */
1160 struct hammer2_chain_list lru_list; /* chains on LRU */
1161 int lru_count; /* #of chains on LRU */
1162 hammer2_tid_t modify_tid; /* modify transaction id */
1163 hammer2_tid_t inode_tid; /* inode allocator */
1164 uint8_t pfs_nmasters; /* total masters */
1165 uint8_t pfs_mode; /* operating mode PFSMODE */
1166 uint8_t unused01;
1167 uint8_t unused02;
1168 int unused03;
1169 long inmem_inodes;
1170 uint32_t inmem_dirty_chains;
1171 int count_lwinprog; /* logical write in prog */
1172 struct spinlock list_spin;
1173 struct h2_sideq_list sideq; /* last-close dirty/unlink */
1174 hammer2_thread_t sync_thrs[HAMMER2_MAXCLUSTER];
1175 uint32_t cluster_flags; /* cached cluster flags */
1176 int has_xop_threads;
1177 struct spinlock xop_spin; /* xop sequencer */
1178 hammer2_xop_group_t xop_groups[HAMMER2_XOPGROUPS];
1181 typedef struct hammer2_pfs hammer2_pfs_t;
1183 #define HAMMER2_LRU_LIMIT 1024 /* per pmp lru_list */
1185 #define HAMMER2_DIRTYCHAIN_WAITING 0x80000000
1186 #define HAMMER2_DIRTYCHAIN_MASK 0x7FFFFFFF
1188 #define HAMMER2_LWINPROG_WAITING 0x80000000
1189 #define HAMMER2_LWINPROG_WAITING0 0x40000000
1190 #define HAMMER2_LWINPROG_MASK 0x3FFFFFFF
1193 * hammer2_cluster_check
1195 #define HAMMER2_CHECK_NULL 0x00000001
1198 * Bulkscan
1200 #define HAMMER2_BULK_ABORT 0x00000001
1203 * Misc
1205 #if defined(_KERNEL)
1207 MALLOC_DECLARE(M_HAMMER2);
1209 #define VTOI(vp) ((hammer2_inode_t *)(vp)->v_data)
1210 #define ITOV(ip) ((ip)->vp)
1213 * Currently locked chains retain the locked buffer cache buffer for
1214 * indirect blocks, and indirect blocks can be one of two sizes. The
1215 * device buffer has to match the case to avoid deadlocking recursive
1216 * chains that might otherwise try to access different offsets within
1217 * the same device buffer.
1219 static __inline
1221 hammer2_devblkradix(int radix)
1223 #if 0
1224 if (radix <= HAMMER2_LBUFRADIX) {
1225 return (HAMMER2_LBUFRADIX);
1226 } else {
1227 return (HAMMER2_PBUFRADIX);
1229 #endif
1230 return (HAMMER2_PBUFRADIX);
1234 * XXX almost time to remove this. DIO uses PBUFSIZE exclusively now.
1236 static __inline
1237 size_t
1238 hammer2_devblksize(size_t bytes)
1240 #if 0
1241 if (bytes <= HAMMER2_LBUFSIZE) {
1242 return(HAMMER2_LBUFSIZE);
1243 } else {
1244 KKASSERT(bytes <= HAMMER2_PBUFSIZE &&
1245 (bytes ^ (bytes - 1)) == ((bytes << 1) - 1));
1246 return (HAMMER2_PBUFSIZE);
1248 #endif
1249 return (HAMMER2_PBUFSIZE);
1253 static __inline
1254 hammer2_pfs_t *
1255 MPTOPMP(struct mount *mp)
1257 return ((hammer2_pfs_t *)mp->mnt_data);
1260 #define LOCKSTART int __nlocks = curthread->td_locks
1261 #define LOCKENTER (++curthread->td_locks)
1262 #define LOCKEXIT (--curthread->td_locks)
1263 #define LOCKSTOP KKASSERT(curthread->td_locks == __nlocks)
1265 extern struct vop_ops hammer2_vnode_vops;
1266 extern struct vop_ops hammer2_spec_vops;
1267 extern struct vop_ops hammer2_fifo_vops;
1269 extern int hammer2_debug;
1270 extern int hammer2_cluster_read;
1271 extern int hammer2_cluster_write;
1272 extern int hammer2_dedup_enable;
1273 extern int hammer2_inval_enable;
1274 extern int hammer2_flush_pipe;
1275 extern int hammer2_synchronous_flush;
1276 extern int hammer2_dio_count;
1277 extern long hammer2_chain_allocs;
1278 extern long hammer2_chain_frees;
1279 extern long hammer2_limit_dirty_chains;
1280 extern long hammer2_count_modified_chains;
1281 extern long hammer2_iod_invals;
1282 extern long hammer2_iod_file_read;
1283 extern long hammer2_iod_meta_read;
1284 extern long hammer2_iod_indr_read;
1285 extern long hammer2_iod_fmap_read;
1286 extern long hammer2_iod_volu_read;
1287 extern long hammer2_iod_file_write;
1288 extern long hammer2_iod_file_wembed;
1289 extern long hammer2_iod_file_wzero;
1290 extern long hammer2_iod_file_wdedup;
1291 extern long hammer2_iod_meta_write;
1292 extern long hammer2_iod_indr_write;
1293 extern long hammer2_iod_fmap_write;
1294 extern long hammer2_iod_volu_write;
1296 extern long hammer2_check_xxhash64;
1297 extern long hammer2_check_icrc32;
1299 extern struct objcache *cache_buffer_read;
1300 extern struct objcache *cache_buffer_write;
1301 extern struct objcache *cache_xops;
1304 * hammer2_subr.c
1306 #define hammer2_icrc32(buf, size) iscsi_crc32((buf), (size))
1307 #define hammer2_icrc32c(buf, size, crc) iscsi_crc32_ext((buf), (size), (crc))
1309 int hammer2_signal_check(time_t *timep);
1310 const char *hammer2_error_str(int error);
1312 void hammer2_inode_lock(hammer2_inode_t *ip, int how);
1313 void hammer2_inode_unlock(hammer2_inode_t *ip);
1314 hammer2_chain_t *hammer2_inode_chain(hammer2_inode_t *ip, int clindex, int how);
1315 hammer2_chain_t *hammer2_inode_chain_and_parent(hammer2_inode_t *ip,
1316 int clindex, hammer2_chain_t **parentp, int how);
1317 hammer2_mtx_state_t hammer2_inode_lock_temp_release(hammer2_inode_t *ip);
1318 void hammer2_inode_lock_temp_restore(hammer2_inode_t *ip,
1319 hammer2_mtx_state_t ostate);
1320 int hammer2_inode_lock_upgrade(hammer2_inode_t *ip);
1321 void hammer2_inode_lock_downgrade(hammer2_inode_t *ip, int);
1323 void hammer2_dev_exlock(hammer2_dev_t *hmp);
1324 void hammer2_dev_shlock(hammer2_dev_t *hmp);
1325 void hammer2_dev_unlock(hammer2_dev_t *hmp);
1327 int hammer2_get_dtype(const hammer2_inode_data_t *ipdata);
1328 int hammer2_get_vtype(uint8_t type);
1329 uint8_t hammer2_get_obj_type(enum vtype vtype);
1330 void hammer2_time_to_timespec(uint64_t xtime, struct timespec *ts);
1331 uint64_t hammer2_timespec_to_time(const struct timespec *ts);
1332 uint32_t hammer2_to_unix_xid(const uuid_t *uuid);
1333 void hammer2_guid_to_uuid(uuid_t *uuid, uint32_t guid);
1334 void hammer2_trans_manage_init(hammer2_pfs_t *pmp);
1336 hammer2_key_t hammer2_dirhash(const unsigned char *name, size_t len);
1337 int hammer2_getradix(size_t bytes);
1339 int hammer2_calc_logical(hammer2_inode_t *ip, hammer2_off_t uoff,
1340 hammer2_key_t *lbasep, hammer2_key_t *leofp);
1341 int hammer2_calc_physical(hammer2_inode_t *ip, hammer2_key_t lbase);
1342 void hammer2_update_time(uint64_t *timep);
1343 void hammer2_adjreadcounter(hammer2_blockref_t *bref, size_t bytes);
1346 * hammer2_inode.c
1348 struct vnode *hammer2_igetv(hammer2_inode_t *ip, int *errorp);
1349 hammer2_inode_t *hammer2_inode_lookup(hammer2_pfs_t *pmp,
1350 hammer2_tid_t inum);
1351 hammer2_inode_t *hammer2_inode_get(hammer2_pfs_t *pmp, hammer2_inode_t *dip,
1352 hammer2_cluster_t *cluster, int idx);
1353 void hammer2_inode_free(hammer2_inode_t *ip);
1354 void hammer2_inode_ref(hammer2_inode_t *ip);
1355 void hammer2_inode_drop(hammer2_inode_t *ip);
1356 void hammer2_inode_repoint(hammer2_inode_t *ip, hammer2_inode_t *pip,
1357 hammer2_cluster_t *cluster);
1358 void hammer2_inode_repoint_one(hammer2_inode_t *ip, hammer2_cluster_t *cluster,
1359 int idx);
1360 void hammer2_inode_modify(hammer2_inode_t *ip);
1361 void hammer2_inode_run_sideq(hammer2_pfs_t *pmp);
1363 hammer2_inode_t *hammer2_inode_create(hammer2_inode_t *dip,
1364 hammer2_inode_t *pip,
1365 struct vattr *vap, struct ucred *cred,
1366 const uint8_t *name, size_t name_len, hammer2_key_t lhc,
1367 hammer2_key_t inum, uint8_t type, uint8_t target_type,
1368 int flags, int *errorp);
1369 void hammer2_inode_chain_sync(hammer2_inode_t *ip);
1370 int hammer2_inode_unlink_finisher(hammer2_inode_t *ip, int isopen);
1373 * hammer2_chain.c
1375 void hammer2_voldata_lock(hammer2_dev_t *hmp);
1376 void hammer2_voldata_unlock(hammer2_dev_t *hmp);
1377 void hammer2_voldata_modify(hammer2_dev_t *hmp);
1378 hammer2_chain_t *hammer2_chain_alloc(hammer2_dev_t *hmp,
1379 hammer2_pfs_t *pmp,
1380 hammer2_blockref_t *bref);
1381 void hammer2_chain_core_init(hammer2_chain_t *chain);
1382 void hammer2_chain_ref(hammer2_chain_t *chain);
1383 void hammer2_chain_ref_hold(hammer2_chain_t *chain);
1384 void hammer2_chain_drop(hammer2_chain_t *chain);
1385 void hammer2_chain_drop_unhold(hammer2_chain_t *chain);
1386 void hammer2_chain_lock(hammer2_chain_t *chain, int how);
1387 void hammer2_chain_lock_unhold(hammer2_chain_t *chain, int how);
1388 #if 0
1389 void hammer2_chain_push_shared_lock(hammer2_chain_t *chain);
1390 void hammer2_chain_pull_shared_lock(hammer2_chain_t *chain);
1391 #endif
1392 void hammer2_chain_load_data(hammer2_chain_t *chain);
1393 const hammer2_media_data_t *hammer2_chain_rdata(hammer2_chain_t *chain);
1394 hammer2_media_data_t *hammer2_chain_wdata(hammer2_chain_t *chain);
1395 int hammer2_chain_snapshot(hammer2_chain_t *chain, hammer2_ioc_pfs_t *pmp,
1396 hammer2_tid_t mtid);
1398 int hammer2_chain_hardlink_find(hammer2_chain_t **parentp,
1399 hammer2_chain_t **chainp,
1400 int clindex, int flags);
1401 void hammer2_chain_modify(hammer2_chain_t *chain, hammer2_tid_t mtid,
1402 hammer2_off_t dedup_off, int flags);
1403 void hammer2_chain_modify_ip(hammer2_inode_t *ip, hammer2_chain_t *chain,
1404 hammer2_tid_t mtid, int flags);
1405 void hammer2_chain_resize(hammer2_inode_t *ip, hammer2_chain_t *parent,
1406 hammer2_chain_t *chain,
1407 hammer2_tid_t mtid, hammer2_off_t dedup_off,
1408 int nradix, int flags);
1409 void hammer2_chain_unlock(hammer2_chain_t *chain);
1410 void hammer2_chain_unlock_hold(hammer2_chain_t *chain);
1411 void hammer2_chain_wait(hammer2_chain_t *chain);
1412 hammer2_chain_t *hammer2_chain_get(hammer2_chain_t *parent, int generation,
1413 hammer2_blockref_t *bref);
1414 hammer2_chain_t *hammer2_chain_lookup_init(hammer2_chain_t *parent, int flags);
1415 void hammer2_chain_lookup_done(hammer2_chain_t *parent);
1416 hammer2_chain_t *hammer2_chain_getparent(hammer2_chain_t **parentp, int how);
1417 hammer2_chain_t *hammer2_chain_lookup(hammer2_chain_t **parentp,
1418 hammer2_key_t *key_nextp,
1419 hammer2_key_t key_beg, hammer2_key_t key_end,
1420 int *cache_indexp, int flags);
1421 hammer2_chain_t *hammer2_chain_next(hammer2_chain_t **parentp,
1422 hammer2_chain_t *chain,
1423 hammer2_key_t *key_nextp,
1424 hammer2_key_t key_beg, hammer2_key_t key_end,
1425 int *cache_indexp, int flags);
1426 hammer2_blockref_t *hammer2_chain_scan(hammer2_chain_t *parent,
1427 hammer2_chain_t **chainp,
1428 hammer2_blockref_t *bref,
1429 int *firstp, int *cache_indexp, int flags);
1431 int hammer2_chain_create(hammer2_chain_t **parentp, hammer2_chain_t **chainp,
1432 hammer2_pfs_t *pmp, int methods,
1433 hammer2_key_t key, int keybits,
1434 int type, size_t bytes, hammer2_tid_t mtid,
1435 hammer2_off_t dedup_off, int flags);
1436 void hammer2_chain_rename(hammer2_blockref_t *bref,
1437 hammer2_chain_t **parentp,
1438 hammer2_chain_t *chain,
1439 hammer2_tid_t mtid, int flags);
1440 void hammer2_chain_delete(hammer2_chain_t *parent, hammer2_chain_t *chain,
1441 hammer2_tid_t mtid, int flags);
1442 void hammer2_chain_setflush(hammer2_chain_t *chain);
1443 void hammer2_chain_countbrefs(hammer2_chain_t *chain,
1444 hammer2_blockref_t *base, int count);
1445 hammer2_chain_t *hammer2_chain_bulksnap(hammer2_chain_t *chain);
1446 void hammer2_chain_bulkdrop(hammer2_chain_t *copy);
1448 void hammer2_chain_setcheck(hammer2_chain_t *chain, void *bdata);
1449 int hammer2_chain_testcheck(hammer2_chain_t *chain, void *bdata);
1451 void hammer2_pfs_memory_wait(hammer2_pfs_t *pmp);
1452 void hammer2_pfs_memory_inc(hammer2_pfs_t *pmp);
1453 void hammer2_pfs_memory_wakeup(hammer2_pfs_t *pmp);
1455 void hammer2_base_delete(hammer2_chain_t *chain,
1456 hammer2_blockref_t *base, int count,
1457 int *cache_indexp, hammer2_chain_t *child);
1458 void hammer2_base_insert(hammer2_chain_t *chain,
1459 hammer2_blockref_t *base, int count,
1460 int *cache_indexp, hammer2_chain_t *child);
1463 * hammer2_flush.c
1465 void hammer2_flush(hammer2_chain_t *chain, int istop);
1466 void hammer2_flush_quick(hammer2_dev_t *hmp);
1467 void hammer2_delayed_flush(hammer2_chain_t *chain);
1470 * hammer2_trans.c
1472 void hammer2_trans_init(hammer2_pfs_t *pmp, uint32_t flags);
1473 hammer2_tid_t hammer2_trans_sub(hammer2_pfs_t *pmp);
1474 void hammer2_trans_done(hammer2_pfs_t *pmp);
1475 hammer2_tid_t hammer2_trans_newinum(hammer2_pfs_t *pmp);
1476 void hammer2_trans_assert_strategy(hammer2_pfs_t *pmp);
1477 void hammer2_dedup_record(hammer2_chain_t *chain, char *data);
1480 * hammer2_ioctl.c
1482 int hammer2_ioctl(hammer2_inode_t *ip, u_long com, void *data,
1483 int fflag, struct ucred *cred);
1486 * hammer2_io.c
1488 void hammer2_io_putblk(hammer2_io_t **diop);
1489 void hammer2_io_cleanup(hammer2_dev_t *hmp, struct hammer2_io_tree *tree);
1490 char *hammer2_io_data(hammer2_io_t *dio, off_t lbase);
1491 hammer2_io_t *hammer2_io_getquick(hammer2_dev_t *hmp, off_t lbase, int lsize);
1492 void hammer2_io_resetinval(hammer2_dev_t *hmp, off_t lbase);
1493 void hammer2_io_getblk(hammer2_dev_t *hmp, off_t lbase, int lsize,
1494 hammer2_iocb_t *iocb);
1495 void hammer2_io_complete(hammer2_iocb_t *iocb);
1496 void hammer2_io_callback(struct bio *bio);
1497 void hammer2_iocb_wait(hammer2_iocb_t *iocb);
1498 int hammer2_io_new(hammer2_dev_t *hmp, int btype, off_t lbase, int lsize,
1499 hammer2_io_t **diop);
1500 int hammer2_io_newnz(hammer2_dev_t *hmp, int btype, off_t lbase, int lsize,
1501 hammer2_io_t **diop);
1502 void hammer2_io_newq(hammer2_dev_t *hmp, int btype, off_t lbase, int lsize);
1503 int hammer2_io_bread(hammer2_dev_t *hmp, int btype, off_t lbase, int lsize,
1504 hammer2_io_t **diop);
1505 void hammer2_io_bawrite(hammer2_io_t **diop);
1506 void hammer2_io_bdwrite(hammer2_io_t **diop);
1507 int hammer2_io_bwrite(hammer2_io_t **diop);
1508 int hammer2_io_isdirty(hammer2_io_t *dio);
1509 void hammer2_io_setdirty(hammer2_io_t *dio);
1510 void hammer2_io_setinval(hammer2_io_t *dio, hammer2_off_t off, u_int bytes);
1511 void hammer2_io_brelse(hammer2_io_t **diop);
1512 void hammer2_io_bqrelse(hammer2_io_t **diop);
1513 int hammer2_io_crc_good(hammer2_chain_t *chain, uint64_t *maskp);
1514 void hammer2_io_crc_setmask(hammer2_io_t *dio, uint64_t mask);
1515 void hammer2_io_crc_clrmask(hammer2_io_t *dio, uint64_t mask);
1518 * hammer2_thread.c
1520 void hammer2_thr_signal(hammer2_thread_t *thr, uint32_t flags);
1521 void hammer2_thr_return(hammer2_thread_t *thr, uint32_t flags);
1522 void hammer2_thr_wait(hammer2_thread_t *thr, uint32_t flags);
1523 void hammer2_thr_wait_neg(hammer2_thread_t *thr, uint32_t flags);
1524 void hammer2_thr_create(hammer2_thread_t *thr, hammer2_pfs_t *pmp,
1525 const char *id, int clindex, int repidx,
1526 void (*func)(void *arg));
1527 void hammer2_thr_delete(hammer2_thread_t *thr);
1528 void hammer2_thr_remaster(hammer2_thread_t *thr);
1529 void hammer2_thr_freeze_async(hammer2_thread_t *thr);
1530 void hammer2_thr_freeze(hammer2_thread_t *thr);
1531 void hammer2_thr_unfreeze(hammer2_thread_t *thr);
1532 int hammer2_thr_break(hammer2_thread_t *thr);
1533 void hammer2_primary_xops_thread(void *arg);
1536 * hammer2_thread.c (XOP API)
1538 void hammer2_xop_group_init(hammer2_pfs_t *pmp, hammer2_xop_group_t *xgrp);
1539 void *hammer2_xop_alloc(hammer2_inode_t *ip, int flags);
1540 void hammer2_xop_setname(hammer2_xop_head_t *xop,
1541 const char *name, size_t name_len);
1542 void hammer2_xop_setname2(hammer2_xop_head_t *xop,
1543 const char *name, size_t name_len);
1544 size_t hammer2_xop_setname_inum(hammer2_xop_head_t *xop, hammer2_key_t inum);
1545 void hammer2_xop_setip2(hammer2_xop_head_t *xop, hammer2_inode_t *ip2);
1546 void hammer2_xop_setip3(hammer2_xop_head_t *xop, hammer2_inode_t *ip3);
1547 void hammer2_xop_reinit(hammer2_xop_head_t *xop);
1548 void hammer2_xop_helper_create(hammer2_pfs_t *pmp);
1549 void hammer2_xop_helper_cleanup(hammer2_pfs_t *pmp);
1550 void hammer2_xop_start(hammer2_xop_head_t *xop, hammer2_xop_func_t func);
1551 void hammer2_xop_start_except(hammer2_xop_head_t *xop, hammer2_xop_func_t func,
1552 int notidx);
1553 int hammer2_xop_collect(hammer2_xop_head_t *xop, int flags);
1554 void hammer2_xop_retire(hammer2_xop_head_t *xop, uint32_t mask);
1555 int hammer2_xop_active(hammer2_xop_head_t *xop);
1556 int hammer2_xop_feed(hammer2_xop_head_t *xop, hammer2_chain_t *chain,
1557 int clindex, int error);
1560 * hammer2_synchro.c
1562 void hammer2_primary_sync_thread(void *arg);
1565 * XOP backends in hammer2_xops.c, primarily for VNOPS. Other XOP backends
1566 * may be integrated into other source files.
1568 void hammer2_xop_ipcluster(hammer2_xop_t *xop, int clidx);
1569 void hammer2_xop_readdir(hammer2_xop_t *xop, int clidx);
1570 void hammer2_xop_nresolve(hammer2_xop_t *xop, int clidx);
1571 void hammer2_xop_unlink(hammer2_xop_t *xop, int clidx);
1572 void hammer2_xop_nrename(hammer2_xop_t *xop, int clidx);
1573 void hammer2_xop_nlink(hammer2_xop_t *xop, int clidx);
1574 void hammer2_xop_scanlhc(hammer2_xop_t *xop, int clidx);
1575 void hammer2_xop_scanall(hammer2_xop_t *xop, int clidx);
1576 void hammer2_xop_lookup(hammer2_xop_t *xop, int clidx);
1577 void hammer2_inode_xop_create(hammer2_xop_t *xop, int clidx);
1578 void hammer2_inode_xop_destroy(hammer2_xop_t *xop, int clidx);
1579 void hammer2_inode_xop_chain_sync(hammer2_xop_t *xop, int clidx);
1580 void hammer2_inode_xop_unlinkall(hammer2_xop_t *xop, int clidx);
1581 void hammer2_inode_xop_connect(hammer2_xop_t *xop, int clidx);
1582 void hammer2_inode_xop_flush(hammer2_xop_t *xop, int clidx);
1585 * hammer2_msgops.c
1587 int hammer2_msg_dbg_rcvmsg(kdmsg_msg_t *msg);
1588 int hammer2_msg_adhoc_input(kdmsg_msg_t *msg);
1591 * hammer2_vfsops.c
1593 void hammer2_volconf_update(hammer2_dev_t *hmp, int index);
1594 void hammer2_dump_chain(hammer2_chain_t *chain, int tab, int *countp, char pfx);
1595 int hammer2_vfs_sync(struct mount *mp, int waitflags);
1596 hammer2_pfs_t *hammer2_pfsalloc(hammer2_chain_t *chain,
1597 const hammer2_inode_data_t *ripdata,
1598 hammer2_tid_t modify_tid,
1599 hammer2_dev_t *force_local);
1600 int hammer2_vfs_vget(struct mount *mp, struct vnode *dvp,
1601 ino_t ino, struct vnode **vpp);
1603 void hammer2_lwinprog_ref(hammer2_pfs_t *pmp);
1604 void hammer2_lwinprog_drop(hammer2_pfs_t *pmp);
1605 void hammer2_lwinprog_wait(hammer2_pfs_t *pmp, int pipe);
1608 * hammer2_freemap.c
1610 int hammer2_freemap_alloc(hammer2_chain_t *chain, size_t bytes);
1611 void hammer2_freemap_adjust(hammer2_dev_t *hmp,
1612 hammer2_blockref_t *bref, int how);
1615 * hammer2_cluster.c
1617 uint8_t hammer2_cluster_type(hammer2_cluster_t *cluster);
1618 const hammer2_media_data_t *hammer2_cluster_rdata(hammer2_cluster_t *cluster);
1619 hammer2_media_data_t *hammer2_cluster_wdata(hammer2_cluster_t *cluster);
1620 hammer2_cluster_t *hammer2_cluster_from_chain(hammer2_chain_t *chain);
1621 void hammer2_cluster_bref(hammer2_cluster_t *cluster, hammer2_blockref_t *bref);
1622 hammer2_cluster_t *hammer2_cluster_alloc(hammer2_pfs_t *pmp,
1623 hammer2_blockref_t *bref);
1624 void hammer2_cluster_ref(hammer2_cluster_t *cluster);
1625 void hammer2_cluster_drop(hammer2_cluster_t *cluster);
1626 void hammer2_cluster_lock(hammer2_cluster_t *cluster, int how);
1627 int hammer2_cluster_check(hammer2_cluster_t *cluster, hammer2_key_t lokey,
1628 int flags);
1629 void hammer2_cluster_resolve(hammer2_cluster_t *cluster);
1630 void hammer2_cluster_forcegood(hammer2_cluster_t *cluster);
1631 hammer2_cluster_t *hammer2_cluster_copy(hammer2_cluster_t *ocluster);
1632 void hammer2_cluster_unlock(hammer2_cluster_t *cluster);
1634 int hammer2_bulkfree_pass(hammer2_dev_t *hmp,
1635 struct hammer2_ioc_bulkfree *bfi);
1638 * hammer2_iocom.c
1640 void hammer2_iocom_init(hammer2_dev_t *hmp);
1641 void hammer2_iocom_uninit(hammer2_dev_t *hmp);
1642 void hammer2_cluster_reconnect(hammer2_dev_t *hmp, struct file *fp);
1645 * hammer2_strategy.c
1647 int hammer2_vop_strategy(struct vop_strategy_args *ap);
1648 int hammer2_vop_bmap(struct vop_bmap_args *ap);
1649 void hammer2_write_thread(void *arg);
1650 void hammer2_bioq_sync(hammer2_pfs_t *pmp);
1651 void hammer2_dedup_clear(hammer2_dev_t *hmp);
1653 #endif /* !_KERNEL */
1654 #endif /* !_VFS_HAMMER2_HAMMER2_H_ */