[Cluster-devel] [PATCH 15/32] gfs2_edit: Don't use gfs2_buffer_head in display_block_type()
Andrew Price
anprice at redhat.com
Thu Aug 6 13:37:50 UTC 2020
Signed-off-by: Andrew Price <anprice at redhat.com>
---
gfs2/edit/hexedit.c | 19 +++++++++----------
gfs2/edit/hexedit.h | 2 +-
gfs2/edit/savemeta.c | 4 ++--
3 files changed, 12 insertions(+), 13 deletions(-)
diff --git a/gfs2/edit/hexedit.c b/gfs2/edit/hexedit.c
index 357e790a..6019996d 100644
--- a/gfs2/edit/hexedit.c
+++ b/gfs2/edit/hexedit.c
@@ -298,12 +298,11 @@ const struct lgfs2_metadata *get_block_type(char *buf)
return NULL;
}
-/* ------------------------------------------------------------------------ */
-/* display_block_type */
-/* returns: metatype if block is a GFS2 structure block type */
-/* 0 if block is not a GFS2 structure */
-/* ------------------------------------------------------------------------ */
-int display_block_type(struct gfs2_buffer_head *dbh, int from_restore)
+/**
+ * returns: metatype if block is a GFS2 structure block type
+ * 0 if block is not a GFS2 structure
+ */
+int display_block_type(char *buf, uint64_t addr, int from_restore)
{
const struct lgfs2_metadata *mtype;
const struct gfs2_meta_header *mh;
@@ -324,7 +323,7 @@ int display_block_type(struct gfs2_buffer_head *dbh, int from_restore)
else if (block == JOURNALS_DUMMY_BLOCK)
print_gfs2("Journal Status: ");
else
- print_gfs2("%"PRIu64" (0x%"PRIx64")", dbh->b_blocknr, dbh->b_blocknr);
+ print_gfs2("%"PRIu64" (0x%"PRIx64")", addr, addr);
if (termlines) {
if (edit_row[dmode] == -1)
COLORS_NORMAL;
@@ -340,7 +339,7 @@ int display_block_type(struct gfs2_buffer_head *dbh, int from_restore)
ret_type = GFS2_METATYPE_DI;
struct_len = 0;
} else {
- mtype = get_block_type(dbh->b_data);
+ mtype = get_block_type(buf);
if (mtype != NULL) {
print_gfs2("(%s)", mtype->display);
struct_len = mtype->size;
@@ -350,7 +349,7 @@ int display_block_type(struct gfs2_buffer_head *dbh, int from_restore)
ret_type = 0;
}
}
- mh = dbh->iov.iov_base;
+ mh = (void *)buf;
eol(0);
if (from_restore)
return ret_type;
@@ -1035,7 +1034,7 @@ int display(int identify_only, int trunc_zeros, uint64_t flagref,
}
}
line = 1;
- gfs2_struct_type = display_block_type(bh, FALSE);
+ gfs2_struct_type = display_block_type(bh->b_data, bh->b_blocknr, FALSE);
if (identify_only)
return 0;
indirect_blocks = 0;
diff --git a/gfs2/edit/hexedit.h b/gfs2/edit/hexedit.h
index a73c150d..1c94c901 100644
--- a/gfs2/edit/hexedit.h
+++ b/gfs2/edit/hexedit.h
@@ -222,7 +222,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(struct gfs2_buffer_head *bh, int from_restore);
+extern int display_block_type(char *buf, uint64_t addr, 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, const char *buf);
extern void gfs_log_header_print(struct gfs_log_header *lh);
diff --git a/gfs2/edit/savemeta.c b/gfs2/edit/savemeta.c
index c42f2da0..f3c85b0d 100644
--- a/gfs2/edit/savemeta.c
+++ b/gfs2/edit/savemeta.c
@@ -1153,12 +1153,12 @@ static int restore_data(int fd, struct metafd *mfd, int printonly)
.b_blocknr = savedata.blk,
};
if (printonly > 1 && printonly == savedata.blk) {
- display_block_type(&dummy_bh, TRUE);
+ display_block_type(bp, savedata.blk, TRUE);
display_gfs2(&dummy_bh);
break;
} else if (printonly == 1) {
print_gfs2("%"PRId64" (l=0x%x): ", blks_saved, savedata.siglen);
- display_block_type(&dummy_bh, TRUE);
+ display_block_type(bp, savedata.blk, TRUE);
}
} else {
warm_fuzzy_stuff(savedata.blk, FALSE);
--
2.26.2
More information about the Cluster-devel
mailing list