+ if (lgi->lgi_attr.la_size == 0) {
+ lgi->lgi_off = 0;
+ lgi->lgi_buf.lb_len = llh->llh_hdr.lrh_len;
+ lgi->lgi_buf.lb_buf = &llh->llh_hdr;
+ rc = dt_record_write(env, o, &lgi->lgi_buf, &lgi->lgi_off, th);
+ if (rc != 0)
+ GOTO(out, rc);
+ } else {
+ /* Note: If this is not initialization (size == 0), then do not
+ * write the whole header (8k bytes), only update header/tail
+ * and bits needs to be updated. Because this update might be
+ * part of cross-MDT operation, which needs to write these
+ * updates into the update log(32KB limit) and also pack inside
+ * the RPC (1MB limit), if we write 8K for each operation, which
+ * will cost a lot space, and keep us adding more updates to one
+ * update log.*/
+ lgi->lgi_off = offsetof(typeof(*llh), llh_count);
+ lgi->lgi_buf.lb_len = sizeof(llh->llh_count);
+ lgi->lgi_buf.lb_buf = &llh->llh_count;
+ rc = dt_record_write(env, o, &lgi->lgi_buf, &lgi->lgi_off, th);
+ if (rc != 0)
+ GOTO(out, rc);
+
+ lgi->lgi_off = offsetof(typeof(*llh),
+ llh_bitmap[index / (sizeof(*llh->llh_bitmap) * 8)]);
+ lgi->lgi_buf.lb_len = sizeof(*llh->llh_bitmap);
+ lgi->lgi_buf.lb_buf =
+ &llh->llh_bitmap[index/(sizeof(*llh->llh_bitmap)*8)];
+ rc = dt_record_write(env, o, &lgi->lgi_buf, &lgi->lgi_off, th);
+ if (rc != 0)
+ GOTO(out, rc);
+
+ lgi->lgi_off = offsetof(typeof(*llh), llh_tail);
+ lgi->lgi_buf.lb_len = sizeof(llh->llh_tail);
+ lgi->lgi_buf.lb_buf = &llh->llh_tail;
+ rc = dt_record_write(env, o, &lgi->lgi_buf, &lgi->lgi_off, th);
+ if (rc != 0)
+ GOTO(out, rc);
+ }