kernel/vm: Rename *_putpages()'s 'sync' argument to 'flags'.
[dragonfly.git] / sys / kern / vfs_vopops.c
blob3bb52951daa87928ddfb23faccb1f60ea9ec2cd5
1 /*
2 * Copyright (c) 2004,2009 The DragonFly Project. All rights reserved.
3 *
4 * This code is derived from software contributed to The DragonFly Project
5 * by Matthew Dillon <dillon@backplane.com>
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
16 * distribution.
17 * 3. Neither the name of The DragonFly Project nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific, prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
29 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
31 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
35 * Implement vnode ops wrappers. All vnode ops are wrapped through
36 * these functions.
38 * These wrappers are responsible for hanlding all MPSAFE issues related
39 * to a vnode operation.
42 #include <sys/param.h>
43 #include <sys/systm.h>
44 #include <sys/buf.h>
45 #include <sys/conf.h>
46 #include <sys/dirent.h>
47 #include <sys/domain.h>
48 #include <sys/eventhandler.h>
49 #include <sys/fcntl.h>
50 #include <sys/kernel.h>
51 #include <sys/kthread.h>
52 #include <sys/malloc.h>
53 #include <sys/mbuf.h>
54 #include <sys/mount.h>
55 #include <sys/proc.h>
56 #include <sys/namei.h>
57 #include <sys/reboot.h>
58 #include <sys/socket.h>
59 #include <sys/stat.h>
60 #include <sys/sysctl.h>
61 #include <sys/syslog.h>
62 #include <sys/vmmeter.h>
63 #include <sys/vnode.h>
64 #include <sys/vfsops.h>
65 #include <sys/sysmsg.h>
66 #include <sys/vfs_quota.h>
68 #include <machine/limits.h>
70 #include <vm/vm.h>
71 #include <vm/vm_object.h>
72 #include <vm/vm_extern.h>
73 #include <vm/vm_kern.h>
74 #include <vm/pmap.h>
75 #include <vm/vm_map.h>
76 #include <vm/vm_page.h>
77 #include <vm/vm_pager.h>
78 #include <vm/vnode_pager.h>
79 #include <vm/vm_zone.h>
81 #include <sys/buf2.h>
82 #include <sys/mplock2.h>
84 #define VDESCNAME(name) __CONCAT(__CONCAT(vop_,name),_desc)
86 #define VNODEOP_DESC_INIT(name) \
87 struct syslink_desc VDESCNAME(name) = { \
88 __offsetof(struct vop_ops, __CONCAT(vop_, name)), \
89 #name }
91 VNODEOP_DESC_INIT(default);
92 VNODEOP_DESC_INIT(old_lookup);
93 VNODEOP_DESC_INIT(old_create);
94 VNODEOP_DESC_INIT(old_whiteout);
95 VNODEOP_DESC_INIT(old_mknod);
96 VNODEOP_DESC_INIT(open);
97 VNODEOP_DESC_INIT(close);
98 VNODEOP_DESC_INIT(access);
99 VNODEOP_DESC_INIT(getattr);
100 VNODEOP_DESC_INIT(getattr_quick);
101 VNODEOP_DESC_INIT(setattr);
102 VNODEOP_DESC_INIT(read);
103 VNODEOP_DESC_INIT(write);
104 VNODEOP_DESC_INIT(ioctl);
105 VNODEOP_DESC_INIT(poll);
106 VNODEOP_DESC_INIT(kqfilter);
107 VNODEOP_DESC_INIT(mmap);
108 VNODEOP_DESC_INIT(fsync);
109 VNODEOP_DESC_INIT(old_remove);
110 VNODEOP_DESC_INIT(old_link);
111 VNODEOP_DESC_INIT(old_rename);
113 VNODEOP_DESC_INIT(old_mkdir);
114 VNODEOP_DESC_INIT(old_rmdir);
115 VNODEOP_DESC_INIT(old_symlink);
116 VNODEOP_DESC_INIT(readdir);
117 VNODEOP_DESC_INIT(readlink);
118 VNODEOP_DESC_INIT(inactive);
119 VNODEOP_DESC_INIT(reclaim);
120 VNODEOP_DESC_INIT(bmap);
121 VNODEOP_DESC_INIT(strategy);
122 VNODEOP_DESC_INIT(print);
123 VNODEOP_DESC_INIT(pathconf);
124 VNODEOP_DESC_INIT(advlock);
125 VNODEOP_DESC_INIT(balloc);
126 VNODEOP_DESC_INIT(reallocblks);
127 VNODEOP_DESC_INIT(getpages);
128 VNODEOP_DESC_INIT(putpages);
129 VNODEOP_DESC_INIT(freeblks);
130 VNODEOP_DESC_INIT(getacl);
131 VNODEOP_DESC_INIT(setacl);
132 VNODEOP_DESC_INIT(aclcheck);
133 VNODEOP_DESC_INIT(getextattr);
134 VNODEOP_DESC_INIT(setextattr);
135 VNODEOP_DESC_INIT(mountctl);
136 VNODEOP_DESC_INIT(markatime);
138 VNODEOP_DESC_INIT(nresolve);
139 VNODEOP_DESC_INIT(nlookupdotdot);
140 VNODEOP_DESC_INIT(ncreate);
141 VNODEOP_DESC_INIT(nmkdir);
142 VNODEOP_DESC_INIT(nmknod);
143 VNODEOP_DESC_INIT(nlink);
144 VNODEOP_DESC_INIT(nsymlink);
145 VNODEOP_DESC_INIT(nwhiteout);
146 VNODEOP_DESC_INIT(nremove);
147 VNODEOP_DESC_INIT(nrmdir);
148 VNODEOP_DESC_INIT(nrename);
150 #define DO_OPS(ops, error, ap, vop_field) \
151 error = ops->vop_field(ap)
153 /************************************************************************
154 * PRIMARY HIGH LEVEL VNODE OPERATIONS CALLS *
155 ************************************************************************
157 * These procedures are called directly from the kernel and/or fileops
158 * code to perform file/device operations on the system.
160 * NOTE: The old namespace api functions such as vop_rename() are no
161 * longer available for general use and have been renamed to
162 * vop_old_*(). Only the code in vfs_default.c is allowed to call
163 * those ops.
165 * NOTE: The VFS_MPLOCK() macro handle mounts which do not set MNTK_MPSAFE.
167 * MPSAFE
171 vop_old_lookup(struct vop_ops *ops, struct vnode *dvp,
172 struct vnode **vpp, struct componentname *cnp)
174 struct vop_old_lookup_args ap;
175 VFS_MPLOCK_DECLARE;
176 int error;
178 ap.a_head.a_desc = &vop_old_lookup_desc;
179 ap.a_head.a_ops = ops;
180 ap.a_dvp = dvp;
181 ap.a_vpp = vpp;
182 ap.a_cnp = cnp;
183 VFS_MPLOCK(dvp->v_mount);
184 DO_OPS(ops, error, &ap, vop_old_lookup);
185 VFS_MPUNLOCK();
187 return(error);
191 * MPSAFE
194 vop_old_create(struct vop_ops *ops, struct vnode *dvp,
195 struct vnode **vpp, struct componentname *cnp, struct vattr *vap)
197 struct vop_old_create_args ap;
198 VFS_MPLOCK_DECLARE;
199 int error;
201 ap.a_head.a_desc = &vop_old_create_desc;
202 ap.a_head.a_ops = ops;
203 ap.a_dvp = dvp;
204 ap.a_vpp = vpp;
205 ap.a_cnp = cnp;
206 ap.a_vap = vap;
208 VFS_MPLOCK(dvp->v_mount);
209 DO_OPS(ops, error, &ap, vop_old_create);
210 VFS_MPUNLOCK();
212 return(error);
216 * MPSAFE
219 vop_old_whiteout(struct vop_ops *ops, struct vnode *dvp,
220 struct componentname *cnp, int flags)
222 struct vop_old_whiteout_args ap;
223 VFS_MPLOCK_DECLARE;
224 int error;
226 ap.a_head.a_desc = &vop_old_whiteout_desc;
227 ap.a_head.a_ops = ops;
228 ap.a_dvp = dvp;
229 ap.a_cnp = cnp;
230 ap.a_flags = flags;
232 VFS_MPLOCK(dvp->v_mount);
233 DO_OPS(ops, error, &ap, vop_old_whiteout);
234 VFS_MPUNLOCK();
236 return(error);
240 * MPSAFE
243 vop_old_mknod(struct vop_ops *ops, struct vnode *dvp,
244 struct vnode **vpp, struct componentname *cnp, struct vattr *vap)
246 struct vop_old_mknod_args ap;
247 VFS_MPLOCK_DECLARE;
248 int error;
250 ap.a_head.a_desc = &vop_old_mknod_desc;
251 ap.a_head.a_ops = ops;
252 ap.a_dvp = dvp;
253 ap.a_vpp = vpp;
254 ap.a_cnp = cnp;
255 ap.a_vap = vap;
257 VFS_MPLOCK(dvp->v_mount);
258 DO_OPS(ops, error, &ap, vop_old_mknod);
259 VFS_MPUNLOCK();
261 return(error);
265 * NOTE: VAGE is always cleared when calling VOP_OPEN().
268 vop_open(struct vop_ops *ops, struct vnode *vp, int mode, struct ucred *cred,
269 struct file *fp)
271 struct vop_open_args ap;
272 VFS_MPLOCK_DECLARE;
273 int error;
276 * Decrement 3-2-1-0. Does not decrement beyond 0
278 if (vp->v_flag & VAGE0) {
279 vclrflags(vp, VAGE0);
280 } else if (vp->v_flag & VAGE1) {
281 vclrflags(vp, VAGE1);
282 vsetflags(vp, VAGE0);
285 ap.a_head.a_desc = &vop_open_desc;
286 ap.a_head.a_ops = ops;
287 ap.a_vp = vp;
288 ap.a_fp = fp;
289 ap.a_mode = mode;
290 ap.a_cred = cred;
292 VFS_MPLOCK(vp->v_mount);
293 DO_OPS(ops, error, &ap, vop_open);
294 VFS_MPUNLOCK();
296 return(error);
300 * MPSAFE
303 vop_close(struct vop_ops *ops, struct vnode *vp, int fflag,
304 struct file *fp)
306 struct vop_close_args ap;
307 VFS_MPLOCK_DECLARE;
308 int error;
310 ap.a_head.a_desc = &vop_close_desc;
311 ap.a_head.a_ops = ops;
312 ap.a_vp = vp;
313 ap.a_fp = fp;
314 ap.a_fflag = fflag;
316 VFS_MPLOCK(vp->v_mount);
317 DO_OPS(ops, error, &ap, vop_close);
318 VFS_MPUNLOCK();
320 return(error);
324 * MPSAFE
327 vop_access(struct vop_ops *ops, struct vnode *vp, int mode, int flags,
328 struct ucred *cred)
330 struct vop_access_args ap;
331 VFS_MPLOCK_DECLARE;
332 int error;
334 ap.a_head.a_desc = &vop_access_desc;
335 ap.a_head.a_ops = ops;
336 ap.a_vp = vp;
337 ap.a_mode = mode;
338 ap.a_flags = flags;
339 ap.a_cred = cred;
341 VFS_MPLOCK(vp->v_mount);
342 DO_OPS(ops, error, &ap, vop_access);
343 VFS_MPUNLOCK();
345 return(error);
349 * MPSAFE
352 vop_getattr(struct vop_ops *ops, struct vnode *vp, struct vattr *vap,
353 struct file *fp)
355 struct vop_getattr_args ap;
356 VFS_MPLOCK_DECLARE;
357 int error;
359 ap.a_head.a_desc = &vop_getattr_desc;
360 ap.a_head.a_ops = ops;
361 ap.a_vp = vp;
362 ap.a_vap = vap;
363 ap.a_fp = fp;
365 VFS_MPLOCK_FLAG(vp->v_mount, MNTK_GA_MPSAFE);
366 DO_OPS(ops, error, &ap, vop_getattr);
367 VFS_MPUNLOCK();
369 return(error);
373 * MPSAFE
376 vop_getattr_quick(struct vop_ops *ops, struct vnode *vp, struct vattr *vap)
378 struct vop_getattr_args ap;
379 VFS_MPLOCK_DECLARE;
380 int error;
382 ap.a_head.a_desc = &vop_getattr_quick_desc;
383 ap.a_head.a_ops = ops;
384 ap.a_vp = vp;
385 ap.a_vap = vap;
386 ap.a_fp = NULL;
388 VFS_MPLOCK_FLAG(vp->v_mount, MNTK_GA_MPSAFE);
389 DO_OPS(ops, error, &ap, vop_getattr_quick);
390 VFS_MPUNLOCK();
392 return(error);
396 * MPSAFE
399 vop_setattr(struct vop_ops *ops, struct vnode *vp, struct vattr *vap,
400 struct ucred *cred, struct file *fp)
402 struct vop_setattr_args ap;
403 VFS_MPLOCK_DECLARE;
404 int error;
406 ap.a_head.a_desc = &vop_setattr_desc;
407 ap.a_head.a_ops = ops;
408 ap.a_vp = vp;
409 ap.a_vap = vap;
410 ap.a_cred = cred;
411 ap.a_fp = fp;
413 VFS_MPLOCK(vp->v_mount);
414 DO_OPS(ops, error, &ap, vop_setattr);
415 VFS_MPUNLOCK();
417 return(error);
421 * MPSAFE
424 vop_read(struct vop_ops *ops, struct vnode *vp, struct uio *uio, int ioflag,
425 struct ucred *cred, struct file *fp)
427 struct vop_read_args ap;
428 VFS_MPLOCK_DECLARE;
429 int error;
431 ap.a_head.a_desc = &vop_read_desc;
432 ap.a_head.a_ops = ops;
433 ap.a_vp = vp;
434 ap.a_uio = uio;
435 ap.a_ioflag = ioflag;
436 ap.a_cred = cred;
437 ap.a_fp = fp;
439 VFS_MPLOCK_FLAG(vp->v_mount, MNTK_RD_MPSAFE);
440 DO_OPS(ops, error, &ap, vop_read);
441 VFS_MPUNLOCK();
443 return(error);
447 * MPSAFE
450 vop_write(struct vop_ops *ops, struct vnode *vp, struct uio *uio, int ioflag,
451 struct ucred *cred, struct file *fp)
453 struct vop_write_args ap;
454 VFS_MPLOCK_DECLARE;
455 int error, do_accounting = 0;
456 struct vattr va;
457 uint64_t size_before=0, size_after=0;
458 struct mount *mp;
459 uint64_t offset, delta;
461 ap.a_head.a_desc = &vop_write_desc;
462 ap.a_head.a_ops = ops;
463 ap.a_vp = vp;
464 ap.a_uio = uio;
465 ap.a_ioflag = ioflag;
466 ap.a_cred = cred;
467 ap.a_fp = fp;
469 /* is this a regular vnode ? */
470 VFS_MPLOCK_FLAG(vp->v_mount, MNTK_WR_MPSAFE);
471 if (vfs_quota_enabled && (vp->v_type == VREG)) {
472 if ((error = VOP_GETATTR(vp, &va)) != 0)
473 goto done;
474 size_before = va.va_size;
475 /* this file may already have been removed */
476 if (va.va_nlink > 0)
477 do_accounting = 1;
479 offset = uio->uio_offset;
480 if (ioflag & IO_APPEND)
481 offset = size_before;
482 size_after = offset + uio->uio_resid;
483 if (size_after < size_before)
484 size_after = size_before;
485 delta = size_after - size_before;
486 mp = vq_vptomp(vp);
487 /* QUOTA CHECK */
488 if (!vq_write_ok(mp, va.va_uid, va.va_gid, delta)) {
489 error = EDQUOT;
490 goto done;
493 DO_OPS(ops, error, &ap, vop_write);
494 if ((error == 0) && do_accounting) {
495 VFS_ACCOUNT(mp, va.va_uid, va.va_gid, size_after - size_before);
497 done:
498 VFS_MPUNLOCK();
500 return(error);
504 * MPSAFE
507 vop_ioctl(struct vop_ops *ops, struct vnode *vp, u_long command, caddr_t data,
508 int fflag, struct ucred *cred, struct sysmsg *msg)
510 struct vop_ioctl_args ap;
511 VFS_MPLOCK_DECLARE;
512 int error;
514 ap.a_head.a_desc = &vop_ioctl_desc;
515 ap.a_head.a_ops = ops;
516 ap.a_vp = vp;
517 ap.a_command = command;
518 ap.a_data = data;
519 ap.a_fflag = fflag;
520 ap.a_cred = cred;
521 ap.a_sysmsg = msg;
523 VFS_MPLOCK(vp->v_mount);
524 DO_OPS(ops, error, &ap, vop_ioctl);
525 VFS_MPUNLOCK();
527 return(error);
531 * MPSAFE
534 vop_poll(struct vop_ops *ops, struct vnode *vp, int events, struct ucred *cred)
536 struct vop_poll_args ap;
537 VFS_MPLOCK_DECLARE;
538 int error;
540 ap.a_head.a_desc = &vop_poll_desc;
541 ap.a_head.a_ops = ops;
542 ap.a_vp = vp;
543 ap.a_events = events;
544 ap.a_cred = cred;
546 VFS_MPLOCK(vp->v_mount);
547 DO_OPS(ops, error, &ap, vop_poll);
548 VFS_MPUNLOCK();
550 return(error);
554 * MPSAFE
557 vop_kqfilter(struct vop_ops *ops, struct vnode *vp, struct knote *kn)
559 struct vop_kqfilter_args ap;
560 VFS_MPLOCK_DECLARE;
561 int error;
563 ap.a_head.a_desc = &vop_kqfilter_desc;
564 ap.a_head.a_ops = ops;
565 ap.a_vp = vp;
566 ap.a_kn = kn;
568 VFS_MPLOCK(vp->v_mount);
569 DO_OPS(ops, error, &ap, vop_kqfilter);
570 VFS_MPUNLOCK();
572 return(error);
576 * MPSAFE
579 vop_mmap(struct vop_ops *ops, struct vnode *vp, int fflags, struct ucred *cred)
581 struct vop_mmap_args ap;
582 VFS_MPLOCK_DECLARE;
583 int error;
585 ap.a_head.a_desc = &vop_mmap_desc;
586 ap.a_head.a_ops = ops;
587 ap.a_vp = vp;
588 ap.a_fflags = fflags;
589 ap.a_cred = cred;
591 VFS_MPLOCK(vp->v_mount);
592 DO_OPS(ops, error, &ap, vop_mmap);
593 VFS_MPUNLOCK();
595 return(error);
599 * MPSAFE
602 vop_fsync(struct vop_ops *ops, struct vnode *vp, int waitfor, int flags,
603 struct file *fp)
605 struct vop_fsync_args ap;
606 VFS_MPLOCK_DECLARE;
607 int error;
609 ap.a_head.a_desc = &vop_fsync_desc;
610 ap.a_head.a_ops = ops;
611 ap.a_vp = vp;
612 ap.a_waitfor = waitfor;
613 ap.a_flags = flags;
614 ap.a_fp = fp;
616 VFS_MPLOCK(vp->v_mount);
617 DO_OPS(ops, error, &ap, vop_fsync);
618 VFS_MPUNLOCK();
620 return(error);
624 * MPSAFE
627 vop_old_remove(struct vop_ops *ops, struct vnode *dvp,
628 struct vnode *vp, struct componentname *cnp)
630 struct vop_old_remove_args ap;
631 VFS_MPLOCK_DECLARE;
632 int error;
634 ap.a_head.a_desc = &vop_old_remove_desc;
635 ap.a_head.a_ops = ops;
636 ap.a_dvp = dvp;
637 ap.a_vp = vp;
638 ap.a_cnp = cnp;
640 VFS_MPLOCK(dvp->v_mount);
641 DO_OPS(ops, error, &ap, vop_old_remove);
642 VFS_MPUNLOCK();
644 return(error);
648 * MPSAFE
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;
655 VFS_MPLOCK_DECLARE;
656 int error;
658 ap.a_head.a_desc = &vop_old_link_desc;
659 ap.a_head.a_ops = ops;
660 ap.a_tdvp = tdvp;
661 ap.a_vp = vp;
662 ap.a_cnp = cnp;
664 VFS_MPLOCK(tdvp->v_mount);
665 DO_OPS(ops, error, &ap, vop_old_link);
666 VFS_MPUNLOCK();
668 return(error);
672 * MPSAFE
675 vop_old_rename(struct vop_ops *ops,
676 struct vnode *fdvp, struct vnode *fvp, struct componentname *fcnp,
677 struct vnode *tdvp, struct vnode *tvp, struct componentname *tcnp)
679 struct vop_old_rename_args ap;
680 VFS_MPLOCK_DECLARE;
681 int error;
683 ap.a_head.a_desc = &vop_old_rename_desc;
684 ap.a_head.a_ops = ops;
685 ap.a_fdvp = fdvp;
686 ap.a_fvp = fvp;
687 ap.a_fcnp = fcnp;
688 ap.a_tdvp = tdvp;
689 ap.a_tvp = tvp;
690 ap.a_tcnp = tcnp;
692 VFS_MPLOCK(tdvp->v_mount);
693 DO_OPS(ops, error, &ap, vop_old_rename);
694 VFS_MPUNLOCK();
696 return(error);
700 * MPSAFE
703 vop_old_mkdir(struct vop_ops *ops, struct vnode *dvp,
704 struct vnode **vpp, struct componentname *cnp, struct vattr *vap)
706 struct vop_old_mkdir_args ap;
707 VFS_MPLOCK_DECLARE;
708 int error;
710 ap.a_head.a_desc = &vop_old_mkdir_desc;
711 ap.a_head.a_ops = ops;
712 ap.a_dvp = dvp;
713 ap.a_vpp = vpp;
714 ap.a_cnp = cnp;
715 ap.a_vap = vap;
717 VFS_MPLOCK(dvp->v_mount);
718 DO_OPS(ops, error, &ap, vop_old_mkdir);
719 VFS_MPUNLOCK();
721 return(error);
725 * MPSAFE
728 vop_old_rmdir(struct vop_ops *ops, struct vnode *dvp,
729 struct vnode *vp, struct componentname *cnp)
731 struct vop_old_rmdir_args ap;
732 VFS_MPLOCK_DECLARE;
733 int error;
735 ap.a_head.a_desc = &vop_old_rmdir_desc;
736 ap.a_head.a_ops = ops;
737 ap.a_dvp = dvp;
738 ap.a_vp = vp;
739 ap.a_cnp = cnp;
741 VFS_MPLOCK(dvp->v_mount);
742 DO_OPS(ops, error, &ap, vop_old_rmdir);
743 VFS_MPUNLOCK();
745 return(error);
749 * MPSAFE
752 vop_old_symlink(struct vop_ops *ops, struct vnode *dvp,
753 struct vnode **vpp, struct componentname *cnp,
754 struct vattr *vap, char *target)
756 struct vop_old_symlink_args ap;
757 VFS_MPLOCK_DECLARE;
758 int error;
760 ap.a_head.a_desc = &vop_old_symlink_desc;
761 ap.a_head.a_ops = ops;
762 ap.a_dvp = dvp;
763 ap.a_vpp = vpp;
764 ap.a_cnp = cnp;
765 ap.a_vap = vap;
766 ap.a_target = target;
768 VFS_MPLOCK(dvp->v_mount);
769 DO_OPS(ops, error, &ap, vop_old_symlink);
770 VFS_MPUNLOCK();
772 return(error);
776 * MPSAFE
779 vop_readdir(struct vop_ops *ops, struct vnode *vp, struct uio *uio,
780 struct ucred *cred, int *eofflag, int *ncookies, off_t **cookies,
781 struct file *fp)
783 struct vop_readdir_args ap;
784 VFS_MPLOCK_DECLARE;
785 int error;
787 ap.a_head.a_desc = &vop_readdir_desc;
788 ap.a_head.a_ops = ops;
789 ap.a_vp = vp;
790 ap.a_uio = uio;
791 ap.a_cred = cred;
792 ap.a_eofflag = eofflag;
793 ap.a_ncookies = ncookies;
794 ap.a_cookies = cookies;
795 ap.a_fp = fp;
797 VFS_MPLOCK(vp->v_mount);
798 DO_OPS(ops, error, &ap, vop_readdir);
799 VFS_MPUNLOCK();
801 return(error);
805 * MPSAFE
808 vop_readlink(struct vop_ops *ops, struct vnode *vp, struct uio *uio,
809 struct ucred *cred)
811 struct vop_readlink_args ap;
812 VFS_MPLOCK_DECLARE;
813 int error;
815 ap.a_head.a_desc = &vop_readlink_desc;
816 ap.a_head.a_ops = ops;
817 ap.a_vp = vp;
818 ap.a_uio = uio;
819 ap.a_cred = cred;
821 VFS_MPLOCK(vp->v_mount);
822 DO_OPS(ops, error, &ap, vop_readlink);
823 VFS_MPUNLOCK();
825 return(error);
829 * MPSAFE
832 vop_inactive(struct vop_ops *ops, struct vnode *vp)
834 struct vop_inactive_args ap;
835 struct mount *mp;
836 VFS_MPLOCK_DECLARE;
837 int error;
839 ap.a_head.a_desc = &vop_inactive_desc;
840 ap.a_head.a_ops = ops;
841 ap.a_vp = vp;
844 * WARNING! Deactivation of the vnode can cause it to be recycled,
845 * clearing vp->v_mount.
847 mp = vp->v_mount;
848 VFS_MPLOCK_FLAG(mp, MNTK_IN_MPSAFE);
849 DO_OPS(ops, error, &ap, vop_inactive);
850 VFS_MPUNLOCK();
852 return(error);
856 * MPSAFE
859 vop_reclaim(struct vop_ops *ops, struct vnode *vp)
861 struct vop_reclaim_args ap;
862 struct mount *mp;
863 VFS_MPLOCK_DECLARE;
864 int error;
866 ap.a_head.a_desc = &vop_reclaim_desc;
867 ap.a_head.a_ops = ops;
868 ap.a_vp = vp;
871 * WARNING! Reclamation of the vnode will clear vp->v_mount.
873 mp = vp->v_mount;
874 VFS_MPLOCK(mp);
875 DO_OPS(ops, error, &ap, vop_reclaim);
876 VFS_MPUNLOCK();
878 return(error);
882 * MPSAFE
885 vop_bmap(struct vop_ops *ops, struct vnode *vp, off_t loffset,
886 off_t *doffsetp, int *runp, int *runb, buf_cmd_t cmd)
888 struct vop_bmap_args ap;
889 VFS_MPLOCK_DECLARE;
890 int error;
892 ap.a_head.a_desc = &vop_bmap_desc;
893 ap.a_head.a_ops = ops;
894 ap.a_vp = vp;
895 ap.a_loffset = loffset;
896 ap.a_doffsetp = doffsetp;
897 ap.a_runp = runp;
898 ap.a_runb = runb;
899 ap.a_cmd = cmd;
901 VFS_MPLOCK(vp->v_mount);
902 DO_OPS(ops, error, &ap, vop_bmap);
903 VFS_MPUNLOCK();
905 return(error);
909 * WARNING! Vnode can go-away after the ops call (e.g. async flush
910 * from buffer kthread).
913 vop_strategy(struct vop_ops *ops, struct vnode *vp, struct bio *bio)
915 struct vop_strategy_args ap;
916 VFS_MPLOCK_DECLARE;
917 int error;
919 ap.a_head.a_desc = &vop_strategy_desc;
920 ap.a_head.a_ops = ops;
921 ap.a_vp = vp;
922 ap.a_bio = bio;
924 if (vp->v_mount) {
925 VFS_MPLOCK_FLAG(vp->v_mount, MNTK_SG_MPSAFE);
926 DO_OPS(ops, error, &ap, vop_strategy);
927 VFS_MPUNLOCK();
928 } else {
929 /* ugly hack for swap */
930 get_mplock();
931 DO_OPS(ops, error, &ap, vop_strategy);
932 rel_mplock();
934 return(error);
938 * MPSAFE
941 vop_print(struct vop_ops *ops, struct vnode *vp)
943 struct vop_print_args ap;
944 VFS_MPLOCK_DECLARE;
945 int error;
947 ap.a_head.a_desc = &vop_print_desc;
948 ap.a_head.a_ops = ops;
949 ap.a_vp = vp;
951 VFS_MPLOCK(vp->v_mount);
952 DO_OPS(ops, error, &ap, vop_print);
953 VFS_MPUNLOCK();
955 return(error);
959 * MPSAFE
962 vop_pathconf(struct vop_ops *ops, struct vnode *vp, int name,
963 register_t *retval)
965 struct vop_pathconf_args ap;
966 VFS_MPLOCK_DECLARE;
967 int error;
969 ap.a_head.a_desc = &vop_pathconf_desc;
970 ap.a_head.a_ops = ops;
971 ap.a_vp = vp;
972 ap.a_name = name;
973 ap.a_retval = retval;
975 VFS_MPLOCK(vp->v_mount);
976 DO_OPS(ops, error, &ap, vop_pathconf);
977 VFS_MPUNLOCK();
979 return(error);
983 * MPSAFE
986 vop_advlock(struct vop_ops *ops, struct vnode *vp, caddr_t id, int op,
987 struct flock *fl, int flags)
989 struct vop_advlock_args ap;
990 VFS_MPLOCK_DECLARE;
991 int error;
993 ap.a_head.a_desc = &vop_advlock_desc;
994 ap.a_head.a_ops = ops;
995 ap.a_vp = vp;
996 ap.a_id = id;
997 ap.a_op = op;
998 ap.a_fl = fl;
999 ap.a_flags = flags;
1001 VFS_MPLOCK(vp->v_mount);
1002 DO_OPS(ops, error, &ap, vop_advlock);
1003 VFS_MPUNLOCK();
1005 return(error);
1009 * MPSAFE
1012 vop_balloc(struct vop_ops *ops, struct vnode *vp, off_t startoffset,
1013 int size, struct ucred *cred, int flags,
1014 struct buf **bpp)
1016 struct vop_balloc_args ap;
1017 VFS_MPLOCK_DECLARE;
1018 int error;
1020 ap.a_head.a_desc = &vop_balloc_desc;
1021 ap.a_head.a_ops = ops;
1022 ap.a_vp = vp;
1023 ap.a_startoffset = startoffset;
1024 ap.a_size = size;
1025 ap.a_cred = cred;
1026 ap.a_flags = flags;
1027 ap.a_bpp = bpp;
1029 VFS_MPLOCK(vp->v_mount);
1030 DO_OPS(ops, error, &ap, vop_balloc);
1031 VFS_MPUNLOCK();
1033 return(error);
1037 * MPSAFE
1040 vop_reallocblks(struct vop_ops *ops, struct vnode *vp,
1041 struct cluster_save *buflist)
1043 struct vop_reallocblks_args ap;
1044 VFS_MPLOCK_DECLARE;
1045 int error;
1047 ap.a_head.a_desc = &vop_reallocblks_desc;
1048 ap.a_head.a_ops = ops;
1049 ap.a_vp = vp;
1050 ap.a_buflist = buflist;
1052 VFS_MPLOCK(vp->v_mount);
1053 DO_OPS(ops, error, &ap, vop_reallocblks);
1054 VFS_MPUNLOCK();
1056 return(error);
1060 * MPSAFE
1063 vop_getpages(struct vop_ops *ops, struct vnode *vp, vm_page_t *m, int count,
1064 int reqpage, vm_ooffset_t offset, int seqaccess)
1066 struct vop_getpages_args ap;
1067 VFS_MPLOCK_DECLARE;
1068 int error;
1070 ap.a_head.a_desc = &vop_getpages_desc;
1071 ap.a_head.a_ops = ops;
1072 ap.a_vp = vp;
1073 ap.a_m = m;
1074 ap.a_count = count;
1075 ap.a_reqpage = reqpage;
1076 ap.a_offset = offset;
1077 ap.a_seqaccess = seqaccess;
1079 VFS_MPLOCK(vp->v_mount);
1080 DO_OPS(ops, error, &ap, vop_getpages);
1081 VFS_MPUNLOCK();
1083 return(error);
1087 * MPSAFE
1090 vop_putpages(struct vop_ops *ops, struct vnode *vp, vm_page_t *m, int count,
1091 int flags, int *rtvals, vm_ooffset_t offset)
1093 struct vop_putpages_args ap;
1094 VFS_MPLOCK_DECLARE;
1095 int error;
1097 ap.a_head.a_desc = &vop_putpages_desc;
1098 ap.a_head.a_ops = ops;
1099 ap.a_vp = vp;
1100 ap.a_m = m;
1101 ap.a_count = count;
1102 ap.a_flags = flags;
1103 ap.a_rtvals = rtvals;
1104 ap.a_offset = offset;
1106 VFS_MPLOCK(vp->v_mount);
1107 DO_OPS(ops, error, &ap, vop_putpages);
1108 VFS_MPUNLOCK();
1110 return(error);
1114 * MPSAFE
1117 vop_freeblks(struct vop_ops *ops, struct vnode *vp, off_t offset, int length)
1119 struct vop_freeblks_args ap;
1120 VFS_MPLOCK_DECLARE;
1121 int error;
1123 ap.a_head.a_desc = &vop_freeblks_desc;
1124 ap.a_head.a_ops = ops;
1125 ap.a_vp = vp;
1126 ap.a_offset = offset;
1127 ap.a_length = length;
1129 VFS_MPLOCK(vp->v_mount);
1130 DO_OPS(ops, error, &ap, vop_freeblks);
1131 VFS_MPUNLOCK();
1133 return(error);
1137 * MPSAFE
1140 vop_getacl(struct vop_ops *ops, struct vnode *vp, acl_type_t type,
1141 struct acl *aclp, struct ucred *cred)
1143 struct vop_getacl_args ap;
1144 VFS_MPLOCK_DECLARE;
1145 int error;
1147 ap.a_head.a_desc = &vop_getacl_desc;
1148 ap.a_head.a_ops = ops;
1149 ap.a_vp = vp;
1150 ap.a_type = type;
1151 ap.a_aclp = aclp;
1152 ap.a_cred = cred;
1154 VFS_MPLOCK(vp->v_mount);
1155 DO_OPS(ops, error, &ap, vop_getacl);
1156 VFS_MPUNLOCK();
1158 return(error);
1162 * MPSAFE
1165 vop_setacl(struct vop_ops *ops, struct vnode *vp, acl_type_t type,
1166 struct acl *aclp, struct ucred *cred)
1168 struct vop_setacl_args ap;
1169 VFS_MPLOCK_DECLARE;
1170 int error;
1172 ap.a_head.a_desc = &vop_setacl_desc;
1173 ap.a_head.a_ops = ops;
1174 ap.a_vp = vp;
1175 ap.a_type = type;
1176 ap.a_aclp = aclp;
1177 ap.a_cred = cred;
1179 VFS_MPLOCK(vp->v_mount);
1180 DO_OPS(ops, error, &ap, vop_setacl);
1181 VFS_MPUNLOCK();
1183 return(error);
1187 * MPSAFE
1190 vop_aclcheck(struct vop_ops *ops, struct vnode *vp, acl_type_t type,
1191 struct acl *aclp, struct ucred *cred)
1193 struct vop_aclcheck_args ap;
1194 VFS_MPLOCK_DECLARE;
1195 int error;
1197 ap.a_head.a_desc = &vop_aclcheck_desc;
1198 ap.a_head.a_ops = ops;
1199 ap.a_vp = vp;
1200 ap.a_type = type;
1201 ap.a_aclp = aclp;
1202 ap.a_cred = cred;
1204 VFS_MPLOCK(vp->v_mount);
1205 DO_OPS(ops, error, &ap, vop_aclcheck);
1206 VFS_MPUNLOCK();
1208 return(error);
1212 * MPSAFE
1215 vop_getextattr(struct vop_ops *ops, struct vnode *vp, int attrnamespace,
1216 char *attrname, struct uio *uio, struct ucred *cred)
1218 struct vop_getextattr_args ap;
1219 VFS_MPLOCK_DECLARE;
1220 int error;
1222 ap.a_head.a_desc = &vop_getextattr_desc;
1223 ap.a_head.a_ops = ops;
1224 ap.a_vp = vp;
1225 ap.a_attrnamespace = attrnamespace;
1226 ap.a_attrname = attrname;
1227 ap.a_uio = uio;
1228 ap.a_cred = cred;
1230 VFS_MPLOCK(vp->v_mount);
1231 DO_OPS(ops, error, &ap, vop_getextattr);
1232 VFS_MPUNLOCK();
1234 return(error);
1238 * MPSAFE
1241 vop_setextattr(struct vop_ops *ops, struct vnode *vp, int attrnamespace,
1242 char *attrname, struct uio *uio, struct ucred *cred)
1244 struct vop_setextattr_args ap;
1245 VFS_MPLOCK_DECLARE;
1246 int error;
1248 ap.a_head.a_desc = &vop_setextattr_desc;
1249 ap.a_head.a_ops = ops;
1250 ap.a_vp = vp;
1251 ap.a_attrnamespace = attrnamespace;
1252 ap.a_attrname = attrname;
1253 ap.a_uio = uio;
1254 ap.a_cred = cred;
1256 VFS_MPLOCK(vp->v_mount);
1257 DO_OPS(ops, error, &ap, vop_setextattr);
1258 VFS_MPUNLOCK();
1260 return(error);
1264 * MPSAFE
1267 vop_mountctl(struct vop_ops *ops, struct vnode *vp, int op, struct file *fp,
1268 const void *ctl, int ctllen, void *buf, int buflen, int *res)
1270 struct vop_mountctl_args ap;
1271 VFS_MPLOCK_DECLARE;
1272 int error;
1274 ap.a_head.a_desc = &vop_mountctl_desc;
1275 ap.a_head.a_ops = ops;
1276 ap.a_op = op;
1277 ap.a_ctl = ctl;
1278 ap.a_fp = fp;
1279 ap.a_ctllen = ctllen;
1280 ap.a_buf = buf;
1281 ap.a_buflen = buflen;
1282 ap.a_res = res;
1284 VFS_MPLOCK(vp->v_mount);
1285 DO_OPS(ops, error, &ap, vop_mountctl);
1286 VFS_MPUNLOCK();
1288 return(error);
1292 * MPSAFE
1295 vop_markatime(struct vop_ops *ops, struct vnode *vp, struct ucred *cred)
1297 struct vop_markatime_args ap;
1298 VFS_MPLOCK_DECLARE;
1299 int error;
1301 ap.a_head.a_desc = &vop_markatime_desc;
1302 ap.a_head.a_ops = ops;
1303 ap.a_vp = vp;
1304 ap.a_cred = cred;
1306 VFS_MPLOCK(vp->v_mount);
1307 DO_OPS(ops, error, &ap, vop_markatime);
1308 VFS_MPUNLOCK();
1310 return(error);
1314 * NEW API FUNCTIONS
1316 * nresolve takes a locked ncp, a referenced but unlocked dvp, and a cred,
1317 * and resolves the ncp into a positive or negative hit.
1319 * The namecache is automatically adjusted by this function. The ncp
1320 * is left locked on return.
1322 * MPSAFE
1325 vop_nresolve(struct vop_ops *ops, struct nchandle *nch,
1326 struct vnode *dvp, struct ucred *cred)
1328 struct vop_nresolve_args ap;
1329 VFS_MPLOCK_DECLARE;
1330 int error;
1332 ap.a_head.a_desc = &vop_nresolve_desc;
1333 ap.a_head.a_ops = ops;
1334 ap.a_nch = nch;
1335 ap.a_dvp = dvp;
1336 ap.a_cred = cred;
1338 VFS_MPLOCK(dvp->v_mount);
1339 DO_OPS(ops, error, &ap, vop_nresolve);
1340 VFS_MPUNLOCK();
1342 return(error);
1346 * nlookupdotdot takes an unlocked directory, referenced dvp, and looks
1347 * up "..", returning a locked parent directory in *vpp. If an error
1348 * occurs *vpp will be NULL.
1350 * MPSAFE
1353 vop_nlookupdotdot(struct vop_ops *ops, struct vnode *dvp,
1354 struct vnode **vpp, struct ucred *cred, char **fakename)
1356 struct vop_nlookupdotdot_args ap;
1357 VFS_MPLOCK_DECLARE;
1358 int error;
1360 ap.a_head.a_desc = &vop_nlookupdotdot_desc;
1361 ap.a_head.a_ops = ops;
1362 ap.a_dvp = dvp;
1363 ap.a_vpp = vpp;
1364 ap.a_cred = cred;
1365 ap.a_fakename = fakename;
1367 VFS_MPLOCK(dvp->v_mount);
1368 DO_OPS(ops, error, &ap, vop_nlookupdotdot);
1369 VFS_MPUNLOCK();
1371 return(error);
1375 * ncreate takes a locked, resolved ncp that typically represents a negative
1376 * cache hit and creates the file or node specified by the ncp, cred, and
1377 * vattr. If no error occurs a locked vnode is returned in *vpp.
1379 * The dvp passed in is referenced but unlocked.
1381 * The namecache is automatically adjusted by this function. The ncp
1382 * is left locked on return.
1384 * MPSAFE
1387 vop_ncreate(struct vop_ops *ops, struct nchandle *nch, struct vnode *dvp,
1388 struct vnode **vpp, struct ucred *cred, struct vattr *vap)
1390 struct vop_ncreate_args ap;
1391 VFS_MPLOCK_DECLARE;
1392 int error;
1394 ap.a_head.a_desc = &vop_ncreate_desc;
1395 ap.a_head.a_ops = ops;
1396 ap.a_nch = nch;
1397 ap.a_dvp = dvp;
1398 ap.a_vpp = vpp;
1399 ap.a_cred = cred;
1400 ap.a_vap = vap;
1402 VFS_MPLOCK(dvp->v_mount);
1403 DO_OPS(ops, error, &ap, vop_ncreate);
1404 VFS_MPUNLOCK();
1406 return(error);
1410 * nmkdir takes a locked, resolved ncp that typically represents a negative
1411 * cache hit and creates the directory specified by the ncp, cred, and
1412 * vattr. If no error occurs a locked vnode is returned in *vpp.
1414 * The dvp passed in is referenced but unlocked.
1416 * The namecache is automatically adjusted by this function. The ncp
1417 * is left locked on return.
1419 * MPSAFE
1422 vop_nmkdir(struct vop_ops *ops, struct nchandle *nch, struct vnode *dvp,
1423 struct vnode **vpp, struct ucred *cred, struct vattr *vap)
1425 struct vop_nmkdir_args ap;
1426 VFS_MPLOCK_DECLARE;
1427 int error;
1429 ap.a_head.a_desc = &vop_nmkdir_desc;
1430 ap.a_head.a_ops = ops;
1431 ap.a_nch = nch;
1432 ap.a_dvp = dvp;
1433 ap.a_vpp = vpp;
1434 ap.a_cred = cred;
1435 ap.a_vap = vap;
1437 VFS_MPLOCK(dvp->v_mount);
1438 DO_OPS(ops, error, &ap, vop_nmkdir);
1439 VFS_MPUNLOCK();
1441 return(error);
1445 * nmknod takes a locked, resolved ncp that typically represents a negative
1446 * cache hit and creates the node specified by the ncp, cred, and
1447 * vattr. If no error occurs a locked vnode is returned in *vpp.
1449 * The dvp passed in is referenced but unlocked.
1451 * The namecache is automatically adjusted by this function. The ncp
1452 * is left locked on return.
1454 * MPSAFE
1457 vop_nmknod(struct vop_ops *ops, struct nchandle *nch, struct vnode *dvp,
1458 struct vnode **vpp, struct ucred *cred, struct vattr *vap)
1460 struct vop_nmknod_args ap;
1461 VFS_MPLOCK_DECLARE;
1462 int error;
1464 ap.a_head.a_desc = &vop_nmknod_desc;
1465 ap.a_head.a_ops = ops;
1466 ap.a_nch = nch;
1467 ap.a_dvp = dvp;
1468 ap.a_vpp = vpp;
1469 ap.a_cred = cred;
1470 ap.a_vap = vap;
1472 VFS_MPLOCK(dvp->v_mount);
1473 DO_OPS(ops, error, &ap, vop_nmknod);
1474 VFS_MPUNLOCK();
1476 return(error);
1480 * nlink takes a locked, resolved ncp that typically represents a negative
1481 * cache hit and creates the node specified by the ncp, cred, and
1482 * existing vnode. The passed vp must be locked and will remain locked
1483 * on return, as does the ncp, whether an error occurs or not.
1485 * The dvp passed in is referenced but unlocked.
1487 * The namecache is automatically adjusted by this function. The ncp
1488 * is left locked on return.
1490 * MPSAFE
1493 vop_nlink(struct vop_ops *ops, struct nchandle *nch, struct vnode *dvp,
1494 struct vnode *vp, struct ucred *cred)
1496 struct vop_nlink_args ap;
1497 VFS_MPLOCK_DECLARE;
1498 int error;
1500 ap.a_head.a_desc = &vop_nlink_desc;
1501 ap.a_head.a_ops = ops;
1502 ap.a_nch = nch;
1503 ap.a_dvp = dvp;
1504 ap.a_vp = vp;
1505 ap.a_cred = cred;
1507 VFS_MPLOCK(dvp->v_mount);
1508 DO_OPS(ops, error, &ap, vop_nlink);
1509 VFS_MPUNLOCK();
1511 return(error);
1515 * nsymlink takes a locked, resolved ncp that typically represents a negative
1516 * cache hit and creates a symbolic link based on cred, vap, and target (the
1517 * contents of the link). If no error occurs a locked vnode is returned in
1518 * *vpp.
1520 * The dvp passed in is referenced but unlocked.
1522 * The namecache is automatically adjusted by this function. The ncp
1523 * is left locked on return.
1525 * MPSAFE
1528 vop_nsymlink(struct vop_ops *ops, struct nchandle *nch, struct vnode *dvp,
1529 struct vnode **vpp, struct ucred *cred,
1530 struct vattr *vap, char *target)
1532 struct vop_nsymlink_args ap;
1533 VFS_MPLOCK_DECLARE;
1534 int error;
1536 ap.a_head.a_desc = &vop_nsymlink_desc;
1537 ap.a_head.a_ops = ops;
1538 ap.a_nch = nch;
1539 ap.a_dvp = dvp;
1540 ap.a_vpp = vpp;
1541 ap.a_cred = cred;
1542 ap.a_vap = vap;
1543 ap.a_target = target;
1545 VFS_MPLOCK(dvp->v_mount);
1546 DO_OPS(ops, error, &ap, vop_nsymlink);
1547 VFS_MPUNLOCK();
1549 return(error);
1553 * nwhiteout takes a locked, resolved ncp that can represent a positive or
1554 * negative hit and executes the whiteout function specified in flags.
1556 * The dvp passed in is referenced but unlocked.
1558 * The namecache is automatically adjusted by this function. The ncp
1559 * is left locked on return.
1561 * MPSAFE
1564 vop_nwhiteout(struct vop_ops *ops, struct nchandle *nch, struct vnode *dvp,
1565 struct ucred *cred, int flags)
1567 struct vop_nwhiteout_args ap;
1568 VFS_MPLOCK_DECLARE;
1569 int error;
1571 ap.a_head.a_desc = &vop_nwhiteout_desc;
1572 ap.a_head.a_ops = ops;
1573 ap.a_nch = nch;
1574 ap.a_dvp = dvp;
1575 ap.a_cred = cred;
1576 ap.a_flags = flags;
1578 VFS_MPLOCK(dvp->v_mount);
1579 DO_OPS(ops, error, &ap, vop_nwhiteout);
1580 VFS_MPUNLOCK();
1582 return(error);
1586 * nremove takes a locked, resolved ncp that generally represents a
1587 * positive hit and removes the file.
1589 * The dvp passed in is referenced but unlocked.
1591 * The namecache is automatically adjusted by this function. The ncp
1592 * is left locked on return.
1594 * MPSAFE
1597 vop_nremove(struct vop_ops *ops, struct nchandle *nch, struct vnode *dvp,
1598 struct ucred *cred)
1600 struct vop_nremove_args ap;
1601 VFS_MPLOCK_DECLARE;
1602 int error;
1603 struct vattr va;
1605 ap.a_head.a_desc = &vop_nremove_desc;
1606 ap.a_head.a_ops = ops;
1607 ap.a_nch = nch;
1608 ap.a_dvp = dvp;
1609 ap.a_cred = cred;
1611 if ((error = VOP_GETATTR(nch->ncp->nc_vp, &va)) != 0)
1612 return (error);
1614 VFS_MPLOCK(dvp->v_mount);
1615 DO_OPS(ops, error, &ap, vop_nremove);
1616 /* Only update space counters if this is the last hard link */
1617 if ((error == 0) && (va.va_nlink == 1)) {
1618 VFS_ACCOUNT(nch->mount, va.va_uid, va.va_gid, -va.va_size);
1620 VFS_MPUNLOCK();
1622 return(error);
1626 * nrmdir takes a locked, resolved ncp that generally represents a
1627 * directory and removes the directory.
1629 * The dvp passed in is referenced but unlocked.
1631 * The namecache is automatically adjusted by this function. The ncp
1632 * is left locked on return.
1634 * MPSAFE
1637 vop_nrmdir(struct vop_ops *ops, struct nchandle *nch, struct vnode *dvp,
1638 struct ucred *cred)
1640 struct vop_nrmdir_args ap;
1641 VFS_MPLOCK_DECLARE;
1642 int error;
1644 ap.a_head.a_desc = &vop_nrmdir_desc;
1645 ap.a_head.a_ops = ops;
1646 ap.a_nch = nch;
1647 ap.a_dvp = dvp;
1648 ap.a_cred = cred;
1650 VFS_MPLOCK(dvp->v_mount);
1651 DO_OPS(ops, error, &ap, vop_nrmdir);
1652 VFS_MPUNLOCK();
1654 return(error);
1658 * nrename takes TWO locked, resolved ncp's and the cred of the caller
1659 * and renames the source ncp to the target ncp. The target ncp may
1660 * represent a positive or negative hit.
1662 * The fdvp and tdvp passed in are referenced but unlocked.
1664 * The namecache is automatically adjusted by this function. The ncp
1665 * is left locked on return. The source ncp is typically changed to
1666 * a negative cache hit and the target ncp typically takes on the
1667 * source ncp's underlying file.
1669 * MPSAFE
1672 vop_nrename(struct vop_ops *ops,
1673 struct nchandle *fnch, struct nchandle *tnch,
1674 struct vnode *fdvp, struct vnode *tdvp,
1675 struct ucred *cred)
1677 struct vop_nrename_args ap;
1678 VFS_MPLOCK_DECLARE;
1679 int error;
1681 ap.a_head.a_desc = &vop_nrename_desc;
1682 ap.a_head.a_ops = ops;
1683 ap.a_fnch = fnch;
1684 ap.a_tnch = tnch;
1685 ap.a_fdvp = fdvp;
1686 ap.a_tdvp = tdvp;
1687 ap.a_cred = cred;
1689 VFS_MPLOCK(fdvp->v_mount);
1690 DO_OPS(ops, error, &ap, vop_nrename);
1691 VFS_MPUNLOCK();
1693 return(error);
1696 /************************************************************************
1697 * PRIMARY VNODE OPERATIONS FORWARDING CALLS *
1698 ************************************************************************
1700 * These procedures are called from VFSs such as nullfs
1701 * when they wish to forward an operation on one VFS to another. The
1702 * argument structure/message is modified and then directly passed to the
1703 * appropriate routine. This routines may also be called by initiators
1704 * who have an argument structure in hand rather then discreet arguments.
1706 * MPSAFE - Caller expected to already hold the appropriate vfs lock.
1709 vop_vnoperate_ap(struct vop_generic_args *ap)
1711 struct vop_ops *ops;
1712 int error;
1714 ops = ap->a_ops;
1715 error = VOCALL(ops, ap);
1717 return (error);
1721 * This routine is called by the cache coherency layer to execute the actual
1722 * VFS operation. If a journaling layer is present we call though it, else
1723 * we call the native VOP functions.
1726 vop_cache_operate_ap(struct vop_generic_args *ap)
1728 struct vop_ops *ops;
1729 int error;
1731 ops = ap->a_ops;
1732 if (ops->head.vv_mount->mnt_vn_journal_ops)
1733 error = VOCALL(ops->head.vv_mount->mnt_vn_journal_ops, ap);
1734 else
1735 error = VOCALL(ops->head.vv_mount->mnt_vn_norm_ops, ap);
1736 return (error);
1741 * This routine is called by the journaling layer to execute the actual
1742 * VFS operation.
1745 vop_journal_operate_ap(struct vop_generic_args *ap)
1747 struct vop_ops *ops;
1748 int error;
1750 ops = ap->a_ops;
1751 error = VOCALL(ops->head.vv_mount->mnt_vn_norm_ops, ap);
1753 return (error);
1757 vop_open_ap(struct vop_open_args *ap)
1759 int error;
1761 DO_OPS(ap->a_head.a_ops, error, ap, vop_open);
1762 return(error);
1766 vop_close_ap(struct vop_close_args *ap)
1768 int error;
1770 DO_OPS(ap->a_head.a_ops, error, ap, vop_close);
1771 return(error);
1775 vop_access_ap(struct vop_access_args *ap)
1777 int error;
1779 DO_OPS(ap->a_head.a_ops, error, ap, vop_access);
1780 return(error);
1784 vop_getattr_ap(struct vop_getattr_args *ap)
1786 int error;
1788 DO_OPS(ap->a_head.a_ops, error, ap, vop_getattr);
1789 return(error);
1793 vop_getattr_quick_ap(struct vop_getattr_args *ap)
1795 int error;
1797 DO_OPS(ap->a_head.a_ops, error, ap, vop_getattr_quick);
1798 return(error);
1802 vop_setattr_ap(struct vop_setattr_args *ap)
1804 int error;
1806 DO_OPS(ap->a_head.a_ops, error, ap, vop_setattr);
1807 return(error);
1811 vop_read_ap(struct vop_read_args *ap)
1813 int error;
1815 DO_OPS(ap->a_head.a_ops, error, ap, vop_read);
1816 return(error);
1820 vop_write_ap(struct vop_write_args *ap)
1822 int error;
1824 DO_OPS(ap->a_head.a_ops, error, ap, vop_write);
1825 return(error);
1829 vop_ioctl_ap(struct vop_ioctl_args *ap)
1831 int error;
1833 DO_OPS(ap->a_head.a_ops, error, ap, vop_ioctl);
1834 return(error);
1838 vop_poll_ap(struct vop_poll_args *ap)
1840 int error;
1842 DO_OPS(ap->a_head.a_ops, error, ap, vop_poll);
1843 return(error);
1847 vop_kqfilter_ap(struct vop_kqfilter_args *ap)
1849 int error;
1851 DO_OPS(ap->a_head.a_ops, error, ap, vop_kqfilter);
1852 return(error);
1856 vop_mmap_ap(struct vop_mmap_args *ap)
1858 int error;
1860 DO_OPS(ap->a_head.a_ops, error, ap, vop_mmap);
1861 return(error);
1865 vop_fsync_ap(struct vop_fsync_args *ap)
1867 int error;
1869 DO_OPS(ap->a_head.a_ops, error, ap, vop_fsync);
1870 return(error);
1874 vop_readdir_ap(struct vop_readdir_args *ap)
1876 int error;
1878 DO_OPS(ap->a_head.a_ops, error, ap, vop_readdir);
1879 return(error);
1883 vop_readlink_ap(struct vop_readlink_args *ap)
1885 int error;
1887 DO_OPS(ap->a_head.a_ops, error, ap, vop_readlink);
1888 return(error);
1892 vop_inactive_ap(struct vop_inactive_args *ap)
1894 int error;
1896 DO_OPS(ap->a_head.a_ops, error, ap, vop_inactive);
1897 return(error);
1901 vop_reclaim_ap(struct vop_reclaim_args *ap)
1903 int error;
1905 DO_OPS(ap->a_head.a_ops, error, ap, vop_reclaim);
1906 return(error);
1910 vop_bmap_ap(struct vop_bmap_args *ap)
1912 int error;
1914 DO_OPS(ap->a_head.a_ops, error, ap, vop_bmap);
1915 return(error);
1919 vop_strategy_ap(struct vop_strategy_args *ap)
1921 int error;
1923 DO_OPS(ap->a_head.a_ops, error, ap, vop_strategy);
1924 return(error);
1928 vop_print_ap(struct vop_print_args *ap)
1930 int error;
1932 DO_OPS(ap->a_head.a_ops, error, ap, vop_print);
1933 return(error);
1937 vop_pathconf_ap(struct vop_pathconf_args *ap)
1939 int error;
1941 DO_OPS(ap->a_head.a_ops, error, ap, vop_pathconf);
1942 return(error);
1946 vop_advlock_ap(struct vop_advlock_args *ap)
1948 int error;
1950 DO_OPS(ap->a_head.a_ops, error, ap, vop_advlock);
1951 return(error);
1955 vop_balloc_ap(struct vop_balloc_args *ap)
1957 int error;
1959 DO_OPS(ap->a_head.a_ops, error, ap, vop_balloc);
1960 return(error);
1964 vop_reallocblks_ap(struct vop_reallocblks_args *ap)
1966 int error;
1968 DO_OPS(ap->a_head.a_ops, error, ap, vop_reallocblks);
1969 return(error);
1973 vop_getpages_ap(struct vop_getpages_args *ap)
1975 int error;
1977 DO_OPS(ap->a_head.a_ops, error, ap, vop_getpages);
1978 return(error);
1982 vop_putpages_ap(struct vop_putpages_args *ap)
1984 int error;
1986 DO_OPS(ap->a_head.a_ops, error, ap, vop_putpages);
1987 return(error);
1991 vop_freeblks_ap(struct vop_freeblks_args *ap)
1993 int error;
1995 DO_OPS(ap->a_head.a_ops, error, ap, vop_freeblks);
1996 return(error);
2000 vop_getacl_ap(struct vop_getacl_args *ap)
2002 int error;
2004 DO_OPS(ap->a_head.a_ops, error, ap, vop_getacl);
2005 return(error);
2009 vop_setacl_ap(struct vop_setacl_args *ap)
2011 int error;
2013 DO_OPS(ap->a_head.a_ops, error, ap, vop_setacl);
2014 return(error);
2018 vop_aclcheck_ap(struct vop_aclcheck_args *ap)
2020 int error;
2022 DO_OPS(ap->a_head.a_ops, error, ap, vop_aclcheck);
2023 return(error);
2027 vop_getextattr_ap(struct vop_getextattr_args *ap)
2029 int error;
2031 DO_OPS(ap->a_head.a_ops, error, ap, vop_getextattr);
2032 return(error);
2036 vop_setextattr_ap(struct vop_setextattr_args *ap)
2038 int error;
2040 DO_OPS(ap->a_head.a_ops, error, ap, vop_setextattr);
2041 return(error);
2045 vop_mountctl_ap(struct vop_mountctl_args *ap)
2047 int error;
2049 DO_OPS(ap->a_head.a_ops, error, ap, vop_mountctl);
2050 return(error);
2054 vop_markatime_ap(struct vop_markatime_args *ap)
2056 int error;
2058 DO_OPS(ap->a_head.a_ops, error, ap, vop_markatime);
2059 return(error);
2063 vop_nresolve_ap(struct vop_nresolve_args *ap)
2065 int error;
2067 DO_OPS(ap->a_head.a_ops, error, ap, vop_nresolve);
2068 return(error);
2072 vop_nlookupdotdot_ap(struct vop_nlookupdotdot_args *ap)
2074 int error;
2076 DO_OPS(ap->a_head.a_ops, error, ap, vop_nlookupdotdot);
2077 return(error);
2081 vop_ncreate_ap(struct vop_ncreate_args *ap)
2083 int error;
2085 DO_OPS(ap->a_head.a_ops, error, ap, vop_ncreate);
2086 return(error);
2090 vop_nmkdir_ap(struct vop_nmkdir_args *ap)
2092 int error;
2094 DO_OPS(ap->a_head.a_ops, error, ap, vop_nmkdir);
2095 return(error);
2099 vop_nmknod_ap(struct vop_nmknod_args *ap)
2101 int error;
2103 DO_OPS(ap->a_head.a_ops, error, ap, vop_nmknod);
2104 return(error);
2108 vop_nlink_ap(struct vop_nlink_args *ap)
2110 int error;
2112 DO_OPS(ap->a_head.a_ops, error, ap, vop_nlink);
2113 return(error);
2117 vop_nsymlink_ap(struct vop_nsymlink_args *ap)
2119 int error;
2121 DO_OPS(ap->a_head.a_ops, error, ap, vop_nsymlink);
2122 return(error);
2126 vop_nwhiteout_ap(struct vop_nwhiteout_args *ap)
2128 int error;
2130 DO_OPS(ap->a_head.a_ops, error, ap, vop_nwhiteout);
2131 return(error);
2135 vop_nremove_ap(struct vop_nremove_args *ap)
2137 int error;
2139 DO_OPS(ap->a_head.a_ops, error, ap, vop_nremove);
2140 return(error);
2144 vop_nrmdir_ap(struct vop_nrmdir_args *ap)
2146 int error;
2148 DO_OPS(ap->a_head.a_ops, error, ap, vop_nrmdir);
2149 return(error);
2153 vop_nrename_ap(struct vop_nrename_args *ap)
2155 int error;
2157 DO_OPS(ap->a_head.a_ops, error, ap, vop_nrename);
2158 return(error);