summaryrefslogtreecommitdiffstats
path: root/sys/fs/unionfs/union_subr.c
diff options
context:
space:
mode:
authorjulian <julian@FreeBSD.org>2001-09-12 08:38:13 +0000
committerjulian <julian@FreeBSD.org>2001-09-12 08:38:13 +0000
commit5596676e6c6c1e81e899cd0531f9b1c28a292669 (patch)
treeb1a19fcdf05759281fab0d89efb13f0fdf42102e /sys/fs/unionfs/union_subr.c
parent83e00d4274950d2b531c24692cd123538ffbddb9 (diff)
downloadFreeBSD-src-5596676e6c6c1e81e899cd0531f9b1c28a292669.zip
FreeBSD-src-5596676e6c6c1e81e899cd0531f9b1c28a292669.tar.gz
KSE Milestone 2
Note ALL MODULES MUST BE RECOMPILED make the kernel aware that there are smaller units of scheduling than the process. (but only allow one thread per process at this time). This is functionally equivalent to teh previousl -current except that there is a thread associated with each process. Sorry john! (your next MFC will be a doosie!) Reviewed by: peter@freebsd.org, dillon@freebsd.org X-MFC after: ha ha ha ha
Diffstat (limited to 'sys/fs/unionfs/union_subr.c')
-rw-r--r--sys/fs/unionfs/union_subr.c136
1 files changed, 68 insertions, 68 deletions
diff --git a/sys/fs/unionfs/union_subr.c b/sys/fs/unionfs/union_subr.c
index 52a5483..5919672 100644
--- a/sys/fs/unionfs/union_subr.c
+++ b/sys/fs/unionfs/union_subr.c
@@ -89,11 +89,11 @@ static void union_updatevp __P((struct union_node *un,
static void union_newlower __P((struct union_node *, struct vnode *));
static void union_newupper __P((struct union_node *, struct vnode *));
static int union_copyfile __P((struct vnode *, struct vnode *,
- struct ucred *, struct proc *));
+ struct ucred *, struct thread *));
static int union_vn_create __P((struct vnode **, struct union_node *,
- struct proc *));
+ struct thread *));
static int union_vn_close __P((struct vnode *, int, struct ucred *,
- struct proc *));
+ struct thread *));
int
union_init()
@@ -351,7 +351,7 @@ union_allocvp(vpp, mp, dvp, upperdvp, cnp, uppervp, lowervp, docache)
int error;
struct union_node *un = 0;
struct union_mount *um = MOUNTTOUNIONMOUNT(mp);
- struct proc *p = (cnp) ? cnp->cn_proc : curproc;
+ struct thread *td = (cnp) ? cnp->cn_thread : curthread;
int hash = 0;
int vflag;
int try;
@@ -410,7 +410,7 @@ loop:
un->un_uppervp == NULLVP) &&
(UNIONTOV(un)->v_mount == mp)) {
if (vget(UNIONTOV(un), 0,
- cnp ? cnp->cn_proc : NULL)) {
+ cnp ? cnp->cn_thread : NULL)) {
union_list_unlock(hash);
goto loop;
}
@@ -450,21 +450,21 @@ loop:
* while moving up the tree).
*/
VREF(dvp);
- VOP_UNLOCK(dvp, 0, p);
- error = vn_lock(un->un_vnode, LK_EXCLUSIVE, p);
- vn_lock(dvp, LK_EXCLUSIVE | LK_RETRY, p);
+ VOP_UNLOCK(dvp, 0, td);
+ error = vn_lock(un->un_vnode, LK_EXCLUSIVE, td);
+ vn_lock(dvp, LK_EXCLUSIVE | LK_RETRY, td);
vrele(dvp);
} else {
/*
* our new un is under dvp
*/
- error = vn_lock(un->un_vnode, LK_EXCLUSIVE, p);
+ error = vn_lock(un->un_vnode, LK_EXCLUSIVE, td);
}
} else if (dvp == NULLVP) {
/*
* dvp is NULL, we need to lock un.
*/
- error = vn_lock(un->un_vnode, LK_EXCLUSIVE, p);
+ error = vn_lock(un->un_vnode, LK_EXCLUSIVE, td);
} else {
/*
* dvp == un->un_vnode, we are already locked.
@@ -573,7 +573,7 @@ loop:
bzero(un, sizeof(*un));
lockinit(&un->un_lock, PVFS, "unlock", 0, 0);
- vn_lock(*vpp, LK_EXCLUSIVE | LK_RETRY, p);
+ vn_lock(*vpp, LK_EXCLUSIVE | LK_RETRY, td);
un->un_vnode = *vpp;
un->un_uppervp = uppervp;
@@ -656,11 +656,11 @@ union_freevp(vp)
* haven't been bumped at all.
*/
static int
-union_copyfile(fvp, tvp, cred, p)
+union_copyfile(fvp, tvp, cred, td)
struct vnode *fvp;
struct vnode *tvp;
struct ucred *cred;
- struct proc *p;
+ struct thread *td;
{
char *buf;
struct uio uio;
@@ -677,12 +677,12 @@ union_copyfile(fvp, tvp, cred, p)
bzero(&uio, sizeof(uio));
- uio.uio_procp = p;
+ uio.uio_td = td;
uio.uio_segflg = UIO_SYSSPACE;
uio.uio_offset = 0;
- VOP_LEASE(fvp, p, cred, LEASE_READ);
- VOP_LEASE(tvp, p, cred, LEASE_WRITE);
+ VOP_LEASE(fvp, td, cred, LEASE_READ);
+ VOP_LEASE(tvp, td, cred, LEASE_WRITE);
buf = malloc(MAXBSIZE, M_TEMP, M_WAITOK);
@@ -743,11 +743,11 @@ union_copyfile(fvp, tvp, cred, p)
*/
int
-union_copyup(un, docopy, cred, p)
+union_copyup(un, docopy, cred, td)
struct union_node *un;
int docopy;
struct ucred *cred;
- struct proc *p;
+ struct thread *td;
{
int error;
struct mount *mp;
@@ -757,15 +757,15 @@ union_copyup(un, docopy, cred, p)
* If the user does not have read permission, the vnode should not
* be copied to upper layer.
*/
- vn_lock(un->un_lowervp, LK_EXCLUSIVE | LK_RETRY, p);
- error = VOP_ACCESS(un->un_lowervp, VREAD, cred, p);
- VOP_UNLOCK(un->un_lowervp, 0, p);
+ vn_lock(un->un_lowervp, LK_EXCLUSIVE | LK_RETRY, td);
+ error = VOP_ACCESS(un->un_lowervp, VREAD, cred, td);
+ VOP_UNLOCK(un->un_lowervp, 0, td);
if (error)
return (error);
if ((error = vn_start_write(un->un_dirvp, &mp, V_WAIT | PCATCH)) != 0)
return (error);
- if ((error = union_vn_create(&uvp, un, p)) != 0) {
+ if ((error = union_vn_create(&uvp, un, td)) != 0) {
vn_finished_write(mp);
return (error);
}
@@ -778,24 +778,24 @@ union_copyup(un, docopy, cred, p)
* XX - should not ignore errors
* from VOP_CLOSE
*/
- vn_lock(lvp, LK_EXCLUSIVE | LK_RETRY, p);
- error = VOP_OPEN(lvp, FREAD, cred, p);
+ vn_lock(lvp, LK_EXCLUSIVE | LK_RETRY, td);
+ error = VOP_OPEN(lvp, FREAD, cred, td);
if (error == 0 && vn_canvmio(lvp) == TRUE)
- error = vfs_object_create(lvp, p, cred);
+ error = vfs_object_create(lvp, td, cred);
if (error == 0) {
- error = union_copyfile(lvp, uvp, cred, p);
- VOP_UNLOCK(lvp, 0, p);
- (void) VOP_CLOSE(lvp, FREAD, cred, p);
+ error = union_copyfile(lvp, uvp, cred, td);
+ VOP_UNLOCK(lvp, 0, td);
+ (void) VOP_CLOSE(lvp, FREAD, cred, td);
}
if (error == 0)
UDEBUG(("union: copied up %s\n", un->un_path));
}
- VOP_UNLOCK(uvp, 0, p);
+ VOP_UNLOCK(uvp, 0, td);
vn_finished_write(mp);
union_newupper(un, uvp);
KASSERT(uvp->v_usecount > 0, ("copy: uvp refcount 0: %d", uvp->v_usecount));
- union_vn_close(uvp, FWRITE, cred, p);
+ union_vn_close(uvp, FWRITE, cred, td);
KASSERT(uvp->v_usecount > 0, ("copy: uvp refcount 0: %d", uvp->v_usecount));
/*
* Subsequent IOs will go to the top layer, so
@@ -809,12 +809,12 @@ union_copyup(un, docopy, cred, p)
int i;
for (i = 0; i < un->un_openl; i++) {
- (void) VOP_CLOSE(lvp, FREAD, cred, p);
- (void) VOP_OPEN(uvp, FREAD, cred, p);
+ (void) VOP_CLOSE(lvp, FREAD, cred, td);
+ (void) VOP_OPEN(uvp, FREAD, cred, td);
}
if (un->un_openl) {
if (vn_canvmio(uvp) == TRUE)
- error = vfs_object_create(uvp, p, cred);
+ error = vfs_object_create(uvp, td, cred);
}
un->un_openl = 0;
}
@@ -862,7 +862,7 @@ union_relookup(um, dvp, vpp, cnp, cn, path, pathlen)
cn->cn_nameiop = CREATE;
cn->cn_flags = (LOCKPARENT|LOCKLEAF|HASBUF|SAVENAME|ISLASTCN);
- cn->cn_proc = cnp->cn_proc;
+ cn->cn_thread = cnp->cn_thread;
if (um->um_op == UNMNT_ABOVE)
cn->cn_cred = cnp->cn_cred;
else
@@ -871,7 +871,7 @@ union_relookup(um, dvp, vpp, cnp, cn, path, pathlen)
cn->cn_consume = cnp->cn_consume;
VREF(dvp);
- VOP_UNLOCK(dvp, 0, cnp->cn_proc);
+ VOP_UNLOCK(dvp, 0, cnp->cn_thread);
/*
* Pass dvp unlocked and referenced on call to relookup().
@@ -880,7 +880,7 @@ union_relookup(um, dvp, vpp, cnp, cn, path, pathlen)
*/
if ((error = relookup(dvp, vpp, cn)) != 0) {
- vn_lock(dvp, LK_EXCLUSIVE | LK_RETRY, cnp->cn_proc);
+ vn_lock(dvp, LK_EXCLUSIVE | LK_RETRY, cnp->cn_thread);
return(error);
}
@@ -916,7 +916,7 @@ union_mkshadow(um, dvp, cnp, vpp)
{
int error;
struct vattr va;
- struct proc *p = cnp->cn_proc;
+ struct thread *td = cnp->cn_thread;
struct componentname cn;
struct mount *mp;
@@ -955,7 +955,7 @@ union_mkshadow(um, dvp, cnp, vpp)
va.va_mode = um->um_cmode;
/* VOP_LEASE: dvp is locked */
- VOP_LEASE(dvp, p, cn.cn_cred, LEASE_WRITE);
+ VOP_LEASE(dvp, td, cn.cn_cred, LEASE_WRITE);
error = VOP_MKDIR(dvp, vpp, &cn, &va);
if (cn.cn_flags & HASBUF) {
@@ -984,7 +984,7 @@ union_mkwhiteout(um, dvp, cnp, path)
char *path;
{
int error;
- struct proc *p = cnp->cn_proc;
+ struct thread *td = cnp->cn_thread;
struct vnode *wvp;
struct componentname cn;
struct mount *mp;
@@ -1011,7 +1011,7 @@ union_mkwhiteout(um, dvp, cnp, path)
}
/* VOP_LEASE: dvp is locked */
- VOP_LEASE(dvp, p, p->p_ucred, LEASE_WRITE);
+ VOP_LEASE(dvp, td, td->td_proc->p_ucred, LEASE_WRITE);
error = VOP_WHITEOUT(dvp, &cn, CREATE);
if (cn.cn_flags & HASBUF) {
@@ -1037,18 +1037,18 @@ union_mkwhiteout(um, dvp, cnp, path)
* use. If an error occurs *vpp iis undefined.
*/
static int
-union_vn_create(vpp, un, p)
+union_vn_create(vpp, un, td)
struct vnode **vpp;
struct union_node *un;
- struct proc *p;
+ struct thread *td;
{
struct vnode *vp;
- struct ucred *cred = p->p_ucred;
+ struct ucred *cred = td->td_proc->p_ucred;
struct vattr vat;
struct vattr *vap = &vat;
int fmode = FFLAGS(O_WRONLY|O_CREAT|O_TRUNC|O_EXCL);
int error;
- int cmode = UN_FILEMODE & ~p->p_fd->fd_cmask;
+ int cmode = UN_FILEMODE & ~td->td_proc->p_fd->fd_cmask;
struct componentname cn;
*vpp = NULLVP;
@@ -1067,8 +1067,8 @@ union_vn_create(vpp, un, p)
bcopy(un->un_path, cn.cn_pnbuf, cn.cn_namelen+1);
cn.cn_nameiop = CREATE;
cn.cn_flags = (LOCKPARENT|LOCKLEAF|HASBUF|SAVENAME|ISLASTCN);
- cn.cn_proc = p;
- cn.cn_cred = p->p_ucred;
+ cn.cn_thread = td;
+ cn.cn_cred = td->td_proc->p_ucred;
cn.cn_nameptr = cn.cn_pnbuf;
cn.cn_consume = 0;
@@ -1112,7 +1112,7 @@ union_vn_create(vpp, un, p)
VATTR_NULL(vap);
vap->va_type = VREG;
vap->va_mode = cmode;
- VOP_LEASE(un->un_dirvp, p, cred, LEASE_WRITE);
+ VOP_LEASE(un->un_dirvp, td, cred, LEASE_WRITE);
error = VOP_CREATE(un->un_dirvp, &vp, &cn, vap);
if (cn.cn_flags & HASBUF) {
zfree(namei_zone, cn.cn_pnbuf);
@@ -1122,9 +1122,9 @@ union_vn_create(vpp, un, p)
if (error)
return (error);
- error = VOP_OPEN(vp, fmode, cred, p);
+ error = VOP_OPEN(vp, fmode, cred, td);
if (error == 0 && vn_canvmio(vp) == TRUE)
- error = vfs_object_create(vp, p, cred);
+ error = vfs_object_create(vp, td, cred);
if (error) {
vput(vp);
return (error);
@@ -1135,16 +1135,16 @@ union_vn_create(vpp, un, p)
}
static int
-union_vn_close(vp, fmode, cred, p)
+union_vn_close(vp, fmode, cred, td)
struct vnode *vp;
int fmode;
struct ucred *cred;
- struct proc *p;
+ struct thread *td;
{
if (fmode & FWRITE)
--vp->v_writecount;
- return (VOP_CLOSE(vp, fmode, cred, p));
+ return (VOP_CLOSE(vp, fmode, cred, td));
}
#if 0
@@ -1159,7 +1159,7 @@ void
union_removed_upper(un)
struct union_node *un;
{
- struct proc *p = curproc; /* XXX */
+ struct thread *td = curthread; /* XXX */
struct vnode **vpp;
/*
@@ -1188,17 +1188,17 @@ union_removed_upper(un)
* during a remove/rmdir operation.
*/
int
-union_dowhiteout(un, cred, p)
+union_dowhiteout(un, cred, td)
struct union_node *un;
struct ucred *cred;
- struct proc *p;
+ struct thread *td;
{
struct vattr va;
if (un->un_lowervp != NULLVP)
return (1);
- if (VOP_GETATTR(un->un_uppervp, &va, cred, p) == 0 &&
+ if (VOP_GETATTR(un->un_uppervp, &va, cred, td) == 0 &&
(va.va_flags & OPAQUE))
return (1);
@@ -1234,9 +1234,9 @@ union_dircache_r(vp, vppp, cntp)
}
struct vnode *
-union_dircache(vp, p)
+union_dircache(vp, td)
struct vnode *vp;
- struct proc *p;
+ struct thread *td;
{
int cnt;
struct vnode *nvp;
@@ -1245,7 +1245,7 @@ union_dircache(vp, p)
struct union_node *un;
int error;
- vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p);
+ vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td);
dircache = VTOUNION(vp)->un_dircache;
nvp = NULLVP;
@@ -1271,7 +1271,7 @@ union_dircache(vp, p)
if (*vpp == NULLVP)
goto out;
- /*vn_lock(*vpp, LK_EXCLUSIVE | LK_RETRY, p);*/
+ /*vn_lock(*vpp, LK_EXCLUSIVE | LK_RETRY, td);*/
UDEBUG(("ALLOCVP-3 %p ref %d\n", *vpp, (*vpp ? (*vpp)->v_usecount : -99)));
VREF(*vpp);
error = union_allocvp(&nvp, vp->v_mount, NULLVP, NULLVP, NULL, *vpp, NULLVP, 0);
@@ -1284,7 +1284,7 @@ union_dircache(vp, p)
un->un_dircache = dircache;
out:
- VOP_UNLOCK(vp, 0, p);
+ VOP_UNLOCK(vp, 0, td);
return (nvp);
}
@@ -1292,14 +1292,14 @@ out:
* Module glue to remove #ifdef UNION from vfs_syscalls.c
*/
static int
-union_dircheck(struct proc *p, struct vnode **vp, struct file *fp)
+union_dircheck(struct thread *td, struct vnode **vp, struct file *fp)
{
int error = 0;
if ((*vp)->v_op == union_vnodeop_p) {
struct vnode *lvp;
- lvp = union_dircache(*vp, p);
+ lvp = union_dircache(*vp, td);
if (lvp != NULLVP) {
struct vattr va;
@@ -1307,7 +1307,7 @@ union_dircheck(struct proc *p, struct vnode **vp, struct file *fp)
* If the directory is opaque,
* then don't show lower entries
*/
- error = VOP_GETATTR(*vp, &va, fp->f_cred, p);
+ error = VOP_GETATTR(*vp, &va, fp->f_cred, td);
if (va.va_flags & OPAQUE) {
vput(lvp);
lvp = NULL;
@@ -1315,17 +1315,17 @@ union_dircheck(struct proc *p, struct vnode **vp, struct file *fp)
}
if (lvp != NULLVP) {
- error = VOP_OPEN(lvp, FREAD, fp->f_cred, p);
+ error = VOP_OPEN(lvp, FREAD, fp->f_cred, td);
if (error == 0 && vn_canvmio(lvp) == TRUE)
- error = vfs_object_create(lvp, p, fp->f_cred);
+ error = vfs_object_create(lvp, td, fp->f_cred);
if (error) {
vput(lvp);
return (error);
}
- VOP_UNLOCK(lvp, 0, p);
+ VOP_UNLOCK(lvp, 0, td);
fp->f_data = (caddr_t) lvp;
fp->f_offset = 0;
- error = vn_close(*vp, FREAD, fp->f_cred, p);
+ error = vn_close(*vp, FREAD, fp->f_cred, td);
if (error)
return (error);
*vp = lvp;
OpenPOWER on IntegriCloud