2 * Copyright (c) 2007 The DragonFly Project. All rights reserved.
4 * This code is derived from software contributed to The DragonFly Project
5 * by Matthew Dillon <dillon@backplane.com>
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
17 * 3. Neither the name of The DragonFly Project nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific, prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
29 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
31 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * $DragonFly: src/sys/vfs/hammer/hammer.h,v 1.48 2008/04/24 21:20:33 dillon Exp $
37 * This header file contains structures used internally by the HAMMERFS
38 * implementation. See hammer_disk.h for on-disk structures.
41 #include <sys/param.h>
42 #include <sys/types.h>
43 #include <sys/kernel.h>
45 #include <sys/systm.h>
47 #include <sys/malloc.h>
48 #include <sys/mount.h>
49 #include <sys/mountctl.h>
50 #include <sys/vnode.h>
52 #include <sys/globaldata.h>
53 #include <sys/lockf.h>
55 #include <sys/queue.h>
56 #include <sys/globaldata.h>
59 #include <sys/signal2.h>
60 #include "hammer_disk.h"
61 #include "hammer_mount.h"
62 #include "hammer_ioctl.h"
64 #if defined(_KERNEL) || defined(_KERNEL_STRUCTURES)
66 MALLOC_DECLARE(M_HAMMER);
71 * Key structure used for custom RB tree inode lookups. This prototypes
72 * the function hammer_ino_rb_tree_RB_LOOKUP_INFO(root, info).
74 typedef struct hammer_inode_info {
75 int64_t obj_id; /* (key) object identifier */
76 hammer_tid_t obj_asof; /* (key) snapshot transid or 0 */
77 } *hammer_inode_info_t;
79 typedef enum hammer_transaction_type {
83 } hammer_transaction_type_t;
86 * HAMMER Transaction tracking
88 struct hammer_transaction {
89 hammer_transaction_type_t type;
90 struct hammer_mount *hmp;
93 struct hammer_volume *rootvol;
94 /* TAILQ_HEAD(, hammer_io) recycle_list;*/
97 typedef struct hammer_transaction *hammer_transaction_t;
103 int refs; /* active references delay writes */
104 int lockcount; /* lock count for exclusive/shared access */
106 struct thread *locktd;
110 hammer_islocked(struct hammer_lock *lock)
112 return(lock->lockcount != 0);
116 hammer_isactive(struct hammer_lock *lock)
118 return(lock->refs != 0);
122 hammer_islastref(struct hammer_lock *lock)
124 return(lock->refs == 1);
128 * Return if we specifically own the lock exclusively.
131 hammer_lock_excl_owned(struct hammer_lock *lock, thread_t td)
133 if (lock->lockcount > 0 && lock->locktd == td)
139 * Structure used to represent an inode in-memory.
141 * The record and data associated with an inode may be out of sync with
142 * the disk (xDIRTY flags), or not even on the disk at all (ONDISK flag
145 * An inode may also hold a cache of unsynchronized records, used for
146 * database and directories only. Unsynchronized regular file data is
147 * stored in the buffer cache.
149 * NOTE: A file which is created and destroyed within the initial
150 * synchronization period can wind up not doing any disk I/O at all.
152 * Finally, an inode may cache numerous disk-referencing B-Tree cursors.
154 struct hammer_ino_rb_tree;
156 RB_HEAD(hammer_ino_rb_tree, hammer_inode);
157 RB_PROTOTYPEX(hammer_ino_rb_tree, INFO, hammer_inode, rb_node,
158 hammer_ino_rb_compare, hammer_inode_info_t);
160 struct hammer_rec_rb_tree;
161 struct hammer_record;
162 RB_HEAD(hammer_rec_rb_tree, hammer_record);
163 RB_PROTOTYPEX(hammer_rec_rb_tree, INFO, hammer_record, rb_node,
164 hammer_rec_rb_compare, hammer_base_elm_t);
166 TAILQ_HEAD(hammer_node_list, hammer_node);
168 typedef enum hammer_inode_state {
172 } hammer_inode_state_t;
174 struct hammer_inode {
175 RB_ENTRY(hammer_inode) rb_node;
176 hammer_inode_state_t flush_state;
177 TAILQ_ENTRY(hammer_inode) flush_entry;
178 u_int64_t obj_id; /* (key) object identifier */
179 hammer_tid_t obj_asof; /* (key) snapshot or 0 */
180 struct hammer_mount *hmp;
182 int error; /* flush error */
183 int cursor_ip_refs; /* sanity */
185 struct lockf advlock;
186 struct hammer_lock lock; /* sync copy interlock */
187 TAILQ_HEAD(, bio) bio_list; /* BIOs to flush out */
188 TAILQ_HEAD(, bio) bio_alt_list; /* BIOs to flush out */
190 struct hammer_inode_record ino_rec; /* in-memory cache */
191 struct hammer_inode_data ino_data; /* in-memory cache */
192 struct hammer_rec_rb_tree rec_tree; /* in-memory cache */
193 struct hammer_node *cache[2]; /* search initiate cache */
196 * When a demark is created to synchronize an inode to
197 * disk, certain fields are copied so the front-end VOPs
198 * can continue to run in parallel with the synchronization
199 * occuring in the background.
201 int sync_flags; /* to-sync flags cache */
202 off_t sync_trunc_off; /* to-sync truncation */
203 struct hammer_inode_record sync_ino_rec;/* to-sync cache */
204 struct hammer_inode_data sync_ino_data; /* to-sync cache */
207 typedef struct hammer_inode *hammer_inode_t;
209 #define VTOI(vp) ((struct hammer_inode *)(vp)->v_data)
211 #define HAMMER_INODE_DDIRTY 0x0001 /* in-memory ino_data is dirty */
212 #define HAMMER_INODE_RDIRTY 0x0002 /* in-memory ino_rec is dirty */
213 #define HAMMER_INODE_ITIMES 0x0004 /* in-memory mtime/atime modified */
214 #define HAMMER_INODE_XDIRTY 0x0008 /* in-memory records/flsbufs present */
215 #define HAMMER_INODE_ONDISK 0x0010 /* inode is on-disk (else not yet) */
216 #define HAMMER_INODE_FLUSH 0x0020 /* flush on last ref */
217 #define HAMMER_INODE_DELETED 0x0080 /* inode ready for deletion */
218 #define HAMMER_INODE_DELONDISK 0x0100 /* delete synchronized to disk */
219 #define HAMMER_INODE_RO 0x0200 /* read-only (because of as-of) */
220 #define HAMMER_INODE_GONE 0x0400 /* delete flushed out */
221 #define HAMMER_INODE_DONDISK 0x0800 /* data records may be on disk */
222 #define HAMMER_INODE_BUFS 0x1000 /* dirty high level bps present */
223 #define HAMMER_INODE_REFLUSH 0x2000 /* pipelined flush during flush */
224 #define HAMMER_INODE_UNUSED4000 0x4000
225 #define HAMMER_INODE_FLUSHW 0x8000 /* Someone waiting for flush */
227 #define HAMMER_INODE_TRUNCATED 0x00010000
229 #define HAMMER_INODE_MODMASK (HAMMER_INODE_DDIRTY|HAMMER_INODE_RDIRTY| \
230 HAMMER_INODE_XDIRTY|HAMMER_INODE_BUFS| \
231 HAMMER_INODE_ITIMES|HAMMER_INODE_TRUNCATED)
233 #define HAMMER_MAX_INODE_CURSORS 4
236 * Structure used to represent an unsynchronized record in-memory. This
237 * structure is orgranized in a per-inode RB-tree. If the inode is not
238 * on disk then neither are any records and the in-memory record tree
239 * represents the entire contents of the inode. If the inode is on disk
240 * then the on-disk B-Tree is scanned in parallel with the in-memory
241 * RB-Tree to synthesize the current state of the file.
243 * Only current (delete_tid == 0) unsynchronized records are kept in-memory.
245 * blocked is the count of the number of cursors (ip_first/ip_next) blocked
246 * on the record waiting for a synchronization to complete.
248 struct hammer_record {
249 RB_ENTRY(hammer_record) rb_node;
250 hammer_inode_state_t state;
251 struct hammer_lock lock;
252 struct hammer_inode *ip;
253 union hammer_record_ondisk rec;
254 union hammer_data_ondisk *data;
258 typedef struct hammer_record *hammer_record_t;
260 #define HAMMER_RECF_ALLOCDATA 0x0001
261 #define HAMMER_RECF_ONRBTREE 0x0002
262 #define HAMMER_RECF_DELETED_FE 0x0004 /* deleted (frontend) */
263 #define HAMMER_RECF_INBAND 0x0008
264 #define HAMMER_RECF_DELETED_BE 0x0010 /* deleted (backend) */
265 #define HAMMER_RECF_WANTED 0x0020
266 #define HAMMER_RECF_DELETE_ONDISK 0x0040
269 * In-memory structures representing on-disk structures.
271 struct hammer_volume;
272 struct hammer_buffer;
274 RB_HEAD(hammer_vol_rb_tree, hammer_volume);
275 RB_HEAD(hammer_buf_rb_tree, hammer_buffer);
276 RB_HEAD(hammer_nod_rb_tree, hammer_node);
278 RB_PROTOTYPE2(hammer_vol_rb_tree, hammer_volume, rb_node,
279 hammer_vol_rb_compare, int32_t);
280 RB_PROTOTYPE2(hammer_buf_rb_tree, hammer_buffer, rb_node,
281 hammer_buf_rb_compare, hammer_off_t);
282 RB_PROTOTYPE2(hammer_nod_rb_tree, hammer_node, rb_node,
283 hammer_nod_rb_compare, hammer_off_t);
286 * IO management - embedded at the head of various in-memory structures
288 enum hammer_io_type { HAMMER_STRUCTURE_VOLUME,
289 HAMMER_STRUCTURE_BUFFER };
291 union hammer_io_structure;
295 LIST_ENTRY(worklist) node;
298 /*TAILQ_HEAD(hammer_dep_list, hammer_dep);*/
301 struct worklist worklist;
302 struct hammer_lock lock;
303 enum hammer_io_type type;
306 int loading; /* loading/unloading interlock */
307 u_int modified : 1; /* bp's data was modified */
308 u_int released : 1; /* bp released (w/ B_LOCKED set) */
309 u_int running : 1; /* bp write IO in progress */
310 u_int waiting : 1; /* someone is waiting on us */
311 u_int validated : 1; /* ondisk has been validated */
312 u_int flush : 1; /* flush on last release */
313 u_int waitdep : 1; /* flush waits for dependancies */
316 typedef struct hammer_io *hammer_io_t;
319 * In-memory volume representing on-disk buffer
321 struct hammer_volume {
323 RB_ENTRY(hammer_volume) rb_node;
324 struct hammer_buf_rb_tree rb_bufs_root;
325 struct hammer_volume_ondisk *ondisk;
327 int64_t nblocks; /* note: special calculation for statfs */
328 int64_t buffer_base; /* base offset of buffer 0 */
329 hammer_off_t maxbuf_off; /* Maximum buffer offset */
332 struct hammer_mount *hmp;
336 typedef struct hammer_volume *hammer_volume_t;
339 * In-memory buffer (other then volume, super-cluster, or cluster),
340 * representing an on-disk buffer.
342 struct hammer_buffer {
344 RB_ENTRY(hammer_buffer) rb_node;
346 struct hammer_volume *volume;
347 hammer_off_t zone2_offset;
348 hammer_off_t zoneX_offset;
349 struct hammer_node_list clist;
352 typedef struct hammer_buffer *hammer_buffer_t;
355 * In-memory B-Tree node, representing an on-disk B-Tree node.
357 * This is a hang-on structure which is backed by a hammer_buffer,
358 * indexed by a hammer_cluster, and used for fine-grained locking of
359 * B-Tree nodes in order to properly control lock ordering. A hammer_buffer
360 * can contain multiple nodes representing wildly disassociated portions
361 * of the B-Tree so locking cannot be done on a buffer-by-buffer basis.
363 * This structure uses a cluster-relative index to reduce the number
364 * of layers required to access it, and also because all on-disk B-Tree
365 * references are cluster-relative offsets.
368 struct hammer_lock lock; /* node-by-node lock */
369 TAILQ_ENTRY(hammer_node) entry; /* per-buffer linkage */
370 RB_ENTRY(hammer_node) rb_node; /* per-cluster linkage */
371 hammer_off_t node_offset; /* full offset spec */
372 struct hammer_mount *hmp;
373 struct hammer_buffer *buffer; /* backing buffer */
374 hammer_node_ondisk_t ondisk; /* ptr to on-disk structure */
375 struct hammer_node **cache1; /* passive cache(s) */
376 struct hammer_node **cache2;
378 int loading; /* load interlock */
381 #define HAMMER_NODE_DELETED 0x0001
382 #define HAMMER_NODE_FLUSH 0x0002
384 typedef struct hammer_node *hammer_node_t;
387 * List of locked nodes.
389 struct hammer_node_locklist {
390 struct hammer_node_locklist *next;
394 typedef struct hammer_node_locklist *hammer_node_locklist_t;
398 * Common I/O management structure - embedded in in-memory structures
399 * which are backed by filesystem buffers.
401 union hammer_io_structure {
403 struct hammer_volume volume;
404 struct hammer_buffer buffer;
407 typedef union hammer_io_structure *hammer_io_structure_t;
410 * Allocation holes are recorded for a short period of time in an attempt
411 * to use up the space.
414 #define HAMMER_MAX_HOLES 8
418 struct hammer_holes {
419 TAILQ_HEAD(, hammer_hole) list;
423 typedef struct hammer_holes *hammer_holes_t;
426 TAILQ_ENTRY(hammer_hole) entry;
431 typedef struct hammer_hole *hammer_hole_t;
433 #include "hammer_cursor.h"
436 * Internal hammer mount data structure
438 struct hammer_mount {
440 /*struct vnode *rootvp;*/
441 struct hammer_ino_rb_tree rb_inos_root;
442 struct hammer_vol_rb_tree rb_vols_root;
443 struct hammer_nod_rb_tree rb_nods_root;
444 struct hammer_volume *rootvol;
445 struct hammer_base_elm root_btree_beg;
446 struct hammer_base_elm root_btree_end;
447 char *zbuf; /* HAMMER_BUFSIZE bytes worth of all-zeros */
456 u_int check_interrupt;
460 hammer_off_t next_tid;
461 u_int32_t namekey_iterator;
462 hammer_off_t zone_limits[HAMMER_MAX_ZONES];
463 struct netexport export;
464 struct lock blockmap_lock;
465 struct hammer_holes holes[HAMMER_MAX_ZONES];
466 TAILQ_HEAD(, hammer_inode) flush_list;
469 typedef struct hammer_mount *hammer_mount_t;
471 struct hammer_sync_info {
480 extern struct vop_ops hammer_vnode_vops;
481 extern struct vop_ops hammer_spec_vops;
482 extern struct vop_ops hammer_fifo_vops;
483 extern struct bio_ops hammer_bioops;
485 extern int hammer_debug_general;
486 extern int hammer_debug_locks;
487 extern int hammer_debug_btree;
488 extern int hammer_debug_tid;
489 extern int hammer_debug_recover;
490 extern int hammer_debug_recover_faults;
491 extern int hammer_count_inodes;
492 extern int hammer_count_records;
493 extern int hammer_count_record_datas;
494 extern int hammer_count_volumes;
495 extern int hammer_count_buffers;
496 extern int hammer_count_nodes;
497 extern int64_t hammer_contention_count;
499 int hammer_vop_inactive(struct vop_inactive_args *);
500 int hammer_vop_reclaim(struct vop_reclaim_args *);
501 int hammer_get_vnode(struct hammer_inode *ip, int lktype,
503 struct hammer_inode *hammer_get_inode(hammer_transaction_t trans,
504 struct hammer_node **cache,
505 u_int64_t obj_id, hammer_tid_t asof, int flags,
507 void hammer_put_inode(struct hammer_inode *ip);
508 void hammer_put_inode_ref(struct hammer_inode *ip);
510 int hammer_unload_volume(hammer_volume_t volume, void *data __unused);
511 int hammer_unload_buffer(hammer_buffer_t buffer, void *data __unused);
512 int hammer_install_volume(hammer_mount_t hmp, const char *volname);
514 int hammer_ip_lookup(hammer_cursor_t cursor, hammer_inode_t ip);
515 int hammer_ip_first(hammer_cursor_t cursor, hammer_inode_t ip);
516 int hammer_ip_next(hammer_cursor_t cursor);
517 int hammer_ip_resolve_record_and_data(hammer_cursor_t cursor);
518 int hammer_ip_resolve_data(hammer_cursor_t cursor);
519 int hammer_ip_delete_record(hammer_cursor_t cursor, hammer_tid_t tid);
520 int hammer_delete_at_cursor(hammer_cursor_t cursor, int64_t *stat_bytes);
521 int hammer_ip_check_directory_empty(hammer_transaction_t trans,
523 int hammer_sync_hmp(hammer_mount_t hmp, int waitfor);
524 int hammer_sync_volume(hammer_volume_t volume, void *data);
525 int hammer_sync_buffer(hammer_buffer_t buffer, void *data);
528 hammer_alloc_mem_record(hammer_inode_t ip);
529 void hammer_flush_record_done(hammer_record_t record);
530 void hammer_wait_mem_record(hammer_record_t record);
531 void hammer_rel_mem_record(hammer_record_t record);
534 int hammer_cursor_up(hammer_cursor_t cursor);
535 int hammer_cursor_down(hammer_cursor_t cursor);
536 int hammer_cursor_upgrade(hammer_cursor_t cursor);
537 void hammer_cursor_downgrade(hammer_cursor_t cursor);
538 int hammer_cursor_seek(hammer_cursor_t cursor, hammer_node_t node,
540 void hammer_lock_ex(struct hammer_lock *lock);
541 int hammer_lock_ex_try(struct hammer_lock *lock);
542 void hammer_lock_sh(struct hammer_lock *lock);
543 int hammer_lock_upgrade(struct hammer_lock *lock);
544 void hammer_lock_downgrade(struct hammer_lock *lock);
545 void hammer_unlock(struct hammer_lock *lock);
546 void hammer_ref(struct hammer_lock *lock);
547 void hammer_unref(struct hammer_lock *lock);
549 u_int32_t hammer_to_unix_xid(uuid_t *uuid);
550 void hammer_guid_to_uuid(uuid_t *uuid, u_int32_t guid);
551 void hammer_to_timespec(hammer_tid_t tid, struct timespec *ts);
552 hammer_tid_t hammer_timespec_to_transid(struct timespec *ts);
553 hammer_tid_t hammer_alloc_tid(hammer_transaction_t trans);
554 hammer_tid_t hammer_now_tid(void);
555 hammer_tid_t hammer_str_to_tid(const char *str);
557 enum vtype hammer_get_vnode_type(u_int8_t obj_type);
558 int hammer_get_dtype(u_int8_t obj_type);
559 u_int8_t hammer_get_obj_type(enum vtype vtype);
560 int64_t hammer_directory_namekey(void *name, int len);
562 int hammer_init_cursor(hammer_transaction_t trans, hammer_cursor_t cursor,
563 struct hammer_node **cache);
565 void hammer_done_cursor(hammer_cursor_t cursor);
566 void hammer_mem_done(hammer_cursor_t cursor);
568 int hammer_btree_lookup(hammer_cursor_t cursor);
569 int hammer_btree_first(hammer_cursor_t cursor);
570 int hammer_btree_last(hammer_cursor_t cursor);
571 int hammer_btree_extract(hammer_cursor_t cursor, int flags);
572 int hammer_btree_iterate(hammer_cursor_t cursor);
573 int hammer_btree_iterate_reverse(hammer_cursor_t cursor);
574 int hammer_btree_insert(hammer_cursor_t cursor, hammer_btree_elm_t elm);
575 int hammer_btree_delete(hammer_cursor_t cursor);
576 int hammer_btree_cmp(hammer_base_elm_t key1, hammer_base_elm_t key2);
577 int hammer_btree_chkts(hammer_tid_t ts, hammer_base_elm_t key);
578 int hammer_btree_correct_rhb(hammer_cursor_t cursor, hammer_tid_t tid);
579 int hammer_btree_correct_lhb(hammer_cursor_t cursor, hammer_tid_t tid);
582 int hammer_btree_lock_children(hammer_cursor_t cursor,
583 struct hammer_node_locklist **locklistp);
585 void hammer_print_btree_node(hammer_node_ondisk_t ondisk);
586 void hammer_print_btree_elm(hammer_btree_elm_t elm, u_int8_t type, int i);
588 void *hammer_bread(struct hammer_mount *hmp, hammer_off_t off,
589 int *errorp, struct hammer_buffer **bufferp);
590 void *hammer_bnew(struct hammer_mount *hmp, hammer_off_t off,
591 int *errorp, struct hammer_buffer **bufferp);
593 hammer_volume_t hammer_get_root_volume(hammer_mount_t hmp, int *errorp);
594 int hammer_dowrite(hammer_transaction_t trans, hammer_inode_t ip,
597 hammer_volume_t hammer_get_volume(hammer_mount_t hmp,
598 int32_t vol_no, int *errorp);
599 hammer_buffer_t hammer_get_buffer(hammer_mount_t hmp,
600 hammer_off_t buf_offset, int isnew, int *errorp);
601 void hammer_uncache_buffer(struct hammer_mount *hmp, hammer_off_t off);
603 int hammer_ref_volume(hammer_volume_t volume);
604 int hammer_ref_buffer(hammer_buffer_t buffer);
605 void hammer_flush_buffer_nodes(hammer_buffer_t buffer);
607 void hammer_rel_volume(hammer_volume_t volume, int flush);
608 void hammer_rel_buffer(hammer_buffer_t buffer, int flush);
610 int hammer_vfs_export(struct mount *mp, int op,
611 const struct export_args *export);
612 hammer_node_t hammer_get_node(hammer_mount_t hmp,
613 hammer_off_t node_offset, int *errorp);
614 void hammer_ref_node(hammer_node_t node);
615 hammer_node_t hammer_ref_node_safe(struct hammer_mount *hmp,
616 struct hammer_node **cache, int *errorp);
617 void hammer_rel_node(hammer_node_t node);
618 void hammer_delete_node(hammer_transaction_t trans,
620 void hammer_cache_node(hammer_node_t node,
621 struct hammer_node **cache);
622 void hammer_uncache_node(struct hammer_node **cache);
623 void hammer_flush_node(hammer_node_t node);
625 void hammer_dup_buffer(struct hammer_buffer **bufferp,
626 struct hammer_buffer *buffer);
627 hammer_node_t hammer_alloc_btree(hammer_transaction_t trans, int *errorp);
628 void *hammer_alloc_record(hammer_transaction_t trans,
629 hammer_off_t *rec_offp, u_int16_t rec_type,
630 struct hammer_buffer **rec_bufferp,
631 int32_t data_len, void **datap,
632 struct hammer_buffer **data_bufferp, int *errorp);
633 void *hammer_alloc_data(hammer_transaction_t trans, int32_t data_len,
634 hammer_off_t *data_offsetp,
635 struct hammer_buffer **data_bufferp, int *errorp);
637 int hammer_generate_undo(hammer_transaction_t trans, hammer_io_t io,
638 hammer_off_t zone1_offset, void *base, int len);
640 void hammer_put_volume(struct hammer_volume *volume, int flush);
641 void hammer_put_buffer(struct hammer_buffer *buffer, int flush);
643 hammer_off_t hammer_freemap_alloc(hammer_transaction_t trans,
644 hammer_off_t owner, int *errorp);
645 void hammer_freemap_free(hammer_transaction_t trans, hammer_off_t phys_offset,
646 hammer_off_t owner, int *errorp);
647 hammer_off_t hammer_blockmap_alloc(hammer_transaction_t trans, int zone,
648 int bytes, int *errorp);
649 void hammer_blockmap_free(hammer_transaction_t trans,
650 hammer_off_t bmap_off, int bytes);
651 int hammer_blockmap_getfree(hammer_mount_t hmp, hammer_off_t bmap_off,
652 int *curp, int *errorp);
653 hammer_off_t hammer_blockmap_lookup(hammer_mount_t hmp, hammer_off_t bmap_off,
655 hammer_off_t hammer_undo_lookup(hammer_mount_t hmp, hammer_off_t bmap_off,
658 void hammer_start_transaction(struct hammer_transaction *trans,
659 struct hammer_mount *hmp);
660 void hammer_simple_transaction(struct hammer_transaction *trans,
661 struct hammer_mount *hmp);
662 void hammer_start_transaction_fls(struct hammer_transaction *trans,
663 struct hammer_mount *hmp);
664 void hammer_done_transaction(struct hammer_transaction *trans);
666 void hammer_modify_inode(struct hammer_transaction *trans,
667 hammer_inode_t ip, int flags);
668 void hammer_flush_inode(hammer_inode_t ip, int forceit);
669 void hammer_flush_inode_done(hammer_inode_t ip);
670 void hammer_wait_inode(hammer_inode_t ip);
672 int hammer_create_inode(struct hammer_transaction *trans, struct vattr *vap,
673 struct ucred *cred, struct hammer_inode *dip,
674 struct hammer_inode **ipp);
675 void hammer_rel_inode(hammer_inode_t ip, int flush);
676 int hammer_sync_inode(hammer_inode_t ip, int handle_delete);
678 int hammer_ip_add_directory(struct hammer_transaction *trans,
679 hammer_inode_t dip, struct namecache *ncp,
681 int hammer_ip_del_directory(struct hammer_transaction *trans,
682 hammer_cursor_t cursor, hammer_inode_t dip,
684 int hammer_ip_add_record(struct hammer_transaction *trans,
685 hammer_record_t record);
686 int hammer_ip_delete_range(struct hammer_transaction *trans,
687 hammer_inode_t ip, int64_t ran_beg, int64_t ran_end);
688 int hammer_ip_delete_range_all(struct hammer_transaction *trans,
690 int hammer_ip_sync_data(struct hammer_transaction *trans,
691 hammer_inode_t ip, int64_t offset,
692 void *data, int bytes);
693 int hammer_ip_sync_record(hammer_transaction_t trans, hammer_record_t rec);
695 int hammer_ioctl(hammer_inode_t ip, u_long com, caddr_t data, int fflag,
698 void hammer_io_init(hammer_io_t io, enum hammer_io_type type);
699 int hammer_io_read(struct vnode *devvp, struct hammer_io *io);
700 int hammer_io_new(struct vnode *devvp, struct hammer_io *io);
701 void hammer_io_release(struct hammer_io *io);
702 void hammer_io_flush(struct hammer_io *io);
703 int hammer_io_checkflush(hammer_io_t io);
704 void hammer_io_clear_modify(struct hammer_io *io);
705 void hammer_io_waitdep(struct hammer_io *io);
707 void hammer_modify_volume(hammer_transaction_t trans, hammer_volume_t volume,
708 void *base, int len);
709 void hammer_modify_buffer(hammer_transaction_t trans, hammer_buffer_t buffer,
710 void *base, int len);
712 int hammer_ioc_reblock(hammer_transaction_t trans, hammer_inode_t ip,
713 struct hammer_ioc_reblock *reblock);
715 void hammer_init_holes(hammer_mount_t hmp, hammer_holes_t holes);
716 void hammer_free_holes(hammer_mount_t hmp, hammer_holes_t holes);
717 int hammer_signal_check(hammer_mount_t hmp);
719 void hammer_flusher_create(hammer_mount_t hmp);
720 void hammer_flusher_destroy(hammer_mount_t hmp);
721 void hammer_flusher_sync(hammer_mount_t hmp);
722 void hammer_flusher_async(hammer_mount_t hmp);
727 hammer_modify_node_noundo(hammer_transaction_t trans, hammer_node_t node)
729 hammer_modify_buffer(trans, node->buffer, NULL, 0);
733 hammer_modify_node_all(hammer_transaction_t trans, struct hammer_node *node)
735 hammer_modify_buffer(trans, node->buffer,
736 node->ondisk, sizeof(*node->ondisk));
740 hammer_modify_node(hammer_transaction_t trans, hammer_node_t node,
743 KKASSERT((char *)base >= (char *)node->ondisk &&
744 (char *)base + len <=
745 (char *)node->ondisk + sizeof(*node->ondisk));
746 hammer_modify_buffer(trans, node->buffer, base, len);
750 hammer_modify_record(hammer_transaction_t trans, hammer_buffer_t buffer,
753 KKASSERT((char *)base >= (char *)buffer->ondisk &&
754 (char *)base + len <= (char *)buffer->ondisk + HAMMER_BUFSIZE);
755 hammer_modify_buffer(trans, buffer, base, len);