Added support for aborted "chkbfs" runs (so that they won't do any harm).
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2059 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -643,6 +643,9 @@ BlockAllocator::Free(Transaction *transaction, block_run run)
|
|||||||
status_t
|
status_t
|
||||||
BlockAllocator::StartChecking(check_control *control)
|
BlockAllocator::StartChecking(check_control *control)
|
||||||
{
|
{
|
||||||
|
if (control == NULL)
|
||||||
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
status_t status = fLock.Lock();
|
status_t status = fLock.Lock();
|
||||||
if (status < B_OK)
|
if (status < B_OK)
|
||||||
return status;
|
return status;
|
||||||
@@ -673,6 +676,9 @@ BlockAllocator::StartChecking(check_control *control)
|
|||||||
cookie->iterator = NULL;
|
cookie->iterator = NULL;
|
||||||
control->cookie = cookie;
|
control->cookie = cookie;
|
||||||
|
|
||||||
|
fCheckCookie = cookie;
|
||||||
|
// to be able to restore nicely if "chkbfs" exited abnormally
|
||||||
|
|
||||||
// ToDo: check reserved area in bitmap!
|
// ToDo: check reserved area in bitmap!
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
@@ -682,7 +688,14 @@ BlockAllocator::StartChecking(check_control *control)
|
|||||||
status_t
|
status_t
|
||||||
BlockAllocator::StopChecking(check_control *control)
|
BlockAllocator::StopChecking(check_control *control)
|
||||||
{
|
{
|
||||||
check_cookie *cookie = (check_cookie *)control->cookie;
|
check_cookie *cookie;
|
||||||
|
if (control == NULL)
|
||||||
|
cookie = fCheckCookie;
|
||||||
|
else
|
||||||
|
cookie = (check_cookie *)control->cookie;
|
||||||
|
|
||||||
|
if (cookie == NULL)
|
||||||
|
return B_ERROR;
|
||||||
|
|
||||||
if (cookie->iterator != NULL) {
|
if (cookie->iterator != NULL) {
|
||||||
delete cookie->iterator;
|
delete cookie->iterator;
|
||||||
@@ -694,7 +707,7 @@ BlockAllocator::StopChecking(check_control *control)
|
|||||||
|
|
||||||
// if CheckNextNode() could completely work through, we can
|
// if CheckNextNode() could completely work through, we can
|
||||||
// fix any damages of the bitmap
|
// fix any damages of the bitmap
|
||||||
if (control->status == B_ENTRY_NOT_FOUND) {
|
if (control != NULL && control->status == B_ENTRY_NOT_FOUND) {
|
||||||
// calculate the number of used blocks in the check bitmap
|
// calculate the number of used blocks in the check bitmap
|
||||||
size_t size = fVolume->BlockSize() * fNumGroups * fBlocksPerGroup;
|
size_t size = fVolume->BlockSize() * fNumGroups * fBlocksPerGroup;
|
||||||
off_t usedBlocks = 0LL;
|
off_t usedBlocks = 0LL;
|
||||||
@@ -727,6 +740,7 @@ BlockAllocator::StopChecking(check_control *control)
|
|||||||
|
|
||||||
free(fCheckBitmap);
|
free(fCheckBitmap);
|
||||||
fCheckBitmap = NULL;
|
fCheckBitmap = NULL;
|
||||||
|
fCheckCookie = NULL;
|
||||||
delete cookie;
|
delete cookie;
|
||||||
fLock.Unlock();
|
fLock.Unlock();
|
||||||
|
|
||||||
@@ -737,6 +751,9 @@ BlockAllocator::StopChecking(check_control *control)
|
|||||||
status_t
|
status_t
|
||||||
BlockAllocator::CheckNextNode(check_control *control)
|
BlockAllocator::CheckNextNode(check_control *control)
|
||||||
{
|
{
|
||||||
|
if (control == NULL)
|
||||||
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
check_cookie *cookie = (check_cookie *)control->cookie;
|
check_cookie *cookie = (check_cookie *)control->cookie;
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ class Inode;
|
|||||||
struct disk_super_block;
|
struct disk_super_block;
|
||||||
struct block_run;
|
struct block_run;
|
||||||
struct check_control;
|
struct check_control;
|
||||||
|
struct check_cookie;
|
||||||
|
|
||||||
|
|
||||||
class BlockAllocator {
|
class BlockAllocator {
|
||||||
@@ -53,6 +54,7 @@ class BlockAllocator {
|
|||||||
AllocationGroup *fGroups;
|
AllocationGroup *fGroups;
|
||||||
int32 fNumGroups, fBlocksPerGroup;
|
int32 fNumGroups, fBlocksPerGroup;
|
||||||
uint32 *fCheckBitmap;
|
uint32 *fCheckBitmap;
|
||||||
|
check_cookie *fCheckCookie;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* BLOCK_ALLOCATOR_H */
|
#endif /* BLOCK_ALLOCATOR_H */
|
||||||
|
|||||||
Reference in New Issue
Block a user