<p dir="ltr">no, never try to use coroutine please. use something smart but unnecessary is bad practice</p>
<div class="gmail_quote">在 2013-7-15 PM10:49,"Hitoshi Mitake" <<a href="mailto:mitake.hitoshi@gmail.com">mitake.hitoshi@gmail.com</a>>写道:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
At Mon, 15 Jul 2013 14:28:48 +0800,<br>
Liu Yuan wrote:<br>
><br>
> Signed-off-by: Liu Yuan <<a href="mailto:namei.unix@gmail.com">namei.unix@gmail.com</a>><br>
> ---<br>
> sheep/object_cache.c | 28 ++++++++++++++++++++++++++++<br>
> sheep/sheep_priv.h | 1 +<br>
> sheep/store.c | 6 ++++++<br>
> 3 files changed, 35 insertions(+)<br>
><br>
> diff --git a/sheep/object_cache.c b/sheep/object_cache.c<br>
> index e3270df..1579a30 100644<br>
> --- a/sheep/object_cache.c<br>
> +++ b/sheep/object_cache.c<br>
> @@ -1317,6 +1317,34 @@ out:<br>
> return ret;<br>
> }<br>
><br>
> +int object_cache_remove(uint64_t oid)<br>
> +{<br>
> + /* Inc the entry refcount to exclude the reclaimer */<br>
> + struct object_cache_entry *entry = oid_to_entry(oid);<br>
> + struct object_cache *oc = entry->oc;<br>
> + int ret;<br>
> +<br>
> + if (!entry)<br>
> + return SD_RES_NO_OBJ;<br>
> +<br>
> + sd_dprintf("%" PRIx64, oid);<br>
> + while (refcount_read(&entry->refcnt) > 1)<br>
> + usleep(100000); /* Object might be in push */<br>
<br>
I believe this sort of magic number based coding should be<br>
avoided.<br>
<br>
coroutine would be suitable for writing this type of code cleanly. How<br>
about recover it? I've heard that the previous sheepdog had coroutine<br>
but it was reverted because of poor compatibility with valgrind.<br>
<br>
But I believe coroutine is worth considering to use, because other<br>
code in sheepdog (e.g. swithc_journal_file()) would be able to enjoy<br>
it.<br>
<br>
Thanks,<br>
Hitoshi<br>
</blockquote></div>