[sheepdog] [PATCH] dog: type cast miss at vdi_show_progress

Saeki Masaki saeki.masaki at po.ntts.co.jp
Tue Feb 10 10:22:33 CET 2015


On 2015/02/10 16:33, Liu Yuan wrote:
> On Tue, Feb 10, 2015 at 03:03:56PM +0900, Saeki Masaki wrote:
>> The result of the multiplication of uint32 and uint64 are rounded to uint32
>> So, Progress of the command is displayed back to 0%,
>> when it exceeds the boundaries of 32bit.
>>
>> This is only a display issue, command processing can be completed.
>>
>> Signed-off-by: Masaki Saeki <saeki.masaki at po.ntts.co.jp>
>> ---
>>   dog/vdi.c |    8 ++++----
>>   1 files changed, 4 insertions(+), 4 deletions(-)
>>
>> diff --git a/dog/vdi.c b/dog/vdi.c
>> index 58d4a12..0920936 100644
>> --- a/dog/vdi.c
>> +++ b/dog/vdi.c
>> @@ -532,7 +532,7 @@ static int vdi_create(int argc, char **argv)
>>   	max_idx = DIV_ROUND_UP(size, object_size);
>>
>>   	for (idx = 0; idx < max_idx; idx++) {
>> -		vdi_show_progress(idx * object_size, inode->vdi_size);
>> +		vdi_show_progress((uint64_t)idx * object_size, inode->vdi_size);
>
> How about making the idx as uint64_t in the definition and comment that why we
> need unit64_t for it. This would save us from casting everywhere.
>
> Thanks
> Yuan

Hi Yuan. thank you for your comment.

I think idx is also used to manage upper limit of the data objects per VDI.
In the current specification, the upper limit of the object number is 32bit.

so I think scary side effects if change this definition to uint64_t.

What do you think about.

Regards, Saeki.

>
>>   		oid = vid_to_data_oid(vid, idx);
>>
>>   		ret = dog_write_object(oid, 0, NULL, 0, 0, 0, inode->nr_copies,
>> @@ -549,7 +549,7 @@ static int vdi_create(int argc, char **argv)
>>   			goto out;
>>   		}
>>   	}
>> -	vdi_show_progress(idx * object_size, inode->vdi_size);
>> +	vdi_show_progress((uint64_t)idx * object_size, inode->vdi_size);
>>   	ret = EXIT_SUCCESS;
>>
>>   out:
>> @@ -790,7 +790,7 @@ static int vdi_clone(int argc, char **argv)
>>   	for (idx = 0; idx < max_idx; idx++) {
>>   		size_t size;
>>
>> -		vdi_show_progress(idx * object_size, inode->vdi_size);
>> +		vdi_show_progress((uint64_t)idx * object_size, inode->vdi_size);
>>   		vdi_id = sd_inode_get_vid(inode, idx);
>>   		if (vdi_id) {
>>   			oid = vid_to_data_oid(vdi_id, idx);
>> @@ -824,7 +824,7 @@ static int vdi_clone(int argc, char **argv)
>>   			goto out;
>>   		}
>>   	}
>> -	vdi_show_progress(idx * object_size, inode->vdi_size);
>> +	vdi_show_progress((uint64_t)idx * object_size, inode->vdi_size);
>>   	ret = EXIT_SUCCESS;
>>
>>   out:
>> --
>> 1.7.1
>>
>>
>>
>> --
>> sheepdog mailing list
>> sheepdog at lists.wpkg.org
>> https://lists.wpkg.org/mailman/listinfo/sheepdog
>






More information about the sheepdog mailing list