cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
* [Cluster-devel] [PATCH 00/23] gfs2_edit: Code cleanups
@ 2016-02-04 11:20 Andrew Price
  2016-02-04 11:20 ` [Cluster-devel] [PATCH 01/23] gfs2_edit: Don't use the global block variable in block_is_a_journal Andrew Price
                   ` (22 more replies)
  0 siblings, 23 replies; 24+ messages in thread
From: Andrew Price @ 2016-02-04 11:20 UTC (permalink / raw)
  To: cluster-devel.redhat.com

This patch set removes some uses of global variables, mainly in savemeta.c, so that the code is easier to reason about and less fragile to changes. There are a bunch of patches here as the changes had to be done in reverse call chain order, but they're mostly small and simple.

Andrew Price (23):
  gfs2_edit: Don't use the global block variable in block_is_a_journal
  gfs2_edit: Don't use the global block variable in block_is_in_per_node
  gfs2_edit: Don't use the global block variable in block_is_jindex
  gfs2_edit: Don't use the global block variable in block_is_inum_file
  gfs2_edit: Don't use global block variable in block_is_statfs_file
  gfs2_edit: Don't use global block variable in block_is_quota_file
  gfs2_edit: Don't use global block variable in block_is_rindex
  gfs2_edit: Don't use the global block variable in block_is_per_node
  gfs2_edit: Don't use the global block variable in block_is_systemfile
  gfs2_edit: Don't use the global block variable in block_is_rgtree
  gfs2_edit: Don't use the global block variable in block_is_journals
  gfs2_edit: Only declare the block variable where needed
  gfs2_edit: Don't use the global block variable in save_block
  gfs2_edit: Don't use the global block variable in save_indirect_blocks
  gfs2_edit: Don't use the global block variable in save_inode_data
  gfs2_edit: Don't use the global block variable in get_gfs_struct_info
  gfs2_edit: Don't use the global block variable in save_ea_block
  gfs2_edit: Don't use the global block variable in save_allocated
  gfs2_edit: Don't use the global block variable in savemeta
  gfs2_edit: Don't use the global bh variable in display_block_type
  gfs2_edit: Don't use the global block variable in savemeta.c
  gfs2_edit: Don't export bh
  gfs2_edit: Remove block_in_mem and fix a memory leak

 gfs2/edit/extended.c |  16 +++---
 gfs2/edit/gfs2hex.c  |  34 ++++++-------
 gfs2/edit/gfs2hex.h  |   2 +-
 gfs2/edit/hexedit.c  |  91 +++++++++++++--------------------
 gfs2/edit/hexedit.h  |  25 ++++-----
 gfs2/edit/journal.c  |   2 +
 gfs2/edit/savemeta.c | 140 ++++++++++++++++++++++++++-------------------------
 7 files changed, 145 insertions(+), 165 deletions(-)

-- 
2.4.3



^ permalink raw reply	[flat|nested] 24+ messages in thread

* [Cluster-devel] [PATCH 01/23] gfs2_edit: Don't use the global block variable in block_is_a_journal
  2016-02-04 11:20 [Cluster-devel] [PATCH 00/23] gfs2_edit: Code cleanups Andrew Price
@ 2016-02-04 11:20 ` Andrew Price
  2016-02-04 11:20 ` [Cluster-devel] [PATCH 02/23] gfs2_edit: Don't use the global block variable in block_is_in_per_node Andrew Price
                   ` (21 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: Andrew Price @ 2016-02-04 11:20 UTC (permalink / raw)
  To: cluster-devel.redhat.com

Accept it as an argument instead.

Signed-off-by: Andrew Price <anprice@redhat.com>
---
 gfs2/edit/savemeta.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/gfs2/edit/savemeta.c b/gfs2/edit/savemeta.c
index 8ac035c..0dff85a 100644
--- a/gfs2/edit/savemeta.c
+++ b/gfs2/edit/savemeta.c
@@ -64,12 +64,12 @@ static int journals_found = 0;
 int print_level = MSG_NOTICE;
 extern char *device;
 
-static int block_is_a_journal(void)
+static int block_is_a_journal(uint64_t blk)
 {
 	int j;
 
 	for (j = 0; j < journals_found; j++)
-		if (block == journal_blocks[j])
+		if (blk == journal_blocks[j])
 			return TRUE;
 	return FALSE;
 }
@@ -168,7 +168,7 @@ static int block_is_systemfile(void)
 {
 	return block_is_jindex() || block_is_inum_file() ||
 		block_is_statfs_file() || block_is_quota_file() ||
-		block_is_rindex() || block_is_a_journal() ||
+		block_is_rindex() || block_is_a_journal(block) ||
 		block_is_per_node() || block_is_in_per_node();
 }
 
-- 
2.4.3



^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [Cluster-devel] [PATCH 02/23] gfs2_edit: Don't use the global block variable in block_is_in_per_node
  2016-02-04 11:20 [Cluster-devel] [PATCH 00/23] gfs2_edit: Code cleanups Andrew Price
  2016-02-04 11:20 ` [Cluster-devel] [PATCH 01/23] gfs2_edit: Don't use the global block variable in block_is_a_journal Andrew Price
@ 2016-02-04 11:20 ` Andrew Price
  2016-02-04 11:20 ` [Cluster-devel] [PATCH 03/23] gfs2_edit: Don't use the global block variable in block_is_jindex Andrew Price
                   ` (20 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: Andrew Price @ 2016-02-04 11:20 UTC (permalink / raw)
  To: cluster-devel.redhat.com

Accept it as an argument instead.

Signed-off-by: Andrew Price <anprice@redhat.com>
---
 gfs2/edit/savemeta.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/gfs2/edit/savemeta.c b/gfs2/edit/savemeta.c
index 0dff85a..196e2f4 100644
--- a/gfs2/edit/savemeta.c
+++ b/gfs2/edit/savemeta.c
@@ -92,14 +92,14 @@ static void destroy_per_node_lookup(void)
 	}
 }
 
-static int block_is_in_per_node(void)
+static int block_is_in_per_node(uint64_t blk)
 {
 	struct per_node_node *pnp = (struct per_node_node *)per_node_tree.osi_node;
 
 	while (pnp) {
-		if (block < pnp->block)
+		if (blk < pnp->block)
 			pnp = (struct per_node_node *)pnp->node.osi_left;
-		else if (block > pnp->block)
+		else if (blk > pnp->block)
 			pnp = (struct per_node_node *)pnp->node.osi_right;
 		else
 			return 1;
@@ -169,7 +169,7 @@ static int block_is_systemfile(void)
 	return block_is_jindex() || block_is_inum_file() ||
 		block_is_statfs_file() || block_is_quota_file() ||
 		block_is_rindex() || block_is_a_journal(block) ||
-		block_is_per_node() || block_is_in_per_node();
+		block_is_per_node() || block_is_in_per_node(block);
 }
 
 /**
-- 
2.4.3



^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [Cluster-devel] [PATCH 03/23] gfs2_edit: Don't use the global block variable in block_is_jindex
  2016-02-04 11:20 [Cluster-devel] [PATCH 00/23] gfs2_edit: Code cleanups Andrew Price
  2016-02-04 11:20 ` [Cluster-devel] [PATCH 01/23] gfs2_edit: Don't use the global block variable in block_is_a_journal Andrew Price
  2016-02-04 11:20 ` [Cluster-devel] [PATCH 02/23] gfs2_edit: Don't use the global block variable in block_is_in_per_node Andrew Price
@ 2016-02-04 11:20 ` Andrew Price
  2016-02-04 11:20 ` [Cluster-devel] [PATCH 04/23] gfs2_edit: Don't use the global block variable in block_is_inum_file Andrew Price
                   ` (19 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: Andrew Price @ 2016-02-04 11:20 UTC (permalink / raw)
  To: cluster-devel.redhat.com

Accept it as an argument instead.

Signed-off-by: Andrew Price <anprice@redhat.com>
---
 gfs2/edit/extended.c | 2 +-
 gfs2/edit/hexedit.c  | 9 +++------
 gfs2/edit/hexedit.h  | 2 +-
 gfs2/edit/savemeta.c | 2 +-
 4 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/gfs2/edit/extended.c b/gfs2/edit/extended.c
index c01427f..b9d77f8 100644
--- a/gfs2/edit/extended.c
+++ b/gfs2/edit/extended.c
@@ -684,7 +684,7 @@ int display_extended(void)
 		parse_rindex(tmp_inode, FALSE);
 		inode_put(&tmp_inode);
 		brelse(tmp_bh);
-	} else if (block_is_jindex()) {
+	} else if (block_is_jindex(block)) {
 		tmp_bh = bread(&sbd, block);
 		tmp_inode = lgfs2_inode_get(&sbd, tmp_bh);
 		if (tmp_inode == NULL)
diff --git a/gfs2/edit/hexedit.c b/gfs2/edit/hexedit.c
index 70406df..cf13304 100644
--- a/gfs2/edit/hexedit.c
+++ b/gfs2/edit/hexedit.c
@@ -890,12 +890,9 @@ int block_is_rindex(void)
 	return FALSE;
 }
 
-/* ------------------------------------------------------------------------ */
-/* block_is_jindex                                                          */
-/* ------------------------------------------------------------------------ */
-int block_is_jindex(void)
+int block_is_jindex(uint64_t blk)
 {
-	if ((sbd.gfs1 && block == sbd1->sb_jindex_di.no_addr))
+	if ((sbd.gfs1 && blk == sbd1->sb_jindex_di.no_addr))
 		return TRUE;
 	return FALSE;
 }
@@ -953,7 +950,7 @@ static int block_has_extended_info(void)
 	    block_is_rindex() ||
 	    block_is_rgtree() ||
 	    block_is_journals() ||
-	    block_is_jindex() ||
+	    block_is_jindex(block) ||
 	    block_is_inum_file() ||
 	    block_is_statfs_file() ||
 	    block_is_quota_file())
diff --git a/gfs2/edit/hexedit.h b/gfs2/edit/hexedit.h
index 3e9ff5f..745e026 100644
--- a/gfs2/edit/hexedit.h
+++ b/gfs2/edit/hexedit.h
@@ -218,7 +218,7 @@ void die(const char *fmt, ...)
 		} \
 	} while (0)
 
-extern int block_is_jindex(void);
+extern int block_is_jindex(uint64_t blk);
 extern int block_is_rindex(void);
 extern int block_is_inum_file(void);
 extern int block_is_statfs_file(void);
diff --git a/gfs2/edit/savemeta.c b/gfs2/edit/savemeta.c
index 196e2f4..dc2c3d7 100644
--- a/gfs2/edit/savemeta.c
+++ b/gfs2/edit/savemeta.c
@@ -166,7 +166,7 @@ static int init_per_node_lookup(void)
 
 static int block_is_systemfile(void)
 {
-	return block_is_jindex() || block_is_inum_file() ||
+	return block_is_jindex(block) || block_is_inum_file() ||
 		block_is_statfs_file() || block_is_quota_file() ||
 		block_is_rindex() || block_is_a_journal(block) ||
 		block_is_per_node() || block_is_in_per_node(block);
-- 
2.4.3



^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [Cluster-devel] [PATCH 04/23] gfs2_edit: Don't use the global block variable in block_is_inum_file
  2016-02-04 11:20 [Cluster-devel] [PATCH 00/23] gfs2_edit: Code cleanups Andrew Price
                   ` (2 preceding siblings ...)
  2016-02-04 11:20 ` [Cluster-devel] [PATCH 03/23] gfs2_edit: Don't use the global block variable in block_is_jindex Andrew Price
@ 2016-02-04 11:20 ` Andrew Price
  2016-02-04 11:20 ` [Cluster-devel] [PATCH 05/23] gfs2_edit: Don't use global block variable in block_is_statfs_file Andrew Price
                   ` (18 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: Andrew Price @ 2016-02-04 11:20 UTC (permalink / raw)
  To: cluster-devel.redhat.com

Accept it as an argument instead.

Signed-off-by: Andrew Price <anprice@redhat.com>
---
 gfs2/edit/extended.c | 2 +-
 gfs2/edit/hexedit.c  | 9 +++------
 gfs2/edit/hexedit.h  | 2 +-
 gfs2/edit/savemeta.c | 2 +-
 4 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/gfs2/edit/extended.c b/gfs2/edit/extended.c
index b9d77f8..8c7244b 100644
--- a/gfs2/edit/extended.c
+++ b/gfs2/edit/extended.c
@@ -693,7 +693,7 @@ int display_extended(void)
 		inode_put(&tmp_inode);
 		brelse(tmp_bh);
 	}
-	else if (block_is_inum_file()) {
+	else if (block_is_inum_file(block)) {
 		tmp_bh = bread(&sbd, block);
 		tmp_inode = lgfs2_inode_get(&sbd, tmp_bh);
 		if (tmp_inode == NULL)
diff --git a/gfs2/edit/hexedit.c b/gfs2/edit/hexedit.c
index cf13304..6125d04 100644
--- a/gfs2/edit/hexedit.c
+++ b/gfs2/edit/hexedit.c
@@ -897,12 +897,9 @@ int block_is_jindex(uint64_t blk)
 	return FALSE;
 }
 
-/* ------------------------------------------------------------------------ */
-/* block_is_inum_file                                                       */
-/* ------------------------------------------------------------------------ */
-int block_is_inum_file(void)
+int block_is_inum_file(uint64_t blk)
 {
-	if (!sbd.gfs1 && block == masterblock("inum"))
+	if (!sbd.gfs1 && blk == masterblock("inum"))
 		return TRUE;
 	return FALSE;
 }
@@ -951,7 +948,7 @@ static int block_has_extended_info(void)
 	    block_is_rgtree() ||
 	    block_is_journals() ||
 	    block_is_jindex(block) ||
-	    block_is_inum_file() ||
+	    block_is_inum_file(block) ||
 	    block_is_statfs_file() ||
 	    block_is_quota_file())
 		return TRUE;
diff --git a/gfs2/edit/hexedit.h b/gfs2/edit/hexedit.h
index 745e026..f229ed4 100644
--- a/gfs2/edit/hexedit.h
+++ b/gfs2/edit/hexedit.h
@@ -220,7 +220,7 @@ void die(const char *fmt, ...)
 
 extern int block_is_jindex(uint64_t blk);
 extern int block_is_rindex(void);
-extern int block_is_inum_file(void);
+extern int block_is_inum_file(uint64_t blk);
 extern int block_is_statfs_file(void);
 extern int block_is_quota_file(void);
 extern int block_is_per_node(void);
diff --git a/gfs2/edit/savemeta.c b/gfs2/edit/savemeta.c
index dc2c3d7..ab4fe0e 100644
--- a/gfs2/edit/savemeta.c
+++ b/gfs2/edit/savemeta.c
@@ -166,7 +166,7 @@ static int init_per_node_lookup(void)
 
 static int block_is_systemfile(void)
 {
-	return block_is_jindex(block) || block_is_inum_file() ||
+	return block_is_jindex(block) || block_is_inum_file(block) ||
 		block_is_statfs_file() || block_is_quota_file() ||
 		block_is_rindex() || block_is_a_journal(block) ||
 		block_is_per_node() || block_is_in_per_node(block);
-- 
2.4.3



^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [Cluster-devel] [PATCH 05/23] gfs2_edit: Don't use global block variable in block_is_statfs_file
  2016-02-04 11:20 [Cluster-devel] [PATCH 00/23] gfs2_edit: Code cleanups Andrew Price
                   ` (3 preceding siblings ...)
  2016-02-04 11:20 ` [Cluster-devel] [PATCH 04/23] gfs2_edit: Don't use the global block variable in block_is_inum_file Andrew Price
@ 2016-02-04 11:20 ` Andrew Price
  2016-02-04 11:20 ` [Cluster-devel] [PATCH 06/23] gfs2_edit: Don't use global block variable in block_is_quota_file Andrew Price
                   ` (17 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: Andrew Price @ 2016-02-04 11:20 UTC (permalink / raw)
  To: cluster-devel.redhat.com

Accept it as an argument instead.

Signed-off-by: Andrew Price <anprice@redhat.com>
---
 gfs2/edit/extended.c |  2 +-
 gfs2/edit/hexedit.c  | 11 ++++-------
 gfs2/edit/hexedit.h  |  2 +-
 gfs2/edit/savemeta.c |  2 +-
 4 files changed, 7 insertions(+), 10 deletions(-)

diff --git a/gfs2/edit/extended.c b/gfs2/edit/extended.c
index 8c7244b..3d24845 100644
--- a/gfs2/edit/extended.c
+++ b/gfs2/edit/extended.c
@@ -702,7 +702,7 @@ int display_extended(void)
 		inode_put(&tmp_inode);
 		brelse(tmp_bh);
 	}
-	else if (block_is_statfs_file()) {
+	else if (block_is_statfs_file(block)) {
 		tmp_bh = bread(&sbd, block);
 		tmp_inode = lgfs2_inode_get(&sbd, tmp_bh);
 		if (tmp_inode == NULL)
diff --git a/gfs2/edit/hexedit.c b/gfs2/edit/hexedit.c
index 6125d04..5a212dd 100644
--- a/gfs2/edit/hexedit.c
+++ b/gfs2/edit/hexedit.c
@@ -904,14 +904,11 @@ int block_is_inum_file(uint64_t blk)
 	return FALSE;
 }
 
-/* ------------------------------------------------------------------------ */
-/* block_is_statfs_file                                                     */
-/* ------------------------------------------------------------------------ */
-int block_is_statfs_file(void)
+int block_is_statfs_file(uint64_t blk)
 {
-	if (sbd.gfs1 && block == gfs1_license_di.no_addr)
+	if (sbd.gfs1 && blk == gfs1_license_di.no_addr)
 		return TRUE;
-	if (!sbd.gfs1 && block == masterblock("statfs"))
+	if (!sbd.gfs1 && blk == masterblock("statfs"))
 		return TRUE;
 	return FALSE;
 }
@@ -949,7 +946,7 @@ static int block_has_extended_info(void)
 	    block_is_journals() ||
 	    block_is_jindex(block) ||
 	    block_is_inum_file(block) ||
-	    block_is_statfs_file() ||
+	    block_is_statfs_file(block) ||
 	    block_is_quota_file())
 		return TRUE;
 	return FALSE;
diff --git a/gfs2/edit/hexedit.h b/gfs2/edit/hexedit.h
index f229ed4..f959d31 100644
--- a/gfs2/edit/hexedit.h
+++ b/gfs2/edit/hexedit.h
@@ -221,7 +221,7 @@ void die(const char *fmt, ...)
 extern int block_is_jindex(uint64_t blk);
 extern int block_is_rindex(void);
 extern int block_is_inum_file(uint64_t blk);
-extern int block_is_statfs_file(void);
+extern int block_is_statfs_file(uint64_t blk);
 extern int block_is_quota_file(void);
 extern int block_is_per_node(void);
 extern int display_block_type(int from_restore);
diff --git a/gfs2/edit/savemeta.c b/gfs2/edit/savemeta.c
index ab4fe0e..c659cbc 100644
--- a/gfs2/edit/savemeta.c
+++ b/gfs2/edit/savemeta.c
@@ -167,7 +167,7 @@ static int init_per_node_lookup(void)
 static int block_is_systemfile(void)
 {
 	return block_is_jindex(block) || block_is_inum_file(block) ||
-		block_is_statfs_file() || block_is_quota_file() ||
+		block_is_statfs_file(block) || block_is_quota_file() ||
 		block_is_rindex() || block_is_a_journal(block) ||
 		block_is_per_node() || block_is_in_per_node(block);
 }
-- 
2.4.3



^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [Cluster-devel] [PATCH 06/23] gfs2_edit: Don't use global block variable in block_is_quota_file
  2016-02-04 11:20 [Cluster-devel] [PATCH 00/23] gfs2_edit: Code cleanups Andrew Price
                   ` (4 preceding siblings ...)
  2016-02-04 11:20 ` [Cluster-devel] [PATCH 05/23] gfs2_edit: Don't use global block variable in block_is_statfs_file Andrew Price
@ 2016-02-04 11:20 ` Andrew Price
  2016-02-04 11:20 ` [Cluster-devel] [PATCH 07/23] gfs2_edit: Don't use global block variable in block_is_rindex Andrew Price
                   ` (16 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: Andrew Price @ 2016-02-04 11:20 UTC (permalink / raw)
  To: cluster-devel.redhat.com

Accept it as an argument instead.

Signed-off-by: Andrew Price <anprice@redhat.com>
---
 gfs2/edit/extended.c |  2 +-
 gfs2/edit/hexedit.c  | 11 ++++-------
 gfs2/edit/hexedit.h  |  2 +-
 gfs2/edit/savemeta.c |  2 +-
 4 files changed, 7 insertions(+), 10 deletions(-)

diff --git a/gfs2/edit/extended.c b/gfs2/edit/extended.c
index 3d24845..db2c546 100644
--- a/gfs2/edit/extended.c
+++ b/gfs2/edit/extended.c
@@ -711,7 +711,7 @@ int display_extended(void)
 		inode_put(&tmp_inode);
 		brelse(tmp_bh);
 	}
-	else if (block_is_quota_file()) {
+	else if (block_is_quota_file(block)) {
 		tmp_bh = bread(&sbd, block);
 		tmp_inode = lgfs2_inode_get(&sbd, tmp_bh);
 		if (tmp_inode == NULL)
diff --git a/gfs2/edit/hexedit.c b/gfs2/edit/hexedit.c
index 5a212dd..3ce0987 100644
--- a/gfs2/edit/hexedit.c
+++ b/gfs2/edit/hexedit.c
@@ -913,14 +913,11 @@ int block_is_statfs_file(uint64_t blk)
 	return FALSE;
 }
 
-/* ------------------------------------------------------------------------ */
-/* block_is_quota_file                                                      */
-/* ------------------------------------------------------------------------ */
-int block_is_quota_file(void)
+int block_is_quota_file(uint64_t blk)
 {
-	if (sbd.gfs1 && block == gfs1_quota_di.no_addr)
+	if (sbd.gfs1 && blk == gfs1_quota_di.no_addr)
 		return TRUE;
-	if (!sbd.gfs1 && block == masterblock("quota"))
+	if (!sbd.gfs1 && blk == masterblock("quota"))
 		return TRUE;
 	return FALSE;
 }
@@ -947,7 +944,7 @@ static int block_has_extended_info(void)
 	    block_is_jindex(block) ||
 	    block_is_inum_file(block) ||
 	    block_is_statfs_file(block) ||
-	    block_is_quota_file())
+	    block_is_quota_file(block))
 		return TRUE;
 	return FALSE;
 }
diff --git a/gfs2/edit/hexedit.h b/gfs2/edit/hexedit.h
index f959d31..b488262 100644
--- a/gfs2/edit/hexedit.h
+++ b/gfs2/edit/hexedit.h
@@ -222,7 +222,7 @@ extern int block_is_jindex(uint64_t blk);
 extern int block_is_rindex(void);
 extern int block_is_inum_file(uint64_t blk);
 extern int block_is_statfs_file(uint64_t blk);
-extern int block_is_quota_file(void);
+extern int block_is_quota_file(uint64_t blk);
 extern int block_is_per_node(void);
 extern int display_block_type(int from_restore);
 extern void gfs_jindex_in(struct gfs_jindex *jindex, char *buf);
diff --git a/gfs2/edit/savemeta.c b/gfs2/edit/savemeta.c
index c659cbc..079677e 100644
--- a/gfs2/edit/savemeta.c
+++ b/gfs2/edit/savemeta.c
@@ -167,7 +167,7 @@ static int init_per_node_lookup(void)
 static int block_is_systemfile(void)
 {
 	return block_is_jindex(block) || block_is_inum_file(block) ||
-		block_is_statfs_file(block) || block_is_quota_file() ||
+		block_is_statfs_file(block) || block_is_quota_file(block) ||
 		block_is_rindex() || block_is_a_journal(block) ||
 		block_is_per_node() || block_is_in_per_node(block);
 }
-- 
2.4.3



^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [Cluster-devel] [PATCH 07/23] gfs2_edit: Don't use global block variable in block_is_rindex
  2016-02-04 11:20 [Cluster-devel] [PATCH 00/23] gfs2_edit: Code cleanups Andrew Price
                   ` (5 preceding siblings ...)
  2016-02-04 11:20 ` [Cluster-devel] [PATCH 06/23] gfs2_edit: Don't use global block variable in block_is_quota_file Andrew Price
@ 2016-02-04 11:20 ` Andrew Price
  2016-02-04 11:20 ` [Cluster-devel] [PATCH 08/23] gfs2_edit: Don't use the global block variable in block_is_per_node Andrew Price
                   ` (15 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: Andrew Price @ 2016-02-04 11:20 UTC (permalink / raw)
  To: cluster-devel.redhat.com

Accept it as an argument instead.

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

diff --git a/gfs2/edit/extended.c b/gfs2/edit/extended.c
index db2c546..a8a71e7 100644
--- a/gfs2/edit/extended.c
+++ b/gfs2/edit/extended.c
@@ -654,7 +654,7 @@ int display_extended(void)
 
 	dsplines = termlines - line - 1;
 	/* Display any indirect pointers that we have. */
-	if (block_is_rindex()) {
+	if (block_is_rindex(block)) {
 		tmp_bh = bread(&sbd, block);
 		tmp_inode = lgfs2_inode_get(&sbd, tmp_bh);
 		if (tmp_inode == NULL)
diff --git a/gfs2/edit/hexedit.c b/gfs2/edit/hexedit.c
index 3ce0987..7c85ca8 100644
--- a/gfs2/edit/hexedit.c
+++ b/gfs2/edit/hexedit.c
@@ -879,13 +879,10 @@ int has_indirect_blocks(void)
 	return FALSE;
 }
 
-/* ------------------------------------------------------------------------ */
-/* block_is_rindex                                                          */
-/* ------------------------------------------------------------------------ */
-int block_is_rindex(void)
+int block_is_rindex(uint64_t blk)
 {
-	if ((sbd.gfs1 && block == sbd1->sb_rindex_di.no_addr) ||
-	    (block == masterblock("rindex")))
+	if ((sbd.gfs1 && blk == sbd1->sb_rindex_di.no_addr) ||
+	    (blk == masterblock("rindex")))
 		return TRUE;
 	return FALSE;
 }
@@ -938,7 +935,7 @@ int block_is_per_node(void)
 static int block_has_extended_info(void)
 {
 	if (has_indirect_blocks() ||
-	    block_is_rindex() ||
+	    block_is_rindex(block) ||
 	    block_is_rgtree() ||
 	    block_is_journals() ||
 	    block_is_jindex(block) ||
@@ -1187,7 +1184,7 @@ static void push_block(uint64_t blk)
 			blockstack[bhst].lines_per_row[i] = lines_per_row[i];
 		}
 		blockstack[bhst].gfs2_struct_type = gfs2_struct_type;
-		if (edit_row[dmode] >= 0 && !block_is_rindex())
+		if (edit_row[dmode] >= 0 && !block_is_rindex(block))
 			memcpy(&blockstack[bhst].mp,
 			       &indirect->ii[edit_row[dmode]].mp,
 			       sizeof(struct metapath));
diff --git a/gfs2/edit/hexedit.h b/gfs2/edit/hexedit.h
index b488262..9607523 100644
--- a/gfs2/edit/hexedit.h
+++ b/gfs2/edit/hexedit.h
@@ -219,7 +219,7 @@ void die(const char *fmt, ...)
 	} while (0)
 
 extern int block_is_jindex(uint64_t blk);
-extern int block_is_rindex(void);
+extern int block_is_rindex(uint64_t blk);
 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);
diff --git a/gfs2/edit/savemeta.c b/gfs2/edit/savemeta.c
index 079677e..4483e4e 100644
--- a/gfs2/edit/savemeta.c
+++ b/gfs2/edit/savemeta.c
@@ -168,7 +168,7 @@ static int block_is_systemfile(void)
 {
 	return block_is_jindex(block) || block_is_inum_file(block) ||
 		block_is_statfs_file(block) || block_is_quota_file(block) ||
-		block_is_rindex() || block_is_a_journal(block) ||
+		block_is_rindex(block) || block_is_a_journal(block) ||
 		block_is_per_node() || block_is_in_per_node(block);
 }
 
-- 
2.4.3



^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [Cluster-devel] [PATCH 08/23] gfs2_edit: Don't use the global block variable in block_is_per_node
  2016-02-04 11:20 [Cluster-devel] [PATCH 00/23] gfs2_edit: Code cleanups Andrew Price
                   ` (6 preceding siblings ...)
  2016-02-04 11:20 ` [Cluster-devel] [PATCH 07/23] gfs2_edit: Don't use global block variable in block_is_rindex Andrew Price
@ 2016-02-04 11:20 ` Andrew Price
  2016-02-04 11:20 ` [Cluster-devel] [PATCH 09/23] gfs2_edit: Don't use the global block variable in block_is_systemfile Andrew Price
                   ` (14 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: Andrew Price @ 2016-02-04 11:20 UTC (permalink / raw)
  To: cluster-devel.redhat.com

Accept it as an argument instead.

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

diff --git a/gfs2/edit/hexedit.c b/gfs2/edit/hexedit.c
index 7c85ca8..981c02c 100644
--- a/gfs2/edit/hexedit.c
+++ b/gfs2/edit/hexedit.c
@@ -919,12 +919,9 @@ int block_is_quota_file(uint64_t blk)
 	return FALSE;
 }
 
-/* ------------------------------------------------------------------------ */
-/* block_is_per_node                                                        */
-/* ------------------------------------------------------------------------ */
-int block_is_per_node(void)
+int block_is_per_node(uint64_t blk)
 {
-	if (!sbd.gfs1 && block == masterblock("per_node"))
+	if (!sbd.gfs1 && blk == masterblock("per_node"))
 		return TRUE;
 	return FALSE;
 }
diff --git a/gfs2/edit/hexedit.h b/gfs2/edit/hexedit.h
index 9607523..f1f7667 100644
--- a/gfs2/edit/hexedit.h
+++ b/gfs2/edit/hexedit.h
@@ -223,7 +223,7 @@ extern int block_is_rindex(uint64_t blk);
 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(void);
+extern int block_is_per_node(uint64_t blk);
 extern int display_block_type(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,
diff --git a/gfs2/edit/savemeta.c b/gfs2/edit/savemeta.c
index 4483e4e..1899d9a 100644
--- a/gfs2/edit/savemeta.c
+++ b/gfs2/edit/savemeta.c
@@ -169,7 +169,7 @@ static int block_is_systemfile(void)
 	return block_is_jindex(block) || block_is_inum_file(block) ||
 		block_is_statfs_file(block) || block_is_quota_file(block) ||
 		block_is_rindex(block) || block_is_a_journal(block) ||
-		block_is_per_node() || block_is_in_per_node(block);
+		block_is_per_node(block) || block_is_in_per_node(block);
 }
 
 /**
-- 
2.4.3



^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [Cluster-devel] [PATCH 09/23] gfs2_edit: Don't use the global block variable in block_is_systemfile
  2016-02-04 11:20 [Cluster-devel] [PATCH 00/23] gfs2_edit: Code cleanups Andrew Price
                   ` (7 preceding siblings ...)
  2016-02-04 11:20 ` [Cluster-devel] [PATCH 08/23] gfs2_edit: Don't use the global block variable in block_is_per_node Andrew Price
@ 2016-02-04 11:20 ` Andrew Price
  2016-02-04 11:20 ` [Cluster-devel] [PATCH 10/23] gfs2_edit: Don't use the global block variable in block_is_rgtree Andrew Price
                   ` (13 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: Andrew Price @ 2016-02-04 11:20 UTC (permalink / raw)
  To: cluster-devel.redhat.com

Accept it as an argument instead.

Signed-off-by: Andrew Price <anprice@redhat.com>
---
 gfs2/edit/savemeta.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/gfs2/edit/savemeta.c b/gfs2/edit/savemeta.c
index 1899d9a..157a83b 100644
--- a/gfs2/edit/savemeta.c
+++ b/gfs2/edit/savemeta.c
@@ -164,12 +164,12 @@ static int init_per_node_lookup(void)
 	return 0;
 }
 
-static int block_is_systemfile(void)
+static int block_is_systemfile(uint64_t blk)
 {
-	return block_is_jindex(block) || block_is_inum_file(block) ||
-		block_is_statfs_file(block) || block_is_quota_file(block) ||
-		block_is_rindex(block) || block_is_a_journal(block) ||
-		block_is_per_node(block) || block_is_in_per_node(block);
+	return block_is_jindex(blk) || block_is_inum_file(blk) ||
+		block_is_statfs_file(blk) || block_is_quota_file(blk) ||
+		block_is_rindex(blk) || block_is_a_journal(blk) ||
+		block_is_per_node(blk) || block_is_in_per_node(blk);
 }
 
 /**
@@ -238,7 +238,7 @@ static int get_gfs_struct_info(struct gfs2_buffer_head *lbh, int *block_type,
 		if (S_ISDIR(inode->i_di.di_mode) ||
 		     (sbd.gfs1 && inode->i_di.__pad1 == GFS_FILE_DIR))
 			*gstruct_len = sbd.bsize;
-		else if (!inode->i_di.di_height && !block_is_systemfile() &&
+		else if (!inode->i_di.di_height && !block_is_systemfile(block) &&
 			 !S_ISDIR(inode->i_di.di_mode))
 			*gstruct_len = sizeof(struct gfs2_dinode);
 		else
@@ -425,7 +425,7 @@ static int save_block(int fd, struct metafd *mfd, uint64_t blk)
 	   inode, not the block within the inode "blk". They may or may not
 	   be the same thing. */
 	if (get_gfs_struct_info(savebh, &blktype, &blklen) &&
-	    !block_is_systemfile()) {
+	    !block_is_systemfile(block)) {
 		brelse(savebh);
 		return 0; /* Not metadata, and not system file, so skip it */
 	}
@@ -576,7 +576,7 @@ static void save_inode_data(struct metafd *mfd)
 	     (sbd.gfs1 && inode->i_di.__pad1 == GFS_FILE_DIR)))
 		height++;
 	else if (height && !(inode->i_di.di_flags & GFS2_DIF_SYSTEM) &&
-		 !block_is_systemfile() && !S_ISDIR(inode->i_di.di_mode))
+		 !block_is_systemfile(block) && !S_ISDIR(inode->i_di.di_mode))
 		height--;
 	osi_list_add(&metabh->b_altlist, &metalist[0]);
         for (i = 1; i <= height; i++){
-- 
2.4.3



^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [Cluster-devel] [PATCH 10/23] gfs2_edit: Don't use the global block variable in block_is_rgtree
  2016-02-04 11:20 [Cluster-devel] [PATCH 00/23] gfs2_edit: Code cleanups Andrew Price
                   ` (8 preceding siblings ...)
  2016-02-04 11:20 ` [Cluster-devel] [PATCH 09/23] gfs2_edit: Don't use the global block variable in block_is_systemfile Andrew Price
@ 2016-02-04 11:20 ` Andrew Price
  2016-02-04 11:20 ` [Cluster-devel] [PATCH 11/23] gfs2_edit: Don't use the global block variable in block_is_journals Andrew Price
                   ` (12 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: Andrew Price @ 2016-02-04 11:20 UTC (permalink / raw)
  To: cluster-devel.redhat.com

Accept it as an argument instead.

Signed-off-by: Andrew Price <anprice@redhat.com>
---
 gfs2/edit/extended.c | 2 +-
 gfs2/edit/hexedit.c  | 2 +-
 gfs2/edit/hexedit.h  | 4 ++--
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/gfs2/edit/extended.c b/gfs2/edit/extended.c
index a8a71e7..ced2412 100644
--- a/gfs2/edit/extended.c
+++ b/gfs2/edit/extended.c
@@ -673,7 +673,7 @@ int display_extended(void)
 		return -1;
 	else if (display_indirect(indirect, indirect_blocks, 0, 0) == 0)
 		return -1;
-	else if (block_is_rgtree()) {
+	else if (block_is_rgtree(block)) {
 		if (sbd.gfs1)
 			tmp_bh = bread(&sbd, sbd1->sb_rindex_di.no_addr);
 		else
diff --git a/gfs2/edit/hexedit.c b/gfs2/edit/hexedit.c
index 981c02c..b4123a1 100644
--- a/gfs2/edit/hexedit.c
+++ b/gfs2/edit/hexedit.c
@@ -933,7 +933,7 @@ static int block_has_extended_info(void)
 {
 	if (has_indirect_blocks() ||
 	    block_is_rindex(block) ||
-	    block_is_rgtree() ||
+	    block_is_rgtree(block) ||
 	    block_is_journals() ||
 	    block_is_jindex(block) ||
 	    block_is_inum_file(block) ||
diff --git a/gfs2/edit/hexedit.h b/gfs2/edit/hexedit.h
index f1f7667..1f97631 100644
--- a/gfs2/edit/hexedit.h
+++ b/gfs2/edit/hexedit.h
@@ -114,9 +114,9 @@ extern enum dsp_mode dmode;
 /*                   special case meant to parse the rindex and follow the  */
 /*                   blocks to the real rgs.                                */
 /* ------------------------------------------------------------------------ */
-static inline int block_is_rgtree(void)
+static inline int block_is_rgtree(uint64_t blk)
 {
-	if (block == RGLIST_DUMMY_BLOCK)
+	if (blk == RGLIST_DUMMY_BLOCK)
 		return TRUE;
 	return FALSE;
 }
-- 
2.4.3



^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [Cluster-devel] [PATCH 11/23] gfs2_edit: Don't use the global block variable in block_is_journals
  2016-02-04 11:20 [Cluster-devel] [PATCH 00/23] gfs2_edit: Code cleanups Andrew Price
                   ` (9 preceding siblings ...)
  2016-02-04 11:20 ` [Cluster-devel] [PATCH 10/23] gfs2_edit: Don't use the global block variable in block_is_rgtree Andrew Price
@ 2016-02-04 11:20 ` Andrew Price
  2016-02-04 11:20 ` [Cluster-devel] [PATCH 12/23] gfs2_edit: Only declare the block variable where needed Andrew Price
                   ` (11 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: Andrew Price @ 2016-02-04 11:20 UTC (permalink / raw)
  To: cluster-devel.redhat.com

Accept it as an argument instead.

Signed-off-by: Andrew Price <anprice@redhat.com>
---
 gfs2/edit/extended.c | 2 +-
 gfs2/edit/hexedit.c  | 2 +-
 gfs2/edit/hexedit.h  | 4 ++--
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/gfs2/edit/extended.c b/gfs2/edit/extended.c
index ced2412..7a517bf 100644
--- a/gfs2/edit/extended.c
+++ b/gfs2/edit/extended.c
@@ -662,7 +662,7 @@ int display_extended(void)
 		parse_rindex(tmp_inode, TRUE);
 		inode_put(&tmp_inode);
 		brelse(tmp_bh);
-	} else if (block_is_journals()) {
+	} else if (block_is_journals(block)) {
 		if (sbd.gfs1)
 			block = sbd1->sb_jindex_di.no_addr;
 		else
diff --git a/gfs2/edit/hexedit.c b/gfs2/edit/hexedit.c
index b4123a1..12deb13 100644
--- a/gfs2/edit/hexedit.c
+++ b/gfs2/edit/hexedit.c
@@ -934,7 +934,7 @@ static int block_has_extended_info(void)
 	if (has_indirect_blocks() ||
 	    block_is_rindex(block) ||
 	    block_is_rgtree(block) ||
-	    block_is_journals() ||
+	    block_is_journals(block) ||
 	    block_is_jindex(block) ||
 	    block_is_inum_file(block) ||
 	    block_is_statfs_file(block) ||
diff --git a/gfs2/edit/hexedit.h b/gfs2/edit/hexedit.h
index 1f97631..ab4b41b 100644
--- a/gfs2/edit/hexedit.h
+++ b/gfs2/edit/hexedit.h
@@ -121,9 +121,9 @@ static inline int block_is_rgtree(uint64_t blk)
 	return FALSE;
 }
 
-static inline int block_is_journals(void)
+static inline int block_is_journals(uint64_t blk)
 {
-	if (block == JOURNALS_DUMMY_BLOCK)
+	if (blk == JOURNALS_DUMMY_BLOCK)
 		return TRUE;
 	return FALSE;
 }
-- 
2.4.3



^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [Cluster-devel] [PATCH 12/23] gfs2_edit: Only declare the block variable where needed
  2016-02-04 11:20 [Cluster-devel] [PATCH 00/23] gfs2_edit: Code cleanups Andrew Price
                   ` (10 preceding siblings ...)
  2016-02-04 11:20 ` [Cluster-devel] [PATCH 11/23] gfs2_edit: Don't use the global block variable in block_is_journals Andrew Price
@ 2016-02-04 11:20 ` Andrew Price
  2016-02-04 11:20 ` [Cluster-devel] [PATCH 13/23] gfs2_edit: Don't use the global block variable in save_block Andrew Price
                   ` (10 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: Andrew Price @ 2016-02-04 11:20 UTC (permalink / raw)
  To: cluster-devel.redhat.com

This will help in removing it.

Signed-off-by: Andrew Price <anprice@redhat.com>
---
 gfs2/edit/extended.c | 2 ++
 gfs2/edit/hexedit.c  | 1 +
 gfs2/edit/hexedit.h  | 1 -
 gfs2/edit/journal.c  | 2 ++
 gfs2/edit/savemeta.c | 2 ++
 5 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/gfs2/edit/extended.c b/gfs2/edit/extended.c
index 7a517bf..e804853 100644
--- a/gfs2/edit/extended.c
+++ b/gfs2/edit/extended.c
@@ -27,6 +27,8 @@
 #include "extended.h"
 #include "gfs2hex.h"
 
+extern uint64_t block;
+
 static void print_block_details(struct iinfo *ind, int level, int cur_height,
 				int pndx, uint64_t file_offset);
 
diff --git a/gfs2/edit/hexedit.c b/gfs2/edit/hexedit.c
index 12deb13..f732b96 100644
--- a/gfs2/edit/hexedit.c
+++ b/gfs2/edit/hexedit.c
@@ -45,6 +45,7 @@ int details = 0;
 long int gziplevel = 9;
 static int termcols;
 char *device = NULL;
+extern uint64_t block;
 
 /* ------------------------------------------------------------------------- */
 /* erase - clear the screen */
diff --git a/gfs2/edit/hexedit.h b/gfs2/edit/hexedit.h
index ab4b41b..1dd9965 100644
--- a/gfs2/edit/hexedit.h
+++ b/gfs2/edit/hexedit.h
@@ -29,7 +29,6 @@ enum dsp_mode { HEX_MODE = 0, GFS2_MODE = 1, EXTENDED_MODE = 2, INIT_MODE = 3 };
 
 extern const char *mtypes[];
 extern struct gfs2_sb sb;
-extern uint64_t block;
 extern int blockhist;
 extern int edit_mode;
 extern int line;
diff --git a/gfs2/edit/journal.c b/gfs2/edit/journal.c
index 80c8738..ff0c6df 100644
--- a/gfs2/edit/journal.c
+++ b/gfs2/edit/journal.c
@@ -28,6 +28,8 @@
 #include "gfs2hex.h"
 #include "journal.h"
 
+extern uint64_t block;
+
 /**
  * find_journal_block - figure out where a journal starts, given the name
  * Returns: journal block number, changes j_size to the journal size
diff --git a/gfs2/edit/savemeta.c b/gfs2/edit/savemeta.c
index 157a83b..2d001e9 100644
--- a/gfs2/edit/savemeta.c
+++ b/gfs2/edit/savemeta.c
@@ -27,6 +27,8 @@
 #include "hexedit.h"
 #include "libgfs2.h"
 
+extern uint64_t block;
+
 #define DFT_SAVE_FILE "/tmp/gfsmeta.XXXXXX"
 #define MAX_JOURNALS_SAVED 256
 
-- 
2.4.3



^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [Cluster-devel] [PATCH 13/23] gfs2_edit: Don't use the global block variable in save_block
  2016-02-04 11:20 [Cluster-devel] [PATCH 00/23] gfs2_edit: Code cleanups Andrew Price
                   ` (11 preceding siblings ...)
  2016-02-04 11:20 ` [Cluster-devel] [PATCH 12/23] gfs2_edit: Only declare the block variable where needed Andrew Price
@ 2016-02-04 11:20 ` Andrew Price
  2016-02-04 11:20 ` [Cluster-devel] [PATCH 14/23] gfs2_edit: Don't use the global block variable in save_indirect_blocks Andrew Price
                   ` (9 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: Andrew Price @ 2016-02-04 11:20 UTC (permalink / raw)
  To: cluster-devel.redhat.com

Accept the block's owner's address as an argument instead.

Signed-off-by: Andrew Price <anprice@redhat.com>
---
 gfs2/edit/savemeta.c | 34 +++++++++++++++++-----------------
 1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/gfs2/edit/savemeta.c b/gfs2/edit/savemeta.c
index 2d001e9..33d618a 100644
--- a/gfs2/edit/savemeta.c
+++ b/gfs2/edit/savemeta.c
@@ -405,7 +405,7 @@ static int savemetaclose(struct metafd *mfd)
 	return close(mfd->fd);
 }
 
-static int save_block(int fd, struct metafd *mfd, uint64_t blk)
+static int save_block(int fd, struct metafd *mfd, uint64_t blk, uint64_t owner)
 {
 	int blktype, blklen;
 	size_t outsz;
@@ -416,18 +416,18 @@ static int save_block(int fd, struct metafd *mfd, uint64_t blk)
 		fprintf(stderr, "\nWarning: bad block pointer '0x%llx' "
 			"ignored in block (block %llu (0x%llx))",
 			(unsigned long long)blk,
-			(unsigned long long)block, (unsigned long long)block);
+			(unsigned long long)owner, (unsigned long long)owner);
 		return 0;
 	}
 	savebh = bread(&sbd, blk);
 
 	/* If this isn't metadata and isn't a system file, we don't want it.
-	   Note that we're checking "block" here rather than blk.  That's
-	   because we want to know if the source inode's "block" is a system
-	   inode, not the block within the inode "blk". They may or may not
+	   Note that we're checking "owner" here rather than blk.  That's
+	   because we want to know if the source inode is a system inode
+	   not the block within the inode "blk". They may or may not
 	   be the same thing. */
 	if (get_gfs_struct_info(savebh, &blktype, &blklen) &&
-	    !block_is_systemfile(block)) {
+	    !block_is_systemfile(owner)) {
 		brelse(savebh);
 		return 0; /* Not metadata, and not system file, so skip it */
 	}
@@ -484,7 +484,7 @@ static void save_ea_block(struct metafd *mfd, struct gfs2_buffer_head *metabh)
 			b = (uint64_t *)(metabh->b_data);
 			b += charoff + i;
 			blk = be64_to_cpu(*b);
-			save_block(sbd.device_fd, mfd, blk);
+			save_block(sbd.device_fd, mfd, blk, block);
 		}
 		if (!ea.ea_rec_len)
 			break;
@@ -514,7 +514,7 @@ static void save_indirect_blocks(struct metafd *mfd, osi_list_t *cur_list,
 		if (indir_block == old_block)
 			continue;
 		old_block = indir_block;
-		blktype = save_block(sbd.device_fd, mfd, indir_block);
+		blktype = save_block(sbd.device_fd, mfd, indir_block, block);
 		if (blktype == GFS2_METATYPE_EA) {
 			nbh = bread(&sbd, indir_block);
 			save_ea_block(mfd, nbh);
@@ -625,7 +625,7 @@ static void save_inode_data(struct metafd *mfd)
 			mybh = bread(&sbd, leaf_no);
 			warm_fuzzy_stuff(block, FALSE);
 			if (gfs2_check_meta(mybh, GFS2_METATYPE_LF) == 0)
-				save_block(sbd.device_fd, mfd, leaf_no);
+				save_block(sbd.device_fd, mfd, leaf_no, block);
 			brelse(mybh);
 		}
 	}
@@ -634,7 +634,7 @@ static void save_inode_data(struct metafd *mfd)
 		struct gfs2_buffer_head *lbh;
 
 		lbh = bread(&sbd, inode->i_di.di_eattr);
-		save_block(sbd.device_fd, mfd, inode->i_di.di_eattr);
+		save_block(sbd.device_fd, mfd, inode->i_di.di_eattr, block);
 		gfs2_meta_header_in(&mh, lbh);
 		if (mh.mh_magic == GFS2_MAGIC &&
 		    mh.mh_type == GFS2_METATYPE_EA)
@@ -645,7 +645,7 @@ static void save_inode_data(struct metafd *mfd)
 		else {
 			if (mh.mh_magic == GFS2_MAGIC) /* if it's metadata */
 				save_block(sbd.device_fd, mfd,
-					   inode->i_di.di_eattr);
+					   inode->i_di.di_eattr, block);
 			fprintf(stderr,
 				"\nWarning: corrupt extended "
 				"attribute at block %llu (0x%llx) "
@@ -721,7 +721,7 @@ static void save_allocated(struct rgrp_tree *rgd, struct metafd *mfd)
 		for (j = 0; j < m; j++) {
 			block = ibuf[j];
 			warm_fuzzy_stuff(block, FALSE);
-			blktype = save_block(sbd.device_fd, mfd, block);
+			blktype = save_block(sbd.device_fd, mfd, block, block);
 			if (blktype == GFS2_METATYPE_DI)
 				save_inode_data(mfd);
 		}
@@ -733,7 +733,7 @@ static void save_allocated(struct rgrp_tree *rgd, struct metafd *mfd)
 		 * If we don't, we may run into metadata allocation issues. */
 		m = lgfs2_bm_scan(rgd, i, ibuf, GFS2_BLKST_UNLINKED);
 		for (j = 0; j < m; j++) {
-			save_block(sbd.device_fd, mfd, block);
+			save_block(sbd.device_fd, mfd, block, block);
 		}
 	}
 	free(ibuf);
@@ -825,14 +825,14 @@ void savemeta(char *out_fn, int saveoption, int gziplevel)
 		exit(1);
 	}
 	/* Save off the superblock */
-	save_block(sbd.device_fd, &mfd, GFS2_SB_ADDR * GFS2_BASIC_BLOCK / sbd.bsize);
+	save_block(sbd.device_fd, &mfd, GFS2_SB_ADDR * GFS2_BASIC_BLOCK / sbd.bsize, block);
 	/* If this is gfs1, save off the rindex because it's not
 	   part of the file system as it is in gfs2. */
 	if (sbd.gfs1) {
 		int j;
 
 		block = sbd1->sb_rindex_di.no_addr;
-		save_block(sbd.device_fd, &mfd, block);
+		save_block(sbd.device_fd, &mfd, block, block);
 		save_inode_data(&mfd);
 		/* In GFS1, journals aren't part of the RG space */
 		for (j = 0; j < journals_found; j++) {
@@ -840,7 +840,7 @@ void savemeta(char *out_fn, int saveoption, int gziplevel)
 			for (block = journal_blocks[j];
 			     block < journal_blocks[j] + gfs1_journal_size;
 			     block++)
-				save_block(sbd.device_fd, &mfd, block);
+				save_block(sbd.device_fd, &mfd, block, block);
 		}
 	}
 	/* Walk through the resource groups saving everything within */
@@ -858,7 +858,7 @@ void savemeta(char *out_fn, int saveoption, int gziplevel)
 		for (block = rgd->ri.ri_addr;
 		     block < rgd->ri.ri_data0; block++) {
 			warm_fuzzy_stuff(block, FALSE);
-			save_block(sbd.device_fd, &mfd, block);
+			save_block(sbd.device_fd, &mfd, block, block);
 		}
 		/* Save off the other metadata: inodes, etc. if mode is not 'savergs' */
 		if (saveoption != 2) {
-- 
2.4.3



^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [Cluster-devel] [PATCH 14/23] gfs2_edit: Don't use the global block variable in save_indirect_blocks
  2016-02-04 11:20 [Cluster-devel] [PATCH 00/23] gfs2_edit: Code cleanups Andrew Price
                   ` (12 preceding siblings ...)
  2016-02-04 11:20 ` [Cluster-devel] [PATCH 13/23] gfs2_edit: Don't use the global block variable in save_block Andrew Price
@ 2016-02-04 11:20 ` Andrew Price
  2016-02-04 11:20 ` [Cluster-devel] [PATCH 15/23] gfs2_edit: Don't use the global block variable in save_inode_data Andrew Price
                   ` (8 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: Andrew Price @ 2016-02-04 11:20 UTC (permalink / raw)
  To: cluster-devel.redhat.com

Accept the block's owner's address as an argument instead.

Signed-off-by: Andrew Price <anprice@redhat.com>
---
 gfs2/edit/savemeta.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/gfs2/edit/savemeta.c b/gfs2/edit/savemeta.c
index 33d618a..7c7e504 100644
--- a/gfs2/edit/savemeta.c
+++ b/gfs2/edit/savemeta.c
@@ -495,7 +495,7 @@ static void save_ea_block(struct metafd *mfd, struct gfs2_buffer_head *metabh)
  * save_indirect_blocks - save all indirect blocks for the given buffer
  */
 static void save_indirect_blocks(struct metafd *mfd, osi_list_t *cur_list,
-			  struct gfs2_buffer_head *mybh, int height, int hgt)
+           struct gfs2_buffer_head *mybh, uint64_t owner, int height, int hgt)
 {
 	uint64_t old_block = 0, indir_block;
 	uint64_t *ptr;
@@ -514,7 +514,7 @@ static void save_indirect_blocks(struct metafd *mfd, osi_list_t *cur_list,
 		if (indir_block == old_block)
 			continue;
 		old_block = indir_block;
-		blktype = save_block(sbd.device_fd, mfd, indir_block, block);
+		blktype = save_block(sbd.device_fd, mfd, indir_block, owner);
 		if (blktype == GFS2_METATYPE_EA) {
 			nbh = bread(&sbd, indir_block);
 			save_ea_block(mfd, nbh);
@@ -589,7 +589,7 @@ static void save_inode_data(struct metafd *mfd)
 			mybh = osi_list_entry(tmp, struct gfs2_buffer_head,
 					      b_altlist);
 			warm_fuzzy_stuff(block, FALSE);
-			save_indirect_blocks(mfd, cur_list, mybh,
+			save_indirect_blocks(mfd, cur_list, mybh, block,
 					     height, i);
 		} /* for blocks at that height */
 	} /* for height */
@@ -641,7 +641,7 @@ static void save_inode_data(struct metafd *mfd)
 			save_ea_block(mfd, lbh);
 		else if (mh.mh_magic == GFS2_MAGIC &&
 			 mh.mh_type == GFS2_METATYPE_IN)
-			save_indirect_blocks(mfd, cur_list, lbh, 2, 2);
+			save_indirect_blocks(mfd, cur_list, lbh, block, 2, 2);
 		else {
 			if (mh.mh_magic == GFS2_MAGIC) /* if it's metadata */
 				save_block(sbd.device_fd, mfd,
-- 
2.4.3



^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [Cluster-devel] [PATCH 15/23] gfs2_edit: Don't use the global block variable in save_inode_data
  2016-02-04 11:20 [Cluster-devel] [PATCH 00/23] gfs2_edit: Code cleanups Andrew Price
                   ` (13 preceding siblings ...)
  2016-02-04 11:20 ` [Cluster-devel] [PATCH 14/23] gfs2_edit: Don't use the global block variable in save_indirect_blocks Andrew Price
@ 2016-02-04 11:20 ` Andrew Price
  2016-02-04 11:20 ` [Cluster-devel] [PATCH 16/23] gfs2_edit: Don't use the global block variable in get_gfs_struct_info Andrew Price
                   ` (7 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: Andrew Price @ 2016-02-04 11:20 UTC (permalink / raw)
  To: cluster-devel.redhat.com

Accept the block's owner's address as an argument instead.

Signed-off-by: Andrew Price <anprice@redhat.com>
---
 gfs2/edit/savemeta.c | 30 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/gfs2/edit/savemeta.c b/gfs2/edit/savemeta.c
index 7c7e504..1b3674c 100644
--- a/gfs2/edit/savemeta.c
+++ b/gfs2/edit/savemeta.c
@@ -535,7 +535,7 @@ static void save_indirect_blocks(struct metafd *mfd, osi_list_t *cur_list,
  * save_inode_data - save off important data associated with an inode
  *
  * mfd - destination file descriptor
- * block - block number of the inode to save the data for
+ * iblk - block number of the inode to save the data for
  * 
  * For user files, we don't want anything except all the indirect block
  * pointers that reside on blocks on all but the highest height.
@@ -546,7 +546,7 @@ static void save_indirect_blocks(struct metafd *mfd, osi_list_t *cur_list,
  * For file system journals, the "data" is a mixture of metadata and
  * journaled data.  We want all the metadata and none of the user data.
  */
-static void save_inode_data(struct metafd *mfd)
+static void save_inode_data(struct metafd *mfd, uint64_t iblk)
 {
 	uint32_t height;
 	struct gfs2_inode *inode;
@@ -557,7 +557,7 @@ static void save_inode_data(struct metafd *mfd)
 
 	for (i = 0; i < GFS2_MAX_META_HEIGHT; i++)
 		osi_list_init(&metalist[i]);
-	metabh = bread(&sbd, block);
+	metabh = bread(&sbd, iblk);
 	if (sbd.gfs1) {
 		inode = lgfs2_gfs_inode_get(&sbd, metabh);
 	} else {
@@ -578,7 +578,7 @@ static void save_inode_data(struct metafd *mfd)
 	     (sbd.gfs1 && inode->i_di.__pad1 == GFS_FILE_DIR)))
 		height++;
 	else if (height && !(inode->i_di.di_flags & GFS2_DIF_SYSTEM) &&
-		 !block_is_systemfile(block) && !S_ISDIR(inode->i_di.di_mode))
+		 !block_is_systemfile(iblk) && !S_ISDIR(inode->i_di.di_mode))
 		height--;
 	osi_list_add(&metabh->b_altlist, &metalist[0]);
         for (i = 1; i <= height; i++){
@@ -588,8 +588,8 @@ static void save_inode_data(struct metafd *mfd)
 		for (tmp = prev_list->next; tmp != prev_list; tmp = tmp->next){
 			mybh = osi_list_entry(tmp, struct gfs2_buffer_head,
 					      b_altlist);
-			warm_fuzzy_stuff(block, FALSE);
-			save_indirect_blocks(mfd, cur_list, mybh, block,
+			warm_fuzzy_stuff(iblk, FALSE);
+			save_indirect_blocks(mfd, cur_list, mybh, iblk,
 					     height, i);
 		} /* for blocks at that height */
 	} /* for height */
@@ -623,9 +623,9 @@ static void save_inode_data(struct metafd *mfd)
 				continue;
 			old_leaf = leaf_no;
 			mybh = bread(&sbd, leaf_no);
-			warm_fuzzy_stuff(block, FALSE);
+			warm_fuzzy_stuff(iblk, FALSE);
 			if (gfs2_check_meta(mybh, GFS2_METATYPE_LF) == 0)
-				save_block(sbd.device_fd, mfd, leaf_no, block);
+				save_block(sbd.device_fd, mfd, leaf_no, iblk);
 			brelse(mybh);
 		}
 	}
@@ -634,26 +634,26 @@ static void save_inode_data(struct metafd *mfd)
 		struct gfs2_buffer_head *lbh;
 
 		lbh = bread(&sbd, inode->i_di.di_eattr);
-		save_block(sbd.device_fd, mfd, inode->i_di.di_eattr, block);
+		save_block(sbd.device_fd, mfd, inode->i_di.di_eattr, iblk);
 		gfs2_meta_header_in(&mh, lbh);
 		if (mh.mh_magic == GFS2_MAGIC &&
 		    mh.mh_type == GFS2_METATYPE_EA)
 			save_ea_block(mfd, lbh);
 		else if (mh.mh_magic == GFS2_MAGIC &&
 			 mh.mh_type == GFS2_METATYPE_IN)
-			save_indirect_blocks(mfd, cur_list, lbh, block, 2, 2);
+			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, block);
+					   inode->i_di.di_eattr, iblk);
 			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)block,
-				(unsigned long long)block);
+				(unsigned long long)iblk,
+				(unsigned long long)iblk);
 		}
 		brelse(lbh);
 	}
@@ -723,7 +723,7 @@ static void save_allocated(struct rgrp_tree *rgd, struct metafd *mfd)
 			warm_fuzzy_stuff(block, FALSE);
 			blktype = save_block(sbd.device_fd, mfd, block, block);
 			if (blktype == GFS2_METATYPE_DI)
-				save_inode_data(mfd);
+				save_inode_data(mfd, block);
 		}
 
 		if (!sbd.gfs1)
@@ -833,7 +833,7 @@ void savemeta(char *out_fn, int saveoption, int gziplevel)
 
 		block = sbd1->sb_rindex_di.no_addr;
 		save_block(sbd.device_fd, &mfd, block, block);
-		save_inode_data(&mfd);
+		save_inode_data(&mfd, block);
 		/* In GFS1, journals aren't part of the RG space */
 		for (j = 0; j < journals_found; j++) {
 			log_debug("Saving journal #%d\n", j + 1);
-- 
2.4.3



^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [Cluster-devel] [PATCH 16/23] gfs2_edit: Don't use the global block variable in get_gfs_struct_info
  2016-02-04 11:20 [Cluster-devel] [PATCH 00/23] gfs2_edit: Code cleanups Andrew Price
                   ` (14 preceding siblings ...)
  2016-02-04 11:20 ` [Cluster-devel] [PATCH 15/23] gfs2_edit: Don't use the global block variable in save_inode_data Andrew Price
@ 2016-02-04 11:20 ` Andrew Price
  2016-02-04 11:20 ` [Cluster-devel] [PATCH 17/23] gfs2_edit: Don't use the global block variable in save_ea_block Andrew Price
                   ` (6 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: Andrew Price @ 2016-02-04 11:20 UTC (permalink / raw)
  To: cluster-devel.redhat.com

Accept the block's owner's address as an argument instead.

Signed-off-by: Andrew Price <anprice@redhat.com>
---
 gfs2/edit/savemeta.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/gfs2/edit/savemeta.c b/gfs2/edit/savemeta.c
index 1b3674c..2fc4815 100644
--- a/gfs2/edit/savemeta.c
+++ b/gfs2/edit/savemeta.c
@@ -196,14 +196,16 @@ static const char *anthropomorphize(unsigned long long inhuman_value)
 /*
  * get_gfs_struct_info - get block type and structure length
  *
+ * @lbh - The block buffer to examine
+ * @owner - The block address of the parent structure
  * @block_type - pointer to integer to hold the block type
- * @struct_length - pointer to integet to hold the structure length
+ * @gstruct_len - pointer to integer to hold the structure length
  *
  * returns: 0 if successful
  *          -1 if this isn't gfs metadata.
  */
-static int get_gfs_struct_info(struct gfs2_buffer_head *lbh, int *block_type,
-			       int *gstruct_len)
+static int get_gfs_struct_info(struct gfs2_buffer_head *lbh, uint64_t owner,
+                               int *block_type, int *gstruct_len)
 {
 	struct gfs2_meta_header mh;
 	struct gfs2_inode *inode;
@@ -240,7 +242,7 @@ static int get_gfs_struct_info(struct gfs2_buffer_head *lbh, int *block_type,
 		if (S_ISDIR(inode->i_di.di_mode) ||
 		     (sbd.gfs1 && inode->i_di.__pad1 == GFS_FILE_DIR))
 			*gstruct_len = sbd.bsize;
-		else if (!inode->i_di.di_height && !block_is_systemfile(block) &&
+		else if (!inode->i_di.di_height && !block_is_systemfile(owner) &&
 			 !S_ISDIR(inode->i_di.di_mode))
 			*gstruct_len = sizeof(struct gfs2_dinode);
 		else
@@ -426,7 +428,7 @@ static int save_block(int fd, struct metafd *mfd, uint64_t blk, uint64_t owner)
 	   because we want to know if the source inode is a system inode
 	   not the block within the inode "blk". They may or may not
 	   be the same thing. */
-	if (get_gfs_struct_info(savebh, &blktype, &blklen) &&
+	if (get_gfs_struct_info(savebh, owner, &blktype, &blklen) &&
 	    !block_is_systemfile(owner)) {
 		brelse(savebh);
 		return 0; /* Not metadata, and not system file, so skip it */
-- 
2.4.3



^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [Cluster-devel] [PATCH 17/23] gfs2_edit: Don't use the global block variable in save_ea_block
  2016-02-04 11:20 [Cluster-devel] [PATCH 00/23] gfs2_edit: Code cleanups Andrew Price
                   ` (15 preceding siblings ...)
  2016-02-04 11:20 ` [Cluster-devel] [PATCH 16/23] gfs2_edit: Don't use the global block variable in get_gfs_struct_info Andrew Price
@ 2016-02-04 11:20 ` Andrew Price
  2016-02-04 11:20 ` [Cluster-devel] [PATCH 18/23] gfs2_edit: Don't use the global block variable in save_allocated Andrew Price
                   ` (5 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: Andrew Price @ 2016-02-04 11:20 UTC (permalink / raw)
  To: cluster-devel.redhat.com

Accept the block's owner's address as an argument instead.

Signed-off-by: Andrew Price <anprice@redhat.com>
---
 gfs2/edit/savemeta.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/gfs2/edit/savemeta.c b/gfs2/edit/savemeta.c
index 2fc4815..47cabba 100644
--- a/gfs2/edit/savemeta.c
+++ b/gfs2/edit/savemeta.c
@@ -468,7 +468,7 @@ static int save_block(int fd, struct metafd *mfd, uint64_t blk, uint64_t owner)
 /*
  * save_ea_block - save off an extended attribute block
  */
-static void save_ea_block(struct metafd *mfd, struct gfs2_buffer_head *metabh)
+static void save_ea_block(struct metafd *mfd, struct gfs2_buffer_head *metabh, uint64_t owner)
 {
 	int e;
 	struct gfs2_ea_header ea;
@@ -486,7 +486,7 @@ static void save_ea_block(struct metafd *mfd, struct gfs2_buffer_head *metabh)
 			b = (uint64_t *)(metabh->b_data);
 			b += charoff + i;
 			blk = be64_to_cpu(*b);
-			save_block(sbd.device_fd, mfd, blk, block);
+			save_block(sbd.device_fd, mfd, blk, owner);
 		}
 		if (!ea.ea_rec_len)
 			break;
@@ -519,7 +519,7 @@ static void save_indirect_blocks(struct metafd *mfd, osi_list_t *cur_list,
 		blktype = save_block(sbd.device_fd, mfd, indir_block, owner);
 		if (blktype == GFS2_METATYPE_EA) {
 			nbh = bread(&sbd, indir_block);
-			save_ea_block(mfd, nbh);
+			save_ea_block(mfd, nbh, owner);
 			brelse(nbh);
 		}
 		if (height != hgt && /* If not at max height and */
@@ -640,7 +640,7 @@ static void save_inode_data(struct metafd *mfd, uint64_t iblk)
 		gfs2_meta_header_in(&mh, lbh);
 		if (mh.mh_magic == GFS2_MAGIC &&
 		    mh.mh_type == GFS2_METATYPE_EA)
-			save_ea_block(mfd, lbh);
+			save_ea_block(mfd, lbh, iblk);
 		else if (mh.mh_magic == GFS2_MAGIC &&
 			 mh.mh_type == GFS2_METATYPE_IN)
 			save_indirect_blocks(mfd, cur_list, lbh, iblk, 2, 2);
-- 
2.4.3



^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [Cluster-devel] [PATCH 18/23] gfs2_edit: Don't use the global block variable in save_allocated
  2016-02-04 11:20 [Cluster-devel] [PATCH 00/23] gfs2_edit: Code cleanups Andrew Price
                   ` (16 preceding siblings ...)
  2016-02-04 11:20 ` [Cluster-devel] [PATCH 17/23] gfs2_edit: Don't use the global block variable in save_ea_block Andrew Price
@ 2016-02-04 11:20 ` Andrew Price
  2016-02-04 11:20 ` [Cluster-devel] [PATCH 19/23] gfs2_edit: Don't use the global block variable in savemeta Andrew Price
                   ` (4 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: Andrew Price @ 2016-02-04 11:20 UTC (permalink / raw)
  To: cluster-devel.redhat.com

Replace it with a local variable as save_allocated doesn't use its
existing value.

Signed-off-by: Andrew Price <anprice@redhat.com>
---
 gfs2/edit/savemeta.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/gfs2/edit/savemeta.c b/gfs2/edit/savemeta.c
index 47cabba..c376db4 100644
--- a/gfs2/edit/savemeta.c
+++ b/gfs2/edit/savemeta.c
@@ -714,6 +714,7 @@ static void get_journal_inode_blocks(void)
 static void save_allocated(struct rgrp_tree *rgd, struct metafd *mfd)
 {
 	int blktype;
+	uint64_t blk;
 	unsigned i, j, m;
 	uint64_t *ibuf = malloc(sbd.bsize * GFS2_NBBY * sizeof(uint64_t));
 
@@ -721,11 +722,11 @@ static void save_allocated(struct rgrp_tree *rgd, struct metafd *mfd)
 		m = lgfs2_bm_scan(rgd, i, ibuf, GFS2_BLKST_DINODE);
 
 		for (j = 0; j < m; j++) {
-			block = ibuf[j];
-			warm_fuzzy_stuff(block, FALSE);
-			blktype = save_block(sbd.device_fd, mfd, block, block);
+			blk = ibuf[j];
+			warm_fuzzy_stuff(blk, FALSE);
+			blktype = save_block(sbd.device_fd, mfd, blk, blk);
 			if (blktype == GFS2_METATYPE_DI)
-				save_inode_data(mfd, block);
+				save_inode_data(mfd, blk);
 		}
 
 		if (!sbd.gfs1)
@@ -735,7 +736,7 @@ static void save_allocated(struct rgrp_tree *rgd, struct metafd *mfd)
 		 * If we don't, we may run into metadata allocation issues. */
 		m = lgfs2_bm_scan(rgd, i, ibuf, GFS2_BLKST_UNLINKED);
 		for (j = 0; j < m; j++) {
-			save_block(sbd.device_fd, mfd, block, block);
+			save_block(sbd.device_fd, mfd, blk, blk);
 		}
 	}
 	free(ibuf);
-- 
2.4.3



^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [Cluster-devel] [PATCH 19/23] gfs2_edit: Don't use the global block variable in savemeta
  2016-02-04 11:20 [Cluster-devel] [PATCH 00/23] gfs2_edit: Code cleanups Andrew Price
                   ` (17 preceding siblings ...)
  2016-02-04 11:20 ` [Cluster-devel] [PATCH 18/23] gfs2_edit: Don't use the global block variable in save_allocated Andrew Price
@ 2016-02-04 11:20 ` Andrew Price
  2016-02-04 11:20 ` [Cluster-devel] [PATCH 20/23] gfs2_edit: Don't use the global bh variable in display_block_type Andrew Price
                   ` (3 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: Andrew Price @ 2016-02-04 11:20 UTC (permalink / raw)
  To: cluster-devel.redhat.com

Replace it with local variables as savemeta doesn't use its existing
value.

Signed-off-by: Andrew Price <anprice@redhat.com>
---
 gfs2/edit/savemeta.c | 29 +++++++++++++++--------------
 1 file changed, 15 insertions(+), 14 deletions(-)

diff --git a/gfs2/edit/savemeta.c b/gfs2/edit/savemeta.c
index c376db4..17ad35d 100644
--- a/gfs2/edit/savemeta.c
+++ b/gfs2/edit/savemeta.c
@@ -828,26 +828,28 @@ void savemeta(char *out_fn, int saveoption, int gziplevel)
 		exit(1);
 	}
 	/* Save off the superblock */
-	save_block(sbd.device_fd, &mfd, GFS2_SB_ADDR * GFS2_BASIC_BLOCK / sbd.bsize, block);
+	save_block(sbd.device_fd, &mfd, GFS2_SB_ADDR * GFS2_BASIC_BLOCK / sbd.bsize, 0);
 	/* If this is gfs1, save off the rindex because it's not
 	   part of the file system as it is in gfs2. */
 	if (sbd.gfs1) {
+		uint64_t blk;
 		int j;
 
-		block = sbd1->sb_rindex_di.no_addr;
-		save_block(sbd.device_fd, &mfd, block, block);
-		save_inode_data(&mfd, block);
+		blk = sbd1->sb_rindex_di.no_addr;
+		save_block(sbd.device_fd, &mfd, blk, blk);
+		save_inode_data(&mfd, blk);
 		/* In GFS1, journals aren't part of the RG space */
 		for (j = 0; j < journals_found; j++) {
 			log_debug("Saving journal #%d\n", j + 1);
-			for (block = journal_blocks[j];
-			     block < journal_blocks[j] + gfs1_journal_size;
-			     block++)
-				save_block(sbd.device_fd, &mfd, block, block);
+			for (blk = journal_blocks[j];
+			     blk < journal_blocks[j] + gfs1_journal_size;
+			     blk++)
+				save_block(sbd.device_fd, &mfd, blk, blk);
 		}
 	}
 	/* Walk through the resource groups saving everything within */
 	for (n = osi_first(&sbd.rgtree); n; n = osi_next(n)) {
+		uint64_t blk;
 		struct rgrp_tree *rgd;
 
 		rgd = (struct rgrp_tree *)n;
@@ -858,10 +860,10 @@ void savemeta(char *out_fn, int saveoption, int gziplevel)
 			  (unsigned long long)rgd->ri.ri_addr,
 			  rgd->ri.ri_length);
 		/* Save off the rg and bitmaps */
-		for (block = rgd->ri.ri_addr;
-		     block < rgd->ri.ri_data0; block++) {
-			warm_fuzzy_stuff(block, FALSE);
-			save_block(sbd.device_fd, &mfd, block, block);
+		for (blk = rgd->ri.ri_addr;
+		     blk < rgd->ri.ri_data0; blk++) {
+			warm_fuzzy_stuff(blk, FALSE);
+			save_block(sbd.device_fd, &mfd, blk, blk);
 		}
 		/* Save off the other metadata: inodes, etc. if mode is not 'savergs' */
 		if (saveoption != 2) {
@@ -872,8 +874,7 @@ void savemeta(char *out_fn, int saveoption, int gziplevel)
 	/* Clean up */
 	/* There may be a gap between end of file system and end of device */
 	/* so we tell the user that we've processed everything. */
-	block = sbd.fssize;
-	warm_fuzzy_stuff(block, TRUE);
+	warm_fuzzy_stuff(sbd.fssize, TRUE);
 	printf("\nMetadata saved to file %s ", mfd.filename);
 	if (mfd.gziplevel) {
 		printf("(gzipped, level %d).\n", mfd.gziplevel);
-- 
2.4.3



^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [Cluster-devel] [PATCH 20/23] gfs2_edit: Don't use the global bh variable in display_block_type
  2016-02-04 11:20 [Cluster-devel] [PATCH 00/23] gfs2_edit: Code cleanups Andrew Price
                   ` (18 preceding siblings ...)
  2016-02-04 11:20 ` [Cluster-devel] [PATCH 19/23] gfs2_edit: Don't use the global block variable in savemeta Andrew Price
@ 2016-02-04 11:20 ` Andrew Price
  2016-02-04 11:20 ` [Cluster-devel] [PATCH 21/23] gfs2_edit: Don't use the global block variable in savemeta.c Andrew Price
                   ` (2 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: Andrew Price @ 2016-02-04 11:20 UTC (permalink / raw)
  To: cluster-devel.redhat.com

Accept it as an argument instead.

Signed-off-by: Andrew Price <anprice@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



^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [Cluster-devel] [PATCH 21/23] gfs2_edit: Don't use the global block variable in savemeta.c
  2016-02-04 11:20 [Cluster-devel] [PATCH 00/23] gfs2_edit: Code cleanups Andrew Price
                   ` (19 preceding siblings ...)
  2016-02-04 11:20 ` [Cluster-devel] [PATCH 20/23] gfs2_edit: Don't use the global bh variable in display_block_type Andrew Price
@ 2016-02-04 11:20 ` Andrew Price
  2016-02-04 11:20 ` [Cluster-devel] [PATCH 22/23] gfs2_edit: Don't export bh Andrew Price
  2016-02-04 11:20 ` [Cluster-devel] [PATCH 23/23] gfs2_edit: Remove block_in_mem and fix a memory leak Andrew Price
  22 siblings, 0 replies; 24+ messages in thread
From: Andrew Price @ 2016-02-04 11:20 UTC (permalink / raw)
  To: cluster-devel.redhat.com

Tweak the display functions used by printsavedmeta to accept a bh and
use the block number from it. Remove the last uses of 'block' from
restore_data.

Signed-off-by: Andrew Price <anprice@redhat.com>
---
 gfs2/edit/gfs2hex.c  | 32 ++++++++++++++++----------------
 gfs2/edit/gfs2hex.h  |  2 +-
 gfs2/edit/hexedit.c  |  4 ++--
 gfs2/edit/savemeta.c | 18 +++++++-----------
 4 files changed, 26 insertions(+), 30 deletions(-)

diff --git a/gfs2/edit/gfs2hex.c b/gfs2/edit/gfs2hex.c
index 101a063..4915e5c 100644
--- a/gfs2/edit/gfs2hex.c
+++ b/gfs2/edit/gfs2hex.c
@@ -455,7 +455,7 @@ static void gfs1_rgrp_print(struct gfs_rgrp *rg)
         pv(rg, rg_freemeta, "%u", "0x%x");
 }
 
-int display_gfs2(void)
+int display_gfs2(struct gfs2_buffer_head *dbh)
 {
 	struct gfs2_meta_header mh;
 	struct gfs2_rgrp rg;
@@ -467,22 +467,22 @@ int display_gfs2(void)
 
 	uint32_t magic;
 
-	magic = be32_to_cpu(*(uint32_t *)bh->b_data);
+	magic = be32_to_cpu(*(uint32_t *)dbh->b_data);
 
 	switch (magic)
 	{
 	case GFS2_MAGIC:
-		gfs2_meta_header_in(&mh, bh);
+		gfs2_meta_header_in(&mh, dbh);
 		if (mh.mh_type > GFS2_METATYPE_QC)
 			print_gfs2("Unknown metadata type");
 		else
 			print_gfs2("%s:", block_type_str[mh.mh_type]);
 		eol(0);
-		
+
 		switch (mh.mh_type)
 		{
 		case GFS2_METATYPE_SB:
-			gfs2_sb_in(&sbd.sd_sb, bh);
+			gfs2_sb_in(&sbd.sd_sb, dbh);
 			gfs2_sb_print2(&sbd.sd_sb);
 			break;
 
@@ -490,10 +490,10 @@ int display_gfs2(void)
 			if (sbd.gfs1) {
 				struct gfs_rgrp rg1;
 
-				gfs1_rgrp_in(&rg1, bh);
+				gfs1_rgrp_in(&rg1, dbh);
 				gfs1_rgrp_print(&rg1);
 			} else {
-				gfs2_rgrp_in(&rg, bh);
+				gfs2_rgrp_in(&rg, dbh);
 				gfs2_rgrp_print(&rg);
 			}
 			break;
@@ -511,7 +511,7 @@ int display_gfs2(void)
 			break;
 
 		case GFS2_METATYPE_LF:
-			gfs2_leaf_in(&lf, bh);
+			gfs2_leaf_in(&lf, dbh);
 			gfs2_leaf_print(&lf);
 			break;
 
@@ -521,33 +521,33 @@ int display_gfs2(void)
 
 		case GFS2_METATYPE_LH:
 			if (sbd.gfs1) {
-				gfs_log_header_in(&lh1, bh);
+				gfs_log_header_in(&lh1, dbh);
 				gfs_log_header_print(&lh1);
 			} else {
-				gfs2_log_header_in(&lh, bh);
+				gfs2_log_header_in(&lh, dbh);
 				gfs2_log_header_print(&lh);
 			}
 			break;
 
 		case GFS2_METATYPE_LD:
-			gfs2_log_descriptor_in(&ld, bh);
+			gfs2_log_descriptor_in(&ld, dbh);
 			gfs2_log_descriptor_print(&ld);
 			break;
 
 		case GFS2_METATYPE_EA:
-			do_eattr_extended(bh);
+			do_eattr_extended(dbh);
 			break;
-			
+
 		case GFS2_METATYPE_ED:
 			gfs2_meta_header_print(&mh);
 			break;
-			
+
 		case GFS2_METATYPE_LB:
 			gfs2_meta_header_print(&mh);
 			break;
 
 		case GFS2_METATYPE_QC:
-			gfs2_quota_change_in(&qc, bh);
+			gfs2_quota_change_in(&qc, dbh);
 			gfs2_quota_change_print(&qc);
 			break;
 
@@ -555,7 +555,7 @@ int display_gfs2(void)
 			break;
 		}
 		break;
-		
+
 	default:
 		print_gfs2("Unknown block type");
 		eol(0);
diff --git a/gfs2/edit/gfs2hex.h b/gfs2/edit/gfs2hex.h
index 1bd83c3..c3efb27 100644
--- a/gfs2/edit/gfs2hex.h
+++ b/gfs2/edit/gfs2hex.h
@@ -3,7 +3,7 @@
 
 #include "hexedit.h"
 
-extern int display_gfs2(void);
+extern int display_gfs2(struct gfs2_buffer_head *dbh);
 extern int edit_gfs2(void);
 extern void do_dinode_extended(struct gfs2_dinode *di,
 			       struct gfs2_buffer_head *lbh);
diff --git a/gfs2/edit/hexedit.c b/gfs2/edit/hexedit.c
index 07f179d..831ca45 100644
--- a/gfs2/edit/hexedit.c
+++ b/gfs2/edit/hexedit.c
@@ -333,7 +333,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("%"PRId64"    (0x%"PRIx64")", block, block);
+		print_gfs2("%"PRIu64"    (0x%"PRIx64")", dbh->b_blocknr, dbh->b_blocknr);
 	if (termlines) {
 		if (edit_row[dmode] == -1)
 			COLORS_NORMAL;
@@ -1150,7 +1150,7 @@ int display(int identify_only, int trunc_zeros, uint64_t flagref,
 		        flagref, ref_blk);
 	else if (dmode == GFS2_MODE) { /* if structure display */
 		if (block != JOURNALS_DUMMY_BLOCK)
-			display_gfs2();       /* display the gfs2 structure */
+			display_gfs2(bh);  /* display the gfs2 structure */
 	} else
 		display_extended();        /* display extended blocks       */
 	/* No else here because display_extended can switch back to hex mode */
diff --git a/gfs2/edit/savemeta.c b/gfs2/edit/savemeta.c
index e80b425..8510d77 100644
--- a/gfs2/edit/savemeta.c
+++ b/gfs2/edit/savemeta.c
@@ -27,8 +27,6 @@
 #include "hexedit.h"
 #include "libgfs2.h"
 
-extern uint64_t block;
-
 #define DFT_SAVE_FILE "/tmp/gfsmeta.XXXXXX"
 #define MAX_JOURNALS_SAVED 256
 
@@ -1076,20 +1074,18 @@ static int restore_data(int fd, gzFile gzin_fd, off_t pos, int printonly)
 		}
 
 		if (printonly) {
-			struct gfs2_buffer_head dummy_bh;
-			dummy_bh.b_data = savedata->buf;
-			bh = &dummy_bh;
-			block = savedata->blk;
-			if (printonly > 1 && printonly == block) {
-				block_in_mem = block;
-				display(0, 0, 0, 0);
-				bh = NULL;
+			struct gfs2_buffer_head dummy_bh = {
+				.b_data = savedata->buf,
+				.b_blocknr = savedata->blk,
+			};
+			if (printonly > 1 && printonly == savedata->blk) {
+				display_block_type(&dummy_bh, 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);
 			}
-			bh = NULL;
 		} else {
 			warm_fuzzy_stuff(savedata->blk, FALSE);
 			memset(savedata->buf + savedata->siglen, 0, sbd.bsize - savedata->siglen);
-- 
2.4.3



^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [Cluster-devel] [PATCH 22/23] gfs2_edit: Don't export bh
  2016-02-04 11:20 [Cluster-devel] [PATCH 00/23] gfs2_edit: Code cleanups Andrew Price
                   ` (20 preceding siblings ...)
  2016-02-04 11:20 ` [Cluster-devel] [PATCH 21/23] gfs2_edit: Don't use the global block variable in savemeta.c Andrew Price
@ 2016-02-04 11:20 ` Andrew Price
  2016-02-04 11:20 ` [Cluster-devel] [PATCH 23/23] gfs2_edit: Remove block_in_mem and fix a memory leak Andrew Price
  22 siblings, 0 replies; 24+ messages in thread
From: Andrew Price @ 2016-02-04 11:20 UTC (permalink / raw)
  To: cluster-devel.redhat.com

bh is now only used in hexedit.c so restrict its visibility to that
file.

Signed-off-by: Andrew Price <anprice@redhat.com>
---
 gfs2/edit/gfs2hex.c | 1 -
 gfs2/edit/hexedit.c | 1 +
 gfs2/edit/hexedit.h | 1 -
 3 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/gfs2/edit/gfs2hex.c b/gfs2/edit/gfs2hex.c
index 4915e5c..1f55a43 100644
--- a/gfs2/edit/gfs2hex.c
+++ b/gfs2/edit/gfs2hex.c
@@ -29,7 +29,6 @@
 	} while (FALSE);
 
 struct gfs2_sb sb;
-struct gfs2_buffer_head *bh;
 struct gfs2_dinode di;
 int line, termlines, modelines[DMODES];
 char edit_fmt[80];
diff --git a/gfs2/edit/hexedit.c b/gfs2/edit/hexedit.c
index 831ca45..a89ae36 100644
--- a/gfs2/edit/hexedit.c
+++ b/gfs2/edit/hexedit.c
@@ -34,6 +34,7 @@ const char *allocdesc[2][5] = {
 	{"Free ", "Data ", "Unlnk", "Meta ", "Resrv"},
 	{"Free ", "Data ", "FreeM", "Meta ", "Resrv"},};
 
+struct gfs2_buffer_head *bh;
 struct gfs2_rgrp *lrgrp;
 struct gfs2_meta_header *lmh;
 struct gfs2_dinode *ldi;
diff --git a/gfs2/edit/hexedit.h b/gfs2/edit/hexedit.h
index 15586d4..f3220a7 100644
--- a/gfs2/edit/hexedit.h
+++ b/gfs2/edit/hexedit.h
@@ -37,7 +37,6 @@ extern char estring[1024]; /* edit string */
 extern char efield[64];
 extern uint64_t dev_offset;
 extern uint64_t max_block;
-extern struct gfs2_buffer_head *bh;
 extern int termlines;
 extern int insert;
 extern const char *termtype;
-- 
2.4.3



^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [Cluster-devel] [PATCH 23/23] gfs2_edit: Remove block_in_mem and fix a memory leak
  2016-02-04 11:20 [Cluster-devel] [PATCH 00/23] gfs2_edit: Code cleanups Andrew Price
                   ` (21 preceding siblings ...)
  2016-02-04 11:20 ` [Cluster-devel] [PATCH 22/23] gfs2_edit: Don't export bh Andrew Price
@ 2016-02-04 11:20 ` Andrew Price
  22 siblings, 0 replies; 24+ messages in thread
From: Andrew Price @ 2016-02-04 11:20 UTC (permalink / raw)
  To: cluster-devel.redhat.com

block_in_mem is meant to be the block number that relates to the global
bh. bh->b_blocknr can be used for the same purpose so remove
block_in_mem. Also fix a memory leak that occurs when the displayed
block changes.

Signed-off-by: Andrew Price <anprice@redhat.com>
---
 gfs2/edit/gfs2hex.c | 1 -
 gfs2/edit/hexedit.c | 8 ++++----
 gfs2/edit/hexedit.h | 1 -
 3 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/gfs2/edit/gfs2hex.c b/gfs2/edit/gfs2hex.c
index 1f55a43..3d280b5 100644
--- a/gfs2/edit/gfs2hex.c
+++ b/gfs2/edit/gfs2hex.c
@@ -42,7 +42,6 @@ uint64_t block = 0;
 int blockhist = 0;
 struct iinfo *indirect;
 int indirect_blocks;
-uint64_t block_in_mem = -1;
 struct gfs2_sbd sbd;
 uint64_t starting_blk;
 struct blkstack_info blockstack[BLOCK_STACK_SIZE];
diff --git a/gfs2/edit/hexedit.c b/gfs2/edit/hexedit.c
index a89ae36..5adf7c5 100644
--- a/gfs2/edit/hexedit.c
+++ b/gfs2/edit/hexedit.c
@@ -1072,7 +1072,9 @@ int display(int identify_only, int trunc_zeros, uint64_t flagref,
 		display_title_lines();
 		move(2,0);
 	}
-	if (block_in_mem != blk) { /* If we changed blocks from the last read */
+	if (bh == NULL || bh->b_blocknr != blk) { /* If we changed blocks from the last read */
+		if (bh != NULL)
+			brelse(bh);
 		dev_offset = blk * sbd.bsize;
 		ioctl(sbd.device_fd, BLKFLSBUF, 0);
 		if (!(bh = bread(&sbd, blk))) {
@@ -1083,7 +1085,6 @@ int display(int identify_only, int trunc_zeros, uint64_t flagref,
 				(unsigned long long)dev_offset);
 			exit(-1);
 		}
-		block_in_mem = blk; /* remember which block is in memory */
 	}
 	line = 1;
 	gfs2_struct_type = display_block_type(bh, FALSE);
@@ -1869,7 +1870,6 @@ static void interactive_mode(void)
 					bobgets(estring, edit_row[dmode]+4, 24,
 						10, &ch);
 					process_field(efield, estring);
-					block_in_mem = -1;
 				} else
 					bobgets(estring, edit_row[dmode]+6, 14,
 						edit_size[dmode], &ch);
@@ -2534,7 +2534,7 @@ int main(int argc, char *argv[])
 		edit_row[GFS2_MODE]++;
 	else
 		read_master_dir();
-	block_in_mem = -1;
+
 	process_parameters(argc, argv, 1); /* get what to print from cmdline */
 
 	block = blockstack[0].block = starting_blk * (4096 / sbd.bsize);
diff --git a/gfs2/edit/hexedit.h b/gfs2/edit/hexedit.h
index f3220a7..4f7207b 100644
--- a/gfs2/edit/hexedit.h
+++ b/gfs2/edit/hexedit.h
@@ -54,7 +54,6 @@ extern struct gfs2_inum gfs1_license_di; /* kludge because gfs2 sb too small */
 extern struct gfs2_dinode di;
 extern int screen_chunk_size; /* how much of the 4K can fit on screen */
 extern int gfs2_struct_type;
-extern uint64_t block_in_mem;
 extern int identify;
 extern int color_scheme;
 extern WINDOW *wind;
-- 
2.4.3



^ permalink raw reply related	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2016-02-04 11:20 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-04 11:20 [Cluster-devel] [PATCH 00/23] gfs2_edit: Code cleanups Andrew Price
2016-02-04 11:20 ` [Cluster-devel] [PATCH 01/23] gfs2_edit: Don't use the global block variable in block_is_a_journal Andrew Price
2016-02-04 11:20 ` [Cluster-devel] [PATCH 02/23] gfs2_edit: Don't use the global block variable in block_is_in_per_node Andrew Price
2016-02-04 11:20 ` [Cluster-devel] [PATCH 03/23] gfs2_edit: Don't use the global block variable in block_is_jindex Andrew Price
2016-02-04 11:20 ` [Cluster-devel] [PATCH 04/23] gfs2_edit: Don't use the global block variable in block_is_inum_file Andrew Price
2016-02-04 11:20 ` [Cluster-devel] [PATCH 05/23] gfs2_edit: Don't use global block variable in block_is_statfs_file Andrew Price
2016-02-04 11:20 ` [Cluster-devel] [PATCH 06/23] gfs2_edit: Don't use global block variable in block_is_quota_file Andrew Price
2016-02-04 11:20 ` [Cluster-devel] [PATCH 07/23] gfs2_edit: Don't use global block variable in block_is_rindex Andrew Price
2016-02-04 11:20 ` [Cluster-devel] [PATCH 08/23] gfs2_edit: Don't use the global block variable in block_is_per_node Andrew Price
2016-02-04 11:20 ` [Cluster-devel] [PATCH 09/23] gfs2_edit: Don't use the global block variable in block_is_systemfile Andrew Price
2016-02-04 11:20 ` [Cluster-devel] [PATCH 10/23] gfs2_edit: Don't use the global block variable in block_is_rgtree Andrew Price
2016-02-04 11:20 ` [Cluster-devel] [PATCH 11/23] gfs2_edit: Don't use the global block variable in block_is_journals Andrew Price
2016-02-04 11:20 ` [Cluster-devel] [PATCH 12/23] gfs2_edit: Only declare the block variable where needed Andrew Price
2016-02-04 11:20 ` [Cluster-devel] [PATCH 13/23] gfs2_edit: Don't use the global block variable in save_block Andrew Price
2016-02-04 11:20 ` [Cluster-devel] [PATCH 14/23] gfs2_edit: Don't use the global block variable in save_indirect_blocks Andrew Price
2016-02-04 11:20 ` [Cluster-devel] [PATCH 15/23] gfs2_edit: Don't use the global block variable in save_inode_data Andrew Price
2016-02-04 11:20 ` [Cluster-devel] [PATCH 16/23] gfs2_edit: Don't use the global block variable in get_gfs_struct_info Andrew Price
2016-02-04 11:20 ` [Cluster-devel] [PATCH 17/23] gfs2_edit: Don't use the global block variable in save_ea_block Andrew Price
2016-02-04 11:20 ` [Cluster-devel] [PATCH 18/23] gfs2_edit: Don't use the global block variable in save_allocated Andrew Price
2016-02-04 11:20 ` [Cluster-devel] [PATCH 19/23] gfs2_edit: Don't use the global block variable in savemeta Andrew Price
2016-02-04 11:20 ` [Cluster-devel] [PATCH 20/23] gfs2_edit: Don't use the global bh variable in display_block_type Andrew Price
2016-02-04 11:20 ` [Cluster-devel] [PATCH 21/23] gfs2_edit: Don't use the global block variable in savemeta.c Andrew Price
2016-02-04 11:20 ` [Cluster-devel] [PATCH 22/23] gfs2_edit: Don't export bh Andrew Price
2016-02-04 11:20 ` [Cluster-devel] [PATCH 23/23] gfs2_edit: Remove block_in_mem and fix a memory leak Andrew Price

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).