[sheepdog] [PATCH v3 3/3] sheep: remove cache object for discard operation

Hitoshi Mitake mitake.hitoshi at gmail.com
Wed Jul 17 17:59:47 CEST 2013


At Wed, 17 Jul 2013 16:12:35 +0800,
Liu Yuan wrote:
> 
> Signed-off-by: Liu Yuan <namei.unix at gmail.com>
> ---
>  sheep/object_cache.c |   29 +++++++++++++++++++++++++++++
>  sheep/sheep_priv.h   |    1 +
>  sheep/store.c        |    6 ++++++
>  3 files changed, 36 insertions(+)
> 
> diff --git a/sheep/object_cache.c b/sheep/object_cache.c
> index e3270df..1212dc2 100644
> --- a/sheep/object_cache.c
> +++ b/sheep/object_cache.c
> @@ -1317,6 +1317,35 @@ out:
>  	return ret;
>  }
>  
> +int object_cache_remove(uint64_t oid)
> +{
> +	/* Inc the entry refcount to exclude the reclaimer */
> +	struct object_cache_entry *entry = oid_to_entry(oid);
> +	struct object_cache *oc = entry->oc;
> +	int ret;
> +
> +	if (!entry)
> +		return SD_RES_NO_OBJ;
> +
> +	sd_dprintf("%" PRIx64, oid);
> +	while (refcount_read(&entry->refcnt) > 1)
> +		usleep(100000); /* Object might be in push */
> +
> +	write_lock_cache(oc);
> +	assert(refcount_read(&entry->refcnt) == 1);

I think you should add a comment for describing this assert(). This
would not be an obvious thing.

Other parts looks good to me.

Thanks,
Hitoshi



More information about the sheepdog mailing list