#include <hsm_ActiveFH.h>

Definition at line 36 of file hsm_ActiveFH.h.
Public Member Functions | |
| hsm_ActiveFH (fio_CirFileTrans &a_cirFile) | |
| ~hsm_ActiveFH () | |
| void | FindNextClearCurrRec (fio_Transaction &a_trans) |
| void | FindNextRec () |
| ivd_RecordIDX_t | Append (hsm_FileHeader *a_fh_p, fio_Transaction &a_trans) |
| ivd_RecordIDX_t | Update (hsm_FileHeader *a_fh_p, fio_Transaction &a_trans) |
| void | Release (hsm_FileHeader *a_fh_p, fio_Transaction &a_trans) |
| ivd_RecordIDX_t | MoveToEnd (hsm_FileHeader *a_fh_p, fio_Transaction &a_trans) |
| hdb_Active_t & | GetRefRleaseCandRec () |
| void | ActiveToList (string &a_fsID) |
| void | OrphanedToMigList () |
Public Attributes | |
| log_CLASSID_m | |
Private Attributes | |
| fio_CirFileTrans & | m_cirFile |
| ivd_RecordIDX_t | m_idx |
| index of first element in active list | |
| hdb_Active_t | m_activeFH |
| cmn_Mutex | m_activeFH_x |
| hsm_ActiveFH::hsm_ActiveFH | ( | fio_CirFileTrans & | a_cirFile | ) |
Definition at line 42 of file hsm_ActiveFH.cpp.
References log_FUNC_m.
00043 : 00044 m_cirFile(a_cirFile), 00045 m_idx(0) 00046 { 00047 log_FUNC_m(hsm_ActiveFH); 00048 // dont need transaction cause m_idx is zerro 00049 // FindNextRec(); 00050 } //============================================================================//
| hsm_ActiveFH::~hsm_ActiveFH | ( | ) |
Definition at line 54 of file hsm_ActiveFH.cpp.
References dbg_LOW, log_DBG_m, and log_FUNC_m.
00054 { 00055 log_FUNC_m(~hsm_ActiveFH); 00056 log_DBG_m(dbg_LOW, " ~hsm_ActiveFH destructor"); 00057 }
| void hsm_ActiveFH::FindNextClearCurrRec | ( | fio_Transaction & | a_trans | ) |
Definition at line 62 of file hsm_ActiveFH.cpp.
References FindNextRec(), log_FUNC_m, m_activeFH_x, m_cirFile, m_idx, and fio_CirFileTrans::WriteRec().
00062 { 00063 log_FUNC_m(FindNextClearCurrRec); 00064 cmn_MutexLock l(m_activeFH_x); 00065 if (m_idx != 0) { 00066 hdb_ReleaseCand_t rc; // release previous cand record with zeroes 00067 m_cirFile.WriteRec(m_idx, &rc, 1, a_trans); 00068 } 00069 FindNextRec(); 00070 }

| void hsm_ActiveFH::FindNextRec | ( | ) |
Definition at line 74 of file hsm_ActiveFH.cpp.
References hdb_Active_t::Clear(), dbg_DETAIL, hdb_Active_t::generalInode, log_DBG_m, log_FUNC_m, m_activeFH, m_cirFile, m_idx, and fio_CirFileTrans::ReadFront().
Referenced by FindNextClearCurrRec(), and Release().
00074 { 00075 log_FUNC_m(FindNextRec); 00076 ivd_RecordIDX_t idx = 0; 00077 log_DBG_m(dbg_DETAIL, "Current index is " << m_idx); 00078 do { // read util no more records or found actual record 00079 idx = m_cirFile.ReadFront(&m_activeFH); 00080 log_DBG_m(dbg_DETAIL, " ReadFront from idx " << idx); 00081 // first record is already truncate so skip it (idx == m_idx) 00082 } while (idx != 0 && (m_activeFH.generalInode == 0 || idx == m_idx)); 00083 if (idx == 0) { 00084 // log_DBG_m(dbg_DETAIL, "No more records in circ file."); 00085 m_activeFH.Clear(); 00086 } 00087 m_idx = idx; 00088 log_DBG_m(dbg_DETAIL, " New RF idx " << m_idx); 00089 }


| ivd_RecordIDX_t hsm_ActiveFH::Append | ( | hsm_FileHeader * | a_fh_p, | |
| fio_Transaction & | a_trans | |||
| ) |
Definition at line 93 of file hsm_ActiveFH.cpp.
References dbg_DETAIL, hdb_Active_t::generalInode, hsm_FileHeader::GetChgFlag(), hsm_FileHeader::GetFileID(), fio_File::GetFileName(), hsm_FileHeader::GetFileSize(), hsm_FileHeader::GetFName(), hsm_FileHeader::GetfType(), hsm_FileHeader::GetInode(), hsm_FileHeader::GetNameOwnIdx(), hsm_FileHeader::GetOldNameOwnIdx(), log_DBG_m, log_FUNC_m, m_activeFH, m_activeFH_x, m_cirFile, m_idx, and fio_CirFileTrans::WriteBack().
Referenced by MoveToEnd(), and hsm_FileHeader::StoreActiveRec().
00095 { 00096 log_FUNC_m(Append); 00097 hdb_Active_t act( a_fh_p->GetNameOwnIdx(), 00098 a_fh_p->GetOldNameOwnIdx(), 00099 a_fh_p->GetInode(), 00100 a_fh_p->GetChgFlag(), 00101 a_fh_p->GetFileID(), 00102 a_fh_p->GetfType() 00103 ); 00104 00105 log_DBG_m(dbg_DETAIL, act); 00106 00107 ivd_RecordIDX_t idx = m_cirFile.WriteBack(&act, a_trans); 00108 log_DBG_m(dbg_DETAIL, "Added file " << a_fh_p->GetFName() 00109 << " size " << a_fh_p->GetFileSize() 00110 << " to " << m_cirFile.GetFileName() 00111 << " idx " << idx); 00112 00113 00114 cmn_MutexLock l(m_activeFH_x); 00115 if (m_activeFH.generalInode == 0) { 00116 m_activeFH = act; // first record is set immediately 00117 m_idx = idx; // and is skipped by FindNexRec 00118 } 00119 return idx; 00120 }


| ivd_RecordIDX_t hsm_ActiveFH::Update | ( | hsm_FileHeader * | a_fh_p, | |
| fio_Transaction & | a_trans | |||
| ) |
Definition at line 124 of file hsm_ActiveFH.cpp.
References dbg_DETAIL, hdb_Active_t::generalInode, hsm_FileHeader::GetActiveIdx(), hsm_FileHeader::GetChgFlag(), hsm_FileHeader::GetFileID(), fio_File::GetFileName(), hsm_FileHeader::GetFileSize(), hsm_FileHeader::GetFName(), hsm_FileHeader::GetfType(), hsm_FileHeader::GetInode(), hsm_FileHeader::GetNameOwnIdx(), hsm_FileHeader::GetOldNameOwnIdx(), log_DBG_m, log_FUNC_m, m_activeFH, m_activeFH_x, m_cirFile, m_idx, and fio_CirFileTrans::WriteRec().
Referenced by hsm_FileHeader::InitActive(), and hsm_FileHeader::MigrationIsDone().
00126 { 00127 log_FUNC_m(Update); 00128 hdb_Active_t act( a_fh_p->GetNameOwnIdx(), 00129 a_fh_p->GetOldNameOwnIdx(), 00130 a_fh_p->GetInode(), 00131 a_fh_p->GetChgFlag(), 00132 a_fh_p->GetFileID(), 00133 a_fh_p->GetfType() 00134 ); 00135 00136 log_DBG_m(dbg_DETAIL, act); 00137 ivd_RecordIDX_t idx = a_fh_p->GetActiveIdx(); 00138 m_cirFile.WriteRec(idx, &act, 1, a_trans); 00139 log_DBG_m(dbg_DETAIL, "Update file " << a_fh_p->GetFName() 00140 << " size " << a_fh_p->GetFileSize() 00141 << " to " << m_cirFile.GetFileName() 00142 << " idx " << idx); 00143 00144 00145 cmn_MutexLock l(m_activeFH_x); 00146 if (m_activeFH.generalInode == 0) { 00147 m_activeFH = act; // first record is set immediately 00148 m_idx = idx; // and is skipped by FindNexRec 00149 } 00150 return idx; 00151 }


| void hsm_ActiveFH::Release | ( | hsm_FileHeader * | a_fh_p, | |
| fio_Transaction & | a_trans | |||
| ) |
Definition at line 155 of file hsm_ActiveFH.cpp.
References dbg_DETAIL, FindNextRec(), hsm_FileHeader::GetActiveIdx(), fio_File::GetFileName(), hsm_FileHeader::GetFName(), log_DBG_m, log_FUNC_m, m_activeFH_x, m_cirFile, m_idx, and fio_CirFileTrans::WriteRec().
Referenced by hsm_FileHeader::Event(), hsm_FileHeader::InitActive(), MoveToEnd(), and hsm_FileHeader::RemoveFromActiveList().
00156 { 00157 log_FUNC_m(Release); 00158 00159 ivd_RecordIDX_t idx = a_fh_p->GetActiveIdx(); 00160 00161 log_DBG_m(dbg_DETAIL, "remove file: " << a_fh_p->GetFName() 00162 << ", from: " << m_cirFile.GetFileName() 00163 << ", idx: " << idx); 00164 00165 hdb_Active_t act; // record with zerroes 00166 m_cirFile.WriteRec(idx, &act, 1, a_trans); 00167 00168 cmn_MutexLock l(m_activeFH_x); 00169 if (m_idx == idx) { // if current record is released, then read next 00170 FindNextRec(); 00171 } 00172 }


| ivd_RecordIDX_t hsm_ActiveFH::MoveToEnd | ( | hsm_FileHeader * | a_fh_p, | |
| fio_Transaction & | a_trans | |||
| ) |
Definition at line 176 of file hsm_ActiveFH.cpp.
References Append(), log_FUNC_m, and Release().
Referenced by hsm_FileHeader::StoreActiveRec().
00177 { 00178 log_FUNC_m(MoveToEnd); 00179 00180 Release(a_fh_p, a_trans); 00181 return Append(a_fh_p, a_trans); 00182 }


| hdb_Active_t& hsm_ActiveFH::GetRefRleaseCandRec | ( | ) | [inline] |
| void hsm_ActiveFH::ActiveToList | ( | string & | a_fsID | ) |
Simulate delete evvent
Definition at line 186 of file hsm_ActiveFH.cpp.
References CHG_DELETED_d, hdb_Active_t::chgFlags, ivd_FS_File::Close(), dbg_DETAIL, dbg_NORM, hsm_FileHeader::DecrRef(), ivd_FS_File::e_Cache, file, hdb_Active_t::fileID, g_fs_api_p, g_hsm_FHCache_p, g_hsmDB_p, hdb_Active_t::generalInode, ivd_BaseException::GetError(), hsm_FHcache::GetFH(), ivd_BaseException::GetFriendly(), ivd_FS_File::GetProperties(), ivd_FileSystemAPI::GetRootPath(), fio_DataBase::GetTransObj(), hdb_RemoveName(), hdbReadNameOwnRec(), hsmdbGetPath(), hsm_FileHeader::InitActive(), hsm_FHcache::Insert(), IVD_PRINT_ID_FS, log_DBG_m, log_FUNC_m, log_WRN_m, m_cirFile, ivd_FS_FileProperty_t::m_Inode, hsm_FileHeader::MakePath(), hdb_Active_t::nameOwnIdx, NULL, hdb_Active_t::oldNameOwnIdx, ivd_FS_File::Open(), fio_CirFileTrans::ReadNext(), fio_CirFileTrans::ReadNextReset(), fio_DataBase::ReleaseTransObj(), and fio_CirFileTrans::WriteRec().
Referenced by fs_api::EventMounted().
00186 { 00187 log_FUNC_m(ActiveToList); 00188 00189 cmn_File mountPoint(g_fs_api_p->GetRootPath() + "."); 00190 00191 fio_Transaction &trans = *g_hsmDB_p->GetTransObj(); 00192 00193 hdb_Active_t actRec; 00194 ivd_RecordIDX_t idx; 00195 // reset circular list for read 00196 m_cirFile.ReadNextReset(); 00197 while ((idx = m_cirFile.ReadNext(&actRec)) > 0) { 00198 if (actRec.generalInode > 0) { 00199 log_DBG_m(dbg_DETAIL, "Find active FH rec in HSMDB Idx = " 00200 << idx << endl << actRec); 00202 if (!(actRec.chgFlags & CHG_DELETED_d)) { 00203 hdb_DirNode_t dir; // default const. it filled with zeroes 00204 ivd_RecordIDX_t dirTreeIdx = 0; 00205 hdb_String name; 00206 hdbReadNameOwnRec(actRec.nameOwnIdx, dirTreeIdx, name, dir); 00207 ivd_FS_File file(*g_fs_api_p, actRec.generalInode, actRec.fileID); 00208 try { 00209 //HPUX - The file needs to be opened ( to be in the kernel cache ). 00210 file.Open(ivd_FS_File::e_Cache, 00211 (g_fs_api_p->GetRootPath() + hsmdbGetPath(dir) + name)); 00212 ivd_FS_FileProperty_t fileProp; 00213 file.GetProperties(fileProp); 00214 //Close file 00215 file.Close(); 00216 00217 // got current inode from FS 00218 if (actRec.generalInode != fileProp.m_Inode) { 00219 log_DBG_m(dbg_NORM, "Inode changed. from DB " 00220 << IVD_PRINT_ID_FS(actRec.generalInode) 00221 << " from FS " 00222 << IVD_PRINT_ID_FS(fileProp.m_Inode)); 00223 actRec.generalInode = fileProp.m_Inode; 00224 } 00225 } 00226 catch (ivd_SysError &se) { 00227 // if GetProperties not found inode or it has not proper general number throw ENXIO 00228 // TODO renamed file ENOENT has to be resolved on different way. 00229 if ( se.GetError() == ENXIO // inode not exist 00230 && a_fsID == mountPoint.GetFileSystemID()) { // FS is still mounted 00231 log_DBG_m(dbg_DETAIL, "FS mounted, but file is not found."); 00233 trans.StartTransaction(); 00234 if (actRec.oldNameOwnIdx) { // remove old name first 00235 hdb_RemoveName(actRec.oldNameOwnIdx, trans); 00236 } 00237 if (actRec.fileID == 0) { // fileID is not migratted yet so remove it 00238 log_DBG_m(dbg_NORM, "Skip it and remove from DB. INO " << IVD_PRINT_ID_FS(actRec.generalInode)); 00239 hdb_Active_t act; // record with zerroes 00240 m_cirFile.WriteRec(idx, &act, 1, trans); 00241 // remove nameOwnIdx 00242 hdb_RemoveName(actRec.nameOwnIdx, trans); 00243 trans.EndTransaction(); 00244 continue; 00245 } 00246 else { 00247 log_DBG_m(dbg_NORM, "Set in HSMDB as deleted. INO " << IVD_PRINT_ID_FS(actRec.generalInode)); 00248 actRec.chgFlags = CHG_DELETED_d; 00249 actRec.oldNameOwnIdx = actRec.nameOwnIdx; 00250 actRec.nameOwnIdx = 0; 00251 // update active record 00252 m_cirFile.WriteRec(idx, &actRec, 1, trans); 00253 } 00254 trans.EndTransaction(); 00255 } 00256 else { 00257 log_WRN_m(se.GetFriendly() 00258 << " Can't get general inode of fileID " << actRec.fileID 00259 << " File probably not exist or IVDFS is unmounted."); 00260 } 00261 } 00262 } 00263 // directory can be already in cache 00264 hsm_FileHeader *fh_p = g_hsm_FHCache_p->GetFH(actRec.generalInode); 00265 if (fh_p != NULL) { // must be directory 00266 //DEL if (fh_p->GetfType() != ift_DIR) { 00267 // throw ivd_InternalError(ie_HSM_INVTYPE, 00268 // "Expect directory, but got " + cmn_Num2Str(fh_p->GetfType()), true); 00269 // } 00270 log_DBG_m(dbg_DETAIL, "Update FH " << fh_p->MakePath()); 00271 fh_p->InitActive(idx, actRec); 00272 } 00273 else{ 00274 fh_p = new hsm_FileHeader(idx, actRec); 00275 log_DBG_m(dbg_DETAIL, "New FH " << fh_p->MakePath() << " add to cache."); 00276 g_hsm_FHCache_p->Insert(fh_p); 00277 } 00278 // GetFH and constructor increase ref automaticaly, 00279 // to prevent others to dereference FH before is handled in Event method 00280 fh_p->DecrRef(); 00281 } 00282 } 00283 g_hsmDB_p->ReleaseTransObj(trans); 00284 }


| void hsm_ActiveFH::OrphanedToMigList | ( | ) |
Definition at line 287 of file hsm_ActiveFH.cpp.
References CHG_DELETED_d, hdb_Active_t::chgFlags, ivd_FS_File::Close(), dbg_DETAIL, dbg_NORM, hsm_FileHeader::DecrRef(), ivd_FS_File::e_Cache, eDirWaitList, fio_Transaction::EndTransaction(), eNoList, file, hdb_Active_t::fileID, g_fs_api_p, g_hsm_FHCache_p, g_hsm_fhLock, g_hsmDB_p, hdb_Active_t::generalInode, hsm_FHcache::GetFH(), hsm_FileHeader::GetList(), ivd_FS_File::GetProperties(), ivd_FileSystemAPI::GetRootPath(), fio_DataBase::GetTransObj(), hdb_RemoveName(), hdbReadNameOwnRec(), hsmdbGetPath(), hsm_FHcache::Insert(), IVD_PRINT_ID_FS, log_DBG_m, log_FUNC_m, m_cirFile, ivd_FS_FileProperty_t::m_fileID, ivd_FS_FileProperty_t::m_Inode, hdb_Active_t::nameOwnIdx, NULL, hdb_Active_t::oldNameOwnIdx, ivd_FS_File::Open(), path, fio_CirFileTrans::ReadNext(), fio_CirFileTrans::ReadNextReset(), fio_DataBase::ReleaseTransObj(), fio_Transaction::StartTransaction(), hsm_FileHeader::ToMigCand(), and fio_CirFileTrans::WriteRec().
00287 { 00288 log_FUNC_m(OrphanedToMigList); 00289 00290 hdb_Active_t actRec; 00291 ivd_RecordIDX_t idx; 00292 00293 // reset circular list for read 00294 m_cirFile.ReadNextReset(); 00295 while ((idx = m_cirFile.ReadNext(&actRec)) > 0) { 00296 if (actRec.generalInode == 0) { 00297 continue; 00298 } 00299 00301 if (!(actRec.chgFlags & CHG_DELETED_d)) { 00302 hdb_DirNode_t dir; // default const. it filled with zeroes 00303 ivd_RecordIDX_t dirTreeIdx = 0; 00304 hdb_String name; 00305 hdbReadNameOwnRec(actRec.nameOwnIdx, dirTreeIdx, name, dir); 00306 cmn_Path path = g_fs_api_p->GetRootPath() + hsmdbGetPath(dir) + name; 00307 ivd_FS_File file(*g_fs_api_p, path); 00308 try { 00309 //HPUX - The file needs to be opened ( to be in the kernel cache ). 00310 file.Open(ivd_FS_File::e_Cache); 00311 ivd_FS_FileProperty_t fileProp; 00312 file.GetProperties(fileProp); 00313 //HPUX close file 00314 file.Close(); 00315 if (fileProp.m_fileID == actRec.fileID) { 00316 // got current inode from FS 00317 if (actRec.generalInode != fileProp.m_Inode) { 00318 log_DBG_m(dbg_NORM, "Inode changed. from DB " << IVD_PRINT_ID_FS(actRec.generalInode) 00319 << " from FS " << IVD_PRINT_ID_FS(fileProp.m_Inode)); 00320 actRec.generalInode = fileProp.m_Inode; 00321 } 00322 } 00323 else { 00324 } 00325 } 00326 catch (ivd_SysError) { 00327 log_DBG_m(dbg_NORM, "Can't get general inode of fileID " << actRec.fileID 00328 << " File probably not exist."); 00329 //HPUX close file 00330 file.Close(); 00331 if (actRec.fileID == 0) { // fileID is not migratted yet so remove it 00332 log_DBG_m(dbg_NORM, "Removed from DB"); 00333 fio_Transaction *trans = g_hsmDB_p->GetTransObj(); 00334 trans->StartTransaction(); 00335 if (actRec.oldNameOwnIdx) { 00336 hdb_RemoveName(actRec.oldNameOwnIdx, *trans); 00337 } 00338 hdb_Active_t act; // record with zerroes 00339 m_cirFile.WriteRec(idx, &act, 1, *trans); 00340 // remove nameOwnIdx 00341 hdb_RemoveName(actRec.nameOwnIdx, *trans); 00342 00343 trans->EndTransaction(); 00344 g_hsmDB_p->ReleaseTransObj(&trans); 00345 continue; 00346 } 00347 else { // Set changes to Deletted 00348 log_DBG_m(dbg_NORM, "Set as DELETED."); 00349 fio_Transaction *trans = g_hsmDB_p->GetTransObj(); 00350 trans->StartTransaction(); 00351 00352 if (actRec.oldNameOwnIdx) { //oldName will be replaced, so remove it 00353 hdb_RemoveName(actRec.oldNameOwnIdx, *trans); 00354 } 00355 // update active list 00356 actRec.chgFlags = CHG_DELETED_d; 00357 actRec.oldNameOwnIdx = actRec.nameOwnIdx; 00358 actRec.nameOwnIdx = 0; 00359 00360 m_cirFile.WriteRec(idx, &actRec, 1, *trans); 00361 00362 trans->EndTransaction(); 00363 g_hsmDB_p->ReleaseTransObj(&trans); 00364 } 00365 } 00366 } 00367 g_hsm_fhLock.LockByID(actRec.generalInode); 00368 // directory can be already in cache 00369 hsm_FileHeader *fh_p = g_hsm_FHCache_p->GetFH(actRec.generalInode); 00370 if (fh_p == NULL) { 00371 fh_p = new hsm_FileHeader(idx, actRec, true); // add direct to migcand list 00372 log_DBG_m(dbg_DETAIL, "Active in HSMDB, but not in mig process. Idx = " << idx << endl << actRec); 00373 g_hsm_FHCache_p->Insert(fh_p); 00374 } 00375 else { // must be directory 00376 // check if is in active list 00377 hsm_List_e list = fh_p->GetList(); 00378 if ( list == eDirWaitList 00379 || list == eNoList) { 00380 log_DBG_m(dbg_DETAIL, "Active in HSMDB, but not in mig process. Idx = " << idx << endl << actRec); 00381 fh_p->ToMigCand(); 00382 } 00383 } 00384 // GetFH and constructor increase ref automaticaly, 00385 // to prevent others to dereference FH before is handled in Event method 00386 fh_p->DecrRef(); 00387 g_hsm_fhLock.UnLockByID(actRec.generalInode); 00388 } 00389 }

Definition at line 43 of file hsm_ActiveFH.h.
fio_CirFileTrans& hsm_ActiveFH::m_cirFile [private] |
Definition at line 46 of file hsm_ActiveFH.h.
Referenced by ActiveToList(), Append(), FindNextClearCurrRec(), FindNextRec(), OrphanedToMigList(), Release(), and Update().
ivd_RecordIDX_t hsm_ActiveFH::m_idx [private] |
index of first element in active list
Definition at line 49 of file hsm_ActiveFH.h.
Referenced by Append(), FindNextClearCurrRec(), FindNextRec(), Release(), and Update().
hdb_Active_t hsm_ActiveFH::m_activeFH [private] |
Definition at line 50 of file hsm_ActiveFH.h.
Referenced by Append(), FindNextRec(), GetRefRleaseCandRec(), and Update().
cmn_Mutex hsm_ActiveFH::m_activeFH_x [private] |
Definition at line 52 of file hsm_ActiveFH.h.
Referenced by Append(), FindNextClearCurrRec(), Release(), and Update().
1.5.6