Whamcloud - gitweb
Branch HEAD
authortappro <tappro>
Thu, 3 Dec 2009 10:27:01 +0000 (10:27 +0000)
committertappro <tappro>
Thu, 3 Dec 2009 10:27:01 +0000 (10:27 +0000)
b=21430
i=adilger
i=johann

seeds PRNG with current time on server, checks export is connected during
request handling

lustre/include/obd_class.h
lustre/ldlm/ldlm_lib.c
lustre/mdt/mdt_handler.c
lustre/mgs/mgs_handler.c
lustre/obdclass/genops.c
lustre/obdclass/lustre_handles.c
lustre/ost/ost_handler.c

index e1e4bc5..d280454 100644 (file)
@@ -257,6 +257,7 @@ int class_connect(struct lustre_handle *conn, struct obd_device *obd,
                   struct obd_uuid *cluuid);
 int class_disconnect(struct obd_export *exp);
 void class_fail_export(struct obd_export *exp);
                   struct obd_uuid *cluuid);
 int class_disconnect(struct obd_export *exp);
 void class_fail_export(struct obd_export *exp);
+int class_connected_export(struct obd_export *exp);
 void class_disconnect_exports(struct obd_device *obddev);
 int class_manual_cleanup(struct obd_device *obd);
 void class_disconnect_stale_exports(struct obd_device *,
 void class_disconnect_exports(struct obd_device *obddev);
 int class_manual_cleanup(struct obd_device *obd);
 void class_disconnect_stale_exports(struct obd_device *,
index ee89dde..2de9fea 100644 (file)
@@ -957,6 +957,7 @@ dont_check_exports:
 
                 GOTO(out, rc = -EALREADY);
         }
 
                 GOTO(out, rc = -EALREADY);
         }
+        LASSERT(lustre_msg_get_conn_cnt(req->rq_reqmsg) > 0);
         export->exp_conn_cnt = lustre_msg_get_conn_cnt(req->rq_reqmsg);
         export->exp_abort_active_req = 0;
 
         export->exp_conn_cnt = lustre_msg_get_conn_cnt(req->rq_reqmsg);
         export->exp_abort_active_req = 0;
 
index 559e15f..0f8d11b 100644 (file)
@@ -2768,7 +2768,7 @@ static int mdt_recovery(struct mdt_thread_info *info)
                 }
         }
 
                 }
         }
 
-        if (unlikely(req->rq_export == NULL)) {
+        if (unlikely(!class_connected_export(req->rq_export))) {
                 CERROR("operation %d on unconnected MDS from %s\n",
                        lustre_msg_get_opc(req->rq_reqmsg),
                        libcfs_id2str(req->rq_peer));
                 CERROR("operation %d on unconnected MDS from %s\n",
                        lustre_msg_get_opc(req->rq_reqmsg),
                        libcfs_id2str(req->rq_peer));
index 3c5262e..99dd197 100644 (file)
@@ -636,7 +636,7 @@ int mgs_handle(struct ptlrpc_request *req)
                 GOTO(out, rc = 0);
 
         if (opc != MGS_CONNECT) {
                 GOTO(out, rc = 0);
 
         if (opc != MGS_CONNECT) {
-                if (req->rq_export == NULL) {
+                if (!class_connected_export(req->rq_export)) {
                         CERROR("lustre_mgs: operation %d on unconnected MGS\n",
                                opc);
                         req->rq_status = -ENOTCONN;
                         CERROR("lustre_mgs: operation %d on unconnected MGS\n",
                                opc);
                         req->rq_status = -ENOTCONN;
index 16cdccc..9c20af2 100644 (file)
@@ -1137,6 +1137,20 @@ no_disconn:
         RETURN(0);
 }
 
         RETURN(0);
 }
 
+/* Return non-zero for a fully connected export */
+int class_connected_export(struct obd_export *exp)
+{
+        if (exp) {
+                int connected;
+                spin_lock(&exp->exp_lock);
+                connected = (exp->exp_conn_cnt > 0);
+                spin_unlock(&exp->exp_lock);
+                return connected;
+        }
+        return 0;
+}
+EXPORT_SYMBOL(class_connected_export);
+
 static void class_disconnect_export_list(struct list_head *list,
                                          enum obd_option flags)
 {
 static void class_disconnect_export_list(struct list_head *list,
                                          enum obd_option flags)
 {
index 342b34e..b8b07ba 100644 (file)
@@ -220,6 +220,8 @@ void class_handle_free_cb(struct rcu_head *rcu)
 int class_handle_init(void)
 {
         struct handle_bucket *bucket;
 int class_handle_init(void)
 {
         struct handle_bucket *bucket;
+        struct timeval tv;
+        int seed[2];
 
         LASSERT(handle_hash == NULL);
 
 
         LASSERT(handle_hash == NULL);
 
@@ -233,6 +235,12 @@ int class_handle_init(void)
                 CFS_INIT_LIST_HEAD(&bucket->head);
                 spin_lock_init(&bucket->lock);
         }
                 CFS_INIT_LIST_HEAD(&bucket->head);
                 spin_lock_init(&bucket->lock);
         }
+
+        /** bug 21430: add randomness to the initial base */
+        ll_get_random_bytes(seed, sizeof(seed));
+        do_gettimeofday(&tv);
+        ll_srand(tv.tv_sec ^ seed[0], tv.tv_usec ^ seed[1]);
+
         ll_get_random_bytes(&handle_base, sizeof(handle_base));
         LASSERT(handle_base != 0ULL);
 
         ll_get_random_bytes(&handle_base, sizeof(handle_base));
         LASSERT(handle_base != 0ULL);
 
index da41e62..a333280 100644 (file)
@@ -1990,11 +1990,10 @@ int ost_handle(struct ptlrpc_request *req)
 
         req_capsule_init(&req->rq_pill, req, RCL_SERVER);
 
 
         req_capsule_init(&req->rq_pill, req, RCL_SERVER);
 
-        /* XXX identical to MDS */
         if (lustre_msg_get_opc(req->rq_reqmsg) != OST_CONNECT) {
                 int recovering;
 
         if (lustre_msg_get_opc(req->rq_reqmsg) != OST_CONNECT) {
                 int recovering;
 
-                if (req->rq_export == NULL) {
+                if (!class_connected_export(req->rq_export)) {
                         CDEBUG(D_HA,"operation %d on unconnected OST from %s\n",
                                lustre_msg_get_opc(req->rq_reqmsg),
                                libcfs_id2str(req->rq_peer));
                         CDEBUG(D_HA,"operation %d on unconnected OST from %s\n",
                                lustre_msg_get_opc(req->rq_reqmsg),
                                libcfs_id2str(req->rq_peer));