cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
From: Steven Whitehouse <swhiteho@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [gfs2-utils PATCH 04/47] fsck.gfs2: Move function find_free_blk to util.c
Date: Wed, 15 May 2013 17:04:15 +0100	[thread overview]
Message-ID: <1368633855.2732.102.camel@menhir> (raw)
In-Reply-To: <32ea31551b2caf02f10b23451e2e782cb239f512.1368548305.git.rpeterso@redhat.com>

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__ */




  reply	other threads:[~2013-05-15 16:04 UTC|newest]

Thread overview: 59+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-14 16:21 [Cluster-devel] [gfs2-utils PATCH 01/47] libgfs2: externalize dir_split_leaf Bob Peterson
2013-05-14 16:21 ` [Cluster-devel] [gfs2-utils PATCH 02/47] libgfs2: allow dir_split_leaf to receive a leaf buffer Bob Peterson
2013-05-14 16:21 ` [Cluster-devel] [gfs2-utils PATCH 03/47] libgfs2: let dir_split_leaf receive a "broken" lindex Bob Peterson
2013-05-15 16:01   ` Steven Whitehouse
2013-05-20 16:02     ` Bob Peterson
2013-05-14 16:21 ` [Cluster-devel] [gfs2-utils PATCH 04/47] fsck.gfs2: Move function find_free_blk to util.c Bob Peterson
2013-05-15 16:04   ` Steven Whitehouse [this message]
2013-05-14 16:21 ` [Cluster-devel] [gfs2-utils PATCH 05/47] fsck.gfs2: Split out function to make sure lost+found exists Bob Peterson
2013-05-14 16:21 ` [Cluster-devel] [gfs2-utils PATCH 06/47] fsck.gfs2: Check for formal inode mismatch when adding to lost+found Bob Peterson
2013-05-15 16:08   ` Steven Whitehouse
2013-05-17 12:47     ` Bob Peterson
2013-05-17 12:55       ` Steven Whitehouse
2013-05-14 16:21 ` [Cluster-devel] [gfs2-utils PATCH 07/47] fsck.gfs2: shorten some debug messages in lost+found Bob Peterson
2013-05-14 16:21 ` [Cluster-devel] [gfs2-utils PATCH 08/47] fsck.gfs2: Move basic directory entry checks to separate function Bob Peterson
2013-05-14 16:21 ` [Cluster-devel] [gfs2-utils PATCH 09/47] fsck.gfs2: Add formal inode check to basic dirent checks Bob Peterson
2013-05-14 16:21 ` [Cluster-devel] [gfs2-utils PATCH 10/47] fsck.gfs2: Add new function to check dir hash tables Bob Peterson
2013-05-14 16:21 ` [Cluster-devel] [gfs2-utils PATCH 11/47] fsck.gfs2: Special case '..' when processing bad formal inode number Bob Peterson
2013-05-14 16:21 ` [Cluster-devel] [gfs2-utils PATCH 12/47] fsck.gfs2: Move function to read directory hash table to util.c Bob Peterson
2013-05-14 16:21 ` [Cluster-devel] [gfs2-utils PATCH 13/47] fsck.gfs2: Misc cleanups Bob Peterson
2013-05-14 16:21 ` [Cluster-devel] [gfs2-utils PATCH 14/47] fsck.gfs2: Verify dirent hash values correspond to proper leaf block Bob Peterson
2013-05-14 16:21 ` [Cluster-devel] [gfs2-utils PATCH 15/47] fsck.gfs2: re-read hash table if directory height or depth changes Bob Peterson
2013-05-14 16:21 ` [Cluster-devel] [gfs2-utils PATCH 16/47] fsck.gfs2: fix leaf blocks, don't try to patch the hash table Bob Peterson
2013-05-14 16:21 ` [Cluster-devel] [gfs2-utils PATCH 17/47] fsck.gfs2: check leaf depth when validating leaf blocks Bob Peterson
2013-05-14 16:21 ` [Cluster-devel] [gfs2-utils PATCH 18/47] fsck.gfs2: small cleanups Bob Peterson
2013-05-14 16:21 ` [Cluster-devel] [gfs2-utils PATCH 19/47] fsck.gfs2: reprocess inodes when blocks are added Bob Peterson
2013-05-14 16:21 ` [Cluster-devel] [gfs2-utils PATCH 20/47] fsck.gfs2: Remove redundant leaf depth check Bob Peterson
2013-05-14 16:21 ` [Cluster-devel] [gfs2-utils PATCH 21/47] fsck.gfs2: link dinodes that only have extended attribute problems Bob Peterson
2013-05-14 16:21 ` [Cluster-devel] [gfs2-utils PATCH 22/47] fsck.gfs2: Add clarifying message to duplicate processing Bob Peterson
2013-05-14 16:21 ` [Cluster-devel] [gfs2-utils PATCH 23/47] fsck.gfs2: separate function to calculate metadata block header size Bob Peterson
2013-05-14 16:21 ` [Cluster-devel] [gfs2-utils PATCH 24/47] fsck.gfs2: Rework the "undo" functions Bob Peterson
2013-05-16 13:27   ` Steven Whitehouse
2013-05-16 13:49     ` Bob Peterson
2013-05-16 14:02       ` Steven Whitehouse
2013-05-16 15:02         ` Bob Peterson
2013-05-16 15:24           ` Steven Whitehouse
2013-05-20 13:08             ` Bob Peterson
2013-05-14 16:21 ` [Cluster-devel] [gfs2-utils PATCH 25/47] fsck.gfs2: Check for interrupt when resolving duplicates Bob Peterson
2013-05-14 16:21 ` [Cluster-devel] [gfs2-utils PATCH 26/47] fsck.gfs2: Consistent naming of struct duptree variables Bob Peterson
2013-05-14 16:21 ` [Cluster-devel] [gfs2-utils PATCH 27/47] fsck.gfs2: Keep proper counts when duplicates are found Bob Peterson
2013-05-14 16:21 ` [Cluster-devel] [gfs2-utils PATCH 28/47] fsck.gfs2: print metadata block reference on data errors Bob Peterson
2013-05-14 16:21 ` [Cluster-devel] [gfs2-utils PATCH 29/47] fsck.gfs2: print block count values when fixing them Bob Peterson
2013-05-14 16:21 ` [Cluster-devel] [gfs2-utils PATCH 30/47] fsck.gfs2: Do not invalidate metablocks of dinodes with invalid mode Bob Peterson
2013-05-14 16:21 ` [Cluster-devel] [gfs2-utils PATCH 31/47] fsck.gfs2: Log when unrecoverable data block errors are encountered Bob Peterson
2013-05-14 16:21 ` [Cluster-devel] [gfs2-utils PATCH 32/47] fsck.gfs2: don't remove buffers from the list when errors are found Bob Peterson
2013-05-14 16:21 ` [Cluster-devel] [gfs2-utils PATCH 33/47] fsck.gfs2: Don't flag GFS1 non-dinode blocks as duplicates Bob Peterson
2013-05-14 16:21 ` [Cluster-devel] [gfs2-utils PATCH 34/47] fsck.gfs2: externalize check_leaf Bob Peterson
2013-05-14 16:21 ` [Cluster-devel] [gfs2-utils PATCH 35/47] fsck.gfs2: pass2: check leaf blocks when fixing hash table Bob Peterson
2013-05-14 16:21 ` [Cluster-devel] [gfs2-utils PATCH 36/47] fsck.gfs2: standardize check_metatree return codes Bob Peterson
2013-05-14 16:22 ` [Cluster-devel] [gfs2-utils PATCH 37/47] fsck.gfs2: don't invalidate files with duplicate data block refs Bob Peterson
2013-05-14 16:22 ` [Cluster-devel] [gfs2-utils PATCH 38/47] fsck.gfs2: check for duplicate first references Bob Peterson
2013-05-14 16:22 ` [Cluster-devel] [gfs2-utils PATCH 39/47] fsck.gfs2: When flagging a duplicate reference, show valid or invalid Bob Peterson
2013-05-14 16:22 ` [Cluster-devel] [gfs2-utils PATCH 40/47] fsck.gfs2: major duplicate reference reform Bob Peterson
2013-05-14 16:22 ` [Cluster-devel] [gfs2-utils PATCH 41/47] fsck.gfs2: Remove all bad eattr blocks Bob Peterson
2013-05-14 16:22 ` [Cluster-devel] [gfs2-utils PATCH 42/47] fsck.gfs2: Remove unused variable Bob Peterson
2013-05-14 16:22 ` [Cluster-devel] [gfs2-utils PATCH 43/47] fsck.gfs2: double-check transitions from dinode to data Bob Peterson
2013-05-14 16:22 ` [Cluster-devel] [gfs2-utils PATCH 44/47] fsck.gfs2: Stop "undo" process when error data block is reached Bob Peterson
2013-05-14 16:22 ` [Cluster-devel] [gfs2-utils PATCH 45/47] fsck.gfs2: Don't allocate leaf blocks in pass1 Bob Peterson
2013-05-14 16:22 ` [Cluster-devel] [gfs2-utils PATCH 46/47] fsck.gfs2: take hash table start boundaries into account Bob Peterson
2013-05-14 16:22 ` [Cluster-devel] [gfs2-utils PATCH 47/47] fsck.gfs2: delete all duplicates from unrecoverable damaged dinodes Bob Peterson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1368633855.2732.102.camel@menhir \
    --to=swhiteho@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).