[Cluster-devel] [PATCH 20/23] gfs2_edit: Don't use the global bh variable in display_block_type

Andrew Price anprice at redhat.com
Thu Feb 4 11:20:31 UTC 2016


Accept it as an argument instead.

Signed-off-by: Andrew Price <anprice at redhat.com>
---
 gfs2/edit/hexedit.c  | 13 ++++---------
 gfs2/edit/hexedit.h  |  2 +-
 gfs2/edit/savemeta.c |  2 +-
 3 files changed, 6 insertions(+), 11 deletions(-)

diff --git a/gfs2/edit/hexedit.c b/gfs2/edit/hexedit.c
index f732b96..07f179d 100644
--- a/gfs2/edit/hexedit.c
+++ b/gfs2/edit/hexedit.c
@@ -313,7 +313,7 @@ uint32_t get_block_type(const struct gfs2_buffer_head *lbh, int *structlen)
 /* returns: metatype if block is a GFS2 structure block type                */
 /*          0 if block is not a GFS2 structure                              */
 /* ------------------------------------------------------------------------ */
-int display_block_type(int from_restore)
+int display_block_type(struct gfs2_buffer_head *dbh, int from_restore)
 {
 	const struct gfs2_meta_header *mh;
 	int ret_type = 0; /* return type */
@@ -349,7 +349,7 @@ int display_block_type(int from_restore)
 		ret_type = GFS2_METATYPE_DI;
 		struct_len = 0;
 	} else {
-		ret_type = get_block_type(bh, &struct_len);
+		ret_type = get_block_type(dbh, &struct_len);
 		switch (ret_type) {
 		case GFS2_METATYPE_SB:   /* 1 */
 			print_gfs2("(superblock)");
@@ -398,9 +398,7 @@ int display_block_type(int from_restore)
 			break;
 		}
 	}
-	
-
-	mh = bh->iov.iov_base;
+	mh = dbh->iov.iov_base;
 	eol(0);
 	if (from_restore)
 		return ret_type;
@@ -1052,9 +1050,6 @@ static void read_master_dir(void)
 	memcpy(&masterdir, &indirect[0], sizeof(struct indirect_info));
 }
 
-/* ------------------------------------------------------------------------ */
-/* display                                                                  */
-/* ------------------------------------------------------------------------ */
 int display(int identify_only, int trunc_zeros, uint64_t flagref,
 	    uint64_t ref_blk)
 {
@@ -1090,7 +1085,7 @@ int display(int identify_only, int trunc_zeros, uint64_t flagref,
 		block_in_mem = blk; /* remember which block is in memory */
 	}
 	line = 1;
-	gfs2_struct_type = display_block_type(FALSE);
+	gfs2_struct_type = display_block_type(bh, FALSE);
 	if (identify_only)
 		return 0;
 	indirect_blocks = 0;
diff --git a/gfs2/edit/hexedit.h b/gfs2/edit/hexedit.h
index 1dd9965..15586d4 100644
--- a/gfs2/edit/hexedit.h
+++ b/gfs2/edit/hexedit.h
@@ -223,7 +223,7 @@ extern int block_is_inum_file(uint64_t blk);
 extern int block_is_statfs_file(uint64_t blk);
 extern int block_is_quota_file(uint64_t blk);
 extern int block_is_per_node(uint64_t blk);
-extern int display_block_type(int from_restore);
+extern int display_block_type(struct gfs2_buffer_head *bh, int from_restore);
 extern void gfs_jindex_in(struct gfs_jindex *jindex, char *buf);
 extern void gfs_log_header_in(struct gfs_log_header *head,
 			      struct gfs2_buffer_head *bh);
diff --git a/gfs2/edit/savemeta.c b/gfs2/edit/savemeta.c
index 17ad35d..e80b425 100644
--- a/gfs2/edit/savemeta.c
+++ b/gfs2/edit/savemeta.c
@@ -1087,7 +1087,7 @@ static int restore_data(int fd, gzFile gzin_fd, off_t pos, int printonly)
 				break;
 			} else if (printonly == 1) {
 				print_gfs2("%"PRId64" (l=0x%x): ", blks_saved, savedata->siglen);
-				display_block_type(TRUE);
+				display_block_type(&dummy_bh, TRUE);
 			}
 			bh = NULL;
 		} else {
-- 
2.4.3




More information about the Cluster-devel mailing list