// File: yangwanyuan[P]HLKVDS/src/DS_MultiVolume_Impl.cc
// Function: hlkvds::DS_MultiVolume_Impl::OpenAllComponents()
bool DS_MultiVolume_Impl::OpenAllComponents() {
    volNum_ = sbResHeader_.volume_num;
    segSize_ = sbResHeader_.segment_size;
    maxValueLen_ = segSize_ - SegBase::SizeOfSegOnDisk() - IndexManager::SizeOfHashEntryOnDisk();
    sstLengthOnDisk_ = sbMgr_->GetSSTRegionLength();

    BlockDevice *meta_bdev = bdVec_[0];
    uint32_t meta_seg_num = sbResVolVec_[0].segment_num;
    uint32_t meta_cur_seg_id = sbResVolVec_[0].cur_seg_id;

    if (!verifyTopology()) {
        __ERROR("The Device Topoloygy is inconsistent");
        return false;
    }

    //Create Meta Volume
    uint64_t start_off = sbMgr_->GetSSTRegionOffset() + sstLengthOnDisk_;

    Volume *meta_vol = new Volume(meta_bdev, idxMgr_, options_, 0, start_off, segSize_, meta_seg_num, meta_cur_seg_id);
    volMap_.insert( pair<int, Volume *>(0, meta_vol) );

    segTotalNum_ += meta_seg_num;

    //Create Pure Volumes
    if (volNum_ > 1) {
        for (uint32_t i = 1 ; i < volNum_; i++) {
            BlockDevice *bdev = bdVec_[i];
            uint32_t seg_num = sbResVolVec_[i].segment_num;
            uint32_t cur_seg_id = sbResVolVec_[i].cur_seg_id;
            Volume *vol = new Volume(bdev, idxMgr_, options_, i, 0, segSize_, seg_num, cur_seg_id);
            volMap_.insert( pair<int, Volume *>(i, vol) );

            segTotalNum_ += seg_num;
        }
    }

    return true;
}

// Assembly:
subq $0x108, %rsp            # imm = 0x108
movq %rdi, 0xf8(%rsp)
movq 0xf8(%rsp), %rax
movq %rax, 0x58(%rsp)
movl 0x124(%rax), %ecx
movl %ecx, 0xe0(%rax)
movl 0x120(%rax), %ecx
movl %ecx, 0xd8(%rax)
movl 0xd8(%rax), %eax
movq %rax, 0x48(%rsp)
callq 0x166a0
movq %rax, %rcx
movq 0x48(%rsp), %rax
subq %rcx, %rax
movq %rax, 0x50(%rsp)
callq 0x166b0
movq 0x50(%rsp), %rcx
movq %rax, %rdx
movq 0x58(%rsp), %rax
subq %rdx, %rcx
movl %ecx, 0xdc(%rax)
movq 0x18(%rax), %rdi
callq 0x167b0
movq %rax, %rcx
movq 0x58(%rsp), %rax
movq %rcx, 0xe8(%rax)
movq 0x10(%rax), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x166e0
movq 0x58(%rsp), %rdi
movq (%rax), %rax
movq %rax, 0xf0(%rsp)
addq $0x128, %rdi            # imm = 0x128
xorl %eax, %eax
movl %eax, %esi
callq 0x16380
movq 0x58(%rsp), %rdi
movl 0x100(%rax), %eax
movl %eax, 0xec(%rsp)
addq $0x128, %rdi            # imm = 0x128
xorl %eax, %eax
movl %eax, %esi
callq 0x16380
movq 0x58(%rsp), %rdi
movl 0x104(%rax), %eax
movl %eax, 0xe8(%rsp)
callq 0x14810
testb $0x1, %al
jne 0x1451e
jmp 0x144a3
movq 0x5cb2e(%rip), %rax     # 0x70fd8
movq (%rax), %rax
movq %rax, 0x40(%rsp)
callq 0x8480
movq 0x40(%rsp), %rdi
movq %rax, %rdx
leaq 0x3dfeb(%rip), %rsi     # 0x524b1
leaq 0x3e004(%rip), %rcx     # 0x524d1
leaq 0x3e07d(%rip), %r8      # 0x52551
movl $0x161, %r9d            # imm = 0x161
movb $0x0, %al
callq 0x86f0
movq 0x5caf0(%rip), %rax     # 0x70fd8
movq (%rax), %rdi
leaq 0x3e359(%rip), %rsi     # 0x5284b
movb $0x0, %al
callq 0x86f0
movq 0x5cad8(%rip), %rax     # 0x70fd8
movq (%rax), %rdi
leaq 0x3e8bb(%rip), %rsi     # 0x52dc5
movb $0x0, %al
callq 0x86f0
movb $0x0, 0x107(%rsp)
jmp 0x147ec
movq 0x58(%rsp), %rax
movq 0x18(%rax), %rdi
callq 0x167c0
movq 0x58(%rsp), %rcx
movq 0xe8(%rcx), %rcx
addq %rcx, %rax
movq %rax, 0xe0(%rsp)
movl $0x58, %edi
callq 0x84f0
movq %rax, %rdi
movq 0x58(%rsp), %rax
movq %rdi, %rcx
movq %rcx, 0x38(%rsp)
movq 0xf0(%rsp), %rsi
movq 0x8(%rax), %rcx
movq 0x20(%rax), %rdx
movq 0xe0(%rsp), %r9
movl 0xd8(%rax), %r8d
movl 0xec(%rsp), %r10d
movl 0xe8(%rsp), %r11d
movq %rsp, %rax
movl %r11d, 0x10(%rax)
movl %r10d, 0x8(%rax)
movl %r8d, (%rax)
xorl %r8d, %r8d
callq 0x50b10
jmp 0x145a4
movq 0x58(%rsp), %rax
movq 0x38(%rsp), %rcx
movq %rcx, 0xd8(%rsp)
addq $0x28, %rax
movq %rax, 0x30(%rsp)
movl $0x0, 0xb4(%rsp)
leaq 0xb8(%rsp), %rdi
leaq 0xb4(%rsp), %rsi
leaq 0xd8(%rsp), %rdx
callq 0x167d0
movq 0x30(%rsp), %rdi
leaq 0xb8(%rsp), %rsi
callq 0x16700
movq %rax, %rcx
movq 0x58(%rsp), %rax
movq %rcx, 0xa0(%rsp)
movb %dl, 0xa8(%rsp)
movl 0xec(%rsp), %ecx
addl 0xe4(%rax), %ecx
movl %ecx, 0xe4(%rax)
cmpl $0x1, 0xe0(%rax)
jbe 0x147e4
movl $0x1, 0x9c(%rsp)
movq 0x58(%rsp), %rcx
movl 0x9c(%rsp), %eax
cmpl 0xe0(%rcx), %eax
jae 0x147e2
movq 0x58(%rsp), %rax
movq 0x10(%rax), %rdi
movl 0x9c(%rsp), %eax
movl %eax, %esi
callq 0x166e0
movq 0x58(%rsp), %rdi
movq (%rax), %rax
movq %rax, 0x90(%rsp)
addq $0x128, %rdi            # imm = 0x128
movq %rdi, 0x20(%rsp)
movl 0x9c(%rsp), %eax
movl %eax, %esi
callq 0x16380
movq 0x20(%rsp), %rdi
movl 0x100(%rax), %eax
movl %eax, 0x8c(%rsp)
movl 0x9c(%rsp), %eax
movl %eax, %esi
callq 0x16380
movl 0x104(%rax), %eax
movl %eax, 0x88(%rsp)
movl $0x58, %edi
callq 0x84f0
movq %rax, %rdi
movq 0x58(%rsp), %rax
movq %rdi, %rcx
movq %rcx, 0x28(%rsp)
movq 0x90(%rsp), %rsi
movq 0x8(%rax), %rcx
movq 0x20(%rax), %rdx
movl 0x9c(%rsp), %r8d
movl 0xd8(%rax), %r9d
movl 0x8c(%rsp), %r10d
movl 0x88(%rsp), %r11d
movq %rsp, %rax
movl %r11d, 0x10(%rax)
movl %r10d, 0x8(%rax)
movl %r9d, (%rax)
xorl %eax, %eax
movl %eax, %r9d
callq 0x50b10
jmp 0x14724
movq 0x58(%rsp), %rax
movq 0x28(%rsp), %rcx
movq %rcx, 0x80(%rsp)
addq $0x28, %rax
movq %rax, 0x18(%rsp)
leaq 0x70(%rsp), %rdi
leaq 0x9c(%rsp), %rsi
leaq 0x80(%rsp), %rdx
callq 0x16750
movq 0x18(%rsp), %rdi
leaq 0x70(%rsp), %rsi
callq 0x16700
movq %rax, %rcx
movq 0x58(%rsp), %rax
movq %rcx, 0x60(%rsp)
movb %dl, 0x68(%rsp)
movl 0x8c(%rsp), %ecx
addl 0xe4(%rax), %ecx
movl %ecx, 0xe4(%rax)
movl 0x9c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x9c(%rsp)
jmp 0x1463b
movq 0x38(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd0(%rsp)
movl %eax, 0xcc(%rsp)
callq 0x84b0
jmp 0x147fd
movq 0x28(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd0(%rsp)
movl %eax, 0xcc(%rsp)
callq 0x84b0
jmp 0x147fd
jmp 0x147e4
movb $0x1, 0x107(%rsp)
movb 0x107(%rsp), %al
andb $0x1, %al
addq $0x108, %rsp            # imm = 0x108
retq
movq 0xd0(%rsp), %rdi
callq 0x8820
nopw (%rax,%rax)