[Ocfs2-tools-devel] [PATCH 1/1] fsck.ocfs2: Reinitialize o2fsck_state when we reset fs_blocks.

Joel Becker Joel.Becker at oracle.com
Tue Jul 29 15:26:13 PDT 2008


On Tue, Jul 29, 2008 at 05:17:01AM +0800, Tao Ma wrote:
> Hi joel,
> 	You are right, here is the revised patch. Please review. Thanks.
> 
> In fsck.ocfs2, when we find fs_blocks in super block isn't the
> same as the number stored in global_bitmap, we choose to trust
> global_bitmap. In this case, we have to reinitialize the bitmap
> in o2fsck_state since they are fs_blocks based. This bug blocks
> the test case of fsck-test.sh in ocfs2-test.
> 
> Signed-off-by: Tao Ma <tao.ma at oracle.com>
Signed-off-by: Joel Becker <joel.becker at oracle.com>

> ---
>  fsck.ocfs2/fsck.c         |   34 ++++++++++++++++++++++++++++++++++
>  fsck.ocfs2/include/fsck.h |    2 ++
>  fsck.ocfs2/pass0.c        |    6 ++++++
>  fsck.ocfs2/pass1.c        |    2 +-
>  4 files changed, 43 insertions(+), 1 deletions(-)
> 
> diff --git a/fsck.ocfs2/fsck.c b/fsck.ocfs2/fsck.c
> index 4d6070b..6669e56 100644
> --- a/fsck.ocfs2/fsck.c
> +++ b/fsck.ocfs2/fsck.c
> @@ -73,6 +73,8 @@ static char *whoami = "fsck.ocfs2";
>  static o2fsck_state _ost;
>  static int cluster_locked = 0;
>  
> +static void mark_magical_clusters(o2fsck_state *ost);
> +
>  static void handle_signal(int sig)
>  {
>  	switch (sig) {
> @@ -194,6 +196,38 @@ static errcode_t o2fsck_state_init(ocfs2_filesys *fs, o2fsck_state *ost)
>  	return 0;
>  }
>  
> +errcode_t o2fsck_state_reinit(ocfs2_filesys *fs, o2fsck_state *ost)
> +{
> +	errcode_t ret;
> +
> +	ocfs2_bitmap_free(ost->ost_bad_inodes);
> +	ost->ost_bad_inodes = NULL;
> +
> +	ocfs2_bitmap_free(ost->ost_dir_inodes);
> +	ost->ost_dir_inodes = NULL;
> +
> +	ocfs2_bitmap_free(ost->ost_reg_inodes);
> +	ost->ost_reg_inodes = NULL;
> +
> +	ocfs2_bitmap_free(ost->ost_allocated_clusters);
> +	ost->ost_allocated_clusters = NULL;
> +
> +	o2fsck_icount_free(ost->ost_icount_in_inodes);
> +	ost->ost_icount_in_inodes = NULL;
> +
> +	o2fsck_icount_free(ost->ost_icount_refs);
> +	ost->ost_icount_refs = NULL;
> +
> +	ret = o2fsck_state_init(fs, ost);
> +	if (ret) {
> +		com_err(whoami, ret, "while intializing o2fsck_state.");
> +		return ret;
> +	}
> +
> +	mark_magical_clusters(ost);
> +	return 0;
> +}
> +
>  static errcode_t check_superblock(o2fsck_state *ost)
>  {
>  	struct ocfs2_dinode *di = ost->ost_fs->fs_super;
> diff --git a/fsck.ocfs2/include/fsck.h b/fsck.ocfs2/include/fsck.h
> index f3a8105..eccd7ab 100644
> --- a/fsck.ocfs2/include/fsck.h
> +++ b/fsck.ocfs2/include/fsck.h
> @@ -73,6 +73,8 @@ typedef struct _o2fsck_state {
>  			ost_fix_fs_gen:1;
>  } o2fsck_state;
>  
> +errcode_t o2fsck_state_reinit(ocfs2_filesys *fs, o2fsck_state *ost);
> +
>  /* The idea is to let someone off-site run fsck and have it give us 
>   * enough information to diagnose problems with */
>  extern int verbose;
> diff --git a/fsck.ocfs2/pass0.c b/fsck.ocfs2/pass0.c
> index 68dd930..90c0ef9 100644
> --- a/fsck.ocfs2/pass0.c
> +++ b/fsck.ocfs2/pass0.c
> @@ -1100,6 +1100,12 @@ errcode_t o2fsck_pass0(o2fsck_state *ost)
>  			fs->fs_clusters = di->i_clusters;
>  			fs->fs_blocks = ocfs2_clusters_to_blocks(fs,
>  							 fs->fs_clusters);
> +			ret = o2fsck_state_reinit(fs, ost);
> +			if (ret) {
> +				com_err(whoami, ret, "while reinit "
> +					"o2fsck_state.");
> +				goto out;
> +			}
>  		}
>  	}
>  
> diff --git a/fsck.ocfs2/pass1.c b/fsck.ocfs2/pass1.c
> index 175ac38..dddc1f9 100644
> --- a/fsck.ocfs2/pass1.c
> +++ b/fsck.ocfs2/pass1.c
> @@ -762,7 +762,7 @@ static errcode_t o2fsck_check_blocks(ocfs2_filesys *fs, o2fsck_state *ost,
>  				     uint64_t blkno, struct ocfs2_dinode *di)
>  {
>  	uint64_t expected = 0, unexpected = 0;
> -	errcode_t ret;
> +	errcode_t ret = 0;
>  	struct verifying_blocks vb = {
>  		.vb_ost = ost,
>  		.vb_di = di,
> -- 
> 1.5.4.GIT
> 
> 
> _______________________________________________
> Ocfs2-tools-devel mailing list
> Ocfs2-tools-devel at oss.oracle.com
> http://oss.oracle.com/mailman/listinfo/ocfs2-tools-devel

-- 

Life's Little Instruction Book #452

	"Never compromise your integrity."

Joel Becker
Principal Software Developer
Oracle
E-mail: joel.becker at oracle.com
Phone: (650) 506-8127



More information about the Ocfs2-tools-devel mailing list