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.1 2007/10/10 19:37:25 dillon Exp $
37 * This header file contains structures used internally by the HAMMERFS
38 * implementation. See hammerfs.h for on-disk structures.
42 #include <sys/malloc.h>
44 #include "hammer_mount.h"
46 #if defined(_KERNEL) || defined(_KERNEL_STRUCTURES)
48 MALLOC_DECLARE(M_HAMMER);
51 * Key structure used for custom RB tree inode lookups. This prototypes
52 * the function hammer_ino_rb_tree_RB_LOOKUP_INFO(root, info).
54 typedef struct hammer_inode_info {
55 u_int64_t obj_id; /* (key) object identifier */
56 hammer_tid_t obj_asof; /* (key) snapshot transid or 0 */
57 } *hammer_inode_info_t;
60 * Key and caching structure used for HAMMER B-Tree lookups.
62 struct hammer_btree_info {
63 struct hammer_base_elm key;
67 * Structures used to internally represent an inode
69 struct hammer_ino_rb_tree;
71 RB_HEAD(hammer_ino_rb_tree, hammer_inode);
72 RB_PROTOTYPEX(hammer_ino_rb_tree, INFO, hammer_inode, rb_node,
73 hammer_ino_rb_compare, hammer_inode_info_t);
76 RB_ENTRY(hammer_inode) rb_node;
77 u_int64_t obj_id; /* (key) object identifier */
78 hammer_tid_t obj_asof; /* (key) snapshot transid or 0 */
79 struct hammer_mount *hmp;
83 * Structures used to internally represent a volume and a cluster
87 struct hammer_cluster;
88 RB_HEAD(hammer_vol_rb_tree, hammer_volume);
89 RB_HEAD(hammer_clu_rb_tree, hammer_cluster);
91 RB_PROTOTYPE2(hammer_vol_rb_tree, hammer_volume, rb_node,
92 hammer_vol_rb_compare, int32_t);
93 RB_PROTOTYPE2(hammer_clu_rb_tree, hammer_cluster, rb_node,
94 hammer_clu_rb_compare, int32_t);
96 struct hammer_volume {
97 RB_ENTRY(hammer_volume) rb_node;
98 struct hammer_clu_rb_tree rb_clus_root;
99 struct hammer_volume_ondisk *ondisk;
102 int64_t cluster_base; /* base offset of cluster 0 */
105 struct hammer_mount *hmp;
108 struct hammer_cluster {
109 RB_ENTRY(hammer_cluster) rb_node;
110 struct hammer_cluster_ondisk *ondisk;
111 struct hammer_volume *volume;
116 * Internal hammer mount data structure
118 struct hammer_mount {
120 struct vnode *rootvp;
121 struct hammer_ino_rb_tree rb_inos_root;
122 struct hammer_vol_rb_tree rb_vols_root;
123 struct hammer_volume *rootvol;
124 struct hammer_cluster *rootcl;
133 extern struct vop_ops hammer_vnode_vops;
134 int hammer_vop_inactive(struct vop_inactive_args *);
135 int hammer_vop_reclaim(struct vop_reclaim_args *);
136 int hammer_vfs_vget(struct mount *mp, ino_t ino, struct vnode **vpp);
138 int hammer_unload_inode(struct hammer_inode *inode, void *data __unused);
139 int hammer_unload_volume(struct hammer_volume *volume, void *data __unused);
140 int hammer_load_volume(struct hammer_mount *hmp, const char *volname);
141 struct hammer_cluster *hammer_load_cluster(struct hammer_mount *hmp,
142 struct hammer_volume *volume, int clu_no,
145 int hammer_btree_lookup(struct hammer_mount *hmp,
146 struct hammer_btree_info *info);