Commit | Line | Data |
---|---|---|
bfbdd35b BVA |
1 | /* |
2 | * Copyright (C) 2018 Western Digital Corporation or its affiliates. | |
3 | * | |
4 | * This file is released under the GPL. | |
5 | */ | |
6 | ||
7 | #ifndef FIO_ZBD_H | |
8 | #define FIO_ZBD_H | |
9 | ||
10 | #include <inttypes.h> | |
11 | #ifdef CONFIG_LINUX_BLKZONED | |
12 | #include <linux/blkzoned.h> | |
13 | #endif | |
14 | ||
15 | struct fio_file; | |
16 | ||
17 | /* | |
18 | * Zoned block device models. | |
19 | */ | |
20 | enum blk_zoned_model { | |
21 | ZBD_DM_NONE, /* Regular block device */ | |
22 | ZBD_DM_HOST_AWARE, /* Host-aware zoned block device */ | |
23 | ZBD_DM_HOST_MANAGED, /* Host-managed zoned block device */ | |
24 | }; | |
25 | ||
26 | enum io_u_action { | |
27 | io_u_accept = 0, | |
28 | io_u_eof = 1, | |
29 | }; | |
30 | ||
31 | /** | |
32 | * struct fio_zone_info - information about a single ZBD zone | |
33 | * @start: zone start in 512 byte units | |
34 | * @wp: zone write pointer location in 512 byte units | |
35 | * @verify_block: number of blocks that have been verified for this zone | |
36 | * @mutex: protects the modifiable members in this structure | |
37 | * @type: zone type (BLK_ZONE_TYPE_*) | |
38 | * @cond: zone state (BLK_ZONE_COND_*) | |
39 | * @open: whether or not this zone is currently open. Only relevant if | |
40 | * max_open_zones > 0. | |
41 | * @reset_zone: whether or not this zone should be reset before writing to it | |
42 | */ | |
43 | struct fio_zone_info { | |
44 | #ifdef CONFIG_LINUX_BLKZONED | |
45 | pthread_mutex_t mutex; | |
46 | uint64_t start; | |
47 | uint64_t wp; | |
48 | uint32_t verify_block; | |
49 | enum blk_zone_type type:2; | |
50 | enum blk_zone_cond cond:4; | |
51 | unsigned int open:1; | |
52 | unsigned int reset_zone:1; | |
53 | #endif | |
54 | }; | |
55 | ||
56 | /** | |
57 | * zoned_block_device_info - zoned block device characteristics | |
58 | * @model: Device model. | |
59 | * @mutex: Protects the modifiable members in this structure (refcount). | |
60 | * @zone_size: size of a single zone in units of 512 bytes | |
61 | * @zone_size_log2: log2 of the zone size in bytes if it is a power of 2 or 0 | |
62 | * if the zone size is not a power of 2. | |
63 | * @nr_zones: number of zones | |
64 | * @refcount: number of fio files that share this structure | |
65 | * @zone_info: description of the individual zones | |
66 | * | |
67 | * Only devices for which all zones have the same size are supported. | |
68 | * Note: if the capacity is not a multiple of the zone size then the last zone | |
69 | * will be smaller than 'zone_size'. | |
70 | */ | |
71 | struct zoned_block_device_info { | |
72 | enum blk_zoned_model model; | |
73 | pthread_mutex_t mutex; | |
74 | uint64_t zone_size; | |
75 | uint32_t zone_size_log2; | |
76 | uint32_t nr_zones; | |
77 | uint32_t refcount; | |
78 | struct fio_zone_info zone_info[0]; | |
79 | }; | |
80 | ||
81 | #ifdef CONFIG_LINUX_BLKZONED | |
82 | void zbd_free_zone_info(struct fio_file *f); | |
83 | int zbd_init(struct thread_data *td); | |
84 | void zbd_file_reset(struct thread_data *td, struct fio_file *f); | |
85 | bool zbd_unaligned_write(int error_code); | |
86 | enum io_u_action zbd_adjust_block(struct thread_data *td, struct io_u *io_u); | |
87 | int zbd_do_trim(struct thread_data *td, const struct io_u *io_u); | |
88 | void zbd_update_wp(struct thread_data *td, const struct io_u *io_u); | |
fd5d733f | 89 | char *zbd_write_status(const struct thread_stat *ts); |
bfbdd35b BVA |
90 | #else |
91 | static inline void zbd_free_zone_info(struct fio_file *f) | |
92 | { | |
93 | } | |
94 | ||
95 | static inline int zbd_init(struct thread_data *td) | |
96 | { | |
97 | return 0; | |
98 | } | |
99 | ||
100 | static inline void zbd_file_reset(struct thread_data *td, struct fio_file *f) | |
101 | { | |
102 | } | |
103 | ||
104 | static inline bool zbd_unaligned_write(int error_code) | |
105 | { | |
106 | return false; | |
107 | } | |
108 | ||
109 | static inline enum io_u_action zbd_adjust_block(struct thread_data *td, | |
110 | struct io_u *io_u) | |
111 | { | |
112 | return io_u_accept; | |
113 | } | |
114 | ||
115 | static inline int zbd_do_trim(struct thread_data *td, const struct io_u *io_u) | |
116 | { | |
117 | return 1; | |
118 | } | |
119 | ||
120 | static inline void zbd_update_wp(struct thread_data *td, | |
121 | const struct io_u *io_u) | |
122 | { | |
123 | } | |
fd5d733f BVA |
124 | |
125 | static inline char *zbd_write_status(const struct thread_stat *ts) | |
126 | { | |
127 | return NULL; | |
128 | } | |
bfbdd35b BVA |
129 | #endif |
130 | ||
131 | #endif /* FIO_ZBD_H */ |