Collect and show zone reset statistics
[fio.git] / zbd.h
... / ...
CommitLineData
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
15struct fio_file;
16
17/*
18 * Zoned block device models.
19 */
20enum 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
26enum 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 */
43struct 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 */
71struct 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
82void zbd_free_zone_info(struct fio_file *f);
83int zbd_init(struct thread_data *td);
84void zbd_file_reset(struct thread_data *td, struct fio_file *f);
85bool zbd_unaligned_write(int error_code);
86enum io_u_action zbd_adjust_block(struct thread_data *td, struct io_u *io_u);
87int zbd_do_trim(struct thread_data *td, const struct io_u *io_u);
88void zbd_update_wp(struct thread_data *td, const struct io_u *io_u);
89char *zbd_write_status(const struct thread_stat *ts);
90#else
91static inline void zbd_free_zone_info(struct fio_file *f)
92{
93}
94
95static inline int zbd_init(struct thread_data *td)
96{
97 return 0;
98}
99
100static inline void zbd_file_reset(struct thread_data *td, struct fio_file *f)
101{
102}
103
104static inline bool zbd_unaligned_write(int error_code)
105{
106 return false;
107}
108
109static 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
115static inline int zbd_do_trim(struct thread_data *td, const struct io_u *io_u)
116{
117 return 1;
118}
119
120static inline void zbd_update_wp(struct thread_data *td,
121 const struct io_u *io_u)
122{
123}
124
125static inline char *zbd_write_status(const struct thread_stat *ts)
126{
127 return NULL;
128}
129#endif
130
131#endif /* FIO_ZBD_H */