Whamcloud - gitweb
b=2552
[fs/lustre-release.git] / lustre / mds / mds_fs.c
index 453d8b4..1dfc246 100644 (file)
@@ -91,7 +91,7 @@ int mds_client_add(struct obd_device *obd, struct mds_obd *mds,
                 }
         }
 
-        CDEBUG(D_INFO, "client at index %d with UUID '%s' added\n",
+        CDEBUG(D_INFO, "client at idx %d with UUID '%s' added\n",
                cl_idx, med->med_mcd->mcd_uuid);
 
         med->med_idx = cl_idx;
@@ -135,10 +135,12 @@ int mds_client_free(struct obd_export *exp, int clear_client)
         if (!strcmp(med->med_mcd->mcd_uuid, obd->obd_uuid.uuid))
                 GOTO(free_and_out, 0);
 
-        CDEBUG(D_INFO, "freeing client at index %u (%lld)with UUID '%s'\n",
+        CDEBUG(D_INFO, "freeing client at idx %u (%lld)with UUID '%s'\n",
                med->med_idx, med->med_off, med->med_mcd->mcd_uuid);
 
-        if (!test_and_clear_bit(med->med_idx, bitmap)) {
+        /* Clear the bit _after_ zeroing out the client so we don't
+           race with mds_client_add and zero out new clients.*/
+        if (!test_bit(med->med_idx, bitmap)) {
                 CERROR("MDS client %u: bit already clear in bitmap!!\n",
                        med->med_idx);
                 LBUG();
@@ -152,10 +154,16 @@ int mds_client_free(struct obd_export *exp, int clear_client)
                 pop_ctxt(&saved, &obd->obd_ctxt, NULL);
 
                 CDEBUG(rc == 0 ? D_INFO : D_ERROR,
-                       "zeroing out client %s off %u in %s rc %d\n",
+                       "zeroing out client %s idx %u in %s rc %d\n",
                        med->med_mcd->mcd_uuid, med->med_idx, LAST_RCVD, rc);
         }
 
+        if (!test_and_clear_bit(med->med_idx, bitmap)) {
+                CERROR("MDS client %u: bit already clear in bitmap!!\n",
+                       med->med_idx);
+                LBUG();
+        }
+
  free_and_out:
         OBD_FREE(med->med_mcd, sizeof(*med->med_mcd));
 
@@ -265,7 +273,8 @@ static int mds_read_last_rcvd(struct obd_device *obd, struct file *file)
         for (cl_idx = 0, off = le32_to_cpu(msd->msd_client_start);
              off < last_rcvd_size; cl_idx++) {
                 __u64 last_transno;
-                int mount_age;
+                struct obd_export *exp;
+                struct mds_export_data *med;
 
                 if (!mcd) {
                         OBD_ALLOC_WAIT(mcd, sizeof(*mcd));
@@ -296,36 +305,27 @@ static int mds_read_last_rcvd(struct obd_device *obd, struct file *file)
                 /* These exports are cleaned up by mds_disconnect(), so they
                  * need to be set up like real exports as mds_connect() does.
                  */
-                mount_age = mount_count - le64_to_cpu(mcd->mcd_mount_count);
-                if (mount_age < MDS_MOUNT_RECOV) {
-                        struct obd_export *exp = class_new_export(obd);
-                        struct mds_export_data *med;
-                        CDEBUG(D_HA, "RCVRNG CLIENT uuid: %s idx: %d lr: "LPU64
-                               " srv lr: "LPU64" mnt: "LPU64" last mount: "
-                               LPU64"\n", mcd->mcd_uuid, cl_idx,
-                               last_transno, le64_to_cpu(msd->msd_last_transno),
-                               le64_to_cpu(mcd->mcd_mount_count), mount_count);
-                        if (exp == NULL)
-                                GOTO(err_client, rc = -ENOMEM);
-
-                        memcpy(&exp->exp_client_uuid.uuid, mcd->mcd_uuid,
-                               sizeof exp->exp_client_uuid.uuid);
-                        med = &exp->exp_mds_data;
-                        med->med_mcd = mcd;
-                        mds_client_add(obd, mds, med, cl_idx);
-                        /* create helper if export init gets more complex */
-                        INIT_LIST_HEAD(&med->med_open_head);
-                        spin_lock_init(&med->med_open_lock);
-
-                        mcd = NULL;
-                        obd->obd_recoverable_clients++;
-                        obd->obd_max_recoverable_clients++;
-                        class_export_put(exp);
-                } else {
-                        CDEBUG(D_INFO, "discarded client %d, UUID '%s', count "
-                               LPU64"\n", cl_idx, mcd->mcd_uuid,
-                               le64_to_cpu(mcd->mcd_mount_count));
-                }
+                CDEBUG(D_HA, "RCVRNG CLIENT uuid: %s idx: %d lr: "LPU64
+                       " srv lr: "LPU64"\n", mcd->mcd_uuid, cl_idx,
+                       last_transno, le64_to_cpu(msd->msd_last_transno));
+
+                exp = class_new_export(obd);
+                if (exp == NULL)
+                        GOTO(err_client, rc = -ENOMEM);
+
+                memcpy(&exp->exp_client_uuid.uuid, mcd->mcd_uuid,
+                       sizeof exp->exp_client_uuid.uuid);
+                med = &exp->exp_mds_data;
+                med->med_mcd = mcd;
+                mds_client_add(obd, mds, med, cl_idx);
+                /* create helper if export init gets more complex */
+                INIT_LIST_HEAD(&med->med_open_head);
+                spin_lock_init(&med->med_open_lock);
+
+                mcd = NULL;
+                obd->obd_recoverable_clients++;
+                obd->obd_max_recoverable_clients++;
+                class_export_put(exp);
 
                 CDEBUG(D_OTHER, "client at idx %d has last_transno = "LPU64"\n",
                        cl_idx, last_transno);
@@ -336,9 +336,9 @@ static int mds_read_last_rcvd(struct obd_device *obd, struct file *file)
 
         obd->obd_last_committed = mds->mds_last_transno;
         if (obd->obd_recoverable_clients) {
-                CWARN("RECOVERY: %d recoverable clients, last_transno "
-                       LPU64"\n", obd->obd_recoverable_clients,
-                       mds->mds_last_transno);
+                CWARN("RECOVERY: service %s, %d recoverable clients, "
+                      "last_transno "LPU64"\n", obd->obd_name,
+                      obd->obd_recoverable_clients, mds->mds_last_transno);
                 obd->obd_next_recovery_transno = obd->obd_last_committed + 1;
                 obd->obd_recovering = 1;
         }