This is the mail archive of the cluster-cvs@sourceware.org mailing list for the cluster.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

cluster: RHEL5 - GFS2: gfs2_edit savemeta wasn't saving indirecteattribute blocks


Gitweb:        http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=da4f13d800450d66773740bf2a3e3a9894b3cf1c
Commit:        da4f13d800450d66773740bf2a3e3a9894b3cf1c
Parent:        74e37a228d6321cbe72fe1bbab8f3604e2a242e2
Author:        Bob Peterson <rpeterso@redhat.com>
AuthorDate:    Mon Jun 15 14:59:20 2009 -0500
Committer:     Bob Peterson <rpeterso@redhat.com>
CommitterDate: Mon Jun 15 15:52:38 2009 -0500

GFS2: gfs2_edit savemeta wasn't saving indirect eattribute blocks

bz 503529

Normal eattribute blocks were being saved, but dinodes that had
an eattribute pointer that leads to an indirect block
(GFS2_METATYPE_IN) weren't being handled properly and saving
off the sub-blocks.  This adds that capability.
---
 gfs2/edit/savemeta.c |   70 ++++++++++++++++++++++++++++++++------------------
 1 files changed, 45 insertions(+), 25 deletions(-)

diff --git a/gfs2/edit/savemeta.c b/gfs2/edit/savemeta.c
index dea57cb..3ac013f 100644
--- a/gfs2/edit/savemeta.c
+++ b/gfs2/edit/savemeta.c
@@ -267,6 +267,35 @@ void save_indirect_blocks(int out_fd, osi_list_t *cur_list,
 }
 
 /*
+ * save_ea_block - save off an extended attribute block
+ */
+void save_ea_block(int out_fd, struct gfs2_buffer_head *metabh)
+{
+	int i, e, ea_len = sbd.bsize;
+	struct gfs2_ea_header ea;
+
+	for (e = sizeof(struct gfs2_meta_header); e < sbd.bsize; e += ea_len) {
+		uint64_t blk, *b;
+		int charoff;
+
+		gfs2_ea_header_in(&ea, metabh->b_data + e);
+		for (i = 0; i < ea.ea_num_ptrs; i++) {
+			charoff = e + ea.ea_name_len +
+				sizeof(struct gfs2_ea_header) +
+				sizeof(uint64_t) - 1;
+			charoff /= sizeof(uint64_t);
+			b = (uint64_t *)(metabh->b_data);
+			b += charoff + i;
+			blk = be64_to_cpu(*b);
+			save_block(sbd.device_fd, out_fd, blk);
+		}
+		if (!ea.ea_rec_len)
+			break;
+		ea_len = ea.ea_rec_len;
+	}
+}
+
+/*
  * save_inode_data - save off important data associated with an inode
  *
  * out_fd - destination file descriptor
@@ -335,36 +364,27 @@ void save_inode_data(int out_fd)
 		}
 	}
 	if (inode->i_di.di_eattr) { /* if this inode has extended attributes */
-		struct gfs2_ea_header ea;
 		struct gfs2_meta_header mh;
-		int e;
 
 		metabh = bread(&sbd.buf_list, inode->i_di.di_eattr);
 		save_block(sbd.device_fd, out_fd, inode->i_di.di_eattr);
 		gfs2_meta_header_in(&mh, metabh->b_data);
-		if (mh.mh_magic == GFS2_MAGIC) {
-			for (e = sizeof(struct gfs2_meta_header);
-			     e < sbd.bsize; e += ea.ea_rec_len) {
-				uint64_t blk, *b;
-				int charoff;
-
-				gfs2_ea_header_in(&ea, metabh->b_data + e);
-				for (i = 0; i < ea.ea_num_ptrs; i++) {
-					charoff = e + ea.ea_name_len +
-						sizeof(struct gfs2_ea_header) +
-						sizeof(uint64_t) - 1;
-					charoff /= sizeof(uint64_t);
-					b = (uint64_t *)(metabh->b_data);
-					b += charoff + i;
-					blk = be64_to_cpu(*b);
-					save_block(sbd.device_fd, out_fd, blk);
-				}
-				if (!ea.ea_rec_len)
-					break;
-			}
-		} else {
-			fprintf(stderr, "\nWarning: corrupt extended attribute"
-				" at block %llu (0x%llx) detected.\n",
+		if (mh.mh_magic == GFS2_MAGIC &&
+		    mh.mh_type == GFS2_METATYPE_EA)
+			save_ea_block(out_fd, metabh);
+		else if (mh.mh_magic == GFS2_MAGIC &&
+			 mh.mh_type == GFS2_METATYPE_IN)
+			save_indirect_blocks(out_fd, cur_list, metabh, 2, 2);
+		else {
+			if (mh.mh_magic == GFS2_MAGIC) /* if it's metadata */
+				save_block(sbd.device_fd, out_fd,
+					   inode->i_di.di_eattr);
+			fprintf(stderr,
+				"\nWarning: corrupt extended "
+				"attribute at block %llu (0x%llx) "
+				"detected in inode %lld (0x%llx).\n",
+				(unsigned long long)inode->i_di.di_eattr,
+				(unsigned long long)inode->i_di.di_eattr,
 				(unsigned long long)block,
 				(unsigned long long)block);
 		}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]