cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
* [Cluster-devel] [GFS2] gfs2: handle NULL rgd in set_rgrp_preferences
@ 2015-05-05 14:51 Abhi Das
  2015-05-05 16:43 ` Bob Peterson
  0 siblings, 1 reply; 2+ messages in thread
From: Abhi Das @ 2015-05-05 14:51 UTC (permalink / raw)
  To: cluster-devel.redhat.com

The function set_rgrp_preferences() does not handle the (rarely
returned) NULL value from gfs2_rgrpd_get_next() and this patch
fixes that.

The fs image in question is only 150MB in size which allows for
only 1 rgrp to be created. The in-memory rb tree has only 1 node
and when gfs2_rgrpd_get_next() is called on this sole rgrp, it
returns NULL. (Default behavior is to wrap around the rb tree and
return the first node to give the illusion of a circular linked
list. In the case of only 1 rgrp, we can't have
gfs2_rgrpd_get_next() return the same rgrp (first, last, next all
point to the same rgrp)... that would cause unintended consequences
and infinite loops.)

Resolves: rhbz#1211663
Signed-off-by: Abhi Das <adas@redhat.com>
---
 fs/gfs2/rgrp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c
index cb27065..900e515 100644
--- a/fs/gfs2/rgrp.c
+++ b/fs/gfs2/rgrp.c
@@ -978,10 +978,10 @@ static void set_rgrp_preferences(struct gfs2_sbd *sdp)
 		rgd->rd_flags |= GFS2_RDF_PREFERRED;
 		for (i = 0; i < sdp->sd_journals; i++) {
 			rgd = gfs2_rgrpd_get_next(rgd);
-			if (rgd == first)
+			if (!rgd || rgd == first)
 				break;
 		}
-	} while (rgd != first);
+	} while (rgd && rgd != first);
 }
 
 /**
-- 
1.8.1.4



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

* [Cluster-devel] [GFS2] gfs2: handle NULL rgd in set_rgrp_preferences
  2015-05-05 14:51 [Cluster-devel] [GFS2] gfs2: handle NULL rgd in set_rgrp_preferences Abhi Das
@ 2015-05-05 16:43 ` Bob Peterson
  0 siblings, 0 replies; 2+ messages in thread
From: Bob Peterson @ 2015-05-05 16:43 UTC (permalink / raw)
  To: cluster-devel.redhat.com

----- Original Message -----
> The function set_rgrp_preferences() does not handle the (rarely
> returned) NULL value from gfs2_rgrpd_get_next() and this patch
> fixes that.
> 
> The fs image in question is only 150MB in size which allows for
> only 1 rgrp to be created. The in-memory rb tree has only 1 node
> and when gfs2_rgrpd_get_next() is called on this sole rgrp, it
> returns NULL. (Default behavior is to wrap around the rb tree and
> return the first node to give the illusion of a circular linked
> list. In the case of only 1 rgrp, we can't have
> gfs2_rgrpd_get_next() return the same rgrp (first, last, next all
> point to the same rgrp)... that would cause unintended consequences
> and infinite loops.)
> 
> Resolves: rhbz#1211663
> Signed-off-by: Abhi Das <adas@redhat.com>
> ---
>  fs/gfs2/rgrp.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c
> index cb27065..900e515 100644
> --- a/fs/gfs2/rgrp.c
> +++ b/fs/gfs2/rgrp.c
> @@ -978,10 +978,10 @@ static void set_rgrp_preferences(struct gfs2_sbd *sdp)
>  		rgd->rd_flags |= GFS2_RDF_PREFERRED;
>  		for (i = 0; i < sdp->sd_journals; i++) {
>  			rgd = gfs2_rgrpd_get_next(rgd);
> -			if (rgd == first)
> +			if (!rgd || rgd == first)
>  				break;
>  		}
> -	} while (rgd != first);
> +	} while (rgd && rgd != first);
>  }
>  
>  /**
> --
> 1.8.1.4
> 
> 

Hi,

Thanks. Now in the for-next branch of the linux-gfs2 git tree.
FYI: I removed "Resolves:" for upstream.

Regards,

Bob Peterson
Red Hat File Systems



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

end of thread, other threads:[~2015-05-05 16:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-05 14:51 [Cluster-devel] [GFS2] gfs2: handle NULL rgd in set_rgrp_preferences Abhi Das
2015-05-05 16:43 ` Bob Peterson

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).