[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Cluster-devel] [Patch 25/44] fsck.gfs2 pass2: When deleting an inode, delete its extended attributes



>From c88ec089aeddd42c88faa17f5dd9ecb7119e2d61 Mon Sep 17 00:00:00 2001
From: Bob Peterson <rpeterso redhat com>
Date: Tue, 9 Aug 2011 12:48:36 -0500
Subject: [PATCH 25/44] fsck.gfs pass2: When deleting an inode, delete its
 extended attributes

When pass2 decided to delete a bad/corrupt dinode from disk, it was
not deleting extended attributes associated with that dinode.  Oops.
This patch corrects the situation and allows it to delete them.

rhbz#675723
---
 gfs2/fsck/pass2.c |   55 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 55 insertions(+), 0 deletions(-)

diff --git a/gfs2/fsck/pass2.c b/gfs2/fsck/pass2.c
index 870a792..2ee3fe7 100644
--- a/gfs2/fsck/pass2.c
+++ b/gfs2/fsck/pass2.c
@@ -162,6 +162,59 @@ static int check_file_type(uint8_t de_type, uint8_t blk_type)
 	return 0;
 }
 
+static int delete_eattr_entry (struct gfs2_inode *ip,
+			       struct gfs2_buffer_head *leaf_bh,
+			       struct gfs2_ea_header *ea_hdr,
+			       struct gfs2_ea_header *ea_hdr_prev,
+			       void *private)
+{
+	struct gfs2_sbd *sdp = ip->i_sbd;
+	char ea_name[256];
+
+	if (!ea_hdr->ea_name_len){
+		/* Skip this entry for now */
+		return 1;
+	}
+
+	memset(ea_name, 0, sizeof(ea_name));
+	strncpy(ea_name, (char *)ea_hdr + sizeof(struct gfs2_ea_header),
+		ea_hdr->ea_name_len);
+
+	if (!GFS2_EATYPE_VALID(ea_hdr->ea_type) &&
+	   ((ea_hdr_prev) || (!ea_hdr_prev && ea_hdr->ea_type))){
+		/* Skip invalid entry */
+		return 1;
+	}
+
+	if (ea_hdr->ea_num_ptrs){
+		uint32_t avail_size;
+		int max_ptrs;
+
+		avail_size = sdp->sd_sb.sb_bsize - sizeof(struct gfs2_meta_header);
+		max_ptrs = (be32_to_cpu(ea_hdr->ea_data_len) + avail_size - 1) /
+			avail_size;
+
+		if (max_ptrs > ea_hdr->ea_num_ptrs)
+			return 1;
+		else {
+			log_debug( _("  Pointers Required: %d\n  Pointers Reported: %d\n"),
+					  max_ptrs, ea_hdr->ea_num_ptrs);
+		}
+	}
+	return 0;
+}
+
+static int delete_eattr_extentry(struct gfs2_inode *ip, uint64_t *ea_data_ptr,
+				 struct gfs2_buffer_head *leaf_bh,
+				 struct gfs2_ea_header *ea_hdr,
+				 struct gfs2_ea_header *ea_hdr_prev,
+				 void *private)
+{
+        uint64_t block = be64_to_cpu(*ea_data_ptr);
+
+        return delete_metadata(ip, block, NULL, 0, private);
+}
+
 struct metawalk_fxns pass2_fxns_delete = {
 	.private = NULL,
 	.check_metalist = delete_metadata,
@@ -169,6 +222,8 @@ struct metawalk_fxns pass2_fxns_delete = {
 	.check_leaf = delete_leaf,
 	.check_eattr_indir = delete_eattr_indir,
 	.check_eattr_leaf = delete_eattr_leaf,
+	.check_eattr_entry = delete_eattr_entry,
+	.check_eattr_extentry = delete_eattr_extentry,
 };
 
 /* FIXME: should maybe refactor this a bit - but need to deal with
-- 
1.7.4.4


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]