Re: [PATCH 13/16] pnfs: wave 3: filelayout i/o helpers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Feb 15, 2011, at 4:31 AM, Christoph Hellwig wrote:

> On Mon, Feb 14, 2011 at 02:18:33PM -0500, andros@xxxxxxxxxx wrote:
>> +static loff_t
>> +filelayout_get_dserver_offset(struct pnfs_layout_segment *lseg, loff_t offset)
>> +{
>> +	struct nfs4_filelayout_segment *flseg = FILELAYOUT_LSEG(lseg);
>> +
>> +	switch (flseg->stripe_type) {
>> +	case STRIPE_SPARSE:
>> +		return offset;
>> +
>> +	case STRIPE_DENSE:
>> +	{
>> +		u32 stripe_width;
>> +		u64 tmp, off;
>> +		u32 unit = flseg->stripe_unit;
>> +
>> +		stripe_width = unit * flseg->dsaddr->stripe_count;
>> +		tmp = off = offset - flseg->pattern_offset;
>> +		do_div(tmp, stripe_width);
>> +		return tmp * unit + do_div(off, unit);
> 
> For readability's sake I'd split this out into a helper:
> 
> static loff_t
> filelayout_get_dense_offset(struct nfs4_filelayout_segment *flseg,
> 			    loff_t offset)
> {
> 	u32 stripe_width = flseg->stripe_unit * flseg->dsaddr->stripe_count;
> 	u64 tmp;
> 
> 	offset -= flseg->pattern_offset
> 
> 	tmp = off;
> 	do_div(tmp, stripe_width);
> 
> 	return tmp * unit + do_div(offset, flseg->stripe_unit);
> }

OK - I see your point.

-->Andy

> 
> ...
> 
> 
> 	case STRIPE_DENSE:
> 		return filelayout_get_dense_offset(flset, offset);
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Filesystem Development]     [Linux USB Development]     [Linux Media Development]     [Video for Linux]     [Linux NILFS]     [Linux Audio Users]     [Yosemite Info]     [Linux SCSI]

  Powered by Linux