Changeset 756 for Whitix/branches/fs/fs/journal/transaction.c
- Timestamp:
- 07/08/08 18:16:50 (5 months ago)
- Files:
-
- 1 modified
-
Whitix/branches/fs/fs/journal/transaction.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
Whitix/branches/fs/fs/journal/transaction.c
r751 r756 22 22 #include <slab.h> 23 23 24 extern struct Cache* journHandleCache ;24 extern struct Cache* journHandleCache, *journTransCache; 25 25 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 41 struct JournalTrans* JournalTransCreate(struct Journal* journal) 27 42 { 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; 29 59 } 30 60 … … 32 62 { 33 63 int numBlocks=handle->numBlocks; 64 struct JournalTrans* trans; 65 int needed; 34 66 35 67 if (numBlocks > journal->maxTransactionBuffers) … … 49 81 if (!journal->currTransaction) 50 82 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; 51 106 } 52 107 … … 92 147 93 148 SYMBOL_EXPORT(JournalStart); 149 150 /* Intent to modify a buffer for metadata update. */ 151 152 int 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 163 SYMBOL_EXPORT(JournalGetWriteAccess);