Skip to content

Commit 6008d52

Browse files
bjohnstoMike Snitzer
authored andcommitted
dm-vdo: change unnamed enums to defines
Signed-off-by: Bruce Johnston <[email protected]> Signed-off-by: Matthew Sakai <[email protected]> Signed-off-by: Mike Snitzer <[email protected]>
1 parent 04530b4 commit 6008d52

25 files changed

+91
-160
lines changed

drivers/md/dm-vdo/block-map.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,8 @@ const struct block_map_entry UNMAPPED_BLOCK_MAP_ENTRY = {
114114
.pbn_low_word = __cpu_to_le32(VDO_ZERO_BLOCK & UINT_MAX),
115115
};
116116

117-
enum {
118-
LOG_INTERVAL = 4000,
119-
DISPLAY_INTERVAL = 100000,
120-
};
117+
#define LOG_INTERVAL 4000
118+
#define DISPLAY_INTERVAL 100000
121119

122120
/*
123121
* For adjusting VDO page cache statistic fields which are only mutated on the logical zone thread.

drivers/md/dm-vdo/data-vio.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,7 @@ static blk_opf_t PASSTHROUGH_FLAGS = (REQ_PRIO | REQ_META | REQ_SYNC | REQ_RAHEA
114114
* them are awakened.
115115
*/
116116

117-
enum {
118-
DATA_VIO_RELEASE_BATCH_SIZE = 128,
119-
};
117+
#define DATA_VIO_RELEASE_BATCH_SIZE 128
120118

121119
static const unsigned int VDO_SECTORS_PER_BLOCK_MASK = VDO_SECTORS_PER_BLOCK - 1;
122120
static const u32 COMPRESSION_STATUS_MASK = 0xff;
@@ -1044,8 +1042,8 @@ void dump_data_vio_pool(struct data_vio_pool *pool, bool dump_vios)
10441042
* In order that syslog can empty its buffer, sleep after 35 elements for 4ms (till the
10451043
* second clock tick). These numbers were picked based on experiments with lab machines.
10461044
*/
1047-
enum { ELEMENTS_PER_BATCH = 35 };
1048-
enum { SLEEP_FOR_SYSLOG = 4000 };
1045+
static const int ELEMENTS_PER_BATCH = 35;
1046+
static const int SLEEP_FOR_SYSLOG = 4000;
10491047

10501048
if (pool == NULL)
10511049
return;

drivers/md/dm-vdo/dedupe.c

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -154,11 +154,9 @@ struct uds_attribute {
154154
const char *(*show_string)(struct hash_zones *hash_zones);
155155
};
156156

157-
enum timer_state {
158-
DEDUPE_QUERY_TIMER_IDLE,
159-
DEDUPE_QUERY_TIMER_RUNNING,
160-
DEDUPE_QUERY_TIMER_FIRED,
161-
};
157+
#define DEDUPE_QUERY_TIMER_IDLE 0
158+
#define DEDUPE_QUERY_TIMER_RUNNING 1
159+
#define DEDUPE_QUERY_TIMER_FIRED 2
162160

163161
enum dedupe_context_state {
164162
DEDUPE_CONTEXT_IDLE,
@@ -185,11 +183,9 @@ static const char *SUSPENDED = "suspended";
185183
static const char *UNKNOWN = "unknown";
186184

187185
/* Version 2 uses the kernel space UDS index and is limited to 16 bytes */
188-
enum {
189-
UDS_ADVICE_VERSION = 2,
190-
/* version byte + state byte + 64-bit little-endian PBN */
191-
UDS_ADVICE_SIZE = 1 + 1 + sizeof(u64),
192-
};
186+
#define UDS_ADVICE_VERSION 2
187+
/* version byte + state byte + 64-bit little-endian PBN */
188+
#define UDS_ADVICE_SIZE (1 + 1 + sizeof(u64))
193189

194190
enum hash_lock_state {
195191
/* State for locks that are not in use or are being initialized. */
@@ -279,9 +275,7 @@ struct hash_lock {
279275
struct vdo_wait_queue waiters;
280276
};
281277

282-
enum {
283-
LOCK_POOL_CAPACITY = MAXIMUM_VDO_USER_VIOS,
284-
};
278+
#define LOCK_POOL_CAPACITY MAXIMUM_VDO_USER_VIOS
285279

286280
struct hash_zones {
287281
struct action_manager *manager;

drivers/md/dm-vdo/dm-vdo-target.c

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242

4343
#define CURRENT_VERSION "8.3.0.65"
4444

45-
enum {
45+
enum admin_phases {
4646
GROW_LOGICAL_PHASE_START,
4747
GROW_LOGICAL_PHASE_GROW_BLOCK_MAP,
4848
GROW_LOGICAL_PHASE_END,
@@ -142,10 +142,8 @@ static const char * const ADMIN_PHASE_NAMES[] = {
142142
"SUSPEND_PHASE_END",
143143
};
144144

145-
enum {
146-
/* If we bump this, update the arrays below */
147-
TABLE_VERSION = 4,
148-
};
145+
/* If we bump this, update the arrays below */
146+
#define TABLE_VERSION 4
149147

150148
/* arrays for handling different table versions */
151149
static const u8 REQUIRED_ARGC[] = { 10, 12, 9, 7, 6 };
@@ -159,17 +157,15 @@ static const u8 POOL_NAME_ARG_INDEX[] = { 8, 10, 8 };
159157
* need to scan 16 words, so it's not likely to be a big deal compared to other resource usage.
160158
*/
161159

162-
enum {
163-
/*
164-
* This minimum size for the bit array creates a numbering space of 0-999, which allows
165-
* successive starts of the same volume to have different instance numbers in any
166-
* reasonably-sized test. Changing instances on restart allows vdoMonReport to detect that
167-
* the ephemeral stats have reset to zero.
168-
*/
169-
BIT_COUNT_MINIMUM = 1000,
170-
/** Grow the bit array by this many bits when needed */
171-
BIT_COUNT_INCREMENT = 100,
172-
};
160+
/*
161+
* This minimum size for the bit array creates a numbering space of 0-999, which allows
162+
* successive starts of the same volume to have different instance numbers in any
163+
* reasonably-sized test. Changing instances on restart allows vdoMonReport to detect that
164+
* the ephemeral stats have reset to zero.
165+
*/
166+
#define BIT_COUNT_MINIMUM 1000
167+
/* Grow the bit array by this many bits when needed */
168+
#define BIT_COUNT_INCREMENT 100
173169

174170
struct instance_tracker {
175171
unsigned int bit_count;

drivers/md/dm-vdo/dump.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ enum dump_option_flags {
4141
FLAG_SKIP_DEFAULT = (1 << SKIP_DEFAULT)
4242
};
4343

44-
enum {
45-
FLAGS_ALL_POOLS = (FLAG_SHOW_VIO_POOL),
46-
DEFAULT_DUMP_FLAGS = (FLAG_SHOW_QUEUES | FLAG_SHOW_VDO_STATUS)
47-
};
44+
#define FLAGS_ALL_POOLS (FLAG_SHOW_VIO_POOL)
45+
#define DEFAULT_DUMP_FLAGS (FLAG_SHOW_QUEUES | FLAG_SHOW_VDO_STATUS)
46+
/* Another static buffer... log10(256) = 2.408+, round up: */
47+
#define DIGITS_PER_U64 (1 + sizeof(u64) * 2409 / 1000)
4848

4949
static inline bool is_arg_string(const char *arg, const char *this_option)
5050
{
@@ -222,9 +222,6 @@ void dump_data_vio(void *data)
222222
* one does run, the log output will be garbled anyway.
223223
*/
224224
static char vio_completion_dump_buffer[100 + MAX_VDO_WORK_QUEUE_NAME_LEN];
225-
/* Another static buffer... log10(256) = 2.408+, round up: */
226-
enum { DIGITS_PER_U64 = 1 + sizeof(u64) * 2409 / 1000 };
227-
228225
static char vio_block_number_dump_buffer[sizeof("P L D") + 3 * DIGITS_PER_U64];
229226
static char vio_flush_generation_buffer[sizeof(" FG") + DIGITS_PER_U64];
230227
static char flags_dump_buffer[8];

drivers/md/dm-vdo/encodings.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,7 @@ static const struct header GEOMETRY_BLOCK_HEADER_4_0 = {
5555

5656
const u8 VDO_GEOMETRY_MAGIC_NUMBER[VDO_GEOMETRY_MAGIC_NUMBER_SIZE + 1] = "dmvdo001";
5757

58-
enum {
59-
PAGE_HEADER_4_1_SIZE = 8 + 8 + 8 + 1 + 1 + 1 + 1,
60-
};
58+
#define PAGE_HEADER_4_1_SIZE (8 + 8 + 8 + 1 + 1 + 1 + 1)
6159

6260
static const struct version_number BLOCK_MAP_4_1 = {
6361
.major_version = 4,

drivers/md/dm-vdo/errors.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,7 @@ struct error_block {
7979
const struct error_info *infos;
8080
};
8181

82-
enum {
83-
MAX_ERROR_BLOCKS = 6,
84-
};
82+
#define MAX_ERROR_BLOCKS 6
8583

8684
static struct {
8785
int allocated;

drivers/md/dm-vdo/indexer/config.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,10 @@ static const u8 INDEX_CONFIG_MAGIC[] = "ALBIC";
1515
static const u8 INDEX_CONFIG_VERSION_6_02[] = "06.02";
1616
static const u8 INDEX_CONFIG_VERSION_8_02[] = "08.02";
1717

18-
enum {
19-
DEFAULT_VOLUME_READ_THREADS = 2,
20-
MAX_VOLUME_READ_THREADS = 16,
21-
INDEX_CONFIG_MAGIC_LENGTH = sizeof(INDEX_CONFIG_MAGIC) - 1,
22-
INDEX_CONFIG_VERSION_LENGTH = sizeof(INDEX_CONFIG_VERSION_6_02) - 1,
23-
};
18+
#define DEFAULT_VOLUME_READ_THREADS 2
19+
#define MAX_VOLUME_READ_THREADS 16
20+
#define INDEX_CONFIG_MAGIC_LENGTH (sizeof(INDEX_CONFIG_MAGIC) - 1)
21+
#define INDEX_CONFIG_VERSION_LENGTH ((int)(sizeof(INDEX_CONFIG_VERSION_6_02) - 1))
2422

2523
static bool is_version(const u8 *version, u8 *buffer)
2624
{

drivers/md/dm-vdo/indexer/delta-index.c

Lines changed: 11 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -70,63 +70,47 @@
7070
* This is the largest field size supported by get_field() and set_field(). Any field that is
7171
* larger is not guaranteed to fit in a single byte-aligned u32.
7272
*/
73-
enum {
74-
MAX_FIELD_BITS = (sizeof(u32) - 1) * BITS_PER_BYTE + 1,
75-
};
73+
#define MAX_FIELD_BITS ((sizeof(u32) - 1) * BITS_PER_BYTE + 1)
7674

7775
/*
7876
* This is the largest field size supported by get_big_field() and set_big_field(). Any field that
7977
* is larger is not guaranteed to fit in a single byte-aligned u64.
8078
*/
81-
enum {
82-
MAX_BIG_FIELD_BITS = (sizeof(u64) - 1) * BITS_PER_BYTE + 1,
83-
};
79+
#define MAX_BIG_FIELD_BITS ((sizeof(u64) - 1) * BITS_PER_BYTE + 1)
8480

8581
/*
8682
* This is the number of guard bytes needed at the end of the memory byte array when using the bit
8783
* utilities. These utilities call get_big_field() and set_big_field(), which can access up to 7
8884
* bytes beyond the end of the desired field. The definition is written to make it clear how this
8985
* value is derived.
9086
*/
91-
enum {
92-
POST_FIELD_GUARD_BYTES = sizeof(u64) - 1,
93-
};
87+
#define POST_FIELD_GUARD_BYTES (sizeof(u64) - 1)
9488

9589
/* The number of guard bits that are needed in the tail guard list */
96-
enum {
97-
GUARD_BITS = POST_FIELD_GUARD_BYTES * BITS_PER_BYTE
98-
};
90+
#define GUARD_BITS (POST_FIELD_GUARD_BYTES * BITS_PER_BYTE)
9991

10092
/*
10193
* The maximum size of a single delta list in bytes. We count guard bytes in this value because a
10294
* buffer of this size can be used with move_bits().
10395
*/
104-
enum {
105-
DELTA_LIST_MAX_BYTE_COUNT =
106-
((U16_MAX + BITS_PER_BYTE) / BITS_PER_BYTE + POST_FIELD_GUARD_BYTES)
107-
};
96+
#define DELTA_LIST_MAX_BYTE_COUNT \
97+
((U16_MAX + BITS_PER_BYTE) / BITS_PER_BYTE + POST_FIELD_GUARD_BYTES)
10898

10999
/* The number of extra bytes and bits needed to store a collision entry */
110-
enum {
111-
COLLISION_BYTES = UDS_RECORD_NAME_SIZE,
112-
COLLISION_BITS = COLLISION_BYTES * BITS_PER_BYTE
113-
};
100+
#define COLLISION_BYTES UDS_RECORD_NAME_SIZE
101+
#define COLLISION_BITS (COLLISION_BYTES * BITS_PER_BYTE)
114102

115103
/*
116104
* Immutable delta lists are packed into pages containing a header that encodes the delta list
117105
* information into 19 bits per list (64KB bit offset).
118106
*/
119-
120-
enum { IMMUTABLE_HEADER_SIZE = 19 };
107+
#define IMMUTABLE_HEADER_SIZE 19
121108

122109
/*
123110
* Constants and structures for the saved delta index. "DI" is for delta_index, and -##### is a
124111
* number to increment when the format of the data changes.
125112
*/
126-
127-
enum {
128-
MAGIC_SIZE = 8,
129-
};
113+
#define MAGIC_SIZE 8
130114

131115
static const char DELTA_INDEX_MAGIC[] = "DI-00002";
132116

@@ -216,9 +200,7 @@ static void rebalance_delta_zone(const struct delta_zone *delta_zone, u32 first,
216200
static inline size_t get_zone_memory_size(unsigned int zone_count, size_t memory_size)
217201
{
218202
/* Round up so that each zone is a multiple of 64K in size. */
219-
enum {
220-
ALLOC_BOUNDARY = 64 * 1024,
221-
};
203+
size_t ALLOC_BOUNDARY = 64 * 1024;
222204

223205
return (memory_size / zone_count + ALLOC_BOUNDARY - 1) & -ALLOC_BOUNDARY;
224206
}

drivers/md/dm-vdo/indexer/index-layout.c

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,9 @@
5454
* Each save also has a unique nonce.
5555
*/
5656

57-
enum {
58-
MAGIC_SIZE = 32,
59-
NONCE_INFO_SIZE = 32,
60-
MAX_SAVES = 2,
61-
};
57+
#define MAGIC_SIZE 32
58+
#define NONCE_INFO_SIZE 32
59+
#define MAX_SAVES 2
6260

6361
enum region_kind {
6462
RL_KIND_EMPTY = 0,
@@ -82,9 +80,7 @@ enum region_type {
8280
RH_TYPE_UNSAVED = 4,
8381
};
8482

85-
enum {
86-
RL_SOLE_INSTANCE = 65535,
87-
};
83+
#define RL_SOLE_INSTANCE 65535
8884

8985
/*
9086
* Super block version 2 is the first released version.
@@ -98,11 +94,9 @@ enum {
9894
* order to make room to prepend LVM metadata to a volume originally created without lvm. This
9995
* allows the index to retain most its deduplication records.
10096
*/
101-
enum {
102-
SUPER_VERSION_MINIMUM = 3,
103-
SUPER_VERSION_CURRENT = 3,
104-
SUPER_VERSION_MAXIMUM = 7,
105-
};
97+
#define SUPER_VERSION_MINIMUM 3
98+
#define SUPER_VERSION_CURRENT 3
99+
#define SUPER_VERSION_MAXIMUM 7
106100

107101
static const u8 LAYOUT_MAGIC[MAGIC_SIZE] = "*ALBIREO*SINGLE*FILE*LAYOUT*001*";
108102
static const u64 REGION_MAGIC = 0x416c6252676e3031; /* 'AlbRgn01' */

0 commit comments

Comments
 (0)