[Ocfs2-tools-devel] [PATCH 5/6] fsck.ocfs2: Adjust replay_orphan_dir and export it from pass4.

Sunil Mushran sunil.mushran at oracle.com
Tue Sep 16 18:30:23 PDT 2008


Looks good.

Tao Ma wrote:
> replay_orphan_dir will be called in slot recovery, so export it.
> In slot recovery, we should exit the replay process if we meet with any
> error, while in pass4, we should go on the process, so add one parameter
> for it.
>
> Signed-off-by: Tao Ma <tao.ma at oracle.com>
> ---
>  fsck.ocfs2/include/fsck.h  |    1 +
>  fsck.ocfs2/include/pass4.h |    1 +
>  fsck.ocfs2/pass4.c         |   39 ++++++++++++++++++++++++++-------------
>  3 files changed, 28 insertions(+), 13 deletions(-)
>
> diff --git a/fsck.ocfs2/include/fsck.h b/fsck.ocfs2/include/fsck.h
> index eab7197..28a3264 100644
> --- a/fsck.ocfs2/include/fsck.h
> +++ b/fsck.ocfs2/include/fsck.h
> @@ -72,6 +72,7 @@ typedef struct _o2fsck_state {
>   					     * that still indicated mounted */
>  			ost_fix_fs_gen:1,
>  			ost_has_journal_dirty:1;
> +	errcode_t ost_err;
>  } o2fsck_state;
>  
>  errcode_t o2fsck_state_reinit(ocfs2_filesys *fs, o2fsck_state *ost);
> diff --git a/fsck.ocfs2/include/pass4.h b/fsck.ocfs2/include/pass4.h
> index b240182..0340dfa 100644
> --- a/fsck.ocfs2/include/pass4.h
> +++ b/fsck.ocfs2/include/pass4.h
> @@ -26,6 +26,7 @@
>  
>  #include "fsck.h"
>  
> +errcode_t replay_orphan_dir(o2fsck_state *ost, int exit_on_err);
>  errcode_t o2fsck_pass4(o2fsck_state *ost);
>  
>  #endif /* __O2FSCK_PASS4_H__ */
> diff --git a/fsck.ocfs2/pass4.c b/fsck.ocfs2/pass4.c
> index 4c5d112..2723fe9 100644
> --- a/fsck.ocfs2/pass4.c
> +++ b/fsck.ocfs2/pass4.c
> @@ -104,7 +104,7 @@ static int replay_orphan_iterate(struct ocfs2_dir_entry *dirent,
>  {
>  	o2fsck_state *ost = priv_data;
>  	int ret_flags = 0;
> -	errcode_t ret;
> +	errcode_t ret = 0;
>  
>  	if (!(ost->ost_fs->fs_flags & OCFS2_FLAG_RW)) {
>  		printf("** Skipping orphan dir replay because -n was "
> @@ -136,21 +136,28 @@ static int replay_orphan_iterate(struct ocfs2_dir_entry *dirent,
>  		goto out;
>  	}
>  
> -	/* this matches a special case in o2fsck_verify_inode_fields() where
> -	 * orphan dir members are recorded as having 1 link count, even
> -	 * though they have 0 on disk */
> -	o2fsck_icount_delta(ost->ost_icount_in_inodes, dirent->inode, -1);
> -
> -	/* dirs have this dirent ref and their '.' dirent */
> -	if (dirent->file_type == OCFS2_FT_DIR)
> -		o2fsck_icount_delta(ost->ost_icount_refs, dirent->inode, -2);
> -	else
> -		o2fsck_icount_delta(ost->ost_icount_refs, dirent->inode, -1);
> +	/* Only calculate icount in force check. */
> +	if (ost->ost_force) {
> +		/* this matches a special case in o2fsck_verify_inode_fields()
> +		 * where orphan dir members are recorded as having 1 link count,
> +		 * even though they have 0 on disk */
> +		o2fsck_icount_delta(ost->ost_icount_in_inodes,
> +				    dirent->inode, -1);
> +
> +		/* dirs have this dirent ref and their '.' dirent */
> +		if (dirent->file_type == OCFS2_FT_DIR)
> +			o2fsck_icount_delta(ost->ost_icount_refs,
> +					    dirent->inode, -2);
> +		else
> +			o2fsck_icount_delta(ost->ost_icount_refs,
> +					    dirent->inode, -1);
> +	}
>  
>  	dirent->inode = 0;
>  	ret_flags |= OCFS2_DIRENT_CHANGED;
>  
>  out:
> +	ost->ost_err = ret;
>  	return ret_flags;
>  }
>  
> @@ -186,7 +193,7 @@ bail:
>  	return ret;
>  }
>  
> -static errcode_t replay_orphan_dir(o2fsck_state *ost)
> +errcode_t replay_orphan_dir(o2fsck_state *ost, int exit_on_err)
>  {
>  	errcode_t ret = OCFS2_ET_CORRUPT_SUPERBLOCK;
>  	char name[PATH_MAX];
> @@ -225,9 +232,15 @@ static errcode_t replay_orphan_dir(o2fsck_state *ost)
>  			}
>  		}
>  
> +		ost->ost_err = 0;
>  		ret = ocfs2_dir_iterate(ost->ost_fs, ino,
>  					OCFS2_DIRENT_FLAG_EXCLUDE_DOTS, NULL,
>  					replay_orphan_iterate, ost);
> +
> +		if (!ret)
> +			ret = ost->ost_err;
> +		if (ret && exit_on_err)
> +			break;
>  	}
>  
>  out:
> @@ -274,7 +287,7 @@ errcode_t o2fsck_pass4(o2fsck_state *ost)
>  
>  	printf("Pass 4a: checking for orphaned inodes\n");
>  
> -	ret = replay_orphan_dir(ost);
> +	ret = replay_orphan_dir(ost, 0);
>  	if (ret) {
>  		com_err(whoami, ret, "while trying to replay the orphan "
>  			"directory");
>   




More information about the Ocfs2-tools-devel mailing list