2 * Copyright (c) 2011-2012 The DragonFly Project. All rights reserved.
4 * This code is derived from software contributed to The DragonFly Project
5 * by Matthew Dillon <dillon@dragonflybsd.org>
6 * by Venkatesh Srinivas <vsrinivas@dragonflybsd.org>
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in
16 * the documentation and/or other materials provided with the
18 * 3. Neither the name of The DragonFly Project nor the names of its
19 * contributors may be used to endorse or promote products derived
20 * from this software without specific, prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27 * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
28 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
30 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
31 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
32 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37 * This header file contains structures used internally by the HAMMER2
38 * implementation. See hammer2_disk.h for on-disk structures.
41 #ifndef _VFS_HAMMER2_HAMMER2_H_
42 #define _VFS_HAMMER2_HAMMER2_H_
44 #include <sys/param.h>
45 #include <sys/types.h>
46 #include <sys/kernel.h>
48 #include <sys/systm.h>
50 #include <sys/malloc.h>
51 #include <sys/mount.h>
52 #include <sys/vnode.h>
54 #include <sys/mountctl.h>
57 #include <sys/globaldata.h>
58 #include <sys/lockf.h>
60 #include <sys/queue.h>
61 #include <sys/limits.h>
63 #include <sys/signal2.h>
66 #include "hammer2_disk.h"
67 #include "hammer2_mount.h"
75 struct hammer2_inode {
76 struct hammer2_mount *hmp;
79 hammer2_inode_data_t data;
85 typedef struct hammer2_inode hammer2_inode_t;
87 #define HAMMER2_INODE_TYPE_DIR 0x01
88 #define HAMMER2_INODE_TYPE_FILE 0x02
89 #define HAMMER2_INODE_TYPE_ROOT 0x10
90 #define HAMMER2_INODE_TYPE_MASK 0x07
93 * Governing mount structure for filesystem (aka vp->v_mount)
95 struct hammer2_mount {
97 int ronly; /* block device mounted read-only */
98 struct vnode *devvp; /* device vnode */
101 struct hammer2_inode *iroot;
103 struct malloc_type *inodes;
107 struct malloc_type *ipstacks;
111 hammer2_volume_data_t voldata;
113 struct netexport export;
116 typedef struct hammer2_mount hammer2_mount_t;
120 MALLOC_DECLARE(M_HAMMER2);
124 H2TOMP(struct hammer2_mount *hmp)
126 return (struct mount *) hmp->mp;
129 #define VTOI(vp) ((hammer2_inode_t *)(vp)->v_data)
130 #define ITOV(ip) ((ip)->vp)
133 struct hammer2_mount *
134 MPTOH2(struct mount *mp)
136 return (hammer2_mount_t *) mp->mnt_data;
139 extern struct vop_ops hammer2_vnode_vops;
140 extern struct vop_ops hammer2_spec_vops;
141 extern struct vop_ops hammer2_fifo_vops;
145 void hammer2_inode_lock_sh(hammer2_inode_t *ip);
146 void hammer2_inode_lock_up(hammer2_inode_t *ip);
147 void hammer2_inode_lock_ex(hammer2_inode_t *ip);
148 void hammer2_inode_unlock_ex(hammer2_inode_t *ip);
149 void hammer2_inode_unlock_up(hammer2_inode_t *ip);
150 void hammer2_inode_unlock_sh(hammer2_inode_t *ip);
152 void hammer2_mount_exlock(hammer2_mount_t *hmp);
153 void hammer2_mount_shlock(hammer2_mount_t *hmp);
154 void hammer2_mount_unlock(hammer2_mount_t *hmp);
156 struct vnode *hammer2_igetv(hammer2_inode_t *ip, int *errorp);
157 hammer2_inode_t *hammer2_alloci(hammer2_mount_t *hmp);
158 void hammer2_freei(hammer2_inode_t *ip);
160 #endif /* !_KERNEL */
161 #endif /* !_VFS_HAMMER2_HAMMER2_H_ */