From owner-p4-projects@FreeBSD.ORG Thu Jun 14 16:46:35 2007 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id A172D16A469; Thu, 14 Jun 2007 16:46:35 +0000 (UTC) X-Original-To: perforce@FreeBSD.org Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 4331916A46D for ; Thu, 14 Jun 2007 16:46:35 +0000 (UTC) (envelope-from lulf@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [69.147.83.41]) by mx1.freebsd.org (Postfix) with ESMTP id 3203F13C484 for ; Thu, 14 Jun 2007 16:46:35 +0000 (UTC) (envelope-from lulf@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.8/8.13.8) with ESMTP id l5EGkZYO081008 for ; Thu, 14 Jun 2007 16:46:35 GMT (envelope-from lulf@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.8/8.13.8/Submit) id l5EGkZYX080999 for perforce@freebsd.org; Thu, 14 Jun 2007 16:46:35 GMT (envelope-from lulf@FreeBSD.org) Date: Thu, 14 Jun 2007 16:46:35 GMT Message-Id: <200706141646.l5EGkZYX080999@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to lulf@FreeBSD.org using -f From: Ulf Lilleengen To: Perforce Change Reviews Cc: Subject: PERFORCE change 121639 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Jun 2007 16:46:36 -0000 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. */