Whamcloud - gitweb
LU-1222 ldlm: Fix the race in AST sender vs multiple arriving RPCs
[fs/lustre-release.git] / lustre / mgs / mgs_handler.c
index cf3a0ba..beb0b95 100644 (file)
@@ -28,6 +28,8 @@
 /*
  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
+ *
+ * Copyright (c) 2011, 2012, Whamcloud, Inc.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -261,7 +263,7 @@ static int mgs_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
 
         ping_evictor_start();
 
-        LCONSOLE_INFO("MGS %s started\n", obd->obd_name);
+        CDEBUG(D_INFO, "MGS %s started\n", obd->obd_name);
 
         RETURN(0);
 
@@ -286,13 +288,19 @@ err_put:
 
 static int mgs_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage)
 {
+        struct mgs_obd *mgs = &obd->u.mgs;
         int rc = 0;
         ENTRY;
 
         switch (stage) {
         case OBD_CLEANUP_EARLY:
+                break;
         case OBD_CLEANUP_EXPORTS:
+                ping_evictor_stop();
+                ptlrpc_unregister_service(mgs->mgs_service);
+                mgs_cleanup_fsdb_list(obd);
                 rc = obd_llog_finish(obd, 0);
+                lproc_mgs_cleanup(obd);
                 break;
         }
         RETURN(rc);
@@ -309,12 +317,6 @@ static int mgs_cleanup(struct obd_device *obd)
         if (mgs->mgs_sb == NULL)
                 RETURN(0);
 
-        ping_evictor_stop();
-
-        ptlrpc_unregister_service(mgs->mgs_service);
-
-        mgs_cleanup_fsdb_list(obd);
-        lproc_mgs_cleanup(obd);
         mgs_fs_cleanup(obd);
 
         server_put_mount(obd->obd_name, mgs->mgs_vfsmnt);
@@ -747,6 +749,21 @@ static int mgs_handle_exception(struct ptlrpc_request *req)
         RETURN(0);
 }
 
+/*
+ * For old clients there is no direct way of knowing which filesystems
+ * a client is operating at the MGS side. But we need to pick up those
+ * clients so that the MGS can mark the corresponding filesystem as
+ * non-IR capable because old clients are not ready to be notified.
+ *
+ * This is why we have this _hack_ function. We detect the filesystem's
+ * name by hacking llog operation which is currently used by the clients
+ * to fetch configuration logs. At present this is fine because this is
+ * the ONLY llog operation between mgc and the MGS.
+ *
+ * If extra llog operation is going to be added, this function needs fixing.
+ *
+ * If releases prior than 2.0 are not supported, we can remove this function.
+ */
 static int mgs_handle_fslog_hack(struct ptlrpc_request *req)
 {
         char *logname;
@@ -800,8 +817,7 @@ int mgs_handle(struct ptlrpc_request *req)
 
         if (opc != MGS_CONNECT) {
                 if (!class_connected_export(req->rq_export)) {
-                        CERROR("lustre_mgs: operation %d on unconnected MGS\n",
-                               opc);
+                        DEBUG_REQ(D_MGS, req, "operation on unconnected MGS\n");
                         req->rq_status = -ENOTCONN;
                         GOTO(out, rc = -ENOTCONN);
                 }
@@ -931,6 +947,10 @@ static inline int mgs_init_export(struct obd_export *exp)
         exp->exp_connecting = 1;
         cfs_spin_unlock(&exp->exp_lock);
 
+        /* self-export doesn't need client data and ldlm initialization */
+        if (unlikely(obd_uuid_equals(&exp->exp_obd->obd_uuid,
+                                     &exp->exp_client_uuid)))
+                return 0;
         return ldlm_init_export(exp);
 }
 
@@ -940,6 +960,11 @@ static inline int mgs_destroy_export(struct obd_export *exp)
 
         target_destroy_export(exp);
         mgs_client_free(exp);
+
+        if (unlikely(obd_uuid_equals(&exp->exp_obd->obd_uuid,
+                                     &exp->exp_client_uuid)))
+                RETURN(0);
+
         ldlm_destroy_export(exp);
 
         RETURN(0);