hammer2 - followup cleanup
[dragonfly.git] / sys / vfs / hammer2 / hammer2_vnops.c
CommitLineData
e118c14f
MD
1/*
2 * Copyright (c) 2011-2012 The DragonFly Project. All rights reserved.
3 *
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>
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 *
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
17 * distribution.
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.
21 *
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
33 * SUCH DAMAGE.
34 */
703720e4
MD
35#include <sys/param.h>
36#include <sys/systm.h>
37#include <sys/kernel.h>
38#include <sys/fcntl.h>
39#include <sys/buf.h>
40#include <sys/proc.h>
41#include <sys/namei.h>
42#include <sys/mount.h>
43#include <sys/vnode.h>
f0206a67 44#include <sys/mountctl.h>
703720e4
MD
45
46#include "hammer2.h"
47
703720e4
MD
48/*
49 * Last reference to a vnode is going away but it is still cached.
50 */
e118c14f 51static
703720e4 52int
e118c14f 53hammer2_vop_inactive(struct vop_inactive_args *ap)
703720e4
MD
54{
55 struct vnode *vp;
56 struct hammer2_inode *ip;
e118c14f 57#if 0
703720e4 58 struct hammer2_mount *hmp;
e118c14f 59#endif
703720e4
MD
60
61 kprintf("hammer2_inactive\n");
62
63 vp = ap->a_vp;
64 ip = VTOI(vp);
703720e4
MD
65
66 return (0);
67}
68
69/*
70 * Reclaim a vnode so that it can be reused; after the inode is
71 * disassociated, the filesystem must manage it alone.
72 */
e118c14f 73static
703720e4 74int
e118c14f 75hammer2_vop_reclaim(struct vop_reclaim_args *ap)
703720e4
MD
76{
77 struct vnode *vp;
78 struct hammer2_inode *ip;
79 struct hammer2_mount *hmp;
80
703720e4
MD
81 vp = ap->a_vp;
82 ip = VTOI(vp);
54eb943b 83 hmp = ip->hmp;
703720e4 84
54eb943b 85 hammer2_inode_lock_ex(ip);
703720e4 86 vp->v_data = NULL;
0e92b724 87 ip->vp = NULL;
54eb943b
MD
88 hammer2_inode_unlock_ex(ip);
89
90 /*
91 * XXX handle background sync when ip dirty, kernel will no longer
92 * notify us regarding this inode because there is no longer a
93 * vnode attached to it.
94 */
703720e4
MD
95
96 return (0);
97}
98
e118c14f 99static
703720e4 100int
e118c14f 101hammer2_vop_fsync(struct vop_fsync_args *ap)
703720e4
MD
102{
103 kprintf("hammer2_fsync\n");
104 return (EOPNOTSUPP);
105}
106
e118c14f 107static
703720e4 108int
e118c14f 109hammer2_vop_access(struct vop_access_args *ap)
703720e4
MD
110{
111 kprintf("hammer2_access\n");
112 return (0);
113}
114
e118c14f 115static
703720e4 116int
e118c14f 117hammer2_vop_getattr(struct vop_getattr_args *ap)
703720e4
MD
118{
119 struct vnode *vp;
120 struct vattr *vap;
121 struct hammer2_inode *ip;
122
123 vp = ap->a_vp;
124 vap = ap->a_vap;
125
126 kprintf("hammer2_getattr\n");
127
128 ip = VTOI(vp);
129 hammer2_inode_lock_sh(ip);
130
131 vap->va_type = vp->v_type;
132 vap->va_mode = 0777;
133 vap->va_nlink = 1;
134 vap->va_uid = 0;
135 vap->va_gid = 0;
136 vap->va_size = 0;
137 vap->va_blocksize = PAGE_SIZE;
138 vap->va_flags = 0;
139
140 hammer2_inode_unlock_sh(ip);
141
142 return (0);
143}
144
e118c14f 145static
703720e4 146int
e118c14f 147hammer2_vop_readdir(struct vop_readdir_args *ap)
703720e4
MD
148{
149 kprintf("hammer2_readdir\n");
150 return (EOPNOTSUPP);
151}
152
e118c14f 153static
703720e4 154int
e118c14f 155hammer2_vop_read(struct vop_read_args *ap)
703720e4 156{
47902fef
VS
157 return (EOPNOTSUPP);
158}
703720e4 159
e118c14f 160static
47902fef 161int
e118c14f 162hammer2_vop_write(struct vop_write_args *ap)
47902fef
VS
163{
164 return (EOPNOTSUPP);
703720e4
MD
165}
166
e118c14f 167static
703720e4 168int
e118c14f 169hammer2_vop_nresolve(struct vop_nresolve_args *ap)
703720e4
MD
170{
171 kprintf("hammer2_nresolve\n");
47902fef 172 return (EOPNOTSUPP);
703720e4
MD
173}
174
e118c14f 175static
703720e4 176int
e118c14f 177hammer2_vop_bmap(struct vop_bmap_args *ap)
703720e4
MD
178{
179 kprintf("hammer2_bmap\n");
180 return (EOPNOTSUPP);
181}
182
e118c14f 183static
703720e4 184int
e118c14f 185hammer2_vop_open(struct vop_open_args *ap)
703720e4
MD
186{
187 kprintf("hammer2_open\n");
188 return vop_stdopen(ap);
189}
190
e118c14f 191static
703720e4 192int
e118c14f 193hammer2_vop_strategy(struct vop_strategy_args *ap)
703720e4
MD
194{
195 struct vnode *vp;
196 struct bio *biop;
197 struct buf *bp;
198 struct hammer2_inode *ip;
199 int error;
200
201 vp = ap->a_vp;
202 biop = ap->a_bio;
203 bp = biop->bio_buf;
204 ip = VTOI(vp);
205
206 switch(bp->b_cmd) {
207 case (BUF_CMD_READ):
208 case (BUF_CMD_WRITE):
209 default:
210 bp->b_error = error = EINVAL;
211 bp->b_flags |= B_ERROR;
212 biodone(biop);
213 break;
214 }
215
216 return (error);
217}
218
e118c14f 219static
f0206a67 220int
e118c14f 221hammer2_vop_mountctl(struct vop_mountctl_args *ap)
f0206a67
VS
222{
223 struct mount *mp;
224 struct hammer2_mount *hmp;
225 int rc;
226
227 switch (ap->a_op) {
228 case (MOUNTCTL_SET_EXPORT):
229 mp = ap->a_head.a_ops->head.vv_mount;
230 hmp = MPTOH2(mp);
231
232 if (ap->a_ctllen != sizeof(struct export_args))
233 rc = (EINVAL);
234 else
10c5dee0
MD
235 rc = vfs_export(mp, &hmp->export,
236 (const struct export_args *)ap->a_ctl);
f0206a67
VS
237 break;
238 default:
239 rc = vop_stdmountctl(ap);
240 break;
241 }
242 return (rc);
243}
244
703720e4
MD
245struct vop_ops hammer2_vnode_vops = {
246 .vop_default = vop_defaultop,
e118c14f 247 .vop_fsync = hammer2_vop_fsync,
703720e4
MD
248 .vop_getpages = vop_stdgetpages,
249 .vop_putpages = vop_stdputpages,
e118c14f
MD
250 .vop_access = hammer2_vop_access,
251 .vop_getattr = hammer2_vop_getattr,
252 .vop_readdir = hammer2_vop_readdir,
253 .vop_read = hammer2_vop_read,
254 .vop_write = hammer2_vop_write,
255 .vop_open = hammer2_vop_open,
256 .vop_inactive = hammer2_vop_inactive,
257 .vop_reclaim = hammer2_vop_reclaim,
258 .vop_nresolve = hammer2_vop_nresolve,
259 .vop_mountctl = hammer2_vop_mountctl,
260 .vop_bmap = hammer2_vop_bmap,
261 .vop_strategy = hammer2_vop_strategy,
703720e4
MD
262};
263
264struct vop_ops hammer2_spec_vops = {
265
266};
267
268struct vop_ops hammer2_fifo_vops = {
269
270};