+ 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));
+}
+EXPORT_SYMBOL(out_attr_get_pack);
+
+int out_xattr_get_pack(const struct lu_env *env, struct object_update *update,
+ size_t *max_update_size, const struct lu_fid *fid,
+ const char *name, const int bufsize)
+{
+ __u16 size;
+
+ LASSERT(name != NULL);
+ size = strlen(name) + 1;
+
+ return out_update_pack(env, update, max_update_size, OUT_XATTR_GET,
+ fid, 1, &size, (const void **)&name, bufsize);
+}
+EXPORT_SYMBOL(out_xattr_get_pack);
+
+int out_read_pack(const struct lu_env *env, struct object_update *update,
+ size_t *max_update_size, const struct lu_fid *fid,
+ size_t size, loff_t pos)
+{
+ __u16 sizes[2] = {sizeof(size), sizeof(pos)};
+ const void *bufs[2] = {&size, &pos};
+
+ LASSERT(size > 0);
+ size = cpu_to_le64(size);
+ pos = cpu_to_le64(pos);
+
+ return out_update_pack(env, update, max_update_size, OUT_READ, fid,
+ ARRAY_SIZE(sizes), sizes, bufs, size);
+}
+EXPORT_SYMBOL(out_read_pack);
+
+static int tx_extend_args(struct thandle_exec_args *ta, int new_alloc_ta)
+{
+ struct tx_arg **new_ta;
+ int i;
+ int rc = 0;
+
+ if (ta->ta_alloc_args >= new_alloc_ta)
+ return 0;