[sheepdog] [PATCH v2 05/11] sheep: decrement generational reference count on vdi deletion

MORITA Kazutaka morita.kazutaka at lab.ntt.co.jp
Thu Jul 4 07:42:04 CEST 2013


At Wed, 3 Jul 2013 15:38:39 +0800,
Liu Yuan wrote:
> 
> On Wed, Jun 19, 2013 at 02:14:25AM +0900, MORITA Kazutaka wrote:
> > From: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
> > 
> > This removes old vdi deletion code, which reclaims objects only when
> > all relevant snapshots are deleted, and uses a generational reference
> > counting algorithm.
> > 
> > Signed-off-by: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
> > ---
> >  sheep/vdi.c |  213 +++--------------------------------------------------------
> >  1 file changed, 9 insertions(+), 204 deletions(-)
> > 
> > diff --git a/sheep/vdi.c b/sheep/vdi.c
> > index 988145d..93ab536 100644
> > --- a/sheep/vdi.c
> > +++ b/sheep/vdi.c
> > @@ -585,47 +585,11 @@ int read_vdis(char *data, int len, unsigned int *rsp_len)
> >  }
> >  
> >  struct deletion_work {
> > -	uint32_t done;
> > -
> >  	struct work work;
> > -	struct list_head list;
> >  	struct request *req;
> > -
> >  	uint32_t vid;
> > -
> > -	int count;
> > -	uint32_t *buf;
> >  };
> >  
> > -static LIST_HEAD(deletion_work_list);
> > -
> > -static int delete_inode(struct deletion_work *dw)
> > -{
> > -	struct sd_inode *inode = NULL;
> > -	int ret = SD_RES_SUCCESS;
> > -
> > -	inode = xzalloc(sizeof(*inode));
> > -	ret = read_object(vid_to_vdi_oid(dw->vid), (char *)inode,
> > -			  SD_INODE_HEADER_SIZE, 0);
> > -	if (ret != SD_RES_SUCCESS) {
> > -		ret = SD_RES_EIO;
> > -		goto out;
> > -	}
> > -
> > -	memset(inode->name, 0, sizeof(inode->name));
> > -
> > -	ret = write_object(vid_to_vdi_oid(dw->vid), (char *)inode,
> > -			   SD_INODE_HEADER_SIZE, 0, false);
> > -	if (ret != 0) {
> > -		ret = SD_RES_EIO;
> > -		goto out;
> > -	}
> > -
> > -out:
> > -	free(inode);
> > -	return ret;
> > -}
> > -
> >  static int notify_vdi_deletion(uint32_t vdi_id)
> >  {
> >  	struct sd_req hdr;
> > @@ -646,11 +610,11 @@ static int notify_vdi_deletion(uint32_t vdi_id)
> >  static void delete_one(struct work *work)
> >  {
> >  	struct deletion_work *dw = container_of(work, struct deletion_work, work);
> > -	uint32_t vdi_id = *(dw->buf + dw->count - dw->done - 1);
> > +	uint32_t vdi_id = dw->vid;
> >  	int ret, i, nr_deleted;
> >  	struct sd_inode *inode = NULL;
> >  
> > -	sd_dprintf("%d %d, %16x", dw->done, dw->count, vdi_id);
> > +	sd_eprintf("%16" PRIx32, vdi_id);
> 
> Why sd_eprintf instead of sd_dprintf ?

It should be sd_dprintf.  I'll fix it in the next version.

Thanks,

Kazutaka



More information about the sheepdog mailing list