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 | ||
b7694961 DLM |
10 | #include "io_u.h" |
11 | #include "ioengines.h" | |
12 | #include "oslib/blkzoned.h" | |
13 | #include "zbd_types.h" | |
bfbdd35b BVA |
14 | |
15 | struct fio_file; | |
16 | ||
bfbdd35b BVA |
17 | enum io_u_action { |
18 | io_u_accept = 0, | |
19 | io_u_eof = 1, | |
20 | }; | |
21 | ||
22 | /** | |
23 | * struct fio_zone_info - information about a single ZBD zone | |
2c477f4f DLM |
24 | * @start: zone start location (bytes) |
25 | * @wp: zone write pointer location (bytes) | |
bfbdd35b BVA |
26 | * @verify_block: number of blocks that have been verified for this zone |
27 | * @mutex: protects the modifiable members in this structure | |
28 | * @type: zone type (BLK_ZONE_TYPE_*) | |
29 | * @cond: zone state (BLK_ZONE_COND_*) | |
30 | * @open: whether or not this zone is currently open. Only relevant if | |
31 | * max_open_zones > 0. | |
32 | * @reset_zone: whether or not this zone should be reset before writing to it | |
33 | */ | |
34 | struct fio_zone_info { | |
bfbdd35b BVA |
35 | pthread_mutex_t mutex; |
36 | uint64_t start; | |
37 | uint64_t wp; | |
38 | uint32_t verify_block; | |
b7694961 DLM |
39 | enum zbd_zone_type type:2; |
40 | enum zbd_zone_cond cond:4; | |
bfbdd35b BVA |
41 | unsigned int open:1; |
42 | unsigned int reset_zone:1; | |
bfbdd35b BVA |
43 | }; |
44 | ||
45 | /** | |
46 | * zoned_block_device_info - zoned block device characteristics | |
47 | * @model: Device model. | |
59b07544 BVA |
48 | * @mutex: Protects the modifiable members in this structure (refcount and |
49 | * num_open_zones). | |
bfbdd35b | 50 | * @zone_size: size of a single zone in units of 512 bytes |
a7c2b6fc | 51 | * @sectors_with_data: total size of data in all zones in units of 512 bytes |
bfbdd35b BVA |
52 | * @zone_size_log2: log2 of the zone size in bytes if it is a power of 2 or 0 |
53 | * if the zone size is not a power of 2. | |
54 | * @nr_zones: number of zones | |
55 | * @refcount: number of fio files that share this structure | |
59b07544 | 56 | * @num_open_zones: number of open zones |
a7c2b6fc BVA |
57 | * @write_cnt: Number of writes since the latest zone reset triggered by |
58 | * the zone_reset_frequency fio job parameter. | |
59b07544 | 59 | * @open_zones: zone numbers of open zones |
bfbdd35b BVA |
60 | * @zone_info: description of the individual zones |
61 | * | |
62 | * Only devices for which all zones have the same size are supported. | |
63 | * Note: if the capacity is not a multiple of the zone size then the last zone | |
64 | * will be smaller than 'zone_size'. | |
65 | */ | |
66 | struct zoned_block_device_info { | |
b7694961 | 67 | enum zbd_zoned_model model; |
bfbdd35b BVA |
68 | pthread_mutex_t mutex; |
69 | uint64_t zone_size; | |
a7c2b6fc | 70 | uint64_t sectors_with_data; |
bfbdd35b BVA |
71 | uint32_t zone_size_log2; |
72 | uint32_t nr_zones; | |
73 | uint32_t refcount; | |
59b07544 | 74 | uint32_t num_open_zones; |
a7c2b6fc | 75 | uint32_t write_cnt; |
b7694961 | 76 | uint32_t open_zones[ZBD_MAX_OPEN_ZONES]; |
bfbdd35b BVA |
77 | struct fio_zone_info zone_info[0]; |
78 | }; | |
79 | ||
bfbdd35b BVA |
80 | void zbd_free_zone_info(struct fio_file *f); |
81 | int zbd_init(struct thread_data *td); | |
82 | void zbd_file_reset(struct thread_data *td, struct fio_file *f); | |
83 | bool zbd_unaligned_write(int error_code); | |
4d37720a | 84 | void setup_zbd_zone_mode(struct thread_data *td, struct io_u *io_u); |
bfbdd35b | 85 | enum io_u_action zbd_adjust_block(struct thread_data *td, struct io_u *io_u); |
fd5d733f | 86 | char *zbd_write_status(const struct thread_stat *ts); |
d9ed3e63 DLM |
87 | |
88 | static inline void zbd_queue_io_u(struct io_u *io_u, enum fio_q_status status) | |
89 | { | |
90 | if (io_u->zbd_queue_io) { | |
91 | io_u->zbd_queue_io(io_u, status, io_u->error == 0); | |
92 | io_u->zbd_queue_io = NULL; | |
93 | } | |
94 | } | |
95 | ||
96 | static inline void zbd_put_io_u(struct io_u *io_u) | |
97 | { | |
98 | if (io_u->zbd_put_io) { | |
99 | io_u->zbd_put_io(io_u); | |
100 | io_u->zbd_queue_io = NULL; | |
101 | io_u->zbd_put_io = NULL; | |
102 | } | |
103 | } | |
104 | ||
bfbdd35b | 105 | #endif /* FIO_ZBD_H */ |