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

Re: [Cluster-devel] [gfs2-utils PATCH 04/47] fsck.gfs2: Move function find_free_blk to util.c



Hi,

On Tue, 2013-05-14 at 11:21 -0500, Bob Peterson wrote:
> In a future patch to fsck, function find_free_blk will be called in
> order to correctly report blocks that will need to be allocated for
> things such as leaf splits. This patch moves function find_free_blk
> to a more centralized place, util.c, to that end.
> 
> rhbz#902920
> ---
>  gfs2/fsck/lost_n_found.c | 39 ---------------------------------------
>  gfs2/fsck/util.c         | 39 +++++++++++++++++++++++++++++++++++++++
>  gfs2/fsck/util.h         |  2 ++
>  3 files changed, 41 insertions(+), 39 deletions(-)
> 
> diff --git a/gfs2/fsck/lost_n_found.c b/gfs2/fsck/lost_n_found.c
> index 570f3a8..1fb5076 100644
> --- a/gfs2/fsck/lost_n_found.c
> +++ b/gfs2/fsck/lost_n_found.c
> @@ -88,45 +88,6 @@ static void add_dotdot(struct gfs2_inode *ip)
>  	}
>  }
>  
> -static uint64_t find_free_blk(struct gfs2_sbd *sdp)
> -{
> -	struct osi_node *n, *next = NULL;
> -	struct rgrp_tree *rl = NULL;
> -	struct gfs2_rindex *ri;
> -	struct gfs2_rgrp *rg;
> -	unsigned int block, bn = 0, x = 0, y = 0;
> -	unsigned int state;
> -	struct gfs2_buffer_head *bh;
> -
> -	memset(&rg, 0, sizeof(rg));
> -	for (n = osi_first(&sdp->rgtree); n; n = next) {
> -		next = osi_next(n);
> -		rl = (struct rgrp_tree *)n;
> -		if (rl->rg.rg_free)
> -			break;
> -	}
> -
This just looks wrong - it seems to not care where it is allocating
blocks, just grabbing the first one that comes along. This should be
changed so that it can allocate extents and also so that it puts blocks
in a sensible place, but I guess we don't have to do that now - A
thought for the future at least,

Steve.

> -	if (n == NULL)
> -		return 0;
> -
> -	ri = &rl->ri;
> -	rg = &rl->rg;
> -
> -	for (block = 0; block < ri->ri_length; block++) {
> -		bh = rl->bh[block];
> -		x = (block) ? sizeof(struct gfs2_meta_header) : sizeof(struct gfs2_rgrp);
> -
> -		for (; x < sdp->bsize; x++)
> -			for (y = 0; y < GFS2_NBBY; y++) {
> -				state = (bh->b_data[x] >> (GFS2_BIT_SIZE * y)) & 0x03;
> -				if (state == GFS2_BLKST_FREE)
> -					return ri->ri_data0 + bn;
> -				bn++;
> -			}
> -	}
> -	return 0;
> -}
> -
>  /* add_inode_to_lf - Add dir entry to lost+found for the inode
>   * @ip: inode to add to lost + found
>   *
> diff --git a/gfs2/fsck/util.c b/gfs2/fsck/util.c
> index 7c89155..94d532e 100644
> --- a/gfs2/fsck/util.c
> +++ b/gfs2/fsck/util.c
> @@ -615,3 +615,42 @@ bad_dinode:
>  	stack;
>  	return -EPERM;
>  }
> +
> +uint64_t find_free_blk(struct gfs2_sbd *sdp)
> +{
> +	struct osi_node *n, *next = NULL;
> +	struct rgrp_tree *rl = NULL;
> +	struct gfs2_rindex *ri;
> +	struct gfs2_rgrp *rg;
> +	unsigned int block, bn = 0, x = 0, y = 0;
> +	unsigned int state;
> +	struct gfs2_buffer_head *bh;
> +
> +	memset(&rg, 0, sizeof(rg));
> +	for (n = osi_first(&sdp->rgtree); n; n = next) {
> +		next = osi_next(n);
> +		rl = (struct rgrp_tree *)n;
> +		if (rl->rg.rg_free)
> +			break;
> +	}
> +
> +	if (n == NULL)
> +		return 0;
> +
> +	ri = &rl->ri;
> +	rg = &rl->rg;
> +
> +	for (block = 0; block < ri->ri_length; block++) {
> +		bh = rl->bh[block];
> +		x = (block) ? sizeof(struct gfs2_meta_header) : sizeof(struct gfs2_rgrp);
> +
> +		for (; x < sdp->bsize; x++)
> +			for (y = 0; y < GFS2_NBBY; y++) {
> +				state = (bh->b_data[x] >> (GFS2_BIT_SIZE * y)) & 0x03;
> +				if (state == GFS2_BLKST_FREE)
> +					return ri->ri_data0 + bn;
> +				bn++;
> +			}
> +	}
> +	return 0;
> +}
> diff --git a/gfs2/fsck/util.h b/gfs2/fsck/util.h
> index 80ed0c4..1a4811c 100644
> --- a/gfs2/fsck/util.h
> +++ b/gfs2/fsck/util.h
> @@ -184,6 +184,8 @@ extern char generic_interrupt(const char *caller, const char *where,
>                         const char *progress, const char *question,
>                         const char *answers);
>  extern char gfs2_getch(void);
> +extern uint64_t find_free_blk(struct gfs2_sbd *sdp);
> +
>  #define stack log_debug("<backtrace> - %s()\n", __func__)
>  
>  #endif /* __UTIL_H__ */



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