Merge from vendor branch LIBARCHIVE:
[dragonfly.git] / sys / vfs / hammer / hammer.h
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:
10  * 
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.
20  * 
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.
33  * 
34  * $DragonFly: src/sys/vfs/hammer/hammer.h,v 1.84 2008/06/14 01:42:12 dillon Exp $
35  */
36 /*
37  * This header file contains structures used internally by the HAMMERFS
38  * implementation.  See hammer_disk.h for on-disk structures.
39  */
40
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/globaldata.h>
58
59 #include <sys/buf2.h>
60 #include <sys/signal2.h>
61 #include "hammer_disk.h"
62 #include "hammer_mount.h"
63 #include "hammer_ioctl.h"
64
65 #if defined(_KERNEL) || defined(_KERNEL_STRUCTURES)
66
67 MALLOC_DECLARE(M_HAMMER);
68
69 struct hammer_mount;
70
71 /*
72  * Key structure used for custom RB tree inode lookups.  This prototypes
73  * the function hammer_ino_rb_tree_RB_LOOKUP_INFO(root, info).
74  */
75 typedef struct hammer_inode_info {
76         int64_t         obj_id;         /* (key) object identifier */
77         hammer_tid_t    obj_asof;       /* (key) snapshot transid or 0 */
78 } *hammer_inode_info_t;
79
80 typedef enum hammer_transaction_type {
81         HAMMER_TRANS_RO,
82         HAMMER_TRANS_STD,
83         HAMMER_TRANS_FLS
84 } hammer_transaction_type_t;
85
86 /*
87  * HAMMER Transaction tracking
88  */
89 struct hammer_transaction {
90         hammer_transaction_type_t type;
91         struct hammer_mount *hmp;
92         hammer_tid_t    tid;
93         hammer_tid_t    time;
94         int             sync_lock_refs;
95         struct hammer_volume *rootvol;
96 };
97
98 typedef struct hammer_transaction *hammer_transaction_t;
99
100 /*
101  * HAMMER locks
102  */
103 struct hammer_lock {
104         int     refs;           /* active references delay writes */
105         int     lockcount;      /* lock count for exclusive/shared access */
106         int     wanted;
107         struct thread *locktd;
108 };
109
110 static __inline int
111 hammer_islocked(struct hammer_lock *lock)
112 {
113         return(lock->lockcount != 0);
114 }
115
116 static __inline int
117 hammer_isactive(struct hammer_lock *lock)
118 {
119         return(lock->refs != 0);
120 }
121
122 static __inline int
123 hammer_islastref(struct hammer_lock *lock)
124 {
125         return(lock->refs == 1);
126 }
127
128 /*
129  * Return if we specifically own the lock exclusively.
130  */
131 static __inline int
132 hammer_lock_excl_owned(struct hammer_lock *lock, thread_t td)
133 {
134         if (lock->lockcount > 0 && lock->locktd == td)
135                 return(1);
136         return(0);
137 }
138
139 /*
140  * Flush state, used by various structures
141  */
142 typedef enum hammer_inode_state {
143         HAMMER_FST_IDLE,
144         HAMMER_FST_SETUP,
145         HAMMER_FST_FLUSH
146 } hammer_inode_state_t;
147
148 TAILQ_HEAD(hammer_record_list, hammer_record);
149
150 /*
151  * Cache object ids.  A fixed number of objid cache structures are
152  * created to reserve object id's for newly created files in multiples
153  * of 100,000, localized to a particular directory, and recycled as
154  * needed.  This allows parallel create operations in different
155  * directories to retain fairly localized object ids which in turn
156  * improves reblocking performance and layout.
157  */
158 #define OBJID_CACHE_SIZE        1024
159 #define OBJID_CACHE_BULK        100000
160
161 typedef struct hammer_objid_cache {
162         TAILQ_ENTRY(hammer_objid_cache) entry;
163         struct hammer_inode             *dip;
164         hammer_tid_t                    next_tid;
165         int                             count;
166 } *hammer_objid_cache_t;
167
168 /*
169  * Structure used to represent an inode in-memory.
170  *
171  * The record and data associated with an inode may be out of sync with
172  * the disk (xDIRTY flags), or not even on the disk at all (ONDISK flag
173  * clear).
174  *
175  * An inode may also hold a cache of unsynchronized records, used for
176  * database and directories only.  Unsynchronized regular file data is
177  * stored in the buffer cache.
178  *
179  * NOTE: A file which is created and destroyed within the initial
180  * synchronization period can wind up not doing any disk I/O at all.
181  *
182  * Finally, an inode may cache numerous disk-referencing B-Tree cursors.
183  */
184 struct hammer_ino_rb_tree;
185 struct hammer_inode;
186 RB_HEAD(hammer_ino_rb_tree, hammer_inode);
187 RB_PROTOTYPEX(hammer_ino_rb_tree, INFO, hammer_inode, rb_node,
188               hammer_ino_rb_compare, hammer_inode_info_t);
189
190 struct hammer_rec_rb_tree;
191 struct hammer_record;
192 RB_HEAD(hammer_rec_rb_tree, hammer_record);
193 RB_PROTOTYPEX(hammer_rec_rb_tree, INFO, hammer_record, rb_node,
194               hammer_rec_rb_compare, hammer_btree_leaf_elm_t);
195
196 TAILQ_HEAD(hammer_node_list, hammer_node);
197
198 struct hammer_inode {
199         RB_ENTRY(hammer_inode)  rb_node;
200         hammer_inode_state_t    flush_state;
201         int                     flush_group;
202         TAILQ_ENTRY(hammer_inode) flush_entry;
203         struct hammer_record_list target_list;  /* target of dependant recs */
204         u_int64_t               obj_id;         /* (key) object identifier */
205         hammer_tid_t            obj_asof;       /* (key) snapshot or 0 */
206         struct hammer_mount     *hmp;
207         hammer_objid_cache_t    objid_cache;
208         int                     flags;
209         int                     error;          /* flush error */
210         int                     cursor_ip_refs; /* sanity */
211         int                     rsv_databufs;
212         int                     rsv_recs;
213         struct vnode            *vp;
214         struct lockf            advlock;
215         struct hammer_lock      lock;           /* sync copy interlock */
216         off_t                   trunc_off;
217         struct hammer_btree_leaf_elm ino_leaf;  /* in-memory cache */
218         struct hammer_inode_data ino_data;      /* in-memory cache */
219         struct hammer_rec_rb_tree rec_tree;     /* in-memory cache */
220         struct hammer_node      *cache[2];      /* search initiate cache */
221
222         /*
223          * When a demark is created to synchronize an inode to
224          * disk, certain fields are copied so the front-end VOPs
225          * can continue to run in parallel with the synchronization
226          * occuring in the background.
227          */
228         int             sync_flags;             /* to-sync flags cache */
229         off_t           sync_trunc_off;         /* to-sync truncation */
230         struct hammer_btree_leaf_elm sync_ino_leaf; /* to-sync cache */
231         struct hammer_inode_data sync_ino_data; /* to-sync cache */
232 };
233
234 typedef struct hammer_inode *hammer_inode_t;
235
236 #define VTOI(vp)        ((struct hammer_inode *)(vp)->v_data)
237
238 #define HAMMER_INODE_DDIRTY     0x0001  /* in-memory ino_data is dirty */
239 #define HAMMER_INODE_RSV_INODES 0x0002  /* hmp->rsv_inodes bumped */
240 #define HAMMER_INODE_ITIMES     0x0004  /* in-memory mtime/atime modified */
241 #define HAMMER_INODE_XDIRTY     0x0008  /* in-memory records */
242 #define HAMMER_INODE_ONDISK     0x0010  /* inode is on-disk (else not yet) */
243 #define HAMMER_INODE_FLUSH      0x0020  /* flush on last ref */
244 #define HAMMER_INODE_DELETED    0x0080  /* inode delete (backend) */
245 #define HAMMER_INODE_DELONDISK  0x0100  /* delete synchronized to disk */
246 #define HAMMER_INODE_RO         0x0200  /* read-only (because of as-of) */
247 #define HAMMER_INODE_VHELD      0x0400  /* vnode held on sync */
248 #define HAMMER_INODE_DONDISK    0x0800  /* data records may be on disk */
249 #define HAMMER_INODE_BUFS       0x1000  /* dirty high level bps present */
250 #define HAMMER_INODE_REFLUSH    0x2000  /* pipelined flush during flush */
251 #define HAMMER_INODE_RECLAIM    0x4000  /* trying to reclaim */
252 #define HAMMER_INODE_FLUSHW     0x8000  /* Someone waiting for flush */
253
254 #define HAMMER_INODE_TRUNCATED  0x00010000
255 #define HAMMER_INODE_DELETING   0x00020000 /* inode delete request (frontend)*/
256 #define HAMMER_INODE_RESIGNAL   0x00040000 /* re-signal on re-flush */
257 #define HAMMER_INODE_PARTIALW   0x00080000 /* wait partial record flush */
258
259 #define HAMMER_INODE_MODMASK    (HAMMER_INODE_DDIRTY|                       \
260                                  HAMMER_INODE_XDIRTY|HAMMER_INODE_BUFS|     \
261                                  HAMMER_INODE_ITIMES|HAMMER_INODE_TRUNCATED|\
262                                  HAMMER_INODE_DELETING)
263 #define HAMMER_INODE_MODEASY    (HAMMER_INODE_DDIRTY|HAMMER_INODE_ITIMES)
264
265 #define HAMMER_INODE_MODMASK_NOXDIRTY \
266                                 (HAMMER_INODE_MODMASK & ~HAMMER_INODE_XDIRTY)
267
268 #define HAMMER_MAX_INODE_CURSORS        4
269
270 #define HAMMER_FLUSH_SIGNAL     0x0001
271 #define HAMMER_FLUSH_RECURSION  0x0002
272
273 /*
274  * Used by the inode reclaim code to pipeline reclaims and avoid
275  * blowing out kernel memory or letting the flusher get too far
276  * behind.
277  */
278 struct hammer_reclaim {
279         TAILQ_ENTRY(hammer_reclaim) entry;
280         int     okydoky;
281 };
282
283 #define HAMMER_RECLAIM_PIPESIZE 1000
284
285 /*
286  * Structure used to represent an unsynchronized record in-memory.  These
287  * records typically represent directory entries.  Only non-historical
288  * records are kept in-memory.
289  *
290  * Records are organized as a per-inode RB-Tree.  If the inode is not
291  * on disk then neither are any records and the in-memory record tree
292  * represents the entire contents of the inode.  If the inode is on disk
293  * then the on-disk B-Tree is scanned in parallel with the in-memory
294  * RB-Tree to synthesize the current state of the file.
295  *
296  * Records are also used to enforce the ordering of directory create/delete
297  * operations.  A new inode will not be flushed to disk unless its related
298  * directory entry is also being flushed at the same time.  A directory entry
299  * will not be removed unless its related inode is also being removed at the
300  * same time.
301  */
302 typedef enum hammer_record_type {
303         HAMMER_MEM_RECORD_GENERAL,      /* misc record */
304         HAMMER_MEM_RECORD_INODE,        /* inode record */
305         HAMMER_MEM_RECORD_ADD,          /* positive memory cache record */
306         HAMMER_MEM_RECORD_DEL,          /* negative delete-on-disk record */
307         HAMMER_MEM_RECORD_DATA          /* bulk-data record w/on-disk ref */
308 } hammer_record_type_t;
309
310 struct hammer_record {
311         RB_ENTRY(hammer_record)         rb_node;
312         TAILQ_ENTRY(hammer_record)      target_entry;
313         hammer_inode_state_t            flush_state;
314         int                             flush_group;
315         hammer_record_type_t            type;
316         struct hammer_lock              lock;
317         struct hammer_reserve           *resv;
318         struct hammer_inode             *ip;
319         struct hammer_inode             *target_ip;
320         struct hammer_btree_leaf_elm    leaf;
321         union hammer_data_ondisk        *data;
322         int                             flags;
323 };
324
325 typedef struct hammer_record *hammer_record_t;
326
327 /*
328  * Record flags.  Note that FE can only be set by the frontend if the
329  * record has not been interlocked by the backend w/ BE.
330  */
331 #define HAMMER_RECF_ALLOCDATA           0x0001
332 #define HAMMER_RECF_ONRBTREE            0x0002
333 #define HAMMER_RECF_DELETED_FE          0x0004  /* deleted (frontend) */
334 #define HAMMER_RECF_DELETED_BE          0x0008  /* deleted (backend) */
335 #define HAMMER_RECF_UNUSED0010          0x0010
336 #define HAMMER_RECF_INTERLOCK_BE        0x0020  /* backend interlock */
337 #define HAMMER_RECF_WANTED              0x0040  /* wanted by the frontend */
338 #define HAMMER_RECF_CONVERT_DELETE      0x0100 /* special case */
339
340 /*
341  * In-memory structures representing on-disk structures.
342  */
343 struct hammer_volume;
344 struct hammer_buffer;
345 struct hammer_node;
346 struct hammer_undo;
347 struct hammer_reserve;
348
349 RB_HEAD(hammer_vol_rb_tree, hammer_volume);
350 RB_HEAD(hammer_buf_rb_tree, hammer_buffer);
351 RB_HEAD(hammer_nod_rb_tree, hammer_node);
352 RB_HEAD(hammer_und_rb_tree, hammer_undo);
353 RB_HEAD(hammer_res_rb_tree, hammer_reserve);
354
355 RB_PROTOTYPE2(hammer_vol_rb_tree, hammer_volume, rb_node,
356               hammer_vol_rb_compare, int32_t);
357 RB_PROTOTYPE2(hammer_buf_rb_tree, hammer_buffer, rb_node,
358               hammer_buf_rb_compare, hammer_off_t);
359 RB_PROTOTYPE2(hammer_nod_rb_tree, hammer_node, rb_node,
360               hammer_nod_rb_compare, hammer_off_t);
361 RB_PROTOTYPE2(hammer_und_rb_tree, hammer_undo, rb_node,
362               hammer_und_rb_compare, hammer_off_t);
363 RB_PROTOTYPE2(hammer_res_rb_tree, hammer_reserve, rb_node,
364               hammer_res_rb_compare, hammer_off_t);
365
366 /*
367  * IO management - embedded at the head of various in-memory structures
368  *
369  * VOLUME       - hammer_volume containing meta-data
370  * META_BUFFER  - hammer_buffer containing meta-data
371  * DATA_BUFFER  - hammer_buffer containing pure-data
372  *
373  * Dirty volume headers and dirty meta-data buffers are locked until the
374  * flusher can sequence them out.  Dirty pure-data buffers can be written.
375  * Clean buffers can be passively released.
376  */
377 typedef enum hammer_io_type {
378         HAMMER_STRUCTURE_VOLUME,
379         HAMMER_STRUCTURE_META_BUFFER,
380         HAMMER_STRUCTURE_UNDO_BUFFER,
381         HAMMER_STRUCTURE_DATA_BUFFER
382 } hammer_io_type_t;
383
384 union hammer_io_structure;
385 struct hammer_io;
386
387 struct worklist {
388         LIST_ENTRY(worklist) node;
389 };
390
391 TAILQ_HEAD(hammer_io_list, hammer_io);
392 typedef struct hammer_io_list *hammer_io_list_t;
393
394 struct hammer_io {
395         struct worklist         worklist;
396         struct hammer_lock      lock;
397         enum hammer_io_type     type;
398         struct hammer_mount     *hmp;
399         TAILQ_ENTRY(hammer_io)  mod_entry; /* list entry if modified */
400         hammer_io_list_t        mod_list;
401         struct buf              *bp;
402         int64_t                 offset;
403         int                     loading;   /* loading/unloading interlock */
404         int                     modify_refs;
405
406         u_int           modified : 1;   /* bp's data was modified */
407         u_int           released : 1;   /* bp released (w/ B_LOCKED set) */
408         u_int           running : 1;    /* bp write IO in progress */
409         u_int           waiting : 1;    /* someone is waiting on us */
410         u_int           validated : 1;  /* ondisk has been validated */
411         u_int           waitdep : 1;    /* flush waits for dependancies */
412         u_int           recovered : 1;  /* has recovery ref */
413         u_int           waitmod : 1;    /* waiting for modify_refs */
414         u_int           reclaim : 1;    /* reclaim requested */
415 };
416
417 typedef struct hammer_io *hammer_io_t;
418
419 #define HAMMER_CLUSTER_SIZE     (64 * 1024)
420 #if HAMMER_CLUSTER_SIZE > MAXBSIZE
421 #undef  HAMMER_CLUSTER_SIZE
422 #define HAMMER_CLUSTER_SIZE     MAXBSIZE
423 #endif
424 #define HAMMER_CLUSTER_BUFS     (HAMMER_CLUSTER_SIZE / HAMMER_BUFSIZE)
425
426 /*
427  * In-memory volume representing on-disk buffer
428  */
429 struct hammer_volume {
430         struct hammer_io io;
431         RB_ENTRY(hammer_volume) rb_node;
432         struct hammer_volume_ondisk *ondisk;
433         int32_t vol_no;
434         int64_t nblocks;        /* note: special calculation for statfs */
435         int64_t buffer_base;    /* base offset of buffer 0 */
436         hammer_off_t maxbuf_off; /* Maximum buffer offset (zone-2) */
437         hammer_off_t maxraw_off; /* Maximum raw offset for device */
438         char    *vol_name;
439         struct vnode *devvp;
440         int     vol_flags;
441 };
442
443 typedef struct hammer_volume *hammer_volume_t;
444
445 /*
446  * In-memory buffer (other then volume, super-cluster, or cluster),
447  * representing an on-disk buffer.
448  */
449 struct hammer_buffer {
450         struct hammer_io io;
451         RB_ENTRY(hammer_buffer) rb_node;
452         void *ondisk;
453         struct hammer_volume *volume;
454         hammer_off_t zoneX_offset;
455         hammer_off_t zone2_offset;
456         struct hammer_reserve *resv;
457         struct hammer_node_list clist;
458 };
459
460 typedef struct hammer_buffer *hammer_buffer_t;
461
462 /*
463  * In-memory B-Tree node, representing an on-disk B-Tree node.
464  *
465  * This is a hang-on structure which is backed by a hammer_buffer,
466  * indexed by a hammer_cluster, and used for fine-grained locking of
467  * B-Tree nodes in order to properly control lock ordering.  A hammer_buffer
468  * can contain multiple nodes representing wildly disassociated portions
469  * of the B-Tree so locking cannot be done on a buffer-by-buffer basis.
470  *
471  * This structure uses a cluster-relative index to reduce the number
472  * of layers required to access it, and also because all on-disk B-Tree
473  * references are cluster-relative offsets.
474  */
475 struct hammer_node {
476         struct hammer_lock      lock;           /* node-by-node lock */
477         TAILQ_ENTRY(hammer_node) entry;         /* per-buffer linkage */
478         RB_ENTRY(hammer_node)   rb_node;        /* per-cluster linkage */
479         hammer_off_t            node_offset;    /* full offset spec */
480         struct hammer_mount     *hmp;
481         struct hammer_buffer    *buffer;        /* backing buffer */
482         hammer_node_ondisk_t    ondisk;         /* ptr to on-disk structure */
483         struct hammer_node      **cache1;       /* passive cache(s) */
484         struct hammer_node      **cache2;
485         int                     flags;
486         int                     loading;        /* load interlock */
487 };
488
489 #define HAMMER_NODE_DELETED     0x0001
490 #define HAMMER_NODE_FLUSH       0x0002
491
492 typedef struct hammer_node      *hammer_node_t;
493
494 /*
495  * List of locked nodes.
496  */
497 struct hammer_node_locklist {
498         struct hammer_node_locklist *next;
499         hammer_node_t   node;
500 };
501
502 typedef struct hammer_node_locklist *hammer_node_locklist_t;
503
504
505 /*
506  * Common I/O management structure - embedded in in-memory structures
507  * which are backed by filesystem buffers.
508  */
509 union hammer_io_structure {
510         struct hammer_io        io;
511         struct hammer_volume    volume;
512         struct hammer_buffer    buffer;
513 };
514
515 typedef union hammer_io_structure *hammer_io_structure_t;
516
517 /*
518  * Allocation holes are recorded when an allocation does not fit within a
519  * buffer.  Later allocations which might fit may then be satisfied from
520  * a recorded hole.  The resv reference prevents the big block from being
521  * allocated out of via the normal blockmap mechanism.
522  *
523  * This is strictly a heuristic.
524  */
525 #define HAMMER_MAX_HOLES        8
526
527 struct hammer_hole;
528
529 struct hammer_holes {
530         TAILQ_HEAD(, hammer_hole) list;
531         int     count;
532 };
533
534 typedef struct hammer_holes *hammer_holes_t;
535
536 struct hammer_hole {
537         TAILQ_ENTRY(hammer_hole) entry;
538         struct hammer_reserve *resv;
539         hammer_off_t    zone_offset;
540         int             bytes;
541 };
542
543 typedef struct hammer_hole *hammer_hole_t;
544
545 /*
546  * The reserve structure prevents the blockmap from allocating
547  * out of a reserved bigblock.  Such reservations are used by
548  * the direct-write mechanism.
549  *
550  * The structure is also used to hold off on reallocations of
551  * big blocks from the freemap until flush dependancies have
552  * been dealt with.
553  */
554 struct hammer_reserve {
555         RB_ENTRY(hammer_reserve) rb_node;
556         TAILQ_ENTRY(hammer_reserve) delay_entry;
557         int             flush_group;
558         int             refs;
559         hammer_off_t    zone_offset;
560 };
561
562 typedef struct hammer_reserve *hammer_reserve_t;
563
564 #include "hammer_cursor.h"
565
566 /*
567  * The undo structure tracks recent undos to avoid laying down duplicate
568  * undos within a flush group, saving us a significant amount of overhead.
569  *
570  * This is strictly a heuristic.
571  */
572 #define HAMMER_MAX_UNDOS        1024
573 #define HAMMER_MAX_FLUSHERS     4
574
575 struct hammer_undo {
576         RB_ENTRY(hammer_undo)   rb_node;
577         TAILQ_ENTRY(hammer_undo) lru_entry;
578         hammer_off_t            offset;
579         int                     bytes;
580 };
581
582 typedef struct hammer_undo *hammer_undo_t;
583
584 struct hammer_flusher_info;
585
586 struct hammer_flusher {
587         int             signal;         /* flusher thread sequencer */
588         int             act;            /* currently active flush group */
589         int             done;           /* set to act when complete */
590         int             next;           /* next flush group */
591         int             group_lock;     /* lock sequencing of the next flush */
592         int             exiting;        /* request master exit */
593         int             count;          /* number of slave flushers */
594         int             running;        /* number of slave flushers running */
595         thread_t        td;             /* master flusher thread */
596         hammer_tid_t    tid;            /* last flushed transaction id */
597         int             finalize_want;          /* serialize finalization */
598         struct hammer_lock finalize_lock;       /* serialize finalization */
599         struct hammer_transaction trans;        /* shared transaction */
600         struct hammer_flusher_info *info[HAMMER_MAX_FLUSHERS];
601 };
602
603 /*
604  * Internal hammer mount data structure
605  */
606 struct hammer_mount {
607         struct mount *mp;
608         /*struct vnode *rootvp;*/
609         struct hammer_ino_rb_tree rb_inos_root;
610         struct hammer_vol_rb_tree rb_vols_root;
611         struct hammer_nod_rb_tree rb_nods_root;
612         struct hammer_und_rb_tree rb_undo_root;
613         struct hammer_res_rb_tree rb_resv_root;
614         struct hammer_buf_rb_tree rb_bufs_root;
615         struct hammer_volume *rootvol;
616         struct hammer_base_elm root_btree_beg;
617         struct hammer_base_elm root_btree_end;
618         char    *zbuf;  /* HAMMER_BUFSIZE bytes worth of all-zeros */
619         int     flags;
620         int     hflags;
621         int     ronly;
622         int     nvolumes;
623         int     volume_iterator;
624         int     rsv_inodes;     /* reserved space due to dirty inodes */
625         int     rsv_databufs;   /* reserved space due to dirty buffers */
626         int     rsv_databytes;  /* reserved space due to record data */
627         int     rsv_recs;       /* reserved space due to dirty records */
628
629         int     inode_reclaims; /* inodes pending reclaim by flusher */
630         int     count_inodes;   /* total number of inodes */
631         int     count_iqueued;  /* inodes queued to flusher */
632
633         struct hammer_flusher flusher;
634
635         u_int   check_interrupt;
636         uuid_t  fsid;
637         udev_t  fsid_udev;
638         struct hammer_io_list volu_list;        /* dirty undo buffers */
639         struct hammer_io_list undo_list;        /* dirty undo buffers */
640         struct hammer_io_list data_list;        /* dirty data buffers */
641         struct hammer_io_list alt_data_list;    /* dirty data buffers */
642         struct hammer_io_list meta_list;        /* dirty meta bufs    */
643         struct hammer_io_list lose_list;        /* loose buffers      */
644         int     locked_dirty_count;             /* meta/volu count    */
645         int     io_running_count;
646         int     objid_cache_count;
647         hammer_tid_t asof;
648         hammer_off_t next_tid;
649         int64_t copy_stat_freebigblocks;        /* number of free bigblocks */
650
651         u_int32_t namekey_iterator;
652         hammer_off_t zone_limits[HAMMER_MAX_ZONES];
653         struct netexport export;
654         struct hammer_lock sync_lock;
655         struct hammer_lock free_lock;
656         struct hammer_lock undo_lock;
657         struct hammer_lock blkmap_lock;
658         struct hammer_blockmap  blockmap[HAMMER_MAX_ZONES];
659         struct hammer_holes     holes[HAMMER_MAX_ZONES];
660         struct hammer_undo      undos[HAMMER_MAX_UNDOS];
661         int                     undo_alloc;
662         TAILQ_HEAD(, hammer_undo)  undo_lru_list;
663         TAILQ_HEAD(, hammer_inode) flush_list;
664         TAILQ_HEAD(, hammer_reserve) delay_list;
665         TAILQ_HEAD(, hammer_objid_cache) objid_cache_list;
666         TAILQ_HEAD(, hammer_reclaim) reclaim_list;
667 };
668
669 typedef struct hammer_mount     *hammer_mount_t;
670
671 #define HAMMER_MOUNT_UNUSED0001 0x0001
672
673 struct hammer_sync_info {
674         int error;
675         int waitfor;
676 };
677
678 #endif
679
680 #if defined(_KERNEL)
681
682 extern struct vop_ops hammer_vnode_vops;
683 extern struct vop_ops hammer_spec_vops;
684 extern struct vop_ops hammer_fifo_vops;
685 extern struct bio_ops hammer_bioops;
686
687 extern int hammer_debug_io;
688 extern int hammer_debug_general;
689 extern int hammer_debug_debug;
690 extern int hammer_debug_inode;
691 extern int hammer_debug_locks;
692 extern int hammer_debug_btree;
693 extern int hammer_debug_tid;
694 extern int hammer_debug_recover;
695 extern int hammer_debug_recover_faults;
696 extern int hammer_debug_cluster_enable;
697 extern int hammer_count_inodes;
698 extern int hammer_count_iqueued;
699 extern int hammer_count_reclaiming;
700 extern int hammer_count_records;
701 extern int hammer_count_record_datas;
702 extern int hammer_count_volumes;
703 extern int hammer_count_buffers;
704 extern int hammer_count_nodes;
705 extern int hammer_count_dirtybufs;
706 extern int hammer_count_refedbufs;
707 extern int hammer_count_reservations;
708 extern int hammer_count_io_running_read;
709 extern int hammer_count_io_running_write;
710 extern int hammer_count_io_locked;
711 extern int hammer_limit_dirtybufs;
712 extern int hammer_limit_iqueued;
713 extern int hammer_limit_irecs;
714 extern int hammer_limit_recs;
715 extern int hammer_bio_count;
716 extern int hammer_stats_btree_iterations;
717 extern int hammer_stats_record_iterations;
718 extern int64_t hammer_contention_count;
719
720 int     hammer_vop_inactive(struct vop_inactive_args *);
721 int     hammer_vop_reclaim(struct vop_reclaim_args *);
722 int     hammer_get_vnode(struct hammer_inode *ip, struct vnode **vpp);
723 struct hammer_inode *hammer_get_inode(hammer_transaction_t trans,
724                         struct hammer_node **cache,
725                         u_int64_t obj_id, hammer_tid_t asof, int flags,
726                         int *errorp);
727 void    hammer_put_inode(struct hammer_inode *ip);
728 void    hammer_put_inode_ref(struct hammer_inode *ip);
729
730 int     hammer_unload_volume(hammer_volume_t volume, void *data __unused);
731 int     hammer_adjust_volume_mode(hammer_volume_t volume, void *data __unused);
732
733 int     hammer_unload_buffer(hammer_buffer_t buffer, void *data __unused);
734 int     hammer_install_volume(hammer_mount_t hmp, const char *volname);
735
736 int     hammer_ip_lookup(hammer_cursor_t cursor);
737 int     hammer_ip_first(hammer_cursor_t cursor);
738 int     hammer_ip_next(hammer_cursor_t cursor);
739 int     hammer_ip_resolve_data(hammer_cursor_t cursor);
740 int     hammer_ip_delete_record(hammer_cursor_t cursor, hammer_inode_t ip,
741                         hammer_tid_t tid);
742 int     hammer_delete_at_cursor(hammer_cursor_t cursor, int64_t *stat_bytes);
743 int     hammer_ip_check_directory_empty(hammer_transaction_t trans,
744                         hammer_inode_t ip);
745 int     hammer_sync_hmp(hammer_mount_t hmp, int waitfor);
746 int     hammer_queue_inodes_flusher(hammer_mount_t hmp, int waitfor);
747
748
749 hammer_record_t
750         hammer_alloc_mem_record(hammer_inode_t ip, int data_len);
751 void    hammer_flush_record_done(hammer_record_t record, int error);
752 void    hammer_wait_mem_record_ident(hammer_record_t record, const char *ident);
753 void    hammer_rel_mem_record(hammer_record_t record);
754
755 int     hammer_cursor_up(hammer_cursor_t cursor);
756 int     hammer_cursor_up_locked(hammer_cursor_t cursor);
757 int     hammer_cursor_down(hammer_cursor_t cursor);
758 int     hammer_cursor_upgrade(hammer_cursor_t cursor);
759 int     hammer_cursor_upgrade_node(hammer_cursor_t cursor);
760 void    hammer_cursor_downgrade(hammer_cursor_t cursor);
761 int     hammer_cursor_seek(hammer_cursor_t cursor, hammer_node_t node,
762                         int index);
763 void    hammer_lock_ex_ident(struct hammer_lock *lock, const char *ident);
764 int     hammer_lock_ex_try(struct hammer_lock *lock);
765 void    hammer_lock_sh(struct hammer_lock *lock);
766 int     hammer_lock_sh_try(struct hammer_lock *lock);
767 int     hammer_lock_upgrade(struct hammer_lock *lock);
768 void    hammer_lock_downgrade(struct hammer_lock *lock);
769 void    hammer_unlock(struct hammer_lock *lock);
770 void    hammer_ref(struct hammer_lock *lock);
771 void    hammer_unref(struct hammer_lock *lock);
772
773 void    hammer_sync_lock_ex(hammer_transaction_t trans);
774 void    hammer_sync_lock_sh(hammer_transaction_t trans);
775 int     hammer_sync_lock_sh_try(hammer_transaction_t trans);
776 void    hammer_sync_unlock(hammer_transaction_t trans);
777
778 u_int32_t hammer_to_unix_xid(uuid_t *uuid);
779 void hammer_guid_to_uuid(uuid_t *uuid, u_int32_t guid);
780 void    hammer_to_timespec(hammer_tid_t tid, struct timespec *ts);
781 hammer_tid_t hammer_timespec_to_transid(struct timespec *ts);
782 hammer_tid_t hammer_now_tid(void);
783 hammer_tid_t hammer_str_to_tid(const char *str);
784 hammer_tid_t hammer_alloc_objid(hammer_transaction_t trans, hammer_inode_t dip);
785 void hammer_clear_objid(hammer_inode_t dip);
786 void hammer_destroy_objid_cache(hammer_mount_t hmp);
787
788 int hammer_enter_undo_history(hammer_mount_t hmp, hammer_off_t offset,
789                               int bytes);
790 void hammer_clear_undo_history(hammer_mount_t hmp);
791 enum vtype hammer_get_vnode_type(u_int8_t obj_type);
792 int hammer_get_dtype(u_int8_t obj_type);
793 u_int8_t hammer_get_obj_type(enum vtype vtype);
794 int64_t hammer_directory_namekey(void *name, int len);
795 int     hammer_nohistory(hammer_inode_t ip);
796
797 int     hammer_init_cursor(hammer_transaction_t trans, hammer_cursor_t cursor,
798                            struct hammer_node **cache, hammer_inode_t ip);
799 int     hammer_reinit_cursor(hammer_cursor_t cursor);
800 void    hammer_normalize_cursor(hammer_cursor_t cursor);
801 void    hammer_done_cursor(hammer_cursor_t cursor);
802 void    hammer_mem_done(hammer_cursor_t cursor);
803
804 int     hammer_btree_lookup(hammer_cursor_t cursor);
805 int     hammer_btree_first(hammer_cursor_t cursor);
806 int     hammer_btree_last(hammer_cursor_t cursor);
807 int     hammer_btree_extract(hammer_cursor_t cursor, int flags);
808 int     hammer_btree_iterate(hammer_cursor_t cursor);
809 int     hammer_btree_iterate_reverse(hammer_cursor_t cursor);
810 int     hammer_btree_insert(hammer_cursor_t cursor,
811                             hammer_btree_leaf_elm_t elm);
812 int     hammer_btree_delete(hammer_cursor_t cursor);
813 int     hammer_btree_cmp(hammer_base_elm_t key1, hammer_base_elm_t key2);
814 int     hammer_btree_chkts(hammer_tid_t ts, hammer_base_elm_t key);
815 int     hammer_btree_correct_rhb(hammer_cursor_t cursor, hammer_tid_t tid);
816 int     hammer_btree_correct_lhb(hammer_cursor_t cursor, hammer_tid_t tid);
817
818 int     btree_set_parent(hammer_transaction_t trans, hammer_node_t node,
819                         hammer_btree_elm_t elm);
820 int     hammer_btree_lock_children(hammer_cursor_t cursor,
821                         struct hammer_node_locklist **locklistp);
822 void    hammer_btree_unlock_children(struct hammer_node_locklist **locklistp);
823
824
825 void    hammer_print_btree_node(hammer_node_ondisk_t ondisk);
826 void    hammer_print_btree_elm(hammer_btree_elm_t elm, u_int8_t type, int i);
827
828 void    *hammer_bread(struct hammer_mount *hmp, hammer_off_t off,
829                         int *errorp, struct hammer_buffer **bufferp);
830 void    *hammer_bnew(struct hammer_mount *hmp, hammer_off_t off,
831                         int *errorp, struct hammer_buffer **bufferp);
832
833 hammer_volume_t hammer_get_root_volume(hammer_mount_t hmp, int *errorp);
834
835 hammer_volume_t hammer_get_volume(hammer_mount_t hmp,
836                         int32_t vol_no, int *errorp);
837 hammer_buffer_t hammer_get_buffer(hammer_mount_t hmp,
838                         hammer_off_t buf_offset, int isnew, int *errorp);
839 void            hammer_del_buffers(hammer_mount_t hmp, hammer_off_t base_offset,
840                         hammer_off_t zone2_offset, int bytes);
841
842 int             hammer_ref_volume(hammer_volume_t volume);
843 int             hammer_ref_buffer(hammer_buffer_t buffer);
844 void            hammer_flush_buffer_nodes(hammer_buffer_t buffer);
845
846 void            hammer_rel_volume(hammer_volume_t volume, int flush);
847 void            hammer_rel_buffer(hammer_buffer_t buffer, int flush);
848
849 int             hammer_vfs_export(struct mount *mp, int op,
850                         const struct export_args *export);
851 hammer_node_t   hammer_get_node(hammer_mount_t hmp, hammer_off_t node_offset,
852                         int isnew, int *errorp);
853 void            hammer_ref_node(hammer_node_t node);
854 hammer_node_t   hammer_ref_node_safe(struct hammer_mount *hmp,
855                         struct hammer_node **cache, int *errorp);
856 void            hammer_rel_node(hammer_node_t node);
857 void            hammer_delete_node(hammer_transaction_t trans,
858                         hammer_node_t node);
859 void            hammer_cache_node(hammer_node_t node,
860                         struct hammer_node **cache);
861 void            hammer_uncache_node(struct hammer_node **cache);
862 void            hammer_flush_node(hammer_node_t node);
863
864 void hammer_dup_buffer(struct hammer_buffer **bufferp,
865                         struct hammer_buffer *buffer);
866 hammer_node_t hammer_alloc_btree(hammer_transaction_t trans, int *errorp);
867 void *hammer_alloc_data(hammer_transaction_t trans, int32_t data_len,
868                         u_int16_t rec_type, hammer_off_t *data_offsetp,
869                         struct hammer_buffer **data_bufferp, int *errorp);
870
871 int hammer_generate_undo(hammer_transaction_t trans, hammer_io_t io,
872                         hammer_off_t zone1_offset, void *base, int len);
873
874 void hammer_put_volume(struct hammer_volume *volume, int flush);
875 void hammer_put_buffer(struct hammer_buffer *buffer, int flush);
876
877 hammer_off_t hammer_freemap_alloc(hammer_transaction_t trans,
878                         hammer_off_t owner, int *errorp);
879 void hammer_freemap_free(hammer_transaction_t trans, hammer_off_t phys_offset,
880                         hammer_off_t owner, int *errorp);
881 int hammer_checkspace(hammer_mount_t hmp);
882 hammer_off_t hammer_blockmap_alloc(hammer_transaction_t trans, int zone,
883                         int bytes, int *errorp);
884 hammer_reserve_t hammer_blockmap_reserve(hammer_mount_t hmp, int zone,
885                         int bytes, hammer_off_t *zone_offp, int *errorp);
886 void hammer_blockmap_reserve_complete(hammer_mount_t hmp,
887                         hammer_reserve_t resv);
888 void hammer_blockmap_free(hammer_transaction_t trans,
889                         hammer_off_t bmap_off, int bytes);
890 int hammer_blockmap_getfree(hammer_mount_t hmp, hammer_off_t bmap_off,
891                         int *curp, int *errorp);
892 hammer_off_t hammer_blockmap_lookup(hammer_mount_t hmp, hammer_off_t bmap_off,
893                         int *errorp);
894 hammer_off_t hammer_undo_lookup(hammer_mount_t hmp, hammer_off_t bmap_off,
895                         int *errorp);
896 int64_t hammer_undo_used(hammer_mount_t hmp);
897 int64_t hammer_undo_space(hammer_mount_t hmp);
898 int64_t hammer_undo_max(hammer_mount_t hmp);
899
900 void hammer_start_transaction(struct hammer_transaction *trans,
901                               struct hammer_mount *hmp);
902 void hammer_simple_transaction(struct hammer_transaction *trans,
903                               struct hammer_mount *hmp);
904 void hammer_start_transaction_fls(struct hammer_transaction *trans,
905                                   struct hammer_mount *hmp);
906 void hammer_done_transaction(struct hammer_transaction *trans);
907
908 void hammer_modify_inode(hammer_inode_t ip, int flags);
909 void hammer_flush_inode(hammer_inode_t ip, int flags);
910 void hammer_flush_inode_done(hammer_inode_t ip);
911 void hammer_wait_inode(hammer_inode_t ip);
912 void hammer_wait_inode_recs(hammer_inode_t ip);
913
914 int  hammer_create_inode(struct hammer_transaction *trans, struct vattr *vap,
915                         struct ucred *cred, struct hammer_inode *dip,
916                         struct hammer_inode **ipp);
917 void hammer_rel_inode(hammer_inode_t ip, int flush);
918 int hammer_reload_inode(hammer_inode_t ip, void *arg __unused);
919 int hammer_ino_rb_compare(hammer_inode_t ip1, hammer_inode_t ip2);
920
921 int hammer_sync_inode(hammer_inode_t ip);
922 void hammer_test_inode(hammer_inode_t ip);
923 void hammer_inode_unloadable_check(hammer_inode_t ip, int getvp);
924
925 int  hammer_ip_add_directory(struct hammer_transaction *trans,
926                         hammer_inode_t dip, struct namecache *ncp,
927                         hammer_inode_t nip);
928 int  hammer_ip_del_directory(struct hammer_transaction *trans,
929                         hammer_cursor_t cursor, hammer_inode_t dip,
930                         hammer_inode_t ip);
931 hammer_record_t hammer_ip_add_bulk(hammer_inode_t ip, off_t file_offset,
932                         void *data, int bytes, int *errorp);
933 int  hammer_ip_frontend_trunc(struct hammer_inode *ip, off_t file_size);
934 int  hammer_ip_add_record(struct hammer_transaction *trans,
935                         hammer_record_t record);
936 int  hammer_ip_delete_range(hammer_cursor_t cursor, hammer_inode_t ip,
937                         int64_t ran_beg, int64_t ran_end, int truncating);
938 int  hammer_ip_delete_range_all(hammer_cursor_t cursor, hammer_inode_t ip,
939                         int *countp);
940 int  hammer_ip_sync_data(hammer_cursor_t cursor, hammer_inode_t ip,
941                         int64_t offset, void *data, int bytes);
942 int  hammer_ip_sync_record(hammer_transaction_t trans, hammer_record_t rec);
943 int  hammer_ip_sync_record_cursor(hammer_cursor_t cursor, hammer_record_t rec);
944
945 int hammer_ioctl(hammer_inode_t ip, u_long com, caddr_t data, int fflag,
946                         struct ucred *cred);
947
948 void hammer_io_init(hammer_io_t io, hammer_mount_t hmp,
949                         enum hammer_io_type type);
950 int hammer_io_read(struct vnode *devvp, struct hammer_io *io,
951                         hammer_off_t limit);
952 int hammer_io_new(struct vnode *devvp, struct hammer_io *io);
953 void hammer_io_inval(hammer_volume_t volume, hammer_off_t zone2_offset);
954 void hammer_io_release(struct hammer_io *io, int flush);
955 void hammer_io_flush(struct hammer_io *io);
956 void hammer_io_waitdep(struct hammer_io *io);
957 void hammer_io_wait_all(hammer_mount_t hmp, const char *ident);
958 int hammer_io_direct_read(hammer_mount_t hmp, hammer_off_t data_offset,
959                           struct bio *bio);
960 int hammer_io_direct_write(hammer_mount_t hmp, hammer_btree_leaf_elm_t leaf,
961                           struct bio *bio);
962 void hammer_io_write_interlock(hammer_io_t io);
963 void hammer_io_done_interlock(hammer_io_t io);
964 void hammer_io_clear_modify(struct hammer_io *io);
965 void hammer_io_clear_modlist(struct hammer_io *io);
966 void hammer_modify_volume(hammer_transaction_t trans, hammer_volume_t volume,
967                         void *base, int len);
968 void hammer_modify_buffer(hammer_transaction_t trans, hammer_buffer_t buffer,
969                         void *base, int len);
970 void hammer_modify_volume_done(hammer_volume_t volume);
971 void hammer_modify_buffer_done(hammer_buffer_t buffer);
972
973 int hammer_ioc_reblock(hammer_transaction_t trans, hammer_inode_t ip,
974                         struct hammer_ioc_reblock *reblock);
975 int hammer_ioc_prune(hammer_transaction_t trans, hammer_inode_t ip,
976                         struct hammer_ioc_prune *prune);
977
978 void hammer_init_holes(hammer_mount_t hmp, hammer_holes_t holes);
979 void hammer_free_holes(hammer_mount_t hmp, hammer_holes_t holes);
980 int hammer_signal_check(hammer_mount_t hmp);
981
982 void hammer_flusher_create(hammer_mount_t hmp);
983 void hammer_flusher_destroy(hammer_mount_t hmp);
984 void hammer_flusher_sync(hammer_mount_t hmp);
985 void hammer_flusher_async(hammer_mount_t hmp);
986
987 int hammer_recover(hammer_mount_t hmp, hammer_volume_t rootvol);
988 void hammer_recover_flush_buffers(hammer_mount_t hmp,
989                         hammer_volume_t root_volume);
990
991 void hammer_crc_set_blockmap(hammer_blockmap_t blockmap);
992 void hammer_crc_set_volume(hammer_volume_ondisk_t ondisk);
993
994 int hammer_crc_test_blockmap(hammer_blockmap_t blockmap);
995 int hammer_crc_test_volume(hammer_volume_ondisk_t ondisk);
996 int hammer_crc_test_btree(hammer_node_ondisk_t ondisk);
997 void hkprintf(const char *ctl, ...);
998
999 #endif
1000
1001 static __inline void
1002 hammer_wait_mem_record(hammer_record_t record)
1003 {
1004         hammer_wait_mem_record_ident(record, "hmmwai");
1005 }
1006
1007 static __inline void
1008 hammer_lock_ex(struct hammer_lock *lock)
1009 {
1010         hammer_lock_ex_ident(lock, "hmrlck");
1011 }
1012
1013 static __inline void
1014 hammer_modify_node_noundo(hammer_transaction_t trans, hammer_node_t node)
1015 {
1016         hammer_modify_buffer(trans, node->buffer, NULL, 0);
1017 }
1018
1019 static __inline void
1020 hammer_modify_node_all(hammer_transaction_t trans, struct hammer_node *node)
1021 {
1022         hammer_modify_buffer(trans, node->buffer,
1023                              node->ondisk, sizeof(*node->ondisk));
1024 }
1025
1026 static __inline void
1027 hammer_modify_node(hammer_transaction_t trans, hammer_node_t node,
1028                    void *base, int len)
1029 {
1030         hammer_crc_t *crcptr;
1031
1032         KKASSERT((char *)base >= (char *)node->ondisk &&
1033                  (char *)base + len <=
1034                     (char *)node->ondisk + sizeof(*node->ondisk));
1035         hammer_modify_buffer(trans, node->buffer, base, len);
1036         crcptr = &node->ondisk->crc;
1037         hammer_modify_buffer(trans, node->buffer, crcptr, sizeof(hammer_crc_t));
1038         --node->buffer->io.modify_refs; /* only want one ref */
1039 }
1040
1041 static __inline void
1042 hammer_modify_node_done(hammer_node_t node)
1043 {
1044         node->ondisk->crc = crc32(&node->ondisk->crc + 1, HAMMER_BTREE_CRCSIZE);
1045         hammer_modify_buffer_done(node->buffer);
1046 }
1047
1048 #define hammer_modify_volume_field(trans, vol, field)           \
1049         hammer_modify_volume(trans, vol, &(vol)->ondisk->field, \
1050                              sizeof((vol)->ondisk->field))
1051
1052 #define hammer_modify_node_field(trans, node, field)            \
1053         hammer_modify_node(trans, node, &(node)->ondisk->field, \
1054                              sizeof((node)->ondisk->field))
1055