summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
Diffstat (limited to 'sys')
-rw-r--r--sys/compat/svr4/svr4_filio.c8
-rw-r--r--sys/compat/svr4/svr4_misc.c4
-rw-r--r--sys/dev/streams/streams.c8
-rw-r--r--sys/fs/fdescfs/fdesc_vfsops.c4
-rw-r--r--sys/fs/fdescfs/fdesc_vnops.c10
-rw-r--r--sys/fs/unionfs/union_subr.c4
-rw-r--r--sys/fs/unionfs/union_vfsops.c4
-rw-r--r--sys/kern/kern_descrip.c30
-rw-r--r--sys/kern/kern_event.c8
-rw-r--r--sys/kern/kern_exec.c6
-rw-r--r--sys/kern/kern_fork.c10
-rw-r--r--sys/kern/sys_generic.c12
-rw-r--r--sys/kern/uipc_syscalls.c10
-rw-r--r--sys/kern/vfs_extattr.c28
-rw-r--r--sys/kern/vfs_syscalls.c28
-rw-r--r--sys/sys/filedesc.h3
16 files changed, 90 insertions, 87 deletions
diff --git a/sys/compat/svr4/svr4_filio.c b/sys/compat/svr4/svr4_filio.c
index ef0352d..edf6803 100644
--- a/sys/compat/svr4/svr4_filio.c
+++ b/sys/compat/svr4/svr4_filio.c
@@ -211,15 +211,15 @@ svr4_fil_ioctl(fp, td, retval, fd, cmd, data)
switch (cmd) {
case SVR4_FIOCLEX:
- FILEDESC_LOCK(fdp);
+ FILEDESC_LOCK_FAST(fdp);
fdp->fd_ofileflags[fd] |= UF_EXCLOSE;
- FILEDESC_UNLOCK(fdp);
+ FILEDESC_UNLOCK_FAST(fdp);
return 0;
case SVR4_FIONCLEX:
- FILEDESC_LOCK(fdp);
+ FILEDESC_LOCK_FAST(fdp);
fdp->fd_ofileflags[fd] &= ~UF_EXCLOSE;
- FILEDESC_UNLOCK(fdp);
+ FILEDESC_UNLOCK_FAST(fdp);
return 0;
case SVR4_FIOGETOWN:
diff --git a/sys/compat/svr4/svr4_misc.c b/sys/compat/svr4/svr4_misc.c
index 349487b..a093565 100644
--- a/sys/compat/svr4/svr4_misc.c
+++ b/sys/compat/svr4/svr4_misc.c
@@ -618,10 +618,10 @@ svr4_sys_fchroot(td, uap)
return error;
}
VREF(vp);
- FILEDESC_LOCK(fdp);
+ FILEDESC_LOCK_FAST(fdp);
vpold = fdp->fd_rdir;
fdp->fd_rdir = vp;
- FILEDESC_UNLOCK(fdp);
+ FILEDESC_UNLOCK_FAST(fdp);
if (vpold != NULL)
vrele(vpold);
fdrop(fp, td);
diff --git a/sys/dev/streams/streams.c b/sys/dev/streams/streams.c
index 1df0952..28a77c8 100644
--- a/sys/dev/streams/streams.c
+++ b/sys/dev/streams/streams.c
@@ -256,26 +256,26 @@ streamsopen(struct cdev *dev, int oflags, int devtype, struct thread *td)
if ((error = socreate(family, &so, type, protocol,
td->td_ucred, td)) != 0) {
- FILEDESC_LOCK(p->p_fd);
+ FILEDESC_LOCK_FAST(p->p_fd);
/* Check the fd table entry hasn't changed since we made it. */
extraref = 0;
if (p->p_fd->fd_ofiles[fd] == fp) {
p->p_fd->fd_ofiles[fd] = NULL;
extraref = 1;
}
- FILEDESC_UNLOCK(p->p_fd);
+ FILEDESC_UNLOCK_FAST(p->p_fd);
if (extraref)
fdrop(fp, td);
fdrop(fp, td);
return error;
}
- FILEDESC_LOCK(p->p_fd);
+ FILEDESC_LOCK_FAST(p->p_fd);
fp->f_data = so;
fp->f_flag = FREAD|FWRITE;
fp->f_ops = &svr4_netops;
fp->f_type = DTYPE_SOCKET;
- FILEDESC_UNLOCK(p->p_fd);
+ FILEDESC_UNLOCK_FAST(p->p_fd);
(void)svr4_stream_get(fp);
fdrop(fp, td);
diff --git a/sys/fs/fdescfs/fdesc_vfsops.c b/sys/fs/fdescfs/fdesc_vfsops.c
index 0b7e403..0e211ad 100644
--- a/sys/fs/fdescfs/fdesc_vfsops.c
+++ b/sys/fs/fdescfs/fdesc_vfsops.c
@@ -166,7 +166,7 @@ fdesc_statfs(mp, sbp, td)
lim = lim_cur(td->td_proc, RLIMIT_NOFILE);
PROC_UNLOCK(td->td_proc);
fdp = td->td_proc->p_fd;
- FILEDESC_LOCK(fdp);
+ FILEDESC_LOCK_FAST(fdp);
last = min(fdp->fd_nfiles, lim);
freefd = 0;
for (i = fdp->fd_freefile; i < last; i++)
@@ -179,7 +179,7 @@ fdesc_statfs(mp, sbp, td)
*/
if (fdp->fd_nfiles < lim)
freefd += (lim - fdp->fd_nfiles);
- FILEDESC_UNLOCK(fdp);
+ FILEDESC_UNLOCK_FAST(fdp);
sbp->f_flags = 0;
sbp->f_bsize = DEV_BSIZE;
diff --git a/sys/fs/fdescfs/fdesc_vnops.c b/sys/fs/fdescfs/fdesc_vnops.c
index e6c0075..b6d1eea 100644
--- a/sys/fs/fdescfs/fdesc_vnops.c
+++ b/sys/fs/fdescfs/fdesc_vnops.c
@@ -440,7 +440,7 @@ fdesc_readdir(ap)
fcnt = i - 2; /* The first two nodes are `.' and `..' */
- FILEDESC_LOCK(fdp);
+ FILEDESC_LOCK_FAST(fdp);
while (i < fdp->fd_nfiles + 2 && uio->uio_resid >= UIO_MX) {
switch (i) {
case 0: /* `.' */
@@ -456,7 +456,7 @@ fdesc_readdir(ap)
break;
default:
if (fdp->fd_ofiles[fcnt] == NULL) {
- FILEDESC_UNLOCK(fdp);
+ FILEDESC_UNLOCK_FAST(fdp);
goto done;
}
@@ -470,15 +470,15 @@ fdesc_readdir(ap)
/*
* And ship to userland
*/
- FILEDESC_UNLOCK(fdp);
+ FILEDESC_UNLOCK_FAST(fdp);
error = uiomove(dp, UIO_MX, uio);
if (error)
goto done;
- FILEDESC_LOCK(fdp);
+ FILEDESC_LOCK_FAST(fdp);
i++;
fcnt++;
}
- FILEDESC_UNLOCK(fdp);
+ FILEDESC_UNLOCK_FAST(fdp);
done:
uio->uio_offset = i * UIO_MX;
diff --git a/sys/fs/unionfs/union_subr.c b/sys/fs/unionfs/union_subr.c
index 99b86ea..364736c 100644
--- a/sys/fs/unionfs/union_subr.c
+++ b/sys/fs/unionfs/union_subr.c
@@ -1053,9 +1053,9 @@ union_vn_create(vpp, un, td)
struct componentname cn;
*vpp = NULLVP;
- FILEDESC_LOCK(td->td_proc->p_fd);
+ FILEDESC_LOCK_FAST(td->td_proc->p_fd);
cmode = UN_FILEMODE & ~td->td_proc->p_fd->fd_cmask;
- FILEDESC_UNLOCK(td->td_proc->p_fd);
+ FILEDESC_UNLOCK_FAST(td->td_proc->p_fd);
/*
* Build a new componentname structure (for the same
diff --git a/sys/fs/unionfs/union_vfsops.c b/sys/fs/unionfs/union_vfsops.c
index 7383c0c..b62233c 100644
--- a/sys/fs/unionfs/union_vfsops.c
+++ b/sys/fs/unionfs/union_vfsops.c
@@ -247,9 +247,9 @@ union_mount(mp, td)
}
um->um_cred = crhold(td->td_ucred);
- FILEDESC_LOCK(td->td_proc->p_fd);
+ FILEDESC_LOCK_FAST(td->td_proc->p_fd);
um->um_cmode = UN_DIRMODE &~ td->td_proc->p_fd->fd_cmask;
- FILEDESC_UNLOCK(td->td_proc->p_fd);
+ FILEDESC_UNLOCK_FAST(td->td_proc->p_fd);
/*
* Depending on what you think the MNT_LOCAL flag might mean,
diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c
index 8f8f636..d629ab3 100644
--- a/sys/kern/kern_descrip.c
+++ b/sys/kern/kern_descrip.c
@@ -549,10 +549,10 @@ kern_fcntl(struct thread *td, int fd, int cmd, intptr_t arg)
break;
}
/* Check for race with close */
- FILEDESC_LOCK(fdp);
+ FILEDESC_LOCK_FAST(fdp);
if ((unsigned) fd >= fdp->fd_nfiles ||
fp != fdp->fd_ofiles[fd]) {
- FILEDESC_UNLOCK(fdp);
+ FILEDESC_UNLOCK_FAST(fdp);
flp->l_whence = SEEK_SET;
flp->l_start = 0;
flp->l_len = 0;
@@ -560,7 +560,7 @@ kern_fcntl(struct thread *td, int fd, int cmd, intptr_t arg)
(void) VOP_ADVLOCK(vp, (caddr_t)p->p_leader,
F_UNLCK, flp, F_POSIX);
} else
- FILEDESC_UNLOCK(fdp);
+ FILEDESC_UNLOCK_FAST(fdp);
fdrop(fp, td);
break;
@@ -736,14 +736,14 @@ do_dup(td, type, old, new, retval)
(void) closef(delfp, td);
mtx_unlock(&Giant);
if (holdleaders) {
- FILEDESC_LOCK(fdp);
+ FILEDESC_LOCK_FAST(fdp);
fdp->fd_holdleaderscount--;
if (fdp->fd_holdleaderscount == 0 &&
fdp->fd_holdleaderswakeup != 0) {
fdp->fd_holdleaderswakeup = 0;
wakeup(&fdp->fd_holdleaderscount);
}
- FILEDESC_UNLOCK(fdp);
+ FILEDESC_UNLOCK_FAST(fdp);
}
} else {
FILEDESC_UNLOCK(fdp);
@@ -1033,14 +1033,14 @@ close(td, uap)
error = closef(fp, td);
mtx_unlock(&Giant);
if (holdleaders) {
- FILEDESC_LOCK(fdp);
+ FILEDESC_LOCK_FAST(fdp);
fdp->fd_holdleaderscount--;
if (fdp->fd_holdleaderscount == 0 &&
fdp->fd_holdleaderswakeup != 0) {
fdp->fd_holdleaderswakeup = 0;
wakeup(&fdp->fd_holdleaderscount);
}
- FILEDESC_UNLOCK(fdp);
+ FILEDESC_UNLOCK_FAST(fdp);
}
return (error);
}
@@ -1472,9 +1472,9 @@ struct filedesc *
fdshare(fdp)
struct filedesc *fdp;
{
- FILEDESC_LOCK(fdp);
+ FILEDESC_LOCK_FAST(fdp);
fdp->fd_refcnt++;
- FILEDESC_UNLOCK(fdp);
+ FILEDESC_UNLOCK_FAST(fdp);
return (fdp);
}
@@ -1495,13 +1495,13 @@ fdcopy(fdp)
return (NULL);
newfdp = fdinit(fdp);
- FILEDESC_LOCK(fdp);
+ FILEDESC_LOCK_FAST(fdp);
while (fdp->fd_lastfile >= newfdp->fd_nfiles) {
- FILEDESC_UNLOCK(fdp);
+ FILEDESC_UNLOCK_FAST(fdp);
FILEDESC_LOCK(newfdp);
fdgrowtable(newfdp, fdp->fd_lastfile + 1);
FILEDESC_UNLOCK(newfdp);
- FILEDESC_LOCK(fdp);
+ FILEDESC_LOCK_FAST(fdp);
}
/* copy everything except kqueue descriptors */
newfdp->fd_freefile = -1;
@@ -1517,17 +1517,17 @@ fdcopy(fdp)
newfdp->fd_freefile = i;
}
}
- FILEDESC_UNLOCK(fdp);
+ FILEDESC_UNLOCK_FAST(fdp);
FILEDESC_LOCK(newfdp);
for (i = 0; i <= newfdp->fd_lastfile; ++i)
if (newfdp->fd_ofiles[i] != NULL)
fdused(newfdp, i);
FILEDESC_UNLOCK(newfdp);
- FILEDESC_LOCK(fdp);
+ FILEDESC_LOCK_FAST(fdp);
if (newfdp->fd_freefile == -1)
newfdp->fd_freefile = i;
newfdp->fd_cmask = fdp->fd_cmask;
- FILEDESC_UNLOCK(fdp);
+ FILEDESC_UNLOCK_FAST(fdp);
return (newfdp);
}
diff --git a/sys/kern/kern_event.c b/sys/kern/kern_event.c
index 61b614c..089b67e 100644
--- a/sys/kern/kern_event.c
+++ b/sys/kern/kern_event.c
@@ -497,9 +497,9 @@ kqueue(struct thread *td, struct kqueue_args *uap)
knlist_init(&kq->kq_sel.si_note, &kq->kq_lock);
TASK_INIT(&kq->kq_task, 0, kqueue_task, kq);
- FILEDESC_LOCK(fdp);
+ FILEDESC_LOCK_FAST(fdp);
SLIST_INSERT_HEAD(&fdp->fd_kqlist, kq, kq_list);
- FILEDESC_UNLOCK(fdp);
+ FILEDESC_UNLOCK_FAST(fdp);
FILE_LOCK(fp);
fp->f_flag = FREAD | FWRITE;
@@ -1391,9 +1391,9 @@ kqueue_close(struct file *fp, struct thread *td)
KQ_UNLOCK(kq);
- FILEDESC_LOCK(fdp);
+ FILEDESC_LOCK_FAST(fdp);
SLIST_REMOVE(&fdp->fd_kqlist, kq, kqueue, kq_list);
- FILEDESC_UNLOCK(fdp);
+ FILEDESC_UNLOCK_FAST(fdp);
knlist_destroy(&kq->kq_sel.si_note);
mtx_destroy(&kq->kq_lock);
diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c
index c6d3e5c..92ed024 100644
--- a/sys/kern/kern_exec.c
+++ b/sys/kern/kern_exec.c
@@ -465,16 +465,16 @@ interpret:
* For security and other reasons, the file descriptor table cannot
* be shared after an exec.
*/
- FILEDESC_LOCK(p->p_fd);
+ FILEDESC_LOCK_FAST(p->p_fd);
if (p->p_fd->fd_refcnt > 1) {
struct filedesc *tmp;
- FILEDESC_UNLOCK(p->p_fd);
+ FILEDESC_UNLOCK_FAST(p->p_fd);
tmp = fdcopy(p->p_fd);
fdfree(td);
p->p_fd = tmp;
} else
- FILEDESC_UNLOCK(p->p_fd);
+ FILEDESC_UNLOCK_FAST(p->p_fd);
/*
* Malloc things before we need locks.
diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c
index c6e2f12..9d90b1c 100644
--- a/sys/kern/kern_fork.c
+++ b/sys/kern/kern_fork.c
@@ -234,16 +234,16 @@ fork1(td, flags, pages, procp)
* Unshare file descriptors (from parent).
*/
if (flags & RFFDG) {
- FILEDESC_LOCK(p1->p_fd);
+ FILEDESC_LOCK_FAST(p1->p_fd);
if (p1->p_fd->fd_refcnt > 1) {
struct filedesc *newfd;
- FILEDESC_UNLOCK(p1->p_fd);
+ FILEDESC_UNLOCK_FAST(p1->p_fd);
newfd = fdcopy(p1->p_fd);
fdfree(td);
p1->p_fd = newfd;
} else
- FILEDESC_UNLOCK(p1->p_fd);
+ FILEDESC_UNLOCK_FAST(p1->p_fd);
}
*procp = NULL;
return (0);
@@ -439,9 +439,9 @@ again:
* shared process leaders.
*/
fdtol = p1->p_fdtol;
- FILEDESC_LOCK(p1->p_fd);
+ FILEDESC_LOCK_FAST(p1->p_fd);
fdtol->fdl_refcount++;
- FILEDESC_UNLOCK(p1->p_fd);
+ FILEDESC_UNLOCK_FAST(p1->p_fd);
} else {
/*
* Shared file descriptor table, and
diff --git a/sys/kern/sys_generic.c b/sys/kern/sys_generic.c
index d329460..068e997 100644
--- a/sys/kern/sys_generic.c
+++ b/sys/kern/sys_generic.c
@@ -490,16 +490,16 @@ ioctl(td, uap)
fdp = td->td_proc->p_fd;
switch (com = uap->com) {
case FIONCLEX:
- FILEDESC_LOCK(fdp);
+ FILEDESC_LOCK_FAST(fdp);
fdp->fd_ofileflags[uap->fd] &= ~UF_EXCLOSE;
- FILEDESC_UNLOCK(fdp);
+ FILEDESC_UNLOCK_FAST(fdp);
fdrop(fp, td);
mtx_unlock(&Giant);
return (0);
case FIOCLEX:
- FILEDESC_LOCK(fdp);
+ FILEDESC_LOCK_FAST(fdp);
fdp->fd_ofileflags[uap->fd] |= UF_EXCLOSE;
- FILEDESC_UNLOCK(fdp);
+ FILEDESC_UNLOCK_FAST(fdp);
fdrop(fp, td);
mtx_unlock(&Giant);
return (0);
@@ -650,11 +650,11 @@ kern_select(struct thread *td, int nd, fd_set *fd_in, fd_set *fd_ou,
* even if none of the file descriptors we poll requires Giant.
*/
mtx_lock(&Giant);
- FILEDESC_LOCK(fdp);
+ FILEDESC_LOCK_FAST(fdp);
if (nd > td->td_proc->p_fd->fd_nfiles)
nd = td->td_proc->p_fd->fd_nfiles; /* forgiving; slightly wrong */
- FILEDESC_UNLOCK(fdp);
+ FILEDESC_UNLOCK_FAST(fdp);
/*
* Allocate just enough bits for the non-null fd_sets. Use the
diff --git a/sys/kern/uipc_syscalls.c b/sys/kern/uipc_syscalls.c
index 54c97d5..63a3a4b 100644
--- a/sys/kern/uipc_syscalls.c
+++ b/sys/kern/uipc_syscalls.c
@@ -117,9 +117,9 @@ getsock(struct filedesc *fdp, int fd, struct file **fpp)
if (fdp == NULL)
error = EBADF;
else {
- FILEDESC_LOCK(fdp);
+ FILEDESC_LOCK_FAST(fdp);
fp = fget_locked(fdp, fd);
- if(fp == NULL)
+ if (fp == NULL)
error = EBADF;
else if (fp->f_type != DTYPE_SOCKET) {
fp = NULL;
@@ -128,7 +128,7 @@ getsock(struct filedesc *fdp, int fd, struct file **fpp)
fhold(fp);
error = 0;
}
- FILEDESC_UNLOCK(fdp);
+ FILEDESC_UNLOCK_FAST(fdp);
}
*fpp = fp;
return (error);
@@ -170,12 +170,12 @@ socket(td, uap)
if (error) {
fdclose(fdp, fp, fd, td);
} else {
- FILEDESC_LOCK(fdp);
+ FILEDESC_LOCK_FAST(fdp);
fp->f_data = so; /* already has ref count */
fp->f_flag = FREAD|FWRITE;
fp->f_ops = &socketops;
fp->f_type = DTYPE_SOCKET;
- FILEDESC_UNLOCK(fdp);
+ FILEDESC_UNLOCK_FAST(fdp);
td->td_retval[0] = fd;
}
fdrop(fp, td);
diff --git a/sys/kern/vfs_extattr.c b/sys/kern/vfs_extattr.c
index d98a885..d006e3f 100644
--- a/sys/kern/vfs_extattr.c
+++ b/sys/kern/vfs_extattr.c
@@ -702,10 +702,10 @@ fchdir(td, uap)
return (error);
}
VOP_UNLOCK(vp, 0, td);
- FILEDESC_LOCK(fdp);
+ FILEDESC_LOCK_FAST(fdp);
vpold = fdp->fd_cdir;
fdp->fd_cdir = vp;
- FILEDESC_UNLOCK(fdp);
+ FILEDESC_UNLOCK_FAST(fdp);
vrele(vpold);
return (0);
}
@@ -747,10 +747,10 @@ kern_chdir(struct thread *td, char *path, enum uio_seg pathseg)
}
VOP_UNLOCK(nd.ni_vp, 0, td);
NDFREE(&nd, NDF_ONLY_PNBUF);
- FILEDESC_LOCK(fdp);
+ FILEDESC_LOCK_FAST(fdp);
vp = fdp->fd_cdir;
fdp->fd_cdir = nd.ni_vp;
- FILEDESC_UNLOCK(fdp);
+ FILEDESC_UNLOCK_FAST(fdp);
vrele(vp);
return (0);
}
@@ -1175,10 +1175,10 @@ restart:
return (EEXIST);
} else {
VATTR_NULL(&vattr);
- FILEDESC_LOCK(td->td_proc->p_fd);
+ FILEDESC_LOCK_FAST(td->td_proc->p_fd);
vattr.va_mode = (mode & ALLPERMS) &
~td->td_proc->p_fd->fd_cmask;
- FILEDESC_UNLOCK(td->td_proc->p_fd);
+ FILEDESC_UNLOCK_FAST(td->td_proc->p_fd);
vattr.va_rdev = dev;
whiteout = 0;
@@ -1283,9 +1283,9 @@ restart:
}
VATTR_NULL(&vattr);
vattr.va_type = VFIFO;
- FILEDESC_LOCK(td->td_proc->p_fd);
+ FILEDESC_LOCK_FAST(td->td_proc->p_fd);
vattr.va_mode = (mode & ALLPERMS) & ~td->td_proc->p_fd->fd_cmask;
- FILEDESC_UNLOCK(td->td_proc->p_fd);
+ FILEDESC_UNLOCK_FAST(td->td_proc->p_fd);
#ifdef MAC
error = mac_check_vnode_create(td->td_ucred, nd.ni_dvp, &nd.ni_cnd,
&vattr);
@@ -1487,9 +1487,9 @@ restart:
goto restart;
}
VATTR_NULL(&vattr);
- FILEDESC_LOCK(td->td_proc->p_fd);
+ FILEDESC_LOCK_FAST(td->td_proc->p_fd);
vattr.va_mode = ACCESSPERMS &~ td->td_proc->p_fd->fd_cmask;
- FILEDESC_UNLOCK(td->td_proc->p_fd);
+ FILEDESC_UNLOCK_FAST(td->td_proc->p_fd);
#ifdef MAC
vattr.va_type = VLNK;
error = mac_check_vnode_create(td->td_ucred, nd.ni_dvp, &nd.ni_cnd,
@@ -3254,9 +3254,9 @@ restart:
}
VATTR_NULL(&vattr);
vattr.va_type = VDIR;
- FILEDESC_LOCK(td->td_proc->p_fd);
+ FILEDESC_LOCK_FAST(td->td_proc->p_fd);
vattr.va_mode = (mode & ACCESSPERMS) &~ td->td_proc->p_fd->fd_cmask;
- FILEDESC_UNLOCK(td->td_proc->p_fd);
+ FILEDESC_UNLOCK_FAST(td->td_proc->p_fd);
#ifdef MAC
error = mac_check_vnode_create(td->td_ucred, nd.ni_dvp, &nd.ni_cnd,
&vattr);
@@ -3658,11 +3658,11 @@ umask(td, uap)
{
register struct filedesc *fdp;
- FILEDESC_LOCK(td->td_proc->p_fd);
+ FILEDESC_LOCK_FAST(td->td_proc->p_fd);
fdp = td->td_proc->p_fd;
td->td_retval[0] = fdp->fd_cmask;
fdp->fd_cmask = uap->newmask & ALLPERMS;
- FILEDESC_UNLOCK(td->td_proc->p_fd);
+ FILEDESC_UNLOCK_FAST(td->td_proc->p_fd);
return (0);
}
diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c
index d98a885..d006e3f 100644
--- a/sys/kern/vfs_syscalls.c
+++ b/sys/kern/vfs_syscalls.c
@@ -702,10 +702,10 @@ fchdir(td, uap)
return (error);
}
VOP_UNLOCK(vp, 0, td);
- FILEDESC_LOCK(fdp);
+ FILEDESC_LOCK_FAST(fdp);
vpold = fdp->fd_cdir;
fdp->fd_cdir = vp;
- FILEDESC_UNLOCK(fdp);
+ FILEDESC_UNLOCK_FAST(fdp);
vrele(vpold);
return (0);
}
@@ -747,10 +747,10 @@ kern_chdir(struct thread *td, char *path, enum uio_seg pathseg)
}
VOP_UNLOCK(nd.ni_vp, 0, td);
NDFREE(&nd, NDF_ONLY_PNBUF);
- FILEDESC_LOCK(fdp);
+ FILEDESC_LOCK_FAST(fdp);
vp = fdp->fd_cdir;
fdp->fd_cdir = nd.ni_vp;
- FILEDESC_UNLOCK(fdp);
+ FILEDESC_UNLOCK_FAST(fdp);
vrele(vp);
return (0);
}
@@ -1175,10 +1175,10 @@ restart:
return (EEXIST);
} else {
VATTR_NULL(&vattr);
- FILEDESC_LOCK(td->td_proc->p_fd);
+ FILEDESC_LOCK_FAST(td->td_proc->p_fd);
vattr.va_mode = (mode & ALLPERMS) &
~td->td_proc->p_fd->fd_cmask;
- FILEDESC_UNLOCK(td->td_proc->p_fd);
+ FILEDESC_UNLOCK_FAST(td->td_proc->p_fd);
vattr.va_rdev = dev;
whiteout = 0;
@@ -1283,9 +1283,9 @@ restart:
}
VATTR_NULL(&vattr);
vattr.va_type = VFIFO;
- FILEDESC_LOCK(td->td_proc->p_fd);
+ FILEDESC_LOCK_FAST(td->td_proc->p_fd);
vattr.va_mode = (mode & ALLPERMS) & ~td->td_proc->p_fd->fd_cmask;
- FILEDESC_UNLOCK(td->td_proc->p_fd);
+ FILEDESC_UNLOCK_FAST(td->td_proc->p_fd);
#ifdef MAC
error = mac_check_vnode_create(td->td_ucred, nd.ni_dvp, &nd.ni_cnd,
&vattr);
@@ -1487,9 +1487,9 @@ restart:
goto restart;
}
VATTR_NULL(&vattr);
- FILEDESC_LOCK(td->td_proc->p_fd);
+ FILEDESC_LOCK_FAST(td->td_proc->p_fd);
vattr.va_mode = ACCESSPERMS &~ td->td_proc->p_fd->fd_cmask;
- FILEDESC_UNLOCK(td->td_proc->p_fd);
+ FILEDESC_UNLOCK_FAST(td->td_proc->p_fd);
#ifdef MAC
vattr.va_type = VLNK;
error = mac_check_vnode_create(td->td_ucred, nd.ni_dvp, &nd.ni_cnd,
@@ -3254,9 +3254,9 @@ restart:
}
VATTR_NULL(&vattr);
vattr.va_type = VDIR;
- FILEDESC_LOCK(td->td_proc->p_fd);
+ FILEDESC_LOCK_FAST(td->td_proc->p_fd);
vattr.va_mode = (mode & ACCESSPERMS) &~ td->td_proc->p_fd->fd_cmask;
- FILEDESC_UNLOCK(td->td_proc->p_fd);
+ FILEDESC_UNLOCK_FAST(td->td_proc->p_fd);
#ifdef MAC
error = mac_check_vnode_create(td->td_ucred, nd.ni_dvp, &nd.ni_cnd,
&vattr);
@@ -3658,11 +3658,11 @@ umask(td, uap)
{
register struct filedesc *fdp;
- FILEDESC_LOCK(td->td_proc->p_fd);
+ FILEDESC_LOCK_FAST(td->td_proc->p_fd);
fdp = td->td_proc->p_fd;
td->td_retval[0] = fdp->fd_cmask;
fdp->fd_cmask = uap->newmask & ALLPERMS;
- FILEDESC_UNLOCK(td->td_proc->p_fd);
+ FILEDESC_UNLOCK_FAST(td->td_proc->p_fd);
return (0);
}
diff --git a/sys/sys/filedesc.h b/sys/sys/filedesc.h
index 22ef5bf..d3cb5e2 100644
--- a/sys/sys/filedesc.h
+++ b/sys/sys/filedesc.h
@@ -99,6 +99,9 @@ struct filedesc_to_leader {
#define FILEDESC_LOCK_ASSERT(fd, type) mtx_assert(&(fd)->fd_mtx, (type))
#define FILEDESC_LOCK_DESC "filedesc structure"
+#define FILEDESC_LOCK_FAST(fd) FILEDESC_LOCK(fd);
+#define FILEDESC_UNLOCK_FAST(fd) FILEDESC_UNLOCK(fd);
+
struct thread;
int closef(struct file *fp, struct thread *td);
OpenPOWER on IntegriCloud