-typedef int (*osp_async_request_interpreter_t)(const struct lu_env *env,
- struct object_update_reply *rep,
- struct ptlrpc_request *req,
- struct osp_object *obj,
- void *data, int index, int rc);
+struct object_update *
+update_buffer_get_update(struct object_update_request *request,
+ unsigned int index);
+
+int osp_extend_update_buffer(const struct lu_env *env,
+ struct osp_update_request *our);
+
+struct osp_update_request_sub *
+osp_current_object_update_request(struct osp_update_request *our);
+
+int osp_object_update_request_create(struct osp_update_request *our,
+ size_t size);
+
+#define osp_update_rpc_pack(env, name, our, op, ...) \
+({ \
+ struct object_update *object_update; \
+ size_t max_update_length; \
+ struct osp_update_request_sub *ours; \
+ int ret; \
+ \
+ while (1) { \
+ ours = osp_current_object_update_request(our); \
+ LASSERT(ours != NULL); \
+ max_update_length = ours->ours_req_size - \
+ object_update_request_size(ours->ours_req); \
+ \
+ object_update = update_buffer_get_update(ours->ours_req,\
+ ours->ours_req->ourq_count); \
+ ret = out_##name##_pack(env, object_update, \
+ &max_update_length, \
+ __VA_ARGS__); \
+ if (ret == -E2BIG) { \
+ int rc1; \
+ /* Create new object update request */ \
+ rc1 = osp_object_update_request_create(our, \
+ max_update_length + \
+ offsetof(struct object_update_request, \
+ ourq_updates[0]) + 1); \
+ if (rc1 != 0) { \
+ ret = rc1; \
+ break; \
+ } \
+ continue; \
+ } else { \
+ if (ret == 0) { \
+ ours->ours_req->ourq_count++; \
+ object_update->ou_flags |= \
+ update->our_flags; \
+ } \
+ break; \
+ } \
+ } \
+ ret; \
+})
+
+static inline bool osp_send_update_thread_running(struct osp_device *osp)
+{
+ return osp->opd_update_thread.t_flags & SVC_RUNNING;
+}
+
+static inline bool osp_send_update_thread_stopped(struct osp_device *osp)
+{
+ return osp->opd_update_thread.t_flags & SVC_STOPPED;
+}
+
+typedef int (*osp_update_interpreter_t)(const struct lu_env *env,
+ struct object_update_reply *rep,
+ struct ptlrpc_request *req,
+ struct osp_object *obj,
+ void *data, int index, int rc);