+struct llog_process_info {
+ struct llog_handle *lpi_loghandle;
+ llog_cb_t lpi_cb;
+ void *lpi_cbdata;
+ void *lpi_catdata;
+ int lpi_rc;
+ struct completion lpi_completion;
+ const struct lu_env *lpi_env;
+ struct task_struct *lpi_reftask;
+};
+
+
+static int llog_test_process_thread(void *arg)
+{
+ struct llog_process_info *lpi = arg;
+ int rc;
+
+ rc = llog_cat_process_or_fork(NULL, lpi->lpi_loghandle, lpi->lpi_cb,
+ NULL, lpi->lpi_cbdata, 1, 0, true);
+
+ complete(&lpi->lpi_completion);
+
+ lpi->lpi_rc = rc;
+ if (rc)
+ CWARN("10h: Error during catalog processing %d\n", rc);
+ return rc;
+}
+
+static int cat_check_old_cb(const struct lu_env *env, struct llog_handle *llh,
+ struct llog_rec_hdr *rec, void *data)
+{
+ struct llog_logid_rec *lir = (struct llog_logid_rec *)rec;
+ struct lu_fid fid = {0};
+ struct lu_fid *prev_fid = data;
+
+ if (rec->lrh_type != LLOG_LOGID_MAGIC) {
+ CERROR("invalid record in catalog\n");
+ RETURN(-EINVAL);
+ }
+
+ logid_to_fid(&lir->lid_id, &fid);
+
+ CWARN("seeing record at index %d - "DFID" in log "DFID"\n",
+ rec->lrh_index, PFID(&fid),
+ PFID(lu_object_fid(&llh->lgh_obj->do_lu)));
+
+ if (prev_fid->f_oid > fid.f_oid) {
+ CWARN("processing old record, fail\n");
+ prev_fid->f_oid = 0xbad;
+ RETURN(-LLOG_EEMPTY);
+ }
+
+ if (prev_fid->f_oid == 0) {
+ cfs_fail_loc = OBD_FAIL_ONCE | OBD_FAIL_LLOG_PROCESS_TIMEOUT;
+ cfs_fail_val = (unsigned int) (llh->lgh_id.lgl_oi.oi.oi_id &
+ 0xFFFFFFFF);
+ msleep(1 * MSEC_PER_SEC);
+ }
+ *prev_fid = fid;
+
+ RETURN(0);
+}
+