Renamed physical_slot_length

This commit is contained in:
Sears Russell 2007-10-03 01:53:51 +00:00
parent 7fb4fd4c1a
commit 22c89bb3fe
7 changed files with 31 additions and 30 deletions

View file

@ -45,7 +45,7 @@ terms specified in this license.
#include <assert.h>
#include "page.h" // For physical_slot_length()
#include "page.h" // For stasis_record_type_to_size()
#include <stasis/logger/logger2.h> // needed for LoggerSizeOfInternalLogEntry()
#include <stasis/logger/logEntry.h>
@ -98,7 +98,7 @@ LogEntry * allocUpdateLogEntry(lsn_t prevLSN, int xid,
LogEntry * ret = calloc(1, sizeof(struct __raw_log_entry) +
sizeof(UpdateLogEntry) + argSize +
((!invertible) ? physical_slot_length(rid.size)
((!invertible) ? stasis_record_type_to_size(rid.size)
: 0) +
(whole_page_phys ? PAGE_SIZE
: 0));
@ -115,7 +115,7 @@ LogEntry * allocUpdateLogEntry(lsn_t prevLSN, int xid,
}
if(!invertible) {
memcpy((void*)getUpdatePreImage(ret), preImage,
physical_slot_length(rid.size));
stasis_record_type_to_size(rid.size));
}
if(whole_page_phys) {
memcpy((void*)getUpdatePreImage(ret), preImage,
@ -159,7 +159,7 @@ long sizeofLogEntry(const LogEntry * log) {
int undoType = operationsTable[log->update.funcID].undo;
return sizeof(struct __raw_log_entry) +
sizeof(UpdateLogEntry) + log->update.argSize +
((undoType == NO_INVERSE) ? physical_slot_length(log->update.rid.size)
((undoType == NO_INVERSE) ? stasis_record_type_to_size(log->update.rid.size)
: 0) +
((undoType == NO_INVERSE_WHOLE_PAGE) ? PAGE_SIZE : 0);
}

View file

@ -305,15 +305,15 @@ static LogEntry * LogAction(TransactionLog * l, Page * p, recordid rid, int oper
argSize = operationsTable[operation].sizeofData;
if(argSize == SIZEOF_RECORD) argSize = physical_slot_length(rid.size);
if(argSize == SIZEOF_RECORD) argSize = stasis_record_type_to_size(rid.size);
if(argSize == SIZEIS_PAGEID) argSize = rid.page;
int undoType = operationsTable[operation].undo;
if(undoType == NO_INVERSE) {
DEBUG("Creating %ld byte physical pre-image.\n", physical_slot_length(rid.size));
DEBUG("Creating %ld byte physical pre-image.\n", stasis_record_type_to_size(rid.size));
preImage = malloc(physical_slot_length(rid.size));
preImage = malloc(stasis_record_type_to_size(rid.size));
stasis_record_read(l->xid, p, rid, preImage);
} else if (undoType == NO_INVERSE_WHOLE_PAGE) {
DEBUG("Logging entire page\n");

View file

@ -82,7 +82,7 @@ static int operate_helper(int xid, Page * p, recordid rid, const void * dat) {
stasis_record_alloc_done(xid, p, rid);
}
assert(stasis_record_length_read(xid, p, rid) == physical_slot_length(rid.size));
assert(stasis_record_length_read(xid, p, rid) == stasis_record_type_to_size(rid.size));
if(rid.size < 0) {
assert(stasis_record_type_read(xid,p,rid) == rid.size);
}
@ -210,21 +210,21 @@ compensated_function recordid Talloc(int xid, unsigned long size) {
pthread_mutex_lock(&talloc_mutex);
Page * p;
availablePage * ap = allocationPolicyFindPage(allocPolicy, xid, physical_slot_length(type));
availablePage * ap = allocationPolicyFindPage(allocPolicy, xid, stasis_record_type_to_size(type));
if(!ap) {
reserveNewRegion(xid);
ap = allocationPolicyFindPage(allocPolicy, xid, physical_slot_length(type));
ap = allocationPolicyFindPage(allocPolicy, xid, stasis_record_type_to_size(type));
}
lastFreepage = ap->pageid;
p = loadPage(xid, lastFreepage);
writelock(p->rwlatch, 0);
while(stasis_record_freespace(xid, p) < physical_slot_length(type)) {
while(stasis_record_freespace(xid, p) < stasis_record_type_to_size(type)) {
stasis_record_compact(p);
int newFreespace = stasis_record_freespace(xid, p);
if(newFreespace >= physical_slot_length(type)) {
if(newFreespace >= stasis_record_type_to_size(type)) {
break;
}
@ -233,11 +233,11 @@ compensated_function recordid Talloc(int xid, unsigned long size) {
releasePage(p);
ap = allocationPolicyFindPage(allocPolicy, xid, physical_slot_length(type));
ap = allocationPolicyFindPage(allocPolicy, xid, stasis_record_type_to_size(type));
if(!ap) {
reserveNewRegion(xid);
ap = allocationPolicyFindPage(allocPolicy, xid, physical_slot_length(type));
ap = allocationPolicyFindPage(allocPolicy, xid, stasis_record_type_to_size(type));
}
lastFreepage = ap->pageid;

View file

@ -360,7 +360,7 @@ static const byte * blkNext(block_t * b) {
}
static int blkSize(block_t * b) {
genericBlockImpl * impl = b->impl;
return physical_slot_length(impl->pos.size);
return stasis_record_type_to_size(impl->pos.size);
}
static void blkRelease(block_t * b) {
free(b->impl);

View file

@ -391,7 +391,8 @@ static const size_t USABLE_SIZE_OF_PAGE = (PAGE_SIZE - sizeof(lsn_t) - sizeof(in
@return The length of the record in bytes.
*/
static inline size_t physical_slot_length(ssize_t type) {
static inline size_t
stasis_record_type_to_size(ssize_t type) {
return type >= 0 ? type : SLOT_TYPE_LENGTHS[0 - type];
}

View file

@ -70,14 +70,14 @@ static void fixedSetType(int xid, Page *p, recordid rid, int type) {
assertlocked(p->rwlatch);
checkRid(p,rid);
assert(rid.slot < *recordcount_ptr(p));
assert(physical_slot_length(type) == physical_slot_length(*recordsize_ptr(p)));
assert(stasis_record_type_to_size(type) == stasis_record_type_to_size(*recordsize_ptr(p)));
*recordsize_ptr(p) = rid.size;
}
static int fixedGetLength(int xid, Page *p, recordid rid) {
assertlocked(p->rwlatch);
assert(*stasis_page_type_ptr(p));
return rid.slot > *recordcount_ptr(p) ?
INVALID_SLOT : physical_slot_length(*recordsize_ptr(p));
INVALID_SLOT : stasis_record_type_to_size(*recordsize_ptr(p));
}
static int notSupported(int xid, Page * p) { return 0; }
@ -86,7 +86,7 @@ static int fixedFreespace(int xid, Page * p) {
assertlocked(p->rwlatch);
if(stasis_fixed_records_per_page(*recordsize_ptr(p)) > *recordcount_ptr(p)) {
// Return the size of a slot; that's the biggest record we can take.
return physical_slot_length(*recordsize_ptr(p));
return stasis_record_type_to_size(*recordsize_ptr(p));
} else {
// Page full; return zero.
return 0;

View file

@ -103,7 +103,7 @@ static inline void slottedFsck(const Page const * page) {
short slot_offset = *slot_ptr(page, i);
if(slot_offset != INVALID_SLOT) {
const unsigned char ci = i % 0xFF;
short slot_len = physical_slot_length(*slot_length_ptr(page, i));
short slot_len = stasis_record_type_to_size(*slot_length_ptr(page, i));
for(short j = 0; j < slot_len; j++) {
assert(image[slot_offset + j] == 0xFF);
@ -161,7 +161,7 @@ static void slottedCompact(Page * page) {
lastFreeSlotBeforeUsedSlot = lastFreeSlot;
short logicalSize = *slot_length_ptr(page, i);
short physicalSize = physical_slot_length(logicalSize);
short physicalSize = stasis_record_type_to_size(logicalSize);
memcpy(&(buffer[*freespace_ptr(&bufPage)]), record_ptr(page, i), physicalSize);
@ -256,11 +256,11 @@ static void really_do_ralloc(Page * page, recordid rid) {
short freeSpace;
// Compact the page if we don't have enough room.
if(slottedFreespaceForSlot(page, rid.slot) < physical_slot_length(rid.size)) {
if(slottedFreespaceForSlot(page, rid.slot) < stasis_record_type_to_size(rid.size)) {
slottedCompact(page);
// Make sure we have enough enough free space for the new record
assert (slottedFreespaceForSlot(page, rid.slot) >= physical_slot_length(rid.size));
assert (slottedFreespaceForSlot(page, rid.slot) >= stasis_record_type_to_size(rid.size));
}
freeSpace = *freespace_ptr(page);
@ -354,7 +354,7 @@ static void really_do_ralloc(Page * page, recordid rid) {
// the slot header.
assert(rid.slot < *numslots_ptr(page));
*freespace_ptr(page) = freeSpace + physical_slot_length(rid.size);
*freespace_ptr(page) = freeSpace + stasis_record_type_to_size(rid.size);
*slot_ptr(page, rid.slot) = freeSpace;
*slot_length_ptr(page, rid.slot) = rid.size;
@ -400,11 +400,11 @@ static void slottedSetType(int xid, Page *p, recordid rid, int type) {
if(type == NORMAL_SLOT) {
// set slot_length_ptr to the physical length.
*slot_length_ptr(p, rid.slot) = physical_slot_length(old_type);
*slot_length_ptr(p, rid.slot) = stasis_record_type_to_size(old_type);
} else {
// Changing to a special slot type; make sure doing so doesn't change
// the record size.
assert(physical_slot_length(type) == physical_slot_length(old_type));
assert(stasis_record_type_to_size(type) == stasis_record_type_to_size(old_type));
*slot_length_ptr(p, rid.slot) = type;
}
}
@ -415,7 +415,7 @@ static int slottedGetLength(int xid, Page *p, recordid rid) {
if( slottedGetType(xid, p, rid) == INVALID_SLOT)
return INVALID_SLOT;
else
return physical_slot_length(*slot_length_ptr(p, rid.slot));
return stasis_record_type_to_size(*slot_length_ptr(p, rid.slot));
}
static recordid slottedNext(int xid, Page *p, recordid rid) {
@ -462,7 +462,7 @@ static recordid slottedPreRalloc(int xid, Page * p, int type) {
rid.slot = *freelist_ptr(p);
}
if(slottedFreespaceForSlot(p, rid.slot) < physical_slot_length(type)) {
if(slottedFreespaceForSlot(p, rid.slot) < stasis_record_type_to_size(type)) {
rid = NULLRID;
}
@ -478,8 +478,8 @@ static void slottedPostRalloc(int xid, Page * p, recordid rid) {
static void slottedFree(int xid, Page * p, recordid rid) {
sanityCheck(p, rid);
if(*freespace_ptr(p) == *slot_ptr(p, rid.slot) + physical_slot_length(rid.size)) {
(*freespace_ptr(p)) -= physical_slot_length(rid.size);
if(*freespace_ptr(p) == *slot_ptr(p, rid.slot) + stasis_record_type_to_size(rid.size)) {
(*freespace_ptr(p)) -= stasis_record_type_to_size(rid.size);
}
assert(rid.slot < *numslots_ptr(p));