diff options
author | Conrad Meyer <cem@FreeBSD.org> | 2020-08-02 16:34:27 +0000 |
---|---|---|
committer | Conrad Meyer <cem@FreeBSD.org> | 2020-08-02 16:34:27 +0000 |
commit | 9da903e5d3fa686b67df0c8d460fcf3ca9444172 (patch) | |
tree | 3f14aeb6225fab9bc5a32bbb79b83cc4fab92bd0 /sys/kern/vfs_bio.c | |
parent | 936c24fabaf5f532b16489d03e88350c3cee4cc7 (diff) | |
download | src-9da903e5d3fa686b67df0c8d460fcf3ca9444172.tar.gz src-9da903e5d3fa686b67df0c8d460fcf3ca9444172.zip |
Unlocked getblk: Fix new false-positive assertion
A free buf's lock may be held (temporarily) due to unlocked lookup, so
buf_alloc() must acquire it without LK_NOWAIT. The unlocked getblk path
should unlock it promptly once it realizes the identity does not match
the buffer it was searching for.
Reported by: gallatin
Reviewed by: kib
Tested by: pho
X-MFC-With: r363482
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D25914
Notes
Notes:
svn path=/head/; revision=363770
Diffstat (limited to 'sys/kern/vfs_bio.c')
-rw-r--r-- | sys/kern/vfs_bio.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/sys/kern/vfs_bio.c b/sys/kern/vfs_bio.c index 524554cdd48f..adc44082d972 100644 --- a/sys/kern/vfs_bio.c +++ b/sys/kern/vfs_bio.c @@ -1637,7 +1637,7 @@ static struct buf * buf_alloc(struct bufdomain *bd) { struct buf *bp; - int freebufs; + int freebufs, error; /* * We can only run out of bufs in the buf zone if the average buf @@ -1660,8 +1660,10 @@ buf_alloc(struct bufdomain *bd) if (freebufs == bd->bd_lofreebuffers) bufspace_daemon_wakeup(bd); - if (BUF_LOCK(bp, LK_EXCLUSIVE | LK_NOWAIT, NULL) != 0) - panic("getnewbuf_empty: Locked buf %p on free queue.", bp); + error = BUF_LOCK(bp, LK_EXCLUSIVE, NULL); + KASSERT(error == 0, ("%s: BUF_LOCK on free buf %p: %d.", __func__, bp, + error)); + (void)error; KASSERT(bp->b_vp == NULL, ("bp: %p still has vnode %p.", bp, bp->b_vp)); |