diff --git a/sys/kern/vfs_bio.c b/sys/kern/vfs_bio.c index 526429d02f45..6a805658bdb7 100644 --- a/sys/kern/vfs_bio.c +++ b/sys/kern/vfs_bio.c @@ -72,6 +72,8 @@ struct buf_ops buf_ops_bio = { */ struct buf *buf; /* buffer header pool */ +static struct proc *bufdaemonproc; + static void vm_hold_free_pages(struct buf * bp, vm_offset_t from, vm_offset_t to); static void vm_hold_load_pages(struct buf * bp, vm_offset_t from, @@ -888,9 +890,13 @@ bwrite(struct buf * bp) * don't allow the async write to saturate the I/O * system. We will not deadlock here because * we are blocking waiting for I/O that is already in-progress - * to complete. + * to complete. We do not block here if it is the update + * or syncer daemon trying to clean up as that can lead + * to deadlock. */ - waitrunningbufspace(); + if (curthread->td_proc != bufdaemonproc && + curthread->td_proc != updateproc) + waitrunningbufspace(); } return (0); @@ -2040,8 +2046,6 @@ getnewbuf(int slpflag, int slptimeo, int size, int maxsize) * take the load in an attempt to prevent getnewbuf() from blocking. */ -static struct proc *bufdaemonproc; - static struct kproc_desc buf_kp = { "bufdaemon", buf_daemon,