-#ifdef HAVE_LDISKFS_OSD
- /*
- * XXX: at the moment mgc_copy_llog() works with lvfs-based llogs
- */
- /* Copy the setup log locally if we can. Don't mess around if we're
- running an MGS though (logs are already local). */
- if (lctxt && lsi && IS_SERVER(lsi) &&
- (lsi->lsi_srv_mnt == cli->cl_mgc_vfsmnt) &&
- !IS_MGS(lsi) && lsi->lsi_srv_mnt) {
- push_ctxt(saved_ctxt, &mgc->obd_lvfs_ctxt, NULL);
- must_pop++;
- if (!local_only)
- /* Only try to copy log if we have the lock. */
- rc = mgc_copy_llog(mgc, ctxt, lctxt, cld->cld_logname);
- if (local_only || rc) {
- if (mgc_llog_is_empty(mgc, lctxt, cld->cld_logname)) {
- LCONSOLE_ERROR_MSG(0x13a, "Failed to get MGS "
- "log %s and no local copy."
- "\n", cld->cld_logname);
- GOTO(out_pop, rc = -ENOTCONN);
- }
- CDEBUG(D_MGC, "Failed to get MGS log %s, using local "
- "copy for now, will try to update later.\n",
- cld->cld_logname);
- }
- /* Now, whether we copied or not, start using the local llog.
- If we failed to copy, we'll start using whatever the old
- log has. */
- llog_ctxt_put(ctxt);
- ctxt = lctxt;
- lctxt = NULL;
- } else
-#endif
- if (local_only) { /* no local log at client side */
- GOTO(out_pop, rc = -EIO);
- }
+ rc = lu_env_init(env, LCT_MG_THREAD);
+ if (rc)
+ GOTO(out_free, rc);
+
+ ctxt = llog_get_context(mgc, LLOG_CONFIG_REPL_CTXT);
+ LASSERT(ctxt);
+
+ lctxt = llog_get_context(mgc, LLOG_CONFIG_ORIG_CTXT);
+
+ /* Copy the setup log locally if we can. Don't mess around if we're
+ * running an MGS though (logs are already local). */
+ if (lctxt && lsi && IS_SERVER(lsi) && !IS_MGS(lsi) &&
+ cli->cl_mgc_configs_dir != NULL &&
+ lu2dt_dev(cli->cl_mgc_configs_dir->do_lu.lo_dev) ==
+ lsi->lsi_dt_dev) {
+ if (!local_only)
+ /* Only try to copy log if we have the lock. */
+ rc = mgc_llog_local_copy(env, mgc, ctxt, lctxt,
+ cld->cld_logname);
+ if (local_only || rc) {
+ if (llog_is_empty(env, lctxt, cld->cld_logname)) {
+ LCONSOLE_ERROR_MSG(0x13a, "Failed to get MGS "
+ "log %s and no local copy."
+ "\n", cld->cld_logname);
+ GOTO(out_pop, rc = -ENOTCONN);
+ }
+ CDEBUG(D_MGC, "Failed to get MGS log %s, using local "
+ "copy for now, will try to update later.\n",
+ cld->cld_logname);
+ }
+ /* Now, whether we copied or not, start using the local llog.
+ * If we failed to copy, we'll start using whatever the old
+ * log has. */
+ llog_ctxt_put(ctxt);
+ ctxt = lctxt;
+ lctxt = NULL;
+ } else {
+ if (local_only) /* no local log at client side */
+ GOTO(out_pop, rc = -EIO);
+ }