diff options
| author | hannken <hannken@NetBSD.org> | 2023-03-14 12:55:43 +0000 |
|---|---|---|
| committer | hannken <hannken@NetBSD.org> | 2023-03-14 12:55:43 +0000 |
| commit | 3c4e1b3b03829f927ed2ed94ca7420ca84598845 (patch) | |
| tree | 6c1f2bc7361e0e8d6ecb5c160b4c29f3871957b0 /sys/dev | |
| parent | cb6a5a3575fd9678245ac90623c4fbe964c14704 (diff) | |
Do not limit the number of pending requests for the worker thread.
With wedge on vnd it prevents a deadlock when requests get queued with
biodone() -> dkstart() -> vndstrategy().
Fixes PR kern/57263 "vnd locks up when using vn_rdwr"
Diffstat (limited to 'sys/dev')
| -rw-r--r-- | sys/dev/vnd.c | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/sys/dev/vnd.c b/sys/dev/vnd.c index 8998f9b40b7..1e597b5e9b4 100644 --- a/sys/dev/vnd.c +++ b/sys/dev/vnd.c @@ -1,4 +1,4 @@ -/* $NetBSD: vnd.c,v 1.287 2022/09/04 21:56:38 mlelstv Exp $ */ +/* $NetBSD: vnd.c,v 1.288 2023/03/14 12:55:43 hannken Exp $ */ /*- * Copyright (c) 1996, 1997, 1998, 2008, 2020 The NetBSD Foundation, Inc. @@ -91,7 +91,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.287 2022/09/04 21:56:38 mlelstv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.288 2023/03/14 12:55:43 hannken Exp $"); #if defined(_KERNEL_OPT) #include "opt_vnd.h" @@ -553,11 +553,18 @@ vndstrategy(struct buf *bp) printf("vndstrategy(%p): unit %d\n", bp, unit); #endif if ((vnd->sc_flags & VNF_USE_VN_RDWR)) { - KASSERT(vnd->sc_pending >= 0 && - vnd->sc_pending <= VND_MAXPENDING(vnd)); - while (vnd->sc_pending == VND_MAXPENDING(vnd)) - tsleep(&vnd->sc_pending, PRIBIO, "vndpc", 0); + /* + * Limit the number of pending requests to not exhaust + * resources needed for I/O but always allow the worker + * thread to add requests, as a wedge on vnd queues + * requests with biodone() -> dkstart() -> vndstrategy(). + */ + if (curlwp != vnd->sc_kthread) { + while (vnd->sc_pending >= VND_MAXPENDING(vnd)) + tsleep(&vnd->sc_pending, PRIBIO, "vndpc", 0); + } vnd->sc_pending++; + KASSERT(vnd->sc_pending > 0); } bufq_put(vnd->sc_tab, bp); wakeup(&vnd->sc_tab); @@ -674,8 +681,7 @@ vndthread(void *arg) continue; }; if ((vnd->sc_flags & VNF_USE_VN_RDWR)) { - KASSERT(vnd->sc_pending > 0 && - vnd->sc_pending <= VND_MAXPENDING(vnd)); + KASSERT(vnd->sc_pending > 0); if (vnd->sc_pending-- == VND_MAXPENDING(vnd)) wakeup(&vnd->sc_pending); } |
