Even though this looks like it, this is not a complex code change.
The interface into the "VMIO" system has changed to be more consistant and robust. Essentially, it is now no longer necessary to call vn_open to get merged VM/Buffer cache operation, and exceptional conditions such as merged operation of VBLK devices is simpler and more correct. This code corrects a potentially large set of problems including the problems with ktrace output and loaded systems, file create/deletes, etc. Most of the changes to NFS are cosmetic and name changes, eliminating a layer of subroutine calls. The direct calls to vput/vrele have been re-instituted for better cross platform compatibility. Reviewed by: davidg
This commit is contained in:
parent
fe6869c2d0
commit
6476c0d204
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=17761
@ -31,7 +31,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)spec_vnops.c 8.6 (Berkeley) 4/9/94
|
||||
* $Id: spec_vnops.c,v 1.29 1996/03/19 05:13:17 dyson Exp $
|
||||
* $Id: spec_vnops.c,v 1.30 1996/07/27 03:50:31 dyson Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -57,6 +57,7 @@
|
||||
#include <vm/vm_page.h>
|
||||
#include <vm/vm_pager.h>
|
||||
#include <vm/vnode_pager.h>
|
||||
#include <vm/vm_extern.h>
|
||||
|
||||
#include <miscfs/specfs/specdev.h>
|
||||
|
||||
@ -625,9 +626,13 @@ spec_close(ap)
|
||||
* sum of the reference counts on all the aliased
|
||||
* vnodes descends to one, we are on last close.
|
||||
*/
|
||||
if ((vcount(vp) > ((vp->v_flag & VVMIO)?2:1)) &&
|
||||
if ((vcount(vp) > (vp->v_object?2:1)) &&
|
||||
(vp->v_flag & VXLOCK) == 0)
|
||||
return (0);
|
||||
|
||||
if (vp->v_object)
|
||||
vnode_pager_uncache(vp);
|
||||
|
||||
devclose = bdevsw[major(dev)]->d_close;
|
||||
mode = S_IFBLK;
|
||||
break;
|
||||
|
@ -18,7 +18,7 @@
|
||||
* 5. Modifications may be freely made to this file if the above conditions
|
||||
* are met.
|
||||
*
|
||||
* $Id: vfs_bio.c,v 1.94 1996/06/30 05:17:08 davidg Exp $
|
||||
* $Id: vfs_bio.c,v 1.95 1996/08/04 20:13:08 phk Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -113,6 +113,9 @@ static struct bqueues bufqueues[BUFFER_QUEUES];
|
||||
extern int vm_swap_size;
|
||||
|
||||
#define BUF_MAXUSE 8
|
||||
/*
|
||||
#define NO_B_MALLOC
|
||||
*/
|
||||
|
||||
/*
|
||||
* Initialize buffer headers and related structures.
|
||||
@ -844,7 +847,7 @@ getnewbuf(int slpflag, int slptimeo, int doingvmio)
|
||||
bp->b_data = buffers_kva + (bp - buf) * MAXBSIZE;
|
||||
bp->b_dirtyoff = bp->b_dirtyend = 0;
|
||||
bp->b_validoff = bp->b_validend = 0;
|
||||
bp->b_usecount = 2;
|
||||
bp->b_usecount = 4;
|
||||
if (bufspace >= maxbufspace + nbyteswritten) {
|
||||
bp->b_flags |= B_INVAL;
|
||||
brelse(bp);
|
||||
@ -1120,12 +1123,15 @@ allocbuf(struct buf * bp, int size)
|
||||
* Just get anonymous memory from the kernel
|
||||
*/
|
||||
mbsize = (size + DEV_BSIZE - 1) & ~(DEV_BSIZE - 1);
|
||||
#if !defined(NO_B_MALLOC)
|
||||
if (bp->b_flags & B_MALLOC)
|
||||
newbsize = mbsize;
|
||||
else
|
||||
#endif
|
||||
newbsize = round_page(size);
|
||||
|
||||
if (newbsize < bp->b_bufsize) {
|
||||
#if !defined(NO_B_MALLOC)
|
||||
/*
|
||||
* malloced buffers are not shrunk
|
||||
*/
|
||||
@ -1143,11 +1149,13 @@ allocbuf(struct buf * bp, int size)
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
vm_hold_free_pages(
|
||||
bp,
|
||||
(vm_offset_t) bp->b_data + newbsize,
|
||||
(vm_offset_t) bp->b_data + bp->b_bufsize);
|
||||
} else if (newbsize > bp->b_bufsize) {
|
||||
#if !defined(NO_B_MALLOC)
|
||||
/*
|
||||
* We only use malloced memory on the first allocation.
|
||||
* and revert to page-allocated memory when the buffer grows.
|
||||
@ -1164,8 +1172,10 @@ allocbuf(struct buf * bp, int size)
|
||||
bufmallocspace += mbsize;
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
origbuf = NULL;
|
||||
origbufsize = 0;
|
||||
#if !defined(NO_B_MALLOC)
|
||||
/*
|
||||
* If the buffer is growing on it's other-than-first allocation,
|
||||
* then we revert to the page-allocation scheme.
|
||||
@ -1180,14 +1190,17 @@ allocbuf(struct buf * bp, int size)
|
||||
bp->b_flags &= ~B_MALLOC;
|
||||
newbsize = round_page(newbsize);
|
||||
}
|
||||
#endif
|
||||
vm_hold_load_pages(
|
||||
bp,
|
||||
(vm_offset_t) bp->b_data + bp->b_bufsize,
|
||||
(vm_offset_t) bp->b_data + newbsize);
|
||||
#if !defined(NO_B_MALLOC)
|
||||
if (origbuf) {
|
||||
bcopy(origbuf, bp->b_data, origbufsize);
|
||||
free(origbuf, M_BIOBUF);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
} else {
|
||||
vm_page_t m;
|
||||
@ -1196,8 +1209,10 @@ allocbuf(struct buf * bp, int size)
|
||||
newbsize = (size + DEV_BSIZE - 1) & ~(DEV_BSIZE - 1);
|
||||
desiredpages = (round_page(newbsize) >> PAGE_SHIFT);
|
||||
|
||||
#if !defined(NO_B_MALLOC)
|
||||
if (bp->b_flags & B_MALLOC)
|
||||
panic("allocbuf: VMIO buffer can't be malloced");
|
||||
#endif
|
||||
|
||||
if (newbsize < bp->b_bufsize) {
|
||||
if (desiredpages < bp->b_npages) {
|
||||
|
@ -36,7 +36,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)vfs_subr.c 8.13 (Berkeley) 4/18/94
|
||||
* $Id: vfs_subr.c,v 1.57 1996/07/30 18:00:25 bde Exp $
|
||||
* $Id: vfs_subr.c,v 1.58 1996/08/15 06:45:01 dyson Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -65,6 +65,8 @@
|
||||
#include <vm/vm_param.h>
|
||||
#include <vm/vm_object.h>
|
||||
#include <vm/vm_extern.h>
|
||||
#include <vm/vm_pager.h>
|
||||
#include <vm/vnode_pager.h>
|
||||
#include <sys/sysctl.h>
|
||||
|
||||
#include <miscfs/specfs/specdev.h>
|
||||
@ -477,6 +479,8 @@ vinvalbuf(vp, flags, cred, p, slpflag, slptimeo)
|
||||
if (vp->v_dirtyblkhd.lh_first != NULL)
|
||||
panic("vinvalbuf: dirty bufs");
|
||||
}
|
||||
|
||||
s = splbio();
|
||||
for (;;) {
|
||||
if ((blist = vp->v_cleanblkhd.lh_first) && (flags & V_SAVEMETA))
|
||||
while (blist && blist->b_lblkno < 0)
|
||||
@ -492,7 +496,6 @@ vinvalbuf(vp, flags, cred, p, slpflag, slptimeo)
|
||||
nbp = bp->b_vnbufs.le_next;
|
||||
if ((flags & V_SAVEMETA) && bp->b_lblkno < 0)
|
||||
continue;
|
||||
s = splbio();
|
||||
if (bp->b_flags & B_BUSY) {
|
||||
bp->b_flags |= B_WANTED;
|
||||
error = tsleep((caddr_t) bp,
|
||||
@ -505,7 +508,6 @@ vinvalbuf(vp, flags, cred, p, slpflag, slptimeo)
|
||||
}
|
||||
bremfree(bp);
|
||||
bp->b_flags |= B_BUSY;
|
||||
splx(s);
|
||||
/*
|
||||
* XXX Since there are no node locks for NFS, I
|
||||
* believe there is a slight chance that a delayed
|
||||
@ -520,6 +522,7 @@ vinvalbuf(vp, flags, cred, p, slpflag, slptimeo)
|
||||
brelse(bp);
|
||||
}
|
||||
}
|
||||
splx(s);
|
||||
|
||||
s = splbio();
|
||||
while (vp->v_numoutput > 0) {
|
||||
@ -638,7 +641,6 @@ reassignbuf(bp, newvp)
|
||||
register struct buf *bp;
|
||||
register struct vnode *newvp;
|
||||
{
|
||||
register struct buflists *listheadp;
|
||||
int s;
|
||||
|
||||
if (newvp == NULL) {
|
||||
@ -670,8 +672,7 @@ reassignbuf(bp, newvp)
|
||||
LIST_INSERT_AFTER(tbp, bp, b_vnbufs);
|
||||
}
|
||||
} else {
|
||||
listheadp = &newvp->v_cleanblkhd;
|
||||
bufinsvn(bp, listheadp);
|
||||
bufinsvn(bp, &newvp->v_cleanblkhd);
|
||||
}
|
||||
splx(s);
|
||||
}
|
||||
@ -745,6 +746,7 @@ checkalias(nvp, nvp_rdev, mp)
|
||||
goto loop;
|
||||
break;
|
||||
}
|
||||
|
||||
if (vp == NULL || vp->v_tag != VT_NON) {
|
||||
MALLOC(nvp->v_specinfo, struct specinfo *,
|
||||
sizeof(struct specinfo), M_VNODE, M_WAITOK);
|
||||
@ -804,8 +806,18 @@ vget(vp, lockflag)
|
||||
freevnodes--;
|
||||
}
|
||||
vp->v_usecount++;
|
||||
|
||||
/*
|
||||
* Create the VM object, if needed
|
||||
*/
|
||||
if ((vp->v_type == VREG) &&
|
||||
((vp->v_object == NULL) ||
|
||||
(vp->v_object->flags & OBJ_VFS_REF) == 0)) {
|
||||
vfs_object_create(vp, curproc, curproc->p_ucred, 0);
|
||||
}
|
||||
if (lockflag)
|
||||
VOP_LOCK(vp);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
@ -816,9 +828,21 @@ void
|
||||
vref(vp)
|
||||
struct vnode *vp;
|
||||
{
|
||||
|
||||
if (vp->v_usecount <= 0)
|
||||
panic("vref used where vget required");
|
||||
|
||||
if ((vp->v_type == VREG) &&
|
||||
((vp->v_object == NULL) ||
|
||||
((vp->v_object->flags & OBJ_VFS_REF) == 0)) ) {
|
||||
/*
|
||||
* We need to lock to VP during the time that
|
||||
* the object is created. This is necessary to
|
||||
* keep the system from re-entrantly doing it
|
||||
* multiple times.
|
||||
*/
|
||||
vfs_object_create(vp, curproc, curproc->p_ucred, 0);
|
||||
}
|
||||
|
||||
vp->v_usecount++;
|
||||
}
|
||||
|
||||
@ -829,7 +853,6 @@ void
|
||||
vput(vp)
|
||||
register struct vnode *vp;
|
||||
{
|
||||
|
||||
VOP_UNLOCK(vp);
|
||||
vrele(vp);
|
||||
}
|
||||
@ -847,10 +870,21 @@ vrele(vp)
|
||||
if (vp == NULL)
|
||||
panic("vrele: null vp");
|
||||
#endif
|
||||
|
||||
vp->v_usecount--;
|
||||
|
||||
if ((vp->v_usecount == 1) &&
|
||||
vp->v_object &&
|
||||
(vp->v_object->flags & OBJ_VFS_REF)) {
|
||||
vp->v_object->flags &= ~OBJ_VFS_REF;
|
||||
vm_object_deallocate(vp->v_object);
|
||||
return;
|
||||
}
|
||||
|
||||
if (vp->v_usecount > 0)
|
||||
return;
|
||||
if (vp->v_usecount < 0 /* || vp->v_writecount < 0 */ ) {
|
||||
|
||||
if (vp->v_usecount < 0) {
|
||||
#ifdef DIAGNOSTIC
|
||||
vprint("vrele: negative ref count", vp);
|
||||
#endif
|
||||
@ -944,6 +978,11 @@ vflush(mp, skipvp, flags)
|
||||
if ((flags & WRITECLOSE) &&
|
||||
(vp->v_writecount == 0 || vp->v_type != VREG))
|
||||
continue;
|
||||
|
||||
if ((vp->v_usecount == 1) && vp->v_object) {
|
||||
pager_cache(vp->v_object, FALSE);
|
||||
}
|
||||
|
||||
/*
|
||||
* With v_usecount == 0, all we need to do is clear out the
|
||||
* vnode data structures and we are done.
|
||||
@ -1546,8 +1585,62 @@ vfs_msync(struct mount *mp, int flags) {
|
||||
if (VOP_ISLOCKED(vp) && (flags != MNT_WAIT))
|
||||
continue;
|
||||
if (vp->v_object &&
|
||||
(((vm_object_t) vp->v_object)->flags & OBJ_MIGHTBEDIRTY)) {
|
||||
(vp->v_object->flags & OBJ_MIGHTBEDIRTY)) {
|
||||
vm_object_page_clean(vp->v_object, 0, 0, TRUE, TRUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Create the VM object needed for VMIO and mmap support. This
|
||||
* is done for all VREG files in the system. Some filesystems might
|
||||
* afford the additional metadata buffering capability of the
|
||||
* VMIO code by making the device node be VMIO mode also.
|
||||
*/
|
||||
int
|
||||
vfs_object_create(vp, p, cred, waslocked)
|
||||
struct vnode *vp;
|
||||
struct proc *p;
|
||||
struct ucred *cred;
|
||||
int waslocked;
|
||||
{
|
||||
struct vattr vat;
|
||||
vm_object_t object;
|
||||
int error = 0;
|
||||
|
||||
retry:
|
||||
if ((object = vp->v_object) == NULL) {
|
||||
if (vp->v_type == VREG) {
|
||||
if ((error = VOP_GETATTR(vp, &vat, cred, p)) != 0)
|
||||
goto retn;
|
||||
(void) vnode_pager_alloc(vp,
|
||||
OFF_TO_IDX(round_page(vat.va_size)), 0, 0);
|
||||
} else {
|
||||
/*
|
||||
* This simply allocates the biggest object possible
|
||||
* for a VBLK vnode. This should be fixed, but doesn't
|
||||
* cause any problems (yet).
|
||||
*/
|
||||
(void) vnode_pager_alloc(vp, INT_MAX, 0, 0);
|
||||
}
|
||||
vp->v_object->flags |= OBJ_VFS_REF;
|
||||
} else {
|
||||
if (object->flags & OBJ_DEAD) {
|
||||
if (waslocked)
|
||||
VOP_UNLOCK(vp);
|
||||
tsleep(object, PVM, "vodead", 0);
|
||||
if (waslocked)
|
||||
VOP_LOCK(vp);
|
||||
goto retry;
|
||||
}
|
||||
if ((object->flags & OBJ_VFS_REF) == 0) {
|
||||
object->flags |= OBJ_VFS_REF;
|
||||
vm_object_reference(object);
|
||||
}
|
||||
}
|
||||
if (vp->v_object)
|
||||
vp->v_flag |= VVMIO;
|
||||
|
||||
retn:
|
||||
return error;
|
||||
}
|
||||
|
@ -36,7 +36,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)vfs_subr.c 8.13 (Berkeley) 4/18/94
|
||||
* $Id: vfs_subr.c,v 1.57 1996/07/30 18:00:25 bde Exp $
|
||||
* $Id: vfs_subr.c,v 1.58 1996/08/15 06:45:01 dyson Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -65,6 +65,8 @@
|
||||
#include <vm/vm_param.h>
|
||||
#include <vm/vm_object.h>
|
||||
#include <vm/vm_extern.h>
|
||||
#include <vm/vm_pager.h>
|
||||
#include <vm/vnode_pager.h>
|
||||
#include <sys/sysctl.h>
|
||||
|
||||
#include <miscfs/specfs/specdev.h>
|
||||
@ -477,6 +479,8 @@ vinvalbuf(vp, flags, cred, p, slpflag, slptimeo)
|
||||
if (vp->v_dirtyblkhd.lh_first != NULL)
|
||||
panic("vinvalbuf: dirty bufs");
|
||||
}
|
||||
|
||||
s = splbio();
|
||||
for (;;) {
|
||||
if ((blist = vp->v_cleanblkhd.lh_first) && (flags & V_SAVEMETA))
|
||||
while (blist && blist->b_lblkno < 0)
|
||||
@ -492,7 +496,6 @@ vinvalbuf(vp, flags, cred, p, slpflag, slptimeo)
|
||||
nbp = bp->b_vnbufs.le_next;
|
||||
if ((flags & V_SAVEMETA) && bp->b_lblkno < 0)
|
||||
continue;
|
||||
s = splbio();
|
||||
if (bp->b_flags & B_BUSY) {
|
||||
bp->b_flags |= B_WANTED;
|
||||
error = tsleep((caddr_t) bp,
|
||||
@ -505,7 +508,6 @@ vinvalbuf(vp, flags, cred, p, slpflag, slptimeo)
|
||||
}
|
||||
bremfree(bp);
|
||||
bp->b_flags |= B_BUSY;
|
||||
splx(s);
|
||||
/*
|
||||
* XXX Since there are no node locks for NFS, I
|
||||
* believe there is a slight chance that a delayed
|
||||
@ -520,6 +522,7 @@ vinvalbuf(vp, flags, cred, p, slpflag, slptimeo)
|
||||
brelse(bp);
|
||||
}
|
||||
}
|
||||
splx(s);
|
||||
|
||||
s = splbio();
|
||||
while (vp->v_numoutput > 0) {
|
||||
@ -638,7 +641,6 @@ reassignbuf(bp, newvp)
|
||||
register struct buf *bp;
|
||||
register struct vnode *newvp;
|
||||
{
|
||||
register struct buflists *listheadp;
|
||||
int s;
|
||||
|
||||
if (newvp == NULL) {
|
||||
@ -670,8 +672,7 @@ reassignbuf(bp, newvp)
|
||||
LIST_INSERT_AFTER(tbp, bp, b_vnbufs);
|
||||
}
|
||||
} else {
|
||||
listheadp = &newvp->v_cleanblkhd;
|
||||
bufinsvn(bp, listheadp);
|
||||
bufinsvn(bp, &newvp->v_cleanblkhd);
|
||||
}
|
||||
splx(s);
|
||||
}
|
||||
@ -745,6 +746,7 @@ checkalias(nvp, nvp_rdev, mp)
|
||||
goto loop;
|
||||
break;
|
||||
}
|
||||
|
||||
if (vp == NULL || vp->v_tag != VT_NON) {
|
||||
MALLOC(nvp->v_specinfo, struct specinfo *,
|
||||
sizeof(struct specinfo), M_VNODE, M_WAITOK);
|
||||
@ -804,8 +806,18 @@ vget(vp, lockflag)
|
||||
freevnodes--;
|
||||
}
|
||||
vp->v_usecount++;
|
||||
|
||||
/*
|
||||
* Create the VM object, if needed
|
||||
*/
|
||||
if ((vp->v_type == VREG) &&
|
||||
((vp->v_object == NULL) ||
|
||||
(vp->v_object->flags & OBJ_VFS_REF) == 0)) {
|
||||
vfs_object_create(vp, curproc, curproc->p_ucred, 0);
|
||||
}
|
||||
if (lockflag)
|
||||
VOP_LOCK(vp);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
@ -816,9 +828,21 @@ void
|
||||
vref(vp)
|
||||
struct vnode *vp;
|
||||
{
|
||||
|
||||
if (vp->v_usecount <= 0)
|
||||
panic("vref used where vget required");
|
||||
|
||||
if ((vp->v_type == VREG) &&
|
||||
((vp->v_object == NULL) ||
|
||||
((vp->v_object->flags & OBJ_VFS_REF) == 0)) ) {
|
||||
/*
|
||||
* We need to lock to VP during the time that
|
||||
* the object is created. This is necessary to
|
||||
* keep the system from re-entrantly doing it
|
||||
* multiple times.
|
||||
*/
|
||||
vfs_object_create(vp, curproc, curproc->p_ucred, 0);
|
||||
}
|
||||
|
||||
vp->v_usecount++;
|
||||
}
|
||||
|
||||
@ -829,7 +853,6 @@ void
|
||||
vput(vp)
|
||||
register struct vnode *vp;
|
||||
{
|
||||
|
||||
VOP_UNLOCK(vp);
|
||||
vrele(vp);
|
||||
}
|
||||
@ -847,10 +870,21 @@ vrele(vp)
|
||||
if (vp == NULL)
|
||||
panic("vrele: null vp");
|
||||
#endif
|
||||
|
||||
vp->v_usecount--;
|
||||
|
||||
if ((vp->v_usecount == 1) &&
|
||||
vp->v_object &&
|
||||
(vp->v_object->flags & OBJ_VFS_REF)) {
|
||||
vp->v_object->flags &= ~OBJ_VFS_REF;
|
||||
vm_object_deallocate(vp->v_object);
|
||||
return;
|
||||
}
|
||||
|
||||
if (vp->v_usecount > 0)
|
||||
return;
|
||||
if (vp->v_usecount < 0 /* || vp->v_writecount < 0 */ ) {
|
||||
|
||||
if (vp->v_usecount < 0) {
|
||||
#ifdef DIAGNOSTIC
|
||||
vprint("vrele: negative ref count", vp);
|
||||
#endif
|
||||
@ -944,6 +978,11 @@ vflush(mp, skipvp, flags)
|
||||
if ((flags & WRITECLOSE) &&
|
||||
(vp->v_writecount == 0 || vp->v_type != VREG))
|
||||
continue;
|
||||
|
||||
if ((vp->v_usecount == 1) && vp->v_object) {
|
||||
pager_cache(vp->v_object, FALSE);
|
||||
}
|
||||
|
||||
/*
|
||||
* With v_usecount == 0, all we need to do is clear out the
|
||||
* vnode data structures and we are done.
|
||||
@ -1546,8 +1585,62 @@ vfs_msync(struct mount *mp, int flags) {
|
||||
if (VOP_ISLOCKED(vp) && (flags != MNT_WAIT))
|
||||
continue;
|
||||
if (vp->v_object &&
|
||||
(((vm_object_t) vp->v_object)->flags & OBJ_MIGHTBEDIRTY)) {
|
||||
(vp->v_object->flags & OBJ_MIGHTBEDIRTY)) {
|
||||
vm_object_page_clean(vp->v_object, 0, 0, TRUE, TRUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Create the VM object needed for VMIO and mmap support. This
|
||||
* is done for all VREG files in the system. Some filesystems might
|
||||
* afford the additional metadata buffering capability of the
|
||||
* VMIO code by making the device node be VMIO mode also.
|
||||
*/
|
||||
int
|
||||
vfs_object_create(vp, p, cred, waslocked)
|
||||
struct vnode *vp;
|
||||
struct proc *p;
|
||||
struct ucred *cred;
|
||||
int waslocked;
|
||||
{
|
||||
struct vattr vat;
|
||||
vm_object_t object;
|
||||
int error = 0;
|
||||
|
||||
retry:
|
||||
if ((object = vp->v_object) == NULL) {
|
||||
if (vp->v_type == VREG) {
|
||||
if ((error = VOP_GETATTR(vp, &vat, cred, p)) != 0)
|
||||
goto retn;
|
||||
(void) vnode_pager_alloc(vp,
|
||||
OFF_TO_IDX(round_page(vat.va_size)), 0, 0);
|
||||
} else {
|
||||
/*
|
||||
* This simply allocates the biggest object possible
|
||||
* for a VBLK vnode. This should be fixed, but doesn't
|
||||
* cause any problems (yet).
|
||||
*/
|
||||
(void) vnode_pager_alloc(vp, INT_MAX, 0, 0);
|
||||
}
|
||||
vp->v_object->flags |= OBJ_VFS_REF;
|
||||
} else {
|
||||
if (object->flags & OBJ_DEAD) {
|
||||
if (waslocked)
|
||||
VOP_UNLOCK(vp);
|
||||
tsleep(object, PVM, "vodead", 0);
|
||||
if (waslocked)
|
||||
VOP_LOCK(vp);
|
||||
goto retry;
|
||||
}
|
||||
if ((object->flags & OBJ_VFS_REF) == 0) {
|
||||
object->flags |= OBJ_VFS_REF;
|
||||
vm_object_reference(object);
|
||||
}
|
||||
}
|
||||
if (vp->v_object)
|
||||
vp->v_flag |= VVMIO;
|
||||
|
||||
retn:
|
||||
return error;
|
||||
}
|
||||
|
@ -36,7 +36,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)vfs_vnops.c 8.2 (Berkeley) 1/21/94
|
||||
* $Id: vfs_vnops.c,v 1.24 1996/03/02 03:45:05 dyson Exp $
|
||||
* $Id: vfs_vnops.c,v 1.25 1996/03/09 06:42:15 dyson Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -162,12 +162,13 @@ vn_open(ndp, fmode, cmode)
|
||||
if (error)
|
||||
goto bad;
|
||||
/*
|
||||
* this is here for VMIO support
|
||||
* Make sure that a VM object is created for VMIO support.
|
||||
*/
|
||||
if (vp->v_type == VREG) {
|
||||
if ((error = vn_vmio_open(vp, p, cred)) != 0)
|
||||
if ((error = vfs_object_create(vp, p, cred, 1)) != 0)
|
||||
goto bad;
|
||||
}
|
||||
|
||||
if (fmode & FWRITE)
|
||||
vp->v_writecount++;
|
||||
return (0);
|
||||
@ -211,7 +212,7 @@ vn_close(vp, flags, cred, p)
|
||||
if (flags & FWRITE)
|
||||
vp->v_writecount--;
|
||||
error = VOP_CLOSE(vp, flags, cred, p);
|
||||
vn_vmio_close(vp);
|
||||
vrele(vp);
|
||||
return (error);
|
||||
}
|
||||
|
||||
@ -462,55 +463,3 @@ vn_closefile(fp, p)
|
||||
return (vn_close(((struct vnode *)fp->f_data), fp->f_flag,
|
||||
fp->f_cred, p));
|
||||
}
|
||||
|
||||
int
|
||||
vn_vmio_open(vp, p, cred)
|
||||
struct vnode *vp;
|
||||
struct proc *p;
|
||||
struct ucred *cred;
|
||||
{
|
||||
struct vattr vat;
|
||||
int error;
|
||||
/*
|
||||
* this is here for VMIO support
|
||||
*/
|
||||
if (vp->v_type == VREG || vp->v_type == VBLK) {
|
||||
retry:
|
||||
if ((vp->v_flag & VVMIO) == 0) {
|
||||
if ((error = VOP_GETATTR(vp, &vat, cred, p)) != 0)
|
||||
return error;
|
||||
(void) vnode_pager_alloc(vp, OFF_TO_IDX(round_page(vat.va_size)), 0, 0);
|
||||
vp->v_flag |= VVMIO;
|
||||
} else {
|
||||
vm_object_t object;
|
||||
if ((object = vp->v_object) &&
|
||||
(object->flags & OBJ_DEAD)) {
|
||||
VOP_UNLOCK(vp);
|
||||
tsleep(object, PVM, "vodead", 0);
|
||||
VOP_LOCK(vp);
|
||||
goto retry;
|
||||
}
|
||||
if (!object)
|
||||
panic("vn_open: VMIO object missing");
|
||||
vm_object_reference(object);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
vn_vmio_close(vp)
|
||||
struct vnode *vp;
|
||||
{
|
||||
/*
|
||||
* this code is here for VMIO support, will eventually
|
||||
* be in vfs code.
|
||||
*/
|
||||
if (vp->v_flag & VVMIO) {
|
||||
vrele(vp);
|
||||
if (vp->v_object == NULL)
|
||||
panic("vn_close: VMIO object missing");
|
||||
vm_object_deallocate(vp->v_object);
|
||||
} else
|
||||
vrele(vp);
|
||||
}
|
||||
|
@ -31,7 +31,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)spec_vnops.c 8.6 (Berkeley) 4/9/94
|
||||
* $Id: spec_vnops.c,v 1.29 1996/03/19 05:13:17 dyson Exp $
|
||||
* $Id: spec_vnops.c,v 1.30 1996/07/27 03:50:31 dyson Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -57,6 +57,7 @@
|
||||
#include <vm/vm_page.h>
|
||||
#include <vm/vm_pager.h>
|
||||
#include <vm/vnode_pager.h>
|
||||
#include <vm/vm_extern.h>
|
||||
|
||||
#include <miscfs/specfs/specdev.h>
|
||||
|
||||
@ -625,9 +626,13 @@ spec_close(ap)
|
||||
* sum of the reference counts on all the aliased
|
||||
* vnodes descends to one, we are on last close.
|
||||
*/
|
||||
if ((vcount(vp) > ((vp->v_flag & VVMIO)?2:1)) &&
|
||||
if ((vcount(vp) > (vp->v_object?2:1)) &&
|
||||
(vp->v_flag & VXLOCK) == 0)
|
||||
return (0);
|
||||
|
||||
if (vp->v_object)
|
||||
vnode_pager_uncache(vp);
|
||||
|
||||
devclose = bdevsw[major(dev)]->d_close;
|
||||
mode = S_IFBLK;
|
||||
break;
|
||||
|
@ -34,7 +34,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)nfs.h 8.1 (Berkeley) 6/10/93
|
||||
* $Id: nfs.h,v 1.16 1995/12/17 21:12:05 phk Exp $
|
||||
* $Id: nfs.h,v 1.17 1996/01/30 22:59:39 mpp Exp $
|
||||
*/
|
||||
|
||||
#ifndef _NFS_NFS_H_
|
||||
@ -535,9 +535,7 @@ void nfsrv_rcv __P((struct socket *so, caddr_t arg, int waitflag));
|
||||
void nfsrvw_sort __P((gid_t [],int));
|
||||
void nfsrv_setcred __P((struct ucred *,struct ucred *));
|
||||
int nfs_writebp __P((struct buf *,int));
|
||||
int nfsrv_vput __P(( struct vnode * ));
|
||||
int nfsrv_vrele __P(( struct vnode * ));
|
||||
int nfsrv_vmio __P(( struct vnode * ));
|
||||
int nfsrv_object_create __P(( struct vnode * ));
|
||||
void nfsrv_wakenfsd __P((struct nfssvc_sock *slp));
|
||||
int nfsrv_writegather __P((struct nfsrv_descript **, struct nfssvc_sock *,
|
||||
struct proc *, struct mbuf **));
|
||||
|
@ -34,7 +34,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)nfs_subs.c 8.3 (Berkeley) 1/4/94
|
||||
* $Id: nfs_subs.c,v 1.30 1996/06/23 17:19:25 bde Exp $
|
||||
* $Id: nfs_subs.c,v 1.31 1996/07/16 10:19:44 dfr Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -1486,7 +1486,7 @@ nfs_namei(ndp, fhp, len, slp, nam, mdp, dposp, retdirp, p, kerbflag)
|
||||
nam, &rdonly, kerbflag))
|
||||
goto out;
|
||||
if (dp->v_type != VDIR) {
|
||||
nfsrv_vrele(dp);
|
||||
vrele(dp);
|
||||
error = ENOTDIR;
|
||||
goto out;
|
||||
}
|
||||
@ -1517,7 +1517,7 @@ nfs_namei(ndp, fhp, len, slp, nam, mdp, dposp, retdirp, p, kerbflag)
|
||||
goto out;
|
||||
}
|
||||
|
||||
nfsrv_vmio(ndp->ni_vp);
|
||||
nfsrv_object_create(ndp->ni_vp);
|
||||
|
||||
/*
|
||||
* Check for saved name request
|
||||
@ -1748,7 +1748,7 @@ nfsrv_fhtovp(fhp, lockflag, vpp, cred, slp, nam, rdonlyp, kerbflag)
|
||||
else
|
||||
*rdonlyp = 0;
|
||||
|
||||
nfsrv_vmio(*vpp);
|
||||
nfsrv_object_create(*vpp);
|
||||
|
||||
if (!lockflag)
|
||||
VOP_UNLOCK(*vpp);
|
||||
@ -1940,53 +1940,10 @@ nfsrv_errmap(nd, err)
|
||||
}
|
||||
|
||||
int
|
||||
nfsrv_vmio(struct vnode *vp) {
|
||||
vm_object_t object;
|
||||
nfsrv_object_create(struct vnode *vp) {
|
||||
|
||||
if ((vp == NULL) || (vp->v_type != VREG))
|
||||
return 1;
|
||||
|
||||
retry:
|
||||
if ((vp->v_flag & VVMIO) == 0) {
|
||||
struct vattr vat;
|
||||
struct proc *p = curproc;
|
||||
|
||||
if (VOP_GETATTR(vp, &vat, p->p_ucred, p) != 0)
|
||||
panic("nfsrv_vmio: VOP_GETATTR failed");
|
||||
|
||||
(void) vnode_pager_alloc(vp, OFF_TO_IDX(round_page(vat.va_size)), 0, 0);
|
||||
|
||||
vp->v_flag |= VVMIO;
|
||||
} else {
|
||||
if ((object = vp->v_object) &&
|
||||
(object->flags & OBJ_DEAD)) {
|
||||
tsleep(object, PVM, "nfdead", 0);
|
||||
goto retry;
|
||||
}
|
||||
if (!object)
|
||||
panic("nfsrv_vmio: VMIO object missing");
|
||||
vm_object_reference(object);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
int
|
||||
nfsrv_vput(struct vnode *vp) {
|
||||
if ((vp->v_flag & VVMIO) && vp->v_object) {
|
||||
vput(vp);
|
||||
vm_object_deallocate(vp->v_object);
|
||||
} else {
|
||||
vput(vp);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
int
|
||||
nfsrv_vrele(struct vnode *vp) {
|
||||
if ((vp->v_flag & VVMIO) && vp->v_object) {
|
||||
vrele(vp);
|
||||
vm_object_deallocate(vp->v_object);
|
||||
} else {
|
||||
vrele(vp);
|
||||
}
|
||||
return 0;
|
||||
return vfs_object_create(vp, curproc, curproc?curproc->p_ucred:NULL, 1);
|
||||
}
|
||||
#endif /* NFS_NOSERVER */
|
||||
|
@ -34,7 +34,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)nfs_nqlease.c 8.3 (Berkeley) 1/4/94
|
||||
* $Id: nfs_nqlease.c,v 1.18 1995/12/17 21:12:16 phk Exp $
|
||||
* $Id: nfs_nqlease.c,v 1.19 1996/01/13 23:27:43 phk Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -758,13 +758,13 @@ nqnfsrv_getlease(nfsd, slp, procp, mrq)
|
||||
nfsm_reply(0);
|
||||
if (rdonly && flags == ND_WRITE) {
|
||||
error = EROFS;
|
||||
nfsrv_vput(vp);
|
||||
vput(vp);
|
||||
nfsm_reply(0);
|
||||
}
|
||||
(void) nqsrv_getlease(vp, &nfsd->nd_duration, flags, slp, procp,
|
||||
nam, &cache, &frev, cred);
|
||||
error = VOP_GETATTR(vp, vap, cred, procp);
|
||||
nfsrv_vput(vp);
|
||||
vput(vp);
|
||||
nfsm_reply(NFSX_V3FATTR + 4 * NFSX_UNSIGNED);
|
||||
nfsm_build(tl, u_long *, 4 * NFSX_UNSIGNED);
|
||||
*tl++ = txdr_unsigned(cache);
|
||||
|
@ -34,7 +34,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)nfs_serv.c 8.3 (Berkeley) 1/12/94
|
||||
* $Id: nfs_serv.c,v 1.29 1996/04/30 23:23:07 bde Exp $
|
||||
* $Id: nfs_serv.c,v 1.30 1996/06/08 12:16:26 bde Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -165,7 +165,7 @@ nfsrv3_access(nfsd, slp, procp, mrq)
|
||||
nfsrv_access(vp, VEXEC, cred, rdonly, procp))
|
||||
nfsmode &= ~testmode;
|
||||
getret = VOP_GETATTR(vp, vap, cred, procp);
|
||||
nfsrv_vput(vp);
|
||||
vput(vp);
|
||||
nfsm_reply(NFSX_POSTOPATTR(1) + NFSX_UNSIGNED);
|
||||
nfsm_srvpostop_attr(getret, vap);
|
||||
nfsm_build(tl, u_long *, NFSX_UNSIGNED);
|
||||
@ -210,7 +210,7 @@ nfsrv_getattr(nfsd, slp, procp, mrq)
|
||||
}
|
||||
nqsrv_getl(vp, ND_READ);
|
||||
error = VOP_GETATTR(vp, vap, cred, procp);
|
||||
nfsrv_vput(vp);
|
||||
vput(vp);
|
||||
nfsm_reply(NFSX_FATTR(nfsd->nd_flag & ND_NFSV3));
|
||||
if (error)
|
||||
return (0);
|
||||
@ -309,7 +309,7 @@ nfsrv_setattr(nfsd, slp, procp, mrq)
|
||||
preat.va_ctime.ts_nsec != guard.ts_nsec))
|
||||
error = NFSERR_NOT_SYNC;
|
||||
if (error) {
|
||||
nfsrv_vput(vp);
|
||||
vput(vp);
|
||||
nfsm_reply(NFSX_WCCDATA(v3));
|
||||
nfsm_srvwcc_data(preat_ret, &preat, postat_ret, vap);
|
||||
return (0);
|
||||
@ -338,7 +338,7 @@ nfsrv_setattr(nfsd, slp, procp, mrq)
|
||||
if (!error)
|
||||
error = postat_ret;
|
||||
out:
|
||||
nfsrv_vput(vp);
|
||||
vput(vp);
|
||||
nfsm_reply(NFSX_WCCORFATTR(v3));
|
||||
if (v3) {
|
||||
nfsm_srvwcc_data(preat_ret, &preat, postat_ret, vap);
|
||||
@ -392,7 +392,7 @@ nfsrv_lookup(nfsd, slp, procp, mrq)
|
||||
if (v3)
|
||||
dirattr_ret = VOP_GETATTR(dirp, &dirattr, cred,
|
||||
procp);
|
||||
nfsrv_vrele(dirp);
|
||||
vrele(dirp);
|
||||
}
|
||||
if (error) {
|
||||
nfsm_reply(NFSX_POSTOPATTR(v3));
|
||||
@ -400,7 +400,7 @@ nfsrv_lookup(nfsd, slp, procp, mrq)
|
||||
return (0);
|
||||
}
|
||||
nqsrv_getl(nd.ni_startdir, ND_READ);
|
||||
nfsrv_vrele(nd.ni_startdir);
|
||||
vrele(nd.ni_startdir);
|
||||
FREE(nd.ni_cnd.cn_pnbuf, M_NAMEI);
|
||||
vp = nd.ni_vp;
|
||||
bzero((caddr_t)fhp, sizeof(nfh));
|
||||
@ -408,7 +408,7 @@ nfsrv_lookup(nfsd, slp, procp, mrq)
|
||||
error = VFS_VPTOFH(vp, &fhp->fh_fid);
|
||||
if (!error)
|
||||
error = VOP_GETATTR(vp, vap, cred, procp);
|
||||
nfsrv_vput(vp);
|
||||
vput(vp);
|
||||
nfsm_reply(NFSX_SRVFH(v3) + NFSX_POSTOPORFATTR(v3) + NFSX_POSTOPATTR(v3));
|
||||
if (error) {
|
||||
nfsm_srvpostop_attr(dirattr_ret, &dirattr);
|
||||
@ -508,7 +508,7 @@ nfsrv_readlink(nfsd, slp, procp, mrq)
|
||||
error = VOP_READLINK(vp, uiop, cred);
|
||||
out:
|
||||
getret = VOP_GETATTR(vp, &attr, cred, procp);
|
||||
nfsrv_vput(vp);
|
||||
vput(vp);
|
||||
if (error)
|
||||
m_freem(mp3);
|
||||
nfsm_reply(NFSX_POSTOPATTR(v3) + NFSX_UNSIGNED);
|
||||
@ -594,7 +594,7 @@ nfsrv_read(nfsd, slp, procp, mrq)
|
||||
if (!error)
|
||||
error = getret;
|
||||
if (error) {
|
||||
nfsrv_vput(vp);
|
||||
vput(vp);
|
||||
nfsm_reply(NFSX_POSTOPATTR(v3));
|
||||
nfsm_srvpostop_attr(getret, vap);
|
||||
return (0);
|
||||
@ -669,14 +669,14 @@ nfsrv_read(nfsd, slp, procp, mrq)
|
||||
if (!error)
|
||||
error = getret;
|
||||
m_freem(mreq);
|
||||
nfsrv_vput(vp);
|
||||
vput(vp);
|
||||
nfsm_reply(NFSX_POSTOPATTR(v3));
|
||||
nfsm_srvpostop_attr(getret, vap);
|
||||
return (0);
|
||||
}
|
||||
} else
|
||||
uiop->uio_resid = 0;
|
||||
nfsrv_vput(vp);
|
||||
vput(vp);
|
||||
nfsm_srvfillattr(vap, fp);
|
||||
len -= uiop->uio_resid;
|
||||
tlen = nfsm_rndup(len);
|
||||
@ -806,7 +806,7 @@ nfsrv_write(nfsd, slp, procp, mrq)
|
||||
error = nfsrv_access(vp, VWRITE, cred, rdonly, procp);
|
||||
}
|
||||
if (error) {
|
||||
nfsrv_vput(vp);
|
||||
vput(vp);
|
||||
nfsm_reply(NFSX_WCCDATA(v3));
|
||||
nfsm_srvwcc_data(forat_ret, &forat, aftat_ret, vap);
|
||||
return (0);
|
||||
@ -850,7 +850,7 @@ nfsrv_write(nfsd, slp, procp, mrq)
|
||||
FREE((caddr_t)iv, M_TEMP);
|
||||
}
|
||||
aftat_ret = VOP_GETATTR(vp, vap, cred, procp);
|
||||
nfsrv_vput(vp);
|
||||
vput(vp);
|
||||
if (!error)
|
||||
error = aftat_ret;
|
||||
nfsm_reply(NFSX_PREOPATTR(v3) + NFSX_POSTOPORFATTR(v3) +
|
||||
@ -1118,7 +1118,7 @@ nfsrv_writegather(ndp, slp, procp, mrq)
|
||||
m_freem(mrep);
|
||||
if (vp) {
|
||||
aftat_ret = VOP_GETATTR(vp, &va, cred, procp);
|
||||
nfsrv_vput(vp);
|
||||
vput(vp);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1327,7 +1327,7 @@ nfsrv_create(nfsd, slp, procp, mrq)
|
||||
dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred,
|
||||
procp);
|
||||
else {
|
||||
nfsrv_vrele(dirp);
|
||||
vrele(dirp);
|
||||
dirp = (struct vnode *)0;
|
||||
}
|
||||
}
|
||||
@ -1335,7 +1335,7 @@ nfsrv_create(nfsd, slp, procp, mrq)
|
||||
nfsm_reply(NFSX_WCCDATA(v3));
|
||||
nfsm_srvwcc_data(dirfor_ret, &dirfor, diraft_ret, &diraft);
|
||||
if (dirp)
|
||||
nfsrv_vrele(dirp);
|
||||
vrele(dirp);
|
||||
return (0);
|
||||
}
|
||||
VATTR_NULL(vap);
|
||||
@ -1387,11 +1387,11 @@ nfsrv_create(nfsd, slp, procp, mrq)
|
||||
*/
|
||||
if (nd.ni_vp == NULL) {
|
||||
if (vap->va_type == VREG || vap->va_type == VSOCK) {
|
||||
nfsrv_vrele(nd.ni_startdir);
|
||||
vrele(nd.ni_startdir);
|
||||
nqsrv_getl(nd.ni_dvp, ND_WRITE);
|
||||
error = VOP_CREATE(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, vap);
|
||||
if (!error) {
|
||||
nfsrv_vmio(nd.ni_vp);
|
||||
nfsrv_object_create(nd.ni_vp);
|
||||
FREE(nd.ni_cnd.cn_pnbuf, M_NAMEI);
|
||||
if (exclusive_flag) {
|
||||
exclusive_flag = 0;
|
||||
@ -1407,17 +1407,17 @@ nfsrv_create(nfsd, slp, procp, mrq)
|
||||
if (vap->va_type == VCHR && rdev == 0xffffffff)
|
||||
vap->va_type = VFIFO;
|
||||
if (error = suser(cred, (u_short *)0)) {
|
||||
nfsrv_vrele(nd.ni_startdir);
|
||||
vrele(nd.ni_startdir);
|
||||
free(nd.ni_cnd.cn_pnbuf, M_NAMEI);
|
||||
VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
|
||||
nfsrv_vput(nd.ni_dvp);
|
||||
vput(nd.ni_dvp);
|
||||
nfsm_reply(0);
|
||||
return (error);
|
||||
} else
|
||||
vap->va_rdev = (dev_t)rdev;
|
||||
nqsrv_getl(nd.ni_dvp, ND_WRITE);
|
||||
if (error = VOP_MKNOD(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, vap)) {
|
||||
nfsrv_vrele(nd.ni_startdir);
|
||||
vrele(nd.ni_startdir);
|
||||
nfsm_reply(0);
|
||||
}
|
||||
nd.ni_cnd.cn_nameiop = LOOKUP;
|
||||
@ -1428,31 +1428,31 @@ nfsrv_create(nfsd, slp, procp, mrq)
|
||||
free(nd.ni_cnd.cn_pnbuf, M_NAMEI);
|
||||
nfsm_reply(0);
|
||||
}
|
||||
nfsrv_vmio(nd.ni_vp);
|
||||
nfsrv_object_create(nd.ni_vp);
|
||||
FREE(nd.ni_cnd.cn_pnbuf, M_NAMEI);
|
||||
if (nd.ni_cnd.cn_flags & ISSYMLINK) {
|
||||
nfsrv_vrele(nd.ni_dvp);
|
||||
nfsrv_vput(nd.ni_vp);
|
||||
vrele(nd.ni_dvp);
|
||||
vput(nd.ni_vp);
|
||||
VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
|
||||
error = EINVAL;
|
||||
nfsm_reply(0);
|
||||
}
|
||||
} else {
|
||||
nfsrv_vrele(nd.ni_startdir);
|
||||
vrele(nd.ni_startdir);
|
||||
free(nd.ni_cnd.cn_pnbuf, M_NAMEI);
|
||||
VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
|
||||
nfsrv_vput(nd.ni_dvp);
|
||||
vput(nd.ni_dvp);
|
||||
error = ENXIO;
|
||||
}
|
||||
vp = nd.ni_vp;
|
||||
} else {
|
||||
nfsrv_vrele(nd.ni_startdir);
|
||||
vrele(nd.ni_startdir);
|
||||
free(nd.ni_cnd.cn_pnbuf, M_NAMEI);
|
||||
vp = nd.ni_vp;
|
||||
if (nd.ni_dvp == vp)
|
||||
nfsrv_vrele(nd.ni_dvp);
|
||||
vrele(nd.ni_dvp);
|
||||
else
|
||||
nfsrv_vput(nd.ni_dvp);
|
||||
vput(nd.ni_dvp);
|
||||
VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
|
||||
if (vap->va_size != -1) {
|
||||
error = nfsrv_access(vp, VWRITE, cred,
|
||||
@ -1466,7 +1466,7 @@ nfsrv_create(nfsd, slp, procp, mrq)
|
||||
procp);
|
||||
}
|
||||
if (error)
|
||||
nfsrv_vput(vp);
|
||||
vput(vp);
|
||||
}
|
||||
}
|
||||
if (!error) {
|
||||
@ -1475,14 +1475,14 @@ nfsrv_create(nfsd, slp, procp, mrq)
|
||||
error = VFS_VPTOFH(vp, &fhp->fh_fid);
|
||||
if (!error)
|
||||
error = VOP_GETATTR(vp, vap, cred, procp);
|
||||
nfsrv_vput(vp);
|
||||
vput(vp);
|
||||
}
|
||||
if (v3) {
|
||||
if (exclusive_flag && !error &&
|
||||
bcmp(cverf, (caddr_t)&vap->va_atime, NFSX_V3CREATEVERF))
|
||||
error = EEXIST;
|
||||
diraft_ret = VOP_GETATTR(dirp, &diraft, cred, procp);
|
||||
nfsrv_vrele(dirp);
|
||||
vrele(dirp);
|
||||
}
|
||||
nfsm_reply(NFSX_SRVFH(v3) + NFSX_FATTR(v3) + NFSX_WCCDATA(v3));
|
||||
if (v3) {
|
||||
@ -1499,18 +1499,18 @@ nfsrv_create(nfsd, slp, procp, mrq)
|
||||
return (0);
|
||||
nfsmout:
|
||||
if (dirp)
|
||||
nfsrv_vrele(dirp);
|
||||
vrele(dirp);
|
||||
if (nd.ni_cnd.cn_nameiop) {
|
||||
nfsrv_vrele(nd.ni_startdir);
|
||||
vrele(nd.ni_startdir);
|
||||
free((caddr_t)nd.ni_cnd.cn_pnbuf, M_NAMEI);
|
||||
}
|
||||
VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
|
||||
if (nd.ni_dvp == nd.ni_vp)
|
||||
nfsrv_vrele(nd.ni_dvp);
|
||||
vrele(nd.ni_dvp);
|
||||
else
|
||||
nfsrv_vput(nd.ni_dvp);
|
||||
vput(nd.ni_dvp);
|
||||
if (nd.ni_vp)
|
||||
nfsrv_vput(nd.ni_vp);
|
||||
vput(nd.ni_vp);
|
||||
return (error);
|
||||
}
|
||||
|
||||
@ -1559,17 +1559,17 @@ nfsrv_mknod(nfsd, slp, procp, mrq)
|
||||
nfsm_reply(NFSX_WCCDATA(1));
|
||||
nfsm_srvwcc_data(dirfor_ret, &dirfor, diraft_ret, &diraft);
|
||||
if (dirp)
|
||||
nfsrv_vrele(dirp);
|
||||
vrele(dirp);
|
||||
return (0);
|
||||
}
|
||||
nfsm_dissect(tl, u_long *, NFSX_UNSIGNED);
|
||||
vtyp = nfsv3tov_type(*tl);
|
||||
if (vtyp != VCHR && vtyp != VBLK && vtyp != VSOCK && vtyp != VFIFO) {
|
||||
nfsrv_vrele(nd.ni_startdir);
|
||||
vrele(nd.ni_startdir);
|
||||
free((caddr_t)nd.ni_cnd.cn_pnbuf, M_NAMEI);
|
||||
error = NFSERR_BADTYPE;
|
||||
VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
|
||||
nfsrv_vput(nd.ni_dvp);
|
||||
vput(nd.ni_dvp);
|
||||
goto out;
|
||||
}
|
||||
VATTR_NULL(vap);
|
||||
@ -1585,31 +1585,31 @@ nfsrv_mknod(nfsd, slp, procp, mrq)
|
||||
* Iff doesn't exist, create it.
|
||||
*/
|
||||
if (nd.ni_vp) {
|
||||
nfsrv_vrele(nd.ni_startdir);
|
||||
vrele(nd.ni_startdir);
|
||||
free((caddr_t)nd.ni_cnd.cn_pnbuf, M_NAMEI);
|
||||
error = EEXIST;
|
||||
VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
|
||||
nfsrv_vput(nd.ni_dvp);
|
||||
vput(nd.ni_dvp);
|
||||
goto out;
|
||||
}
|
||||
vap->va_type = vtyp;
|
||||
if (vtyp == VSOCK) {
|
||||
nfsrv_vrele(nd.ni_startdir);
|
||||
vrele(nd.ni_startdir);
|
||||
nqsrv_getl(nd.ni_dvp, ND_WRITE);
|
||||
error = VOP_CREATE(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, vap);
|
||||
if (!error)
|
||||
FREE(nd.ni_cnd.cn_pnbuf, M_NAMEI);
|
||||
} else {
|
||||
if (error = suser(cred, (u_short *)0)) {
|
||||
nfsrv_vrele(nd.ni_startdir);
|
||||
vrele(nd.ni_startdir);
|
||||
free((caddr_t)nd.ni_cnd.cn_pnbuf, M_NAMEI);
|
||||
VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
|
||||
nfsrv_vput(nd.ni_dvp);
|
||||
vput(nd.ni_dvp);
|
||||
goto out;
|
||||
}
|
||||
nqsrv_getl(nd.ni_dvp, ND_WRITE);
|
||||
if (error = VOP_MKNOD(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, vap)) {
|
||||
nfsrv_vrele(nd.ni_startdir);
|
||||
vrele(nd.ni_startdir);
|
||||
goto out;
|
||||
}
|
||||
nd.ni_cnd.cn_nameiop = LOOKUP;
|
||||
@ -1621,8 +1621,8 @@ nfsrv_mknod(nfsd, slp, procp, mrq)
|
||||
if (error)
|
||||
goto out;
|
||||
if (nd.ni_cnd.cn_flags & ISSYMLINK) {
|
||||
nfsrv_vrele(nd.ni_dvp);
|
||||
nfsrv_vput(nd.ni_vp);
|
||||
vrele(nd.ni_dvp);
|
||||
vput(nd.ni_vp);
|
||||
VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
|
||||
error = EINVAL;
|
||||
}
|
||||
@ -1635,10 +1635,10 @@ nfsrv_mknod(nfsd, slp, procp, mrq)
|
||||
error = VFS_VPTOFH(vp, &fhp->fh_fid);
|
||||
if (!error)
|
||||
error = VOP_GETATTR(vp, vap, cred, procp);
|
||||
nfsrv_vput(vp);
|
||||
vput(vp);
|
||||
}
|
||||
diraft_ret = VOP_GETATTR(dirp, &diraft, cred, procp);
|
||||
nfsrv_vrele(dirp);
|
||||
vrele(dirp);
|
||||
nfsm_reply(NFSX_SRVFH(1) + NFSX_POSTOPATTR(1) + NFSX_WCCDATA(1));
|
||||
if (!error) {
|
||||
nfsm_srvpostop_fh(fhp);
|
||||
@ -1648,18 +1648,18 @@ nfsrv_mknod(nfsd, slp, procp, mrq)
|
||||
return (0);
|
||||
nfsmout:
|
||||
if (dirp)
|
||||
nfsrv_vrele(dirp);
|
||||
vrele(dirp);
|
||||
if (nd.ni_cnd.cn_nameiop) {
|
||||
nfsrv_vrele(nd.ni_startdir);
|
||||
vrele(nd.ni_startdir);
|
||||
free((caddr_t)nd.ni_cnd.cn_pnbuf, M_NAMEI);
|
||||
}
|
||||
VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
|
||||
if (nd.ni_dvp == nd.ni_vp)
|
||||
nfsrv_vrele(nd.ni_dvp);
|
||||
vrele(nd.ni_dvp);
|
||||
else
|
||||
nfsrv_vput(nd.ni_dvp);
|
||||
vput(nd.ni_dvp);
|
||||
if (nd.ni_vp)
|
||||
nfsrv_vput(nd.ni_vp);
|
||||
vput(nd.ni_vp);
|
||||
return (error);
|
||||
}
|
||||
|
||||
@ -1707,7 +1707,7 @@ nfsrv_remove(nfsd, slp, procp, mrq)
|
||||
dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred,
|
||||
procp);
|
||||
else
|
||||
nfsrv_vrele(dirp);
|
||||
vrele(dirp);
|
||||
}
|
||||
if (!error) {
|
||||
vp = nd.ni_vp;
|
||||
@ -1721,30 +1721,26 @@ nfsrv_remove(nfsd, slp, procp, mrq)
|
||||
error = EBUSY;
|
||||
goto out;
|
||||
}
|
||||
vnode_pager_uncache(vp);
|
||||
out:
|
||||
if (!error) {
|
||||
int deallocobj = 0;
|
||||
vnode_pager_uncache(vp);
|
||||
nqsrv_getl(nd.ni_dvp, ND_WRITE);
|
||||
nqsrv_getl(vp, ND_WRITE);
|
||||
|
||||
if ((vp->v_flag & VVMIO) && vp->v_object)
|
||||
deallocobj = 1;
|
||||
error = VOP_REMOVE(nd.ni_dvp, nd.ni_vp, &nd.ni_cnd);
|
||||
if (error == 0 && deallocobj)
|
||||
vm_object_deallocate(vp->v_object);
|
||||
|
||||
} else {
|
||||
VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
|
||||
if (nd.ni_dvp == vp)
|
||||
nfsrv_vrele(nd.ni_dvp);
|
||||
vrele(nd.ni_dvp);
|
||||
else
|
||||
nfsrv_vput(nd.ni_dvp);
|
||||
nfsrv_vput(vp);
|
||||
vput(nd.ni_dvp);
|
||||
vput(vp);
|
||||
}
|
||||
}
|
||||
if (dirp && v3) {
|
||||
diraft_ret = VOP_GETATTR(dirp, &diraft, cred, procp);
|
||||
nfsrv_vrele(dirp);
|
||||
vrele(dirp);
|
||||
}
|
||||
nfsm_reply(NFSX_WCCDATA(v3));
|
||||
if (v3) {
|
||||
@ -1809,7 +1805,7 @@ nfsrv_rename(nfsd, slp, procp, mrq)
|
||||
fdirfor_ret = VOP_GETATTR(fdirp, &fdirfor, cred,
|
||||
procp);
|
||||
else {
|
||||
nfsrv_vrele(fdirp);
|
||||
vrele(fdirp);
|
||||
fdirp = (struct vnode *)0;
|
||||
}
|
||||
}
|
||||
@ -1818,7 +1814,7 @@ nfsrv_rename(nfsd, slp, procp, mrq)
|
||||
nfsm_srvwcc_data(fdirfor_ret, &fdirfor, fdiraft_ret, &fdiraft);
|
||||
nfsm_srvwcc_data(tdirfor_ret, &tdirfor, tdiraft_ret, &tdiraft);
|
||||
if (fdirp)
|
||||
nfsrv_vrele(fdirp);
|
||||
vrele(fdirp);
|
||||
return (0);
|
||||
}
|
||||
fvp = fromnd.ni_vp;
|
||||
@ -1835,14 +1831,14 @@ nfsrv_rename(nfsd, slp, procp, mrq)
|
||||
tdirfor_ret = VOP_GETATTR(tdirp, &tdirfor, cred,
|
||||
procp);
|
||||
else {
|
||||
nfsrv_vrele(tdirp);
|
||||
vrele(tdirp);
|
||||
tdirp = (struct vnode *)0;
|
||||
}
|
||||
}
|
||||
if (error) {
|
||||
VOP_ABORTOP(fromnd.ni_dvp, &fromnd.ni_cnd);
|
||||
nfsrv_vrele(fromnd.ni_dvp);
|
||||
nfsrv_vrele(fvp);
|
||||
vrele(fromnd.ni_dvp);
|
||||
vrele(fvp);
|
||||
goto out1;
|
||||
}
|
||||
tdvp = tond.ni_dvp;
|
||||
@ -1900,50 +1896,40 @@ nfsrv_rename(nfsd, slp, procp, mrq)
|
||||
error = -1;
|
||||
out:
|
||||
if (!error) {
|
||||
int deallocobjfrom = 0, deallocobjto = 0;
|
||||
nqsrv_getl(fromnd.ni_dvp, ND_WRITE);
|
||||
nqsrv_getl(tdvp, ND_WRITE);
|
||||
if (tvp) {
|
||||
nqsrv_getl(tvp, ND_WRITE);
|
||||
if ((tvp->v_flag & VVMIO) && tvp->v_object)
|
||||
deallocobjto = 1;
|
||||
(void) vnode_pager_uncache(tvp);
|
||||
}
|
||||
if ((fvp->v_flag & VVMIO) && fvp->v_object)
|
||||
deallocobjfrom = 1;
|
||||
error = VOP_RENAME(fromnd.ni_dvp, fromnd.ni_vp, &fromnd.ni_cnd,
|
||||
tond.ni_dvp, tond.ni_vp, &tond.ni_cnd);
|
||||
if (deallocobjfrom)
|
||||
vm_object_deallocate(fvp->v_object);
|
||||
if (deallocobjto)
|
||||
vm_object_deallocate(tvp->v_object);
|
||||
|
||||
} else {
|
||||
VOP_ABORTOP(tond.ni_dvp, &tond.ni_cnd);
|
||||
if (tdvp == tvp)
|
||||
nfsrv_vrele(tdvp);
|
||||
vrele(tdvp);
|
||||
else
|
||||
nfsrv_vput(tdvp);
|
||||
vput(tdvp);
|
||||
if (tvp)
|
||||
nfsrv_vput(tvp);
|
||||
vput(tvp);
|
||||
VOP_ABORTOP(fromnd.ni_dvp, &fromnd.ni_cnd);
|
||||
nfsrv_vrele(fromnd.ni_dvp);
|
||||
nfsrv_vrele(fvp);
|
||||
vrele(fromnd.ni_dvp);
|
||||
vrele(fvp);
|
||||
if (error == -1)
|
||||
error = 0;
|
||||
}
|
||||
nfsrv_vrele(tond.ni_startdir);
|
||||
vrele(tond.ni_startdir);
|
||||
FREE(tond.ni_cnd.cn_pnbuf, M_NAMEI);
|
||||
out1:
|
||||
if (fdirp) {
|
||||
fdiraft_ret = VOP_GETATTR(fdirp, &fdiraft, cred, procp);
|
||||
nfsrv_vrele(fdirp);
|
||||
vrele(fdirp);
|
||||
}
|
||||
if (tdirp) {
|
||||
tdiraft_ret = VOP_GETATTR(tdirp, &tdiraft, cred, procp);
|
||||
nfsrv_vrele(tdirp);
|
||||
vrele(tdirp);
|
||||
}
|
||||
nfsrv_vrele(fromnd.ni_startdir);
|
||||
vrele(fromnd.ni_startdir);
|
||||
FREE(fromnd.ni_cnd.cn_pnbuf, M_NAMEI);
|
||||
nfsm_reply(2 * NFSX_WCCDATA(v3));
|
||||
if (v3) {
|
||||
@ -1954,19 +1940,19 @@ nfsrv_rename(nfsd, slp, procp, mrq)
|
||||
|
||||
nfsmout:
|
||||
if (fdirp)
|
||||
nfsrv_vrele(fdirp);
|
||||
vrele(fdirp);
|
||||
if (tdirp)
|
||||
nfsrv_vrele(tdirp);
|
||||
vrele(tdirp);
|
||||
if (tond.ni_cnd.cn_nameiop) {
|
||||
nfsrv_vrele(tond.ni_startdir);
|
||||
vrele(tond.ni_startdir);
|
||||
FREE(tond.ni_cnd.cn_pnbuf, M_NAMEI);
|
||||
}
|
||||
if (fromnd.ni_cnd.cn_nameiop) {
|
||||
nfsrv_vrele(fromnd.ni_startdir);
|
||||
vrele(fromnd.ni_startdir);
|
||||
FREE(fromnd.ni_cnd.cn_pnbuf, M_NAMEI);
|
||||
VOP_ABORTOP(fromnd.ni_dvp, &fromnd.ni_cnd);
|
||||
nfsrv_vrele(fromnd.ni_dvp);
|
||||
nfsrv_vrele(fvp);
|
||||
vrele(fromnd.ni_dvp);
|
||||
vrele(fvp);
|
||||
}
|
||||
return (error);
|
||||
}
|
||||
@ -2023,7 +2009,7 @@ nfsrv_link(nfsd, slp, procp, mrq)
|
||||
dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred,
|
||||
procp);
|
||||
else {
|
||||
nfsrv_vrele(dirp);
|
||||
vrele(dirp);
|
||||
dirp = (struct vnode *)0;
|
||||
}
|
||||
}
|
||||
@ -2049,20 +2035,20 @@ nfsrv_link(nfsd, slp, procp, mrq)
|
||||
} else {
|
||||
VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
|
||||
if (nd.ni_dvp == nd.ni_vp)
|
||||
nfsrv_vrele(nd.ni_dvp);
|
||||
vrele(nd.ni_dvp);
|
||||
else
|
||||
nfsrv_vput(nd.ni_dvp);
|
||||
vput(nd.ni_dvp);
|
||||
if (nd.ni_vp)
|
||||
nfsrv_vrele(nd.ni_vp);
|
||||
vrele(nd.ni_vp);
|
||||
}
|
||||
out1:
|
||||
if (v3)
|
||||
getret = VOP_GETATTR(vp, &at, cred, procp);
|
||||
if (dirp) {
|
||||
diraft_ret = VOP_GETATTR(dirp, &diraft, cred, procp);
|
||||
nfsrv_vrele(dirp);
|
||||
vrele(dirp);
|
||||
}
|
||||
nfsrv_vrele(vp);
|
||||
vrele(vp);
|
||||
nfsm_reply(NFSX_POSTOPATTR(v3) + NFSX_WCCDATA(v3));
|
||||
if (v3) {
|
||||
nfsm_srvpostop_attr(getret, &at);
|
||||
@ -2087,7 +2073,6 @@ nfsrv_symlink(nfsd, slp, procp, mrq)
|
||||
caddr_t dpos = nfsd->nd_dpos;
|
||||
struct ucred *cred = &nfsd->nd_cr;
|
||||
struct vattr va, dirfor, diraft;
|
||||
struct vnode *ovp;
|
||||
struct nameidata nd;
|
||||
register struct vattr *vap = &va;
|
||||
register u_long *tl;
|
||||
@ -2103,7 +2088,6 @@ nfsrv_symlink(nfsd, slp, procp, mrq)
|
||||
nfsfh_t nfh;
|
||||
fhandle_t *fhp;
|
||||
u_quad_t frev;
|
||||
int deallocobj = 0;
|
||||
|
||||
nd.ni_cnd.cn_nameiop = 0;
|
||||
fhp = &nfh.fh_generic;
|
||||
@ -2119,7 +2103,7 @@ nfsrv_symlink(nfsd, slp, procp, mrq)
|
||||
dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred,
|
||||
procp);
|
||||
else {
|
||||
nfsrv_vrele(dirp);
|
||||
vrele(dirp);
|
||||
dirp = (struct vnode *)0;
|
||||
}
|
||||
}
|
||||
@ -2146,25 +2130,21 @@ nfsrv_symlink(nfsd, slp, procp, mrq)
|
||||
}
|
||||
*(pathcp + len2) = '\0';
|
||||
if (nd.ni_vp) {
|
||||
nfsrv_vrele(nd.ni_startdir);
|
||||
vrele(nd.ni_startdir);
|
||||
free(nd.ni_cnd.cn_pnbuf, M_NAMEI);
|
||||
VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
|
||||
if (nd.ni_dvp == nd.ni_vp)
|
||||
nfsrv_vrele(nd.ni_dvp);
|
||||
vrele(nd.ni_dvp);
|
||||
else
|
||||
nfsrv_vput(nd.ni_dvp);
|
||||
nfsrv_vrele(nd.ni_vp);
|
||||
vput(nd.ni_dvp);
|
||||
vrele(nd.ni_vp);
|
||||
error = EEXIST;
|
||||
goto out;
|
||||
}
|
||||
nqsrv_getl(nd.ni_dvp, ND_WRITE);
|
||||
if ((ovp = nd.ni_vp) && (ovp->v_flag & VVMIO) && ovp->v_object)
|
||||
deallocobj = 1;
|
||||
error = VOP_SYMLINK(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, vap, pathcp);
|
||||
if (error == 0 && deallocobj)
|
||||
vm_object_deallocate(ovp->v_object);
|
||||
if (error)
|
||||
nfsrv_vrele(nd.ni_startdir);
|
||||
vrele(nd.ni_startdir);
|
||||
else {
|
||||
if (v3) {
|
||||
nd.ni_cnd.cn_nameiop = LOOKUP;
|
||||
@ -2180,10 +2160,10 @@ nfsrv_symlink(nfsd, slp, procp, mrq)
|
||||
if (!error)
|
||||
error = VOP_GETATTR(nd.ni_vp, vap, cred,
|
||||
procp);
|
||||
nfsrv_vput(nd.ni_vp);
|
||||
vput(nd.ni_vp);
|
||||
}
|
||||
} else
|
||||
nfsrv_vrele(nd.ni_startdir);
|
||||
vrele(nd.ni_startdir);
|
||||
FREE(nd.ni_cnd.cn_pnbuf, M_NAMEI);
|
||||
}
|
||||
out:
|
||||
@ -2191,7 +2171,7 @@ nfsrv_symlink(nfsd, slp, procp, mrq)
|
||||
FREE(pathcp, M_TEMP);
|
||||
if (dirp) {
|
||||
diraft_ret = VOP_GETATTR(dirp, &diraft, cred, procp);
|
||||
nfsrv_vrele(dirp);
|
||||
vrele(dirp);
|
||||
}
|
||||
nfsm_reply(NFSX_SRVFH(v3) + NFSX_POSTOPATTR(v3) + NFSX_WCCDATA(v3));
|
||||
if (v3) {
|
||||
@ -2204,18 +2184,18 @@ nfsrv_symlink(nfsd, slp, procp, mrq)
|
||||
return (0);
|
||||
nfsmout:
|
||||
if (nd.ni_cnd.cn_nameiop) {
|
||||
nfsrv_vrele(nd.ni_startdir);
|
||||
vrele(nd.ni_startdir);
|
||||
free(nd.ni_cnd.cn_pnbuf, M_NAMEI);
|
||||
}
|
||||
if (dirp)
|
||||
nfsrv_vrele(dirp);
|
||||
vrele(dirp);
|
||||
VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
|
||||
if (nd.ni_dvp == nd.ni_vp)
|
||||
nfsrv_vrele(nd.ni_dvp);
|
||||
vrele(nd.ni_dvp);
|
||||
else
|
||||
nfsrv_vput(nd.ni_dvp);
|
||||
vput(nd.ni_dvp);
|
||||
if (nd.ni_vp)
|
||||
nfsrv_vrele(nd.ni_vp);
|
||||
vrele(nd.ni_vp);
|
||||
if (pathcp)
|
||||
FREE(pathcp, M_TEMP);
|
||||
return (error);
|
||||
@ -2265,7 +2245,7 @@ nfsrv_mkdir(nfsd, slp, procp, mrq)
|
||||
dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred,
|
||||
procp);
|
||||
else {
|
||||
nfsrv_vrele(dirp);
|
||||
vrele(dirp);
|
||||
dirp = (struct vnode *)0;
|
||||
}
|
||||
}
|
||||
@ -2273,7 +2253,7 @@ nfsrv_mkdir(nfsd, slp, procp, mrq)
|
||||
nfsm_reply(NFSX_WCCDATA(v3));
|
||||
nfsm_srvwcc_data(dirfor_ret, &dirfor, diraft_ret, &diraft);
|
||||
if (dirp)
|
||||
nfsrv_vrele(dirp);
|
||||
vrele(dirp);
|
||||
return (0);
|
||||
}
|
||||
VATTR_NULL(vap);
|
||||
@ -2288,10 +2268,10 @@ nfsrv_mkdir(nfsd, slp, procp, mrq)
|
||||
if (vp != NULL) {
|
||||
VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
|
||||
if (nd.ni_dvp == vp)
|
||||
nfsrv_vrele(nd.ni_dvp);
|
||||
vrele(nd.ni_dvp);
|
||||
else
|
||||
nfsrv_vput(nd.ni_dvp);
|
||||
nfsrv_vrele(vp);
|
||||
vput(nd.ni_dvp);
|
||||
vrele(vp);
|
||||
error = EEXIST;
|
||||
goto out;
|
||||
}
|
||||
@ -2304,12 +2284,12 @@ nfsrv_mkdir(nfsd, slp, procp, mrq)
|
||||
error = VFS_VPTOFH(vp, &fhp->fh_fid);
|
||||
if (!error)
|
||||
error = VOP_GETATTR(vp, vap, cred, procp);
|
||||
nfsrv_vput(vp);
|
||||
vput(vp);
|
||||
}
|
||||
out:
|
||||
if (dirp) {
|
||||
diraft_ret = VOP_GETATTR(dirp, &diraft, cred, procp);
|
||||
nfsrv_vrele(dirp);
|
||||
vrele(dirp);
|
||||
}
|
||||
nfsm_reply(NFSX_SRVFH(v3) + NFSX_POSTOPATTR(v3) + NFSX_WCCDATA(v3));
|
||||
if (v3) {
|
||||
@ -2326,14 +2306,14 @@ nfsrv_mkdir(nfsd, slp, procp, mrq)
|
||||
return (0);
|
||||
nfsmout:
|
||||
if (dirp)
|
||||
nfsrv_vrele(dirp);
|
||||
vrele(dirp);
|
||||
VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
|
||||
if (nd.ni_dvp == nd.ni_vp)
|
||||
nfsrv_vrele(nd.ni_dvp);
|
||||
vrele(nd.ni_dvp);
|
||||
else
|
||||
nfsrv_vput(nd.ni_dvp);
|
||||
vput(nd.ni_dvp);
|
||||
if (nd.ni_vp)
|
||||
nfsrv_vrele(nd.ni_vp);
|
||||
vrele(nd.ni_vp);
|
||||
return (error);
|
||||
}
|
||||
|
||||
@ -2378,7 +2358,7 @@ nfsrv_rmdir(nfsd, slp, procp, mrq)
|
||||
dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred,
|
||||
procp);
|
||||
else {
|
||||
nfsrv_vrele(dirp);
|
||||
vrele(dirp);
|
||||
dirp = (struct vnode *)0;
|
||||
}
|
||||
}
|
||||
@ -2386,7 +2366,7 @@ nfsrv_rmdir(nfsd, slp, procp, mrq)
|
||||
nfsm_reply(NFSX_WCCDATA(v3));
|
||||
nfsm_srvwcc_data(dirfor_ret, &dirfor, diraft_ret, &diraft);
|
||||
if (dirp)
|
||||
nfsrv_vrele(dirp);
|
||||
vrele(dirp);
|
||||
return (0);
|
||||
}
|
||||
vp = nd.ni_vp;
|
||||
@ -2414,14 +2394,14 @@ nfsrv_rmdir(nfsd, slp, procp, mrq)
|
||||
} else {
|
||||
VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
|
||||
if (nd.ni_dvp == nd.ni_vp)
|
||||
nfsrv_vrele(nd.ni_dvp);
|
||||
vrele(nd.ni_dvp);
|
||||
else
|
||||
nfsrv_vput(nd.ni_dvp);
|
||||
nfsrv_vput(vp);
|
||||
vput(nd.ni_dvp);
|
||||
vput(vp);
|
||||
}
|
||||
if (dirp) {
|
||||
diraft_ret = VOP_GETATTR(dirp, &diraft, cred, procp);
|
||||
nfsrv_vrele(dirp);
|
||||
vrele(dirp);
|
||||
}
|
||||
nfsm_reply(NFSX_WCCDATA(v3));
|
||||
if (v3) {
|
||||
@ -2535,7 +2515,7 @@ nfsrv_readdir(nfsd, slp, procp, mrq)
|
||||
if (!error)
|
||||
error = nfsrv_access(vp, VEXEC, cred, rdonly, procp);
|
||||
if (error) {
|
||||
nfsrv_vput(vp);
|
||||
vput(vp);
|
||||
nfsm_reply(NFSX_POSTOPATTR(v3));
|
||||
nfsm_srvpostop_attr(getret, &at);
|
||||
return (0);
|
||||
@ -2578,7 +2558,7 @@ nfsrv_readdir(nfsd, slp, procp, mrq)
|
||||
}
|
||||
VOP_UNLOCK(vp);
|
||||
if (error) {
|
||||
nfsrv_vrele(vp);
|
||||
vrele(vp);
|
||||
free((caddr_t)rbuf, M_TEMP);
|
||||
if (cookies)
|
||||
free((caddr_t)cookies, M_TEMP);
|
||||
@ -2594,7 +2574,7 @@ nfsrv_readdir(nfsd, slp, procp, mrq)
|
||||
* rpc reply
|
||||
*/
|
||||
if (siz == 0) {
|
||||
nfsrv_vrele(vp);
|
||||
vrele(vp);
|
||||
nfsm_reply(NFSX_POSTOPATTR(v3) + NFSX_COOKIEVERF(v3) +
|
||||
2 * NFSX_UNSIGNED);
|
||||
if (v3) {
|
||||
@ -2720,7 +2700,7 @@ nfsrv_readdir(nfsd, slp, procp, mrq)
|
||||
cookiep++;
|
||||
ncookies--;
|
||||
}
|
||||
nfsrv_vrele(vp);
|
||||
vrele(vp);
|
||||
nfsm_clget;
|
||||
*tl = nfs_false;
|
||||
bp += NFSX_UNSIGNED;
|
||||
@ -2802,7 +2782,7 @@ nfsrv_readdirplus(nfsd, slp, procp, mrq)
|
||||
error = nfsrv_access(vp, VEXEC, cred, rdonly, procp);
|
||||
}
|
||||
if (error) {
|
||||
nfsrv_vput(vp);
|
||||
vput(vp);
|
||||
nfsm_reply(NFSX_V3POSTOPATTR);
|
||||
nfsm_srvpostop_attr(getret, &at);
|
||||
return (0);
|
||||
@ -2843,7 +2823,7 @@ nfsrv_readdirplus(nfsd, slp, procp, mrq)
|
||||
if (!error)
|
||||
error = getret;
|
||||
if (error) {
|
||||
nfsrv_vrele(vp);
|
||||
vrele(vp);
|
||||
if (cookies)
|
||||
free((caddr_t)cookies, M_TEMP);
|
||||
free((caddr_t)rbuf, M_TEMP);
|
||||
@ -2859,7 +2839,7 @@ nfsrv_readdirplus(nfsd, slp, procp, mrq)
|
||||
* rpc reply
|
||||
*/
|
||||
if (siz == 0) {
|
||||
nfsrv_vrele(vp);
|
||||
vrele(vp);
|
||||
nfsm_reply(NFSX_V3POSTOPATTR + NFSX_V3COOKIEVERF +
|
||||
2 * NFSX_UNSIGNED);
|
||||
nfsm_srvpostop_attr(getret, &at);
|
||||
@ -2912,7 +2892,7 @@ nfsrv_readdirplus(nfsd, slp, procp, mrq)
|
||||
*/
|
||||
if (VFS_VGET(vp->v_mount, dp->d_fileno, &nvp) == EOPNOTSUPP) {
|
||||
error = NFSERR_NOTSUPP;
|
||||
nfsrv_vrele(vp);
|
||||
vrele(vp);
|
||||
free((caddr_t)cookies, M_TEMP);
|
||||
free((caddr_t)rbuf, M_TEMP);
|
||||
nfsm_reply(NFSX_V3POSTOPATTR);
|
||||
@ -3036,7 +3016,7 @@ nfsrv_readdirplus(nfsd, slp, procp, mrq)
|
||||
cookiep++;
|
||||
ncookies--;
|
||||
}
|
||||
nfsrv_vrele(vp);
|
||||
vrele(vp);
|
||||
nfsm_clget;
|
||||
*tl = nfs_false;
|
||||
bp += NFSX_UNSIGNED;
|
||||
@ -3105,7 +3085,7 @@ nfsrv_commit(nfsd, slp, procp, mrq)
|
||||
for_ret = VOP_GETATTR(vp, &bfor, cred, procp);
|
||||
error = VOP_FSYNC(vp, cred, MNT_WAIT, procp);
|
||||
aft_ret = VOP_GETATTR(vp, &aft, cred, procp);
|
||||
nfsrv_vput(vp);
|
||||
vput(vp);
|
||||
nfsm_reply(NFSX_V3WCCDATA + NFSX_V3WRITEVERF);
|
||||
nfsm_srvwcc_data(for_ret, &bfor, aft_ret, &aft);
|
||||
if (!error) {
|
||||
@ -3161,7 +3141,7 @@ nfsrv_statfs(nfsd, slp, procp, mrq)
|
||||
sf = &statfs;
|
||||
error = VFS_STATFS(vp->v_mount, sf, procp);
|
||||
getret = VOP_GETATTR(vp, &at, cred, procp);
|
||||
nfsrv_vput(vp);
|
||||
vput(vp);
|
||||
nfsm_reply(NFSX_POSTOPATTR(v3) + NFSX_STATFS(v3));
|
||||
if (v3)
|
||||
nfsm_srvpostop_attr(getret, &at);
|
||||
@ -3234,7 +3214,7 @@ nfsrv_fsinfo(nfsd, slp, procp, mrq)
|
||||
return (0);
|
||||
}
|
||||
getret = VOP_GETATTR(vp, &at, cred, procp);
|
||||
nfsrv_vput(vp);
|
||||
vput(vp);
|
||||
nfsm_reply(NFSX_V3POSTOPATTR + NFSX_V3FSINFO);
|
||||
nfsm_srvpostop_attr(getret, &at);
|
||||
nfsm_build(sip, struct nfsv3_fsinfo *, NFSX_V3FSINFO);
|
||||
@ -3312,7 +3292,7 @@ nfsrv_pathconf(nfsd, slp, procp, mrq)
|
||||
if (!error)
|
||||
error = VOP_PATHCONF(vp, _PC_NO_TRUNC, ¬runc);
|
||||
getret = VOP_GETATTR(vp, &at, cred, procp);
|
||||
nfsrv_vput(vp);
|
||||
vput(vp);
|
||||
nfsm_reply(NFSX_V3POSTOPATTR + NFSX_V3PATHCONF);
|
||||
nfsm_srvpostop_attr(getret, &at);
|
||||
if (error)
|
||||
|
@ -34,7 +34,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)nfs_subs.c 8.3 (Berkeley) 1/4/94
|
||||
* $Id: nfs_subs.c,v 1.30 1996/06/23 17:19:25 bde Exp $
|
||||
* $Id: nfs_subs.c,v 1.31 1996/07/16 10:19:44 dfr Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -1486,7 +1486,7 @@ nfs_namei(ndp, fhp, len, slp, nam, mdp, dposp, retdirp, p, kerbflag)
|
||||
nam, &rdonly, kerbflag))
|
||||
goto out;
|
||||
if (dp->v_type != VDIR) {
|
||||
nfsrv_vrele(dp);
|
||||
vrele(dp);
|
||||
error = ENOTDIR;
|
||||
goto out;
|
||||
}
|
||||
@ -1517,7 +1517,7 @@ nfs_namei(ndp, fhp, len, slp, nam, mdp, dposp, retdirp, p, kerbflag)
|
||||
goto out;
|
||||
}
|
||||
|
||||
nfsrv_vmio(ndp->ni_vp);
|
||||
nfsrv_object_create(ndp->ni_vp);
|
||||
|
||||
/*
|
||||
* Check for saved name request
|
||||
@ -1748,7 +1748,7 @@ nfsrv_fhtovp(fhp, lockflag, vpp, cred, slp, nam, rdonlyp, kerbflag)
|
||||
else
|
||||
*rdonlyp = 0;
|
||||
|
||||
nfsrv_vmio(*vpp);
|
||||
nfsrv_object_create(*vpp);
|
||||
|
||||
if (!lockflag)
|
||||
VOP_UNLOCK(*vpp);
|
||||
@ -1940,53 +1940,10 @@ nfsrv_errmap(nd, err)
|
||||
}
|
||||
|
||||
int
|
||||
nfsrv_vmio(struct vnode *vp) {
|
||||
vm_object_t object;
|
||||
nfsrv_object_create(struct vnode *vp) {
|
||||
|
||||
if ((vp == NULL) || (vp->v_type != VREG))
|
||||
return 1;
|
||||
|
||||
retry:
|
||||
if ((vp->v_flag & VVMIO) == 0) {
|
||||
struct vattr vat;
|
||||
struct proc *p = curproc;
|
||||
|
||||
if (VOP_GETATTR(vp, &vat, p->p_ucred, p) != 0)
|
||||
panic("nfsrv_vmio: VOP_GETATTR failed");
|
||||
|
||||
(void) vnode_pager_alloc(vp, OFF_TO_IDX(round_page(vat.va_size)), 0, 0);
|
||||
|
||||
vp->v_flag |= VVMIO;
|
||||
} else {
|
||||
if ((object = vp->v_object) &&
|
||||
(object->flags & OBJ_DEAD)) {
|
||||
tsleep(object, PVM, "nfdead", 0);
|
||||
goto retry;
|
||||
}
|
||||
if (!object)
|
||||
panic("nfsrv_vmio: VMIO object missing");
|
||||
vm_object_reference(object);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
int
|
||||
nfsrv_vput(struct vnode *vp) {
|
||||
if ((vp->v_flag & VVMIO) && vp->v_object) {
|
||||
vput(vp);
|
||||
vm_object_deallocate(vp->v_object);
|
||||
} else {
|
||||
vput(vp);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
int
|
||||
nfsrv_vrele(struct vnode *vp) {
|
||||
if ((vp->v_flag & VVMIO) && vp->v_object) {
|
||||
vrele(vp);
|
||||
vm_object_deallocate(vp->v_object);
|
||||
} else {
|
||||
vrele(vp);
|
||||
}
|
||||
return 0;
|
||||
return vfs_object_create(vp, curproc, curproc?curproc->p_ucred:NULL, 1);
|
||||
}
|
||||
#endif /* NFS_NOSERVER */
|
||||
|
@ -34,7 +34,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)nfs.h 8.1 (Berkeley) 6/10/93
|
||||
* $Id: nfs.h,v 1.16 1995/12/17 21:12:05 phk Exp $
|
||||
* $Id: nfs.h,v 1.17 1996/01/30 22:59:39 mpp Exp $
|
||||
*/
|
||||
|
||||
#ifndef _NFS_NFS_H_
|
||||
@ -535,9 +535,7 @@ void nfsrv_rcv __P((struct socket *so, caddr_t arg, int waitflag));
|
||||
void nfsrvw_sort __P((gid_t [],int));
|
||||
void nfsrv_setcred __P((struct ucred *,struct ucred *));
|
||||
int nfs_writebp __P((struct buf *,int));
|
||||
int nfsrv_vput __P(( struct vnode * ));
|
||||
int nfsrv_vrele __P(( struct vnode * ));
|
||||
int nfsrv_vmio __P(( struct vnode * ));
|
||||
int nfsrv_object_create __P(( struct vnode * ));
|
||||
void nfsrv_wakenfsd __P((struct nfssvc_sock *slp));
|
||||
int nfsrv_writegather __P((struct nfsrv_descript **, struct nfssvc_sock *,
|
||||
struct proc *, struct mbuf **));
|
||||
|
@ -34,7 +34,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)nfs_subs.c 8.3 (Berkeley) 1/4/94
|
||||
* $Id: nfs_subs.c,v 1.30 1996/06/23 17:19:25 bde Exp $
|
||||
* $Id: nfs_subs.c,v 1.31 1996/07/16 10:19:44 dfr Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -1486,7 +1486,7 @@ nfs_namei(ndp, fhp, len, slp, nam, mdp, dposp, retdirp, p, kerbflag)
|
||||
nam, &rdonly, kerbflag))
|
||||
goto out;
|
||||
if (dp->v_type != VDIR) {
|
||||
nfsrv_vrele(dp);
|
||||
vrele(dp);
|
||||
error = ENOTDIR;
|
||||
goto out;
|
||||
}
|
||||
@ -1517,7 +1517,7 @@ nfs_namei(ndp, fhp, len, slp, nam, mdp, dposp, retdirp, p, kerbflag)
|
||||
goto out;
|
||||
}
|
||||
|
||||
nfsrv_vmio(ndp->ni_vp);
|
||||
nfsrv_object_create(ndp->ni_vp);
|
||||
|
||||
/*
|
||||
* Check for saved name request
|
||||
@ -1748,7 +1748,7 @@ nfsrv_fhtovp(fhp, lockflag, vpp, cred, slp, nam, rdonlyp, kerbflag)
|
||||
else
|
||||
*rdonlyp = 0;
|
||||
|
||||
nfsrv_vmio(*vpp);
|
||||
nfsrv_object_create(*vpp);
|
||||
|
||||
if (!lockflag)
|
||||
VOP_UNLOCK(*vpp);
|
||||
@ -1940,53 +1940,10 @@ nfsrv_errmap(nd, err)
|
||||
}
|
||||
|
||||
int
|
||||
nfsrv_vmio(struct vnode *vp) {
|
||||
vm_object_t object;
|
||||
nfsrv_object_create(struct vnode *vp) {
|
||||
|
||||
if ((vp == NULL) || (vp->v_type != VREG))
|
||||
return 1;
|
||||
|
||||
retry:
|
||||
if ((vp->v_flag & VVMIO) == 0) {
|
||||
struct vattr vat;
|
||||
struct proc *p = curproc;
|
||||
|
||||
if (VOP_GETATTR(vp, &vat, p->p_ucred, p) != 0)
|
||||
panic("nfsrv_vmio: VOP_GETATTR failed");
|
||||
|
||||
(void) vnode_pager_alloc(vp, OFF_TO_IDX(round_page(vat.va_size)), 0, 0);
|
||||
|
||||
vp->v_flag |= VVMIO;
|
||||
} else {
|
||||
if ((object = vp->v_object) &&
|
||||
(object->flags & OBJ_DEAD)) {
|
||||
tsleep(object, PVM, "nfdead", 0);
|
||||
goto retry;
|
||||
}
|
||||
if (!object)
|
||||
panic("nfsrv_vmio: VMIO object missing");
|
||||
vm_object_reference(object);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
int
|
||||
nfsrv_vput(struct vnode *vp) {
|
||||
if ((vp->v_flag & VVMIO) && vp->v_object) {
|
||||
vput(vp);
|
||||
vm_object_deallocate(vp->v_object);
|
||||
} else {
|
||||
vput(vp);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
int
|
||||
nfsrv_vrele(struct vnode *vp) {
|
||||
if ((vp->v_flag & VVMIO) && vp->v_object) {
|
||||
vrele(vp);
|
||||
vm_object_deallocate(vp->v_object);
|
||||
} else {
|
||||
vrele(vp);
|
||||
}
|
||||
return 0;
|
||||
return vfs_object_create(vp, curproc, curproc?curproc->p_ucred:NULL, 1);
|
||||
}
|
||||
#endif /* NFS_NOSERVER */
|
||||
|
@ -34,7 +34,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)nfs.h 8.1 (Berkeley) 6/10/93
|
||||
* $Id: nfs.h,v 1.16 1995/12/17 21:12:05 phk Exp $
|
||||
* $Id: nfs.h,v 1.17 1996/01/30 22:59:39 mpp Exp $
|
||||
*/
|
||||
|
||||
#ifndef _NFS_NFS_H_
|
||||
@ -535,9 +535,7 @@ void nfsrv_rcv __P((struct socket *so, caddr_t arg, int waitflag));
|
||||
void nfsrvw_sort __P((gid_t [],int));
|
||||
void nfsrv_setcred __P((struct ucred *,struct ucred *));
|
||||
int nfs_writebp __P((struct buf *,int));
|
||||
int nfsrv_vput __P(( struct vnode * ));
|
||||
int nfsrv_vrele __P(( struct vnode * ));
|
||||
int nfsrv_vmio __P(( struct vnode * ));
|
||||
int nfsrv_object_create __P(( struct vnode * ));
|
||||
void nfsrv_wakenfsd __P((struct nfssvc_sock *slp));
|
||||
int nfsrv_writegather __P((struct nfsrv_descript **, struct nfssvc_sock *,
|
||||
struct proc *, struct mbuf **));
|
||||
|
@ -34,7 +34,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)nfs.h 8.1 (Berkeley) 6/10/93
|
||||
* $Id: nfs.h,v 1.16 1995/12/17 21:12:05 phk Exp $
|
||||
* $Id: nfs.h,v 1.17 1996/01/30 22:59:39 mpp Exp $
|
||||
*/
|
||||
|
||||
#ifndef _NFS_NFS_H_
|
||||
@ -535,9 +535,7 @@ void nfsrv_rcv __P((struct socket *so, caddr_t arg, int waitflag));
|
||||
void nfsrvw_sort __P((gid_t [],int));
|
||||
void nfsrv_setcred __P((struct ucred *,struct ucred *));
|
||||
int nfs_writebp __P((struct buf *,int));
|
||||
int nfsrv_vput __P(( struct vnode * ));
|
||||
int nfsrv_vrele __P(( struct vnode * ));
|
||||
int nfsrv_vmio __P(( struct vnode * ));
|
||||
int nfsrv_object_create __P(( struct vnode * ));
|
||||
void nfsrv_wakenfsd __P((struct nfssvc_sock *slp));
|
||||
int nfsrv_writegather __P((struct nfsrv_descript **, struct nfssvc_sock *,
|
||||
struct proc *, struct mbuf **));
|
||||
|
@ -34,7 +34,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)nfs.h 8.1 (Berkeley) 6/10/93
|
||||
* $Id: nfs.h,v 1.16 1995/12/17 21:12:05 phk Exp $
|
||||
* $Id: nfs.h,v 1.17 1996/01/30 22:59:39 mpp Exp $
|
||||
*/
|
||||
|
||||
#ifndef _NFS_NFS_H_
|
||||
@ -535,9 +535,7 @@ void nfsrv_rcv __P((struct socket *so, caddr_t arg, int waitflag));
|
||||
void nfsrvw_sort __P((gid_t [],int));
|
||||
void nfsrv_setcred __P((struct ucred *,struct ucred *));
|
||||
int nfs_writebp __P((struct buf *,int));
|
||||
int nfsrv_vput __P(( struct vnode * ));
|
||||
int nfsrv_vrele __P(( struct vnode * ));
|
||||
int nfsrv_vmio __P(( struct vnode * ));
|
||||
int nfsrv_object_create __P(( struct vnode * ));
|
||||
void nfsrv_wakenfsd __P((struct nfssvc_sock *slp));
|
||||
int nfsrv_writegather __P((struct nfsrv_descript **, struct nfssvc_sock *,
|
||||
struct proc *, struct mbuf **));
|
||||
|
@ -34,7 +34,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)nfs_serv.c 8.3 (Berkeley) 1/12/94
|
||||
* $Id: nfs_serv.c,v 1.29 1996/04/30 23:23:07 bde Exp $
|
||||
* $Id: nfs_serv.c,v 1.30 1996/06/08 12:16:26 bde Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -165,7 +165,7 @@ nfsrv3_access(nfsd, slp, procp, mrq)
|
||||
nfsrv_access(vp, VEXEC, cred, rdonly, procp))
|
||||
nfsmode &= ~testmode;
|
||||
getret = VOP_GETATTR(vp, vap, cred, procp);
|
||||
nfsrv_vput(vp);
|
||||
vput(vp);
|
||||
nfsm_reply(NFSX_POSTOPATTR(1) + NFSX_UNSIGNED);
|
||||
nfsm_srvpostop_attr(getret, vap);
|
||||
nfsm_build(tl, u_long *, NFSX_UNSIGNED);
|
||||
@ -210,7 +210,7 @@ nfsrv_getattr(nfsd, slp, procp, mrq)
|
||||
}
|
||||
nqsrv_getl(vp, ND_READ);
|
||||
error = VOP_GETATTR(vp, vap, cred, procp);
|
||||
nfsrv_vput(vp);
|
||||
vput(vp);
|
||||
nfsm_reply(NFSX_FATTR(nfsd->nd_flag & ND_NFSV3));
|
||||
if (error)
|
||||
return (0);
|
||||
@ -309,7 +309,7 @@ nfsrv_setattr(nfsd, slp, procp, mrq)
|
||||
preat.va_ctime.ts_nsec != guard.ts_nsec))
|
||||
error = NFSERR_NOT_SYNC;
|
||||
if (error) {
|
||||
nfsrv_vput(vp);
|
||||
vput(vp);
|
||||
nfsm_reply(NFSX_WCCDATA(v3));
|
||||
nfsm_srvwcc_data(preat_ret, &preat, postat_ret, vap);
|
||||
return (0);
|
||||
@ -338,7 +338,7 @@ nfsrv_setattr(nfsd, slp, procp, mrq)
|
||||
if (!error)
|
||||
error = postat_ret;
|
||||
out:
|
||||
nfsrv_vput(vp);
|
||||
vput(vp);
|
||||
nfsm_reply(NFSX_WCCORFATTR(v3));
|
||||
if (v3) {
|
||||
nfsm_srvwcc_data(preat_ret, &preat, postat_ret, vap);
|
||||
@ -392,7 +392,7 @@ nfsrv_lookup(nfsd, slp, procp, mrq)
|
||||
if (v3)
|
||||
dirattr_ret = VOP_GETATTR(dirp, &dirattr, cred,
|
||||
procp);
|
||||
nfsrv_vrele(dirp);
|
||||
vrele(dirp);
|
||||
}
|
||||
if (error) {
|
||||
nfsm_reply(NFSX_POSTOPATTR(v3));
|
||||
@ -400,7 +400,7 @@ nfsrv_lookup(nfsd, slp, procp, mrq)
|
||||
return (0);
|
||||
}
|
||||
nqsrv_getl(nd.ni_startdir, ND_READ);
|
||||
nfsrv_vrele(nd.ni_startdir);
|
||||
vrele(nd.ni_startdir);
|
||||
FREE(nd.ni_cnd.cn_pnbuf, M_NAMEI);
|
||||
vp = nd.ni_vp;
|
||||
bzero((caddr_t)fhp, sizeof(nfh));
|
||||
@ -408,7 +408,7 @@ nfsrv_lookup(nfsd, slp, procp, mrq)
|
||||
error = VFS_VPTOFH(vp, &fhp->fh_fid);
|
||||
if (!error)
|
||||
error = VOP_GETATTR(vp, vap, cred, procp);
|
||||
nfsrv_vput(vp);
|
||||
vput(vp);
|
||||
nfsm_reply(NFSX_SRVFH(v3) + NFSX_POSTOPORFATTR(v3) + NFSX_POSTOPATTR(v3));
|
||||
if (error) {
|
||||
nfsm_srvpostop_attr(dirattr_ret, &dirattr);
|
||||
@ -508,7 +508,7 @@ nfsrv_readlink(nfsd, slp, procp, mrq)
|
||||
error = VOP_READLINK(vp, uiop, cred);
|
||||
out:
|
||||
getret = VOP_GETATTR(vp, &attr, cred, procp);
|
||||
nfsrv_vput(vp);
|
||||
vput(vp);
|
||||
if (error)
|
||||
m_freem(mp3);
|
||||
nfsm_reply(NFSX_POSTOPATTR(v3) + NFSX_UNSIGNED);
|
||||
@ -594,7 +594,7 @@ nfsrv_read(nfsd, slp, procp, mrq)
|
||||
if (!error)
|
||||
error = getret;
|
||||
if (error) {
|
||||
nfsrv_vput(vp);
|
||||
vput(vp);
|
||||
nfsm_reply(NFSX_POSTOPATTR(v3));
|
||||
nfsm_srvpostop_attr(getret, vap);
|
||||
return (0);
|
||||
@ -669,14 +669,14 @@ nfsrv_read(nfsd, slp, procp, mrq)
|
||||
if (!error)
|
||||
error = getret;
|
||||
m_freem(mreq);
|
||||
nfsrv_vput(vp);
|
||||
vput(vp);
|
||||
nfsm_reply(NFSX_POSTOPATTR(v3));
|
||||
nfsm_srvpostop_attr(getret, vap);
|
||||
return (0);
|
||||
}
|
||||
} else
|
||||
uiop->uio_resid = 0;
|
||||
nfsrv_vput(vp);
|
||||
vput(vp);
|
||||
nfsm_srvfillattr(vap, fp);
|
||||
len -= uiop->uio_resid;
|
||||
tlen = nfsm_rndup(len);
|
||||
@ -806,7 +806,7 @@ nfsrv_write(nfsd, slp, procp, mrq)
|
||||
error = nfsrv_access(vp, VWRITE, cred, rdonly, procp);
|
||||
}
|
||||
if (error) {
|
||||
nfsrv_vput(vp);
|
||||
vput(vp);
|
||||
nfsm_reply(NFSX_WCCDATA(v3));
|
||||
nfsm_srvwcc_data(forat_ret, &forat, aftat_ret, vap);
|
||||
return (0);
|
||||
@ -850,7 +850,7 @@ nfsrv_write(nfsd, slp, procp, mrq)
|
||||
FREE((caddr_t)iv, M_TEMP);
|
||||
}
|
||||
aftat_ret = VOP_GETATTR(vp, vap, cred, procp);
|
||||
nfsrv_vput(vp);
|
||||
vput(vp);
|
||||
if (!error)
|
||||
error = aftat_ret;
|
||||
nfsm_reply(NFSX_PREOPATTR(v3) + NFSX_POSTOPORFATTR(v3) +
|
||||
@ -1118,7 +1118,7 @@ nfsrv_writegather(ndp, slp, procp, mrq)
|
||||
m_freem(mrep);
|
||||
if (vp) {
|
||||
aftat_ret = VOP_GETATTR(vp, &va, cred, procp);
|
||||
nfsrv_vput(vp);
|
||||
vput(vp);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1327,7 +1327,7 @@ nfsrv_create(nfsd, slp, procp, mrq)
|
||||
dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred,
|
||||
procp);
|
||||
else {
|
||||
nfsrv_vrele(dirp);
|
||||
vrele(dirp);
|
||||
dirp = (struct vnode *)0;
|
||||
}
|
||||
}
|
||||
@ -1335,7 +1335,7 @@ nfsrv_create(nfsd, slp, procp, mrq)
|
||||
nfsm_reply(NFSX_WCCDATA(v3));
|
||||
nfsm_srvwcc_data(dirfor_ret, &dirfor, diraft_ret, &diraft);
|
||||
if (dirp)
|
||||
nfsrv_vrele(dirp);
|
||||
vrele(dirp);
|
||||
return (0);
|
||||
}
|
||||
VATTR_NULL(vap);
|
||||
@ -1387,11 +1387,11 @@ nfsrv_create(nfsd, slp, procp, mrq)
|
||||
*/
|
||||
if (nd.ni_vp == NULL) {
|
||||
if (vap->va_type == VREG || vap->va_type == VSOCK) {
|
||||
nfsrv_vrele(nd.ni_startdir);
|
||||
vrele(nd.ni_startdir);
|
||||
nqsrv_getl(nd.ni_dvp, ND_WRITE);
|
||||
error = VOP_CREATE(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, vap);
|
||||
if (!error) {
|
||||
nfsrv_vmio(nd.ni_vp);
|
||||
nfsrv_object_create(nd.ni_vp);
|
||||
FREE(nd.ni_cnd.cn_pnbuf, M_NAMEI);
|
||||
if (exclusive_flag) {
|
||||
exclusive_flag = 0;
|
||||
@ -1407,17 +1407,17 @@ nfsrv_create(nfsd, slp, procp, mrq)
|
||||
if (vap->va_type == VCHR && rdev == 0xffffffff)
|
||||
vap->va_type = VFIFO;
|
||||
if (error = suser(cred, (u_short *)0)) {
|
||||
nfsrv_vrele(nd.ni_startdir);
|
||||
vrele(nd.ni_startdir);
|
||||
free(nd.ni_cnd.cn_pnbuf, M_NAMEI);
|
||||
VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
|
||||
nfsrv_vput(nd.ni_dvp);
|
||||
vput(nd.ni_dvp);
|
||||
nfsm_reply(0);
|
||||
return (error);
|
||||
} else
|
||||
vap->va_rdev = (dev_t)rdev;
|
||||
nqsrv_getl(nd.ni_dvp, ND_WRITE);
|
||||
if (error = VOP_MKNOD(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, vap)) {
|
||||
nfsrv_vrele(nd.ni_startdir);
|
||||
vrele(nd.ni_startdir);
|
||||
nfsm_reply(0);
|
||||
}
|
||||
nd.ni_cnd.cn_nameiop = LOOKUP;
|
||||
@ -1428,31 +1428,31 @@ nfsrv_create(nfsd, slp, procp, mrq)
|
||||
free(nd.ni_cnd.cn_pnbuf, M_NAMEI);
|
||||
nfsm_reply(0);
|
||||
}
|
||||
nfsrv_vmio(nd.ni_vp);
|
||||
nfsrv_object_create(nd.ni_vp);
|
||||
FREE(nd.ni_cnd.cn_pnbuf, M_NAMEI);
|
||||
if (nd.ni_cnd.cn_flags & ISSYMLINK) {
|
||||
nfsrv_vrele(nd.ni_dvp);
|
||||
nfsrv_vput(nd.ni_vp);
|
||||
vrele(nd.ni_dvp);
|
||||
vput(nd.ni_vp);
|
||||
VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
|
||||
error = EINVAL;
|
||||
nfsm_reply(0);
|
||||
}
|
||||
} else {
|
||||
nfsrv_vrele(nd.ni_startdir);
|
||||
vrele(nd.ni_startdir);
|
||||
free(nd.ni_cnd.cn_pnbuf, M_NAMEI);
|
||||
VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
|
||||
nfsrv_vput(nd.ni_dvp);
|
||||
vput(nd.ni_dvp);
|
||||
error = ENXIO;
|
||||
}
|
||||
vp = nd.ni_vp;
|
||||
} else {
|
||||
nfsrv_vrele(nd.ni_startdir);
|
||||
vrele(nd.ni_startdir);
|
||||
free(nd.ni_cnd.cn_pnbuf, M_NAMEI);
|
||||
vp = nd.ni_vp;
|
||||
if (nd.ni_dvp == vp)
|
||||
nfsrv_vrele(nd.ni_dvp);
|
||||
vrele(nd.ni_dvp);
|
||||
else
|
||||
nfsrv_vput(nd.ni_dvp);
|
||||
vput(nd.ni_dvp);
|
||||
VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
|
||||
if (vap->va_size != -1) {
|
||||
error = nfsrv_access(vp, VWRITE, cred,
|
||||
@ -1466,7 +1466,7 @@ nfsrv_create(nfsd, slp, procp, mrq)
|
||||
procp);
|
||||
}
|
||||
if (error)
|
||||
nfsrv_vput(vp);
|
||||
vput(vp);
|
||||
}
|
||||
}
|
||||
if (!error) {
|
||||
@ -1475,14 +1475,14 @@ nfsrv_create(nfsd, slp, procp, mrq)
|
||||
error = VFS_VPTOFH(vp, &fhp->fh_fid);
|
||||
if (!error)
|
||||
error = VOP_GETATTR(vp, vap, cred, procp);
|
||||
nfsrv_vput(vp);
|
||||
vput(vp);
|
||||
}
|
||||
if (v3) {
|
||||
if (exclusive_flag && !error &&
|
||||
bcmp(cverf, (caddr_t)&vap->va_atime, NFSX_V3CREATEVERF))
|
||||
error = EEXIST;
|
||||
diraft_ret = VOP_GETATTR(dirp, &diraft, cred, procp);
|
||||
nfsrv_vrele(dirp);
|
||||
vrele(dirp);
|
||||
}
|
||||
nfsm_reply(NFSX_SRVFH(v3) + NFSX_FATTR(v3) + NFSX_WCCDATA(v3));
|
||||
if (v3) {
|
||||
@ -1499,18 +1499,18 @@ nfsrv_create(nfsd, slp, procp, mrq)
|
||||
return (0);
|
||||
nfsmout:
|
||||
if (dirp)
|
||||
nfsrv_vrele(dirp);
|
||||
vrele(dirp);
|
||||
if (nd.ni_cnd.cn_nameiop) {
|
||||
nfsrv_vrele(nd.ni_startdir);
|
||||
vrele(nd.ni_startdir);
|
||||
free((caddr_t)nd.ni_cnd.cn_pnbuf, M_NAMEI);
|
||||
}
|
||||
VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
|
||||
if (nd.ni_dvp == nd.ni_vp)
|
||||
nfsrv_vrele(nd.ni_dvp);
|
||||
vrele(nd.ni_dvp);
|
||||
else
|
||||
nfsrv_vput(nd.ni_dvp);
|
||||
vput(nd.ni_dvp);
|
||||
if (nd.ni_vp)
|
||||
nfsrv_vput(nd.ni_vp);
|
||||
vput(nd.ni_vp);
|
||||
return (error);
|
||||
}
|
||||
|
||||
@ -1559,17 +1559,17 @@ nfsrv_mknod(nfsd, slp, procp, mrq)
|
||||
nfsm_reply(NFSX_WCCDATA(1));
|
||||
nfsm_srvwcc_data(dirfor_ret, &dirfor, diraft_ret, &diraft);
|
||||
if (dirp)
|
||||
nfsrv_vrele(dirp);
|
||||
vrele(dirp);
|
||||
return (0);
|
||||
}
|
||||
nfsm_dissect(tl, u_long *, NFSX_UNSIGNED);
|
||||
vtyp = nfsv3tov_type(*tl);
|
||||
if (vtyp != VCHR && vtyp != VBLK && vtyp != VSOCK && vtyp != VFIFO) {
|
||||
nfsrv_vrele(nd.ni_startdir);
|
||||
vrele(nd.ni_startdir);
|
||||
free((caddr_t)nd.ni_cnd.cn_pnbuf, M_NAMEI);
|
||||
error = NFSERR_BADTYPE;
|
||||
VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
|
||||
nfsrv_vput(nd.ni_dvp);
|
||||
vput(nd.ni_dvp);
|
||||
goto out;
|
||||
}
|
||||
VATTR_NULL(vap);
|
||||
@ -1585,31 +1585,31 @@ nfsrv_mknod(nfsd, slp, procp, mrq)
|
||||
* Iff doesn't exist, create it.
|
||||
*/
|
||||
if (nd.ni_vp) {
|
||||
nfsrv_vrele(nd.ni_startdir);
|
||||
vrele(nd.ni_startdir);
|
||||
free((caddr_t)nd.ni_cnd.cn_pnbuf, M_NAMEI);
|
||||
error = EEXIST;
|
||||
VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
|
||||
nfsrv_vput(nd.ni_dvp);
|
||||
vput(nd.ni_dvp);
|
||||
goto out;
|
||||
}
|
||||
vap->va_type = vtyp;
|
||||
if (vtyp == VSOCK) {
|
||||
nfsrv_vrele(nd.ni_startdir);
|
||||
vrele(nd.ni_startdir);
|
||||
nqsrv_getl(nd.ni_dvp, ND_WRITE);
|
||||
error = VOP_CREATE(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, vap);
|
||||
if (!error)
|
||||
FREE(nd.ni_cnd.cn_pnbuf, M_NAMEI);
|
||||
} else {
|
||||
if (error = suser(cred, (u_short *)0)) {
|
||||
nfsrv_vrele(nd.ni_startdir);
|
||||
vrele(nd.ni_startdir);
|
||||
free((caddr_t)nd.ni_cnd.cn_pnbuf, M_NAMEI);
|
||||
VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
|
||||
nfsrv_vput(nd.ni_dvp);
|
||||
vput(nd.ni_dvp);
|
||||
goto out;
|
||||
}
|
||||
nqsrv_getl(nd.ni_dvp, ND_WRITE);
|
||||
if (error = VOP_MKNOD(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, vap)) {
|
||||
nfsrv_vrele(nd.ni_startdir);
|
||||
vrele(nd.ni_startdir);
|
||||
goto out;
|
||||
}
|
||||
nd.ni_cnd.cn_nameiop = LOOKUP;
|
||||
@ -1621,8 +1621,8 @@ nfsrv_mknod(nfsd, slp, procp, mrq)
|
||||
if (error)
|
||||
goto out;
|
||||
if (nd.ni_cnd.cn_flags & ISSYMLINK) {
|
||||
nfsrv_vrele(nd.ni_dvp);
|
||||
nfsrv_vput(nd.ni_vp);
|
||||
vrele(nd.ni_dvp);
|
||||
vput(nd.ni_vp);
|
||||
VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
|
||||
error = EINVAL;
|
||||
}
|
||||
@ -1635,10 +1635,10 @@ nfsrv_mknod(nfsd, slp, procp, mrq)
|
||||
error = VFS_VPTOFH(vp, &fhp->fh_fid);
|
||||
if (!error)
|
||||
error = VOP_GETATTR(vp, vap, cred, procp);
|
||||
nfsrv_vput(vp);
|
||||
vput(vp);
|
||||
}
|
||||
diraft_ret = VOP_GETATTR(dirp, &diraft, cred, procp);
|
||||
nfsrv_vrele(dirp);
|
||||
vrele(dirp);
|
||||
nfsm_reply(NFSX_SRVFH(1) + NFSX_POSTOPATTR(1) + NFSX_WCCDATA(1));
|
||||
if (!error) {
|
||||
nfsm_srvpostop_fh(fhp);
|
||||
@ -1648,18 +1648,18 @@ nfsrv_mknod(nfsd, slp, procp, mrq)
|
||||
return (0);
|
||||
nfsmout:
|
||||
if (dirp)
|
||||
nfsrv_vrele(dirp);
|
||||
vrele(dirp);
|
||||
if (nd.ni_cnd.cn_nameiop) {
|
||||
nfsrv_vrele(nd.ni_startdir);
|
||||
vrele(nd.ni_startdir);
|
||||
free((caddr_t)nd.ni_cnd.cn_pnbuf, M_NAMEI);
|
||||
}
|
||||
VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
|
||||
if (nd.ni_dvp == nd.ni_vp)
|
||||
nfsrv_vrele(nd.ni_dvp);
|
||||
vrele(nd.ni_dvp);
|
||||
else
|
||||
nfsrv_vput(nd.ni_dvp);
|
||||
vput(nd.ni_dvp);
|
||||
if (nd.ni_vp)
|
||||
nfsrv_vput(nd.ni_vp);
|
||||
vput(nd.ni_vp);
|
||||
return (error);
|
||||
}
|
||||
|
||||
@ -1707,7 +1707,7 @@ nfsrv_remove(nfsd, slp, procp, mrq)
|
||||
dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred,
|
||||
procp);
|
||||
else
|
||||
nfsrv_vrele(dirp);
|
||||
vrele(dirp);
|
||||
}
|
||||
if (!error) {
|
||||
vp = nd.ni_vp;
|
||||
@ -1721,30 +1721,26 @@ nfsrv_remove(nfsd, slp, procp, mrq)
|
||||
error = EBUSY;
|
||||
goto out;
|
||||
}
|
||||
vnode_pager_uncache(vp);
|
||||
out:
|
||||
if (!error) {
|
||||
int deallocobj = 0;
|
||||
vnode_pager_uncache(vp);
|
||||
nqsrv_getl(nd.ni_dvp, ND_WRITE);
|
||||
nqsrv_getl(vp, ND_WRITE);
|
||||
|
||||
if ((vp->v_flag & VVMIO) && vp->v_object)
|
||||
deallocobj = 1;
|
||||
error = VOP_REMOVE(nd.ni_dvp, nd.ni_vp, &nd.ni_cnd);
|
||||
if (error == 0 && deallocobj)
|
||||
vm_object_deallocate(vp->v_object);
|
||||
|
||||
} else {
|
||||
VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
|
||||
if (nd.ni_dvp == vp)
|
||||
nfsrv_vrele(nd.ni_dvp);
|
||||
vrele(nd.ni_dvp);
|
||||
else
|
||||
nfsrv_vput(nd.ni_dvp);
|
||||
nfsrv_vput(vp);
|
||||
vput(nd.ni_dvp);
|
||||
vput(vp);
|
||||
}
|
||||
}
|
||||
if (dirp && v3) {
|
||||
diraft_ret = VOP_GETATTR(dirp, &diraft, cred, procp);
|
||||
nfsrv_vrele(dirp);
|
||||
vrele(dirp);
|
||||
}
|
||||
nfsm_reply(NFSX_WCCDATA(v3));
|
||||
if (v3) {
|
||||
@ -1809,7 +1805,7 @@ nfsrv_rename(nfsd, slp, procp, mrq)
|
||||
fdirfor_ret = VOP_GETATTR(fdirp, &fdirfor, cred,
|
||||
procp);
|
||||
else {
|
||||
nfsrv_vrele(fdirp);
|
||||
vrele(fdirp);
|
||||
fdirp = (struct vnode *)0;
|
||||
}
|
||||
}
|
||||
@ -1818,7 +1814,7 @@ nfsrv_rename(nfsd, slp, procp, mrq)
|
||||
nfsm_srvwcc_data(fdirfor_ret, &fdirfor, fdiraft_ret, &fdiraft);
|
||||
nfsm_srvwcc_data(tdirfor_ret, &tdirfor, tdiraft_ret, &tdiraft);
|
||||
if (fdirp)
|
||||
nfsrv_vrele(fdirp);
|
||||
vrele(fdirp);
|
||||
return (0);
|
||||
}
|
||||
fvp = fromnd.ni_vp;
|
||||
@ -1835,14 +1831,14 @@ nfsrv_rename(nfsd, slp, procp, mrq)
|
||||
tdirfor_ret = VOP_GETATTR(tdirp, &tdirfor, cred,
|
||||
procp);
|
||||
else {
|
||||
nfsrv_vrele(tdirp);
|
||||
vrele(tdirp);
|
||||
tdirp = (struct vnode *)0;
|
||||
}
|
||||
}
|
||||
if (error) {
|
||||
VOP_ABORTOP(fromnd.ni_dvp, &fromnd.ni_cnd);
|
||||
nfsrv_vrele(fromnd.ni_dvp);
|
||||
nfsrv_vrele(fvp);
|
||||
vrele(fromnd.ni_dvp);
|
||||
vrele(fvp);
|
||||
goto out1;
|
||||
}
|
||||
tdvp = tond.ni_dvp;
|
||||
@ -1900,50 +1896,40 @@ nfsrv_rename(nfsd, slp, procp, mrq)
|
||||
error = -1;
|
||||
out:
|
||||
if (!error) {
|
||||
int deallocobjfrom = 0, deallocobjto = 0;
|
||||
nqsrv_getl(fromnd.ni_dvp, ND_WRITE);
|
||||
nqsrv_getl(tdvp, ND_WRITE);
|
||||
if (tvp) {
|
||||
nqsrv_getl(tvp, ND_WRITE);
|
||||
if ((tvp->v_flag & VVMIO) && tvp->v_object)
|
||||
deallocobjto = 1;
|
||||
(void) vnode_pager_uncache(tvp);
|
||||
}
|
||||
if ((fvp->v_flag & VVMIO) && fvp->v_object)
|
||||
deallocobjfrom = 1;
|
||||
error = VOP_RENAME(fromnd.ni_dvp, fromnd.ni_vp, &fromnd.ni_cnd,
|
||||
tond.ni_dvp, tond.ni_vp, &tond.ni_cnd);
|
||||
if (deallocobjfrom)
|
||||
vm_object_deallocate(fvp->v_object);
|
||||
if (deallocobjto)
|
||||
vm_object_deallocate(tvp->v_object);
|
||||
|
||||
} else {
|
||||
VOP_ABORTOP(tond.ni_dvp, &tond.ni_cnd);
|
||||
if (tdvp == tvp)
|
||||
nfsrv_vrele(tdvp);
|
||||
vrele(tdvp);
|
||||
else
|
||||
nfsrv_vput(tdvp);
|
||||
vput(tdvp);
|
||||
if (tvp)
|
||||
nfsrv_vput(tvp);
|
||||
vput(tvp);
|
||||
VOP_ABORTOP(fromnd.ni_dvp, &fromnd.ni_cnd);
|
||||
nfsrv_vrele(fromnd.ni_dvp);
|
||||
nfsrv_vrele(fvp);
|
||||
vrele(fromnd.ni_dvp);
|
||||
vrele(fvp);
|
||||
if (error == -1)
|
||||
error = 0;
|
||||
}
|
||||
nfsrv_vrele(tond.ni_startdir);
|
||||
vrele(tond.ni_startdir);
|
||||
FREE(tond.ni_cnd.cn_pnbuf, M_NAMEI);
|
||||
out1:
|
||||
if (fdirp) {
|
||||
fdiraft_ret = VOP_GETATTR(fdirp, &fdiraft, cred, procp);
|
||||
nfsrv_vrele(fdirp);
|
||||
vrele(fdirp);
|
||||
}
|
||||
if (tdirp) {
|
||||
tdiraft_ret = VOP_GETATTR(tdirp, &tdiraft, cred, procp);
|
||||
nfsrv_vrele(tdirp);
|
||||
vrele(tdirp);
|
||||
}
|
||||
nfsrv_vrele(fromnd.ni_startdir);
|
||||
vrele(fromnd.ni_startdir);
|
||||
FREE(fromnd.ni_cnd.cn_pnbuf, M_NAMEI);
|
||||
nfsm_reply(2 * NFSX_WCCDATA(v3));
|
||||
if (v3) {
|
||||
@ -1954,19 +1940,19 @@ nfsrv_rename(nfsd, slp, procp, mrq)
|
||||
|
||||
nfsmout:
|
||||
if (fdirp)
|
||||
nfsrv_vrele(fdirp);
|
||||
vrele(fdirp);
|
||||
if (tdirp)
|
||||
nfsrv_vrele(tdirp);
|
||||
vrele(tdirp);
|
||||
if (tond.ni_cnd.cn_nameiop) {
|
||||
nfsrv_vrele(tond.ni_startdir);
|
||||
vrele(tond.ni_startdir);
|
||||
FREE(tond.ni_cnd.cn_pnbuf, M_NAMEI);
|
||||
}
|
||||
if (fromnd.ni_cnd.cn_nameiop) {
|
||||
nfsrv_vrele(fromnd.ni_startdir);
|
||||
vrele(fromnd.ni_startdir);
|
||||
FREE(fromnd.ni_cnd.cn_pnbuf, M_NAMEI);
|
||||
VOP_ABORTOP(fromnd.ni_dvp, &fromnd.ni_cnd);
|
||||
nfsrv_vrele(fromnd.ni_dvp);
|
||||
nfsrv_vrele(fvp);
|
||||
vrele(fromnd.ni_dvp);
|
||||
vrele(fvp);
|
||||
}
|
||||
return (error);
|
||||
}
|
||||
@ -2023,7 +2009,7 @@ nfsrv_link(nfsd, slp, procp, mrq)
|
||||
dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred,
|
||||
procp);
|
||||
else {
|
||||
nfsrv_vrele(dirp);
|
||||
vrele(dirp);
|
||||
dirp = (struct vnode *)0;
|
||||
}
|
||||
}
|
||||
@ -2049,20 +2035,20 @@ nfsrv_link(nfsd, slp, procp, mrq)
|
||||
} else {
|
||||
VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
|
||||
if (nd.ni_dvp == nd.ni_vp)
|
||||
nfsrv_vrele(nd.ni_dvp);
|
||||
vrele(nd.ni_dvp);
|
||||
else
|
||||
nfsrv_vput(nd.ni_dvp);
|
||||
vput(nd.ni_dvp);
|
||||
if (nd.ni_vp)
|
||||
nfsrv_vrele(nd.ni_vp);
|
||||
vrele(nd.ni_vp);
|
||||
}
|
||||
out1:
|
||||
if (v3)
|
||||
getret = VOP_GETATTR(vp, &at, cred, procp);
|
||||
if (dirp) {
|
||||
diraft_ret = VOP_GETATTR(dirp, &diraft, cred, procp);
|
||||
nfsrv_vrele(dirp);
|
||||
vrele(dirp);
|
||||
}
|
||||
nfsrv_vrele(vp);
|
||||
vrele(vp);
|
||||
nfsm_reply(NFSX_POSTOPATTR(v3) + NFSX_WCCDATA(v3));
|
||||
if (v3) {
|
||||
nfsm_srvpostop_attr(getret, &at);
|
||||
@ -2087,7 +2073,6 @@ nfsrv_symlink(nfsd, slp, procp, mrq)
|
||||
caddr_t dpos = nfsd->nd_dpos;
|
||||
struct ucred *cred = &nfsd->nd_cr;
|
||||
struct vattr va, dirfor, diraft;
|
||||
struct vnode *ovp;
|
||||
struct nameidata nd;
|
||||
register struct vattr *vap = &va;
|
||||
register u_long *tl;
|
||||
@ -2103,7 +2088,6 @@ nfsrv_symlink(nfsd, slp, procp, mrq)
|
||||
nfsfh_t nfh;
|
||||
fhandle_t *fhp;
|
||||
u_quad_t frev;
|
||||
int deallocobj = 0;
|
||||
|
||||
nd.ni_cnd.cn_nameiop = 0;
|
||||
fhp = &nfh.fh_generic;
|
||||
@ -2119,7 +2103,7 @@ nfsrv_symlink(nfsd, slp, procp, mrq)
|
||||
dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred,
|
||||
procp);
|
||||
else {
|
||||
nfsrv_vrele(dirp);
|
||||
vrele(dirp);
|
||||
dirp = (struct vnode *)0;
|
||||
}
|
||||
}
|
||||
@ -2146,25 +2130,21 @@ nfsrv_symlink(nfsd, slp, procp, mrq)
|
||||
}
|
||||
*(pathcp + len2) = '\0';
|
||||
if (nd.ni_vp) {
|
||||
nfsrv_vrele(nd.ni_startdir);
|
||||
vrele(nd.ni_startdir);
|
||||
free(nd.ni_cnd.cn_pnbuf, M_NAMEI);
|
||||
VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
|
||||
if (nd.ni_dvp == nd.ni_vp)
|
||||
nfsrv_vrele(nd.ni_dvp);
|
||||
vrele(nd.ni_dvp);
|
||||
else
|
||||
nfsrv_vput(nd.ni_dvp);
|
||||
nfsrv_vrele(nd.ni_vp);
|
||||
vput(nd.ni_dvp);
|
||||
vrele(nd.ni_vp);
|
||||
error = EEXIST;
|
||||
goto out;
|
||||
}
|
||||
nqsrv_getl(nd.ni_dvp, ND_WRITE);
|
||||
if ((ovp = nd.ni_vp) && (ovp->v_flag & VVMIO) && ovp->v_object)
|
||||
deallocobj = 1;
|
||||
error = VOP_SYMLINK(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, vap, pathcp);
|
||||
if (error == 0 && deallocobj)
|
||||
vm_object_deallocate(ovp->v_object);
|
||||
if (error)
|
||||
nfsrv_vrele(nd.ni_startdir);
|
||||
vrele(nd.ni_startdir);
|
||||
else {
|
||||
if (v3) {
|
||||
nd.ni_cnd.cn_nameiop = LOOKUP;
|
||||
@ -2180,10 +2160,10 @@ nfsrv_symlink(nfsd, slp, procp, mrq)
|
||||
if (!error)
|
||||
error = VOP_GETATTR(nd.ni_vp, vap, cred,
|
||||
procp);
|
||||
nfsrv_vput(nd.ni_vp);
|
||||
vput(nd.ni_vp);
|
||||
}
|
||||
} else
|
||||
nfsrv_vrele(nd.ni_startdir);
|
||||
vrele(nd.ni_startdir);
|
||||
FREE(nd.ni_cnd.cn_pnbuf, M_NAMEI);
|
||||
}
|
||||
out:
|
||||
@ -2191,7 +2171,7 @@ nfsrv_symlink(nfsd, slp, procp, mrq)
|
||||
FREE(pathcp, M_TEMP);
|
||||
if (dirp) {
|
||||
diraft_ret = VOP_GETATTR(dirp, &diraft, cred, procp);
|
||||
nfsrv_vrele(dirp);
|
||||
vrele(dirp);
|
||||
}
|
||||
nfsm_reply(NFSX_SRVFH(v3) + NFSX_POSTOPATTR(v3) + NFSX_WCCDATA(v3));
|
||||
if (v3) {
|
||||
@ -2204,18 +2184,18 @@ nfsrv_symlink(nfsd, slp, procp, mrq)
|
||||
return (0);
|
||||
nfsmout:
|
||||
if (nd.ni_cnd.cn_nameiop) {
|
||||
nfsrv_vrele(nd.ni_startdir);
|
||||
vrele(nd.ni_startdir);
|
||||
free(nd.ni_cnd.cn_pnbuf, M_NAMEI);
|
||||
}
|
||||
if (dirp)
|
||||
nfsrv_vrele(dirp);
|
||||
vrele(dirp);
|
||||
VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
|
||||
if (nd.ni_dvp == nd.ni_vp)
|
||||
nfsrv_vrele(nd.ni_dvp);
|
||||
vrele(nd.ni_dvp);
|
||||
else
|
||||
nfsrv_vput(nd.ni_dvp);
|
||||
vput(nd.ni_dvp);
|
||||
if (nd.ni_vp)
|
||||
nfsrv_vrele(nd.ni_vp);
|
||||
vrele(nd.ni_vp);
|
||||
if (pathcp)
|
||||
FREE(pathcp, M_TEMP);
|
||||
return (error);
|
||||
@ -2265,7 +2245,7 @@ nfsrv_mkdir(nfsd, slp, procp, mrq)
|
||||
dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred,
|
||||
procp);
|
||||
else {
|
||||
nfsrv_vrele(dirp);
|
||||
vrele(dirp);
|
||||
dirp = (struct vnode *)0;
|
||||
}
|
||||
}
|
||||
@ -2273,7 +2253,7 @@ nfsrv_mkdir(nfsd, slp, procp, mrq)
|
||||
nfsm_reply(NFSX_WCCDATA(v3));
|
||||
nfsm_srvwcc_data(dirfor_ret, &dirfor, diraft_ret, &diraft);
|
||||
if (dirp)
|
||||
nfsrv_vrele(dirp);
|
||||
vrele(dirp);
|
||||
return (0);
|
||||
}
|
||||
VATTR_NULL(vap);
|
||||
@ -2288,10 +2268,10 @@ nfsrv_mkdir(nfsd, slp, procp, mrq)
|
||||
if (vp != NULL) {
|
||||
VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
|
||||
if (nd.ni_dvp == vp)
|
||||
nfsrv_vrele(nd.ni_dvp);
|
||||
vrele(nd.ni_dvp);
|
||||
else
|
||||
nfsrv_vput(nd.ni_dvp);
|
||||
nfsrv_vrele(vp);
|
||||
vput(nd.ni_dvp);
|
||||
vrele(vp);
|
||||
error = EEXIST;
|
||||
goto out;
|
||||
}
|
||||
@ -2304,12 +2284,12 @@ nfsrv_mkdir(nfsd, slp, procp, mrq)
|
||||
error = VFS_VPTOFH(vp, &fhp->fh_fid);
|
||||
if (!error)
|
||||
error = VOP_GETATTR(vp, vap, cred, procp);
|
||||
nfsrv_vput(vp);
|
||||
vput(vp);
|
||||
}
|
||||
out:
|
||||
if (dirp) {
|
||||
diraft_ret = VOP_GETATTR(dirp, &diraft, cred, procp);
|
||||
nfsrv_vrele(dirp);
|
||||
vrele(dirp);
|
||||
}
|
||||
nfsm_reply(NFSX_SRVFH(v3) + NFSX_POSTOPATTR(v3) + NFSX_WCCDATA(v3));
|
||||
if (v3) {
|
||||
@ -2326,14 +2306,14 @@ nfsrv_mkdir(nfsd, slp, procp, mrq)
|
||||
return (0);
|
||||
nfsmout:
|
||||
if (dirp)
|
||||
nfsrv_vrele(dirp);
|
||||
vrele(dirp);
|
||||
VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
|
||||
if (nd.ni_dvp == nd.ni_vp)
|
||||
nfsrv_vrele(nd.ni_dvp);
|
||||
vrele(nd.ni_dvp);
|
||||
else
|
||||
nfsrv_vput(nd.ni_dvp);
|
||||
vput(nd.ni_dvp);
|
||||
if (nd.ni_vp)
|
||||
nfsrv_vrele(nd.ni_vp);
|
||||
vrele(nd.ni_vp);
|
||||
return (error);
|
||||
}
|
||||
|
||||
@ -2378,7 +2358,7 @@ nfsrv_rmdir(nfsd, slp, procp, mrq)
|
||||
dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred,
|
||||
procp);
|
||||
else {
|
||||
nfsrv_vrele(dirp);
|
||||
vrele(dirp);
|
||||
dirp = (struct vnode *)0;
|
||||
}
|
||||
}
|
||||
@ -2386,7 +2366,7 @@ nfsrv_rmdir(nfsd, slp, procp, mrq)
|
||||
nfsm_reply(NFSX_WCCDATA(v3));
|
||||
nfsm_srvwcc_data(dirfor_ret, &dirfor, diraft_ret, &diraft);
|
||||
if (dirp)
|
||||
nfsrv_vrele(dirp);
|
||||
vrele(dirp);
|
||||
return (0);
|
||||
}
|
||||
vp = nd.ni_vp;
|
||||
@ -2414,14 +2394,14 @@ nfsrv_rmdir(nfsd, slp, procp, mrq)
|
||||
} else {
|
||||
VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
|
||||
if (nd.ni_dvp == nd.ni_vp)
|
||||
nfsrv_vrele(nd.ni_dvp);
|
||||
vrele(nd.ni_dvp);
|
||||
else
|
||||
nfsrv_vput(nd.ni_dvp);
|
||||
nfsrv_vput(vp);
|
||||
vput(nd.ni_dvp);
|
||||
vput(vp);
|
||||
}
|
||||
if (dirp) {
|
||||
diraft_ret = VOP_GETATTR(dirp, &diraft, cred, procp);
|
||||
nfsrv_vrele(dirp);
|
||||
vrele(dirp);
|
||||
}
|
||||
nfsm_reply(NFSX_WCCDATA(v3));
|
||||
if (v3) {
|
||||
@ -2535,7 +2515,7 @@ nfsrv_readdir(nfsd, slp, procp, mrq)
|
||||
if (!error)
|
||||
error = nfsrv_access(vp, VEXEC, cred, rdonly, procp);
|
||||
if (error) {
|
||||
nfsrv_vput(vp);
|
||||
vput(vp);
|
||||
nfsm_reply(NFSX_POSTOPATTR(v3));
|
||||
nfsm_srvpostop_attr(getret, &at);
|
||||
return (0);
|
||||
@ -2578,7 +2558,7 @@ nfsrv_readdir(nfsd, slp, procp, mrq)
|
||||
}
|
||||
VOP_UNLOCK(vp);
|
||||
if (error) {
|
||||
nfsrv_vrele(vp);
|
||||
vrele(vp);
|
||||
free((caddr_t)rbuf, M_TEMP);
|
||||
if (cookies)
|
||||
free((caddr_t)cookies, M_TEMP);
|
||||
@ -2594,7 +2574,7 @@ nfsrv_readdir(nfsd, slp, procp, mrq)
|
||||
* rpc reply
|
||||
*/
|
||||
if (siz == 0) {
|
||||
nfsrv_vrele(vp);
|
||||
vrele(vp);
|
||||
nfsm_reply(NFSX_POSTOPATTR(v3) + NFSX_COOKIEVERF(v3) +
|
||||
2 * NFSX_UNSIGNED);
|
||||
if (v3) {
|
||||
@ -2720,7 +2700,7 @@ nfsrv_readdir(nfsd, slp, procp, mrq)
|
||||
cookiep++;
|
||||
ncookies--;
|
||||
}
|
||||
nfsrv_vrele(vp);
|
||||
vrele(vp);
|
||||
nfsm_clget;
|
||||
*tl = nfs_false;
|
||||
bp += NFSX_UNSIGNED;
|
||||
@ -2802,7 +2782,7 @@ nfsrv_readdirplus(nfsd, slp, procp, mrq)
|
||||
error = nfsrv_access(vp, VEXEC, cred, rdonly, procp);
|
||||
}
|
||||
if (error) {
|
||||
nfsrv_vput(vp);
|
||||
vput(vp);
|
||||
nfsm_reply(NFSX_V3POSTOPATTR);
|
||||
nfsm_srvpostop_attr(getret, &at);
|
||||
return (0);
|
||||
@ -2843,7 +2823,7 @@ nfsrv_readdirplus(nfsd, slp, procp, mrq)
|
||||
if (!error)
|
||||
error = getret;
|
||||
if (error) {
|
||||
nfsrv_vrele(vp);
|
||||
vrele(vp);
|
||||
if (cookies)
|
||||
free((caddr_t)cookies, M_TEMP);
|
||||
free((caddr_t)rbuf, M_TEMP);
|
||||
@ -2859,7 +2839,7 @@ nfsrv_readdirplus(nfsd, slp, procp, mrq)
|
||||
* rpc reply
|
||||
*/
|
||||
if (siz == 0) {
|
||||
nfsrv_vrele(vp);
|
||||
vrele(vp);
|
||||
nfsm_reply(NFSX_V3POSTOPATTR + NFSX_V3COOKIEVERF +
|
||||
2 * NFSX_UNSIGNED);
|
||||
nfsm_srvpostop_attr(getret, &at);
|
||||
@ -2912,7 +2892,7 @@ nfsrv_readdirplus(nfsd, slp, procp, mrq)
|
||||
*/
|
||||
if (VFS_VGET(vp->v_mount, dp->d_fileno, &nvp) == EOPNOTSUPP) {
|
||||
error = NFSERR_NOTSUPP;
|
||||
nfsrv_vrele(vp);
|
||||
vrele(vp);
|
||||
free((caddr_t)cookies, M_TEMP);
|
||||
free((caddr_t)rbuf, M_TEMP);
|
||||
nfsm_reply(NFSX_V3POSTOPATTR);
|
||||
@ -3036,7 +3016,7 @@ nfsrv_readdirplus(nfsd, slp, procp, mrq)
|
||||
cookiep++;
|
||||
ncookies--;
|
||||
}
|
||||
nfsrv_vrele(vp);
|
||||
vrele(vp);
|
||||
nfsm_clget;
|
||||
*tl = nfs_false;
|
||||
bp += NFSX_UNSIGNED;
|
||||
@ -3105,7 +3085,7 @@ nfsrv_commit(nfsd, slp, procp, mrq)
|
||||
for_ret = VOP_GETATTR(vp, &bfor, cred, procp);
|
||||
error = VOP_FSYNC(vp, cred, MNT_WAIT, procp);
|
||||
aft_ret = VOP_GETATTR(vp, &aft, cred, procp);
|
||||
nfsrv_vput(vp);
|
||||
vput(vp);
|
||||
nfsm_reply(NFSX_V3WCCDATA + NFSX_V3WRITEVERF);
|
||||
nfsm_srvwcc_data(for_ret, &bfor, aft_ret, &aft);
|
||||
if (!error) {
|
||||
@ -3161,7 +3141,7 @@ nfsrv_statfs(nfsd, slp, procp, mrq)
|
||||
sf = &statfs;
|
||||
error = VFS_STATFS(vp->v_mount, sf, procp);
|
||||
getret = VOP_GETATTR(vp, &at, cred, procp);
|
||||
nfsrv_vput(vp);
|
||||
vput(vp);
|
||||
nfsm_reply(NFSX_POSTOPATTR(v3) + NFSX_STATFS(v3));
|
||||
if (v3)
|
||||
nfsm_srvpostop_attr(getret, &at);
|
||||
@ -3234,7 +3214,7 @@ nfsrv_fsinfo(nfsd, slp, procp, mrq)
|
||||
return (0);
|
||||
}
|
||||
getret = VOP_GETATTR(vp, &at, cred, procp);
|
||||
nfsrv_vput(vp);
|
||||
vput(vp);
|
||||
nfsm_reply(NFSX_V3POSTOPATTR + NFSX_V3FSINFO);
|
||||
nfsm_srvpostop_attr(getret, &at);
|
||||
nfsm_build(sip, struct nfsv3_fsinfo *, NFSX_V3FSINFO);
|
||||
@ -3312,7 +3292,7 @@ nfsrv_pathconf(nfsd, slp, procp, mrq)
|
||||
if (!error)
|
||||
error = VOP_PATHCONF(vp, _PC_NO_TRUNC, ¬runc);
|
||||
getret = VOP_GETATTR(vp, &at, cred, procp);
|
||||
nfsrv_vput(vp);
|
||||
vput(vp);
|
||||
nfsm_reply(NFSX_V3POSTOPATTR + NFSX_V3PATHCONF);
|
||||
nfsm_srvpostop_attr(getret, &at);
|
||||
if (error)
|
||||
|
@ -34,7 +34,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)nfs_subs.c 8.3 (Berkeley) 1/4/94
|
||||
* $Id: nfs_subs.c,v 1.30 1996/06/23 17:19:25 bde Exp $
|
||||
* $Id: nfs_subs.c,v 1.31 1996/07/16 10:19:44 dfr Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -1486,7 +1486,7 @@ nfs_namei(ndp, fhp, len, slp, nam, mdp, dposp, retdirp, p, kerbflag)
|
||||
nam, &rdonly, kerbflag))
|
||||
goto out;
|
||||
if (dp->v_type != VDIR) {
|
||||
nfsrv_vrele(dp);
|
||||
vrele(dp);
|
||||
error = ENOTDIR;
|
||||
goto out;
|
||||
}
|
||||
@ -1517,7 +1517,7 @@ nfs_namei(ndp, fhp, len, slp, nam, mdp, dposp, retdirp, p, kerbflag)
|
||||
goto out;
|
||||
}
|
||||
|
||||
nfsrv_vmio(ndp->ni_vp);
|
||||
nfsrv_object_create(ndp->ni_vp);
|
||||
|
||||
/*
|
||||
* Check for saved name request
|
||||
@ -1748,7 +1748,7 @@ nfsrv_fhtovp(fhp, lockflag, vpp, cred, slp, nam, rdonlyp, kerbflag)
|
||||
else
|
||||
*rdonlyp = 0;
|
||||
|
||||
nfsrv_vmio(*vpp);
|
||||
nfsrv_object_create(*vpp);
|
||||
|
||||
if (!lockflag)
|
||||
VOP_UNLOCK(*vpp);
|
||||
@ -1940,53 +1940,10 @@ nfsrv_errmap(nd, err)
|
||||
}
|
||||
|
||||
int
|
||||
nfsrv_vmio(struct vnode *vp) {
|
||||
vm_object_t object;
|
||||
nfsrv_object_create(struct vnode *vp) {
|
||||
|
||||
if ((vp == NULL) || (vp->v_type != VREG))
|
||||
return 1;
|
||||
|
||||
retry:
|
||||
if ((vp->v_flag & VVMIO) == 0) {
|
||||
struct vattr vat;
|
||||
struct proc *p = curproc;
|
||||
|
||||
if (VOP_GETATTR(vp, &vat, p->p_ucred, p) != 0)
|
||||
panic("nfsrv_vmio: VOP_GETATTR failed");
|
||||
|
||||
(void) vnode_pager_alloc(vp, OFF_TO_IDX(round_page(vat.va_size)), 0, 0);
|
||||
|
||||
vp->v_flag |= VVMIO;
|
||||
} else {
|
||||
if ((object = vp->v_object) &&
|
||||
(object->flags & OBJ_DEAD)) {
|
||||
tsleep(object, PVM, "nfdead", 0);
|
||||
goto retry;
|
||||
}
|
||||
if (!object)
|
||||
panic("nfsrv_vmio: VMIO object missing");
|
||||
vm_object_reference(object);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
int
|
||||
nfsrv_vput(struct vnode *vp) {
|
||||
if ((vp->v_flag & VVMIO) && vp->v_object) {
|
||||
vput(vp);
|
||||
vm_object_deallocate(vp->v_object);
|
||||
} else {
|
||||
vput(vp);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
int
|
||||
nfsrv_vrele(struct vnode *vp) {
|
||||
if ((vp->v_flag & VVMIO) && vp->v_object) {
|
||||
vrele(vp);
|
||||
vm_object_deallocate(vp->v_object);
|
||||
} else {
|
||||
vrele(vp);
|
||||
}
|
||||
return 0;
|
||||
return vfs_object_create(vp, curproc, curproc?curproc->p_ucred:NULL, 1);
|
||||
}
|
||||
#endif /* NFS_NOSERVER */
|
||||
|
@ -34,7 +34,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)nfs.h 8.1 (Berkeley) 6/10/93
|
||||
* $Id: nfs.h,v 1.16 1995/12/17 21:12:05 phk Exp $
|
||||
* $Id: nfs.h,v 1.17 1996/01/30 22:59:39 mpp Exp $
|
||||
*/
|
||||
|
||||
#ifndef _NFS_NFS_H_
|
||||
@ -535,9 +535,7 @@ void nfsrv_rcv __P((struct socket *so, caddr_t arg, int waitflag));
|
||||
void nfsrvw_sort __P((gid_t [],int));
|
||||
void nfsrv_setcred __P((struct ucred *,struct ucred *));
|
||||
int nfs_writebp __P((struct buf *,int));
|
||||
int nfsrv_vput __P(( struct vnode * ));
|
||||
int nfsrv_vrele __P(( struct vnode * ));
|
||||
int nfsrv_vmio __P(( struct vnode * ));
|
||||
int nfsrv_object_create __P(( struct vnode * ));
|
||||
void nfsrv_wakenfsd __P((struct nfssvc_sock *slp));
|
||||
int nfsrv_writegather __P((struct nfsrv_descript **, struct nfssvc_sock *,
|
||||
struct proc *, struct mbuf **));
|
||||
|
@ -31,7 +31,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)vnode.h 8.7 (Berkeley) 2/4/94
|
||||
* $Id: vnode.h,v 1.32 1996/03/29 06:39:39 davidg Exp $
|
||||
* $Id: vnode.h,v 1.33 1996/05/31 00:20:32 peter Exp $
|
||||
*/
|
||||
|
||||
#ifndef _SYS_VNODE_H_
|
||||
@ -68,6 +68,7 @@ enum vtagtype {
|
||||
LIST_HEAD(buflists, buf);
|
||||
|
||||
typedef int vop_t __P((void *));
|
||||
struct vm_object;
|
||||
|
||||
struct vnode {
|
||||
u_long v_flag; /* vnode flags (see below) */
|
||||
@ -98,7 +99,7 @@ struct vnode {
|
||||
int v_ralen; /* Read-ahead length */
|
||||
int v_usage; /* Vnode usage counter */
|
||||
daddr_t v_maxra; /* last readahead block */
|
||||
void *v_object; /* Place to store VM object */
|
||||
struct vm_object *v_object; /* Place to store VM object */
|
||||
enum vtagtype v_tag; /* type of underlying data */
|
||||
void *v_data; /* private data for fs */
|
||||
};
|
||||
@ -213,7 +214,7 @@ void vhold __P((struct vnode *));
|
||||
#define HOLDRELE(vp) (vp)->v_holdcnt-- /* decrease buf or page ref */
|
||||
#define VATTR_NULL(vap) (*(vap) = va_null) /* initialize a vattr */
|
||||
#define VHOLD(vp) (vp)->v_holdcnt++ /* increase buf or page ref */
|
||||
#define VREF(vp) (vp)->v_usecount++ /* increase reference */
|
||||
#define VREF(vp) vref(vp) /* increase reference */
|
||||
#endif
|
||||
|
||||
#define NULLVP ((struct vnode *)NULL)
|
||||
@ -422,9 +423,8 @@ int vn_rdwr __P((enum uio_rw rw, struct vnode *vp, caddr_t base,
|
||||
int len, off_t offset, enum uio_seg segflg, int ioflg,
|
||||
struct ucred *cred, int *aresid, struct proc *p));
|
||||
int vn_stat __P((struct vnode *vp, struct stat *sb, struct proc *p));
|
||||
void vn_vmio_close __P((struct vnode *vp));
|
||||
int vn_vmio_open __P((struct vnode *vp, struct proc *p,
|
||||
struct ucred *cred));
|
||||
int vfs_object_create __P((struct vnode *vp, struct proc *p,
|
||||
struct ucred *cred, int waslocked));
|
||||
int vn_writechk __P((struct vnode *vp));
|
||||
void vprint __P((char *label, struct vnode *vp));
|
||||
void vput __P((struct vnode *vp));
|
||||
|
@ -31,7 +31,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)ffs_vfsops.c 8.8 (Berkeley) 4/18/94
|
||||
* $Id: ffs_vfsops.c,v 1.38 1996/03/02 22:18:34 dyson Exp $
|
||||
* $Id: ffs_vfsops.c,v 1.39 1996/06/12 03:37:51 davidg Exp $
|
||||
*/
|
||||
|
||||
#include "opt_quota.h"
|
||||
@ -67,6 +67,7 @@
|
||||
#include <vm/vm_prot.h>
|
||||
#include <vm/vm_page.h>
|
||||
#include <vm/vm_object.h>
|
||||
#include <vm/vm_extern.h>
|
||||
|
||||
static int ffs_sbupdate __P((struct ufsmount *, int));
|
||||
static int ffs_reload __P((struct mount *,struct ucred *,struct proc *));
|
||||
@ -468,6 +469,7 @@ ffs_mountfs(devvp, mp, p)
|
||||
int error, i, size;
|
||||
int ronly;
|
||||
u_int strsize;
|
||||
int ncount;
|
||||
|
||||
/*
|
||||
* Disallow multiple mounts of the same device.
|
||||
@ -478,7 +480,10 @@ ffs_mountfs(devvp, mp, p)
|
||||
error = vfs_mountedon(devvp);
|
||||
if (error)
|
||||
return (error);
|
||||
if (vcount(devvp) > 1 && devvp != rootvp)
|
||||
ncount = vcount(devvp);
|
||||
if (devvp->v_object)
|
||||
ncount -= 1;
|
||||
if (ncount > 1 && devvp != rootvp)
|
||||
return (EBUSY);
|
||||
error = vinvalbuf(devvp, V_SAVE, p->p_ucred, p, 0, 0);
|
||||
if (error)
|
||||
@ -587,9 +592,11 @@ ffs_mountfs(devvp, mp, p)
|
||||
/*
|
||||
* Only VMIO the backing device if the backing device is a real
|
||||
* block device. This excludes the original MFS implementation.
|
||||
* Note that it is optional that the backing device be VMIOed. This
|
||||
* increases the opportunity for metadata caching.
|
||||
*/
|
||||
if ((devvp->v_type == VBLK) && (major(devvp->v_rdev) < nblkdev)) {
|
||||
vn_vmio_open(devvp, p, p->p_ucred);
|
||||
vfs_object_create(devvp, p, p->p_ucred, 0);
|
||||
}
|
||||
return (0);
|
||||
out:
|
||||
@ -663,9 +670,14 @@ ffs_unmount(mp, mntflags, p)
|
||||
ffs_sbupdate(ump, MNT_WAIT);
|
||||
}
|
||||
ump->um_devvp->v_specflags &= ~SI_MOUNTEDON;
|
||||
|
||||
vnode_pager_uncache(ump->um_devvp);
|
||||
|
||||
error = VOP_CLOSE(ump->um_devvp, ronly ? FREAD : FREAD|FWRITE,
|
||||
NOCRED, p);
|
||||
vn_vmio_close(ump->um_devvp);
|
||||
|
||||
vrele(ump->um_devvp);
|
||||
|
||||
free(fs->fs_csp[0], M_UFSMNT);
|
||||
free(fs, M_UFSMNT);
|
||||
free(ump, M_UFSMNT);
|
||||
|
@ -61,7 +61,7 @@
|
||||
* any improvements or extensions that they make and grant Carnegie the
|
||||
* rights to redistribute these changes.
|
||||
*
|
||||
* $Id: vm_object.c,v 1.77 1996/07/27 03:24:03 dyson Exp $
|
||||
* $Id: vm_object.c,v 1.78 1996/07/30 03:08:14 dyson Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -231,7 +231,7 @@ vm_object_allocate(type, size)
|
||||
*
|
||||
* Gets another reference to the given object.
|
||||
*/
|
||||
inline void
|
||||
void
|
||||
vm_object_reference(object)
|
||||
register vm_object_t object;
|
||||
{
|
||||
@ -332,7 +332,9 @@ vm_object_deallocate(object)
|
||||
*/
|
||||
if (object->flags & OBJ_CANPERSIST) {
|
||||
if (object->resident_page_count != 0) {
|
||||
#if 0
|
||||
vm_object_page_clean(object, 0, 0 ,TRUE, TRUE);
|
||||
#endif
|
||||
TAILQ_INSERT_TAIL(&vm_object_cached_list, object,
|
||||
cached_list);
|
||||
vm_object_cached++;
|
||||
@ -392,11 +394,15 @@ vm_object_terminate(object)
|
||||
*/
|
||||
if (object->type == OBJT_VNODE) {
|
||||
struct vnode *vp = object->handle;
|
||||
int waslocked;
|
||||
|
||||
VOP_LOCK(vp);
|
||||
waslocked = VOP_ISLOCKED(vp);
|
||||
if (!waslocked)
|
||||
VOP_LOCK(vp);
|
||||
vm_object_page_clean(object, 0, 0, TRUE, FALSE);
|
||||
vinvalbuf(vp, V_SAVE, NOCRED, NULL, 0, 0);
|
||||
VOP_UNLOCK(vp);
|
||||
if (!waslocked)
|
||||
VOP_UNLOCK(vp);
|
||||
}
|
||||
/*
|
||||
* Now free the pages. For internal objects, this also removes them
|
||||
|
@ -61,7 +61,7 @@
|
||||
* any improvements or extensions that they make and grant Carnegie the
|
||||
* rights to redistribute these changes.
|
||||
*
|
||||
* $Id: vm_object.h,v 1.27 1996/03/02 02:54:23 dyson Exp $
|
||||
* $Id: vm_object.h,v 1.28 1996/05/19 07:36:50 dyson Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -130,6 +130,7 @@ struct vm_object {
|
||||
#define OBJ_WRITEABLE 0x0080 /* object has been made writable */
|
||||
#define OBJ_MIGHTBEDIRTY 0x0100 /* object might be dirty */
|
||||
#define OBJ_CLEANING 0x0200
|
||||
#define OBJ_VFS_REF 0x0400 /* object is refed by vfs layer */
|
||||
|
||||
|
||||
#define OBJ_NORMAL 0x0 /* default behavior */
|
||||
|
@ -38,7 +38,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* from: @(#)vnode_pager.c 7.5 (Berkeley) 4/20/91
|
||||
* $Id: vnode_pager.c,v 1.61 1996/07/27 03:24:10 dyson Exp $
|
||||
* $Id: vnode_pager.c,v 1.62 1996/07/30 03:08:21 dyson Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -151,7 +151,7 @@ vnode_pager_alloc(handle, size, prot, offset)
|
||||
/*
|
||||
* Hold a reference to the vnode and initialize object data.
|
||||
*/
|
||||
VREF(vp);
|
||||
vp->v_usecount++;
|
||||
object->un_pager.vnp.vnp_size = (vm_ooffset_t) size * PAGE_SIZE;
|
||||
|
||||
object->handle = handle;
|
||||
|
Loading…
Reference in New Issue
Block a user