- /* fill the update into the update buffer */
- fid_cpu_to_le(&obj_update->u_fid, fid);
- obj_update->u_type = cpu_to_le32(op);
- obj_update->u_batchid = update->ur_batchid;
- for (i = 0; i < count; i++)
- obj_update->u_lens[i] = cpu_to_le32(lens[i]);
+ OBD_FREE_LARGE(dt_update->dur_req, dt_update->dur_req_len);
+
+ dt_update->dur_req = ureq;
+ dt_update->dur_req_len = new_size;
+
+ return 0;
+}
+
+#define OUT_UPDATE_BUFFER_SIZE_ADD 4096
+#define OUT_UPDATE_BUFFER_SIZE_MAX (64 * 4096) /* 64KB update size now */
+/**
+ * Insert the update into the th_bufs for the device.
+ */
+
+int out_insert_update(const struct lu_env *env,
+ struct dt_update_request *update, int op,
+ const struct lu_fid *fid, int params_count, int *lens,
+ const char **bufs)
+{
+ struct object_update_request *ureq = update->dur_req;
+ int ureq_len;
+ struct object_update *obj_update;
+ struct object_update_param *param;
+ int update_length;
+ int rc = 0;
+ char *ptr;
+ int i;
+ ENTRY;
+
+ /* Check update size to make sure it can fit into the buffer */
+ ureq_len = object_update_request_size(ureq);
+ update_length = offsetof(struct object_update, ou_params[0]);
+ for (i = 0; i < params_count; i++)
+ update_length += cfs_size_round(lens[i] + sizeof(*param));
+
+ if (unlikely(cfs_size_round(ureq_len + update_length) >
+ update->dur_req_len)) {
+ int new_size = update->dur_req_len;
+
+ /* enlarge object update request size */
+ while (new_size <
+ cfs_size_round(ureq_len + update_length))
+ new_size += OUT_UPDATE_BUFFER_SIZE_ADD;
+ if (new_size >= OUT_UPDATE_BUFFER_SIZE_MAX)
+ RETURN(-E2BIG);
+
+ rc = out_resize_update_req(update, new_size);
+ if (rc != 0)
+ RETURN(rc);
+
+ ureq = update->dur_req;
+ }