3 * Copyright (c) 2004 The DragonFly Project. All rights reserved.
5 * This code is derived from software contributed to The DragonFly Project
6 * by Matthew Dillon <dillon@backplane.com>
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
35 * $DragonFly: src/sys/kern/vfs_vopops.c,v 1.21 2006/04/25 22:11:28 dillon Exp $
38 #include <sys/param.h>
39 #include <sys/systm.h>
42 #include <sys/dirent.h>
43 #include <sys/domain.h>
44 #include <sys/eventhandler.h>
45 #include <sys/fcntl.h>
46 #include <sys/kernel.h>
47 #include <sys/kthread.h>
48 #include <sys/malloc.h>
50 #include <sys/mount.h>
52 #include <sys/namei.h>
53 #include <sys/reboot.h>
54 #include <sys/socket.h>
56 #include <sys/sysctl.h>
57 #include <sys/syslog.h>
58 #include <sys/vmmeter.h>
59 #include <sys/vnode.h>
60 #include <sys/vfsops.h>
62 #include <machine/limits.h>
65 #include <vm/vm_object.h>
66 #include <vm/vm_extern.h>
67 #include <vm/vm_kern.h>
69 #include <vm/vm_map.h>
70 #include <vm/vm_page.h>
71 #include <vm/vm_pager.h>
72 #include <vm/vnode_pager.h>
73 #include <vm/vm_zone.h>
76 #include <sys/thread2.h>
78 #define VOFFNAME(name) __CONCAT(__CONCAT(vop_,name),_vp_offsets)
79 #define VDESCNAME(name) __CONCAT(__CONCAT(vop_,name),_desc)
80 #define VARGSSTRUCT(name) struct __CONCAT(__CONCAT(vop_,name),_args)
82 #define VNODEOP_DESC_INIT(name, flags, vpoffs, vpp, cred, proc, comp) \
83 struct vnodeop_desc VDESCNAME(name) = { \
84 __offsetof(struct vop_ops, __CONCAT(vop_, name)), \
85 #name, flags, vpoffs, vpp, cred, proc, comp }
87 #define VNODEOP_DESC_INIT_SIMPLE(name) \
88 VNODEOP_DESC_INIT(name, 0, NULL, \
94 #define VNODEOP_DESC_INIT_VP(name) \
95 static int VOFFNAME(name)[] = { \
96 __offsetof(VARGSSTRUCT(name), a_vp), \
98 VNODEOP_DESC_INIT(name, 0, VOFFNAME(name), \
104 #define VNODEOP_DESC_INIT_VP_VPP(name) \
105 static int VOFFNAME(name)[] = { \
106 __offsetof(VARGSSTRUCT(name), a_vp), \
108 VNODEOP_DESC_INIT(name, 0, VOFFNAME(name), \
109 __offsetof(VARGSSTRUCT(name), a_vpp), \
114 #define VNODEOP_DESC_INIT_VP_CRED(name) \
115 static int VOFFNAME(name)[] = { \
116 __offsetof(VARGSSTRUCT(name), a_vp), \
118 VNODEOP_DESC_INIT(name, 0, VOFFNAME(name), \
120 __offsetof(VARGSSTRUCT(name), a_cred), \
124 #define VNODEOP_DESC_INIT_NCP(name) \
125 VNODEOP_DESC_INIT(name, 0, NULL, \
131 #define VNODEOP_DESC_INIT_NCP2_CRED(name) \
132 VNODEOP_DESC_INIT(name, 0, NULL, \
134 __offsetof(VARGSSTRUCT(name), a_cred), \
138 #define VNODEOP_DESC_INIT_NCP_CRED(name) \
139 VNODEOP_DESC_INIT(name, 0, NULL, \
141 __offsetof(VARGSSTRUCT(name), a_cred), \
145 #define VNODEOP_DESC_INIT_NCP_VP_CRED(name) \
146 static int VOFFNAME(name)[] = { \
147 __offsetof(VARGSSTRUCT(name), a_vp), \
149 VNODEOP_DESC_INIT(name, 0, VOFFNAME(name), \
151 __offsetof(VARGSSTRUCT(name), a_cred), \
155 #define VNODEOP_DESC_INIT_NCP_CRED_VPP(name) \
156 VNODEOP_DESC_INIT(name, 0, NULL, \
157 __offsetof(VARGSSTRUCT(name), a_vpp), \
158 __offsetof(VARGSSTRUCT(name), a_cred), \
162 #define VNODEOP_DESC_INIT_DVP_VPP_CNP(name) \
163 static int VOFFNAME(name)[] = { \
164 __offsetof(VARGSSTRUCT(name), a_dvp), \
166 VNODEOP_DESC_INIT(name, 0, VOFFNAME(name), \
167 __offsetof(VARGSSTRUCT(name), a_vpp), \
170 __offsetof(VARGSSTRUCT(name), a_cnp))
172 #define VNODEOP_DESC_INIT_DVP_VPP_CRED(name) \
173 static int VOFFNAME(name)[] = { \
174 __offsetof(VARGSSTRUCT(name), a_dvp), \
176 VNODEOP_DESC_INIT(name, 0, VOFFNAME(name), \
177 __offsetof(VARGSSTRUCT(name), a_vpp), \
178 __offsetof(VARGSSTRUCT(name), a_cred), \
182 #define VNODEOP_DESC_INIT_DVP_CNP(name) \
183 static int VOFFNAME(name)[] = { \
184 __offsetof(VARGSSTRUCT(name), a_dvp), \
186 VNODEOP_DESC_INIT(name, 0, VOFFNAME(name), \
190 __offsetof(VARGSSTRUCT(name), a_cnp))
192 #define VNODEOP_DESC_INIT_DVP_VP_CNP(name) \
193 static int VOFFNAME(name)[] = { \
194 __offsetof(VARGSSTRUCT(name), a_dvp), \
195 __offsetof(VARGSSTRUCT(name), a_vp), \
197 VNODEOP_DESC_INIT(name, 0, VOFFNAME(name), \
201 __offsetof(VARGSSTRUCT(name), a_cnp))
203 #define VNODEOP_DESC_INIT_TDVP_VP_CNP(name) \
204 static int VOFFNAME(name)[] = { \
205 __offsetof(VARGSSTRUCT(name), a_tdvp), \
206 __offsetof(VARGSSTRUCT(name), a_vp), \
208 VNODEOP_DESC_INIT(name, 0, VOFFNAME(name), \
212 __offsetof(VARGSSTRUCT(name), a_cnp))
214 VNODEOP_DESC_INIT_SIMPLE(default);
215 VNODEOP_DESC_INIT_VP(islocked);
216 VNODEOP_DESC_INIT_DVP_VPP_CNP(old_lookup);
217 VNODEOP_DESC_INIT_DVP_VPP_CNP(old_create);
218 VNODEOP_DESC_INIT_DVP_CNP(old_whiteout);
219 VNODEOP_DESC_INIT_DVP_VPP_CNP(old_mknod);
220 VNODEOP_DESC_INIT_VP_CRED(open);
221 VNODEOP_DESC_INIT_VP(close);
222 VNODEOP_DESC_INIT_VP_CRED(access);
223 VNODEOP_DESC_INIT_VP(getattr);
224 VNODEOP_DESC_INIT_VP_CRED(setattr);
225 VNODEOP_DESC_INIT_VP_CRED(read);
226 VNODEOP_DESC_INIT_VP_CRED(write);
227 VNODEOP_DESC_INIT_VP_CRED(ioctl);
228 VNODEOP_DESC_INIT_VP_CRED(poll);
229 VNODEOP_DESC_INIT_VP(kqfilter);
230 VNODEOP_DESC_INIT_VP(revoke);
231 VNODEOP_DESC_INIT_VP_CRED(mmap);
232 VNODEOP_DESC_INIT_VP(fsync);
233 VNODEOP_DESC_INIT_DVP_VP_CNP(old_remove);
234 VNODEOP_DESC_INIT_TDVP_VP_CNP(old_link);
236 static int VOFFNAME(old_rename)[] = {
237 __offsetof(VARGSSTRUCT(old_rename), a_fdvp),
238 __offsetof(VARGSSTRUCT(old_rename), a_fvp),
239 __offsetof(VARGSSTRUCT(old_rename), a_tdvp),
240 __offsetof(VARGSSTRUCT(old_rename), a_tvp),
243 VNODEOP_DESC_INIT(old_rename,
244 VDESC_VP0_WILLRELE|VDESC_VP1_WILLRELE|
245 VDESC_VP2_WILLRELE|VDESC_VP3_WILLRELE|
246 VDESC_VP2_WILLUNLOCK|VDESC_VP3_WILLUNLOCK, /* tdvp and tvp */
247 VOFFNAME(old_rename),
251 __offsetof(VARGSSTRUCT(old_rename), a_fcnp));
253 VNODEOP_DESC_INIT_DVP_VPP_CNP(old_mkdir);
254 VNODEOP_DESC_INIT_DVP_VP_CNP(old_rmdir);
255 VNODEOP_DESC_INIT_DVP_VPP_CNP(old_symlink);
256 VNODEOP_DESC_INIT_VP_CRED(readdir);
257 VNODEOP_DESC_INIT_VP_CRED(readlink);
258 VNODEOP_DESC_INIT_VP(inactive);
259 VNODEOP_DESC_INIT_VP(reclaim);
260 VNODEOP_DESC_INIT_VP(lock);
261 VNODEOP_DESC_INIT_VP(unlock);
262 VNODEOP_DESC_INIT_VP_VPP(bmap);
263 VNODEOP_DESC_INIT_VP(strategy);
264 VNODEOP_DESC_INIT_VP(print);
265 VNODEOP_DESC_INIT_VP(pathconf);
266 VNODEOP_DESC_INIT_VP(advlock);
267 VNODEOP_DESC_INIT_VP_CRED(balloc);
268 VNODEOP_DESC_INIT_VP(reallocblks);
269 VNODEOP_DESC_INIT_VP(getpages);
270 VNODEOP_DESC_INIT_VP(putpages);
271 VNODEOP_DESC_INIT_VP(freeblks);
272 VNODEOP_DESC_INIT_VP(bwrite);
273 VNODEOP_DESC_INIT_VP_CRED(getacl);
274 VNODEOP_DESC_INIT_VP_CRED(setacl);
275 VNODEOP_DESC_INIT_VP_CRED(aclcheck);
276 VNODEOP_DESC_INIT_VP_CRED(getextattr);
277 VNODEOP_DESC_INIT_VP_CRED(setextattr);
278 VNODEOP_DESC_INIT_SIMPLE(mountctl);
280 VNODEOP_DESC_INIT_NCP_CRED(nresolve);
281 VNODEOP_DESC_INIT_DVP_VPP_CRED(nlookupdotdot);
282 VNODEOP_DESC_INIT_NCP_CRED_VPP(ncreate);
283 VNODEOP_DESC_INIT_NCP_CRED_VPP(nmkdir);
284 VNODEOP_DESC_INIT_NCP_CRED_VPP(nmknod);
285 VNODEOP_DESC_INIT_NCP_VP_CRED(nlink);
286 VNODEOP_DESC_INIT_NCP_CRED_VPP(nsymlink);
287 VNODEOP_DESC_INIT_NCP_CRED(nwhiteout);
288 VNODEOP_DESC_INIT_NCP_CRED(nremove);
289 VNODEOP_DESC_INIT_NCP_CRED(nrmdir);
290 VNODEOP_DESC_INIT_NCP2_CRED(nrename);
292 #define DO_OPS(ops, error, ap, vop_field) \
293 error = ops->vop_field(ap);
295 /************************************************************************
296 * PRIMARY HIGH LEVEL VNODE OPERATIONS CALLS *
297 ************************************************************************
299 * These procedures are called directly from the kernel and/or fileops
300 * code to perform file/device operations on the system.
302 * NOTE: The old namespace api functions such as vop_rename() are no longer
303 * available for general use and have been renamed to vop_old_*(). Only
304 * the code in vfs_default.c is allowed to call those ops.
308 vop_islocked(struct vop_ops *ops, struct vnode *vp, struct thread *td)
310 struct vop_islocked_args ap;
313 ap.a_head.a_desc = &vop_islocked_desc;
314 ap.a_head.a_ops = ops;
318 DO_OPS(ops, error, &ap, vop_islocked);
323 vop_old_lookup(struct vop_ops *ops, struct vnode *dvp,
324 struct vnode **vpp, struct componentname *cnp)
326 struct vop_old_lookup_args ap;
329 ap.a_head.a_desc = &vop_old_lookup_desc;
330 ap.a_head.a_ops = ops;
335 DO_OPS(ops, error, &ap, vop_old_lookup);
340 vop_old_create(struct vop_ops *ops, struct vnode *dvp,
341 struct vnode **vpp, struct componentname *cnp, struct vattr *vap)
343 struct vop_old_create_args ap;
346 ap.a_head.a_desc = &vop_old_create_desc;
347 ap.a_head.a_ops = ops;
353 DO_OPS(ops, error, &ap, vop_old_create);
358 vop_old_whiteout(struct vop_ops *ops, struct vnode *dvp,
359 struct componentname *cnp, int flags)
361 struct vop_old_whiteout_args ap;
364 ap.a_head.a_desc = &vop_old_whiteout_desc;
365 ap.a_head.a_ops = ops;
370 DO_OPS(ops, error, &ap, vop_old_whiteout);
375 vop_old_mknod(struct vop_ops *ops, struct vnode *dvp,
376 struct vnode **vpp, struct componentname *cnp, struct vattr *vap)
378 struct vop_old_mknod_args ap;
381 ap.a_head.a_desc = &vop_old_mknod_desc;
382 ap.a_head.a_ops = ops;
388 DO_OPS(ops, error, &ap, vop_old_mknod);
393 vop_open(struct vop_ops *ops, struct vnode *vp, int mode, struct ucred *cred,
394 struct file *fp, struct thread *td)
396 struct vop_open_args ap;
399 ap.a_head.a_desc = &vop_open_desc;
400 ap.a_head.a_ops = ops;
407 DO_OPS(ops, error, &ap, vop_open);
412 vop_close(struct vop_ops *ops, struct vnode *vp, int fflag, struct thread *td)
414 struct vop_close_args ap;
417 ap.a_head.a_desc = &vop_close_desc;
418 ap.a_head.a_ops = ops;
423 DO_OPS(ops, error, &ap, vop_close);
428 vop_access(struct vop_ops *ops, struct vnode *vp, int mode, struct ucred *cred,
431 struct vop_access_args ap;
434 ap.a_head.a_desc = &vop_access_desc;
435 ap.a_head.a_ops = ops;
441 DO_OPS(ops, error, &ap, vop_access);
446 vop_getattr(struct vop_ops *ops, struct vnode *vp, struct vattr *vap,
449 struct vop_getattr_args ap;
450 struct namecache *ncp;
453 ap.a_head.a_desc = &vop_getattr_desc;
454 ap.a_head.a_ops = ops;
459 DO_OPS(ops, error, &ap, vop_getattr);
460 if ((ops->vv_flags & VVF_SUPPORTS_FSMID) == 0) {
461 if ((ncp = TAILQ_FIRST(&vp->v_namecache)) != NULL) {
462 if (ncp->nc_flag & NCF_FSMID) {
463 ncp->nc_flag &= ~NCF_FSMID;
466 vap->va_fsmid = ncp->nc_fsmid;
473 vop_setattr(struct vop_ops *ops, struct vnode *vp, struct vattr *vap,
474 struct ucred *cred, struct thread *td)
476 struct vop_setattr_args ap;
479 ap.a_head.a_desc = &vop_setattr_desc;
480 ap.a_head.a_ops = ops;
486 DO_OPS(ops, error, &ap, vop_setattr);
488 cache_update_fsmid_vp(vp);
493 vop_read(struct vop_ops *ops, struct vnode *vp, struct uio *uio, int ioflag,
496 struct vop_read_args ap;
499 ap.a_head.a_desc = &vop_read_desc;
500 ap.a_head.a_ops = ops;
503 ap.a_ioflag = ioflag;
506 DO_OPS(ops, error, &ap, vop_read);
511 vop_write(struct vop_ops *ops, struct vnode *vp, struct uio *uio, int ioflag,
514 struct vop_write_args ap;
517 ap.a_head.a_desc = &vop_write_desc;
518 ap.a_head.a_ops = ops;
521 ap.a_ioflag = ioflag;
524 DO_OPS(ops, error, &ap, vop_write);
526 cache_update_fsmid_vp(vp);
531 vop_ioctl(struct vop_ops *ops, struct vnode *vp, u_long command, caddr_t data,
532 int fflag, struct ucred *cred,
535 struct vop_ioctl_args ap;
538 ap.a_head.a_desc = &vop_ioctl_desc;
539 ap.a_head.a_ops = ops;
541 ap.a_command = command;
547 DO_OPS(ops, error, &ap, vop_ioctl);
552 vop_poll(struct vop_ops *ops, struct vnode *vp, int events, struct ucred *cred,
555 struct vop_poll_args ap;
558 ap.a_head.a_desc = &vop_poll_desc;
559 ap.a_head.a_ops = ops;
561 ap.a_events = events;
565 DO_OPS(ops, error, &ap, vop_poll);
570 vop_kqfilter(struct vop_ops *ops, struct vnode *vp, struct knote *kn)
572 struct vop_kqfilter_args ap;
575 ap.a_head.a_desc = &vop_kqfilter_desc;
576 ap.a_head.a_ops = ops;
580 DO_OPS(ops, error, &ap, vop_kqfilter);
585 vop_revoke(struct vop_ops *ops, struct vnode *vp, int flags)
587 struct vop_revoke_args ap;
590 ap.a_head.a_desc = &vop_revoke_desc;
591 ap.a_head.a_ops = ops;
595 DO_OPS(ops, error, &ap, vop_revoke);
600 vop_mmap(struct vop_ops *ops, struct vnode *vp, int fflags, struct ucred *cred,
603 struct vop_mmap_args ap;
606 ap.a_head.a_desc = &vop_mmap_desc;
607 ap.a_head.a_ops = ops;
609 ap.a_fflags = fflags;
613 DO_OPS(ops, error, &ap, vop_mmap);
618 vop_fsync(struct vop_ops *ops, struct vnode *vp, int waitfor, struct thread *td)
620 struct vop_fsync_args ap;
623 ap.a_head.a_desc = &vop_fsync_desc;
624 ap.a_head.a_ops = ops;
626 ap.a_waitfor = waitfor;
629 DO_OPS(ops, error, &ap, vop_fsync);
634 vop_old_remove(struct vop_ops *ops, struct vnode *dvp,
635 struct vnode *vp, struct componentname *cnp)
637 struct vop_old_remove_args ap;
640 ap.a_head.a_desc = &vop_old_remove_desc;
641 ap.a_head.a_ops = ops;
646 DO_OPS(ops, error, &ap, vop_old_remove);
651 vop_old_link(struct vop_ops *ops, struct vnode *tdvp,
652 struct vnode *vp, struct componentname *cnp)
654 struct vop_old_link_args ap;
657 ap.a_head.a_desc = &vop_old_link_desc;
658 ap.a_head.a_ops = ops;
663 DO_OPS(ops, error, &ap, vop_old_link);
668 vop_old_rename(struct vop_ops *ops,
669 struct vnode *fdvp, struct vnode *fvp, struct componentname *fcnp,
670 struct vnode *tdvp, struct vnode *tvp, struct componentname *tcnp)
672 struct vop_old_rename_args ap;
675 ap.a_head.a_desc = &vop_old_rename_desc;
676 ap.a_head.a_ops = ops;
684 DO_OPS(ops, error, &ap, vop_old_rename);
689 vop_old_mkdir(struct vop_ops *ops, struct vnode *dvp,
690 struct vnode **vpp, struct componentname *cnp, struct vattr *vap)
692 struct vop_old_mkdir_args ap;
695 ap.a_head.a_desc = &vop_old_mkdir_desc;
696 ap.a_head.a_ops = ops;
702 DO_OPS(ops, error, &ap, vop_old_mkdir);
707 vop_old_rmdir(struct vop_ops *ops, struct vnode *dvp,
708 struct vnode *vp, struct componentname *cnp)
710 struct vop_old_rmdir_args ap;
713 ap.a_head.a_desc = &vop_old_rmdir_desc;
714 ap.a_head.a_ops = ops;
719 DO_OPS(ops, error, &ap, vop_old_rmdir);
724 vop_old_symlink(struct vop_ops *ops, struct vnode *dvp,
725 struct vnode **vpp, struct componentname *cnp,
726 struct vattr *vap, char *target)
728 struct vop_old_symlink_args ap;
731 ap.a_head.a_desc = &vop_old_symlink_desc;
732 ap.a_head.a_ops = ops;
737 ap.a_target = target;
739 DO_OPS(ops, error, &ap, vop_old_symlink);
744 vop_readdir(struct vop_ops *ops, struct vnode *vp, struct uio *uio,
745 struct ucred *cred, int *eofflag, int *ncookies, u_long **cookies)
747 struct vop_readdir_args ap;
750 ap.a_head.a_desc = &vop_readdir_desc;
751 ap.a_head.a_ops = ops;
755 ap.a_eofflag = eofflag;
756 ap.a_ncookies = ncookies;
757 ap.a_cookies = cookies;
759 DO_OPS(ops, error, &ap, vop_readdir);
764 vop_readlink(struct vop_ops *ops, struct vnode *vp, struct uio *uio,
767 struct vop_readlink_args ap;
770 ap.a_head.a_desc = &vop_readlink_desc;
771 ap.a_head.a_ops = ops;
776 DO_OPS(ops, error, &ap, vop_readlink);
781 vop_inactive(struct vop_ops *ops, struct vnode *vp, struct thread *td)
783 struct vop_inactive_args ap;
786 ap.a_head.a_desc = &vop_inactive_desc;
787 ap.a_head.a_ops = ops;
791 DO_OPS(ops, error, &ap, vop_inactive);
796 vop_reclaim(struct vop_ops *ops, struct vnode *vp, struct thread *td)
798 struct vop_reclaim_args ap;
801 ap.a_head.a_desc = &vop_reclaim_desc;
802 ap.a_head.a_ops = ops;
806 DO_OPS(ops, error, &ap, vop_reclaim);
811 vop_lock(struct vop_ops *ops, struct vnode *vp, int flags, struct thread *td)
813 struct vop_lock_args ap;
816 ap.a_head.a_desc = &vop_lock_desc;
817 ap.a_head.a_ops = ops;
822 DO_OPS(ops, error, &ap, vop_lock);
827 vop_unlock(struct vop_ops *ops, struct vnode *vp, int flags, struct thread *td)
829 struct vop_unlock_args ap;
832 ap.a_head.a_desc = &vop_unlock_desc;
833 ap.a_head.a_ops = ops;
838 DO_OPS(ops, error, &ap, vop_unlock);
843 vop_bmap(struct vop_ops *ops, struct vnode *vp, off_t loffset,
844 struct vnode **vpp, off_t *doffsetp, int *runp, int *runb)
846 struct vop_bmap_args ap;
849 ap.a_head.a_desc = &vop_bmap_desc;
850 ap.a_head.a_ops = ops;
852 ap.a_loffset = loffset;
854 ap.a_doffsetp = doffsetp;
858 DO_OPS(ops, error, &ap, vop_bmap);
863 vop_strategy(struct vop_ops *ops, struct vnode *vp, struct bio *bio)
865 struct vop_strategy_args ap;
868 ap.a_head.a_desc = &vop_strategy_desc;
869 ap.a_head.a_ops = ops;
873 DO_OPS(ops, error, &ap, vop_strategy);
874 if (error == 0 && (bio->bio_buf->b_flags & B_READ) == 0)
875 cache_update_fsmid_vp(vp);
880 vop_print(struct vop_ops *ops, struct vnode *vp)
882 struct vop_print_args ap;
885 ap.a_head.a_desc = &vop_print_desc;
886 ap.a_head.a_ops = ops;
889 DO_OPS(ops, error, &ap, vop_print);
894 vop_pathconf(struct vop_ops *ops, struct vnode *vp, int name,
897 struct vop_pathconf_args ap;
900 ap.a_head.a_desc = &vop_pathconf_desc;
901 ap.a_head.a_ops = ops;
904 ap.a_retval = retval;
906 DO_OPS(ops, error, &ap, vop_pathconf);
911 vop_advlock(struct vop_ops *ops, struct vnode *vp, caddr_t id, int op,
912 struct flock *fl, int flags)
914 struct vop_advlock_args ap;
917 ap.a_head.a_desc = &vop_advlock_desc;
918 ap.a_head.a_ops = ops;
925 DO_OPS(ops, error, &ap, vop_advlock);
930 vop_balloc(struct vop_ops *ops, struct vnode *vp, off_t startoffset,
931 int size, struct ucred *cred, int flags,
934 struct vop_balloc_args ap;
937 ap.a_head.a_desc = &vop_balloc_desc;
938 ap.a_head.a_ops = ops;
940 ap.a_startoffset = startoffset;
946 DO_OPS(ops, error, &ap, vop_balloc);
951 vop_reallocblks(struct vop_ops *ops, struct vnode *vp,
952 struct cluster_save *buflist)
954 struct vop_reallocblks_args ap;
957 ap.a_head.a_desc = &vop_reallocblks_desc;
958 ap.a_head.a_ops = ops;
960 ap.a_buflist = buflist;
962 DO_OPS(ops, error, &ap, vop_reallocblks);
967 vop_getpages(struct vop_ops *ops, struct vnode *vp, vm_page_t *m, int count,
968 int reqpage, vm_ooffset_t offset)
970 struct vop_getpages_args ap;
973 ap.a_head.a_desc = &vop_getpages_desc;
974 ap.a_head.a_ops = ops;
978 ap.a_reqpage = reqpage;
979 ap.a_offset = offset;
981 DO_OPS(ops, error, &ap, vop_getpages);
986 vop_putpages(struct vop_ops *ops, struct vnode *vp, vm_page_t *m, int count,
987 int sync, int *rtvals, vm_ooffset_t offset)
989 struct vop_putpages_args ap;
992 ap.a_head.a_desc = &vop_putpages_desc;
993 ap.a_head.a_ops = ops;
998 ap.a_rtvals = rtvals;
999 ap.a_offset = offset;
1001 DO_OPS(ops, error, &ap, vop_putpages);
1003 cache_update_fsmid_vp(vp);
1008 vop_freeblks(struct vop_ops *ops, struct vnode *vp, off_t offset, int length)
1010 struct vop_freeblks_args ap;
1013 ap.a_head.a_desc = &vop_freeblks_desc;
1014 ap.a_head.a_ops = ops;
1016 ap.a_offset = offset;
1017 ap.a_length = length;
1019 DO_OPS(ops, error, &ap, vop_freeblks);
1024 vop_bwrite(struct vop_ops *ops, struct vnode *vp, struct buf *bp)
1026 struct vop_bwrite_args ap;
1029 ap.a_head.a_desc = &vop_bwrite_desc;
1030 ap.a_head.a_ops = ops;
1034 DO_OPS(ops, error, &ap, vop_bwrite);
1036 cache_update_fsmid_vp(vp);
1041 vop_getacl(struct vop_ops *ops, struct vnode *vp, acl_type_t type,
1042 struct acl *aclp, struct ucred *cred, struct thread *td)
1044 struct vop_getacl_args ap;
1047 ap.a_head.a_desc = &vop_getacl_desc;
1048 ap.a_head.a_ops = ops;
1055 DO_OPS(ops, error, &ap, vop_getacl);
1060 vop_setacl(struct vop_ops *ops, struct vnode *vp, acl_type_t type,
1061 struct acl *aclp, struct ucred *cred, struct thread *td)
1063 struct vop_setacl_args ap;
1066 ap.a_head.a_desc = &vop_setacl_desc;
1067 ap.a_head.a_ops = ops;
1074 DO_OPS(ops, error, &ap, vop_setacl);
1076 cache_update_fsmid_vp(vp);
1081 vop_aclcheck(struct vop_ops *ops, struct vnode *vp, acl_type_t type,
1082 struct acl *aclp, struct ucred *cred, struct thread *td)
1084 struct vop_aclcheck_args ap;
1087 ap.a_head.a_desc = &vop_aclcheck_desc;
1088 ap.a_head.a_ops = ops;
1095 DO_OPS(ops, error, &ap, vop_aclcheck);
1100 vop_getextattr(struct vop_ops *ops, struct vnode *vp, char *name,
1101 struct uio *uio, struct ucred *cred, struct thread *td)
1103 struct vop_getextattr_args ap;
1106 ap.a_head.a_desc = &vop_getextattr_desc;
1107 ap.a_head.a_ops = ops;
1114 DO_OPS(ops, error, &ap, vop_getextattr);
1119 vop_setextattr(struct vop_ops *ops, struct vnode *vp, char *name,
1120 struct uio *uio, struct ucred *cred, struct thread *td)
1122 struct vop_setextattr_args ap;
1125 ap.a_head.a_desc = &vop_setextattr_desc;
1126 ap.a_head.a_ops = ops;
1133 DO_OPS(ops, error, &ap, vop_setextattr);
1135 cache_update_fsmid_vp(vp);
1140 vop_mountctl(struct vop_ops *ops, int op, struct file *fp,
1141 const void *ctl, int ctllen, void *buf, int buflen, int *res)
1143 struct vop_mountctl_args ap;
1146 ap.a_head.a_desc = &vop_mountctl_desc;
1147 ap.a_head.a_ops = ops;
1151 ap.a_ctllen = ctllen;
1153 ap.a_buflen = buflen;
1156 DO_OPS(ops, error, &ap, vop_mountctl);
1163 * nresolve takes a locked ncp and a cred and resolves the ncp into a
1164 * positive or negative hit.
1166 * The namecache is automatically adjusted by this function. The ncp
1167 * is left locked on return.
1170 vop_nresolve(struct vop_ops *ops, struct namecache *ncp, struct ucred *cred)
1172 struct vop_nresolve_args ap;
1175 ap.a_head.a_desc = &vop_nresolve_desc;
1176 ap.a_head.a_ops = ops;
1180 DO_OPS(ops, error, &ap, vop_nresolve);
1185 * nlookupdotdot takes an unlocked directory, dvp, and looks up "..", returning
1186 * a locked parent directory in *vpp. If an error occurs *vpp will be NULL.
1189 vop_nlookupdotdot(struct vop_ops *ops, struct vnode *dvp,
1190 struct vnode **vpp, struct ucred *cred)
1192 struct vop_nlookupdotdot_args ap;
1195 ap.a_head.a_desc = &vop_nlookupdotdot_desc;
1196 ap.a_head.a_ops = ops;
1201 DO_OPS(ops, error, &ap, vop_nlookupdotdot);
1206 * ncreate takes a locked, resolved ncp that typically represents a negative
1207 * cache hit and creates the file or node specified by the ncp, cred, and
1208 * vattr. If no error occurs a locked vnode is returned in *vpp.
1210 * The namecache is automatically adjusted by this function. The ncp
1211 * is left locked on return.
1214 vop_ncreate(struct vop_ops *ops, struct namecache *ncp,
1215 struct vnode **vpp, struct ucred *cred, struct vattr *vap)
1217 struct vop_ncreate_args ap;
1220 ap.a_head.a_desc = &vop_ncreate_desc;
1221 ap.a_head.a_ops = ops;
1227 DO_OPS(ops, error, &ap, vop_ncreate);
1228 if (error == 0 && *vpp)
1229 cache_update_fsmid_vp(*vpp);
1234 * nmkdir takes a locked, resolved ncp that typically represents a negative
1235 * cache hit and creates the directory specified by the ncp, cred, and
1236 * vattr. If no error occurs a locked vnode is returned in *vpp.
1238 * The namecache is automatically adjusted by this function. The ncp
1239 * is left locked on return.
1242 vop_nmkdir(struct vop_ops *ops, struct namecache *ncp,
1243 struct vnode **vpp, struct ucred *cred, struct vattr *vap)
1245 struct vop_nmkdir_args ap;
1248 ap.a_head.a_desc = &vop_nmkdir_desc;
1249 ap.a_head.a_ops = ops;
1255 DO_OPS(ops, error, &ap, vop_nmkdir);
1256 if (error == 0 && *vpp)
1257 cache_update_fsmid_vp(*vpp);
1262 * nmknod takes a locked, resolved ncp that typically represents a negative
1263 * cache hit and creates the node specified by the ncp, cred, and
1264 * vattr. If no error occurs a locked vnode is returned in *vpp.
1266 * The namecache is automatically adjusted by this function. The ncp
1267 * is left locked on return.
1270 vop_nmknod(struct vop_ops *ops, struct namecache *ncp,
1271 struct vnode **vpp, struct ucred *cred, struct vattr *vap)
1273 struct vop_nmknod_args ap;
1276 ap.a_head.a_desc = &vop_nmknod_desc;
1277 ap.a_head.a_ops = ops;
1283 DO_OPS(ops, error, &ap, vop_nmknod);
1284 if (error == 0 && *vpp)
1285 cache_update_fsmid_vp(*vpp);
1290 * nlink takes a locked, resolved ncp that typically represents a negative
1291 * cache hit and creates the node specified by the ncp, cred, and
1292 * existing vnode. The passed vp must be locked and will remain locked
1293 * on return, as does the ncp, whether an error occurs or not.
1295 * The namecache is automatically adjusted by this function. The ncp
1296 * is left locked on return.
1299 vop_nlink(struct vop_ops *ops, struct namecache *ncp,
1300 struct vnode *vp, struct ucred *cred)
1302 struct vop_nlink_args ap;
1305 ap.a_head.a_desc = &vop_nlink_desc;
1306 ap.a_head.a_ops = ops;
1311 DO_OPS(ops, error, &ap, vop_nlink);
1313 cache_update_fsmid(ncp);
1318 * nsymlink takes a locked, resolved ncp that typically represents a negative
1319 * cache hit and creates a symbolic link based on cred, vap, and target (the
1320 * contents of the link). If no error occurs a locked vnode is returned in
1323 * The namecache is automatically adjusted by this function. The ncp
1324 * is left locked on return.
1327 vop_nsymlink(struct vop_ops *ops, struct namecache *ncp,
1328 struct vnode **vpp, struct ucred *cred,
1329 struct vattr *vap, char *target)
1331 struct vop_nsymlink_args ap;
1334 ap.a_head.a_desc = &vop_nsymlink_desc;
1335 ap.a_head.a_ops = ops;
1340 ap.a_target = target;
1342 DO_OPS(ops, error, &ap, vop_nsymlink);
1344 cache_update_fsmid(ncp);
1349 * nwhiteout takes a locked, resolved ncp that can represent a positive or
1350 * negative hit and executes the whiteout function specified in flags.
1352 * The namecache is automatically adjusted by this function. The ncp
1353 * is left locked on return.
1356 vop_nwhiteout(struct vop_ops *ops, struct namecache *ncp,
1357 struct ucred *cred, int flags)
1359 struct vop_nwhiteout_args ap;
1362 ap.a_head.a_desc = &vop_nwhiteout_desc;
1363 ap.a_head.a_ops = ops;
1368 DO_OPS(ops, error, &ap, vop_nwhiteout);
1370 cache_update_fsmid(ncp);
1375 * nremove takes a locked, resolved ncp that generally represents a
1376 * positive hit and removes the file.
1378 * The namecache is automatically adjusted by this function. The ncp
1379 * is left locked on return.
1382 vop_nremove(struct vop_ops *ops, struct namecache *ncp, struct ucred *cred)
1384 struct vop_nremove_args ap;
1387 ap.a_head.a_desc = &vop_nremove_desc;
1388 ap.a_head.a_ops = ops;
1392 DO_OPS(ops, error, &ap, vop_nremove);
1394 cache_update_fsmid(ncp);
1399 * nrmdir takes a locked, resolved ncp that generally represents a
1400 * directory and removes the directory.
1402 * The namecache is automatically adjusted by this function. The ncp
1403 * is left locked on return.
1406 vop_nrmdir(struct vop_ops *ops, struct namecache *ncp, struct ucred *cred)
1408 struct vop_nrmdir_args ap;
1411 ap.a_head.a_desc = &vop_nrmdir_desc;
1412 ap.a_head.a_ops = ops;
1416 DO_OPS(ops, error, &ap, vop_nrmdir);
1418 cache_update_fsmid(ncp);
1423 * nrename takes TWO locked, resolved ncp's and the cred of the caller
1424 * and renames the source ncp to the target ncp. The target ncp may
1425 * represent a positive or negative hit.
1427 * The namecache is automatically adjusted by this function. The ncp
1428 * is left locked on return. The source ncp is typically changed to
1429 * a negative cache hit and the target ncp typically takes on the
1430 * source ncp's underlying file.
1433 vop_nrename(struct vop_ops *ops, struct namecache *fncp,
1434 struct namecache *tncp, struct ucred *cred)
1436 struct vop_nrename_args ap;
1439 ap.a_head.a_desc = &vop_nrename_desc;
1440 ap.a_head.a_ops = ops;
1445 DO_OPS(ops, error, &ap, vop_nrename);
1447 cache_update_fsmid(fncp);
1448 cache_update_fsmid(tncp);
1453 /************************************************************************
1454 * PRIMARY VNODE OPERATIONS FORWARDING CALLS *
1455 ************************************************************************
1457 * These procedures are called from VFSs such as unionfs and nullfs
1458 * when they wish to forward an operation on one VFS to another. The
1459 * argument structure/message is modified and then directly passed to the
1460 * appropriate routine. This routines may also be called by initiators
1461 * who have an argument structure in hand rather then discreet arguments.
1464 vop_vnoperate_ap(struct vop_generic_args *ap)
1466 struct vop_ops *ops;
1470 error = VOCALL(ops, ap);
1476 * This routine is called by the cache coherency layer to execute the actual
1477 * VFS operation. If a journaling layer is present we call though it, else
1478 * we call the native VOP functions.
1481 vop_cache_operate_ap(struct vop_generic_args *ap)
1483 struct vop_ops *ops;
1487 if (ops->vv_mount->mnt_vn_journal_ops)
1488 error = VOCALL(ops->vv_mount->mnt_vn_journal_ops, ap);
1490 error = VOCALL(ops->vv_mount->mnt_vn_norm_ops, ap);
1496 * This routine is called by the journaling layer to execute the actual
1500 vop_journal_operate_ap(struct vop_generic_args *ap)
1502 struct vop_ops *ops;
1506 error = VOCALL(ops->vv_mount->mnt_vn_norm_ops, ap);
1512 vop_islocked_ap(struct vop_islocked_args *ap)
1516 DO_OPS(ap->a_head.a_ops, error, ap, vop_islocked);
1521 vop_open_ap(struct vop_open_args *ap)
1525 DO_OPS(ap->a_head.a_ops, error, ap, vop_open);
1530 vop_close_ap(struct vop_close_args *ap)
1534 DO_OPS(ap->a_head.a_ops, error, ap, vop_close);
1539 vop_access_ap(struct vop_access_args *ap)
1543 DO_OPS(ap->a_head.a_ops, error, ap, vop_access);
1548 vop_getattr_ap(struct vop_getattr_args *ap)
1552 DO_OPS(ap->a_head.a_ops, error, ap, vop_getattr);
1557 vop_setattr_ap(struct vop_setattr_args *ap)
1561 DO_OPS(ap->a_head.a_ops, error, ap, vop_setattr);
1566 vop_read_ap(struct vop_read_args *ap)
1570 DO_OPS(ap->a_head.a_ops, error, ap, vop_read);
1575 vop_write_ap(struct vop_write_args *ap)
1579 DO_OPS(ap->a_head.a_ops, error, ap, vop_write);
1584 vop_ioctl_ap(struct vop_ioctl_args *ap)
1588 DO_OPS(ap->a_head.a_ops, error, ap, vop_ioctl);
1593 vop_poll_ap(struct vop_poll_args *ap)
1597 DO_OPS(ap->a_head.a_ops, error, ap, vop_poll);
1602 vop_kqfilter_ap(struct vop_kqfilter_args *ap)
1606 DO_OPS(ap->a_head.a_ops, error, ap, vop_kqfilter);
1611 vop_revoke_ap(struct vop_revoke_args *ap)
1615 DO_OPS(ap->a_head.a_ops, error, ap, vop_revoke);
1620 vop_mmap_ap(struct vop_mmap_args *ap)
1624 DO_OPS(ap->a_head.a_ops, error, ap, vop_mmap);
1629 vop_fsync_ap(struct vop_fsync_args *ap)
1633 DO_OPS(ap->a_head.a_ops, error, ap, vop_fsync);
1638 vop_readdir_ap(struct vop_readdir_args *ap)
1642 DO_OPS(ap->a_head.a_ops, error, ap, vop_readdir);
1647 vop_readlink_ap(struct vop_readlink_args *ap)
1651 DO_OPS(ap->a_head.a_ops, error, ap, vop_readlink);
1656 vop_inactive_ap(struct vop_inactive_args *ap)
1660 DO_OPS(ap->a_head.a_ops, error, ap, vop_inactive);
1665 vop_reclaim_ap(struct vop_reclaim_args *ap)
1669 DO_OPS(ap->a_head.a_ops, error, ap, vop_reclaim);
1674 vop_lock_ap(struct vop_lock_args *ap)
1678 DO_OPS(ap->a_head.a_ops, error, ap, vop_lock);
1683 vop_unlock_ap(struct vop_unlock_args *ap)
1687 DO_OPS(ap->a_head.a_ops, error, ap, vop_unlock);
1692 vop_bmap_ap(struct vop_bmap_args *ap)
1696 DO_OPS(ap->a_head.a_ops, error, ap, vop_bmap);
1701 vop_strategy_ap(struct vop_strategy_args *ap)
1705 DO_OPS(ap->a_head.a_ops, error, ap, vop_strategy);
1710 vop_print_ap(struct vop_print_args *ap)
1714 DO_OPS(ap->a_head.a_ops, error, ap, vop_print);
1719 vop_pathconf_ap(struct vop_pathconf_args *ap)
1723 DO_OPS(ap->a_head.a_ops, error, ap, vop_pathconf);
1728 vop_advlock_ap(struct vop_advlock_args *ap)
1732 DO_OPS(ap->a_head.a_ops, error, ap, vop_advlock);
1737 vop_balloc_ap(struct vop_balloc_args *ap)
1741 DO_OPS(ap->a_head.a_ops, error, ap, vop_balloc);
1746 vop_reallocblks_ap(struct vop_reallocblks_args *ap)
1750 DO_OPS(ap->a_head.a_ops, error, ap, vop_reallocblks);
1755 vop_getpages_ap(struct vop_getpages_args *ap)
1759 DO_OPS(ap->a_head.a_ops, error, ap, vop_getpages);
1764 vop_putpages_ap(struct vop_putpages_args *ap)
1768 DO_OPS(ap->a_head.a_ops, error, ap, vop_putpages);
1773 vop_freeblks_ap(struct vop_freeblks_args *ap)
1777 DO_OPS(ap->a_head.a_ops, error, ap, vop_freeblks);
1782 vop_bwrite_ap(struct vop_bwrite_args *ap)
1786 DO_OPS(ap->a_head.a_ops, error, ap, vop_bwrite);
1791 vop_getacl_ap(struct vop_getacl_args *ap)
1795 DO_OPS(ap->a_head.a_ops, error, ap, vop_getacl);
1800 vop_setacl_ap(struct vop_setacl_args *ap)
1804 DO_OPS(ap->a_head.a_ops, error, ap, vop_setacl);
1809 vop_aclcheck_ap(struct vop_aclcheck_args *ap)
1813 DO_OPS(ap->a_head.a_ops, error, ap, vop_aclcheck);
1818 vop_getextattr_ap(struct vop_getextattr_args *ap)
1822 DO_OPS(ap->a_head.a_ops, error, ap, vop_getextattr);
1827 vop_setextattr_ap(struct vop_setextattr_args *ap)
1831 DO_OPS(ap->a_head.a_ops, error, ap, vop_setextattr);
1836 vop_mountctl_ap(struct vop_mountctl_args *ap)
1840 DO_OPS(ap->a_head.a_ops, error, ap, vop_mountctl);
1845 vop_nresolve_ap(struct vop_nresolve_args *ap)
1849 DO_OPS(ap->a_head.a_ops, error, ap, vop_nresolve);
1854 vop_nlookupdotdot_ap(struct vop_nlookupdotdot_args *ap)
1858 DO_OPS(ap->a_head.a_ops, error, ap, vop_nlookupdotdot);
1863 vop_ncreate_ap(struct vop_ncreate_args *ap)
1867 DO_OPS(ap->a_head.a_ops, error, ap, vop_ncreate);
1872 vop_nmkdir_ap(struct vop_nmkdir_args *ap)
1876 DO_OPS(ap->a_head.a_ops, error, ap, vop_nmkdir);
1881 vop_nmknod_ap(struct vop_nmknod_args *ap)
1885 DO_OPS(ap->a_head.a_ops, error, ap, vop_nmknod);
1890 vop_nlink_ap(struct vop_nlink_args *ap)
1894 DO_OPS(ap->a_head.a_ops, error, ap, vop_nlink);
1899 vop_nsymlink_ap(struct vop_nsymlink_args *ap)
1903 DO_OPS(ap->a_head.a_ops, error, ap, vop_nsymlink);
1908 vop_nwhiteout_ap(struct vop_nwhiteout_args *ap)
1912 DO_OPS(ap->a_head.a_ops, error, ap, vop_nwhiteout);
1917 vop_nremove_ap(struct vop_nremove_args *ap)
1921 DO_OPS(ap->a_head.a_ops, error, ap, vop_nremove);
1926 vop_nrmdir_ap(struct vop_nrmdir_args *ap)
1930 DO_OPS(ap->a_head.a_ops, error, ap, vop_nrmdir);
1935 vop_nrename_ap(struct vop_nrename_args *ap)
1939 DO_OPS(ap->a_head.a_ops, error, ap, vop_nrename);