What is geom_start() and struct bio contract?

Lev Serebryakov lev at FreeBSD.org
Sun Oct 2 12:56:43 UTC 2011


Hello, Lev.
You wrote 2 октября 2011 г., 16:46:58:

>  Is it Ok? What should store this field? If it should store provider,
>  which ISSUED this bio, why g_io_request() reset it? If it should
>  store provider, which will EXECUTE this bio, why geom_nop set it to
>  itself provider, and why is here this field at all, as it could be
>  derived from bio_from (it seems, that it is always set to
>  bio_from->provider!)?

  On the other hand, bio_done() is called only if bio_from is NULL,
and any bio issued with g_io_request() could not have bio_form set to
NULL:


g_io_request(struct bio *bp, struct g_consumer *cp)
{
        struct g_provider *pp;
        int first;

        KASSERT(cp != NULL, ("NULL cp in g_io_request"));
        ...
        bp->bio_from = cp;
        ...
}

void
g_io_deliver(struct bio *bp, int error)
{
        struct g_consumer *cp;
        struct g_provider *pp;
        ...
        cp = bp->bio_from;
        if (cp == NULL) {
                bp->bio_error = error;
                bp->bio_done(bp);
                return;
        }
        ...
}

 I'm completely puzzled, how does it work at all! Many GEOMs set
 bio_done to their done utilities, and then submit bio with
 g_io_request() and it seems to work! But why?! I could not understand
 this from quoted code!

-- 
// Black Lion AKA Lev Serebryakov <lev at FreeBSD.org>



More information about the freebsd-geom mailing list