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

Add to journal code.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • 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);