1 /* 2 * Copyright 2001-2010, Haiku Inc. All rights reserved. 3 * This file may be used under the terms of the MIT License. 4 * 5 * Authors: 6 * Janito V. Ferreira Filho 7 */ 8 9 10 #include "InodeJournal.h" 11 12 #include <new> 13 14 #include <fs_cache.h> 15 16 #include "HashRevokeManager.h" 17 18 19 //#define TRACE_EXT2 20 #ifdef TRACE_EXT2 21 # define TRACE(x...) dprintf("\33[34mext2:\33[0m " x) 22 #else 23 # define TRACE(x...) ; 24 #endif 25 26 27 InodeJournal::InodeJournal(Inode* inode) 28 : 29 Journal(), 30 fInode(inode) 31 { 32 if (inode == NULL) 33 fInitStatus = B_BAD_DATA; 34 else { 35 Volume* volume = inode->GetVolume(); 36 37 fFilesystemVolume = volume; 38 fFilesystemBlockCache = volume->BlockCache(); 39 fJournalVolume = volume; 40 fJournalBlockCache = volume->BlockCache(); 41 42 if (!inode->IsFileCacheDisabled()) 43 fInitStatus = inode->DisableFileCache(); 44 else 45 fInitStatus = B_OK; 46 47 if (fInitStatus == B_OK) { 48 TRACE("InodeJournal::InodeJournal(): Inode's file cache disabled " 49 "successfully\n"); 50 HashRevokeManager* revokeManager = new(std::nothrow) 51 HashRevokeManager; 52 TRACE("InodeJournal::InodeJournal(): Allocated a hash revoke " 53 "manager at %p\n", revokeManager); 54 55 if (revokeManager == NULL) { 56 TRACE("InodeJournal::InodeJournal(): Insufficient memory to " 57 "create the hash revoke manager\n"); 58 fInitStatus = B_NO_MEMORY; 59 } else { 60 fInitStatus = revokeManager->Init(); 61 62 if (fInitStatus == B_OK) { 63 fRevokeManager = revokeManager; 64 fInitStatus = _LoadSuperBlock(); 65 } else 66 delete revokeManager; 67 } 68 } 69 } 70 } 71 72 73 InodeJournal::~InodeJournal() 74 { 75 } 76 77 78 status_t 79 InodeJournal::InitCheck() 80 { 81 if (fInitStatus != B_OK) 82 TRACE("InodeJournal: Initialization error\n"); 83 return fInitStatus; 84 } 85 86 87 status_t 88 InodeJournal::MapBlock(off_t logical, fsblock_t& physical) 89 { 90 TRACE("InodeJournal::MapBlock()\n"); 91 return fInode->FindBlock(logical * fBlockSize, physical); 92 } 93