Commit 76558b82 authored by Philip Carns's avatar Philip Carns
Browse files

encode region size in id

parent cf9857ad
Pipeline #341 skipped
...@@ -20,9 +20,10 @@ typedef uint64_t bake_target_id_t; ...@@ -20,9 +20,10 @@ typedef uint64_t bake_target_id_t;
/** /**
* Persistent, opaque identifier for a bulk region within a BAKE target. * Persistent, opaque identifier for a bulk region within a BAKE target.
*/ */
#define BAKE_BULK_REGION_ID_SIZE 16 #define BAKE_BULK_REGION_ID_DATA_SIZE 24
typedef struct { typedef struct {
char data[BAKE_BULK_REGION_ID_SIZE]; uint32_t type;
char data[BAKE_BULK_REGION_ID_DATA_SIZE];
} bake_bulk_region_id_t; } bake_bulk_region_id_t;
/** /**
......
...@@ -14,6 +14,12 @@ ...@@ -14,6 +14,12 @@
*/ */
extern PMEMobjpool *pmem_pool; extern PMEMobjpool *pmem_pool;
/* definition of internal region_id_t identifier for libpmemobj back end */
typedef struct {
PMEMoid oid;
uint64_t size;
} pmemobj_region_id_t;
/* service a remote RPC that instructs the server daemon to shut down */ /* service a remote RPC that instructs the server daemon to shut down */
static void bake_bulk_shutdown_ult(hg_handle_t handle) static void bake_bulk_shutdown_ult(hg_handle_t handle)
{ {
...@@ -47,9 +53,11 @@ static void bake_bulk_create_ult(hg_handle_t handle) ...@@ -47,9 +53,11 @@ static void bake_bulk_create_ult(hg_handle_t handle)
{ {
bake_bulk_create_out_t out; bake_bulk_create_out_t out;
bake_bulk_create_in_t in; bake_bulk_create_in_t in;
PMEMoid oid;
hg_return_t hret; hg_return_t hret;
pmemobj_region_id_t* prid;
/* TODO: this check needs to be somewhere else */
assert(sizeof(pmemobj_region_id_t) <= BAKE_BULK_REGION_ID_DATA_SIZE);
printf("Got RPC request to create bulk region.\n"); printf("Got RPC request to create bulk region.\n");
memset(&out, 0, sizeof(out)); memset(&out, 0, sizeof(out));
...@@ -63,12 +71,9 @@ static void bake_bulk_create_ult(hg_handle_t handle) ...@@ -63,12 +71,9 @@ static void bake_bulk_create_ult(hg_handle_t handle)
return; return;
} }
out.ret = pmemobj_alloc(pmem_pool, &oid, in.region_size, 0, NULL, NULL); prid = (pmemobj_region_id_t*)out.rid.data;
if(out.ret == 0) prid->size = in.region_size;
{ out.ret = pmemobj_alloc(pmem_pool, &prid->oid, in.region_size, 0, NULL, NULL);
/* TODO: real translation functions for opaque type */
memcpy(&out.rid, &oid, sizeof(oid));
}
HG_Free_input(handle, &in); HG_Free_input(handle, &in);
HG_Respond(handle, NULL, NULL, &out); HG_Respond(handle, NULL, NULL, &out);
...@@ -83,12 +88,12 @@ static void bake_bulk_write_ult(hg_handle_t handle) ...@@ -83,12 +88,12 @@ static void bake_bulk_write_ult(hg_handle_t handle)
bake_bulk_write_out_t out; bake_bulk_write_out_t out;
bake_bulk_write_in_t in; bake_bulk_write_in_t in;
hg_return_t hret; hg_return_t hret;
PMEMoid oid;
char* buffer; char* buffer;
hg_size_t size; hg_size_t size;
hg_bulk_t bulk_handle; hg_bulk_t bulk_handle;
struct hg_info *hgi; struct hg_info *hgi;
margo_instance_id mid; margo_instance_id mid;
pmemobj_region_id_t* prid;
printf("Got RPC request to write bulk region.\n"); printf("Got RPC request to write bulk region.\n");
...@@ -107,11 +112,10 @@ static void bake_bulk_write_ult(hg_handle_t handle) ...@@ -107,11 +112,10 @@ static void bake_bulk_write_ult(hg_handle_t handle)
return; return;
} }
/* TODO: real translation functions for opaque type */ prid = (pmemobj_region_id_t*)in.rid.data;
memcpy(&oid, &in.rid, sizeof(oid));
/* find memory address for target object */ /* find memory address for target object */
buffer = pmemobj_direct(oid); buffer = pmemobj_direct(prid->oid);
if(!buffer) if(!buffer)
{ {
out.ret = -1; out.ret = -1;
...@@ -163,9 +167,8 @@ static void bake_bulk_persist_ult(hg_handle_t handle) ...@@ -163,9 +167,8 @@ static void bake_bulk_persist_ult(hg_handle_t handle)
bake_bulk_persist_out_t out; bake_bulk_persist_out_t out;
bake_bulk_persist_in_t in; bake_bulk_persist_in_t in;
hg_return_t hret; hg_return_t hret;
PMEMoid oid;
char* buffer; char* buffer;
hg_size_t size; pmemobj_region_id_t* prid;
printf("Got RPC request to persist bulk region.\n"); printf("Got RPC request to persist bulk region.\n");
...@@ -180,11 +183,10 @@ static void bake_bulk_persist_ult(hg_handle_t handle) ...@@ -180,11 +183,10 @@ static void bake_bulk_persist_ult(hg_handle_t handle)
return; return;
} }
/* TODO: real translation functions for opaque type */ prid = (pmemobj_region_id_t*)in.rid.data;
memcpy(&oid, &in.rid, sizeof(oid));
/* find memory address for target object */ /* find memory address for target object */
buffer = pmemobj_direct(oid); buffer = pmemobj_direct(prid->oid);
if(!buffer) if(!buffer)
{ {
out.ret = -1; out.ret = -1;
...@@ -194,12 +196,7 @@ static void bake_bulk_persist_ult(hg_handle_t handle) ...@@ -194,12 +196,7 @@ static void bake_bulk_persist_ult(hg_handle_t handle)
return; return;
} }
/* TODO: how to get the size of the object? */ pmemobj_persist(pmem_pool, buffer, prid->size);
/* TODO: let's put a header on each object with a magic number and a size
*/
size = 1;
pmemobj_persist(pmem_pool, buffer, size);
out.ret = 0; out.ret = 0;
......
...@@ -52,10 +52,12 @@ DECLARE_MARGO_RPC_HANDLER(bake_bulk_persist_ult) ...@@ -52,10 +52,12 @@ DECLARE_MARGO_RPC_HANDLER(bake_bulk_persist_ult)
static inline hg_return_t hg_proc_bake_bulk_region_id_t(hg_proc_t proc, bake_bulk_region_id_t *rid) static inline hg_return_t hg_proc_bake_bulk_region_id_t(hg_proc_t proc, bake_bulk_region_id_t *rid)
{ {
/* TODO: update later depending on final region_id_t type */ /* TODO: update later depending on final region_id_t type */
/* TODO: need separate encoders for different backend types */
int i; int i;
hg_return_t ret; hg_return_t ret;
for(i=0; i<BAKE_BULK_REGION_ID_SIZE; i++) hg_proc_hg_uint32_t(proc, &rid->type);
for(i=0; i<BAKE_BULK_REGION_ID_DATA_SIZE; i++)
{ {
ret = hg_proc_hg_uint8_t(proc, (uint8_t*)&rid->data[i]); ret = hg_proc_hg_uint8_t(proc, (uint8_t*)&rid->data[i]);
if(ret != HG_SUCCESS) if(ret != HG_SUCCESS)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment