+struct object_update_param {
+ __u16 oup_len; /* length of this parameter */
+ __u16 oup_padding;
+ __u32 oup_padding2;
+ char oup_buf[0];
+};
+
+static inline size_t
+object_update_param_size(const struct object_update_param *param)
+{
+ return cfs_size_round(sizeof(*param) + param->oup_len);
+}
+
+/* object update */
+struct object_update {
+ __u16 ou_type; /* enum update_type */
+ __u16 ou_params_count; /* update parameters count */
+ __u32 ou_master_index; /* master MDT/OST index */
+ __u32 ou_flags; /* enum update_flag */
+ __u32 ou_padding1; /* padding 1 */
+ __u64 ou_batchid; /* op transno on master */
+ struct lu_fid ou_fid; /* object to be updated */
+ struct object_update_param ou_params[0]; /* update params */
+};
+
+#define UPDATE_REQUEST_MAGIC_V1 0xBDDE0001
+#define UPDATE_REQUEST_MAGIC_V2 0xBDDE0002
+#define UPDATE_REQUEST_MAGIC UPDATE_REQUEST_MAGIC_V2
+/* Hold object_updates sending to the remote OUT in single RPC */
+struct object_update_request {
+ __u32 ourq_magic;
+ __u16 ourq_count; /* number of ourq_updates[] */
+ __u16 ourq_padding;
+ struct object_update ourq_updates[0];
+};
+
+void lustre_swab_object_update(struct object_update *ou);
+void lustre_swab_object_update_request(struct object_update_request *our);
+
+static inline size_t
+object_update_size(const struct object_update *update)
+{
+ const struct object_update_param *param;
+ size_t size;
+ unsigned int i;
+
+ size = offsetof(struct object_update, ou_params[0]);
+ for (i = 0; i < update->ou_params_count; i++) {
+ param = (struct object_update_param *)((char *)update + size);
+ size += object_update_param_size(param);
+ }
+
+ return size;
+}
+
+static inline struct object_update *
+object_update_request_get(const struct object_update_request *our,
+ unsigned int index, size_t *size)
+{
+ void *ptr;
+ unsigned int i;
+
+ if (index >= our->ourq_count)
+ return NULL;
+
+ ptr = (void *)&our->ourq_updates[0];
+ for (i = 0; i < index; i++)
+ ptr += object_update_size(ptr);
+
+ if (size != NULL)
+ *size = object_update_size(ptr);
+
+ return ptr;
+}
+
+
+/* the result of object update */
+struct object_update_result {
+ __u32 our_rc;
+ __u16 our_datalen;
+ __u16 our_padding;
+ __u32 our_data[0];
+};
+
+#define UPDATE_REPLY_MAGIC_V1 0x00BD0001
+#define UPDATE_REPLY_MAGIC_V2 0x00BD0002
+#define UPDATE_REPLY_MAGIC UPDATE_REPLY_MAGIC_V2
+/* Hold object_update_results being replied from the remote OUT. */
+struct object_update_reply {
+ __u32 ourp_magic;
+ __u16 ourp_count;
+ __u16 ourp_padding;
+ __u16 ourp_lens[0];
+};
+
+void lustre_swab_object_update_result(struct object_update_result *our);
+void lustre_swab_object_update_reply(struct object_update_reply *our);
+
+static inline struct object_update_result *
+object_update_result_get(const struct object_update_reply *reply,
+ unsigned int index, size_t *size)
+{
+ __u16 count = reply->ourp_count;
+ unsigned int i;
+ void *ptr;
+
+ if (index >= count)
+ return NULL;
+
+ ptr = (char *)reply +
+ cfs_size_round(offsetof(struct object_update_reply,
+ ourp_lens[count]));
+ for (i = 0; i < index; i++) {
+ if (reply->ourp_lens[i] == 0)
+ return NULL;
+
+ ptr += cfs_size_round(reply->ourp_lens[i]);
+ }
+
+ if (size != NULL)
+ *size = reply->ourp_lens[index];
+
+ return ptr;
+}