cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
* [Cluster-devel] [PATCH 1/5] gfs2_edit: Initialize metafds fully in savemetaopen
@ 2011-09-06 12:00 Andrew Price
  2011-09-06 12:00 ` [Cluster-devel] [PATCH 2/5] libgfs2: clean up some dead code in gfs2_writei Andrew Price
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Andrew Price @ 2011-09-06 12:00 UTC (permalink / raw)
  To: cluster-devel.redhat.com

Coverity showed that savemetaopen() can return a metafd without
initializing the gzfd member. This isn't currently a problem as we only
use gzfd when it is set but this patch initializes the metafd fully to
avoid future problems.

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

diff --git a/gfs2/edit/savemeta.c b/gfs2/edit/savemeta.c
index 3a0e45e..9e5d111 100644
--- a/gfs2/edit/savemeta.c
+++ b/gfs2/edit/savemeta.c
@@ -211,7 +211,7 @@ static void warm_fuzzy_stuff(uint64_t wfsblock, int force)
  */
 static struct metafd savemetaopen(char *out_fn, int gziplevel)
 {
-	struct metafd mfd;
+	struct metafd mfd = {-1, NULL, NULL, gziplevel};
 	char gzmode[3] = "w9";
 	char dft_fn[] = DFT_SAVE_FILE;
 
@@ -233,7 +233,6 @@ static struct metafd savemetaopen(char *out_fn, int gziplevel)
 		exit(1);
 	}
 
-	mfd.gziplevel = gziplevel;
 	if (gziplevel > 0) {
 		gzmode[1] = '0' + gziplevel;
 		mfd.gzfd = gzdopen(mfd.fd, gzmode);
-- 
1.7.6



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

* [Cluster-devel] [PATCH 2/5] libgfs2: clean up some dead code in gfs2_writei
  2011-09-06 12:00 [Cluster-devel] [PATCH 1/5] gfs2_edit: Initialize metafds fully in savemetaopen Andrew Price
@ 2011-09-06 12:00 ` Andrew Price
  2011-09-06 12:00 ` [Cluster-devel] [PATCH 3/5] libgfs2: Remove dead code from gfs2_get_leaf Andrew Price
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: Andrew Price @ 2011-09-06 12:00 UTC (permalink / raw)
  To: cluster-devel.redhat.com

This patch cleans up an error variable which was initialized to 0 and
then never changed, and a 'fail' section which could be replaced by a
return. It also removes the 'out' label which was only referenced from
the dead if-statement in the 'fail' section.

Signed-off-by: Andrew Price <anprice@redhat.com>
---
 gfs2/libgfs2/gfs1.c |   11 +----------
 1 files changed, 1 insertions(+), 10 deletions(-)

diff --git a/gfs2/libgfs2/gfs1.c b/gfs2/libgfs2/gfs1.c
index 2bd5282..4549959 100644
--- a/gfs2/libgfs2/gfs1.c
+++ b/gfs2/libgfs2/gfs1.c
@@ -181,11 +181,9 @@ int gfs1_writei(struct gfs2_inode *ip, char *buf, uint64_t offset,
 	int journaled = fs_is_jdata(ip);
 	const uint64_t start = offset;
 	int copied = 0;
-	int error = 0;
 
 	if (!size)
-		goto fail;  /*  Not really an error  */
-
+		return 0;
 
 	if (!ip->i_di.di_height && /* stuffed */
 	    ((start + size) > (sdp->bsize - sizeof(struct gfs_dinode))))
@@ -243,7 +241,6 @@ int gfs1_writei(struct gfs2_inode *ip, char *buf, uint64_t offset,
 		offset = (journaled) ? sizeof(struct gfs2_meta_header) : 0;
 	}
 
- out:
 	if (ip->i_di.di_size < start + copied) {
 		bmodified(ip->i_bh);
 		ip->i_di.di_size = start + copied;
@@ -253,12 +250,6 @@ int gfs1_writei(struct gfs2_inode *ip, char *buf, uint64_t offset,
 	gfs2_dinode_out(&ip->i_di, ip->i_bh);
 
 	return copied;
-
- fail:
-	if (copied)
-		goto out;
-
-	return error;
 }
 
 /* ------------------------------------------------------------------------ */
-- 
1.7.6



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

* [Cluster-devel] [PATCH 3/5] libgfs2: Remove dead code from gfs2_get_leaf
  2011-09-06 12:00 [Cluster-devel] [PATCH 1/5] gfs2_edit: Initialize metafds fully in savemetaopen Andrew Price
  2011-09-06 12:00 ` [Cluster-devel] [PATCH 2/5] libgfs2: clean up some dead code in gfs2_writei Andrew Price
@ 2011-09-06 12:00 ` Andrew Price
  2011-09-06 12:00 ` [Cluster-devel] [PATCH 4/5] gfs_controld: Remove dead code from loop() Andrew Price
  2011-09-06 12:00 ` [Cluster-devel] [PATCH 5/5] gfs2_edit: Fix segfault in find by resource group Andrew Price
  3 siblings, 0 replies; 7+ messages in thread
From: Andrew Price @ 2011-09-06 12:00 UTC (permalink / raw)
  To: cluster-devel.redhat.com

The value of error is always 0 when this if statement is reached. This
patch removes it.

Signed-off-by: Andrew Price <anprice@redhat.com>
---
 gfs2/libgfs2/fs_ops.c |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/gfs2/libgfs2/fs_ops.c b/gfs2/libgfs2/fs_ops.c
index c778564..d344bc4 100644
--- a/gfs2/libgfs2/fs_ops.c
+++ b/gfs2/libgfs2/fs_ops.c
@@ -1032,8 +1032,6 @@ int gfs2_get_leaf(struct gfs2_inode *dip, uint64_t leaf_no,
 	int error = 0;
 
 	*bhp = bread(dip->i_sbd, leaf_no);
-	if (error)
-		return error;
 	error = gfs2_check_meta(*bhp, GFS2_METATYPE_LF);
 	if(error)
 		brelse(*bhp);
-- 
1.7.6



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

* [Cluster-devel] [PATCH 4/5] gfs_controld: Remove dead code from loop()
  2011-09-06 12:00 [Cluster-devel] [PATCH 1/5] gfs2_edit: Initialize metafds fully in savemetaopen Andrew Price
  2011-09-06 12:00 ` [Cluster-devel] [PATCH 2/5] libgfs2: clean up some dead code in gfs2_writei Andrew Price
  2011-09-06 12:00 ` [Cluster-devel] [PATCH 3/5] libgfs2: Remove dead code from gfs2_get_leaf Andrew Price
@ 2011-09-06 12:00 ` Andrew Price
  2011-09-06 12:43   ` Steven Whitehouse
  2011-09-06 14:36   ` David Teigland
  2011-09-06 12:00 ` [Cluster-devel] [PATCH 5/5] gfs2_edit: Fix segfault in find by resource group Andrew Price
  3 siblings, 2 replies; 7+ messages in thread
From: Andrew Price @ 2011-09-06 12:00 UTC (permalink / raw)
  To: cluster-devel.redhat.com

This patch removes an if statement where the true branch is never taken.
At this point in the code, poll_timeout could only be 500 or -1.

Signed-off-by: Andrew Price <anprice@redhat.com>
---
 group/gfs_controld/main.c |    3 ---
 1 files changed, 0 insertions(+), 3 deletions(-)

diff --git a/group/gfs_controld/main.c b/group/gfs_controld/main.c
index 252965a..aa38839 100644
--- a/group/gfs_controld/main.c
+++ b/group/gfs_controld/main.c
@@ -1286,9 +1286,6 @@ static void loop(void)
 			if (dmsetup_wait) {
 				if (poll_timeout == -1)
 					poll_timeout = 1000;
-			} else {
-				if (poll_timeout == 1000)
-					poll_timeout = -1;
 			}
 		}
 		query_unlock();
-- 
1.7.6



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

* [Cluster-devel] [PATCH 5/5] gfs2_edit: Fix segfault in find by resource group
  2011-09-06 12:00 [Cluster-devel] [PATCH 1/5] gfs2_edit: Initialize metafds fully in savemetaopen Andrew Price
                   ` (2 preceding siblings ...)
  2011-09-06 12:00 ` [Cluster-devel] [PATCH 4/5] gfs_controld: Remove dead code from loop() Andrew Price
@ 2011-09-06 12:00 ` Andrew Price
  3 siblings, 0 replies; 7+ messages in thread
From: Andrew Price @ 2011-09-06 12:00 UTC (permalink / raw)
  To: cluster-devel.redhat.com

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



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

* [Cluster-devel] [PATCH 4/5] gfs_controld: Remove dead code from loop()
  2011-09-06 12:00 ` [Cluster-devel] [PATCH 4/5] gfs_controld: Remove dead code from loop() Andrew Price
@ 2011-09-06 12:43   ` Steven Whitehouse
  2011-09-06 14:36   ` David Teigland
  1 sibling, 0 replies; 7+ messages in thread
From: Steven Whitehouse @ 2011-09-06 12:43 UTC (permalink / raw)
  To: cluster-devel.redhat.com

Hi,

Those all look good to me,

Steve.

On Tue, 2011-09-06 at 13:00 +0100, Andrew Price wrote:
> This patch removes an if statement where the true branch is never taken.
> At this point in the code, poll_timeout could only be 500 or -1.
> 
> Signed-off-by: Andrew Price <anprice@redhat.com>
> ---
>  group/gfs_controld/main.c |    3 ---
>  1 files changed, 0 insertions(+), 3 deletions(-)
> 
> diff --git a/group/gfs_controld/main.c b/group/gfs_controld/main.c
> index 252965a..aa38839 100644
> --- a/group/gfs_controld/main.c
> +++ b/group/gfs_controld/main.c
> @@ -1286,9 +1286,6 @@ static void loop(void)
>  			if (dmsetup_wait) {
>  				if (poll_timeout == -1)
>  					poll_timeout = 1000;
> -			} else {
> -				if (poll_timeout == 1000)
> -					poll_timeout = -1;
>  			}
>  		}
>  		query_unlock();




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

* [Cluster-devel] [PATCH 4/5] gfs_controld: Remove dead code from loop()
  2011-09-06 12:00 ` [Cluster-devel] [PATCH 4/5] gfs_controld: Remove dead code from loop() Andrew Price
  2011-09-06 12:43   ` Steven Whitehouse
@ 2011-09-06 14:36   ` David Teigland
  1 sibling, 0 replies; 7+ messages in thread
From: David Teigland @ 2011-09-06 14:36 UTC (permalink / raw)
  To: cluster-devel.redhat.com

On Tue, Sep 06, 2011 at 01:00:16PM +0100, Andrew Price wrote:
> This patch removes an if statement where the true branch is never taken.
> At this point in the code, poll_timeout could only be 500 or -1.
> 
> Signed-off-by: Andrew Price <anprice@redhat.com>
> ---
>  group/gfs_controld/main.c |    3 ---
>  1 files changed, 0 insertions(+), 3 deletions(-)
> 
> diff --git a/group/gfs_controld/main.c b/group/gfs_controld/main.c
> index 252965a..aa38839 100644
> --- a/group/gfs_controld/main.c
> +++ b/group/gfs_controld/main.c
> @@ -1286,9 +1286,6 @@ static void loop(void)
>  			if (dmsetup_wait) {
>  				if (poll_timeout == -1)
>  					poll_timeout = 1000;
> -			} else {
> -				if (poll_timeout == 1000)
> -					poll_timeout = -1;

ok

>  			}
>  		}
>  		query_unlock();
> -- 
> 1.7.6



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

end of thread, other threads:[~2011-09-06 14:36 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-06 12:00 [Cluster-devel] [PATCH 1/5] gfs2_edit: Initialize metafds fully in savemetaopen Andrew Price
2011-09-06 12:00 ` [Cluster-devel] [PATCH 2/5] libgfs2: clean up some dead code in gfs2_writei Andrew Price
2011-09-06 12:00 ` [Cluster-devel] [PATCH 3/5] libgfs2: Remove dead code from gfs2_get_leaf Andrew Price
2011-09-06 12:00 ` [Cluster-devel] [PATCH 4/5] gfs_controld: Remove dead code from loop() Andrew Price
2011-09-06 12:43   ` Steven Whitehouse
2011-09-06 14:36   ` David Teigland
2011-09-06 12:00 ` [Cluster-devel] [PATCH 5/5] gfs2_edit: Fix segfault in find by resource group 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).