2 * Copyright (C) 2018 Western Digital Corporation or its affiliates.
4 * This file is released under the GPL.
11 #include "fio.h" /* FIO_MAX_OPEN_ZBD_ZONES */
12 #ifdef CONFIG_LINUX_BLKZONED
13 #include <linux/blkzoned.h>
19 * Zoned block device models.
21 enum blk_zoned_model {
22 ZBD_DM_NONE, /* Regular block device */
23 ZBD_DM_HOST_AWARE, /* Host-aware zoned block device */
24 ZBD_DM_HOST_MANAGED, /* Host-managed zoned block device */
33 * struct fio_zone_info - information about a single ZBD zone
34 * @start: zone start in 512 byte units
35 * @wp: zone write pointer location in 512 byte units
36 * @verify_block: number of blocks that have been verified for this zone
37 * @mutex: protects the modifiable members in this structure
38 * @type: zone type (BLK_ZONE_TYPE_*)
39 * @cond: zone state (BLK_ZONE_COND_*)
40 * @open: whether or not this zone is currently open. Only relevant if
42 * @reset_zone: whether or not this zone should be reset before writing to it
44 struct fio_zone_info {
45 #ifdef CONFIG_LINUX_BLKZONED
46 pthread_mutex_t mutex;
49 uint32_t verify_block;
50 enum blk_zone_type type:2;
51 enum blk_zone_cond cond:4;
53 unsigned int reset_zone:1;
58 * zoned_block_device_info - zoned block device characteristics
59 * @model: Device model.
60 * @mutex: Protects the modifiable members in this structure (refcount and
62 * @zone_size: size of a single zone in units of 512 bytes
63 * @zone_size_log2: log2 of the zone size in bytes if it is a power of 2 or 0
64 * if the zone size is not a power of 2.
65 * @nr_zones: number of zones
66 * @refcount: number of fio files that share this structure
67 * @num_open_zones: number of open zones
68 * @open_zones: zone numbers of open zones
69 * @zone_info: description of the individual zones
71 * Only devices for which all zones have the same size are supported.
72 * Note: if the capacity is not a multiple of the zone size then the last zone
73 * will be smaller than 'zone_size'.
75 struct zoned_block_device_info {
76 enum blk_zoned_model model;
77 pthread_mutex_t mutex;
79 uint32_t zone_size_log2;
82 uint32_t num_open_zones;
83 uint32_t open_zones[FIO_MAX_OPEN_ZBD_ZONES];
84 struct fio_zone_info zone_info[0];
87 #ifdef CONFIG_LINUX_BLKZONED
88 void zbd_free_zone_info(struct fio_file *f);
89 int zbd_init(struct thread_data *td);
90 void zbd_file_reset(struct thread_data *td, struct fio_file *f);
91 bool zbd_unaligned_write(int error_code);
92 enum io_u_action zbd_adjust_block(struct thread_data *td, struct io_u *io_u);
93 int zbd_do_trim(struct thread_data *td, const struct io_u *io_u);
94 void zbd_update_wp(struct thread_data *td, const struct io_u *io_u);
95 char *zbd_write_status(const struct thread_stat *ts);
97 static inline void zbd_free_zone_info(struct fio_file *f)
101 static inline int zbd_init(struct thread_data *td)
106 static inline void zbd_file_reset(struct thread_data *td, struct fio_file *f)
110 static inline bool zbd_unaligned_write(int error_code)
115 static inline enum io_u_action zbd_adjust_block(struct thread_data *td,
121 static inline int zbd_do_trim(struct thread_data *td, const struct io_u *io_u)
126 static inline void zbd_update_wp(struct thread_data *td,
127 const struct io_u *io_u)
131 static inline char *zbd_write_status(const struct thread_stat *ts)
137 #endif /* FIO_ZBD_H */