+ RETURN(0);
+}
+EXPORT_SYMBOL(out_update_pack);
+
+/**
+ * Pack various updates into the update_buffer.
+ *
+ * The following functions pack different updates into the update_buffer
+ * So parameters of these API is basically same as its correspondent OSD/OSP
+ * API, for detail description of these parameters see osd_handler.c or
+ * osp_md_object.c.
+ *
+ * \param[in] env execution environment
+ * \param[in] ubuf update buffer
+ * \param[in] fid fid of this object for the update
+ *
+ * \retval 0 if insertion succeeds.
+ * \retval negative errno if insertion fails.
+ */
+int out_create_pack(const struct lu_env *env, struct object_update *update,
+ size_t *max_update_size, const struct lu_fid *fid,
+ const struct lu_attr *attr, struct dt_allocation_hint *hint,
+ struct dt_object_format *dof)
+{
+ struct obdo *obdo;
+ __u16 sizes[2] = {sizeof(*obdo), 0};
+ int buf_count = 1;
+ const struct lu_fid *parent_fid = NULL;
+ int rc;
+ ENTRY;
+
+ if (hint != NULL && hint->dah_parent) {
+ parent_fid = lu_object_fid(&hint->dah_parent->do_lu);
+ sizes[1] = sizeof(*parent_fid);
+ buf_count++;
+ }
+
+ rc = out_update_header_pack(env, update, max_update_size, OUT_CREATE,
+ fid, buf_count, sizes, 0);
+ if (rc != 0)
+ RETURN(rc);
+
+ obdo = object_update_param_get(update, 0, NULL);
+ if (IS_ERR(obdo))
+ RETURN(PTR_ERR(obdo));
+
+ obdo->o_valid = 0;
+ obdo_from_la(obdo, attr, attr->la_valid);
+ lustre_set_wire_obdo(NULL, obdo, obdo);
+
+ if (parent_fid != NULL) {
+ struct lu_fid *tmp;
+
+ tmp = object_update_param_get(update, 1, NULL);
+ if (IS_ERR(tmp))
+ RETURN(PTR_ERR(tmp));
+
+ fid_cpu_to_le(tmp, parent_fid);
+ }
+
+ RETURN(0);
+}
+EXPORT_SYMBOL(out_create_pack);
+
+int out_ref_del_pack(const struct lu_env *env, struct object_update *update,
+ size_t *max_update_size, const struct lu_fid *fid)
+{
+ return out_update_pack(env, update, max_update_size, OUT_REF_DEL, fid,
+ 0, NULL, NULL, 0);
+}
+EXPORT_SYMBOL(out_ref_del_pack);
+
+int out_ref_add_pack(const struct lu_env *env, struct object_update *update,
+ size_t *max_update_size, const struct lu_fid *fid)
+{
+ return out_update_pack(env, update, max_update_size, OUT_REF_ADD, fid,
+ 0, NULL, NULL, 0);
+}
+EXPORT_SYMBOL(out_ref_add_pack);
+
+int out_attr_set_pack(const struct lu_env *env, struct object_update *update,
+ size_t *max_update_size, const struct lu_fid *fid,
+ const struct lu_attr *attr)
+{
+ struct obdo *obdo;
+ __u16 size = sizeof(*obdo);
+ int rc;
+ ENTRY;
+
+ rc = out_update_header_pack(env, update, max_update_size,
+ OUT_ATTR_SET, fid, 1, &size, 0);
+ if (rc != 0)
+ RETURN(rc);
+
+ obdo = object_update_param_get(update, 0, NULL);
+ if (IS_ERR(obdo))
+ RETURN(PTR_ERR(obdo));
+
+ obdo->o_valid = 0;
+ obdo_from_la(obdo, attr, attr->la_valid);
+ lustre_set_wire_obdo(NULL, obdo, obdo);
+
+ RETURN(0);
+}
+EXPORT_SYMBOL(out_attr_set_pack);
+
+int out_xattr_set_pack(const struct lu_env *env, struct object_update *update,
+ size_t *max_update_size, const struct lu_fid *fid,
+ const struct lu_buf *buf, const char *name, __u32 flag)
+{
+ __u16 sizes[3] = {strlen(name) + 1, buf->lb_len, sizeof(flag)};
+ const void *bufs[3] = {(char *)name, (char *)buf->lb_buf,
+ (char *)&flag};
+
+ return out_update_pack(env, update, max_update_size, OUT_XATTR_SET,
+ fid, ARRAY_SIZE(sizes), sizes, bufs, 0);
+}
+EXPORT_SYMBOL(out_xattr_set_pack);
+
+int out_xattr_del_pack(const struct lu_env *env, struct object_update *update,
+ size_t *max_update_size, const struct lu_fid *fid,
+ const char *name)
+{
+ __u16 size = strlen(name) + 1;
+
+ return out_update_pack(env, update, max_update_size, OUT_XATTR_DEL,
+ fid, 1, &size, (const void **)&name, 0);
+}
+EXPORT_SYMBOL(out_xattr_del_pack);
+
+int out_index_insert_pack(const struct lu_env *env,
+ struct object_update *update,
+ size_t *max_update_size, const struct lu_fid *fid,
+ const struct dt_rec *rec, const struct dt_key *key)
+{
+ struct dt_insert_rec *rec1 = (struct dt_insert_rec *)rec;
+ struct lu_fid rec_fid;
+ __u32 type = cpu_to_le32(rec1->rec_type);
+ __u16 sizes[3] = { strlen((char *)key) + 1,
+ sizeof(rec_fid),
+ sizeof(type) };
+ const void *bufs[3] = { (char *)key,
+ (char *)&rec_fid,
+ (char *)&type };
+
+ fid_cpu_to_le(&rec_fid, rec1->rec_fid);
+
+ return out_update_pack(env, update, max_update_size, OUT_INDEX_INSERT,
+ fid, ARRAY_SIZE(sizes), sizes, bufs, 0);
+}
+EXPORT_SYMBOL(out_index_insert_pack);
+
+int out_index_delete_pack(const struct lu_env *env,
+ struct object_update *update,
+ size_t *max_update_size, const struct lu_fid *fid,
+ const struct dt_key *key)
+{
+ __u16 size = strlen((char *)key) + 1;
+ const void *buf = key;
+
+ return out_update_pack(env, update, max_update_size, OUT_INDEX_DELETE,
+ fid, 1, &size, &buf, 0);
+}
+EXPORT_SYMBOL(out_index_delete_pack);
+
+int out_object_destroy_pack(const struct lu_env *env,
+ struct object_update *update,
+ size_t *max_update_size, const struct lu_fid *fid)
+{
+ return out_update_pack(env, update, max_update_size, OUT_DESTROY, fid,
+ 0, NULL, NULL, 0);
+}
+EXPORT_SYMBOL(out_object_destroy_pack);
+
+int out_write_pack(const struct lu_env *env, struct object_update *update,
+ size_t *max_update_size, const struct lu_fid *fid,
+ const struct lu_buf *buf, __u64 pos)
+{
+ __u16 sizes[2] = {buf->lb_len, sizeof(pos)};
+ const void *bufs[2] = {(char *)buf->lb_buf, (char *)&pos};
+ int rc;
+
+ pos = cpu_to_le64(pos);
+
+ rc = out_update_pack(env, update, max_update_size, OUT_WRITE, fid,
+ ARRAY_SIZE(sizes), sizes, bufs, 0);
+ return rc;
+}
+EXPORT_SYMBOL(out_write_pack);
+
+/**
+ * Pack various readonly updates into the update_buffer.
+ *
+ * The following update funcs are only used by read-only ops, lookup,
+ * getattr etc, so it does not need transaction here. Currently they
+ * are only used by OSP.
+ *
+ * \param[in] env execution environment
+ * \param[in] fid fid of this object for the update
+ * \param[in] ubuf update buffer
+ *
+ * \retval = 0 pack succeed.
+ * < 0 pack failed.
+ **/
+int out_index_lookup_pack(const struct lu_env *env,
+ struct object_update *update,
+ size_t *max_update_size, const struct lu_fid *fid,
+ struct dt_rec *rec, const struct dt_key *key)
+{
+ const void *name = key;
+ __u16 size = strlen((char *)name) + 1;
+
+ /* XXX: this shouldn't be hardcoded */
+ return out_update_pack(env, update, max_update_size, OUT_INDEX_LOOKUP,
+ fid, 1, &size, &name, 256);
+}
+EXPORT_SYMBOL(out_index_lookup_pack);
+
+int out_attr_get_pack(const struct lu_env *env, struct object_update *update,
+ size_t *max_update_size, const struct lu_fid *fid)
+{
+ return out_update_pack(env, update, max_update_size, OUT_ATTR_GET,
+ fid, 0, NULL, NULL, sizeof(struct obdo));