Whamcloud - gitweb
LU-5319 ptlrpc: Add OBD_CONNECT_MULTIMODRPCS flag
[fs/lustre-release.git] / lustre / include / lustre_update.h
index d99e141..c75e4fb 100644 (file)
@@ -20,7 +20,7 @@
  * GPL HEADER END
  */
 /*
- * Copyright (c) 2013, Intel Corporation.
+ * Copyright (c) 2013, 2014, Intel Corporation.
  */
 /*
  * lustre/include/lustre_update.h
 
 #ifndef _LUSTRE_UPDATE_H
 #define _LUSTRE_UPDATE_H
+#include <lustre_net.h>
+
+#define OUT_UPDATE_INIT_BUFFER_SIZE    4096
+#define OUT_UPDATE_REPLY_SIZE          8192
+
+struct dt_object;
+struct dt_object_hint;
+struct dt_object_format;
+struct dt_allocation_hint;
+struct dt_key;
+struct dt_rec;
+struct thandle;
+
+struct update_buffer {
+       struct object_update_request    *ub_req;
+       size_t                          ub_req_size;
+};
 
-#define OUT_UPDATE_INIT_BUFFER_SIZE    8192
-#define OUT_UPDATE_REPLY_SIZE  8192
+/**
+ * Tracking the updates being executed on this dt_device.
+ */
 struct dt_update_request {
        struct dt_device                *dur_dt;
        /* attached itself to thandle */
@@ -42,40 +60,17 @@ struct dt_update_request {
        int                             dur_rc;
        /* Current batch(transaction) id */
        __u64                           dur_batchid;
-       /* Holding the update req */
-       struct object_update_request    *dur_req;
-       int                             dur_req_len;
+       /* Holding object updates */
+       struct update_buffer            dur_buf;
        struct list_head                dur_cb_items;
 };
 
-static inline unsigned long
-object_update_param_size(const struct object_update_param *param)
-{
-       return cfs_size_round(sizeof(*param) + param->oup_len);
-}
-
-static inline unsigned long
-object_update_size(const struct object_update *update)
-{
-       const struct    object_update_param *param;
-       unsigned long   size;
-       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 void
-*object_update_param_get(const struct object_update *update, int index,
-                        int *size)
+*object_update_param_get(const struct object_update *update, size_t index,
+                        size_t *size)
 {
        const struct    object_update_param *param;
-       int             i;
+       size_t          i;
 
        if (index >= update->ou_params_count)
                return NULL;
@@ -97,8 +92,8 @@ static inline void
 static inline unsigned long
 object_update_request_size(const struct object_update_request *our)
 {
-       unsigned long size;
-       int        i = 0;
+       unsigned long   size;
+       size_t          i = 0;
 
        size = offsetof(struct object_update_request, ourq_updates[0]);
        for (i = 0; i < our->ourq_count; i++) {
@@ -110,62 +105,16 @@ object_update_request_size(const struct object_update_request *our)
        return size;
 }
 
-static inline struct object_update
-*object_update_request_get(const struct object_update_request *our,
-                          int index, int *size)
-{
-       void    *ptr;
-       int     i;
-
-       if (index >= our->ourq_count)
-               return NULL;
-
-       ptr = (char *)our + offsetof(struct object_update_request,
-                                    ourq_updates[0]);
-       for (i = 0; i < index; i++)
-               ptr += object_update_size((struct object_update *)ptr);
-
-       if (size != NULL)
-               *size = object_update_size((struct object_update *)ptr);
-
-       return ptr;
-}
-
 static inline void
-object_update_reply_init(struct object_update_reply *reply, int count)
+object_update_reply_init(struct object_update_reply *reply, size_t count)
 {
        reply->ourp_magic = UPDATE_REPLY_MAGIC;
        reply->ourp_count = count;
 }
 
-static inline struct object_update_result
-*object_update_result_get(const struct object_update_reply *reply,
-                         int index, int *size)
-{
-       char *ptr;
-       int count = reply->ourp_count;
-       int i;
-
-       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++) {
-               LASSERT(reply->ourp_lens[i] > 0);
-               ptr += cfs_size_round(reply->ourp_lens[i]);
-       }
-
-       if (size != NULL)
-               *size = reply->ourp_lens[index];
-
-       return (struct object_update_result *)ptr;
-}
-
 static inline void
 object_update_result_insert(struct object_update_reply *reply,
-                           void *data, int data_len, int index,
+                           void *data, size_t data_len, size_t index,
                            int rc)
 {
        struct object_update_result *update_result;
@@ -189,11 +138,11 @@ object_update_result_insert(struct object_update_reply *reply,
 
 static inline int
 object_update_result_data_get(const struct object_update_reply *reply,
-                             struct lu_buf *lbuf, int index)
+                             struct lu_buf *lbuf, size_t index)
 {
        struct object_update_result *update_result;
-       int  size = 0;
-       int  result;
+       size_t size = 0;
+       int    result;
 
        LASSERT(lbuf != NULL);
        update_result = object_update_result_get(reply, index, &size);
@@ -217,4 +166,52 @@ static inline void update_inc_batchid(struct dt_update_request *update)
        update->dur_batchid++;
 }
 
+/* target/out_lib.c */
+struct thandle_update;
+struct dt_update_request *out_find_update(struct thandle_update *tu,
+                                         struct dt_device *dt_dev);
+void dt_update_request_destroy(struct dt_update_request *update);
+struct dt_update_request *dt_update_request_create(struct dt_device *dt);
+struct dt_update_request *dt_update_request_find_or_create(struct thandle *th,
+                                                         struct dt_object *dt);
+int out_update_pack(const struct lu_env *env, struct update_buffer *ubuf,
+                   enum update_type op, const struct lu_fid *fid,
+                   int params_count, __u16 *param_sizes, const void **bufs,
+                   __u64 batchid);
+int out_create_pack(const struct lu_env *env, struct update_buffer *ubuf,
+                   const struct lu_fid *fid, struct lu_attr *attr,
+                   struct dt_allocation_hint *hint,
+                   struct dt_object_format *dof, __u64 batchid);
+int out_object_destroy_pack(const struct lu_env *env,
+                           struct update_buffer *ubuf,
+                           const struct lu_fid *fid, __u64 batchid);
+int out_index_delete_pack(const struct lu_env *env, struct update_buffer *ubuf,
+                         const struct lu_fid *fid, const struct dt_key *key,
+                         __u64 batchid);
+int out_index_insert_pack(const struct lu_env *env, struct update_buffer *ubuf,
+                         const struct lu_fid *fid, const struct dt_rec *rec,
+                         const struct dt_key *key, __u64 batchid);
+int out_xattr_set_pack(const struct lu_env *env, struct update_buffer *ubuf,
+                      const struct lu_fid *fid, const struct lu_buf *buf,
+                      const char *name, int flag, __u64 batchid);
+int out_xattr_del_pack(const struct lu_env *env, struct update_buffer *ubuf,
+                      const struct lu_fid *fid, const char *name,
+                      __u64 batchid);
+int out_attr_set_pack(const struct lu_env *env, struct update_buffer *ubuf,
+                     const struct lu_fid *fid, const struct lu_attr *attr,
+                     __u64 batchid);
+int out_ref_add_pack(const struct lu_env *env, struct update_buffer *ubuf,
+                    const struct lu_fid *fid, __u64 batchid);
+int out_ref_del_pack(const struct lu_env *env, struct update_buffer *ubuf,
+                    const struct lu_fid *fid, __u64 batchid);
+int out_write_pack(const struct lu_env *env, struct update_buffer *ubuf,
+                  const struct lu_fid *fid, const struct lu_buf *buf,
+                  loff_t pos, __u64 batchid);
+int out_attr_get_pack(const struct lu_env *env, struct update_buffer *ubuf,
+                     const struct lu_fid *fid);
+int out_index_lookup_pack(const struct lu_env *env, struct update_buffer *ubuf,
+                         const struct lu_fid *fid, struct dt_rec *rec,
+                         const struct dt_key *key);
+int out_xattr_get_pack(const struct lu_env *env, struct update_buffer *ubuf,
+                      const struct lu_fid *fid, const char *name);
 #endif