summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrwatson <rwatson@FreeBSD.org>2007-07-11 21:32:08 +0000
committerrwatson <rwatson@FreeBSD.org>2007-07-11 21:32:08 +0000
commit4f942d92aa035ca844a5c3963c110132a8b82226 (patch)
treece2366253733b52e5002cf7e4e685bb4b5a3dcbb
parentc2081368d230e2160f4ab899eadf89a0201e6bbb (diff)
downloadFreeBSD-src-4f942d92aa035ca844a5c3963c110132a8b82226.zip
FreeBSD-src-4f942d92aa035ca844a5c3963c110132a8b82226.tar.gz
Replace CODA_OPEN with CODA_OPEN_BY_FD: coda_open was disabled because
we can't open container files by device/inode number pair anymore. Replace the CODA_OPEN upcall with CODA_OPEN_BY_FD, where venus returns an open file descriptor for the container file. We can then grab a reference on the vnode coda_psdev.c:vc_nb_write and use this vnode for further accesses to the container file. Submitted by: Jan Harkes <jaharkes@cs.cmu.edu> Approved by: re (kensmith)
-rw-r--r--sys/coda/cnode.h2
-rw-r--r--sys/coda/coda.h2
-rw-r--r--sys/coda/coda_psdev.c23
-rw-r--r--sys/coda/coda_venus.c19
-rw-r--r--sys/coda/coda_venus.h2
-rw-r--r--sys/coda/coda_vnops.c137
-rw-r--r--sys/fs/coda/cnode.h2
-rw-r--r--sys/fs/coda/coda.h2
-rw-r--r--sys/fs/coda/coda_psdev.c23
-rw-r--r--sys/fs/coda/coda_venus.c19
-rw-r--r--sys/fs/coda/coda_venus.h2
-rw-r--r--sys/fs/coda/coda_vnops.c137
12 files changed, 108 insertions, 262 deletions
diff --git a/sys/coda/cnode.h b/sys/coda/cnode.h
index 0504c74..bf77288 100644
--- a/sys/coda/cnode.h
+++ b/sys/coda/cnode.h
@@ -107,8 +107,6 @@ struct cnode {
struct vattr c_vattr; /* attributes */
char *c_symlink; /* pointer to symbolic link */
u_short c_symlen; /* length of symbolic link */
- struct cdev *c_device; /* associated vnode device */
- ino_t c_inode; /* associated vnode inode */
struct cnode *c_next; /* links if on NetBSD machine */
};
#define VTOC(vp) ((struct cnode *)(vp)->v_data)
diff --git a/sys/coda/coda.h b/sys/coda/coda.h
index 7cc6277..93547a4 100644
--- a/sys/coda/coda.h
+++ b/sys/coda/coda.h
@@ -679,7 +679,7 @@ struct coda_open_by_fd_in {
struct coda_open_by_fd_out {
struct coda_out_hdr oh;
int fd;
- struct file *fh;
+ struct vnode *vp;
};
/* coda_open_by_path: */
diff --git a/sys/coda/coda_psdev.c b/sys/coda/coda_psdev.c
index b9a45a9..f62a246 100644
--- a/sys/coda/coda_psdev.c
+++ b/sys/coda/coda_psdev.c
@@ -65,6 +65,7 @@ extern int coda_nc_initialized; /* Set if cache has been initialized */
#include <sys/mutex.h>
#include <sys/poll.h>
#include <sys/proc.h>
+#include <sys/filedesc.h>
#include <coda/coda.h>
#include <coda/cnode.h>
@@ -370,9 +371,29 @@ vc_nb_write(dev, uiop, flag)
out->unique = seq;
vmp->vm_outSize = buf[0]; /* Amount of data transferred? */
vmp->vm_flags |= VM_WRITE;
+
+ error = 0;
+ if (opcode == CODA_OPEN_BY_FD) {
+ struct coda_open_by_fd_out *tmp = (struct coda_open_by_fd_out *)out;
+ struct file *fp;
+ struct vnode *vp = NULL;
+
+ if (tmp->oh.result == 0) {
+ error = getvnode(uiop->uio_td->td_proc->p_fd, tmp->fd, &fp);
+ if (!error) {
+ mtx_lock(&Giant);
+ vp = fp->f_vnode;
+ VREF(vp);
+ fdrop(fp, uiop->uio_td);
+ mtx_unlock(&Giant);
+ }
+ }
+ tmp->vp = vp;
+ }
+
wakeup(&vmp->vm_sleep);
- return(0);
+ return(error);
}
int
diff --git a/sys/coda/coda_venus.c b/sys/coda/coda_venus.c
index 56d627b..b1e044a 100644
--- a/sys/coda/coda_venus.c
+++ b/sys/coda/coda_venus.c
@@ -198,30 +198,23 @@ venus_root(void *mdp,
int
venus_open(void *mdp, CodaFid *fid, int flag,
struct ucred *cred, struct proc *p,
-/*out*/ struct cdev **dev, ino_t *inode)
+/*out*/ struct vnode **vp)
{
-#if 0
int cflag;
- DECL(coda_open); /* sets Isize & Osize */
- ALLOC(coda_open); /* sets inp & outp */
+ DECL(coda_open_by_fd); /* sets Isize & Osize */
+ ALLOC(coda_open_by_fd); /* sets inp & outp */
/* send the open to venus. */
- INIT_IN(&inp->ih, CODA_OPEN, cred, p);
+ INIT_IN(&inp->ih, CODA_OPEN_BY_FD, cred, p);
inp->Fid = *fid;
CNV_OFLAG(cflag, flag);
inp->flags = cflag;
error = coda_call(mdp, Isize, &Osize, (char *)inp);
- if (!error) {
- *dev = findcdev(outp->dev);
- *inode = outp->inode;
- }
+ *vp = error ? NULL : outp->vp;
- CODA_FREE(inp, coda_open_size);
+ CODA_FREE(inp, coda_open_by_fd_size);
return error;
-#else
- return (EOPNOTSUPP);
-#endif
}
int
diff --git a/sys/coda/coda_venus.h b/sys/coda/coda_venus.h
index 1d1e0cf..d8f0198 100644
--- a/sys/coda/coda_venus.h
+++ b/sys/coda/coda_venus.h
@@ -39,7 +39,7 @@ venus_root(void *mdp,
int
venus_open(void *mdp, CodaFid *fid, int flag,
struct ucred *cred, struct proc *p,
-/*out*/ struct cdev **dev, ino_t *inode);
+/*out*/ struct vnode **vp);
int
venus_close(void *mdp, CodaFid *fid, int flag,
diff --git a/sys/coda/coda_vnops.c b/sys/coda/coda_vnops.c
index d0b5c60..6aa32ff 100644
--- a/sys/coda/coda_vnops.c
+++ b/sys/coda/coda_vnops.c
@@ -178,9 +178,10 @@ coda_vnodeopstats_init(void)
}
/*
- * coda_open calls Venus to return the device, inode pair of the cache
- * file holding the data. Using iget, coda_open finds the vnode of the
- * cache file, and then opens it.
+ * coda_open calls Venus which returns an open file descriptor the cache
+ * file holding the data. We get the vnode while we are still in the
+ * context of the venus process in coda_psdev.c. This vnode is then
+ * passed back to the caller and opened.
*/
int
coda_open(struct vop_open_args *ap)
@@ -199,8 +200,6 @@ coda_open(struct vop_open_args *ap)
/* locals */
int error;
struct vnode *vp;
- struct cdev *dev;
- ino_t inode;
MARK_ENTRY(CODA_OPEN_STATS);
@@ -216,23 +215,12 @@ coda_open(struct vop_open_args *ap)
return(0);
}
- error = venus_open(vtomi((*vpp)), &cp->c_fid, flag, cred, td->td_proc, &dev, &inode);
+ error = venus_open(vtomi((*vpp)), &cp->c_fid, flag, cred, td->td_proc, &vp);
if (error)
return (error);
- if (!error) {
- CODADEBUG( CODA_OPEN,myprintf(("open: dev %#lx inode %lu result %d\n",
- (u_long)dev2udev(dev), (u_long)inode,
- error)); )
- }
- /* Translate the <device, inode> pair for the cache file into
- an inode pointer. */
- error = coda_grab_vnode(dev, inode, &vp);
- if (error)
- return (error);
+ CODADEBUG( CODA_OPEN,myprintf(("open: vp %p result %d\n", vp, error));)
- /* We get the vnode back locked. Needs unlocked */
- VOP_UNLOCK(vp, 0, td);
/* Keep a reference until the close comes in. */
vref(*vpp);
@@ -251,11 +239,6 @@ coda_open(struct vop_open_args *ap)
cp->c_flags &= ~C_VATTR;
}
- /* Save the <device, inode> pair for the cache file to speed
- up subsequent page_read's. */
- cp->c_device = dev;
- cp->c_inode = inode;
-
/* Open the cache file. */
error = VOP_OPEN(vp, flag, cred, td, NULL);
if (error) {
@@ -290,28 +273,13 @@ coda_close(struct vop_close_args *ap)
return(0);
}
- if (IS_UNMOUNTING(cp)) {
- if (cp->c_ovp) {
-#ifdef CODA_VERBOSE
- printf("coda_close: destroying container ref %d, ufs vp %p of vp %p/cp %p\n",
- vrefcnt(vp), cp->c_ovp, vp, cp);
-#endif
-#ifdef hmm
- vgone(cp->c_ovp);
-#else
- VOP_CLOSE(cp->c_ovp, flag, cred, td); /* Do errors matter here? */
- vrele(cp->c_ovp);
-#endif
- } else {
-#ifdef CODA_VERBOSE
- printf("coda_close: NO container vp %p/cp %p\n", vp, cp);
-#endif
- }
- return ENODEV;
- } else {
+ if (cp->c_ovp) {
VOP_CLOSE(cp->c_ovp, flag, cred, td); /* Do errors matter here? */
vrele(cp->c_ovp);
}
+#ifdef CODA_VERBOSE
+ else printf("coda_close: NO container vp %p/cp %p\n", vp, cp);
+#endif
if (--cp->c_ocount == 0)
cp->c_ovp = NULL;
@@ -319,8 +287,11 @@ coda_close(struct vop_close_args *ap)
if (flag & FWRITE) /* file was opened for write */
--cp->c_owrite;
- error = venus_close(vtomi(vp), &cp->c_fid, flag, cred, td->td_proc);
- vrele(CTOV(cp));
+ if (!IS_UNMOUNTING(cp))
+ error = venus_close(vtomi(vp), &cp->c_fid, flag, cred, td->td_proc);
+ else error = ENODEV;
+
+ vrele(vp);
CODADEBUG(CODA_CLOSE, myprintf(("close: result %d\n",error)); )
return(error);
@@ -353,12 +324,8 @@ coda_rdwr(struct vnode *vp, struct uio *uiop, enum uio_rw rw, int ioflag,
/* locals */
struct cnode *cp = VTOC(vp);
struct vnode *cfvp = cp->c_ovp;
- struct proc *p = td->td_proc;
- struct thread *ltd = td;
- int igot_internally = 0;
int opened_internally = 0;
int error = 0;
- int iscore = 0;
MARK_ENTRY(CODA_RDWR_STATS);
@@ -373,51 +340,19 @@ coda_rdwr(struct vnode *vp, struct uio *uiop, enum uio_rw rw, int ioflag,
}
/*
- * If file is not already open this must be a page
- * {read,write} request. Iget the cache file's inode
- * pointer if we still have its <device, inode> pair.
- * Otherwise, we must do an internal open to derive the
- * pair.
+ * If file is not already open this must be a page {read,write} request
+ * and we should open it internally.
*/
if (cfvp == NULL) {
- /*
- * If we're dumping core, do the internal open. Otherwise
- * venus won't have the correct size of the core when
- * it's completely written.
- */
- if (p) {
- PROC_LOCK(p);
- iscore = (p->p_acflag & ACORE);
- PROC_UNLOCK(p);
- }
- else
- ltd = curthread;
-
- if (cp->c_inode != 0 && !iscore) {
- igot_internally = 1;
- error = coda_grab_vnode(cp->c_device, cp->c_inode, &cfvp);
- if (error) {
- MARK_INT_FAIL(CODA_RDWR_STATS);
- return(error);
- }
- /*
- * We get the vnode back locked by curthread in both Mach and
- * NetBSD. Needs unlocked
- */
- VOP_UNLOCK(cfvp, 0, ltd);
- }
- else {
- opened_internally = 1;
- MARK_INT_GEN(CODA_OPEN_STATS);
- error = VOP_OPEN(vp, (rw == UIO_READ ? FREAD : FWRITE),
- cred, td, NULL);
-printf("coda_rdwr: Internally Opening %p\n", vp);
- if (error) {
+ opened_internally = 1;
+ MARK_INT_GEN(CODA_OPEN_STATS);
+ error = VOP_OPEN(vp, (rw == UIO_READ ? FREAD : FWRITE), cred, td, NULL);
+ printf("coda_rdwr: Internally Opening %p\n", vp);
+ if (error) {
printf("coda_rdwr: VOP_OPEN on container failed %d\n", error);
return (error);
- }
- cfvp = cp->c_ovp;
}
+ cfvp = cp->c_ovp;
}
/* Have UFS handle the call. */
@@ -1526,7 +1461,7 @@ coda_readdir(struct vop_readdir_args *ap)
opened_internally = 1;
MARK_INT_GEN(CODA_OPEN_STATS);
error = VOP_OPEN(vp, FREAD, cred, td, NULL);
-printf("coda_readdir: Internally Opening %p\n", vp);
+ printf("coda_readdir: Internally Opening %p\n", vp);
if (error) {
printf("coda_readdir: VOP_OPEN on container failed %d\n", error);
return (error);
@@ -1677,30 +1612,6 @@ coda_islocked(struct vop_islocked_args *ap)
return (vop_stdislocked(ap));
}
-/* How one looks up a vnode given a device/inode pair: */
-int
-coda_grab_vnode(struct cdev *dev, ino_t ino, struct vnode **vpp)
-{
- /* This is like VFS_VGET() or igetinode()! */
- int error;
- struct mount *mp;
-
- if (!(mp = devtomp(dev))) {
- myprintf(("coda_grab_vnode: devtomp(%#lx) returns NULL\n",
- (u_long)dev2udev(dev)));
- return(ENXIO);
- }
-
- /* XXX - ensure that nonzero-return means failure */
- error = VFS_VGET(mp,ino,LK_EXCLUSIVE,vpp);
- if (error) {
- myprintf(("coda_grab_vnode: iget/vget(%lx, %lu) returns %p, err %d\n",
- (u_long)dev2udev(dev), (u_long)ino, (void *)*vpp, error));
- return(ENOENT);
- }
- return(0);
-}
-
void
print_vattr(struct vattr *attr)
{
diff --git a/sys/fs/coda/cnode.h b/sys/fs/coda/cnode.h
index 0504c74..bf77288 100644
--- a/sys/fs/coda/cnode.h
+++ b/sys/fs/coda/cnode.h
@@ -107,8 +107,6 @@ struct cnode {
struct vattr c_vattr; /* attributes */
char *c_symlink; /* pointer to symbolic link */
u_short c_symlen; /* length of symbolic link */
- struct cdev *c_device; /* associated vnode device */
- ino_t c_inode; /* associated vnode inode */
struct cnode *c_next; /* links if on NetBSD machine */
};
#define VTOC(vp) ((struct cnode *)(vp)->v_data)
diff --git a/sys/fs/coda/coda.h b/sys/fs/coda/coda.h
index 7cc6277..93547a4 100644
--- a/sys/fs/coda/coda.h
+++ b/sys/fs/coda/coda.h
@@ -679,7 +679,7 @@ struct coda_open_by_fd_in {
struct coda_open_by_fd_out {
struct coda_out_hdr oh;
int fd;
- struct file *fh;
+ struct vnode *vp;
};
/* coda_open_by_path: */
diff --git a/sys/fs/coda/coda_psdev.c b/sys/fs/coda/coda_psdev.c
index b9a45a9..f62a246 100644
--- a/sys/fs/coda/coda_psdev.c
+++ b/sys/fs/coda/coda_psdev.c
@@ -65,6 +65,7 @@ extern int coda_nc_initialized; /* Set if cache has been initialized */
#include <sys/mutex.h>
#include <sys/poll.h>
#include <sys/proc.h>
+#include <sys/filedesc.h>
#include <coda/coda.h>
#include <coda/cnode.h>
@@ -370,9 +371,29 @@ vc_nb_write(dev, uiop, flag)
out->unique = seq;
vmp->vm_outSize = buf[0]; /* Amount of data transferred? */
vmp->vm_flags |= VM_WRITE;
+
+ error = 0;
+ if (opcode == CODA_OPEN_BY_FD) {
+ struct coda_open_by_fd_out *tmp = (struct coda_open_by_fd_out *)out;
+ struct file *fp;
+ struct vnode *vp = NULL;
+
+ if (tmp->oh.result == 0) {
+ error = getvnode(uiop->uio_td->td_proc->p_fd, tmp->fd, &fp);
+ if (!error) {
+ mtx_lock(&Giant);
+ vp = fp->f_vnode;
+ VREF(vp);
+ fdrop(fp, uiop->uio_td);
+ mtx_unlock(&Giant);
+ }
+ }
+ tmp->vp = vp;
+ }
+
wakeup(&vmp->vm_sleep);
- return(0);
+ return(error);
}
int
diff --git a/sys/fs/coda/coda_venus.c b/sys/fs/coda/coda_venus.c
index 56d627b..b1e044a 100644
--- a/sys/fs/coda/coda_venus.c
+++ b/sys/fs/coda/coda_venus.c
@@ -198,30 +198,23 @@ venus_root(void *mdp,
int
venus_open(void *mdp, CodaFid *fid, int flag,
struct ucred *cred, struct proc *p,
-/*out*/ struct cdev **dev, ino_t *inode)
+/*out*/ struct vnode **vp)
{
-#if 0
int cflag;
- DECL(coda_open); /* sets Isize & Osize */
- ALLOC(coda_open); /* sets inp & outp */
+ DECL(coda_open_by_fd); /* sets Isize & Osize */
+ ALLOC(coda_open_by_fd); /* sets inp & outp */
/* send the open to venus. */
- INIT_IN(&inp->ih, CODA_OPEN, cred, p);
+ INIT_IN(&inp->ih, CODA_OPEN_BY_FD, cred, p);
inp->Fid = *fid;
CNV_OFLAG(cflag, flag);
inp->flags = cflag;
error = coda_call(mdp, Isize, &Osize, (char *)inp);
- if (!error) {
- *dev = findcdev(outp->dev);
- *inode = outp->inode;
- }
+ *vp = error ? NULL : outp->vp;
- CODA_FREE(inp, coda_open_size);
+ CODA_FREE(inp, coda_open_by_fd_size);
return error;
-#else
- return (EOPNOTSUPP);
-#endif
}
int
diff --git a/sys/fs/coda/coda_venus.h b/sys/fs/coda/coda_venus.h
index 1d1e0cf..d8f0198 100644
--- a/sys/fs/coda/coda_venus.h
+++ b/sys/fs/coda/coda_venus.h
@@ -39,7 +39,7 @@ venus_root(void *mdp,
int
venus_open(void *mdp, CodaFid *fid, int flag,
struct ucred *cred, struct proc *p,
-/*out*/ struct cdev **dev, ino_t *inode);
+/*out*/ struct vnode **vp);
int
venus_close(void *mdp, CodaFid *fid, int flag,
diff --git a/sys/fs/coda/coda_vnops.c b/sys/fs/coda/coda_vnops.c
index d0b5c60..6aa32ff 100644
--- a/sys/fs/coda/coda_vnops.c
+++ b/sys/fs/coda/coda_vnops.c
@@ -178,9 +178,10 @@ coda_vnodeopstats_init(void)
}
/*
- * coda_open calls Venus to return the device, inode pair of the cache
- * file holding the data. Using iget, coda_open finds the vnode of the
- * cache file, and then opens it.
+ * coda_open calls Venus which returns an open file descriptor the cache
+ * file holding the data. We get the vnode while we are still in the
+ * context of the venus process in coda_psdev.c. This vnode is then
+ * passed back to the caller and opened.
*/
int
coda_open(struct vop_open_args *ap)
@@ -199,8 +200,6 @@ coda_open(struct vop_open_args *ap)
/* locals */
int error;
struct vnode *vp;
- struct cdev *dev;
- ino_t inode;
MARK_ENTRY(CODA_OPEN_STATS);
@@ -216,23 +215,12 @@ coda_open(struct vop_open_args *ap)
return(0);
}
- error = venus_open(vtomi((*vpp)), &cp->c_fid, flag, cred, td->td_proc, &dev, &inode);
+ error = venus_open(vtomi((*vpp)), &cp->c_fid, flag, cred, td->td_proc, &vp);
if (error)
return (error);
- if (!error) {
- CODADEBUG( CODA_OPEN,myprintf(("open: dev %#lx inode %lu result %d\n",
- (u_long)dev2udev(dev), (u_long)inode,
- error)); )
- }
- /* Translate the <device, inode> pair for the cache file into
- an inode pointer. */
- error = coda_grab_vnode(dev, inode, &vp);
- if (error)
- return (error);
+ CODADEBUG( CODA_OPEN,myprintf(("open: vp %p result %d\n", vp, error));)
- /* We get the vnode back locked. Needs unlocked */
- VOP_UNLOCK(vp, 0, td);
/* Keep a reference until the close comes in. */
vref(*vpp);
@@ -251,11 +239,6 @@ coda_open(struct vop_open_args *ap)
cp->c_flags &= ~C_VATTR;
}
- /* Save the <device, inode> pair for the cache file to speed
- up subsequent page_read's. */
- cp->c_device = dev;
- cp->c_inode = inode;
-
/* Open the cache file. */
error = VOP_OPEN(vp, flag, cred, td, NULL);
if (error) {
@@ -290,28 +273,13 @@ coda_close(struct vop_close_args *ap)
return(0);
}
- if (IS_UNMOUNTING(cp)) {
- if (cp->c_ovp) {
-#ifdef CODA_VERBOSE
- printf("coda_close: destroying container ref %d, ufs vp %p of vp %p/cp %p\n",
- vrefcnt(vp), cp->c_ovp, vp, cp);
-#endif
-#ifdef hmm
- vgone(cp->c_ovp);
-#else
- VOP_CLOSE(cp->c_ovp, flag, cred, td); /* Do errors matter here? */
- vrele(cp->c_ovp);
-#endif
- } else {
-#ifdef CODA_VERBOSE
- printf("coda_close: NO container vp %p/cp %p\n", vp, cp);
-#endif
- }
- return ENODEV;
- } else {
+ if (cp->c_ovp) {
VOP_CLOSE(cp->c_ovp, flag, cred, td); /* Do errors matter here? */
vrele(cp->c_ovp);
}
+#ifdef CODA_VERBOSE
+ else printf("coda_close: NO container vp %p/cp %p\n", vp, cp);
+#endif
if (--cp->c_ocount == 0)
cp->c_ovp = NULL;
@@ -319,8 +287,11 @@ coda_close(struct vop_close_args *ap)
if (flag & FWRITE) /* file was opened for write */
--cp->c_owrite;
- error = venus_close(vtomi(vp), &cp->c_fid, flag, cred, td->td_proc);
- vrele(CTOV(cp));
+ if (!IS_UNMOUNTING(cp))
+ error = venus_close(vtomi(vp), &cp->c_fid, flag, cred, td->td_proc);
+ else error = ENODEV;
+
+ vrele(vp);
CODADEBUG(CODA_CLOSE, myprintf(("close: result %d\n",error)); )
return(error);
@@ -353,12 +324,8 @@ coda_rdwr(struct vnode *vp, struct uio *uiop, enum uio_rw rw, int ioflag,
/* locals */
struct cnode *cp = VTOC(vp);
struct vnode *cfvp = cp->c_ovp;
- struct proc *p = td->td_proc;
- struct thread *ltd = td;
- int igot_internally = 0;
int opened_internally = 0;
int error = 0;
- int iscore = 0;
MARK_ENTRY(CODA_RDWR_STATS);
@@ -373,51 +340,19 @@ coda_rdwr(struct vnode *vp, struct uio *uiop, enum uio_rw rw, int ioflag,
}
/*
- * If file is not already open this must be a page
- * {read,write} request. Iget the cache file's inode
- * pointer if we still have its <device, inode> pair.
- * Otherwise, we must do an internal open to derive the
- * pair.
+ * If file is not already open this must be a page {read,write} request
+ * and we should open it internally.
*/
if (cfvp == NULL) {
- /*
- * If we're dumping core, do the internal open. Otherwise
- * venus won't have the correct size of the core when
- * it's completely written.
- */
- if (p) {
- PROC_LOCK(p);
- iscore = (p->p_acflag & ACORE);
- PROC_UNLOCK(p);
- }
- else
- ltd = curthread;
-
- if (cp->c_inode != 0 && !iscore) {
- igot_internally = 1;
- error = coda_grab_vnode(cp->c_device, cp->c_inode, &cfvp);
- if (error) {
- MARK_INT_FAIL(CODA_RDWR_STATS);
- return(error);
- }
- /*
- * We get the vnode back locked by curthread in both Mach and
- * NetBSD. Needs unlocked
- */
- VOP_UNLOCK(cfvp, 0, ltd);
- }
- else {
- opened_internally = 1;
- MARK_INT_GEN(CODA_OPEN_STATS);
- error = VOP_OPEN(vp, (rw == UIO_READ ? FREAD : FWRITE),
- cred, td, NULL);
-printf("coda_rdwr: Internally Opening %p\n", vp);
- if (error) {
+ opened_internally = 1;
+ MARK_INT_GEN(CODA_OPEN_STATS);
+ error = VOP_OPEN(vp, (rw == UIO_READ ? FREAD : FWRITE), cred, td, NULL);
+ printf("coda_rdwr: Internally Opening %p\n", vp);
+ if (error) {
printf("coda_rdwr: VOP_OPEN on container failed %d\n", error);
return (error);
- }
- cfvp = cp->c_ovp;
}
+ cfvp = cp->c_ovp;
}
/* Have UFS handle the call. */
@@ -1526,7 +1461,7 @@ coda_readdir(struct vop_readdir_args *ap)
opened_internally = 1;
MARK_INT_GEN(CODA_OPEN_STATS);
error = VOP_OPEN(vp, FREAD, cred, td, NULL);
-printf("coda_readdir: Internally Opening %p\n", vp);
+ printf("coda_readdir: Internally Opening %p\n", vp);
if (error) {
printf("coda_readdir: VOP_OPEN on container failed %d\n", error);
return (error);
@@ -1677,30 +1612,6 @@ coda_islocked(struct vop_islocked_args *ap)
return (vop_stdislocked(ap));
}
-/* How one looks up a vnode given a device/inode pair: */
-int
-coda_grab_vnode(struct cdev *dev, ino_t ino, struct vnode **vpp)
-{
- /* This is like VFS_VGET() or igetinode()! */
- int error;
- struct mount *mp;
-
- if (!(mp = devtomp(dev))) {
- myprintf(("coda_grab_vnode: devtomp(%#lx) returns NULL\n",
- (u_long)dev2udev(dev)));
- return(ENXIO);
- }
-
- /* XXX - ensure that nonzero-return means failure */
- error = VFS_VGET(mp,ino,LK_EXCLUSIVE,vpp);
- if (error) {
- myprintf(("coda_grab_vnode: iget/vget(%lx, %lu) returns %p, err %d\n",
- (u_long)dev2udev(dev), (u_long)ino, (void *)*vpp, error));
- return(ENOENT);
- }
- return(0);
-}
-
void
print_vattr(struct vattr *attr)
{
OpenPOWER on IntegriCloud