git: b72d51cfffab - stable/13 - Avoid "consumer not attached in g_io_request" panic when disk lost while using a UFS snapshot.

From: Kirk McKusick <mckusick_at_FreeBSD.org>
Date: Thu, 07 Oct 2021 23:08:03 UTC
The branch stable/13 has been updated by mckusick:

URL: https://cgit.FreeBSD.org/src/commit/?id=b72d51cfffab35f43cd05ee385047f222e0ab8e0

commit b72d51cfffab35f43cd05ee385047f222e0ab8e0
Author:     Kirk McKusick <mckusick@FreeBSD.org>
AuthorDate: 2021-09-28 03:03:43 +0000
Commit:     Kirk McKusick <mckusick@FreeBSD.org>
CommitDate: 2021-10-07 23:05:39 +0000

    Avoid "consumer not attached in g_io_request" panic when disk lost
    while using a UFS snapshot.
    
    Differential revision: https://reviews.freebsd.org/D32150
    Sponsored by: Netflix
    
    (cherry picked from commit 4a365e863f209b0c82641c909a858dab53b19134)
---
 sys/ufs/ffs/ffs_snapshot.c | 17 ++++++-----------
 1 file changed, 6 insertions(+), 11 deletions(-)

diff --git a/sys/ufs/ffs/ffs_snapshot.c b/sys/ufs/ffs/ffs_snapshot.c
index baad50cab2ba..5855a679ab84 100644
--- a/sys/ufs/ffs/ffs_snapshot.c
+++ b/sys/ufs/ffs/ffs_snapshot.c
@@ -63,6 +63,7 @@ __FBSDID("$FreeBSD$");
 #include <vm/vm_extern.h>
 
 #include <geom/geom.h>
+#include <geom/geom_vfs.h>
 
 #include <ufs/ufs/extattr.h>
 #include <ufs/ufs/quota.h>
@@ -2554,22 +2555,16 @@ readblock(vp, bp, lbn)
 	ufs2_daddr_t lbn;
 {
 	struct inode *ip;
-	struct bio *bip;
 	struct fs *fs;
 
 	ip = VTOI(vp);
 	fs = ITOFS(ip);
 
-	bip = g_alloc_bio();
-	bip->bio_cmd = BIO_READ;
-	bip->bio_offset = dbtob(fsbtodb(fs, blkstofrags(fs, lbn)));
-	bip->bio_data = bp->b_data;
-	bip->bio_length = bp->b_bcount;
-	bip->bio_done = NULL;
-
-	g_io_request(bip, ITODEVVP(ip)->v_bufobj.bo_private);
-	bp->b_error = biowait(bip, "snaprdb");
-	g_destroy_bio(bip);
+	bp->b_iocmd = BIO_READ;
+	bp->b_iooffset = dbtob(fsbtodb(fs, blkstofrags(fs, lbn)));
+	bp->b_iodone = bdone;
+	g_vfs_strategy(&ITODEVVP(ip)->v_bufobj, bp);
+	bufwait(bp);
 	return (bp->b_error);
 }