git: 10ae42ccbde4 - main - GEOM: Set G_CF_DIRECT_SEND/RECEIVE for taste consumers.

From: Alexander Motin <mav_at_FreeBSD.org>
Date: Sun, 30 Jan 2022 03:00:16 UTC
The branch main has been updated by mav:

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

commit 10ae42ccbde4fe7c8c9de3d54f3c0d63457a1a68
Author:     Alexander Motin <mav@FreeBSD.org>
AuthorDate: 2022-01-30 02:59:03 +0000
Commit:     Alexander Motin <mav@FreeBSD.org>
CommitDate: 2022-01-30 02:59:03 +0000

    GEOM: Set G_CF_DIRECT_SEND/RECEIVE for taste consumers.
    
    All I/O requests through the taste consumers are synchronous, done
    with g_read_data() and without any locks held.  It makes no sense
    to delegate the I/O to g_down/g_up threads.
    
    This removes many of context switches during disk retaste.
    
    MFC after:      2 weeks
---
 sys/geom/cache/g_cache.c         | 1 +
 sys/geom/concat/g_concat.c       | 1 +
 sys/geom/journal/g_journal.c     | 1 +
 sys/geom/linux_lvm/g_linux_lvm.c | 1 +
 sys/geom/mirror/g_mirror.c       | 1 +
 sys/geom/multipath/g_multipath.c | 1 +
 sys/geom/raid3/g_raid3.c         | 1 +
 sys/geom/shsec/g_shsec.c         | 1 +
 sys/geom/stripe/g_stripe.c       | 1 +
 sys/geom/vinum/geom_vinum.c      | 1 +
 sys/geom/virstor/g_virstor.c     | 1 +
 11 files changed, 11 insertions(+)

diff --git a/sys/geom/cache/g_cache.c b/sys/geom/cache/g_cache.c
index 2caae5ede0f4..86c2a9bb36a2 100644
--- a/sys/geom/cache/g_cache.c
+++ b/sys/geom/cache/g_cache.c
@@ -673,6 +673,7 @@ g_cache_taste(struct g_class *mp, struct g_provider *pp, int flags __unused)
 	gp->orphan = g_cache_orphan;
 	gp->access = g_cache_access;
 	cp = g_new_consumer(gp);
+	cp->flags |= G_CF_DIRECT_SEND | G_CF_DIRECT_RECEIVE;
 	error = g_attach(cp, pp);
 	if (error == 0) {
 		error = g_cache_read_metadata(cp, &md);
diff --git a/sys/geom/concat/g_concat.c b/sys/geom/concat/g_concat.c
index c4a5e0476edf..af6109bcc2f5 100644
--- a/sys/geom/concat/g_concat.c
+++ b/sys/geom/concat/g_concat.c
@@ -760,6 +760,7 @@ g_concat_taste(struct g_class *mp, struct g_provider *pp, int flags __unused)
 	gp->access = g_concat_access;
 	gp->orphan = g_concat_orphan;
 	cp = g_new_consumer(gp);
+	cp->flags |= G_CF_DIRECT_SEND | G_CF_DIRECT_RECEIVE;
 	error = g_attach(cp, pp);
 	if (error == 0) {
 		error = g_concat_read_metadata(cp, &md);
diff --git a/sys/geom/journal/g_journal.c b/sys/geom/journal/g_journal.c
index 60c2aeb4fad6..866305ed8578 100644
--- a/sys/geom/journal/g_journal.c
+++ b/sys/geom/journal/g_journal.c
@@ -2481,6 +2481,7 @@ g_journal_taste(struct g_class *mp, struct g_provider *pp, int flags __unused)
 	/* This orphan function should be never called. */
 	gp->orphan = g_journal_taste_orphan;
 	cp = g_new_consumer(gp);
+	cp->flags |= G_CF_DIRECT_SEND | G_CF_DIRECT_RECEIVE;
 	error = g_attach(cp, pp);
 	if (error == 0) {
 		error = g_journal_metadata_read(cp, &md);
diff --git a/sys/geom/linux_lvm/g_linux_lvm.c b/sys/geom/linux_lvm/g_linux_lvm.c
index b835baecc93d..f17827757139 100644
--- a/sys/geom/linux_lvm/g_linux_lvm.c
+++ b/sys/geom/linux_lvm/g_linux_lvm.c
@@ -543,6 +543,7 @@ g_llvm_taste(struct g_class *mp, struct g_provider *pp, int flags __unused)
 	/* This orphan function should be never called. */
 	gp->orphan = g_llvm_taste_orphan;
 	cp = g_new_consumer(gp);
+	cp->flags |= G_CF_DIRECT_SEND | G_CF_DIRECT_RECEIVE;
 	error = g_attach(cp, pp);
 	if (error == 0) {
 		error = g_llvm_read_label(cp, &ll);
diff --git a/sys/geom/mirror/g_mirror.c b/sys/geom/mirror/g_mirror.c
index 051628e40700..94e615c8038d 100644
--- a/sys/geom/mirror/g_mirror.c
+++ b/sys/geom/mirror/g_mirror.c
@@ -3269,6 +3269,7 @@ g_mirror_taste(struct g_class *mp, struct g_provider *pp, int flags __unused)
 	 */
 	gp->orphan = g_mirror_taste_orphan;
 	cp = g_new_consumer(gp);
+	cp->flags |= G_CF_DIRECT_SEND | G_CF_DIRECT_RECEIVE;
 	error = g_attach(cp, pp);
 	if (error == 0) {
 		error = g_mirror_read_metadata(cp, &md);
diff --git a/sys/geom/multipath/g_multipath.c b/sys/geom/multipath/g_multipath.c
index ee1db72f68f9..33fcfd95925e 100644
--- a/sys/geom/multipath/g_multipath.c
+++ b/sys/geom/multipath/g_multipath.c
@@ -828,6 +828,7 @@ g_multipath_taste(struct g_class *mp, struct g_provider *pp, int flags __unused)
 	gp->access = g_multipath_access;
 	gp->orphan = g_multipath_orphan;
 	cp = g_new_consumer(gp);
+	cp->flags |= G_CF_DIRECT_SEND | G_CF_DIRECT_RECEIVE;
 	error = g_attach(cp, pp);
 	if (error == 0) {
 		error = g_multipath_read_metadata(cp, &md);
diff --git a/sys/geom/raid3/g_raid3.c b/sys/geom/raid3/g_raid3.c
index 7fcf8aa2e024..22e833c25f5d 100644
--- a/sys/geom/raid3/g_raid3.c
+++ b/sys/geom/raid3/g_raid3.c
@@ -3310,6 +3310,7 @@ g_raid3_taste(struct g_class *mp, struct g_provider *pp, int flags __unused)
 	/* This orphan function should be never called. */
 	gp->orphan = g_raid3_taste_orphan;
 	cp = g_new_consumer(gp);
+	cp->flags |= G_CF_DIRECT_SEND | G_CF_DIRECT_RECEIVE;
 	error = g_attach(cp, pp);
 	if (error == 0) {
 		error = g_raid3_read_metadata(cp, &md);
diff --git a/sys/geom/shsec/g_shsec.c b/sys/geom/shsec/g_shsec.c
index 88add59f6d26..c1bbe69f4b8f 100644
--- a/sys/geom/shsec/g_shsec.c
+++ b/sys/geom/shsec/g_shsec.c
@@ -651,6 +651,7 @@ g_shsec_taste(struct g_class *mp, struct g_provider *pp, int flags __unused)
 	gp->access = g_shsec_access;
 	gp->orphan = g_shsec_orphan;
 	cp = g_new_consumer(gp);
+	cp->flags |= G_CF_DIRECT_SEND | G_CF_DIRECT_RECEIVE;
 	error = g_attach(cp, pp);
 	if (error == 0) {
 		error = g_shsec_read_metadata(cp, &md);
diff --git a/sys/geom/stripe/g_stripe.c b/sys/geom/stripe/g_stripe.c
index ec3bfb28b6a5..00a81e88bf3a 100644
--- a/sys/geom/stripe/g_stripe.c
+++ b/sys/geom/stripe/g_stripe.c
@@ -954,6 +954,7 @@ g_stripe_taste(struct g_class *mp, struct g_provider *pp, int flags __unused)
 	gp->access = g_stripe_access;
 	gp->orphan = g_stripe_orphan;
 	cp = g_new_consumer(gp);
+	cp->flags |= G_CF_DIRECT_SEND | G_CF_DIRECT_RECEIVE;
 	error = g_attach(cp, pp);
 	if (error == 0) {
 		error = g_stripe_read_metadata(cp, &md);
diff --git a/sys/geom/vinum/geom_vinum.c b/sys/geom/vinum/geom_vinum.c
index 0c60a051619f..86f5c9f08e1f 100644
--- a/sys/geom/vinum/geom_vinum.c
+++ b/sys/geom/vinum/geom_vinum.c
@@ -599,6 +599,7 @@ gv_taste(struct g_class *mp, struct g_provider *pp, int flags __unused)
 	sc = gp->softc;
 
 	cp = g_new_consumer(gp);
+	cp->flags |= G_CF_DIRECT_SEND | G_CF_DIRECT_RECEIVE;
 	if (g_attach(cp, pp) != 0) {
 		g_destroy_consumer(cp);
 		return (NULL);
diff --git a/sys/geom/virstor/g_virstor.c b/sys/geom/virstor/g_virstor.c
index 6c201b24ab19..93f103cadb6d 100644
--- a/sys/geom/virstor/g_virstor.c
+++ b/sys/geom/virstor/g_virstor.c
@@ -780,6 +780,7 @@ g_virstor_taste(struct g_class *mp, struct g_provider *pp, int flags)
 	gp->orphan = (void *)invalid_call;	/* I really want these to fail. */
 
 	cp = g_new_consumer(gp);
+	cp->flags |= G_CF_DIRECT_SEND | G_CF_DIRECT_RECEIVE;
 	error = g_attach(cp, pp);
 	if (error == 0) {
 		error = read_metadata(cp, &md);