+ /*
+ * Catalog processing stops when it processed last catalog record
+ * with index equal to the end of catalog bitmap. Or if it is wrapped,
+ * processing stops with index equal to the lgh_last_idx. We need to
+ * continue processing.
+ */
+ d->opd_sync_last_catalog_idx = 0;
+ do {
+ int size;
+
+ wrapped = (llh->lgh_hdr->llh_cat_idx >= llh->lgh_last_idx &&
+ llh->lgh_hdr->llh_count > 1);
+
+ if (OBD_FAIL_CHECK(OBD_FAIL_OSP_CANT_PROCESS_LLOG)) {
+ rc = -EINPROGRESS;
+ goto next;
+ }
+ rc = llog_cat_process(&env, llh, osp_sync_process_queues, d,
+ d->opd_sync_last_catalog_idx, 0);
+
+next:
+ size = OBD_FAIL_PRECHECK(OBD_FAIL_CAT_RECORDS) ?
+ cfs_fail_val : (LLOG_HDR_BITMAP_SIZE(llh->lgh_hdr) - 1);
+ /* processing reaches catalog bottom */
+ if (d->opd_sync_last_catalog_idx == size)
+ d->opd_sync_last_catalog_idx = LLOG_CAT_FIRST;
+ /* If catalog is wrapped we can`t predict last index of
+ * processing because lgh_last_idx could be changed.
+ * Starting form the next one. Index would be increased
+ * at llog_process_thread
+ */
+ } while (rc == 0 && (wrapped ||
+ d->opd_sync_last_catalog_idx == LLOG_CAT_FIRST));
+
+ if (rc < 0) {
+ if (rc == -EINPROGRESS) {
+ /* can't access the llog now - OI scrub is trying to fix
+ * underlying issue. let's wait and try again */
+ llog_cat_close(&env, llh);
+ rc = llog_cleanup(&env, ctxt);
+ if (rc)
+ GOTO(out, rc);
+ schedule_timeout_interruptible(cfs_time_seconds(5));
+ goto again;
+ }
+
+ CERROR("%s: llog process with osp_sync_process_queues "
+ "failed: %d\n", d->opd_obd->obd_name, rc);
+ GOTO(close, rc);
+ }