Lines Matching refs:transaction

80 	cache_transaction* transaction;
176 /*! Checks whether or not this is an event that closes a transaction. */
251 set_notification(cache_transaction* transaction,
255 notification.transaction_id = transaction != NULL ? transaction->id : -1;
306 /*! Notifies all interested listeners of this transaction about the \a event.
312 notify_transaction_listeners(block_cache* cache, cache_transaction* transaction,
318 ListenerList::Iterator iterator = transaction->listeners.GetIterator();
334 // most transaction events, we can do it here.
340 transaction.
343 remove_transaction_listeners(block_cache* cache, cache_transaction* transaction)
345 ListenerList::Iterator iterator = transaction->listeners.GetIterator();
356 add_transaction_listener(block_cache* cache, cache_transaction* transaction,
359 ListenerList::Iterator iterator = transaction->listeners.GetIterator();
374 set_notification(transaction, *listener, events, hookFunction, data);
375 transaction->listeners.Add(listener);
380 // #pragma mark - private transaction
399 cache_transaction* transaction = (cache_transaction*)_transaction;
402 return transaction->id - *id;
409 cache_transaction* transaction = (cache_transaction*)_transaction;
412 if (transaction != NULL)
413 return transaction->id % range;
420 delete_transaction(block_cache* cache, cache_transaction* transaction)
422 if (cache->last_transaction == transaction)
425 remove_transaction_listeners(cache, transaction);
426 delete transaction;
580 block->transaction = block->previous_transaction = NULL;
631 /*! Discards the block from a transaction (this method must not be called
632 for blocks not part of a transaction).
678 && block->transaction == NULL && block->previous_transaction == NULL) {
679 // This block is not used anymore, and not part of any transaction
772 This is the only method to insert a block into a transaction. It makes
779 TRACE(("get_writable_cached_block(blockNumber = %lld, transaction = %d)\n",
798 // if there is no transaction support, we just return the current block
810 cache_transaction* transaction = block->transaction;
812 if (transaction != NULL && transaction->id != transactionID) {
813 // TODO: we have to wait here until the other transaction is done.
815 fssh_panic("get_writable_cached_block(): asked to get busy writable block (transaction %d)\n", (int)transaction->id);
819 if (transaction == NULL && transactionID != -1) {
820 // get new transaction
821 transaction = lookup_transaction(cache, transactionID);
822 if (transaction == NULL) {
823 fssh_panic("get_writable_cached_block(): invalid transaction %d!\n",
828 if (!transaction->open) {
829 fssh_panic("get_writable_cached_block(): transaction already done!\n");
834 block->transaction = transaction;
836 // attach the block to the transaction block list
837 block->transaction_next = transaction->first_block;
838 transaction->first_block = block;
839 transaction->num_blocks++;
857 // remember any previous contents for the parent transaction
860 // TODO: maybe we should just continue the current transaction in this case...
867 transaction->sub_num_blocks++;
868 } else if (transaction != NULL && transaction->has_sub_transaction
870 transaction->sub_num_blocks++;
883 the oldest change of the block if it is part of more than one transaction.
917 if (block->original_data != NULL && block->transaction == NULL) {
918 // This block is not part of a transaction, so it does not need
926 TRACE(("cache transaction %ld finished!\n", previous->id));
936 if (block->transaction == NULL && block->ref_count == 0 && !block->unused) {
968 // #pragma mark - public transaction API
981 fssh_panic("last transaction (%d) still open!\n",
985 cache_transaction* transaction = new(nothrow) cache_transaction;
986 if (transaction == NULL)
989 transaction->id = fssh_atomic_add(&cache->next_transaction_id, 1);
990 cache->last_transaction = transaction;
992 TRACE(("cache_start_transaction(): id %d started\n", transaction->id));
994 hash_insert(cache->transaction_hash, transaction);
996 return transaction->id;
1012 cache_transaction* transaction;
1013 while ((transaction = (cache_transaction*)hash_next(
1017 if (transaction->id <= id && !transaction->open) {
1019 while (transaction->num_blocks > 0) {
1020 status = write_cached_block(cache, transaction->blocks.Head(),
1027 delete_transaction(cache, transaction);
1050 cache_transaction* transaction = lookup_transaction(cache, id);
1051 if (transaction == NULL) {
1052 fssh_panic("cache_end_transaction(): invalid transaction ID\n");
1056 notify_transaction_listeners(cache, transaction, FSSH_TRANSACTION_ENDED);
1058 if (add_transaction_listener(cache, transaction, FSSH_TRANSACTION_WRITTEN,
1065 cached_block* block = transaction->first_block;
1075 // This block has been discarded in the transaction
1077 transaction->num_blocks--;
1085 if (transaction->has_sub_transaction) {
1091 // move the block to the previous transaction list
1092 transaction->blocks.Add(block);
1094 block->previous_transaction = transaction;
1096 block->transaction = NULL;
1099 transaction->open = false;
1112 cache_transaction* transaction = lookup_transaction(cache, id);
1113 if (transaction == NULL) {
1114 fssh_panic("cache_abort_transaction(): invalid transaction ID\n");
1118 notify_transaction_listeners(cache, transaction, FSSH_TRANSACTION_ABORTED);
1122 cached_block* block = transaction->first_block;
1129 transaction->id, block->block_number));
1134 if (transaction->has_sub_transaction) {
1141 block->transaction = NULL;
1145 hash_remove(cache->transaction_hash, transaction);
1146 delete_transaction(cache, transaction);
1151 /*! Acknowledges the current parent transaction, and starts a new transaction
1152 from its sub transaction.
1153 The new transaction also gets a new transaction ID.
1164 cache_transaction* transaction = lookup_transaction(cache, id);
1165 if (transaction == NULL) {
1166 fssh_panic("cache_detach_sub_transaction(): invalid transaction ID\n");
1169 if (!transaction->has_sub_transaction)
1172 // create a new transaction for the sub transaction
1179 notify_transaction_listeners(cache, transaction, FSSH_TRANSACTION_ENDED);
1181 if (add_transaction_listener(cache, transaction, FSSH_TRANSACTION_WRITTEN,
1189 cached_block* block = transaction->first_block;
1201 transaction->main_num_blocks--;
1206 // free the original data if the parent data of the transaction
1213 // we need to move this block over to the new transaction
1220 block->transaction = newTransaction;
1223 block->transaction = NULL;
1226 // move the block to the previous transaction list
1227 transaction->blocks.Add(block);
1228 block->previous_transaction = transaction;
1235 newTransaction->num_blocks = transaction->sub_num_blocks;
1237 transaction->open = false;
1238 transaction->has_sub_transaction = false;
1239 transaction->num_blocks = transaction->main_num_blocks;
1240 transaction->sub_num_blocks = 0;
1257 cache_transaction* transaction = lookup_transaction(cache, id);
1258 if (transaction == NULL) {
1259 fssh_panic("cache_abort_sub_transaction(): invalid transaction ID\n");
1262 if (!transaction->has_sub_transaction)
1265 notify_transaction_listeners(cache, transaction, FSSH_TRANSACTION_ABORTED);
1269 cached_block* block = transaction->first_block;
1276 // the parent transaction didn't change the block, but the sub
1277 // transaction did - we need to revert from the original data
1284 transaction->id, block->block_number));
1294 // all subsequent changes will go into the main transaction
1295 transaction->has_sub_transaction = false;
1296 transaction->sub_num_blocks = 0;
1310 cache_transaction* transaction = lookup_transaction(cache, id);
1311 if (transaction == NULL) {
1312 fssh_panic("cache_start_sub_transaction(): invalid transaction ID %d\n", (int)id);
1316 notify_transaction_listeners(cache, transaction, FSSH_TRANSACTION_ENDED);
1320 cached_block* block = transaction->first_block;
1327 // This block has been discarded in the parent transaction
1331 transaction->first_block = next;
1334 transaction->num_blocks--;
1337 if (transaction->has_sub_transaction
1340 // there already is an older sub transaction - we acknowledge
1351 // all subsequent changes will go into the sub transaction
1352 transaction->has_sub_transaction = true;
1353 transaction->main_num_blocks = transaction->num_blocks;
1354 transaction->sub_num_blocks = 0;
1360 /*! Adds a transaction listener that gets notified when the transaction
1392 cache_transaction* transaction = lookup_transaction(cache, id);
1393 if (transaction == NULL || !transaction->open)
1397 block = transaction->first_block;
1401 if (transaction->has_sub_transaction) {
1434 cache_transaction* transaction = lookup_transaction(cache, id);
1435 if (transaction == NULL)
1438 return transaction->num_blocks;
1448 cache_transaction* transaction = lookup_transaction(cache, id);
1449 if (transaction == NULL)
1452 return transaction->main_num_blocks;
1462 cache_transaction* transaction = lookup_transaction(cache, id);
1463 if (transaction == NULL)
1466 return transaction->sub_num_blocks;
1479 return (block != NULL && block->transaction != NULL
1480 && block->transaction->id == id);
1509 cache_transaction* transaction;
1510 while ((transaction = (cache_transaction*)hash_remove_first(
1512 delete transaction;
1542 // transaction or no transaction only
1551 || (block->transaction == NULL && block->is_dirty)) {
1570 // transaction or no transaction only
1587 || (block->transaction == NULL && block->is_dirty)) {
1618 if (block->transaction != NULL && block->parent_data != NULL
1621 "been changed in this transaction!", blockNumber);
1624 // mark it as discarded (in the current transaction only, if any)
1633 int32_t transaction)
1644 blockNumber, 1, transaction, false, &block);
1656 fssh_off_t base, fssh_off_t length, int32_t transaction, void** _block)
1661 TRACE(("block_cache_get_writable_etc(block = %lld, transaction = %ld)\n",
1662 blockNumber, transaction));
1667 transaction, false, _block);
1673 int32_t transaction)
1677 blockNumber, blockNumber, 1, transaction, &block);
1687 int32_t transaction)
1692 TRACE(("block_cache_get_empty(block = %lld, transaction = %ld)\n",
1693 blockNumber, transaction));
1699 blockNumber, 1, transaction, true, &block) == FSSH_B_OK)
1752 int32_t transaction)