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

[Cluster-devel] [PATCH 5/5] gfs2_edit: Fix segfault in find by resource group



When using 'find' on block types which require searching by resource
group, a segfault occurs in __gfs2_next_rg_meta due to rgd->bh being
empty. This patch fixes the segfault by reading in the resource group
data, thus populating rgd->bh, prior to the search.

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

diff --git a/gfs2/edit/hexedit.c b/gfs2/edit/hexedit.c
index 2182704..dd0cf60 100644
--- a/gfs2/edit/hexedit.c
+++ b/gfs2/edit/hexedit.c
@@ -2056,7 +2056,7 @@ static uint64_t find_metablockoftype_slow(uint64_t startblk, int metatype, int p
 static uint64_t find_metablockoftype_rg(uint64_t startblk, int metatype, int print)
 {
 	struct osi_node *n, *next = NULL;
-	uint64_t blk;
+	uint64_t blk, errblk;
 	int first = 1, found = 0;
 	struct rgrp_tree *rgd;
 	struct gfs2_rindex *ri;
@@ -2087,6 +2087,9 @@ static uint64_t find_metablockoftype_rg(uint64_t startblk, int metatype, int pri
 	for (; !found && n; n = next){
 		next = osi_next(n);
 		rgd = (struct rgrp_tree *)n;
+		errblk = gfs2_rgrp_read(&sbd, rgd);
+		if (errblk)
+			continue;
 		first = 1;
 		do {
 			if (gfs2_next_rg_metatype(&sbd, rgd, &blk, metatype,
@@ -2098,6 +2101,7 @@ static uint64_t find_metablockoftype_rg(uint64_t startblk, int metatype, int pri
 			}
 			first = 0;
 		} while (blk <= startblk);
+		gfs2_rgrp_relse(rgd);
 	}
 	if (!found)
 		blk = 0;
-- 
1.7.6


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