+ CDEBUG(D_OTHER, "after swabbing, type=%#x idx=%d\n",
+ rec->lrh_type, rec->lrh_index);
+
+ /* the bitmap could be changed during processing
+ * records from the chunk. For wrapped catalog
+ * it means we can read deleted record and try to
+ * process it. Check this case and reread the chunk. */
+
+ /* for partial chunk the end of it is zeroed, check
+ * for index 0 to distinguish it. */
+ if ((partial_chunk && rec->lrh_index == 0) ||
+ (index == lh_last_idx &&
+ lh_last_idx != (loghandle->lgh_last_idx + 1))) {
+ /* concurrent llog_add() might add new records
+ * while llog_processing, check this is not
+ * the case and re-read the current chunk
+ * otherwise. */
+ int records;
+ /* lgh_last_idx could be less then index
+ * for catalog, if catalog is wrapped */
+ if ((index > loghandle->lgh_last_idx &&
+ !(loghandle->lgh_hdr->llh_flags &
+ LLOG_F_IS_CAT)) || repeated ||
+ (loghandle->lgh_obj != NULL &&
+ dt_object_remote(loghandle->lgh_obj)))
+ GOTO(out, rc = 0);
+ /* <2 records means no more records
+ * if the last record we processed was
+ * the final one, then the underlying
+ * object might have been destroyed yet.
+ * we better don't access that.. */
+ mutex_lock(&loghandle->lgh_hdr_mutex);
+ records = loghandle->lgh_hdr->llh_count;
+ mutex_unlock(&loghandle->lgh_hdr_mutex);
+ if (records <= 1)
+ GOTO(out, rc = 0);
+ CDEBUG(D_OTHER, "Re-read last llog buffer for "
+ "new records, index %u, last %u\n",
+ index, loghandle->lgh_last_idx);
+ /* save offset inside buffer for the re-read */
+ buf_offset = (char *)rec - (char *)buf;
+ cur_offset = chunk_offset;
+ repeated = true;
+ goto repeat;
+ }