kernel - lwkt_token revamp
[dragonfly.git] / sys / kern / vfs_vopops.c
... / ...
CommitLineData
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:
10 *
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.
20 *
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.
33 */
34/*
35 * Implement vnode ops wrappers. All vnode ops are wrapped through
36 * these functions.
37 *
38 * These wrappers are responsible for hanlding all MPSAFE issues related
39 * to a vnode operation.
40 */
41
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
67#include <machine/limits.h>
68
69#include <vm/vm.h>
70#include <vm/vm_object.h>
71#include <vm/vm_extern.h>
72#include <vm/vm_kern.h>
73#include <vm/pmap.h>
74#include <vm/vm_map.h>
75#include <vm/vm_page.h>
76#include <vm/vm_pager.h>
77#include <vm/vnode_pager.h>
78#include <vm/vm_zone.h>
79
80#include <sys/buf2.h>
81#include <sys/thread2.h>
82#include <sys/mplock2.h>
83
84#define VDESCNAME(name) __CONCAT(__CONCAT(vop_,name),_desc)
85
86#define VNODEOP_DESC_INIT(name) \
87 struct syslink_desc VDESCNAME(name) = { \
88 __offsetof(struct vop_ops, __CONCAT(vop_, name)), \
89 #name }
90
91VNODEOP_DESC_INIT(default);
92VNODEOP_DESC_INIT(old_lookup);
93VNODEOP_DESC_INIT(old_create);
94VNODEOP_DESC_INIT(old_whiteout);
95VNODEOP_DESC_INIT(old_mknod);
96VNODEOP_DESC_INIT(open);
97VNODEOP_DESC_INIT(close);
98VNODEOP_DESC_INIT(access);
99VNODEOP_DESC_INIT(getattr);
100VNODEOP_DESC_INIT(setattr);
101VNODEOP_DESC_INIT(read);
102VNODEOP_DESC_INIT(write);
103VNODEOP_DESC_INIT(ioctl);
104VNODEOP_DESC_INIT(poll);
105VNODEOP_DESC_INIT(kqfilter);
106VNODEOP_DESC_INIT(mmap);
107VNODEOP_DESC_INIT(fsync);
108VNODEOP_DESC_INIT(old_remove);
109VNODEOP_DESC_INIT(old_link);
110VNODEOP_DESC_INIT(old_rename);
111
112VNODEOP_DESC_INIT(old_mkdir);
113VNODEOP_DESC_INIT(old_rmdir);
114VNODEOP_DESC_INIT(old_symlink);
115VNODEOP_DESC_INIT(readdir);
116VNODEOP_DESC_INIT(readlink);
117VNODEOP_DESC_INIT(inactive);
118VNODEOP_DESC_INIT(reclaim);
119VNODEOP_DESC_INIT(bmap);
120VNODEOP_DESC_INIT(strategy);
121VNODEOP_DESC_INIT(print);
122VNODEOP_DESC_INIT(pathconf);
123VNODEOP_DESC_INIT(advlock);
124VNODEOP_DESC_INIT(balloc);
125VNODEOP_DESC_INIT(reallocblks);
126VNODEOP_DESC_INIT(getpages);
127VNODEOP_DESC_INIT(putpages);
128VNODEOP_DESC_INIT(freeblks);
129VNODEOP_DESC_INIT(getacl);
130VNODEOP_DESC_INIT(setacl);
131VNODEOP_DESC_INIT(aclcheck);
132VNODEOP_DESC_INIT(getextattr);
133VNODEOP_DESC_INIT(setextattr);
134VNODEOP_DESC_INIT(mountctl);
135VNODEOP_DESC_INIT(markatime);
136
137VNODEOP_DESC_INIT(nresolve);
138VNODEOP_DESC_INIT(nlookupdotdot);
139VNODEOP_DESC_INIT(ncreate);
140VNODEOP_DESC_INIT(nmkdir);
141VNODEOP_DESC_INIT(nmknod);
142VNODEOP_DESC_INIT(nlink);
143VNODEOP_DESC_INIT(nsymlink);
144VNODEOP_DESC_INIT(nwhiteout);
145VNODEOP_DESC_INIT(nremove);
146VNODEOP_DESC_INIT(nrmdir);
147VNODEOP_DESC_INIT(nrename);
148
149#define DO_OPS(ops, error, ap, vop_field) \
150 error = ops->vop_field(ap);
151
152/************************************************************************
153 * PRIMARY HIGH LEVEL VNODE OPERATIONS CALLS *
154 ************************************************************************
155 *
156 * These procedures are called directly from the kernel and/or fileops
157 * code to perform file/device operations on the system.
158 *
159 * NOTE: The old namespace api functions such as vop_rename() are no
160 * longer available for general use and have been renamed to
161 * vop_old_*(). Only the code in vfs_default.c is allowed to call
162 * those ops.
163 *
164 * NOTE: The VFS_MPLOCK*() macros handle mounts which do not set
165 * MNTK_MPSAFE or MNTK_xx_MPSAFE.
166 *
167 * MPSAFE
168 */
169
170int
171vop_old_lookup(struct vop_ops *ops, struct vnode *dvp,
172 struct vnode **vpp, struct componentname *cnp)
173{
174 struct vop_old_lookup_args ap;
175 VFS_MPLOCK_DECLARE;
176 int error;
177
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_MPLOCK1(dvp->v_mount);
184 DO_OPS(ops, error, &ap, vop_old_lookup);
185 VFS_MPUNLOCK(dvp->v_mount);
186 return(error);
187}
188
189/*
190 * MPSAFE
191 */
192int
193vop_old_create(struct vop_ops *ops, struct vnode *dvp,
194 struct vnode **vpp, struct componentname *cnp, struct vattr *vap)
195{
196 struct vop_old_create_args ap;
197 VFS_MPLOCK_DECLARE;
198 int error;
199
200 ap.a_head.a_desc = &vop_old_create_desc;
201 ap.a_head.a_ops = ops;
202 ap.a_dvp = dvp;
203 ap.a_vpp = vpp;
204 ap.a_cnp = cnp;
205 ap.a_vap = vap;
206
207 VFS_MPLOCK1(dvp->v_mount);
208 DO_OPS(ops, error, &ap, vop_old_create);
209 VFS_MPUNLOCK(dvp->v_mount);
210 return(error);
211}
212
213/*
214 * MPSAFE
215 */
216int
217vop_old_whiteout(struct vop_ops *ops, struct vnode *dvp,
218 struct componentname *cnp, int flags)
219{
220 struct vop_old_whiteout_args ap;
221 VFS_MPLOCK_DECLARE;
222 int error;
223
224 ap.a_head.a_desc = &vop_old_whiteout_desc;
225 ap.a_head.a_ops = ops;
226 ap.a_dvp = dvp;
227 ap.a_cnp = cnp;
228 ap.a_flags = flags;
229
230 VFS_MPLOCK1(dvp->v_mount);
231 DO_OPS(ops, error, &ap, vop_old_whiteout);
232 VFS_MPUNLOCK(dvp->v_mount);
233 return(error);
234}
235
236/*
237 * MPSAFE
238 */
239int
240vop_old_mknod(struct vop_ops *ops, struct vnode *dvp,
241 struct vnode **vpp, struct componentname *cnp, struct vattr *vap)
242{
243 struct vop_old_mknod_args ap;
244 VFS_MPLOCK_DECLARE;
245 int error;
246
247 ap.a_head.a_desc = &vop_old_mknod_desc;
248 ap.a_head.a_ops = ops;
249 ap.a_dvp = dvp;
250 ap.a_vpp = vpp;
251 ap.a_cnp = cnp;
252 ap.a_vap = vap;
253
254 VFS_MPLOCK1(dvp->v_mount);
255 DO_OPS(ops, error, &ap, vop_old_mknod);
256 VFS_MPUNLOCK(dvp->v_mount);
257 return(error);
258}
259
260/*
261 * NOTE: VAGE is always cleared when calling VOP_OPEN().
262 */
263int
264vop_open(struct vop_ops *ops, struct vnode *vp, int mode, struct ucred *cred,
265 struct file *fp)
266{
267 struct vop_open_args ap;
268 VFS_MPLOCK_DECLARE;
269 int error;
270
271 /*
272 * Decrement 3-2-1-0. Does not decrement beyond 0
273 */
274 if (vp->v_flag & VAGE0) {
275 vclrflags(vp, VAGE0);
276 } else if (vp->v_flag & VAGE1) {
277 vclrflags(vp, VAGE1);
278 vsetflags(vp, VAGE0);
279 }
280
281 ap.a_head.a_desc = &vop_open_desc;
282 ap.a_head.a_ops = ops;
283 ap.a_vp = vp;
284 ap.a_fp = fp;
285 ap.a_mode = mode;
286 ap.a_cred = cred;
287
288 VFS_MPLOCK1(vp->v_mount);
289 DO_OPS(ops, error, &ap, vop_open);
290 VFS_MPUNLOCK(vp->v_mount);
291 return(error);
292}
293
294/*
295 * MPSAFE
296 */
297int
298vop_close(struct vop_ops *ops, struct vnode *vp, int fflag)
299{
300 struct vop_close_args ap;
301 VFS_MPLOCK_DECLARE;
302 int error;
303
304 ap.a_head.a_desc = &vop_close_desc;
305 ap.a_head.a_ops = ops;
306 ap.a_vp = vp;
307 ap.a_fflag = fflag;
308
309 VFS_MPLOCK1(vp->v_mount);
310 DO_OPS(ops, error, &ap, vop_close);
311 VFS_MPUNLOCK(vp->v_mount);
312 return(error);
313}
314
315/*
316 * MPSAFE
317 */
318int
319vop_access(struct vop_ops *ops, struct vnode *vp, int mode, int flags,
320 struct ucred *cred)
321{
322 struct vop_access_args ap;
323 VFS_MPLOCK_DECLARE;
324 int error;
325
326 ap.a_head.a_desc = &vop_access_desc;
327 ap.a_head.a_ops = ops;
328 ap.a_vp = vp;
329 ap.a_mode = mode;
330 ap.a_flags = flags;
331 ap.a_cred = cred;
332
333 VFS_MPLOCK1(vp->v_mount);
334 DO_OPS(ops, error, &ap, vop_access);
335 VFS_MPUNLOCK(vp->v_mount);
336 return(error);
337}
338
339/*
340 * MPSAFE
341 */
342int
343vop_getattr(struct vop_ops *ops, struct vnode *vp, struct vattr *vap)
344{
345 struct vop_getattr_args ap;
346 VFS_MPLOCK_DECLARE;
347 int error;
348
349 ap.a_head.a_desc = &vop_getattr_desc;
350 ap.a_head.a_ops = ops;
351 ap.a_vp = vp;
352 ap.a_vap = vap;
353
354 VFS_MPLOCK_FLAG(vp->v_mount, MNTK_GA_MPSAFE);
355 DO_OPS(ops, error, &ap, vop_getattr);
356 VFS_MPUNLOCK(vp->v_mount);
357
358 return(error);
359}
360
361/*
362 * MPSAFE
363 */
364int
365vop_setattr(struct vop_ops *ops, struct vnode *vp, struct vattr *vap,
366 struct ucred *cred)
367{
368 struct vop_setattr_args ap;
369 VFS_MPLOCK_DECLARE;
370 int error;
371
372 ap.a_head.a_desc = &vop_setattr_desc;
373 ap.a_head.a_ops = ops;
374 ap.a_vp = vp;
375 ap.a_vap = vap;
376 ap.a_cred = cred;
377
378 VFS_MPLOCK1(vp->v_mount);
379 DO_OPS(ops, error, &ap, vop_setattr);
380 VFS_MPUNLOCK(vp->v_mount);
381 return(error);
382}
383
384/*
385 * MPSAFE
386 */
387int
388vop_read(struct vop_ops *ops, struct vnode *vp, struct uio *uio, int ioflag,
389 struct ucred *cred)
390{
391 struct vop_read_args ap;
392 VFS_MPLOCK_DECLARE;
393 int error;
394
395 ap.a_head.a_desc = &vop_read_desc;
396 ap.a_head.a_ops = ops;
397 ap.a_vp = vp;
398 ap.a_uio = uio;
399 ap.a_ioflag = ioflag;
400 ap.a_cred = cred;
401
402 VFS_MPLOCK_FLAG(vp->v_mount, MNTK_RD_MPSAFE);
403 DO_OPS(ops, error, &ap, vop_read);
404 VFS_MPUNLOCK(vp->v_mount);
405 return(error);
406}
407
408/*
409 * MPSAFE
410 */
411int
412vop_write(struct vop_ops *ops, struct vnode *vp, struct uio *uio, int ioflag,
413 struct ucred *cred)
414{
415 struct vop_write_args ap;
416 VFS_MPLOCK_DECLARE;
417 int error;
418
419 ap.a_head.a_desc = &vop_write_desc;
420 ap.a_head.a_ops = ops;
421 ap.a_vp = vp;
422 ap.a_uio = uio;
423 ap.a_ioflag = ioflag;
424 ap.a_cred = cred;
425
426 VFS_MPLOCK_FLAG(vp->v_mount, MNTK_WR_MPSAFE);
427 DO_OPS(ops, error, &ap, vop_write);
428 VFS_MPUNLOCK(vp->v_mount);
429 return(error);
430}
431
432/*
433 * MPSAFE
434 */
435int
436vop_ioctl(struct vop_ops *ops, struct vnode *vp, u_long command, caddr_t data,
437 int fflag, struct ucred *cred, struct sysmsg *msg)
438{
439 struct vop_ioctl_args ap;
440 VFS_MPLOCK_DECLARE;
441 int error;
442
443 ap.a_head.a_desc = &vop_ioctl_desc;
444 ap.a_head.a_ops = ops;
445 ap.a_vp = vp;
446 ap.a_command = command;
447 ap.a_data = data;
448 ap.a_fflag = fflag;
449 ap.a_cred = cred;
450 ap.a_sysmsg = msg;
451
452 VFS_MPLOCK1(vp->v_mount);
453 DO_OPS(ops, error, &ap, vop_ioctl);
454 VFS_MPUNLOCK(vp->v_mount);
455 return(error);
456}
457
458/*
459 * MPSAFE
460 */
461int
462vop_poll(struct vop_ops *ops, struct vnode *vp, int events, struct ucred *cred)
463{
464 struct vop_poll_args ap;
465 VFS_MPLOCK_DECLARE;
466 int error;
467
468 ap.a_head.a_desc = &vop_poll_desc;
469 ap.a_head.a_ops = ops;
470 ap.a_vp = vp;
471 ap.a_events = events;
472 ap.a_cred = cred;
473
474 VFS_MPLOCK1(vp->v_mount);
475 DO_OPS(ops, error, &ap, vop_poll);
476 VFS_MPUNLOCK(vp->v_mount);
477 return(error);
478}
479
480/*
481 * MPSAFE
482 */
483int
484vop_kqfilter(struct vop_ops *ops, struct vnode *vp, struct knote *kn)
485{
486 struct vop_kqfilter_args ap;
487 VFS_MPLOCK_DECLARE;
488 int error;
489
490 ap.a_head.a_desc = &vop_kqfilter_desc;
491 ap.a_head.a_ops = ops;
492 ap.a_vp = vp;
493 ap.a_kn = kn;
494
495 VFS_MPLOCK1(vp->v_mount);
496 DO_OPS(ops, error, &ap, vop_kqfilter);
497 VFS_MPUNLOCK(vp->v_mount);
498 return(error);
499}
500
501/*
502 * MPSAFE
503 */
504int
505vop_mmap(struct vop_ops *ops, struct vnode *vp, int fflags, struct ucred *cred)
506{
507 struct vop_mmap_args ap;
508 VFS_MPLOCK_DECLARE;
509 int error;
510
511 ap.a_head.a_desc = &vop_mmap_desc;
512 ap.a_head.a_ops = ops;
513 ap.a_vp = vp;
514 ap.a_fflags = fflags;
515 ap.a_cred = cred;
516
517 VFS_MPLOCK1(vp->v_mount);
518 DO_OPS(ops, error, &ap, vop_mmap);
519 VFS_MPUNLOCK(vp->v_mount);
520 return(error);
521}
522
523/*
524 * MPSAFE
525 */
526int
527vop_fsync(struct vop_ops *ops, struct vnode *vp, int waitfor, int flags)
528{
529 struct vop_fsync_args ap;
530 VFS_MPLOCK_DECLARE;
531 int error;
532
533 ap.a_head.a_desc = &vop_fsync_desc;
534 ap.a_head.a_ops = ops;
535 ap.a_vp = vp;
536 ap.a_waitfor = waitfor;
537 ap.a_flags = flags;
538
539 VFS_MPLOCK1(vp->v_mount);
540 DO_OPS(ops, error, &ap, vop_fsync);
541 VFS_MPUNLOCK(vp->v_mount);
542 return(error);
543}
544
545/*
546 * MPSAFE
547 */
548int
549vop_old_remove(struct vop_ops *ops, struct vnode *dvp,
550 struct vnode *vp, struct componentname *cnp)
551{
552 struct vop_old_remove_args ap;
553 VFS_MPLOCK_DECLARE;
554 int error;
555
556 ap.a_head.a_desc = &vop_old_remove_desc;
557 ap.a_head.a_ops = ops;
558 ap.a_dvp = dvp;
559 ap.a_vp = vp;
560 ap.a_cnp = cnp;
561
562 VFS_MPLOCK1(dvp->v_mount);
563 DO_OPS(ops, error, &ap, vop_old_remove);
564 VFS_MPUNLOCK(dvp->v_mount);
565 return(error);
566}
567
568/*
569 * MPSAFE
570 */
571int
572vop_old_link(struct vop_ops *ops, struct vnode *tdvp,
573 struct vnode *vp, struct componentname *cnp)
574{
575 struct vop_old_link_args ap;
576 VFS_MPLOCK_DECLARE;
577 int error;
578
579 ap.a_head.a_desc = &vop_old_link_desc;
580 ap.a_head.a_ops = ops;
581 ap.a_tdvp = tdvp;
582 ap.a_vp = vp;
583 ap.a_cnp = cnp;
584
585 VFS_MPLOCK1(tdvp->v_mount);
586 DO_OPS(ops, error, &ap, vop_old_link);
587 VFS_MPUNLOCK(tdvp->v_mount);
588 return(error);
589}
590
591/*
592 * MPSAFE
593 */
594int
595vop_old_rename(struct vop_ops *ops,
596 struct vnode *fdvp, struct vnode *fvp, struct componentname *fcnp,
597 struct vnode *tdvp, struct vnode *tvp, struct componentname *tcnp)
598{
599 struct vop_old_rename_args ap;
600 VFS_MPLOCK_DECLARE;
601 int error;
602
603 ap.a_head.a_desc = &vop_old_rename_desc;
604 ap.a_head.a_ops = ops;
605 ap.a_fdvp = fdvp;
606 ap.a_fvp = fvp;
607 ap.a_fcnp = fcnp;
608 ap.a_tdvp = tdvp;
609 ap.a_tvp = tvp;
610 ap.a_tcnp = tcnp;
611
612 VFS_MPLOCK1(tdvp->v_mount);
613 DO_OPS(ops, error, &ap, vop_old_rename);
614 VFS_MPUNLOCK(tdvp->v_mount);
615 return(error);
616}
617
618/*
619 * MPSAFE
620 */
621int
622vop_old_mkdir(struct vop_ops *ops, struct vnode *dvp,
623 struct vnode **vpp, struct componentname *cnp, struct vattr *vap)
624{
625 struct vop_old_mkdir_args ap;
626 VFS_MPLOCK_DECLARE;
627 int error;
628
629 ap.a_head.a_desc = &vop_old_mkdir_desc;
630 ap.a_head.a_ops = ops;
631 ap.a_dvp = dvp;
632 ap.a_vpp = vpp;
633 ap.a_cnp = cnp;
634 ap.a_vap = vap;
635
636 VFS_MPLOCK1(dvp->v_mount);
637 DO_OPS(ops, error, &ap, vop_old_mkdir);
638 VFS_MPUNLOCK(dvp->v_mount);
639 return(error);
640}
641
642/*
643 * MPSAFE
644 */
645int
646vop_old_rmdir(struct vop_ops *ops, struct vnode *dvp,
647 struct vnode *vp, struct componentname *cnp)
648{
649 struct vop_old_rmdir_args ap;
650 VFS_MPLOCK_DECLARE;
651 int error;
652
653 ap.a_head.a_desc = &vop_old_rmdir_desc;
654 ap.a_head.a_ops = ops;
655 ap.a_dvp = dvp;
656 ap.a_vp = vp;
657 ap.a_cnp = cnp;
658
659 VFS_MPLOCK1(dvp->v_mount);
660 DO_OPS(ops, error, &ap, vop_old_rmdir);
661 VFS_MPUNLOCK(dvp->v_mount);
662 return(error);
663}
664
665/*
666 * MPSAFE
667 */
668int
669vop_old_symlink(struct vop_ops *ops, struct vnode *dvp,
670 struct vnode **vpp, struct componentname *cnp,
671 struct vattr *vap, char *target)
672{
673 struct vop_old_symlink_args ap;
674 VFS_MPLOCK_DECLARE;
675 int error;
676
677 ap.a_head.a_desc = &vop_old_symlink_desc;
678 ap.a_head.a_ops = ops;
679 ap.a_dvp = dvp;
680 ap.a_vpp = vpp;
681 ap.a_cnp = cnp;
682 ap.a_vap = vap;
683 ap.a_target = target;
684
685 VFS_MPLOCK1(dvp->v_mount);
686 DO_OPS(ops, error, &ap, vop_old_symlink);
687 VFS_MPUNLOCK(dvp->v_mount);
688 return(error);
689}
690
691/*
692 * MPSAFE
693 */
694int
695vop_readdir(struct vop_ops *ops, struct vnode *vp, struct uio *uio,
696 struct ucred *cred, int *eofflag, int *ncookies, off_t **cookies)
697{
698 struct vop_readdir_args ap;
699 VFS_MPLOCK_DECLARE;
700 int error;
701
702 ap.a_head.a_desc = &vop_readdir_desc;
703 ap.a_head.a_ops = ops;
704 ap.a_vp = vp;
705 ap.a_uio = uio;
706 ap.a_cred = cred;
707 ap.a_eofflag = eofflag;
708 ap.a_ncookies = ncookies;
709 ap.a_cookies = cookies;
710
711 VFS_MPLOCK1(vp->v_mount);
712 DO_OPS(ops, error, &ap, vop_readdir);
713 VFS_MPUNLOCK(vp->v_mount);
714 return(error);
715}
716
717/*
718 * MPSAFE
719 */
720int
721vop_readlink(struct vop_ops *ops, struct vnode *vp, struct uio *uio,
722 struct ucred *cred)
723{
724 struct vop_readlink_args ap;
725 VFS_MPLOCK_DECLARE;
726 int error;
727
728 ap.a_head.a_desc = &vop_readlink_desc;
729 ap.a_head.a_ops = ops;
730 ap.a_vp = vp;
731 ap.a_uio = uio;
732 ap.a_cred = cred;
733
734 VFS_MPLOCK1(vp->v_mount);
735 DO_OPS(ops, error, &ap, vop_readlink);
736 VFS_MPUNLOCK(vp->v_mount);
737 return(error);
738}
739
740/*
741 * MPSAFE
742 */
743int
744vop_inactive(struct vop_ops *ops, struct vnode *vp)
745{
746 struct vop_inactive_args ap;
747 struct mount *mp;
748 VFS_MPLOCK_DECLARE;
749 int error;
750
751 ap.a_head.a_desc = &vop_inactive_desc;
752 ap.a_head.a_ops = ops;
753 ap.a_vp = vp;
754
755 /*
756 * WARNING! Deactivation of the vnode can cause it to be recycled,
757 * clearing vp->v_mount.
758 */
759 mp = vp->v_mount;
760 VFS_MPLOCK_FLAG(mp, MNTK_IN_MPSAFE);
761 DO_OPS(ops, error, &ap, vop_inactive);
762 VFS_MPUNLOCK(mp);
763 return(error);
764}
765
766/*
767 * MPSAFE
768 */
769int
770vop_reclaim(struct vop_ops *ops, struct vnode *vp)
771{
772 struct vop_reclaim_args ap;
773 struct mount *mp;
774 VFS_MPLOCK_DECLARE;
775 int error;
776
777 ap.a_head.a_desc = &vop_reclaim_desc;
778 ap.a_head.a_ops = ops;
779 ap.a_vp = vp;
780
781 /*
782 * WARNING! Reclamation of the vnode will clear vp->v_mount.
783 */
784 mp = vp->v_mount;
785 VFS_MPLOCK1(mp);
786 DO_OPS(ops, error, &ap, vop_reclaim);
787 VFS_MPUNLOCK(mp);
788 return(error);
789}
790
791/*
792 * MPSAFE
793 */
794int
795vop_bmap(struct vop_ops *ops, struct vnode *vp, off_t loffset,
796 off_t *doffsetp, int *runp, int *runb, buf_cmd_t cmd)
797{
798 struct vop_bmap_args ap;
799 VFS_MPLOCK_DECLARE;
800 int error;
801
802 ap.a_head.a_desc = &vop_bmap_desc;
803 ap.a_head.a_ops = ops;
804 ap.a_vp = vp;
805 ap.a_loffset = loffset;
806 ap.a_doffsetp = doffsetp;
807 ap.a_runp = runp;
808 ap.a_runb = runb;
809 ap.a_cmd = cmd;
810
811 VFS_MPLOCK1(vp->v_mount);
812 DO_OPS(ops, error, &ap, vop_bmap);
813 VFS_MPUNLOCK(vp->v_mount);
814 return(error);
815}
816
817/*
818 * MPSAFE
819 */
820int
821vop_strategy(struct vop_ops *ops, struct vnode *vp, struct bio *bio)
822{
823 struct vop_strategy_args ap;
824 VFS_MPLOCK_DECLARE;
825 int error;
826
827 ap.a_head.a_desc = &vop_strategy_desc;
828 ap.a_head.a_ops = ops;
829 ap.a_vp = vp;
830 ap.a_bio = bio;
831
832 if (vp->v_mount) {
833
834 VFS_MPLOCK_FLAG(vp->v_mount, MNTK_SG_MPSAFE);
835 DO_OPS(ops, error, &ap, vop_strategy);
836 VFS_MPUNLOCK(vp->v_mount);
837 } else {
838 /* ugly hack for swap */
839 get_mplock();
840 DO_OPS(ops, error, &ap, vop_strategy);
841 rel_mplock();
842 }
843 return(error);
844}
845
846/*
847 * MPSAFE
848 */
849int
850vop_print(struct vop_ops *ops, struct vnode *vp)
851{
852 struct vop_print_args ap;
853 VFS_MPLOCK_DECLARE;
854 int error;
855
856 ap.a_head.a_desc = &vop_print_desc;
857 ap.a_head.a_ops = ops;
858 ap.a_vp = vp;
859
860 VFS_MPLOCK1(vp->v_mount);
861 DO_OPS(ops, error, &ap, vop_print);
862 VFS_MPUNLOCK(vp->v_mount);
863 return(error);
864}
865
866/*
867 * MPSAFE
868 */
869int
870vop_pathconf(struct vop_ops *ops, struct vnode *vp, int name,
871 register_t *retval)
872{
873 struct vop_pathconf_args ap;
874 VFS_MPLOCK_DECLARE;
875 int error;
876
877 ap.a_head.a_desc = &vop_pathconf_desc;
878 ap.a_head.a_ops = ops;
879 ap.a_vp = vp;
880 ap.a_name = name;
881 ap.a_retval = retval;
882
883 VFS_MPLOCK1(vp->v_mount);
884 DO_OPS(ops, error, &ap, vop_pathconf);
885 VFS_MPUNLOCK(vp->v_mount);
886 return(error);
887}
888
889/*
890 * MPSAFE
891 */
892int
893vop_advlock(struct vop_ops *ops, struct vnode *vp, caddr_t id, int op,
894 struct flock *fl, int flags)
895{
896 struct vop_advlock_args ap;
897 VFS_MPLOCK_DECLARE;
898 int error;
899
900 ap.a_head.a_desc = &vop_advlock_desc;
901 ap.a_head.a_ops = ops;
902 ap.a_vp = vp;
903 ap.a_id = id;
904 ap.a_op = op;
905 ap.a_fl = fl;
906 ap.a_flags = flags;
907
908 VFS_MPLOCK1(vp->v_mount);
909 DO_OPS(ops, error, &ap, vop_advlock);
910 VFS_MPUNLOCK(vp->v_mount);
911 return(error);
912}
913
914/*
915 * MPSAFE
916 */
917int
918vop_balloc(struct vop_ops *ops, struct vnode *vp, off_t startoffset,
919 int size, struct ucred *cred, int flags,
920 struct buf **bpp)
921{
922 struct vop_balloc_args ap;
923 VFS_MPLOCK_DECLARE;
924 int error;
925
926 ap.a_head.a_desc = &vop_balloc_desc;
927 ap.a_head.a_ops = ops;
928 ap.a_vp = vp;
929 ap.a_startoffset = startoffset;
930 ap.a_size = size;
931 ap.a_cred = cred;
932 ap.a_flags = flags;
933 ap.a_bpp = bpp;
934
935 VFS_MPLOCK1(vp->v_mount);
936 DO_OPS(ops, error, &ap, vop_balloc);
937 VFS_MPUNLOCK(vp->v_mount);
938 return(error);
939}
940
941/*
942 * MPSAFE
943 */
944int
945vop_reallocblks(struct vop_ops *ops, struct vnode *vp,
946 struct cluster_save *buflist)
947{
948 struct vop_reallocblks_args ap;
949 VFS_MPLOCK_DECLARE;
950 int error;
951
952 ap.a_head.a_desc = &vop_reallocblks_desc;
953 ap.a_head.a_ops = ops;
954 ap.a_vp = vp;
955 ap.a_buflist = buflist;
956
957 VFS_MPLOCK1(vp->v_mount);
958 DO_OPS(ops, error, &ap, vop_reallocblks);
959 VFS_MPUNLOCK(vp->v_mount);
960 return(error);
961}
962
963/*
964 * MPSAFE
965 */
966int
967vop_getpages(struct vop_ops *ops, struct vnode *vp, vm_page_t *m, int count,
968 int reqpage, vm_ooffset_t offset, int seqaccess)
969{
970 struct vop_getpages_args ap;
971 VFS_MPLOCK_DECLARE;
972 int error;
973
974 ap.a_head.a_desc = &vop_getpages_desc;
975 ap.a_head.a_ops = ops;
976 ap.a_vp = vp;
977 ap.a_m = m;
978 ap.a_count = count;
979 ap.a_reqpage = reqpage;
980 ap.a_offset = offset;
981 ap.a_seqaccess = seqaccess;
982
983 VFS_MPLOCK1(vp->v_mount);
984 DO_OPS(ops, error, &ap, vop_getpages);
985 VFS_MPUNLOCK(vp->v_mount);
986 return(error);
987}
988
989/*
990 * MPSAFE
991 */
992int
993vop_putpages(struct vop_ops *ops, struct vnode *vp, vm_page_t *m, int count,
994 int sync, int *rtvals, vm_ooffset_t offset)
995{
996 struct vop_putpages_args ap;
997 VFS_MPLOCK_DECLARE;
998 int error;
999
1000 ap.a_head.a_desc = &vop_putpages_desc;
1001 ap.a_head.a_ops = ops;
1002 ap.a_vp = vp;
1003 ap.a_m = m;
1004 ap.a_count = count;
1005 ap.a_sync = sync;
1006 ap.a_rtvals = rtvals;
1007 ap.a_offset = offset;
1008
1009 VFS_MPLOCK1(vp->v_mount);
1010 DO_OPS(ops, error, &ap, vop_putpages);
1011 VFS_MPUNLOCK(vp->v_mount);
1012 return(error);
1013}
1014
1015/*
1016 * MPSAFE
1017 */
1018int
1019vop_freeblks(struct vop_ops *ops, struct vnode *vp, off_t offset, int length)
1020{
1021 struct vop_freeblks_args ap;
1022 VFS_MPLOCK_DECLARE;
1023 int error;
1024
1025 ap.a_head.a_desc = &vop_freeblks_desc;
1026 ap.a_head.a_ops = ops;
1027 ap.a_vp = vp;
1028 ap.a_offset = offset;
1029 ap.a_length = length;
1030
1031 VFS_MPLOCK1(vp->v_mount);
1032 DO_OPS(ops, error, &ap, vop_freeblks);
1033 VFS_MPUNLOCK(vp->v_mount);
1034 return(error);
1035}
1036
1037/*
1038 * MPSAFE
1039 */
1040int
1041vop_getacl(struct vop_ops *ops, struct vnode *vp, acl_type_t type,
1042 struct acl *aclp, struct ucred *cred)
1043{
1044 struct vop_getacl_args ap;
1045 VFS_MPLOCK_DECLARE;
1046 int error;
1047
1048 ap.a_head.a_desc = &vop_getacl_desc;
1049 ap.a_head.a_ops = ops;
1050 ap.a_vp = vp;
1051 ap.a_type = type;
1052 ap.a_aclp = aclp;
1053 ap.a_cred = cred;
1054
1055 VFS_MPLOCK1(vp->v_mount);
1056 DO_OPS(ops, error, &ap, vop_getacl);
1057 VFS_MPUNLOCK(vp->v_mount);
1058 return(error);
1059}
1060
1061/*
1062 * MPSAFE
1063 */
1064int
1065vop_setacl(struct vop_ops *ops, struct vnode *vp, acl_type_t type,
1066 struct acl *aclp, struct ucred *cred)
1067{
1068 struct vop_setacl_args ap;
1069 VFS_MPLOCK_DECLARE;
1070 int error;
1071
1072 ap.a_head.a_desc = &vop_setacl_desc;
1073 ap.a_head.a_ops = ops;
1074 ap.a_vp = vp;
1075 ap.a_type = type;
1076 ap.a_aclp = aclp;
1077 ap.a_cred = cred;
1078
1079 VFS_MPLOCK1(vp->v_mount);
1080 DO_OPS(ops, error, &ap, vop_setacl);
1081 VFS_MPUNLOCK(vp->v_mount);
1082 return(error);
1083}
1084
1085/*
1086 * MPSAFE
1087 */
1088int
1089vop_aclcheck(struct vop_ops *ops, struct vnode *vp, acl_type_t type,
1090 struct acl *aclp, struct ucred *cred)
1091{
1092 struct vop_aclcheck_args ap;
1093 VFS_MPLOCK_DECLARE;
1094 int error;
1095
1096 ap.a_head.a_desc = &vop_aclcheck_desc;
1097 ap.a_head.a_ops = ops;
1098 ap.a_vp = vp;
1099 ap.a_type = type;
1100 ap.a_aclp = aclp;
1101 ap.a_cred = cred;
1102
1103 VFS_MPLOCK1(vp->v_mount);
1104 DO_OPS(ops, error, &ap, vop_aclcheck);
1105 VFS_MPUNLOCK(vp->v_mount);
1106 return(error);
1107}
1108
1109/*
1110 * MPSAFE
1111 */
1112int
1113vop_getextattr(struct vop_ops *ops, struct vnode *vp, int attrnamespace,
1114 char *attrname, struct uio *uio, struct ucred *cred)
1115{
1116 struct vop_getextattr_args ap;
1117 VFS_MPLOCK_DECLARE;
1118 int error;
1119
1120 ap.a_head.a_desc = &vop_getextattr_desc;
1121 ap.a_head.a_ops = ops;
1122 ap.a_vp = vp;
1123 ap.a_attrnamespace = attrnamespace;
1124 ap.a_attrname = attrname;
1125 ap.a_uio = uio;
1126 ap.a_cred = cred;
1127
1128 VFS_MPLOCK1(vp->v_mount);
1129 DO_OPS(ops, error, &ap, vop_getextattr);
1130 VFS_MPUNLOCK(vp->v_mount);
1131 return(error);
1132}
1133
1134/*
1135 * MPSAFE
1136 */
1137int
1138vop_setextattr(struct vop_ops *ops, struct vnode *vp, int attrnamespace,
1139 char *attrname, struct uio *uio, struct ucred *cred)
1140{
1141 struct vop_setextattr_args ap;
1142 VFS_MPLOCK_DECLARE;
1143 int error;
1144
1145 ap.a_head.a_desc = &vop_setextattr_desc;
1146 ap.a_head.a_ops = ops;
1147 ap.a_vp = vp;
1148 ap.a_attrnamespace = attrnamespace;
1149 ap.a_attrname = attrname;
1150 ap.a_uio = uio;
1151 ap.a_cred = cred;
1152
1153 VFS_MPLOCK1(vp->v_mount);
1154 DO_OPS(ops, error, &ap, vop_setextattr);
1155 VFS_MPUNLOCK(vp->v_mount);
1156 return(error);
1157}
1158
1159/*
1160 * MPSAFE
1161 */
1162int
1163vop_mountctl(struct vop_ops *ops, struct vnode *vp, int op, struct file *fp,
1164 const void *ctl, int ctllen, void *buf, int buflen, int *res)
1165{
1166 struct vop_mountctl_args ap;
1167 VFS_MPLOCK_DECLARE;
1168 int error;
1169
1170 ap.a_head.a_desc = &vop_mountctl_desc;
1171 ap.a_head.a_ops = ops;
1172 ap.a_op = op;
1173 ap.a_ctl = ctl;
1174 ap.a_fp = fp;
1175 ap.a_ctllen = ctllen;
1176 ap.a_buf = buf;
1177 ap.a_buflen = buflen;
1178 ap.a_res = res;
1179
1180 VFS_MPLOCK1(vp->v_mount);
1181 DO_OPS(ops, error, &ap, vop_mountctl);
1182 VFS_MPUNLOCK(vp->v_mount);
1183 return(error);
1184}
1185
1186/*
1187 * MPSAFE
1188 */
1189int
1190vop_markatime(struct vop_ops *ops, struct vnode *vp, struct ucred *cred)
1191{
1192 struct vop_markatime_args ap;
1193 VFS_MPLOCK_DECLARE;
1194 int error;
1195
1196 ap.a_head.a_desc = &vop_markatime_desc;
1197 ap.a_head.a_ops = ops;
1198 ap.a_vp = vp;
1199 ap.a_cred = cred;
1200
1201 VFS_MPLOCK1(vp->v_mount);
1202 DO_OPS(ops, error, &ap, vop_markatime);
1203 VFS_MPUNLOCK(vp->v_mount);
1204 return(error);
1205}
1206
1207/*
1208 * NEW API FUNCTIONS
1209 *
1210 * nresolve takes a locked ncp, a referenced but unlocked dvp, and a cred,
1211 * and resolves the ncp into a positive or negative hit.
1212 *
1213 * The namecache is automatically adjusted by this function. The ncp
1214 * is left locked on return.
1215 *
1216 * MPSAFE
1217 */
1218int
1219vop_nresolve(struct vop_ops *ops, struct nchandle *nch,
1220 struct vnode *dvp, struct ucred *cred)
1221{
1222 struct vop_nresolve_args ap;
1223 VFS_MPLOCK_DECLARE;
1224 int error;
1225
1226 ap.a_head.a_desc = &vop_nresolve_desc;
1227 ap.a_head.a_ops = ops;
1228 ap.a_nch = nch;
1229 ap.a_dvp = dvp;
1230 ap.a_cred = cred;
1231
1232 VFS_MPLOCK1(dvp->v_mount);
1233 DO_OPS(ops, error, &ap, vop_nresolve);
1234 VFS_MPUNLOCK(dvp->v_mount);
1235 return(error);
1236}
1237
1238/*
1239 * nlookupdotdot takes an unlocked directory, referenced dvp, and looks
1240 * up "..", returning a locked parent directory in *vpp. If an error
1241 * occurs *vpp will be NULL.
1242 *
1243 * MPSAFE
1244 */
1245int
1246vop_nlookupdotdot(struct vop_ops *ops, struct vnode *dvp,
1247 struct vnode **vpp, struct ucred *cred, char **fakename)
1248{
1249 struct vop_nlookupdotdot_args ap;
1250 VFS_MPLOCK_DECLARE;
1251 int error;
1252
1253 ap.a_head.a_desc = &vop_nlookupdotdot_desc;
1254 ap.a_head.a_ops = ops;
1255 ap.a_dvp = dvp;
1256 ap.a_vpp = vpp;
1257 ap.a_cred = cred;
1258 ap.a_fakename = fakename;
1259
1260 VFS_MPLOCK1(dvp->v_mount);
1261 DO_OPS(ops, error, &ap, vop_nlookupdotdot);
1262 VFS_MPUNLOCK(dvp->v_mount);
1263 return(error);
1264}
1265
1266/*
1267 * ncreate takes a locked, resolved ncp that typically represents a negative
1268 * cache hit and creates the file or node specified by the ncp, cred, and
1269 * vattr. If no error occurs a locked vnode is returned in *vpp.
1270 *
1271 * The dvp passed in is referenced but unlocked.
1272 *
1273 * The namecache is automatically adjusted by this function. The ncp
1274 * is left locked on return.
1275 *
1276 * MPSAFE
1277 */
1278int
1279vop_ncreate(struct vop_ops *ops, struct nchandle *nch, struct vnode *dvp,
1280 struct vnode **vpp, struct ucred *cred, struct vattr *vap)
1281{
1282 struct vop_ncreate_args ap;
1283 VFS_MPLOCK_DECLARE;
1284 int error;
1285
1286 ap.a_head.a_desc = &vop_ncreate_desc;
1287 ap.a_head.a_ops = ops;
1288 ap.a_nch = nch;
1289 ap.a_dvp = dvp;
1290 ap.a_vpp = vpp;
1291 ap.a_cred = cred;
1292 ap.a_vap = vap;
1293
1294 VFS_MPLOCK1(dvp->v_mount);
1295 DO_OPS(ops, error, &ap, vop_ncreate);
1296 VFS_MPUNLOCK(dvp->v_mount);
1297 return(error);
1298}
1299
1300/*
1301 * nmkdir takes a locked, resolved ncp that typically represents a negative
1302 * cache hit and creates the directory specified by the ncp, cred, and
1303 * vattr. If no error occurs a locked vnode is returned in *vpp.
1304 *
1305 * The dvp passed in is referenced but unlocked.
1306 *
1307 * The namecache is automatically adjusted by this function. The ncp
1308 * is left locked on return.
1309 *
1310 * MPSAFE
1311 */
1312int
1313vop_nmkdir(struct vop_ops *ops, struct nchandle *nch, struct vnode *dvp,
1314 struct vnode **vpp, struct ucred *cred, struct vattr *vap)
1315{
1316 struct vop_nmkdir_args ap;
1317 VFS_MPLOCK_DECLARE;
1318 int error;
1319
1320 ap.a_head.a_desc = &vop_nmkdir_desc;
1321 ap.a_head.a_ops = ops;
1322 ap.a_nch = nch;
1323 ap.a_dvp = dvp;
1324 ap.a_vpp = vpp;
1325 ap.a_cred = cred;
1326 ap.a_vap = vap;
1327
1328 VFS_MPLOCK1(dvp->v_mount);
1329 DO_OPS(ops, error, &ap, vop_nmkdir);
1330 VFS_MPUNLOCK(dvp->v_mount);
1331 return(error);
1332}
1333
1334/*
1335 * nmknod takes a locked, resolved ncp that typically represents a negative
1336 * cache hit and creates the node specified by the ncp, cred, and
1337 * vattr. If no error occurs a locked vnode is returned in *vpp.
1338 *
1339 * The dvp passed in is referenced but unlocked.
1340 *
1341 * The namecache is automatically adjusted by this function. The ncp
1342 * is left locked on return.
1343 *
1344 * MPSAFE
1345 */
1346int
1347vop_nmknod(struct vop_ops *ops, struct nchandle *nch, struct vnode *dvp,
1348 struct vnode **vpp, struct ucred *cred, struct vattr *vap)
1349{
1350 struct vop_nmknod_args ap;
1351 VFS_MPLOCK_DECLARE;
1352 int error;
1353
1354 ap.a_head.a_desc = &vop_nmknod_desc;
1355 ap.a_head.a_ops = ops;
1356 ap.a_nch = nch;
1357 ap.a_dvp = dvp;
1358 ap.a_vpp = vpp;
1359 ap.a_cred = cred;
1360 ap.a_vap = vap;
1361
1362 VFS_MPLOCK1(dvp->v_mount);
1363 DO_OPS(ops, error, &ap, vop_nmknod);
1364 VFS_MPUNLOCK(dvp->v_mount);
1365 return(error);
1366}
1367
1368/*
1369 * nlink takes a locked, resolved ncp that typically represents a negative
1370 * cache hit and creates the node specified by the ncp, cred, and
1371 * existing vnode. The passed vp must be locked and will remain locked
1372 * on return, as does the ncp, whether an error occurs or not.
1373 *
1374 * The dvp passed in is referenced but unlocked.
1375 *
1376 * The namecache is automatically adjusted by this function. The ncp
1377 * is left locked on return.
1378 *
1379 * MPSAFE
1380 */
1381int
1382vop_nlink(struct vop_ops *ops, struct nchandle *nch, struct vnode *dvp,
1383 struct vnode *vp, struct ucred *cred)
1384{
1385 struct vop_nlink_args ap;
1386 VFS_MPLOCK_DECLARE;
1387 int error;
1388
1389 ap.a_head.a_desc = &vop_nlink_desc;
1390 ap.a_head.a_ops = ops;
1391 ap.a_nch = nch;
1392 ap.a_dvp = dvp;
1393 ap.a_vp = vp;
1394 ap.a_cred = cred;
1395
1396 VFS_MPLOCK1(dvp->v_mount);
1397 DO_OPS(ops, error, &ap, vop_nlink);
1398 VFS_MPUNLOCK(dvp->v_mount);
1399 return(error);
1400}
1401
1402/*
1403 * nsymlink takes a locked, resolved ncp that typically represents a negative
1404 * cache hit and creates a symbolic link based on cred, vap, and target (the
1405 * contents of the link). If no error occurs a locked vnode is returned in
1406 * *vpp.
1407 *
1408 * The dvp passed in is referenced but unlocked.
1409 *
1410 * The namecache is automatically adjusted by this function. The ncp
1411 * is left locked on return.
1412 *
1413 * MPSAFE
1414 */
1415int
1416vop_nsymlink(struct vop_ops *ops, struct nchandle *nch, struct vnode *dvp,
1417 struct vnode **vpp, struct ucred *cred,
1418 struct vattr *vap, char *target)
1419{
1420 struct vop_nsymlink_args ap;
1421 VFS_MPLOCK_DECLARE;
1422 int error;
1423
1424 ap.a_head.a_desc = &vop_nsymlink_desc;
1425 ap.a_head.a_ops = ops;
1426 ap.a_nch = nch;
1427 ap.a_dvp = dvp;
1428 ap.a_vpp = vpp;
1429 ap.a_cred = cred;
1430 ap.a_vap = vap;
1431 ap.a_target = target;
1432
1433 VFS_MPLOCK1(dvp->v_mount);
1434 DO_OPS(ops, error, &ap, vop_nsymlink);
1435 VFS_MPUNLOCK(dvp->v_mount);
1436 return(error);
1437}
1438
1439/*
1440 * nwhiteout takes a locked, resolved ncp that can represent a positive or
1441 * negative hit and executes the whiteout function specified in flags.
1442 *
1443 * The dvp passed in is referenced but unlocked.
1444 *
1445 * The namecache is automatically adjusted by this function. The ncp
1446 * is left locked on return.
1447 *
1448 * MPSAFE
1449 */
1450int
1451vop_nwhiteout(struct vop_ops *ops, struct nchandle *nch, struct vnode *dvp,
1452 struct ucred *cred, int flags)
1453{
1454 struct vop_nwhiteout_args ap;
1455 VFS_MPLOCK_DECLARE;
1456 int error;
1457
1458 ap.a_head.a_desc = &vop_nwhiteout_desc;
1459 ap.a_head.a_ops = ops;
1460 ap.a_nch = nch;
1461 ap.a_dvp = dvp;
1462 ap.a_cred = cred;
1463 ap.a_flags = flags;
1464
1465 VFS_MPLOCK1(dvp->v_mount);
1466 DO_OPS(ops, error, &ap, vop_nwhiteout);
1467 VFS_MPUNLOCK(dvp->v_mount);
1468 return(error);
1469}
1470
1471/*
1472 * nremove takes a locked, resolved ncp that generally represents a
1473 * positive hit and removes the file.
1474 *
1475 * The dvp passed in is referenced but unlocked.
1476 *
1477 * The namecache is automatically adjusted by this function. The ncp
1478 * is left locked on return.
1479 *
1480 * MPSAFE
1481 */
1482int
1483vop_nremove(struct vop_ops *ops, struct nchandle *nch, struct vnode *dvp,
1484 struct ucred *cred)
1485{
1486 struct vop_nremove_args ap;
1487 VFS_MPLOCK_DECLARE;
1488 int error;
1489
1490 ap.a_head.a_desc = &vop_nremove_desc;
1491 ap.a_head.a_ops = ops;
1492 ap.a_nch = nch;
1493 ap.a_dvp = dvp;
1494 ap.a_cred = cred;
1495
1496 VFS_MPLOCK1(dvp->v_mount);
1497 DO_OPS(ops, error, &ap, vop_nremove);
1498 VFS_MPUNLOCK(dvp->v_mount);
1499 return(error);
1500}
1501
1502/*
1503 * nrmdir takes a locked, resolved ncp that generally represents a
1504 * directory and removes the directory.
1505 *
1506 * The dvp passed in is referenced but unlocked.
1507 *
1508 * The namecache is automatically adjusted by this function. The ncp
1509 * is left locked on return.
1510 *
1511 * MPSAFE
1512 */
1513int
1514vop_nrmdir(struct vop_ops *ops, struct nchandle *nch, struct vnode *dvp,
1515 struct ucred *cred)
1516{
1517 struct vop_nrmdir_args ap;
1518 VFS_MPLOCK_DECLARE;
1519 int error;
1520
1521 ap.a_head.a_desc = &vop_nrmdir_desc;
1522 ap.a_head.a_ops = ops;
1523 ap.a_nch = nch;
1524 ap.a_dvp = dvp;
1525 ap.a_cred = cred;
1526
1527 VFS_MPLOCK1(dvp->v_mount);
1528 DO_OPS(ops, error, &ap, vop_nrmdir);
1529 VFS_MPUNLOCK(dvp->v_mount);
1530 return(error);
1531}
1532
1533/*
1534 * nrename takes TWO locked, resolved ncp's and the cred of the caller
1535 * and renames the source ncp to the target ncp. The target ncp may
1536 * represent a positive or negative hit.
1537 *
1538 * The fdvp and tdvp passed in are referenced but unlocked.
1539 *
1540 * The namecache is automatically adjusted by this function. The ncp
1541 * is left locked on return. The source ncp is typically changed to
1542 * a negative cache hit and the target ncp typically takes on the
1543 * source ncp's underlying file.
1544 *
1545 * MPSAFE
1546 */
1547int
1548vop_nrename(struct vop_ops *ops,
1549 struct nchandle *fnch, struct nchandle *tnch,
1550 struct vnode *fdvp, struct vnode *tdvp,
1551 struct ucred *cred)
1552{
1553 struct vop_nrename_args ap;
1554 VFS_MPLOCK_DECLARE;
1555 int error;
1556
1557 ap.a_head.a_desc = &vop_nrename_desc;
1558 ap.a_head.a_ops = ops;
1559 ap.a_fnch = fnch;
1560 ap.a_tnch = tnch;
1561 ap.a_fdvp = fdvp;
1562 ap.a_tdvp = tdvp;
1563 ap.a_cred = cred;
1564
1565 VFS_MPLOCK1(fdvp->v_mount);
1566 DO_OPS(ops, error, &ap, vop_nrename);
1567 VFS_MPUNLOCK(fdvp->v_mount);
1568 return(error);
1569}
1570
1571/************************************************************************
1572 * PRIMARY VNODE OPERATIONS FORWARDING CALLS *
1573 ************************************************************************
1574 *
1575 * These procedures are called from VFSs such as unionfs and nullfs
1576 * when they wish to forward an operation on one VFS to another. The
1577 * argument structure/message is modified and then directly passed to the
1578 * appropriate routine. This routines may also be called by initiators
1579 * who have an argument structure in hand rather then discreet arguments.
1580 *
1581 * MPSAFE - Caller expected to already hold the appropriate vfs lock.
1582 */
1583int
1584vop_vnoperate_ap(struct vop_generic_args *ap)
1585{
1586 struct vop_ops *ops;
1587 int error;
1588
1589 ops = ap->a_ops;
1590 error = VOCALL(ops, ap);
1591
1592 return (error);
1593}
1594
1595/*
1596 * This routine is called by the cache coherency layer to execute the actual
1597 * VFS operation. If a journaling layer is present we call though it, else
1598 * we call the native VOP functions.
1599 */
1600int
1601vop_cache_operate_ap(struct vop_generic_args *ap)
1602{
1603 struct vop_ops *ops;
1604 int error;
1605
1606 ops = ap->a_ops;
1607 if (ops->head.vv_mount->mnt_vn_journal_ops)
1608 error = VOCALL(ops->head.vv_mount->mnt_vn_journal_ops, ap);
1609 else
1610 error = VOCALL(ops->head.vv_mount->mnt_vn_norm_ops, ap);
1611 return (error);
1612}
1613
1614
1615/*
1616 * This routine is called by the journaling layer to execute the actual
1617 * VFS operation.
1618 */
1619int
1620vop_journal_operate_ap(struct vop_generic_args *ap)
1621{
1622 struct vop_ops *ops;
1623 int error;
1624
1625 ops = ap->a_ops;
1626 error = VOCALL(ops->head.vv_mount->mnt_vn_norm_ops, ap);
1627
1628 return (error);
1629}
1630
1631int
1632vop_open_ap(struct vop_open_args *ap)
1633{
1634 int error;
1635
1636 DO_OPS(ap->a_head.a_ops, error, ap, vop_open);
1637 return(error);
1638}
1639
1640int
1641vop_close_ap(struct vop_close_args *ap)
1642{
1643 int error;
1644
1645 DO_OPS(ap->a_head.a_ops, error, ap, vop_close);
1646 return(error);
1647}
1648
1649int
1650vop_access_ap(struct vop_access_args *ap)
1651{
1652 int error;
1653
1654 DO_OPS(ap->a_head.a_ops, error, ap, vop_access);
1655 return(error);
1656}
1657
1658int
1659vop_getattr_ap(struct vop_getattr_args *ap)
1660{
1661 int error;
1662
1663 DO_OPS(ap->a_head.a_ops, error, ap, vop_getattr);
1664 return(error);
1665}
1666
1667int
1668vop_setattr_ap(struct vop_setattr_args *ap)
1669{
1670 int error;
1671
1672 DO_OPS(ap->a_head.a_ops, error, ap, vop_setattr);
1673 return(error);
1674}
1675
1676int
1677vop_read_ap(struct vop_read_args *ap)
1678{
1679 int error;
1680
1681 DO_OPS(ap->a_head.a_ops, error, ap, vop_read);
1682 return(error);
1683}
1684
1685int
1686vop_write_ap(struct vop_write_args *ap)
1687{
1688 int error;
1689
1690 DO_OPS(ap->a_head.a_ops, error, ap, vop_write);
1691 return(error);
1692}
1693
1694int
1695vop_ioctl_ap(struct vop_ioctl_args *ap)
1696{
1697 int error;
1698
1699 DO_OPS(ap->a_head.a_ops, error, ap, vop_ioctl);
1700 return(error);
1701}
1702
1703int
1704vop_poll_ap(struct vop_poll_args *ap)
1705{
1706 int error;
1707
1708 DO_OPS(ap->a_head.a_ops, error, ap, vop_poll);
1709 return(error);
1710}
1711
1712int
1713vop_kqfilter_ap(struct vop_kqfilter_args *ap)
1714{
1715 int error;
1716
1717 DO_OPS(ap->a_head.a_ops, error, ap, vop_kqfilter);
1718 return(error);
1719}
1720
1721int
1722vop_mmap_ap(struct vop_mmap_args *ap)
1723{
1724 int error;
1725
1726 DO_OPS(ap->a_head.a_ops, error, ap, vop_mmap);
1727 return(error);
1728}
1729
1730int
1731vop_fsync_ap(struct vop_fsync_args *ap)
1732{
1733 int error;
1734
1735 DO_OPS(ap->a_head.a_ops, error, ap, vop_fsync);
1736 return(error);
1737}
1738
1739int
1740vop_readdir_ap(struct vop_readdir_args *ap)
1741{
1742 int error;
1743
1744 DO_OPS(ap->a_head.a_ops, error, ap, vop_readdir);
1745 return(error);
1746}
1747
1748int
1749vop_readlink_ap(struct vop_readlink_args *ap)
1750{
1751 int error;
1752
1753 DO_OPS(ap->a_head.a_ops, error, ap, vop_readlink);
1754 return(error);
1755}
1756
1757int
1758vop_inactive_ap(struct vop_inactive_args *ap)
1759{
1760 int error;
1761
1762 DO_OPS(ap->a_head.a_ops, error, ap, vop_inactive);
1763 return(error);
1764}
1765
1766int
1767vop_reclaim_ap(struct vop_reclaim_args *ap)
1768{
1769 int error;
1770
1771 DO_OPS(ap->a_head.a_ops, error, ap, vop_reclaim);
1772 return(error);
1773}
1774
1775int
1776vop_bmap_ap(struct vop_bmap_args *ap)
1777{
1778 int error;
1779
1780 DO_OPS(ap->a_head.a_ops, error, ap, vop_bmap);
1781 return(error);
1782}
1783
1784int
1785vop_strategy_ap(struct vop_strategy_args *ap)
1786{
1787 int error;
1788
1789 DO_OPS(ap->a_head.a_ops, error, ap, vop_strategy);
1790 return(error);
1791}
1792
1793int
1794vop_print_ap(struct vop_print_args *ap)
1795{
1796 int error;
1797
1798 DO_OPS(ap->a_head.a_ops, error, ap, vop_print);
1799 return(error);
1800}
1801
1802int
1803vop_pathconf_ap(struct vop_pathconf_args *ap)
1804{
1805 int error;
1806
1807 DO_OPS(ap->a_head.a_ops, error, ap, vop_pathconf);
1808 return(error);
1809}
1810
1811int
1812vop_advlock_ap(struct vop_advlock_args *ap)
1813{
1814 int error;
1815
1816 DO_OPS(ap->a_head.a_ops, error, ap, vop_advlock);
1817 return(error);
1818}
1819
1820int
1821vop_balloc_ap(struct vop_balloc_args *ap)
1822{
1823 int error;
1824
1825 DO_OPS(ap->a_head.a_ops, error, ap, vop_balloc);
1826 return(error);
1827}
1828
1829int
1830vop_reallocblks_ap(struct vop_reallocblks_args *ap)
1831{
1832 int error;
1833
1834 DO_OPS(ap->a_head.a_ops, error, ap, vop_reallocblks);
1835 return(error);
1836}
1837
1838int
1839vop_getpages_ap(struct vop_getpages_args *ap)
1840{
1841 int error;
1842
1843 DO_OPS(ap->a_head.a_ops, error, ap, vop_getpages);
1844 return(error);
1845}
1846
1847int
1848vop_putpages_ap(struct vop_putpages_args *ap)
1849{
1850 int error;
1851
1852 DO_OPS(ap->a_head.a_ops, error, ap, vop_putpages);
1853 return(error);
1854}
1855
1856int
1857vop_freeblks_ap(struct vop_freeblks_args *ap)
1858{
1859 int error;
1860
1861 DO_OPS(ap->a_head.a_ops, error, ap, vop_freeblks);
1862 return(error);
1863}
1864
1865int
1866vop_getacl_ap(struct vop_getacl_args *ap)
1867{
1868 int error;
1869
1870 DO_OPS(ap->a_head.a_ops, error, ap, vop_getacl);
1871 return(error);
1872}
1873
1874int
1875vop_setacl_ap(struct vop_setacl_args *ap)
1876{
1877 int error;
1878
1879 DO_OPS(ap->a_head.a_ops, error, ap, vop_setacl);
1880 return(error);
1881}
1882
1883int
1884vop_aclcheck_ap(struct vop_aclcheck_args *ap)
1885{
1886 int error;
1887
1888 DO_OPS(ap->a_head.a_ops, error, ap, vop_aclcheck);
1889 return(error);
1890}
1891
1892int
1893vop_getextattr_ap(struct vop_getextattr_args *ap)
1894{
1895 int error;
1896
1897 DO_OPS(ap->a_head.a_ops, error, ap, vop_getextattr);
1898 return(error);
1899}
1900
1901int
1902vop_setextattr_ap(struct vop_setextattr_args *ap)
1903{
1904 int error;
1905
1906 DO_OPS(ap->a_head.a_ops, error, ap, vop_setextattr);
1907 return(error);
1908}
1909
1910int
1911vop_mountctl_ap(struct vop_mountctl_args *ap)
1912{
1913 int error;
1914
1915 DO_OPS(ap->a_head.a_ops, error, ap, vop_mountctl);
1916 return(error);
1917}
1918
1919int
1920vop_markatime_ap(struct vop_markatime_args *ap)
1921{
1922 int error;
1923
1924 DO_OPS(ap->a_head.a_ops, error, ap, vop_markatime);
1925 return(error);
1926}
1927
1928int
1929vop_nresolve_ap(struct vop_nresolve_args *ap)
1930{
1931 int error;
1932
1933 DO_OPS(ap->a_head.a_ops, error, ap, vop_nresolve);
1934 return(error);
1935}
1936
1937int
1938vop_nlookupdotdot_ap(struct vop_nlookupdotdot_args *ap)
1939{
1940 int error;
1941
1942 DO_OPS(ap->a_head.a_ops, error, ap, vop_nlookupdotdot);
1943 return(error);
1944}
1945
1946int
1947vop_ncreate_ap(struct vop_ncreate_args *ap)
1948{
1949 int error;
1950
1951 DO_OPS(ap->a_head.a_ops, error, ap, vop_ncreate);
1952 return(error);
1953}
1954
1955int
1956vop_nmkdir_ap(struct vop_nmkdir_args *ap)
1957{
1958 int error;
1959
1960 DO_OPS(ap->a_head.a_ops, error, ap, vop_nmkdir);
1961 return(error);
1962}
1963
1964int
1965vop_nmknod_ap(struct vop_nmknod_args *ap)
1966{
1967 int error;
1968
1969 DO_OPS(ap->a_head.a_ops, error, ap, vop_nmknod);
1970 return(error);
1971}
1972
1973int
1974vop_nlink_ap(struct vop_nlink_args *ap)
1975{
1976 int error;
1977
1978 DO_OPS(ap->a_head.a_ops, error, ap, vop_nlink);
1979 return(error);
1980}
1981
1982int
1983vop_nsymlink_ap(struct vop_nsymlink_args *ap)
1984{
1985 int error;
1986
1987 DO_OPS(ap->a_head.a_ops, error, ap, vop_nsymlink);
1988 return(error);
1989}
1990
1991int
1992vop_nwhiteout_ap(struct vop_nwhiteout_args *ap)
1993{
1994 int error;
1995
1996 DO_OPS(ap->a_head.a_ops, error, ap, vop_nwhiteout);
1997 return(error);
1998}
1999
2000int
2001vop_nremove_ap(struct vop_nremove_args *ap)
2002{
2003 int error;
2004
2005 DO_OPS(ap->a_head.a_ops, error, ap, vop_nremove);
2006 return(error);
2007}
2008
2009int
2010vop_nrmdir_ap(struct vop_nrmdir_args *ap)
2011{
2012 int error;
2013
2014 DO_OPS(ap->a_head.a_ops, error, ap, vop_nrmdir);
2015 return(error);
2016}
2017
2018int
2019vop_nrename_ap(struct vop_nrename_args *ap)
2020{
2021 int error;
2022
2023 DO_OPS(ap->a_head.a_ops, error, ap, vop_nrename);
2024 return(error);
2025}
2026