- CDEBUG(D_OTHER, "after swabbing, type=%#x idx=%d\n",
- rec->lrh_type, rec->lrh_index);
-
- if (rec->lrh_index == 0) {
- /* probably another rec just got added? */
- if (index <= loghandle->lgh_last_idx)
- GOTO(repeat, rc = 0);
- GOTO(out, rc = 0); /* no more records */
+ CDEBUG(D_OTHER, "after swabbing, type=%#x idx=%d\n",
+ rec->lrh_type, rec->lrh_index);
+
+ /* for partial chunk the end of it is zeroed, check
+ * for index 0 to distinguish it. */
+ if (partial_chunk && rec->lrh_index == 0) {
+ /* concurrent llog_add() might add new records
+ * while llog_processing, check this is not
+ * the case and re-read the current chunk
+ * otherwise. */
+ if (index > loghandle->lgh_last_idx)
+ 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;
+ goto repeat;