X-Git-Url: https://gitweb.dragonflybsd.org/dragonfly.git/blobdiff_plain/ec6cbd247624d7e00b0e700e6dc83ab0761a69da..dc1be39cdb26fb1f08501b2d0400fe731592e6e0:/sys/vm/vm_swap.c diff --git a/sys/vm/vm_swap.c b/sys/vm/vm_swap.c index 2c765e8cf2..57a449b7a8 100644 --- a/sys/vm/vm_swap.c +++ b/sys/vm/vm_swap.c @@ -32,7 +32,7 @@ * * @(#)vm_swap.c 8.5 (Berkeley) 2/17/94 * $FreeBSD: src/sys/vm/vm_swap.c,v 1.96.2.2 2001/10/14 18:46:47 iedowse Exp $ - * $DragonFly: src/sys/vm/vm_swap.c,v 1.12 2004/05/19 22:53:06 dillon Exp $ + * $DragonFly: src/sys/vm/vm_swap.c,v 1.19 2005/09/17 07:43:12 dillon Exp $ */ #include "opt_swap.h" @@ -42,7 +42,7 @@ #include #include #include -#include +#include #include /* XXX */ #include #include @@ -51,6 +51,7 @@ #include #include #include +#include #include #include #include @@ -87,7 +88,7 @@ swapdev_strategy(struct vop_strategy_args /* { struct buf *a_bp; } */ *ap) { - int s, sz, off, seg, index; + int sz, off, seg, index; struct swdevt *sp; struct vnode *vp; struct buf *bp; @@ -136,7 +137,7 @@ swapdev_strategy(struct vop_strategy_args /* { bp->b_blkno = ctodb(bp->b_blkno); vhold(sp->sw_vp); - s = splvm(); + crit_enter(); if ((bp->b_flags & B_READ) == 0) { vp = bp->b_vp; if (vp) { @@ -149,7 +150,7 @@ swapdev_strategy(struct vop_strategy_args /* { sp->sw_vp->v_numoutput++; } pbreassignbuf(bp, sp->sw_vp); - splx(s); + crit_exit(); VOP_STRATEGY(bp->b_vp, bp); return 0; } @@ -158,14 +159,14 @@ swapdev_strategy(struct vop_strategy_args /* { * Create a special vnode op vector for swapdev_vp - we only use * VOP_STRATEGY(), everything else returns an error. */ -vop_t **swapdev_vnodeop_p; +struct vop_ops *swapdev_vnode_vops; static struct vnodeopv_entry_desc swapdev_vnodeop_entries[] = { - { &vop_default_desc, (vop_t *) vop_defaultop }, - { &vop_strategy_desc, (vop_t *) swapdev_strategy }, + { &vop_default_desc, vop_defaultop }, + { &vop_strategy_desc, (void *) swapdev_strategy }, { NULL, NULL } }; static struct vnodeopv_desc swapdev_vnodeop_opv_desc = - { &swapdev_vnodeop_p, swapdev_vnodeop_entries }; + { &swapdev_vnode_vops, swapdev_vnodeop_entries, 0 }; VNODEOP_SET(swapdev_vnodeop_opv_desc); @@ -183,7 +184,7 @@ swapon(struct swapon_args *uap) struct thread *td = curthread; struct vattr attr; struct vnode *vp; - struct nameidata nd; + struct nlookupdata nd; int error; struct ucred *cred; @@ -194,14 +195,16 @@ swapon(struct swapon_args *uap) if (error) return (error); - NDINIT(&nd, NAMEI_LOOKUP, CNP_FOLLOW, UIO_USERSPACE, uap->name, td); - error = namei(&nd); + vp = NULL; + error = nlookup_init(&nd, uap->name, UIO_USERSPACE, NLC_FOLLOW); + if (error == 0) + error = nlookup(&nd); + if (error == 0) + error = cache_vref(nd.nl_ncp, nd.nl_cred, &vp); + nlookup_done(&nd); if (error) return (error); - NDFREE(&nd, NDF_ONLY_PNBUF); - vp = nd.ni_vp; - if (vn_isdisk(vp, &error)) error = swaponvp(td, vp, 0); else if (vp->v_type == VREG && vp->v_tag == VT_NFS && @@ -247,11 +250,12 @@ swaponvp(struct thread *td, struct vnode *vp, u_long nblks) cred = td->td_proc->p_ucred; if (!swapdev_vp) { - error = getnewvnode(VT_NON, NULL, swapdev_vnodeop_p, - &swapdev_vp); + error = getspecialvnode(VT_NON, NULL, &swapdev_vnode_vops, + &swapdev_vp, 0, 0); if (error) panic("Cannot get vnode for swapdev"); swapdev_vp->v_type = VNON; /* Untyped */ + vx_unlock(swapdev_vp); } ASSERT_VOP_UNLOCKED(vp, "swaponvp"); @@ -264,9 +268,9 @@ swaponvp(struct thread *td, struct vnode *vp, u_long nblks) } return EINVAL; found: - vn_lock(vp, NULL, LK_EXCLUSIVE | LK_RETRY, td); - error = VOP_OPEN(vp, FREAD | FWRITE, cred, td); - VOP_UNLOCK(vp, NULL, 0, td); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); + error = VOP_OPEN(vp, FREAD | FWRITE, cred, NULL, td); + VOP_UNLOCK(vp, 0, td); if (error) return (error);