Deleted Added
full compact
null_vfsops.c (245665) null_vfsops.c (250978)
1/*-
2 * Copyright (c) 1992, 1993, 1995
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software donated to Berkeley by
6 * Jan-Simon Pendry.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 18 unchanged lines hidden (view full) ---

27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE.
31 *
32 * @(#)null_vfsops.c 8.2 (Berkeley) 1/21/94
33 *
34 * @(#)lofs_vfsops.c 1.2 (Berkeley) 6/18/92
1/*-
2 * Copyright (c) 1992, 1993, 1995
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software donated to Berkeley by
6 * Jan-Simon Pendry.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 18 unchanged lines hidden (view full) ---

27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE.
31 *
32 * @(#)null_vfsops.c 8.2 (Berkeley) 1/21/94
33 *
34 * @(#)lofs_vfsops.c 1.2 (Berkeley) 6/18/92
35 * $FreeBSD: stable/9/sys/fs/nullfs/null_vfsops.c 245665 2013-01-19 06:39:49Z kib $
35 * $FreeBSD: stable/9/sys/fs/nullfs/null_vfsops.c 250978 2013-05-25 11:05:00Z kib $
36 */
37
38/*
39 * Null Layer
40 * (See null_vnops.c for a description of what this does.)
41 */
42
43#include <sys/param.h>

--- 16 unchanged lines hidden (view full) ---

60static vfs_mount_t nullfs_mount;
61static vfs_quotactl_t nullfs_quotactl;
62static vfs_root_t nullfs_root;
63static vfs_sync_t nullfs_sync;
64static vfs_statfs_t nullfs_statfs;
65static vfs_unmount_t nullfs_unmount;
66static vfs_vget_t nullfs_vget;
67static vfs_extattrctl_t nullfs_extattrctl;
36 */
37
38/*
39 * Null Layer
40 * (See null_vnops.c for a description of what this does.)
41 */
42
43#include <sys/param.h>

--- 16 unchanged lines hidden (view full) ---

60static vfs_mount_t nullfs_mount;
61static vfs_quotactl_t nullfs_quotactl;
62static vfs_root_t nullfs_root;
63static vfs_sync_t nullfs_sync;
64static vfs_statfs_t nullfs_statfs;
65static vfs_unmount_t nullfs_unmount;
66static vfs_vget_t nullfs_vget;
67static vfs_extattrctl_t nullfs_extattrctl;
68static vfs_reclaim_lowervp_t nullfs_reclaim_lowervp;
69
70/*
71 * Mount null layer
72 */
73static int
74nullfs_mount(struct mount *mp)
75{
76 int error = 0;

--- 308 unchanged lines hidden (view full) ---

385static void
386nullfs_reclaim_lowervp(struct mount *mp, struct vnode *lowervp)
387{
388 struct vnode *vp;
389
390 vp = null_hashget(mp, lowervp);
391 if (vp == NULL)
392 return;
68
69/*
70 * Mount null layer
71 */
72static int
73nullfs_mount(struct mount *mp)
74{
75 int error = 0;

--- 308 unchanged lines hidden (view full) ---

384static void
385nullfs_reclaim_lowervp(struct mount *mp, struct vnode *lowervp)
386{
387 struct vnode *vp;
388
389 vp = null_hashget(mp, lowervp);
390 if (vp == NULL)
391 return;
392 VTONULL(vp)->null_flags |= NULLV_NOUNLOCK;
393 vgone(vp);
393 vgone(vp);
394 vn_lock(lowervp, LK_EXCLUSIVE | LK_RETRY);
394 vput(vp);
395}
396
395}
396
397static void
398nullfs_unlink_lowervp(struct mount *mp, struct vnode *lowervp)
399{
400 struct vnode *vp;
401 struct null_node *xp;
402
403 vp = null_hashget(mp, lowervp);
404 if (vp == NULL)
405 return;
406 xp = VTONULL(vp);
407 xp->null_flags |= NULLV_DROP | NULLV_NOUNLOCK;
408 vhold(vp);
409 vunref(vp);
410
411 if (vp->v_usecount == 0) {
412 /*
413 * If vunref() dropped the last use reference on the
414 * nullfs vnode, it must be reclaimed, and its lock
415 * was split from the lower vnode lock. Need to do
416 * extra unlock before allowing the final vdrop() to
417 * free the vnode.
418 */
419 KASSERT((vp->v_iflag & VI_DOOMED) != 0,
420 ("not reclaimed nullfs vnode %p", vp));
421 VOP_UNLOCK(vp, 0);
422 } else {
423 /*
424 * Otherwise, the nullfs vnode still shares the lock
425 * with the lower vnode, and must not be unlocked.
426 * Also clear the NULLV_NOUNLOCK, the flag is not
427 * relevant for future reclamations.
428 */
429 ASSERT_VOP_ELOCKED(vp, "unlink_lowervp");
430 KASSERT((vp->v_iflag & VI_DOOMED) == 0,
431 ("reclaimed nullfs vnode %p", vp));
432 xp->null_flags &= ~NULLV_NOUNLOCK;
433 }
434 vdrop(vp);
435}
436
397static struct vfsops null_vfsops = {
398 .vfs_extattrctl = nullfs_extattrctl,
399 .vfs_fhtovp = nullfs_fhtovp,
400 .vfs_init = nullfs_init,
401 .vfs_mount = nullfs_mount,
402 .vfs_quotactl = nullfs_quotactl,
403 .vfs_root = nullfs_root,
404 .vfs_statfs = nullfs_statfs,
405 .vfs_sync = nullfs_sync,
406 .vfs_uninit = nullfs_uninit,
407 .vfs_unmount = nullfs_unmount,
408 .vfs_vget = nullfs_vget,
409 .vfs_reclaim_lowervp = nullfs_reclaim_lowervp,
437static struct vfsops null_vfsops = {
438 .vfs_extattrctl = nullfs_extattrctl,
439 .vfs_fhtovp = nullfs_fhtovp,
440 .vfs_init = nullfs_init,
441 .vfs_mount = nullfs_mount,
442 .vfs_quotactl = nullfs_quotactl,
443 .vfs_root = nullfs_root,
444 .vfs_statfs = nullfs_statfs,
445 .vfs_sync = nullfs_sync,
446 .vfs_uninit = nullfs_uninit,
447 .vfs_unmount = nullfs_unmount,
448 .vfs_vget = nullfs_vget,
449 .vfs_reclaim_lowervp = nullfs_reclaim_lowervp,
450 .vfs_unlink_lowervp = nullfs_unlink_lowervp,
410};
411
412VFS_SET(null_vfsops, nullfs, VFCF_LOOPBACK | VFCF_JAIL);
451};
452
453VFS_SET(null_vfsops, nullfs, VFCF_LOOPBACK | VFCF_JAIL);