- rc = mdo_ref_del(env, mdd_cobj, handle);
- if (rc != 0) {
- __mdd_index_insert_only(env, mdd_pobj, mdo2fid(mdd_cobj),
- name, handle,
- mdd_object_capa(env, mdd_pobj));
- GOTO(cleanup, rc);
+ if (likely(mdd_cobj != NULL)) {
+ rc = mdo_ref_del(env, mdd_cobj, handle);
+ if (rc != 0) {
+ __mdd_index_insert_only(env, mdd_pobj,
+ mdo2fid(mdd_cobj),
+ name, handle,
+ mdd_object_capa(env, mdd_pobj));
+ GOTO(cleanup, rc);
+ }
+
+ if (is_dir)
+ /* unlink dot */
+ mdo_ref_del(env, mdd_cobj, handle);
+
+ /* fetch updated nlink */
+ rc = mdd_la_get(env, mdd_cobj, cattr,
+ mdd_object_capa(env, mdd_cobj));
+ if (rc)
+ GOTO(cleanup, rc);