+ 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_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_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);