Whamcloud - gitweb
LU-8990 lod: put root at cleanup
[fs/lustre-release.git] / lustre / lod / lod_dev.c
index bb1a90c..0c2ddcb 100644 (file)
@@ -23,7 +23,7 @@
  * Copyright  2009 Sun Microsystems, Inc. All rights reserved
  * Use is subject to license terms.
  *
- * Copyright (c) 2012, 2016, 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>
 
@@ -316,9 +316,9 @@ 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 :"
+               CERROR("%s broken update record! index %u "DFID".%u :"
                       " rc = %d\n", lod2obd(lrd->lrd_lod)->obd_name, index,
-                      POSTID(&llh->lgh_id.lgl_oi), rec->lrh_index, -EIO);
+                      PFID(&llh->lgh_id.lgl_oi.oi_fid), rec->lrh_index, -EIO);
                return -EINVAL;
        }
 
@@ -326,9 +326,9 @@ static int lod_process_recovery_updates(const struct lu_env *env,
        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 ||
@@ -353,16 +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 = NULL;
-       struct lu_env                   env;
+       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;
-
-
-       int                             rc;
+       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;
@@ -383,6 +386,8 @@ static int lod_sub_recovery_thread(void *arg)
        else
                dt = lrd->lrd_ltd->ltd_tgt;
 
+       start = ktime_get_real_seconds();
+
 again:
        rc = lod_sub_prep_llog(&env, lod, dt, lrd->lrd_idx);
        if (!rc && !lod->lod_child->dd_rdonly) {
@@ -412,10 +417,13 @@ again:
                                                       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 getting update log failed: rc = %d\n",
+               CERROR("%s get update log failed: rc = %d\n",
                       dt->dd_lu_dev.ld_obd->obd_name, rc);
                llog_ctxt_put(ctxt);
 
@@ -429,35 +437,35 @@ again:
        }
        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 (!lod->lod_child_got_update_log) {
+               spin_unlock(&lod->lod_lock);
+               GOTO(out, rc = 0);
+       }
 
-               if (all_got_log) {
-                       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);
@@ -466,7 +474,7 @@ out:
        wake_up(&lut->lut_tdtd->tdtd_recovery_threads_waitq);
        wake_up(&thread->t_ctl_waitq);
        lu_env_fini(&env);
-       RETURN(rc);
+       return rc;
 }
 
 /**
@@ -1023,19 +1031,20 @@ static int lod_process_config(const struct lu_env *env,
                        GOTO(out, rc);
                }
 
+
                obd = lod2obd(lod);
-               rc = class_process_proc_param(PARAM_LOV, obd->obd_vars,
+               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: {
-               if (lod->lod_md_root != NULL) {
-                       lu_object_put(env, &lod->lod_md_root->ldo_obj.do_lu);
-                       lod->lod_md_root = NULL;
-               }
-
                lod_sub_process_config(env, lod, &lod->lod_mdt_descs, lcfg);
                lod_sub_process_config(env, lod, &lod->lod_ost_descs, lcfg);
                next = &lod->lod_child->dd_lu_dev;
@@ -1050,6 +1059,11 @@ static int lod_process_config(const struct lu_env *env,
                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
@@ -1203,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);
@@ -1214,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)
@@ -1225,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);
 }
@@ -1631,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);
@@ -1669,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);
@@ -1829,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.
@@ -1839,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);
 }