+ /*
+ * If its size > llog chunk_size, then write current chunk to the update
+ * llog, NB the padding should >= LLOG_MIN_REC_SIZE.
+ *
+ * So check padding length is either >= LLOG_MIN_REC_SIZE or is 0
+ * (record length just matches the chunk size).
+ */
+
+ reclen = record->lur_hdr.lrh_len;
+ if (reclen + LLOG_MIN_REC_SIZE <= ctxt->loc_chunk_size ||
+ reclen == ctxt->loc_chunk_size) {
+ OBD_ALLOC_PTR(stc);
+ if (stc == NULL)
+ GOTO(llog_put, rc = -ENOMEM);
+ INIT_LIST_HEAD(&stc->stc_list);
+
+ rc = llog_add(env, ctxt->loc_handle, &record->lur_hdr,
+ &stc->stc_cookie, sub_th->st_sub_th);
+
+ CDEBUG(D_INFO, "%s: Add update log "DFID".%u: rc = %d\n",
+ dt->dd_lu_dev.ld_obd->obd_name,
+ PFID(&stc->stc_cookie.lgc_lgl.lgl_oi.oi_fid),
+ stc->stc_cookie.lgc_index, rc);
+
+ if (rc > 0) {
+ list_add(&stc->stc_list, &sub_th->st_cookie_list);
+ rc = 0;
+ } else {
+ OBD_FREE_PTR(stc);
+ }
+
+ GOTO(llog_put, rc);
+ }
+
+ /* Split the records into chunk_size update record */
+ OBD_ALLOC_LARGE(lur, ctxt->loc_chunk_size);
+ if (lur == NULL)
+ GOTO(llog_put, rc = -ENOMEM);
+
+ memcpy(lur, &record->lur_hdr, sizeof(record->lur_hdr));
+ lur->lur_update_rec.ur_update_count = 0;
+ lur->lur_update_rec.ur_param_count = 0;
+ start = (char *)&record->lur_update_rec.ur_ops;
+ cur = next = start;
+ do {
+ if (update_count < record->lur_update_rec.ur_update_count)
+ next = (char *)update_op_next_op(
+ (struct update_op *)cur);
+ else if (param_count < record->lur_update_rec.ur_param_count)
+ next = (char *)update_param_next_param(
+ (struct update_param *)cur);
+ else
+ eof = true;
+
+ reclen = __llog_update_record_size(
+ __update_records_size(next - start));
+ if ((reclen + LLOG_MIN_REC_SIZE <= ctxt->loc_chunk_size ||
+ reclen == ctxt->loc_chunk_size) &&
+ !eof) {
+ cur = next;
+
+ if (update_count <
+ record->lur_update_rec.ur_update_count)
+ update_count++;
+ else if (param_count <
+ record->lur_update_rec.ur_param_count)
+ param_count++;
+ continue;
+ }