Whamcloud - gitweb
Fixes and cleanups in lmv.
[fs/lustre-release.git] / lustre / mds / handler.c
index 045daa3..dfdad07 100644 (file)
@@ -835,7 +835,7 @@ static int mds_getattr_name(int offset, struct ptlrpc_request *req,
         char *name;
         ENTRY;
 
-        LASSERT(!strcmp(obd->obd_type->typ_name, "mds"));
+        LASSERT(!strcmp(obd->obd_type->typ_name, LUSTRE_MDS_NAME));
 
         /* Swab now, before anyone looks inside the request */
 
@@ -948,13 +948,13 @@ static int mds_getattr_name(int offset, struct ptlrpc_request *req,
 
         cleanup_phase = 2; /* dchild, dparent, locks */
 
-fill_inode:
-
         /* let's make sure this name should leave on this mds node */
         rc = mds_check_mds_num(obd, dparent->d_inode, name, namesize);
         if (rc)
                 GOTO(cleanup, rc);
 
+fill_inode:
+
         if (!DENTRY_VALID(dchild)) {
                 intent_set_disposition(rep, DISP_LOOKUP_NEG);
                 /* in the intent case, the policy clears this error:
@@ -1369,7 +1369,7 @@ repeat:
         if (IS_ERR(new)) {
                 CERROR("%s: can't lookup new inode (%s) for mkdir: %d\n",
                        obd->obd_name, fidname, (int) PTR_ERR(new));
-                fsfilt_commit(obd, new->d_inode, handle, 0);
+                fsfilt_commit(obd, mds->mds_sb, new->d_inode, handle, 0);
                 up(&parent_inode->i_sem);
                 RETURN(PTR_ERR(new));
         } else if (new->d_inode) {
@@ -2110,33 +2110,59 @@ static int mds_postsetup(struct obd_device *obd)
 err_cleanup:
         mds_lov_clean(obd);
 err_llog:
-        obd_llog_cleanup(llog_get_context(&obd->obd_llogs, LLOG_CONFIG_ORIG_CTXT));
+        obd_llog_cleanup(llog_get_context(&obd->obd_llogs,
+                                          LLOG_CONFIG_ORIG_CTXT));
         RETURN(rc);
 }
 
-static int mds_postrecov(struct obd_device *obd)
-
+int mds_postrecov(struct obd_device *obd)
 {
+        struct mds_obd *mds = &obd->u.mds;
         struct llog_ctxt *ctxt;
-        int rc, rc2;
+        int rc, item = 0;
         ENTRY;
 
         LASSERT(!obd->obd_recovering);
         ctxt = llog_get_context(&obd->obd_llogs, LLOG_UNLINK_ORIG_CTXT);
         LASSERT(ctxt != NULL);
 
+        /* set nextid first, so we are sure it happens */
+        rc = mds_lov_set_nextid(obd);
+        if (rc) {
+                CERROR("%s: mds_lov_set_nextid failed\n", obd->obd_name);
+                GOTO(out, rc);
+        }
+
+        /* clean PENDING dir */
+        rc = mds_cleanup_orphans(obd);
+        if (rc < 0)
+                GOTO(out, rc);
+        item = rc;
+
         rc = llog_connect(ctxt, obd->u.mds.mds_lov_desc.ld_tgt_count,
                           NULL, NULL, NULL);
-        if (rc != 0) {
-                CERROR("faild at llog_origin_connect: %d\n", rc);
+        if (rc) {
+                CERROR("%s: failed at llog_origin_connect: %d\n", 
+                       obd->obd_name, rc);
+                GOTO(out, rc);
         }
 
-        rc = mds_cleanup_orphans(obd);
+        /* remove the orphaned precreated objects */
+        rc = mds_lov_clearorphans(mds, NULL /* all OSTs */);
+        if (rc)
+                GOTO(err_llog, rc);
+
+out:
+        RETURN(rc < 0 ? rc : item);
 
-        rc2 = mds_lov_set_nextid(obd);
-        if (rc2 == 0)
-                rc2 = rc;
-        RETURN(rc2);
+err_llog:
+        /* cleanup all llogging subsystems */
+        rc = obd_llog_finish(obd, &obd->obd_llogs,
+                             mds->mds_lov_desc.ld_tgt_count);
+        if (rc)
+                CERROR("%s: failed to cleanup llogging subsystems\n",
+                        obd->obd_name);
+        goto out;
 }
 
 int mds_lov_clean(struct obd_device *obd)
@@ -2365,6 +2391,7 @@ static int mds_intent_policy(struct ldlm_namespace *ns,
                 break;
         case IT_LOOKUP:
                 getattr_part = MDS_INODELOCK_LOOKUP;
+        case IT_CHDIR:
         case IT_GETATTR:
                 getattr_part |= MDS_INODELOCK_LOOKUP;
         case IT_READDIR: