HAMMER 59E/Many: Stabilization pass
[dragonfly.git] / sys / vfs / hammer / hammer.h
blob94142edcb25721e076bda35611b8ae44ccd15b8c
1 /*
2 * Copyright (c) 2007-2008 The DragonFly Project. All rights reserved.
3 *
4 * This code is derived from software contributed to The DragonFly Project
5 * by Matthew Dillon <dillon@backplane.com>
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
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
16 * distribution.
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
32 * SUCH DAMAGE.
34 * $DragonFly: src/sys/vfs/hammer/hammer.h,v 1.98 2008/06/30 02:45:30 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>
44 #include <sys/conf.h>
45 #include <sys/systm.h>
46 #include <sys/tree.h>
47 #include <sys/malloc.h>
48 #include <sys/mount.h>
49 #include <sys/mountctl.h>
50 #include <sys/vnode.h>
51 #include <sys/proc.h>
52 #include <sys/stat.h>
53 #include <sys/globaldata.h>
54 #include <sys/lockf.h>
55 #include <sys/buf.h>
56 #include <sys/queue.h>
57 #include <sys/ktr.h>
58 #include <sys/globaldata.h>
60 #include <sys/buf2.h>
61 #include <sys/signal2.h>
62 #include "hammer_disk.h"
63 #include "hammer_mount.h"
64 #include "hammer_ioctl.h"
66 #if defined(_KERNEL) || defined(_KERNEL_STRUCTURES)
68 MALLOC_DECLARE(M_HAMMER);
71 * Kernel trace
73 #if !defined(KTR_HAMMER)
74 #define KTR_HAMMER KTR_ALL
75 #endif
76 KTR_INFO_MASTER_EXTERN(hammer);
79 * Misc structures
81 struct hammer_mount;
84 * Key structure used for custom RB tree inode lookups. This prototypes
85 * the function hammer_ino_rb_tree_RB_LOOKUP_INFO(root, info).
87 typedef struct hammer_inode_info {
88 int64_t obj_id; /* (key) object identifier */
89 hammer_tid_t obj_asof; /* (key) snapshot transid or 0 */
90 u_int32_t obj_localization; /* (key) pseudo-fs */
91 union {
92 struct hammer_btree_leaf_elm *leaf;
93 } u;
94 } *hammer_inode_info_t;
96 typedef enum hammer_transaction_type {
97 HAMMER_TRANS_RO,
98 HAMMER_TRANS_STD,
99 HAMMER_TRANS_FLS
100 } hammer_transaction_type_t;
103 * HAMMER Transaction tracking
105 struct hammer_transaction {
106 hammer_transaction_type_t type;
107 struct hammer_mount *hmp;
108 hammer_tid_t tid;
109 u_int64_t time;
110 u_int32_t time32;
111 int sync_lock_refs;
112 struct hammer_volume *rootvol;
115 typedef struct hammer_transaction *hammer_transaction_t;
118 * HAMMER locks
120 struct hammer_lock {
121 int refs; /* active references delay writes */
122 int lockcount; /* lock count for exclusive/shared access */
123 int wanted;
124 int exwanted; /* number of threads waiting for ex lock */
125 struct thread *locktd;
128 static __inline int
129 hammer_islocked(struct hammer_lock *lock)
131 return(lock->lockcount != 0);
134 static __inline int
135 hammer_isactive(struct hammer_lock *lock)
137 return(lock->refs != 0);
140 static __inline int
141 hammer_islastref(struct hammer_lock *lock)
143 return(lock->refs == 1);
147 * Return if we specifically own the lock exclusively.
149 static __inline int
150 hammer_lock_excl_owned(struct hammer_lock *lock, thread_t td)
152 if (lock->lockcount > 0 && lock->locktd == td)
153 return(1);
154 return(0);
158 * Flush state, used by various structures
160 typedef enum hammer_inode_state {
161 HAMMER_FST_IDLE,
162 HAMMER_FST_SETUP,
163 HAMMER_FST_FLUSH
164 } hammer_inode_state_t;
166 TAILQ_HEAD(hammer_record_list, hammer_record);
169 * Cache object ids. A fixed number of objid cache structures are
170 * created to reserve object id's for newly created files in multiples
171 * of 100,000, localized to a particular directory, and recycled as
172 * needed. This allows parallel create operations in different
173 * directories to retain fairly localized object ids which in turn
174 * improves reblocking performance and layout.
176 #define OBJID_CACHE_SIZE 1024
177 #define OBJID_CACHE_BULK 100000
179 typedef struct hammer_objid_cache {
180 TAILQ_ENTRY(hammer_objid_cache) entry;
181 struct hammer_inode *dip;
182 hammer_tid_t next_tid;
183 int count;
184 } *hammer_objid_cache_t;
187 * Associate an inode with a B-Tree node to cache search start positions
189 typedef struct hammer_node_cache {
190 TAILQ_ENTRY(hammer_node_cache) entry;
191 struct hammer_node *node;
192 struct hammer_inode *ip;
193 } *hammer_node_cache_t;
195 TAILQ_HEAD(hammer_node_cache_list, hammer_node_cache);
198 * Structure used to represent an inode in-memory.
200 * The record and data associated with an inode may be out of sync with
201 * the disk (xDIRTY flags), or not even on the disk at all (ONDISK flag
202 * clear).
204 * An inode may also hold a cache of unsynchronized records, used for
205 * database and directories only. Unsynchronized regular file data is
206 * stored in the buffer cache.
208 * NOTE: A file which is created and destroyed within the initial
209 * synchronization period can wind up not doing any disk I/O at all.
211 * Finally, an inode may cache numerous disk-referencing B-Tree cursors.
213 struct hammer_ino_rb_tree;
214 struct hammer_inode;
215 RB_HEAD(hammer_ino_rb_tree, hammer_inode);
216 RB_PROTOTYPEX(hammer_ino_rb_tree, INFO, hammer_inode, rb_node,
217 hammer_ino_rb_compare, hammer_inode_info_t);
219 struct hammer_rec_rb_tree;
220 struct hammer_record;
221 RB_HEAD(hammer_rec_rb_tree, hammer_record);
222 RB_PROTOTYPEX(hammer_rec_rb_tree, INFO, hammer_record, rb_node,
223 hammer_rec_rb_compare, hammer_btree_leaf_elm_t);
225 TAILQ_HEAD(hammer_node_list, hammer_node);
227 struct hammer_inode {
228 RB_ENTRY(hammer_inode) rb_node;
229 hammer_inode_state_t flush_state;
230 int flush_group;
231 TAILQ_ENTRY(hammer_inode) flush_entry;
232 struct hammer_record_list target_list; /* target of dependant recs */
233 u_int64_t obj_id; /* (key) object identifier */
234 hammer_tid_t obj_asof; /* (key) snapshot or 0 */
235 u_int32_t obj_localization; /* (key) pseudo-fs */
236 struct hammer_mount *hmp;
237 hammer_objid_cache_t objid_cache;
238 int flags;
239 int error; /* flush error */
240 int cursor_ip_refs; /* sanity */
241 int rsv_databufs;
242 int rsv_recs;
243 struct vnode *vp;
244 struct lockf advlock;
245 struct hammer_lock lock; /* sync copy interlock */
246 off_t trunc_off;
247 struct hammer_btree_leaf_elm ino_leaf; /* in-memory cache */
248 struct hammer_inode_data ino_data; /* in-memory cache */
249 struct hammer_rec_rb_tree rec_tree; /* in-memory cache */
250 struct hammer_node_cache cache[2]; /* search initiate cache */
253 * When a demark is created to synchronize an inode to
254 * disk, certain fields are copied so the front-end VOPs
255 * can continue to run in parallel with the synchronization
256 * occuring in the background.
258 int sync_flags; /* to-sync flags cache */
259 off_t sync_trunc_off; /* to-sync truncation */
260 off_t save_trunc_off; /* write optimization */
261 struct hammer_btree_leaf_elm sync_ino_leaf; /* to-sync cache */
262 struct hammer_inode_data sync_ino_data; /* to-sync cache */
265 typedef struct hammer_inode *hammer_inode_t;
267 #define VTOI(vp) ((struct hammer_inode *)(vp)->v_data)
269 #define HAMMER_INODE_DDIRTY 0x0001 /* in-memory ino_data is dirty */
270 /* (not including atime/mtime) */
271 #define HAMMER_INODE_RSV_INODES 0x0002 /* hmp->rsv_inodes bumped */
272 #define HAMMER_INODE_UNUSED0004 0x0004
273 #define HAMMER_INODE_XDIRTY 0x0008 /* in-memory records */
274 #define HAMMER_INODE_ONDISK 0x0010 /* inode is on-disk (else not yet) */
275 #define HAMMER_INODE_FLUSH 0x0020 /* flush on last ref */
276 #define HAMMER_INODE_DELETED 0x0080 /* inode delete (backend) */
277 #define HAMMER_INODE_DELONDISK 0x0100 /* delete synchronized to disk */
278 #define HAMMER_INODE_RO 0x0200 /* read-only (because of as-of) */
279 #define HAMMER_INODE_VHELD 0x0400 /* vnode held on sync */
280 #define HAMMER_INODE_DONDISK 0x0800 /* data records may be on disk */
281 #define HAMMER_INODE_BUFS 0x1000 /* dirty high level bps present */
282 #define HAMMER_INODE_REFLUSH 0x2000 /* pipelined flush during flush */
283 #define HAMMER_INODE_RECLAIM 0x4000 /* trying to reclaim */
284 #define HAMMER_INODE_FLUSHW 0x8000 /* Someone waiting for flush */
286 #define HAMMER_INODE_TRUNCATED 0x00010000
287 #define HAMMER_INODE_DELETING 0x00020000 /* inode delete request (frontend)*/
288 #define HAMMER_INODE_RESIGNAL 0x00040000 /* re-signal on re-flush */
289 #define HAMMER_INODE_ATIME 0x00100000 /* in-memory atime modified */
290 #define HAMMER_INODE_MTIME 0x00200000 /* in-memory mtime modified */
291 #define HAMMER_INODE_WOULDBLOCK 0x00400000 /* re-issue to new flush group */
293 #define HAMMER_INODE_MODMASK (HAMMER_INODE_DDIRTY| \
294 HAMMER_INODE_XDIRTY|HAMMER_INODE_BUFS| \
295 HAMMER_INODE_ATIME|HAMMER_INODE_MTIME| \
296 HAMMER_INODE_TRUNCATED|HAMMER_INODE_DELETING)
298 #define HAMMER_INODE_MODMASK_NOXDIRTY \
299 (HAMMER_INODE_MODMASK & ~HAMMER_INODE_XDIRTY)
301 #define HAMMER_FLUSH_GROUP_SIZE 64
303 #define HAMMER_FLUSH_SIGNAL 0x0001
304 #define HAMMER_FLUSH_RECURSION 0x0002
307 * Used by the inode reclaim code to pipeline reclaims and avoid
308 * blowing out kernel memory or letting the flusher get too far
309 * behind.
311 struct hammer_reclaim {
312 TAILQ_ENTRY(hammer_reclaim) entry;
313 int okydoky;
316 #define HAMMER_RECLAIM_FLUSH 2000
317 #define HAMMER_RECLAIM_WAIT 4000
320 * Structure used to represent an unsynchronized record in-memory. These
321 * records typically represent directory entries. Only non-historical
322 * records are kept in-memory.
324 * Records are organized as a per-inode RB-Tree. If the inode is not
325 * on disk then neither are any records and the in-memory record tree
326 * represents the entire contents of the inode. If the inode is on disk
327 * then the on-disk B-Tree is scanned in parallel with the in-memory
328 * RB-Tree to synthesize the current state of the file.
330 * Records are also used to enforce the ordering of directory create/delete
331 * operations. A new inode will not be flushed to disk unless its related
332 * directory entry is also being flushed at the same time. A directory entry
333 * will not be removed unless its related inode is also being removed at the
334 * same time.
336 typedef enum hammer_record_type {
337 HAMMER_MEM_RECORD_GENERAL, /* misc record */
338 HAMMER_MEM_RECORD_INODE, /* inode record */
339 HAMMER_MEM_RECORD_ADD, /* positive memory cache record */
340 HAMMER_MEM_RECORD_DEL, /* negative delete-on-disk record */
341 HAMMER_MEM_RECORD_DATA /* bulk-data record w/on-disk ref */
342 } hammer_record_type_t;
344 struct hammer_record {
345 RB_ENTRY(hammer_record) rb_node;
346 TAILQ_ENTRY(hammer_record) target_entry;
347 hammer_inode_state_t flush_state;
348 int flush_group;
349 hammer_record_type_t type;
350 struct hammer_lock lock;
351 struct hammer_reserve *resv;
352 struct hammer_inode *ip;
353 struct hammer_inode *target_ip;
354 struct hammer_btree_leaf_elm leaf;
355 union hammer_data_ondisk *data;
356 int flags;
359 typedef struct hammer_record *hammer_record_t;
362 * Record flags. Note that FE can only be set by the frontend if the
363 * record has not been interlocked by the backend w/ BE.
365 #define HAMMER_RECF_ALLOCDATA 0x0001
366 #define HAMMER_RECF_ONRBTREE 0x0002
367 #define HAMMER_RECF_DELETED_FE 0x0004 /* deleted (frontend) */
368 #define HAMMER_RECF_DELETED_BE 0x0008 /* deleted (backend) */
369 #define HAMMER_RECF_UNUSED0010 0x0010
370 #define HAMMER_RECF_INTERLOCK_BE 0x0020 /* backend interlock */
371 #define HAMMER_RECF_WANTED 0x0040 /* wanted by the frontend */
372 #define HAMMER_RECF_CONVERT_DELETE 0x0100 /* special case */
375 * In-memory structures representing on-disk structures.
377 struct hammer_volume;
378 struct hammer_buffer;
379 struct hammer_node;
380 struct hammer_undo;
381 struct hammer_reserve;
383 RB_HEAD(hammer_vol_rb_tree, hammer_volume);
384 RB_HEAD(hammer_buf_rb_tree, hammer_buffer);
385 RB_HEAD(hammer_nod_rb_tree, hammer_node);
386 RB_HEAD(hammer_und_rb_tree, hammer_undo);
387 RB_HEAD(hammer_res_rb_tree, hammer_reserve);
389 RB_PROTOTYPE2(hammer_vol_rb_tree, hammer_volume, rb_node,
390 hammer_vol_rb_compare, int32_t);
391 RB_PROTOTYPE2(hammer_buf_rb_tree, hammer_buffer, rb_node,
392 hammer_buf_rb_compare, hammer_off_t);
393 RB_PROTOTYPE2(hammer_nod_rb_tree, hammer_node, rb_node,
394 hammer_nod_rb_compare, hammer_off_t);
395 RB_PROTOTYPE2(hammer_und_rb_tree, hammer_undo, rb_node,
396 hammer_und_rb_compare, hammer_off_t);
397 RB_PROTOTYPE2(hammer_res_rb_tree, hammer_reserve, rb_node,
398 hammer_res_rb_compare, hammer_off_t);
401 * IO management - embedded at the head of various in-memory structures
403 * VOLUME - hammer_volume containing meta-data
404 * META_BUFFER - hammer_buffer containing meta-data
405 * DATA_BUFFER - hammer_buffer containing pure-data
407 * Dirty volume headers and dirty meta-data buffers are locked until the
408 * flusher can sequence them out. Dirty pure-data buffers can be written.
409 * Clean buffers can be passively released.
411 typedef enum hammer_io_type {
412 HAMMER_STRUCTURE_VOLUME,
413 HAMMER_STRUCTURE_META_BUFFER,
414 HAMMER_STRUCTURE_UNDO_BUFFER,
415 HAMMER_STRUCTURE_DATA_BUFFER
416 } hammer_io_type_t;
418 union hammer_io_structure;
419 struct hammer_io;
421 struct worklist {
422 LIST_ENTRY(worklist) node;
425 TAILQ_HEAD(hammer_io_list, hammer_io);
426 typedef struct hammer_io_list *hammer_io_list_t;
428 struct hammer_io {
429 struct worklist worklist;
430 struct hammer_lock lock;
431 enum hammer_io_type type;
432 struct hammer_mount *hmp;
433 TAILQ_ENTRY(hammer_io) mod_entry; /* list entry if modified */
434 hammer_io_list_t mod_list;
435 struct buf *bp;
436 int64_t offset; /* zone-2 offset */
437 int bytes; /* buffer cache buffer size */
438 int loading; /* loading/unloading interlock */
439 int modify_refs;
441 u_int modified : 1; /* bp's data was modified */
442 u_int released : 1; /* bp released (w/ B_LOCKED set) */
443 u_int running : 1; /* bp write IO in progress */
444 u_int waiting : 1; /* someone is waiting on us */
445 u_int validated : 1; /* ondisk has been validated */
446 u_int waitdep : 1; /* flush waits for dependancies */
447 u_int recovered : 1; /* has recovery ref */
448 u_int waitmod : 1; /* waiting for modify_refs */
449 u_int reclaim : 1; /* reclaim requested */
450 u_int gencrc : 1; /* crc needs to be generated */
453 typedef struct hammer_io *hammer_io_t;
455 #define HAMMER_CLUSTER_SIZE (64 * 1024)
456 #if HAMMER_CLUSTER_SIZE > MAXBSIZE
457 #undef HAMMER_CLUSTER_SIZE
458 #define HAMMER_CLUSTER_SIZE MAXBSIZE
459 #endif
460 #define HAMMER_CLUSTER_BUFS (HAMMER_CLUSTER_SIZE / HAMMER_BUFSIZE)
463 * In-memory volume representing on-disk buffer
465 struct hammer_volume {
466 struct hammer_io io;
467 RB_ENTRY(hammer_volume) rb_node;
468 struct hammer_volume_ondisk *ondisk;
469 int32_t vol_no;
470 int64_t nblocks; /* note: special calculation for statfs */
471 int64_t buffer_base; /* base offset of buffer 0 */
472 hammer_off_t maxbuf_off; /* Maximum buffer offset (zone-2) */
473 hammer_off_t maxraw_off; /* Maximum raw offset for device */
474 char *vol_name;
475 struct vnode *devvp;
476 int vol_flags;
479 typedef struct hammer_volume *hammer_volume_t;
482 * In-memory buffer (other then volume, super-cluster, or cluster),
483 * representing an on-disk buffer.
485 struct hammer_buffer {
486 struct hammer_io io;
487 RB_ENTRY(hammer_buffer) rb_node;
488 void *ondisk;
489 struct hammer_volume *volume;
490 hammer_off_t zoneX_offset;
491 hammer_off_t zone2_offset;
492 struct hammer_reserve *resv;
493 struct hammer_node_list clist;
496 typedef struct hammer_buffer *hammer_buffer_t;
499 * In-memory B-Tree node, representing an on-disk B-Tree node.
501 * This is a hang-on structure which is backed by a hammer_buffer,
502 * indexed by a hammer_cluster, and used for fine-grained locking of
503 * B-Tree nodes in order to properly control lock ordering. A hammer_buffer
504 * can contain multiple nodes representing wildly disassociated portions
505 * of the B-Tree so locking cannot be done on a buffer-by-buffer basis.
507 * This structure uses a cluster-relative index to reduce the number
508 * of layers required to access it, and also because all on-disk B-Tree
509 * references are cluster-relative offsets.
511 struct hammer_node {
512 struct hammer_lock lock; /* node-by-node lock */
513 TAILQ_ENTRY(hammer_node) entry; /* per-buffer linkage */
514 RB_ENTRY(hammer_node) rb_node; /* per-cluster linkage */
515 hammer_off_t node_offset; /* full offset spec */
516 struct hammer_mount *hmp;
517 struct hammer_buffer *buffer; /* backing buffer */
518 hammer_node_ondisk_t ondisk; /* ptr to on-disk structure */
519 struct hammer_node_cache_list cache_list; /* passive caches */
520 int flags;
521 int loading; /* load interlock */
524 #define HAMMER_NODE_DELETED 0x0001
525 #define HAMMER_NODE_FLUSH 0x0002
526 #define HAMMER_NODE_CRCGOOD 0x0004
527 #define HAMMER_NODE_NEEDSCRC 0x0008
528 #define HAMMER_NODE_NEEDSMIRROR 0x0010
530 typedef struct hammer_node *hammer_node_t;
533 * List of locked nodes.
535 struct hammer_node_locklist {
536 struct hammer_node_locklist *next;
537 hammer_node_t node;
540 typedef struct hammer_node_locklist *hammer_node_locklist_t;
544 * Common I/O management structure - embedded in in-memory structures
545 * which are backed by filesystem buffers.
547 union hammer_io_structure {
548 struct hammer_io io;
549 struct hammer_volume volume;
550 struct hammer_buffer buffer;
553 typedef union hammer_io_structure *hammer_io_structure_t;
556 * The reserve structure prevents the blockmap from allocating
557 * out of a reserved bigblock. Such reservations are used by
558 * the direct-write mechanism.
560 * The structure is also used to hold off on reallocations of
561 * big blocks from the freemap until flush dependancies have
562 * been dealt with.
564 struct hammer_reserve {
565 RB_ENTRY(hammer_reserve) rb_node;
566 TAILQ_ENTRY(hammer_reserve) delay_entry;
567 int flush_group;
568 int flags;
569 int refs;
570 int zone;
571 hammer_off_t zone_offset;
574 typedef struct hammer_reserve *hammer_reserve_t;
576 #define HAMMER_RESF_ONDELAY 0x0001
578 #include "hammer_cursor.h"
581 * The undo structure tracks recent undos to avoid laying down duplicate
582 * undos within a flush group, saving us a significant amount of overhead.
584 * This is strictly a heuristic.
586 #define HAMMER_MAX_UNDOS 1024
587 #define HAMMER_MAX_FLUSHERS 4
589 struct hammer_undo {
590 RB_ENTRY(hammer_undo) rb_node;
591 TAILQ_ENTRY(hammer_undo) lru_entry;
592 hammer_off_t offset;
593 int bytes;
596 typedef struct hammer_undo *hammer_undo_t;
598 struct hammer_flusher_info;
600 struct hammer_flusher {
601 int signal; /* flusher thread sequencer */
602 int act; /* currently active flush group */
603 int done; /* set to act when complete */
604 int next; /* next flush group */
605 int group_lock; /* lock sequencing of the next flush */
606 int exiting; /* request master exit */
607 int count; /* number of slave flushers */
608 int running; /* number of slave flushers running */
609 thread_t td; /* master flusher thread */
610 hammer_tid_t tid; /* last flushed transaction id */
611 int finalize_want; /* serialize finalization */
612 struct hammer_lock finalize_lock; /* serialize finalization */
613 struct hammer_transaction trans; /* shared transaction */
614 struct hammer_flusher_info *info[HAMMER_MAX_FLUSHERS];
618 * Internal hammer mount data structure
620 struct hammer_mount {
621 struct mount *mp;
622 /*struct vnode *rootvp;*/
623 struct hammer_ino_rb_tree rb_inos_root;
624 struct hammer_vol_rb_tree rb_vols_root;
625 struct hammer_nod_rb_tree rb_nods_root;
626 struct hammer_und_rb_tree rb_undo_root;
627 struct hammer_res_rb_tree rb_resv_root;
628 struct hammer_buf_rb_tree rb_bufs_root;
629 struct hammer_volume *rootvol;
630 struct hammer_base_elm root_btree_beg;
631 struct hammer_base_elm root_btree_end;
632 int flags;
633 int hflags;
634 int ronly;
635 int nvolumes;
636 int volume_iterator;
637 int masterid; /* -1 or 0-15 - clustering and mirroring */
638 int rsv_inodes; /* reserved space due to dirty inodes */
639 int rsv_databufs; /* reserved space due to dirty buffers */
640 int rsv_databytes; /* reserved space due to record data */
641 int rsv_recs; /* reserved space due to dirty records */
642 int last_newrecords;
643 int count_newrecords;
645 int inode_reclaims; /* inodes pending reclaim by flusher */
646 int count_inodes; /* total number of inodes */
647 int count_iqueued; /* inodes queued to flusher */
649 struct hammer_flusher flusher;
651 u_int check_interrupt;
652 uuid_t fsid;
653 udev_t fsid_udev;
654 struct hammer_io_list volu_list; /* dirty undo buffers */
655 struct hammer_io_list undo_list; /* dirty undo buffers */
656 struct hammer_io_list data_list; /* dirty data buffers */
657 struct hammer_io_list alt_data_list; /* dirty data buffers */
658 struct hammer_io_list meta_list; /* dirty meta bufs */
659 struct hammer_io_list lose_list; /* loose buffers */
660 int locked_dirty_space; /* meta/volu count */
661 int io_running_space;
662 int objid_cache_count;
663 hammer_tid_t asof; /* snapshot mount */
664 hammer_off_t next_tid;
665 int64_t copy_stat_freebigblocks; /* number of free bigblocks */
667 u_int32_t namekey_iterator;
668 struct netexport export;
669 struct hammer_lock sync_lock;
670 struct hammer_lock free_lock;
671 struct hammer_lock undo_lock;
672 struct hammer_lock blkmap_lock;
673 struct hammer_blockmap blockmap[HAMMER_MAX_ZONES];
674 struct hammer_undo undos[HAMMER_MAX_UNDOS];
675 int undo_alloc;
676 TAILQ_HEAD(, hammer_undo) undo_lru_list;
677 TAILQ_HEAD(, hammer_inode) flush_list;
678 TAILQ_HEAD(, hammer_reserve) delay_list;
679 TAILQ_HEAD(, hammer_objid_cache) objid_cache_list;
680 TAILQ_HEAD(, hammer_reclaim) reclaim_list;
683 typedef struct hammer_mount *hammer_mount_t;
685 #define HAMMER_MOUNT_UNUSED0001 0x0001
687 struct hammer_sync_info {
688 int error;
689 int waitfor;
692 #endif
694 #if defined(_KERNEL)
696 extern struct vop_ops hammer_vnode_vops;
697 extern struct vop_ops hammer_spec_vops;
698 extern struct vop_ops hammer_fifo_vops;
699 extern struct bio_ops hammer_bioops;
701 extern int hammer_debug_io;
702 extern int hammer_debug_general;
703 extern int hammer_debug_debug;
704 extern int hammer_debug_inode;
705 extern int hammer_debug_locks;
706 extern int hammer_debug_btree;
707 extern int hammer_debug_tid;
708 extern int hammer_debug_recover;
709 extern int hammer_debug_recover_faults;
710 extern int hammer_debug_cluster_enable;
711 extern int hammer_count_inodes;
712 extern int hammer_count_iqueued;
713 extern int hammer_count_reclaiming;
714 extern int hammer_count_records;
715 extern int hammer_count_record_datas;
716 extern int hammer_count_volumes;
717 extern int hammer_count_buffers;
718 extern int hammer_count_nodes;
719 extern int64_t hammer_stats_btree_lookups;
720 extern int64_t hammer_stats_btree_searches;
721 extern int64_t hammer_stats_btree_inserts;
722 extern int64_t hammer_stats_btree_deletes;
723 extern int64_t hammer_stats_btree_elements;
724 extern int64_t hammer_stats_btree_splits;
725 extern int64_t hammer_stats_btree_iterations;
726 extern int64_t hammer_stats_record_iterations;
727 extern int hammer_count_dirtybufspace;
728 extern int hammer_count_refedbufs;
729 extern int hammer_count_reservations;
730 extern int hammer_count_io_running_read;
731 extern int hammer_count_io_running_write;
732 extern int hammer_count_io_locked;
733 extern int hammer_limit_dirtybufspace;
734 extern int hammer_limit_iqueued;
735 extern int hammer_limit_recs;
736 extern int hammer_bio_count;
737 extern int hammer_verify_zone;
738 extern int hammer_write_mode;
739 extern int64_t hammer_contention_count;
741 int hammer_vop_inactive(struct vop_inactive_args *);
742 int hammer_vop_reclaim(struct vop_reclaim_args *);
743 int hammer_get_vnode(struct hammer_inode *ip, struct vnode **vpp);
744 struct hammer_inode *hammer_get_inode(hammer_transaction_t trans,
745 hammer_inode_t dip, u_int64_t obj_id,
746 hammer_tid_t asof, u_int32_t localization,
747 int flags, int *errorp);
748 void hammer_scan_inode_snapshots(hammer_mount_t hmp,
749 hammer_inode_info_t iinfo,
750 int (*callback)(hammer_inode_t ip, void *data),
751 void *data);
752 void hammer_put_inode(struct hammer_inode *ip);
753 void hammer_put_inode_ref(struct hammer_inode *ip);
754 void hammer_inode_waitreclaims(hammer_mount_t hmp);
756 int hammer_unload_volume(hammer_volume_t volume, void *data __unused);
757 int hammer_adjust_volume_mode(hammer_volume_t volume, void *data __unused);
759 int hammer_unload_buffer(hammer_buffer_t buffer, void *data __unused);
760 int hammer_install_volume(hammer_mount_t hmp, const char *volname);
762 int hammer_ip_lookup(hammer_cursor_t cursor);
763 int hammer_ip_first(hammer_cursor_t cursor);
764 int hammer_ip_next(hammer_cursor_t cursor);
765 int hammer_ip_resolve_data(hammer_cursor_t cursor);
766 int hammer_ip_delete_record(hammer_cursor_t cursor, hammer_inode_t ip,
767 hammer_tid_t tid);
768 int hammer_delete_at_cursor(hammer_cursor_t cursor, int64_t *stat_bytes);
769 int hammer_ip_check_directory_empty(hammer_transaction_t trans,
770 hammer_inode_t ip);
771 int hammer_sync_hmp(hammer_mount_t hmp, int waitfor);
772 int hammer_queue_inodes_flusher(hammer_mount_t hmp, int waitfor);
775 hammer_record_t
776 hammer_alloc_mem_record(hammer_inode_t ip, int data_len);
777 void hammer_flush_record_done(hammer_record_t record, int error);
778 void hammer_wait_mem_record_ident(hammer_record_t record, const char *ident);
779 void hammer_rel_mem_record(hammer_record_t record);
781 int hammer_cursor_up(hammer_cursor_t cursor);
782 int hammer_cursor_up_locked(hammer_cursor_t cursor);
783 int hammer_cursor_down(hammer_cursor_t cursor);
784 int hammer_cursor_upgrade(hammer_cursor_t cursor);
785 int hammer_cursor_upgrade_node(hammer_cursor_t cursor);
786 void hammer_cursor_downgrade(hammer_cursor_t cursor);
787 int hammer_cursor_seek(hammer_cursor_t cursor, hammer_node_t node,
788 int index);
789 void hammer_lock_ex_ident(struct hammer_lock *lock, const char *ident);
790 int hammer_lock_ex_try(struct hammer_lock *lock);
791 void hammer_lock_sh(struct hammer_lock *lock);
792 void hammer_lock_sh_lowpri(struct hammer_lock *lock);
793 int hammer_lock_sh_try(struct hammer_lock *lock);
794 int hammer_lock_upgrade(struct hammer_lock *lock);
795 void hammer_lock_downgrade(struct hammer_lock *lock);
796 void hammer_unlock(struct hammer_lock *lock);
797 void hammer_ref(struct hammer_lock *lock);
798 void hammer_unref(struct hammer_lock *lock);
800 void hammer_sync_lock_ex(hammer_transaction_t trans);
801 void hammer_sync_lock_sh(hammer_transaction_t trans);
802 int hammer_sync_lock_sh_try(hammer_transaction_t trans);
803 void hammer_sync_unlock(hammer_transaction_t trans);
805 u_int32_t hammer_to_unix_xid(uuid_t *uuid);
806 void hammer_guid_to_uuid(uuid_t *uuid, u_int32_t guid);
807 void hammer_time_to_timespec(u_int64_t xtime, struct timespec *ts);
808 u_int64_t hammer_timespec_to_time(struct timespec *ts);
809 hammer_tid_t hammer_str_to_tid(const char *str);
810 hammer_tid_t hammer_alloc_objid(hammer_mount_t hmp, hammer_inode_t dip);
811 void hammer_clear_objid(hammer_inode_t dip);
812 void hammer_destroy_objid_cache(hammer_mount_t hmp);
814 int hammer_enter_undo_history(hammer_mount_t hmp, hammer_off_t offset,
815 int bytes);
816 void hammer_clear_undo_history(hammer_mount_t hmp);
817 enum vtype hammer_get_vnode_type(u_int8_t obj_type);
818 int hammer_get_dtype(u_int8_t obj_type);
819 u_int8_t hammer_get_obj_type(enum vtype vtype);
820 int64_t hammer_directory_namekey(const void *name, int len);
821 int hammer_nohistory(hammer_inode_t ip);
823 int hammer_init_cursor(hammer_transaction_t trans, hammer_cursor_t cursor,
824 hammer_node_cache_t cache, hammer_inode_t ip);
825 int hammer_reinit_cursor(hammer_cursor_t cursor);
826 void hammer_normalize_cursor(hammer_cursor_t cursor);
827 void hammer_done_cursor(hammer_cursor_t cursor);
828 void hammer_mem_done(hammer_cursor_t cursor);
830 int hammer_btree_lookup(hammer_cursor_t cursor);
831 int hammer_btree_first(hammer_cursor_t cursor);
832 int hammer_btree_last(hammer_cursor_t cursor);
833 int hammer_btree_extract(hammer_cursor_t cursor, int flags);
834 int hammer_btree_iterate(hammer_cursor_t cursor);
835 int hammer_btree_iterate_reverse(hammer_cursor_t cursor);
836 int hammer_btree_insert(hammer_cursor_t cursor,
837 hammer_btree_leaf_elm_t elm);
838 int hammer_btree_delete(hammer_cursor_t cursor);
839 int hammer_btree_mirror_propagate(hammer_transaction_t trans,
840 hammer_node_t node, int index,
841 hammer_tid_t mirror_tid);
843 int hammer_btree_cmp(hammer_base_elm_t key1, hammer_base_elm_t key2);
844 int hammer_btree_chkts(hammer_tid_t ts, hammer_base_elm_t key);
845 int hammer_btree_correct_rhb(hammer_cursor_t cursor, hammer_tid_t tid);
846 int hammer_btree_correct_lhb(hammer_cursor_t cursor, hammer_tid_t tid);
848 int btree_set_parent(hammer_transaction_t trans, hammer_node_t node,
849 hammer_btree_elm_t elm);
850 int hammer_btree_lock_children(hammer_cursor_t cursor,
851 struct hammer_node_locklist **locklistp);
852 void hammer_btree_unlock_children(struct hammer_node_locklist **locklistp);
853 int hammer_btree_search_node(hammer_base_elm_t elm, hammer_node_ondisk_t node);
854 hammer_node_t hammer_btree_get_parent(hammer_node_t node, int *parent_indexp,
855 int *errorp, int try_exclusive);
857 void hammer_print_btree_node(hammer_node_ondisk_t ondisk);
858 void hammer_print_btree_elm(hammer_btree_elm_t elm, u_int8_t type, int i);
860 void *hammer_bread(struct hammer_mount *hmp, hammer_off_t off,
861 int *errorp, struct hammer_buffer **bufferp);
862 void *hammer_bnew(struct hammer_mount *hmp, hammer_off_t off,
863 int *errorp, struct hammer_buffer **bufferp);
864 void *hammer_bread_ext(struct hammer_mount *hmp, hammer_off_t off, int bytes,
865 int *errorp, struct hammer_buffer **bufferp);
866 void *hammer_bnew_ext(struct hammer_mount *hmp, hammer_off_t off, int bytes,
867 int *errorp, struct hammer_buffer **bufferp);
869 hammer_volume_t hammer_get_root_volume(hammer_mount_t hmp, int *errorp);
871 hammer_volume_t hammer_get_volume(hammer_mount_t hmp,
872 int32_t vol_no, int *errorp);
873 hammer_buffer_t hammer_get_buffer(hammer_mount_t hmp, hammer_off_t buf_offset,
874 int bytes, int isnew, int *errorp);
875 void hammer_del_buffers(hammer_mount_t hmp, hammer_off_t base_offset,
876 hammer_off_t zone2_offset, int bytes);
878 int hammer_ref_volume(hammer_volume_t volume);
879 int hammer_ref_buffer(hammer_buffer_t buffer);
880 void hammer_flush_buffer_nodes(hammer_buffer_t buffer);
882 void hammer_rel_volume(hammer_volume_t volume, int flush);
883 void hammer_rel_buffer(hammer_buffer_t buffer, int flush);
885 int hammer_vfs_export(struct mount *mp, int op,
886 const struct export_args *export);
887 hammer_node_t hammer_get_node(hammer_mount_t hmp, hammer_off_t node_offset,
888 int isnew, int *errorp);
889 void hammer_ref_node(hammer_node_t node);
890 hammer_node_t hammer_ref_node_safe(struct hammer_mount *hmp,
891 hammer_node_cache_t cache, int *errorp);
892 void hammer_rel_node(hammer_node_t node);
893 void hammer_delete_node(hammer_transaction_t trans,
894 hammer_node_t node);
895 void hammer_cache_node(hammer_node_cache_t cache,
896 hammer_node_t node);
897 void hammer_uncache_node(hammer_node_cache_t cache);
898 void hammer_flush_node(hammer_node_t node);
900 void hammer_dup_buffer(struct hammer_buffer **bufferp,
901 struct hammer_buffer *buffer);
902 hammer_node_t hammer_alloc_btree(hammer_transaction_t trans, int *errorp);
903 void *hammer_alloc_data(hammer_transaction_t trans, int32_t data_len,
904 u_int16_t rec_type, hammer_off_t *data_offsetp,
905 struct hammer_buffer **data_bufferp, int *errorp);
907 int hammer_generate_undo(hammer_transaction_t trans, hammer_io_t io,
908 hammer_off_t zone1_offset, void *base, int len);
910 void hammer_put_volume(struct hammer_volume *volume, int flush);
911 void hammer_put_buffer(struct hammer_buffer *buffer, int flush);
913 hammer_off_t hammer_freemap_alloc(hammer_transaction_t trans,
914 hammer_off_t owner, int *errorp);
915 void hammer_freemap_free(hammer_transaction_t trans, hammer_off_t phys_offset,
916 hammer_off_t owner, int *errorp);
917 int hammer_checkspace(hammer_mount_t hmp);
918 hammer_off_t hammer_blockmap_alloc(hammer_transaction_t trans, int zone,
919 int bytes, int *errorp);
920 hammer_reserve_t hammer_blockmap_reserve(hammer_mount_t hmp, int zone,
921 int bytes, hammer_off_t *zone_offp, int *errorp);
922 void hammer_blockmap_reserve_complete(hammer_mount_t hmp,
923 hammer_reserve_t resv);
924 void hammer_reserve_setdelay(hammer_mount_t hmp, hammer_reserve_t resv,
925 hammer_off_t zone2_offset);
926 void hammer_reserve_clrdelay(hammer_mount_t hmp, hammer_reserve_t resv);
927 void hammer_blockmap_free(hammer_transaction_t trans,
928 hammer_off_t bmap_off, int bytes);
929 void hammer_blockmap_finalize(hammer_transaction_t trans,
930 hammer_off_t bmap_off, int bytes);
931 int hammer_blockmap_getfree(hammer_mount_t hmp, hammer_off_t bmap_off,
932 int *curp, int *errorp);
933 hammer_off_t hammer_blockmap_lookup(hammer_mount_t hmp, hammer_off_t bmap_off,
934 int *errorp);
935 hammer_off_t hammer_undo_lookup(hammer_mount_t hmp, hammer_off_t bmap_off,
936 int *errorp);
937 int64_t hammer_undo_used(hammer_transaction_t trans);
938 int64_t hammer_undo_space(hammer_transaction_t trans);
939 int64_t hammer_undo_max(hammer_mount_t hmp);
941 void hammer_start_transaction(struct hammer_transaction *trans,
942 struct hammer_mount *hmp);
943 void hammer_simple_transaction(struct hammer_transaction *trans,
944 struct hammer_mount *hmp);
945 void hammer_start_transaction_fls(struct hammer_transaction *trans,
946 struct hammer_mount *hmp);
947 void hammer_done_transaction(struct hammer_transaction *trans);
949 void hammer_modify_inode(hammer_inode_t ip, int flags);
950 void hammer_flush_inode(hammer_inode_t ip, int flags);
951 void hammer_flush_inode_done(hammer_inode_t ip);
952 void hammer_wait_inode(hammer_inode_t ip);
954 int hammer_create_inode(struct hammer_transaction *trans, struct vattr *vap,
955 struct ucred *cred, struct hammer_inode *dip,
956 int pseudofs, struct hammer_inode **ipp);
957 void hammer_rel_inode(hammer_inode_t ip, int flush);
958 int hammer_reload_inode(hammer_inode_t ip, void *arg __unused);
959 int hammer_ino_rb_compare(hammer_inode_t ip1, hammer_inode_t ip2);
961 int hammer_sync_inode(hammer_inode_t ip);
962 void hammer_test_inode(hammer_inode_t ip);
963 void hammer_inode_unloadable_check(hammer_inode_t ip, int getvp);
965 int hammer_ip_add_directory(struct hammer_transaction *trans,
966 hammer_inode_t dip, const char *name, int bytes,
967 hammer_inode_t nip);
968 int hammer_ip_del_directory(struct hammer_transaction *trans,
969 hammer_cursor_t cursor, hammer_inode_t dip,
970 hammer_inode_t ip);
971 hammer_record_t hammer_ip_add_bulk(hammer_inode_t ip, off_t file_offset,
972 void *data, int bytes, int *errorp);
973 int hammer_ip_frontend_trunc(struct hammer_inode *ip, off_t file_size);
974 int hammer_ip_add_record(struct hammer_transaction *trans,
975 hammer_record_t record);
976 int hammer_ip_delete_range(hammer_cursor_t cursor, hammer_inode_t ip,
977 int64_t ran_beg, int64_t ran_end, int truncating);
978 int hammer_ip_delete_clean(hammer_cursor_t cursor, hammer_inode_t ip,
979 int *countp);
980 int hammer_ip_sync_data(hammer_cursor_t cursor, hammer_inode_t ip,
981 int64_t offset, void *data, int bytes);
982 int hammer_ip_sync_record(hammer_transaction_t trans, hammer_record_t rec);
983 int hammer_ip_sync_record_cursor(hammer_cursor_t cursor, hammer_record_t rec);
985 int hammer_ioctl(hammer_inode_t ip, u_long com, caddr_t data, int fflag,
986 struct ucred *cred);
988 void hammer_io_init(hammer_io_t io, hammer_mount_t hmp,
989 enum hammer_io_type type);
990 int hammer_io_read(struct vnode *devvp, struct hammer_io *io,
991 hammer_off_t limit);
992 int hammer_io_new(struct vnode *devvp, struct hammer_io *io);
993 void hammer_io_inval(hammer_volume_t volume, hammer_off_t zone2_offset);
994 struct buf *hammer_io_release(struct hammer_io *io, int flush);
995 void hammer_io_flush(struct hammer_io *io);
996 void hammer_io_waitdep(struct hammer_io *io);
997 void hammer_io_wait_all(hammer_mount_t hmp, const char *ident);
998 int hammer_io_direct_read(hammer_mount_t hmp, struct bio *bio);
999 int hammer_io_direct_write(hammer_mount_t hmp, hammer_btree_leaf_elm_t leaf,
1000 struct bio *bio);
1001 void hammer_io_direct_uncache(hammer_mount_t hmp, hammer_btree_leaf_elm_t leaf);
1002 void hammer_io_write_interlock(hammer_io_t io);
1003 void hammer_io_done_interlock(hammer_io_t io);
1004 void hammer_io_clear_modify(struct hammer_io *io, int inval);
1005 void hammer_io_clear_modlist(struct hammer_io *io);
1006 void hammer_modify_volume(hammer_transaction_t trans, hammer_volume_t volume,
1007 void *base, int len);
1008 void hammer_modify_buffer(hammer_transaction_t trans, hammer_buffer_t buffer,
1009 void *base, int len);
1010 void hammer_modify_volume_done(hammer_volume_t volume);
1011 void hammer_modify_buffer_done(hammer_buffer_t buffer);
1013 int hammer_ioc_reblock(hammer_transaction_t trans, hammer_inode_t ip,
1014 struct hammer_ioc_reblock *reblock);
1015 int hammer_ioc_prune(hammer_transaction_t trans, hammer_inode_t ip,
1016 struct hammer_ioc_prune *prune);
1017 int hammer_ioc_mirror_read(hammer_transaction_t trans, hammer_inode_t ip,
1018 struct hammer_ioc_mirror_rw *mirror);
1019 int hammer_ioc_mirror_write(hammer_transaction_t trans, hammer_inode_t ip,
1020 struct hammer_ioc_mirror_rw *mirror);
1022 int hammer_signal_check(hammer_mount_t hmp);
1024 void hammer_flusher_create(hammer_mount_t hmp);
1025 void hammer_flusher_destroy(hammer_mount_t hmp);
1026 void hammer_flusher_sync(hammer_mount_t hmp);
1027 void hammer_flusher_async(hammer_mount_t hmp);
1028 int hammer_flusher_meta_limit(hammer_mount_t hmp);
1029 int hammer_flusher_undo_exhausted(hammer_transaction_t trans, int quarter);
1030 void hammer_flusher_clean_loose_ios(hammer_mount_t hmp);
1032 int hammer_recover(hammer_mount_t hmp, hammer_volume_t rootvol);
1033 void hammer_recover_flush_buffers(hammer_mount_t hmp,
1034 hammer_volume_t root_volume, int final);
1036 void hammer_crc_set_blockmap(hammer_blockmap_t blockmap);
1037 void hammer_crc_set_volume(hammer_volume_ondisk_t ondisk);
1038 void hammer_crc_set_leaf(void *data, hammer_btree_leaf_elm_t leaf);
1040 int hammer_crc_test_blockmap(hammer_blockmap_t blockmap);
1041 int hammer_crc_test_volume(hammer_volume_ondisk_t ondisk);
1042 int hammer_crc_test_btree(hammer_node_ondisk_t ondisk);
1043 int hammer_crc_test_leaf(void *data, hammer_btree_leaf_elm_t leaf);
1044 void hkprintf(const char *ctl, ...);
1046 int hammer_blocksize(int64_t file_offset);
1047 int64_t hammer_blockdemarc(int64_t file_offset1, int64_t file_offset2);
1049 #endif
1051 static __inline void
1052 hammer_wait_mem_record(hammer_record_t record)
1054 hammer_wait_mem_record_ident(record, "hmmwai");
1057 static __inline void
1058 hammer_lock_ex(struct hammer_lock *lock)
1060 hammer_lock_ex_ident(lock, "hmrlck");
1064 * Indicate that a B-Tree node is being modified.
1066 static __inline void
1067 hammer_modify_node_noundo(hammer_transaction_t trans, hammer_node_t node)
1069 hammer_modify_buffer(trans, node->buffer, NULL, 0);
1072 static __inline void
1073 hammer_modify_node_all(hammer_transaction_t trans, struct hammer_node *node)
1075 hammer_modify_buffer(trans, node->buffer,
1076 node->ondisk, sizeof(*node->ondisk));
1079 static __inline void
1080 hammer_modify_node(hammer_transaction_t trans, hammer_node_t node,
1081 void *base, int len)
1083 hammer_crc_t *crcptr;
1085 KKASSERT((char *)base >= (char *)node->ondisk &&
1086 (char *)base + len <=
1087 (char *)node->ondisk + sizeof(*node->ondisk));
1088 hammer_modify_buffer(trans, node->buffer, base, len);
1089 crcptr = &node->ondisk->crc;
1090 hammer_modify_buffer(trans, node->buffer, crcptr, sizeof(hammer_crc_t));
1091 --node->buffer->io.modify_refs; /* only want one ref */
1095 * Indicate that the specified modifications have been completed.
1097 * Do not try to generate the crc here, it's very expensive to do and a
1098 * sequence of insertions or deletions can result in many calls to this
1099 * function on the same node.
1101 static __inline void
1102 hammer_modify_node_done(hammer_node_t node)
1104 node->flags |= HAMMER_NODE_CRCGOOD;
1105 if ((node->flags & HAMMER_NODE_NEEDSCRC) == 0) {
1106 node->flags |= HAMMER_NODE_NEEDSCRC;
1107 node->buffer->io.gencrc = 1;
1108 hammer_ref_node(node);
1110 hammer_modify_buffer_done(node->buffer);
1113 #define hammer_modify_volume_field(trans, vol, field) \
1114 hammer_modify_volume(trans, vol, &(vol)->ondisk->field, \
1115 sizeof((vol)->ondisk->field))
1117 #define hammer_modify_node_field(trans, node, field) \
1118 hammer_modify_node(trans, node, &(node)->ondisk->field, \
1119 sizeof((node)->ondisk->field))