2006-07-29 00:56:54 +00:00
|
|
|
#ifndef ALLOCATION_POLICY_H
|
|
|
|
#define ALLOCATION_POLICY_H
|
|
|
|
|
2008-10-03 02:42:25 +00:00
|
|
|
#include <stasis/common.h>
|
|
|
|
|
2006-07-29 00:56:54 +00:00
|
|
|
struct allocationPolicy;
|
|
|
|
typedef struct allocationPolicy allocationPolicy;
|
|
|
|
|
|
|
|
typedef struct availablePage {
|
|
|
|
int freespace;
|
2008-10-03 02:42:25 +00:00
|
|
|
pageid_t pageid;
|
2006-08-10 23:39:36 +00:00
|
|
|
int lockCount; // Number of active transactions that have alloced or dealloced from this page.
|
2006-07-29 00:56:54 +00:00
|
|
|
} availablePage;
|
|
|
|
|
|
|
|
allocationPolicy * allocationPolicyInit();
|
2006-08-10 23:39:36 +00:00
|
|
|
void allocationPolicyDeinit(allocationPolicy * ap);
|
2006-07-29 00:56:54 +00:00
|
|
|
void allocationPolicyAddPages(allocationPolicy * ap, availablePage** newPages);
|
|
|
|
availablePage * allocationPolicyFindPage(allocationPolicy * ap, int xid, int freespace);
|
|
|
|
void allocationPolicyTransactionCompleted(allocationPolicy * ap, int xid);
|
|
|
|
void allocationPolicyUpdateFreespaceUnlockedPage(allocationPolicy * ap, availablePage * key, int newFree);
|
|
|
|
void allocationPolicyUpdateFreespaceLockedPage(allocationPolicy * ap, int xid, availablePage * key, int newFree);
|
2008-10-03 02:42:25 +00:00
|
|
|
void allocationPolicyLockPage(allocationPolicy * ap, int xid, pageid_t page);
|
2008-10-27 23:30:53 +00:00
|
|
|
void allocationPolicyAllocedFromPage(allocationPolicy * ap, int xid, pageid_t page);
|
|
|
|
/**
|
|
|
|
Check to see if it is safe to allocate from a particular page.
|
|
|
|
|
|
|
|
If concurrent transactions have freed up space on a page, but they
|
|
|
|
eventually abort, then it might not be safe for the current
|
|
|
|
transaction to reuse the storage those transactions freed. This is
|
|
|
|
needed for methods such as TallocFromPage(), which do not consult
|
|
|
|
allocation policy before deciding where to attempt allocation.
|
|
|
|
|
|
|
|
@param ap The allocation policy managing the space in question
|
|
|
|
@param xid The transaction that wants to allocate space from the page
|
|
|
|
@param page The page that will be allocated from.
|
|
|
|
@return true if the allocation would be safe. false if not sure.
|
|
|
|
*/
|
|
|
|
int allocationPolicyCanXidAllocFromPage(allocationPolicy * ap, int xid, pageid_t page);
|
2006-07-29 00:56:54 +00:00
|
|
|
#endif // ALLOCATION_POLICY_H
|