cluster: STABLE3 - Move duplicate code from libgfs2 to fsck.gfs2

Bob Peterson rpeterso at fedoraproject.org
Tue Jan 26 21:19:30 UTC 2010


Gitweb:        http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=2f222faced71bb3a90d1ed9d1dd4af3bede7eaf6
Commit:        2f222faced71bb3a90d1ed9d1dd4af3bede7eaf6
Parent:        327ce87f9acba792daf2729140b7f2ab6b0b3636
Author:        Bob Peterson <bob at ganesha.peterson>
AuthorDate:    Wed Jan 20 09:47:30 2010 -0600
Committer:     Bob Peterson <rpeterso at redhat.com>
CommitterDate: Tue Jan 26 14:39:28 2010 -0600

Move duplicate code from libgfs2 to fsck.gfs2

This patch removes the duplicate block management from
libgfs2 and puts it into the only code that used it: fsck.gfs2.
This has several advantages for performance and readability.
Since it no longer has to worry about duplicates, the blockmap
code in libgfs2 can do less work in places where fsck.gfs2
doesn't care one way or another if the block is a duplicate.
Conversely, the places in fsck.gfs2 that only care if the
block is a duplicate are also simplified because they don't
have to do the additional blockmap code that went along.
This also paves the way for future code simplification.

rhbz#455300
---
 gfs2/fsck/eattr.c         |   10 +----
 gfs2/fsck/fsck.h          |    7 +++
 gfs2/fsck/initialize.c    |   18 ++++++++-
 gfs2/fsck/main.c          |    1 +
 gfs2/fsck/metawalk.c      |   16 +++++++-
 gfs2/fsck/metawalk.h      |    3 +
 gfs2/fsck/pass1.c         |   31 ++++++--------
 gfs2/fsck/pass1b.c        |   24 +++++-----
 gfs2/fsck/pass2.c         |    8 ++--
 gfs2/fsck/util.c          |   17 ++++++++
 gfs2/fsck/util.h          |    1 +
 gfs2/libgfs2/block_list.c |  100 ++++-----------------------------------------
 gfs2/libgfs2/libgfs2.h    |   11 -----
 13 files changed, 100 insertions(+), 147 deletions(-)

diff --git a/gfs2/fsck/eattr.c b/gfs2/fsck/eattr.c
index 10e5636..a319500 100644
--- a/gfs2/fsck/eattr.c
+++ b/gfs2/fsck/eattr.c
@@ -6,17 +6,11 @@
 #include "libgfs2.h"
 #include "fsck.h"
 #include "eattr.h"
+#include "metawalk.h"
 
 static int clear_blk_nodup(struct gfs2_sbd *sbp, uint64_t block)
 {
-	struct gfs2_block_query q;
-
-	if(gfs2_block_check(sbp, bl, block, &q)) {
-		stack;
-		return -1;
-	}
-
-	if(q.dup_block) {
+	if(is_duplicate(block)) {
 		log_debug( _("Not clearing block with marked as a duplicate\n"));
 		return 1;
 	}
diff --git a/gfs2/fsck/fsck.h b/gfs2/fsck/fsck.h
index 15c33f9..05a1147 100644
--- a/gfs2/fsck/fsck.h
+++ b/gfs2/fsck/fsck.h
@@ -59,6 +59,12 @@ enum rgindex_trust_level { /* how far can we trust our RG index? */
 			  gfs2_grow or something.  Count the RGs by hand. */
 };
 
+struct dup_blks {
+	osi_list_t list;
+	uint64_t block_no;
+	osi_list_t ref_inode_list;
+};
+
 extern struct gfs2_inode *fsck_load_inode(struct gfs2_sbd *sbp, uint64_t block);
 extern struct gfs2_inode *fsck_inode_get(struct gfs2_sbd *sdp,
 				  struct gfs2_buffer_head *bh);
@@ -93,5 +99,6 @@ extern int skip_this_pass, fsck_abort;
 extern int errors_found, errors_corrected;
 extern uint64_t last_data_block;
 extern uint64_t first_data_block;
+extern struct dup_blks dup_blocks;
 
 #endif /* _FSCK_H */
diff --git a/gfs2/fsck/initialize.c b/gfs2/fsck/initialize.c
index ec9c3cc..79f88fd 100644
--- a/gfs2/fsck/initialize.c
+++ b/gfs2/fsck/initialize.c
@@ -55,6 +55,19 @@ static int block_mounters(struct gfs2_sbd *sbp, int block_em)
 	return 0;
 }
 
+static void gfs2_dup_free(void)
+{
+	struct dup_blks *f;
+
+	while(!osi_list_empty(&dup_blocks.list)) {
+		f = osi_list_entry(dup_blocks.list.next, struct dup_blks,
+				   list);
+		while (!osi_list_empty(&f->ref_inode_list))
+			osi_list_del(&f->ref_inode_list);
+		osi_list_del(&f->list);
+		free(f);
+	}
+}
 
 /*
  * empty_super_block - free all structures in the super block
@@ -87,8 +100,10 @@ static void empty_super_block(struct gfs2_sbd *sdp)
 		}
 	}
 
-	if (bl)
+	if (bl) {
 		gfs2_bmap_destroy(sdp, bl);
+		gfs2_dup_free();
+	}
 }
 
 
@@ -380,6 +395,7 @@ static int init_system_inodes(struct gfs2_sbd *sdp)
 		log_crit( _("Please increase your swap space by that amount and run gfs2_fsck again.\n"));
 		goto fail;
 	}
+	osi_list_init(&dup_blocks.list);
 	return 0;
  fail:
 	empty_super_block(sdp);
diff --git a/gfs2/fsck/main.c b/gfs2/fsck/main.c
index 195958c..34cc045 100644
--- a/gfs2/fsck/main.c
+++ b/gfs2/fsck/main.c
@@ -29,6 +29,7 @@ const char *pass = "";
 uint64_t last_data_block;
 uint64_t first_data_block;
 int preen = 0, force_check = 0;
+struct dup_blks dup_blocks;
 
 /* This function is for libgfs2's sake.                                      */
 void print_it(const char *label, const char *fmt, const char *fmt2, ...)
diff --git a/gfs2/fsck/metawalk.c b/gfs2/fsck/metawalk.c
index 1f48e0a..aaa1144 100644
--- a/gfs2/fsck/metawalk.c
+++ b/gfs2/fsck/metawalk.c
@@ -16,6 +16,20 @@
 
 #define COMFORTABLE_BLKS 5242880 /* 20GB in 4K blocks */
 
+struct dup_blks *dupfind(uint64_t num)
+{
+	osi_list_t *head = &dup_blocks.list;
+	osi_list_t *tmp;
+	struct dup_blks *b;
+
+	for (tmp = head->next; tmp != head; tmp = tmp->next) {
+		b = osi_list_entry(tmp, struct dup_blks, list);
+		if (b->block_no == num)
+			return b;
+	}
+	return NULL;
+}
+
 static struct gfs2_inode *get_system_inode(struct gfs2_sbd *sbp,
 					   uint64_t block)
 {
@@ -1184,7 +1198,7 @@ int delete_blocks(struct gfs2_inode *ip, uint64_t block,
 	if (gfs2_check_range(ip->i_sbd, block) == 0) {
 		if (gfs2_block_check(ip->i_sbd, bl, block, &q))
 			return 0;
-		if (!q.dup_block) {
+		if(!is_duplicate(block)) {
 			log_info( _("Deleting %s block %lld (0x%llx) as part "
 				    "of inode %lld (0x%llx)\n"), btype,
 				  (unsigned long long)block,
diff --git a/gfs2/fsck/metawalk.h b/gfs2/fsck/metawalk.h
index b720516..0ad0aa2 100644
--- a/gfs2/fsck/metawalk.h
+++ b/gfs2/fsck/metawalk.h
@@ -25,6 +25,9 @@ int delete_eattr_indir(struct gfs2_inode *ip, uint64_t block, uint64_t parent,
 		       struct gfs2_buffer_head **bh, void *private);
 int delete_eattr_leaf(struct gfs2_inode *ip, uint64_t block, uint64_t parent,
 		      struct gfs2_buffer_head **bh, void *private);
+struct dup_blks *dupfind(uint64_t num);
+
+#define is_duplicate(dblock) ((dupfind(dblock)) ? 1 : 0)
 
 /* metawalk_fxns: function pointers to check various parts of the fs
  *
diff --git a/gfs2/fsck/pass1.c b/gfs2/fsck/pass1.c
index b284e56..5baf351 100644
--- a/gfs2/fsck/pass1.c
+++ b/gfs2/fsck/pass1.c
@@ -104,7 +104,7 @@ static int check_metalist(struct gfs2_inode *ip, uint64_t block,
 	if(q.block_type != gfs2_block_free) {
 		log_err( _("Found duplicate block referenced as metadata in "
 			   "indirect block - was marked %d\n"), q.block_type);
-		gfs2_block_mark(ip->i_sbd, bl, block, gfs2_dup_block);
+		gfs2_dup_set(block);
 		found_dup = 1;
 	}
 	nbh = bread(ip->i_sbd, block);
@@ -160,7 +160,7 @@ static int check_data(struct gfs2_inode *ip, uint64_t block, void *private)
 		log_err( _("Found duplicate block referenced as data at %"
 			   PRIu64 " (0x%"PRIx64 ")\n"), block, block);
 		if (q.block_type != gfs2_meta_inval) {
-			gfs2_block_mark(ip->i_sbd, bl, block, gfs2_dup_block);
+			gfs2_dup_set(block);
 			/* If the prev ref was as data, this is likely a data
 			   block, so keep the block count for both refs. */
 			if (q.block_type == gfs2_block_used)
@@ -178,11 +178,11 @@ static int check_data(struct gfs2_inode *ip, uint64_t block, void *private)
 		   marked as duplicate, but also as a data block. */
 		error = 1;
 		gfs2_block_unmark(ip->i_sbd, bl, block, gfs2_meta_inval);
-		gfs2_block_mark(ip->i_sbd, bl, block, gfs2_dup_block);
+		gfs2_dup_set(block);
 	}
 	log_debug( _("Marking block %llu (0x%llx) as data block\n"),
 		   (unsigned long long)block, (unsigned long long)block);
-	gfs2_block_mark(ip->i_sbd, bl, block, gfs2_block_used);
+	gfs2_blockmap_set(ip->i_sbd, bl, block, gfs2_block_used);
 
 	/* This is also confusing, so I'll clarify.  There are two bitmaps:
 	   (1) The gfs2_bmap that fsck uses to keep track of what block
@@ -245,12 +245,12 @@ static int ask_remove_inode_eattr(struct gfs2_inode *ip,
 	if (query( _("Clear all Extended Attributes from the "
 		     "inode? (y/n) "))) {
 		struct gfs2_block_query q;
-
 		if(gfs2_block_check(ip->i_sbd, bl, ip->i_di.di_eattr, &q)) {
 			stack;
 			return -1;
 		}
-		if (!remove_inode_eattr(ip, bc, q.dup_block))
+		if (!remove_inode_eattr(ip, bc,
+					is_duplicate(ip->i_di.di_eattr)))
 			log_err( _("Extended attributes were removed.\n"));
 		else
 			log_err( _("Unable to remove inode eattr pointer; "
@@ -333,8 +333,7 @@ static int check_eattr_indir(struct gfs2_inode *ip, uint64_t indirect,
 			if (!clear_eas(ip, bc, indirect, 1,
 				       _("Bad indirect Extended Attribute "
 					 "duplicate found"))) {
-				gfs2_block_mark(sdp, bl, indirect,
-						gfs2_dup_block);
+				gfs2_dup_set(indirect);
 				bc->ea_count++;
 			}
 			return 1;
@@ -352,7 +351,7 @@ static int check_eattr_indir(struct gfs2_inode *ip, uint64_t indirect,
 			 (unsigned long long)ip->i_di.di_num.no_addr,
 			 (unsigned long long)indirect,
 			 (unsigned long long)indirect);
-		gfs2_block_mark(sdp, bl, indirect, gfs2_dup_block);
+		gfs2_dup_set(indirect);
 		bc->ea_count++;
 		ret = 1;
 	} else {
@@ -428,7 +427,7 @@ static int check_leaf_block(struct gfs2_inode *ip, uint64_t block, int btype,
 		log_debug( _("Duplicate block found at #%lld (0x%llx).\n"),
 			   (unsigned long long)block,
 			   (unsigned long long)block);
-		gfs2_block_mark(sdp, bl, block, gfs2_dup_block);
+		gfs2_dup_set(block);
 		bc->ea_count++;
 		brelse(leaf_bh);
 		return 1;
@@ -576,7 +575,7 @@ static int clear_metalist(struct gfs2_inode *ip, uint64_t block,
 		stack;
 		return -1;
 	}
-	if(!q.dup_block) {
+	if(!is_duplicate(block)) {
 		gfs2_blockmap_set(ip->i_sbd, bl, block, gfs2_block_free);
 		return 0;
 	}
@@ -591,7 +590,7 @@ static int clear_data(struct gfs2_inode *ip, uint64_t block, void *private)
 		stack;
 		return -1;
 	}
-	if(!q.dup_block) {
+	if(!is_duplicate(block)) {
 		gfs2_blockmap_set(ip->i_sbd, bl, block, gfs2_block_free);
 		return 0;
 	}
@@ -611,7 +610,7 @@ static int clear_leaf(struct gfs2_inode *ip, uint64_t block,
 		stack;
 		return -1;
 	}
-	if(!q.dup_block) {
+	if(!is_duplicate(block)) {
 		log_crit( _("Setting leaf #%" PRIu64 " (0x%" PRIx64 ") invalid\n"),
 				 block, block);
 		if(gfs2_blockmap_set(ip->i_sbd, bl, block, gfs2_block_free)) {
@@ -692,11 +691,7 @@ static int handle_di(struct gfs2_sbd *sdp, struct gfs2_buffer_head *bh,
 	if(q.block_type != gfs2_block_free) {
 		log_err( _("Found duplicate block referenced as an inode at "
 			   "#%" PRIu64 " (0x%" PRIx64 ")\n"), block, block);
-		if(gfs2_block_mark(sdp, bl, block, gfs2_dup_block)) {
-			stack;
-			fsck_inode_put(&ip);
-			return -1;
-		}
+		gfs2_dup_set(block);
 		fsck_inode_put(&ip);
 		return 0;
 	}
diff --git a/gfs2/fsck/pass1b.c b/gfs2/fsck/pass1b.c
index 26e8f63..a25e4da 100644
--- a/gfs2/fsck/pass1b.c
+++ b/gfs2/fsck/pass1b.c
@@ -28,7 +28,7 @@ struct fxn_info {
 };
 
 struct dup_handler {
-	struct dup_blocks *b;
+	struct dup_blks *b;
 	struct inode_with_dups *id;
 	int ref_inode_count;
 	int ref_count;
@@ -113,12 +113,12 @@ static int find_dentry(struct gfs2_inode *ip, struct gfs2_dirent *de,
 		       uint16_t *count, void *priv)
 {
 	osi_list_t *tmp1, *tmp2;
-	struct dup_blocks *b;
+	struct dup_blks *b;
 	struct inode_with_dups *id;
 	struct gfs2_leaf leaf;
 
-	osi_list_foreach(tmp1, &ip->i_sbd->dup_blocks.list) {
-		b = osi_list_entry(tmp1, struct dup_blocks, list);
+	osi_list_foreach(tmp1, &dup_blocks.list) {
+		b = osi_list_entry(tmp1, struct dup_blks, list);
 		osi_list_foreach(tmp2, &b->ref_inode_list) {
 			id = osi_list_entry(tmp2, struct inode_with_dups,
 					    list);
@@ -313,7 +313,7 @@ static int clear_eattr_extentry(struct gfs2_inode *ip, uint64_t *ea_data_ptr,
 }
 
 /* Finds all references to duplicate blocks in the metadata */
-static int find_block_ref(struct gfs2_sbd *sbp, uint64_t inode, struct dup_blocks *b)
+static int find_block_ref(struct gfs2_sbd *sbp, uint64_t inode, struct dup_blks *b)
 {
 	struct gfs2_inode *ip;
 	struct fxn_info myfi = {b->block_no, 0, 1};
@@ -367,7 +367,7 @@ static int find_block_ref(struct gfs2_sbd *sbp, uint64_t inode, struct dup_block
 	return 0;
 }
 
-static int handle_dup_blk(struct gfs2_sbd *sbp, struct dup_blocks *b)
+static int handle_dup_blk(struct gfs2_sbd *sbp, struct dup_blks *b)
 {
 	osi_list_t *tmp;
 	struct inode_with_dups *id;
@@ -492,7 +492,7 @@ static int handle_dup_blk(struct gfs2_sbd *sbp, struct dup_blocks *b)
  * use in pass2 */
 int pass1b(struct gfs2_sbd *sbp)
 {
-	struct dup_blocks *b;
+	struct dup_blks *b;
 	uint64_t i;
 	struct gfs2_block_query q;
 	osi_list_t *tmp = NULL, *x;
@@ -503,7 +503,7 @@ int pass1b(struct gfs2_sbd *sbp)
 	log_info( _("Looking for duplicate blocks...\n"));
 
 	/* If there were no dups in the bitmap, we don't need to do anymore */
-	if(osi_list_empty(&sbp->dup_blocks.list)) {
+	if(osi_list_empty(&dup_blocks.list)) {
 		log_info( _("No duplicate blocks found\n"));
 		return FSCK_OK;
 	}
@@ -531,8 +531,8 @@ int pass1b(struct gfs2_sbd *sbp)
 		   (q.block_type == gfs2_inode_chr) ||
 		   (q.block_type == gfs2_inode_fifo) ||
 		   (q.block_type == gfs2_inode_sock)) {
-			osi_list_foreach_safe(tmp, &sbp->dup_blocks.list, x) {
-				b = osi_list_entry(tmp, struct dup_blocks,
+			osi_list_foreach_safe(tmp, &dup_blocks.list, x) {
+				b = osi_list_entry(tmp, struct dup_blks,
 						   list);
 				if(find_block_ref(sbp, i, b)) {
 					stack;
@@ -550,8 +550,8 @@ int pass1b(struct gfs2_sbd *sbp)
 	 * it later */
 	log_info( _("Handling duplicate blocks\n"));
 out:
-        osi_list_foreach_safe(tmp, &sbp->dup_blocks.list, x) {
-                b = osi_list_entry(tmp, struct dup_blocks, list);
+        osi_list_foreach_safe(tmp, &dup_blocks.list, x) {
+                b = osi_list_entry(tmp, struct dup_blks, list);
 		if (!skip_this_pass && !rc) /* no error & not asked to skip the rest */
 			handle_dup_blk(sbp, b);
 	}
diff --git a/gfs2/fsck/pass2.c b/gfs2/fsck/pass2.c
index 4858c2f..7453e47 100644
--- a/gfs2/fsck/pass2.c
+++ b/gfs2/fsck/pass2.c
@@ -663,7 +663,7 @@ int pass2(struct gfs2_sbd *sbp)
 	int filename_len;
 	char tmp_name[256];
 	int error = 0;
-	struct dup_blocks *b;
+	struct dup_blks *b;
 
 	/* Check all the system directory inodes. */
 	if (check_system_dir(sbp->md.jiinode, "jindex", build_jindex)) {
@@ -809,9 +809,9 @@ int pass2(struct gfs2_sbd *sbp)
 	   deleting it from both inodes referencing it. Note: The other
 	   returns from this function are premature exits of the program
 	   and gfs2_block_list_destroy should get rid of the list for us. */
-	while (!osi_list_empty(&sbp->dup_blocks.list)) {
-		b = osi_list_entry(sbp->dup_blocks.list.next,
-				   struct dup_blocks, list);
+	while (!osi_list_empty(&dup_blocks.list)) {
+		b = osi_list_entry(dup_blocks.list.next,
+				   struct dup_blks, list);
 		osi_list_del(&b->list);
 		free(b);
 	}
diff --git a/gfs2/fsck/util.c b/gfs2/fsck/util.c
index 3159720..08eb831 100644
--- a/gfs2/fsck/util.c
+++ b/gfs2/fsck/util.c
@@ -10,6 +10,7 @@
 
 #include "libgfs2.h"
 #include "fs_bits.h"
+#include "metawalk.h"
 #include "util.h"
 
 void big_file_comfort(struct gfs2_inode *ip, uint64_t blks_checked)
@@ -149,3 +150,19 @@ int fsck_query(const char *format, ...)
 	opts.query = FALSE;
 	return ret;
 }
+
+void gfs2_dup_set(uint64_t block)
+{
+	struct dup_blks *b;
+
+	if (dupfind(block))
+		return;
+	b = malloc(sizeof(struct dup_blks));
+	if (b) {
+		memset(b, 0, sizeof(*b));
+		b->block_no = block;
+		osi_list_init(&b->ref_inode_list);
+		osi_list_add(&b->list, &dup_blocks.list);
+	}
+	return;
+}
diff --git a/gfs2/fsck/util.h b/gfs2/fsck/util.h
index fa18506..5e5f96e 100644
--- a/gfs2/fsck/util.h
+++ b/gfs2/fsck/util.h
@@ -10,5 +10,6 @@ struct di_info *search_list(osi_list_t *list, uint64_t addr);
 void big_file_comfort(struct gfs2_inode *ip, uint64_t blks_checked);
 void warm_fuzzy_stuff(uint64_t block);
 const char *block_type_string(struct gfs2_block_query *q);
+void gfs2_dup_set(uint64_t block);
 
 #endif /* __UTIL_H__ */
diff --git a/gfs2/libgfs2/block_list.c b/gfs2/libgfs2/block_list.c
index 31cc530..e76217b 100644
--- a/gfs2/libgfs2/block_list.c
+++ b/gfs2/libgfs2/block_list.c
@@ -8,14 +8,6 @@
 
 #include "libgfs2.h"
 
-/* Must be kept in sync with mark_block enum in libgfs2.h */
-static int mark_to_gbmap[16] = {
-	FREE, BLOCK_IN_USE, DIR_INDIR_BLK, DIR_INODE, FILE_INODE,
-	LNK_INODE, BLK_INODE, CHR_INODE, FIFO_INODE, SOCK_INODE,
-	DIR_LEAF_INODE, JOURNAL_BLK, OTHER_META, EATTR_META,
-	BAD_BLOCK, INVALID_META
-};
-
 static int gfs2_blockmap_create(struct gfs2_bmap *bmap, uint64_t size)
 {
 	bmap->size = size;
@@ -57,7 +49,6 @@ struct gfs2_bmap *gfs2_bmap_create(struct gfs2_sbd *sdp, uint64_t size,
 		free(il);
 		il = NULL;
 	}
-	osi_list_init(&sdp->dup_blocks.list);
 	osi_list_init(&sdp->eattr_blocks.list);
 	return il;
 }
@@ -74,19 +65,6 @@ void gfs2_special_free(struct special_blocks *blist)
 	}
 }
 
-static void gfs2_dup_free(struct dup_blocks *blist)
-{
-	struct dup_blocks *f;
-
-	while(!osi_list_empty(&blist->list)) {
-		f = osi_list_entry(blist->list.next, struct dup_blocks, list);
-		while (!osi_list_empty(&f->ref_inode_list))
-			osi_list_del(&f->ref_inode_list);
-		osi_list_del(&f->list);
-		free(f);
-	}
-}
-
 struct special_blocks *blockfind(struct special_blocks *blist, uint64_t num)
 {
 	osi_list_t *head = &blist->list;
@@ -101,20 +79,6 @@ struct special_blocks *blockfind(struct special_blocks *blist, uint64_t num)
 	return NULL;
 }
 
-static struct dup_blocks *dupfind(struct dup_blocks *blist, uint64_t num)
-{
-	osi_list_t *head = &blist->list;
-	osi_list_t *tmp;
-	struct dup_blocks *b;
-
-	for (tmp = head->next; tmp != head; tmp = tmp->next) {
-		b = osi_list_entry(tmp, struct dup_blocks, list);
-		if (b->block_no == num)
-			return b;
-	}
-	return NULL;
-}
-
 void gfs2_special_set(struct special_blocks *blocklist, uint64_t block)
 {
 	struct special_blocks *b;
@@ -130,33 +94,6 @@ void gfs2_special_set(struct special_blocks *blocklist, uint64_t block)
 	return;
 }
 
-static void gfs2_dup_set(struct dup_blocks *blocklist, uint64_t block)
-{
-	struct dup_blocks *b;
-
-	if (dupfind(blocklist, block))
-		return;
-	b = malloc(sizeof(struct dup_blocks));
-	if (b) {
-		memset(b, 0, sizeof(*b));
-		b->block_no = block;
-		osi_list_init(&b->ref_inode_list);
-		osi_list_add(&b->list, &blocklist->list);
-	}
-	return;
-}
-
-static void gfs2_dup_clear(struct dup_blocks *blocklist, uint64_t block)
-{
-	struct dup_blocks *b;
-
-	b = dupfind(blocklist, block);
-	if (b) {
-		osi_list_del(&b->list);
-		free(b);
-	}
-}
-
 void gfs2_special_clear(struct special_blocks *blocklist, uint64_t block)
 {
 	struct special_blocks *b;
@@ -168,39 +105,20 @@ void gfs2_special_clear(struct special_blocks *blocklist, uint64_t block)
 	}
 }
 
-int gfs2_block_mark(struct gfs2_sbd *sdp, struct gfs2_bmap *il,
-		    uint64_t block, enum gfs2_mark_block mark)
-{
-	int err = 0;
-
-	if(mark == gfs2_dup_block)
-		gfs2_dup_set(&sdp->dup_blocks, block);
-	else
-		err = gfs2_blockmap_set(sdp, il, block, mark_to_gbmap[mark]);
-	return err;
-}
-
 /* gfs2_block_unmark clears ONE mark for the given block */
 int gfs2_block_unmark(struct gfs2_sbd *sdp, struct gfs2_bmap *bmap,
 		      uint64_t block, enum gfs2_mark_block mark)
 {
-	int err = 0;
-
-	if (mark == gfs2_dup_block)
-		gfs2_dup_clear(&sdp->dup_blocks, block);
-	else {
-		static unsigned char *byte;
-		static uint64_t b;
+	static unsigned char *byte;
+	static uint64_t b;
 
-		if(block > bmap->size)
-			return -1;
+	if(block > bmap->size)
+		return -1;
 
-		byte = bmap->map + BLOCKMAP_SIZE4(block);
-		b = BLOCKMAP_BYTE_OFFSET4(block);
-		*byte &= ~(BLOCKMAP_MASK4 << b);
-		return 0;
-	}
-	return err;
+	byte = bmap->map + BLOCKMAP_SIZE4(block);
+	b = BLOCKMAP_BYTE_OFFSET4(block);
+	*byte &= ~(BLOCKMAP_MASK4 << b);
+	return 0;
 }
 
 int gfs2_blockmap_set(struct gfs2_sbd *sdp, struct gfs2_bmap *bmap,
@@ -228,7 +146,6 @@ int gfs2_block_check(struct gfs2_sbd *sdp, struct gfs2_bmap *il,
 	if(block >= il->size)
 		return -1;
 
-	val->dup_block = (dupfind(&sdp->dup_blocks, block) ? 1 : 0);
 	byte = il->map + BLOCKMAP_SIZE4(block);
 	b = BLOCKMAP_BYTE_OFFSET4(block);
 	val->block_type = (*byte & (BLOCKMAP_MASK4 << b )) >> b;
@@ -242,7 +159,6 @@ void *gfs2_bmap_destroy(struct gfs2_sbd *sdp, struct gfs2_bmap *il)
 		free(il);
 		il = NULL;
 	}
-	gfs2_dup_free(&sdp->dup_blocks);
 	gfs2_special_free(&sdp->eattr_blocks);
 	return il;
 }
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index 1d2d5e8..035193f 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -116,12 +116,6 @@ struct gfs2_buffer_head {
 	struct gfs2_sbd *sdp;
 };
 
-struct dup_blocks {
-	osi_list_t list;
-	uint64_t block_no;
-	osi_list_t ref_inode_list;
-};
-
 struct special_blocks {
 	osi_list_t list;
 	uint64_t block;
@@ -240,7 +234,6 @@ struct gfs2_sbd {
 	unsigned int writes;
 	int metafs_fd;
 	char metafs_path[PATH_MAX]; /* where metafs is mounted */
-	struct dup_blocks dup_blocks;
 	struct special_blocks eattr_blocks;
 };
 
@@ -305,12 +298,10 @@ enum gfs2_mark_block {
 	gfs2_meta_eattr = EATTR_META,
 	gfs2_bad_block = BAD_BLOCK, /* Contains at least one bad block */
 	gfs2_meta_inval = INVALID_META,
-	gfs2_dup_block,      /* Contains at least one duplicate block */
 };
 
 struct gfs2_block_query {
         uint8_t block_type;
-        uint8_t dup_block;
 };
 
 extern struct gfs2_bmap *gfs2_bmap_create(struct gfs2_sbd *sdp, uint64_t size,
@@ -322,8 +313,6 @@ extern int gfs2_blockmap_set(struct gfs2_sbd *sdp, struct gfs2_bmap *il,
 			  uint64_t block, enum gfs2_mark_block mark);
 extern void gfs2_special_clear(struct special_blocks *blocklist,
 			       uint64_t block);
-extern int gfs2_block_mark(struct gfs2_sbd *sdp, struct gfs2_bmap *il,
-			   uint64_t block, enum gfs2_mark_block mark);
 /* gfs2_block_unmark clears ONE mark for the given block */
 extern int gfs2_block_unmark(struct gfs2_sbd *sdp, struct gfs2_bmap *il,
 			     uint64_t block, enum gfs2_mark_block m);


More information about the cluster-commits mailing list