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

Liu Yuan namei.unix at gmail.com
Tue Jul 17 05:37:29 CEST 2012


On 07/09/2012 02:29 PM, levin li wrote:
> This patch do reclaiming work when the total size of cached objects
> reaches the max size specified by user, I did it in the following way:
> 
> 1. check the object tree for the object entry to determine whether the
>    cache entry is exist and whether it's reclaiming, if it's reclaiming
>    we make sheep ingore the cache.
> 2. In object_cache_rw() we search the cache entry, after passed the sanity
>    check, we increment its refcnt to tell the reclaiming worker that this
>    entry is being referenced, we should not reclaim it now.
> 3. In add_to_object_cache(), when the cached size reaches the max size,
>    we start a reclaiming thread, only one such thread can be running at
>    one time.
> 4. In reclaim_work(), we reclaim cached objects until the cache size reduced
>    to 80% of the max size.
> 5. In reclaim_object(), we start to reclaim an object, before this, we check
>    that if the cache is flushing, we don't reclaim it, and if the refcnt of
>    the object is not zero, we also don't reclaim it.
>    If the cached object is dirty, we flush it by push_cache_object(), and

I think we can have a daemon thread to constantly check the disk usage
and do object reclaim in background when the disk usage reach a high
watermark. This will amortize the reclaim work and its affection to the
performance, in combination of a direct reclaim algorithm.

Thanks,
Yuan




More information about the sheepdog mailing list