Changeset 789

Show
Ignore:
Timestamp:
07/13/08 20:46:20 (3 months ago)
Author:
mwhitworth
Message:

Add more list types, add support for blocks on two different transactions.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • Whitix/branches/fs/fs/journal/transaction.c

    r775 r789  
    5858        INIT_LIST_HEAD(&ret->metaDataList); 
    5959        INIT_LIST_HEAD(&ret->logControlList); 
     60        INIT_LIST_HEAD(&ret->shadowList); 
     61        INIT_LIST_HEAD(&ret->ioList); 
     62        INIT_LIST_HEAD(&ret->forgetList); 
    6063 
    6164        /* TODO: Set up timer. */ 
     
    6871int JournalHandleStart(struct Journal* journal, struct JournalHandle* handle) 
    6972{ 
    70         int numBlocks=handle->numBlocks; 
     73        DWORD numBlocks=handle->numBlocks; 
    7174        struct JournalTrans* trans; 
    7275        int needed; 
     
    101104 
    102105        /* Check log space left. */ 
     106//      KePrint("free = %u\n", journal->free); 
    103107 
    104108        /* Account for all the buffers, and add the handle to the running transaction. */ 
     
    138142 
    139143        handle=JournalHandleAllocate(numBlocks); 
    140  
    141144        currThread->currHandle=handle; 
    142  
    143145        ret=JournalHandleStart(journal, handle); 
    144146 
     
    159161        struct JournalTrans* trans=handle->transaction; 
    160162        struct Journal* journal=trans->journal; 
    161  
     163         
    162164        currThread->currHandle=NULL; 
     165 
     166        --handle->refs; 
     167         
     168        if (handle->refs > 0) 
     169                return 0; 
    163170 
    164171        trans->updates--; 
    165172        trans->outstandingBlocks-=handle->numBlocks; 
    166173 
     174//      KePrint("JournalStop: %u\n", trans->updates); 
     175 
    167176        if (!trans->updates) 
    168177        { 
    169                 /* Wake up waiters. */ 
     178//              KePrint("Here! %u %u\n", currTime.seconds, trans->expires); 
     179                WakeUp(&journal->waitUpdates); 
    170180        } 
    171181 
     
    190200{ 
    191201        struct ListHead* list; 
     202 
     203        if (!head) 
     204        { 
     205                KePrint("JournalFileBuffer: head = NULL\n"); 
     206                return; 
     207        } 
    192208 
    193209        /* Already filed? */ 
     
    201217 
    202218        if (head->transaction == trans && head->list > 0 && head->list != type) 
    203                 ListRemove(&head->next); 
     219                JournalUnfileBuffer(head); 
     220        else 
     221                head->transaction=trans; 
    204222 
    205223        switch (type) 
     
    215233                case JOURN_LOGCTL: 
    216234                        list=&trans->logControlList; 
     235                        break; 
     236 
     237                case JOURN_SHADOW: 
     238                        list=&trans->shadowList; 
     239                        break; 
     240 
     241                case JOURN_IO: 
     242                        list=&trans->ioList; 
     243                        break; 
     244                         
     245                case JOURN_FORGET: 
     246                        list=&trans->forgetList; 
    217247                        break; 
    218248 
     
    226256} 
    227257 
     258void JournalUnfileBuffer(struct JournalHead* head) 
     259{ 
     260        ListRemove(&head->next); 
     261} 
     262 
    228263/* Intent to modify a buffer for metadata update. */ 
    229264 
     
    238273        JournalLock(journal); 
    239274 
    240         /* Check if buffer is locked. */ 
     275        BufferLock(buffer); 
     276 
     277repeat: 
     278        if (head->transaction && head->transaction != trans) 
     279        { 
     280                if (head->list == JOURN_SHADOW) 
     281                { 
     282                        JournalUnlock(journal); 
     283//                      KePrint("shadow wait, %#X, %u\n", head, JournHeadToBuffer(head)->blockNum); 
     284                        WAIT_ON(head->wait, head->list != JOURN_SHADOW); 
     285                        JournalLock(journal); 
     286                        goto repeat; 
     287                } 
     288                 
     289                if (head->list != JOURN_FORGET) 
     290                { 
     291                } 
     292                 
     293                head->nextTransaction=trans; 
     294        } 
    241295 
    242296        if (!head->transaction) 
     
    245299                JournalFileBuffer(head, trans, JOURN_RESERVED); 
    246300        } 
     301         
     302        BufferUnlock(buffer); 
     303         
     304        if (handle->numBlocks <= 0) 
     305        { 
     306                KePrint("numBlocks <= 0\n"); 
     307                cli(); hlt(); 
     308                return 0; 
     309        } 
     310         
     311        handle->numBlocks--; 
     312         
     313//      KePrint("blocks left: %u\n", handle->numBlocks); 
    247314 
    248315        JournalUnlock(journal);