[Tux3] [PATHC 2/4] log cleanup

OGAWA Hirofumi hirofumi at mail.parknet.co.jp
Mon Mar 9 18:30:46 PDT 2009


diff -puN user/kernel/commit.c~log-cleanup user/kernel/commit.c
--- tux3/user/kernel/commit.c~log-cleanup	2009-03-10 09:58:20.000000000 +0900
+++ tux3-hirofumi/user/kernel/commit.c	2009-03-10 09:58:20.000000000 +0900
@@ -163,8 +163,7 @@ static int stage_delta(struct sb *sb)
 
 	/* allocate and write log blocks */
 
-	if (sb->logbuf)
-		log_finish(sb);
+	log_finish(sb);
 	for (unsigned index = sb->logthis; index < sb->lognext; index++) {
 		block_t block;
 		int err = balloc(sb, 1, &block);
diff -puN user/kernel/log.c~log-cleanup user/kernel/log.c
--- tux3/user/kernel/log.c~log-cleanup	2009-03-10 09:58:20.000000000 +0900
+++ tux3-hirofumi/user/kernel/log.c	2009-03-10 09:58:20.000000000 +0900
@@ -14,20 +14,21 @@ void log_next(struct sb *sb)
 
 void log_finish(struct sb *sb)
 {
-	struct logblock *log = bufdata(sb->logbuf);
-	assert(sb->logtop >= sb->logpos);
-	log->bytes = to_be_u16(sb->logpos - log->data);
-	memset(sb->logpos, 0, sb->logtop - sb->logpos);
-	brelse(sb->logbuf);
-	sb->logbuf = NULL;
+	if (sb->logbuf) {
+		struct logblock *log = bufdata(sb->logbuf);
+		assert(sb->logtop >= sb->logpos);
+		log->bytes = to_be_u16(sb->logpos - log->data);
+		memset(sb->logpos, 0, sb->logtop - sb->logpos);
+		brelse(sb->logbuf);
+		sb->logbuf = NULL;
+	}
 }
 
 void *log_begin(struct sb *sb, unsigned bytes)
 {
 	mutex_lock(&sb->loglock);
 	if (1 || sb->logpos + bytes > sb->logtop) {
-		if (sb->logbuf)
-			log_finish(sb);
+		log_finish(sb);
 		log_next(sb);
 		*(struct logblock *)bufdata(sb->logbuf) = (struct logblock){
 			.magic = to_be_u16(0xc0de) };
@@ -43,6 +44,7 @@ void log_end(struct sb *sb, void *pos)
 
 static void log_extent(struct sb *sb, u8 intent, block_t block, unsigned count)
 {
+	assert(count < 256);	/* FIXME: extent max is 64 for now */
 	unsigned char *data = log_begin(sb, 8);
 	*data++ = intent;
 	*data++ = count;
diff -puN user/kernel/tux3.h~log-cleanup user/kernel/tux3.h
--- tux3/user/kernel/tux3.h~log-cleanup	2009-03-10 09:58:20.000000000 +0900
+++ tux3-hirofumi/user/kernel/tux3.h	2009-03-10 09:58:20.000000000 +0900
@@ -348,7 +348,12 @@ struct sb {
 
 /* logging  */
 
-struct logblock { be_u16 magic, bytes; be_u64 logchain; unsigned char data[]; };
+struct logblock {
+	be_u16 magic, bytes;
+	u32 unused;
+	be_u64 logchain;
+	unsigned char data[];
+};
 enum { LOG_ALLOC = 0x33, LOG_FREE, LOG_UPDATE, LOG_DROOT, LOG_IROOT, LOG_REDIRECT };
 struct commit_entry { be_u64 previous; };
 
_

-- 
OGAWA Hirofumi <hirofumi at mail.parknet.co.jp>

_______________________________________________
Tux3 mailing list
Tux3 at tux3.org
http://mailman.tux3.org/cgi-bin/mailman/listinfo/tux3



More information about the Tux3 mailing list