Whamcloud - gitweb
LU-8990 lod: put root at cleanup
[fs/lustre-release.git] / lustre / lod / lod_dev.c
index 7c7a1cb..0c2ddcb 100644 (file)
@@ -23,7 +23,7 @@
  * Copyright  2009 Sun Microsystems, Inc. All rights reserved
  * Use is subject to license terms.
  *
- * Copyright (c) 2012, 2014, Intel Corporation.
+ * Copyright (c) 2012, 2017, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -93,7 +93,7 @@
 #include <obd_class.h>
 #include <md_object.h>
 #include <lustre_fid.h>
-#include <lustre_param.h>
+#include <uapi/linux/lustre/lustre_param.h>
 #include <lustre_update.h>
 #include <lustre_log.h>
 
@@ -164,7 +164,7 @@ int lod_fld_lookup(const struct lu_env *env, struct lod_device *lod,
        *tgt = range.lsr_index;
        *type = range.lsr_flags;
 
-       CDEBUG(D_INFO, "%s: got tgt %x for sequence: "LPX64"\n",
+       CDEBUG(D_INFO, "%s: got tgt %x for sequence: %#llx\n",
               lod2obd(lod)->obd_name, *tgt, fid_seq(fid));
 
        RETURN(0);
@@ -316,21 +316,25 @@ static int lod_process_recovery_updates(const struct lu_env *env,
 
        if (rec->lrh_len !=
                llog_update_record_size((struct llog_update_record *)rec)) {
-               CERROR("%s broken update record! index %u "DOSTID":%u : rc = %d\n",
-                      lod2obd(lrd->lrd_lod)->obd_name, index,
-                      POSTID(&llh->lgh_id.lgl_oi), rec->lrh_index, -EIO);
-               return -EIO;
+               CERROR("%s broken update record! index %u "DFID".%u :"
+                      " rc = %d\n", lod2obd(lrd->lrd_lod)->obd_name, index,
+                      PFID(&llh->lgh_id.lgl_oi.oi_fid), rec->lrh_index, -EIO);
+               return -EINVAL;
        }
 
        cookie->lgc_lgl = llh->lgh_id;
        cookie->lgc_index = rec->lrh_index;
        cookie->lgc_subsys = LLOG_UPDATELOG_ORIG_CTXT;
 
-       CDEBUG(D_HA, "%s: process recovery updates "DOSTID":%u\n",
+       CDEBUG(D_HA, "%s: process recovery updates "DFID".%u\n",
               lod2obd(lrd->lrd_lod)->obd_name,
-              POSTID(&llh->lgh_id.lgl_oi), rec->lrh_index);
+              PFID(&llh->lgh_id.lgl_oi.oi_fid), rec->lrh_index);
        lut = lod2lu_dev(lrd->lrd_lod)->ld_site->ls_tgt;
 
+       if (lut->lut_obd->obd_stopping ||
+           lut->lut_obd->obd_abort_recovery)
+               return -ESHUTDOWN;
+
        return insert_update_records_to_replay_list(lut->lut_tdtd,
                                        (struct llog_update_record *)rec,
                                        cookie, index);
@@ -349,13 +353,19 @@ static int lod_process_recovery_updates(const struct lu_env *env,
  */
 static int lod_sub_recovery_thread(void *arg)
 {
-       struct lod_recovery_data        *lrd = arg;
-       struct lod_device               *lod = lrd->lrd_lod;
-       struct dt_device                *dt;
-       struct ptlrpc_thread            *thread = lrd->lrd_thread;
-       struct llog_ctxt                *ctxt;
-       struct lu_env                   env;
-       int                             rc;
+       struct lod_recovery_data *lrd = arg;
+       struct lod_device *lod = lrd->lrd_lod;
+       struct dt_device *dt;
+       struct ptlrpc_thread *thread = lrd->lrd_thread;
+       struct llog_ctxt *ctxt = NULL;
+       struct lu_env env;
+       struct lu_target *lut;
+       struct lod_tgt_descs *ltd = &lod->lod_mdt_descs;
+       struct lod_tgt_desc *tgt = NULL;
+       time64_t start;
+       int retries = 0;
+       int i;
+       int rc;
        ENTRY;
 
        thread->t_flags = SVC_RUNNING;
@@ -369,69 +379,102 @@ static int lod_sub_recovery_thread(void *arg)
                RETURN(rc);
        }
 
+       lut = lod2lu_dev(lod)->ld_site->ls_tgt;
+       atomic_inc(&lut->lut_tdtd->tdtd_recovery_threads_count);
        if (lrd->lrd_ltd == NULL)
                dt = lod->lod_child;
        else
                dt = lrd->lrd_ltd->ltd_tgt;
 
-       rc = lod_sub_prep_llog(&env, lod, dt, lrd->lrd_idx);
-       if (rc != 0)
-               GOTO(out, rc);
+       start = ktime_get_real_seconds();
 
-       /* Process the recovery record */
-       ctxt = llog_get_context(dt->dd_lu_dev.ld_obd, LLOG_UPDATELOG_ORIG_CTXT);
-       LASSERT(ctxt != NULL);
-       LASSERT(ctxt->loc_handle != NULL);
-
-       rc = llog_cat_process(&env, ctxt->loc_handle,
-                             lod_process_recovery_updates, lrd, 0, 0);
-       llog_ctxt_put(ctxt);
+again:
+       rc = lod_sub_prep_llog(&env, lod, dt, lrd->lrd_idx);
+       if (!rc && !lod->lod_child->dd_rdonly) {
+               /* Process the recovery record */
+               ctxt = llog_get_context(dt->dd_lu_dev.ld_obd,
+                                       LLOG_UPDATELOG_ORIG_CTXT);
+               LASSERT(ctxt != NULL);
+               LASSERT(ctxt->loc_handle != NULL);
+
+               rc = llog_cat_process(&env, ctxt->loc_handle,
+                                     lod_process_recovery_updates, lrd, 0, 0);
+       }
 
        if (rc < 0) {
-               CERROR("%s getting update log failed: rc = %d\n",
+               struct lu_device *top_device;
+
+               top_device = lod->lod_dt_dev.dd_lu_dev.ld_site->ls_top_dev;
+               /* Because the remote target might failover at the same time,
+                * let's retry here */
+               if ((rc == -ETIMEDOUT || rc == -EAGAIN || rc == -EIO) &&
+                    dt != lod->lod_child &&
+                   !top_device->ld_obd->obd_abort_recovery &&
+                   !top_device->ld_obd->obd_stopping) {
+                       if (ctxt != NULL) {
+                               if (ctxt->loc_handle != NULL)
+                                       llog_cat_close(&env,
+                                                      ctxt->loc_handle);
+                               llog_ctxt_put(ctxt);
+                       }
+                       retries++;
+                       CDEBUG(D_HA, "%s get update log failed %d, retry\n",
+                              dt->dd_lu_dev.ld_obd->obd_name, rc);
+                       goto again;
+               }
+
+               CERROR("%s get update log failed: rc = %d\n",
                       dt->dd_lu_dev.ld_obd->obd_name, rc);
+               llog_ctxt_put(ctxt);
+
+               spin_lock(&top_device->ld_obd->obd_dev_lock);
+               if (!top_device->ld_obd->obd_abort_recovery &&
+                   !top_device->ld_obd->obd_stopping)
+                       top_device->ld_obd->obd_abort_recovery = 1;
+               spin_unlock(&top_device->ld_obd->obd_dev_lock);
+
                GOTO(out, rc);
        }
+       llog_ctxt_put(ctxt);
 
-       CDEBUG(D_HA, "%s retrieve update log: rc = %d\n",
-              dt->dd_lu_dev.ld_obd->obd_name, rc);
+       CDEBUG(D_HA, "%s retrieved update log, duration %lld, retries %d\n",
+              dt->dd_lu_dev.ld_obd->obd_name, ktime_get_real_seconds() - start,
+              retries);
 
+       spin_lock(&lod->lod_lock);
        if (lrd->lrd_ltd == NULL)
                lod->lod_child_got_update_log = 1;
        else
                lrd->lrd_ltd->ltd_got_update_log = 1;
 
-       if (lod->lod_child_got_update_log) {
-               struct lod_tgt_descs    *ltd = &lod->lod_mdt_descs;
-               struct lod_tgt_desc     *tgt = NULL;
-               bool                    all_got_log = true;
-               int                     i;
-
-               cfs_foreach_bit(ltd->ltd_tgt_bitmap, i) {
-                       tgt = LTD_TGT(ltd, i);
-                       if (!tgt->ltd_got_update_log) {
-                               all_got_log = false;
-                               break;
-                       }
-               }
-
-               if (all_got_log) {
-                       struct lu_target *lut;
+       if (!lod->lod_child_got_update_log) {
+               spin_unlock(&lod->lod_lock);
+               GOTO(out, rc = 0);
+       }
 
-                       lut = lod2lu_dev(lod)->ld_site->ls_tgt;
-                       CDEBUG(D_HA, "%s got update logs from all MDTs.\n",
-                              lut->lut_obd->obd_name);
-                       lut->lut_tdtd->tdtd_replay_ready = 1;
-                       wake_up(&lut->lut_obd->obd_next_transno_waitq);
+       cfs_foreach_bit(ltd->ltd_tgt_bitmap, i) {
+               tgt = LTD_TGT(ltd, i);
+               if (!tgt->ltd_got_update_log) {
+                       spin_unlock(&lod->lod_lock);
+                       GOTO(out, rc = 0);
                }
        }
+       lut->lut_tdtd->tdtd_replay_ready = 1;
+       spin_unlock(&lod->lod_lock);
+
+       CDEBUG(D_HA, "%s got update logs from all MDTs.\n",
+              lut->lut_obd->obd_name);
+       wake_up(&lut->lut_obd->obd_next_transno_waitq);
+       EXIT;
 
 out:
        OBD_FREE_PTR(lrd);
        thread->t_flags = SVC_STOPPED;
+       atomic_dec(&lut->lut_tdtd->tdtd_recovery_threads_count);
+       wake_up(&lut->lut_tdtd->tdtd_recovery_threads_waitq);
        wake_up(&thread->t_ctl_waitq);
        lu_env_fini(&env);
-       RETURN(rc);
+       return rc;
 }
 
 /**
@@ -631,6 +674,50 @@ free_lrd:
 }
 
 /**
+ * Stop sub recovery thread
+ *
+ * Stop sub recovery thread on all subs.
+ *
+ * \param[in] env      execution environment
+ * \param[in] lod      lod device to do update recovery
+ */
+static void lod_sub_stop_recovery_threads(const struct lu_env *env,
+                                         struct lod_device *lod)
+{
+       struct lod_tgt_descs *ltd = &lod->lod_mdt_descs;
+       struct ptlrpc_thread    *thread;
+       unsigned int i;
+
+       /* Stop the update log commit cancel threads and finish master
+        * llog ctxt */
+       thread = &lod->lod_child_recovery_thread;
+       /* Stop recovery thread first */
+       if (thread != NULL && thread->t_flags & SVC_RUNNING) {
+               thread->t_flags = SVC_STOPPING;
+               wake_up(&thread->t_ctl_waitq);
+               wait_event(thread->t_ctl_waitq, thread->t_flags & SVC_STOPPED);
+       }
+
+       lod_getref(ltd);
+       cfs_foreach_bit(ltd->ltd_tgt_bitmap, i) {
+               struct lod_tgt_desc     *tgt;
+
+               tgt = LTD_TGT(ltd, i);
+               thread = tgt->ltd_recovery_thread;
+               if (thread != NULL && thread->t_flags & SVC_RUNNING) {
+                       thread->t_flags = SVC_STOPPING;
+                       wake_up(&thread->t_ctl_waitq);
+                       wait_event(thread->t_ctl_waitq,
+                                  thread->t_flags & SVC_STOPPED);
+                       OBD_FREE_PTR(tgt->ltd_recovery_thread);
+                       tgt->ltd_recovery_thread = NULL;
+               }
+       }
+
+       lod_putref(lod, ltd);
+}
+
+/**
  * finish all sub llog
  *
  * cleanup all of sub llog ctxt on the LOD.
@@ -653,17 +740,64 @@ static void lod_sub_fini_all_llogs(const struct lu_env *env,
                struct lod_tgt_desc     *tgt;
 
                tgt = LTD_TGT(ltd, i);
-               if (tgt->ltd_recovery_thread != NULL) {
-                       lod_sub_fini_llog(env, tgt->ltd_tgt,
-                                         tgt->ltd_recovery_thread);
-                       OBD_FREE_PTR(tgt->ltd_recovery_thread);
-                       tgt->ltd_recovery_thread = NULL;
-               }
+               lod_sub_fini_llog(env, tgt->ltd_tgt,
+                                 tgt->ltd_recovery_thread);
        }
 
        lod_putref(lod, ltd);
 }
 
+static char *lod_show_update_logs_retrievers(void *data, int *size, int *count)
+{
+       struct lod_device       *lod = (struct lod_device *)data;
+       struct lu_target        *lut = lod2lu_dev(lod)->ld_site->ls_tgt;
+       struct lod_tgt_descs    *ltd = &lod->lod_mdt_descs;
+       struct lod_tgt_desc     *tgt = NULL;
+       char                    *buf;
+       int                      len = 0;
+       int                      rc;
+       int                      i;
+
+       *count = atomic_read(&lut->lut_tdtd->tdtd_recovery_threads_count);
+       if (*count == 0) {
+               *size = 0;
+               return NULL;
+       }
+
+       *size = 5 * *count + 1;
+       OBD_ALLOC(buf, *size);
+       if (buf == NULL)
+               return NULL;
+
+       *count = 0;
+       memset(buf, 0, *size);
+
+       if (!lod->lod_child_got_update_log) {
+               rc = lodname2mdt_index(lod2obd(lod)->obd_name, &i);
+               LASSERTF(rc == 0, "Fail to parse target index: rc = %d\n", rc);
+
+               rc = snprintf(buf + len, *size - len, " %04x", i);
+               LASSERT(rc > 0);
+
+               len += rc;
+               (*count)++;
+       }
+
+       cfs_foreach_bit(ltd->ltd_tgt_bitmap, i) {
+               tgt = LTD_TGT(ltd, i);
+               if (!tgt->ltd_got_update_log) {
+                       rc = snprintf(buf + len, *size - len, " %04x", i);
+                       if (unlikely(rc <= 0))
+                               break;
+
+                       len += rc;
+                       (*count)++;
+               }
+       }
+
+       return buf;
+}
+
 /**
  * Prepare distribute txn
  *
@@ -689,7 +823,7 @@ static int lod_prepare_distribute_txn(const struct lu_env *env,
                RETURN(-ENOMEM);
 
        lut = lod2lu_dev(lod)->ld_site->ls_tgt;
-
+       tdtd->tdtd_dt = &lod->lod_dt_dev;
        rc = distribute_txn_init(env, lut, tdtd,
                lu_site2seq(lod2lu_dev(lod)->ld_site)->ss_node_id);
 
@@ -700,11 +834,9 @@ static int lod_prepare_distribute_txn(const struct lu_env *env,
                RETURN(rc);
        }
 
-       tdtd->tdtd_dt = &lod->lod_dt_dev;
-       INIT_LIST_HEAD(&tdtd->tdtd_replay_list);
-       spin_lock_init(&tdtd->tdtd_replay_list_lock);
-       tdtd->tdtd_replay_handler = distribute_txn_replay_handle;
-       tdtd->tdtd_replay_ready = 0;
+       tdtd->tdtd_show_update_logs_retrievers =
+               lod_show_update_logs_retrievers;
+       tdtd->tdtd_show_retrievers_cbdata = lod;
 
        lut->lut_tdtd = tdtd;
 
@@ -726,6 +858,7 @@ static void lod_fini_distribute_txn(const struct lu_env *env,
        struct lu_target                  *lut;
 
        lut = lod2lu_dev(lod)->ld_site->ls_tgt;
+       target_recovery_fini(lut->lut_obd);
        if (lut->lut_tdtd == NULL)
                return;
 
@@ -826,12 +959,89 @@ static int lod_process_config(const struct lu_env *env,
        }
 
        case LCFG_PARAM: {
-               struct obd_device *obd = lod2obd(lod);
+               struct obd_device *obd;
+               char *param;
+
+               /* Check if it is activate/deactivate mdc
+                * lustre-MDTXXXX-osp-MDTXXXX.active=1 */
+               param = lustre_cfg_buf(lcfg, 1);
+               if (strstr(param, "osp") != NULL &&
+                   strstr(param, ".active=") != NULL) {
+                       struct lod_tgt_descs    *ltd = &lod->lod_mdt_descs;
+                       struct lod_tgt_desc     *sub_tgt = NULL;
+                       char *ptr;
+                       char *tmp;
+                       int i;
+
+                       ptr = strstr(param, ".");
+                       *ptr = '\0';
+                       obd = class_name2obd(param);
+                       if (obd == NULL) {
+                               CERROR("%s: can not find %s: rc = %d\n",
+                                      lod2obd(lod)->obd_name, param, -EINVAL);
+                               *ptr = '.';
+                               GOTO(out, rc);
+                       }
+
+                       cfs_foreach_bit(ltd->ltd_tgt_bitmap, i) {
+                               struct lod_tgt_desc *tgt;
+
+                               tgt = LTD_TGT(ltd, i);
+                               if (tgt->ltd_tgt->dd_lu_dev.ld_obd == obd) {
+                                       sub_tgt = tgt;
+                                       break;
+                               }
+                       }
+
+                       if (sub_tgt == NULL) {
+                               CERROR("%s: can not find %s: rc = %d\n",
+                                      lod2obd(lod)->obd_name, param, -EINVAL);
+                               *ptr = '.';
+                               GOTO(out, rc);
+                       }
+
+                       *ptr = '.';
+                       tmp = strstr(param, "=");
+                       tmp++;
+                       if (*tmp == '1') {
+                               struct llog_ctxt *ctxt;
 
-               rc = class_process_proc_param(PARAM_LOV, obd->obd_vars,
+                               obd = sub_tgt->ltd_tgt->dd_lu_dev.ld_obd;
+                               ctxt = llog_get_context(obd,
+                                               LLOG_UPDATELOG_ORIG_CTXT);
+                               if (ctxt == NULL) {
+                                       rc = llog_setup(env, obd, &obd->obd_olg,
+                                                      LLOG_UPDATELOG_ORIG_CTXT,
+                                                   NULL, &llog_common_cat_ops);
+                                       if (rc < 0)
+                                               GOTO(out, rc);
+                               } else {
+                                       llog_ctxt_put(ctxt);
+                               }
+                               rc = lod_sub_prep_llog(env, lod,
+                                                      sub_tgt->ltd_tgt,
+                                                      sub_tgt->ltd_index);
+                               if (rc == 0)
+                                       sub_tgt->ltd_active = 1;
+                       } else {
+                               lod_sub_fini_llog(env, sub_tgt->ltd_tgt,
+                                                 NULL);
+                               sub_tgt->ltd_active = 0;
+                       }
+                       GOTO(out, rc);
+               }
+
+
+               obd = lod2obd(lod);
+               if (strstr(param, PARAM_LOD) != NULL)
+                       rc = class_process_proc_param(PARAM_LOD, obd->obd_vars,
+                                             lcfg, obd);
+               else
+                       rc = class_process_proc_param(PARAM_LOV, obd->obd_vars,
                                              lcfg, obd);
                if (rc > 0)
                        rc = 0;
+
                GOTO(out, rc);
        }
        case LCFG_PRE_CLEANUP: {
@@ -843,11 +1053,17 @@ static int lod_process_config(const struct lu_env *env,
                        CDEBUG(D_HA, "%s: can't process %u: %d\n",
                               lod2obd(lod)->obd_name, lcfg->lcfg_command, rc);
 
+               lod_sub_stop_recovery_threads(env, lod);
                lod_fini_distribute_txn(env, lod);
                lod_sub_fini_all_llogs(env, lod);
                break;
        }
        case LCFG_CLEANUP: {
+               if (lod->lod_md_root != NULL) {
+                       dt_object_put(env, &lod->lod_md_root->ldo_obj);
+                       lod->lod_md_root = NULL;
+               }
+
                /*
                 * do cleanup on underlying storage only when
                 * all OSPs are cleaned up, as they use that OSD as well
@@ -1001,7 +1217,7 @@ static int lod_prepare(const struct lu_env *env, struct lu_device *pdev,
        if (IS_ERR(dto))
                GOTO(out_put, rc = PTR_ERR(dto));
 
-       lu_object_put(env, &dto->do_lu);
+       dt_object_put(env, dto);
 
        /* Create update log dir */
        lu_update_log_dir_fid(fid, index);
@@ -1012,7 +1228,7 @@ static int lod_prepare(const struct lu_env *env, struct lu_device *pdev,
        if (IS_ERR(dto))
                GOTO(out_put, rc = PTR_ERR(dto));
 
-       lu_object_put(env, &dto->do_lu);
+       dt_object_put(env, dto);
 
        rc = lod_prepare_distribute_txn(env, lod);
        if (rc != 0)
@@ -1023,7 +1239,7 @@ static int lod_prepare(const struct lu_env *env, struct lu_device *pdev,
                GOTO(out_put, rc);
 
 out_put:
-       lu_object_put(env, &root->do_lu);
+       dt_object_put(env, root);
 
        RETURN(rc);
 }
@@ -1101,6 +1317,42 @@ static int lod_trans_cb_add(struct thandle *th,
 }
 
 /**
+ * add noop update to the update records
+ *
+ * Add noop updates to the update records, which is only used in
+ * test right now.
+ *
+ * \param[in] env      execution environment
+ * \param[in] dt       dt device of lod
+ * \param[in] th       thandle
+ * \param[in] count    the count of update records to be added.
+ *
+ * \retval             0 if adding succeeds.
+ * \retval             negative errno if adding fails.
+ */
+static int lod_add_noop_records(const struct lu_env *env,
+                               struct dt_device *dt, struct thandle *th,
+                               int count)
+{
+       struct top_thandle *top_th;
+       struct lu_fid *fid = &lod_env_info(env)->lti_fid;
+       int i;
+       int rc = 0;
+
+       top_th = container_of(th, struct top_thandle, tt_super);
+       if (top_th->tt_multiple_thandle == NULL)
+               return 0;
+
+       fid_zero(fid);
+       for (i = 0; i < count; i++) {
+               rc = update_record_pack(noop, th, fid);
+               if (rc < 0)
+                       return rc;
+       }
+       return rc;
+}
+
+/**
  * Implementation of dt_device_operations::dt_trans_stop() for LOD
  *
  * Stops the set of local transactions using the targets involved
@@ -1111,6 +1363,13 @@ static int lod_trans_cb_add(struct thandle *th,
 static int lod_trans_stop(const struct lu_env *env, struct dt_device *dt,
                          struct thandle *th)
 {
+       if (OBD_FAIL_CHECK(OBD_FAIL_SPLIT_UPDATE_REC)) {
+               int rc;
+
+               rc = lod_add_noop_records(env, dt, th, 5000);
+               if (rc < 0)
+                       RETURN(rc);
+       }
        return top_trans_stop(env, dt2lod_dev(dt)->lod_child, th);
 }
 
@@ -1140,6 +1399,7 @@ static int lod_sync(const struct lu_env *env, struct dt_device *dev)
 {
        struct lod_device   *lod = dt2lod_dev(dev);
        struct lod_ost_desc *ost;
+       struct lod_mdt_desc *mdt;
        unsigned int         i;
        int                  rc = 0;
        ENTRY;
@@ -1150,12 +1410,29 @@ static int lod_sync(const struct lu_env *env, struct dt_device *dev)
                LASSERT(ost && ost->ltd_ost);
                rc = dt_sync(env, ost->ltd_ost);
                if (rc) {
-                       CERROR("%s: can't sync %u: %d\n",
+                       CERROR("%s: can't sync ost %u: %d\n",
                               lod2obd(lod)->obd_name, i, rc);
                        break;
                }
        }
        lod_putref(lod, &lod->lod_ost_descs);
+
+       if (rc)
+               RETURN(rc);
+
+       lod_getref(&lod->lod_mdt_descs);
+       lod_foreach_mdt(lod, i) {
+               mdt = MDT_TGT(lod, i);
+               LASSERT(mdt && mdt->ltd_mdt);
+               rc = dt_sync(env, mdt->ltd_mdt);
+               if (rc) {
+                       CERROR("%s: can't sync mdt %u: %d\n",
+                              lod2obd(lod)->obd_name, i, rc);
+                       break;
+               }
+       }
+       lod_putref(lod, &lod->lod_mdt_descs);
+
        if (rc == 0)
                rc = dt_sync(env, lod->lod_child);
 
@@ -1238,7 +1515,7 @@ static int lod_connect_to_osd(const struct lu_env *env, struct lod_device *lod,
         * we use "-MDT" to differentiate 2.x from 1.8 */
 
        if ((p = lustre_cfg_string(cfg, 0)) && strstr(p, "-mdtlov")) {
-               len = strlen(p) + 1;
+               len = strlen(p) + 6;
                OBD_ALLOC(nextdev, len);
                if (nextdev == NULL)
                        GOTO(out, rc = -ENOMEM);
@@ -1368,6 +1645,7 @@ static int lod_init0(const struct lu_env *env, struct lod_device *lod,
 
        dt_conf_get(env, &lod->lod_dt_dev, &ddp);
        lod->lod_osd_max_easize = ddp.ddp_max_ea_size;
+       lod->lod_dom_max_stripesize = (1ULL << 20); /* 1Mb as default value */
 
        /* setup obd to be used with old lov code */
        rc = lod_pools_init(lod, cfg);
@@ -1378,7 +1656,7 @@ static int lod_init0(const struct lu_env *env, struct lod_device *lod,
        if (rc)
                GOTO(out_pools, rc);
 
-       spin_lock_init(&lod->lod_desc_lock);
+       spin_lock_init(&lod->lod_lock);
        spin_lock_init(&lod->lod_connects_lock);
        lod_tgt_desc_init(&lod->lod_mdt_descs);
        lod_tgt_desc_init(&lod->lod_ost_descs);
@@ -1406,6 +1684,11 @@ static struct lu_device *lod_device_free(const struct lu_env *env,
        struct lu_device  *next = &lod->lod_child->dd_lu_dev;
        ENTRY;
 
+       if (atomic_read(&lu->ld_ref) > 0 &&
+           !cfs_hash_is_empty(lu->ld_site->ls_obj_hash)) {
+               LIBCFS_DEBUG_MSG_DATA_DECL(msgdata, D_ERROR, NULL);
+               lu_site_print(env, lu->ld_site, &msgdata, lu_cdebug_printer);
+       }
        LASSERTF(atomic_read(&lu->ld_ref) == 0, "lu is %p\n", lu);
        dt_device_fini(&lod->lod_dt_dev);
        OBD_FREE_PTR(lod);
@@ -1566,6 +1849,10 @@ static void lod_key_fini(const struct lu_context *ctx,
                struct lu_context_key *key, void *data)
 {
        struct lod_thread_info *info = data;
+       struct lod_layout_component *lds =
+                               info->lti_def_striping.lds_def_comp_entries;
+       struct ost_pool *inuse = &info->lti_inuse_osts;
+
        /* allocated in lod_get_lov_ea
         * XXX: this is overload, a tread may have such store but used only
         * once. Probably better would be pool of such stores per LOD.
@@ -1576,6 +1863,17 @@ static void lod_key_fini(const struct lu_context *ctx,
                info->lti_ea_store_size = 0;
        }
        lu_buf_free(&info->lti_linkea_buf);
+
+       if (lds != NULL)
+               lod_free_def_comp_entries(&info->lti_def_striping);
+
+       if (inuse->op_size)
+               OBD_FREE(inuse->op_array, inuse->op_size);
+
+       if (info->lti_comp_size > 0)
+               OBD_FREE(info->lti_comp_idx,
+                        info->lti_comp_size * sizeof(__u32));
+
        OBD_FREE_PTR(info);
 }
 
@@ -1659,13 +1957,22 @@ static int lod_obd_get_info(const struct lu_env *env, struct obd_export *exp,
                        tgt = MDT_TGT(d, i);
                        LASSERT(tgt != NULL);
                        LASSERT(tgt->ltd_tgt != NULL);
+                       if (!tgt->ltd_active)
+                               continue;
+
                        ctxt = llog_get_context(tgt->ltd_tgt->dd_lu_dev.ld_obd,
                                                LLOG_UPDATELOG_ORIG_CTXT);
                        if (ctxt == NULL) {
+                               CDEBUG(D_INFO, "%s: %s is not ready.\n",
+                                      obd->obd_name,
+                                     tgt->ltd_tgt->dd_lu_dev.ld_obd->obd_name);
                                rc = -EAGAIN;
                                break;
                        }
                        if (ctxt->loc_handle == NULL) {
+                               CDEBUG(D_INFO, "%s: %s is not ready.\n",
+                                      obd->obd_name,
+                                     tgt->ltd_tgt->dd_lu_dev.ld_obd->obd_name);
                                rc = -EAGAIN;
                                llog_ctxt_put(ctxt);
                                break;
@@ -1680,18 +1987,77 @@ static int lod_obd_get_info(const struct lu_env *env, struct obd_export *exp,
        RETURN(rc);
 }
 
+static int lod_obd_set_info_async(const struct lu_env *env,
+                                 struct obd_export *exp,
+                                 __u32 keylen, void *key,
+                                 __u32 vallen, void *val,
+                                 struct ptlrpc_request_set *set)
+{
+       struct obd_device *obd = class_exp2obd(exp);
+       struct lod_device *d;
+       struct lod_tgt_desc *tgt;
+       int no_set = 0;
+       int i, rc = 0, rc2;
+       ENTRY;
+
+       if (set == NULL) {
+               no_set = 1;
+               set = ptlrpc_prep_set();
+               if (!set)
+                       RETURN(-ENOMEM);
+       }
+
+       d = lu2lod_dev(obd->obd_lu_dev);
+       lod_getref(&d->lod_ost_descs);
+       lod_foreach_ost(d, i) {
+               tgt = OST_TGT(d, i);
+               LASSERT(tgt && tgt->ltd_tgt);
+               if (!tgt->ltd_active)
+                       continue;
+
+               rc2 = obd_set_info_async(env, tgt->ltd_exp, keylen, key,
+                                        vallen, val, set);
+               if (rc2 != 0 && rc == 0)
+                       rc = rc2;
+       }
+       lod_putref(d, &d->lod_ost_descs);
+
+       lod_getref(&d->lod_mdt_descs);
+       lod_foreach_mdt(d, i) {
+               tgt = MDT_TGT(d, i);
+               LASSERT(tgt && tgt->ltd_tgt);
+               if (!tgt->ltd_active)
+                       continue;
+               rc2 = obd_set_info_async(env, tgt->ltd_exp, keylen, key,
+                                        vallen, val, set);
+               if (rc2 != 0 && rc == 0)
+                       rc = rc2;
+       }
+       lod_putref(d, &d->lod_mdt_descs);
+
+
+       if (no_set) {
+               rc2 = ptlrpc_set_wait(set);
+               if (rc2 == 0 && rc == 0)
+                       rc = rc2;
+               ptlrpc_set_destroy(set);
+       }
+       RETURN(rc);
+}
+
 static struct obd_ops lod_obd_device_ops = {
        .o_owner        = THIS_MODULE,
        .o_connect      = lod_obd_connect,
        .o_disconnect   = lod_obd_disconnect,
        .o_get_info     = lod_obd_get_info,
+       .o_set_info_async = lod_obd_set_info_async,
        .o_pool_new     = lod_pool_new,
        .o_pool_rem     = lod_pool_remove,
        .o_pool_add     = lod_pool_add,
        .o_pool_del     = lod_pool_del,
 };
 
-static int __init lod_mod_init(void)
+static int __init lod_init(void)
 {
        struct obd_type *type;
        int rc;
@@ -1723,16 +2089,16 @@ static int __init lod_mod_init(void)
        return rc;
 }
 
-static void __exit lod_mod_exit(void)
+static void __exit lod_exit(void)
 {
        class_unregister_type(LUSTRE_LOD_NAME);
        lu_kmem_fini(lod_caches);
 }
 
-MODULE_AUTHOR("Intel Corporation. <https://wiki.hpdd.intel.com/>");
+MODULE_AUTHOR("OpenSFS, Inc. <http://www.lustre.org/>");
 MODULE_DESCRIPTION("Lustre Logical Object Device ("LUSTRE_LOD_NAME")");
+MODULE_VERSION(LUSTRE_VERSION_STRING);
 MODULE_LICENSE("GPL");
 
-module_init(lod_mod_init);
-module_exit(lod_mod_exit);
-
+module_init(lod_init);
+module_exit(lod_exit);