Triton-commits
Threads by month
- ----- 2026 -----
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
April 2010
- 1 participants
- 39 discussions
Triton Repository branch, master, updated. a2007ed02b331b2173ae9ed009ee5f0659baf6f3
by noreply@mcs.anl.gov 28 Apr '10
by noreply@mcs.anl.gov 28 Apr '10
28 Apr '10
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Triton Repository".
The branch, master has been updated
via a2007ed02b331b2173ae9ed009ee5f0659baf6f3 (commit)
via 3883ac36763ae2ed03074f213eb1b7716435d483 (commit)
from 6996d98bad93712d4e2327fb073260705e8407f5 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit a2007ed02b331b2173ae9ed009ee5f0659baf6f3
Author: Phil Carns <carns(a)mcs.anl.gov>
Date: Wed Apr 28 16:34:36 2010 -0400
misc. comments
commit 3883ac36763ae2ed03074f213eb1b7716435d483
Author: Phil Carns <carns(a)mcs.anl.gov>
Date: Wed Apr 28 16:31:06 2010 -0400
untested vosd_remove() function
-----------------------------------------------------------------------
Summary of changes:
code/src/versioned-osd/prototype/versioned-osd.ae | 277 ++++++++++++++++++++
code/src/versioned-osd/prototype/versioned-osd.hae | 9 +-
code/src/versioned-osd/prototype/vosd-fd-cache.ae | 1 +
3 files changed, 279 insertions(+), 8 deletions(-)
Diff of changes:
diff --git a/code/src/versioned-osd/prototype/versioned-osd.ae b/code/src/versioned-osd/prototype/versioned-osd.ae
index 5e9cfa8..2a01259 100644
--- a/code/src/versioned-osd/prototype/versioned-osd.ae
+++ b/code/src/versioned-osd/prototype/versioned-osd.ae
@@ -177,6 +177,270 @@ static __blocking triton_ret_t __vosd_create_retryable(uint64_t oid)
return(tret);
}
+/* TODO: this function is a temporary workaround for compile time error when
+ * clear_missing_vers() invokes two blocking functions in a for loop
+ */
+static __blocking triton_ret_t cursor_get_and_del_missing_ver(uint64_t oid,
+ DBT* missing_ver_key, DBT* missing_ver_value, int c_get_flag,
+ DBC *missing_ver_dbcp)
+{
+ triton_ret_t tret;
+ struct missing_version* mvk = missing_ver_key->data;
+
+ tret = bdb_cursor_get(missing_ver_dbcp,
+ missing_ver_key, missing_ver_value, c_get_flag);
+ if(tret == TRITON_SUCCESS && mvk->oid != oid)
+ {
+ /* hit the next object */
+ tret = TRITON_ERR_NOENT;
+ }
+ else if(tret == TRITON_SUCCESS)
+ {
+ /* delete entry */
+ tret = bdb_cursor_del(missing_ver_dbcp, 0);
+ }
+
+ return(tret);
+}
+
+#if 0
+static __blocking triton_ret_t clear_missing_vers(
+ uint64_t oid,
+ DB_TXN *txn,
+ DBC *missing_ver_dbcp);
+#endif
+static __blocking triton_ret_t clear_missing_vers(
+ uint64_t oid,
+ DB_TXN *txn,
+ DBC *missing_ver_dbcp)
+{
+ triton_ret_t tret;
+ DBT missing_ver_key;
+ DBT missing_ver_value;
+ struct missing_version mvk;
+ int c_get_flag = DB_SET_RANGE;
+
+ VOSD_INIT_DBT(missing_ver_key, mvk);
+ VOSD_INIT_DBT_EMPTY(missing_ver_value);
+
+ /* search for any missing versions */
+ mvk.oid = oid;
+ mvk.version = 0;
+ c_get_flag = DB_SET_RANGE;
+
+ for(tret = TRITON_SUCCESS; tret == TRITON_SUCCESS; )
+ {
+ tret = cursor_get_and_del_missing_ver(oid,
+ &missing_ver_key, &missing_ver_value, c_get_flag,
+ missing_ver_dbcp);
+ c_get_flag = DB_NEXT;
+ }
+ if(tret == TRITON_ERR_NOENT)
+ {
+ /* no error, just ran out of stuff to delete */
+#if 0
+ triton_error_destroy(tret);
+#endif
+ tret = TRITON_SUCCESS;
+ }
+
+ return(tret);
+}
+
+/* TODO: this function is a temporary workaround for compile time error when
+ * clear_logical_map() invokes two blocking functions in a for loop
+ */
+static __blocking triton_ret_t cursor_get_and_del_log_map(uint64_t oid,
+ DBT* log_map_key, DBT* log_map_value, int c_get_flag,
+ DBC *log_map_dbcp)
+{
+ triton_ret_t tret;
+ struct logical_map_key* lmk = log_map_key->data;
+
+ tret = bdb_cursor_get(log_map_dbcp,
+ log_map_key, log_map_value, c_get_flag);
+ if(tret == TRITON_SUCCESS && lmk->oid != oid)
+ {
+ /* hit the next object */
+ tret = TRITON_ERR_NOENT;
+ }
+ else if(tret == TRITON_SUCCESS)
+ {
+ /* delete entry */
+ tret = bdb_cursor_del(log_map_dbcp, 0);
+ }
+
+ return(tret);
+}
+
+
+#if 0
+static __blocking triton_ret_t clear_logical_map(
+ uint64_t oid,
+ DB_TXN *txn,
+ DBC *log_map_dbcp);
+#endif
+static __blocking triton_ret_t clear_logical_map(
+ uint64_t oid,
+ DB_TXN *txn,
+ DBC *log_map_dbcp)
+{
+ triton_ret_t tret;
+ int c_get_flag = DB_SET_RANGE;
+ DBT log_map_key;
+ DBT log_map_value;
+ struct logical_map_key lmk;
+ struct logical_map_entry lmv;
+
+ VOSD_INIT_DBT(log_map_key, lmk);
+ VOSD_INIT_DBT(log_map_value, lmv);
+
+ /* search for any logical map entries */
+ lmk.oid = oid;
+ lmk.fork = 0;
+ lmk.logical_offset_end = 0;
+ c_get_flag = DB_SET_RANGE;
+
+ for(tret = TRITON_SUCCESS; tret == TRITON_SUCCESS; )
+ {
+ tret = cursor_get_and_del_log_map(oid,
+ &log_map_key, &log_map_value, c_get_flag,
+ log_map_dbcp);
+ c_get_flag = DB_NEXT;
+ }
+ if(tret == TRITON_ERR_NOENT)
+ {
+ /* no error, just ran out of stuff to delete */
+#if 0
+ triton_error_destroy(tret);
+#endif
+ tret = TRITON_SUCCESS;
+ }
+
+ return(tret);
+}
+
+#if 0
+static __blocking triton_ret_t __vosd_remove_retryable(uint64_t oid);
+#endif
+
+static __blocking triton_ret_t __vosd_remove_retryable(uint64_t oid)
+{
+ triton_ret_t tret;
+ triton_ret_t tret_tmp;
+ DB_TXN *txn;
+ DBC *log_map_dbcp, *missing_ver_dbcp;
+ DBT ver_key;
+ DBT ver_value;
+ uint64_t vk;
+ uint64_t vv;
+
+ tret = bdb_txn_begin(envp, NULL, &txn, 0);
+ if(tret != TRITON_SUCCESS)
+ {
+ return(tret);
+ }
+
+ VOSD_INIT_DBT(ver_key, vk);
+ VOSD_INIT_DBT(ver_value, vv);
+ vk = oid;
+
+ /* delete version key */
+ tret = bdb_del(ver_dbp, txn, &ver_key, 0);
+ if(tret != TRITON_SUCCESS)
+ {
+ /* NOTE: TRITON_ERR_NOENT may propigate out of here if the object
+ * did not exist
+ */
+ tret_tmp = bdb_txn_abort(txn);
+#if 0
+ triton_error_destroy(tret_tmp);
+#endif
+ return(tret);
+ }
+
+ tret = bdb_cursor(missing_ver_dbp, txn, &missing_ver_dbcp, 0);
+ if(tret != TRITON_SUCCESS)
+ {
+ tret_tmp = bdb_txn_abort(txn);
+#if 0
+ triton_error_destroy(tret_tmp);
+#endif
+ return(tret);
+ }
+
+ /* try to clean out missing version information */
+ tret = clear_missing_vers(oid, txn, missing_ver_dbcp);
+ if(tret != TRITON_SUCCESS)
+ {
+ tret_tmp = bdb_cursor_close(missing_ver_dbcp);
+#if 0
+ triton_error_destroy(tret_tmp);
+#endif
+ tret_tmp = bdb_txn_abort(txn);
+#if 0
+ triton_error_destroy(tret_tmp);
+#endif
+ return(tret);
+ }
+
+ tret = bdb_cursor_close(missing_ver_dbcp);
+ if(tret != TRITON_SUCCESS)
+ {
+ tret_tmp = bdb_txn_abort(txn);
+#if 0
+ triton_error_destroy(tret_tmp);
+#endif
+ return(tret);
+ }
+
+ tret = bdb_cursor(log_map_dbp, txn, &log_map_dbcp, 0);
+ if(tret != TRITON_SUCCESS)
+ {
+ tret_tmp = bdb_txn_abort(txn);
+#if 0
+ triton_error_destroy(tret_tmp);
+#endif
+ return(tret);
+ }
+
+ /* try to clean out log map information */
+ tret = clear_logical_map(oid, txn, missing_ver_dbcp);
+ if(tret != TRITON_SUCCESS)
+ {
+ tret_tmp = bdb_cursor_close(log_map_dbcp);
+#if 0
+ triton_error_destroy(tret_tmp);
+#endif
+ tret_tmp = bdb_txn_abort(txn);
+#if 0
+ triton_error_destroy(tret_tmp);
+#endif
+ return(tret);
+ }
+
+ tret = bdb_cursor_close(log_map_dbcp);
+ if(tret != TRITON_SUCCESS)
+ {
+ tret_tmp = bdb_txn_abort(txn);
+#if 0
+ triton_error_destroy(tret_tmp);
+#endif
+ return(tret);
+ }
+
+ tret = bdb_txn_commit(txn, 0);
+ if(tret != TRITON_SUCCESS)
+ {
+ return(tret);
+ }
+
+ /* get rid of the underlying file */
+ fd_cache_remove(vk);
+
+ return(tret);
+}
+
#if 0
static __blocking triton_ret_t __vosd_get_version_retryable(uint64_t oid, uint64_t* version);
#endif
@@ -1556,7 +1820,20 @@ __blocking triton_ret_t vosd_read(
return(TRITON_SUCCESS);
}
+__blocking triton_ret_t vosd_remove(uint64_t oid)
+{
+ triton_ret_t tret;
+
+ for(tret = TRITON_ERR_DEADLOCK; tret == TRITON_ERR_DEADLOCK; )
+ {
+#if 0
+ triton_error_destroy(tret);
+#endif
+ tret = __vosd_remove_retryable(oid);
+ }
+ return(tret);
+}
static int compare_log_map_key(DB * dbp, const DBT * a, const DBT * b)
diff --git a/code/src/versioned-osd/prototype/versioned-osd.hae b/code/src/versioned-osd/prototype/versioned-osd.hae
index 39dd7d0..b2b191b 100644
--- a/code/src/versioned-osd/prototype/versioned-osd.hae
+++ b/code/src/versioned-osd/prototype/versioned-osd.hae
@@ -106,20 +106,13 @@ __blocking triton_ret_t vosd_read(
int64_t* out_size /**< amount read */
);
-
-
-#if 0
-
/**
* Removes an existing object
- * \return 0 on success, -errno on failure
*/
-__blocking int gs_cosd_remove(
+__blocking triton_ret_t vosd_remove(
uint64_t oid /**< oid to remove */
);
-#endif
-
#endif /* __VERSIONED_OSD_HAE__ */
/* @} */
diff --git a/code/src/versioned-osd/prototype/vosd-fd-cache.ae b/code/src/versioned-osd/prototype/vosd-fd-cache.ae
index 4b1531b..64bc7aa 100644
--- a/code/src/versioned-osd/prototype/vosd-fd-cache.ae
+++ b/code/src/versioned-osd/prototype/vosd-fd-cache.ae
@@ -131,6 +131,7 @@ __blocking void fd_cache_remove(uint64_t oid)
/* actually unlink the log file */
sprintf(log_name, "%s/%llu.dat", fd_cache_cosd_log_path,
llu(oid));
+ /* TODO: this should be a resource function */
unlink(log_name);
triton_mutex_unlock(&fd_mutex);
hooks/post-receive
--
Triton Repository
1
0
Triton Repository branch, master, updated. 6996d98bad93712d4e2327fb073260705e8407f5
by noreply@mcs.anl.gov 28 Apr '10
by noreply@mcs.anl.gov 28 Apr '10
28 Apr '10
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Triton Repository".
The branch, master has been updated
via 6996d98bad93712d4e2327fb073260705e8407f5 (commit)
via c03053cd025feedfa7f15ba593a0e19cdf08ada2 (commit)
from bcce3f03149f3c79a0b5144ad347f780e2e1ffe6 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 6996d98bad93712d4e2327fb073260705e8407f5
Author: Phil Carns <carns(a)mcs.anl.gov>
Date: Wed Apr 28 14:09:06 2010 -0400
support for remaining vosd write flags
commit c03053cd025feedfa7f15ba593a0e19cdf08ada2
Author: Phil Carns <carns(a)mcs.anl.gov>
Date: Wed Apr 28 13:28:07 2010 -0400
TRUNCATE flag support for VOSD write
-----------------------------------------------------------------------
Summary of changes:
code/src/versioned-osd/prototype/tests/vosd1.ae | 71 +++++++++++++++++++++
code/src/versioned-osd/prototype/versioned-osd.ae | 22 +++++-
2 files changed, 89 insertions(+), 4 deletions(-)
Diff of changes:
diff --git a/code/src/versioned-osd/prototype/tests/vosd1.ae b/code/src/versioned-osd/prototype/tests/vosd1.ae
index 4412001..8d40c71 100644
--- a/code/src/versioned-osd/prototype/tests/vosd1.ae
+++ b/code/src/versioned-osd/prototype/tests/vosd1.ae
@@ -446,6 +446,77 @@ static __blocking int do_vosd_test(void)
tret = vosd_dump();
assert(tret == TRITON_SUCCESS);
+ /********************************************************/
+ printf("opening txn...\n");
+ tret = vosd_txn_open(1, 0, (++version));
+ if(tret != TRITON_SUCCESS)
+ {
+ printf("Error opening txn 1: %d\n", ret);
+ free(buffer);
+#if 0
+ triton_error_destroy(tret);
+#endif
+ return 1;
+ }
+ printf("DONE\n");
+
+ printf("writing 0-1024 with truncate flag...\n");
+ buffer_offsets[0] = buffer;
+ buffer_szs[0] = 1024;
+ obj_offsets[0] = 0;
+ obj_szs[0] = 1024;
+ tret = vosd_write(1, 0, (version), buffer_offsets, buffer_szs, 1,
+ obj_offsets, obj_szs, 1, VOSD_FLAG_TRUNC_WRITE);
+ if(tret != TRITON_SUCCESS)
+ {
+ printf("Error writing 0-1024: %d\n", ret);
+ free(buffer);
+#if 0
+ triton_error_destroy(tret);
+#endif
+ return 1;
+ }
+ printf("DONE\n");
+
+ printf("closing txn...\n");
+ tret = vosd_txn_close(1, 0, (version));
+ if(tret != TRITON_SUCCESS)
+ {
+ printf("Error closing txn 1: %d\n", ret);
+ free(buffer);
+#if 0
+ triton_error_destroy(tret);
+#endif
+ return 1;
+ }
+ printf("DONE\n");
+
+ tret = vosd_dump();
+ assert(tret == TRITON_SUCCESS);
+
+ /********************************************************/
+
+ printf("writing 512-1024 with auto txn...\n");
+ buffer_offsets[0] = buffer;
+ buffer_szs[0] = 512;
+ obj_offsets[0] = 512;
+ obj_szs[0] = 512;
+ tret = vosd_write(1, 0, (++version), buffer_offsets, buffer_szs, 1,
+ obj_offsets, obj_szs, 1, VOSD_FLAG_AUTO_TXN);
+ if(tret != TRITON_SUCCESS)
+ {
+ printf("Error writing 512-1024\n");
+ free(buffer);
+#if 0
+ triton_error_destroy(tret);
+#endif
+ return 1;
+ }
+ printf("DONE\n");
+
+ tret = vosd_dump();
+ assert(tret == TRITON_SUCCESS);
+
return 1;
}
diff --git a/code/src/versioned-osd/prototype/versioned-osd.ae b/code/src/versioned-osd/prototype/versioned-osd.ae
index 91c567f..5e9cfa8 100644
--- a/code/src/versioned-osd/prototype/versioned-osd.ae
+++ b/code/src/versioned-osd/prototype/versioned-osd.ae
@@ -1296,9 +1296,17 @@ __blocking triton_ret_t vosd_write(
assert(mem_count > 0);
assert(obj_count > 0);
- /* TODO: deal with flags */
- assert(!(flags & VOSD_FLAG_TRUNC_WRITE));
- assert(!(flags & VOSD_FLAG_AUTO_TXN));
+ if(flags & VOSD_FLAG_AUTO_TXN)
+ {
+ tret = vosd_txn_open(oid, fork, txn_number);
+ if(tret != TRITON_SUCCESS)
+ {
+ return(tret);
+ }
+ }
+ /* TODO: add vosd_txn_abort() calls in return paths through the rest of
+ * this function
+ */
tret = fd_cache_get(&fd_entry, oid);
if(tret != TRITON_SUCCESS)
@@ -1430,8 +1438,14 @@ __blocking triton_ret_t vosd_write(
if(scratch_buffer)
free(scratch_buffer);
fd_cache_put(fd_entry);
+
+ tret = TRITON_SUCCESS;
+ if(flags & VOSD_FLAG_AUTO_TXN)
+ {
+ tret = vosd_txn_close(oid, fork, txn_number);
+ }
- return(TRITON_SUCCESS);
+ return(tret);
}
__blocking triton_ret_t vosd_txn_close(
hooks/post-receive
--
Triton Repository
1
0
Triton Repository branch, master, updated. bcce3f03149f3c79a0b5144ad347f780e2e1ffe6
by noreply@mcs.anl.gov 28 Apr '10
by noreply@mcs.anl.gov 28 Apr '10
28 Apr '10
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Triton Repository".
The branch, master has been updated
via bcce3f03149f3c79a0b5144ad347f780e2e1ffe6 (commit)
via 4fb533503380cd370e1e8cbcb23e68209fe45371 (commit)
via 342a4364b074850b339eeacd7ffb579824197c60 (commit)
via b3176378aa60abd8e5c70b584f55296b3bd3dd4d (commit)
from 2e6c4841ce062739de191721e7a85aebcd65d7aa (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit bcce3f03149f3c79a0b5144ad347f780e2e1ffe6
Author: Phil Carns <carns(a)mcs.anl.gov>
Date: Wed Apr 28 12:43:18 2010 -0400
lots more vosd test case (reads, forks, etc.)
commit 4fb533503380cd370e1e8cbcb23e68209fe45371
Author: Phil Carns <carns(a)mcs.anl.gov>
Date: Wed Apr 28 12:11:18 2010 -0400
test read beyond eof
commit 342a4364b074850b339eeacd7ffb579824197c60
Author: Phil Carns <carns(a)mcs.anl.gov>
Date: Wed Apr 28 12:08:18 2010 -0400
test aligned reads
commit b3176378aa60abd8e5c70b584f55296b3bd3dd4d
Author: Phil Carns <carns(a)mcs.anl.gov>
Date: Wed Apr 28 12:03:04 2010 -0400
complete, but untested, vosd_read() function
-----------------------------------------------------------------------
Summary of changes:
code/src/versioned-osd/prototype/tests/vosd1.ae | 199 +++++++++++++++++++++
code/src/versioned-osd/prototype/versioned-osd.ae | 117 +++++++++++--
2 files changed, 305 insertions(+), 11 deletions(-)
Diff of changes:
diff --git a/code/src/versioned-osd/prototype/tests/vosd1.ae b/code/src/versioned-osd/prototype/tests/vosd1.ae
index b193213..4412001 100644
--- a/code/src/versioned-osd/prototype/tests/vosd1.ae
+++ b/code/src/versioned-osd/prototype/tests/vosd1.ae
@@ -26,6 +26,8 @@ static __blocking int do_vosd_test(void)
int64_t obj_offsets[3];
int64_t obj_szs[3];
int ret;
+ int64_t out_size;
+ int i;
ret = posix_memalign(&void_buffer, 512, 4096);
assert(ret == 0);
@@ -246,6 +248,203 @@ static __blocking int do_vosd_test(void)
return(1);
}
+ /********************************************************/
+ printf("reading a single aligned buffer...\n");
+ buffer_offsets[0] = buffer;
+ buffer_szs[0] = 512;
+ obj_offsets[0] = 1024;
+ obj_szs[0] = 512;
+ tret = vosd_read(1, 0, buffer_offsets, buffer_szs, 1, obj_offsets,
+ obj_szs, 1, &out_size);
+ assert(out_size == 512);
+ if(tret != TRITON_SUCCESS)
+ {
+ printf("Error reading aligned buffer\n");
+ free(buffer);
+#if 0
+ triton_error_destroy(tret);
+#endif
+ return(-1);
+ }
+ printf("DONE\n");
+
+ /********************************************************/
+ printf("reading beyond eof...\n");
+ buffer_offsets[0] = buffer;
+ buffer_szs[0] = 512;
+ obj_offsets[0] = 51200;
+ obj_szs[0] = 512;
+ tret = vosd_read(1, 0, buffer_offsets, buffer_szs, 1, obj_offsets,
+ obj_szs, 1, &out_size);
+ if(tret != TRITON_SUCCESS || out_size != 0)
+ {
+ printf("Error: bad error code our out size from EOF read\n");
+ free(buffer);
+#if 0
+ triton_error_destroy(tret);
+#endif
+ return(-1);
+ }
+ printf("DONE\n");
+
+ /********************************************************/
+ printf("reading unaligned data with listio...\n");
+ buffer_offsets[0] = buffer+100;
+ buffer_offsets[1] = buffer+1612;
+ buffer_szs[0] = 1512;
+ buffer_szs[1] = 12;
+ obj_offsets[0] = 13;
+ obj_szs[0] = 1524;
+ tret = vosd_read(1, 0, buffer_offsets, buffer_szs, 2, obj_offsets,
+ obj_szs, 1, &out_size);
+ if(tret != TRITON_SUCCESS)
+ {
+ printf("Error: could not read unaligned buffers: %d\n", ret);
+ free(buffer);
+#if 0
+ triton_error_destroy(tret);
+#endif
+ return(-1);
+ }
+ assert(out_size == 1524);
+ printf("DONE\n");
+
+ /********************************************************/
+ printf("opening txn...\n");
+ tret = vosd_txn_open(1, 0, (++version));
+ if(tret != TRITON_SUCCESS)
+ {
+ printf("Error opening txn 1: %d\n", ret);
+ free(buffer);
+#if 0
+ triton_error_destroy(tret);
+#endif
+ return 1;
+ }
+ printf("DONE\n");
+
+ printf("writing 10024-10037...\n");
+ buffer_offsets[0] = buffer;
+ buffer_szs[0] = 13;
+ sprintf(buffer, "Hello world.");
+ obj_offsets[0] = 10024;
+ obj_szs[0] = 13;
+ tret = vosd_write(1, 0, (version), buffer_offsets, buffer_szs, 1,
+ obj_offsets, obj_szs, 1, 0);
+ if(tret != TRITON_SUCCESS)
+ {
+ printf("Error writing 10024-10037: %d\n", ret);
+ free(buffer);
+#if 0
+ triton_error_destroy(tret);
+#endif
+ return 1;
+ }
+ printf("DONE\n");
+
+ printf("closing txn...\n");
+ tret = vosd_txn_close(1, 0, (version));
+ if(tret != TRITON_SUCCESS)
+ {
+ printf("Error closing txn: %d\n", ret);
+ free(buffer);
+#if 0
+ triton_error_destroy(tret);
+#endif
+ return 1;
+ }
+ printf("DONE\n");
+
+ tret = vosd_dump();
+ assert(tret == TRITON_SUCCESS);
+
+ /********************************************************/
+ printf("reading with a hole...\n");
+ buffer_offsets[0] = buffer;
+ buffer_szs[0] = 512;
+ obj_offsets[0] = 9525;
+ obj_szs[0] = 512;
+ tret = vosd_read(1, 0, buffer_offsets, buffer_szs, 1, obj_offsets,
+ obj_szs, 1, &out_size);
+ if(tret != TRITON_SUCCESS)
+ {
+ printf("Error on read with hole: %d\n", ret);
+ free(buffer);
+#if 0
+ triton_error_destroy(tret);
+#endif
+ return(-1);
+ }
+ assert(out_size == 512);
+ printf("DONE\n");
+
+ /* confirm buffer contents */
+ for(i=0; i<499; i++)
+ assert(buffer[i] = '0');
+
+ printf("buffer: %s\n", &buffer[499]);
+
+ /********************************************************/
+ printf("writing to two forks...\n");
+ tret = vosd_txn_open(1, 1, (++version));
+ assert(tret == TRITON_SUCCESS);
+
+ buffer_offsets[0] = buffer;
+ buffer_szs[0] = 6;
+ sprintf(buffer, "fork1");
+ obj_offsets[0] = 0;
+ obj_szs[0] = 6;
+ tret = vosd_write(1, 1, (version), buffer_offsets, buffer_szs, 1,
+ obj_offsets, obj_szs, 1, 0);
+ assert(tret == TRITON_SUCCESS);
+
+ tret = vosd_txn_close(1, 1, (version));
+ assert(tret == TRITON_SUCCESS);
+
+ tret = vosd_txn_open(1, 2, (++version));
+ assert(tret == TRITON_SUCCESS);
+
+ buffer_offsets[0] = buffer;
+ buffer_szs[0] = 6;
+ sprintf(buffer, "fork2");
+ obj_offsets[0] = 0;
+ obj_szs[0] = 6;
+ tret = vosd_write(1, 2, (version), buffer_offsets, buffer_szs, 1,
+ obj_offsets, obj_szs, 1, 0);
+ assert(tret == TRITON_SUCCESS);
+
+ tret = vosd_txn_close(1, 2, (version));
+ assert(tret == TRITON_SUCCESS);
+
+ printf("DONE\n");
+ printf("reading from first fork...\n");
+
+ buffer_offsets[0] = buffer;
+ buffer_szs[0] = 512;
+ obj_offsets[0] = 0;
+ obj_szs[0] = 512;
+ tret = vosd_read(1, 1, buffer_offsets, buffer_szs, 1, obj_offsets,
+ obj_szs, 1, &out_size);
+ assert(tret == TRITON_SUCCESS && out_size == 6);
+
+ printf("DONE\n");
+ printf("reading from second fork...\n");
+
+ buffer_offsets[0] = &buffer[256];
+ buffer_szs[0] = 256;
+ obj_offsets[0] = 0;
+ obj_szs[0] = 256;
+ tret = vosd_read(1, 2, buffer_offsets, buffer_szs, 1, obj_offsets,
+ obj_szs, 1, &out_size);
+ assert(tret == TRITON_SUCCESS && out_size == 6);
+
+ printf("buffer from fork 1: %s, buffer from fork 2: %s\n",
+ buffer, &buffer[256]);
+
+ printf("DONE\n");
+
+ tret = vosd_dump();
+ assert(tret == TRITON_SUCCESS);
return 1;
}
diff --git a/code/src/versioned-osd/prototype/versioned-osd.ae b/code/src/versioned-osd/prototype/versioned-osd.ae
index 4b96584..91c567f 100644
--- a/code/src/versioned-osd/prototype/versioned-osd.ae
+++ b/code/src/versioned-osd/prototype/versioned-osd.ae
@@ -610,13 +610,15 @@ static __blocking triton_ret_t read_segment(
struct logical_map_key lmk;
triton_ret_t tret;
struct fd_cache_entry* fd_entry;
-
- /* get a file descriptor */
- tret = fd_cache_get(&fd_entry, oid);
- if(tret != TRITON_SUCCESS)
- {
- return(tret);
- }
+ int64_t pread_ret = -1;
+ int64_t scratch_offset;
+ char* copy_ptr = NULL;
+ int copy_remaining = 0;
+ int copy_amt = 0;
+ int scratch_buffer_size = 0;
+ int ret;
+ void* scratch_buffer = NULL;
+ int scratch_size = 0;
/* look for logical mapping for the object offset we need to access */
lmk.oid = oid;
@@ -631,7 +633,6 @@ static __blocking triton_ret_t read_segment(
tret = get_read_region(&lmk, &lme);
if(tret != TRITON_SUCCESS)
{
- fd_cache_put(fd_entry);
return(tret);
}
@@ -655,10 +656,100 @@ static __blocking triton_ret_t read_segment(
return(TRITON_SUCCESS);
}
- /* TODO: pick up here */
-
+ /* Modify lme to reflect what we actually want to read rather than
+ * the entire extent
+ */
+ if(lme.logical_offset < obj_offset)
+ {
+ /* chop off begining of logical map entry */
+ int64_t diff = obj_offset - lme.logical_offset;
+ lme.size -= diff;
+ lme.logical_offset += diff;
+ lme.log_offset += diff;
+ }
+ if(lme.size > obj_size)
+ {
+ /* chop off end of logical map entry */
+ int64_t diff = lme.size - obj_size;
+ lme.size -= diff;
+ lme.logical_offset_end -= diff;
+ }
+ if(lme.size > mem_size)
+ {
+ /* chop off end of logical map entry */
+ int64_t diff = lme.size - mem_size;
+ lme.size -= diff;
+ lme.logical_offset_end -= diff;
+ }
+
+ /* get a file descriptor so we can actually read something */
+ tret = fd_cache_get(&fd_entry, oid);
+ if(tret != TRITON_SUCCESS)
+ {
+ return(tret);
+ }
- return(TRITON_ERR_NOSYS);
+ /* read straight to a memory buffer if everything is aligned */
+ if(lme.log_offset % DIRECT_ALIGN == 0 &&
+ lme.size % DIRECT_ALIGN == 0 &&
+ ((unsigned long)mem_offset) % DIRECT_ALIGN == 0)
+ {
+ assert(lme.size > 0);
+ pread_ret = pread(fd_entry->fd, mem_offset,
+ lme.size, lme.log_offset);
+ if(pread_ret < 0)
+ {
+ tret = triton_ret_from_bdb(errno);
+ fd_cache_put(fd_entry);
+ return(tret);
+ }
+ *amt_read = pread_ret;
+ fd_cache_put(fd_entry);
+ return(TRITON_SUCCESS);
+ }
+
+ /* If we fall to this point, alignment is out of whack somewhere.
+ * Use a scratch buffer
+ */
+ scratch_buffer_size = (((lme.size / DIRECT_ALIGN + 2) * DIRECT_ALIGN));
+ assert(scratch_buffer_size > 0);
+ ret = posix_memalign(&scratch_buffer, DIRECT_ALIGN, scratch_buffer_size);
+ if(ret != 0)
+ {
+ tret = triton_ret_from_bdb(ret);
+ fd_cache_put(fd_entry);
+ return(tret);
+ }
+
+ /* round offset down to nearest alignment boundary */
+ scratch_offset = (lme.log_offset/DIRECT_ALIGN) * DIRECT_ALIGN;
+ /* expand size to account for front alignment */
+ scratch_size = lme.size + (lme.log_offset - scratch_offset);
+ /* round size up to next alignment boundary */
+ if(scratch_size % DIRECT_ALIGN)
+ scratch_size = (scratch_size/DIRECT_ALIGN + 1) * DIRECT_ALIGN;
+
+ /* read data */
+ pread_ret = pread(fd_entry->fd, scratch_buffer, scratch_size,
+ scratch_offset);
+ if(pread_ret < 0)
+ {
+ tret = triton_ret_from_bdb(errno);
+ fd_cache_put(fd_entry);
+ free(scratch_buffer);
+ return(tret);
+ }
+
+ /* copy out of scratch buffer */
+ copy_ptr = scratch_buffer;
+ copy_ptr += (lme.log_offset - scratch_offset);
+ memcpy(mem_offset, copy_ptr, lme.size);
+
+ *amt_read = lme.size;
+ fd_cache_put(fd_entry);
+ free(scratch_buffer);
+
+ return(TRITON_SUCCESS);
}
triton_ret_t vosd_init(const char* path)
@@ -1411,6 +1502,10 @@ __blocking triton_ret_t vosd_read(
/* TODO: safety check that total mem size equals total obj size */
/* TODO: safety check no zero buffers in either list */
+ /* Reads could be optimized and/or made more coherent by treating all of
+ * the segments as one atomic unit. Not bothering right now unless we
+ * find a need for it.
+ */
while(!done)
{
/* try to read one piece */
hooks/post-receive
--
Triton Repository
1
0
Triton Repository branch, master, updated. 2e6c4841ce062739de191721e7a85aebcd65d7aa
by noreply@mcs.anl.gov 28 Apr '10
by noreply@mcs.anl.gov 28 Apr '10
28 Apr '10
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Triton Repository".
The branch, master has been updated
via 2e6c4841ce062739de191721e7a85aebcd65d7aa (commit)
via d0177bc24a22e8b823925d2dda7735bd477beff3 (commit)
from f3855cfbc4fe3fc1d69c6346303dc207bb995ade (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 2e6c4841ce062739de191721e7a85aebcd65d7aa
Author: Phil Carns <carns(a)mcs.anl.gov>
Date: Wed Apr 28 11:14:53 2010 -0400
partial progress on vosd_read()
commit d0177bc24a22e8b823925d2dda7735bd477beff3
Author: Phil Carns <carns(a)mcs.anl.gov>
Date: Wed Apr 28 09:42:34 2010 -0400
disable fakess build if mpi not present
-----------------------------------------------------------------------
Summary of changes:
code/src/fakess/module.mk.in | 4 +
code/src/versioned-osd/prototype/versioned-osd.ae | 206 +++++++++++++++++++-
code/src/versioned-osd/prototype/versioned-osd.hae | 2 +-
3 files changed, 207 insertions(+), 5 deletions(-)
Diff of changes:
diff --git a/code/src/fakess/module.mk.in b/code/src/fakess/module.mk.in
index 8032547..e9c8cc8 100644
--- a/code/src/fakess/module.mk.in
+++ b/code/src/fakess/module.mk.in
@@ -1,8 +1,12 @@
DIR := src/fakess
+ifneq (,$(BUILD_MPI))
+
AELIBSRC += $(DIR)/fakess.ae
MODCFLAGS_$(DIR)/fakess = $(MPICFLAGS)
MODLDFLAGS_$(DIR)/fakess = $(MPILDFLAGS)
MODLIBS_$(DIR)/fakess = $(MPILIBS)
MODCC_$(DIR)/fakess = $(MPICC)
+
+endif # BUILD_MPI
diff --git a/code/src/versioned-osd/prototype/versioned-osd.ae b/code/src/versioned-osd/prototype/versioned-osd.ae
index c25789a..4b96584 100644
--- a/code/src/versioned-osd/prototype/versioned-osd.ae
+++ b/code/src/versioned-osd/prototype/versioned-osd.ae
@@ -317,7 +317,7 @@ static __blocking triton_ret_t __vosd_txn_close_retryable(
int64_t missing_ver;
DBT mv_key, mv_value;
struct missing_version mv;
- void* free_ptr;
+ void* free_ptr = NULL;
DBC *dbc_p = NULL;
struct logical_map_key lmk;
triton_ret_t tret;
@@ -387,7 +387,6 @@ static __blocking triton_ret_t __vosd_txn_close_retryable(
if(tret != TRITON_SUCCESS)
{
free_logical_map_list(&on_disk_entries);
- free(free_ptr);
tret_tmp = bdb_txn_abort(txn);
#if 0
triton_err_destroy(tret_tmp);
@@ -506,6 +505,162 @@ static __blocking triton_ret_t __vosd_txn_close_retryable(
return(tret);
}
+
+#if 0
+static __blocking triton_ret_t __get_read_region_retryable(
+ struct logical_map_key* lmk, struct logical_map_entry* lme)
+#endif
+
+static __blocking triton_ret_t __get_read_region_retryable(
+ struct logical_map_key* lmk, struct logical_map_entry* lme)
+{
+ DB_TXN *txn;
+ DBT key, value;
+ triton_ret_t tret;
+ triton_ret_t tret_tmp;
+ DBC *dbc_p = NULL;
+
+ tret = bdb_txn_begin(envp, NULL, &txn, 0);
+ if(tret != TRITON_SUCCESS)
+ {
+ return(tret);
+ }
+
+ /* create a cursor to move through logical map db */
+ tret = bdb_cursor(log_map_dbp, txn, &dbc_p, 0);
+ if(tret != TRITON_SUCCESS)
+ {
+ tret_tmp = bdb_txn_abort(txn);
+#if 0
+ triton_err_destroy(tret_tmp);
+#endif
+ return(tret);
+ }
+ VOSD_INIT_DBT(key, (*lmk));
+ VOSD_INIT_DBT(value, (*lme));
+
+ tret = bdb_cursor_get(dbc_p, &key, &value, DB_SET_RANGE);
+ /* return whatever error code we got here */
+
+ tret_tmp = bdb_cursor_close(dbc_p);
+#if 0
+ triton_err_destroy(tret_tmp);
+#endif
+ tret_tmp = bdb_txn_commit(txn, 0);
+#if 0
+ triton_err_destroy(tret_tmp);
+#endif
+
+ return(tret);
+}
+
+#if 0
+static __blocking triton_ret_t get_read_region(
+ struct logical_map_key* lmk, struct logical_map_entry* lme)
+#endif
+
+static __blocking triton_ret_t get_read_region(
+ struct logical_map_key* lmk, struct logical_map_entry* lme)
+{
+ struct logical_map_key lmk_orig = *lmk;
+ triton_ret_t tret;
+
+ for(tret = TRITON_ERR_DEADLOCK; tret == TRITON_ERR_DEADLOCK; )
+ {
+#if 0
+ triton_error_destroy(tret);
+#endif
+ *lmk = lmk_orig;
+ tret = __get_read_region_retryable(lmk, lme);
+ }
+
+ if(tret == TRITON_SUCCESS &&
+ (lmk->oid != lmk_orig.oid || lmk->fork != lmk_orig.fork))
+ {
+ /* We overshot the object that we were looking for (EOF, in other
+ * words). Return NOENT to caller.
+ */
+ return(TRITON_ERR_NOENT);
+ }
+
+ return(tret);
+}
+
+#if 0
+static __blocking triton_ret_t read_segment(
+ uint64_t oid,
+ uint64_t fork,
+ char* mem_offset,
+ int64_t mem_size,
+ int64_t obj_offset,
+ int64_t obj_size,
+ int64_t *amt_read);
+#endif
+
+static __blocking triton_ret_t read_segment(
+ uint64_t oid,
+ uint64_t fork,
+ char* mem_offset,
+ int64_t mem_size,
+ int64_t obj_offset,
+ int64_t obj_size,
+ int64_t *amt_read)
+{
+ struct logical_map_entry lme;
+ struct logical_map_key lmk;
+ triton_ret_t tret;
+ struct fd_cache_entry* fd_entry;
+
+ /* get a file descriptor */
+ tret = fd_cache_get(&fd_entry, oid);
+ if(tret != TRITON_SUCCESS)
+ {
+ return(tret);
+ }
+
+ /* look for logical mapping for the object offset we need to access */
+ lmk.oid = oid;
+ lmk.fork = fork;
+ lmk.logical_offset_end = obj_offset + 1;
+
+ /* look for logical mapping for the object offset we need to access */
+ /* NOTE: reads do not have to be atomic. It is possible (and legal
+ * in our semantics) for each region to see a different logical view
+ * if concurrent writes are modifying the log
+ */
+ tret = get_read_region(&lmk, &lme);
+ if(tret != TRITON_SUCCESS)
+ {
+ fd_cache_put(fd_entry);
+ return(tret);
+ }
+
+ if(lme.logical_offset > obj_offset)
+ {
+ /* hit a "hole" in the object, no data in this extent yet */
+ int64_t amt_to_zero;
+
+ /* figure out how big the hole is (in object) */
+ if(obj_size > (lme.logical_offset - obj_offset))
+ amt_to_zero = lme.logical_offset - obj_offset;
+ else
+ amt_to_zero = obj_size;
+
+ /* how big is the memory segment we are working on? */
+ if(mem_size < amt_to_zero)
+ amt_to_zero = mem_size;
+
+ memset(mem_offset, 0, amt_to_zero);
+ *amt_read = amt_to_zero;
+ return(TRITON_SUCCESS);
+ }
+
+ /* TODO: pick up here */
+
+
+ return(TRITON_ERR_NOSYS);
+}
+
triton_ret_t vosd_init(const char* path)
{
triton_ret_t tret;
@@ -1234,7 +1389,7 @@ __blocking triton_ret_t vosd_txn_close(
}
-__blocking triton_ret_t gs_cosd_read(
+__blocking triton_ret_t vosd_read(
uint64_t oid,
uint64_t fork,
char** mem_offsets,
@@ -1245,8 +1400,51 @@ __blocking triton_ret_t gs_cosd_read(
int obj_count,
int64_t* out_size)
{
+ triton_ret_t tret;
+ int done = 0;
+ int64_t amt_read = 0;
+ int mem_index = 0;
+ int obj_index = 0;
+
+ *out_size = 0;
- return(TRITON_ERR_NOSYS);
+ /* TODO: safety check that total mem size equals total obj size */
+ /* TODO: safety check no zero buffers in either list */
+
+ while(!done)
+ {
+ /* try to read one piece */
+ tret = read_segment(oid, fork, mem_offsets[mem_index],
+ mem_sizes[mem_index], obj_offsets[obj_index], obj_sizes[obj_index],
+ &amt_read);
+ if(tret == TRITON_ERR_NOENT)
+ {
+ /* hit eof, return success with what we have so far (short read) */
+#if 0
+ triton_err_destroy(tret);
+#endif
+ return(TRITON_SUCCESS);
+ }
+ if(tret != TRITON_SUCCESS)
+ {
+ return(tret);
+ }
+
+ /* move to next segment */
+ done = advance_listio_ptrs(
+ mem_offsets,
+ mem_sizes,
+ mem_count,
+ &mem_index,
+ obj_offsets,
+ obj_sizes,
+ obj_count,
+ &obj_index,
+ amt_read);
+ *out_size += amt_read;
+ }
+
+ return(TRITON_SUCCESS);
}
diff --git a/code/src/versioned-osd/prototype/versioned-osd.hae b/code/src/versioned-osd/prototype/versioned-osd.hae
index d43c3f0..39dd7d0 100644
--- a/code/src/versioned-osd/prototype/versioned-osd.hae
+++ b/code/src/versioned-osd/prototype/versioned-osd.hae
@@ -94,7 +94,7 @@ __blocking triton_ret_t vosd_txn_close(
/**
* Reads data from an object
*/
-__blocking triton_ret_t gs_cosd_read(
+__blocking triton_ret_t vosd_read(
uint64_t oid, /**< object to operate on */
uint64_t fork, /**< object fork to operate on */
char** mem_offsets, /**< memory region pointers */
hooks/post-receive
--
Triton Repository
1
0
Triton Repository branch, master, updated. f3855cfbc4fe3fc1d69c6346303dc207bb995ade
by noreply@mcs.anl.gov 27 Apr '10
by noreply@mcs.anl.gov 27 Apr '10
27 Apr '10
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Triton Repository".
The branch, master has been updated
via f3855cfbc4fe3fc1d69c6346303dc207bb995ade (commit)
from e79e9f11bdbd404898659e2a5fbbe7d33a94c6f2 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit f3855cfbc4fe3fc1d69c6346303dc207bb995ade
Author: Seung Woo Son <sson(a)bblogin.mcs.anl.gov>
Date: Tue Apr 27 10:13:24 2010 -0500
fixes for old wikis
-----------------------------------------------------------------------
Summary of changes:
sim/gobs/About.txt | 2 +-
sim/gobs/src/gobs/sim/ParallelRUSH.java | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
Diff of changes:
diff --git a/sim/gobs/About.txt b/sim/gobs/About.txt
index f76285a..56ff152 100644
--- a/sim/gobs/About.txt
+++ b/sim/gobs/About.txt
@@ -1,4 +1,4 @@
See the wiki for up-to-date usage information:
-http://wiki.mcs.anl.gov/radix/grayskull/index.php/GOBS_Simulator
+http://wiki.mcs.anl.gov/radix/triton/index.php/GOBS_Simulator
diff --git a/sim/gobs/src/gobs/sim/ParallelRUSH.java b/sim/gobs/src/gobs/sim/ParallelRUSH.java
index abfbfad..2679a09 100644
--- a/sim/gobs/src/gobs/sim/ParallelRUSH.java
+++ b/sim/gobs/src/gobs/sim/ParallelRUSH.java
@@ -112,7 +112,7 @@ public class ParallelRUSH
}
/**
- <a href="http://wiki.mcs.anl.gov/radix/grayskull/index.php/Stripe_placement_and_rebu…">From the wiki.</a>
+ <a href="http://wiki.mcs.anl.gov/radix/triton/index.php/Stripe_placement_and_rebuild…">From the wiki.</a>
@param x The object id (key).
@param i The strip number
hooks/post-receive
--
Triton Repository
1
0
Triton Repository branch, master, updated. e79e9f11bdbd404898659e2a5fbbe7d33a94c6f2
by noreply@mcs.anl.gov 26 Apr '10
by noreply@mcs.anl.gov 26 Apr '10
26 Apr '10
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Triton Repository".
The branch, master has been updated
via e79e9f11bdbd404898659e2a5fbbe7d33a94c6f2 (commit)
via e4f2329705e10ba0460dce052c2ef2716537403c (commit)
via d0f4447e73c367821d7fca6bff0ab73c3fea457e (commit)
from 62218dc0feba70252ae2dbdfb4c07238100f90d8 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit e79e9f11bdbd404898659e2a5fbbe7d33a94c6f2
Author: Justin Wozniak <wozniak(a)mcs.anl.gov>
Date: Mon Apr 26 16:58:21 2010 -0500
First fakess use of MPI.
commit e4f2329705e10ba0460dce052c2ef2716537403c
Author: Justin Wozniak <wozniak(a)mcs.anl.gov>
Date: Sun Apr 25 21:58:37 2010 -0500
Better fakess data structures.
commit d0f4447e73c367821d7fca6bff0ab73c3fea457e
Author: Justin Wozniak <wozniak(a)mcs.anl.gov>
Date: Sun Apr 25 21:38:41 2010 -0500
Support and tests for triton-nodes as keys in hashes
-----------------------------------------------------------------------
Summary of changes:
code/src/common/tests/testhash.c | 51 +++++++++++++++++++++
code/src/common/triton-hash.h | 7 +++
code/src/fakess/fakess.ae | 77 ++++++++++++++++++++++++++++++--
code/src/fakess/fakess.hae | 56 +++++++++++++++++++++---
code/src/fakess/module.mk.in | 5 ++
code/src/fakess/test/fakess01.ae | 6 ++-
code/src/fakess/test/fakess02.ae | 89 +++++++++++++++++++++++++++++++++++++
code/src/fakess/test/module.mk.in | 13 +++++-
8 files changed, 292 insertions(+), 12 deletions(-)
create mode 100644 code/src/fakess/test/fakess02.ae
Diff of changes:
diff --git a/code/src/common/tests/testhash.c b/code/src/common/tests/testhash.c
index 6a0d078..607cd54 100644
--- a/code/src/common/tests/testhash.c
+++ b/code/src/common/tests/testhash.c
@@ -1,9 +1,12 @@
#include <stdlib.h>
+
#include "src/common/triton-list.h"
#include "src/common/triton-hash.h"
#include "src/common/triton-string.h"
+#include "src/net/triton-node.h"
+
struct e
{
int v;
@@ -16,6 +19,12 @@ struct s
triton_list_link_t link;
};
+struct n
+{
+ triton_node_t *node;
+ triton_list_link_t link;
+};
+
int e_compare(void *key, struct triton_hash_link *link)
{
int *value1 = (int *)key;
@@ -36,15 +45,30 @@ int s_compare(void *key, struct triton_hash_link *link)
return (!strcmp(value2->v->string, value1->string));
}
+int n_compare(void *key, struct triton_hash_link *link)
+{
+ triton_node_t *value1 = (triton_node_t *)key;
+ struct n *value2 = triton_hash_get_entry(link, struct n, link);
+ assert(key);
+ assert(link);
+
+ return (value2->node->l == value1->l &&
+ value2->node->u == value1->u);
+}
+
void e_destroy(struct e *entry)
{}
+void s_destroy(struct s *entry)
+{}
+
int main(int argc, char *argv[])
{
struct triton_hash_table *table;
struct e *entry;
struct e *es;
struct s *ss;
+ struct n *ns;
struct triton_hash_link *result;
int i, j, testsize, hash;
triton_string_t *string;
@@ -113,12 +137,39 @@ int main(int argc, char *argv[])
string = malloc(sizeof(triton_string_t));
triton_string_init(string, "[%i]", i);
result = triton_hash_search(table, string);
+ assert(result != NULL);
ss = triton_hash_get_entry(result, struct s, link);
sscanf(ss->v->string, "[%i]", &j);
assert(i == j);
free(string);
}
+ triton_hash_destroy_and_finalize(table, struct s, link, s_destroy);
+
+ table = triton_hash_init(n_compare, triton_hash_128bit_hash, 23);
+
+ for(i = 0; i < 3; ++i)
+ {
+ ns = malloc(sizeof(*ns));
+ ns->node = malloc(sizeof(triton_node_t));
+ ns->node->l = i*i;
+ ns->node->u = i+i;
+ triton_hash_add(table, ns->node, &(ns->link));
+ }
+
+ for(i = 0; i < 3; ++i)
+ {
+ triton_node_t node;
+ node.l = i*i;
+ node.u = i+i;
+ result = triton_hash_search(table, &node);
+ assert(result != NULL);
+ ns = triton_hash_get_entry(result, struct n, link);
+ assert(ns != NULL);
+ assert(ns->node->l == node.l &&
+ ns->node->u == node.u);
+ }
+
free(es);
return 0;
}
diff --git a/code/src/common/triton-hash.h b/code/src/common/triton-hash.h
index aeaa042..fd239a3 100644
--- a/code/src/common/triton-hash.h
+++ b/code/src/common/triton-hash.h
@@ -283,6 +283,13 @@ static inline int triton_hash_64bit_hash(void *k, int table_size)
return (int) (pc & (table_size - 1));
}
+static inline int triton_hash_128bit_hash(void *k, int table_size)
+{
+ uint32_t pc = 0, pb = 0;
+ bj_hashlittle2(k, 16, &pc, &pb);
+ return (int) (pc & (table_size - 1));
+}
+
static inline int triton_hash_strhash(void *k, int table_size)
{
uint32_t pc = 0, pb = 0;
diff --git a/code/src/fakess/fakess.ae b/code/src/fakess/fakess.ae
index c8711c7..3e4b502 100644
--- a/code/src/fakess/fakess.ae
+++ b/code/src/fakess/fakess.ae
@@ -3,20 +3,57 @@
* Triton fake system state
*/
+#include "mpi.h"
+
#include "src/fakess/fakess.hae"
+#include "src/net/mpi/mpi.hae"
struct triton_fakess_s state;
+static int string_compare(void *key, struct triton_hash_link *link)
+{
+ triton_string_t *value1 = (triton_string_t *)key;
+ triton_string_entry *value2 =
+ triton_hash_get_entry(link, triton_string_entry, link);
+ assert(key);
+ assert(link);
+
+ return (!strcmp(value2->string.string, value1->string));
+}
+
+static int node_compare(void *key, struct triton_hash_link *link)
+{
+ triton_node_t *value1 = (triton_node_t *)key;
+ triton_node_entry *value2 =
+ triton_hash_get_entry(link, triton_node_entry, link);
+ assert(key);
+ assert(link);
+
+ return (value2->node.l == value1->l &&
+ value2->node.u == value1->u);
+}
+
__blocking triton_ret_t triton_fakess_init(void)
{
- triton_list_init(&(state.nodes));
+ state.globals = triton_hash_init(string_compare,
+ triton_hash_string_hash,
+ 113);
+ state.nodes = triton_hash_init(node_compare,
+ triton_hash_128bit_hash,
+ 23);
+
+
+ return TRITON_SUCCESS;
+}
+__blocking triton_ret_t triton_fakess_shutdown(void)
+{
return TRITON_SUCCESS;
}
-__blocking triton_ret_t triton_fakess_count(int *count)
+__blocking triton_ret_t triton_fakess_node_count(int *count)
{
- *count = triton_list_count(&(state.nodes));
+ *count = state.nodes->table_count;
return TRITON_SUCCESS;
}
@@ -27,7 +64,39 @@ __blocking triton_ret_t triton_fakess_add(triton_node_t *node)
return TRITON_SUCCESS;
}
-__blocking triton_ret_t triton_fakess_shutdown(void)
+__blocking triton_ret_t triton_fakess_post_global(triton_string_t *key,
+ triton_string_t *value)
+{
+ int i,rank,nodes;
+ int length;
+ char *buffer;
+ int error;
+
+ buffer = malloc(TRITON_FAKESS_MESSAGE);
+ length = sprintf(buffer, "GLOBAL: %s %s",
+ key->string, value->string);
+ printf("triton_fakess_post_global: %s\n", buffer);
+
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+ MPI_Comm_size(MPI_COMM_WORLD, &nodes);
+ for(i = 0; i < nodes; i++)
+ {
+ if(i != rank)
+ {
+ printf("send to: %i %i\n", i, length);
+ error = triton_mpi_send(buffer, length+1, MPI_CHAR, i,
+ TRITON_TAG_FAKESS, MPI_COMM_WORLD);
+ printf("sent\n");
+ if(error != 0)
+ {
+ return TRITON_ERR_MPI;
+ }
+ }
+ }
+ return TRITON_SUCCESS;
+}
+
+__blocking triton_ret_t triton_fakess_recv(void)
{
return TRITON_SUCCESS;
}
diff --git a/code/src/fakess/fakess.hae b/code/src/fakess/fakess.hae
index 7296c3d..adafef8 100644
--- a/code/src/fakess/fakess.hae
+++ b/code/src/fakess/fakess.hae
@@ -3,19 +3,63 @@
#include "src/aesop/aesop.h"
#include "src/common/triton-debug.h"
+#include "src/common/triton-hash.h"
#include "src/common/triton-list.h"
+#include "src/net/triton-node.h"
+
+// Must come up with a Triton tag mechanism
+#define TRITON_TAG_FAKESS 47
+
+#define TRITON_FAKESS_MESSAGE 1024
+
+typedef struct
+{
+ triton_node_t node;
+ struct triton_hash_link *link;
+} triton_node_entry;
+
+typedef struct
+{
+ triton_string_t string;
+ struct triton_hash_link *link;
+} triton_string_entry;
+
+typedef struct triton_hash_table triton_state_table;
+
struct triton_fakess_s
{
- /**
- List of triton-nodes.
- */
- triton_list_t nodes;
+ triton_state_table *globals;
+
+ /**
+ Map from triton-nodes to state_tables
+ */
+ struct triton_hash_table *nodes;
};
+// Setup/shutdown...
__blocking triton_ret_t triton_fakess_init(void);
-__blocking triton_ret_t triton_fakess_count(int *count);
-__blocking triton_ret_t triton_fakess_add(triton_node_t *node);
__blocking triton_ret_t triton_fakess_shutdown(void);
+// Queries...
+__blocking triton_ret_t triton_fakess_node_count(int *count);
+
+// Updates (respond to posts)...
+__blocking triton_ret_t triton_fakess_recv(void);
+__blocking triton_ret_t triton_fakess_add(triton_node_t *node);
+
+// Posts (change global state)...
+__blocking triton_ret_t triton_fakess_post_global(triton_string_t *key,
+ triton_string_t *value);
+
#endif
+
+/*
+ * Local variables:
+ * c-indent-level: 4
+ * c-basic-offset: 4
+ * End:
+ *
+ * vim: ts=8 sts=4 sw=4 expandtab
+ */
+
diff --git a/code/src/fakess/module.mk.in b/code/src/fakess/module.mk.in
index f525af6..8032547 100644
--- a/code/src/fakess/module.mk.in
+++ b/code/src/fakess/module.mk.in
@@ -1,3 +1,8 @@
DIR := src/fakess
AELIBSRC += $(DIR)/fakess.ae
+
+MODCFLAGS_$(DIR)/fakess = $(MPICFLAGS)
+MODLDFLAGS_$(DIR)/fakess = $(MPILDFLAGS)
+MODLIBS_$(DIR)/fakess = $(MPILIBS)
+MODCC_$(DIR)/fakess = $(MPICC)
diff --git a/code/src/fakess/test/fakess01.ae b/code/src/fakess/test/fakess01.ae
index 93bdfa6..a7ba3fd 100644
--- a/code/src/fakess/test/fakess01.ae
+++ b/code/src/fakess/test/fakess01.ae
@@ -1,4 +1,8 @@
+/**
+ Test init(), count(), shutdown().
+*/
+
#include <stdio.h>
#include "src/aesop/aesop.h"
#include "src/common/resources/timer/timer.hae"
@@ -12,7 +16,7 @@ static __blocking int fakess01(void)
code = triton_fakess_init();
assert(code == TRITON_SUCCESS);
- code = triton_fakess_count(&count);
+ code = triton_fakess_node_count(&count);
assert(code == TRITON_SUCCESS);
assert(count == 0);
diff --git a/code/src/fakess/test/fakess02.ae b/code/src/fakess/test/fakess02.ae
new file mode 100644
index 0000000..f33795c
--- /dev/null
+++ b/code/src/fakess/test/fakess02.ae
@@ -0,0 +1,89 @@
+
+#include <stdio.h>
+#include "src/aesop/aesop.h"
+#include "src/net/mpi/mpi.hae"
+#include "src/fakess/fakess.hae"
+
+static __blocking int send_recv(int numprocs, int rank)
+{
+ char recvbuf[TRITON_FAKESS_MESSAGE];
+ MPI_Status status;
+ int recvsize;
+ int ret;
+ triton_string_t *key;
+ triton_string_t *value;
+
+ if(rank == 0)
+ {
+ key = malloc(sizeof(triton_string_t));
+ value = malloc(sizeof(triton_string_t));
+ triton_string_init(key, "K1");
+ triton_string_init(value, "V1");
+ triton_fakess_post_global(key, value);
+ }
+ else
+ {
+ printf("%d: receiving message from %d\n", rank, 0);
+ ret = triton_mpi_recv(recvbuf, TRITON_FAKESS_MESSAGE, MPI_CHAR, 0,
+ TRITON_TAG_FAKESS, MPI_COMM_WORLD, &status);
+ MPI_Get_count(&status, MPI_CHAR, &recvsize);
+ printf("%d: received message from %d: %.*s\n", rank,
+ 0, recvsize, recvbuf);
+ }
+
+ return 0;
+}
+
+int done = 0;
+
+static void done_callback(void *user_ptr, int ret)
+{
+ done = 1;
+}
+
+int main(int argc, char *argv[])
+{
+ int numprocs, rank;
+ ae_op_id_t op_id;
+ ae_context_t ctx;
+
+#ifdef GDB_WAIT
+ int gdb_wait = 0;
+ pid_t pid;
+#endif
+
+ MPI_Init(&argc, &argv);
+
+ MPI_Comm_size(MPI_COMM_WORLD, &numprocs);
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+
+#ifdef GDB_WAIT
+ pid = getpid();
+ printf("gdb_wait: rank: %i pid: %i\n", rank, pid);
+ if (rank == 0)
+ while (!gdb_wait);
+#endif
+
+ triton_mpi_init();
+
+ ae_context_create(&ctx, 1, "mpi");
+
+ send_recv_post(numprocs, rank, done_callback, NULL, NULL, ctx, &op_id);
+ while (done == 0)
+ {
+ ae_poll(ctx, 10);
+ }
+
+ MPI_Finalize();
+ ae_context_destroy(ctx);
+ triton_mpi_finalize();
+ return 0;
+}
+
+/*
+ * Local Variables:
+ * c-basic-offset: 4
+ * End:
+ *
+ * vim: ft=c ts=8 sts=4 sw=4 expandtab
+ */
diff --git a/code/src/fakess/test/module.mk.in b/code/src/fakess/test/module.mk.in
index 16ccf98..8b4dc91 100644
--- a/code/src/fakess/test/module.mk.in
+++ b/code/src/fakess/test/module.mk.in
@@ -1,3 +1,14 @@
DIR = src/fakess/test
-AETESTSRC += $(DIR)/fakess01.ae
+AETESTSRC += $(DIR)/fakess01.ae
+AETESTSRC += $(DIR)/fakess02.ae
+
+MODCFLAGS_$(DIR)/fakess01 = $(MPICFLAGS)
+MODLDFLAGS_$(DIR)/fakess01 = $(MPILDFLAGS)
+MODLIBS_$(DIR)/fakess01 = $(MPILIBS)
+MODCC_$(DIR)/fakess01 = $(MPICC)
+
+MODCFLAGS_$(DIR)/fakess02 = $(MPICFLAGS)
+MODLDFLAGS_$(DIR)/fakess02 = $(MPILDFLAGS)
+MODLIBS_$(DIR)/fakess02 = $(MPILIBS)
+MODCC_$(DIR)/fakess02 = $(MPICC)
hooks/post-receive
--
Triton Repository
1
0
Triton Repository branch, master, updated. 62218dc0feba70252ae2dbdfb4c07238100f90d8
by noreply@mcs.anl.gov 26 Apr '10
by noreply@mcs.anl.gov 26 Apr '10
26 Apr '10
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Triton Repository".
The branch, master has been updated
via 62218dc0feba70252ae2dbdfb4c07238100f90d8 (commit)
from 662361693c4537a90d3dc0cd9b5aaa08588e6cb2 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 62218dc0feba70252ae2dbdfb4c07238100f90d8
Author: Phil Carns <carns(a)mcs.anl.gov>
Date: Mon Apr 26 10:56:31 2010 -0400
remove stale COSD code
-----------------------------------------------------------------------
Summary of changes:
code/configure | 3 +-
code/configure.ac | 6 -
code/src/cosd/prototype/README | 2 -
code/src/cosd/prototype/cosd-prototype.c | 1994 --------------------
code/src/cosd/prototype/cosd-prototype.hae | 116 --
code/src/cosd/prototype/module.mk.in | 6 -
code/src/cosd/prototype/test/4M-w-serial.txt | 7 -
code/src/cosd/prototype/test/README | 1 -
.../cosd/prototype/test/cosd-bench-concurrent.ae | 235 ---
code/src/cosd/prototype/test/cosd1.ae | 236 ---
code/src/cosd/prototype/test/module.mk.in | 8 -
code/src/cosd/prototype/test/workload-gen.ae | 122 --
12 files changed, 1 insertions(+), 2735 deletions(-)
delete mode 100644 code/src/cosd/prototype/README
delete mode 100644 code/src/cosd/prototype/cosd-prototype.c
delete mode 100644 code/src/cosd/prototype/cosd-prototype.hae
delete mode 100644 code/src/cosd/prototype/module.mk.in
delete mode 100644 code/src/cosd/prototype/test/4M-w-serial.txt
delete mode 100644 code/src/cosd/prototype/test/README
delete mode 100644 code/src/cosd/prototype/test/cosd-bench-concurrent.ae
delete mode 100644 code/src/cosd/prototype/test/cosd1.ae
delete mode 100644 code/src/cosd/prototype/test/module.mk.in
delete mode 100644 code/src/cosd/prototype/test/workload-gen.ae
Diff of changes:
diff --git a/code/configure b/code/configure
index a03c0ff..3030fd1 100755
--- a/code/configure
+++ b/code/configure
@@ -1304,7 +1304,7 @@ Optional Features:
--enable-verbose Enables verbose output during build process
--enable-warnings Do not generate compiler error on warnings (not -Werror)
--enable-strict Turn on strict compiler warnings
- --enable-aesop-debug Turn on debugging of the gs-parser
+ --enable-aesop-debug Turn on debugging of the aesop-parser
--enable-coverage Enable coverage analysis (disables optimizations)
--disable-thread-safety Disables thread safety in the client library
@@ -5115,7 +5115,6 @@ fi
-
ac_config_files="$ac_config_files Makefile src/common/module.mk src/common/tests/module.mk src/common/resources/timer/test/module.mk src/common/resources/timer/module.mk src/common/resources/scheduling/module.mk src/common/resources/scheduling/test/module.mk src/net/module.mk src/net/mpi/module.mk src/net/mpi/test/module.mk src/remote/module.mk src/aesop/module.mk src/aesop/parser/module.mk src/aesop/examples/module.mk src/aesop/parser/tests/remote/module.mk src/aesop/parser/tests/blocking/module.mk src/versioned-osd/prototype/module.mk src/versioned-osd/prototype/tests/module.mk src/versioned-osd/prototype/bdb-resource/module.mk src/versioned-osd/prototype/file-resource/module.mk src/fakess/module.mk src/fakess/test/module.mk"
cat >confcache <<\_ACEOF
diff --git a/code/configure.ac b/code/configure.ac
index e67ed94..0dc22f0 100644
--- a/code/configure.ac
+++ b/code/configure.ac
@@ -135,12 +135,6 @@ AC_SUBST(THREAD_LIB)
TRITON_LIB_SQLITE(3.0.0)
-dnl src/cosd/prototype/test/module.mk
-dnl src/cosd/prototype/module.mk
-dnl src/cosd/storage/osd-target/module.mk
-dnl src/cosd/storage/test/module.mk
-dnl src/cosd/storage/module.mk
-
AC_OUTPUT(Makefile
src/common/module.mk
src/common/tests/module.mk
diff --git a/code/src/cosd/prototype/README b/code/src/cosd/prototype/README
deleted file mode 100644
index 71b5f71..0000000
--- a/code/src/cosd/prototype/README
+++ /dev/null
@@ -1,2 +0,0 @@
-This resource is a prototype of the COSD object layer, intended for use as a
-replication building block.
diff --git a/code/src/cosd/prototype/cosd-prototype.c b/code/src/cosd/prototype/cosd-prototype.c
deleted file mode 100644
index ff7c456..0000000
--- a/code/src/cosd/prototype/cosd-prototype.c
+++ /dev/null
@@ -1,1994 +0,0 @@
-#define _GNU_SOURCE
-#define _XOPEN_SOURCE 600
-
-#include <time.h>
-#include <sys/time.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <unistd.h>
-#include <pthread.h>
-#include <stdio.h>
-#include <limits.h>
-#include <db.h>
-#include <stdlib.h>
-#include "triton-config.h"
-
-/**************************************************************/
-/* TODO: general stuff:
- * - deadlock detection and avoidance
- * - consider non-durable transactions in order to coalesce commits
- * - use txn_checkpoint to flush when coalescing
- * - consider rmw locks where appropriate
- * - long term: consider fallocate hint for logs to keep them linear
- * - try computing cksum along the way, store in db
- * - either in log map itself or db that matches its keys
- */
-/**************************************************************/
-
-/* TODO: this needs to be in a header somewhere */
-#ifndef llu
-#if SIZEOF_LONG_INT == 4
-# define llu(x) (x)
-# define lld(x) (x)
-# define SCANF_lld "%lld"
-#elif SIZEOF_LONG_INT == 8
-# define llu(x) (unsigned long long)(x)
-# define lld(x) (long long)(x)
-# define SCANF_lld "%ld"
-#else
-# error Unexpected sizeof(long int)
-#endif
-#endif
-
-#include "src/aesop/aesop.h"
-#include "src/aesop/op.h"
-#include "src/aesop/opcache.h"
-#include "src/common/triton-hash.h"
-#include "src/cosd/prototype/cosd-prototype.h"
-
-#define STORAGE_DEFAULT_OPCACHE_SIZE 1024
-#define COSD_LOG_SUBDIR "logs"
-#define COSD_MIN(__a, __b) ((__a) < (__b) ? (__a) : (__b))
-#define COSD_MAX(__a, __b) ((__a) > (__b) ? (__a) : (__b))
-/* TODO: find this programmatically? */
-#define DIRECT_ALIGN 512
-#define COSD_INIT_DBT(__dbt, __data) \
- do { \
- memset(&(__dbt), 0, sizeof(__dbt)); \
- (__dbt).data = &(__data); \
- (__dbt).size = sizeof(__data); \
- (__dbt).ulen = sizeof(__data); \
- (__dbt).flags = DB_DBT_USERMEM; \
- }while(0)
-#define COSD_INIT_DBT_EMPTY(__dbt) \
- do { \
- memset(&(__dbt), 0, sizeof(__dbt)); \
- (__dbt).flags = DB_DBT_USERMEM; \
- }while(0)
-
-
-static ae_opcache_t cosd_opcache;
-static ae_ops_t cosd_oplist;
-static triton_mutex_t cosd_mutex = TRITON_MUTEX_INITIALIZER;
-static char* cosd_path = NULL;
-static char* cosd_log_path = NULL;
-static struct triton_hash_table *txn_table = NULL;
-static triton_mutex_t txn_mutex = TRITON_MUTEX_INITIALIZER;
-
-static DB *log_map_dbp = NULL;
-static DB *missing_ver_dbp = NULL;
-static DB *ver_dbp = NULL;
-static DB *log_offset_dbp = NULL;
-DB_ENV *envp = NULL;
-
-/* temporary: a global fd and log offset used to access object */
-static int global_fd = -1;
-static int64_t global_log_offset = -1;
-static triton_mutex_t global_log_mutex = TRITON_MUTEX_INITIALIZER;
-
-static int cosd_resource_id;
-static enum progress_mode triton_cosd_progress_mode = TRITON_PROG_NONE;
-
-static int merge_logical_map(triton_list_t* list1_in, int
- list1_count, triton_list_t* list2_in, int list2_count,
- triton_list_t* list_out, void** free_ptr);
-static int compare_log_map_key(DB * dbp, const DBT * a, const DBT * b);
-static int compare_missing_version(DB * dbp, const DBT * a, const DBT * b);
-static int compare_uint64(DB * dbp, const DBT * a, const DBT * b);
-static int cmp_lme(const void *p1, const void *p2);
-
-/* counter used by poll function in thread-per-op case to know if ops have
- * finished since last poll
- */
-static int completed_counter = 0;
-static triton_mutex_t completed_counter_mutex = TRITON_MUTEX_INITIALIZER;
-static triton_cond_t completed_counter_cond = TRITON_COND_INITIALIZER;
-
-/* uniquely identifies each active txn (in memory) */
-struct txn_accumulator
-{
- /* txn identifier */
- uint64_t txn_number;
- /* list of updates included in this txn */
- triton_list_t update_list;
- int update_list_count;
-
- /* link into hash table of current txns */
- struct triton_hash_link hash_link;
-};
-
-/* db entry representing region in logical map */
-/* indexed via last offset */
-struct logical_map_entry
-{
- int64_t size; /* size of region */
- int64_t logical_offset; /* beginning of logical region */
- int64_t logical_offset_end; /* end of logical region */
- int64_t log_offset; /* offset into log */
- uint64_t version; /* version number */
- struct triton_list_link list_link;
-};
-
-struct logical_map_key
-{
- uint64_t oid;
- int64_t logical_offset_end;
-};
-
-/* represents a missing version number in a particular object */
-struct missing_version
-{
- uint64_t oid;
- uint64_t version;
-};
-
-struct cosd_op
-{
- union {
- struct create_op{
- uint64_t requested_oid;
- uint64_t* out_oid;
- } create;
- struct write_op{
- uint64_t oid;
- uint64_t txn_number;
- char** mem_offsets;
- int64_t* mem_sizes;
- int mem_count;
- int64_t* obj_offsets;
- int64_t* obj_sizes;
- int obj_count;
- } write;
- struct txn_close_op{
- uint64_t oid;
- uint64_t txn_number;
- } txn_close;
- struct get_version_op{
- uint64_t oid;
- uint64_t *version;
- } get_version;
-#if 0
- struct remove_op{
- uint64_t oid;
- } remove;
- struct setattr_list_op{
- uint64_t oid;
- int count;
- const uint32_t* page_array;
- const uint32_t* number_array;
- const void** val_array;
- const int* len_array;
- } setattr_list;
- struct getattr_list_op{
- uint64_t oid;
- int count;
- const uint32_t* page_array;
- const uint32_t* number_array;
- void** val_array;
- int* len_array;
- } getattr_list;
-#endif
- } u;
- ae_op_id_t op_id;
- struct ae_op op;
- int error_code;
- void (*cleanup_fn)(struct cosd_op* c_op);
-};
-
-static void* thread_fn(void* foo)
-{
- struct ae_op* op = foo;
- struct cosd_op* c_op = ae_op_entry(op, struct cosd_op, op);
-
- triton_mutex_lock(&cosd_mutex);
- /* pull off of list */
- ae_ops_del(op);
- triton_mutex_unlock(&cosd_mutex);
-
- /* spin on op worker */
- while(op->op_worker(op) != 1);
-
- /* call cleanup function if present */
- if(c_op->cleanup_fn)
- {
- c_op->cleanup_fn(c_op);
- }
-
- /* trigger completion of the operation */
- ae_opcache_complete_op(cosd_opcache, op, c_op->error_code);
-
- /* wake up any pollers */
- triton_mutex_lock(&completed_counter_mutex);
- completed_counter++;
- triton_cond_signal(&completed_counter_cond);
- triton_mutex_unlock(&completed_counter_mutex);
-
- return(NULL);
-}
-
-static int txn_acc_compare(void *key, struct triton_hash_link *hash_link)
-{
- struct txn_accumulator *txn_acc;
-
- txn_acc = triton_hash_get_entry(hash_link, struct txn_accumulator, hash_link);
- return(*((uint64_t*)key) == txn_acc->txn_number);
-}
-
-static int triton_cosd_launch_op(struct ae_op *op, enum progress_mode mode)
-{
- int ret;
- pthread_t tid;
- pthread_attr_t attr;
-
- switch(mode)
- {
- case TRITON_PROG_POLL:
- triton_mutex_lock(&cosd_mutex);
- ae_ops_enqueue(op, &cosd_oplist);
- triton_mutex_unlock(&cosd_mutex);
- break;
- case TRITON_PROG_THREAD_PER_OP:
- /* TODO: make this better. Right now its a free for all */
-
- /* put on the queue */
- triton_mutex_lock(&cosd_mutex);
- ae_ops_enqueue(op, &cosd_oplist);
- triton_mutex_unlock(&cosd_mutex);
-
- /* launch a thread to do the work */
- /* TODO: error handling */
- ret = pthread_attr_init(&attr);
- assert(ret == 0);
- ret = pthread_attr_setdetachstate(&attr,
- PTHREAD_CREATE_DETACHED);
- assert(ret == 0);
- /* TODO: store tid in op (to help with cancelling or joining?) */
- ret = pthread_create(&tid, &attr, thread_fn, op);
- assert(ret == 0);
- pthread_attr_destroy(&attr);
-
- break;
- case TRITON_PROG_NONE:
- return(-EINVAL);
- break;
- case TRITON_PROG_THREAD_POOL:
- /* TODO: alert the thread pool etc. */
- /* TODO: gossip... */
- triton_mutex_lock(&cosd_mutex);
- ae_ops_enqueue(op, &cosd_oplist);
- triton_mutex_unlock(&cosd_mutex);
- return(-EINVAL);
- break;
- case TRITON_PROG_MAX:
- break;
- }
-
- return(0);
-}
-
-/* triton_cosd_poll_thread_per_op()
- *
- * poll function in the thread-per-op mode that doesn't do anything except
- * make sure that triton_poll wakes up if operations complete.
- */
-static int triton_cosd_poll_thread_per_op(ae_context_t context, int millisecs)
-{
- struct timespec abstime;
- struct timeval start;
- int ret;
-
- if(millisecs > 0)
- {
- ret = gettimeofday(&start, NULL);
- if (ret < 0)
- return (0);
-
- abstime.tv_sec = start.tv_sec + millisecs / 1000;
- abstime.tv_nsec = (start.tv_usec + ((millisecs % 1000)*1000))*1000;
- if (abstime.tv_nsec > 1000000000)
- {
- abstime.tv_nsec = abstime.tv_nsec - 1000000000;
- abstime.tv_sec++;
- }
- }
-
- triton_mutex_lock(&completed_counter_mutex);
- ret = 0;
- while(completed_counter == 0 && ret == 0)
- {
- if(millisecs > 0)
- {
- ret = triton_cond_timedwait(&completed_counter_cond,
- &completed_counter_mutex, &abstime);
- }
- else
- {
- ret = ETIMEDOUT;
- }
- }
- completed_counter = 0; /* reset for next poller */
- triton_mutex_unlock(&completed_counter_mutex);
-
- return(0);
-}
-
-static int triton_cosd_poll(ae_context_t context, int millisecs)
-{
- struct ae_op *gop;
- struct cosd_op *c_op;
- struct timespec ts_sleep;
- int ret;
-
- /* NOTE: just servicing one op per call right now */
-
- /* NOTE: poll doesn't need locking, because it is not used in the
- * threaded modes
- */
-
- /* triton_mutex_lock(&cosd_mutex); */
-
- /* TODO: decouple locking for op list from servicing of operations so
- * that multithreaded apps can post while servicing happens
- * simultaneously
- */
- gop = ae_ops_dequeue(&cosd_oplist);
- if(!gop)
- {
- /* sleep */
- /* TODO: this needs to be something that can be interrupted if
- * something is posted
- */
- ts_sleep.tv_sec = (int)(millisecs / 1e3);
- ts_sleep.tv_nsec = (millisecs % 1000) * 1e6;
- nanosleep(&ts_sleep, NULL);
- /* triton_mutex_unlock(&cosd_mutex); */
- return(0);
- }
-
- c_op = ae_op_entry(gop, struct cosd_op, op);
-
- ret = gop->op_worker(gop);
- if(ret == 1)
- {
- /* call cleanup function if present */
- if(c_op->cleanup_fn)
- {
- c_op->cleanup_fn(c_op);
- }
-
- /* done */
- ae_opcache_complete_op(cosd_opcache, gop, c_op->error_code);
- }
- else
- {
- assert(ret == 0); /* only 0 and 1 allowed? */
- /* not done */
- ae_ops_enqueue(gop, &cosd_oplist);
- }
-
- /* triton_mutex_unlock(&cosd_mutex); */
-
- return 0;
-}
-
-/* TODO: does this have to handle the case of the op already having
- * disappeared, or does the aesop engine protect against that?
- */
-static int triton_cosd_cancel(ae_context_t ctx, ae_op_id_t op_id)
-{
- int cache_id, resource_id;
- triton_mutex_lock(&cosd_mutex);
- struct ae_op *op;
- struct cosd_op *c_op;
-
- cache_id = triton_id_lookup(op_id, &resource_id);
- assert(resource_id == cosd_resource_id);
-
- op = ae_opcache_lookup(cosd_opcache, (int)cache_id);
- c_op = ae_op_entry(op, struct cosd_op, op);
-#if 0
- ae_ops_del(op);
- ae_opcache_put(cosd_opcache, op);
-#endif
-
- triton_mutex_unlock(&cosd_mutex);
-
- return 0;
-}
-
-struct triton_resource cosd_resource =
-{
- .resource_name = "cosd",
- .poll_context = triton_cosd_poll,
- .cancel = triton_cosd_cancel
-};
-
-int triton_cosd_init(enum progress_mode mode, const char* path)
-{
- int ret = 0;
- int dir_exists = 0;
- uint32_t env_flags;
- uint32_t open_flags;
-
- /* make a directory for storage if not already present */
- ret = mkdir(path, 0755);
- if(ret != 0 && errno == EEXIST)
- {
- dir_exists = 1;
- }
- else if(ret != 0)
- {
- /* some other error */
- return(ret);
- }
-
- /* store paths */
- /* TODO: free both of these on error */
- cosd_path = strdup(path);
- if(!cosd_path)
- return(-errno);
- cosd_log_path = malloc(strlen(path)+strlen(COSD_LOG_SUBDIR)+2);
- if(!cosd_log_path)
- return(-errno);
- sprintf(cosd_log_path, "%s/%s", path, COSD_LOG_SUBDIR);
-
- /* create berkeley db environment */
- ret = db_env_create(&envp, 0);
- if(ret != 0)
- {
- /* TODO: err handling */
- return(-1);
- }
-
- /* have db do deadlock detection and reject txn with fewest locks */
- ret = envp->set_lk_detect(envp, DB_LOCK_MINWRITE);
- if(ret != 0)
- {
- /* TODO: err handling */
- return(-1);
- }
-
- env_flags =
- DB_CREATE | /* Create the environment if it does not exist */
- DB_RECOVER | /* Run normal recovery. */
- DB_INIT_LOCK | /* Initialize the locking subsystem */
- DB_INIT_LOG | /* Initialize the logging subsystem */
- DB_INIT_TXN | /* Initialize the transactional subsystem. This
- * also turns on logging. */
- DB_INIT_MPOOL | /* Initialize the memory pool (in-memory cache) */
- DB_THREAD | /* Cause the environment to be free-threaded */
- DB_RECOVER; /* Run normal recovery steps */
-
- if(!dir_exists)
- {
- /* making a brand new storage space */
-
- /* new directory for logs */
- ret = mkdir(cosd_log_path, 0755);
- if(ret != 0)
- return(-errno);
- }
-
- /* open environment */
- ret = envp->open(envp, cosd_path, env_flags, 0);
- if(ret != 0)
- {
- /* TODO: error handling */
- return(-1);
- }
-
- /* create db handles */
- /* custom sort functions allow all dbs to be queried using cursors over
- * id ranges
- */
- ret = db_create(&log_map_dbp, envp, 0);
- if(ret != 0)
- {
- /* TODO: error handling */
- return(-1);
- }
- log_map_dbp->set_bt_compare(log_map_dbp, compare_log_map_key);
- ret = db_create(&missing_ver_dbp, envp, 0);
- if(ret != 0)
- {
- /* TODO: error handling */
- return(-1);
- }
- missing_ver_dbp->set_bt_compare(missing_ver_dbp, compare_missing_version);
- ret = db_create(&ver_dbp, envp, 0);
- if(ret != 0)
- {
- /* TODO: error handling */
- return(-1);
- }
- ver_dbp->set_bt_compare(ver_dbp, compare_uint64);
- ret = db_create(&log_offset_dbp, envp, 0);
- if(ret != 0)
- {
- /* TODO: error handling */
- return(-1);
- }
- log_offset_dbp->set_bt_compare(log_offset_dbp, compare_uint64);
-
-
- /* open dbs */
- open_flags = DB_CREATE | /* Allow database creation */
- DB_READ_UNCOMMITTED | /* Allow dirty reads */
- DB_AUTO_COMMIT; /* Allow autocommit */
-
- ret = log_map_dbp->open(log_map_dbp, NULL, "logical-map.db",
- NULL, DB_BTREE, open_flags, 0);
- if(ret != 0)
- {
- /* TODO: error handling */
- return(-1);
- }
- ret = missing_ver_dbp->open(missing_ver_dbp, NULL, "missing_versions.db",
- NULL, DB_BTREE, open_flags, 0);
- if(ret != 0)
- {
- /* TODO: error handling */
- return(-1);
- }
- ret = ver_dbp->open(ver_dbp, NULL, "version.db",
- NULL, DB_BTREE, open_flags, 0);
- if(ret != 0)
- {
- /* TODO: error handling */
- return(-1);
- }
- ret = log_offset_dbp->open(log_offset_dbp, NULL, "log-offset.db",
- NULL, DB_BTREE, open_flags, 0);
- if(ret != 0)
- {
- /* TODO: error handling */
- return(-1);
- }
-
- /* flush out txn logs up front; otherwise the first I/O operation to the
- * COSD may bog down instead.
- */
- envp->txn_checkpoint(envp, 0, 0, 0);
-
- triton_mutex_lock(&txn_mutex);
- /* create hash table for open txns */
- txn_table = triton_hash_init(txn_acc_compare, triton_hash_64bit_hash, 1024);
- if(!txn_table)
- {
- /* TODO: error handling */
- triton_mutex_unlock(&txn_mutex);
- return(-1);
- }
- triton_mutex_unlock(&txn_mutex);
-
- ae_ops_init(&cosd_oplist);
-
- ret = TRITON_OPCACHE_INIT(struct cosd_op, op, STORAGE_DEFAULT_OPCACHE_SIZE, &cosd_opcache);
- if(ret < 0)
- {
- return(ret);
- }
-
- assert(mode > TRITON_PROG_NONE && mode < TRITON_PROG_MAX);
-
- /* modify poll function depending on requested mode */
- switch(mode)
- {
- case TRITON_PROG_POLL:
- cosd_resource.poll_context = triton_cosd_poll;
- break;
- case TRITON_PROG_THREAD_PER_OP:
- case TRITON_PROG_THREAD_POOL:
- cosd_resource.poll_context = triton_cosd_poll_thread_per_op;
- break;
- case TRITON_PROG_NONE:
- case TRITON_PROG_MAX:
- return(-EINVAL);
- }
-
- cosd_resource_id = ae_resource_register(&cosd_resource);
- if(cosd_resource_id < 0)
- {
- ae_opcache_destroy(cosd_opcache);
- return(cosd_resource_id);
- }
- triton_cosd_progress_mode = mode;
-
- return ret;
-}
-
-int triton_cosd_finalize(void)
-{
- triton_resource_unregister(cosd_resource_id);
- ae_opcache_destroy(cosd_opcache);
-
- envp = log_map_dbp->get_env(log_map_dbp);
- log_map_dbp->close(log_map_dbp, 0);
- missing_ver_dbp->close(missing_ver_dbp, 0);
- ver_dbp->close(ver_dbp, 0);
- log_offset_dbp->close(log_offset_dbp, 0);
-
- triton_mutex_lock(&txn_mutex);
- triton_hash_finalize(txn_table);
- triton_mutex_unlock(&txn_mutex);
-
- return 0;
-}
-
-/* write_op_cleanup()
- *
- * cleans up memory after a write operation completes
- */
-static void write_op_cleanup(struct cosd_op *c_op)
-{
- if(c_op->u.write.mem_offsets)
- free(c_op->u.write.mem_offsets);
- if(c_op->u.write.mem_sizes)
- free(c_op->u.write.mem_sizes);
- if(c_op->u.write.obj_sizes)
- free(c_op->u.write.obj_sizes);
- if(c_op->u.write.obj_offsets)
- free(c_op->u.write.obj_offsets);
-
- return;
-}
-
-/* write_op_worker()
- *
- * writes data to an object
- */
-static int write_op_worker(struct ae_op* op)
-{
- struct cosd_op *c_op;
- int ret;
- DB_TXN *txn;
- DBT key, value;
- char log_name[PATH_MAX];
- int done = 0;
- int mem_index = 0;
- int obj_index = 0;
- struct logical_map_entry *tmp_update;
- const char* mem_ptr;
- void* scratch_buffer = NULL;
- int scratch_size = 0;
- int64_t aligned_size = 0;
- struct txn_accumulator* txn_acc;
- struct triton_hash_link* hash_link;
-
- c_op = ae_op_entry(op, struct cosd_op, op);
- assert(c_op);
-
- /* only support one object for now */
- assert(c_op->u.write.oid == 1);
-
- assert(c_op->u.write.mem_count > 0);
- assert(c_op->u.write.obj_count > 0);
-
- if(global_fd < 0)
- {
- /* open log file */
- sprintf(log_name, "%s/%llu.dat", cosd_log_path,
- llu(c_op->u.write.oid));
- ret = open(log_name, O_RDWR|O_DIRECT|O_EXCL|O_NOATIME,
- S_IRUSR|S_IWUSR);
- if(ret < 0)
- {
- c_op->error_code = -errno;
- return(1);
- }
- global_fd = ret;
- }
-
- /* TODO: safety check that total mem size equals total obj size */
- /* TODO: safety check no zero buffers in either list */
-
- while(!done)
- {
- /* structure to track this update in the txn */
- tmp_update = malloc(sizeof(*tmp_update));
- if(!tmp_update)
- {
- /* TODO: err handling */
- c_op->error_code = -errno;
- return(1);
- }
-
- /* find the next chunk that is contiguous in memory and disk */
- mem_ptr = c_op->u.write.mem_offsets[mem_index];
- tmp_update->logical_offset = c_op->u.write.obj_offsets[obj_index];
- tmp_update->size = c_op->u.write.mem_sizes[mem_index];
- tmp_update->logical_offset_end = tmp_update->logical_offset +
- tmp_update->size;
- if(tmp_update->size >= c_op->u.write.obj_sizes[obj_index])
- {
- /* mem region is bigger than obj region */
- tmp_update->size = c_op->u.write.obj_sizes[obj_index];
- }
-
- /* advance pointers */
- c_op->u.write.mem_sizes[mem_index] -= tmp_update->size;
- c_op->u.write.mem_offsets[mem_index] += tmp_update->size;
- if(c_op->u.write.mem_sizes[mem_index] == 0)
- {
- if(mem_index == (c_op->u.write.mem_count -1))
- done = 1;
- else
- mem_index++;
- }
- c_op->u.write.obj_sizes[obj_index] -= tmp_update->size;
- c_op->u.write.obj_offsets[obj_index] += tmp_update->size;
- if(c_op->u.write.obj_sizes[obj_index] == 0)
- {
- if(obj_index == (c_op->u.write.obj_count -1))
- done = 1;
- else
- obj_index++;
- }
-
- /* calculate aligned buffer size */
- if(tmp_update->size % DIRECT_ALIGN != 0)
- aligned_size =
- ((tmp_update->size / DIRECT_ALIGN)+1)*DIRECT_ALIGN;
- else
- aligned_size = tmp_update->size;
-
- /* TODO: think about how to track this per object; we need to
- * atomically get a new log offset, but it doesn't have to be
- * flushed to db until we close a transaction. For now using a
- * global var and global mutex
- */
- /* get next log offset and increment */
- triton_mutex_lock(&global_log_mutex);
- if(global_log_offset < 0)
- {
- COSD_INIT_DBT(key, c_op->u.write.oid);
- COSD_INIT_DBT(value, global_log_offset);
-
-write_op_txn:
- /* read log offset from db */
- ret = envp->txn_begin(envp, NULL, &txn, 0);
- if(ret != 0)
- {
- /* TODO: error handling */
- c_op->error_code = -1;
- return(1);
- }
-
- ret = log_offset_dbp->get(log_offset_dbp, txn, &key, &value, 0);
- if(ret != 0)
- {
- txn->abort(txn);
- if(ret == DB_LOCK_DEADLOCK)
- goto write_op_txn;
-
- /* TODO: error handling */
- c_op->error_code = -1;
- return(1);
- }
-
- ret = txn->commit(txn, 0);
- if(ret != 0)
- {
- txn->abort(txn);
- if(ret == DB_LOCK_DEADLOCK)
- goto write_op_txn;
-
- /* TODO: error handling */
- assert(0);
- }
-
- assert(global_log_offset > -1);
- }
-
- tmp_update->log_offset = global_log_offset;
- global_log_offset += aligned_size;
- triton_mutex_unlock(&global_log_mutex);
-
- if(((unsigned long)mem_ptr) % DIRECT_ALIGN || tmp_update->size != aligned_size)
- {
- /* mem buffer is not aligned */
- /* allocate a scratch buffer to copy to */
- if(scratch_size < aligned_size)
- {
- if(scratch_buffer)
- free(scratch_buffer);
- scratch_size = aligned_size;
- ret = posix_memalign(&scratch_buffer, DIRECT_ALIGN,
- aligned_size);
- if(ret < 0)
- {
- /* TODO: err handling */
- c_op->error_code = -errno;
- return(1);
- }
- }
- memcpy(scratch_buffer, mem_ptr, tmp_update->size);
- mem_ptr = scratch_buffer;
- }
-
- /* actually write the data */
- ret = pwrite(global_fd, mem_ptr, aligned_size,
- tmp_update->log_offset);
- if(ret < 0)
- {
- /* TODO: err handling */
- c_op->error_code = -errno;
- return(1);
- }
-
- /* track this update in the txn accumulator */
- triton_mutex_lock(&txn_mutex);
- hash_link = triton_hash_search(txn_table, &c_op->u.write.txn_number);
- if(!hash_link)
- {
- /* TODO: txn is gone (which could be normal); error handling */
- c_op->error_code = -1;
- triton_mutex_unlock(&txn_mutex);
- return(1);
- }
- txn_acc = triton_hash_get_entry(hash_link, struct txn_accumulator,
- hash_link);
- tmp_update->version = txn_acc->txn_number;
- triton_list_add_front(&tmp_update->list_link, &txn_acc->update_list);
- txn_acc->update_list_count++;
- triton_mutex_unlock(&txn_mutex);
- }
-
- /* cleanup any leftover buffer */
- if(scratch_buffer)
- free(scratch_buffer);
-
- c_op->error_code = 0;
- return(1);
-}
-
-/* dump_op_worker()
- *
- * dumps all db information from cosd
- */
-/* TODO: audit for deadlocks */
-static int dump_op_worker(struct ae_op* op)
-{
- struct cosd_op *c_op;
- int ret;
- DB_TXN *txn;
- DBC *log_map_dbcp, *missing_ver_dbcp, *ver_dbcp, *log_offset_dbcp;
- DBT log_map_key, missing_ver_key, ver_key, log_offset_key;
- DBT log_map_value, missing_ver_value, ver_value, log_offset_value;
- int c_get_flag = DB_SET_RANGE;
-
- /* keys for each db */
- struct logical_map_key lmk;
- struct missing_version mvk;
- uint64_t lok;
- uint64_t vk;
- COSD_INIT_DBT(log_map_key, lmk);
- COSD_INIT_DBT(missing_ver_key, mvk);
- COSD_INIT_DBT(log_offset_key, lok);
- COSD_INIT_DBT(ver_key, vk);
-
- /* values for each db */
- struct logical_map_entry lmv;
- uint64_t vv;
- int64_t lov;
- COSD_INIT_DBT(log_map_value, lmv);
- COSD_INIT_DBT_EMPTY(missing_ver_value);
- COSD_INIT_DBT(log_offset_value, lov);
- COSD_INIT_DBT(ver_value, vv);
-
- c_op = ae_op_entry(op, struct cosd_op, op);
- assert(c_op);
-
- ret = envp->txn_begin(envp, NULL, &txn, 0);
- if(ret != 0)
- {
- /* TODO: error handling */
- c_op->error_code = -1;
- return(1);
- }
-
- /* create cursors on all 4 dbs */
- ret = log_map_dbp->cursor(log_map_dbp, txn, &log_map_dbcp, 0);
- assert(ret == 0); /* TODO: err handling */
- ret = ver_dbp->cursor(ver_dbp, txn, &ver_dbcp, 0);
- assert(ret == 0); /* TODO: err handling */
- ret = missing_ver_dbp->cursor(missing_ver_dbp, txn, &missing_ver_dbcp, 0);
- assert(ret == 0); /* TODO: err handling */
- ret = log_offset_dbp->cursor(log_offset_dbp, txn, &log_offset_dbcp, 0);
- assert(ret == 0); /* TODO: err handling */
-
- /* loop through version db, one entry per object */
- while ((ret = ver_dbcp->c_get(ver_dbcp, &ver_key, &ver_value, DB_NEXT)) == 0)
- {
- printf("OID: %llu\n", llu(vk));
- printf("=============================================\n");
- printf(" version: %llu\n", llu(vv));
-
- /* next log offset entry should match, no need to search */
- ret = log_offset_dbcp->c_get(log_offset_dbcp, &log_offset_key,
- &log_offset_value, DB_NEXT);
- assert(ret == 0); /* TODO: err handling */
- assert(lok == vk);
- printf(" next log offset: %lld\n", lld(lov));
-
- /* search for any missing versions */
- printf(" missing versions: ");
- mvk.oid = vk;
- mvk.version = 0;
- c_get_flag = DB_SET_RANGE;
- while((ret = missing_ver_dbcp->c_get(missing_ver_dbcp,
- &missing_ver_key, &missing_ver_value, c_get_flag)) == 0)
- {
- c_get_flag = DB_NEXT;
- printf("%llu ", llu(mvk.version));
- }
- printf("\n");
- assert(ret == DB_NOTFOUND); /* TODO: err handling */
-
- /* search for logical map entries */
- printf(" logical map:\n");
- printf(" ------------------------------------------\n");
- lmk.oid = vk;
- lmk.logical_offset_end = 0;
- c_get_flag = DB_SET_RANGE;
- while((ret = log_map_dbcp->c_get(log_map_dbcp,
- &log_map_key, &log_map_value, c_get_flag)) == 0)
- {
- printf("logical_off: %lld, logical_end: %lld, size: %lld, log_off: %lld, ver: %llu\n",
- lld(lmv.logical_offset), lld(lmv.logical_offset_end),
- lld(lmv.size), lld(lmv.log_offset), llu(lmv.version));
- c_get_flag = DB_NEXT;
- }
- assert(ret == DB_NOTFOUND); /* TODO: err handling */
-
- printf("\n");
- }
- assert(ret == DB_NOTFOUND); /* TODO: err handling */
-
- log_map_dbcp->c_close(log_map_dbcp);
- log_offset_dbcp->c_close(log_offset_dbcp);
- ver_dbcp->c_close(ver_dbcp);
- missing_ver_dbcp->c_close(missing_ver_dbcp);
-
- ret = txn->commit(txn, 0);
- if(ret != 0)
- {
- /* TODO: error handling */
- assert(0);
- }
-
- c_op->error_code = 0;
- return(1);
-}
-
-
-/* create_op_worker()
- *
- * creates an object
- */
-/* TODO: audit for deadlocks */
-static int create_op_worker(struct ae_op* op)
-{
- struct cosd_op *c_op;
- int ret;
- DB_TXN *txn;
- int64_t val;
- DBT key, value;
- char log_name[PATH_MAX];
-
- c_op = ae_op_entry(op, struct cosd_op, op);
- assert(c_op);
-
- /* only support one object for now */
- assert(c_op->u.create.requested_oid == 1);
- *c_op->u.create.out_oid = 1;
-
- /* create a log file */
- sprintf(log_name, "%s/%llu.dat", cosd_log_path,
- llu(c_op->u.create.requested_oid));
- ret = open(log_name, O_RDWR|O_CREAT|O_DIRECT|O_EXCL|O_NOATIME,
- S_IRUSR|S_IWUSR);
- if(ret < 0)
- {
- c_op->error_code = -errno;
- return(1);
- }
- global_fd = ret;
-
- /* do db stuff */
- ret = envp->txn_begin(envp, NULL, &txn, 0);
- if(ret != 0)
- {
- /* TODO: error handling */
- c_op->error_code = -1;
- return(1);
- }
-
- /* set initial version of 1 */
- val = 1;
- COSD_INIT_DBT(key, c_op->u.create.requested_oid);
- COSD_INIT_DBT(value, val);
-
- ret = ver_dbp->put(ver_dbp, txn, &key, &value, 0);
- if(ret != 0)
- {
- /* TODO: error handling */
- assert(0);
- }
-
- /* set initial log offset of 0 */
- val = 0;
- ret = log_offset_dbp->put(log_offset_dbp, txn, &key, &value, 0);
- if(ret != 0)
- {
- /* TODO: error handling */
- assert(0);
- }
-
- ret = txn->commit(txn, 0);
- if(ret != 0)
- {
- /* TODO: error handling */
- assert(0);
- }
-
- c_op->error_code = 0;
-
- return(1);
-}
-
-triton_ret_t triton_cosd_write_post(
- uint64_t oid,
- uint64_t txn_number,
- char** mem_offsets,
- int64_t* mem_sizes,
- int mem_count,
- int64_t* obj_offsets,
- int64_t* obj_sizes,
- int obj_count,
- void (*callback)(void *ptr, int ret),
- void *user_ptr,
- ae_hints_t hints,
- ae_context_t ctx,
- ae_op_id_t *op_id)
-{
- struct ae_op *op;
- struct cosd_op *c_op;
-
- op = ae_opcache_get(cosd_opcache);
- ae_op_fill(op, callback, user_ptr, hints, ctx);
-
- c_op = ae_op_entry(op, struct cosd_op, op);
- c_op->op_id = triton_id_gen(cosd_resource_id, (uint64_t)(op->cache_id));
- c_op->u.write.oid = oid;
- c_op->u.write.txn_number = txn_number;
- c_op->u.write.mem_count = mem_count;
- c_op->u.write.obj_count = obj_count;
-
- /* copy arrays so that we can modify them internally */
- /* TODO: error handling */
- c_op->u.write.mem_offsets = malloc(mem_count*sizeof(*mem_offsets));
- assert(c_op->u.write.mem_offsets);
- memcpy(c_op->u.write.mem_offsets, mem_offsets,
- mem_count*sizeof(*mem_offsets));
-
- c_op->u.write.mem_sizes = malloc(mem_count*sizeof(*mem_sizes));
- assert(c_op->u.write.mem_sizes);
- memcpy(c_op->u.write.mem_sizes, mem_sizes,
- mem_count*sizeof(*mem_sizes));
-
- c_op->u.write.obj_offsets = malloc(obj_count*sizeof(*obj_offsets));
- assert(c_op->u.write.obj_offsets);
- memcpy(c_op->u.write.obj_offsets, obj_offsets,
- obj_count*sizeof(*obj_offsets));
-
- c_op->u.write.obj_sizes = malloc(obj_count*sizeof(*obj_sizes));
- assert(c_op->u.write.obj_sizes);
- memcpy(c_op->u.write.obj_sizes, obj_sizes,
- obj_count*sizeof(*obj_sizes));
-
- *op_id = c_op->op_id;
-
- /* TODO: put this in the fill function if we keep it? */
- op->op_worker = write_op_worker;
- c_op->cleanup_fn = write_op_cleanup;
-
- triton_cosd_launch_op(op, triton_cosd_progress_mode);
-
- return TRITON_SUCCESS;
-}
-triton_ret_t (* triton_cosd_write)(
- uint64_t oid,
- uint64_t txn_number,
- char** mem_offsets,
- int64_t* mem_sizes,
- int mem_count,
- int64_t* obj_offsets,
- int64_t* obj_sizes,
- int obj_count,
- void (*callback)(void *ptr, int ret),
- void *user_ptr,
- ae_hints_t hints,
- ae_context_t ctx,
- ae_op_id_t *op_id) = triton_cosd_write_post;
-
-
-triton_ret_t triton_cosd_dump_post(
- void (*callback)(void *ptr, int ret),
- void *user_ptr,
- ae_hints_t hints,
- ae_context_t ctx,
- ae_op_id_t *op_id)
-{
- struct ae_op *op;
- struct cosd_op *c_op;
-
- op = ae_opcache_get(cosd_opcache);
- ae_op_fill(op, callback, user_ptr, hints, ctx);
-
- c_op = ae_op_entry(op, struct cosd_op, op);
- c_op->op_id = triton_id_gen(cosd_resource_id, (uint64_t)(op->cache_id));
-
- *op_id = c_op->op_id;
-
- /* TODO: put this in the fill function if we keep it? */
- op->op_worker = dump_op_worker;
- c_op->cleanup_fn = NULL;
-
- triton_cosd_launch_op(op, triton_cosd_progress_mode);
-
- return TRITON_SUCCESS;
-}
-triton_ret_t (* triton_cosd_dump)(
- void (*callback)(void *ptr, int ret),
- void *user_ptr,
- ae_hints_t hints,
- ae_context_t ctx,
- ae_op_id_t *op_id) = triton_cosd_dump_post;
-
-
-triton_ret_t triton_cosd_create_post(
- uint64_t requested_oid,
- uint64_t* out_oid,
- void (*callback)(void *ptr, int ret),
- void *user_ptr,
- ae_hints_t hints,
- ae_context_t ctx,
- ae_op_id_t *op_id)
-{
- struct ae_op *op;
- struct cosd_op *c_op;
-
- op = ae_opcache_get(cosd_opcache);
- ae_op_fill(op, callback, user_ptr, hints, ctx);
-
- c_op = ae_op_entry(op, struct cosd_op, op);
- c_op->op_id = triton_id_gen(cosd_resource_id, (uint64_t)(op->cache_id));
- c_op->u.create.requested_oid = requested_oid;
- c_op->u.create.out_oid = out_oid;
-
- *op_id = c_op->op_id;
-
- /* TODO: put this in the fill function if we keep it? */
- op->op_worker = create_op_worker;
- c_op->cleanup_fn = NULL;
-
- triton_cosd_launch_op(op, triton_cosd_progress_mode);
-
- return TRITON_SUCCESS;
-}
-triton_ret_t (* triton_cosd_create)(
- uint64_t requested_oid,
- uint64_t* out_oid,
- void (*callback)(void *ptr, int ret),
- void *user_ptr,
- ae_hints_t hints,
- ae_context_t ctx,
- ae_op_id_t *op_id) = triton_cosd_create_post;
-
-int triton_cosd_txn_open(uint64_t oid, uint64_t txn_number)
-{
- struct txn_accumulator *txn_acc;
-
- txn_acc = malloc(sizeof(*txn_acc));
- if(!txn_acc)
- {
- return(-ENOMEM);
- }
- memset(txn_acc, 0, sizeof(*txn_acc));
-
- txn_acc->txn_number = txn_number;
- triton_list_init(&txn_acc->update_list);
-
- triton_mutex_lock(&txn_mutex);
- /* TODO: safety test for duplicate txn numbers */
- triton_hash_add(txn_table, &txn_acc->txn_number, &txn_acc->hash_link);
- triton_mutex_unlock(&txn_mutex);
-
- return(0);
-}
-
-
-/* get_version_op_worker()
- *
- * retrieves the current version number of an object
- */
-/* TODO: audit for deadlocks */
-static int get_version_op_worker(struct ae_op* op)
-{
- struct cosd_op *c_op;
- int ret;
- DB_TXN *txn;
- uint64_t version;
- DBT key, value;
-
- c_op = ae_op_entry(op, struct cosd_op, op);
- assert(c_op);
-
- /* only support one object for now */
- assert(c_op->u.get_version.oid == 1);
-
- /* do db stuff */
- ret = envp->txn_begin(envp, NULL, &txn, 0);
- if(ret != 0)
- {
- /* TODO: error handling */
- c_op->error_code = -1;
- return(1);
- }
-
- /* read current version */
- COSD_INIT_DBT(key, c_op->u.get_version.oid);
- COSD_INIT_DBT(value, version);
-
- ret = ver_dbp->get(ver_dbp, txn, &key, &value, 0);
- if(ret != 0)
- {
- /* TODO: error handling */
- assert(0);
- }
-
- *c_op->u.get_version.version = version;
-
- ret = txn->commit(txn, 0);
- if(ret != 0)
- {
- /* TODO: error handling */
- assert(0);
- }
-
- c_op->error_code = 0;
-
- return(1);
-}
-
-
-triton_ret_t triton_cosd_get_version_post(
- uint64_t oid,
- uint64_t* version,
- void (*callback)(void *ptr, int ret),
- void *user_ptr,
- ae_hints_t hints,
- ae_context_t ctx,
- ae_op_id_t *op_id)
-{
- struct ae_op *op;
- struct cosd_op *c_op;
-
- op = ae_opcache_get(cosd_opcache);
- ae_op_fill(op, callback, user_ptr, hints, ctx);
-
- c_op = ae_op_entry(op, struct cosd_op, op);
- c_op->op_id = triton_id_gen(cosd_resource_id, (uint64_t)(op->cache_id));
- c_op->u.get_version.oid = oid;
- c_op->u.get_version.version = version;
-
- *op_id = c_op->op_id;
-
- /* TODO: put this in the fill function if we keep it? */
- op->op_worker = get_version_op_worker;
- c_op->cleanup_fn = NULL;
-
- triton_cosd_launch_op(op, triton_cosd_progress_mode);
-
- return TRITON_SUCCESS;
-}
-triton_ret_t (* triton_cosd_get_version)(
- uint64_t oid,
- uint64_t* version,
- void (*callback)(void *ptr, int ret),
- void *user_ptr,
- ae_hints_t hints,
- ae_context_t ctx,
- ae_op_id_t *op_id) = triton_cosd_get_version_post;
-
-
-/* txn_close_op_worker()
- *
- * closes a transaction
- */
-static int txn_close_op_worker(struct ae_op* op)
-{
- struct cosd_op *c_op;
- int ret;
- DB_TXN *txn;
- DBT key, value;
- struct txn_accumulator* txn_acc;
- struct triton_hash_link* hash_link;
- struct triton_list_link* iterator;
- struct triton_list_link* scratch;
- struct logical_map_entry* tmp_entry;
- struct logical_map_entry* tmp_update;
- DBC *dbc_p = NULL;
- struct logical_map_entry lme;
- struct logical_map_key lmk;
- triton_list_t on_disk_entries;
- triton_list_t new_disk_entries;
- int on_disk_count = 0;
- int done = 0;
- int c_get_flag = DB_SET_RANGE;
- int64_t version;
- int64_t missing_ver;
- DBT mv_key, mv_value;
- struct missing_version mv;
- void* free_ptr;
-
- c_op = ae_op_entry(op, struct cosd_op, op);
- assert(c_op);
-
- /* only support one object for now */
- assert(c_op->u.txn_close.oid == 1);
-
- lmk.oid = c_op->u.txn_close.oid;
-
- /* pull txn accumulator out of hash so no one can touch it */
- triton_mutex_lock(&txn_mutex);
- hash_link = triton_hash_search(txn_table, &c_op->u.txn_close.txn_number);
- if(!hash_link)
- {
- /* TODO: txn is gone (which could be normal); error handling */
- c_op->error_code = -1;
- triton_mutex_unlock(&txn_mutex);
- return(1);
- }
- txn_acc = triton_hash_get_entry(hash_link, struct txn_accumulator,
- hash_link);
- triton_list_del(&txn_acc->hash_link);
- triton_mutex_unlock(&txn_mutex);
-
-txn_close_op_retry:
- on_disk_count = 0;
- done = 0;
- c_get_flag = DB_SET_RANGE;
- /* clear up on disk list in case this is a retry */
- triton_list_for_each(iterator, scratch, &on_disk_entries)
- {
- tmp_entry = triton_list_get_entry(iterator, struct
- logical_map_entry, list_link);
- triton_list_del(&tmp_entry->list_link);
- free(tmp_entry);
- }
-
- /* do db stuff */
- ret = envp->txn_begin(envp, NULL, &txn, 0);
- if(ret != 0)
- {
- /* TODO: error handling */
- c_op->error_code = -1;
- return(1);
- }
-
- /* create a cursor to move through logical map db */
- /* TODO: check flags */
- ret = log_map_dbp->cursor(log_map_dbp, txn, &dbc_p, 0);
- if(ret != 0)
- {
- txn->abort(txn);
- if(ret == DB_LOCK_DEADLOCK)
- goto txn_close_op_retry;
- /* TODO: error handling */
- assert(0);
- }
- COSD_INIT_DBT(key, lmk);
- COSD_INIT_DBT(value, lme);
-
- /* TODO: optimize to avoid updates if no log regions need to be
- * replaced
- */
-
- /* loop through each update in the cosd txn */
- triton_list_for_each(iterator, scratch, &txn_acc->update_list)
- {
- tmp_update = triton_list_get_entry(iterator, struct logical_map_entry,
- list_link);
-
- lmk.logical_offset_end = tmp_update->logical_offset + 1;
- done = 0;
- while(!done)
- {
- /* get each potentially overlapping on disk region */
- ret = dbc_p->c_get(dbc_p, &key, &value, c_get_flag);
- if(ret == DB_NOTFOUND)
- {
- done = 1;
- break;
- }
- if(ret != 0)
- {
- txn->abort(txn);
- if(ret == DB_LOCK_DEADLOCK)
- goto txn_close_op_retry;
- /* TODO: err handling */
- assert(0);
- }
-
- if(lme.logical_offset >= tmp_update->logical_offset_end)
- {
- /* run out of overlapping regions */
- done = 1;
- break;
- }
-
- /* store this in a linked list */
- tmp_entry = malloc(sizeof(*tmp_entry));
- if(!tmp_entry)
- {
- /* TODO: err handling */
- assert(0);
- }
- *tmp_entry = lme;
- triton_list_add_front(&tmp_entry->list_link, &on_disk_entries);
- on_disk_count++;
- c_get_flag = DB_NEXT;
-
- /* TODO: worth optimizing? We can instead calculate exactly
- * what needs to be updated/added/removed/left alone for each
- * region
- */
- /* delete it from db; will be added back later if necessary */
- ret = dbc_p->c_del(dbc_p, 0);
- if(ret != 0)
- {
- txn->abort(txn);
- if(ret == DB_LOCK_DEADLOCK)
- goto txn_close_op_retry;
- /* TODO: err handling */
- assert(0);
- }
- }
- }
- ret = dbc_p->c_close(dbc_p);
- if(ret != 0)
- {
- txn->abort(txn);
- if(ret == DB_LOCK_DEADLOCK)
- goto txn_close_op_retry;
- /* TODO: error handling */
- assert(0);
- }
-
- /* merge on disk and txn regions */
- ret = merge_logical_map(&on_disk_entries, on_disk_count,
- &txn_acc->update_list, txn_acc->update_list_count,
- &new_disk_entries, &free_ptr);
- if(ret != 0)
- {
- /* TODO: err handling */
- assert(0);
- }
-
- /* write new logical map updates */
- triton_list_for_each(iterator, scratch, &new_disk_entries)
- {
- tmp_entry = triton_list_get_entry(iterator, struct logical_map_entry,
- list_link);
- lme = *tmp_entry;
- lmk.logical_offset_end = lme.logical_offset_end;
- ret = log_map_dbp->put(log_map_dbp, txn, &key, &value, 0);
- if(ret != 0)
- {
- txn->abort(txn);
- free(free_ptr);
- if(ret == DB_LOCK_DEADLOCK)
- goto txn_close_op_retry;
- /* TODO: err handling */
- assert(0);
- }
- }
- free(free_ptr);
-
- /* read current version */
- COSD_INIT_DBT(key, c_op->u.txn_close.oid);
- COSD_INIT_DBT(value, version);
-
- ret = ver_dbp->get(ver_dbp, txn, &key, &value, 0);
- if(ret != 0)
- {
- txn->abort(txn);
- if(ret == DB_LOCK_DEADLOCK)
- goto txn_close_op_retry;
-
- /* TODO: error handling */
- assert(0);
- }
-
- if(txn_acc->txn_number > version)
- {
- /* this update is newer than the current version of the object */
- COSD_INIT_DBT(mv_key, mv);
- COSD_INIT_DBT_EMPTY(mv_value);
-
- /* identify skipped version numbers */
- missing_ver = version + 1;
- while(missing_ver < txn_acc->txn_number)
- {
- mv.oid = c_op->u.txn_close.oid;
- mv.version = missing_ver;
-
- /* record each missing ver in db */
- ret = missing_ver_dbp->put(missing_ver_dbp, txn, &mv_key, &mv_value, 0);
- if(ret != 0)
- {
- txn->abort(txn);
- if(ret == DB_LOCK_DEADLOCK)
- goto txn_close_op_retry;
- /* TODO: error handling */
- assert(0);
- }
-
- missing_ver++;
- }
-
- /* bump overall version number */
- version = txn_acc->txn_number;
- ret = ver_dbp->put(ver_dbp, txn, &key, &value, 0);
- if(ret != 0)
- {
- txn->abort(txn);
- if(ret == DB_LOCK_DEADLOCK)
- goto txn_close_op_retry;
- /* TODO: error handling */
- assert(0);
- }
- }
- if(txn_acc->txn_number < version)
- {
- /* this update is older than the current version of the object */
- /* remove it from list of missing versions if present */
- memset(&mv_key, 0, sizeof(DBT));
- mv_key.data = &mv;
- mv_key.size = sizeof(mv);
- mv.oid = c_op->u.txn_close.oid;
- mv.version = txn_acc->txn_number;
-
- /* delete from db db */
- ret = missing_ver_dbp->del(missing_ver_dbp, txn, &mv_key, 0);
- if(ret == DB_LOCK_DEADLOCK)
- {
- txn->abort(txn);
- goto txn_close_op_retry;
- }
- if(ret != 0 && ret != DB_NOTFOUND)
- {
- txn->abort(txn);
- /* TODO: error handling */
- assert(0);
- }
- }
-
- /* flush current log offset to db in the same txn */
- /* TODO: any deadlock potential here because of ordering with mutex
- * relative to txn?
- */
- triton_mutex_lock(&global_log_mutex);
- COSD_INIT_DBT(key, c_op->u.txn_close.oid);
- COSD_INIT_DBT(value, global_log_offset);
-
- ret = log_offset_dbp->put(log_offset_dbp, txn, &key, &value, 0);
- if(ret != 0)
- {
- txn->abort(txn);
- if(ret == DB_LOCK_DEADLOCK)
- goto txn_close_op_retry;
-
- /* TODO: error handling */
- assert(0);
- }
- triton_mutex_unlock(&global_log_mutex);
-
- ret = txn->commit(txn, 0);
- if(ret != 0)
- {
- txn->abort(txn);
- if(ret == DB_LOCK_DEADLOCK)
- goto txn_close_op_retry;
-
- /* TODO: error handling */
- assert(0);
- }
-
- triton_list_for_each(iterator, scratch, &on_disk_entries)
- {
- tmp_entry = triton_list_get_entry(iterator, struct
- logical_map_entry, list_link);
- triton_list_del(&tmp_entry->list_link);
- free(tmp_entry);
- }
- triton_list_for_each(iterator, scratch, &txn_acc->update_list)
- {
- tmp_entry = triton_list_get_entry(iterator, struct
- logical_map_entry, list_link);
- triton_list_del(&tmp_entry->list_link);
- free(tmp_entry);
- }
-
- free(txn_acc);
- c_op->error_code = 0;
- return(1);
-}
-
-triton_ret_t triton_cosd_txn_close_post(
- uint64_t oid,
- uint64_t txn_number,
- void (*callback)(void *ptr, int ret),
- void *user_ptr,
- ae_hints_t hints,
- ae_context_t ctx,
- ae_op_id_t *op_id)
-{
- struct ae_op *op;
- struct cosd_op *c_op;
-
- op = ae_opcache_get(cosd_opcache);
- ae_op_fill(op, callback, user_ptr, hints, ctx);
-
- c_op = ae_op_entry(op, struct cosd_op, op);
- c_op->op_id = triton_id_gen(cosd_resource_id, (uint64_t)(op->cache_id));
- c_op->u.txn_close.oid = oid;
- c_op->u.txn_close.txn_number = txn_number;
-
- *op_id = c_op->op_id;
-
- /* TODO: put this in the fill function if we keep it? */
- op->op_worker = txn_close_op_worker;
- c_op->cleanup_fn = NULL;
-
- triton_cosd_launch_op(op, triton_cosd_progress_mode);
-
- return TRITON_SUCCESS;
-}
-triton_ret_t (* triton_cosd_txn_close)(
- uint64_t oid,
- uint64_t txn_number,
- void (*callback)(void *ptr, int ret),
- void *user_ptr,
- ae_hints_t hints,
- ae_context_t ctx,
- ae_op_id_t *op_id) = triton_cosd_txn_close_post;
-
-
-/* merge_logical_map()
- *
- * merges two logical maps into one map. The output map is allocated from
- * scratch and can be freed via the free_ptr argument.
- *
- * returns 0 on success, -errno on failure
- */
-static int merge_logical_map(triton_list_t* list1_in, int
- list1_count, triton_list_t* list2_in, int list2_count,
- triton_list_t* list_out, void** free_ptr)
-{
- struct triton_list_link* iterator;
- struct triton_list_link* scratch;
- struct logical_map_entry* tmp_entry;
- int i=0;
- int j=0;
- int k=0;
- struct logical_map_entry* list1_array;
- struct logical_map_entry* list2_array;
- struct logical_map_entry* list_out_array;
- struct logical_map_entry* winner;
- struct logical_map_entry* loser;
- int list_out_array_count = 0;
- int64_t logical_offset;
-
- /* maximum size of merged array */
- if(list1_count > list2_count)
- list_out_array_count = list1_count * 3;
- else
- list_out_array_count = list2_count * 3;
-
- /* allocate linear arrays to use for sorting */
- list_out_array = malloc(list_out_array_count*sizeof(*list_out_array));
- list1_array = malloc(list1_count*sizeof(*list1_array));
- list2_array = malloc(list2_count*sizeof(*list2_array));
- /* TODO: err handling */
- assert(list_out_array && list1_array && list2_array);
-
- /* populate arrays */
- i=0;
- triton_list_for_each(iterator, scratch, list1_in)
- {
- tmp_entry = triton_list_get_entry(iterator, struct logical_map_entry,
- list_link);
- list1_array[i] = *tmp_entry;
- i++;
- }
- assert(i==list1_count);
- i=0;
- triton_list_for_each(iterator, scratch, list2_in)
- {
- tmp_entry = triton_list_get_entry(iterator, struct logical_map_entry,
- list_link);
- list2_array[i] = *tmp_entry;
- i++;
- }
- assert(i==list2_count);
-
- /* sort arrays */
- qsort(list1_array, list1_count, sizeof(struct logical_map_entry),
- cmp_lme);
- qsort(list2_array, list2_count, sizeof(struct logical_map_entry),
- cmp_lme);
-
- /* pick lowest logical offset to use for iterator */
- assert(list1_count || list2_count); /* at least one needs entries */
- if(list1_count == 0)
- logical_offset = list2_array[0].logical_offset;
- else if(list2_count == 0)
- logical_offset = list1_array[0].logical_offset;
- else
- {
- logical_offset = COSD_MIN(list1_array[0].logical_offset,
- list2_array[0].logical_offset);
- }
-
- /* loop through arrays and merge into output array */
- i=0;
- j=0;
- while(i<list1_count || j<list2_count)
- {
-
- /* consume any elements that have been entirely passed over */
- if(i < list1_count && list1_array[i].logical_offset_end <= logical_offset)
- {
- i++;
- continue;
- }
- if(j < list2_count && list2_array[j].logical_offset_end <= logical_offset)
- {
- j++;
- continue;
- }
-
- /* shave off the beginning of any extent that has been partially
- * passed over
- */
- if(i < list1_count && list1_array[i].logical_offset < logical_offset)
- {
- list1_array[i].size -= (logical_offset -
- list1_array[i].logical_offset);
- list1_array[i].log_offset += (logical_offset -
- list1_array[i].logical_offset);
- list1_array[i].logical_offset = logical_offset;
- }
- if(j < list2_count && list2_array[j].logical_offset < logical_offset)
- {
- list2_array[j].size -= (logical_offset -
- list2_array[j].logical_offset);
- list2_array[j].log_offset += (logical_offset -
- list2_array[j].logical_offset);
- list2_array[j].logical_offset = logical_offset;
- }
-
- /* if one list is already exhausted, then the other wins */
- if(i >= list1_count)
- {
- logical_offset = list2_array[j].logical_offset_end;
- list_out_array[k++] = list2_array[j++];
- continue;
- }
- if(j >= list2_count)
- {
- logical_offset = list1_array[i].logical_offset_end;
- list_out_array[k++] = list1_array[i++];
- continue;
- }
-
- /* pick winner for overlapped regions */
- if(list1_array[i].logical_offset == list2_array[j].logical_offset)
- {
- /* TODO: think about how to handle version wrap... */
- if(list1_array[i].version > list2_array[j].version)
- {
- winner = &list1_array[i];
- loser = &list2_array[j];
- }
- else
- {
- winner = &list2_array[j];
- loser = &list1_array[i];
- }
- list_out_array[k] = *winner;
- logical_offset = COSD_MIN(winner->logical_offset_end,
- loser->logical_offset_end);
- list_out_array[k].logical_offset_end = logical_offset;
- list_out_array[k].size = list_out_array[k].logical_offset_end -
- list_out_array[k].logical_offset;
- k++;
- continue;
- }
-
- /* pick easy winner for any non-overlapping regions */
- if(list1_array[i].logical_offset < list2_array[j].logical_offset)
- {
- winner = &list1_array[i];
- loser = &list2_array[j];
- }
- if(list2_array[j].logical_offset < list1_array[i].logical_offset)
- {
- winner = &list2_array[j];
- loser = &list1_array[i];
- }
- list_out_array[k] = *winner;
- logical_offset = COSD_MIN(winner->logical_offset_end,
- loser->logical_offset);
- list_out_array[k].logical_offset_end = logical_offset;
- list_out_array[k].size = list_out_array[k].logical_offset_end -
- list_out_array[k].logical_offset;
- k++;
- }
-
- /* TODO: assert that there is no overlap of extents _within_ either
- * input array
- */
-
- /* merge any adjacent entries in output array that have the same version
- * number. The above loop may have split some regions more than was
- * strictly needed
- */
- i=0;
- j=1;
- list_out_array_count = k;
- while(j<k)
- {
- if(list_out_array[i].logical_offset_end ==
- list_out_array[j].logical_offset &&
- list_out_array[i].version == list_out_array[j].version &&
- (list_out_array[i].log_offset + list_out_array[j].size ==
- list_out_array[j].log_offset))
- {
- list_out_array[i].size += list_out_array[j].size;
- list_out_array[i].logical_offset_end += list_out_array[j].size;
- list_out_array_count--;
- }
- else
- {
- i++;
- list_out_array[i] = list_out_array[j];
- }
- j++;
- }
-
- /* turn final array into a linked list */
- triton_list_init(list_out);
- for(i=0; i<list_out_array_count; i++)
- {
- triton_list_add_front(&list_out_array[i].list_link, list_out);
- }
- *free_ptr = list_out_array;
- free(list1_array);
- free(list2_array);
-
- return(0);
-}
-
-static int compare_log_map_key(DB * dbp, const DBT * a, const DBT * b)
-{
- struct logical_map_key* lmk_a;
- struct logical_map_key* lmk_b;
-
- lmk_a = (struct logical_map_key *) a->data;
- lmk_b = (struct logical_map_key *) b->data;
-
- /* oid takes precedence */
- if(lmk_a->oid > lmk_b->oid)
- return(1);
- if(lmk_a->oid < lmk_b->oid)
- return(-1);
-
- /* then ending offset within oid */
- if(lmk_a->logical_offset_end > lmk_b->logical_offset_end)
- return(1);
- if(lmk_a->logical_offset_end < lmk_b->logical_offset_end)
- return(-1);
-
- return 0;
-}
-
-static int compare_missing_version(DB * dbp, const DBT * a, const DBT * b)
-{
- struct missing_version* ver_a;
- struct missing_version* ver_b;
-
- ver_a = (struct missing_version *) a->data;
- ver_b = (struct missing_version *) b->data;
-
- /* oid takes precendenc */
- if(ver_a->oid > ver_b->oid)
- return 1;
- if(ver_a->oid < ver_b->oid)
- return -1;
-
- /* then version within oid */
- if(ver_a->version > ver_b->version)
- return 1;
- if(ver_a->version < ver_b->version)
- return -1;
-
- return(0);
-}
-
-static int compare_uint64(DB * dbp, const DBT * a, const DBT * b)
-{
- uint64_t* int_a;
- uint64_t* int_b;
-
- int_a = (uint64_t *) a->data;
- int_b = (uint64_t *) b->data;
-
- if(*int_a > *int_b)
- return(1);
- if(*int_a < *int_b)
- return(-1);
-
- return(0);
-}
-
-/* cmp_lme()
- *
- * logical map entry comparison function for qsort()
- */
-static int cmp_lme(const void *p1, const void *p2)
-{
- const struct logical_map_entry* lme1 = p1;
- const struct logical_map_entry* lme2 = p2;
-
- if(lme1->logical_offset < lme2->logical_offset)
- return(-1);
- if(lme1->logical_offset > lme2->logical_offset)
- return(1);
-
- return(0);
-}
-
-/*
- * Local variables:
- * c-indent-level: 4
- * c-basic-offset: 4
- * End:
- *
- * vim: ts=8 sts=4 sw=4 expandtab
- */
diff --git a/code/src/cosd/prototype/cosd-prototype.hae b/code/src/cosd/prototype/cosd-prototype.hae
deleted file mode 100644
index fa29f67..0000000
--- a/code/src/cosd/prototype/cosd-prototype.hae
+++ /dev/null
@@ -1,116 +0,0 @@
-#ifndef __COSD_PROTOTYPE_GSH__
-#define __COSD_PROTOTYPE_GSH__
-
-/** \defgroup COSD prototype
- *
- * This is a prototype COSD to be used for initial studies of the Grayskull
- * replication protocol.
- *
- * Notes:
- * - All functions return 0 on success or -errno on failure unless otherwise
- * noted
- * .
- * @{
- */
-
-/** \file
- * Declarations for COSD object storage resource.
- */
-
-#include "src/aesop/aesop.h"
-
-/** modes of making progress on posted storage operations */
-enum progress_mode
-{
- TRITON_PROG_NONE = 0, /**< invalid mode */
- TRITON_PROG_POLL, /**< requires active polling by client */
- TRITON_PROG_THREAD_PER_OP, /**< spawns new thread for each op */
- TRITON_PROG_THREAD_POOL, /**< uses pre-allocated thread pool */
- TRITON_PROG_MAX, /**< invalid mode */
-};
-
-/**
- * Initializes COSD interface
- */
-int triton_cosd_init(
- enum progress_mode mode, /**< progress mode */
- const char* path /**< local path to use for storing data,
- will be created if needed */
-);
-
-/**
- * Shuts down COSD interface
- */
-int triton_cosd_finalize(void);
-
-/**
- * Creates a new object
- * \return 0 on success, -errno on failure
- */
-__blocking int triton_cosd_create(
- uint64_t requested_oid, /**< requested identifier, a value of zero
- allows OSD to choose. */
- uint64_t* out_oid /**< assigned identifier */
-);
-
-/**
- * Retrieves current version number of object
- * \return 0 on success, -errno on failure
- */
-__blocking int triton_cosd_get_version(
- uint64_t oid, /**< object to operate on */
- uint64_t* version /**< version number of object */
-);
-
-/**
- * Opens a txn
- * \return 0 on success, -errno on failure
- */
-int triton_cosd_txn_open(
- uint64_t oid, /**< object to operate on */
- uint64_t txn_number /**< caller-assigned txn identifier */
-);
-
-/**
- * Closes a txn
- * \return 0 on success, -errno on failure
- */
-__blocking int triton_cosd_txn_close(
- uint64_t oid, /**< object to operate on */
- uint64_t txn_number /**< caller-assigned txn identifier */
-);
-
-/**
- * Writes data into an object
- * \return 0 on success, -errno on failure
- */
-__blocking int triton_cosd_write(
- uint64_t oid, /**< object to operate on */
- uint64_t txn_number, /**< txn identifier */
- char** mem_offsets, /**< memory region pointers */
- int64_t* mem_sizes, /**< memory region sizes */
- int mem_count, /**< memory region count */
- int64_t* obj_offsets, /**< object region offsets */
- int64_t* obj_sizes, /**< object region sizes */
- int obj_count /**< object region count */
-);
-
-
-/**
- * Dumps object version and log information from cosd to stdout
- * \return 0 on success, -errno on failure
- */
-__blocking int triton_cosd_dump(void);
-
-#endif
-
-/* @} */
-
-/*
- * Local variables:
- * c-indent-level: 4
- * c-basic-offset: 4
- * End:
- *
- * vim: ft=c ts=8 sts=4 sw=4 expandtab
- */
diff --git a/code/src/cosd/prototype/module.mk.in b/code/src/cosd/prototype/module.mk.in
deleted file mode 100644
index 9449bbd..0000000
--- a/code/src/cosd/prototype/module.mk.in
+++ /dev/null
@@ -1,6 +0,0 @@
-DIR := resources/cosd-prototype
-
-GSHDR += $(DIR)/cosd-prototype.hae
-LIBSRC += $(DIR)/cosd-prototype.c
-
-MODCFLATRITON_$(DIR) = @DB_CFLAGS@
diff --git a/code/src/cosd/prototype/test/4M-w-serial.txt b/code/src/cosd/prototype/test/4M-w-serial.txt
deleted file mode 100644
index 22c07a2..0000000
--- a/code/src/cosd/prototype/test/4M-w-serial.txt
+++ /dev/null
@@ -1,7 +0,0 @@
-# <op> <offset> <size>
-write 0 4194304
-write 4194304 4194304
-write 8388608 4194304
-write 12582912 4194304
-write 16777216 4194304
-write 20971520 4194304
diff --git a/code/src/cosd/prototype/test/README b/code/src/cosd/prototype/test/README
deleted file mode 100644
index 8b13789..0000000
--- a/code/src/cosd/prototype/test/README
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/code/src/cosd/prototype/test/cosd-bench-concurrent.ae b/code/src/cosd/prototype/test/cosd-bench-concurrent.ae
deleted file mode 100644
index bc5c8e5..0000000
--- a/code/src/cosd/prototype/test/cosd-bench-concurrent.ae
+++ /dev/null
@@ -1,235 +0,0 @@
-
-#include <stdio.h>
-#include <errno.h>
-#include "src/aesop/aesop.h"
-#include "src/cosd/prototype/cosd-prototype.hae"
-#include "triton-config.h"
-
-/* TODO: this needs to be in a header somewhere */
-#ifndef llu
-#if SIZEOF_LONG_INT == 4
-# define llu(x) (x)
-# define lld(x) (x)
-# define SCANF_lld lld
-#elif SIZEOF_LONG_INT == 8
-# define llu(x) (unsigned long long)(x)
-# define lld(x) (long long)(x)
-# define SCANF_lld ld
-#else
-# error Unexpected sizeof(long int)
-#endif
-#endif
-
-enum op_type
-{
- WRITE,
- READ
-};
-
-struct bench_op
-{
- int64_t offset;
- int64_t size;
- enum op_type type;
- struct triton_list_link list_link;
-};
-
-TRITON_LIST_DEFINE(op_list);
-triton_mutex_t op_list_mutex = TRITON_MUTEX_INITIALIZER;
-
-static __blocking int do_cosd_test(void)
-{
- int ret;
-
- uint64_t out_oid1;
- uint64_t version;
-
- ret = triton_cosd_create(1, &out_oid1);
- if(ret == -EEXIST)
- {
- printf("# operating on existing object.\n");
- }
- else if(ret != 0)
- {
- printf("Error creating oid=1: %d\n", ret);
- return 1;
- }
-
- ret = triton_cosd_get_version(1, &version);
- if(ret != 0)
- {
- printf("Error getting version number for oid=1: %d\n", ret);
- return(1);
- }
-
- pwait
- {
- int i;
- /* TODO: make "16" tunable */
- for(i=0; i<16; i++)
- {
- pbranch
- {
- struct triton_list_link* tmp_link;
- char* buffer = NULL;
- uint64_t b_version;
- struct bench_op* tmp_op;
- int b_ret;
- /* TODO: make buffer size configurable, and check that
- * nothing in workload desc is bigger than this
- */
- int64_t buffer_size = 4*1024*1024;
-
- buffer = malloc(buffer_size);
- assert(buffer);
-
- triton_mutex_lock(&op_list_mutex);
- while((tmp_link = triton_queue_dequeue(&op_list)) != NULL)
- {
- b_version = version++;
- triton_mutex_unlock(&op_list_mutex);
-
- tmp_op = triton_list_get_entry(tmp_link, struct bench_op,
- list_link);
- /* only writes for now */
- assert(tmp_op->type == WRITE);
- ret = triton_cosd_txn_open(1, b_version);
- if(ret != 0)
- {
- /* TODO: err handling */
- assert(0);
- }
-
- b_ret = triton_cosd_write(1, b_version, &buffer,
- &buffer_size, 1, &tmp_op->offset, &tmp_op->size, 1);
- if(b_ret < 0)
- {
- /* TODO: error handling */
- assert(0);
- }
-
- ret = triton_cosd_txn_close(1, b_version);
- if(ret != 0)
- {
- /* TODO: error handling */
- assert(0);
- }
-
- triton_mutex_lock(&op_list_mutex);
- }
- triton_mutex_unlock(&op_list_mutex);
-
- free(buffer);
- }
- }
- }
-
-#if 0
- ret = triton_cosd_dump();
- assert(ret == 0);
-#endif
- return 0;
-}
-
-int done = 0;
-
-static void done_callback(void *up, int ret)
-{
- done = 1;
-}
-
-
-int main(int argc, char *argv[])
-{
- triton_context_t ctx;
- triton_op_id_t op_id;
- int mode = TRITON_PROG_POLL;
- int pc = 0;
- FILE *desc = 0;
- char line[2048];
- char op_string[100];
- int64_t size;
- int64_t offset;
- int ret;
- struct bench_op* tmp_op;
-
- if(argc != 4)
- {
- fprintf(stderr, "Usage: cosd1 <1|2> <workload description file> <cosd dir>\n");
- fprintf(stderr, " # 1 for polling\n");
- fprintf(stderr, " # 2 for thread-per-op\n");
- return(-1);
- }
-
- sscanf(argv[1], "%d", &mode);
- if(mode > 2 || mode < 1)
- {
- fprintf(stderr, "Usage: cosd1 <1|2>\n");
- fprintf(stderr, " # 1 for polling\n");
- fprintf(stderr, " # 2 for thread-per-op\n");
- return(-1);
- }
-
- /* parse description of workload */
- desc = fopen(argv[2], "r");
- if(!desc)
- {
- perror("fopen");
- return(-1);
- }
- while(fgets(line, 2048, desc))
- {
- if(line[0] == '#')
- continue;
-#if SIZEOF_LONG_INT == 4
- ret = sscanf(line, "%s %lld %lld", op_string, &offset, &size);
-#else
- ret = sscanf(line, "%s %ld %ld", op_string, &offset, &size);
-#endif
- if(ret != 3)
- {
- fprintf(stderr, "Error: bad line: %s\n", line);
- return(-1);
- }
- tmp_op = malloc(sizeof(*tmp_op));
- assert(tmp_op);
-
- /* only writes for now */
- assert(strcmp(op_string, "write") == 0);
- tmp_op->type = WRITE;
- tmp_op->offset = offset;
- tmp_op->size = size;
- triton_queue_enqueue(&tmp_op->list_link, &op_list);
- }
- fclose(desc);
-
- if(mode == 1)
- printf("# Initializing cosd in poll-driven mode.\n");
- else
- printf("# Initializing cosd in thread-per-op mode.\n");
-
- triton_cosd_init(mode, argv[3]);
-
- triton_context_create(&ctx, 1, "cosd");
-
- done = 0;
- do_cosd_test_post(done_callback, NULL, NULL, ctx, &op_id);
- while(done == 0)
- {
- pc++;
- triton_poll(ctx, 10000);
- }
-
- triton_cosd_finalize();
- triton_context_destroy(ctx);
- return 0;
-}
-
-/*
- * Local variables:
- * c-indent-level: 4
- * c-basic-offset: 4
- * End:
- *
- * vim: ft=c ts=8 sts=4 sw=4 expandtab
- */
diff --git a/code/src/cosd/prototype/test/cosd1.ae b/code/src/cosd/prototype/test/cosd1.ae
deleted file mode 100644
index 7b2b51a..0000000
--- a/code/src/cosd/prototype/test/cosd1.ae
+++ /dev/null
@@ -1,236 +0,0 @@
-
-#include <stdio.h>
-#include <errno.h>
-#include "src/aesop/aesop.h"
-#include "src/cosd/prototype/cosd-prototype.hae"
-#include "triton-config.h"
-
-/* TODO: this needs to be in a header somewhere */
-#ifndef llu
-#if SIZEOF_LONG_INT == 4
-# define llu(x) (x)
-# define lld(x) (x)
-# define SCANF_lld "%lld"
-#elif SIZEOF_LONG_INT == 8
-# define llu(x) (unsigned long long)(x)
-# define lld(x) (long long)(x)
-# define SCANF_lld "%ld"
-#else
-# error Unexpected sizeof(long int)
-#endif
-#endif
-
-static __blocking int do_cosd_test(void)
-{
- int ret;
- char buffer[4096];
-
- int64_t buffer_szs[3];
- char* buffer_offsets[3];
- int64_t obj_offsets[3];
- int64_t obj_szs[3];
-
- uint64_t out_oid1;
- uint64_t version;
-
- printf("Creating oid 1 (if it doesn't already exist)...\n");
- ret = triton_cosd_create(1, &out_oid1);
- if(ret != 0 && ret != -EEXIST)
- {
- printf("Error creating oid=1: %d\n", ret);
- return 1;
- }
- printf("DONE\n");
-
- printf("Getting version number of oid 1...\n");
- ret = triton_cosd_get_version(1, &version);
- if(ret != 0)
- {
- printf("Error getting version number for oid=1: %d\n", ret);
- return(1);
- }
- printf("DONE: %llu\n", llu(version));
-
- ret = triton_cosd_dump();
- assert(ret == 0);
- /********************************************************/
- printf("opening txn...\n");
- ret = triton_cosd_txn_open(1, (version+1));
- if(ret != 0)
- {
- printf("Error opening txn 1: %d\n", ret);
- return 1;
- }
- printf("DONE\n");
-
- printf("writing 0-1024...\n");
- buffer_offsets[0] = buffer;
- buffer_szs[0] = 1024;
- obj_offsets[0] = 0;
- obj_szs[0] = 1024;
- ret = triton_cosd_write(1, (version+1), buffer_offsets, buffer_szs, 1,
- obj_offsets, obj_szs, 1);
- if(ret != 0)
- {
- printf("Error writing 0-1024: %d\n", ret);
- return 1;
- }
- printf("DONE\n");
-
- printf("closing txn...\n");
- ret = triton_cosd_txn_close(1, (version+1));
- if(ret != 0)
- {
- printf("Error closing txn 1: %d\n", ret);
- return 1;
- }
- printf("DONE\n");
-
- ret = triton_cosd_dump();
- assert(ret == 0);
- /********************************************************/
- printf("opening txn...\n");
- ret = triton_cosd_txn_open(1, (version+3));
- if(ret != 0)
- {
- printf("Error opening txn 1: %d\n", ret);
- return 1;
- }
- printf("DONE\n");
-
- printf("writing with listio (3 mem regions, 2 file regions)...\n");
- buffer_offsets[0] = buffer;
- buffer_offsets[1] = buffer+512;
- buffer_offsets[2] = buffer+768;
- buffer_szs[0] = 512;
- buffer_szs[1] = 256;
- buffer_szs[2] = 256;
- obj_offsets[0] = 1024;
- obj_offsets[1] = 2000;
- obj_szs[0] = 100;
- obj_szs[1] = 924;
- ret = triton_cosd_write(1, (version+3), buffer_offsets, buffer_szs, 3,
- obj_offsets, obj_szs, 2);
- if(ret != 0)
- {
- printf("Error writing with listio: %d\n", ret);
- return 1;
- }
- printf("DONE\n");
-
- printf("closing txn...\n");
- ret = triton_cosd_txn_close(1, (version+3));
- if(ret != 0)
- {
- printf("Error closing txn 1: %d\n", ret);
- return 1;
- }
- printf("DONE\n");
-
- ret = triton_cosd_dump();
- assert(ret == 0);
- /********************************************************/
- printf("opening txn...\n");
- ret = triton_cosd_txn_open(1, (version+2));
- if(ret != 0)
- {
- printf("Error opening txn 1: %d\n", ret);
- return 1;
- }
- printf("DONE\n");
-
- printf("writing bigger region with old version...\n");
- buffer_offsets[0] = buffer;
- buffer_szs[0] = 4096;
- obj_offsets[0] = 200;
- obj_szs[0] = 4096;
- ret = triton_cosd_write(1, (version+2), buffer_offsets, buffer_szs, 1,
- obj_offsets, obj_szs, 1);
- if(ret != 0)
- {
- printf("Error writing with listio: %d\n", ret);
- return 1;
- }
- printf("DONE\n");
-
- printf("closing txn...\n");
- ret = triton_cosd_txn_close(1, (version+2));
- if(ret != 0)
- {
- printf("Error closing txn 1: %d\n", ret);
- return 1;
- }
- printf("DONE\n");
-
-
-
- ret = triton_cosd_dump();
- assert(ret == 0);
- return 0;
-}
-
-int done = 0;
-
-static void done_callback(void *up, int ret)
-{
- done = 1;
-}
-
-
-int main(int argc, char *argv[])
-{
- triton_context_t ctx;
- triton_op_id_t op_id;
- int mode = TRITON_PROG_POLL;
- int pc = 0;
-
- if(argc != 2)
- {
- fprintf(stderr, "Usage: cosd1 <1|2>\n");
- fprintf(stderr, " # 1 for polling\n");
- fprintf(stderr, " # 2 for thread-per-op\n");
- return(-1);
- }
-
- sscanf(argv[1], "%d", &mode);
- if(mode > 2 || mode < 1)
- {
- fprintf(stderr, "Usage: cosd1 <1|2>\n");
- fprintf(stderr, " # 1 for polling\n");
- fprintf(stderr, " # 2 for thread-per-op\n");
- return(-1);
- }
-
- if(mode == 1)
- printf("Initializing cosd in poll-driven mode...\n");
- else
- printf("Initializing cosd in thread-per-op mode...\n");
-
- triton_cosd_init(mode, "/tmp/cosd");
- printf("Done.\n");
-
- triton_context_create(&ctx, 1, "cosd");
-
- done = 0;
- do_cosd_test_post(done_callback, NULL, NULL, ctx, &op_id);
- while(done == 0)
- {
- pc++;
- triton_poll(ctx, 10000);
- fflush(NULL);
- printf("polled %d times...\n", pc);
- }
-
- triton_cosd_finalize();
- triton_context_destroy(ctx);
- return 0;
-}
-
-/*
- * Local variables:
- * c-indent-level: 4
- * c-basic-offset: 4
- * End:
- *
- * vim: ft=c ts=8 sts=4 sw=4 expandtab
- */
diff --git a/code/src/cosd/prototype/test/module.mk.in b/code/src/cosd/prototype/test/module.mk.in
deleted file mode 100644
index 5b6d349..0000000
--- a/code/src/cosd/prototype/test/module.mk.in
+++ /dev/null
@@ -1,8 +0,0 @@
-DIR := resources/cosd-prototype/test
-
-AETESTSRC += $(DIR)/cosd1.ae
-AETESTSRC += $(DIR)/cosd-bench-concurrent.ae
-AETESTSRC += $(DIR)/workload-gen.ae
-
-MODLIBS_$(DIR) = -lpthread @DB_LIB@
-
diff --git a/code/src/cosd/prototype/test/workload-gen.ae b/code/src/cosd/prototype/test/workload-gen.ae
deleted file mode 100644
index f83c225..0000000
--- a/code/src/cosd/prototype/test/workload-gen.ae
+++ /dev/null
@@ -1,122 +0,0 @@
-#include <stdio.h>
-#include <errno.h>
-#include <assert.h>
-#include <stdlib.h>
-
-#include "src/aesop/aesop.h"
-#include "src/cosd/prototype/cosd-prototype.hae"
-#include "triton-config.h"
-
-
-/*
- * arguments:
- * ./workload-gen <total size> <op size> <l|r>
- */
-
-/* TODO: this needs to be in a header somewhere */
-#ifndef llu
-#if SIZEOF_LONG_INT == 4
-# define llu(x) (x)
-# define lld(x) (x)
-# define SCANF_lld lld
-#elif SIZEOF_LONG_INT == 8
-# define llu(x) (unsigned long long)(x)
-# define lld(x) (long long)(x)
-# define SCANF_lld ld
-#else
-# error Unexpected sizeof(long int)
-#endif
-#endif
-
-int main(int argc, char **argv)
-{
- int64_t total_size = -1;
- int64_t op_size = -1;
- int random_flag = 0;
- int op_count = 0;
- int64_t* offset_array;
- int i;
- int64_t current_offset = 0;
-
- if(argc != 4)
- {
- fprintf(stderr, "Usage: %s <total size> <op size> <l|r>\n",
- argv[0]);
- fprintf(stderr, " r=random, l=linear\n");
- return(-1);
- }
-
-#if SIZEOF_LONG_INT == 4
- sscanf(argv[1], "%lld", &total_size);
- sscanf(argv[2], "%lld", &op_size);
-#else
- sscanf(argv[1], "%ld", &total_size);
- sscanf(argv[2], "%ld", &op_size);
-#endif
-
- if(total_size < 1 || op_size < 1)
- {
- fprintf(stderr, "Usage: %s <total size> <op size> <l|r>\n",
- argv[0]);
- fprintf(stderr, " r=random, l=linear\n");
- return(-1);
- }
-
- if(strcmp(argv[3], "l") == 0)
- random_flag = 0;
- else if(strcmp(argv[3], "r") == 0)
- random_flag = 1;
- else
- {
- fprintf(stderr, "Usage: %s <total size> <op size> <l|r>\n",
- argv[0]);
- fprintf(stderr, " r=random, l=linear\n");
- return(-1);
- }
-
- if(total_size % op_size != 0)
- {
- fprintf(stderr, "Error: sizes must be evenly divisible.\n");
- return(-1);
- }
-
- op_count = total_size/op_size;
-
- /* allocate one big array with all of the offset */
- offset_array = malloc(op_count*sizeof(int64_t));
- assert(offset_array);
-
- for(i=0; i<op_count; i++)
- {
- offset_array[i] = current_offset;
- current_offset+= op_size;
- }
-
- if(random_flag && op_count > 1)
- {
- for(i=0; i<(op_count-1); i++)
- {
- int j = i + rand() / (RAND_MAX / (op_count-i) + 1);
- int64_t t = offset_array[j];
- offset_array[j] = offset_array[i];
- offset_array[i] = t;
- }
- }
-
- printf("# <op> <offset> <size>\n");
- for(i=0; i<op_count; i++)
- {
- printf("write\t%lld\t%lld\n", lld(offset_array[i]), lld(op_size));
- }
-
- return(0);
-}
-
-/*
- * Local variables:
- * c-indent-level: 4
- * c-basic-offset: 4
- * End:
- *
- * vim: ft=c ts=8 sts=4 sw=4 expandtab
- */
hooks/post-receive
--
Triton Repository
1
0
Triton Repository branch, master, updated. 662361693c4537a90d3dc0cd9b5aaa08588e6cb2
by noreply@mcs.anl.gov 24 Apr '10
by noreply@mcs.anl.gov 24 Apr '10
24 Apr '10
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Triton Repository".
The branch, master has been updated
via 662361693c4537a90d3dc0cd9b5aaa08588e6cb2 (commit)
via c568756ba28adf23e89bfe398987d5401640e3e8 (commit)
via 705d839eedd93b9c0dc59fc75c078be7721d0ee1 (commit)
via 5ae8a3de0f3e3951e3f62a9de10b79bcc0ba1cb0 (commit)
from c4d74ef3a992a37f38a92c0b258a8ccb5d40e816 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 662361693c4537a90d3dc0cd9b5aaa08588e6cb2
Author: Justin Wozniak <wozniak(a)mcs.anl.gov>
Date: Sat Apr 24 01:13:30 2010 -0500
Cleanups
commit c568756ba28adf23e89bfe398987d5401640e3e8
Author: Justin Wozniak <wozniak(a)mcs.anl.gov>
Date: Sat Apr 24 01:10:00 2010 -0500
Include strings as keys in testhash.c
commit 705d839eedd93b9c0dc59fc75c078be7721d0ee1
Author: Justin Wozniak <wozniak(a)mcs.anl.gov>
Date: Sat Apr 24 00:56:47 2010 -0500
New triton_hash_string_hash() for triton_strings
commit 5ae8a3de0f3e3951e3f62a9de10b79bcc0ba1cb0
Author: Justin Wozniak <wozniak(a)mcs.anl.gov>
Date: Sat Apr 24 00:54:36 2010 -0500
Minor bug fix and error check in triton-string
-----------------------------------------------------------------------
Summary of changes:
code/src/common/tests/testhash.c | 63 +++++++++++++++++++++++++++++++++++---
code/src/common/triton-hash.h | 11 ++++++
code/src/common/triton-string.h | 4 ++-
3 files changed, 72 insertions(+), 6 deletions(-)
Diff of changes:
diff --git a/code/src/common/tests/testhash.c b/code/src/common/tests/testhash.c
index facc902..6a0d078 100644
--- a/code/src/common/tests/testhash.c
+++ b/code/src/common/tests/testhash.c
@@ -2,6 +2,7 @@
#include <stdlib.h>
#include "src/common/triton-list.h"
#include "src/common/triton-hash.h"
+#include "src/common/triton-string.h"
struct e
{
@@ -9,6 +10,12 @@ struct e
triton_list_link_t link;
};
+struct s
+{
+ triton_string_t *v;
+ triton_list_link_t link;
+};
+
int e_compare(void *key, struct triton_hash_link *link)
{
int *value1 = (int *)key;
@@ -19,18 +26,28 @@ int e_compare(void *key, struct triton_hash_link *link)
return (value2->v == *value1);
}
+int s_compare(void *key, struct triton_hash_link *link)
+{
+ triton_string_t *value1 = (triton_string_t *)key;
+ struct s *value2 = triton_hash_get_entry(link, struct s, link);
+ assert(key);
+ assert(link);
+
+ return (!strcmp(value2->v->string, value1->string));
+}
+
void e_destroy(struct e *entry)
{}
int main(int argc, char *argv[])
{
- triton_list_t l;
struct triton_hash_table *table;
struct e *entry;
struct e *es;
+ struct s *ss;
struct triton_hash_link *result;
- // triton_list_link_t *p, *s;
- int i, testsize, delcount;
+ int i, j, testsize, hash;
+ triton_string_t *string;
assert(argc == 2);
@@ -40,10 +57,10 @@ int main(int argc, char *argv[])
es = malloc(sizeof(*es) * testsize);
- triton_list_init(&l);
+ // Begin integer tests...
+
table = triton_hash_init(e_compare, triton_hash_32bit_hash, 16);
- /* test push/pop */
for(i = 0; i < testsize; ++i)
{
es[i].v = i;
@@ -66,6 +83,42 @@ int main(int argc, char *argv[])
triton_hash_destroy_and_finalize(table, struct e, link, e_destroy);
+ // Begin string tests...
+
+ for (i = 0; i < 10; i++)
+ {
+ string = malloc(sizeof(triton_string_t));
+ triton_string_init(string, "string: _%d_", i);
+ hash = triton_hash_string_hash(string, 23);
+ printf("hash(\"%s\") -> %i\n", string->string, hash);
+ triton_string_destroy(string);
+ free(string);
+ }
+
+ table = triton_hash_init(s_compare, triton_hash_string_hash, 23);
+
+ for(i = 0; i < testsize; ++i)
+ {
+ ss = malloc(sizeof(*ss));
+ string = malloc(sizeof(triton_string_t));
+ triton_string_init(string, "[%i]", i);
+ ss->v = string;
+ triton_hash_add(table, string, &(ss->link));
+ }
+
+ assert(table->table_count == testsize);
+
+ for(i = 0; i < testsize; ++i)
+ {
+ string = malloc(sizeof(triton_string_t));
+ triton_string_init(string, "[%i]", i);
+ result = triton_hash_search(table, string);
+ ss = triton_hash_get_entry(result, struct s, link);
+ sscanf(ss->v->string, "[%i]", &j);
+ assert(i == j);
+ free(string);
+ }
+
free(es);
return 0;
}
diff --git a/code/src/common/triton-hash.h b/code/src/common/triton-hash.h
index bca9ca6..aeaa042 100644
--- a/code/src/common/triton-hash.h
+++ b/code/src/common/triton-hash.h
@@ -7,6 +7,7 @@
#define TRITON_HASH_H
#include "src/common/triton-list.h"
+#include "src/common/triton-string.h"
#include "src/common/triton-thread.h"
#include "src/common/jenkins-hash.h"
@@ -289,6 +290,16 @@ static inline int triton_hash_strhash(void *k, int table_size)
return pc & (table_size - 1);
}
+static inline int triton_hash_string_hash(void *k, int table_size)
+{
+ uint32_t pc = 0, pb = 0;
+ triton_string_t *s;
+ s = (triton_string_t *)k;
+ assert(s->string);
+ bj_hashlittle2(s->string, s->size, &pc, &pb);
+ return pc & (table_size - 1);
+}
+
#endif /* TRITON_HASH_H */
/*
diff --git a/code/src/common/triton-string.h b/code/src/common/triton-string.h
index a4572f7..b9feb35 100644
--- a/code/src/common/triton-string.h
+++ b/code/src/common/triton-string.h
@@ -18,6 +18,7 @@ typedef struct
static inline void triton_string_init(triton_string_t *s, const char *format, ...)
{
va_list ap, aap;
+ int err;
if(format)
{
va_start(ap, format);
@@ -25,7 +26,8 @@ static inline void triton_string_init(triton_string_t *s, const char *format, ..
s->size = vsnprintf(NULL, 0, format, ap) + 1;
va_end(ap);
s->string = malloc(s->size);
- vsnprintf(s->string, s->size, format, ap);
+ err = vsnprintf(s->string, s->size, format, aap);
+ assert(err >= 0 && err < s->size);
va_end(aap);
}
else
hooks/post-receive
--
Triton Repository
1
0
Triton Repository branch, master, updated. c4d74ef3a992a37f38a92c0b258a8ccb5d40e816
by noreply@mcs.anl.gov 23 Apr '10
by noreply@mcs.anl.gov 23 Apr '10
23 Apr '10
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Triton Repository".
The branch, master has been updated
via c4d74ef3a992a37f38a92c0b258a8ccb5d40e816 (commit)
from 3c8dbfa9382dd2dc2d2d072fab6f0813dc59ecfc (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit c4d74ef3a992a37f38a92c0b258a8ccb5d40e816
Author: Justin Wozniak <wozniak(a)mcs.anl.gov>
Date: Fri Apr 23 16:49:57 2010 -0500
Notifications basically work.
-----------------------------------------------------------------------
Summary of changes:
code/src/common/module.mk.in | 1 +
code/src/common/tests/testnoter.ae | 34 +++++++++++++++++++++------
code/src/common/triton-notify.c | 44 ++++++++++++++++++++++++++++++++++++
code/src/common/triton-notify.h | 24 ++++++++++++++++++-
4 files changed, 94 insertions(+), 9 deletions(-)
create mode 100644 code/src/common/triton-notify.c
Diff of changes:
diff --git a/code/src/common/module.mk.in b/code/src/common/module.mk.in
index f6828df..c5f2661 100644
--- a/code/src/common/module.mk.in
+++ b/code/src/common/module.mk.in
@@ -3,6 +3,7 @@ DIR := src/common
LIBSRC += $(DIR)/triton-error.c \
$(DIR)/triton-debug.c \
$(DIR)/triton-log.c \
+ $(DIR)/triton-notify.c \
$(DIR)/triton-string.c \
$(DIR)/lookup3.c
diff --git a/code/src/common/tests/testnoter.ae b/code/src/common/tests/testnoter.ae
index 236900c..bcfb558 100644
--- a/code/src/common/tests/testnoter.ae
+++ b/code/src/common/tests/testnoter.ae
@@ -4,23 +4,39 @@
#include "src/aesop/aesop.h"
#include "src/common/resources/timer/timer.hae"
#include "src/common/triton-notify.h"
+#include "src/common/triton-string.h"
bool exit_loop = false;
+void listener(triton_noter_t *noter, void *message)
+{
+ triton_string_t* string;
+ string = (triton_string_t *)message;
+ printf("received notification: %s\n", string->string);
+ exit_loop = true;
+}
+
+triton_noter_t *noter;
+
static __blocking int dotimer(void)
{
+ int count = 1;
+ triton_string_t *message;
+ noter = triton_noter_init(NULL);
pwait
{
pbranch
{
- int count = 0;
+ triton_noter_listen(noter, listener);
+
while(!exit_loop)
{
- printf("sleeping for 100 ms\n");
+ printf("listener sleeping for 100 ms\n");
triton_timer(100);
- printf("100 ms done.\n");
- if (count++ == 3)
+ printf("listener slept: %i00 ms\n", count);
+ if(count++ == 8)
{
+ printf("listener was not notified\n");
exit_loop = true;
}
}
@@ -28,9 +44,12 @@ static __blocking int dotimer(void)
pbranch
{
- printf("sleeping for 1000 ms\n");
- triton_timer(1000);
- printf("1000 ms done.\n");
+ message = malloc(sizeof(triton_string_t));
+ triton_string_init(message, "WAKE UP!");
+ printf("notifier sleeping for 500 ms\n");
+ triton_timer(500);
+ printf("notifier awake\n");
+ triton_notify(noter, message);
}
}
return 0;
@@ -56,7 +75,6 @@ int main(int argc, char *argv[])
while(done == 0)
{
ae_poll(ctx, 10);
- printf("polled %d times\n", ++pc);
}
ae_context_destroy(ctx);
diff --git a/code/src/common/triton-notify.c b/code/src/common/triton-notify.c
new file mode 100644
index 0000000..862379f
--- /dev/null
+++ b/code/src/common/triton-notify.c
@@ -0,0 +1,44 @@
+
+#include "triton-notify.h"
+
+triton_noter_t *triton_noter_init(void *context)
+{
+ triton_noter_t *noter;
+
+ noter = malloc(sizeof(triton_noter_t));
+ noter->listeners = malloc(sizeof(triton_list_t));
+ triton_list_init(noter->listeners);
+
+ return noter;
+}
+
+void triton_noter_listen(triton_noter_t *noter,
+ triton_listener_t listener)
+{
+ struct triton_listener_entry *entry;
+
+ entry = calloc(1, sizeof(triton_listener_entry_t));
+ entry->listener = listener;
+
+ triton_list_add_back(&(entry->link), noter->listeners);
+}
+
+void triton_notify(triton_noter_t *noter, void *message)
+{
+ triton_listener_entry_t *entry;
+ triton_listener_entry_t *scratch;
+
+ triton_list_for_each_entry(entry, scratch, noter->listeners, link)
+ {
+ entry->listener(noter, message);
+ }
+}
+
+/*
+ * Local variables:
+ * c-indent-level: 4
+ * c-basic-offset: 4
+ * End:
+ *
+ * vim: ts=8 sts=4 sw=4 expandtab
+ */
diff --git a/code/src/common/triton-notify.h b/code/src/common/triton-notify.h
index df7f280..78e4ddc 100644
--- a/code/src/common/triton-notify.h
+++ b/code/src/common/triton-notify.h
@@ -17,6 +17,28 @@ typedef struct
triton_list_t *listeners;
} triton_noter_t;
-typedef void(triton_listener_t)(triton_noter_t*);
+typedef void(*triton_listener_t)(triton_noter_t *noter, void *message);
+
+typedef struct triton_listener_entry
+{
+ triton_listener_t listener;
+ struct triton_list_link link;
+} triton_listener_entry_t;
+
+triton_noter_t *triton_noter_init(void *context);
+
+void triton_noter_listen(triton_noter_t *noter,
+ triton_listener_t listener);
+
+void triton_notify(triton_noter_t *noter, void *message);
#endif
+
+/*
+ * Local variables:
+ * c-indent-level: 4
+ * c-basic-offset: 4
+ * End:
+ *
+ * vim: ts=8 sts=4 sw=4 expandtab
+ */
hooks/post-receive
--
Triton Repository
1
0
Triton Repository branch, master, updated. 3c8dbfa9382dd2dc2d2d072fab6f0813dc59ecfc
by noreply@mcs.anl.gov 23 Apr '10
by noreply@mcs.anl.gov 23 Apr '10
23 Apr '10
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Triton Repository".
The branch, master has been updated
via 3c8dbfa9382dd2dc2d2d072fab6f0813dc59ecfc (commit)
from 9f80f86d7ca0286e101c0e842a755a01e6ad15a5 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 3c8dbfa9382dd2dc2d2d072fab6f0813dc59ecfc
Author: Phil Carns <carns(a)mcs.anl.gov>
Date: Fri Apr 23 17:04:00 2010 -0400
stub for vosd_read()
-----------------------------------------------------------------------
Summary of changes:
code/src/versioned-osd/prototype/versioned-osd.ae | 17 +++++++++++++
code/src/versioned-osd/prototype/versioned-osd.hae | 25 +++++++++----------
2 files changed, 29 insertions(+), 13 deletions(-)
Diff of changes:
diff --git a/code/src/versioned-osd/prototype/versioned-osd.ae b/code/src/versioned-osd/prototype/versioned-osd.ae
index a109ca0..c25789a 100644
--- a/code/src/versioned-osd/prototype/versioned-osd.ae
+++ b/code/src/versioned-osd/prototype/versioned-osd.ae
@@ -1229,10 +1229,27 @@ __blocking triton_ret_t vosd_txn_close(
}
/* TODO: any cleanup steps if we failed to close the txn? */
+ /* For now just assume that we leave the txn as is */
return(tret);
}
+__blocking triton_ret_t gs_cosd_read(
+ uint64_t oid,
+ uint64_t fork,
+ char** mem_offsets,
+ int64_t* mem_sizes,
+ int mem_count,
+ int64_t* obj_offsets,
+ int64_t* obj_sizes,
+ int obj_count,
+ int64_t* out_size)
+{
+
+ return(TRITON_ERR_NOSYS);
+}
+
+
static int compare_log_map_key(DB * dbp, const DBT * a, const DBT * b)
diff --git a/code/src/versioned-osd/prototype/versioned-osd.hae b/code/src/versioned-osd/prototype/versioned-osd.hae
index 94983be..d43c3f0 100644
--- a/code/src/versioned-osd/prototype/versioned-osd.hae
+++ b/code/src/versioned-osd/prototype/versioned-osd.hae
@@ -91,22 +91,10 @@ __blocking triton_ret_t vosd_txn_close(
uint64_t txn_number /**< caller-assigned txn identifier */
);
-
-#if 0
-
-/**
- * Removes an existing object
- * \return 0 on success, -errno on failure
- */
-__blocking int gs_cosd_remove(
- uint64_t oid /**< oid to remove */
-);
-
/**
* Reads data from an object
- * \return 0 on success, -errno on failure
*/
-__blocking int gs_cosd_read(
+__blocking triton_ret_t gs_cosd_read(
uint64_t oid, /**< object to operate on */
uint64_t fork, /**< object fork to operate on */
char** mem_offsets, /**< memory region pointers */
@@ -119,6 +107,17 @@ __blocking int gs_cosd_read(
);
+
+#if 0
+
+/**
+ * Removes an existing object
+ * \return 0 on success, -errno on failure
+ */
+__blocking int gs_cosd_remove(
+ uint64_t oid /**< oid to remove */
+);
+
#endif
#endif /* __VERSIONED_OSD_HAE__ */
hooks/post-receive
--
Triton Repository
1
0