[sheepdog] [PATCH v5 6/8] object cache: reclaim cached objects when cache reaches the max size

Liu Yuan namei.unix at gmail.com
Sat Jul 28 09:39:40 CEST 2012


On 07/27/2012 08:01 PM, levin li wrote:
> +retry:
>  	if (sys->enable_write_cache && object_is_cached(oid)) {
>  		ret = object_cache_write(oid, data, datalen, offset,
>  					 flags, create);
> +		if (ret == SD_RES_NO_CACHE)
> +			goto retry;
> +
>  		if (ret != 0) {
>  			eprintf("write cache failed %"PRIx64" %"PRIx32"\n",
>  				oid, ret);
> @@ -529,8 +533,12 @@ int read_object(uint64_t oid, char *data, unsigned int datalen,
>  	struct sd_req hdr;
>  	int ret;
>  
> +retry:
>  	if (sys->enable_write_cache && object_is_cached(oid)) {
>  		ret = object_cache_read(oid, data, datalen, offset);
> +		if (ret == SD_RES_NO_CACHE)
> +			goto retry;
> +
>  		if (ret != SD_RES_SUCCESS) {
>  			eprintf("try forward read %"PRIx64" %"PRIx32"\n",
>  				oid, ret);

we don't need goto retry, just break out and read/write the backend store if ret == SD_RES_NO_CACHE.

-- 
thanks,
Yuan



More information about the sheepdog mailing list