[Devel] Re: [RFC v14][PATCH 10/54] Infrastructure for shared objects

Serge E. Hallyn serue at us.ibm.com
Tue Apr 28 18:03:17 PDT 2009


Quoting Oren Laadan (orenl at cs.columbia.edu):
> +/**
> + * checkpoint_obj - if not already in hash, add object and checkpoint
> + * @ctx: checkpoint context
> + * @ptr: pointer to object
> + * @type: object type
> + *
> + * Look up the object pointed to by @ptr in the hash table. If it
> + * isn't already there, then add the object to the table, allocate a
> + * fresh unique id (objref) and save the object's state, and grab a
> + * reference to every object that is added. (Maintain the reference
> + * until the entire hash is free).
> + *
> + * [This is used during checkpoint].
> + *
> + * Returns: objref
> + */
> +int checkpoint_obj(struct ckpt_ctx *ctx, void *ptr, enum obj_type type)
> +{
> +	struct ckpt_obj_ops *ops = &ckpt_obj_ops[type];
> +	struct ckpt_hdr_objref *h;
> +	struct ckpt_obj *obj;
> +	int objref, ret;
> +
> +	/* make sure we don't change this accidentally */
> +	BUG_ON(ops->obj_type != type);
> +
> +	obj = obj_find_by_ptr(ctx, ptr);
> +	if (obj) {
> +		BUG_ON(obj->ops->obj_type != type);
> +		return obj->objref;
> +	}
> +
> +	h = ckpt_hdr_get_type(ctx, sizeof(*h), CKPT_HDR_OBJREF);
> +	if (!h)
> +		return -ENOMEM;
> +
> +	objref = obj_new(ctx, ptr, 0, ops);
> +	if (objref < 0)

	ckpt_hdr_put(ctx, h);    ?

> +		return objref;
> +
> +	h->objtype = type;
> +	h->objref = objref;
> +	ret = ckpt_write_obj(ctx, (struct ckpt_hdr *) h);
> +	ckpt_hdr_put(ctx, h);

-serge
_______________________________________________
Containers mailing list
Containers at lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/containers




More information about the Devel mailing list