- rc = llog_create(ctxt, &llh, NULL, LOG_SPTLRPC_TMP);
- if (rc == 0) {
- rc = llog_init_handle(llh, LLOG_F_IS_PLAIN, NULL);
- if (rc == 0) {
- rc = llog_destroy(llh);
- llog_free_handle(llh);
- } else {
- llog_close(llh);
- }
- }
-
- if (rc) {
- CERROR("target %s: cannot erase temporary sptlrpc log: "
- "rc = %d\n", obd->obd_name, rc);
- GOTO(out_dput, rc);
- }
-
- /* write temporary log */
- rc = llog_create(ctxt, &llh, NULL, LOG_SPTLRPC_TMP);
- if (rc)
- GOTO(out_dput, rc);
- rc = llog_init_handle(llh, LLOG_F_IS_PLAIN, NULL);
+ rc = llog_erase(NULL, ctxt, NULL, LOG_SPTLRPC_TMP);
+ if (rc < 0 && rc != -ENOENT) {
+ CERROR("%s: cannot erase temporary sptlrpc log: rc = %d\n",
+ obd->obd_name, rc);
+ GOTO(out_dput, rc);
+ }
+
+ /* write temporary log */
+ rc = llog_open_create(NULL, ctxt, &llh, NULL, LOG_SPTLRPC_TMP);
+ if (rc)
+ GOTO(out_dput, rc);
+ rc = llog_init_handle(NULL, llh, LLOG_F_IS_PLAIN, NULL);