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.15 2005/09/14 01:13:20 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(lease);
228 VNODEOP_DESC_INIT_VP_CRED(ioctl);
229 VNODEOP_DESC_INIT_VP_CRED(poll);
230 VNODEOP_DESC_INIT_VP(kqfilter);
231 VNODEOP_DESC_INIT_VP(revoke);
232 VNODEOP_DESC_INIT_VP_CRED(mmap);
233 VNODEOP_DESC_INIT_VP(fsync);
234 VNODEOP_DESC_INIT_DVP_VP_CNP(old_remove);
235 VNODEOP_DESC_INIT_TDVP_VP_CNP(old_link);
237 static int VOFFNAME(old_rename)[] = {
238 __offsetof(VARGSSTRUCT(old_rename), a_fdvp),
239 __offsetof(VARGSSTRUCT(old_rename), a_fvp),
240 __offsetof(VARGSSTRUCT(old_rename), a_tdvp),
241 __offsetof(VARGSSTRUCT(old_rename), a_tvp),
244 VNODEOP_DESC_INIT(old_rename,
245 VDESC_VP0_WILLRELE|VDESC_VP1_WILLRELE|
246 VDESC_VP2_WILLRELE|VDESC_VP3_WILLRELE|
247 VDESC_VP2_WILLUNLOCK|VDESC_VP3_WILLUNLOCK, /* tdvp and tvp */
248 VOFFNAME(old_rename),
252 __offsetof(VARGSSTRUCT(old_rename), a_fcnp));
254 VNODEOP_DESC_INIT_DVP_VPP_CNP(old_mkdir);
255 VNODEOP_DESC_INIT_DVP_VP_CNP(old_rmdir);
256 VNODEOP_DESC_INIT_DVP_VPP_CNP(old_symlink);
257 VNODEOP_DESC_INIT_VP_CRED(readdir);
258 VNODEOP_DESC_INIT_VP_CRED(readlink);
259 VNODEOP_DESC_INIT_VP(inactive);
260 VNODEOP_DESC_INIT_VP(reclaim);
261 VNODEOP_DESC_INIT_VP(lock);
262 VNODEOP_DESC_INIT_VP(unlock);
263 VNODEOP_DESC_INIT_VP_VPP(bmap);
264 VNODEOP_DESC_INIT_VP(strategy);
265 VNODEOP_DESC_INIT_VP(print);
266 VNODEOP_DESC_INIT_VP(pathconf);
267 VNODEOP_DESC_INIT_VP(advlock);
268 VNODEOP_DESC_INIT_VP_CRED(balloc);
269 VNODEOP_DESC_INIT_VP(reallocblks);
270 VNODEOP_DESC_INIT_VP(getpages);
271 VNODEOP_DESC_INIT_VP(putpages);
272 VNODEOP_DESC_INIT_VP(freeblks);
273 VNODEOP_DESC_INIT_VP(bwrite);
274 VNODEOP_DESC_INIT_VP_CRED(getacl);
275 VNODEOP_DESC_INIT_VP_CRED(setacl);
276 VNODEOP_DESC_INIT_VP_CRED(aclcheck);
277 VNODEOP_DESC_INIT_VP_CRED(getextattr);
278 VNODEOP_DESC_INIT_VP_CRED(setextattr);
279 VNODEOP_DESC_INIT_VP(createvobject);
280 VNODEOP_DESC_INIT_VP(destroyvobject);
281 VNODEOP_DESC_INIT_VP(getvobject);
282 VNODEOP_DESC_INIT_SIMPLE(mountctl);
284 VNODEOP_DESC_INIT_NCP_CRED(nresolve);
285 VNODEOP_DESC_INIT_DVP_VPP_CRED(nlookupdotdot);
286 VNODEOP_DESC_INIT_NCP_CRED_VPP(ncreate);
287 VNODEOP_DESC_INIT_NCP_CRED_VPP(nmkdir);
288 VNODEOP_DESC_INIT_NCP_CRED_VPP(nmknod);
289 VNODEOP_DESC_INIT_NCP_VP_CRED(nlink);
290 VNODEOP_DESC_INIT_NCP_CRED_VPP(nsymlink);
291 VNODEOP_DESC_INIT_NCP_CRED(nwhiteout);
292 VNODEOP_DESC_INIT_NCP_CRED(nremove);
293 VNODEOP_DESC_INIT_NCP_CRED(nrmdir);
294 VNODEOP_DESC_INIT_NCP2_CRED(nrename);
296 #define DO_OPS(ops, error, ap, vop_field) \
297 error = ops->vop_field(ap);
299 /************************************************************************
300 * PRIMARY HIGH LEVEL VNODE OPERATIONS CALLS *
301 ************************************************************************
303 * These procedures are called directly from the kernel and/or fileops
304 * code to perform file/device operations on the system.
306 * NOTE: The old namespace api functions such as vop_rename() are no longer
307 * available for general use and have been renamed to vop_old_*(). Only
308 * the code in vfs_default.c is allowed to call those ops.
312 vop_islocked(struct vop_ops *ops, struct vnode *vp, struct thread *td)
314 struct vop_islocked_args ap;
317 ap.a_head.a_desc = &vop_islocked_desc;
318 ap.a_head.a_ops = ops;
322 DO_OPS(ops, error, &ap, vop_islocked);
327 vop_old_lookup(struct vop_ops *ops, struct vnode *dvp,
328 struct vnode **vpp, struct componentname *cnp)
330 struct vop_old_lookup_args ap;
333 ap.a_head.a_desc = &vop_old_lookup_desc;
334 ap.a_head.a_ops = ops;
339 DO_OPS(ops, error, &ap, vop_old_lookup);
344 vop_old_create(struct vop_ops *ops, struct vnode *dvp,
345 struct vnode **vpp, struct componentname *cnp, struct vattr *vap)
347 struct vop_old_create_args ap;
350 ap.a_head.a_desc = &vop_old_create_desc;
351 ap.a_head.a_ops = ops;
357 DO_OPS(ops, error, &ap, vop_old_create);
362 vop_old_whiteout(struct vop_ops *ops, struct vnode *dvp,
363 struct componentname *cnp, int flags)
365 struct vop_old_whiteout_args ap;
368 ap.a_head.a_desc = &vop_old_whiteout_desc;
369 ap.a_head.a_ops = ops;
374 DO_OPS(ops, error, &ap, vop_old_whiteout);
379 vop_old_mknod(struct vop_ops *ops, struct vnode *dvp,
380 struct vnode **vpp, struct componentname *cnp, struct vattr *vap)
382 struct vop_old_mknod_args ap;
385 ap.a_head.a_desc = &vop_old_mknod_desc;
386 ap.a_head.a_ops = ops;
392 DO_OPS(ops, error, &ap, vop_old_mknod);
397 vop_open(struct vop_ops *ops, struct vnode *vp, int mode, struct ucred *cred,
398 struct file *fp, struct thread *td)
400 struct vop_open_args ap;
403 ap.a_head.a_desc = &vop_open_desc;
404 ap.a_head.a_ops = ops;
411 DO_OPS(ops, error, &ap, vop_open);
416 vop_close(struct vop_ops *ops, struct vnode *vp, int fflag, struct thread *td)
418 struct vop_close_args ap;
421 ap.a_head.a_desc = &vop_close_desc;
422 ap.a_head.a_ops = ops;
427 DO_OPS(ops, error, &ap, vop_close);
432 vop_access(struct vop_ops *ops, struct vnode *vp, int mode, struct ucred *cred,
435 struct vop_access_args ap;
438 ap.a_head.a_desc = &vop_access_desc;
439 ap.a_head.a_ops = ops;
445 DO_OPS(ops, error, &ap, vop_access);
450 vop_getattr(struct vop_ops *ops, struct vnode *vp, struct vattr *vap,
453 struct vop_getattr_args ap;
456 ap.a_head.a_desc = &vop_getattr_desc;
457 ap.a_head.a_ops = ops;
462 DO_OPS(ops, error, &ap, vop_getattr);
467 vop_setattr(struct vop_ops *ops, struct vnode *vp, struct vattr *vap,
468 struct ucred *cred, struct thread *td)
470 struct vop_setattr_args ap;
473 ap.a_head.a_desc = &vop_setattr_desc;
474 ap.a_head.a_ops = ops;
480 DO_OPS(ops, error, &ap, vop_setattr);
482 cache_update_fsmid_vp(vp);
487 vop_read(struct vop_ops *ops, struct vnode *vp, struct uio *uio, int ioflag,
490 struct vop_read_args ap;
493 ap.a_head.a_desc = &vop_read_desc;
494 ap.a_head.a_ops = ops;
497 ap.a_ioflag = ioflag;
500 DO_OPS(ops, error, &ap, vop_read);
505 vop_write(struct vop_ops *ops, struct vnode *vp, struct uio *uio, int ioflag,
508 struct vop_write_args ap;
511 ap.a_head.a_desc = &vop_write_desc;
512 ap.a_head.a_ops = ops;
515 ap.a_ioflag = ioflag;
518 DO_OPS(ops, error, &ap, vop_write);
520 cache_update_fsmid_vp(vp);
525 vop_lease(struct vop_ops *ops, struct vnode *vp, struct thread *td,
526 struct ucred *cred, int flag)
528 struct vop_lease_args ap;
531 ap.a_head.a_desc = &vop_lease_desc;
532 ap.a_head.a_ops = ops;
538 DO_OPS(ops, error, &ap, vop_lease);
543 vop_ioctl(struct vop_ops *ops, struct vnode *vp, u_long command, caddr_t data,
544 int fflag, struct ucred *cred,
547 struct vop_ioctl_args ap;
550 ap.a_head.a_desc = &vop_ioctl_desc;
551 ap.a_head.a_ops = ops;
553 ap.a_command = command;
559 DO_OPS(ops, error, &ap, vop_ioctl);
564 vop_poll(struct vop_ops *ops, struct vnode *vp, int events, struct ucred *cred,
567 struct vop_poll_args ap;
570 ap.a_head.a_desc = &vop_poll_desc;
571 ap.a_head.a_ops = ops;
573 ap.a_events = events;
577 DO_OPS(ops, error, &ap, vop_poll);
582 vop_kqfilter(struct vop_ops *ops, struct vnode *vp, struct knote *kn)
584 struct vop_kqfilter_args ap;
587 ap.a_head.a_desc = &vop_kqfilter_desc;
588 ap.a_head.a_ops = ops;
592 DO_OPS(ops, error, &ap, vop_kqfilter);
597 vop_revoke(struct vop_ops *ops, struct vnode *vp, int flags)
599 struct vop_revoke_args ap;
602 ap.a_head.a_desc = &vop_revoke_desc;
603 ap.a_head.a_ops = ops;
607 DO_OPS(ops, error, &ap, vop_revoke);
612 vop_mmap(struct vop_ops *ops, struct vnode *vp, int fflags, struct ucred *cred,
615 struct vop_mmap_args ap;
618 ap.a_head.a_desc = &vop_mmap_desc;
619 ap.a_head.a_ops = ops;
621 ap.a_fflags = fflags;
625 DO_OPS(ops, error, &ap, vop_mmap);
630 vop_fsync(struct vop_ops *ops, struct vnode *vp, int waitfor, struct thread *td)
632 struct vop_fsync_args ap;
635 ap.a_head.a_desc = &vop_fsync_desc;
636 ap.a_head.a_ops = ops;
638 ap.a_waitfor = waitfor;
641 DO_OPS(ops, error, &ap, vop_fsync);
646 vop_old_remove(struct vop_ops *ops, struct vnode *dvp,
647 struct vnode *vp, struct componentname *cnp)
649 struct vop_old_remove_args ap;
652 ap.a_head.a_desc = &vop_old_remove_desc;
653 ap.a_head.a_ops = ops;
658 DO_OPS(ops, error, &ap, vop_old_remove);
663 vop_old_link(struct vop_ops *ops, struct vnode *tdvp,
664 struct vnode *vp, struct componentname *cnp)
666 struct vop_old_link_args ap;
669 ap.a_head.a_desc = &vop_old_link_desc;
670 ap.a_head.a_ops = ops;
675 DO_OPS(ops, error, &ap, vop_old_link);
680 vop_old_rename(struct vop_ops *ops,
681 struct vnode *fdvp, struct vnode *fvp, struct componentname *fcnp,
682 struct vnode *tdvp, struct vnode *tvp, struct componentname *tcnp)
684 struct vop_old_rename_args ap;
687 ap.a_head.a_desc = &vop_old_rename_desc;
688 ap.a_head.a_ops = ops;
696 DO_OPS(ops, error, &ap, vop_old_rename);
701 vop_old_mkdir(struct vop_ops *ops, struct vnode *dvp,
702 struct vnode **vpp, struct componentname *cnp, struct vattr *vap)
704 struct vop_old_mkdir_args ap;
707 ap.a_head.a_desc = &vop_old_mkdir_desc;
708 ap.a_head.a_ops = ops;
714 DO_OPS(ops, error, &ap, vop_old_mkdir);
719 vop_old_rmdir(struct vop_ops *ops, struct vnode *dvp,
720 struct vnode *vp, struct componentname *cnp)
722 struct vop_old_rmdir_args ap;
725 ap.a_head.a_desc = &vop_old_rmdir_desc;
726 ap.a_head.a_ops = ops;
731 DO_OPS(ops, error, &ap, vop_old_rmdir);
736 vop_old_symlink(struct vop_ops *ops, struct vnode *dvp,
737 struct vnode **vpp, struct componentname *cnp,
738 struct vattr *vap, char *target)
740 struct vop_old_symlink_args ap;
743 ap.a_head.a_desc = &vop_old_symlink_desc;
744 ap.a_head.a_ops = ops;
749 ap.a_target = target;
751 DO_OPS(ops, error, &ap, vop_old_symlink);
756 vop_readdir(struct vop_ops *ops, struct vnode *vp, struct uio *uio,
757 struct ucred *cred, int *eofflag, int *ncookies, u_long **cookies)
759 struct vop_readdir_args ap;
762 ap.a_head.a_desc = &vop_readdir_desc;
763 ap.a_head.a_ops = ops;
767 ap.a_eofflag = eofflag;
768 ap.a_ncookies = ncookies;
769 ap.a_cookies = cookies;
771 DO_OPS(ops, error, &ap, vop_readdir);
776 vop_readlink(struct vop_ops *ops, struct vnode *vp, struct uio *uio,
779 struct vop_readlink_args ap;
782 ap.a_head.a_desc = &vop_readlink_desc;
783 ap.a_head.a_ops = ops;
788 DO_OPS(ops, error, &ap, vop_readlink);
793 vop_inactive(struct vop_ops *ops, struct vnode *vp, struct thread *td)
795 struct vop_inactive_args ap;
798 ap.a_head.a_desc = &vop_inactive_desc;
799 ap.a_head.a_ops = ops;
803 DO_OPS(ops, error, &ap, vop_inactive);
808 vop_reclaim(struct vop_ops *ops, struct vnode *vp, struct thread *td)
810 struct vop_reclaim_args ap;
813 ap.a_head.a_desc = &vop_reclaim_desc;
814 ap.a_head.a_ops = ops;
818 DO_OPS(ops, error, &ap, vop_reclaim);
823 vop_lock(struct vop_ops *ops, struct vnode *vp, int flags, struct thread *td)
825 struct vop_lock_args ap;
828 ap.a_head.a_desc = &vop_lock_desc;
829 ap.a_head.a_ops = ops;
834 DO_OPS(ops, error, &ap, vop_lock);
839 vop_unlock(struct vop_ops *ops, struct vnode *vp, int flags, struct thread *td)
841 struct vop_unlock_args ap;
844 ap.a_head.a_desc = &vop_unlock_desc;
845 ap.a_head.a_ops = ops;
850 DO_OPS(ops, error, &ap, vop_unlock);
855 vop_bmap(struct vop_ops *ops, struct vnode *vp, daddr_t bn, struct vnode **vpp,
856 daddr_t *bnp, int *runp, int *runb)
858 struct vop_bmap_args ap;
861 ap.a_head.a_desc = &vop_bmap_desc;
862 ap.a_head.a_ops = ops;
870 DO_OPS(ops, error, &ap, vop_bmap);
875 vop_strategy(struct vop_ops *ops, struct vnode *vp, struct buf *bp)
877 struct vop_strategy_args ap;
880 ap.a_head.a_desc = &vop_strategy_desc;
881 ap.a_head.a_ops = ops;
885 DO_OPS(ops, error, &ap, vop_strategy);
886 if (error == 0 && (bp->b_flags & B_READ) == 0)
887 cache_update_fsmid_vp(vp);
892 vop_print(struct vop_ops *ops, struct vnode *vp)
894 struct vop_print_args ap;
897 ap.a_head.a_desc = &vop_print_desc;
898 ap.a_head.a_ops = ops;
901 DO_OPS(ops, error, &ap, vop_print);
906 vop_pathconf(struct vop_ops *ops, struct vnode *vp, int name,
909 struct vop_pathconf_args ap;
912 ap.a_head.a_desc = &vop_pathconf_desc;
913 ap.a_head.a_ops = ops;
916 ap.a_retval = retval;
918 DO_OPS(ops, error, &ap, vop_pathconf);
923 vop_advlock(struct vop_ops *ops, struct vnode *vp, caddr_t id, int op,
924 struct flock *fl, int flags)
926 struct vop_advlock_args ap;
929 ap.a_head.a_desc = &vop_advlock_desc;
930 ap.a_head.a_ops = ops;
937 DO_OPS(ops, error, &ap, vop_advlock);
942 vop_balloc(struct vop_ops *ops, struct vnode *vp, off_t startoffset,
943 int size, struct ucred *cred, int flags,
946 struct vop_balloc_args ap;
949 ap.a_head.a_desc = &vop_balloc_desc;
950 ap.a_head.a_ops = ops;
952 ap.a_startoffset = startoffset;
958 DO_OPS(ops, error, &ap, vop_balloc);
963 vop_reallocblks(struct vop_ops *ops, struct vnode *vp,
964 struct cluster_save *buflist)
966 struct vop_reallocblks_args ap;
969 ap.a_head.a_desc = &vop_reallocblks_desc;
970 ap.a_head.a_ops = ops;
972 ap.a_buflist = buflist;
974 DO_OPS(ops, error, &ap, vop_reallocblks);
979 vop_getpages(struct vop_ops *ops, struct vnode *vp, vm_page_t *m, int count,
980 int reqpage, vm_ooffset_t offset)
982 struct vop_getpages_args ap;
985 ap.a_head.a_desc = &vop_getpages_desc;
986 ap.a_head.a_ops = ops;
990 ap.a_reqpage = reqpage;
991 ap.a_offset = offset;
993 DO_OPS(ops, error, &ap, vop_getpages);
998 vop_putpages(struct vop_ops *ops, struct vnode *vp, vm_page_t *m, int count,
999 int sync, int *rtvals, vm_ooffset_t offset)
1001 struct vop_putpages_args ap;
1004 ap.a_head.a_desc = &vop_putpages_desc;
1005 ap.a_head.a_ops = ops;
1010 ap.a_rtvals = rtvals;
1011 ap.a_offset = offset;
1013 DO_OPS(ops, error, &ap, vop_putpages);
1015 cache_update_fsmid_vp(vp);
1020 vop_freeblks(struct vop_ops *ops, struct vnode *vp,
1021 daddr_t addr, daddr_t length)
1023 struct vop_freeblks_args ap;
1026 ap.a_head.a_desc = &vop_freeblks_desc;
1027 ap.a_head.a_ops = ops;
1030 ap.a_length = length;
1032 DO_OPS(ops, error, &ap, vop_freeblks);
1037 vop_bwrite(struct vop_ops *ops, struct vnode *vp, struct buf *bp)
1039 struct vop_bwrite_args ap;
1042 ap.a_head.a_desc = &vop_bwrite_desc;
1043 ap.a_head.a_ops = ops;
1047 DO_OPS(ops, error, &ap, vop_bwrite);
1049 cache_update_fsmid_vp(vp);
1054 vop_getacl(struct vop_ops *ops, struct vnode *vp, acl_type_t type,
1055 struct acl *aclp, struct ucred *cred, struct thread *td)
1057 struct vop_getacl_args ap;
1060 ap.a_head.a_desc = &vop_getacl_desc;
1061 ap.a_head.a_ops = ops;
1068 DO_OPS(ops, error, &ap, vop_getacl);
1073 vop_setacl(struct vop_ops *ops, struct vnode *vp, acl_type_t type,
1074 struct acl *aclp, struct ucred *cred, struct thread *td)
1076 struct vop_setacl_args ap;
1079 ap.a_head.a_desc = &vop_setacl_desc;
1080 ap.a_head.a_ops = ops;
1087 DO_OPS(ops, error, &ap, vop_setacl);
1089 cache_update_fsmid_vp(vp);
1094 vop_aclcheck(struct vop_ops *ops, struct vnode *vp, acl_type_t type,
1095 struct acl *aclp, struct ucred *cred, struct thread *td)
1097 struct vop_aclcheck_args ap;
1100 ap.a_head.a_desc = &vop_aclcheck_desc;
1101 ap.a_head.a_ops = ops;
1108 DO_OPS(ops, error, &ap, vop_aclcheck);
1113 vop_getextattr(struct vop_ops *ops, struct vnode *vp, char *name,
1114 struct uio *uio, struct ucred *cred, struct thread *td)
1116 struct vop_getextattr_args ap;
1119 ap.a_head.a_desc = &vop_getextattr_desc;
1120 ap.a_head.a_ops = ops;
1127 DO_OPS(ops, error, &ap, vop_getextattr);
1132 vop_setextattr(struct vop_ops *ops, struct vnode *vp, char *name,
1133 struct uio *uio, struct ucred *cred, struct thread *td)
1135 struct vop_setextattr_args ap;
1138 ap.a_head.a_desc = &vop_setextattr_desc;
1139 ap.a_head.a_ops = ops;
1146 DO_OPS(ops, error, &ap, vop_setextattr);
1148 cache_update_fsmid_vp(vp);
1153 vop_createvobject(struct vop_ops *ops, struct vnode *vp, struct thread *td)
1155 struct vop_createvobject_args ap;
1158 ap.a_head.a_desc = &vop_createvobject_desc;
1159 ap.a_head.a_ops = ops;
1163 DO_OPS(ops, error, &ap, vop_createvobject);
1168 vop_destroyvobject(struct vop_ops *ops, struct vnode *vp)
1170 struct vop_destroyvobject_args ap;
1173 ap.a_head.a_desc = &vop_destroyvobject_desc;
1174 ap.a_head.a_ops = ops;
1177 DO_OPS(ops, error, &ap, vop_destroyvobject);
1182 vop_getvobject(struct vop_ops *ops, struct vnode *vp, struct vm_object **objpp)
1184 struct vop_getvobject_args ap;
1187 ap.a_head.a_desc = &vop_getvobject_desc;
1188 ap.a_head.a_ops = ops;
1192 DO_OPS(ops, error, &ap, vop_getvobject);
1197 vop_mountctl(struct vop_ops *ops, int op, struct file *fp,
1198 const void *ctl, int ctllen, void *buf, int buflen, int *res)
1200 struct vop_mountctl_args ap;
1203 ap.a_head.a_desc = &vop_mountctl_desc;
1204 ap.a_head.a_ops = ops;
1208 ap.a_ctllen = ctllen;
1210 ap.a_buflen = buflen;
1213 DO_OPS(ops, error, &ap, vop_mountctl);
1220 * nresolve takes a locked ncp and a cred and resolves the ncp into a
1221 * positive or negative hit.
1223 * The namecache is automatically adjusted by this function. The ncp
1224 * is left locked on return.
1227 vop_nresolve(struct vop_ops *ops, struct namecache *ncp, struct ucred *cred)
1229 struct vop_nresolve_args ap;
1232 ap.a_head.a_desc = &vop_nresolve_desc;
1233 ap.a_head.a_ops = ops;
1237 DO_OPS(ops, error, &ap, vop_nresolve);
1242 * nlookupdotdot takes an unlocked directory, dvp, and looks up "..", returning
1243 * a locked parent directory in *vpp. If an error occurs *vpp will be NULL.
1246 vop_nlookupdotdot(struct vop_ops *ops, struct vnode *dvp,
1247 struct vnode **vpp, struct ucred *cred)
1249 struct vop_nlookupdotdot_args ap;
1252 ap.a_head.a_desc = &vop_nlookupdotdot_desc;
1253 ap.a_head.a_ops = ops;
1258 DO_OPS(ops, error, &ap, vop_nlookupdotdot);
1263 * ncreate takes a locked, resolved ncp that typically represents a negative
1264 * cache hit and creates the file or node specified by the ncp, cred, and
1265 * vattr. If no error occurs a locked vnode is returned in *vpp.
1267 * The namecache is automatically adjusted by this function. The ncp
1268 * is left locked on return.
1271 vop_ncreate(struct vop_ops *ops, struct namecache *ncp,
1272 struct vnode **vpp, struct ucred *cred, struct vattr *vap)
1274 struct vop_ncreate_args ap;
1277 ap.a_head.a_desc = &vop_ncreate_desc;
1278 ap.a_head.a_ops = ops;
1284 DO_OPS(ops, error, &ap, vop_ncreate);
1285 if (error == 0 && *vpp)
1286 cache_update_fsmid_vp(*vpp);
1291 * nmkdir takes a locked, resolved ncp that typically represents a negative
1292 * cache hit and creates the directory specified by the ncp, cred, and
1293 * vattr. If no error occurs a locked vnode is returned in *vpp.
1295 * The namecache is automatically adjusted by this function. The ncp
1296 * is left locked on return.
1299 vop_nmkdir(struct vop_ops *ops, struct namecache *ncp,
1300 struct vnode **vpp, struct ucred *cred, struct vattr *vap)
1302 struct vop_nmkdir_args ap;
1305 ap.a_head.a_desc = &vop_nmkdir_desc;
1306 ap.a_head.a_ops = ops;
1312 DO_OPS(ops, error, &ap, vop_nmkdir);
1313 if (error == 0 && *vpp)
1314 cache_update_fsmid_vp(*vpp);
1319 * nmknod takes a locked, resolved ncp that typically represents a negative
1320 * cache hit and creates the node specified by the ncp, cred, and
1321 * vattr. If no error occurs a locked vnode is returned in *vpp.
1323 * The namecache is automatically adjusted by this function. The ncp
1324 * is left locked on return.
1327 vop_nmknod(struct vop_ops *ops, struct namecache *ncp,
1328 struct vnode **vpp, struct ucred *cred, struct vattr *vap)
1330 struct vop_nmknod_args ap;
1333 ap.a_head.a_desc = &vop_nmknod_desc;
1334 ap.a_head.a_ops = ops;
1340 DO_OPS(ops, error, &ap, vop_nmknod);
1341 if (error == 0 && *vpp)
1342 cache_update_fsmid_vp(*vpp);
1347 * nlink takes a locked, resolved ncp that typically represents a negative
1348 * cache hit and creates the node specified by the ncp, cred, and
1349 * existing vnode. The passed vp must be locked and will remain locked
1350 * on return, as does the ncp, whether an error occurs or not.
1352 * The namecache is automatically adjusted by this function. The ncp
1353 * is left locked on return.
1356 vop_nlink(struct vop_ops *ops, struct namecache *ncp,
1357 struct vnode *vp, struct ucred *cred)
1359 struct vop_nlink_args ap;
1362 ap.a_head.a_desc = &vop_nlink_desc;
1363 ap.a_head.a_ops = ops;
1368 DO_OPS(ops, error, &ap, vop_nlink);
1370 cache_update_fsmid(ncp);
1375 * nsymlink takes a locked, resolved ncp that typically represents a negative
1376 * cache hit and creates a symbolic link based on cred, vap, and target (the
1377 * contents of the link). If no error occurs a locked vnode is returned in
1380 * The namecache is automatically adjusted by this function. The ncp
1381 * is left locked on return.
1384 vop_nsymlink(struct vop_ops *ops, struct namecache *ncp,
1385 struct vnode **vpp, struct ucred *cred,
1386 struct vattr *vap, char *target)
1388 struct vop_nsymlink_args ap;
1391 ap.a_head.a_desc = &vop_nsymlink_desc;
1392 ap.a_head.a_ops = ops;
1397 ap.a_target = target;
1399 DO_OPS(ops, error, &ap, vop_nsymlink);
1401 cache_update_fsmid(ncp);
1406 * nwhiteout takes a locked, resolved ncp that can represent a positive or
1407 * negative hit and executes the whiteout function specified in flags.
1409 * The namecache is automatically adjusted by this function. The ncp
1410 * is left locked on return.
1413 vop_nwhiteout(struct vop_ops *ops, struct namecache *ncp,
1414 struct ucred *cred, int flags)
1416 struct vop_nwhiteout_args ap;
1419 ap.a_head.a_desc = &vop_nwhiteout_desc;
1420 ap.a_head.a_ops = ops;
1425 DO_OPS(ops, error, &ap, vop_nwhiteout);
1427 cache_update_fsmid(ncp);
1432 * nremove takes a locked, resolved ncp that generally represents a
1433 * positive hit and removes the file.
1435 * The namecache is automatically adjusted by this function. The ncp
1436 * is left locked on return.
1439 vop_nremove(struct vop_ops *ops, struct namecache *ncp, struct ucred *cred)
1441 struct vop_nremove_args ap;
1444 ap.a_head.a_desc = &vop_nremove_desc;
1445 ap.a_head.a_ops = ops;
1449 DO_OPS(ops, error, &ap, vop_nremove);
1451 cache_update_fsmid(ncp);
1456 * nrmdir takes a locked, resolved ncp that generally represents a
1457 * directory and removes the directory.
1459 * The namecache is automatically adjusted by this function. The ncp
1460 * is left locked on return.
1463 vop_nrmdir(struct vop_ops *ops, struct namecache *ncp, struct ucred *cred)
1465 struct vop_nrmdir_args ap;
1468 ap.a_head.a_desc = &vop_nrmdir_desc;
1469 ap.a_head.a_ops = ops;
1473 DO_OPS(ops, error, &ap, vop_nrmdir);
1475 cache_update_fsmid(ncp);
1480 * nrename takes TWO locked, resolved ncp's and the cred of the caller
1481 * and renames the source ncp to the target ncp. The target ncp may
1482 * represent a positive or negative hit.
1484 * The namecache is automatically adjusted by this function. The ncp
1485 * is left locked on return. The source ncp is typically changed to
1486 * a negative cache hit and the target ncp typically takes on the
1487 * source ncp's underlying file.
1490 vop_nrename(struct vop_ops *ops, struct namecache *fncp,
1491 struct namecache *tncp, struct ucred *cred)
1493 struct vop_nrename_args ap;
1496 ap.a_head.a_desc = &vop_nrename_desc;
1497 ap.a_head.a_ops = ops;
1502 DO_OPS(ops, error, &ap, vop_nrename);
1504 cache_update_fsmid(fncp);
1505 cache_update_fsmid(tncp);
1510 /************************************************************************
1511 * PRIMARY VNODE OPERATIONS FORWARDING CALLS *
1512 ************************************************************************
1514 * These procedures are called from VFSs such as unionfs and nullfs
1515 * when they wish to forward an operation on one VFS to another. The
1516 * argument structure/message is modified and then directly passed to the
1517 * appropriate routine. This routines may also be called by initiators
1518 * who have an argument structure in hand rather then discreet arguments.
1521 vop_vnoperate_ap(struct vop_generic_args *ap)
1523 struct vop_ops *ops;
1527 error = VOCALL(ops, ap);
1533 * This routine is called by the cache coherency layer to execute the actual
1534 * VFS operation. If a journaling layer is present we call though it, else
1535 * we call the native VOP functions.
1538 vop_cache_operate_ap(struct vop_generic_args *ap)
1540 struct vop_ops *ops;
1544 if (ops->vv_mount->mnt_vn_journal_ops)
1545 error = VOCALL(ops->vv_mount->mnt_vn_journal_ops, ap);
1547 error = VOCALL(ops->vv_mount->mnt_vn_norm_ops, ap);
1553 * This routine is called by the journaling layer to execute the actual
1557 vop_journal_operate_ap(struct vop_generic_args *ap)
1559 struct vop_ops *ops;
1563 error = VOCALL(ops->vv_mount->mnt_vn_norm_ops, ap);
1569 vop_islocked_ap(struct vop_islocked_args *ap)
1573 DO_OPS(ap->a_head.a_ops, error, ap, vop_islocked);
1578 vop_open_ap(struct vop_open_args *ap)
1582 DO_OPS(ap->a_head.a_ops, error, ap, vop_open);
1587 vop_close_ap(struct vop_close_args *ap)
1591 DO_OPS(ap->a_head.a_ops, error, ap, vop_close);
1596 vop_access_ap(struct vop_access_args *ap)
1600 DO_OPS(ap->a_head.a_ops, error, ap, vop_access);
1605 vop_getattr_ap(struct vop_getattr_args *ap)
1609 DO_OPS(ap->a_head.a_ops, error, ap, vop_getattr);
1614 vop_setattr_ap(struct vop_setattr_args *ap)
1618 DO_OPS(ap->a_head.a_ops, error, ap, vop_setattr);
1623 vop_read_ap(struct vop_read_args *ap)
1627 DO_OPS(ap->a_head.a_ops, error, ap, vop_read);
1632 vop_write_ap(struct vop_write_args *ap)
1636 DO_OPS(ap->a_head.a_ops, error, ap, vop_write);
1641 vop_lease_ap(struct vop_lease_args *ap)
1645 DO_OPS(ap->a_head.a_ops, error, ap, vop_lease);
1650 vop_ioctl_ap(struct vop_ioctl_args *ap)
1654 DO_OPS(ap->a_head.a_ops, error, ap, vop_ioctl);
1659 vop_poll_ap(struct vop_poll_args *ap)
1663 DO_OPS(ap->a_head.a_ops, error, ap, vop_poll);
1668 vop_kqfilter_ap(struct vop_kqfilter_args *ap)
1672 DO_OPS(ap->a_head.a_ops, error, ap, vop_kqfilter);
1677 vop_revoke_ap(struct vop_revoke_args *ap)
1681 DO_OPS(ap->a_head.a_ops, error, ap, vop_revoke);
1686 vop_mmap_ap(struct vop_mmap_args *ap)
1690 DO_OPS(ap->a_head.a_ops, error, ap, vop_mmap);
1695 vop_fsync_ap(struct vop_fsync_args *ap)
1699 DO_OPS(ap->a_head.a_ops, error, ap, vop_fsync);
1704 vop_readdir_ap(struct vop_readdir_args *ap)
1708 DO_OPS(ap->a_head.a_ops, error, ap, vop_readdir);
1713 vop_readlink_ap(struct vop_readlink_args *ap)
1717 DO_OPS(ap->a_head.a_ops, error, ap, vop_readlink);
1722 vop_inactive_ap(struct vop_inactive_args *ap)
1726 DO_OPS(ap->a_head.a_ops, error, ap, vop_inactive);
1731 vop_reclaim_ap(struct vop_reclaim_args *ap)
1735 DO_OPS(ap->a_head.a_ops, error, ap, vop_reclaim);
1740 vop_lock_ap(struct vop_lock_args *ap)
1744 DO_OPS(ap->a_head.a_ops, error, ap, vop_lock);
1749 vop_unlock_ap(struct vop_unlock_args *ap)
1753 DO_OPS(ap->a_head.a_ops, error, ap, vop_unlock);
1758 vop_bmap_ap(struct vop_bmap_args *ap)
1762 DO_OPS(ap->a_head.a_ops, error, ap, vop_bmap);
1767 vop_strategy_ap(struct vop_strategy_args *ap)
1771 DO_OPS(ap->a_head.a_ops, error, ap, vop_strategy);
1776 vop_print_ap(struct vop_print_args *ap)
1780 DO_OPS(ap->a_head.a_ops, error, ap, vop_print);
1785 vop_pathconf_ap(struct vop_pathconf_args *ap)
1789 DO_OPS(ap->a_head.a_ops, error, ap, vop_pathconf);
1794 vop_advlock_ap(struct vop_advlock_args *ap)
1798 DO_OPS(ap->a_head.a_ops, error, ap, vop_advlock);
1803 vop_balloc_ap(struct vop_balloc_args *ap)
1807 DO_OPS(ap->a_head.a_ops, error, ap, vop_balloc);
1812 vop_reallocblks_ap(struct vop_reallocblks_args *ap)
1816 DO_OPS(ap->a_head.a_ops, error, ap, vop_reallocblks);
1821 vop_getpages_ap(struct vop_getpages_args *ap)
1825 DO_OPS(ap->a_head.a_ops, error, ap, vop_getpages);
1830 vop_putpages_ap(struct vop_putpages_args *ap)
1834 DO_OPS(ap->a_head.a_ops, error, ap, vop_putpages);
1839 vop_freeblks_ap(struct vop_freeblks_args *ap)
1843 DO_OPS(ap->a_head.a_ops, error, ap, vop_freeblks);
1848 vop_bwrite_ap(struct vop_bwrite_args *ap)
1852 DO_OPS(ap->a_head.a_ops, error, ap, vop_bwrite);
1857 vop_getacl_ap(struct vop_getacl_args *ap)
1861 DO_OPS(ap->a_head.a_ops, error, ap, vop_getacl);
1866 vop_setacl_ap(struct vop_setacl_args *ap)
1870 DO_OPS(ap->a_head.a_ops, error, ap, vop_setacl);
1875 vop_aclcheck_ap(struct vop_aclcheck_args *ap)
1879 DO_OPS(ap->a_head.a_ops, error, ap, vop_aclcheck);
1884 vop_getextattr_ap(struct vop_getextattr_args *ap)
1888 DO_OPS(ap->a_head.a_ops, error, ap, vop_getextattr);
1893 vop_setextattr_ap(struct vop_setextattr_args *ap)
1897 DO_OPS(ap->a_head.a_ops, error, ap, vop_setextattr);
1902 vop_createvobject_ap(struct vop_createvobject_args *ap)
1906 DO_OPS(ap->a_head.a_ops, error, ap, vop_createvobject);
1911 vop_destroyvobject_ap(struct vop_destroyvobject_args *ap)
1915 DO_OPS(ap->a_head.a_ops, error, ap, vop_destroyvobject);
1920 vop_getvobject_ap(struct vop_getvobject_args *ap)
1924 DO_OPS(ap->a_head.a_ops, error, ap, vop_getvobject);
1929 vop_mountctl_ap(struct vop_mountctl_args *ap)
1933 DO_OPS(ap->a_head.a_ops, error, ap, vop_mountctl);
1938 vop_nresolve_ap(struct vop_nresolve_args *ap)
1942 DO_OPS(ap->a_head.a_ops, error, ap, vop_nresolve);
1947 vop_nlookupdotdot_ap(struct vop_nlookupdotdot_args *ap)
1951 DO_OPS(ap->a_head.a_ops, error, ap, vop_nlookupdotdot);
1956 vop_ncreate_ap(struct vop_ncreate_args *ap)
1960 DO_OPS(ap->a_head.a_ops, error, ap, vop_ncreate);
1965 vop_nmkdir_ap(struct vop_nmkdir_args *ap)
1969 DO_OPS(ap->a_head.a_ops, error, ap, vop_nmkdir);
1974 vop_nmknod_ap(struct vop_nmknod_args *ap)
1978 DO_OPS(ap->a_head.a_ops, error, ap, vop_nmknod);
1983 vop_nlink_ap(struct vop_nlink_args *ap)
1987 DO_OPS(ap->a_head.a_ops, error, ap, vop_nlink);
1992 vop_nsymlink_ap(struct vop_nsymlink_args *ap)
1996 DO_OPS(ap->a_head.a_ops, error, ap, vop_nsymlink);
2001 vop_nwhiteout_ap(struct vop_nwhiteout_args *ap)
2005 DO_OPS(ap->a_head.a_ops, error, ap, vop_nwhiteout);
2010 vop_nremove_ap(struct vop_nremove_args *ap)
2014 DO_OPS(ap->a_head.a_ops, error, ap, vop_nremove);
2019 vop_nrmdir_ap(struct vop_nrmdir_args *ap)
2023 DO_OPS(ap->a_head.a_ops, error, ap, vop_nrmdir);
2028 vop_nrename_ap(struct vop_nrename_args *ap)
2032 DO_OPS(ap->a_head.a_ops, error, ap, vop_nrename);