[Sheepdog] [PATCH v2 2/3] sheep: timestamp the epoch log

Liu Yuan namei.unix at gmail.com
Wed Oct 26 09:26:51 CEST 2011


On 10/26/2011 03:12 PM, MORITA Kazutaka wrote:

>>> @@ -147,6 +147,7 @@ struct sheepdog_vnode_list_entry {
>>>  
>>>  struct epoch_log {
>>>  	uint64_t ctime;
>>> +	time_t time;
>>>  	uint32_t epoch;
>>>  	uint32_t nr_nodes;
>>>  	struct sheepdog_node_list_entry nodes[SD_MAX_NODES];
> 
> This is not 64 bit aligned.
> 


What do you mean by alignment? So where you suggest to place time in
this structure?

> 
>>> diff --git a/sheep/ops.c b/sheep/ops.c
>>> index 743eb0f..e2d7fb1 100644
>>> --- a/sheep/ops.c
>>> +++ b/sheep/ops.c
>>> @@ -279,6 +279,7 @@ static int local_stat_cluster(const struct sd_req *req, struct sd_rsp *rsp,
>>>  
>>>  		rsp->data_length += sizeof(*log);
>>>  		log->nr_nodes /= sizeof(log->nodes[0]);
>>> +		log->time = *(time_t *)(&log->nodes[log->nr_nodes]);
> 
> Looks a bit hacky to me.  In addition, this doesn't work if
> sizeof(log->nodes[0]) < sizeof(time_t).



Yes, tricky, but simplest. even sizeof(log->nodes[0]) < sizeof(time_t), I think this works out, cause

we just need to get the address of end of the nodes array. Dereference
is okay since it has converted into the right type(time_t *).

any other more suitable means?

Thanks,
Yuan



More information about the sheepdog mailing list