-
Notifications
You must be signed in to change notification settings - Fork 1
/
thin_pool.h
94 lines (71 loc) · 2.57 KB
/
thin_pool.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
// Copyright (C) 2011 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
// <http://www.gnu.org/licenses/>.
#ifndef MULTISNAP_METADATA_H
#define MULTISNAP_METADATA_H
#include "metadata.h"
#include <string>
#include <boost/shared_ptr.hpp>
//----------------------------------------------------------------
namespace thin_provisioning {
// This interface is very like that in the kernel. It'll allow us
// to write simulators to try out different space maps etc. Not
// currently used by the tools.
class thin_pool;
class thin {
public:
typedef boost::shared_ptr<thin> ptr;
typedef boost::optional<block_time> maybe_address;
thin_dev_t get_dev_t() const;
maybe_address lookup(block_address thin_block);
void insert(block_address thin_block, block_address data_block);
void remove(block_address thin_block);
void set_snapshot_time(uint32_t time);
block_address get_mapped_blocks() const;
void set_mapped_blocks(block_address count);
private:
friend class thin_pool;
thin(thin_dev_t dev, thin_pool *pool); // FIXME: pass a reference rather than a ptr
thin_dev_t dev_;
thin_pool *pool_;
};
class thin_pool {
public:
typedef boost::shared_ptr<thin_pool> ptr;
thin_pool(metadata::ptr md);
~thin_pool();
void create_thin(thin_dev_t dev);
void create_snap(thin_dev_t dev, thin_dev_t origin);
void del(thin_dev_t);
void set_transaction_id(uint64_t id);
uint64_t get_transaction_id() const;
block_address get_metadata_snap() const;
block_address alloc_data_block();
void free_data_block(block_address b);
// accessors
block_address get_nr_free_data_blocks() const;
sector_t get_data_block_size() const;
block_address get_data_dev_size() const;
thin::ptr open_thin(thin_dev_t);
private:
friend class thin;
bool device_exists(thin_dev_t dev) const;
metadata::ptr md_;
};
};
//----------------------------------------------------------------
#endif