0001
0002
0003
0004
0005
0006
0007 #ifndef _LINUX_DM_SPACE_MAP_H
0008 #define _LINUX_DM_SPACE_MAP_H
0009
0010 #include "dm-block-manager.h"
0011
0012 typedef void (*dm_sm_threshold_fn)(void *context);
0013
0014
0015
0016
0017
0018 struct dm_space_map {
0019 void (*destroy)(struct dm_space_map *sm);
0020
0021
0022
0023
0024 int (*extend)(struct dm_space_map *sm, dm_block_t extra_blocks);
0025
0026
0027
0028
0029
0030 int (*get_nr_blocks)(struct dm_space_map *sm, dm_block_t *count);
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040 int (*get_nr_free)(struct dm_space_map *sm, dm_block_t *count);
0041
0042 int (*get_count)(struct dm_space_map *sm, dm_block_t b, uint32_t *result);
0043 int (*count_is_more_than_one)(struct dm_space_map *sm, dm_block_t b,
0044 int *result);
0045 int (*set_count)(struct dm_space_map *sm, dm_block_t b, uint32_t count);
0046
0047 int (*commit)(struct dm_space_map *sm);
0048
0049 int (*inc_blocks)(struct dm_space_map *sm, dm_block_t b, dm_block_t e);
0050 int (*dec_blocks)(struct dm_space_map *sm, dm_block_t b, dm_block_t e);
0051
0052
0053
0054
0055 int (*new_block)(struct dm_space_map *sm, dm_block_t *b);
0056
0057
0058
0059
0060
0061
0062 int (*root_size)(struct dm_space_map *sm, size_t *result);
0063 int (*copy_root)(struct dm_space_map *sm, void *copy_to_here_le, size_t len);
0064
0065
0066
0067
0068
0069 int (*register_threshold_callback)(struct dm_space_map *sm,
0070 dm_block_t threshold,
0071 dm_sm_threshold_fn fn,
0072 void *context);
0073 };
0074
0075
0076
0077 static inline void dm_sm_destroy(struct dm_space_map *sm)
0078 {
0079 sm->destroy(sm);
0080 }
0081
0082 static inline int dm_sm_extend(struct dm_space_map *sm, dm_block_t extra_blocks)
0083 {
0084 return sm->extend(sm, extra_blocks);
0085 }
0086
0087 static inline int dm_sm_get_nr_blocks(struct dm_space_map *sm, dm_block_t *count)
0088 {
0089 return sm->get_nr_blocks(sm, count);
0090 }
0091
0092 static inline int dm_sm_get_nr_free(struct dm_space_map *sm, dm_block_t *count)
0093 {
0094 return sm->get_nr_free(sm, count);
0095 }
0096
0097 static inline int dm_sm_get_count(struct dm_space_map *sm, dm_block_t b,
0098 uint32_t *result)
0099 {
0100 return sm->get_count(sm, b, result);
0101 }
0102
0103 static inline int dm_sm_count_is_more_than_one(struct dm_space_map *sm,
0104 dm_block_t b, int *result)
0105 {
0106 return sm->count_is_more_than_one(sm, b, result);
0107 }
0108
0109 static inline int dm_sm_set_count(struct dm_space_map *sm, dm_block_t b,
0110 uint32_t count)
0111 {
0112 return sm->set_count(sm, b, count);
0113 }
0114
0115 static inline int dm_sm_commit(struct dm_space_map *sm)
0116 {
0117 return sm->commit(sm);
0118 }
0119
0120 static inline int dm_sm_inc_blocks(struct dm_space_map *sm, dm_block_t b, dm_block_t e)
0121 {
0122 return sm->inc_blocks(sm, b, e);
0123 }
0124
0125 static inline int dm_sm_inc_block(struct dm_space_map *sm, dm_block_t b)
0126 {
0127 return dm_sm_inc_blocks(sm, b, b + 1);
0128 }
0129
0130 static inline int dm_sm_dec_blocks(struct dm_space_map *sm, dm_block_t b, dm_block_t e)
0131 {
0132 return sm->dec_blocks(sm, b, e);
0133 }
0134
0135 static inline int dm_sm_dec_block(struct dm_space_map *sm, dm_block_t b)
0136 {
0137 return dm_sm_dec_blocks(sm, b, b + 1);
0138 }
0139
0140 static inline int dm_sm_new_block(struct dm_space_map *sm, dm_block_t *b)
0141 {
0142 return sm->new_block(sm, b);
0143 }
0144
0145 static inline int dm_sm_root_size(struct dm_space_map *sm, size_t *result)
0146 {
0147 return sm->root_size(sm, result);
0148 }
0149
0150 static inline int dm_sm_copy_root(struct dm_space_map *sm, void *copy_to_here_le, size_t len)
0151 {
0152 return sm->copy_root(sm, copy_to_here_le, len);
0153 }
0154
0155 static inline int dm_sm_register_threshold_callback(struct dm_space_map *sm,
0156 dm_block_t threshold,
0157 dm_sm_threshold_fn fn,
0158 void *context)
0159 {
0160 if (sm->register_threshold_callback)
0161 return sm->register_threshold_callback(sm, threshold, fn, context);
0162
0163 return -EINVAL;
0164 }
0165
0166
0167 #endif