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

Re: [lvm-devel] [PATCH v4 2/5] cmdline: support for bytes and sectors



On Sun, Jul 05, 2009 at 10:39:47PM -0400, Mike Snitzer wrote:
> Allow commandline sizes to be specified in terms of bytes and sectors.
> Update the man pages to document size units uniformly.
 
Does the addition of 'bytes' now permit invalid sizes to be specified anywhere
leading to rounding happening without warning messages?

If rounding occurs the user should be notified.
E.g. 	lvcreate has: log_print("Rounding size (%d extents) up to stripe boundary "

(Whether to round up or to round down may depend on the context - see lvresize,
for example.)

> @@ -274,11 +274,19 @@ static int _size_arg(struct cmd_context 
>  
>  		if (i < 0)
>  			return 0;
> -
> -		while (i-- > 0)
> -			v *= 1024;
> -
> -		v *= 2;
> +		else if (i == 7) {

else superfluous?

> +			/* sectors */
> +			v = v;
> +		} else if (i == 6) {
> +			/* bytes */

Warning messages needed here, I think.

> +			if (v < 512)
> +				return 0;
> +			v /= 512;
> +		} else {

Add comment like the others to indicate which cases this now covers

> +			while (i-- > 0)
> +				v *= 1024;
> +			v *= 2;
> +		}
>  	} else
>  		v *= factor;

Alasdair


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