Whamcloud - gitweb
LU-12930 various: use schedule_timeout_*interruptible
[fs/lustre-release.git] / lustre / obdclass / obd_mount_server.c
index 5b5cb20..d3854db 100644 (file)
@@ -419,7 +419,7 @@ int lustre_register_lwp_item(const char *lwpname, struct obd_export **exp,
                        RETURN(-ENOMEM);
                }
                memcpy(uuid->uuid, lwpname, strlen(lwpname));
-               *exp = cfs_hash_lookup(lwp->obd_uuid_hash, uuid);
+               *exp = obd_uuid_lookup(lwp, uuid);
                OBD_FREE_PTR(uuid);
        }
 
@@ -476,8 +476,7 @@ void lustre_deregister_lwp_item(struct obd_export **exp)
                CDEBUG(D_MOUNT, "lri reference count %u, repeat: %d\n",
                       atomic_read(&lri->lri_ref), repeat);
                repeat++;
-               set_current_state(TASK_INTERRUPTIBLE);
-               schedule_timeout(cfs_time_seconds(1));
+               schedule_timeout_interruptible(cfs_time_seconds(1));
        }
        lustre_put_lwp_item(lri);
 }
@@ -881,6 +880,20 @@ static int client_lwp_config_process(const struct lu_env *env,
                if (!is_mdc_device(devname))
                        break;
 
+               if (!(cfg->cfg_flags & CFG_F_MARKER)) {
+                       CDEBUG(D_CONFIG, "Skipping add_conn for %s, rec %d\n",
+                              devname, rec->lrh_index);
+                       break;
+               }
+
+               /* add_conn should follow by add_uuid. This
+                * guarantee lwp device was created
+                */
+               if (!(cfg->cfg_flags & CFG_F_SKIP)) {
+                       CWARN("Error at config for %s rec %d, add_conn should follow by add_uuid\n",
+                             devname, rec->lrh_index);
+                       break;
+               }
                ptr = strrchr(devname, '-');
                if (ptr == NULL)
                        break;
@@ -1101,7 +1114,7 @@ static int server_stop_servers(int lsiflags)
        LASSERTF(type, "Server flags %d, obd %s\n", lsiflags,
                 obd ? obd->obd_name : "NULL");
 
-       type_last = (type->typ_refcnt == 1);
+       type_last = (atomic_read(&type->typ_refcnt) == 1);
 
        class_put_type(type);
        if (obd != NULL && type_last) {
@@ -1251,9 +1264,8 @@ again:
                        if ((rc == -ESHUTDOWN || rc == -EIO) && ++tried < 5) {
                                /* The connection with MGS is not established.
                                 * Try again after 2 seconds. Interruptable. */
-                               set_current_state(TASK_INTERRUPTIBLE);
-                               schedule_timeout(cfs_time_seconds(2));
-                               set_current_state(TASK_RUNNING);
+                               schedule_timeout_interruptible(
+                                       cfs_time_seconds(2));
                                if (!signal_pending(current))
                                        goto again;
                        }
@@ -1367,6 +1379,10 @@ static int server_start_targets(struct super_block *sb)
        /* hold a type reference and put it at server_stop_servers */
        type = class_get_type(IS_MDT(lsi) ?
                              LUSTRE_MDT_NAME : LUSTRE_OST_NAME);
+       if (!type) {
+               mutex_unlock(&server_start_lock);
+               GOTO(out_stop_service, rc = -ENODEV);
+       }
        lsi->lsi_server_started = 1;
        mutex_unlock(&server_start_lock);
        if (OBD_FAIL_PRECHECK(OBD_FAIL_OBD_STOP_MDS_RACE) &&