2 * Copyright (C) 2011 Red Hat, Inc. All rights reserved.
4 * This file is released under the GPL.
7 #ifndef DM_SPACE_MAP_COMMON_H
8 #define DM_SPACE_MAP_COMMON_H
13 *--------------------------------------------------------------------
14 * Low level disk format
19 * Each value stored in the btree is an index_entry. This points to a
20 * block that is used as a bitmap. Within the bitmap hold 2 bits per
21 * entry, which represent UNUSED = 0, REF_COUNT = 1, REF_COUNT = 2 and
27 * Any entry that has a ref count higher than 2 gets entered in the ref
28 * count tree. The leaf values for this tree is the 32-bit ref count.
29 *---------------------------------------------------------------------
32 struct disk_index_entry
{
35 __le32 none_free_before
;
39 #define MAX_METADATA_BITMAPS 255
40 struct disk_metadata_index
{
45 struct disk_index_entry index
[MAX_METADATA_BITMAPS
];
49 struct dm_transaction_manager
*tm
;
50 struct dm_btree_info bitmap_info
;
51 struct dm_btree_info ref_count_info
;
54 uint32_t entries_per_block
;
56 dm_block_t nr_allocated
;
59 * bitmap_root may be a btree root or a simple index.
61 dm_block_t bitmap_root
;
63 dm_block_t ref_count_root
;
65 struct disk_metadata_index mi_le
;
72 __le64 ref_count_root
;
75 #define ENTRIES_PER_BYTE 4
77 struct disk_bitmap_header
{
84 * These bitops work on a block's worth of bits.
86 unsigned sm_lookup_bitmap(void *addr
, unsigned b
);
87 void sm_set_bitmap(void *addr
, unsigned b
, unsigned val
);
88 int sm_find_free(void *addr
, unsigned begin
, unsigned end
, unsigned *result
);
90 void *dm_bitmap_data(struct dm_block
*b
);
92 extern struct dm_block_validator dm_sm_bitmap_validator
;
94 #endif /* DM_SPACE_MAP_COMMON_H */