Changeset 881 for Whitix/trunk/fs/vfs/bcache.c
- Timestamp:
- 09/23/08 14:18:34 (4 months ago)
- Files:
-
- 1 modified
-
Whitix/trunk/fs/vfs/bcache.c (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
-
Whitix/trunk/fs/vfs/bcache.c
r778 r881 58 58 * 59 59 * DESCRIPTION: Lock a buffer for unique access. Waits for the buffer to 60 * be unlocked, and then locks it again.60 * be unlocked, and then locks it again. 61 61 * 62 62 * PARAMETERS: buffer - buffer in question. 63 63 * 64 * RETURNS: Nothing.64 * RETURNS: Nothing. 65 65 * 66 66 ***********************************************************************/ … … 72 72 } 73 73 74 SYMBOL_EXPORT(BufferLock); 75 74 76 /*********************************************************************** 75 77 * … … 90 92 } 91 93 94 SYMBOL_EXPORT(BufferUnlock); 95 92 96 static void BufferWait(struct Buffer* buffer) 93 97 { 94 98 BufferGet(buffer); 95 99 INIT_WAITQUEUE_ENTRY(bufferWait); 96 100 97 101 do 98 102 { … … 123 127 } 124 128 129 SYMBOL_EXPORT(WaitForBuffer); 130 125 131 /*********************************************************************** 126 132 * … … 144 150 return NULL; 145 151 152 ZeroMemory(buff, sizeof(struct Buffer)); 153 146 154 buff->device=device; 147 155 buff->blockNum=blockNum; 148 156 buff->refs=1; 149 buff->data=(BYTE*) malloc(device->softBlockSize);157 buff->data=(BYTE*)MemAlloc(device->softBlockSize); 150 158 if (!buff->data) 159 { 160 MemCacheFree(blockCache, buff); 151 161 return NULL; 162 } 152 163 153 164 INIT_WAITQUEUE_HEAD(&buff->waitQueue); 154 BufferLock(buff); 165 166 BufferLock(buff); /* Buffer is unlocked in StorageEndRequest. */ 155 167 BlockAddToHashTable(buff); 156 168 … … 158 170 } 159 171 172 SYMBOL_EXPORT(BlockBufferAlloc); 173 160 174 /*********************************************************************** 161 175 * … … 173 187 { 174 188 WaitForBuffer(buff); 175 free(buff->data);189 MemFree(buff->data); 176 190 ListRemove(&buff->list); 177 MemCacheFree(blockCache, buff);191 MemCacheFree(blockCache, buff); 178 192 } 179 193 … … 211 225 ***********************************************************************/ 212 226 213 int BlockSendRequestRaw(struct StorageDevice* device, struct Request* request)227 int BlockSendRequestRaw(struct StorageDevice* device, struct Request* request) 214 228 { 215 229 int err; … … 307 321 } 308 322 323 /* TODO: device is redundant here. */ 324 309 325 int BlockWrite(struct StorageDevice* device,struct Buffer* buffer) 310 326 { … … 378 394 /* Write all the blocks belonging to device to disk */ 379 395 ListForEachEntry(buff, head, list) 396 { 380 397 if (BufferDirty(buff)) 381 398 { 399 WaitForBuffer(buff); 400 382 401 /* For each block, call the respective StorageDevice write function */ 383 402 DoBlockWrite(buff->device,buff); 384 403 buff->flags &= ~(1 << BUFFER_DIRTY); 385 404 } 405 } 386 406 } 387 407 … … 431 451 static void BufferFlusher() 432 452 { 433 struct StorageDevice* sDevice;453 // struct StorageDevice* sDevice; 434 454 ThrSetPriority(currThread,1); 435 455 … … 439 459 ThrSchedule(); 440 460 441 ListForEachEntry(sDevice,&sDeviceList,list) 442 BlockSyncDevice(sDevice); 461 /* FIXME: TEMP */ 462 // ListForEachEntry(sDevice,&sDeviceList,list) 463 // BlockSyncDevice(sDevice); 443 464 } 444 465 } … … 461 482 DWORD i; 462 483 463 dev->hashLists=(struct ListHead*) malloc(1 << HASH_TABLE_ORDER);484 dev->hashLists=(struct ListHead*)MemAlloc(1 << HASH_TABLE_ORDER); 464 485 465 486 for (i=0; i<HASH_NUM_ENTRIES; i++) … … 480 501 { 481 502 BufferGet(curr); 482 PreemptEnable(); /* As WaitForBuffer may sleep. */503 PreemptEnable(); 483 504 WaitForBuffer(curr); 484 505 return curr;