transactions now can check with allocation policy before allocating to pages of their own choosing
This commit is contained in:
parent
fa18df2424
commit
71cc9d6df7
2 changed files with 21 additions and 0 deletions
|
@ -302,6 +302,23 @@ availablePage * allocationPolicyFindPage(allocationPolicy * ap, int xid, int fre
|
||||||
return (availablePage*) ret;
|
return (availablePage*) ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int allocationPolicyCanXidAllocFromPage(allocationPolicy *ap, int xid, pageid_t page) {
|
||||||
|
availablePage * p = getAvailablePage(ap, page);
|
||||||
|
const availablePage * check1 = RB_ENTRY(find)(p, ap->availablePages);
|
||||||
|
int * xidp = LH_ENTRY(find)(ap->pageOwners, &(page), sizeof(page));
|
||||||
|
if(!(xidp || check1)) {
|
||||||
|
// the page is not available, and not owned.
|
||||||
|
return 0; // can't safely alloc from page
|
||||||
|
}
|
||||||
|
if(check1) {
|
||||||
|
// the page is available and unlocked
|
||||||
|
return 1; // can safely alloc from page
|
||||||
|
} else {
|
||||||
|
// someone owns the page. Is it this xid?
|
||||||
|
return (*xidp == xid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void allocationPolicyAllocedFromPage(allocationPolicy *ap, int xid, pageid_t page) {
|
void allocationPolicyAllocedFromPage(allocationPolicy *ap, int xid, pageid_t page) {
|
||||||
availablePage * p = getAvailablePage(ap, page);
|
availablePage * p = getAvailablePage(ap, page);
|
||||||
const availablePage * check1 = RB_ENTRY(find)(p, ap->availablePages);
|
const availablePage * check1 = RB_ENTRY(find)(p, ap->availablePages);
|
||||||
|
|
|
@ -365,6 +365,10 @@ compensated_function recordid TallocFromPage(int xid, pageid_t page, unsigned lo
|
||||||
}
|
}
|
||||||
|
|
||||||
pthread_mutex_lock(&talloc_mutex);
|
pthread_mutex_lock(&talloc_mutex);
|
||||||
|
if(!allocationPolicyCanXidAllocFromPage(allocPolicy, xid, page)) {
|
||||||
|
pthread_mutex_unlock(&talloc_mutex);
|
||||||
|
return NULLRID;
|
||||||
|
}
|
||||||
Page * p = loadPage(xid, page);
|
Page * p = loadPage(xid, page);
|
||||||
writelock(p->rwlatch,0);
|
writelock(p->rwlatch,0);
|
||||||
recordid rid = stasis_record_alloc_begin(xid, p, type);
|
recordid rid = stasis_record_alloc_begin(xid, p, type);
|
||||||
|
|
Loading…
Reference in a new issue