1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * Copyright 2023 Red Hat
4  */
5 
6 #ifndef VDO_CONSTANTS_H
7 #define VDO_CONSTANTS_H
8 
9 #include <linux/blkdev.h>
10 
11 #include "types.h"
12 
13 enum {
14 	/*
15 	 * The maximum number of contiguous PBNs which will go to a single bio submission queue,
16 	 * assuming there is more than one queue.
17 	 */
18 	VDO_BIO_ROTATION_INTERVAL_LIMIT = 1024,
19 
20 	/* The number of entries on a block map page */
21 	VDO_BLOCK_MAP_ENTRIES_PER_PAGE = 812,
22 
23 	/* The origin of the flat portion of the block map */
24 	VDO_BLOCK_MAP_FLAT_PAGE_ORIGIN = 1,
25 
26 	/*
27 	 * The height of a block map tree. Assuming a root count of 60 and 812 entries per page,
28 	 * this is big enough to represent almost 95 PB of logical space.
29 	 */
30 	VDO_BLOCK_MAP_TREE_HEIGHT = 5,
31 
32 	/* The default number of bio submission queues. */
33 	DEFAULT_VDO_BIO_SUBMIT_QUEUE_COUNT = 4,
34 
35 	/* The number of contiguous PBNs to be submitted to a single bio queue. */
36 	DEFAULT_VDO_BIO_SUBMIT_QUEUE_ROTATE_INTERVAL = 64,
37 
38 	/* The number of trees in the arboreal block map */
39 	DEFAULT_VDO_BLOCK_MAP_TREE_ROOT_COUNT = 60,
40 
41 	/* The default size of the recovery journal, in blocks */
42 	DEFAULT_VDO_RECOVERY_JOURNAL_SIZE = 32 * 1024,
43 
44 	/* The default size of each slab journal, in blocks */
45 	DEFAULT_VDO_SLAB_JOURNAL_SIZE = 224,
46 
47 	/* Unit test minimum */
48 	MINIMUM_VDO_SLAB_JOURNAL_BLOCKS = 2,
49 
50 	/*
51 	 * The initial size of lbn_operations and pbn_operations, which is based upon the expected
52 	 * maximum number of outstanding VIOs. This value was chosen to make it highly unlikely
53 	 * that the maps would need to be resized.
54 	 */
55 	VDO_LOCK_MAP_CAPACITY = 10000,
56 
57 	/* The maximum number of logical zones */
58 	MAX_VDO_LOGICAL_ZONES = 60,
59 
60 	/* The maximum number of physical zones */
61 	MAX_VDO_PHYSICAL_ZONES = 16,
62 
63 	/* The base-2 logarithm of the maximum blocks in one slab */
64 	MAX_VDO_SLAB_BITS = 23,
65 
66 	/* The maximum number of slabs the slab depot supports */
67 	MAX_VDO_SLABS = 8192,
68 
69 	/*
70 	 * The maximum number of block map pages to load simultaneously during recovery or rebuild.
71 	 */
72 	MAXIMUM_SIMULTANEOUS_VDO_BLOCK_MAP_RESTORATION_READS = 1024,
73 
74 	/* The maximum number of entries in the slab summary */
75 	MAXIMUM_VDO_SLAB_SUMMARY_ENTRIES = MAX_VDO_SLABS * MAX_VDO_PHYSICAL_ZONES,
76 
77 	/* The maximum number of total threads in a VDO thread configuration. */
78 	MAXIMUM_VDO_THREADS = 100,
79 
80 	/* The maximum number of VIOs in the system at once */
81 	MAXIMUM_VDO_USER_VIOS = 2048,
82 
83 	/* The only physical block size supported by VDO */
84 	VDO_BLOCK_SIZE = 4096,
85 
86 	/* The number of sectors per block */
87 	VDO_SECTORS_PER_BLOCK = (VDO_BLOCK_SIZE >> SECTOR_SHIFT),
88 
89 	/* The size of a sector that will not be torn */
90 	VDO_SECTOR_SIZE = 512,
91 
92 	/* The physical block number reserved for storing the zero block */
93 	VDO_ZERO_BLOCK = 0,
94 };
95 
96 #endif /* VDO_CONSTANTS_H */
97