From: claudio Date: Mon, 25 Oct 2021 10:24:54 +0000 (+0000) Subject: Revert commitid: ufM9BcSbXqfLpzBH; X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=8e49fb4c2a30057c387ac447b5598aa90b4ad4fa;p=openbsd Revert commitid: ufM9BcSbXqfLpzBH; Move vfs_stall_barrier() from the fd layer into vn_lock() and the vfs layer. In some cases it can result in a deadlock while suspending. Discussed with mpi@ and deraadt@ --- diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c index ea3e3399ce0..17d9deaf54d 100644 --- a/sys/kern/kern_descrip.c +++ b/sys/kern/kern_descrip.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_descrip.c,v 1.203 2021/10/21 09:59:13 claudio Exp $ */ +/* $OpenBSD: kern_descrip.c,v 1.204 2021/10/25 10:24:54 claudio Exp $ */ /* $NetBSD: kern_descrip.c,v 1.42 1996/03/30 22:24:38 christos Exp $ */ /* @@ -232,6 +232,8 @@ fd_getfile(struct filedesc *fdp, int fd) { struct file *fp; + vfs_stall_barrier(); + if ((u_int)fd >= fdp->fd_nfiles) return (NULL); diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index f8a300a3007..43a7cbd4ae9 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vfs_subr.c,v 1.312 2021/10/24 00:02:25 jsg Exp $ */ +/* $OpenBSD: vfs_subr.c,v 1.313 2021/10/25 10:24:54 claudio Exp $ */ /* $NetBSD: vfs_subr.c,v 1.53 1996/04/22 01:39:13 christos Exp $ */ /* @@ -1705,10 +1705,8 @@ void vfs_stall_barrier(void) { if (__predict_false(vfs_stalling)) { - if (curproc != RWLOCK_OWNER(&vfs_stall_lock)) { - rw_enter_read(&vfs_stall_lock); - rw_exit_read(&vfs_stall_lock); - } + rw_enter_read(&vfs_stall_lock); + rw_exit_read(&vfs_stall_lock); } } diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c index de6d7593b14..5f89a6c2ef8 100644 --- a/sys/kern/vfs_vnops.c +++ b/sys/kern/vfs_vnops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vfs_vnops.c,v 1.117 2021/10/21 09:59:14 claudio Exp $ */ +/* $OpenBSD: vfs_vnops.c,v 1.118 2021/10/25 10:24:54 claudio Exp $ */ /* $NetBSD: vfs_vnops.c,v 1.20 1996/02/04 02:18:41 christos Exp $ */ /* @@ -565,8 +565,6 @@ vn_lock(struct vnode *vp, int flags) { int error, xlocked, do_wakeup; - vfs_stall_barrier(); - do { mtx_enter(&vnode_mtx); if (vp->v_lflag & VXLOCK) { diff --git a/sys/sys/file.h b/sys/sys/file.h index b440e1275c5..19136100ed8 100644 --- a/sys/sys/file.h +++ b/sys/sys/file.h @@ -1,4 +1,4 @@ -/* $OpenBSD: file.h,v 1.63 2021/10/21 09:59:14 claudio Exp $ */ +/* $OpenBSD: file.h,v 1.64 2021/10/25 10:24:54 claudio Exp $ */ /* $NetBSD: file.h,v 1.11 1995/03/26 20:24:13 jtc Exp $ */ /* @@ -106,7 +106,11 @@ struct file { #define FIF_INSERTED 0x80 /* present in `filehead' */ #define FREF(fp) \ - atomic_inc_int(&(fp)->f_count) + do { \ + extern void vfs_stall_barrier(void); \ + vfs_stall_barrier(); \ + atomic_inc_int(&(fp)->f_count); \ + } while (0) #define FRELE(fp,p) \ (atomic_dec_int_nv(&fp->f_count) == 0 ? fdrop(fp, p) : 0)