Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 2 Aug 2012 11:31:19 -0700
From:      Jim Harris <jimharris@freebsd.org>
To:        freebsd-geom@freebsd.org
Subject:   Re: bio_flags (BIO_ORDERED) and g_clone_bio()
Message-ID:  <CAJP=Hc-7c_7J3MijRa%2Bw19gMbhcX846KAK-utkyR3eYaW=uzpA@mail.gmail.com>
In-Reply-To: <CAJP=Hc8xOhLvPXAe091-vTWs4RBV2mEMq2c2WunKA8k2TbaX3A@mail.gmail.com>
References:  <CAJP=Hc8xOhLvPXAe091-vTWs4RBV2mEMq2c2WunKA8k2TbaX3A@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, Aug 2, 2012 at 11:01 AM, Jim Harris <jimharris@freebsd.org> wrote:
> I'm trying to understand how the BIO_ORDERED flag ever gets passed
> down to disk consumers (i.e. daX)  It's obvious that g_io_flush() sets
> the BIO_ORDERED flag, but when the bio gets cloned, the bio_flags do
> not get cloned.  So while the FLUSH command does make it to the disk
> consumer, it is without the BIO_ORDERED flag.  I'm sure some flags are
> not meant to be cloned, but is seems BIO_ORDERED should.
>
> I'm sure I'm missing something here, but haven't figured it out yet.
> Any help would be appreciated.
>

The following patch seems to be appropriate.  The other flags
(BIO_ERROR, BIO_DONE, and BIO_ONQUEUE) aren't suitable for cloning.

diff --git a/sys/geom/geom_io.c b/sys/geom/geom_io.c
index b4044a7..00c7d39 100644
--- a/sys/geom/geom_io.c
+++ b/sys/geom/geom_io.c
@@ -177,6 +177,8 @@ g_clone_bio(struct bio *bp)
        if (bp2 != NULL) {
                bp2->bio_parent = bp;
                bp2->bio_cmd = bp->bio_cmd;
+               /* Only BIO_ORDERED flag is suitable to be cloned. */
+               bp2->bio_flags = bp->bio_flags & BIO_ORDERED;
                bp2->bio_length = bp->bio_length;
                bp2->bio_offset = bp->bio_offset;
                bp2->bio_data = bp->bio_data;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAJP=Hc-7c_7J3MijRa%2Bw19gMbhcX846KAK-utkyR3eYaW=uzpA>