[Ocfs2-tools-devel] [PATCH 2/2] Ocfs2-tools: Update fswreck part to meet fsck's enhancement of solving multiply-claimed clusters.

tristan.ye tristan.ye at oracle.com
Mon Aug 10 18:30:26 PDT 2009


Joel,

This patch need your sob:)

On Sun, 2009-08-02 at 15:32 +0800, Tristan Ye wrote:
> Add support of codes 'DUP_CLUSTERS_SYSFILE_CLONE, DUP_CLUSTERS_CLONE, DUP_CLUSTERS_DELETE'
> to fswreck to make it compatible with fsck part after joel's patches series of sovling
> multiply-claimed clusters in fsck.ocfs2 get pushed.
> 
> Signed-off-by: Tristan Ye <tristan.ye at oracle.com>
> ---
>  fswreck/corrupt.c           |    4 +++-
>  fswreck/include/fsck_type.h |    7 ++++++-
>  fswreck/inode.c             |   43 ++++++++++++++++++++++++++++++++++---------
>  fswreck/main.c              |    6 +++++-
>  4 files changed, 48 insertions(+), 12 deletions(-)
> 
> diff --git a/fswreck/corrupt.c b/fswreck/corrupt.c
> index 160c6dd..146e1c2 100644
> --- a/fswreck/corrupt.c
> +++ b/fswreck/corrupt.c
> @@ -252,7 +252,9 @@ void corrupt_file(ocfs2_filesys *fs, enum fsck_type type, uint16_t slotnum)
>  	case INODE_INLINE_CLUSTERS:
>  		func = mess_up_inline_inode;
>  		break;
> -	case DUPLICATE_CLUSTERS:
> +	case DUP_CLUSTERS_CLONE:
> +	case DUP_CLUSTERS_DELETE:
> +	case DUP_CLUSTERS_SYSFILE_CLONE:
>  		func = mess_up_dup_clusters;
>  		break;
>  	default:
> diff --git a/fswreck/include/fsck_type.h b/fswreck/include/fsck_type.h
> index 94f7694..77ff1fa 100644
> --- a/fswreck/include/fsck_type.h
> +++ b/fswreck/include/fsck_type.h
> @@ -121,7 +121,9 @@ enum fsck_type
>  	INLINE_DATA_COUNT_INVALID,
>  	INODE_INLINE_SIZE,
>  	INODE_INLINE_CLUSTERS,
> -	DUPLICATE_CLUSTERS,
> +	DUP_CLUSTERS_SYSFILE_CLONE,
> +	DUP_CLUSTERS_CLONE,
> +	DUP_CLUSTERS_DELETE,
>  	JOURNAL_FILE_INVALID,
>  	JOURNAL_UNKNOWN_FEATURE,
>  	JOURNAL_MISSING_FEATURE,
> @@ -204,5 +206,8 @@ enum fsck_type
>   * Inline file:	INLINE_DATA_FLAG_INVALID, INLINE_DATA_COUNT_INVALID
>   *		INODE_INLINE_SIZE, INODE_INLINE_CLUSTERS
>   *
> + * Duplicate clusters error:	DUP_CLUSTERS_CLONE, DUP_CLUSTERS_DELETE
> + *				DUP_CLUSTERS_SYSFILE_CLONE
> + *
>   */
>  #endif
> diff --git a/fswreck/inode.c b/fswreck/inode.c
> index 46f99a9..6b3bafa 100644
> --- a/fswreck/inode.c
> +++ b/fswreck/inode.c
> @@ -458,15 +458,40 @@ void mess_up_dup_clusters(ocfs2_filesys *fs, enum fsck_type type,
>  	di2->i_size = di1->i_size;
>  	di2->i_clusters = di1->i_clusters;
>  
> -	err = ocfs2_write_inode(fs, inode2_blkno, (char *)di2);
> -	if (err)
> -		FSWRK_COM_FATAL(progname, err);
> -
> -	fprintf(stdout, "DUPLICATE_CLUSTERS: "
> -		"Create two inodes #%"PRIu64" and #%"PRIu64
> -		" by allocating same cluster to them.",
> -		inode1_blkno, inode2_blkno);
> -
> +	if (type == DUP_CLUSTERS_SYSFILE_CLONE) {
> +
> +		di1->i_flags |= OCFS2_SYSTEM_FL;
> +		di2->i_flags |= OCFS2_SYSTEM_FL;
> +
> +		err = ocfs2_write_inode(fs, inode1_blkno, (char *)di1);
> +		if (err)
> +			FSWRK_COM_FATAL(progname, err);
> +		
> +		err = ocfs2_write_inode(fs, inode2_blkno, (char *)di2);
> +		if (err)
> +			FSWRK_COM_FATAL(progname, err);
> +
> +		fprintf(stdout, "DUP_CLUSTERS_SYSFILE_CLONE: "
> +			"Create two system inodes #%"PRIu64" and #%"PRIu64
> +			" by allocating same cluster to them.\n",
> +			inode1_blkno, inode2_blkno);
> +	} else {
> +		err = ocfs2_write_inode(fs, inode2_blkno, (char *)di2);
> +		if (err)
> +			FSWRK_COM_FATAL(progname, err);
> +
> +		if (type == DUP_CLUSTERS_CLONE)
> +			fprintf(stdout, "DUP_CLUSTERS_CLONE: "
> +				"Create two inodes #%"PRIu64" and #%"PRIu64
> +				" by allocating same cluster to them.\n",
> +				inode1_blkno, inode2_blkno);
> +		else
> +			fprintf(stdout, "DUP_CLUSTERS_DELETE: "
> +				"Create two inodes #%"PRIu64" and #%"PRIu64
> +				" by allocating same cluster to them.\n",
> +				inode1_blkno, inode2_blkno);
> +	}
> +	
>  	ocfs2_free(&buf);
>  }
>  
> diff --git a/fswreck/main.c b/fswreck/main.c
> index 3debe70..d08f51a 100644
> --- a/fswreck/main.c
> +++ b/fswreck/main.c
> @@ -149,8 +149,12 @@ static struct prompt_code prompt_codes[NUM_FSCK_TYPE] = {
>  			   "Corrupt inlined inode's i_size"),
>  	define_prompt_code(INODE_INLINE_CLUSTERS, corrupt_file,
>  			   "Corrupt inlined inode's i_clusters"),
> -	define_prompt_code(DUPLICATE_CLUSTERS, corrupt_file,
> +	define_prompt_code(DUP_CLUSTERS_CLONE, corrupt_file,
>  			   "Allocate same cluster to different files"),
> +	define_prompt_code(DUP_CLUSTERS_DELETE, corrupt_file,
> +			   "Allocate same cluster to different files"),
> +	define_prompt_code(DUP_CLUSTERS_SYSFILE_CLONE, corrupt_file,
> +			   "Allocate same cluster to different system files"),
>  	define_prompt_code(CHAIN_COUNT, corrupt_sys_file,
>  			   "Corrupt chain list's cl_count"),
>  	define_prompt_code(CHAIN_NEXT_FREE, corrupt_sys_file,




More information about the Ocfs2-tools-devel mailing list