2 * Copyright (C) 2018 Western Digital Corporation or its affiliates.
4 * This file is released under the GPL.
11 #ifdef CONFIG_LINUX_BLKZONED
12 #include <linux/blkzoned.h>
18 * Zoned block device models.
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 */
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
41 * @reset_zone: whether or not this zone should be reset before writing to it
43 struct fio_zone_info {
44 #ifdef CONFIG_LINUX_BLKZONED
45 pthread_mutex_t mutex;
48 uint32_t verify_block;
49 enum blk_zone_type type:2;
50 enum blk_zone_cond cond:4;
52 unsigned int reset_zone:1;
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
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'.
71 struct zoned_block_device_info {
72 enum blk_zoned_model model;
73 pthread_mutex_t mutex;
75 uint32_t zone_size_log2;
78 struct fio_zone_info zone_info[0];
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);
89 char *zbd_write_status(const struct thread_stat *ts);
91 static inline void zbd_free_zone_info(struct fio_file *f)
95 static inline int zbd_init(struct thread_data *td)
100 static inline void zbd_file_reset(struct thread_data *td, struct fio_file *f)
104 static inline bool zbd_unaligned_write(int error_code)
109 static inline enum io_u_action zbd_adjust_block(struct thread_data *td,
115 static inline int zbd_do_trim(struct thread_data *td, const struct io_u *io_u)
120 static inline void zbd_update_wp(struct thread_data *td,
121 const struct io_u *io_u)
125 static inline char *zbd_write_status(const struct thread_stat *ts)
131 #endif /* FIO_ZBD_H */