Whamcloud - gitweb
b=4059
authoralex <alex>
Mon, 2 Aug 2004 23:39:02 +0000 (23:39 +0000)
committeralex <alex>
Mon, 2 Aug 2004 23:39:02 +0000 (23:39 +0000)
- race in lmv_check_connect() has been fixed: few threads might try to
  establish LMV's connects to MDCs and some of them might find not-yet-
  -connected LMV operational

lustre/include/linux/obd.h
lustre/lmv/lmv_obd.c

index 94616f8..56eab77 100644 (file)
@@ -450,6 +450,7 @@ struct lmv_obd {
         int                     max_cookiesize;
         int                     server_timeout;
         int                     connect_flags;
+        struct semaphore        init_sem;
 };
 
 struct niobuf_local {
index 9d6aab1..66d9d7f 100644 (file)
@@ -197,6 +197,7 @@ static int lmv_connect(struct lustre_handle *conn, struct obd_device *obd,
         lmv->connect_flags = connect_flags;
         lmv->connected = 0;
         lmv->exp = exp;
+        sema_init(&lmv->init_sem, 1);
 
         RETURN(0);
 }
@@ -233,7 +234,13 @@ int lmv_check_connect(struct obd_device *obd)
 
         if (lmv->connected)
                 return 0;
-      
+
+        down(&lmv->init_sem);
+        if (lmv->connected) {
+                up(&lmv->init_sem);
+                return 0;
+        }
+
         lmv->connected = 1;
         cluuid = &lmv->cluuid;
         exp = lmv->exp;
@@ -302,6 +309,7 @@ int lmv_check_connect(struct obd_device *obd)
 
         lmv_set_timeouts(obd);
         class_export_put(exp);
+        up(&lmv->init_sem);
         return 0;
 
  out_disc:
@@ -318,6 +326,7 @@ int lmv_check_connect(struct obd_device *obd)
                                "error %d\n", uuid.uuid, i, rc2);
         }
         class_disconnect(exp, 0);
+        up(&lmv->init_sem);
         RETURN (rc);
 }