[sheepdog] [PATCH v2 7/9] object cache: reclaim cached objects when cache reaches the max size

Liu Yuan namei.unix at gmail.com
Thu Jul 26 08:13:37 CEST 2012


On 07/26/2012 11:46 AM, levin li wrote:
> OK, but even if we define it as uint8_t, it would also be aligned
> to 32 bit.
> 

But future added fields will take the padding space.

>>> +
>>> +static int check_cache_status(struct object_cache *oc,
>>> +			      struct object_cache_entry *entry)
>>> +{
>>> +	int refcnt = uatomic_read(&entry->refcnt);
>>> +
>>> +	if (cache_is_flushing(oc)) {
>>> +		dprintf("cache %" PRIx32 " is flushing, don't reclaim it.\n",
>>> +			oc->vid);
>>> +		return SD_RES_CACHE_FLUSHING;
>>> +	}
>>> +
>>> +	/* If entry is being accessed, we don't reclaim it */
>>> +	if (refcnt > 0) {
>>
>> uatomic_read(&entry->refcnt); should be placed in if clause.
>>
> 
> Callers of this function always holds the lock, so it's doesn't matter
> where we call uatomic_read().

When cache_is_flushing() returns true, you don't need read refcnt.

> 
> This would make the number of cache_size not too big.
> 

is it possible to overflow? uint64_t is big enough, I don't think we
need to waste extra CPU cycles for it.

Thanks,
Yuan



More information about the sheepdog mailing list