- struct obd_uuid *uuid;
- struct llog_handle *orig_llh, *bak_llh;
- struct llog_ctxt *lctxt;
- int rc, rc2;
- ENTRY;
-
- lctxt = llog_get_context(mgs, LLOG_CONFIG_ORIG_CTXT);
- if (!lctxt) {
- CERROR("%s: missing llog context\n", mgs->obd_name);
- GOTO(out, rc = -EINVAL);
- }
-
- /* Make sure there's no old backup log */
- rc = llog_erase(env, lctxt, NULL, backup);
- if (rc < 0 && rc != -ENOENT)
- GOTO(out_put, rc);
-
- /* open backup log */
- rc = llog_open_create(env, lctxt, &bak_llh, NULL, backup);
- if (rc) {
- CERROR("%s: backup logfile open %s: rc = %d\n",
- mgs->obd_name, backup, rc);
- GOTO(out_put, rc);
- }
-
- /* set the log header uuid */
- OBD_ALLOC_PTR(uuid);
- if (uuid == NULL)
- GOTO(out_put, rc = -ENOMEM);
- obd_str2uuid(uuid, backup);
- rc = llog_init_handle(env, bak_llh, LLOG_F_IS_PLAIN, uuid);
- OBD_FREE_PTR(uuid);
- if (rc)
- GOTO(out_close1, rc);
-
- /* open original log */
- rc = llog_open(env, lctxt, &orig_llh, NULL, fsname,
- LLOG_OPEN_EXISTS);
- if (rc < 0) {
- if (rc == -ENOENT)
- rc = 0;
- GOTO(out_close1, rc);
- }
-
- rc = llog_init_handle(env, orig_llh, LLOG_F_IS_PLAIN, NULL);
- if (rc)
- GOTO(out_close2, rc);