thin-provisioning-tools/thin-provisioning/metadata_disk_structures.h

115 lines
3.2 KiB
C
Raw Normal View History

2011-12-16 00:04:31 +05:30
// Copyright (C) 2011 Red Hat, Inc. All rights reserved.
2011-12-06 19:23:05 +05:30
//
2011-12-06 19:13:56 +05:30
// 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
// <http://www.gnu.org/licenses/>.
2011-07-22 20:39:56 +05:30
#ifndef METADATA_DISK_STRUCTURES_H
#define METADATA_DISK_STRUCTURES_H
#include "persistent-data/endian_utils.h"
#include "persistent-data/data-structures/btree.h"
2011-07-22 20:39:56 +05:30
//----------------------------------------------------------------
namespace thin_provisioning {
using namespace base; // FIXME: don't use namespaces in headers.
unsigned const SPACE_MAP_ROOT_SIZE = 128;
typedef unsigned char __u8;
struct superblock_disk {
2013-03-22 21:18:43 +05:30
le32 csum_;
le32 flags_;
le64 blocknr_;
2011-07-22 20:39:56 +05:30
__u8 uuid_[16];
2013-03-22 21:18:43 +05:30
le64 magic_;
le32 version_;
le32 time_;
2011-07-22 20:39:56 +05:30
2013-03-22 21:18:43 +05:30
le64 trans_id_;
2011-07-22 20:39:56 +05:30
/* root for userspace's transaction (for migration and friends) */
2013-03-22 21:18:43 +05:30
le64 metadata_snap_;
2011-07-22 20:39:56 +05:30
__u8 data_space_map_root_[SPACE_MAP_ROOT_SIZE];
__u8 metadata_space_map_root_[SPACE_MAP_ROOT_SIZE];
/* 2 level btree mapping (dev_id, (dev block, time)) -> data block */
2013-03-22 21:18:43 +05:30
le64 data_mapping_root_;
2011-07-22 20:39:56 +05:30
/* device detail root mapping dev_id -> device_details */
2013-03-22 21:18:43 +05:30
le64 device_details_root_;
2011-07-22 20:39:56 +05:30
2013-03-22 21:18:43 +05:30
le32 data_block_size_; /* in 512-byte sectors */
2011-07-22 20:39:56 +05:30
2013-03-22 21:18:43 +05:30
le32 metadata_block_size_; /* in 512-byte sectors */
le64 metadata_nr_blocks_;
2011-07-22 20:39:56 +05:30
2013-03-22 21:18:43 +05:30
le32 compat_flags_;
le32 compat_ro_flags_;
le32 incompat_flags_;
2011-07-22 20:39:56 +05:30
} __attribute__ ((packed));
struct superblock {
uint32_t csum_;
uint32_t flags_;
uint64_t blocknr_;
unsigned char uuid_[16];
uint64_t magic_;
uint32_t version_;
uint32_t time_;
uint64_t trans_id_;
/* root for userspace's transaction (for migration and friends) */
uint64_t metadata_snap_;
2011-07-22 20:39:56 +05:30
unsigned char data_space_map_root_[SPACE_MAP_ROOT_SIZE];
unsigned char metadata_space_map_root_[SPACE_MAP_ROOT_SIZE];
/* 2 level btree mapping (dev_id, (dev block, time)) -> data block */
uint64_t data_mapping_root_;
/* device detail root mapping dev_id -> device_details */
uint64_t device_details_root_;
uint32_t data_block_size_; /* in 512-byte sectors */
uint32_t metadata_block_size_; /* in 512-byte sectors */
uint64_t metadata_nr_blocks_;
uint32_t compat_flags_;
uint32_t compat_ro_flags_;
2011-07-22 20:39:56 +05:30
uint32_t incompat_flags_;
};
struct superblock_traits {
typedef superblock_disk disk_type;
typedef superblock value_type;
typedef no_op_ref_counter<superblock> ref_counter;
2011-07-22 20:39:56 +05:30
2013-03-15 20:29:32 +05:30
static void unpack(superblock_disk const &disk, superblock &core);
static void pack(superblock const &core, superblock_disk &disk);
2011-07-22 20:39:56 +05:30
};
2013-04-25 20:57:07 +05:30
block_address const SUPERBLOCK_LOCATION = 0;
2011-07-22 20:39:56 +05:30
}
//----------------------------------------------------------------
#endif