public inbox for cluster-cvs@sourceware.org
help / color / mirror / Atom feed
From: Bob Peterson <rpeterso@fedoraproject.org>
To: cluster-cvs-relay@redhat.com
Subject: cluster: RHEL5 - GFS2: gfs2_edit savemeta wasn't saving indirect eattribute blocks
Date: Mon, 15 Jun 2009 20:54:00 -0000	[thread overview]
Message-ID: <20090615205407.0670912026D@lists.fedorahosted.org> (raw)

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);
 		}


                 reply	other threads:[~2009-06-15 20:54 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090615205407.0670912026D@lists.fedorahosted.org \
    --to=rpeterso@fedoraproject.org \
    --cc=cluster-cvs-relay@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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 read-only IMAP folder(s) and NNTP newsgroup(s).