Skip to contentSkip to conversation

cluster/gfs2 convert/gfs2_convert.c fsck/Makef ...

Cluster-devel [email protected] 1 participant 1 message May 1, 2007

lore
Share & tools
lore
#0 lore raw

CVSROOT: /cvs/cluster
Module name: cluster
Branch: RHEL5
Changes by: rpeterso at sourceware.org 2007-05-01 19:20:50

Modified files:
gfs2/convert : gfs2_convert.c
gfs2/fsck : Makefile fsck.h initialize.c main.c pass1.c
pass2.c
gfs2/libgfs2 : device_geometry.c fs_geometry.c fs_ops.c
libgfs2.h rgrp.c super.c
gfs2/mkfs : main_mkfs.c
Added files:
gfs2/fsck : rgrepair.c

Log message:
Resolves: bz 223893: gfs2_fsck unable to fix damaged RGs and RG indexes.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/convert/gfs2_convert.c.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.7.2.1&r2=1.7.2.2
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/fsck/rgrepair.c.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=NONE&r2=1.1.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/fsck/Makefile.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.6.2.1&r2=1.6.2.2
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/fsck/fsck.h.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.3.2.1&r2=1.3.2.2
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/fsck/initialize.c.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.6.2.1&r2=1.6.2.2
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/fsck/main.c.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.4.2.2&r2=1.4.2.3
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/fsck/pass1.c.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.4.2.2&r2=1.4.2.3
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/fsck/pass2.c.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.4.2.1&r2=1.4.2.2
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/libgfs2/device_geometry.c.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.1&r2=1.1.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/libgfs2/fs_geometry.c.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.2.2.1&r2=1.2.2.2
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/libgfs2/fs_ops.c.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.4.2.2&r2=1.4.2.3
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/libgfs2/libgfs2.h.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.7.2.3&r2=1.7.2.4
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/libgfs2/rgrp.c.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.1&r2=1.1.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/libgfs2/super.c.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.3&r2=1.3.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/mkfs/main_mkfs.c.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.8.2.3&r2=1.8.2.4

gfs2/convert/gfs2_convert.c +3 -3
@@ -3,7 +3,7 @@
 **
 **  gfs2_convert - convert a gfs1 filesystem into a gfs2 filesystem.
 **
-**  Copyright (C) 2006 Red Hat, Inc.  All rights reserved.
+**  Copyright (C) 2006-2007 Red Hat, Inc.  All rights reserved.
 **
 **  This copyrighted material is made available to anyone wishing to use,
 **  modify, copy, or redistribute it subject to the terms and conditions
@@ -801,7 +801,7 @@
 	/* look like a directory, temporarily.                               */
 	sbp->md.riinode->i_di.di_mode &= ~S_IFMT;
 	sbp->md.riinode->i_di.di_mode |= S_IFDIR; 
-	if (ri_update(sbp, &rgcount)){
+	if (ri_update(sbp, 0, &rgcount)){
 		log_crit("Unable to fill in resource group information.\n");
 		return -1;
 	}
@@ -1181,7 +1181,7 @@
 		/* Now delete the now-obsolete gfs1 files: */
 		remove_obsolete_gfs1(&sb2);
 		/* Now free all the in memory */
-		gfs2_rgrp_free(&sb2, updated);
+		gfs2_rgrp_free(&sb2.rglist, updated);
 		log_notice("Committing changes to disk.\n");
 		fflush(stdout);
 		/* Set filesystem type in superblock to gfs2.  We do this at the */

/cvs/cluster/cluster/gfs2/fsck/rgrepair.c,v --> standard output revision 1.1.2.1

- renamed from gfs2/fsck/rgrepair.c +527 -0

527 lines not on this page · raw message

gfs2/fsck/Makefile +2 -2
@@ -1,7 +1,7 @@
 ###############################################################################
 ###############################################################################
 ##
-##  Copyright (C) 2005 Red Hat, Inc.  All rights reserved.
+##  Copyright (C) 2005-2007 Red Hat, Inc.  All rights reserved.
 ##
 ##  This copyrighted material is made available to anyone wishing to use,
 ##  modify, copy, or redistribute it subject to the terms and conditions
@@ -22,7 +22,7 @@
 .PHONY: all clean
 
 sources = main.c initialize.c pass1.c pass1b.c pass1c.c pass2.c pass3.c \
-	pass4.c pass5.c util.c fs_recovery.c \
+	pass4.c pass5.c util.c fs_recovery.c rgrepair.c\
 	lost_n_found.c link.c eattr.c hash.c inode_hash.c metawalk.c
 
 CFLAGS+=-D_FILE_OFFSET_BITS=64 -DHELPER_PROGRAM -DGFS_RELEASE_NAME=\"${RELEASE}\" -Wall -O2
gfs2/fsck/fsck.h +20 -1
@@ -1,7 +1,7 @@
 /*****************************************************************************
 *******************************************************************************
 **
-**  Copyright (C) 2005 Red Hat, Inc.  All rights reserved.
+**  Copyright (C) 2005-2007 Red Hat, Inc.  All rights reserved.
 **
 **  This copyrighted material is made available to anyone wishing to use,
 **  modify, copy, or redistribute it subject to the terms and conditions
@@ -38,6 +38,24 @@
 
 };
 
+struct dir_status {
+	uint8_t dotdir:1;
+	uint8_t dotdotdir:1;
+	struct gfs2_block_query q;
+	uint32_t entry_count;
+};
+
+enum rgindex_trust_level { /* how far can we trust our RG index? */
+	blind_faith = 0, /* We'd like to trust the rgindex. We always used to
+			    before bz 179069. This should cover most cases. */
+	open_minded = 1, /* At least 1 RG is corrupt. Try to calculate what it
+			    should be, in a perfect world where our RGs are all
+			    on even boundaries. Blue sky. Chirping birds. */
+	distrust = 2   /* The world isn't perfect, our RGs are not on nice neat
+			  boundaries.  The fs must have been messed with by
+			  gfs2_grow or something.  Count the RGs by hand. */
+};
+
 int initialize(struct gfs2_sbd *sbp);
 void destroy(struct gfs2_sbd *sbp);
 int block_mounters(struct gfs2_sbd *sbp, int block_em);
@@ -48,6 +66,7 @@
 int pass3(struct gfs2_sbd *sbp);
 int pass4(struct gfs2_sbd *sbp);
 int pass5(struct gfs2_sbd *sbp);
+int rg_repair(struct gfs2_sbd *sdp, int trust_lvl, int *rg_count);
 
 /* FIXME: Hack to get this going for pass2 - this should be pulled out
  * of pass1 and put somewhere else... */
gfs2/fsck/initialize.c +20 -8
@@ -2,7 +2,7 @@
 *******************************************************************************
 **
 **  Copyright (C) Sistina Software, Inc.  1997-2003  All rights reserved.
-**  Copyright (C) 2004-2005 Red Hat, Inc.  All rights reserved.
+**  Copyright (C) 2004-2007 Red Hat, Inc.  All rights reserved.
 **
 **  This copyrighted material is made available to anyone wishing to use,
 **  modify, copy, or redistribute it subject to the terms and conditions
@@ -100,6 +100,8 @@
 		struct rgrp_list *rgd;
 
 		rgd = osi_list_entry(sdp->rglist.next, struct rgrp_list, list);
+		log_debug("Deleting rgd for 0x%p:  rgd=0x%p bits=0x%p\n",
+			  rgd->ri.ri_addr, rgd, rgd->bits);
 		osi_list_del(&rgd->list);
 		if(rgd->bits)
 			free(rgd->bits);
@@ -189,7 +191,6 @@
 	return -1;
 }
 
-
 /**
  * fill_super_block
  * @sdp:
@@ -204,6 +205,7 @@
 	struct gfs2_statfs_change sc;
 	int rgcount;
 	uint64_t addl_mem_needed;
+	enum rgindex_trust_level trust_lvl;
 
 	sync();
 
@@ -243,7 +245,8 @@
 	log_info("Initializing special inodes...\n");
 
 	/* Get master dinode */
-	sdp->master_dir = gfs2_load_inode(sdp, sdp->sd_sb.sb_master_dir.no_addr);
+	sdp->master_dir = gfs2_load_inode(sdp,
+					  sdp->sd_sb.sb_master_dir.no_addr);
 	/* Get root dinode */
 	sdp->md.rooti = gfs2_load_inode(sdp, sdp->sd_sb.sb_root_dir.no_addr);
 
@@ -255,8 +258,6 @@
 	sdp->md.next_inum = be64_to_cpu(inumbuf);
 
 	gfs2_lookupi(sdp->master_dir, "statfs", 6, &sdp->md.statfs);
-	/* Read inum entry into buffer */
-	/* FIXME finish this */
 	buf = malloc(sdp->md.statfs->i_di.di_size);
 	gfs2_readi(sdp->md.statfs, buf, 0, sdp->md.statfs->i_di.di_size);
 	/* call gfs2_inum_range_in() to retrieve range */
@@ -284,11 +285,22 @@
 		return -1;
 	}
 
-	if(ri_update(sdp, &rgcount)){
-		log_err("Unable to fill in resource group information.\n");
+	log_warn("Validating Resource Group index.\n");
+	for (trust_lvl = blind_faith; trust_lvl <= distrust; trust_lvl++) {
+		log_warn("Level %d RG check.\n", trust_lvl + 1);
+		if ((rg_repair(sdp, trust_lvl, &rgcount) == 0) &&
+		    (ri_update(sdp, 0, &rgcount) == 0)) {
+			log_err("(level %d passed)\n", trust_lvl + 1);
+			break;
+		}
+		else
+			log_err("(level %d failed)\n", trust_lvl + 1);
+	}
+	if (trust_lvl > distrust) {
+		log_err("RG recovery impossible; I can't fix this file system.\n");
 		goto fail;
 	}
-
+	log_info("%u resource groups found.\n", rgcount);
 	/*******************************************************************
 	 *******  Now, set boundary fields in the super block  *************
 	 *******************************************************************/
gfs2/fsck/main.c +120 -1

139 lines not on this page · raw message

gfs2/fsck/pass1.c +2 -2
@@ -2,7 +2,7 @@
 *******************************************************************************
 **
 **  Copyright (C) Sistina Software, Inc.  1997-2003  All rights reserved.
-**  Copyright (C) 2004-2005 Red Hat, Inc.  All rights reserved.
+**  Copyright (C) 2004-2007 Red Hat, Inc.  All rights reserved.
 **
 **  This copyrighted material is made available to anyone wishing to use,
 **  modify, copy, or redistribute it subject to the terms and conditions
@@ -471,7 +471,7 @@
 		return -1;
 	}
 
-	if(!(newdi = (struct dir_info *) malloc(sizeof(*newdi)))) {
+	if(!(newdi = (struct dir_info *) malloc(sizeof(struct dir_info)))) {
 		log_crit("Unable to allocate dir_info structure\n");
 		return -1;
 	}
gfs2/fsck/pass2.c +68 -112

264 lines not on this page · raw message

gfs2/libgfs2/device_geometry.c +27 -96

154 lines not on this page · raw message

gfs2/libgfs2/fs_geometry.c +78 -55

199 lines not on this page · raw message

gfs2/libgfs2/fs_ops.c +7 -3
@@ -2,7 +2,7 @@
 *******************************************************************************
 **
 **  Copyright (C) Sistina Software, Inc.  1997-2003  All rights reserved.
-**  Copyright (C) 2004 Red Hat, Inc.  All rights reserved.
+**  Copyright (C) 2004-2007 Red Hat, Inc.  All rights reserved.
 **
 **  This copyrighted material is made available to anyone wishing to use,
 **  modify, copy, or redistribute it subject to the terms and conditions
@@ -729,7 +729,7 @@
 		      index * sizeof(uint64_t),
 		      sizeof(uint64_t));
 	if (count != sizeof(uint64_t))
-		die("gfs2_get_leaf_nr\n");
+		die("gfs2_get_leaf_nr:  Bad internal read.\n");
 
 	*leaf_out = be64_to_cpu(leaf_no);
 }
@@ -953,7 +953,11 @@
 
  restart:
 	hash = gfs2_disk_hash(filename, len);
-	index = hash >> (32 - dip->i_di.di_depth);
+	/* Have to kludge because (hash >> 32) gives hash for some reason. */
+	if (dip->i_di.di_depth)
+		index = hash >> (32 - dip->i_di.di_depth);
+	else
+		index = 0;
 
 	gfs2_get_leaf_nr(dip, index, &leaf_no);
 
gfs2/libgfs2/libgfs2.h +11 -14
@@ -2,7 +2,7 @@
 *******************************************************************************
 **
 **  Copyright (C) Sistina Software, Inc.  1997-2003  All rights reserved.
-**  Copyright (C) 2004 Red Hat, Inc.  All rights reserved.
+**  Copyright (C) 2004-2007 Red Hat, Inc.  All rights reserved.
 **
 **  This copyrighted material is made available to anyone wishing to use,
 **  modify, copy, or redistribute it subject to the terms and conditions
@@ -17,6 +17,7 @@
 #include <inttypes.h>
 #include <sys/types.h>
 #include <linux/types.h>
+#include <linux/limits.h>
 
 #include "linux_endian.h"
 #include <linux/gfs2_ondisk.h>
@@ -63,17 +64,12 @@
 #define RESRANDOM do { srandom(RANDOM(1000000000)); } while (0)
 #define RANDOM(values) ((values) * (random() / (RAND_MAX + 1.0)))
 
-struct subdevice {
+struct device {
 	uint64_t start;
 	uint64_t length;
 	uint32_t rgf_flags;
 };
 
-struct device {
-	unsigned int nsubdev;
-	struct subdevice *subdev;
-};
-
 struct gfs2_bitmap
 {
 	uint32_t   bi_offset;  /* The offset in the buffer of the first byte */
@@ -84,9 +80,6 @@
 
 struct rgrp_list {
 	osi_list_t list;
-
-	uint32_t subdevice;	/* The subdevice who holds this resource group */
-
 	uint64_t start;	   /* The offset of the beginning of this resource group */
 	uint64_t length;	/* The length of this resource group */
 	uint32_t rgf_flags;
@@ -169,7 +162,6 @@
 
 	int debug;
 	int quiet;
-	int test;
 	int expert;
 	int override;
 
@@ -374,8 +366,12 @@
 int gfs2_set_bitmap(struct gfs2_sbd *sdp, uint64_t blkno, int state);
 
 /* fs_geometry.c */
+void rgblocks2bitblocks(unsigned int bsize, uint32_t *rgblocks,
+			uint32_t *bitblocks);
+uint64_t how_many_rgrps(struct gfs2_sbd *sdp, struct device *dev,
+			int rgsize_specified);
 void compute_rgrp_layout(struct gfs2_sbd *sdp, int rgsize_specified);
-void build_rgrps(struct gfs2_sbd *sdp);
+void build_rgrps(struct gfs2_sbd *sdp, int write);
 
 /* fs_ops.c */
 #define IS_LEAF     (1)
@@ -507,7 +503,7 @@
 struct rgrp_list *gfs2_blk2rgrpd(struct gfs2_sbd *sdp, uint64_t blk);
 uint64_t gfs2_rgrp_read(struct gfs2_sbd *sdp, struct rgrp_list *rgd);
 void gfs2_rgrp_relse(struct rgrp_list *rgd, enum update_flags updated);
-void gfs2_rgrp_free(struct gfs2_sbd *sdp, enum update_flags updated);
+void gfs2_rgrp_free(osi_list_t *rglist, enum update_flags updated);
 
 /* structures.c */
 void build_master(struct gfs2_sbd *sdp);
@@ -530,7 +526,8 @@
 /* super.c */
 int read_sb(struct gfs2_sbd *sdp);
 int ji_update(struct gfs2_sbd *sdp);
-int ri_update(struct gfs2_sbd *sdp, int *rgcount);
+int rindex_read(struct gfs2_sbd *sdp, int fd, int *count1);
+int ri_update(struct gfs2_sbd *sdp, int fd, int *rgcount);
 int write_sb(struct gfs2_sbd *sdp);
 
 /* ondisk.c */
gfs2/libgfs2/rgrp.c +9 -8
@@ -2,7 +2,7 @@
 *******************************************************************************
 **
 **  Copyright (C) Sistina Software, Inc.  1997-2003  All rights reserved.
-**  Copyright (C) 2004-2005 Red Hat, Inc.  All rights reserved.
+**  Copyright (C) 2004-2007 Red Hat, Inc.  All rights reserved.
 **
 **  This copyrighted material is made available to anyone wishing to use,
 **  modify, copy, or redistribute it subject to the terms and conditions
@@ -124,7 +124,8 @@
 	for (x = 0; x < length; x++){
 		rgd->bh[x] = bread(sdp, rgd->ri.ri_addr + x);
 		if(gfs2_check_meta(rgd->bh[x],
-						   (x) ? GFS2_METATYPE_RB : GFS2_METATYPE_RG)) {
+				   (x) ? GFS2_METATYPE_RB : GFS2_METATYPE_RG))
+		{
 			uint64_t error;
 
 			error = rgd->ri.ri_addr + x;
@@ -146,15 +147,15 @@
 		brelse(rgd->bh[x], updated);
 }
 
-void gfs2_rgrp_free(struct gfs2_sbd *sdp, enum update_flags updated)
+void gfs2_rgrp_free(osi_list_t *rglist, enum update_flags updated)
 {
 	struct rgrp_list *rgd;
 
-	while(!osi_list_empty(&sdp->rglist)){
-		rgd = osi_list_entry(sdp->rglist.next, struct rgrp_list, list);
-		if (rgd->bh && rgd->bh[0] && /* if a buffer exists and           */
-			rgd->bh[0]->b_count)     /* the first buffer is allocated    */
-			gfs2_rgrp_relse(rgd, updated); /* they must all be so free them. */
+	while(!osi_list_empty(rglist->next)){
+		rgd = osi_list_entry(rglist->next, struct rgrp_list, list);
+		if (rgd->bh && rgd->bh[0] && /* if a buffer exists and       */
+			rgd->bh[0]->b_count) /* the 1st buffer is allocated */
+			gfs2_rgrp_relse(rgd, updated); /* free them all. */
 		if(rgd->bits)
 			free(rgd->bits);
 		if(rgd->bh)
gfs2/libgfs2/super.c +60 -37

139 lines not on this page · raw message

gfs2/mkfs/main_mkfs.c +2 -2
@@ -2,7 +2,7 @@
 *******************************************************************************
 **
 **  Copyright (C) Sistina Software, Inc.  1997-2003  All rights reserved.
-**  Copyright (C) 2004 Red Hat, Inc.  All rights reserved.
+**  Copyright (C) 2004-2007 Red Hat, Inc.  All rights reserved.
 **
 **  This copyrighted material is made available to anyone wishing to use,
 **  modify, copy, or redistribute it subject to the terms and conditions
@@ -375,7 +375,7 @@
 
 	/* Build ondisk structures */
 
-	build_rgrps(sdp);
+	build_rgrps(sdp, TRUE);
 	build_root(sdp);
 	build_master(sdp);
 	build_sb(sdp);