.ldt_ops = &ls_device_type_ops,
};
-static struct ls_device *ls_device_get(const struct lu_env *env,
- struct dt_device *dev)
+struct ls_device *ls_device_get(struct dt_device *dev)
{
struct ls_device *ls;
RETURN(ls);
}
-static void ls_device_put(const struct lu_env *env, struct ls_device *ls)
+void ls_device_put(const struct lu_env *env, struct ls_device *ls)
{
LASSERT(env);
if (!cfs_atomic_dec_and_test(&ls->ls_refcount))
} else {
struct ls_device *ls;
- ls = ls_device_get(env, dt);
+ ls = ls_device_get(dt);
if (IS_ERR(ls)) {
dto = ERR_PTR(PTR_ERR(ls));
} else {
} else {
struct ls_device *ls;
- ls = ls_device_get(env, dt);
+ ls = ls_device_get(dt);
if (IS_ERR(ls)) {
dto = ERR_PTR(PTR_ERR(ls));
} else {
}
EXPORT_SYMBOL(local_index_find_or_create_with_fid);
-static struct local_oid_storage *dt_los_find(struct ls_device *ls, __u64 seq)
+struct local_oid_storage *dt_los_find(struct ls_device *ls, __u64 seq)
{
struct local_oid_storage *los, *ret = NULL;
return ret;
}
+void dt_los_put(struct local_oid_storage *los)
+{
+ if (cfs_atomic_dec_and_test(&los->los_refcount))
+ /* should never happen, only local_oid_storage_fini should
+ * drop refcount to zero */
+ LBUG();
+ return;
+}
+
/**
* Initialize local OID storage for required sequence.
* That may be needed for services that uses local files and requires
struct dt_thread_info *dti = dt_info(env);
struct ls_device *ls;
struct los_ondisk losd;
- struct dt_object *o;
struct dt_object *root = NULL;
+ struct dt_object *o = NULL;
struct thandle *th;
int rc;
ENTRY;
- ls = ls_device_get(env, dev);
+ ls = ls_device_get(dev);
if (IS_ERR(ls))
RETURN(PTR_ERR(ls));
cfs_atomic_inc(&ls->ls_refcount);
cfs_list_add(&(*los)->los_list, &ls->ls_los_list);
- /* initialize data allowing to generate new fids,
- * literally we need a sequence */
- o = ls_locate(env, ls, first_fid);
- if (IS_ERR(o))
- GOTO(out_los, rc = PTR_ERR(o));
-
rc = dt_root_get(env, dev, &dti->dti_fid);
if (rc)
GOTO(out_los, rc);
if (IS_ERR(root))
GOTO(out_los, rc = PTR_ERR(root));
- if (dt_try_as_dir(env, root) == 0)
- GOTO(out_los, rc = -ENOTDIR);
+ snprintf(dti->dti_buf, sizeof(dti->dti_buf), "seq-%Lx-lastid",
+ fid_seq(first_fid));
+ rc = dt_lookup_dir(env, root, dti->dti_buf, &dti->dti_fid);
+ if (rc != 0 && rc != -ENOENT)
+ GOTO(out_los, rc);
+
+ /* initialize data allowing to generate new fids,
+ * literally we need a sequence */
+ if (rc == 0)
+ o = ls_locate(env, ls, &dti->dti_fid);
+ else
+ o = ls_locate(env, ls, first_fid);
+ if (IS_ERR(o))
+ GOTO(out_los, rc = PTR_ERR(o));
dt_write_lock(env, o, 0);
if (!dt_object_exists(o)) {
+ LASSERT(rc == -ENOENT);
+
th = dt_trans_create(env, dev);
if (IS_ERR(th))
GOTO(out_lock, rc = PTR_ERR(th));
if (rc)
GOTO(out_trans, rc);
- snprintf(dti->dti_buf, sizeof(dti->dti_buf),
- "seq-%Lx-lastid", fid_seq(first_fid));
rc = dt_declare_insert(env, root,
(const struct dt_rec *)lu_object_fid(&o->do_lu),
(const struct dt_key *)dti->dti_buf,
rc = dt_record_write(env, o, &dti->dti_lb, &dti->dti_off, th);
if (rc)
GOTO(out_trans, rc);
- rc = dt_insert(env, root,
- (const struct dt_rec *)lu_object_fid(&o->do_lu),
- (const struct dt_key *)dti->dti_buf, th,
- BYPASS_CAPA, 1);
- if (rc)
- GOTO(out_trans, rc);
+#if LUSTRE_VERSION_CODE >= OBD_OCD_VERSION(2, 3, 90, 0)
+#error "fix this before release"
+#endif
+ /*
+ * there is one technical debt left in Orion:
+ * proper hanlding of named vs no-name objects.
+ * Llog objects have name always as they are placed in O/d/...
+ */
+ if (fid_seq(lu_object_fid(&o->do_lu)) != FID_SEQ_LLOG) {
+ rc = dt_insert(env, root,
+ (const struct dt_rec *)first_fid,
+ (const struct dt_key *)dti->dti_buf,
+ th, BYPASS_CAPA, 1);
+ if (rc)
+ GOTO(out_trans, rc);
+ }
out_trans:
dt_trans_stop(env, dev, th);
} else {
out_lock:
dt_write_unlock(env, o);
out_los:
- if (root)
+ if (root != NULL && !IS_ERR(root))
lu_object_put_nocache(env, &root->do_lu);
- if (rc) {
+
+ if (rc != 0) {
+ cfs_list_del(&(*los)->los_list);
+ cfs_atomic_dec(&ls->ls_refcount);
OBD_FREE_PTR(*los);
*los = NULL;
- if (o)
+ if (o != NULL && !IS_ERR(o))
lu_object_put_nocache(env, &o->do_lu);
} else {
(*los)->los_seq = fid_seq(first_fid);