Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
dm-space-map-common.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2011 Red Hat, Inc.
3  *
4  * This file is released under the GPL.
5  */
6 
7 #ifndef DM_SPACE_MAP_COMMON_H
8 #define DM_SPACE_MAP_COMMON_H
9 
10 #include "dm-btree.h"
11 
12 /*----------------------------------------------------------------*/
13 
14 /*
15  * Low level disk format
16  *
17  * Bitmap btree
18  * ------------
19  *
20  * Each value stored in the btree is an index_entry. This points to a
21  * block that is used as a bitmap. Within the bitmap hold 2 bits per
22  * entry, which represent UNUSED = 0, REF_COUNT = 1, REF_COUNT = 2 and
23  * REF_COUNT = many.
24  *
25  * Refcount btree
26  * --------------
27  *
28  * Any entry that has a ref count higher than 2 gets entered in the ref
29  * count tree. The leaf values for this tree is the 32-bit ref count.
30  */
31 
36 } __packed;
37 
38 
39 #define MAX_METADATA_BITMAPS 255
44 
46 } __packed;
47 
48 struct ll_disk;
49 
50 typedef int (*load_ie_fn)(struct ll_disk *ll, dm_block_t index, struct disk_index_entry *result);
51 typedef int (*save_ie_fn)(struct ll_disk *ll, dm_block_t index, struct disk_index_entry *ie);
52 typedef int (*init_index_fn)(struct ll_disk *ll);
53 typedef int (*open_index_fn)(struct ll_disk *ll);
54 typedef dm_block_t (*max_index_entries_fn)(struct ll_disk *ll);
55 typedef int (*commit_fn)(struct ll_disk *ll);
56 
57 struct ll_disk {
61 
66 
67  /*
68  * bitmap_root may be a btree root or a simple index.
69  */
71 
73 
82 };
83 
84 struct disk_sm_root {
89 } __packed;
90 
91 #define ENTRIES_PER_BYTE 4
92 
97 } __packed;
98 
103 };
104 
105 /*----------------------------------------------------------------*/
106 
107 int sm_ll_extend(struct ll_disk *ll, dm_block_t extra_blocks);
109 int sm_ll_lookup(struct ll_disk *ll, dm_block_t b, uint32_t *result);
110 int sm_ll_find_free_block(struct ll_disk *ll, dm_block_t begin,
112 int sm_ll_insert(struct ll_disk *ll, dm_block_t b, uint32_t ref_count, enum allocation_event *ev);
113 int sm_ll_inc(struct ll_disk *ll, dm_block_t b, enum allocation_event *ev);
114 int sm_ll_dec(struct ll_disk *ll, dm_block_t b, enum allocation_event *ev);
115 int sm_ll_commit(struct ll_disk *ll);
116 
117 int sm_ll_new_metadata(struct ll_disk *ll, struct dm_transaction_manager *tm);
118 int sm_ll_open_metadata(struct ll_disk *ll, struct dm_transaction_manager *tm,
119  void *root_le, size_t len);
120 
121 int sm_ll_new_disk(struct ll_disk *ll, struct dm_transaction_manager *tm);
122 int sm_ll_open_disk(struct ll_disk *ll, struct dm_transaction_manager *tm,
123  void *root_le, size_t len);
124 
125 /*----------------------------------------------------------------*/
126 
127 #endif /* DM_SPACE_MAP_COMMON_H */