Mercurial > nomad > experimental
changeset 669:c0730cae0a8e
objstore: require initobj op
Without it, we have no way of knowing how many versions an object has, and
what its heads are. We assume that we know both for every object.
Signed-off-by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
author | Josef 'Jeff' Sipek <jeffpc@josefsipek.net> |
---|---|
date | Mon, 04 Mar 2019 17:20:27 -0500 |
parents | e188f5c2824e |
children | f376beae5867 |
files | src/objstore/obj.c |
diffstat | 1 files changed, 18 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/src/objstore/obj.c Mon Mar 04 17:08:30 2019 -0500 +++ b/src/objstore/obj.c Mon Mar 04 17:20:27 2019 -0500 @@ -236,17 +236,14 @@ switch (obj->state) { case OBJ_STATE_NEW: - if (vol->ops && vol->ops->initobj && - (ret = vol->ops->initobj(obj))) { - /* the initobj op failed, mark the obj dead */ - obj->state = OBJ_STATE_DEAD; + if (!vol->ops || !vol->ops->initobj) { + ret = -ENOTSUP; + goto err_obj_new; + } - /* remove the object from the objs list */ - MXLOCK(&vol->lock); - rb_remove(&vol->objs, obj); - MXUNLOCK(&vol->lock); - goto err_obj; - } + ret = vol->ops->initobj(obj); + if (ret) + goto err_obj_new; /* must have at least one version & head */ ASSERT3U(obj->nversions, >=, 1); @@ -258,12 +255,21 @@ break; case OBJ_STATE_DEAD: ret = -EINVAL; - goto err_obj; + goto err_obj_dead; } return obj; -err_obj: +err_obj_new: + /* the initobj op failed, mark the obj dead */ + obj->state = OBJ_STATE_DEAD; + + /* remove the object from the objs list */ + MXLOCK(&vol->lock); + rb_remove(&vol->objs, obj); + MXUNLOCK(&vol->lock); + +err_obj_dead: MXUNLOCK(&obj->lock); obj_putref(obj);