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: gfs2-utils: master - GFS2: gfs2_edit savemeta wasn't saving ea sub-blocks
Date: Tue, 16 Jun 2009 19:57:00 -0000	[thread overview]
Message-ID: <20090616195730.DB63F12010C@lists.fedorahosted.org> (raw)

Gitweb:        http://git.fedorahosted.org/git/gfs2-utils.git?p=gfs2-utils.git;a=commitdiff;h=4b0aa4e27fee3750814fa2a7532bb2885dbaf87c
Commit:        4b0aa4e27fee3750814fa2a7532bb2885dbaf87c
Parent:        83a6c710483e9fb430d2f48820679ae1205a9017
Author:        Bob Peterson <rpeterso@redhat.com>
AuthorDate:    Tue Jun 16 14:46:09 2009 -0500
Committer:     Bob Peterson <rpeterso@redhat.com>
CommitterDate: Tue Jun 16 14:46:09 2009 -0500

GFS2: gfs2_edit savemeta wasn't saving ea sub-blocks

bz 503529

Indirect extended attribute blocks may have sub-blocks, and those
weren't getting saved.  This adds that capability.
---
 gfs2/edit/savemeta.c |   72 +++++++++++++++++++++++++++-----------------------
 1 files changed, 39 insertions(+), 33 deletions(-)

diff --git a/gfs2/edit/savemeta.c b/gfs2/edit/savemeta.c
index 383b945..d579b91 100644
--- a/gfs2/edit/savemeta.c
+++ b/gfs2/edit/savemeta.c
@@ -185,8 +185,9 @@ static int save_block(int fd, int out_fd, uint64_t blk)
 	char *p;
 
 	if (blk > last_fs_block) {
-		fprintf(stderr, "\nWarning: bad block pointer ignored in "
-			"block (block %llu (%llx))",
+		fprintf(stderr, "\nWarning: bad block pointer '0x%llx' "
+			"ignored in block (block %llu (%llx))",
+			(unsigned long long)blk,
 			(unsigned long long)block, (unsigned long long)block);
 		return 0;
 	}
@@ -256,6 +257,35 @@ static int save_block(int fd, int out_fd, uint64_t blk)
 }
 
 /*
+ * 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_indirect_blocks - save all indirect blocks for the given buffer
  */
 static void save_indirect_blocks(int out_fd, osi_list_t *cur_list,
@@ -263,7 +293,7 @@ static void save_indirect_blocks(int out_fd, osi_list_t *cur_list,
 {
 	uint64_t old_block = 0, indir_block;
 	uint64_t *ptr;
-	int head_size;
+	int head_size, blktype;
 	struct gfs2_buffer_head *nbh;
 
 	head_size = (hgt > 1 ?
@@ -278,7 +308,12 @@ static void save_indirect_blocks(int out_fd, osi_list_t *cur_list,
 		if (indir_block == old_block)
 			continue;
 		old_block = indir_block;
-		save_block(sbd.device_fd, out_fd, indir_block);
+		blktype = save_block(sbd.device_fd, out_fd, indir_block);
+		if (blktype == GFS2_METATYPE_EA) {
+			nbh = bread(&sbd.buf_list, indir_block);
+			save_ea_block(out_fd, nbh);
+			brelse(nbh, not_updated);
+		}
 		if (height != hgt) { /* If not at max height */
 			nbh = bread(&sbd.buf_list, indir_block);
 			osi_list_add_prev(&nbh->b_altlist,
@@ -289,35 +324,6 @@ static 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


                 reply	other threads:[~2009-06-16 19:57 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=20090616195730.DB63F12010C@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).