[sheepdog] [PATCH 2/3] sheep: teach sheep to discard unused objects

MORITA Kazutaka morita.kazutaka at gmail.com
Mon Apr 15 17:15:31 CEST 2013


(Drop qemu-devel from CC since this patch is specific to sheepdog.)

At Sat, 13 Apr 2013 19:27:20 +0800,
Liu Yuan wrote:
> 
> +static int local_discard(struct request *req)
> +{
> +	uint64_t oid = req->rq.obj.oid;
> +	uint32_t vid = oid_to_vid(oid), zero = 0;
> +	int ret, cp = get_vdi_copy_number(vid), idx = data_oid_to_idx(oid);
> +
> +	sd_dprintf("%"PRIx64, oid);
> +	ret = remove_object(oid, cp);
> +	if (ret != SD_RES_SUCCESS)
> +		return ret;
> +	return write_object(vid_to_vdi_oid(vid), (char *)&zero, sizeof(zero),
> +			    SD_INODE_HEADER_SIZE + sizeof(vid) * idx, 0, cp);
> +}

We should update the vdi object first before removing data objects.
Otherwise, if write_object() fails, sheep can return SD_RES_NO_OBJ to
VMs.

Thanks,

Kazutaka



More information about the sheepdog mailing list