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.50 2008/04/26 02:54:00 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;
96 typedef struct hammer_transaction *hammer_transaction_t;
102 int refs; /* active references delay writes */
103 int lockcount; /* lock count for exclusive/shared access */
105 struct thread *locktd;
109 hammer_islocked(struct hammer_lock *lock)
111 return(lock->lockcount != 0);
115 hammer_isactive(struct hammer_lock *lock)
117 return(lock->refs != 0);
121 hammer_islastref(struct hammer_lock *lock)
123 return(lock->refs == 1);
127 * Return if we specifically own the lock exclusively.
130 hammer_lock_excl_owned(struct hammer_lock *lock, thread_t td)
132 if (lock->lockcount > 0 && lock->locktd == td)
138 * Structure used to represent an inode in-memory.
140 * The record and data associated with an inode may be out of sync with
141 * the disk (xDIRTY flags), or not even on the disk at all (ONDISK flag
144 * An inode may also hold a cache of unsynchronized records, used for
145 * database and directories only. Unsynchronized regular file data is
146 * stored in the buffer cache.
148 * NOTE: A file which is created and destroyed within the initial
149 * synchronization period can wind up not doing any disk I/O at all.
151 * Finally, an inode may cache numerous disk-referencing B-Tree cursors.
153 struct hammer_ino_rb_tree;
155 RB_HEAD(hammer_ino_rb_tree, hammer_inode);
156 RB_PROTOTYPEX(hammer_ino_rb_tree, INFO, hammer_inode, rb_node,
157 hammer_ino_rb_compare, hammer_inode_info_t);
159 struct hammer_rec_rb_tree;
160 struct hammer_record;
161 RB_HEAD(hammer_rec_rb_tree, hammer_record);
162 RB_PROTOTYPEX(hammer_rec_rb_tree, INFO, hammer_record, rb_node,
163 hammer_rec_rb_compare, hammer_base_elm_t);
165 TAILQ_HEAD(hammer_node_list, hammer_node);
167 typedef enum hammer_inode_state {
171 } hammer_inode_state_t;
173 struct hammer_inode {
174 RB_ENTRY(hammer_inode) rb_node;
175 hammer_inode_state_t flush_state;
176 TAILQ_ENTRY(hammer_inode) flush_entry;
177 u_int64_t obj_id; /* (key) object identifier */
178 hammer_tid_t obj_asof; /* (key) snapshot or 0 */
179 struct hammer_mount *hmp;
181 int error; /* flush error */
182 int cursor_ip_refs; /* sanity */
184 struct lockf advlock;
185 struct hammer_lock lock; /* sync copy interlock */
186 TAILQ_HEAD(, bio) bio_list; /* BIOs to flush out */
187 TAILQ_HEAD(, bio) bio_alt_list; /* BIOs to flush out */
189 struct hammer_inode_record ino_rec; /* in-memory cache */
190 struct hammer_inode_data ino_data; /* in-memory cache */
191 struct hammer_rec_rb_tree rec_tree; /* in-memory cache */
192 struct hammer_node *cache[2]; /* search initiate cache */
195 * When a demark is created to synchronize an inode to
196 * disk, certain fields are copied so the front-end VOPs
197 * can continue to run in parallel with the synchronization
198 * occuring in the background.
200 int sync_flags; /* to-sync flags cache */
201 off_t sync_trunc_off; /* to-sync truncation */
202 struct hammer_inode_record sync_ino_rec;/* to-sync cache */
203 struct hammer_inode_data sync_ino_data; /* to-sync cache */
206 typedef struct hammer_inode *hammer_inode_t;
208 #define VTOI(vp) ((struct hammer_inode *)(vp)->v_data)
210 #define HAMMER_INODE_DDIRTY 0x0001 /* in-memory ino_data is dirty */
211 #define HAMMER_INODE_RDIRTY 0x0002 /* in-memory ino_rec is dirty */
212 #define HAMMER_INODE_ITIMES 0x0004 /* in-memory mtime/atime modified */
213 #define HAMMER_INODE_XDIRTY 0x0008 /* in-memory records/flsbufs present */
214 #define HAMMER_INODE_ONDISK 0x0010 /* inode is on-disk (else not yet) */
215 #define HAMMER_INODE_FLUSH 0x0020 /* flush on last ref */
216 #define HAMMER_INODE_DELETED 0x0080 /* inode ready for deletion */
217 #define HAMMER_INODE_DELONDISK 0x0100 /* delete synchronized to disk */
218 #define HAMMER_INODE_RO 0x0200 /* read-only (because of as-of) */
219 #define HAMMER_INODE_GONE 0x0400 /* delete flushed out */
220 #define HAMMER_INODE_DONDISK 0x0800 /* data records may be on disk */
221 #define HAMMER_INODE_BUFS 0x1000 /* dirty high level bps present */
222 #define HAMMER_INODE_REFLUSH 0x2000 /* pipelined flush during flush */
223 #define HAMMER_INODE_UNUSED4000 0x4000
224 #define HAMMER_INODE_FLUSHW 0x8000 /* Someone waiting for flush */
226 #define HAMMER_INODE_TRUNCATED 0x00010000
228 #define HAMMER_INODE_MODMASK (HAMMER_INODE_DDIRTY|HAMMER_INODE_RDIRTY| \
229 HAMMER_INODE_XDIRTY|HAMMER_INODE_BUFS| \
230 HAMMER_INODE_ITIMES|HAMMER_INODE_TRUNCATED)
232 #define HAMMER_MAX_INODE_CURSORS 4
234 #define HAMMER_FLUSH_SIGNAL 0x0001
235 #define HAMMER_FLUSH_FORCE 0x0002
238 * Structure used to represent an unsynchronized record in-memory. This
239 * structure is orgranized in a per-inode RB-tree. If the inode is not
240 * on disk then neither are any records and the in-memory record tree
241 * represents the entire contents of the inode. If the inode is on disk
242 * then the on-disk B-Tree is scanned in parallel with the in-memory
243 * RB-Tree to synthesize the current state of the file.
245 * Only current (delete_tid == 0) unsynchronized records are kept in-memory.
247 * blocked is the count of the number of cursors (ip_first/ip_next) blocked
248 * on the record waiting for a synchronization to complete.
250 struct hammer_record {
251 RB_ENTRY(hammer_record) rb_node;
252 hammer_inode_state_t state;
253 struct hammer_lock lock;
254 struct hammer_inode *ip;
255 union hammer_record_ondisk rec;
256 union hammer_data_ondisk *data;
260 typedef struct hammer_record *hammer_record_t;
262 #define HAMMER_RECF_ALLOCDATA 0x0001
263 #define HAMMER_RECF_ONRBTREE 0x0002
264 #define HAMMER_RECF_DELETED_FE 0x0004 /* deleted (frontend) */
265 #define HAMMER_RECF_INBAND 0x0008
266 #define HAMMER_RECF_DELETED_BE 0x0010 /* deleted (backend) */
267 #define HAMMER_RECF_WANTED 0x0020
268 #define HAMMER_RECF_DELETE_ONDISK 0x0040
271 * In-memory structures representing on-disk structures.
273 struct hammer_volume;
274 struct hammer_buffer;
276 RB_HEAD(hammer_vol_rb_tree, hammer_volume);
277 RB_HEAD(hammer_buf_rb_tree, hammer_buffer);
278 RB_HEAD(hammer_nod_rb_tree, hammer_node);
280 RB_PROTOTYPE2(hammer_vol_rb_tree, hammer_volume, rb_node,
281 hammer_vol_rb_compare, int32_t);
282 RB_PROTOTYPE2(hammer_buf_rb_tree, hammer_buffer, rb_node,
283 hammer_buf_rb_compare, hammer_off_t);
284 RB_PROTOTYPE2(hammer_nod_rb_tree, hammer_node, rb_node,
285 hammer_nod_rb_compare, hammer_off_t);
288 * IO management - embedded at the head of various in-memory structures
290 * VOLUME - hammer_volume containing meta-data
291 * META_BUFFER - hammer_buffer containing meta-data
292 * DATA_BUFFER - hammer_buffer containing pure-data
294 * Dirty volume headers and dirty meta-data buffers are locked until the
295 * flusher can sequence them out. Dirty pure-data buffers can be written.
296 * Clean buffers can be passively released.
298 typedef enum hammer_io_type {
299 HAMMER_STRUCTURE_VOLUME,
300 HAMMER_STRUCTURE_META_BUFFER,
301 HAMMER_STRUCTURE_UNDO_BUFFER,
302 HAMMER_STRUCTURE_DATA_BUFFER
305 union hammer_io_structure;
309 LIST_ENTRY(worklist) node;
312 TAILQ_HEAD(hammer_io_list, hammer_io);
313 typedef struct hammer_io_list *hammer_io_list_t;
316 struct worklist worklist;
317 struct hammer_lock lock;
318 enum hammer_io_type type;
319 struct hammer_mount *hmp;
320 TAILQ_ENTRY(hammer_io) mod_entry; /* list entry if modified */
321 hammer_io_list_t mod_list;
324 int loading; /* loading/unloading interlock */
327 u_int modified : 1; /* bp's data was modified */
328 u_int released : 1; /* bp released (w/ B_LOCKED set) */
329 u_int running : 1; /* bp write IO in progress */
330 u_int waiting : 1; /* someone is waiting on us */
331 u_int validated : 1; /* ondisk has been validated */
332 u_int flush : 1; /* flush on last release */
333 u_int waitdep : 1; /* flush waits for dependancies */
336 typedef struct hammer_io *hammer_io_t;
339 * In-memory volume representing on-disk buffer
341 struct hammer_volume {
343 RB_ENTRY(hammer_volume) rb_node;
344 struct hammer_buf_rb_tree rb_bufs_root;
345 struct hammer_volume_ondisk *ondisk;
347 int64_t nblocks; /* note: special calculation for statfs */
348 int64_t buffer_base; /* base offset of buffer 0 */
349 hammer_off_t maxbuf_off; /* Maximum buffer offset */
355 typedef struct hammer_volume *hammer_volume_t;
358 * In-memory buffer (other then volume, super-cluster, or cluster),
359 * representing an on-disk buffer.
361 struct hammer_buffer {
363 RB_ENTRY(hammer_buffer) rb_node;
365 struct hammer_volume *volume;
366 hammer_off_t zone2_offset;
367 hammer_off_t zoneX_offset;
368 struct hammer_node_list clist;
371 typedef struct hammer_buffer *hammer_buffer_t;
374 * In-memory B-Tree node, representing an on-disk B-Tree node.
376 * This is a hang-on structure which is backed by a hammer_buffer,
377 * indexed by a hammer_cluster, and used for fine-grained locking of
378 * B-Tree nodes in order to properly control lock ordering. A hammer_buffer
379 * can contain multiple nodes representing wildly disassociated portions
380 * of the B-Tree so locking cannot be done on a buffer-by-buffer basis.
382 * This structure uses a cluster-relative index to reduce the number
383 * of layers required to access it, and also because all on-disk B-Tree
384 * references are cluster-relative offsets.
387 struct hammer_lock lock; /* node-by-node lock */
388 TAILQ_ENTRY(hammer_node) entry; /* per-buffer linkage */
389 RB_ENTRY(hammer_node) rb_node; /* per-cluster linkage */
390 hammer_off_t node_offset; /* full offset spec */
391 struct hammer_mount *hmp;
392 struct hammer_buffer *buffer; /* backing buffer */
393 hammer_node_ondisk_t ondisk; /* ptr to on-disk structure */
394 struct hammer_node **cache1; /* passive cache(s) */
395 struct hammer_node **cache2;
397 int loading; /* load interlock */
400 #define HAMMER_NODE_DELETED 0x0001
401 #define HAMMER_NODE_FLUSH 0x0002
403 typedef struct hammer_node *hammer_node_t;
406 * List of locked nodes.
408 struct hammer_node_locklist {
409 struct hammer_node_locklist *next;
413 typedef struct hammer_node_locklist *hammer_node_locklist_t;
417 * Common I/O management structure - embedded in in-memory structures
418 * which are backed by filesystem buffers.
420 union hammer_io_structure {
422 struct hammer_volume volume;
423 struct hammer_buffer buffer;
426 typedef union hammer_io_structure *hammer_io_structure_t;
429 * Allocation holes are recorded for a short period of time in an attempt
430 * to use up the space.
433 #define HAMMER_MAX_HOLES 8
437 struct hammer_holes {
438 TAILQ_HEAD(, hammer_hole) list;
442 typedef struct hammer_holes *hammer_holes_t;
445 TAILQ_ENTRY(hammer_hole) entry;
450 typedef struct hammer_hole *hammer_hole_t;
452 #include "hammer_cursor.h"
455 * Internal hammer mount data structure
457 struct hammer_mount {
459 /*struct vnode *rootvp;*/
460 struct hammer_ino_rb_tree rb_inos_root;
461 struct hammer_vol_rb_tree rb_vols_root;
462 struct hammer_nod_rb_tree rb_nods_root;
463 struct hammer_volume *rootvol;
464 struct hammer_base_elm root_btree_beg;
465 struct hammer_base_elm root_btree_end;
466 char *zbuf; /* HAMMER_BUFSIZE bytes worth of all-zeros */
476 u_int check_interrupt;
479 struct hammer_io_list volu_list; /* dirty undo buffers */
480 struct hammer_io_list undo_list; /* dirty undo buffers */
481 struct hammer_io_list data_list; /* dirty data buffers */
482 struct hammer_io_list meta_list; /* dirty meta bufs */
483 struct hammer_io_list lose_list; /* loose buffers */
484 int locked_dirty_count; /* meta/volu count */
485 int io_running_count;
487 hammer_off_t next_tid;
488 u_int32_t namekey_iterator;
489 hammer_off_t zone_limits[HAMMER_MAX_ZONES];
490 struct netexport export;
491 struct lock blockmap_lock;
492 struct hammer_holes holes[HAMMER_MAX_ZONES];
493 TAILQ_HEAD(, hammer_inode) flush_list;
496 typedef struct hammer_mount *hammer_mount_t;
498 struct hammer_sync_info {
507 extern struct vop_ops hammer_vnode_vops;
508 extern struct vop_ops hammer_spec_vops;
509 extern struct vop_ops hammer_fifo_vops;
510 extern struct bio_ops hammer_bioops;
512 extern int hammer_debug_general;
513 extern int hammer_debug_locks;
514 extern int hammer_debug_btree;
515 extern int hammer_debug_tid;
516 extern int hammer_debug_recover;
517 extern int hammer_debug_recover_faults;
518 extern int hammer_count_inodes;
519 extern int hammer_count_records;
520 extern int hammer_count_record_datas;
521 extern int hammer_count_volumes;
522 extern int hammer_count_buffers;
523 extern int hammer_count_nodes;
524 extern int64_t hammer_contention_count;
526 int hammer_vop_inactive(struct vop_inactive_args *);
527 int hammer_vop_reclaim(struct vop_reclaim_args *);
528 int hammer_get_vnode(struct hammer_inode *ip, int lktype,
530 struct hammer_inode *hammer_get_inode(hammer_transaction_t trans,
531 struct hammer_node **cache,
532 u_int64_t obj_id, hammer_tid_t asof, int flags,
534 void hammer_put_inode(struct hammer_inode *ip);
535 void hammer_put_inode_ref(struct hammer_inode *ip);
537 int hammer_unload_volume(hammer_volume_t volume, void *data __unused);
538 int hammer_unload_buffer(hammer_buffer_t buffer, void *data __unused);
539 int hammer_install_volume(hammer_mount_t hmp, const char *volname);
541 int hammer_ip_lookup(hammer_cursor_t cursor, hammer_inode_t ip);
542 int hammer_ip_first(hammer_cursor_t cursor, hammer_inode_t ip);
543 int hammer_ip_next(hammer_cursor_t cursor);
544 int hammer_ip_resolve_record_and_data(hammer_cursor_t cursor);
545 int hammer_ip_resolve_data(hammer_cursor_t cursor);
546 int hammer_ip_delete_record(hammer_cursor_t cursor, hammer_tid_t tid);
547 int hammer_delete_at_cursor(hammer_cursor_t cursor, int64_t *stat_bytes);
548 int hammer_ip_check_directory_empty(hammer_transaction_t trans,
550 int hammer_sync_hmp(hammer_mount_t hmp, int waitfor);
553 hammer_alloc_mem_record(hammer_inode_t ip);
554 void hammer_flush_record_done(hammer_record_t record);
555 void hammer_wait_mem_record(hammer_record_t record);
556 void hammer_rel_mem_record(hammer_record_t record);
559 int hammer_cursor_up(hammer_cursor_t cursor);
560 int hammer_cursor_down(hammer_cursor_t cursor);
561 int hammer_cursor_upgrade(hammer_cursor_t cursor);
562 void hammer_cursor_downgrade(hammer_cursor_t cursor);
563 int hammer_cursor_seek(hammer_cursor_t cursor, hammer_node_t node,
565 void hammer_lock_ex(struct hammer_lock *lock);
566 int hammer_lock_ex_try(struct hammer_lock *lock);
567 void hammer_lock_sh(struct hammer_lock *lock);
568 int hammer_lock_upgrade(struct hammer_lock *lock);
569 void hammer_lock_downgrade(struct hammer_lock *lock);
570 void hammer_unlock(struct hammer_lock *lock);
571 void hammer_ref(struct hammer_lock *lock);
572 void hammer_unref(struct hammer_lock *lock);
574 u_int32_t hammer_to_unix_xid(uuid_t *uuid);
575 void hammer_guid_to_uuid(uuid_t *uuid, u_int32_t guid);
576 void hammer_to_timespec(hammer_tid_t tid, struct timespec *ts);
577 hammer_tid_t hammer_timespec_to_transid(struct timespec *ts);
578 hammer_tid_t hammer_alloc_tid(hammer_transaction_t trans);
579 hammer_tid_t hammer_now_tid(void);
580 hammer_tid_t hammer_str_to_tid(const char *str);
582 enum vtype hammer_get_vnode_type(u_int8_t obj_type);
583 int hammer_get_dtype(u_int8_t obj_type);
584 u_int8_t hammer_get_obj_type(enum vtype vtype);
585 int64_t hammer_directory_namekey(void *name, int len);
587 int hammer_init_cursor(hammer_transaction_t trans, hammer_cursor_t cursor,
588 struct hammer_node **cache);
590 void hammer_done_cursor(hammer_cursor_t cursor);
591 void hammer_mem_done(hammer_cursor_t cursor);
593 int hammer_btree_lookup(hammer_cursor_t cursor);
594 int hammer_btree_first(hammer_cursor_t cursor);
595 int hammer_btree_last(hammer_cursor_t cursor);
596 int hammer_btree_extract(hammer_cursor_t cursor, int flags);
597 int hammer_btree_iterate(hammer_cursor_t cursor);
598 int hammer_btree_iterate_reverse(hammer_cursor_t cursor);
599 int hammer_btree_insert(hammer_cursor_t cursor, hammer_btree_elm_t elm);
600 int hammer_btree_delete(hammer_cursor_t cursor);
601 int hammer_btree_cmp(hammer_base_elm_t key1, hammer_base_elm_t key2);
602 int hammer_btree_chkts(hammer_tid_t ts, hammer_base_elm_t key);
603 int hammer_btree_correct_rhb(hammer_cursor_t cursor, hammer_tid_t tid);
604 int hammer_btree_correct_lhb(hammer_cursor_t cursor, hammer_tid_t tid);
607 int hammer_btree_lock_children(hammer_cursor_t cursor,
608 struct hammer_node_locklist **locklistp);
610 void hammer_print_btree_node(hammer_node_ondisk_t ondisk);
611 void hammer_print_btree_elm(hammer_btree_elm_t elm, u_int8_t type, int i);
613 void *hammer_bread(struct hammer_mount *hmp, hammer_off_t off,
614 int *errorp, struct hammer_buffer **bufferp);
615 void *hammer_bnew(struct hammer_mount *hmp, hammer_off_t off,
616 int *errorp, struct hammer_buffer **bufferp);
618 hammer_volume_t hammer_get_root_volume(hammer_mount_t hmp, int *errorp);
619 int hammer_dowrite(hammer_transaction_t trans, hammer_inode_t ip,
622 hammer_volume_t hammer_get_volume(hammer_mount_t hmp,
623 int32_t vol_no, int *errorp);
624 hammer_buffer_t hammer_get_buffer(hammer_mount_t hmp,
625 hammer_off_t buf_offset, int isnew, int *errorp);
626 void hammer_uncache_buffer(struct hammer_mount *hmp, hammer_off_t off);
628 int hammer_ref_volume(hammer_volume_t volume);
629 int hammer_ref_buffer(hammer_buffer_t buffer);
630 void hammer_flush_buffer_nodes(hammer_buffer_t buffer);
632 void hammer_rel_volume(hammer_volume_t volume, int flush);
633 void hammer_rel_buffer(hammer_buffer_t buffer, int flush);
635 int hammer_vfs_export(struct mount *mp, int op,
636 const struct export_args *export);
637 hammer_node_t hammer_get_node(hammer_mount_t hmp,
638 hammer_off_t node_offset, int *errorp);
639 void hammer_ref_node(hammer_node_t node);
640 hammer_node_t hammer_ref_node_safe(struct hammer_mount *hmp,
641 struct hammer_node **cache, int *errorp);
642 void hammer_rel_node(hammer_node_t node);
643 void hammer_delete_node(hammer_transaction_t trans,
645 void hammer_cache_node(hammer_node_t node,
646 struct hammer_node **cache);
647 void hammer_uncache_node(struct hammer_node **cache);
648 void hammer_flush_node(hammer_node_t node);
650 void hammer_dup_buffer(struct hammer_buffer **bufferp,
651 struct hammer_buffer *buffer);
652 hammer_node_t hammer_alloc_btree(hammer_transaction_t trans, int *errorp);
653 void *hammer_alloc_record(hammer_transaction_t trans,
654 hammer_off_t *rec_offp, u_int16_t rec_type,
655 struct hammer_buffer **rec_bufferp,
656 int32_t data_len, void **datap,
657 struct hammer_buffer **data_bufferp, int *errorp);
658 void *hammer_alloc_data(hammer_transaction_t trans, int32_t data_len,
659 hammer_off_t *data_offsetp,
660 struct hammer_buffer **data_bufferp, int *errorp);
662 int hammer_generate_undo(hammer_transaction_t trans, hammer_io_t io,
663 hammer_off_t zone1_offset, void *base, int len);
665 void hammer_put_volume(struct hammer_volume *volume, int flush);
666 void hammer_put_buffer(struct hammer_buffer *buffer, int flush);
668 hammer_off_t hammer_freemap_alloc(hammer_transaction_t trans,
669 hammer_off_t owner, int *errorp);
670 void hammer_freemap_free(hammer_transaction_t trans, hammer_off_t phys_offset,
671 hammer_off_t owner, int *errorp);
672 hammer_off_t hammer_blockmap_alloc(hammer_transaction_t trans, int zone,
673 int bytes, int *errorp);
674 void hammer_blockmap_free(hammer_transaction_t trans,
675 hammer_off_t bmap_off, int bytes);
676 int hammer_blockmap_getfree(hammer_mount_t hmp, hammer_off_t bmap_off,
677 int *curp, int *errorp);
678 hammer_off_t hammer_blockmap_lookup(hammer_mount_t hmp, hammer_off_t bmap_off,
680 hammer_off_t hammer_undo_lookup(hammer_mount_t hmp, hammer_off_t bmap_off,
683 void hammer_start_transaction(struct hammer_transaction *trans,
684 struct hammer_mount *hmp);
685 void hammer_simple_transaction(struct hammer_transaction *trans,
686 struct hammer_mount *hmp);
687 void hammer_start_transaction_fls(struct hammer_transaction *trans,
688 struct hammer_mount *hmp);
689 void hammer_done_transaction(struct hammer_transaction *trans);
691 void hammer_modify_inode(struct hammer_transaction *trans,
692 hammer_inode_t ip, int flags);
693 void hammer_flush_inode(hammer_inode_t ip, int flags);
694 void hammer_flush_inode_done(hammer_inode_t ip);
695 void hammer_wait_inode(hammer_inode_t ip);
697 int hammer_create_inode(struct hammer_transaction *trans, struct vattr *vap,
698 struct ucred *cred, struct hammer_inode *dip,
699 struct hammer_inode **ipp);
700 void hammer_rel_inode(hammer_inode_t ip, int flush);
701 int hammer_sync_inode(hammer_inode_t ip, int handle_delete);
703 int hammer_ip_add_directory(struct hammer_transaction *trans,
704 hammer_inode_t dip, struct namecache *ncp,
706 int hammer_ip_del_directory(struct hammer_transaction *trans,
707 hammer_cursor_t cursor, hammer_inode_t dip,
709 int hammer_ip_add_record(struct hammer_transaction *trans,
710 hammer_record_t record);
711 int hammer_ip_delete_range(struct hammer_transaction *trans,
712 hammer_inode_t ip, int64_t ran_beg, int64_t ran_end);
713 int hammer_ip_delete_range_all(struct hammer_transaction *trans,
715 int hammer_ip_sync_data(struct hammer_transaction *trans,
716 hammer_inode_t ip, int64_t offset,
717 void *data, int bytes);
718 int hammer_ip_sync_record(hammer_transaction_t trans, hammer_record_t rec);
720 int hammer_ioctl(hammer_inode_t ip, u_long com, caddr_t data, int fflag,
723 void hammer_io_init(hammer_io_t io, hammer_mount_t hmp,
724 enum hammer_io_type type);
725 void hammer_io_reinit(hammer_io_t io, enum hammer_io_type type);
726 int hammer_io_read(struct vnode *devvp, struct hammer_io *io);
727 int hammer_io_new(struct vnode *devvp, struct hammer_io *io);
728 void hammer_io_release(struct hammer_io *io);
729 void hammer_io_flush(struct hammer_io *io);
730 int hammer_io_checkflush(hammer_io_t io);
731 void hammer_io_clear_modify(struct hammer_io *io);
732 void hammer_io_waitdep(struct hammer_io *io);
734 void hammer_modify_volume(hammer_transaction_t trans, hammer_volume_t volume,
735 void *base, int len);
736 void hammer_modify_buffer(hammer_transaction_t trans, hammer_buffer_t buffer,
737 void *base, int len);
738 void hammer_modify_volume_done(hammer_volume_t volume);
739 void hammer_modify_buffer_done(hammer_buffer_t buffer);
741 int hammer_ioc_reblock(hammer_transaction_t trans, hammer_inode_t ip,
742 struct hammer_ioc_reblock *reblock);
744 void hammer_init_holes(hammer_mount_t hmp, hammer_holes_t holes);
745 void hammer_free_holes(hammer_mount_t hmp, hammer_holes_t holes);
746 int hammer_signal_check(hammer_mount_t hmp);
748 void hammer_flusher_create(hammer_mount_t hmp);
749 void hammer_flusher_destroy(hammer_mount_t hmp);
750 void hammer_flusher_sync(hammer_mount_t hmp);
751 void hammer_flusher_async(hammer_mount_t hmp);
753 int hammer_recover(hammer_mount_t hmp, hammer_volume_t rootvol);
758 hammer_modify_node_noundo(hammer_transaction_t trans, hammer_node_t node)
760 hammer_modify_buffer(trans, node->buffer, NULL, 0);
764 hammer_modify_node_all(hammer_transaction_t trans, struct hammer_node *node)
766 hammer_modify_buffer(trans, node->buffer,
767 node->ondisk, sizeof(*node->ondisk));
771 hammer_modify_node(hammer_transaction_t trans, hammer_node_t node,
774 KKASSERT((char *)base >= (char *)node->ondisk &&
775 (char *)base + len <=
776 (char *)node->ondisk + sizeof(*node->ondisk));
777 hammer_modify_buffer(trans, node->buffer, base, len);
781 hammer_modify_node_done(hammer_node_t node)
783 hammer_modify_buffer_done(node->buffer);
787 hammer_modify_record(hammer_transaction_t trans, hammer_buffer_t buffer,
790 KKASSERT((char *)base >= (char *)buffer->ondisk &&
791 (char *)base + len <= (char *)buffer->ondisk + HAMMER_BUFSIZE);
792 hammer_modify_buffer(trans, buffer, base, len);
796 hammer_modify_record_done(hammer_buffer_t buffer)
798 hammer_modify_buffer_done(buffer);