| Commit | Line | Data |
|---|---|---|
| 703720e4 MD |
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> | |
| 46558838 | 57 | #include <sys/thread.h> |
| 703720e4 MD |
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" | |
| 2910a90c | 69 | #include "hammer2_ioctl.h" |
| 1ad77ed9 | 70 | #include "hammer2_ccms.h" |
| 26bf1a36 | 71 | #include "hammer2_network.h" |
| 703720e4 | 72 | |
| 5c23d7f1 | 73 | struct hammer2_chain; |
| 703720e4 MD |
74 | struct hammer2_inode; |
| 75 | struct hammer2_mount; | |
| e4e20f48 | 76 | struct hammer2_pfsmount; |
| 26bf1a36 MD |
77 | struct hammer2_state; |
| 78 | struct hammer2_msg; | |
| 703720e4 | 79 | |
| 703720e4 | 80 | /* |
| 50e4f8f4 MD |
81 | * The chain structure tracks blockref recursions all the way to |
| 82 | * the root volume. These consist of indirect blocks, inodes, | |
| 83 | * and eventually the volume header. | |
| 84 | * | |
| 7cfa8da5 MD |
85 | * The chain structure is embedded in the hammer2_mount, hammer2_inode, |
| 86 | * and other system memory structures. The chain structure typically | |
| 87 | * implements the reference count and busy flag for the larger structure. | |
| 88 | * | |
| 89 | * It is always possible to track a chain element all the way back to the | |
| 90 | * root by following the (parent) links. (index) is a type-dependent index | |
| 91 | * in the parent indicating where in the parent the chain element resides. | |
| 5c23d7f1 MD |
92 | * |
| 93 | * When a blockref is added or deleted the related chain element is marked | |
| 94 | * modified and all of its parents are marked SUBMODIFIED (the parent | |
| 95 | * recursion can stop once we hit a node that is already marked SUBMODIFIED). | |
| 96 | * A deleted chain element must remain intact until synchronized against | |
| 97 | * its parent. | |
| 98 | * | |
| 99 | * The blockref at (parent, index) is not adjusted until the modified chain | |
| 100 | * element is flushed and unmarked. Until then the child's blockref may | |
| 101 | * not match the blockref at (parent, index). | |
| 50e4f8f4 | 102 | */ |
| ecc33e71 | 103 | RB_HEAD(hammer2_chain_tree, hammer2_chain); |
| 26bf1a36 | 104 | RB_HEAD(hammer2_state_tree, hammer2_state); |
| a0ed3c24 | 105 | TAILQ_HEAD(flush_deferral_list, hammer2_chain); |
| 5c23d7f1 | 106 | |
| 50e4f8f4 | 107 | struct hammer2_chain { |
| 46558838 | 108 | ccms_cst_t cst; /* attr or data cst */ |
| 50e4f8f4 | 109 | struct hammer2_blockref bref; |
| 004f88b4 | 110 | struct hammer2_blockref bref_flush; /* synchronized w/MOVED bit */ |
| 26bf1a36 | 111 | struct hammer2_chain *parent; /* return chain to root */ |
| ecc33e71 | 112 | struct hammer2_chain_tree rbhead; |
| 26bf1a36 | 113 | struct hammer2_state *state; /* if active cache msg */ |
| ecc33e71 | 114 | RB_ENTRY(hammer2_chain) rbnode; |
| 1c9f601e | 115 | TAILQ_ENTRY(hammer2_chain) flush_node; /* flush deferral list */ |
| 7cfa8da5 MD |
116 | union { |
| 117 | struct hammer2_inode *ip; | |
| 5c23d7f1 MD |
118 | struct hammer2_indblock *np; |
| 119 | struct hammer2_data *dp; | |
| 120 | void *mem; | |
| 7cfa8da5 | 121 | } u; |
| 5c23d7f1 MD |
122 | |
| 123 | struct buf *bp; /* buffer cache (ro) */ | |
| 124 | hammer2_media_data_t *data; /* modified copy of data (rw) */ | |
| 866d5273 | 125 | u_int bytes; /* physical size of data */ |
| 5c23d7f1 MD |
126 | int index; /* index in parent */ |
| 127 | u_int refs; | |
| 5c23d7f1 | 128 | u_int flags; |
| 50e4f8f4 MD |
129 | }; |
| 130 | ||
| 131 | typedef struct hammer2_chain hammer2_chain_t; | |
| 132 | ||
| 5c23d7f1 | 133 | int hammer2_chain_cmp(hammer2_chain_t *chain1, hammer2_chain_t *chain2); |
| ecc33e71 | 134 | RB_PROTOTYPE(hammer2_chain_tree, hammer2_chain, rbnode, hammer2_chain_cmp); |
| 5c23d7f1 | 135 | |
| 28ee5f14 MD |
136 | /* |
| 137 | * MOVED - This bit is set during the flush when the MODIFIED bit is cleared, | |
| 138 | * indicating that the parent's blocktable must inherit a change to | |
| 139 | * the bref (typically a block reallocation) | |
| 140 | * | |
| 141 | * It must also be set in situations where a chain is not MODIFIED | |
| 142 | * but whos bref has changed (typically due to fields other than | |
| 143 | * a block reallocation). | |
| 144 | */ | |
| 2910a90c | 145 | #define HAMMER2_CHAIN_MODIFIED 0x00000001 /* active mods */ |
| 214f4a77 | 146 | #define HAMMER2_CHAIN_DIRTYEMBED 0x00000002 /* inode embedded */ |
| a92f82c4 | 147 | #define HAMMER2_CHAIN_DIRTYBP 0x00000004 /* dirty on unlock */ |
| 73e441b9 | 148 | #define HAMMER2_CHAIN_SUBMODIFIED 0x00000008 /* 1+ subs modified */ |
| b7926f31 | 149 | #define HAMMER2_CHAIN_DELETED 0x00000010 |
| 01eabad4 | 150 | #define HAMMER2_CHAIN_INITIAL 0x00000020 /* initial create */ |
| c667909f | 151 | #define HAMMER2_CHAIN_FLUSHED 0x00000040 /* flush on unlock */ |
| 28ee5f14 | 152 | #define HAMMER2_CHAIN_MOVED 0x00000080 /* bref changed */ |
| 37aa19df | 153 | #define HAMMER2_CHAIN_IOFLUSH 0x00000100 /* bawrite on put */ |
| 1c9f601e | 154 | #define HAMMER2_CHAIN_DEFERRED 0x00000200 /* on a deferral list*/ |
| 222d9e22 | 155 | #define HAMMER2_CHAIN_DESTROYED 0x00000400 /* destroying */ |
| 2910a90c | 156 | #define HAMMER2_CHAIN_MODIFIED_AUX 0x00000800 /* hmp->vchain only */ |
| 4d5318eb MD |
157 | #define HAMMER2_CHAIN_MODIFY_TID 0x00001000 /* mod updates field */ |
| 158 | #define HAMMER2_CHAIN_MOUNTED 0x00002000 /* PFS is mounted */ | |
| c667909f MD |
159 | |
| 160 | /* | |
| 161 | * Flags passed to hammer2_chain_lookup() and hammer2_chain_next() | |
| 162 | */ | |
| 163 | #define HAMMER2_LOOKUP_NOLOCK 0x00000001 /* ref only */ | |
| 8cce658d | 164 | #define HAMMER2_LOOKUP_NODATA 0x00000002 /* data left NULL */ |
| a0ed3c24 | 165 | #define HAMMER2_LOOKUP_SHARED 0x00000100 |
| 5c23d7f1 | 166 | |
| 50e4f8f4 | 167 | /* |
| 01eabad4 MD |
168 | * Flags passed to hammer2_chain_modify() and hammer2_chain_resize() |
| 169 | * | |
| 170 | * NOTE: OPTDATA allows us to avoid instantiating buffers for INDIRECT | |
| 171 | * blocks in the INITIAL-create state. | |
| 4d5318eb MD |
172 | * |
| 173 | * NOTE: NO_MODIFY_TID tells the function to not set HAMMER2_CHAIN_MODIFY_TID | |
| 174 | * when marking the chain modified (used when a sub-chain modification | |
| 175 | * propagates upward). | |
| 01eabad4 MD |
176 | */ |
| 177 | #define HAMMER2_MODIFY_NOSUB 0x00000001 /* do not set SUBMOD */ | |
| 178 | #define HAMMER2_MODIFY_OPTDATA 0x00000002 /* data can be NULL */ | |
| 4d5318eb | 179 | #define HAMMER2_MODIFY_NO_MODIFY_TID 0x00000004 |
| 01eabad4 MD |
180 | |
| 181 | /* | |
| 182 | * Flags passed to hammer2_chain_lock() | |
| 183 | */ | |
| 184 | #define HAMMER2_RESOLVE_NEVER 1 | |
| 185 | #define HAMMER2_RESOLVE_MAYBE 2 | |
| 186 | #define HAMMER2_RESOLVE_ALWAYS 3 | |
| a0ed3c24 MD |
187 | #define HAMMER2_RESOLVE_MASK 0x0F |
| 188 | ||
| 189 | #define HAMMER2_RESOLVE_SHARED 0x10 | |
| 01eabad4 MD |
190 | |
| 191 | /* | |
| 6ba3b984 MD |
192 | * Cluster different types of storage together for allocations |
| 193 | */ | |
| 194 | #define HAMMER2_FREECACHE_INODE 0 | |
| 195 | #define HAMMER2_FREECACHE_INDIR 1 | |
| 196 | #define HAMMER2_FREECACHE_DATA 2 | |
| 197 | #define HAMMER2_FREECACHE_UNUSED3 3 | |
| 198 | #define HAMMER2_FREECACHE_TYPES 4 | |
| 199 | ||
| 200 | /* | |
| 201 | * BMAP read-ahead maximum parameters | |
| 202 | */ | |
| 203 | #define HAMMER2_BMAP_COUNT 16 /* max bmap read-ahead */ | |
| 204 | #define HAMMER2_BMAP_BYTES (HAMMER2_PBUFSIZE * HAMMER2_BMAP_COUNT) | |
| 205 | ||
| 206 | /* | |
| 1c9f601e MD |
207 | * Misc |
| 208 | */ | |
| 209 | #define HAMMER2_FLUSH_DEPTH_LIMIT 40 /* stack recursion limit */ | |
| 210 | ||
| 211 | /* | |
| 5c23d7f1 | 212 | * HAMMER2 IN-MEMORY CACHE OF MEDIA STRUCTURES |
| 7cfa8da5 | 213 | * |
| 5c23d7f1 MD |
214 | * There is an in-memory representation of all on-media data structure. |
| 215 | * | |
| 216 | * When accessed read-only the data will be mapped to the related buffer | |
| 217 | * cache buffer. | |
| 218 | * | |
| 219 | * When accessed read-write (marked modified) a kmalloc()'d copy of the | |
| 220 | * is created which can then be modified. The copy is destroyed when a | |
| 221 | * filesystem block is allocated to replace it. | |
| 222 | * | |
| 223 | * Active inodes (those with vnodes attached) will maintain the kmalloc()'d | |
| 224 | * copy for both the read-only and the read-write case. The combination of | |
| 225 | * (bp) and (data) determines whether (data) was allocated or not. | |
| 226 | * | |
| 227 | * The in-memory representation may remain cached (for example in order to | |
| 228 | * placemark clustering locks) even after the related data has been | |
| 229 | * detached. | |
| 230 | */ | |
| 231 | ||
| 232 | /* | |
| 233 | * A hammer2 inode. | |
| 46558838 MD |
234 | * |
| 235 | * NOTE: The inode's attribute CST which is also used to lock the inode | |
| 236 | * is embedded in the chain (chain.cst) and aliased w/ attr_cst. | |
| 703720e4 MD |
237 | */ |
| 238 | struct hammer2_inode { | |
| e4e20f48 MD |
239 | struct hammer2_mount *hmp; /* Global mount */ |
| 240 | struct hammer2_pfsmount *pmp; /* PFS mount */ | |
| e028fa74 | 241 | struct hammer2_inode *pip; /* parent inode */ |
| 703720e4 | 242 | struct vnode *vp; |
| 46558838 | 243 | ccms_cst_t topo_cst; /* directory topology cst */ |
| 50e4f8f4 | 244 | hammer2_chain_t chain; |
| 5c23d7f1 | 245 | struct hammer2_inode_data ip_data; |
| 37aa19df | 246 | struct lockf advlock; |
| 99535653 | 247 | u_int depth; /* directory depth */ |
| 28ee5f14 MD |
248 | hammer2_off_t delta_dcount; /* adjust data_count */ |
| 249 | hammer2_off_t delta_icount; /* adjust inode_count */ | |
| 703720e4 MD |
250 | }; |
| 251 | ||
| 54eb943b MD |
252 | typedef struct hammer2_inode hammer2_inode_t; |
| 253 | ||
| 703720e4 | 254 | /* |
| 7cfa8da5 MD |
255 | * A hammer2 indirect block |
| 256 | */ | |
| 257 | struct hammer2_indblock { | |
| 258 | hammer2_chain_t chain; | |
| 7cfa8da5 MD |
259 | }; |
| 260 | ||
| 261 | typedef struct hammer2_indblock hammer2_indblock_t; | |
| 262 | ||
| 5c23d7f1 MD |
263 | /* |
| 264 | * A hammer2 data block | |
| 265 | */ | |
| 266 | struct hammer2_data { | |
| 267 | hammer2_chain_t chain; | |
| 268 | }; | |
| 269 | ||
| 5c23d7f1 MD |
270 | typedef struct hammer2_data hammer2_data_t; |
| 271 | ||
| 004f88b4 MD |
272 | struct hammer2_freecache { |
| 273 | hammer2_off_t bulk; | |
| 274 | hammer2_off_t single; | |
| 275 | }; | |
| 276 | ||
| 277 | typedef struct hammer2_freecache hammer2_freecache_t; | |
| 278 | ||
| 7cfa8da5 | 279 | /* |
| e4e20f48 | 280 | * Global (per device) mount structure for device (aka vp->v_mount->hmp) |
| 703720e4 MD |
281 | */ |
| 282 | struct hammer2_mount { | |
| 50e4f8f4 | 283 | struct vnode *devvp; /* device vnode */ |
| 50e4f8f4 | 284 | int ronly; /* read-only mount */ |
| e4e20f48 MD |
285 | int pmp_count; /* PFS mounts backed by us */ |
| 286 | TAILQ_ENTRY(hammer2_mount) mntentry; /* hammer2_mntlist */ | |
| 703720e4 | 287 | |
| 5c23d7f1 | 288 | struct malloc_type *minode; |
| 54eb943b MD |
289 | int ninodes; |
| 290 | int maxinodes; | |
| 703720e4 | 291 | |
| 5c23d7f1 | 292 | struct malloc_type *mchain; |
| 54eb943b MD |
293 | int nipstacks; |
| 294 | int maxipstacks; | |
| 7cfa8da5 MD |
295 | hammer2_chain_t vchain; /* anchor chain */ |
| 296 | hammer2_chain_t *schain; /* super-root */ | |
| 01eabad4 | 297 | struct lock alloclk; /* lockmgr lock */ |
| 2910a90c | 298 | struct lock voldatalk; /* lockmgr lock */ |
| 703720e4 | 299 | |
| 54eb943b | 300 | hammer2_volume_data_t voldata; |
| bfc3a7b1 MD |
301 | hammer2_freecache_t freecache[HAMMER2_FREECACHE_TYPES] |
| 302 | [HAMMER2_MAX_RADIX+1]; | |
| 703720e4 MD |
303 | }; |
| 304 | ||
| 54eb943b MD |
305 | typedef struct hammer2_mount hammer2_mount_t; |
| 306 | ||
| e4e20f48 MD |
307 | /* |
| 308 | * Per-PFS mount structure for device (aka vp->v_mount) | |
| 309 | */ | |
| 310 | struct hammer2_pfsmount { | |
| 311 | struct mount *mp; /* kernel mount */ | |
| 312 | struct hammer2_mount *hmp; /* device global mount */ | |
| 313 | hammer2_chain_t *rchain; /* PFS root chain */ | |
| 314 | hammer2_inode_t *iroot; /* PFS root inode */ | |
| 26bf1a36 | 315 | struct malloc_type *mmsg; |
| 609a8021 | 316 | ccms_domain_t ccms_dom; |
| e4e20f48 MD |
317 | struct netexport export; /* nfs export */ |
| 318 | int ronly; /* read-only mount */ | |
| bfc3a7b1 MD |
319 | struct file *msg_fp; /* cluster pipe->userland */ |
| 320 | thread_t msgrd_td; /* cluster thread */ | |
| 321 | thread_t msgwr_td; /* cluster thread */ | |
| 322 | int msg_ctl; /* wakeup flags */ | |
| 8c280d5d | 323 | int msg_seq; /* cluster msg sequence id */ |
| 9b8b748f | 324 | uint32_t msgid_iterator; |
| 26bf1a36 MD |
325 | struct lock msglk; /* lockmgr lock */ |
| 326 | TAILQ_HEAD(, hammer2_msg) msgq; /* transmit queue */ | |
| 327 | struct hammer2_state *freerd_state; /* allocation cache */ | |
| 328 | struct hammer2_state *freewr_state; /* allocation cache */ | |
| 329 | struct hammer2_state_tree staterd_tree; /* active messages */ | |
| 330 | struct hammer2_state_tree statewr_tree; /* active messages */ | |
| e4e20f48 MD |
331 | }; |
| 332 | ||
| 333 | typedef struct hammer2_pfsmount hammer2_pfsmount_t; | |
| 334 | ||
| bfc3a7b1 MD |
335 | #define HAMMER2_CLUSTERCTL_KILL 0x0001 |
| 336 | ||
| 26bf1a36 MD |
337 | /* |
| 338 | * In-memory message structure for hammer2. | |
| 339 | * | |
| 340 | * Persistent cache state messages will be associated with a hammer2_chain. | |
| 9b8b748f MD |
341 | * |
| 342 | * NOTE! If REPLY is set then the source and target fields in the message | |
| 343 | * are swapped. That is, source and target remain unchanged whether | |
| 344 | * the message is a command from side A or a reply from side B. | |
| 345 | * The message is routed based on target if REPLY is not set, and on | |
| 346 | * source if REPLY is set. | |
| 26bf1a36 MD |
347 | */ |
| 348 | struct hammer2_state { | |
| 349 | RB_ENTRY(hammer2_state) rbnode; /* indexed by msgid */ | |
| 350 | struct hammer2_pfsmount *pmp; | |
| 351 | uint32_t txcmd; /* mostly for CMDF flags */ | |
| 352 | uint32_t rxcmd; /* mostly for CMDF flags */ | |
| 8c280d5d MD |
353 | uint64_t spanid; /* spanning tree routing */ |
| 354 | uint64_t msgid; /* {spanid,msgid} uniq */ | |
| 26bf1a36 MD |
355 | int flags; |
| 356 | int error; | |
| 357 | struct hammer2_chain *chain; /* msg associated w/chain */ | |
| 358 | struct hammer2_msg *msg; | |
| 8c280d5d MD |
359 | int (*func)(struct hammer2_state *, struct hammer2_msg *); |
| 360 | union { | |
| 361 | void *any; | |
| 362 | hammer2_pfsmount_t *pmp; | |
| 363 | } any; | |
| 26bf1a36 MD |
364 | }; |
| 365 | ||
| 366 | #define HAMMER2_STATE_INSERTED 0x0001 | |
| 367 | #define HAMMER2_STATE_DYNAMIC 0x0002 | |
| 368 | ||
| 369 | struct hammer2_msg { | |
| 370 | TAILQ_ENTRY(hammer2_msg) qentry; /* serialized queue */ | |
| 371 | struct hammer2_state *state; | |
| 372 | size_t hdr_size; | |
| 373 | size_t aux_size; | |
| 374 | char *aux_data; | |
| 42e2a62e | 375 | hammer2_msg_any_t any; |
| 26bf1a36 MD |
376 | }; |
| 377 | ||
| 378 | typedef struct hammer2_state hammer2_state_t; | |
| 379 | typedef struct hammer2_msg hammer2_msg_t; | |
| 380 | ||
| 381 | int hammer2_state_cmp(hammer2_state_t *state1, hammer2_state_t *state2); | |
| 382 | RB_PROTOTYPE(hammer2_state_tree, hammer2_state, rbnode, hammer2_state_cmp); | |
| 383 | ||
| 384 | ||
| 703720e4 MD |
385 | #if defined(_KERNEL) |
| 386 | ||
| 387 | MALLOC_DECLARE(M_HAMMER2); | |
| 388 | ||
| e4e20f48 MD |
389 | #define VTOI(vp) ((hammer2_inode_t *)(vp)->v_data) |
| 390 | #define ITOV(ip) ((ip)->vp) | |
| 391 | ||
| e118c14f | 392 | static __inline |
| e4e20f48 MD |
393 | hammer2_pfsmount_t * |
| 394 | MPTOPMP(struct mount *mp) | |
| 703720e4 | 395 | { |
| e4e20f48 | 396 | return ((hammer2_pfsmount_t *)mp->mnt_data); |
| 703720e4 MD |
397 | } |
| 398 | ||
| e118c14f | 399 | static __inline |
| e4e20f48 MD |
400 | hammer2_mount_t * |
| 401 | MPTOHMP(struct mount *mp) | |
| 47902fef | 402 | { |
| e4e20f48 | 403 | return (((hammer2_pfsmount_t *)mp->mnt_data)->hmp); |
| 47902fef VS |
404 | } |
| 405 | ||
| 703720e4 MD |
406 | extern struct vop_ops hammer2_vnode_vops; |
| 407 | extern struct vop_ops hammer2_spec_vops; | |
| 408 | extern struct vop_ops hammer2_fifo_vops; | |
| 409 | ||
| 37aa19df | 410 | extern int hammer2_debug; |
| 01eabad4 | 411 | extern int hammer2_cluster_enable; |
| e708f8b9 | 412 | extern int hammer2_hardlink_enable; |
| 01eabad4 MD |
413 | extern long hammer2_iod_file_read; |
| 414 | extern long hammer2_iod_meta_read; | |
| 415 | extern long hammer2_iod_indr_read; | |
| 416 | extern long hammer2_iod_file_write; | |
| 417 | extern long hammer2_iod_meta_write; | |
| 418 | extern long hammer2_iod_indr_write; | |
| 419 | extern long hammer2_iod_volu_write; | |
| 420 | extern long hammer2_ioa_file_read; | |
| 421 | extern long hammer2_ioa_meta_read; | |
| 422 | extern long hammer2_ioa_indr_read; | |
| 423 | extern long hammer2_ioa_file_write; | |
| 424 | extern long hammer2_ioa_meta_write; | |
| 425 | extern long hammer2_ioa_indr_write; | |
| 426 | extern long hammer2_ioa_volu_write; | |
| 37aa19df | 427 | |
| 7cfa8da5 MD |
428 | /* |
| 429 | * hammer2_subr.c | |
| 430 | */ | |
| 54eb943b MD |
431 | void hammer2_inode_lock_ex(hammer2_inode_t *ip); |
| 432 | void hammer2_inode_unlock_ex(hammer2_inode_t *ip); | |
| 9c2e0de0 | 433 | void hammer2_inode_lock_sh(hammer2_inode_t *ip); |
| 54eb943b | 434 | void hammer2_inode_unlock_sh(hammer2_inode_t *ip); |
| 9c2e0de0 MD |
435 | void hammer2_inode_busy(hammer2_inode_t *ip); |
| 436 | void hammer2_inode_unbusy(hammer2_inode_t *ip); | |
| 2910a90c MD |
437 | void hammer2_voldata_lock(hammer2_mount_t *hmp); |
| 438 | void hammer2_voldata_unlock(hammer2_mount_t *hmp); | |
| e118c14f | 439 | |
| 54eb943b MD |
440 | void hammer2_mount_exlock(hammer2_mount_t *hmp); |
| 441 | void hammer2_mount_shlock(hammer2_mount_t *hmp); | |
| 442 | void hammer2_mount_unlock(hammer2_mount_t *hmp); | |
| 703720e4 | 443 | |
| e028fa74 | 444 | int hammer2_get_dtype(hammer2_inode_t *ip); |
| cd4b3d92 | 445 | int hammer2_get_vtype(hammer2_inode_t *ip); |
| 37494cab | 446 | u_int8_t hammer2_get_obj_type(enum vtype vtype); |
| cd4b3d92 | 447 | void hammer2_time_to_timespec(u_int64_t xtime, struct timespec *ts); |
| b2b78aaa | 448 | u_int64_t hammer2_timespec_to_time(struct timespec *ts); |
| 37494cab | 449 | u_int32_t hammer2_to_unix_xid(uuid_t *uuid); |
| b2b78aaa | 450 | void hammer2_guid_to_uuid(uuid_t *uuid, u_int32_t guid); |
| e028fa74 | 451 | |
| 7cfa8da5 | 452 | hammer2_key_t hammer2_dirhash(const unsigned char *name, size_t len); |
| 6ba3b984 | 453 | int hammer2_bytes_to_radix(size_t bytes); |
| 7cfa8da5 | 454 | |
| 8cce658d MD |
455 | int hammer2_calc_logical(hammer2_inode_t *ip, hammer2_off_t uoff, |
| 456 | hammer2_key_t *lbasep, hammer2_key_t *leofp); | |
| b2b78aaa | 457 | void hammer2_update_time(uint64_t *timep); |
| 8cce658d | 458 | |
| 7cfa8da5 MD |
459 | /* |
| 460 | * hammer2_inode.c | |
| 461 | */ | |
| 54eb943b | 462 | struct vnode *hammer2_igetv(hammer2_inode_t *ip, int *errorp); |
| ae183399 | 463 | |
| e708f8b9 MD |
464 | void hammer2_inode_lock_nlinks(hammer2_inode_t *ip); |
| 465 | void hammer2_inode_unlock_nlinks(hammer2_inode_t *ip); | |
| e4e20f48 | 466 | hammer2_inode_t *hammer2_inode_alloc(hammer2_pfsmount_t *pmp, void *data); |
| 7cfa8da5 MD |
467 | void hammer2_inode_free(hammer2_inode_t *ip); |
| 468 | void hammer2_inode_ref(hammer2_inode_t *ip); | |
| 469 | void hammer2_inode_drop(hammer2_inode_t *ip); | |
| 866d5273 | 470 | int hammer2_inode_calc_alloc(hammer2_key_t filesize); |
| 6934ae32 | 471 | |
| e4e20f48 | 472 | int hammer2_inode_create(hammer2_inode_t *dip, |
| e708f8b9 MD |
473 | struct vattr *vap, struct ucred *cred, |
| 474 | const uint8_t *name, size_t name_len, | |
| 475 | hammer2_inode_t **nipp); | |
| 6934ae32 | 476 | |
| 99535653 MD |
477 | int hammer2_inode_duplicate(hammer2_inode_t *dip, |
| 478 | hammer2_inode_t *oip, hammer2_inode_t **nipp, | |
| 479 | const uint8_t *name, size_t name_len); | |
| 480 | int hammer2_inode_connect(hammer2_inode_t *dip, hammer2_inode_t *oip, | |
| db0c2eb3 MD |
481 | const uint8_t *name, size_t name_len); |
| 482 | ||
| ae183399 | 483 | int hammer2_unlink_file(hammer2_inode_t *dip, |
| 004f88b4 MD |
484 | const uint8_t *name, size_t name_len, |
| 485 | int isdir, hammer2_inode_t *retain_ip); | |
| 99535653 | 486 | int hammer2_hardlink_consolidate(hammer2_inode_t **ipp, hammer2_inode_t *tdip); |
| e708f8b9 MD |
487 | int hammer2_hardlink_deconsolidate(hammer2_inode_t *dip, |
| 488 | hammer2_chain_t **chainp, hammer2_inode_t **ipp); | |
| 489 | int hammer2_hardlink_find(hammer2_inode_t *dip, hammer2_chain_t **chainp, | |
| 490 | hammer2_inode_t **ipp); | |
| ae183399 | 491 | |
| 7cfa8da5 MD |
492 | /* |
| 493 | * hammer2_chain.c | |
| 494 | */ | |
| 2910a90c | 495 | void hammer2_modify_volume(hammer2_mount_t *hmp); |
| 5c23d7f1 MD |
496 | hammer2_chain_t *hammer2_chain_alloc(hammer2_mount_t *hmp, |
| 497 | hammer2_blockref_t *bref); | |
| 498 | void hammer2_chain_free(hammer2_mount_t *hmp, hammer2_chain_t *chain); | |
| 7cfa8da5 MD |
499 | void hammer2_chain_ref(hammer2_mount_t *hmp, hammer2_chain_t *chain); |
| 500 | void hammer2_chain_drop(hammer2_mount_t *hmp, hammer2_chain_t *chain); | |
| 01eabad4 MD |
501 | int hammer2_chain_lock(hammer2_mount_t *hmp, hammer2_chain_t *chain, int how); |
| 502 | void hammer2_chain_moved(hammer2_mount_t *hmp, hammer2_chain_t *chain); | |
| 214f4a77 | 503 | void hammer2_chain_modify(hammer2_mount_t *hmp, hammer2_chain_t *chain, |
| 01eabad4 | 504 | int flags); |
| 28ee5f14 | 505 | void hammer2_chain_resize(hammer2_inode_t *ip, hammer2_chain_t *chain, |
| 01eabad4 | 506 | int nradix, int flags); |
| 5c23d7f1 | 507 | void hammer2_chain_unlock(hammer2_mount_t *hmp, hammer2_chain_t *chain); |
| b7926f31 MD |
508 | hammer2_chain_t *hammer2_chain_find(hammer2_mount_t *hmp, |
| 509 | hammer2_chain_t *parent, int index); | |
| 232a50f9 | 510 | hammer2_chain_t *hammer2_chain_get(hammer2_mount_t *hmp, |
| c667909f MD |
511 | hammer2_chain_t *parent, |
| 512 | int index, int flags); | |
| 5c23d7f1 | 513 | hammer2_chain_t *hammer2_chain_lookup(hammer2_mount_t *hmp, |
| e028fa74 | 514 | hammer2_chain_t **parentp, |
| c667909f MD |
515 | hammer2_key_t key_beg, hammer2_key_t key_end, |
| 516 | int flags); | |
| 7cfa8da5 | 517 | hammer2_chain_t *hammer2_chain_next(hammer2_mount_t *hmp, |
| 5c23d7f1 MD |
518 | hammer2_chain_t **parentp, |
| 519 | hammer2_chain_t *chain, | |
| c667909f MD |
520 | hammer2_key_t key_beg, hammer2_key_t key_end, |
| 521 | int flags); | |
| 5c23d7f1 MD |
522 | hammer2_chain_t *hammer2_chain_create(hammer2_mount_t *hmp, |
| 523 | hammer2_chain_t *parent, | |
| 6934ae32 | 524 | hammer2_chain_t *chain, |
| 5c23d7f1 MD |
525 | hammer2_key_t key, int keybits, |
| 526 | int type, size_t bytes); | |
| 3ac6a319 | 527 | void hammer2_chain_delete(hammer2_mount_t *hmp, hammer2_chain_t *parent, |
| 004f88b4 | 528 | hammer2_chain_t *chain, int retain); |
| 4d5318eb MD |
529 | void hammer2_chain_flush(hammer2_mount_t *hmp, hammer2_chain_t *chain, |
| 530 | hammer2_tid_t modify_tid); | |
| b7926f31 | 531 | void hammer2_chain_commit(hammer2_mount_t *hmp, hammer2_chain_t *chain); |
| 50e4f8f4 | 532 | |
| df9ea374 | 533 | /* |
| 2910a90c MD |
534 | * hammer2_ioctl.c |
| 535 | */ | |
| 536 | int hammer2_ioctl(hammer2_inode_t *ip, u_long com, void *data, | |
| 537 | int fflag, struct ucred *cred); | |
| 538 | ||
| 539 | /* | |
| 26bf1a36 MD |
540 | * hammer2_msg.c |
| 541 | */ | |
| 542 | int hammer2_state_msgrx(hammer2_pfsmount_t *pmp, hammer2_msg_t *msg); | |
| 543 | int hammer2_state_msgtx(hammer2_pfsmount_t *pmp, hammer2_msg_t *msg); | |
| 544 | void hammer2_state_cleanuprx(hammer2_pfsmount_t *pmp, hammer2_msg_t *msg); | |
| 545 | void hammer2_state_cleanuptx(hammer2_pfsmount_t *pmp, hammer2_msg_t *msg); | |
| 546 | int hammer2_msg_execute(hammer2_pfsmount_t *pmp, hammer2_msg_t *msg); | |
| 547 | void hammer2_state_free(hammer2_state_t *state); | |
| 548 | void hammer2_msg_free(hammer2_pfsmount_t *pmp, hammer2_msg_t *msg); | |
| 8c280d5d | 549 | hammer2_msg_t *hammer2_msg_alloc(hammer2_pfsmount_t *pmp, uint64_t spanid, |
| 9b8b748f | 550 | uint32_t cmd); |
| 8c280d5d | 551 | void hammer2_msg_write(hammer2_pfsmount_t *pmp, |
| 9b8b748f | 552 | hammer2_msg_t *msg, |
| 8c280d5d MD |
553 | int (*func)(hammer2_state_t *, hammer2_msg_t *), |
| 554 | void *data); | |
| 555 | void hammer2_msg_reply(hammer2_pfsmount_t *pmp, | |
| 556 | hammer2_msg_t *msg, uint32_t error); | |
| 557 | void hammer2_msg_result(hammer2_pfsmount_t *pmp, | |
| 558 | hammer2_msg_t *msg, uint32_t error); | |
| 9b8b748f MD |
559 | |
| 560 | /* | |
| 561 | * hammer2_msgops.c | |
| 562 | */ | |
| 8c280d5d | 563 | int hammer2_msg_dbg_rcvmsg(hammer2_pfsmount_t *pmp, hammer2_msg_t *msg); |
| 9b8b748f | 564 | int hammer2_msg_adhoc_input(hammer2_pfsmount_t *pmp, hammer2_msg_t *msg); |
| 26bf1a36 MD |
565 | |
| 566 | /* | |
| df9ea374 MD |
567 | * hammer2_freemap.c |
| 568 | */ | |
| 6ba3b984 MD |
569 | hammer2_off_t hammer2_freemap_alloc(hammer2_mount_t *hmp, |
| 570 | int type, size_t bytes); | |
| 004f88b4 MD |
571 | void hammer2_freemap_free(hammer2_mount_t *hmp, hammer2_off_t data_off, |
| 572 | int type); | |
| df9ea374 | 573 | |
| 47902fef VS |
574 | #endif /* !_KERNEL */ |
| 575 | #endif /* !_VFS_HAMMER2_HAMMER2_H_ */ |