1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36 #ifndef _xfs_xnode_h
37 #define _xfs_xnode_h
38
39 #include <sys/types.h>
40 #include <sys/time.h>
41 #ifdef HAVE_KERNEL_LF_ADVLOCK
42 #include <sys/lockf.h>
43 #endif
44
45 #include <xfs/xfs_attr.h>
46 #include <xfs/xfs_message.h>
47 #include <xfs/xfs_queue.h>
48
49 #ifdef __APPLE__
50 typedef struct lock__bsd__ xfs_vnode_lock;
51 #else
52 typedef struct lock xfs_vnode_lock;
53 #endif
54
55 struct xfs_node {
56 #if defined(__NetBSD_Version__) && __NetBSD_Version__ >= 105280000
57 struct genfs_node gnode;
58 #endif
59 struct vnode *vn;
60 struct vnode *data;
61 struct vattr attr;
62 uint32_t offset;
63 u_int flags;
64 u_int tokens;
65 xfs_handle handle;
66 xfs_pag_t id[MAXRIGHTS];
67 u_char rights[MAXRIGHTS];
68 u_char anonrights;
69 #if defined(HAVE_KERNEL_LOCKMGR) || defined(HAVE_KERNEL_DEBUGLOCKMGR)
70 xfs_vnode_lock lock;
71 #else
72 int vnlocks;
73 #endif
74 #ifdef HAVE_KERNEL_LF_ADVLOCK
75 struct lockf *lockf;
76 #endif
77 struct ucred *rd_cred;
78 struct ucred *wr_cred;
79 NNPQUEUE_ENTRY(xfs_node) nn_hash;
80 };
81
82 #define XN_HASHSIZE 101
83
84 NNPQUEUE_HEAD(nh_node_list, xfs_node);
85
86 struct xfs_nodelist_head {
87 struct nh_node_list nh_nodelist[XN_HASHSIZE];
88 };
89
90 void nnfs_init_head(struct xfs_nodelist_head *);
91 void xfs_node_purge(struct xfs_nodelist_head *,
92 void (*func)(struct xfs_node *));
93 struct xfs_node *
94 xfs_node_find(struct xfs_nodelist_head *, xfs_handle *);
95 void xfs_remove_node(struct xfs_nodelist_head *, struct xfs_node *);
96 void xfs_insert(struct xfs_nodelist_head *, struct xfs_node *);
97 int xfs_update_handle(struct xfs_nodelist_head *, xfs_handle *,
98 xfs_handle *);
99
100
101 struct xfs;
102
103 int xfs_getnewvnode(struct xfs *xfsp, struct vnode **vpp,
104 struct xfs_handle *handle);
105
106
107 #define DATA_FROM_VNODE(vp) DATA_FROM_XNODE(VNODE_TO_XNODE(vp))
108
109 #define DATA_FROM_XNODE(xp) ((xp)->data)
110
111 #define XNODE_TO_VNODE(xp) ((xp)->vn)
112 #define VNODE_TO_XNODE(vp) ((struct xfs_node *) (vp)->v_data)
113
114 #if defined(HAVE_ONE_ARGUMENT_VGET)
115 #define xfs_do_vget(vp, lockflag, proc) vget((vp))
116 #elif defined(HAVE_TWO_ARGUMENT_VGET)
117 #define xfs_do_vget(vp, lockflag, proc) vget((vp), (lockflag))
118 #elif defined(HAVE_THREE_ARGUMENT_VGET)
119 #define xfs_do_vget(vp, lockflag, proc) vget((vp), (lockflag), (proc))
120 #else
121 #error what kind of vget
122 #endif
123
124 #ifndef HAVE_VOP_T
125 typedef int vop_t (void *);
126 #endif
127
128 #ifdef LK_INTERLOCK
129 #define HAVE_LK_INTERLOCK
130 #else
131 #define LK_INTERLOCK 0
132 #endif
133
134 #ifdef LK_RETRY
135 #define HAVE_LK_RETRY
136 #else
137 #define LK_RETRY 0
138 #endif
139
140
141
142
143
144
145
146 #ifdef LK_EXCLUSIVE
147 #define HAVE_LK_EXCLUSIVE 1
148 #else
149 #define LK_EXCLUSIVE 1
150 #endif
151
152 #ifdef LK_SHARED
153 #define HAVE_LK_SHARED 1
154 #else
155 #define LK_SHARED 1
156 #endif
157
158 void xfs_update_write_cred(struct xfs_node *, struct ucred *);
159 void xfs_update_read_cred(struct xfs_node *, struct ucred *);
160
161 #endif