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.46 2008/03/30 21:33:42 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;
80 * HAMMER Transaction tracking
82 struct hammer_transaction {
83 struct hammer_mount *hmp;
85 struct hammer_volume *rootvol;
86 /* TAILQ_HEAD(, hammer_io) recycle_list;*/
89 typedef struct hammer_transaction *hammer_transaction_t;
95 int refs; /* active references delay writes */
96 int lockcount; /* lock count for exclusive/shared access */
98 struct thread *locktd;
102 hammer_islocked(struct hammer_lock *lock)
104 return(lock->lockcount != 0);
108 hammer_isactive(struct hammer_lock *lock)
110 return(lock->refs != 0);
114 hammer_islastref(struct hammer_lock *lock)
116 return(lock->refs == 1);
120 * Return if we specifically own the lock exclusively.
123 hammer_lock_excl_owned(struct hammer_lock *lock, thread_t td)
125 if (lock->lockcount > 0 && lock->locktd == td)
131 * Structure used to represent an inode in-memory.
133 * The record and data associated with an inode may be out of sync with
134 * the disk (xDIRTY flags), or not even on the disk at all (ONDISK flag
137 * An inode may also hold a cache of unsynchronized records, used for
138 * database and directories only. Unsynchronized regular file data is
139 * stored in the buffer cache.
141 * NOTE: A file which is created and destroyed within the initial
142 * synchronization period can wind up not doing any disk I/O at all.
144 * Finally, an inode may cache numerous disk-referencing B-Tree cursors.
146 struct hammer_ino_rb_tree;
148 RB_HEAD(hammer_ino_rb_tree, hammer_inode);
149 RB_PROTOTYPEX(hammer_ino_rb_tree, INFO, hammer_inode, rb_node,
150 hammer_ino_rb_compare, hammer_inode_info_t);
152 struct hammer_rec_rb_tree;
153 struct hammer_record;
154 RB_HEAD(hammer_rec_rb_tree, hammer_record);
155 RB_PROTOTYPEX(hammer_rec_rb_tree, INFO, hammer_record, rb_node,
156 hammer_rec_rb_compare, hammer_base_elm_t);
158 TAILQ_HEAD(hammer_node_list, hammer_node);
160 struct hammer_inode {
161 RB_ENTRY(hammer_inode) rb_node;
162 u_int64_t obj_id; /* (key) object identifier */
163 hammer_tid_t obj_asof; /* (key) snapshot transid or 0 */
164 hammer_tid_t last_tid; /* last modified tid (for fsync) */
165 hammer_tid_t sync_tid; /* last inode tid synced to disk */
166 struct hammer_mount *hmp;
168 int cursor_ip_refs; /* sanity */
170 struct lockf advlock;
171 struct hammer_lock lock;
172 struct hammer_inode_record ino_rec;
173 struct hammer_inode_data ino_data;
174 struct hammer_rec_rb_tree rec_tree; /* red-black record tree */
175 struct hammer_node *cache[2]; /* search initiate cache */
178 typedef struct hammer_inode *hammer_inode_t;
180 #define VTOI(vp) ((struct hammer_inode *)(vp)->v_data)
182 #define HAMMER_INODE_DDIRTY 0x0001 /* in-memory ino_data is dirty */
183 #define HAMMER_INODE_RDIRTY 0x0002 /* in-memory ino_rec is dirty */
184 #define HAMMER_INODE_ITIMES 0x0004 /* in-memory mtime/atime modified */
185 #define HAMMER_INODE_XDIRTY 0x0008 /* in-memory records present */
186 #define HAMMER_INODE_ONDISK 0x0010 /* inode is on-disk (else not yet) */
187 #define HAMMER_INODE_FLUSH 0x0020 /* flush on last ref */
188 #define HAMMER_INODE_DELETED 0x0080 /* inode ready for deletion */
189 #define HAMMER_INODE_DELONDISK 0x0100 /* delete synchronized to disk */
190 #define HAMMER_INODE_RO 0x0200 /* read-only (because of as-of) */
191 #define HAMMER_INODE_GONE 0x0400 /* delete flushed out */
192 #define HAMMER_INODE_DONDISK 0x0800 /* data records may be on disk */
193 #define HAMMER_INODE_BUFS 0x1000 /* dirty high level bps present */
194 #define HAMMER_INODE_TIDLOCKED 0x2000 /* tid locked until inode synced */
196 #define HAMMER_INODE_MODMASK (HAMMER_INODE_DDIRTY|HAMMER_INODE_RDIRTY| \
197 HAMMER_INODE_XDIRTY|HAMMER_INODE_BUFS| \
198 HAMMER_INODE_ITIMES|HAMMER_INODE_DELETED)
200 #define HAMMER_MAX_INODE_CURSORS 4
203 * Structure used to represent an unsynchronized record in-memory. This
204 * structure is orgranized in a per-inode RB-tree. If the inode is not
205 * on disk then neither are any records and the in-memory record tree
206 * represents the entire contents of the inode. If the inode is on disk
207 * then the on-disk B-Tree is scanned in parallel with the in-memory
208 * RB-Tree to synthesize the current state of the file.
210 * Only current (delete_tid == 0) unsynchronized records are kept in-memory.
212 * blocked is the count of the number of cursors (ip_first/ip_next) blocked
213 * on the record waiting for a synchronization to complete.
215 struct hammer_record {
216 RB_ENTRY(hammer_record) rb_node;
217 struct hammer_lock lock;
218 struct hammer_inode *ip;
219 union hammer_record_ondisk rec;
220 union hammer_data_ondisk *data;
225 typedef struct hammer_record *hammer_record_t;
227 #define HAMMER_RECF_ALLOCDATA 0x0001
228 #define HAMMER_RECF_ONRBTREE 0x0002
229 #define HAMMER_RECF_DELETED 0x0004
230 #define HAMMER_RECF_INBAND 0x0008
231 #define HAMMER_RECF_SYNCING 0x0010
232 #define HAMMER_RECF_WANTED 0x0020
235 * In-memory structures representing on-disk structures.
237 struct hammer_volume;
238 struct hammer_buffer;
240 RB_HEAD(hammer_vol_rb_tree, hammer_volume);
241 RB_HEAD(hammer_buf_rb_tree, hammer_buffer);
242 RB_HEAD(hammer_nod_rb_tree, hammer_node);
244 RB_PROTOTYPE2(hammer_vol_rb_tree, hammer_volume, rb_node,
245 hammer_vol_rb_compare, int32_t);
246 RB_PROTOTYPE2(hammer_buf_rb_tree, hammer_buffer, rb_node,
247 hammer_buf_rb_compare, hammer_off_t);
248 RB_PROTOTYPE2(hammer_nod_rb_tree, hammer_node, rb_node,
249 hammer_nod_rb_compare, hammer_off_t);
252 * IO management - embedded at the head of various in-memory structures
254 enum hammer_io_type { HAMMER_STRUCTURE_VOLUME,
255 HAMMER_STRUCTURE_BUFFER };
257 union hammer_io_structure;
261 LIST_ENTRY(worklist) node;
264 /*TAILQ_HEAD(hammer_dep_list, hammer_dep);*/
267 struct worklist worklist;
268 struct hammer_lock lock;
269 enum hammer_io_type type;
272 int loading; /* loading/unloading interlock */
273 u_int modified : 1; /* bp's data was modified */
274 u_int released : 1; /* bp released (w/ B_LOCKED set) */
275 u_int running : 1; /* bp write IO in progress */
276 u_int waiting : 1; /* someone is waiting on us */
277 u_int validated : 1; /* ondisk has been validated */
278 u_int flush : 1; /* flush on last release */
279 u_int waitdep : 1; /* flush waits for dependancies */
282 typedef struct hammer_io *hammer_io_t;
285 * In-memory volume representing on-disk buffer
287 struct hammer_volume {
289 RB_ENTRY(hammer_volume) rb_node;
290 struct hammer_buf_rb_tree rb_bufs_root;
291 struct hammer_volume_ondisk *ondisk;
293 int64_t nblocks; /* note: special calculation for statfs */
294 int64_t buffer_base; /* base offset of buffer 0 */
295 hammer_off_t maxbuf_off; /* Maximum buffer offset */
298 struct hammer_mount *hmp;
302 typedef struct hammer_volume *hammer_volume_t;
305 * In-memory buffer (other then volume, super-cluster, or cluster),
306 * representing an on-disk buffer.
308 struct hammer_buffer {
310 RB_ENTRY(hammer_buffer) rb_node;
312 struct hammer_volume *volume;
313 hammer_off_t zone2_offset;
314 hammer_off_t zoneX_offset;
315 struct hammer_node_list clist;
318 typedef struct hammer_buffer *hammer_buffer_t;
321 * In-memory B-Tree node, representing an on-disk B-Tree node.
323 * This is a hang-on structure which is backed by a hammer_buffer,
324 * indexed by a hammer_cluster, and used for fine-grained locking of
325 * B-Tree nodes in order to properly control lock ordering. A hammer_buffer
326 * can contain multiple nodes representing wildly disassociated portions
327 * of the B-Tree so locking cannot be done on a buffer-by-buffer basis.
329 * This structure uses a cluster-relative index to reduce the number
330 * of layers required to access it, and also because all on-disk B-Tree
331 * references are cluster-relative offsets.
334 struct hammer_lock lock; /* node-by-node lock */
335 TAILQ_ENTRY(hammer_node) entry; /* per-buffer linkage */
336 RB_ENTRY(hammer_node) rb_node; /* per-cluster linkage */
337 hammer_off_t node_offset; /* full offset spec */
338 struct hammer_mount *hmp;
339 struct hammer_buffer *buffer; /* backing buffer */
340 hammer_node_ondisk_t ondisk; /* ptr to on-disk structure */
341 struct hammer_node **cache1; /* passive cache(s) */
342 struct hammer_node **cache2;
344 int loading; /* load interlock */
347 #define HAMMER_NODE_DELETED 0x0001
348 #define HAMMER_NODE_FLUSH 0x0002
350 typedef struct hammer_node *hammer_node_t;
353 * List of locked nodes.
355 struct hammer_node_locklist {
356 struct hammer_node_locklist *next;
360 typedef struct hammer_node_locklist *hammer_node_locklist_t;
364 * Common I/O management structure - embedded in in-memory structures
365 * which are backed by filesystem buffers.
367 union hammer_io_structure {
369 struct hammer_volume volume;
370 struct hammer_buffer buffer;
373 typedef union hammer_io_structure *hammer_io_structure_t;
376 * Allocation holes are recorded for a short period of time in an attempt
377 * to use up the space.
380 #define HAMMER_MAX_HOLES 8
384 struct hammer_holes {
385 TAILQ_HEAD(, hammer_hole) list;
389 typedef struct hammer_holes *hammer_holes_t;
392 TAILQ_ENTRY(hammer_hole) entry;
397 typedef struct hammer_hole *hammer_hole_t;
399 #include "hammer_cursor.h"
402 * Internal hammer mount data structure
404 struct hammer_mount {
406 /*struct vnode *rootvp;*/
407 struct hammer_ino_rb_tree rb_inos_root;
408 struct hammer_vol_rb_tree rb_vols_root;
409 struct hammer_nod_rb_tree rb_nods_root;
410 struct hammer_volume *rootvol;
411 struct hammer_base_elm root_btree_beg;
412 struct hammer_base_elm root_btree_end;
413 char *zbuf; /* HAMMER_BUFSIZE bytes worth of all-zeros */
418 u_int check_interrupt;
422 u_int32_t namekey_iterator;
423 hammer_off_t zone_limits[HAMMER_MAX_ZONES];
424 struct netexport export;
425 struct lock blockmap_lock;
426 struct hammer_holes holes[HAMMER_MAX_ZONES];
429 typedef struct hammer_mount *hammer_mount_t;
431 struct hammer_sync_info {
440 extern struct vop_ops hammer_vnode_vops;
441 extern struct vop_ops hammer_spec_vops;
442 extern struct vop_ops hammer_fifo_vops;
443 extern struct bio_ops hammer_bioops;
445 extern int hammer_debug_general;
446 extern int hammer_debug_locks;
447 extern int hammer_debug_btree;
448 extern int hammer_debug_tid;
449 extern int hammer_debug_recover;
450 extern int hammer_debug_recover_faults;
451 extern int hammer_count_inodes;
452 extern int hammer_count_records;
453 extern int hammer_count_record_datas;
454 extern int hammer_count_volumes;
455 extern int hammer_count_buffers;
456 extern int hammer_count_nodes;
457 extern int64_t hammer_contention_count;
459 int hammer_vop_inactive(struct vop_inactive_args *);
460 int hammer_vop_reclaim(struct vop_reclaim_args *);
461 int hammer_get_vnode(struct hammer_inode *ip, int lktype,
463 struct hammer_inode *hammer_get_inode(hammer_transaction_t trans,
464 struct hammer_node **cache,
465 u_int64_t obj_id, hammer_tid_t asof, int flags,
467 void hammer_put_inode(struct hammer_inode *ip);
468 void hammer_put_inode_ref(struct hammer_inode *ip);
470 int hammer_unload_inode(hammer_inode_t ip, void *data);
471 int hammer_unload_volume(hammer_volume_t volume, void *data __unused);
472 int hammer_unload_buffer(hammer_buffer_t buffer, void *data __unused);
473 int hammer_install_volume(hammer_mount_t hmp, const char *volname);
475 int hammer_ip_lookup(hammer_cursor_t cursor, hammer_inode_t ip);
476 int hammer_ip_first(hammer_cursor_t cursor, hammer_inode_t ip);
477 int hammer_ip_next(hammer_cursor_t cursor);
478 int hammer_ip_resolve_record_and_data(hammer_cursor_t cursor);
479 int hammer_ip_resolve_data(hammer_cursor_t cursor);
480 int hammer_ip_delete_record(hammer_cursor_t cursor, hammer_tid_t tid);
481 int hammer_delete_at_cursor(hammer_cursor_t cursor, int64_t *stat_bytes);
482 int hammer_ip_check_directory_empty(hammer_transaction_t trans,
484 int hammer_sync_hmp(hammer_mount_t hmp, int waitfor);
485 int hammer_sync_volume(hammer_volume_t volume, void *data);
486 int hammer_sync_buffer(hammer_buffer_t buffer, void *data);
489 hammer_alloc_mem_record(hammer_inode_t ip);
490 void hammer_rel_mem_record(hammer_record_t record);
492 int hammer_cursor_up(hammer_cursor_t cursor);
493 int hammer_cursor_down(hammer_cursor_t cursor);
494 int hammer_cursor_upgrade(hammer_cursor_t cursor);
495 void hammer_cursor_downgrade(hammer_cursor_t cursor);
496 int hammer_cursor_seek(hammer_cursor_t cursor, hammer_node_t node,
498 void hammer_lock_ex(struct hammer_lock *lock);
499 int hammer_lock_ex_try(struct hammer_lock *lock);
500 void hammer_lock_sh(struct hammer_lock *lock);
501 int hammer_lock_upgrade(struct hammer_lock *lock);
502 void hammer_lock_downgrade(struct hammer_lock *lock);
503 void hammer_unlock(struct hammer_lock *lock);
504 void hammer_ref(struct hammer_lock *lock);
505 void hammer_unref(struct hammer_lock *lock);
507 u_int32_t hammer_to_unix_xid(uuid_t *uuid);
508 void hammer_guid_to_uuid(uuid_t *uuid, u_int32_t guid);
509 void hammer_to_timespec(hammer_tid_t tid, struct timespec *ts);
510 hammer_tid_t hammer_timespec_to_transid(struct timespec *ts);
511 hammer_tid_t hammer_alloc_tid(hammer_transaction_t trans);
512 hammer_tid_t hammer_now_tid(void);
513 hammer_tid_t hammer_str_to_tid(const char *str);
515 enum vtype hammer_get_vnode_type(u_int8_t obj_type);
516 int hammer_get_dtype(u_int8_t obj_type);
517 u_int8_t hammer_get_obj_type(enum vtype vtype);
518 int64_t hammer_directory_namekey(void *name, int len);
520 int hammer_init_cursor(hammer_transaction_t trans, hammer_cursor_t cursor,
521 struct hammer_node **cache);
523 void hammer_done_cursor(hammer_cursor_t cursor);
524 void hammer_mem_done(hammer_cursor_t cursor);
526 int hammer_btree_lookup(hammer_cursor_t cursor);
527 int hammer_btree_first(hammer_cursor_t cursor);
528 int hammer_btree_last(hammer_cursor_t cursor);
529 int hammer_btree_extract(hammer_cursor_t cursor, int flags);
530 int hammer_btree_iterate(hammer_cursor_t cursor);
531 int hammer_btree_iterate_reverse(hammer_cursor_t cursor);
532 int hammer_btree_insert(hammer_cursor_t cursor, hammer_btree_elm_t elm);
533 int hammer_btree_delete(hammer_cursor_t cursor);
534 int hammer_btree_cmp(hammer_base_elm_t key1, hammer_base_elm_t key2);
535 int hammer_btree_chkts(hammer_tid_t ts, hammer_base_elm_t key);
536 int hammer_btree_correct_rhb(hammer_cursor_t cursor, hammer_tid_t tid);
537 int hammer_btree_correct_lhb(hammer_cursor_t cursor, hammer_tid_t tid);
540 int hammer_btree_lock_children(hammer_cursor_t cursor,
541 struct hammer_node_locklist **locklistp);
543 void hammer_print_btree_node(hammer_node_ondisk_t ondisk);
544 void hammer_print_btree_elm(hammer_btree_elm_t elm, u_int8_t type, int i);
546 void *hammer_bread(struct hammer_mount *hmp, hammer_off_t off,
547 int *errorp, struct hammer_buffer **bufferp);
548 void *hammer_bnew(struct hammer_mount *hmp, hammer_off_t off,
549 int *errorp, struct hammer_buffer **bufferp);
551 hammer_volume_t hammer_get_root_volume(hammer_mount_t hmp, int *errorp);
553 hammer_volume_t hammer_get_volume(hammer_mount_t hmp,
554 int32_t vol_no, int *errorp);
555 hammer_buffer_t hammer_get_buffer(hammer_mount_t hmp,
556 hammer_off_t buf_offset, int isnew, int *errorp);
557 void hammer_uncache_buffer(struct hammer_mount *hmp, hammer_off_t off);
559 int hammer_ref_volume(hammer_volume_t volume);
560 int hammer_ref_buffer(hammer_buffer_t buffer);
561 void hammer_flush_buffer_nodes(hammer_buffer_t buffer);
563 void hammer_rel_volume(hammer_volume_t volume, int flush);
564 void hammer_rel_buffer(hammer_buffer_t buffer, int flush);
566 int hammer_vfs_export(struct mount *mp, int op,
567 const struct export_args *export);
568 hammer_node_t hammer_get_node(hammer_mount_t hmp,
569 hammer_off_t node_offset, int *errorp);
570 void hammer_ref_node(hammer_node_t node);
571 hammer_node_t hammer_ref_node_safe(struct hammer_mount *hmp,
572 struct hammer_node **cache, int *errorp);
573 void hammer_rel_node(hammer_node_t node);
574 void hammer_delete_node(hammer_transaction_t trans,
576 void hammer_cache_node(hammer_node_t node,
577 struct hammer_node **cache);
578 void hammer_uncache_node(struct hammer_node **cache);
579 void hammer_flush_node(hammer_node_t node);
581 void hammer_dup_buffer(struct hammer_buffer **bufferp,
582 struct hammer_buffer *buffer);
583 hammer_node_t hammer_alloc_btree(hammer_transaction_t trans, int *errorp);
584 void *hammer_alloc_record(hammer_transaction_t trans,
585 hammer_off_t *rec_offp, u_int16_t rec_type,
586 struct hammer_buffer **rec_bufferp,
587 int32_t data_len, void **datap,
588 struct hammer_buffer **data_bufferp, int *errorp);
589 void *hammer_alloc_data(hammer_transaction_t trans, int32_t data_len,
590 hammer_off_t *data_offsetp,
591 struct hammer_buffer **data_bufferp, int *errorp);
593 int hammer_generate_undo(hammer_transaction_t trans, hammer_off_t zone1_offset,
594 void *base, int len);
596 void hammer_put_volume(struct hammer_volume *volume, int flush);
597 void hammer_put_buffer(struct hammer_buffer *buffer, int flush);
599 hammer_off_t hammer_freemap_alloc(hammer_transaction_t trans,
600 hammer_off_t owner, int *errorp);
601 void hammer_freemap_free(hammer_transaction_t trans, hammer_off_t phys_offset,
602 hammer_off_t owner, int *errorp);
603 hammer_off_t hammer_blockmap_alloc(hammer_transaction_t trans, int zone,
604 int bytes, int *errorp);
605 void hammer_blockmap_free(hammer_transaction_t trans,
606 hammer_off_t bmap_off, int bytes);
607 int hammer_blockmap_getfree(hammer_mount_t hmp, hammer_off_t bmap_off,
608 int *curp, int *errorp);
609 hammer_off_t hammer_blockmap_lookup(hammer_mount_t hmp, hammer_off_t bmap_off,
611 hammer_off_t hammer_undo_lookup(hammer_mount_t hmp, hammer_off_t bmap_off,
614 void hammer_start_transaction(struct hammer_transaction *trans,
615 struct hammer_mount *hmp);
616 void hammer_simple_transaction(struct hammer_transaction *trans,
617 struct hammer_mount *hmp);
618 void hammer_start_transaction_tid(struct hammer_transaction *trans,
619 struct hammer_mount *hmp, hammer_tid_t tid);
620 void hammer_commit_transaction(struct hammer_transaction *trans);
621 void hammer_abort_transaction(struct hammer_transaction *trans);
623 void hammer_modify_inode(struct hammer_transaction *trans,
624 hammer_inode_t ip, int flags);
625 int hammer_create_inode(struct hammer_transaction *trans, struct vattr *vap,
626 struct ucred *cred, struct hammer_inode *dip,
627 struct hammer_inode **ipp);
628 void hammer_rel_inode(hammer_inode_t ip, int flush);
629 int hammer_sync_inode(hammer_inode_t ip, int waitfor, int handle_delete);
631 int hammer_ip_add_directory(struct hammer_transaction *trans,
632 hammer_inode_t dip, struct namecache *ncp,
634 int hammer_ip_del_directory(struct hammer_transaction *trans,
635 hammer_cursor_t cursor, hammer_inode_t dip,
637 int hammer_ip_add_record(struct hammer_transaction *trans,
638 hammer_record_t record);
639 int hammer_ip_delete_range(struct hammer_transaction *trans,
640 hammer_inode_t ip, int64_t ran_beg, int64_t ran_end);
641 int hammer_ip_delete_range_all(struct hammer_transaction *trans,
643 int hammer_ip_sync_data(struct hammer_transaction *trans,
644 hammer_inode_t ip, int64_t offset,
645 void *data, int bytes);
646 int hammer_ip_sync_record(hammer_transaction_t trans, hammer_record_t rec);
648 int hammer_ioctl(hammer_inode_t ip, u_long com, caddr_t data, int fflag,
651 void hammer_io_init(hammer_io_t io, enum hammer_io_type type);
652 int hammer_io_read(struct vnode *devvp, struct hammer_io *io);
653 int hammer_io_new(struct vnode *devvp, struct hammer_io *io);
654 void hammer_io_release(struct hammer_io *io);
655 void hammer_io_flush(struct hammer_io *io);
656 int hammer_io_checkflush(hammer_io_t io);
657 void hammer_io_clear_modify(struct hammer_io *io);
658 void hammer_io_waitdep(struct hammer_io *io);
660 void hammer_modify_volume(hammer_transaction_t trans, hammer_volume_t volume,
661 void *base, int len);
662 void hammer_modify_buffer(hammer_transaction_t trans, hammer_buffer_t buffer,
663 void *base, int len);
665 int hammer_ioc_reblock(hammer_transaction_t trans, hammer_inode_t ip,
666 struct hammer_ioc_reblock *reblock);
668 void hammer_init_holes(hammer_mount_t hmp, hammer_holes_t holes);
669 void hammer_free_holes(hammer_mount_t hmp, hammer_holes_t holes);
670 int hammer_signal_check(hammer_mount_t hmp);
675 hammer_modify_node_noundo(hammer_transaction_t trans, hammer_node_t node)
677 hammer_modify_buffer(trans, node->buffer, NULL, 0);
681 hammer_modify_node_all(hammer_transaction_t trans, struct hammer_node *node)
683 hammer_modify_buffer(trans, node->buffer,
684 node->ondisk, sizeof(*node->ondisk));
688 hammer_modify_node(hammer_transaction_t trans, hammer_node_t node,
691 KKASSERT((char *)base >= (char *)node->ondisk &&
692 (char *)base + len <=
693 (char *)node->ondisk + sizeof(*node->ondisk));
694 hammer_modify_buffer(trans, node->buffer, base, len);
698 hammer_modify_record(hammer_transaction_t trans, hammer_buffer_t buffer,
701 KKASSERT((char *)base >= (char *)buffer->ondisk &&
702 (char *)base + len <= (char *)buffer->ondisk + HAMMER_BUFSIZE);
703 hammer_modify_buffer(trans, buffer, base, len);