struct mdd_object *mdd_sobj = mdd_object_find(ctxt, mdd, lf);
struct mdd_object *mdd_tobj = NULL;
struct thandle *handle;
+ int is_dir = S_ISDIR(mdd_object_type(ctxt, mdd_sobj));
int rc;
ENTRY;
GOTO(cleanup, rc);
/*if sobj is dir, its parent object nlink should be dec too*/
- if (S_ISDIR(mdd_object_type(ctxt, mdd_sobj)))
+ if (is_dir)
__mdd_ref_del(ctxt, mdd_spobj, handle);
if (tobj) {
rc = __mdd_index_insert(ctxt, mdd_tpobj, lf, tname, handle);
if (rc)
GOTO(cleanup, rc);
+ /*if sobj is dir, its new parent object nlink should be inc */
+ if (is_dir)
+ __mdd_ref_add(ctxt, mdd_tpobj, handle);
+
if (tobj && lu_object_exists(&tobj->mo_lu)) {
__mdd_ref_del(ctxt, mdd_tobj, handle);
/* remove dot reference */
- if (S_ISDIR(mdd_object_type(ctxt, mdd_tobj)))
+ if (is_dir)
__mdd_ref_del(ctxt, mdd_tobj, handle);
rc = __mdd_finish_unlink(ctxt, mdd_tobj, ma);
if (rc)
GOTO(out_unlock_child, rc);
-
- rc = mdt_handle_last_unlink(info, mc, ma);
+ mdt_handle_last_unlink(info, mc, ma);
GOTO(out_unlock_child, rc);
out_unlock_child:
mdt_object_child(mtgtdir), old_fid,
rr->rr_name, mnew ? mdt_object_child(mnew): NULL,
rr->rr_tgt, ma);
- /*TODO: handle last link of tgt object*/
+ /* handle last link of tgt object */
+ if (mnew)
+ mdt_handle_last_unlink(info, mnew, ma);
out_unlock_new:
if (mnew) {