From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17089 invoked by alias); 15 Jun 2009 20:54:32 -0000 Received: (qmail 17082 invoked by alias); 15 Jun 2009 20:54:31 -0000 X-SWARE-Spam-Status: No, hits=-0.9 required=5.0 tests=AWL,BAYES_00,J_CHICKENPOX_45,J_CHICKENPOX_66,SPF_HELO_PASS X-Spam-Status: No, hits=-0.9 required=5.0 tests=AWL,BAYES_00,J_CHICKENPOX_45,J_CHICKENPOX_66,SPF_HELO_PASS X-Spam-Check-By: sourceware.org X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on bastion2.fedora.phx.redhat.com Subject: cluster: RHEL5 - GFS2: gfs2_edit savemeta wasn't saving indirect eattribute blocks To: cluster-cvs-relay@redhat.com X-Project: Cluster Project X-Git-Module: cluster.git X-Git-Refname: refs/heads/RHEL5 X-Git-Reftype: branch X-Git-Oldrev: 74e37a228d6321cbe72fe1bbab8f3604e2a242e2 X-Git-Newrev: da4f13d800450d66773740bf2a3e3a9894b3cf1c From: Bob Peterson Message-Id: <20090615205407.0670912026D@lists.fedorahosted.org> Date: Mon, 15 Jun 2009 20:54:00 -0000 X-Scanned-By: MIMEDefang 2.58 on 172.16.52.254 Mailing-List: contact cluster-cvs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: cluster-cvs-owner@sourceware.org X-SW-Source: 2009-q2/txt/msg00529.txt.bz2 Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=da4f13d800450d66773740bf2a3e3a9894b3cf1c Commit: da4f13d800450d66773740bf2a3e3a9894b3cf1c Parent: 74e37a228d6321cbe72fe1bbab8f3604e2a242e2 Author: Bob Peterson AuthorDate: Mon Jun 15 14:59:20 2009 -0500 Committer: Bob Peterson 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); }