[Ocfs2-devel] [PATCH 12/15] ocfs2: Some tiny bug fixes for discontiguous block allocation.

Joel Becker Joel.Becker at oracle.com
Wed Mar 31 20:34:06 PDT 2010


On Thu, Apr 01, 2010 at 10:59:09AM +0800, Tao Ma wrote:
> -static inline int ocfs2_supports_discontig_bh(struct ocfs2_super *osb)
> +static inline int ocfs2_supports_discontig_bg(struct ocfs2_super *osb)

	D'oh!

> -	rec->e_blkno = p_blkno;
> +	rec->e_blkno = cpu_to_le64(p_blkno);

	D'oh!!

> +	le16_add_cpu(&bg->bg_free_bits_count,
> +		     clusters * le16_to_cpu(cl->cl_bpc));

	D'oh!!!
> @@ -511,8 +513,8 @@ static int ocfs2_block_group_grow_discontig(handle_t *handle,
>  	struct ocfs2_super *osb = OCFS2_SB(alloc_inode->i_sb);
>  	struct ocfs2_group_desc *bg =
>  		(struct ocfs2_group_desc *)bg_bh->b_data;
> -	unsigned int needed =
> -		ocfs2_bits_per_group(cl) - le16_to_cpu(bg->bg_bits);
> +	unsigned int needed = le16_to_cpu(cl->cl_cpg) -
> +			 le16_to_cpu(bg->bg_bits) / le16_to_cpu(cl->cl_bpc);

	Ouch!  But can you put parens around the divide?  Make the
intention clear.

> @@ -733,18 +734,20 @@ static int ocfs2_block_group_alloc(struct ocfs2_super *osb,
>  		goto bail;
>  	}
>  
> -	le32_add_cpu(&cl->cl_recs[bg->bg_chain].c_free,
> +	alloc_rec = le16_to_cpu(bg->bg_chain);
> +	le32_add_cpu(&cl->cl_recs[alloc_rec].c_free,
>  		     le16_to_cpu(bg->bg_free_bits_count));

	D'oh!!!!

> -	le32_add_cpu(&cl->cl_recs[bg->bg_chain].c_total,
> +	le32_add_cpu(&cl->cl_recs[alloc_rec].c_total,
>  		     le16_to_cpu(bg->bg_bits));
> -	cl->cl_recs[bg->bg_chain].c_blkno  = cpu_to_le64(bg_blkno);
> +	cl->cl_recs[alloc_rec].c_blkno  = cpu_to_le64(bg->bg_blkno);
>  	if (le16_to_cpu(cl->cl_next_free_rec) < le16_to_cpu(cl->cl_count))
>  		le16_add_cpu(&cl->cl_next_free_rec, 1);
>  
>  	le32_add_cpu(&fe->id1.bitmap1.i_used, le16_to_cpu(bg->bg_bits) -
>  					le16_to_cpu(bg->bg_free_bits_count));
>  	le32_add_cpu(&fe->id1.bitmap1.i_total, le16_to_cpu(bg->bg_bits));
> -	le32_add_cpu(&fe->i_clusters, le16_to_cpu(cl->cl_cpg));
> +	le32_add_cpu(&fe->i_clusters,
> +		     le16_to_cpu(bg->bg_bits) / le16_to_cpu(cl->cl_bpc));

	You don't need to change this.  Either we've allocated cpg or
we've failed out.

Joel

-- 

"There is shadow under this red rock.
 (Come in under the shadow of this red rock)
 And I will show you something different from either
 Your shadow at morning striding behind you
 Or your shadow at evening rising to meet you.
 I will show you fear in a handful of dust."

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