Changeset 789
- Timestamp:
- 07/13/08 20:46:20 (3 months ago)
- Files:
-
- 1 modified
-
Whitix/branches/fs/fs/journal/transaction.c (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
Whitix/branches/fs/fs/journal/transaction.c
r775 r789 58 58 INIT_LIST_HEAD(&ret->metaDataList); 59 59 INIT_LIST_HEAD(&ret->logControlList); 60 INIT_LIST_HEAD(&ret->shadowList); 61 INIT_LIST_HEAD(&ret->ioList); 62 INIT_LIST_HEAD(&ret->forgetList); 60 63 61 64 /* TODO: Set up timer. */ … … 68 71 int JournalHandleStart(struct Journal* journal, struct JournalHandle* handle) 69 72 { 70 intnumBlocks=handle->numBlocks;73 DWORD numBlocks=handle->numBlocks; 71 74 struct JournalTrans* trans; 72 75 int needed; … … 101 104 102 105 /* Check log space left. */ 106 // KePrint("free = %u\n", journal->free); 103 107 104 108 /* Account for all the buffers, and add the handle to the running transaction. */ … … 138 142 139 143 handle=JournalHandleAllocate(numBlocks); 140 141 144 currThread->currHandle=handle; 142 143 145 ret=JournalHandleStart(journal, handle); 144 146 … … 159 161 struct JournalTrans* trans=handle->transaction; 160 162 struct Journal* journal=trans->journal; 161 163 162 164 currThread->currHandle=NULL; 165 166 --handle->refs; 167 168 if (handle->refs > 0) 169 return 0; 163 170 164 171 trans->updates--; 165 172 trans->outstandingBlocks-=handle->numBlocks; 166 173 174 // KePrint("JournalStop: %u\n", trans->updates); 175 167 176 if (!trans->updates) 168 177 { 169 /* Wake up waiters. */ 178 // KePrint("Here! %u %u\n", currTime.seconds, trans->expires); 179 WakeUp(&journal->waitUpdates); 170 180 } 171 181 … … 190 200 { 191 201 struct ListHead* list; 202 203 if (!head) 204 { 205 KePrint("JournalFileBuffer: head = NULL\n"); 206 return; 207 } 192 208 193 209 /* Already filed? */ … … 201 217 202 218 if (head->transaction == trans && head->list > 0 && head->list != type) 203 ListRemove(&head->next); 219 JournalUnfileBuffer(head); 220 else 221 head->transaction=trans; 204 222 205 223 switch (type) … … 215 233 case JOURN_LOGCTL: 216 234 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; 217 247 break; 218 248 … … 226 256 } 227 257 258 void JournalUnfileBuffer(struct JournalHead* head) 259 { 260 ListRemove(&head->next); 261 } 262 228 263 /* Intent to modify a buffer for metadata update. */ 229 264 … … 238 273 JournalLock(journal); 239 274 240 /* Check if buffer is locked. */ 275 BufferLock(buffer); 276 277 repeat: 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 } 241 295 242 296 if (!head->transaction) … … 245 299 JournalFileBuffer(head, trans, JOURN_RESERVED); 246 300 } 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); 247 314 248 315 JournalUnlock(journal);
