// File: yangwanyuan[P]HLKVDS/src/Tier.cc
// Function: hlkvds::MediumTier::OpenVolume(std::vector<hlkvds::BlockDevice*, std::allocator<hlkvds::BlockDevice*>>&)
bool MediumTier::OpenVolume(std::vector<BlockDevice*> &bd_vec) {
    int fast_tier_device_num = hlkvds::FastTierVolNum;

    segSize_ = sbResMediumTierHeader_.segment_size;
    volNum_ = sbResMediumTierHeader_.volume_num;

    if (!verifyTopology(bd_vec)) {
        __ERROR("TheDevice Topology is inconsistent");
        return false;
    }

    for (uint32_t i = 0; i < volNum_; i++) {
        BlockDevice *bdev = bd_vec[i + fast_tier_device_num];
        uint32_t seg_num = sbResMediumTierVolVec_[i].segment_num;
        uint32_t cur_seg_id = sbResMediumTierVolVec_[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 $0xa8, %rsp
movq %rdi, 0x98(%rsp)
movq %rsi, 0x90(%rsp)
movq 0x98(%rsp), %rdi
movq %rdi, 0x38(%rsp)
movl $0x1, 0x8c(%rsp)
movl 0x18(%rdi), %eax
movl %eax, 0x38(%rdi)
movl 0x1c(%rdi), %eax
movl %eax, 0x40(%rdi)
movq 0x90(%rsp), %rsi
callq 0x4dcc0
testb $0x1, %al
jne 0x4db29
jmp 0x4daae
movq 0x23523(%rip), %rax     # 0x70fd8
movq (%rax), %rax
movq %rax, 0x30(%rsp)
callq 0x8480
movq 0x30(%rsp), %rdi
movq %rax, %rdx
leaq 0x49e0(%rip), %rsi      # 0x524b1
leaq 0x6af3(%rip), %rcx      # 0x545cb
leaq 0x6a03(%rip), %r8       # 0x544e2
movl $0x306, %r9d            # imm = 0x306
movb $0x0, %al
callq 0x86f0
movq 0x234e5(%rip), %rax     # 0x70fd8
movq (%rax), %rdi
leaq 0x6ad9(%rip), %rsi      # 0x545d6
movb $0x0, %al
callq 0x86f0
movq 0x234cd(%rip), %rax     # 0x70fd8
movq (%rax), %rdi
leaq 0x52b0(%rip), %rsi      # 0x52dc5
movb $0x0, %al
callq 0x86f0
movb $0x0, 0xa7(%rsp)
jmp 0x4dca0
movl $0x0, 0x88(%rsp)
movq 0x38(%rsp), %rcx
movl 0x88(%rsp), %eax
cmpl 0x40(%rcx), %eax
jae 0x4dc98
movq 0x90(%rsp), %rdi
movl 0x88(%rsp), %eax
movl 0x8c(%rsp), %ecx
addl %ecx, %eax
movl %eax, %esi
callq 0x166e0
movq 0x38(%rsp), %rdi
movq (%rax), %rax
movq %rax, 0x80(%rsp)
addq $0x20, %rdi
movq %rdi, 0x20(%rsp)
movl 0x88(%rsp), %eax
movl %eax, %esi
callq 0x4eca0
movq 0x20(%rsp), %rdi
movl 0x100(%rax), %eax
movl %eax, 0x7c(%rsp)
movl 0x88(%rsp), %eax
movl %eax, %esi
callq 0x4eca0
movl 0x104(%rax), %eax
movl %eax, 0x78(%rsp)
movl $0x58, %edi
callq 0x84f0
movq %rax, %rdi
movq 0x38(%rsp), %rax
movq %rdi, %rcx
movq %rcx, 0x28(%rsp)
movq 0x80(%rsp), %rsi
movq (%rax), %rcx
movq 0x10(%rax), %rdx
movl 0x88(%rsp), %r8d
movl 0x38(%rax), %r9d
movl 0x7c(%rsp), %r10d
movl 0x78(%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 0x4dc0f
movq 0x38(%rsp), %rax
movq 0x28(%rsp), %rcx
movq %rcx, 0x70(%rsp)
addq $0x48, %rax
movq %rax, 0x18(%rsp)
leaq 0x50(%rsp), %rdi
leaq 0x88(%rsp), %rsi
leaq 0x70(%rsp), %rdx
callq 0x16750
movq 0x18(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0x16700
movq %rax, %rcx
movq 0x38(%rsp), %rax
movq %rcx, 0x40(%rsp)
movb %dl, 0x48(%rsp)
movl 0x7c(%rsp), %ecx
addl 0x3c(%rax), %ecx
movl %ecx, 0x3c(%rax)
movl 0x88(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x88(%rsp)
jmp 0x4db34
movq 0x28(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x68(%rsp)
movl %eax, 0x64(%rsp)
callq 0x84b0
jmp 0x4dcb1
movb $0x1, 0xa7(%rsp)
movb 0xa7(%rsp), %al
andb $0x1, %al
addq $0xa8, %rsp
retq
movq 0x68(%rsp), %rdi
callq 0x8820
nopl (%rax,%rax)