[sheepdog] [PATCH v1] sheep/http: add Created-Time for onode

Liu Yuan namei.unix at gmail.com
Thu Feb 27 08:16:51 CET 2014


On Wed, Feb 26, 2014 at 04:15:33PM +0800, Robin Dong wrote:
> From: Robin Dong <sanbai at taobao.com>
> 
> At present, we allocate space for an onode and then write data for it,
> so we should record two times: 'ctime' means when the onode is created
> and allocated space, 'mtime' means when the data of onode have all be
> written done.
> 
> Signed-off-by: Robin Dong <sanbai at taobao.com>
> ---
>  sheep/http/kv.c | 12 +++++++++++-
>  1 file changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/sheep/http/kv.c b/sheep/http/kv.c
> index 6f648e3..61014a3 100644
> --- a/sheep/http/kv.c
> +++ b/sheep/http/kv.c
> @@ -61,6 +61,7 @@ struct kv_onode {
>  			/* a hash value for etag */
>  			uint8_t sha1[round_up(SHA1_DIGEST_SIZE, 8)];
>  			uint64_t size;
> +			uint64_t ctime;
>  			uint64_t mtime;
>  			uint32_t data_vid;
>  			uint32_t nr_extent;
> @@ -751,7 +752,7 @@ static int onode_allocate_data(struct kv_onode *onode, struct http_request *req)
>  			goto out;
>  	}
>  
> -	onode->mtime = get_seconds();
> +	onode->ctime = get_seconds();
>  	onode->size = req->data_length;
>  out:
>  	return ret;
> @@ -786,6 +787,13 @@ static int onode_populate_data(struct kv_onode *onode, struct http_request *req)
>  			      sizeof(uint8_t), offset, false);
>  	if (ret != SD_RES_SUCCESS)
>  		sd_err("Failed to write flags of onode %s", onode->name);
> +	/* write mtime for onode */
> +	onode->mtime = get_seconds();
> +	offset = offsetof(struct kv_onode, mtime);
> +	ret = sd_write_object(onode->oid, (char *)onode + offset,
> +			      sizeof(uint64_t), offset, false);
> +	if (ret != SD_RES_SUCCESS)
> +		sd_err("Failed to write mtime of onode %s", onode->name);

I think we should write onode back only once, not twice as one for flag and
another for mtime.

Thanks
Yuan



More information about the sheepdog mailing list