// Copyright (C) 2012 Red Hat, Inc. All rights reserved.
//
// This file is part of the thin-provisioning-tools source.
//
// thin-provisioning-tools is free software: you can redistribute it
// and/or modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation, either version 3 of
// the License, or (at your option) any later version.
//
// thin-provisioning-tools is distributed in the hope that it will be
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with thin-provisioning-tools. If not, see
// .
#include "metadata_disk_structures.h"
#include
using namespace cache_tools;
//----------------------------------------------------------------
void
superblock_traits::unpack(superblock_disk const &disk, superblock &core)
{
core.csum = to_cpu(disk.csum);
core.flags = to_cpu(disk.flags);
core.blocknr = to_cpu(disk.blocknr);
::memcpy(core.uuid, disk.uuid, sizeof(core.uuid));
core.magic = to_cpu(disk.magic);
core.version = to_cpu(disk.version);
::memcpy(core.policy_name, disk.policy_name, sizeof(core.policy_name));
for (unsigned i = 0; i < CACHE_POLICY_VERSION_SIZE; i++)
core.policy_version[i] = to_cpu(disk.policy_version[i]);
core.policy_hint_size = to_cpu(disk.policy_hint_size);
::memcpy(core.metadata_space_map_root,
disk.metadata_space_map_root,
sizeof(core.metadata_space_map_root));
core.mapping_root = to_cpu(disk.mapping_root);
core.hint_root = to_cpu(disk.hint_root);
core.discard_root = to_cpu(disk.discard_root);
core.discard_block_size = to_cpu(disk.discard_block_size);
core.discard_nr_blocks = to_cpu(disk.discard_nr_blocks);
core.data_block_size = to_cpu(disk.data_block_size);
core.metadata_block_size = to_cpu(disk.metadata_block_size);
core.cache_blocks = to_cpu(disk.cache_blocks);
core.compat_flags = to_cpu(disk.compat_flags);
core.compat_ro_flags = to_cpu(disk.compat_ro_flags);
core.incompat_flags = to_cpu(disk.incompat_flags);
core.read_hits = to_cpu(disk.read_hits);
core.read_misses = to_cpu(disk.read_misses);
core.write_hits = to_cpu(disk.write_hits);
core.write_misses = to_cpu(disk.write_misses);
}
void
superblock_traits::pack(superblock const &core, superblock_disk &disk)
{
disk.csum = to_disk(core.csum);
disk.flags = to_disk(core.flags);
disk.blocknr = to_disk(core.blocknr);
::memcpy(disk.uuid, core.uuid, sizeof(disk.uuid));
disk.magic = to_disk(core.magic);
disk.version = to_disk(core.version);
::memcpy(disk.policy_name, core.policy_name, sizeof(disk.policy_name));
for (unsigned i = 0; i < CACHE_POLICY_VERSION_SIZE; i++)
disk.policy_version[i] = to_disk(core.policy_version[i]);
disk.policy_hint_size = to_disk(core.policy_hint_size);
::memcpy(disk.metadata_space_map_root,
core.metadata_space_map_root,
sizeof(disk.metadata_space_map_root));
disk.mapping_root = to_disk(core.mapping_root);
disk.hint_root = to_disk(core.hint_root);
disk.discard_root = to_disk(core.discard_root);
disk.discard_block_size = to_disk(core.discard_block_size);
disk.discard_nr_blocks = to_disk(core.discard_nr_blocks);
disk.data_block_size = to_disk(core.data_block_size);
disk.metadata_block_size = to_disk(core.metadata_block_size);
disk.cache_blocks = to_disk(core.cache_blocks);
disk.compat_flags = to_disk(core.compat_flags);
disk.compat_ro_flags = to_disk(core.compat_ro_flags);
disk.incompat_flags = to_disk(core.incompat_flags);
disk.read_hits = to_disk(core.read_hits);
disk.read_misses = to_disk(core.read_misses);
disk.write_hits = to_disk(core.write_hits);
disk.write_misses = to_disk(core.write_misses);
}
//----------------------------------------------------------------