- Timestamp:
- 10/14/08 19:37:00 (1 month ago)
- Files:
-
- 1 modified
-
Whitix/branches/keobject/fs/vfs/bcache.c (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
Whitix/branches/keobject/fs/vfs/bcache.c
r1094 r1132 18 18 19 19 #include <typedefs.h> 20 #include <malloc.h> 20 21 #include <fs/vfs.h> 21 22 #include <error.h> … … 40 41 DWORD cacheSize=0; 41 42 extern struct DevClass storageClass; 43 int numDirty=0; 42 44 43 45 static void BufferWait(struct Buffer* buffer); … … 238 240 KePrint("BlockSendRequest: error (%d) reading %u\n",err,request->sector); 239 241 err=-EIO; 240 } 242 } 243 244 // if (request->type == REQUEST_WRITE && request->sector < 10) 245 // KePrint("(%u) ", request->sector); 241 246 242 247 return err; … … 325 330 int BlockWrite(struct StorageDevice* device,struct Buffer* buffer) 326 331 { 332 if (!(buffer->flags & (1 << BUFFER_DIRTY))) 333 numDirty++; 334 327 335 /* Just signal that the buffer is dirty, and let BufferFlusher write it to disk in the near future as an update */ 328 336 buffer->flags |= (1 << BUFFER_DIRTY); 329 337 330 if (bufferFlusher) 331 ThrResumeThread(bufferFlusher); 332 338 if (numDirty == 1) 339 { 340 if (bufferFlusher) 341 ThrResumeThread(bufferFlusher); 342 } 343 333 344 return 0; 334 345 } … … 384 395 { 385 396 DWORD flags, i; 386 struct Buffer* buff; 397 struct Buffer* buff, *buff2; 398 399 // KePrint("BlockSyncDevice(%s), numDirty = %d\n", KeObjGetName(&device->device.object), numDirty); 387 400 388 401 IrqSaveFlags(flags); … … 393 406 394 407 /* Write all the blocks belonging to device to disk */ 395 ListForEachEntry (buff, head, list)408 ListForEachEntrySafe(buff, buff2, head, list) 396 409 { 397 410 if (BufferDirty(buff)) 398 411 { 412 --numDirty; 399 413 /* For each block, call the respective StorageDevice write function */ 400 414 DoBlockWrite(buff->device,buff); … … 411 425 int BlockSyncAll() 412 426 { 413 // struct StorageDevice* sDevice;414 415 /* Sync all vnodes */416 // extern void VNodeSyncAll();417 // VNodeSyncAll();418 419 427 struct StorageDevice* sDevice; 420 428 struct KeObject* object, *object2; … … 460 468 while (1) 461 469 { 462 ThrSuspendThread(currThread); 463 ThrSchedule(); 470 if (!numDirty) 471 { 472 ThrSuspendThread(currThread); 473 ThrSchedule(); 474 } 464 475 465 476 BlockSyncAll(); … … 477 488 struct ListHead* head=BUFFER_HASH(buffer->device, buffer->blockNum); 478 489 479 ListAdd (&buffer->list, head);490 ListAddTail(&buffer->list, head); 480 491 } 481 492
