[Ocfs2-tools-devel] [PATCH 2/3] Ocfs2-tools: Implement new prompt codes of sparse file for fswreck.

Tao Ma tao.ma at oracle.com
Thu Jul 2 00:49:40 PDT 2009


Hi Tristan,

Tristan Ye wrote:
> Adding new corruptions of sparse file for fswreck after fsck.ocfs2
> supported new separated prompt codes.
> 
> Signed-off-by: Tristan Ye <tristan.ye at oracle.com>
> ---
>  fswreck/corrupt.c           |    6 ++++++
>  fswreck/include/fsck_type.h |    5 ++++-
>  fswreck/inode.c             |   30 +++++++++++++++++++++++++++---
>  fswreck/main.c              |    4 ++++
>  4 files changed, 41 insertions(+), 4 deletions(-)
> 
> diff --git a/fswreck/corrupt.c b/fswreck/corrupt.c
> index 151d308..a9e5188 100644
> --- a/fswreck/corrupt.c
> +++ b/fswreck/corrupt.c
> @@ -103,12 +115,25 @@ static void damage_inode(ocfs2_filesys *fs, uint64_t blkno,
> +	case INODE_SPARSE_SIZE:
> +		fprintf(stdout, "INODE_SPARSE_SIZE: "
> +			"Corrupt inode#%"PRIu64", change i_size"
> +			" from %"PRIu64" to %"PRIu64"\n",
> +			 blkno, di->i_size, (di->i_size + 100));
> +		di->i_size += fs->fs_clustersize;
you forget to change the fprintf. ;)

What' more, I suddenly recalled that actually for a sparse file, any 
larger inode size is allowed. And I just checked fsck.ocfs2 and it is 
right. Even with i_clusters = 0, it is safe to have i_size = 10000. So 
you corruption here doesn't work.

Actually now for a sparse file, we only check i_size if it is small 
enough that the last cluster is out of the range.
Let me give you an example.
if the last cluster's virtual offset is 10, then i_size should not be 
less than 9 * cluster_size(that will make the last cluster out of space).

So I guess the corruption for INODE_SPARSE_SIZE should be extend the 
file to some clusters while change i_size = 0. and it shold work.

Regards,
Tao



More information about the Ocfs2-tools-devel mailing list