Quoting Oren Laadan (orenl@xxxxxxxxxxxxxxx): > +/** > + * 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@xxxxxxxxxxxxxxxxxxxxxxxxxx https://lists.linux-foundation.org/mailman/listinfo/containers