void stasis_operation_do(const LogEntry * e, Page * p) { if(p) assertlocked(p->rwlatch); assert(e->update.funcID != OPERATION_INVALID); stasis_operation_table[e->update.funcID].run(e, p); DEBUG("OPERATION xid %d Do, %lld {%lld:%lld}\n", e->xid, e->LSN, e->update.page, p ? stasis_page_lsn_read(p) : -1); if(p) stasis_page_lsn_write(e->xid, p, e->LSN); }
/** @todo need to sync the page file to disk occasionally, so that the dirty page table can be kept up to date. */ static void pfPageWrite(stasis_page_handle_t * h, Page * ret) { /** If the page is clean, there's no reason to write it out. */ assertlocked(ret->rwlatch); if(!stasis_dirty_page_table_is_dirty(h->dirtyPages, ret)) { DEBUG(" =^)~ "); return; } pageid_t pageoffset = ret->id * PAGE_SIZE; pageid_t offset ; stasis_page_flushed(ret); // If necessary, force the log to disk so that ret's LSN will be stable. assert(ret->LSN == stasis_page_lsn_read(ret)); if(h->log) { stasis_log_force(h->log, ret->LSN, LOG_FORCE_WAL); } pthread_mutex_lock(&stable_mutex); if(oldOffset != pageoffset) { offset = myLseekNoLock(stable, pageoffset, SEEK_SET); assert(offset == pageoffset); } else { offset = oldOffset; } oldOffset = offset + PAGE_SIZE; assert(ret->memAddr); /* DEBUG("Writing page %d\n", ret->id); */ int write_ret = write(stable, ret->memAddr, PAGE_SIZE); if(write_ret != PAGE_SIZE) { if(-1 == write_ret) { perror("pageFile.c couldn't write"); fflush(NULL); abort(); } else if(0 == write_ret) { /* now what? */ printf("write_ret is zero\n"); fflush(NULL); abort(); } else { printf("write_ret is %d\n", write_ret); fflush(NULL); abort(); } } stasis_dirty_page_table_set_clean(h->dirtyPages, ret); pthread_mutex_unlock(&stable_mutex); }
void stasis_page_blob_initialize_page(Page * p) { assertlocked(p->rwlatch); DEBUG("lsn: %lld\n",(long long)p->LSN); stasis_page_cleanup(p); p->pageType = BLOB_PAGE; }