Changeset 756 for Whitix/branches

Show
Ignore:
Timestamp:
07/08/08 18:16:50 (5 months ago)
Author:
mwhitworth
Message:

Add to journal code.

Location:
Whitix/branches/fs/fs/journal
Files:
3 modified

Legend:

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

    r751 r756  
    2626struct Thread* journalCommitter=NULL; 
    2727 
    28 struct Cache* journalCache=NULL; 
     28struct Cache* journalCache=NULL, *journHandleCache=NULL, *journTransCache=NULL; 
    2929 
    3030static void JournalCommitter() 
     
    4545        /* Init caches. */ 
    4646        journalCache=MemCacheCreate("Journal cache", sizeof(struct Journal), NULL, NULL, 0); 
     47        journHandleCache=MemCacheCreate("Journal handle cache",  
     48                sizeof(struct JournalHandle), NULL, NULL, 0); 
     49        journTransCache=MemCacheCreate("Journal transaction cache", 
     50                sizeof(struct JournalTrans), NULL, NULL, 0); 
    4751 
    4852        journalCommitter=ThrCreateKernelThread(JournalCommitter); 
  • Whitix/branches/fs/fs/journal/journals.c

    r751 r756  
    8888        journal->maxLength=vNode->size/BYTES_PER_SECTOR(vNode->superBlock); 
    8989        journal->sectorSize=BYTES_PER_SECTOR(vNode->superBlock); 
     90        journal->transSequence=1; 
    9091 
    9192        if (BeToCpu32(jSb->maxLen) < journal->maxLength) 
  • Whitix/branches/fs/fs/journal/transaction.c

    r751 r756  
    2222#include <slab.h> 
    2323 
    24 extern struct Cache* journHandleCache; 
     24extern struct Cache* journHandleCache, *journTransCache; 
    2525 
    26 int JournalTransCreate(struct Journal* journal) 
     26/******************************************************************************* 
     27 * 
     28 * FUNCTION:    JournalTransCreate 
     29 * 
     30 * DESCRIPTION: Create a new current transaction for the journal. The journal 
     31 *                              lock must be held on entry to this function. Create it in a 
     32 *                              RUNNING state and add it to the new journal. 
     33 * 
     34 * PARAMETERS:  journal - the journal to create a new filesystem transaction for 
     35 * 
     36 * RETURNS:     a structure representing the new current transaction for the 
     37 *                              journal. 
     38 * 
     39 ******************************************************************************/ 
     40 
     41struct JournalTrans* JournalTransCreate(struct Journal* journal) 
    2742{ 
    28         KePrint("JournalTransCreate\n"); 
     43        struct JournalTrans* ret; 
     44 
     45        ret=(struct JournalTrans*)MemCacheAlloc(journTransCache); 
     46 
     47        if (!ret) 
     48                return NULL; 
     49 
     50        ret->journal=journal; 
     51        ret->state=JTRANS_RUNNING; 
     52        ret->transId=journal->transSequence++; 
     53 
     54        /* TODO: Set up timer. */ 
     55 
     56        journal->currTransaction=ret; 
     57 
     58        return ret; 
    2959} 
    3060 
     
    3262{ 
    3363        int numBlocks=handle->numBlocks; 
     64        struct JournalTrans* trans; 
     65        int needed; 
    3466 
    3567        if (numBlocks > journal->maxTransactionBuffers) 
     
    4981        if (!journal->currTransaction) 
    5082                journal->currTransaction=JournalTransCreate(journal); 
     83 
     84        trans=journal->currTransaction; 
     85 
     86        /* Check if locked. */ 
     87 
     88        needed=trans->outstandingBlocks+numBlocks; 
     89 
     90        if (needed > journal->maxTransactionBuffers) 
     91        { 
     92                /* Current transaction is too large. TODO: Commit it. */ 
     93        } 
     94 
     95        /* Check log space left. */ 
     96 
     97        /* Account for all the buffers, and add the handle to the running transaction. */ 
     98        handle->transaction=trans; 
     99        trans->outstandingBlocks+=numBlocks; 
     100        trans->updates++; 
     101        trans->handleCount++; 
     102 
     103        JournalUnlock(journal); 
     104 
     105        return 0; 
    51106} 
    52107 
     
    92147 
    93148SYMBOL_EXPORT(JournalStart); 
     149 
     150/* Intent to modify a buffer for metadata update. */ 
     151 
     152int JournalGetWriteAccess(struct JournalHandle* handle, struct Buffer* buffer) 
     153{ 
     154        struct JournalTrans* trans=handle->transaction; 
     155        struct Journal* journal=trans->journal; 
     156        struct JournalHead* head; 
     157 
     158        head=JournalAddHeader(buffer); 
     159 
     160        return 0; 
     161} 
     162 
     163SYMBOL_EXPORT(JournalGetWriteAccess);