+int llog_cat_cancel_arr_rec(const struct lu_env *env,
+ struct llog_handle *cathandle,
+ struct llog_logid *lgl, int count, int *index)
+{
+ struct llog_handle *loghandle;
+ int rc;
+
+ ENTRY;
+ rc = llog_cat_id2handle(env, cathandle, &loghandle, lgl);
+ if (rc) {
+ CDEBUG(D_HA, "%s: cannot find llog for handle "DFID":%x"
+ ": rc = %d\n",
+ cathandle->lgh_ctxt->loc_obd->obd_name,
+ PFID(&lgl->lgl_oi.oi_fid), lgl->lgl_ogen, rc);
+ RETURN(rc);
+ }
+
+ if ((cathandle->lgh_ctxt->loc_flags &
+ LLOG_CTXT_FLAG_NORMAL_FID) && !llog_exist(loghandle)) {
+ /* For update log, some of loghandles of cathandle
+ * might not exist because remote llog creation might
+ * be failed, so let's skip the record cancellation
+ * for these non-exist llogs.
+ */
+ rc = -ENOENT;
+ CDEBUG(D_HA, "%s: llog "DFID":%x does not exist"
+ ": rc = %d\n",
+ cathandle->lgh_ctxt->loc_obd->obd_name,
+ PFID(&lgl->lgl_oi.oi_fid), lgl->lgl_ogen, rc);
+
+ llog_handle_put(env, loghandle);
+ RETURN(rc);
+ }
+
+ rc = llog_cancel_arr_rec(env, loghandle, count, index);
+ if (rc == LLOG_DEL_PLAIN) { /* log has been destroyed */
+ int cat_index;
+
+ cat_index = loghandle->u.phd.phd_cookie.lgc_index;
+ rc = llog_cat_cleanup(env, cathandle, loghandle, cat_index);
+ if (rc)
+ CERROR("%s: fail to cancel catalog record: rc = %d\n",
+ cathandle->lgh_ctxt->loc_obd->obd_name, rc);
+ rc = 0;
+
+ }
+ llog_handle_put(env, loghandle);
+
+ if (rc)
+ CERROR("%s: fail to cancel %d llog-records: rc = %d\n",
+ cathandle->lgh_ctxt->loc_obd->obd_name, count,
+ rc);
+
+ RETURN(rc);
+}
+EXPORT_SYMBOL(llog_cat_cancel_arr_rec);
+