cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
* [Cluster-devel] cluster/gfs2/fsck metawalk.c
@ 2006-11-14 22:51 rpeterso
  0 siblings, 0 replies; 12+ messages in thread
From: rpeterso @ 2006-11-14 22:51 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	cluster
Changes by:	rpeterso at sourceware.org	2006-11-14 22:51:35

Modified files:
	gfs2/fsck      : metawalk.c 

Log message:
	Resolves: bz211465
	fsck errors on gfs2 volume

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/fsck/metawalk.c.diff?cvsroot=cluster&r1=1.3&r2=1.4

--- cluster/gfs2/fsck/metawalk.c	2006/06/12 20:41:43	1.3
+++ cluster/gfs2/fsck/metawalk.c	2006/11/14 22:51:35	1.4
@@ -74,15 +74,26 @@
 				return 1;
 			}
 		} else {
-			error = pass->check_dentry(ip, dent, prev, bh, filename, update,
-									   count, pass->private);
-			if(error < 0) {
-				stack;
-				return -1;
+			if (!de.de_inum.no_addr && first) { /* reverse sentinel */
+				log_debug("First dirent is a Sentinel (place holder).\n");
+				/* Swap the two to silently make it a proper sentinel */
+				de.de_inum.no_addr = de.de_inum.no_formal_ino;
+				de.de_inum.no_formal_ino = 0;
+				gfs2_dirent_out(&de, (char *)dent);
+				*update = 1; /* Mark dirent buffer as modified */
+				first = 0;
+			}
+			else {
+				error = pass->check_dentry(ip, dent, prev, bh, filename,
+							   update, count, pass->private);
+				if(error < 0) {
+					stack;
+					return -1;
+				}
+				/*if(error > 0) {
+				  return 1;
+				  }*/
 			}
-			/*if(error > 0) {
-			  return 1;
-			  }*/
 		}
 
 		if ((char *)dent + de.de_rec_len >= bh_end){
@@ -165,7 +176,7 @@
 				/* Since the buffer possibly got
 				   updated directly, release it now,
 				   and grab it again later if we need it */
-				brelse(lbh, not_updated);
+				brelse(lbh, *update);
 				if(error < 0) {
 					stack;
 					return -1;



^ permalink raw reply	[flat|nested] 12+ messages in thread
* [Cluster-devel] cluster/gfs2/fsck metawalk.c
@ 2006-11-14 22:55 rpeterso
  0 siblings, 0 replies; 12+ messages in thread
From: rpeterso @ 2006-11-14 22:55 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	cluster
Branch: 	RHEL5
Changes by:	rpeterso at sourceware.org	2006-11-14 22:55:29

Modified files:
	gfs2/fsck      : metawalk.c 

Log message:
	Resolves: bz211465
	fsck errors on gfs2 volume

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/fsck/metawalk.c.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.3&r2=1.3.2.1

--- cluster/gfs2/fsck/metawalk.c	2006/06/12 20:41:43	1.3
+++ cluster/gfs2/fsck/metawalk.c	2006/11/14 22:55:29	1.3.2.1
@@ -74,15 +74,26 @@
 				return 1;
 			}
 		} else {
-			error = pass->check_dentry(ip, dent, prev, bh, filename, update,
-									   count, pass->private);
-			if(error < 0) {
-				stack;
-				return -1;
+			if (!de.de_inum.no_addr && first) { /* reverse sentinel */
+				log_debug("First dirent is a Sentinel (place holder).\n");
+				/* Swap the two to silently make it a proper sentinel */
+				de.de_inum.no_addr = de.de_inum.no_formal_ino;
+				de.de_inum.no_formal_ino = 0;
+				gfs2_dirent_out(&de, (char *)dent);
+				*update = 1; /* Mark dirent buffer as modified */
+				first = 0;
+			}
+			else {
+				error = pass->check_dentry(ip, dent, prev, bh, filename,
+							   update, count, pass->private);
+				if(error < 0) {
+					stack;
+					return -1;
+				}
+				/*if(error > 0) {
+				  return 1;
+				  }*/
 			}
-			/*if(error > 0) {
-			  return 1;
-			  }*/
 		}
 
 		if ((char *)dent + de.de_rec_len >= bh_end){
@@ -165,7 +176,7 @@
 				/* Since the buffer possibly got
 				   updated directly, release it now,
 				   and grab it again later if we need it */
-				brelse(lbh, not_updated);
+				brelse(lbh, *update);
 				if(error < 0) {
 					stack;
 					return -1;



^ permalink raw reply	[flat|nested] 12+ messages in thread
* [Cluster-devel] cluster/gfs2/fsck metawalk.c
@ 2006-11-16 19:56 rohara
  0 siblings, 0 replies; 12+ messages in thread
From: rohara @ 2006-11-16 19:56 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	cluster
Branch: 	RHEL5
Changes by:	rohara at sourceware.org	2006-11-16 19:56:10

Modified files:
	gfs2/fsck      : metawalk.c 

Log message:
	Detect and fix potential endian problem in lf_dirent_format.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/fsck/metawalk.c.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.3.2.1&r2=1.3.2.2

--- cluster/gfs2/fsck/metawalk.c	2006/11/14 22:55:29	1.3.2.1
+++ cluster/gfs2/fsck/metawalk.c	2006/11/16 19:56:09	1.3.2.2
@@ -162,21 +162,39 @@
 				}
 			}
 
+			enum update_flags u = not_updated;
+
 			lbh = bread(sbp, leaf_no);
 			gfs2_leaf_in(&leaf, lbh->b_data);
 
+			/*
+			 * Early versions of GFS2 had an endianess bug in the kernel
+			 * that set lf_dirent_format to cpu_to_be16(GFS2_FORMAT_DE).
+			 * This was fixed to use cpu_to_be32(), but we should check
+			 * for incorrect values and replace them with the correct value. */
+
+			if (leaf.lf_dirent_format == (GFS2_FORMAT_DE << 16)) {
+				log_debug("incorrect lf_dirent_format@leaf #%" PRIu64 "\n", leaf_no);
+				leaf.lf_dirent_format = GFS2_FORMAT_DE;
+				gfs2_leaf_out(&leaf, lbh->b_data);
+				u = updated;
+			}
+
 			exp_count = (1 << (ip->i_di.di_depth - leaf.lf_depth));
 			log_debug("expected count %u - di_depth %u, leaf depth %u\n",
 					  exp_count, ip->i_di.di_depth, leaf.lf_depth);
+
 			if(pass->check_dentry &&
 			   S_ISDIR(ip->i_di.di_mode)) {
 				error = check_entries(ip, lbh, index, DIR_EXHASH, update,
 									  &count, pass);
 
 				/* Since the buffer possibly got
-				   updated directly, release it now,
-				   and grab it again later if we need it */
+				 * updated directly, release it now,
+				 * and grab it again later if we need it. */
+
 				brelse(lbh, *update);
+
 				if(error < 0) {
 					stack;
 					return -1;
@@ -186,9 +204,8 @@
 					return 1;
 
 				if(update && (count != leaf.lf_entries)) {
-					enum update_flags f;
+					enum update_flags f = not_updated;
 
-					f = not_updated;
 					lbh = bread(sbp, leaf_no);
 					gfs2_leaf_in(&leaf, lbh->b_data);
 
@@ -210,7 +227,9 @@
 				 * compare it against leaf->lf_entries */
 				break;
 			} else {
-				brelse(lbh, not_updated);
+				if (u == updated)
+					log_debug("Fixing lf_dirent_format.\n");
+				brelse(lbh, u);
 				if(!leaf.lf_next)
 					break;
 				leaf_no = leaf.lf_next;



^ permalink raw reply	[flat|nested] 12+ messages in thread
* [Cluster-devel] cluster/gfs2/fsck metawalk.c
@ 2006-11-16 20:12 rohara
  0 siblings, 0 replies; 12+ messages in thread
From: rohara @ 2006-11-16 20:12 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	cluster
Changes by:	rohara at sourceware.org	2006-11-16 20:12:46

Modified files:
	gfs2/fsck      : metawalk.c 

Log message:
	Detect and fix potential endia problem in lf_dirent_format.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/fsck/metawalk.c.diff?cvsroot=cluster&r1=1.4&r2=1.5

--- cluster/gfs2/fsck/metawalk.c	2006/11/14 22:51:35	1.4
+++ cluster/gfs2/fsck/metawalk.c	2006/11/16 20:12:45	1.5
@@ -162,21 +162,39 @@
 				}
 			}
 
+			enum update_flags u = not_updated;
+
 			lbh = bread(sbp, leaf_no);
 			gfs2_leaf_in(&leaf, lbh->b_data);
 
+			/*
+			 * Early versions of GFS2 had an endianess bug in the kernel
+			 * that set lf_dirent_format to cpu_to_be16(GFS2_FORMAT_DE).
+			 * This was fixed to use cpu_to_be32(), but we should check
+			 * for incorrect values and replace them with the correct value. */
+
+			if (leaf.lf_dirent_format == (GFS2_FORMAT_DE << 16)) {
+				log_debug("incorrect lf_dirent_format@leaf #%" PRIu64 "\n", leaf_no);
+				leaf.lf_dirent_format = GFS2_FORMAT_DE;
+				gfs2_leaf_out(&leaf, lbh->b_data);
+				u = updated;
+			}
+
 			exp_count = (1 << (ip->i_di.di_depth - leaf.lf_depth));
 			log_debug("expected count %u - di_depth %u, leaf depth %u\n",
 					  exp_count, ip->i_di.di_depth, leaf.lf_depth);
+
 			if(pass->check_dentry &&
 			   S_ISDIR(ip->i_di.di_mode)) {
 				error = check_entries(ip, lbh, index, DIR_EXHASH, update,
 									  &count, pass);
 
 				/* Since the buffer possibly got
-				   updated directly, release it now,
-				   and grab it again later if we need it */
+				 * updated directly, release it now,
+				 * and grab it again later if we need it. */
+
 				brelse(lbh, *update);
+
 				if(error < 0) {
 					stack;
 					return -1;
@@ -186,9 +204,8 @@
 					return 1;
 
 				if(update && (count != leaf.lf_entries)) {
-					enum update_flags f;
+					enum update_flags f = not_updated;
 
-					f = not_updated;
 					lbh = bread(sbp, leaf_no);
 					gfs2_leaf_in(&leaf, lbh->b_data);
 
@@ -210,7 +227,9 @@
 				 * compare it against leaf->lf_entries */
 				break;
 			} else {
-				brelse(lbh, not_updated);
+				if (u == updated)
+					log_debug("Fixing lf_dirent_format.\n");
+				brelse(lbh, u);
 				if(!leaf.lf_next)
 					break;
 				leaf_no = leaf.lf_next;



^ permalink raw reply	[flat|nested] 12+ messages in thread
* [Cluster-devel] cluster/gfs2/fsck metawalk.c
@ 2006-11-20 15:35 rpeterso
  0 siblings, 0 replies; 12+ messages in thread
From: rpeterso @ 2006-11-20 15:35 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	cluster
Changes by:	rpeterso at sourceware.org	2006-11-20 15:35:12

Modified files:
	gfs2/fsck      : metawalk.c 

Log message:
	Fix another case where lf_dirent_format was not rewritten to disk
	after it was fixed.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/fsck/metawalk.c.diff?cvsroot=cluster&r1=1.5&r2=1.6

--- cluster/gfs2/fsck/metawalk.c	2006/11/16 20:12:45	1.5
+++ cluster/gfs2/fsck/metawalk.c	2006/11/20 15:35:12	1.6
@@ -162,8 +162,7 @@
 				}
 			}
 
-			enum update_flags u = not_updated;
-
+			*update = not_updated;
 			lbh = bread(sbp, leaf_no);
 			gfs2_leaf_in(&leaf, lbh->b_data);
 
@@ -177,7 +176,8 @@
 				log_debug("incorrect lf_dirent_format at leaf #%" PRIu64 "\n", leaf_no);
 				leaf.lf_dirent_format = GFS2_FORMAT_DE;
 				gfs2_leaf_out(&leaf, lbh->b_data);
-				u = updated;
+				log_debug("Fixing lf_dirent_format.\n");
+				*update = updated;
 			}
 
 			exp_count = (1 << (ip->i_di.di_depth - leaf.lf_depth));
@@ -227,9 +227,7 @@
 				 * compare it against leaf->lf_entries */
 				break;
 			} else {
-				if (u == updated)
-					log_debug("Fixing lf_dirent_format.\n");
-				brelse(lbh, u);
+				brelse(lbh, *update);
 				if(!leaf.lf_next)
 					break;
 				leaf_no = leaf.lf_next;



^ permalink raw reply	[flat|nested] 12+ messages in thread
* [Cluster-devel] cluster/gfs2/fsck metawalk.c
@ 2006-11-20 15:44 rohara
  0 siblings, 0 replies; 12+ messages in thread
From: rohara @ 2006-11-20 15:44 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	cluster
Branch: 	RHEL5
Changes by:	rohara at sourceware.org	2006-11-20 15:44:53

Modified files:
	gfs2/fsck      : metawalk.c 

Log message:
	Fix another case where lf_dirent_format was not rewritten to disk
	after it was fixed.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/fsck/metawalk.c.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.3.2.2&r2=1.3.2.3

--- cluster/gfs2/fsck/metawalk.c	2006/11/16 19:56:09	1.3.2.2
+++ cluster/gfs2/fsck/metawalk.c	2006/11/20 15:44:53	1.3.2.3
@@ -162,8 +162,7 @@
 				}
 			}
 
-			enum update_flags u = not_updated;
-
+			*update = not_updated;
 			lbh = bread(sbp, leaf_no);
 			gfs2_leaf_in(&leaf, lbh->b_data);
 
@@ -177,7 +176,8 @@
 				log_debug("incorrect lf_dirent_format at leaf #%" PRIu64 "\n", leaf_no);
 				leaf.lf_dirent_format = GFS2_FORMAT_DE;
 				gfs2_leaf_out(&leaf, lbh->b_data);
-				u = updated;
+				log_debug("Fixing lf_dirent_format.\n");
+				*update = updated;
 			}
 
 			exp_count = (1 << (ip->i_di.di_depth - leaf.lf_depth));
@@ -227,9 +227,7 @@
 				 * compare it against leaf->lf_entries */
 				break;
 			} else {
-				if (u == updated)
-					log_debug("Fixing lf_dirent_format.\n");
-				brelse(lbh, u);
+				brelse(lbh, *updated);
 				if(!leaf.lf_next)
 					break;
 				leaf_no = leaf.lf_next;



^ permalink raw reply	[flat|nested] 12+ messages in thread
* [Cluster-devel] cluster/gfs2/fsck metawalk.c
@ 2006-11-20 21:30 rpeterso
  0 siblings, 0 replies; 12+ messages in thread
From: rpeterso @ 2006-11-20 21:30 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	cluster
Branch: 	RHEL50
Changes by:	rpeterso at sourceware.org	2006-11-20 21:30:40

Modified files:
	gfs2/fsck      : metawalk.c 

Log message:
	Resolves: bz215809: fsck errors on gfs2 volume

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/fsck/metawalk.c.diff?cvsroot=cluster&only_with_tag=RHEL50&r1=1.3&r2=1.3.4.1

--- cluster/gfs2/fsck/metawalk.c	2006/06/12 20:41:43	1.3
+++ cluster/gfs2/fsck/metawalk.c	2006/11/20 21:30:40	1.3.4.1
@@ -74,15 +74,26 @@
 				return 1;
 			}
 		} else {
-			error = pass->check_dentry(ip, dent, prev, bh, filename, update,
-									   count, pass->private);
-			if(error < 0) {
-				stack;
-				return -1;
+			if (!de.de_inum.no_addr && first) { /* reverse sentinel */
+				log_debug("First dirent is a Sentinel (place holder).\n");
+				/* Swap the two to silently make it a proper sentinel */
+				de.de_inum.no_addr = de.de_inum.no_formal_ino;
+				de.de_inum.no_formal_ino = 0;
+				gfs2_dirent_out(&de, (char *)dent);
+				*update = 1; /* Mark dirent buffer as modified */
+				first = 0;
+			}
+			else {
+				error = pass->check_dentry(ip, dent, prev, bh, filename,
+							   update, count, pass->private);
+				if(error < 0) {
+					stack;
+					return -1;
+				}
+				/*if(error > 0) {
+				  return 1;
+				  }*/
 			}
-			/*if(error > 0) {
-			  return 1;
-			  }*/
 		}
 
 		if ((char *)dent + de.de_rec_len >= bh_end){
@@ -151,21 +162,25 @@
 				}
 			}
 
+			*update = not_updated;
 			lbh = bread(sbp, leaf_no);
 			gfs2_leaf_in(&leaf, lbh->b_data);
 
 			exp_count = (1 << (ip->i_di.di_depth - leaf.lf_depth));
 			log_debug("expected count %u - di_depth %u, leaf depth %u\n",
 					  exp_count, ip->i_di.di_depth, leaf.lf_depth);
+
 			if(pass->check_dentry &&
 			   S_ISDIR(ip->i_di.di_mode)) {
 				error = check_entries(ip, lbh, index, DIR_EXHASH, update,
 									  &count, pass);
 
 				/* Since the buffer possibly got
-				   updated directly, release it now,
-				   and grab it again later if we need it */
-				brelse(lbh, not_updated);
+				 * updated directly, release it now,
+				 * and grab it again later if we need it. */
+
+				brelse(lbh, *update);
+
 				if(error < 0) {
 					stack;
 					return -1;



^ permalink raw reply	[flat|nested] 12+ messages in thread
* [Cluster-devel] cluster/gfs2/fsck metawalk.c
@ 2006-11-20 21:46 rpeterso
  0 siblings, 0 replies; 12+ messages in thread
From: rpeterso @ 2006-11-20 21:46 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	cluster
Branch: 	RHEL50
Changes by:	rpeterso at sourceware.org	2006-11-20 21:46:23

Modified files:
	gfs2/fsck      : metawalk.c 

Log message:
	Fix another case where lf_dirent_format was not rewritten to disk
	after it was fixed.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/fsck/metawalk.c.diff?cvsroot=cluster&only_with_tag=RHEL50&r1=1.3.4.1&r2=1.3.4.2

--- cluster/gfs2/fsck/metawalk.c	2006/11/20 21:30:40	1.3.4.1
+++ cluster/gfs2/fsck/metawalk.c	2006/11/20 21:46:23	1.3.4.2
@@ -166,6 +166,20 @@
 			lbh = bread(sbp, leaf_no);
 			gfs2_leaf_in(&leaf, lbh->b_data);
 
+			/*
+			 * Early versions of GFS2 had an endianess bug in the kernel
+			 * that set lf_dirent_format to cpu_to_be16(GFS2_FORMAT_DE).
+			 * This was fixed to use cpu_to_be32(), but we should check
+			 * for incorrect values and replace them with the correct value. */
+
+			if (leaf.lf_dirent_format == (GFS2_FORMAT_DE << 16)) {
+				log_debug("incorrect lf_dirent_format@leaf #%" PRIu64 "\n", leaf_no);
+				leaf.lf_dirent_format = GFS2_FORMAT_DE;
+				gfs2_leaf_out(&leaf, lbh->b_data);
+				log_debug("Fixing lf_dirent_format.\n");
+				*update = updated;
+			}
+
 			exp_count = (1 << (ip->i_di.di_depth - leaf.lf_depth));
 			log_debug("expected count %u - di_depth %u, leaf depth %u\n",
 					  exp_count, ip->i_di.di_depth, leaf.lf_depth);
@@ -190,9 +204,8 @@
 					return 1;
 
 				if(update && (count != leaf.lf_entries)) {
-					enum update_flags f;
+					enum update_flags f = not_updated;
 
-					f = not_updated;
 					lbh = bread(sbp, leaf_no);
 					gfs2_leaf_in(&leaf, lbh->b_data);
 
@@ -214,7 +227,7 @@
 				 * compare it against leaf->lf_entries */
 				break;
 			} else {
-				brelse(lbh, not_updated);
+				brelse(lbh, *update);
 				if(!leaf.lf_next)
 					break;
 				leaf_no = leaf.lf_next;



^ permalink raw reply	[flat|nested] 12+ messages in thread
* [Cluster-devel] cluster/gfs2/fsck metawalk.c
@ 2007-01-23 19:44 rpeterso
  0 siblings, 0 replies; 12+ messages in thread
From: rpeterso @ 2007-01-23 19:44 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	cluster
Changes by:	rpeterso at sourceware.org	2007-01-23 19:44:12

Modified files:
	gfs2/fsck      : metawalk.c 

Log message:
	Resolves: bz 223843 GFS2: gfs2_fsck segfaulting on corrupt extended
	attributes

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/fsck/metawalk.c.diff?cvsroot=cluster&r1=1.6&r2=1.7

--- cluster/gfs2/fsck/metawalk.c	2006/11/20 15:35:12	1.6
+++ cluster/gfs2/fsck/metawalk.c	2007/01/23 19:44:12	1.7
@@ -247,6 +247,7 @@
 	uint64_t *ea_data_ptr = NULL;
 	int i;
 	int error = 0;
+	uint32_t offset = (uint32_t)sizeof(struct gfs2_meta_header);
 
 	if(!pass->check_eattr_entry) {
 		return 0;
@@ -287,11 +288,11 @@
 				}
 			}
 		}
-		if(ea_hdr->ea_flags & GFS2_EAFLAG_LAST){
-			/* FIXME: better equal the end of the block */
+		offset += be32_to_cpu(ea_hdr->ea_rec_len);
+		if(ea_hdr->ea_flags & GFS2_EAFLAG_LAST ||
+		   offset >= ip->i_sbd->sd_sb.sb_bsize || ea_hdr->ea_rec_len == 0){
 			break;
 		}
-		/* FIXME: be sure this doesn't go beyond the end */
 		ea_hdr_prev = ea_hdr;
 		ea_hdr = (struct gfs2_ea_header *)
 			((char *)(ea_hdr) +



^ permalink raw reply	[flat|nested] 12+ messages in thread
* [Cluster-devel] cluster/gfs2/fsck metawalk.c
@ 2007-01-23 19:54 rpeterso
  0 siblings, 0 replies; 12+ messages in thread
From: rpeterso @ 2007-01-23 19:54 UTC (permalink / raw)
  To: cluster-devel.redhat.com

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

Modified files:
	gfs2/fsck      : metawalk.c 

Log message:
	Resolves: bz 223843 GFS2: gfs2_fsck segfaulting on corrupt extended
	attributes

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/fsck/metawalk.c.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.3.2.3&r2=1.3.2.4

--- cluster/gfs2/fsck/metawalk.c	2006/11/20 15:44:53	1.3.2.3
+++ cluster/gfs2/fsck/metawalk.c	2007/01/23 19:54:23	1.3.2.4
@@ -227,7 +227,7 @@
 				 * compare it against leaf->lf_entries */
 				break;
 			} else {
-				brelse(lbh, *updated);
+				brelse(lbh, *update);
 				if(!leaf.lf_next)
 					break;
 				leaf_no = leaf.lf_next;
@@ -247,6 +247,7 @@
 	uint64_t *ea_data_ptr = NULL;
 	int i;
 	int error = 0;
+	uint32_t offset = (uint32_t)sizeof(struct gfs2_meta_header);
 
 	if(!pass->check_eattr_entry) {
 		return 0;
@@ -287,11 +288,11 @@
 				}
 			}
 		}
-		if(ea_hdr->ea_flags & GFS2_EAFLAG_LAST){
-			/* FIXME: better equal the end of the block */
+		offset += be32_to_cpu(ea_hdr->ea_rec_len);
+		if(ea_hdr->ea_flags & GFS2_EAFLAG_LAST ||
+		   offset >= ip->i_sbd->sd_sb.sb_bsize || ea_hdr->ea_rec_len == 0){
 			break;
 		}
-		/* FIXME: be sure this doesn't go beyond the end */
 		ea_hdr_prev = ea_hdr;
 		ea_hdr = (struct gfs2_ea_header *)
 			((char *)(ea_hdr) +



^ permalink raw reply	[flat|nested] 12+ messages in thread
* [Cluster-devel] cluster/gfs2/fsck metawalk.c
@ 2007-02-26 19:19 rpeterso
  0 siblings, 0 replies; 12+ messages in thread
From: rpeterso @ 2007-02-26 19:19 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	cluster
Changes by:	rpeterso at sourceware.org	2007-02-26 19:19:06

Modified files:
	gfs2/fsck      : metawalk.c 

Log message:
	Resolves bz: 229222: gfs2_fsck stuck in infinite loop

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/fsck/metawalk.c.diff?cvsroot=cluster&r1=1.7&r2=1.8

--- cluster/gfs2/fsck/metawalk.c	2007/01/23 19:44:12	1.7
+++ cluster/gfs2/fsck/metawalk.c	2007/02/26 19:19:06	1.8
@@ -96,6 +96,15 @@
 			}
 		}
 
+		if (de.de_rec_len < sizeof(struct gfs2_dirent)) {
+			log_err("Entry %" PRIu64 "(0x%"
+				PRIx64 ") of directory %" PRIu64 "(0x%"
+				PRIx64 ") is corrupt, skipping.\n",
+				bh->b_blocknr, bh->b_blocknr,
+				ip->i_di.di_num.no_addr,
+				ip->i_di.di_num.no_addr);
+                        break;
+                }
 		if ((char *)dent + de.de_rec_len >= bh_end){
 			log_debug("Last entry processed.\n");
 			break;
@@ -180,6 +189,15 @@
 				*update = updated;
 			}
 
+			/* Make sure it's really a leaf. */
+			if (leaf.lf_header.mh_type != GFS2_METATYPE_LF) {
+				log_err("Inode %" PRIu64 " (0x%"
+					PRIx64 ") points to bad leaf "
+					PRIu64 " (0x%" PRIx64 ").\n",
+					ip->i_di.di_num.no_addr, leaf_no);
+				brelse(lbh, *update);
+				break;
+			}
 			exp_count = (1 << (ip->i_di.di_depth - leaf.lf_depth));
 			log_debug("expected count %u - di_depth %u, leaf depth %u\n",
 					  exp_count, ip->i_di.di_depth, leaf.lf_depth);



^ permalink raw reply	[flat|nested] 12+ messages in thread
* [Cluster-devel] cluster/gfs2/fsck metawalk.c
@ 2007-02-26 19:20 rpeterso
  0 siblings, 0 replies; 12+ messages in thread
From: rpeterso @ 2007-02-26 19:20 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	cluster
Branch: 	RHEL5
Changes by:	rpeterso at sourceware.org	2007-02-26 19:20:46

Modified files:
	gfs2/fsck      : metawalk.c 

Log message:
	Resolves bz: 229222: gfs2_fsck stuck in infinite loop

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/fsck/metawalk.c.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.3.2.4&r2=1.3.2.5

--- cluster/gfs2/fsck/metawalk.c	2007/01/23 19:54:23	1.3.2.4
+++ cluster/gfs2/fsck/metawalk.c	2007/02/26 19:20:46	1.3.2.5
@@ -96,6 +96,15 @@
 			}
 		}
 
+		if (de.de_rec_len < sizeof(struct gfs2_dirent)) {
+			log_err("Entry %" PRIu64 "(0x%"
+				PRIx64 ") of directory %" PRIu64 "(0x%"
+				PRIx64 ") is corrupt, skipping.\n",
+				bh->b_blocknr, bh->b_blocknr,
+				ip->i_di.di_num.no_addr,
+				ip->i_di.di_num.no_addr);
+                        break;
+                }
 		if ((char *)dent + de.de_rec_len >= bh_end){
 			log_debug("Last entry processed.\n");
 			break;
@@ -180,6 +189,15 @@
 				*update = updated;
 			}
 
+			/* Make sure it's really a leaf. */
+			if (leaf.lf_header.mh_type != GFS2_METATYPE_LF) {
+				log_err("Inode %" PRIu64 " (0x%"
+					PRIx64 ") points to bad leaf "
+					PRIu64 " (0x%" PRIx64 ").\n",
+					ip->i_di.di_num.no_addr, leaf_no);
+				brelse(lbh, *update);
+				break;
+			}
 			exp_count = (1 << (ip->i_di.di_depth - leaf.lf_depth));
 			log_debug("expected count %u - di_depth %u, leaf depth %u\n",
 					  exp_count, ip->i_di.di_depth, leaf.lf_depth);



^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2007-02-26 19:20 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-11-14 22:51 [Cluster-devel] cluster/gfs2/fsck metawalk.c rpeterso
  -- strict thread matches above, loose matches on Subject: below --
2006-11-14 22:55 rpeterso
2006-11-16 19:56 rohara
2006-11-16 20:12 rohara
2006-11-20 15:35 rpeterso
2006-11-20 15:44 rohara
2006-11-20 21:30 rpeterso
2006-11-20 21:46 rpeterso
2007-01-23 19:44 rpeterso
2007-01-23 19:54 rpeterso
2007-02-26 19:19 rpeterso
2007-02-26 19:20 rpeterso

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).