您好,登錄后才能下訂單哦!
這篇文章主要介紹MDSTable相關內容有哪些,文中介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們一定要看完!
對MDSTable的操作主要是對version和state保存到集群以及從集群中讀取的操作。具體操作處理函數說明如下:
MDSTable::save()
|__對version和state進行encode操作
|__設置committing_version = version 設置committing_version
|__設置waitfor_save[version].push_back(onfinish)
|__get_object_name() 得到對象名稱mds_${table_name}
|__得到object_locator_t類實例,即:將數據存放到metadata pool中
|__mds->object_write_full() 將version和state的encode數據寫入到metadata pool中的mds_${table_name}對象中
MDSTable::save_2()
|__committed_version = v 設置committed_version
|__遍歷waitfor_save數組
|__對于waitfor_save[i]->first <=v的,從waitfor_save數組中刪除
MDSTable::reset()
|__reset_state()
|__state = STATE_ACTIVE 設置state當前值
MDSTable::load()
|__state = STATE_OPENING 設置state當前值
|__get_object_name() 得到對象名稱mds_${table_name}
|__得到object_locator_t類實例,即:將數據存放到metadata pool中
|__mds->objecter->read_full() 從集群中獲取MDSTable信息
MDSTable::load_2()
|__state = STATE_ACTIVE
|__若r == -EBLACKLISTED,則調用mds->respawn()
|__若r < 0,則調用mds->damaged()
|__從集群的得到version值且設置projected_version=committed_version=version
|__從集群中得到state信息
MDSTableServer類繼承MDSTable類
class MDSTableServer : public MDSTable {
int table;
map<version_t,mds_table_pending_t> pending_for_mds; 記錄對mds操作未完成的信息
};
MDSTableServer::handle_request() 總路由調度函數,負責將請求分派給不同的handle_*()來處理
|__TABLESERVER_OP_QUERY
|__handle_query()
|__TABLESERVER_OP_PREPARE
|__handle_prepare()
|__TABLESERVER_OP_COMMIT
|__handle_commit()
|__TABLESERVER_OP_ROLLBACK
|__handle_rollback()
MDSTableServer::handle_prepare()
|___prepare() 調用子類的_prepare()函數從request消息中得到具體的信息
|___note_prepare() 填充pending_for_mds數組
|__創建ETableServer類對象
|__mds->mdlog->submit_entry() 寫log
|__mds->mdlog->flush()
MDSTableServer::_prepare_logged() 該函數是handle_prepare()執行完寫log后的回調函數
|__創建MMDSTableRequest類消息(TABLESERVER_OP_AGREE)
|__mds->send_message_mds() 將類消息發送回給調用handle_prepare()的對端
MDSTableServer::handle_commit()
|__檢查pending_for_mds數組中是否包含對應的項
|___commit() 執行子類的commit操作
|___note_commit() 刪除pending_for_mds數組中對應的項
|__mds->mdlog->start_submit_entry() 寫log
MDSTableServer::_commit_logged() 該函數是handle_commit()執行完寫log后的回調函數
|__創建MMDSTableRequest類消息(TABLESERVER_OP_ACK)
|__mds->send_message_mds() 將類消息發送回給調用handle_prepare()的對端
MDSTableServer::handle_rollback()
|___rollback() 執行子類的rollback操作
|___note_rollback() 刪除pending_for_mds數組中對應的項
|___mds->mdlog->start_submit_entry() 寫log
MDSTableServer::do_server_update()
|__創建ETableServer類實例
|__mds->mdlog->start_entry()
|__mds->mdlog->submit_entry() 寫log
MDSTableServer::finish_recovery()
|__遍歷參數中的mds_rank_t集合
|__handle_mds_recovery()
MDSTableServer::handle_mds_recovery()
|__遍歷pending_for_mds數組
|__創建MMDSTableRequest類消息(TABLESERVER_OP_AGREE)
|__mds->send_message_mds() 發送mds消息
|__創建MMDSTableRequest類消息(TABLESERVER_OP_SERVER_READY)
|__mds->send_message_mds() 發送mds消息
SnapServer類繼承于MDSTableServer,用來記錄需要進行Snap操作的相關信息
class SnapServer: public MDSTableServer {
MonClient *mon_client; 與monitor交互的client端
snapid_t last_snap;
map<snapid_t, SnapInfo> snaps;
map<int, set<snapid_t>> need_to_purge;
map<version_t, SnapInfo> pending_update;
map<version_t, pair<snapid_t, snapid_t>> pending_destroy;
set<version_t> pending_noop;
version_t last_checked_osdmap;
};
SnapServer::reset_state() 清空snaps和need_to_purge這兩個數組,之后獲取last_snap值
|__設置last_snap=1
|__清除snaps和need_to_purge數組
|__遍歷mds使用的osdmap
|__遍歷mdsmap使用的所有data pools
|__從osdmap中得到data pool對應的pg_pool_t結構
|__對于pg_pool_t結構中removed_snaps數組不為空,則取removed_snaps.range_end()最大值
|__設置last_snap = removed_snaps.range_end()的最大值
SnapServer::_prepare()
|__TABLE_OP_CREATE
|__更新version值(version++)
|__從參數bufferlist中得到SnapInfo信息(ino/name/stamp)
|__設置SnapInfo的snapid = ++last_snap/long_name=“create"
|__更新pending_update[version] = info
|__TABLE_OP_DESTROY
|__從參數bufferlist中得到inodeno_t和snapid_t的值
|__更新version值和last_snap值(version++/++last_snap)
|__更新pending_destroy[version]數組
|__TABLE_OP_UPDATE
|__從參數bufferlist中得到SnapInfo信息(ino/snapid/name/stamp)
|__更新version值和last_snap值(version++/++last_snap)
|__更新pending_update[version] = info
SnapServer::_is_prepared()
|__判斷pending_update或pending_destroy數組中是否包含參數指定的tid
SnapServer::_commit()
|__待commit的tid在pending_update數組中
|__從pending_update數組中得到指定tid的SnapInfo值
|__更新snaps[info.snapid] = info
|__刪除pending_update[tid]
|__待commit的tid在pending_destroy數組中
|__從pending_destroy數組中得到指定tid對應的snapid和last_snapid
|__從snaps數組中刪除snapid對應的值
|__遍歷mdsmap所有的data pools
|__更新need_to_purge數組(need_to_purge[*p].insert(snapid)/need_to_purge[*p].insert(last_snapid)
|__刪除pending_destroy[tid]
|__更新version (version++)
SnapServer::_rollback()
|__在pending_update/pending_destroy數組中刪除掉指定tid的值
SnapServer::_server_update()
|__從參數bufferlist中得到map<int, vector<snapid_t>> purge值
|__遍歷purge
|__刪除need_to_purge中指定的內容
|__更新version
SnapServer::check_osd_map()
|__遍歷mds對應的所有osdmap
|__遍歷need_to_purge數組
|__從osdmap中得到pg_pool_t數據結構的值
|__若pg_pool_t為空,則設置all_purged[id] = need_to_purge[id].all
|__遍歷need_to_purge數組的第二個參數
|__若pg_pool_t->is_removed_snap(i),則設置all_purged[id].push_back(i),否則設置all_purge[id].push_back(i)
|__對于all_purged數組不為空
|__將all_purged數組序列化
|__MDSTableServer::do_server_update()
|__SnapServer::_server_update()
|__創建ETableServer類對象
|__mds->mdlog->start_entry()
|__mds->mdlog->submit_entry() 寫log
|__對于all_purge數組不為空
|__創建MRemoveSnaps類消息
|__mon_client->send_mon_message() 將消息發送給monitor來刪除對應的snaps
MDSTable/MDSTableServer/SnapServer之間的關系如下圖所示:
以上是“MDSTable相關內容有哪些”這篇文章的所有內容,感謝各位的閱讀!希望分享的內容對大家有幫助,更多相關知識,歡迎關注億速云行業資訊頻道!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。