From: Andrew Price Date: Thu, 6 Aug 2020 14:37:40 +0100 Subject: [Cluster-devel] [PATCH 05/32] savemeta: Don't save bad xattr blocks twice In-Reply-To: <20200806133807.111280-1-anprice@redhat.com> References: <20200806133807.111280-1-anprice@redhat.com> Message-ID: <20200806133807.111280-6-anprice@redhat.com> List-Id: To: cluster-devel.redhat.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit This could only happen if the xattr block has a corrupt mh_type. We've already saved the xattr block by the time we figure out that we can't recognise its mh type so don't bother saving it again there. Also relax mh type checking for the xattr blocks so that we save as much of the (possibly corrupt) fs as possible. Just use the mh_type field to decide whether to save indirect pointers or xattrs. Signed-off-by: Andrew Price --- gfs2/edit/savemeta.c | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/gfs2/edit/savemeta.c b/gfs2/edit/savemeta.c index b44e887e..10e3bcce 100644 --- a/gfs2/edit/savemeta.c +++ b/gfs2/edit/savemeta.c @@ -789,31 +789,15 @@ static void save_inode_data(struct metafd *mfd, uint64_t iblk) } } if (inode->i_di.di_eattr) { /* if this inode has extended attributes */ - struct gfs2_meta_header mh; struct gfs2_buffer_head *lbh; + int mhtype; lbh = bread(&sbd, inode->i_di.di_eattr); - save_block(sbd.device_fd, mfd, inode->i_di.di_eattr, iblk, NULL); - gfs2_meta_header_in(&mh, lbh->b_data); - if (mh.mh_magic == GFS2_MAGIC && - mh.mh_type == GFS2_METATYPE_EA) + save_block(sbd.device_fd, mfd, inode->i_di.di_eattr, iblk, &mhtype); + if (mhtype == GFS2_METATYPE_EA) save_ea_block(mfd, lbh->b_data, iblk); - else if (mh.mh_magic == GFS2_MAGIC && - mh.mh_type == GFS2_METATYPE_IN) + else if (mhtype == GFS2_METATYPE_IN) save_indirect_blocks(mfd, cur_list, lbh, iblk, 2, 2); - else { - if (mh.mh_magic == GFS2_MAGIC) /* if it's metadata */ - save_block(sbd.device_fd, mfd, inode->i_di.di_eattr, - iblk, NULL); - 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)iblk, - (unsigned long long)iblk); - } brelse(lbh); } inode_put(&inode); -- 2.26.2