# HG changeset patch # User Josef 'Jeff' Sipek # Date 1551738027 18000 # Node ID c0730cae0a8e63ea087cea8dae7cf9090a7e3391 # Parent e188f5c2824eda49ae21aa0fe3b2e4b6194d3e96 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 diff -r e188f5c2824e -r c0730cae0a8e src/objstore/obj.c --- 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);