+ repeated = false;
+
+ if (rec->lrh_len == 0 || rec->lrh_len > chunk_size) {
+ CWARN("%s: invalid length %d in llog "DFID
+ "record for index %d/%d\n",
+ loghandle->lgh_ctxt->loc_obd->obd_name,
+ rec->lrh_len,
+ PFID(&loghandle->lgh_id.lgl_oi.oi_fid),
+ rec->lrh_index, index);
+
+ GOTO(out, rc = -EINVAL);
+ }
+
+ if (rec->lrh_index < index) {
+ CDEBUG(D_OTHER, "skipping lrh_index %d\n",
+ rec->lrh_index);
+ continue;
+ }
+
+ if (rec->lrh_index != index) {
+ CERROR("%s: "DFID" Invalid record: index %u"
+ " but expected %u\n",
+ loghandle->lgh_ctxt->loc_obd->obd_name,
+ PFID(&loghandle->lgh_id.lgl_oi.oi_fid),
+ rec->lrh_index, index);
+ GOTO(out, rc = -ERANGE);
+ }
+
+ CDEBUG(D_OTHER,
+ "lrh_index: %d lrh_len: %d (%d remains)\n",
+ rec->lrh_index, rec->lrh_len,
+ (int)(buf + chunk_size - (char *)rec));
+
+ /* lgh_cur_offset is used only at llog_test_3 */
+ loghandle->lgh_cur_offset = (char *)rec - (char *)buf +
+ chunk_offset;
+
+ /* if set, process the callback on this record */
+ if (ext2_test_bit(index, LLOG_HDR_BITMAP(llh))) {
+ struct llog_cookie *lgc;
+ __u64 tmp_off;
+ int tmp_idx;
+
+ CDEBUG(D_OTHER, "index: %d, lh_last_idx: %d "
+ "synced_idx: %d lgh_last_idx: %d\n",
+ index, lh_last_idx, synced_idx,
+ loghandle->lgh_last_idx);
+
+ if (lti != NULL) {
+ lgc = <i->lgi_cookie;
+ /* store lu_env for recursive calls */
+ tmp_off = lgc->lgc_offset;
+ tmp_idx = lgc->lgc_index;
+
+ lgc->lgc_offset = (char *)rec -
+ (char *)buf + chunk_offset;
+ lgc->lgc_index = rec->lrh_index;
+ }
+ /* using lu_env for passing record offset to
+ * llog_write through various callbacks */