[Ocfs2-tools-devel] [PATCH 1/1] Add corrupt code for inline data in fswreck:Revised

Tao Ma tao.ma at oracle.com
Tue Aug 12 07:46:30 PDT 2008



tristan wrote:
>  Add corrupt code for inline data in fswreck,include both regular file
> and dir.
>  Mainly aims at corrupting the newly added checking codes in
> fsck.ocfs2.checks for inline-data.
> 
> Signed-off-by: Tristan Ye <tristan.ye at oracle.com>
> ---
>  fswreck/corrupt.c           |   13 +++++
>  fswreck/dir.c               |  107
> +++++++++++++++++++++++++++++++++++++++++++
>  fswreck/include/dir.h       |    2 +
>  fswreck/include/fsck_type.h |   20 ++++++++
>  fswreck/include/inode.h     |    2 +
>  fswreck/include/main.h      |    5 ++-
>  fswreck/inode.c             |  104
> +++++++++++++++++++++++++++++++++++++++++
>  fswreck/main.c              |    7 ++-
>  8 files changed, 258 insertions(+), 2 deletions(-)
> 
> diff --git a/fswreck/corrupt.c b/fswreck/corrupt.c
> index f698cb0..188b767 100644
> --- a/fswreck/corrupt.c
> +++ b/fswreck/corrupt.c
> @@ -147,6 +147,19 @@ void corrupt_file(ocfs2_filesys *fs, int code,
> uint16_t slotnum)
>  	case CORRUPT_DIR_NOT_CONNECTED:
>  		func = mess_up_dir_not_connected;
>  		break;
> +	case CORRUPT_REGULAR_INLINE_DATA_FLAG:
> +		func = mess_up_regular_inline_flag;
> +		break;
> +	case CORRUPT_REGULAR_INLINE_DATA_SIZE:
> +		func = mess_up_regular_inline_size;
> +		break;
> +	case CORRUPT_DIR_INLINE_DATA_FLAG:
> +		func = mess_up_dir_inline_flag;
> +		break;
> +	case CORRUPT_DIR_INLINE_DATA_SIZE:
> +		func = mess_up_dir_inline_size;
> +		break;
> +
>  	default:
>  		FSWRK_FATAL("Invalid code=%d", code);
>  	}
> diff --git a/fswreck/dir.c b/fswreck/dir.c
> index 3338a17..4009e2f 100644
> --- a/fswreck/dir.c
> +++ b/fswreck/dir.c
> @@ -452,3 +452,110 @@ void mess_up_dir_not_connected(ocfs2_filesys *fs,
> uint64_t blkno)
>  
>  	return;
>  }
> +
> +void create_inline_dir(ocfs2_filesys *fs, const char *dirname,
> +		       uint64_t blkno, uint64_t *retblkno)
why do you create this new function? It is almost the same as 
create_directory in this file(dir.c).
> +{
> +	errcode_t ret;
> +	uint64_t tmp_blkno;
> +
> +	ret = ocfs2_check_directory(fs, blkno);
> +	if (ret)
> +		FSWRK_COM_FATAL(progname, ret);
> +
> +	ret  = ocfs2_new_inode(fs, &tmp_blkno, S_IFDIR | 0755);
> +	if (ret)
> +		FSWRK_COM_FATAL(progname, ret);
> +
> +	ret = ocfs2_init_dir(fs, tmp_blkno, blkno);
> +	if (ret)
> +		FSWRK_COM_FATAL(progname, ret);
> +
> +	ret = ocfs2_link(fs, blkno, dirname, tmp_blkno, OCFS2_FT_DIR);
> +	if (ret)
> +		FSWRK_COM_FATAL(progname, ret);
> +
> +	*retblkno = tmp_blkno;
> +	return;
> +}
> diff --git a/fswreck/include/fsck_type.h b/fswreck/include/fsck_type.h
> index a6a4873..4785c3e 100644
> --- a/fswreck/include/fsck_type.h
> +++ b/fswreck/include/fsck_type.h
> @@ -112,6 +112,14 @@ enum fsck_type
>  	INODE_NOT_CONNECTED,
>  	INODE_COUNT,
>  	INODE_ORPHANED,
> +	REGULAR_INLINE_DATA_FLAG,
> +	REGULAR_INLINE_DATA_ID_COUNT,
> +	REGULAR_INLINE_DATA_I_CLUSTER,
> +	REGULAR_INLINE_DATA_I_SIZE,
> +	DIR_INLINE_DATA_FLAG,
> +	DIR_INLINE_DATA_ID_COUNT,
> +	DIR_INLINE_DATA_I_CLUSTER,
> +	DIR_INLINE_DATA_I_SIZE,
>  	NUM_FSCK_TYPE
>  };
As I have said in the previous mail, this number is copied from 
fsck.ocfs2/fsck.ocfs2.checks.8.in, it only contains 2 new fsck_type: 
INLINE_DATA_FLAG_INVALID and INLINE_DATA_COUNT_INVALID.

As for the check of i_size, you can add your test case in the corrupt 
code which verify it.

Regards,
Tao



More information about the Ocfs2-tools-devel mailing list