Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 17 Aug 2007 00:03:35 GMT
From:      Sonja Milicic <smilicic@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 125250 for review
Message-ID:  <200708170003.l7H03ZDG042026@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=125250

Change 125250 by smilicic@tanarri_marilith on 2007/08/17 00:02:48

	added snapshot creation, rollback to snapshot, snapshot I/O
	   fixed a bug with reading from disk
	   fixed style errors in geom_log_so.c and glog.h

Affected files ...

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

Differences ...

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

@@ -6,10 +6,10 @@
  * 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.
+ *	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.
+ *	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
@@ -51,57 +51,43 @@
 /*static void log_main(struct gctl_req *req, unsigned flags);*/
 
 struct g_command class_commands[] = {
-    { "stop", G_FLAG_VERBOSE, NULL,
-        {
-            { 'f', "force", NULL, G_TYPE_NONE },
-            G_OPT_SENTINEL
-        },
-        "[-fv] prov ..."
-    },
-    { "start", G_FLAG_VERBOSE, NULL,
-        {
-            G_OPT_SENTINEL
-        },
-        "[-v] prov file"
-    },
-    { "commit", G_FLAG_VERBOSE, NULL,
-        {
-            G_OPT_SENTINEL
-        },
-        "[-v] prov ..."
-    },
-    { "rollback", G_FLAG_VERBOSE, NULL,
-        {
-            G_OPT_SENTINEL
-        },
-        "[-v] prov ..."
-    },
-    { "dump", G_FLAG_VERBOSE, NULL,
-        {
-            { 'n', "nidx", NULL, G_TYPE_NUMBER },
-            G_OPT_SENTINEL
-        },
-        "[-n nidx] prov ..."
-    },
-    G_CMD_SENTINEL
-};
-
-
-/*static void
-log_main(struct gctl_req *req, unsigned flags)
-{
-    const char *name;
-    int verbose = 0;
-    
-    if ((flags & G_FLAG_VERBOSE) != 0)
-        verbose = 1;
-
-    name = gctl_get_asciiparam(req, "verb");
-    if (name == NULL) {
-        gctl_error(req, "Verb missing.", NULL);
-        return;
-    }
-    
-}*/
-
-
+	{ "stop", G_FLAG_VERBOSE, NULL,
+		{
+			{ 'f', "force", NULL, G_TYPE_NONE },
+			G_OPT_SENTINEL
+		},
+		"[-fv] provider ..."
+	},
+	{ "start", G_FLAG_VERBOSE, NULL,
+		{
+			G_OPT_SENTINEL
+		},
+		"[-v] provider filename"
+	},
+	{ "commit", G_FLAG_VERBOSE, NULL,
+		{
+			G_OPT_SENTINEL
+		},
+		"[-v] provider ..."
+	},
+	{ "rollback", G_FLAG_VERBOSE, NULL,
+		{
+			G_OPT_SENTINEL
+		},
+		"[-v] provider filename ..."
+	},
+	{ "snapshot", G_FLAG_VERBOSE, NULL,
+		{
+			G_OPT_SENTINEL
+		},
+		"[-v] provider filename ..."
+	},
+	{ "dump", G_FLAG_VERBOSE, NULL,
+		{
+			{ 'n', "nidx", NULL, G_TYPE_NUMBER },
+			G_OPT_SENTINEL
+		},
+		"[-n compartment] provider ..."
+	},
+	G_CMD_SENTINEL
+};

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

@@ -58,6 +58,7 @@
 static enum gctl_verb g_log_verb_id(const char* verb);
 static struct g_geom * g_log_create_geom(const char *prov, const char *file, 
 	    struct g_class *mp, int *err);
+static int g_log_load_logfile(struct g_log_softc *sc, const char *file);
 static int g_log_destroy_geom(struct gctl_req *req __unused, 
 	    struct g_class *mp __unused, struct g_geom *gp);
 static void g_log_start(struct bio *bp); 
@@ -74,6 +75,7 @@
 static void g_log_read(struct bio *bp);
 static void g_log_rollback(struct g_log_softc *sc);
 static void g_log_commit(struct g_log_softc *sc);
+static void g_log_snapshot(struct g_log_softc *sc);
 static void g_log_dumpconf(struct sbuf *sb, const char *indent, 
 	    struct g_geom *gp, struct g_consumer *cp, struct g_provider *pp);
 static void g_log_ctl_destroy(struct gctl_req *req, struct g_class *mp);
@@ -114,7 +116,7 @@
 
 /* gctl verb IDs */
 enum gctl_verb { GCTL_INVALID, GCTL_COMMIT, GCTL_ROLLBACK, GCTL_START, 
-	GCTL_STOP, GCTL_DUMP};
+	GCTL_STOP, GCTL_DUMP, GCTL_SNAPSHOT};
 
 static void
 g_log_init(struct g_class *mp __unused)
@@ -156,14 +158,13 @@
 	struct g_provider *pp_log, *pp_disk;
 	struct g_consumer *cp_disk;
 	struct g_log_softc *sc;
-	struct g_log_header head;
 	int max_elements;
+
 	/*initialize softc*/
 	sc = malloc(sizeof(*sc), M_GLOG, M_WAITOK | M_ZERO);
 
 	/*create geom for log*/
 	gp = g_new_geomf(mp, "%s.log", prov);
-
 	gp->start = g_log_start;
 	gp->spoiled = g_log_orphan;
 	gp->orphan = g_log_orphan;
@@ -175,7 +176,6 @@
 	}
 	
 	/* get provider and consumer for disk*/
-	G_LOG_DEBUG(0, "Getting provider and consumer for disk");
 	if (strncmp(prov, "/dev/", strlen("/dev/")) == 0)
 		prov += strlen("/dev/");
 	pp_disk = g_provider_by_name(prov);
@@ -189,11 +189,11 @@
 		return (NULL);
 	}
 	g_error_provider(pp_disk, 0);
+	g_access(cp_disk, 1, 1, 0);
 	sc->sc_prov_disk = pp_disk;
 	sc->sc_cons_disk = cp_disk;
 	
 	/*create provider for log*/
-	G_LOG_DEBUG(0, "Creating provider for log");
 	pp_log = g_new_providerf(gp, "%s.log", prov);
 	pp_log->mediasize = pp_disk->mediasize;
 	pp_log->sectorsize = pp_disk->sectorsize;
@@ -201,67 +201,71 @@
 	sc->sc_prov_log = pp_log;
 	
 	/*initialize alloc table*/
-	G_LOG_DEBUG(0, "Initializing allocation table");
 	sc->sc_alloctable = malloc(sizeof(*sc->sc_alloctable), M_GLOG, 
 	    M_WAITOK | M_ZERO);	
 	g_log_alloctable_init(sc, M_GLOG);
 
 	/*initialize request sublist*/
-	G_LOG_DEBUG(0, "Initializing request sublist");
 	max_elements = (int)(MAXPHYS / sc->sc_prov_log->sectorsize);
 	sc->sc_req_sublist = malloc (max_elements * sizeof(
 	    struct g_log_data), M_GLOG, M_WAITOK | M_ZERO);
 	sc->sc_req_sublist_size = 0;
 	
+	/*load log file*/
+	if (g_log_load_logfile(sc, file) == 1) {
+		*err = 5;
+		return (NULL);
+	}
+	sc->sc_file_name = strdup(file, M_GLOG);
+
+	sc->sc_geom_log = gp;
+	gp->softc = sc;
+	G_LOG_DEBUG(0, "Created geom %s", gp->name);
+
+	/*initialize worker thread*/
+	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);
+		return (NULL);
+	}
+	return gp;
+}
+
+/*load a log file*/
+static int
+g_log_load_logfile(struct g_log_softc *sc, const char *file)
+{
+	struct g_log_header head;
+	
 	/*open file*/
-	G_LOG_DEBUG(0, "Opening log file");
 	sc->sc_vn = g_log_open_file(file, FWRITE | FREAD | O_CREAT | O_TRUNC, 
 	    S_IRUSR | S_IWUSR);
+	if (sc->sc_vn == NULL)
+		return(1);
 	/*see if the file can be used as a log file (has to be either empty or 
 	 *have geom log header), add header if the file's empty, exit with an 
 	 *error if file is neither empty nor has header
-	 */
- 	G_LOG_DEBUG(0, "Checking log file");
+	*/
 	if (g_log_get_size(sc->sc_vn) > 0) {
-	 	G_LOG_DEBUG(0, "Reading header");
 		g_log_read_data(sc->sc_vn, &head, sizeof(head), 0);
 		if (strcmp(head.text,"GEOM_LOG")!=0) {
-			*err = 1;
-			return (NULL);
+			g_log_close_file(sc->sc_vn, FWRITE | FREAD);
+			return(1);
 		}
 		/*warn if the log file was made with different version of glog*/
 		if (head.version != G_LOG_VERSION)
 			G_LOG_DEBUG(0, "Header version: %d\nCurrent version: %d"
 			    , head.version, G_LOG_VERSION);
 		/*restore alloc table from file*/
-		G_LOG_DEBUG(0, "Restoring alloctable from file");
 		sc->sc_curr_offset = sizeof(head);
 		g_log_alloctable_restore(sc, M_GLOG);
 	}
-	else {
-	 	G_LOG_DEBUG(0, "Writing header");
-		G_LOG_DEBUG(0, "Log file empty, writing header.");
+	else { /*log file empty, write header*/
 		g_log_write_header(sc->sc_vn); 
 		sc->sc_curr_offset = sizeof(head);
 	}
-	
-	if (sc->sc_vn == NULL) {
-		*err = 5;
-		return (NULL);
-	}
-	sc->sc_file_name = strdup(file, M_GLOG);
-
-	sc->sc_geom_log = gp;
-	gp->softc = sc;
-	G_LOG_DEBUG(0, "Created geom %s", gp->name);
-	/*initialize worker thread*/
-	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);
-		return (NULL);
-	}
-	return gp;
+	return(0);
 }
 
 /*initialize sink thread*/
@@ -392,10 +396,6 @@
 		break;
 	case GCTL_COMMIT:
 		if (*num_arg == 1) {
-			/*printf("Are you sure (y/n)?");
-			scanf("%c", &confirm);
-			if (confirm != 'y')
-				break;*/
 			prov = gctl_get_asciiparam(req, "arg0");
 			sc = g_log_find(mp, prov);
 			if (sc == NULL) {
@@ -409,17 +409,20 @@
 			gctl_error(req, "Wrong number of parameters.");
 		break;
 	case GCTL_ROLLBACK:
-		if (*num_arg ==1){
-			/*printf("Are you sure (y/n)?");
-			scanf("%c", &confirm);
-			if (confirm != 'y')
-				break;*/
+		if (*num_arg >= 1){
 			prov = gctl_get_asciiparam(req, "arg0");    
 			sc = g_log_find(mp, prov);
 			if (sc == NULL) {
 				G_LOG_DEBUG(0, "Geom not found.");
 				break;
 			}
+			if (*num_arg == 2) {
+				file = gctl_get_asciiparam(req, "arg1");
+				sc->sc_snapshot = strdup(file, M_GLOG);
+			}
+			else 
+				file = NULL;
+
 			g_log_post_event(&sc->sc_events, GLOG_EVROLLBACK, 
 			    GLOG_FLAG_WAKEUP_SC, sc, 0);
 		} else
@@ -446,6 +449,18 @@
 		}
 		g_log_dump_alloctable(sc, *icp);		
 		break;	
+	case GCTL_SNAPSHOT:
+		prov = gctl_get_asciiparam(req, "arg0"); 
+		file = gctl_get_asciiparam(req, "arg1");
+		sc = g_log_find(mp, prov);
+		if (sc == NULL) {
+			G_LOG_DEBUG(0, "Geom not found.");
+			break;
+		}
+		sc->sc_snapshot = strdup(file, M_GLOG);
+		g_log_post_event(&sc->sc_events, GLOG_EVSNAPSHOT, 
+		    GLOG_FLAG_WAKEUP_SC, sc, 0);
+		break;
 	default:
 		gctl_error(req, "Unknown verb.");
 		break;
@@ -499,7 +514,7 @@
 	pp_log = sc->sc_prov_log;
 	pp_disk = sc->sc_prov_disk;
 	cp_disk = sc->sc_cons_disk;
-	
+	g_access(cp_disk, -1, -1, 0);
 	if (pp_log != NULL && (pp_log->acr != 0 || pp_log->acw !=0 || 
 	    pp_log->ace != 0)){
 		if (force)
@@ -633,13 +648,17 @@
 			es->worker_thread = NULL;
 			kthread_exit(0);
 			break;
+		case GLOG_EVSNAPSHOT:
+			g_log_snapshot(sc);
+			break;
 		default:
 			G_LOG_DEBUG(0, "unhandled event %d", ev->type);
 		}
 		free(ev,M_GLOG);
-sleep:		tsleep(es, PRIBIO, "glogidle", 1000);
+sleep:		tsleep(es, PRIBIO, "glogidle", hz);
 	}
-
+	G_LOG_DEBUG(0, "Worker died.");
+	
 }
 /* adds event to event queue */
 static int
@@ -738,11 +757,11 @@
 {
 	struct g_log_softc *sc;
 	struct g_log_data *gd;
-	int err, i, max_elements, offset_buf;
+	int i, max_elements, offset_buf;
 
 	sc = bp->bio_to->geom->softc;
 	KASSERT(sc != NULL, ("%s: softc is null", __func__));
-
+	
 	/*clean up request sublist*/
 	free(sc->sc_req_sublist, M_GLOG);
 	max_elements = (int)(MAXPHYS / sc->sc_prov_log->sectorsize);
@@ -756,7 +775,7 @@
 	G_LOG_DEBUG(0, "Requested %jd, %jd", bp->bio_offset, bp->bio_length);
 
 	/*retrieve request sublist*/
-	err = g_log_alloctable_get(sc, bp->bio_offset, (ssize_t)bp->bio_length);
+	g_log_alloctable_get(sc, bp->bio_offset, (ssize_t)bp->bio_length);
 	
 	/*read requested data*/	
 	for (i = 0; i < sc->sc_req_sublist_size; i++) {
@@ -799,50 +818,90 @@
 	int i, err;
 	
 	KASSERT(sc != NULL, ("%s: sc is null!", __func__));
-	G_LOG_DEBUG(0, "Starting commit...");
-	g_topology_assert();
-	err = g_access(sc->sc_cons_disk, 0, 1, 0);
-	g_topology_unlock();
-	if (err != 0) {
-		G_LOG_DEBUG(0, "Error accessing provider %s", sc->sc_cons_disk->provider->name);
-		return;
-	}
+
 	/*write contents of all compartments to disk*/
 	for (i = 0; i < sc->sc_alloctable->tablesize; i++) {
 		te = &sc->sc_alloctable->table[i];
 		SLIST_FOREACH(ae, &te->allocq, linkage) {
 			if (ae->offset_log != -1) {
-				data = malloc(ae->data_size * sizeof(char), M_GLOG, M_WAITOK | M_ZERO);
-				G_LOG_DEBUG(0, "Committing %jd, %jd, %d", ae->offset_disk, ae->offset_log, ae->data_size);
+				data = malloc(ae->data_size * sizeof(char), 
+				    M_GLOG, M_WAITOK | M_ZERO);
+				    
 				/*get data from log file*/
-				g_log_read_data(sc->sc_vn, (void*)data, ae->data_size, ae->offset_log);
+				g_log_read_data(sc->sc_vn, (void*)data, 
+				    ae->data_size, ae->offset_log);
 				
 				/*write it to disk*/
-				err = g_write_data(sc->sc_cons_disk, ae->offset_disk, data, ae->data_size);
-				g_topology_lock();
-				err = g_access(sc->sc_cons_disk, 0, -1, 0);
-				G_LOG_DEBUG(0, "Write error %d", err);
+				err = g_write_data(sc->sc_cons_disk, 
+				    ae->offset_disk, data, ae->data_size);
 				free(data, M_GLOG);
 			}
 		}	
 	}
+	/*reset log file and alloc table*/
+	g_log_rollback(sc);
 }
 
 /*drop the changes*/
 static void
 g_log_rollback(struct g_log_softc *sc)
 {
-	/*reset log file*/	
-	sc->sc_vn = g_log_empty_file(sc->sc_vn, sc->sc_file_name);
-	g_log_write_header(sc->sc_vn); 
-	sc->sc_curr_offset = sizeof(struct g_log_header);
 	
 	/*reset alloc table*/
 	g_log_alloctable_free(sc->sc_alloctable, M_GLOG);
 	g_log_alloctable_init(sc, M_GLOG);
+	
+	if (sc->sc_snapshot != NULL) { 	/*load snapshot*/
+		g_log_close_file(sc->sc_vn, FREAD | FWRITE);
+		g_log_load_logfile(sc, sc->sc_snapshot);
+		sc->sc_snapshot=NULL;
+		
+	}
+	else { /*reset log file*/	
+		sc->sc_vn = g_log_empty_file(sc->sc_vn, sc->sc_file_name);
+		g_log_write_header(sc->sc_vn); 
+		sc->sc_curr_offset = sizeof(struct g_log_header);
+	}
 }
 
-
+/*create a snapshot*/
+static void
+g_log_snapshot(struct g_log_softc *sc)
+{
+	struct vnode *ss_vn;
+	struct g_log_header *head;
+	struct g_log_data *gd;
+	char *data;
+	size_t offset, filesize;
+	
+	ss_vn = g_log_open_file(sc->sc_snapshot, FWRITE | O_CREAT | O_TRUNC, S_IWUSR);
+	head = malloc(sizeof(*head), M_GLOG, M_WAITOK | M_ZERO);
+	gd = malloc(sizeof(*gd), M_GLOG, M_WAITOK | M_ZERO);
+	offset = 0;
+	filesize = g_log_get_size(sc->sc_vn);
+	/*copy the contents of current log file to snapshot file*/
+	/*first, the header*/
+	g_log_read_data(sc->sc_vn, head, sizeof(*head), 0);
+	g_log_write_file(ss_vn, head, sizeof(*head), 0);
+	offset += sizeof(*head);
+	/*then data*/
+	while (offset < filesize) {
+		/*data header*/
+		g_log_read_data(sc->sc_vn, gd, sizeof(*gd), offset);
+		g_log_write_file(ss_vn, gd, sizeof(*gd), offset);
+		offset += sizeof(*gd);
+		/*data*/
+		data = malloc(gd->data_size, M_GLOG, M_WAITOK |
+		    M_ZERO);
+		g_log_read_data(sc->sc_vn, (void *)data, gd->data_size, offset);
+		g_log_write_file(ss_vn, (void *)data, gd->data_size, offset);
+		free(data, M_GLOG);
+		offset += gd->data_size;
+	}
+	free(head, M_GLOG);
+	free(gd, M_GLOG);
+	g_log_close_file(ss_vn, FWRITE);
+}
 static int
 g_log_destroy_geom(struct gctl_req *req __unused, struct g_class *mp __unused,
 	    struct g_geom *gp)
@@ -914,6 +973,8 @@
 		return GCTL_STOP;
 	else if (strcmp(verb, "dump") == 0)
 		return GCTL_DUMP;
+	else if (strcmp(verb, "snapshot") == 0)
+		return GCTL_SNAPSHOT;
 	else
 		return GCTL_INVALID;
 };

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

@@ -35,40 +35,41 @@
 #define DBG_NOTICE 15
 
 struct g_log_event {
-        unsigned short int type;
-        unsigned short int flags;
+	unsigned short int type;
+	unsigned short int flags;
 #define GLOG_EVCOMMIT 1
 #define GLOG_EVROLLBACK 2
 #define GLOG_EVREAD 3
 #define GLOG_EVWRITE 4
 #define GLOG_EVSTOP 5
-#define GLOG_FLAG_WAKEUP_SC  6
-
-        void*       data1;
-        int         data2;
-        TAILQ_ENTRY(g_log_event) linkage;
+#define GLOG_EVSNAPSHOT 6
+#define GLOG_FLAG_WAKEUP_SC  7
+	void*       data1;
+	int         data2;
+	TAILQ_ENTRY(g_log_event) linkage;
 };
 
 struct g_log_event_sink {
-    struct proc *worker_thread;
-    struct g_log_softc *sc;
-    TAILQ_HEAD(, g_log_event) eventq;
-    struct mtx  eventq_mtx;
-    uint32_t    flags;
+	struct proc *worker_thread;
+	struct g_log_softc *sc;
+	TAILQ_HEAD(, g_log_event) eventq;
+	struct mtx  eventq_mtx;
+	uint32_t    flags;
 };
 
 struct g_log_softc {
-        struct g_geom *sc_geom_log;
-        struct g_provider *sc_prov_log;
-        struct g_provider *sc_prov_disk;
-        struct g_consumer *sc_cons_disk;
-        struct vnode *sc_vn;
-        struct g_log_event_sink sc_events;
+	struct g_geom *sc_geom_log;
+	struct g_provider *sc_prov_log;
+	struct g_provider *sc_prov_disk;
+	struct g_consumer *sc_cons_disk;
+	struct vnode *sc_vn;
+	struct g_log_event_sink sc_events;
 	struct g_log_alloc_table *sc_alloctable;
 	struct g_log_data *sc_req_sublist;
 	size_t sc_req_sublist_size;
 	off_t sc_curr_offset;
 	char *sc_file_name;
+	char *sc_snapshot;
 };
 
 /*this is the structure that's written to the log file*/
@@ -78,8 +79,6 @@
 	size_t data_size;
 };
 
-#endif /* _KERNEL */
-
 /*a header that's written at the start of log file, so that geom log can 
  * recognize the file later*/
 struct g_log_header {
@@ -87,4 +86,6 @@
 	int version;
 };
 
+#endif /* _KERNEL */
+
 

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

@@ -106,7 +106,7 @@
 		ae->offset_disk = gd->offset_disk;
 		ae->offset_log = gd->offset_log;
 		ae->data_size = gd->data_size;
-		sc->sc_curr_offset +=  gd->offset_log + gd->data_size; /*skip data*/
+		sc->sc_curr_offset +=  gd->offset_log + gd->data_size; 
 		G_LOG_DEBUG(0, "Found element %jd %jd %d, adding, curr offset "
 		    "%jd", ae->offset_disk, ae->offset_log, ae->data_size, 
 		    sc->sc_curr_offset);
@@ -127,7 +127,6 @@
 	struct g_log_alloc_element *aePrev, *aePrevTmp, *aeNext, *aeNextTmp;
 	off_t key, aePrevOriginalOffsetLog;
 	size_t overlap_size, aePrevOriginalSize;
-	G_LOG_DEBUG(0, "Adding %jd %jd %d", ae->offset_disk, ae->offset_log, ae->data_size);
 	/*find the key - offset range where the new element belongs*/
 	key = (off_t) (ae->offset_disk / OFFSET_RANGE);
 	te = &at->table[key];
@@ -254,58 +253,48 @@
 	struct g_log_alloc_table_element *te;
 	struct g_log_alloc_element *ae, *tmpae;
 	struct g_log_data gd;
-	G_LOG_DEBUG(0, "Key is %jd", key);
 
 	/*find the compartment*/
 	te = &sc->sc_alloctable->table[key];
 	/*if compartment is empty, exit*/
 	if ((te == NULL) || SLIST_EMPTY(&te->allocq)) 
 		return(1);
-	G_LOG_DEBUG(0, "Finding first");
 	/*find the first element of the request and add it*/
 	ae = SLIST_FIRST(&te->allocq);
 	tmpae = ae;
 	while (ae->offset_disk <= offset) {
 		tmpae = ae;
 		ae = SLIST_NEXT(tmpae, linkage);
-		G_LOG_DEBUG(0, "tmpae %jd %jd %d", tmpae->offset_disk, tmpae->offset_log, tmpae->data_size);
 		if (ae == NULL)
 			break;
-		G_LOG_DEBUG(0, "ae %jd %jd %d", ae->offset_disk, ae->offset_log, ae->data_size);
 	}
 	ae = tmpae;
-	G_LOG_DEBUG(0, "Found first");
 	gd.offset_disk = ae->offset_disk;
 	gd.offset_log = ae->offset_log;
 	gd.data_size = ae->data_size;
 	sc->sc_req_sublist[pos] = gd;
 	sc->sc_req_sublist_size++;
 	size = size + offset - ae->offset_disk - ae->data_size;
-	G_LOG_DEBUG(0, "Adding rest");
-	/*now keep adding until the request is complete (size is 0)*/
+
+	/*now keep adding until the request is complete (size is 0 or less)*/
 	while (size > 0) {
-		G_LOG_DEBUG(0, "Size is %d", size);
 		pos++;
 		ae = SLIST_NEXT(ae, linkage);
 		if (ae == NULL){
 		/*part of requested sublist is in next compartment?*/
-			G_LOG_DEBUG(0, "Recursion");
 			g_log_alloctable_get_rec(sc, 0, size, key+1, pos);
-			G_LOG_DEBUG(0, "Recursion over");
 		}
 		else {
-			G_LOG_DEBUG(0, "Adding %jd %d", ae->offset_disk, ae->data_size);
+			G_LOG_DEBUG(0, "Adding %jd %d", ae->offset_disk, 
+			    ae->data_size);
 			size -= ae->data_size;
 			gd.offset_disk = ae->offset_disk;
 			gd.offset_log = ae->offset_log;
 			gd.data_size = ae->data_size;
 			sc->sc_req_sublist[pos] = gd;
 			sc->sc_req_sublist_size++;
-			G_LOG_DEBUG(0, "Added %jd %d", ae->offset_disk, ae->data_size);
-		}
-		G_LOG_DEBUG(0, "Done %d", size);		
+		}		
 	}
-	G_LOG_DEBUG(0, "Added rest");
 	return (0);
 }
 /*free an alloc table*/

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


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

@@ -182,29 +182,18 @@
 	int err, i;
 	
 	KASSERT(sc != 0, ("%s: sc is null", __func__));
-	G_LOG_DEBUG(0, "Reading element %jd, %jd, %d", gd->offset_disk, gd->offset_log, gd->data_size);
+	G_LOG_DEBUG(0, "Reading element %jd, %jd, %d", gd->offset_disk, 
+	    gd->offset_log, gd->data_size);
 	if (gd->offset_log == -1) {/*read from disk*/
-		G_LOG_DEBUG(0, "Reading from disk %s", sc->sc_cons_disk->provider->name);
-		g_topology_lock();
-		err = g_access(sc->sc_cons_disk, 1, 0, 0);
-		g_topology_unlock();
-		if (err != 0) {
-			G_LOG_DEBUG(0, "Error accessing provider %s", sc->sc_cons_disk->provider->name);
-			return (err);
-		}
-		
 		tmp_buf = g_read_data(sc->sc_cons_disk, 
 		    gd->offset_disk, gd->data_size, &err);
-		g_topology_lock();
-		g_access(sc->sc_cons_disk, -1, 0, 0);
 		if (tmp_buf == NULL) {
-			G_LOG_DEBUG(0, "ENOENT");
 			return (ENOENT);
 		}
 	}
 	else { /*read from log file*/
-		G_LOG_DEBUG(0, "Reading from log");
-		tmp_buf = malloc(gd->data_size * sizeof(char), type, M_WAITOK | M_ZERO);
+		tmp_buf = malloc(gd->data_size * sizeof(char), type, M_WAITOK | 
+		    M_ZERO);
 		g_log_read_data(sc->sc_vn, (void*)tmp_buf, gd->data_size,
 		    gd->offset_log);
 	}

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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200708170003.l7H03ZDG042026>