git: 09be14a7b80d - stable/12 - gmultipath: make physpath distinct from the underlying providers'

From: Alan Somers <asomers_at_FreeBSD.org>
Date: Thu, 07 Oct 2021 19:31:31 UTC
The branch stable/12 has been updated by asomers:

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

commit 09be14a7b80d75e39faf01596583ad4ed18e3232
Author:     Alan Somers <asomers@FreeBSD.org>
AuthorDate: 2021-04-22 21:09:03 +0000
Commit:     Alan Somers <asomers@FreeBSD.org>
CommitDate: 2021-10-07 19:27:13 +0000

    gmultipath: make physpath distinct from the underlying providers'
    
    zfsd uses a device's physical path attribute to automatically replace a
    missing ZFS disk when a blank disk is inserted into the same physical
    slot.  Currently gmultipath passes through its underlying providers'
    physical path attribute.  That may cause zfsd to replace a missing
    gmultipath provider with a newly arrived, single-path disk.  That would
    be bad.
    
    This commit fixes that problem by simply appending "/mp" to the
    underlying providers' physical path, in a manner similar to what geli
    already does.
    
    Sponsored by:   Axcient
    Differential Revision: https://reviews.freebsd.org/D29941
    
    (cherry picked from commit 420dbe763f15b076751443edfeeb4f676deb3c44)
---
 sys/geom/multipath/g_multipath.c       | 6 ++++++
 tests/sys/geom/class/multipath/misc.sh | 4 ++--
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/sys/geom/multipath/g_multipath.c b/sys/geom/multipath/g_multipath.c
index f5fe539a879c..7a8c88ab61fc 100644
--- a/sys/geom/multipath/g_multipath.c
+++ b/sys/geom/multipath/g_multipath.c
@@ -393,6 +393,12 @@ g_multipath_done(struct bio *bp)
 			mtx_unlock(&sc->sc_mtx);
 		} else
 			mtx_unlock(&sc->sc_mtx);
+		if (bp->bio_error == 0 &&
+			bp->bio_cmd == BIO_GETATTR &&
+			!strcmp(bp->bio_attribute, "GEOM::physpath"))
+		{
+			strlcat(bp->bio_data, "/mp", bp->bio_length);
+		}
 		g_std_done(bp);
 	}
 }
diff --git a/tests/sys/geom/class/multipath/misc.sh b/tests/sys/geom/class/multipath/misc.sh
index 583434e1cfa5..4da8462588ca 100755
--- a/tests/sys/geom/class/multipath/misc.sh
+++ b/tests/sys/geom/class/multipath/misc.sh
@@ -198,7 +198,7 @@ fail_on_error_cleanup()
 atf_test_case physpath cleanup
 physpath_head()
 {
-	atf_set "descr" "gmultipath should pass through the underlying providers' physical path"
+	atf_set "descr" "gmultipath should append /mp to the underlying providers' physical path"
 	atf_set "require.user" "root"
 }
 physpath_body()
@@ -217,7 +217,7 @@ physpath_body()
 	atf_check gnop create -z $physpath /dev/${md1}
 	atf_check -s exit:0 gmultipath create "$name" ${md0}.nop ${md1}.nop
 	gmultipath_physpath=$(diskinfo -p multipath/"$name") 
-	atf_check_equal "$physpath" "$gmultipath_physpath"
+	atf_check_equal "$physpath/mp" "$gmultipath_physpath"
 }
 physpath_cleanup()
 {