[Ocfs2-devel] [PATCH 17/41] ocfs2: Add CoW support.

Joel Becker Joel.Becker at oracle.com
Fri Aug 21 13:58:00 PDT 2009


On Fri, Aug 21, 2009 at 11:39:44AM -0700, Joel Becker wrote:
> On Fri, Aug 21, 2009 at 04:24:25PM +0800, Tao Ma wrote:
> > 	As our talk in irc, here is the updated one. Please review.
> 
> 	Perfect.
> 	Here's a version with the math wrapped in shiny readable
> inlines.  Some comments were updated too.  I didn't actually change the
> logic, so please verify I got it right.
> 
> Joel
> 
> diff --git a/fs/ocfs2/refcounttree.c b/fs/ocfs2/refcounttree.c
> index d59860d..8f0d210 100644
> --- a/fs/ocfs2/refcounttree.c
> +++ b/fs/ocfs2/refcounttree.c
> @@ -2499,7 +2499,52 @@ out:
>  	return ret;
>  }
>  
> -#define	MAX_COW_BYTES	1048576
> +#define	MAX_CONTIG_BYTES	1048576
> +
> +static inline unsigned int ocfs2_cow_contig_clusters(struct super_block *sb)
> +{
> +	return ocfs2_clusters_for_bytes(sb, MAX_CONTIG_BYTES);
> +}
> +
> +static inline unsigned int ocfs2_cow_contig_mask(struct super_block *sb)
> +{
> +	return ~(ocfs2_cow_contig_clusters(sb) - 1);
> +}
> +
> +/*
> + * Given an extent that starts at 'start and an I/O that starts at
> + * 'cpos, find an offset (start * (n * contig_clusters)) that is closest

	Erg, "(start + (n * contig_clusters))".

Joel

-- 

"The only way to get rid of a temptation is to yield to it."
         - Oscar Wilde 

Joel Becker
Principal Software Developer
Oracle
E-mail: joel.becker at oracle.com
Phone: (650) 506-8127



More information about the Ocfs2-devel mailing list