Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > by-pkgid > 9383e745e23602bc45f9c92184feea59 > files > 90

gfs2-utils-0.1.62-28.el5.src.rpm

commit 9d1b57ae8baa0592b556654feaa86414cadc4e2b
Author: Bob Peterson <rpeterso@redhat.com>
Date:   Tue Jun 16 14:46:09 2009 -0500

    GFS2: gfs2_edit savemeta wasn't saving ea sub-blocks
    
    Indirect extended attribute blocks may have sub-blocks, and those
    weren't getting saved.  This adds that capability.
    
    rhbz#527770

diff --git a/gfs2/edit/savemeta.c b/gfs2/edit/savemeta.c
index b5bf33f..d2fca05 100644
--- a/gfs2/edit/savemeta.c
+++ b/gfs2/edit/savemeta.c
@@ -200,8 +200,9 @@ 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;
 	}
@@ -235,6 +236,35 @@ 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
  */
 void save_indirect_blocks(int out_fd, osi_list_t *cur_list,
@@ -242,7 +272,7 @@ 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 ?
@@ -257,7 +287,12 @@ 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,