[Cluster-devel] [PATCH 01/11] gfs2: Always check the result of gfs2_rbm_from_block

Steven Whitehouse swhiteho at redhat.com
Mon Oct 8 10:12:17 UTC 2018


Hi,


On 05/10/18 20:18, Andreas Gruenbacher wrote:
> When gfs2_rbm_from_block fails, the rbm it returns is undefined, so we
> always want to make sure gfs2_rbm_from_block has succeeded before
> looking at the rbm.
>
> Signed-off-by: Andreas Gruenbacher <agruenba at redhat.com>
> ---
>   fs/gfs2/rgrp.c | 7 ++++---
>   1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c
> index fc181c81cca2..c9caddc2627c 100644
> --- a/fs/gfs2/rgrp.c
> +++ b/fs/gfs2/rgrp.c
> @@ -2227,7 +2227,7 @@ static struct gfs2_rgrpd *rgblk_free(struct gfs2_sbd *sdp, u64 bstart,
>   		return NULL;
>   	}
>   
> -	gfs2_rbm_from_block(&rbm, bstart);
> +	BUG_ON(gfs2_rbm_from_block(&rbm, bstart));
>   	while (blen--) {
>   		bi = rbm_bi(&rbm);
>   		if (bi != bi_prev) {
> @@ -2360,7 +2360,7 @@ static void gfs2_set_alloc_start(struct gfs2_rbm *rbm,
>   	else
>   		goal = rbm->rgd->rd_last_alloc + rbm->rgd->rd_data0;
>   
> -	gfs2_rbm_from_block(rbm, goal);
> +	BUG_ON(gfs2_rbm_from_block(rbm, goal));
>   }
Could we make this a warn once with a failure path here? It is a bit 
more friendly than BUG_ON,

Steve.

>   
>   /**
> @@ -2569,7 +2569,8 @@ int gfs2_check_blk_type(struct gfs2_sbd *sdp, u64 no_addr, unsigned int type)
>   
>   	rbm.rgd = rgd;
>   	error = gfs2_rbm_from_block(&rbm, no_addr);
> -	WARN_ON_ONCE(error != 0);
> +	if (WARN_ON_ONCE(error))
> +		goto fail;
>   
>   	if (gfs2_testbit(&rbm, false) != type)
>   		error = -ESTALE;




More information about the Cluster-devel mailing list