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.42 2008/03/20 06:08:40 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 * This inline is specifically optimized for the case where the caller
121 * owns the lock, but wants to know what kind of lock he owns. A
122 * negative value indicates a shared lock, a positive value indicates
126 hammer_lock_held(struct hammer_lock *lock)
128 return(lock->lockcount);
132 * Structure used to represent an inode in-memory.
134 * The record and data associated with an inode may be out of sync with
135 * the disk (xDIRTY flags), or not even on the disk at all (ONDISK flag
138 * An inode may also hold a cache of unsynchronized records, used for
139 * database and directories only. Unsynchronized regular file data is
140 * stored in the buffer cache.
142 * NOTE: A file which is created and destroyed within the initial
143 * synchronization period can wind up not doing any disk I/O at all.
145 * Finally, an inode may cache numerous disk-referencing B-Tree cursors.
147 struct hammer_ino_rb_tree;
149 RB_HEAD(hammer_ino_rb_tree, hammer_inode);
150 RB_PROTOTYPEX(hammer_ino_rb_tree, INFO, hammer_inode, rb_node,
151 hammer_ino_rb_compare, hammer_inode_info_t);
153 struct hammer_rec_rb_tree;
154 struct hammer_record;
155 RB_HEAD(hammer_rec_rb_tree, hammer_record);
156 RB_PROTOTYPEX(hammer_rec_rb_tree, INFO, hammer_record, rb_node,
157 hammer_rec_rb_compare, hammer_base_elm_t);
159 TAILQ_HEAD(hammer_node_list, hammer_node);
161 struct hammer_inode {
162 RB_ENTRY(hammer_inode) rb_node;
163 u_int64_t obj_id; /* (key) object identifier */
164 hammer_tid_t obj_asof; /* (key) snapshot transid or 0 */
165 hammer_tid_t last_tid; /* last modified tid (for fsync) */
166 hammer_tid_t sync_tid; /* last inode tid synced to disk */
167 struct hammer_mount *hmp;
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_io_list, hammer_io);
267 struct worklist worklist;
268 struct hammer_lock lock;
269 enum hammer_io_type type;
272 TAILQ_ENTRY(hammer_io) entry; /* based on modified flag */
273 struct hammer_io_list *entry_list;
274 struct hammer_io_list deplist;
275 u_int modified : 1; /* bp's data was modified */
276 u_int released : 1; /* bp released (w/ B_LOCKED set) */
277 u_int running : 1; /* bp write IO in progress */
278 u_int waiting : 1; /* someone is waiting on us */
279 u_int loading : 1; /* ondisk is loading */
280 u_int validated : 1; /* ondisk has been validated */
283 typedef struct hammer_io *hammer_io_t;
286 * In-memory volume representing on-disk buffer
288 struct hammer_volume {
290 RB_ENTRY(hammer_volume) rb_node;
291 struct hammer_buf_rb_tree rb_bufs_root;
292 struct hammer_volume_ondisk *ondisk;
294 int64_t nblocks; /* note: special calculation for statfs */
295 int64_t buffer_base; /* base offset of buffer 0 */
296 hammer_off_t maxbuf_off; /* Maximum buffer offset */
299 struct hammer_mount *hmp;
303 typedef struct hammer_volume *hammer_volume_t;
306 * In-memory buffer (other then volume, super-cluster, or cluster),
307 * representing an on-disk buffer.
309 struct hammer_buffer {
311 RB_ENTRY(hammer_buffer) rb_node;
313 struct hammer_volume *volume;
314 hammer_off_t zone2_offset;
315 hammer_off_t zoneX_offset;
316 struct hammer_node_list clist;
319 typedef struct hammer_buffer *hammer_buffer_t;
322 * In-memory B-Tree node, representing an on-disk B-Tree node.
324 * This is a hang-on structure which is backed by a hammer_buffer,
325 * indexed by a hammer_cluster, and used for fine-grained locking of
326 * B-Tree nodes in order to properly control lock ordering. A hammer_buffer
327 * can contain multiple nodes representing wildly disassociated portions
328 * of the B-Tree so locking cannot be done on a buffer-by-buffer basis.
330 * This structure uses a cluster-relative index to reduce the number
331 * of layers required to access it, and also because all on-disk B-Tree
332 * references are cluster-relative offsets.
335 struct hammer_lock lock; /* node-by-node lock */
336 TAILQ_ENTRY(hammer_node) entry; /* per-buffer linkage */
337 RB_ENTRY(hammer_node) rb_node; /* per-cluster linkage */
338 hammer_off_t node_offset; /* full offset spec */
339 struct hammer_mount *hmp;
340 struct hammer_buffer *buffer; /* backing buffer */
341 hammer_node_ondisk_t ondisk; /* ptr to on-disk structure */
342 struct hammer_node **cache1; /* passive cache(s) */
343 struct hammer_node **cache2;
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_btree;
447 extern int hammer_debug_tid;
448 extern int hammer_debug_recover;
449 extern int hammer_debug_recover_faults;
450 extern int hammer_count_inodes;
451 extern int hammer_count_records;
452 extern int hammer_count_record_datas;
453 extern int hammer_count_volumes;
454 extern int hammer_count_buffers;
455 extern int hammer_count_nodes;
457 int hammer_vop_inactive(struct vop_inactive_args *);
458 int hammer_vop_reclaim(struct vop_reclaim_args *);
459 int hammer_get_vnode(struct hammer_inode *ip, int lktype,
461 struct hammer_inode *hammer_get_inode(hammer_transaction_t trans,
462 struct hammer_node **cache,
463 u_int64_t obj_id, hammer_tid_t asof, int flags,
465 void hammer_put_inode(struct hammer_inode *ip);
466 void hammer_put_inode_ref(struct hammer_inode *ip);
468 int hammer_unload_inode(hammer_inode_t ip, void *data);
469 int hammer_unload_volume(hammer_volume_t volume, void *data __unused);
470 int hammer_unload_buffer(hammer_buffer_t buffer, void *data __unused);
471 int hammer_install_volume(hammer_mount_t hmp, const char *volname);
473 int hammer_ip_lookup(hammer_cursor_t cursor, hammer_inode_t ip);
474 int hammer_ip_first(hammer_cursor_t cursor, hammer_inode_t ip);
475 int hammer_ip_next(hammer_cursor_t cursor);
476 int hammer_ip_resolve_record_and_data(hammer_cursor_t cursor);
477 int hammer_ip_resolve_data(hammer_cursor_t cursor);
478 int hammer_ip_delete_record(hammer_cursor_t cursor, hammer_tid_t tid);
479 int hammer_delete_at_cursor(hammer_cursor_t cursor, int64_t *stat_bytes);
480 int hammer_ip_check_directory_empty(hammer_transaction_t trans,
482 int hammer_sync_hmp(hammer_mount_t hmp, int waitfor);
483 int hammer_sync_volume(hammer_volume_t volume, void *data);
484 int hammer_sync_buffer(hammer_buffer_t buffer, void *data);
487 hammer_alloc_mem_record(hammer_inode_t ip);
488 void hammer_rel_mem_record(hammer_record_t record);
490 int hammer_cursor_up(hammer_cursor_t cursor);
491 int hammer_cursor_down(hammer_cursor_t cursor);
492 int hammer_cursor_upgrade(hammer_cursor_t cursor);
493 void hammer_cursor_downgrade(hammer_cursor_t cursor);
494 int hammer_cursor_seek(hammer_cursor_t cursor, hammer_node_t node,
496 void hammer_lock_ex(struct hammer_lock *lock);
497 int hammer_lock_ex_try(struct hammer_lock *lock);
498 void hammer_lock_sh(struct hammer_lock *lock);
499 int hammer_lock_upgrade(struct hammer_lock *lock);
500 void hammer_lock_downgrade(struct hammer_lock *lock);
501 void hammer_unlock(struct hammer_lock *lock);
502 void hammer_ref(struct hammer_lock *lock);
503 void hammer_unref(struct hammer_lock *lock);
505 u_int32_t hammer_to_unix_xid(uuid_t *uuid);
506 void hammer_guid_to_uuid(uuid_t *uuid, u_int32_t guid);
507 void hammer_to_timespec(hammer_tid_t tid, struct timespec *ts);
508 hammer_tid_t hammer_timespec_to_transid(struct timespec *ts);
509 hammer_tid_t hammer_alloc_tid(hammer_transaction_t trans);
510 hammer_tid_t hammer_now_tid(void);
511 hammer_tid_t hammer_str_to_tid(const char *str);
513 enum vtype hammer_get_vnode_type(u_int8_t obj_type);
514 int hammer_get_dtype(u_int8_t obj_type);
515 u_int8_t hammer_get_obj_type(enum vtype vtype);
516 int64_t hammer_directory_namekey(void *name, int len);
518 int hammer_init_cursor(hammer_transaction_t trans, hammer_cursor_t cursor,
519 struct hammer_node **cache);
521 void hammer_done_cursor(hammer_cursor_t cursor);
522 void hammer_mem_done(hammer_cursor_t cursor);
524 int hammer_btree_lookup(hammer_cursor_t cursor);
525 int hammer_btree_first(hammer_cursor_t cursor);
526 int hammer_btree_last(hammer_cursor_t cursor);
527 int hammer_btree_extract(hammer_cursor_t cursor, int flags);
528 int hammer_btree_iterate(hammer_cursor_t cursor);
529 int hammer_btree_iterate_reverse(hammer_cursor_t cursor);
530 int hammer_btree_insert(hammer_cursor_t cursor, hammer_btree_elm_t elm);
531 int hammer_btree_delete(hammer_cursor_t cursor);
532 int hammer_btree_cmp(hammer_base_elm_t key1, hammer_base_elm_t key2);
533 int hammer_btree_chkts(hammer_tid_t ts, hammer_base_elm_t key);
534 int hammer_btree_correct_rhb(hammer_cursor_t cursor, hammer_tid_t tid);
535 int hammer_btree_correct_lhb(hammer_cursor_t cursor, hammer_tid_t tid);
538 int hammer_btree_lock_children(hammer_cursor_t cursor,
539 struct hammer_node_locklist **locklistp);
541 void hammer_print_btree_node(hammer_node_ondisk_t ondisk);
542 void hammer_print_btree_elm(hammer_btree_elm_t elm, u_int8_t type, int i);
544 void *hammer_bread(struct hammer_mount *hmp, hammer_off_t off,
545 int *errorp, struct hammer_buffer **bufferp);
546 void *hammer_bnew(struct hammer_mount *hmp, hammer_off_t off,
547 int *errorp, struct hammer_buffer **bufferp);
549 hammer_volume_t hammer_get_root_volume(hammer_mount_t hmp, int *errorp);
551 hammer_volume_t hammer_get_volume(hammer_mount_t hmp,
552 int32_t vol_no, int *errorp);
553 hammer_buffer_t hammer_get_buffer(hammer_mount_t hmp,
554 hammer_off_t buf_offset, int isnew, int *errorp);
556 int hammer_ref_volume(hammer_volume_t volume);
557 int hammer_ref_buffer(hammer_buffer_t buffer);
558 void hammer_flush_buffer_nodes(hammer_buffer_t buffer);
560 void hammer_rel_volume(hammer_volume_t volume, int flush);
561 void hammer_rel_buffer(hammer_buffer_t buffer, int flush);
563 int hammer_vfs_export(struct mount *mp, int op,
564 const struct export_args *export);
565 hammer_node_t hammer_get_node(hammer_mount_t hmp,
566 hammer_off_t node_offset, int *errorp);
567 int hammer_ref_node(hammer_node_t node);
568 hammer_node_t hammer_ref_node_safe(struct hammer_mount *hmp,
569 struct hammer_node **cache, int *errorp);
570 void hammer_rel_node(hammer_node_t node);
571 void hammer_delete_node(hammer_transaction_t trans,
573 void hammer_cache_node(hammer_node_t node,
574 struct hammer_node **cache);
575 void hammer_uncache_node(struct hammer_node **cache);
576 void hammer_flush_node(hammer_node_t node);
578 void hammer_dup_buffer(struct hammer_buffer **bufferp,
579 struct hammer_buffer *buffer);
580 hammer_node_t hammer_alloc_btree(hammer_transaction_t trans, int *errorp);
581 void *hammer_alloc_record(hammer_transaction_t trans,
582 hammer_off_t *rec_offp, u_int16_t rec_type,
583 struct hammer_buffer **rec_bufferp,
584 int32_t data_len, void **datap,
585 struct hammer_buffer **data_bufferp, int *errorp);
586 void *hammer_alloc_data(hammer_transaction_t trans, int32_t data_len,
587 hammer_off_t *data_offsetp,
588 struct hammer_buffer **data_bufferp, int *errorp);
590 int hammer_generate_undo(hammer_transaction_t trans, hammer_off_t zone1_offset,
591 void *base, int len);
593 void hammer_put_volume(struct hammer_volume *volume, int flush);
594 void hammer_put_buffer(struct hammer_buffer *buffer, int flush);
596 hammer_off_t hammer_freemap_alloc(hammer_transaction_t trans,
597 hammer_off_t owner, int *errorp);
598 void hammer_freemap_free(hammer_transaction_t trans, hammer_off_t phys_offset,
599 hammer_off_t owner, int *errorp);
600 hammer_off_t hammer_blockmap_alloc(hammer_transaction_t trans, int zone,
601 int bytes, int *errorp);
602 void hammer_blockmap_free(hammer_transaction_t trans,
603 hammer_off_t bmap_off, int bytes);
604 int hammer_blockmap_getfree(hammer_mount_t hmp, hammer_off_t bmap_off,
605 int *curp, int *errorp);
606 hammer_off_t hammer_blockmap_lookup(hammer_mount_t hmp, hammer_off_t bmap_off,
608 hammer_off_t hammer_undo_lookup(hammer_mount_t hmp, hammer_off_t bmap_off,
611 void hammer_start_transaction(struct hammer_transaction *trans,
612 struct hammer_mount *hmp);
613 void hammer_simple_transaction(struct hammer_transaction *trans,
614 struct hammer_mount *hmp);
615 void hammer_start_transaction_tid(struct hammer_transaction *trans,
616 struct hammer_mount *hmp, hammer_tid_t tid);
617 void hammer_commit_transaction(struct hammer_transaction *trans);
618 void hammer_abort_transaction(struct hammer_transaction *trans);
620 void hammer_modify_inode(struct hammer_transaction *trans,
621 hammer_inode_t ip, int flags);
622 int hammer_create_inode(struct hammer_transaction *trans, struct vattr *vap,
623 struct ucred *cred, struct hammer_inode *dip,
624 struct hammer_inode **ipp);
625 void hammer_rel_inode(hammer_inode_t ip, int flush);
626 int hammer_sync_inode(hammer_inode_t ip, int waitfor, int handle_delete);
628 int hammer_ip_add_directory(struct hammer_transaction *trans,
629 hammer_inode_t dip, struct namecache *ncp,
631 int hammer_ip_del_directory(struct hammer_transaction *trans,
632 hammer_cursor_t cursor, hammer_inode_t dip,
634 int hammer_ip_add_record(struct hammer_transaction *trans,
635 hammer_record_t record);
636 int hammer_ip_delete_range(struct hammer_transaction *trans,
637 hammer_inode_t ip, int64_t ran_beg, int64_t ran_end);
638 int hammer_ip_delete_range_all(struct hammer_transaction *trans,
640 int hammer_ip_sync_data(struct hammer_transaction *trans,
641 hammer_inode_t ip, int64_t offset,
642 void *data, int bytes);
643 int hammer_ip_sync_record(hammer_transaction_t trans, hammer_record_t rec);
645 int hammer_ioctl(hammer_inode_t ip, u_long com, caddr_t data, int fflag,
648 void hammer_io_init(hammer_io_t io, enum hammer_io_type type);
649 int hammer_io_read(struct vnode *devvp, struct hammer_io *io);
650 int hammer_io_new(struct vnode *devvp, struct hammer_io *io);
651 void hammer_io_release(struct hammer_io *io, int flush);
652 void hammer_io_flush(struct hammer_io *io);
653 int hammer_io_checkflush(hammer_io_t io);
654 void hammer_io_clear_modify(struct hammer_io *io);
655 void hammer_io_waitdep(struct hammer_io *io);
657 void hammer_modify_volume(hammer_transaction_t trans, hammer_volume_t volume,
658 void *base, int len);
659 void hammer_modify_buffer(hammer_transaction_t trans, hammer_buffer_t buffer,
660 void *base, int len);
662 int hammer_ioc_reblock(hammer_transaction_t trans, hammer_inode_t ip,
663 struct hammer_ioc_reblock *reblock);
665 void hammer_init_holes(hammer_mount_t hmp, hammer_holes_t holes);
666 void hammer_free_holes(hammer_mount_t hmp, hammer_holes_t holes);
667 int hammer_signal_check(hammer_mount_t hmp);
672 hammer_modify_node_noundo(hammer_transaction_t trans, hammer_node_t node)
674 hammer_modify_buffer(trans, node->buffer, NULL, 0);
678 hammer_modify_node_all(hammer_transaction_t trans, struct hammer_node *node)
680 hammer_modify_buffer(trans, node->buffer,
681 node->ondisk, sizeof(*node->ondisk));
685 hammer_modify_node(hammer_transaction_t trans, hammer_node_t node,
688 KKASSERT((char *)base >= (char *)node->ondisk &&
689 (char *)base + len <=
690 (char *)node->ondisk + sizeof(*node->ondisk));
691 hammer_modify_buffer(trans, node->buffer, base, len);
695 hammer_modify_record(hammer_transaction_t trans, hammer_buffer_t buffer,
698 KKASSERT((char *)base >= (char *)buffer->ondisk &&
699 (char *)base + len <= (char *)buffer->ondisk + HAMMER_BUFSIZE);
700 hammer_modify_buffer(trans, buffer, base, len);