Whamcloud - gitweb
- fix defect with lost nlink++ in rename
authortappro <tappro>
Fri, 18 Aug 2006 23:22:13 +0000 (23:22 +0000)
committertappro <tappro>
Fri, 18 Aug 2006 23:22:13 +0000 (23:22 +0000)
- mdt_device_fini() shouldn't return child device
- mdt_handle_last_unlink() shouldn't change the result code

lustre/mdd/mdd_handler.c
lustre/mdt/mdt_handler.c
lustre/mdt/mdt_reint.c

index 0aaa733..744dc35 100644 (file)
@@ -1294,6 +1294,7 @@ static int mdd_rename(const struct lu_context *ctxt, struct md_object *src_pobj,
         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;
 
@@ -1321,7 +1322,7 @@ static int mdd_rename(const struct lu_context *ctxt, struct md_object *src_pobj,
                 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) {
@@ -1333,11 +1334,15 @@ static int mdd_rename(const struct lu_context *ctxt, struct md_object *src_pobj,
         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);
index 767de74..ec5a67c 100644 (file)
@@ -2698,7 +2698,7 @@ static struct lu_device* mdt_device_fini(const struct lu_context *ctx, struct lu
         struct mdt_device *m = mdt_dev(d);
 
         mdt_fini(ctx, m);
-        RETURN (md2lu_dev(m->mdt_child));
+        RETURN (NULL);
 }
 
 static void mdt_device_free(const struct lu_context *ctx, struct lu_device *d)
index 175b04d..d9bd795 100644 (file)
@@ -301,8 +301,7 @@ static int mdt_reint_unlink(struct mdt_thread_info *info)
         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:
@@ -549,7 +548,9 @@ static int mdt_reint_rename(struct mdt_thread_info *info)
                         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) {