Whamcloud - gitweb
LU-2104 recovery: keep valid obd_stale_clients during recovery
[fs/lustre-release.git] / lustre / ofd / ofd_dev.c
index 7b2710e..1f7bf8e 100644 (file)
@@ -179,6 +179,12 @@ static void ofd_stack_fini(const struct lu_env *env, struct ofd_device *m,
        EXIT;
 }
 
+/* For interoperability, see mdt_interop_param[]. */
+static struct cfg_interop_param ofd_interop_param[] = {
+       { "ost.quota_type",     NULL },
+       { NULL }
+};
+
 /* used by MGS to process specific configurations */
 static int ofd_process_config(const struct lu_env *env, struct lu_device *d,
                              struct lustre_cfg *cfg)
@@ -194,6 +200,38 @@ static int ofd_process_config(const struct lu_env *env, struct lu_device *d,
        case LCFG_PARAM: {
                struct lprocfs_static_vars lvars;
 
+               /* For interoperability */
+               struct cfg_interop_param   *ptr = NULL;
+               struct lustre_cfg          *old_cfg = NULL;
+               char                       *param = NULL;
+
+               param = lustre_cfg_string(cfg, 1);
+               if (param == NULL) {
+                       CERROR("param is empty\n");
+                       rc = -EINVAL;
+                       break;
+               }
+
+               ptr = class_find_old_param(param, ofd_interop_param);
+               if (ptr != NULL) {
+                       if (ptr->new_param == NULL) {
+                               rc = 0;
+                               CWARN("For interoperability, skip this %s."
+                                     " It is obsolete.\n", ptr->old_param);
+                               break;
+                       }
+
+                       CWARN("Found old param %s, changed it to %s.\n",
+                             ptr->old_param, ptr->new_param);
+
+                       old_cfg = cfg;
+                       cfg = lustre_cfg_rename(old_cfg, ptr->new_param);
+                       if (IS_ERR(cfg)) {
+                               rc = PTR_ERR(cfg);
+                               break;
+                       }
+               }
+
                lprocfs_ofd_init_vars(&lvars);
                rc = class_process_proc_param(PARAM_OST, lvars.obd_vars, cfg,
                                              d->ld_obd);
@@ -293,17 +331,39 @@ static struct lu_object *ofd_object_alloc(const struct lu_env *env,
 
 extern int ost_handle(struct ptlrpc_request *req);
 
-static int ofd_start(const struct lu_env *env, struct lu_device *dev)
+static int ofd_prepare(const struct lu_env *env, struct lu_device *pdev,
+                      struct lu_device *dev)
 {
+       struct ofd_thread_info *info;
        struct ofd_device       *ofd = ofd_dev(dev);
+       struct obd_device       *obd = ofd_obd(ofd);
        struct lu_device        *next = &ofd->ofd_osd->dd_lu_dev;
        int                      rc;
 
        ENTRY;
 
+       rc = lu_env_refill((struct lu_env *)env);
+       if (rc != 0) {
+               CERROR("Failure to refill session: '%d'\n", rc);
+               RETURN(rc);
+       }
+
+       info = ofd_info_init(env, NULL);
+       if (info == NULL)
+               RETURN(-EFAULT);
+
        /* initialize lower device */
        rc = next->ld_ops->ldo_prepare(env, dev, next);
 
+       target_recovery_init(&ofd->ofd_lut, ost_handle);
+       LASSERT(obd->obd_no_conn);
+       spin_lock(&obd->obd_dev_lock);
+       obd->obd_no_conn = 0;
+       spin_unlock(&obd->obd_dev_lock);
+
+       if (obd->obd_recovering == 0)
+               ofd_postrecov(env, ofd);
+
        RETURN(rc);
 }
 
@@ -331,6 +391,7 @@ static struct lu_device_operations ofd_lu_ops = {
        .ldo_object_alloc       = ofd_object_alloc,
        .ldo_process_config     = ofd_process_config,
        .ldo_recovery_complete  = ofd_recovery_complete,
+       .ldo_prepare            = ofd_prepare,
 };
 
 static int ofd_procfs_init(struct ofd_device *ofd)
@@ -389,8 +450,14 @@ static int ofd_procfs_init(struct ofd_device *ofd)
                       obd->obd_name, rc);
                GOTO(free_obd_stats, rc);
        }
-       RETURN(0);
 
+       rc = lprocfs_job_stats_init(obd, LPROC_OFD_STATS_LAST,
+                                   ofd_stats_counter_init);
+       if (rc)
+               GOTO(remove_entry_clear, rc);
+       RETURN(0);
+remove_entry_clear:
+       lprocfs_remove_proc_entry("clear", obd->obd_proc_exports_entry);
 free_obd_stats:
        lprocfs_free_obd_stats(obd);
 obd_cleanup:
@@ -402,6 +469,7 @@ static int ofd_procfs_fini(struct ofd_device *ofd)
 {
        struct obd_device *obd = ofd_obd(ofd);
 
+       lprocfs_job_stats_fini(obd);
        lprocfs_remove_proc_entry("clear", obd->obd_proc_exports_entry);
        lprocfs_free_per_client_stats(obd);
        lprocfs_free_obd_stats(obd);
@@ -437,27 +505,27 @@ static int ofd_init0(const struct lu_env *env, struct ofd_device *m,
        m->ofd_fmd_max_num = OFD_FMD_MAX_NUM_DEFAULT;
        m->ofd_fmd_max_age = OFD_FMD_MAX_AGE_DEFAULT;
 
-       cfs_spin_lock_init(&m->ofd_flags_lock);
+       spin_lock_init(&m->ofd_flags_lock);
        m->ofd_raid_degraded = 0;
        m->ofd_syncjournal = 0;
        ofd_slc_set(m);
        m->ofd_grant_compat_disable = 0;
 
        /* statfs data */
-       cfs_spin_lock_init(&m->ofd_osfs_lock);
+       spin_lock_init(&m->ofd_osfs_lock);
        m->ofd_osfs_age = cfs_time_shift_64(-1000);
        m->ofd_osfs_unstable = 0;
        m->ofd_statfs_inflight = 0;
        m->ofd_osfs_inflight = 0;
 
        /* grant data */
-       cfs_spin_lock_init(&m->ofd_grant_lock);
+       spin_lock_init(&m->ofd_grant_lock);
        m->ofd_tot_dirty = 0;
        m->ofd_tot_granted = 0;
        m->ofd_tot_pending = 0;
        m->ofd_max_group = 0;
 
-       cfs_rwlock_init(&obd->u.filter.fo_sptlrpc_lock);
+       rwlock_init(&obd->u.filter.fo_sptlrpc_lock);
        sptlrpc_rule_set_init(&obd->u.filter.fo_sptlrpc_rset);
 
        obd->u.filter.fo_fl_oss_capa = 0;
@@ -511,7 +579,11 @@ static int ofd_init0(const struct lu_env *env, struct ofd_device *m,
                                obd->obd_name, osfs->os_bsize);
                GOTO(err_fini_stack, rc = -EPROTO);
        }
-       m->ofd_blockbits = cfs_fls(osfs->os_bsize) - 1;
+       m->ofd_blockbits = fls(osfs->os_bsize) - 1;
+
+       m->ofd_precreate_batch = OFD_PRECREATE_BATCH_DEFAULT;
+       if (osfs->os_bsize * osfs->os_blocks < OFD_PRECREATE_SMALL_FS)
+               m->ofd_precreate_batch = OFD_PRECREATE_BATCH_SMALL;
 
        snprintf(info->fti_u.name, sizeof(info->fti_u.name), "filter-%p", m);
        m->ofd_namespace = ldlm_namespace_new(obd, info->fti_u.name,
@@ -539,11 +611,7 @@ static int ofd_init0(const struct lu_env *env, struct ofd_device *m,
        m->ofd_grant_ratio =
                ofd_grant_ratio_conv(m->ofd_dt_conf.ddp_grant_reserved);
 
-       rc = ofd_start(env, &m->ofd_dt_dev.dd_lu_dev);
-       if (rc)
-               GOTO(err_fini_stack, rc);
-
-       rc = lut_init(env, &m->ofd_lut, obd, m->ofd_osd);
+       rc = tgt_init(env, &m->ofd_lut, obd, m->ofd_osd);
        if (rc)
                GOTO(err_free_ns, rc);
 
@@ -551,11 +619,9 @@ static int ofd_init0(const struct lu_env *env, struct ofd_device *m,
        if (rc)
                GOTO(err_fini_lut, rc);
 
-       target_recovery_init(&m->ofd_lut, ost_handle);
-
        RETURN(0);
 err_fini_lut:
-       lut_fini(env, &m->ofd_lut);
+       tgt_fini(env, &m->ofd_lut);
 err_free_ns:
        ldlm_namespace_free(m->ofd_namespace, 0, obd->obd_force);
        obd->obd_namespace = m->ofd_namespace = NULL;
@@ -575,7 +641,7 @@ static void ofd_fini(const struct lu_env *env, struct ofd_device *m)
        obd_exports_barrier(obd);
        obd_zombie_barrier();
 
-       lut_fini(env, &m->ofd_lut);
+       tgt_fini(env, &m->ofd_lut);
        ofd_fs_cleanup(env, m);
 
        ofd_free_capa_keys(m);