PERFORCE change 123439 for review

Sonja Milicic smilicic at FreeBSD.org
Fri Jul 13 13:10:18 UTC 2007


http://perforce.freebsd.org/chv.cgi?CH=123439

Change 123439 by smilicic at tanarri_marilith on 2007/07/13 13:09:48

	added license statements to files that didn't have them
	   fixed a bug in g_log_access
	   redirecting write requests to log file now works

Affected files ...

.. //depot/projects/soc2007/smilicic_glog/sys/geom/log/geom_log_so.c#2 edit
.. //depot/projects/soc2007/smilicic_glog/sys/geom/log/glog.c#7 edit
.. //depot/projects/soc2007/smilicic_glog/sys/geom/log/glog_fileops.c#2 edit
.. //depot/projects/soc2007/smilicic_glog/sys/geom/log/glog_fileops.h#2 edit

Differences ...

==== //depot/projects/soc2007/smilicic_glog/sys/geom/log/geom_log_so.c#2 (text+ko) ====

@@ -1,3 +1,29 @@
+/*-
+ * Copyright (c) 2007 Sonja Milicic <tanarri at geri.cc.fer.hr>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+ 
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
@@ -30,7 +56,7 @@
             { 'f', "force", NULL, G_TYPE_NONE },
             G_OPT_SENTINEL
         },
-        "[-fv] name ..."
+        "[-fv] prov ..."
     },
     { "start", G_FLAG_VERBOSE, NULL,
         {
@@ -42,13 +68,13 @@
         {
             G_OPT_SENTINEL
         },
-        "[-v] name ..."
+        "[-v] prov ..."
     },
     { "rollback", G_FLAG_VERBOSE, NULL,
         {
             G_OPT_SENTINEL
         },
-        "[-v] name ..."
+        "[-v] prov ..."
     },
 
     G_CMD_SENTINEL

==== //depot/projects/soc2007/smilicic_glog/sys/geom/log/glog.c#7 (text+ko) ====

@@ -188,13 +188,13 @@
 	sc->sc_prov_disk = pp_disk;
 	sc->sc_cons_disk = cp_disk;
 	
-	/*create provider for log*/
+	/*create provider and consumer for log*/
 	pp_log = g_new_providerf(gp, "%s.log", prov);
-	pp_log->mediasize = (off_t) 1000;
+	pp_log->mediasize = pp_disk->mediasize;
 	pp_log->sectorsize = pp_disk->sectorsize;
 	g_error_provider(pp_log, 0);
+	
 	sc->sc_prov_log = pp_log;
-	
 	if (g_log_event_sink_init(sc, &sc->sc_events, g_log_worker, "events") !=0){
 		*err=4;
 		g_log_event_sink_destroy(&sc->sc_events);
@@ -302,23 +302,27 @@
 g_log_start(struct bio *bp) 
 {
 	struct g_log_softc *sc; 
+	G_LOG_DEBUG(0, "request received.");
+
 	sc = bp->bio_to->geom->softc;
 	KASSERT(sc != NULL,
 	    ("Provider's error should be set (error=%d)(device=%s).",
 	    bp->bio_to->error, bp->bio_to->name));
 
 	G_LOG_LOGREQ(DBG_NOTICE, bp, "Request received.");
-	g_io_deliver(bp, ENXIO);
-	return;
 	switch(bp->bio_cmd) {
 	case BIO_WRITE:
+		G_LOG_DEBUG(0, "Write request received.");
 		g_log_post_event(&sc->sc_events, GLOG_EVWRITE, GLOG_FLAG_WAKEUP_SC, bp, 0);
 		break;
 	case BIO_READ:
+		g_io_deliver(bp, ENXIO);
+		return;
 		g_log_post_event(&sc->sc_events, GLOG_EVREAD, GLOG_FLAG_WAKEUP_SC, bp, 0);
 		break;
 	default:
-		break;
+		g_io_deliver(bp, ENXIO);
+		return;
 	}
 	return;
 }
@@ -374,7 +378,6 @@
 	
 	g_wither_geom(gp, ENXIO);
 	
-	G_LOG_DEBUG(0, "Really destroyed %s.", gp->name);
 	return 0;
 }
 
@@ -388,6 +391,7 @@
 	
 	gp = pp->geom;
 	sc = gp->softc;
+	cp = sc->sc_cons_disk;
 	G_LOG_DEBUG(DBG_IMPORTANT, "%s: %d %d %d", __func__, dr, dw, de);
 	
 	if (sc == NULL) {
@@ -404,12 +408,10 @@
 		return (0);
 	}
 	
-	LIST_FOREACH(cp, &gp->consumer, consumer){
-		err = g_access(cp, dr ,dw, de);
-		if (err == 0)
-			continue;
-		G_LOG_DEBUG(0, "loop access");
-	}
+	
+	err = g_access(cp, dr ,dw, de);
+	
+	G_LOG_DEBUG(0, "access done, %d", err);
 	return err;
 }
 
@@ -463,6 +465,7 @@
 			g_log_read(bp);
 			break;
 		case GLOG_EVWRITE:
+			G_LOG_DEBUG(0, "About to write data");
 			g_log_write(bp);
 			break;
 		case GLOG_EVSTOP:
@@ -510,7 +513,6 @@
 }
 
 /*gets next event from event queue*/
-/*BUG - causes a panic when there are no events*/
 static struct g_log_event *
 g_log_get_event(struct g_log_event_sink *es) 
 {
@@ -537,12 +539,13 @@
 	struct g_log_softc *sc;
 	void *data;
 	int err;
-	G_LOG_DEBUG(0, "write request");
+	G_LOG_DEBUG(0, "starting to write");
 	sc = bp->bio_to->geom->softc;
 	data = bp->bio_data;
-	err = glog_write_file(sc->sc_vn, data, sizeof(data), 0);
+	err = glog_write_file(sc->sc_vn, data, bp->bio_length, 0);
 	if (err != 0)
 		G_LOG_DEBUG(0, "write error");
+	G_LOG_DEBUG(0, "done writing.");
 }
 
 /*reads data from log file and/or disk*/

==== //depot/projects/soc2007/smilicic_glog/sys/geom/log/glog_fileops.c#2 (text+ko) ====

@@ -1,4 +1,33 @@
+/*-
+ * Copyright (c) 2007 Pawel Jakub Dawidek <pjd at FreeBSD.org>
+ * Copyright (c) 2007 Sonja Milicic <tanarri at geri.cc.fer.hr>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+ 
 #include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
 #include <sys/types.h>
 #include <sys/param.h>
 #include <sys/kernel.h>

==== //depot/projects/soc2007/smilicic_glog/sys/geom/log/glog_fileops.h#2 (text+ko) ====

@@ -1,3 +1,29 @@
+/*-
+ * Copyright (c) 2007 Sonja Milicic <tanarri at geri.cc.fer.hr>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
 struct vnode *glog_open_file(const char *file, int uiflags);
 int glog_close_file(struct vnode *vp, int uiflags);
 int glog_write_file(struct vnode *vp, void *buf, size_t size, off_t off);


More information about the p4-projects mailing list