[Cluster-devel] cluster/gfs2/libgfs2 gfs2_log.c super.c

rpeterso at sourceware.org rpeterso at sourceware.org
Thu Jun 15 18:45:22 UTC 2006


CVSROOT:	/cvs/cluster
Module name:	cluster
Changes by:	rpeterso at sourceware.org	2006-06-15 18:45:22

Modified files:
	gfs2/libgfs2   : gfs2_log.c super.c 

Log message:
	Added some error reporting back in when checking for gfs2 file systems.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/libgfs2/gfs2_log.c.diff?cvsroot=cluster&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/libgfs2/super.c.diff?cvsroot=cluster&r1=1.1&r2=1.2

--- cluster/gfs2/libgfs2/gfs2_log.c	2006/06/12 20:38:27	1.1
+++ cluster/gfs2/libgfs2/gfs2_log.c	2006/06/15 18:45:22	1.2
@@ -45,11 +45,13 @@
 	case MSG_DEBUG:
 		printf("(%s:%d)\t", file, line);
 		vprintf(format, args);
+		fflush(stdout);
 		break;
 	case MSG_INFO:
 	case MSG_NOTICE:
 	case MSG_WARN:
 		vprintf(format, args);
+		fflush(stdout);
 		break;
 	case MSG_ERROR:
 	case MSG_CRITICAL:
--- cluster/gfs2/libgfs2/super.c	2006/06/12 20:38:27	1.1
+++ cluster/gfs2/libgfs2/super.c	2006/06/15 18:45:22	1.2
@@ -36,13 +36,20 @@
 static int check_sb(struct gfs2_sbd *sdp, struct gfs2_sb *sb)
 {
 	if (sb->sb_header.mh_magic != GFS2_MAGIC ||
-	    sb->sb_header.mh_type != GFS2_METATYPE_SB)
+	    sb->sb_header.mh_type != GFS2_METATYPE_SB) {
+		log_crit("Either the super block is corrupted, or this "
+				 "is not a GFS2 filesystem\n");
+		log_debug("Header magic: %X Header Type: %X\n",
+				  sb->sb_header.mh_magic,
+				  sb->sb_header.mh_type);
 		return -EINVAL;
-
+	}
 	/*  If format numbers match exactly, we're done.  */
 	if (sb->sb_fs_format != GFS2_FORMAT_FS ||
-	    sb->sb_multihost_format != GFS2_FORMAT_MULTI)
+	    sb->sb_multihost_format != GFS2_FORMAT_MULTI) {
+		log_crit("Old gfs1 file system detected.\n");
 		return -EINVAL;
+	}
 	return 0;
 }
 
@@ -91,6 +98,7 @@
 		sdp->sd_heightsize[x] = space;
 	}
 	if (x > GFS2_MAX_META_HEIGHT){
+		log_err("Bad max metadata height.\n");
 		error = -1;
 		goto out;
 	}
@@ -105,8 +113,10 @@
 		sdp->sd_jheightsize[x] = space;
 	}
 	sdp->sd_max_jheight = x;
-	if(sdp->sd_max_jheight > GFS2_MAX_META_HEIGHT)
+	if(sdp->sd_max_jheight > GFS2_MAX_META_HEIGHT) {
+		log_err("Bad max jheight.\n");
 		error = -1;
+	}
 	sdp->fssize = lseek(sdp->device_fd, 0, SEEK_END) / sdp->sd_sb.sb_bsize;
 
  out:
@@ -131,17 +141,21 @@
 	char journal_name[JOURNAL_NAME_SIZE];
 	int i;
 
-	if(!ip)
+	if(!ip) {
+		log_crit("Journal inode not found.\n");
 		return -1;
+	}
 
-	if(!(sdp->md.journal = calloc(ip->i_di.di_entries - 2, sizeof(struct gfs2_inode *))))
+	if(!(sdp->md.journal = calloc(ip->i_di.di_entries - 2, sizeof(struct gfs2_inode *)))) {
+		log_err("Unable to allocate journal index\n");
 		return -1;
+	}
 	sdp->md.journals = 0;
 	memset(journal_name, 0, sizeof(*journal_name));
 	for(i = 0; i < ip->i_di.di_entries - 2; i++) {
 		/* FIXME check snprintf return code */
 		snprintf(journal_name, JOURNAL_NAME_SIZE, "journal%u", i);
-		gfs2_lookupi(sdp->md.jiinode, journal_name, strlen(journal_name),
+		gfs2_lookupi(sdp->md.jiinode, journal_name, strlen(journal_name), 
 					 &jip);
 		sdp->md.journal[i] = jip;
 	}
@@ -227,13 +241,11 @@
 
 int write_sb(struct gfs2_sbd *sbp)
 {
-	int error = 0;
 	struct gfs2_buffer_head *bh;
 
 	bh = bread(sbp, GFS2_SB_ADDR >> sbp->sd_fsb2bb_shift);
 	gfs2_sb_out(&sbp->sd_sb, bh->b_data);
 	brelse(bh, updated);
-	return error;
-
+	return 0;
 }
 




More information about the Cluster-devel mailing list