+// Get most recent committed version prior to our read version.
+uint64_t tm_get (txn_t *txn, void *key) {
+
+ // Iterate through update records associated with <key> to find the latest committed version prior to our
+ // read version.
+ update_rec_t *update = (update_rec_t *) map_get(txn->map, key);
+ for (; update != NULL; update = update->next) {
+
+ // If the update's version is not tagged it means the update is committed.
+ if (!IS_TAGGED(update->version)) {
+ if (update->version <= txn->rv)
+ break; // success
+ continue;
+ }
+
+ // If the update's version is tagged then either the update was aborted or the the version number is
+ // actually a pointer to a running transaction's txn_t.
+
+ // Skip updates from aborted transactions.
+ if (EXPECT_FALSE(update->version == ABORTED_VERSION))
+ continue;
+
+ // The update's transaction is still in progress. Access its txn_t.
+ txn_t *writer = (txn_t *)STRIP_TAG(update->version);
+ if (writer == txn) // found our own update
+ break; // success
+
+ txn_state_e writer_state = writer->state;
+ if (writer_state == TXN_RUNNING)
+ continue;
+
+ if (writer_state == TXN_VALIDATING) {
+ if (writer->wv > txn->rv)
+ continue;
+ writer_state = txn_validate(writer);
+ }
+
+ // Skip updates from aborted transactions.
+ if (writer_state == TXN_ABORTED)
+ continue;
+
+ assert(writer_state == TXN_VALIDATED);
+ if (writer->wv > txn->rv)
+ continue;
+ break; // success
+ }
+
+ if (EXPECT_FALSE(update == NULL))
+ return DOES_NOT_EXIST;
+
+ // collect some garbage
+ update_rec_t *next = update->next;
+ if (next != NULL) {
+ uint64_t min_active_version = (uint64_t)sl_min_key(active_);
+ if (next->version < min_active_version) {
+ next = SYNC_SWAP(&update->next, NULL);
+ while (next != NULL) {
+ update = next;
+ next = NULL;
+ if (update->next != NULL) {
+ next = SYNC_SWAP(&update->next, NULL);
+ }
+ nbd_free(update);
+ }
+ }
+ }
+
+ return update->value;
+}
+
+void tm_set (txn_t *txn, void *key, uint64_t value) {