Date: Thu, 14 Jun 2007 16:46:35 GMT From: Ulf Lilleengen <lulf@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 121639 for review Message-ID: <200706141646.l5EGkZYX080999@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=121639 Change 121639 by lulf@lulf_carrot on 2007/06/14 16:46:24 - Fix many bugs i introduced when refractoring my sync code without looking over it. Affected files ... .. //depot/projects/soc2007/lulf/gvinum_fixup/sys/geom/vinum/geom_vinum_init.c#7 edit .. //depot/projects/soc2007/lulf/gvinum_fixup/sys/geom/vinum/geom_vinum_volume.c#4 edit Differences ... ==== //depot/projects/soc2007/lulf/gvinum_fixup/sys/geom/vinum/geom_vinum_init.c#7 (text+ko) ==== @@ -214,7 +214,7 @@ p->flags |= GV_PLEX_SYNCING; printf("VINUM: starting sync of plex %s\n", p->name); error = gv_sync_request(up, p, 0, GV_DFLT_SYNCSIZE, BIO_READ, - g_malloc(GV_DFLT_SYNCSIZE, M_WAITOK)); + NULL); if (error) { printf("VINUM: error syncing plex %s\n", p->name); break; ==== //depot/projects/soc2007/lulf/gvinum_fixup/sys/geom/vinum/geom_vinum_volume.c#4 (text+ko) ==== @@ -183,21 +183,33 @@ g_topology_assert_not(); + err = 0; from = bp->bio_caller2; v = to->vol_sc; - err = gv_sync_request(from, to, bp->bio_offset, bp->bio_length, - bp->bio_cmd, bp->bio_data); - if (err) { + /* If it was a read, write it. */ + if (bp->bio_cmd == BIO_READ) { + err = gv_sync_request(from, to, bp->bio_offset, bp->bio_length, + BIO_WRITE, bp->bio_data); + /* If it was a write, read the next one. */ + } else if (bp->bio_cmd == BIO_WRITE) { if (bp->bio_cflags & GV_BIO_MALLOC) g_free(bp->bio_data); - g_destroy_bio(bp); + /* If we're finished, clean up. */ + if (bp->bio_offset + bp->bio_length >= from->size) { + printf("VINUM: syncing of %s from %s completed\n", + to->name, from->name); + to->flags &= ~GV_PLEX_SYNCING; + } else { + err = gv_sync_request(from, to, bp->bio_offset + + bp->bio_length, bp->bio_length, BIO_READ, NULL); + } + } + g_destroy_bio(bp); + if (err) { + printf("VINUM: error syncing plexes: error code %d\n", err); return; } - /* Free data if we're writing and destroy bio. */ - if (bp->bio_cmd == BIO_WRITE && bp->bio_cflags & GV_BIO_MALLOC) - g_free(bp->bio_data); - g_destroy_bio(bp); /* Check if all plexes are synced, and lower refcounts. */ g_topology_lock(); @@ -228,34 +240,15 @@ bp->bio_done = gv_done; bp->bio_cflags |= GV_BIO_SYNCREQ; bp->bio_offset = offset; - bp->bio_caller2 = to; /* Reverse the caller. */ - - /* If it was a read, write it to the destination. */ - if (type == BIO_READ) { - /*printf("We just read %s at %jd, and now write %s at %jd\n", - to->name, offset, from->name, offset);*/ - bp->bio_cmd = BIO_WRITE; - bp->bio_data = data; - /* If it was a write, read the next one. */ - } else if (type == BIO_WRITE) { - bp->bio_cmd = BIO_READ; - bp->bio_offset += bp->bio_length; - bp->bio_data = g_malloc(bp->bio_length, M_WAITOK); - bp->bio_cflags |= GV_BIO_MALLOC; - - /*printf("We just wrote %s at %jd, and now read %s at %jd\n", - to->name, bp->bio_offset, from->name, bp->bio_offset); - */ - /* If we're finished, clean up. */ - if (bp->bio_offset >= from->size) { - printf("VINUM: syncing of %s from %s completed\n", - to->name, from->name); - to->flags &= ~GV_PLEX_SYNCING; - return (0); - } + bp->bio_caller2 = to; + bp->bio_cmd = type; + if (data == NULL) { + data = g_malloc(length, M_WAITOK); + bp->bio_cflags |= GV_BIO_MALLOC; } + bp->bio_data = data; -/* printf("Sending next bio: "); +/* printf("Sending next bio:\n "); g_print_bio(bp); printf("\n");*/ /* Send down next. */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200706141646.l5EGkZYX080999>