g/c smbfs_getpages()/smbfs_putpages() we don't use on NetBSD
This commit is contained in:
parent
53dbc17caf
commit
c3fb3ac103
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: smbfs_io.c,v 1.4 2003/02/21 20:19:00 jdolecek Exp $ */
|
||||
/* $NetBSD: smbfs_io.c,v 1.5 2003/02/23 17:28:01 jdolecek Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2000-2001, Boris Popov
|
||||
|
@ -392,235 +392,6 @@ smbfs_doio(struct buf *bp, struct ucred *cr, struct proc *p)
|
|||
return error;
|
||||
}
|
||||
|
||||
#ifndef __NetBSD__
|
||||
/*
|
||||
* Vnode op for VM getpages.
|
||||
* Wish wish .... get rid from multiple IO routines
|
||||
*/
|
||||
int
|
||||
smbfs_getpages(ap)
|
||||
struct vop_getpages_args /* {
|
||||
struct vnode *a_vp;
|
||||
vm_page_t *a_m;
|
||||
int a_count;
|
||||
int a_reqpage;
|
||||
vm_ooffset_t a_offset;
|
||||
} */ *ap;
|
||||
{
|
||||
#ifdef SMBFS_RWGENERIC
|
||||
return vop_stdgetpages(ap);
|
||||
#else
|
||||
int i, error, nextoff, size, toff, npages, count;
|
||||
struct uio uio;
|
||||
struct iovec iov;
|
||||
vm_offset_t kva;
|
||||
struct buf *bp;
|
||||
struct vnode *vp;
|
||||
struct proc *p;
|
||||
struct ucred *cred;
|
||||
struct smbmount *smp;
|
||||
struct smbnode *np;
|
||||
struct smb_cred scred;
|
||||
vm_page_t *pages;
|
||||
|
||||
vp = ap->a_vp;
|
||||
p = curproc;
|
||||
cred = td->td_proc->p_ucred; /* XXX */
|
||||
np = VTOSMB(vp);
|
||||
smp = VFSTOSMBFS(vp->v_mount);
|
||||
pages = ap->a_m;
|
||||
count = ap->a_count;
|
||||
|
||||
if (vp->v_object == NULL) {
|
||||
printf("smbfs_getpages: called with non-merged cache vnode??\n");
|
||||
return VM_PAGER_ERROR;
|
||||
}
|
||||
smb_makescred(&scred, td, cred);
|
||||
|
||||
#if __FreeBSD_version >= 400000
|
||||
bp = getpbuf(&smbfs_pbuf_freecnt);
|
||||
#else
|
||||
bp = getpbuf();
|
||||
#endif
|
||||
npages = btoc(count);
|
||||
kva = (vm_offset_t) bp->b_data;
|
||||
pmap_qenter(kva, pages, npages);
|
||||
cnt.v_vnodein++;
|
||||
cnt.v_vnodepgsin += count;
|
||||
|
||||
iov.iov_base = (caddr_t) kva;
|
||||
iov.iov_len = count;
|
||||
uio.uio_iov = &iov;
|
||||
uio.uio_iovcnt = 1;
|
||||
uio.uio_offset = IDX_TO_OFF(pages[0]->pindex);
|
||||
uio.uio_resid = count;
|
||||
uio.uio_segflg = UIO_SYSSPACE;
|
||||
uio.uio_rw = UIO_READ;
|
||||
uio.uio_td = td;
|
||||
|
||||
error = smb_read(smp->sm_share, np->n_fid, &uio, &scred);
|
||||
pmap_qremove(kva, npages);
|
||||
|
||||
#if __FreeBSD_version >= 400000
|
||||
relpbuf(bp, &smbfs_pbuf_freecnt);
|
||||
#else
|
||||
relpbuf(bp);
|
||||
#endif
|
||||
|
||||
if (error && (uio.uio_resid == count)) {
|
||||
printf("smbfs_getpages: error %d\n",error);
|
||||
for (i = 0; i < npages; i++) {
|
||||
if (ap->a_reqpage != i)
|
||||
vm_page_free(pages[i]);
|
||||
}
|
||||
return VM_PAGER_ERROR;
|
||||
}
|
||||
|
||||
size = count - uio.uio_resid;
|
||||
|
||||
for (i = 0, toff = 0; i < npages; i++, toff = nextoff) {
|
||||
vm_page_t m;
|
||||
nextoff = toff + PAGE_SIZE;
|
||||
m = pages[i];
|
||||
|
||||
m->flags &= ~PG_ZERO;
|
||||
|
||||
if (nextoff <= size) {
|
||||
m->valid = VM_PAGE_BITS_ALL;
|
||||
vm_page_undirty(m);
|
||||
} else {
|
||||
int nvalid = ((size + DEV_BSIZE - 1) - toff) & ~(DEV_BSIZE - 1);
|
||||
vm_page_set_validclean(m, 0, nvalid);
|
||||
}
|
||||
|
||||
if (i != ap->a_reqpage) {
|
||||
/*
|
||||
* Whether or not to leave the page activated is up in
|
||||
* the air, but we should put the page on a page queue
|
||||
* somewhere (it already is in the object). Result:
|
||||
* It appears that emperical results show that
|
||||
* deactivating pages is best.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Just in case someone was asking for this page we
|
||||
* now tell them that it is ok to use.
|
||||
*/
|
||||
if (!error) {
|
||||
if (m->flags & PG_WANTED)
|
||||
vm_page_activate(m);
|
||||
else
|
||||
vm_page_deactivate(m);
|
||||
vm_page_wakeup(m);
|
||||
} else {
|
||||
vm_page_free(m);
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
#endif /* SMBFS_RWGENERIC */
|
||||
}
|
||||
|
||||
/*
|
||||
* Vnode op for VM putpages.
|
||||
* possible bug: all IO done in sync mode
|
||||
* Note that vop_close always invalidate pages before close, so it's
|
||||
* not necessary to open vnode.
|
||||
*/
|
||||
int
|
||||
smbfs_putpages(ap)
|
||||
struct vop_putpages_args /* {
|
||||
struct vnode *a_vp;
|
||||
vm_page_t *a_m;
|
||||
int a_count;
|
||||
int a_sync;
|
||||
int *a_rtvals;
|
||||
vm_ooffset_t a_offset;
|
||||
} */ *ap;
|
||||
{
|
||||
int error;
|
||||
struct vnode *vp = ap->a_vp;
|
||||
struct thread *td;
|
||||
struct ucred *cred;
|
||||
|
||||
#ifdef SMBFS_RWGENERIC
|
||||
td = curthread; /* XXX */
|
||||
cred = td->td_proc->p_ucred; /* XXX */
|
||||
VOP_OPEN(vp, FWRITE, cred, td);
|
||||
error = vop_stdputpages(ap);
|
||||
VOP_CLOSE(vp, FWRITE, cred, td);
|
||||
return error;
|
||||
#else
|
||||
struct uio uio;
|
||||
struct iovec iov;
|
||||
vm_offset_t kva;
|
||||
struct buf *bp;
|
||||
int i, npages, count;
|
||||
int *rtvals;
|
||||
struct smbmount *smp;
|
||||
struct smbnode *np;
|
||||
struct smb_cred scred;
|
||||
vm_page_t *pages;
|
||||
|
||||
td = curthread; /* XXX */
|
||||
cred = td->td_proc->p_ucred; /* XXX */
|
||||
/* VOP_OPEN(vp, FWRITE, cred, td);*/
|
||||
np = VTOSMB(vp);
|
||||
smp = VFSTOSMBFS(vp->v_mount);
|
||||
pages = ap->a_m;
|
||||
count = ap->a_count;
|
||||
rtvals = ap->a_rtvals;
|
||||
npages = btoc(count);
|
||||
|
||||
for (i = 0; i < npages; i++) {
|
||||
rtvals[i] = VM_PAGER_AGAIN;
|
||||
}
|
||||
|
||||
#if __FreeBSD_version >= 400000
|
||||
bp = getpbuf(&smbfs_pbuf_freecnt);
|
||||
#else
|
||||
bp = getpbuf();
|
||||
#endif
|
||||
kva = (vm_offset_t) bp->b_data;
|
||||
pmap_qenter(kva, pages, npages);
|
||||
cnt.v_vnodeout++;
|
||||
cnt.v_vnodepgsout += count;
|
||||
|
||||
iov.iov_base = (caddr_t) kva;
|
||||
iov.iov_len = count;
|
||||
uio.uio_iov = &iov;
|
||||
uio.uio_iovcnt = 1;
|
||||
uio.uio_offset = IDX_TO_OFF(pages[0]->pindex);
|
||||
uio.uio_resid = count;
|
||||
uio.uio_segflg = UIO_SYSSPACE;
|
||||
uio.uio_rw = UIO_WRITE;
|
||||
uio.uio_td = td;
|
||||
SMBVDEBUG("ofs=%d,resid=%d\n",(int)uio.uio_offset, uio.uio_resid);
|
||||
|
||||
smb_makescred(&scred, td, cred);
|
||||
error = smb_write(smp->sm_share, np->n_fid, &uio, &scred);
|
||||
/* VOP_CLOSE(vp, FWRITE, cred, td);*/
|
||||
SMBVDEBUG("paged write done: %d\n", error);
|
||||
|
||||
pmap_qremove(kva, npages);
|
||||
#if __FreeBSD_version >= 400000
|
||||
relpbuf(bp, &smbfs_pbuf_freecnt);
|
||||
#else
|
||||
relpbuf(bp);
|
||||
#endif
|
||||
|
||||
if (!error) {
|
||||
int nwritten = round_page(count - uio.uio_resid) / PAGE_SIZE;
|
||||
for (i = 0; i < nwritten; i++) {
|
||||
rtvals[i] = VM_PAGER_OK;
|
||||
vm_page_undirty(pages[i]);
|
||||
}
|
||||
}
|
||||
return rtvals[0];
|
||||
#endif /* SMBFS_RWGENERIC */
|
||||
}
|
||||
#endif /* !__NetBSD__ */
|
||||
|
||||
/*
|
||||
* Flush and invalidate all dirty buffers. If another process is already
|
||||
* doing the flush, just wait for completion.
|
||||
|
|
Loading…
Reference in New Issue