[Ocfs2-tools-devel] [PATCH 4/7] libocfs2: add two types of trees operation of xattr

Joel Becker Joel.Becker at oracle.com
Fri Oct 23 10:06:04 PDT 2009


On Tue, Oct 20, 2009 at 04:41:48PM +0800, Tiger Yang wrote:
> -errcode_t ocfs2_cached_inode_extend_allocation(ocfs2_cached_inode *ci,
> -					       uint32_t new_clusters)
> +errcode_t ocfs2_tree_extend_allocation(ocfs2_filesys *fs,
> +				       uint32_t new_clusters,
> +				       struct ocfs2_extent_tree *et)
>  {
>  	errcode_t ret = 0;
>  	uint32_t n_clusters = 0, cpos;
> -	uint64_t blkno, file_size;
> -	ocfs2_filesys *fs = ci->ci_fs;
> +	uint64_t blkno;
>  
> -	file_size = ci->ci_inode->i_size;
> -	cpos = (file_size + fs->fs_clustersize - 1) / fs->fs_clustersize;
> +	cpos = et->et_ops->eo_get_clusters(et);

	This will break for sparse files.  If i_clusters is less than
the actual file size due to holes, you'll get the wrong cpos.

Joel

-- 

Life's Little Instruction Book #222

	"Think twice before burdening a friend with a secret."

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