At Mon, 26 Mar 2012 05:44:21 +0900,
MORITA Kazutaka wrote:
> 
> At Sat, 24 Mar 2012 16:47:15 +0800,
> Liu Yuan wrote:
> > 
> > From: Liu Yuan <[email protected]>
> > 
> > This is supposed to be initiated by Guest OS, but our collie
> > friend might also like it.
> > 
> > Flush operation is operated on vdi basis, that is, when one guest
> > flush its own dirty data, other guests are not affected.
> > 
> > - use forward_write_obj_req() to flush dirty objects
> > 
> > Signed-off-by: Liu Yuan <[email protected]>
> > ---
> >  include/sheepdog_proto.h |    1 +
> >  sheep/object_cache.c     |   48 
> > ++++++++++++++++++++++++++++++++++++++++++++-
> >  sheep/ops.c              |   23 ++++++++++++++++++++++
> >  sheep/sheep_priv.h       |    2 +
> >  sheep/store.c            |    7 +++++-
> >  5 files changed, 78 insertions(+), 3 deletions(-)
> > 
> > diff --git a/include/sheepdog_proto.h b/include/sheepdog_proto.h
> > index 84f12f1..6138108 100644
> > --- a/include/sheepdog_proto.h
> > +++ b/include/sheepdog_proto.h
> > @@ -29,6 +29,7 @@
> >  #define SD_OP_RELEASE_VDI    0x13
> >  #define SD_OP_GET_VDI_INFO   0x14
> >  #define SD_OP_READ_VDIS      0x15
> > +#define SD_OP_FLUSH_VDI      0x16
> >  
> >  #define SD_FLAG_CMD_WRITE    0x01
> >  #define SD_FLAG_CMD_COW      0x02
> > diff --git a/sheep/object_cache.c b/sheep/object_cache.c
> > index 789a3ef..25b4cbc 100644
> > --- a/sheep/object_cache.c
> > +++ b/sheep/object_cache.c
> > @@ -370,10 +370,54 @@ static uint64_t idx_to_oid(uint32_t vid, uint32_t idx)
> >             return vid_to_data_oid(vid, idx);
> >  }
> >  
> > -static int push_cache_object(int fd, uint64_t oid)
> > +static int push_cache_object(uint32_t vid, uint32_t idx)
> >  {
> > +   struct request fake_req;
> > +   struct sd_obj_req *hdr = (struct sd_obj_req *)&fake_req.rq;
> > +   void *buf;
> > +   unsigned data_length;
> > +   int ret = SD_RES_NO_MEM;
> > +   uint64_t oid = idx_to_oid(vid, idx);
> > +
> >     dprintf("%"PRIx64"\n", oid);
> > -   return 0;
> > +
> > +   memset(&fake_req, 0, sizeof(fake_req));
> > +   if (is_vdi_obj(oid))
> > +           data_length = sizeof(struct sheepdog_inode);
> > +   else
> > +           data_length = SD_DATA_OBJ_SIZE;
> > +
> > +   buf = malloc(data_length);

Use valloc since sheep may run with '-D' option.

Thanks,

Kazutaka
-- 
sheepdog mailing list
[email protected]
http://lists.wpkg.org/mailman/listinfo/sheepdog

Reply via email to