[Ocfs2-tools-devel] [PATCH 1/5] tunefs.ocfs2: Warn if not using complete device

Sunil Mushran sunil.mushran at oracle.com
Thu Jan 12 13:40:37 PST 2012


Signed-off-by: Sunil Mushran <sunil.mushran at oracle.com>

On 12/22/2011 03:42 PM, Goldwyn Rodrigues wrote:
> Sample test case (for a device greater than 16TB):
> 1. Format a device with blocksize 4k and block count<  16TB
> 2. resize device (-S)
> Results: Device is formatted to 16TB even if the device is bigger.
>
> The patch fails the tunefs.ocfs2 attempt and ask user to explicitly state
> block-count to not use the complete device.
>
> Signed-off-by: Goldwyn Rodrigues<rgoldwyn at suse.de>
> ---
>   tunefs.ocfs2/op_resize_volume.c |   19 ++++++++++++++++---
>   1 files changed, 16 insertions(+), 3 deletions(-)
>
> diff --git a/tunefs.ocfs2/op_resize_volume.c b/tunefs.ocfs2/op_resize_volume.c
> index 8541374..0426d41 100644
> --- a/tunefs.ocfs2/op_resize_volume.c
> +++ b/tunefs.ocfs2/op_resize_volume.c
> @@ -535,10 +535,23 @@ static errcode_t check_new_size(ocfs2_filesys
> *fs, uint64_t new_size,
>   	}
>
>   	device_clusters = device_blocks>>  b_to_c_bits;
> -	if (device_clusters>  UINT32_MAX)
> -		device_clusters = UINT32_MAX;
> -	if (!try_clusters)
> +
> +	if (!try_clusters) {
> +		if (device_clusters>  UINT32_MAX) {
> +			verbosef(VL_APP,
> +				"Device clusters (%"PRIu64" is greater than "
> +				"maximum possible clusters %"PRIu32"\n",
> +				device_clusters, UINT32_MAX);
> +			try_blocks = UINT32_MAX<<  b_to_c_bits;
> +			errorf("Device clusters %"PRIu64" is greater than %"
> +				PRIu32".\nIf you want to resize to %"PRIu64
> +				" blocks please specify %"PRIu64" as "
> +				"blocks-count.\n", device_clusters,
> +				UINT32_MAX, try_blocks, try_blocks);
> +			return TUNEFS_ET_INVALID_NUMBER;
> +		}
>   		try_clusters = device_clusters;
> +	}
>   	try_blocks = try_clusters<<  b_to_c_bits;
>
>   	/* Now we're guaranteed that try_clusters is within range */




More information about the Ocfs2-tools-devel mailing list