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.53 2008/04/27 00:45:37 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 * inode->inode dependancy
140 typedef struct hammer_depend {
141 TAILQ_ENTRY(hammer_depend) ip_entry;
142 TAILQ_ENTRY(hammer_depend) rec_entry;
143 struct hammer_inode *ip;
144 struct hammer_record *record;
147 TAILQ_HEAD(hammer_depend_list, hammer_depend);
150 * Structure used to represent an inode in-memory.
152 * The record and data associated with an inode may be out of sync with
153 * the disk (xDIRTY flags), or not even on the disk at all (ONDISK flag
156 * An inode may also hold a cache of unsynchronized records, used for
157 * database and directories only. Unsynchronized regular file data is
158 * stored in the buffer cache.
160 * NOTE: A file which is created and destroyed within the initial
161 * synchronization period can wind up not doing any disk I/O at all.
163 * Finally, an inode may cache numerous disk-referencing B-Tree cursors.
165 struct hammer_ino_rb_tree;
167 RB_HEAD(hammer_ino_rb_tree, hammer_inode);
168 RB_PROTOTYPEX(hammer_ino_rb_tree, INFO, hammer_inode, rb_node,
169 hammer_ino_rb_compare, hammer_inode_info_t);
171 struct hammer_rec_rb_tree;
172 struct hammer_record;
173 RB_HEAD(hammer_rec_rb_tree, hammer_record);
174 RB_PROTOTYPEX(hammer_rec_rb_tree, INFO, hammer_record, rb_node,
175 hammer_rec_rb_compare, hammer_base_elm_t);
177 TAILQ_HEAD(hammer_node_list, hammer_node);
179 typedef enum hammer_inode_state {
183 } hammer_inode_state_t;
185 struct hammer_inode {
186 RB_ENTRY(hammer_inode) rb_node;
187 hammer_inode_state_t flush_state;
188 TAILQ_ENTRY(hammer_inode) flush_entry;
189 struct hammer_depend_list depend_list;
190 u_int64_t obj_id; /* (key) object identifier */
191 hammer_tid_t obj_asof; /* (key) snapshot or 0 */
192 struct hammer_mount *hmp;
194 int error; /* flush error */
196 int cursor_ip_refs; /* sanity */
198 struct lockf advlock;
199 struct hammer_lock lock; /* sync copy interlock */
200 TAILQ_HEAD(, bio) bio_list; /* BIOs to flush out */
201 TAILQ_HEAD(, bio) bio_alt_list; /* BIOs to flush out */
203 struct hammer_inode_record ino_rec; /* in-memory cache */
204 struct hammer_inode_data ino_data; /* in-memory cache */
205 struct hammer_rec_rb_tree rec_tree; /* in-memory cache */
206 struct hammer_node *cache[2]; /* search initiate cache */
209 * When a demark is created to synchronize an inode to
210 * disk, certain fields are copied so the front-end VOPs
211 * can continue to run in parallel with the synchronization
212 * occuring in the background.
214 int sync_flags; /* to-sync flags cache */
215 off_t sync_trunc_off; /* to-sync truncation */
216 struct hammer_inode_record sync_ino_rec;/* to-sync cache */
217 struct hammer_inode_data sync_ino_data; /* to-sync cache */
220 typedef struct hammer_inode *hammer_inode_t;
222 #define VTOI(vp) ((struct hammer_inode *)(vp)->v_data)
224 #define HAMMER_INODE_DDIRTY 0x0001 /* in-memory ino_data is dirty */
225 #define HAMMER_INODE_RDIRTY 0x0002 /* in-memory ino_rec is dirty */
226 #define HAMMER_INODE_ITIMES 0x0004 /* in-memory mtime/atime modified */
227 #define HAMMER_INODE_XDIRTY 0x0008 /* in-memory records/flsbufs present */
228 #define HAMMER_INODE_ONDISK 0x0010 /* inode is on-disk (else not yet) */
229 #define HAMMER_INODE_FLUSH 0x0020 /* flush on last ref */
230 #define HAMMER_INODE_DELETED 0x0080 /* inode ready for deletion */
231 #define HAMMER_INODE_DELONDISK 0x0100 /* delete synchronized to disk */
232 #define HAMMER_INODE_RO 0x0200 /* read-only (because of as-of) */
233 #define HAMMER_INODE_GONE 0x0400 /* delete flushed out */
234 #define HAMMER_INODE_DONDISK 0x0800 /* data records may be on disk */
235 #define HAMMER_INODE_BUFS 0x1000 /* dirty high level bps present */
236 #define HAMMER_INODE_REFLUSH 0x2000 /* pipelined flush during flush */
237 #define HAMMER_INODE_UNUSED4000 0x4000
238 #define HAMMER_INODE_FLUSHW 0x8000 /* Someone waiting for flush */
240 #define HAMMER_INODE_TRUNCATED 0x00010000
241 #define HAMMER_INODE_NEW 0x00020000
243 #define HAMMER_INODE_MODMASK (HAMMER_INODE_DDIRTY|HAMMER_INODE_RDIRTY| \
244 HAMMER_INODE_XDIRTY|HAMMER_INODE_BUFS| \
245 HAMMER_INODE_ITIMES|HAMMER_INODE_TRUNCATED)
247 #define HAMMER_MAX_INODE_CURSORS 4
249 #define HAMMER_FLUSH_SIGNAL 0x0001
250 #define HAMMER_FLUSH_FORCE 0x0002
251 #define HAMMER_FLUSH_RELEASE 0x0004
254 * Structure used to represent an unsynchronized record in-memory. This
255 * structure is orgranized in a per-inode RB-tree. If the inode is not
256 * on disk then neither are any records and the in-memory record tree
257 * represents the entire contents of the inode. If the inode is on disk
258 * then the on-disk B-Tree is scanned in parallel with the in-memory
259 * RB-Tree to synthesize the current state of the file.
261 * Only current (delete_tid == 0) unsynchronized records are kept in-memory.
263 * blocked is the count of the number of cursors (ip_first/ip_next) blocked
264 * on the record waiting for a synchronization to complete.
266 struct hammer_record {
267 RB_ENTRY(hammer_record) rb_node;
268 hammer_inode_state_t state;
269 struct hammer_lock lock;
270 struct hammer_inode *ip;
271 union hammer_record_ondisk rec;
272 union hammer_data_ondisk *data;
274 struct hammer_depend_list depend_list;
277 typedef struct hammer_record *hammer_record_t;
280 * Record flags. Note that FE can only be set by the frontend if the
281 * record has not been interlocked by the backend w/ BE.
283 #define HAMMER_RECF_ALLOCDATA 0x0001
284 #define HAMMER_RECF_ONRBTREE 0x0002
285 #define HAMMER_RECF_DELETED_FE 0x0004 /* deleted (frontend) */
286 #define HAMMER_RECF_DELETED_BE 0x0008 /* deleted (backend) */
287 #define HAMMER_RECF_INBAND 0x0010
288 #define HAMMER_RECF_INTERLOCK_BE 0x0020 /* backend interlock */
289 #define HAMMER_RECF_WANTED 0x0040
290 #define HAMMER_RECF_DELETE_ONDISK 0x0080
291 #define HAMMER_RECF_CONVERT_DELETE_ONDISK 0x0100 /* special case */
294 * In-memory structures representing on-disk structures.
296 struct hammer_volume;
297 struct hammer_buffer;
299 RB_HEAD(hammer_vol_rb_tree, hammer_volume);
300 RB_HEAD(hammer_buf_rb_tree, hammer_buffer);
301 RB_HEAD(hammer_nod_rb_tree, hammer_node);
303 RB_PROTOTYPE2(hammer_vol_rb_tree, hammer_volume, rb_node,
304 hammer_vol_rb_compare, int32_t);
305 RB_PROTOTYPE2(hammer_buf_rb_tree, hammer_buffer, rb_node,
306 hammer_buf_rb_compare, hammer_off_t);
307 RB_PROTOTYPE2(hammer_nod_rb_tree, hammer_node, rb_node,
308 hammer_nod_rb_compare, hammer_off_t);
311 * IO management - embedded at the head of various in-memory structures
313 * VOLUME - hammer_volume containing meta-data
314 * META_BUFFER - hammer_buffer containing meta-data
315 * DATA_BUFFER - hammer_buffer containing pure-data
317 * Dirty volume headers and dirty meta-data buffers are locked until the
318 * flusher can sequence them out. Dirty pure-data buffers can be written.
319 * Clean buffers can be passively released.
321 typedef enum hammer_io_type {
322 HAMMER_STRUCTURE_VOLUME,
323 HAMMER_STRUCTURE_META_BUFFER,
324 HAMMER_STRUCTURE_UNDO_BUFFER,
325 HAMMER_STRUCTURE_DATA_BUFFER
328 union hammer_io_structure;
332 LIST_ENTRY(worklist) node;
335 TAILQ_HEAD(hammer_io_list, hammer_io);
336 typedef struct hammer_io_list *hammer_io_list_t;
339 struct worklist worklist;
340 struct hammer_lock lock;
341 enum hammer_io_type type;
342 struct hammer_mount *hmp;
343 TAILQ_ENTRY(hammer_io) mod_entry; /* list entry if modified */
344 hammer_io_list_t mod_list;
347 int loading; /* loading/unloading interlock */
350 u_int modified : 1; /* bp's data was modified */
351 u_int released : 1; /* bp released (w/ B_LOCKED set) */
352 u_int running : 1; /* bp write IO in progress */
353 u_int waiting : 1; /* someone is waiting on us */
354 u_int validated : 1; /* ondisk has been validated */
355 u_int flush : 1; /* flush on last release */
356 u_int waitdep : 1; /* flush waits for dependancies */
359 typedef struct hammer_io *hammer_io_t;
362 * In-memory volume representing on-disk buffer
364 struct hammer_volume {
366 RB_ENTRY(hammer_volume) rb_node;
367 struct hammer_buf_rb_tree rb_bufs_root;
368 struct hammer_volume_ondisk *ondisk;
370 int64_t nblocks; /* note: special calculation for statfs */
371 int64_t buffer_base; /* base offset of buffer 0 */
372 hammer_off_t maxbuf_off; /* Maximum buffer offset */
378 typedef struct hammer_volume *hammer_volume_t;
381 * In-memory buffer (other then volume, super-cluster, or cluster),
382 * representing an on-disk buffer.
384 struct hammer_buffer {
386 RB_ENTRY(hammer_buffer) rb_node;
388 struct hammer_volume *volume;
389 hammer_off_t zone2_offset;
390 hammer_off_t zoneX_offset;
391 struct hammer_node_list clist;
394 typedef struct hammer_buffer *hammer_buffer_t;
397 * In-memory B-Tree node, representing an on-disk B-Tree node.
399 * This is a hang-on structure which is backed by a hammer_buffer,
400 * indexed by a hammer_cluster, and used for fine-grained locking of
401 * B-Tree nodes in order to properly control lock ordering. A hammer_buffer
402 * can contain multiple nodes representing wildly disassociated portions
403 * of the B-Tree so locking cannot be done on a buffer-by-buffer basis.
405 * This structure uses a cluster-relative index to reduce the number
406 * of layers required to access it, and also because all on-disk B-Tree
407 * references are cluster-relative offsets.
410 struct hammer_lock lock; /* node-by-node lock */
411 TAILQ_ENTRY(hammer_node) entry; /* per-buffer linkage */
412 RB_ENTRY(hammer_node) rb_node; /* per-cluster linkage */
413 hammer_off_t node_offset; /* full offset spec */
414 struct hammer_mount *hmp;
415 struct hammer_buffer *buffer; /* backing buffer */
416 hammer_node_ondisk_t ondisk; /* ptr to on-disk structure */
417 struct hammer_node **cache1; /* passive cache(s) */
418 struct hammer_node **cache2;
420 int loading; /* load interlock */
423 #define HAMMER_NODE_DELETED 0x0001
424 #define HAMMER_NODE_FLUSH 0x0002
426 typedef struct hammer_node *hammer_node_t;
429 * List of locked nodes.
431 struct hammer_node_locklist {
432 struct hammer_node_locklist *next;
436 typedef struct hammer_node_locklist *hammer_node_locklist_t;
440 * Common I/O management structure - embedded in in-memory structures
441 * which are backed by filesystem buffers.
443 union hammer_io_structure {
445 struct hammer_volume volume;
446 struct hammer_buffer buffer;
449 typedef union hammer_io_structure *hammer_io_structure_t;
452 * Allocation holes are recorded for a short period of time in an attempt
453 * to use up the space.
456 #define HAMMER_MAX_HOLES 8
460 struct hammer_holes {
461 TAILQ_HEAD(, hammer_hole) list;
465 typedef struct hammer_holes *hammer_holes_t;
468 TAILQ_ENTRY(hammer_hole) entry;
473 typedef struct hammer_hole *hammer_hole_t;
475 #include "hammer_cursor.h"
478 * Internal hammer mount data structure
480 struct hammer_mount {
482 /*struct vnode *rootvp;*/
483 struct hammer_ino_rb_tree rb_inos_root;
484 struct hammer_vol_rb_tree rb_vols_root;
485 struct hammer_nod_rb_tree rb_nods_root;
486 struct hammer_volume *rootvol;
487 struct hammer_base_elm root_btree_beg;
488 struct hammer_base_elm root_btree_end;
489 char *zbuf; /* HAMMER_BUFSIZE bytes worth of all-zeros */
499 u_int check_interrupt;
502 struct hammer_io_list volu_list; /* dirty undo buffers */
503 struct hammer_io_list undo_list; /* dirty undo buffers */
504 struct hammer_io_list data_list; /* dirty data buffers */
505 struct hammer_io_list meta_list; /* dirty meta bufs */
506 struct hammer_io_list lose_list; /* loose buffers */
507 int locked_dirty_count; /* meta/volu count */
508 int io_running_count;
510 hammer_off_t next_tid;
511 u_int32_t namekey_iterator;
512 hammer_off_t zone_limits[HAMMER_MAX_ZONES];
513 struct netexport export;
514 struct hammer_lock sync_lock;
515 struct lock blockmap_lock;
516 struct hammer_holes holes[HAMMER_MAX_ZONES];
517 TAILQ_HEAD(, hammer_inode) flush_list;
520 typedef struct hammer_mount *hammer_mount_t;
522 struct hammer_sync_info {
531 extern struct vop_ops hammer_vnode_vops;
532 extern struct vop_ops hammer_spec_vops;
533 extern struct vop_ops hammer_fifo_vops;
534 extern struct bio_ops hammer_bioops;
536 extern int hammer_debug_general;
537 extern int hammer_debug_locks;
538 extern int hammer_debug_btree;
539 extern int hammer_debug_tid;
540 extern int hammer_debug_recover;
541 extern int hammer_debug_recover_faults;
542 extern int hammer_count_inodes;
543 extern int hammer_count_records;
544 extern int hammer_count_record_datas;
545 extern int hammer_count_volumes;
546 extern int hammer_count_buffers;
547 extern int hammer_count_nodes;
548 extern int hammer_count_dirtybufs;
549 extern int hammer_limit_dirtybufs;
550 extern int64_t hammer_contention_count;
552 int hammer_vop_inactive(struct vop_inactive_args *);
553 int hammer_vop_reclaim(struct vop_reclaim_args *);
554 int hammer_get_vnode(struct hammer_inode *ip, int lktype,
556 struct hammer_inode *hammer_get_inode(hammer_transaction_t trans,
557 struct hammer_node **cache,
558 u_int64_t obj_id, hammer_tid_t asof, int flags,
560 void hammer_put_inode(struct hammer_inode *ip);
561 void hammer_put_inode_ref(struct hammer_inode *ip);
563 int hammer_unload_volume(hammer_volume_t volume, void *data __unused);
564 int hammer_unload_buffer(hammer_buffer_t buffer, void *data __unused);
565 int hammer_install_volume(hammer_mount_t hmp, const char *volname);
567 int hammer_ip_lookup(hammer_cursor_t cursor, hammer_inode_t ip);
568 int hammer_ip_first(hammer_cursor_t cursor, hammer_inode_t ip);
569 int hammer_ip_next(hammer_cursor_t cursor);
570 int hammer_ip_resolve_record_and_data(hammer_cursor_t cursor);
571 int hammer_ip_resolve_data(hammer_cursor_t cursor);
572 int hammer_ip_delete_record(hammer_cursor_t cursor, hammer_tid_t tid);
573 int hammer_delete_at_cursor(hammer_cursor_t cursor, int64_t *stat_bytes);
574 int hammer_ip_check_directory_empty(hammer_transaction_t trans,
576 int hammer_sync_hmp(hammer_mount_t hmp, int waitfor);
579 hammer_alloc_mem_record(hammer_inode_t ip);
580 void hammer_flush_record_done(hammer_record_t record, int error);
581 void hammer_wait_mem_record(hammer_record_t record);
582 void hammer_rel_mem_record(hammer_record_t record);
583 void hammer_cleardep_mem_record(struct hammer_record *record);
585 int hammer_cursor_up(hammer_cursor_t cursor);
586 int hammer_cursor_down(hammer_cursor_t cursor);
587 int hammer_cursor_upgrade(hammer_cursor_t cursor);
588 void hammer_cursor_downgrade(hammer_cursor_t cursor);
589 int hammer_cursor_seek(hammer_cursor_t cursor, hammer_node_t node,
591 void hammer_lock_ex(struct hammer_lock *lock);
592 int hammer_lock_ex_try(struct hammer_lock *lock);
593 void hammer_lock_sh(struct hammer_lock *lock);
594 int hammer_lock_upgrade(struct hammer_lock *lock);
595 void hammer_lock_downgrade(struct hammer_lock *lock);
596 void hammer_unlock(struct hammer_lock *lock);
597 void hammer_ref(struct hammer_lock *lock);
598 void hammer_unref(struct hammer_lock *lock);
600 u_int32_t hammer_to_unix_xid(uuid_t *uuid);
601 void hammer_guid_to_uuid(uuid_t *uuid, u_int32_t guid);
602 void hammer_to_timespec(hammer_tid_t tid, struct timespec *ts);
603 hammer_tid_t hammer_timespec_to_transid(struct timespec *ts);
604 hammer_tid_t hammer_alloc_tid(hammer_transaction_t trans);
605 hammer_tid_t hammer_now_tid(void);
606 hammer_tid_t hammer_str_to_tid(const char *str);
608 enum vtype hammer_get_vnode_type(u_int8_t obj_type);
609 int hammer_get_dtype(u_int8_t obj_type);
610 u_int8_t hammer_get_obj_type(enum vtype vtype);
611 int64_t hammer_directory_namekey(void *name, int len);
613 int hammer_init_cursor(hammer_transaction_t trans, hammer_cursor_t cursor,
614 struct hammer_node **cache);
616 void hammer_done_cursor(hammer_cursor_t cursor);
617 void hammer_mem_done(hammer_cursor_t cursor);
619 int hammer_btree_lookup(hammer_cursor_t cursor);
620 int hammer_btree_first(hammer_cursor_t cursor);
621 int hammer_btree_last(hammer_cursor_t cursor);
622 int hammer_btree_extract(hammer_cursor_t cursor, int flags);
623 int hammer_btree_iterate(hammer_cursor_t cursor);
624 int hammer_btree_iterate_reverse(hammer_cursor_t cursor);
625 int hammer_btree_insert(hammer_cursor_t cursor, hammer_btree_elm_t elm);
626 int hammer_btree_delete(hammer_cursor_t cursor);
627 int hammer_btree_cmp(hammer_base_elm_t key1, hammer_base_elm_t key2);
628 int hammer_btree_chkts(hammer_tid_t ts, hammer_base_elm_t key);
629 int hammer_btree_correct_rhb(hammer_cursor_t cursor, hammer_tid_t tid);
630 int hammer_btree_correct_lhb(hammer_cursor_t cursor, hammer_tid_t tid);
633 int hammer_btree_lock_children(hammer_cursor_t cursor,
634 struct hammer_node_locklist **locklistp);
636 void hammer_print_btree_node(hammer_node_ondisk_t ondisk);
637 void hammer_print_btree_elm(hammer_btree_elm_t elm, u_int8_t type, int i);
639 void *hammer_bread(struct hammer_mount *hmp, hammer_off_t off,
640 int *errorp, struct hammer_buffer **bufferp);
641 void *hammer_bnew(struct hammer_mount *hmp, hammer_off_t off,
642 int *errorp, struct hammer_buffer **bufferp);
644 hammer_volume_t hammer_get_root_volume(hammer_mount_t hmp, int *errorp);
645 int hammer_dowrite(hammer_transaction_t trans, hammer_inode_t ip,
648 hammer_volume_t hammer_get_volume(hammer_mount_t hmp,
649 int32_t vol_no, int *errorp);
650 hammer_buffer_t hammer_get_buffer(hammer_mount_t hmp,
651 hammer_off_t buf_offset, int isnew, int *errorp);
652 void hammer_uncache_buffer(struct hammer_mount *hmp, hammer_off_t off);
654 int hammer_ref_volume(hammer_volume_t volume);
655 int hammer_ref_buffer(hammer_buffer_t buffer);
656 void hammer_flush_buffer_nodes(hammer_buffer_t buffer);
658 void hammer_rel_volume(hammer_volume_t volume, int flush);
659 void hammer_rel_buffer(hammer_buffer_t buffer, int flush);
661 int hammer_vfs_export(struct mount *mp, int op,
662 const struct export_args *export);
663 hammer_node_t hammer_get_node(hammer_mount_t hmp,
664 hammer_off_t node_offset, int *errorp);
665 void hammer_ref_node(hammer_node_t node);
666 hammer_node_t hammer_ref_node_safe(struct hammer_mount *hmp,
667 struct hammer_node **cache, int *errorp);
668 void hammer_rel_node(hammer_node_t node);
669 void hammer_delete_node(hammer_transaction_t trans,
671 void hammer_cache_node(hammer_node_t node,
672 struct hammer_node **cache);
673 void hammer_uncache_node(struct hammer_node **cache);
674 void hammer_flush_node(hammer_node_t node);
676 void hammer_dup_buffer(struct hammer_buffer **bufferp,
677 struct hammer_buffer *buffer);
678 hammer_node_t hammer_alloc_btree(hammer_transaction_t trans, int *errorp);
679 void *hammer_alloc_record(hammer_transaction_t trans,
680 hammer_off_t *rec_offp, u_int16_t rec_type,
681 struct hammer_buffer **rec_bufferp,
682 int32_t data_len, void **datap,
683 struct hammer_buffer **data_bufferp, int *errorp);
684 void *hammer_alloc_data(hammer_transaction_t trans, int32_t data_len,
685 hammer_off_t *data_offsetp,
686 struct hammer_buffer **data_bufferp, int *errorp);
688 int hammer_generate_undo(hammer_transaction_t trans, hammer_io_t io,
689 hammer_off_t zone1_offset, void *base, int len);
691 void hammer_put_volume(struct hammer_volume *volume, int flush);
692 void hammer_put_buffer(struct hammer_buffer *buffer, int flush);
694 hammer_off_t hammer_freemap_alloc(hammer_transaction_t trans,
695 hammer_off_t owner, int *errorp);
696 void hammer_freemap_free(hammer_transaction_t trans, hammer_off_t phys_offset,
697 hammer_off_t owner, int *errorp);
698 hammer_off_t hammer_blockmap_alloc(hammer_transaction_t trans, int zone,
699 int bytes, int *errorp);
700 void hammer_blockmap_free(hammer_transaction_t trans,
701 hammer_off_t bmap_off, int bytes);
702 int hammer_blockmap_getfree(hammer_mount_t hmp, hammer_off_t bmap_off,
703 int *curp, int *errorp);
704 hammer_off_t hammer_blockmap_lookup(hammer_mount_t hmp, hammer_off_t bmap_off,
706 hammer_off_t hammer_undo_lookup(hammer_mount_t hmp, hammer_off_t bmap_off,
709 void hammer_start_transaction(struct hammer_transaction *trans,
710 struct hammer_mount *hmp);
711 void hammer_simple_transaction(struct hammer_transaction *trans,
712 struct hammer_mount *hmp);
713 void hammer_start_transaction_fls(struct hammer_transaction *trans,
714 struct hammer_mount *hmp);
715 void hammer_done_transaction(struct hammer_transaction *trans);
717 void hammer_modify_inode(struct hammer_transaction *trans,
718 hammer_inode_t ip, int flags);
719 void hammer_flush_inode(hammer_inode_t ip, int flags);
720 void hammer_flush_inode_done(hammer_inode_t ip);
721 void hammer_wait_inode(hammer_inode_t ip);
723 int hammer_create_inode(struct hammer_transaction *trans, struct vattr *vap,
724 struct ucred *cred, struct hammer_inode *dip,
725 struct hammer_inode **ipp);
726 void hammer_finalize_inode(hammer_transaction_t trans, hammer_inode_t ip,
728 void hammer_rel_inode(hammer_inode_t ip, int flush);
729 int hammer_sync_inode(hammer_inode_t ip, int handle_delete);
731 int hammer_ip_add_directory(struct hammer_transaction *trans,
732 hammer_inode_t dip, struct namecache *ncp,
734 int hammer_ip_del_directory(struct hammer_transaction *trans,
735 hammer_cursor_t cursor, hammer_inode_t dip,
737 int hammer_ip_add_record(struct hammer_transaction *trans,
738 hammer_record_t record);
739 int hammer_ip_delete_range(struct hammer_transaction *trans,
740 hammer_inode_t ip, int64_t ran_beg, int64_t ran_end);
741 int hammer_ip_delete_range_all(struct hammer_transaction *trans,
743 int hammer_ip_sync_data(struct hammer_transaction *trans,
744 hammer_inode_t ip, int64_t offset,
745 void *data, int bytes);
746 int hammer_ip_sync_record(hammer_transaction_t trans, hammer_record_t rec);
748 int hammer_ioctl(hammer_inode_t ip, u_long com, caddr_t data, int fflag,
751 void hammer_io_init(hammer_io_t io, hammer_mount_t hmp,
752 enum hammer_io_type type);
753 void hammer_io_reinit(hammer_io_t io, enum hammer_io_type type);
754 int hammer_io_read(struct vnode *devvp, struct hammer_io *io);
755 int hammer_io_new(struct vnode *devvp, struct hammer_io *io);
756 void hammer_io_release(struct hammer_io *io);
757 void hammer_io_flush(struct hammer_io *io);
758 int hammer_io_checkflush(hammer_io_t io);
759 void hammer_io_clear_modify(struct hammer_io *io);
760 void hammer_io_waitdep(struct hammer_io *io);
762 void hammer_modify_volume(hammer_transaction_t trans, hammer_volume_t volume,
763 void *base, int len);
764 void hammer_modify_buffer(hammer_transaction_t trans, hammer_buffer_t buffer,
765 void *base, int len);
766 void hammer_modify_volume_done(hammer_volume_t volume);
767 void hammer_modify_buffer_done(hammer_buffer_t buffer);
769 int hammer_ioc_reblock(hammer_transaction_t trans, hammer_inode_t ip,
770 struct hammer_ioc_reblock *reblock);
772 void hammer_init_holes(hammer_mount_t hmp, hammer_holes_t holes);
773 void hammer_free_holes(hammer_mount_t hmp, hammer_holes_t holes);
774 int hammer_signal_check(hammer_mount_t hmp);
776 void hammer_flusher_create(hammer_mount_t hmp);
777 void hammer_flusher_destroy(hammer_mount_t hmp);
778 void hammer_flusher_sync(hammer_mount_t hmp);
779 void hammer_flusher_async(hammer_mount_t hmp);
781 int hammer_recover(hammer_mount_t hmp, hammer_volume_t rootvol);
786 hammer_modify_node_noundo(hammer_transaction_t trans, hammer_node_t node)
788 hammer_modify_buffer(trans, node->buffer, NULL, 0);
792 hammer_modify_node_all(hammer_transaction_t trans, struct hammer_node *node)
794 hammer_modify_buffer(trans, node->buffer,
795 node->ondisk, sizeof(*node->ondisk));
799 hammer_modify_node(hammer_transaction_t trans, hammer_node_t node,
802 KKASSERT((char *)base >= (char *)node->ondisk &&
803 (char *)base + len <=
804 (char *)node->ondisk + sizeof(*node->ondisk));
805 hammer_modify_buffer(trans, node->buffer, base, len);
809 hammer_modify_node_done(hammer_node_t node)
811 hammer_modify_buffer_done(node->buffer);
815 hammer_modify_record(hammer_transaction_t trans, hammer_buffer_t buffer,
818 KKASSERT((char *)base >= (char *)buffer->ondisk &&
819 (char *)base + len <= (char *)buffer->ondisk + HAMMER_BUFSIZE);
820 hammer_modify_buffer(trans, buffer, base, len);
824 hammer_modify_record_done(hammer_buffer_t buffer)
826 hammer_modify_buffer_done(buffer);