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

Liu Yuan namei.unix at gmail.com
Mon Jul 15 16:52:53 CEST 2013


no, never try to use coroutine please. use something smart but unnecessary
is bad practice
在 2013-7-15 PM10:49,"Hitoshi Mitake" <mitake.hitoshi at gmail.com>写道:

> At Mon, 15 Jul 2013 14:28:48 +0800,
> Liu Yuan wrote:
> >
> > Signed-off-by: Liu Yuan <namei.unix at gmail.com>
> > ---
> >  sheep/object_cache.c |   28 ++++++++++++++++++++++++++++
> >  sheep/sheep_priv.h   |    1 +
> >  sheep/store.c        |    6 ++++++
> >  3 files changed, 35 insertions(+)
> >
> > diff --git a/sheep/object_cache.c b/sheep/object_cache.c
> > index e3270df..1579a30 100644
> > --- a/sheep/object_cache.c
> > +++ b/sheep/object_cache.c
> > @@ -1317,6 +1317,34 @@ 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 */
>
> I believe this sort of magic number based coding should be
> avoided.
>
> coroutine would be suitable for writing this type of code cleanly. How
> about recover it? I've heard that the previous sheepdog had coroutine
> but it was reverted because of poor compatibility with valgrind.
>
> But I believe coroutine is worth considering to use, because other
> code in sheepdog (e.g. swithc_journal_file()) would be able to enjoy
> it.
>
> Thanks,
> Hitoshi
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.wpkg.org/pipermail/sheepdog/attachments/20130715/65e5526c/attachment-0004.html>


More information about the sheepdog mailing list