-enum swd_action {
- CHECK_SWD,
- SET_SWD,
-};
-
-/* Calculate the number of sectors with data (swd) and perform action 'a' */
-static uint64_t zbd_process_swd(struct thread_data *td,
- const struct fio_file *f, enum swd_action a)
-{
- struct fio_zone_info *zb, *ze, *z;
- uint64_t swd = 0;
- uint64_t wp_swd = 0;
-
- zb = zbd_get_zone(f, f->min_zone);
- ze = zbd_get_zone(f, f->max_zone);
- for (z = zb; z < ze; z++) {
- if (z->has_wp) {
- zone_lock(td, f, z);
- wp_swd += z->wp - z->start;
- }
- swd += z->wp - z->start;
- }
-
- pthread_mutex_lock(&f->zbd_info->mutex);
- switch (a) {
- case CHECK_SWD:
- assert(f->zbd_info->sectors_with_data == swd);
- assert(f->zbd_info->wp_sectors_with_data == wp_swd);
- break;
- case SET_SWD:
- f->zbd_info->sectors_with_data = swd;
- f->zbd_info->wp_sectors_with_data = wp_swd;
- break;
- }
- pthread_mutex_unlock(&f->zbd_info->mutex);
-
- for (z = zb; z < ze; z++)
- if (z->has_wp)
- zone_unlock(z);
-
- return swd;
-}
-
-/*
- * The swd check is useful for debugging but takes too much time to leave
- * it enabled all the time. Hence it is disabled by default.
- */
-static const bool enable_check_swd = false;
-
-/* Check whether the values of zbd_info.*sectors_with_data are correct. */
-static void zbd_check_swd(struct thread_data *td, const struct fio_file *f)
-{
- if (!enable_check_swd)
- return;
-
- zbd_process_swd(td, f, CHECK_SWD);
-}
-