Recent changes (master)
The following changes since commit 19d9ef1e091a78ad651703d19c07886cb5dfd302:
Merge branch 'master' of https://github.com/blah325/fio (2025-04-15 19:02:20 -0600)
are available in the Git repository at:
git://git.kernel.dk/fio.git master
for you to fetch changes up to 4dc6c8da6ed938f12a42f167839100ab551ae8d1:
t/zbd: add run-tests-against-scsi_debug (2025-05-07 05:28:47 -0600)
----------------------------------------------------------------
Shin'ichiro Kawasaki (8):
oslib: blkzoned: add blkzoned_move_zone_wp() helper function
ioengine: add move_zone_wp() callback
engines/libzbc: implement move_zone_wp callback
zbd: introduce zbd_move_zone_wp()
zbd: add the recover_zbd_write_error option
t/zbd: set badblocks related parameters in run-tests-against-nullb t/zbd: add the test cases to confirm continue_on_error option t/zbd: add run-tests-against-scsi_debug
HOWTO.rst | 11 +++ cconv.c | 2 + engines/libzbc.c | 28 ++++++ fio.1 | 9 ++ io_u.c | 5 + io_u.h | 3 +- ioengines.c | 2 +- ioengines.h | 4 +- options.c | 10 ++ oslib/blkzoned.h | 3 + oslib/linux-blkzoned.c | 29 ++++++ server.h | 2 +- t/zbd/run-tests-against-nullb | 3 + t/zbd/run-tests-against-scsi_debug | 33 +++++++ t/zbd/test-zbd-support | 185 +++++++++++++++++++++++++++++++++++++ thread_options.h | 2 + zbd.c | 162 +++++++++++++++++++++++++++++++- zbd.h | 12 ++- 18 files changed, 494 insertions(+), 11 deletions(-) create mode 100755 t/zbd/run-tests-against-scsi_debug
---
Diff of recent changes:
HOWTO.rst +11 -0
@@ -1126,6 +1126,17 @@ Target file/device requests. This and the previous parameter can be used to simulate garbage collection activity. +.. option:: recover_zbd_write_error=bool + + If this option is specified together with the option + :option:`continue_on_error`, check the write pointer positions after the + failed writes to sequential write required zones. Then move the write + pointers so that the next writes do not fail due to partial writes and + unexpected write pointer positions. If :option:`continue_on_error` is + not specified, errors out. When the writes are asynchronous, the write + pointer move fills blocks with zero then breaks verify data. If an + asynchronous IO engine and :option:`verify` workload are specified, + errors out. Default: false. I/O type ~~~~~~~~
cconv.c +2 -0
@@ -265,6 +265,7 @@ int convert_thread_options_to_cpu(struct thread_options *o, o->zone_mode =le32_to_cpu (top->zone_mode); o->max_open_zones =__le32_to_cpu (top->max_open_zones); o->ignore_zone_limits =le32_to_cpu (top->ignore_zone_limits); + o->recover_zbd_write_error =le32_to_cpu (top->recover_zbd_write_error); o->lockmem =le64_to_cpu (top->lockmem); o->offset_increment_percent =le32_to_cpu (top->offset_increment_percent); o->offset_increment =le64_to_cpu (top->offset_increment);
@@ -637,6 +638,7 @@ void convert_thread_options_to_net(struct thread_options_pack *top, top->zone_mode =__cpu_to_le32 (o->zone_mode); top->max_open_zones =__cpu_to_le32 (o->max_open_zones); top->ignore_zone_limits =cpu_to_le32 (o->ignore_zone_limits); + top->recover_zbd_write_error =cpu_to_le32 (o->recover_zbd_write_error); top->lockmem =__cpu_to_le64 (o->lockmem); top->ddir_seq_add =__cpu_to_le64 (o->ddir_seq_add); top->file_size_low =__cpu_to_le64 (o->file_size_low);
engines/libzbc.c +28 -0
@@ -323,6 +323,33 @@ err:return -ret; } +static int libzbc_move_zone_wp (struct thread_data *td,struct fio_file *f, +struct zbd_zone *z,uint64_t length, +const char *buf) +{ +struct libzbc_data *ld = td->io_ops_data; +uint64_t sector = z->wp >>9 ; +size_t count = length >>9 ; +struct zbc_errno err; +int ret; + +assert (ld); +assert (ld->zdev); +assert (buf); + + ret =zbc_pwrite (ld->zdev, buf, count, sector); +if (ret == count) +return 0 ; + +zbc_errno (ld->zdev, &err); +td_verror (td, errno,"zbc_write for write pointer move failed" ); +if (err.sk) +log_err ("%s: wp move failed %s:%s\n" , + f->file_name, +zbc_sk_str (err.sk),zbc_asc_ascq_str (err.asc_ascq)); +return -ret; +} +static int libzbc_finish_zone (struct thread_data *td,struct fio_file *f,uint64_t offset,uint64_t length) {
@@ -457,6 +484,7 @@ FIO_STATIC struct ioengine_ops ioengine = { .get_zoned_model = libzbc_get_zoned_model, .report_zones = libzbc_report_zones, .reset_wp = libzbc_reset_wp, + .move_zone_wp = libzbc_move_zone_wp, .get_max_open_zones = libzbc_get_max_open_zones, .finish_zone = libzbc_finish_zone, .queue = libzbc_queue,
fio.1 +9 -0
@@ -890,6 +890,15 @@ A number between zero and one that indicates how often a zone reset should be issued if the zone reset threshold has been exceeded. A zone reset is submitted after each (1 / zone_reset_frequency) write requests. This and the previous parameter can be used to simulate garbage collection activity. +.BI recover_zbd_write_error \fR=\fPbool +If this option is specified together with the option \fBcontinue_on_error\fR, +check the write pointer positions after the failed writes to sequential write +required zones. Then move the write pointers so that the next writes do not +fail due to partial writes and unexpected write pointer positions. If +\fBcontinue_on_error\fR is not specified, errors out. When the writes are +asynchronous, the write pointer move fills blocks with zero then breaks verify +data. If an asynchronous IO engine and \fBverify\fR workload are specified, +errors out. Default: false. .SS "I/O type" .TP
io_u.c +5 -0
@@ -2102,6 +2102,11 @@ static void io_completed(struct thread_data *td, struct io_u **io_u_ptr,assert (io_u->flags &IO_U_F_FLIGHT );io_u_clear (td, io_u,IO_U_F_FLIGHT |IO_U_F_BUSY_OK |IO_U_F_PATTERN_DONE ); +if (td->o.zone_mode ==ZONE_MODE_ZBD && td->o.recover_zbd_write_error && + io_u->error && io_u->ddir ==DDIR_WRITE && + !td_ioengine_flagged (td,FIO_SYNCIO )) +zbd_recover_write_error (td, io_u); +/* * Mark IO ok to verify */
io_u.h +1 -2
@@ -111,8 +111,7 @@ struct io_u {* @success == true means that the I/O operation has been queued or * completed successfully. */ -void (*zbd_queue_io)(struct thread_data *td,struct io_u *,int q, -bool success); +void (*zbd_queue_io)(struct thread_data *td,struct io_u *,int *q);/* * ZBD mode zbd_put_io callback: called in after completion of an I/O
ioengines.c +1 -1
@@ -386,7 +386,7 @@ enum fio_q_status td_io_queue(struct thread_data *td, struct io_u *io_u) } ret = td->io_ops->queue (td, io_u); -zbd_queue_io_u (td, io_u, ret); +zbd_queue_io_u (td, io_u, &ret);unlock_file (td, io_u->file);
ioengines.h +3 -1
@@ -9,7 +9,7 @@#include "zbd_types.h" #include "dataplacement.h" -#define FIO_IOOPS_VERSION 36 +#define FIO_IOOPS_VERSION 37#ifndef CONFIG_DYNAMIC_ENGINES #define FIO_STATIC static
@@ -60,6 +60,8 @@ struct ioengine_ops { uint64_t, struct zbd_zone *, unsigned int);int (*reset_wp)(struct thread_data *,struct fio_file *,uint64_t ,uint64_t ); +int (*move_zone_wp)(struct thread_data *,struct fio_file *, +struct zbd_zone *,uint64_t ,const char *);int (*get_max_open_zones)(struct thread_data *,struct fio_file *,unsigned int *); int (*get_max_active_zones)(struct thread_data *, struct fio_file *,
options.c +10 -0
@@ -3794,6 +3794,16 @@ struct fio_option fio_options[FIO_MAX_OPTS] = { .category = FIO_OPT_C_IO, .group = FIO_OPT_G_ZONE, }, + { + .name = "recover_zbd_write_error", + .lname = "Recover write errors when zonemode=zbd is set", + .type = FIO_OPT_BOOL, + .off1 = offsetof(struct thread_options, recover_zbd_write_error), + .def = 0, + .help = "Continue writes for sequential write required zones after recovering write errors with care for partial write pointer move", + .category = FIO_OPT_C_IO, + .group = FIO_OPT_G_ZONE, + }, { .name = "fdp", .lname = "Flexible data placement",
oslib/blkzoned.h +3 -0
@@ -16,6 +16,9 @@ extern int blkzoned_report_zones(struct thread_data *td, struct zbd_zone *zones, unsigned int nr_zones);extern int blkzoned_reset_wp (struct thread_data *td,struct fio_file *f,uint64_t offset,uint64_t length); +extern int blkzoned_move_zone_wp (struct thread_data *td,struct fio_file *f, +struct zbd_zone *z,uint64_t length, +const char *buf);extern int blkzoned_get_max_open_zones (struct thread_data *td,struct fio_file *f,unsigned int *max_open_zones); extern int blkzoned_get_max_active_zones(struct thread_data *td,
oslib/linux-blkzoned.c +29 -0
@@ -370,3 +370,32 @@ int blkzoned_finish_zone(struct thread_data *td, struct fio_file *f,return ret; } + +int blkzoned_move_zone_wp (struct thread_data *td,struct fio_file *f, +struct zbd_zone *z,uint64_t length,const char *buf) +{ +int fd, ret =0 ; + +/* If the file is not yet open, open it for this function */ + fd = f->fd; +if (fd <0 ) { + fd =open (f->file_name,O_WRONLY |O_DIRECT ); +if (fd <0 ) +return -errno; + } + +/* If write data is not provided, fill zero to move the write pointer */ +if (!buf) { + ret =fallocate (fd,FALLOC_FL_ZERO_RANGE , z->wp, length); + goto out; + } + +if (pwrite (fd, buf, length, z->wp) <0 ) + ret = -errno; + +out: +if (f->fd <0 ) +close (fd); + +return ret; +}
server.h +1 -1
@@ -51,7 +51,7 @@ struct fio_net_cmd_reply { };enum { -FIO_SERVER_VER =109 , +FIO_SERVER_VER =110 ,FIO_SERVER_MAX_FRAGMENT_PDU =1024 ,FIO_SERVER_MAX_CMD_MB =2048 ,
t/zbd/run-tests-against-nullb +3 -0
@@ -91,6 +91,9 @@ configure_nullb() fi fi + [[ -w badblocks_once ]] && echo 1 > badblocks_once + [[ -w badblocks_partial_io ]] && echo 1 > badblocks_partial_io + echo 1 > power || return $? return 0 }
t/zbd/run-tests-against-scsi_debug new file +33 -0
@@ -0,0 +1,33 @@ +#!/bin/bash +# +# Copyright (C) 2020 Western Digital Corporation or its affiliates. +# +# SPDX-License-Identifier: GPL-2.0 +# +# A couple of test cases in t/zbd/test-zbd-support script depend on the error +# injection feature of scsi_debug. Prepare a zoned scsi_debug device and run +# only for the test cases. + +declare dev sg scriptdir + +scriptdir="$(cd "$(dirname "$0")" && pwd)" + +modprobe -qr scsi_debug +modprobe scsi_debug add_host=1 zbc=host-managed zone_nr_conv=0 + +dev=$(dmesg | tail -5 | grep "Attached SCSI disk" | grep -Po ".* \[\Ksd[a-z]*") + +if ! grep -qe scsi_debug /sys/block/"${dev}"/device/vpd_pg83; then + echo "Failed to create scsi_debug device" + exit 1 +fi + +sg=$(echo /sys/block/"${dev}"/device/scsi_generic/*) +sg=${sg##*/} + +echo standard engine: +"${scriptdir}"/test-zbd-support -t 72 -t 73 /dev/"${dev}" +echo libzbc engine with block device: +"${scriptdir}"/test-zbd-support -t 72 -t 73 -l /dev/"${dev}" +echo libzbc engine with sg node: +"${scriptdir}"/test-zbd-support -t 72 -t 73 -l /dev/"${sg}"
t/zbd/test-zbd-support +185 -0
203 lines not on this page · raw message
thread_options.h +2 -0
@@ -390,6 +390,7 @@ struct thread_options {int max_open_zones;unsigned int job_max_open_zones;unsigned int ignore_zone_limits; +unsigned int recover_zbd_write_error;fio_fp64_t zrt;fio_fp64_t zrf;
@@ -710,6 +711,7 @@ struct thread_options_pack {uint32_t zone_mode;int32_t max_open_zones;uint32_t ignore_zone_limits; +uint32_t recover_zbd_write_error;uint32_t log_entries;uint32_t log_prio;
zbd.c +158 -4
221 lines not on this page · raw message
zbd.h +10 -2
@@ -25,6 +25,9 @@ enum io_u_action {* @start: zone start location (bytes) * @wp: zone write pointer location (bytes) * @capacity: maximum size usable from the start of a zone (bytes) +* @writes_in_flight: number of writes in flight fo the zone +* @max_write_error_offset: maximum offset from zone start among the failed +* writes to the zone * @mutex: protects the modifiable members in this structure * @type: zone type (BLK_ZONE_TYPE_*) * @cond: zone state (BLK_ZONE_COND_*)
@@ -32,17 +35,21 @@ enum io_u_action {* @write: whether or not this zone is the write target at this moment. Only * relevant if zbd->max_open_zones > 0. * @reset_zone: whether or not this zone should be reset before writing to it +* @fixing_zone_wp: whether or not the write pointer of this zone is under fix */ struct fio_zone_info {pthread_mutex_t mutex;uint64_t start;uint64_t wp;uint64_t capacity; +uint32_t writes_in_flight; +uint32_t max_write_error_offset;enum zbd_zone_type type:2 ;enum zbd_zone_cond cond:4 ;unsigned int has_wp:1 ;unsigned int write:1 ;unsigned int reset_zone:1 ; +unsigned int fixing_zone_wp:1 ; };/**
@@ -106,6 +113,7 @@ enum io_u_action zbd_adjust_block(struct thread_data *td, struct io_u *io_u);char *zbd_write_status (const struct thread_stat *ts);int zbd_do_io_u_trim (struct thread_data *td,struct io_u *io_u);void zbd_log_err (const struct thread_data *td,const struct io_u *io_u); +void zbd_recover_write_error (struct thread_data *td,struct io_u *io_u);static inline void zbd_close_file (struct fio_file *f) {
@@ -114,10 +122,10 @@ static inline void zbd_close_file(struct fio_file *f) }static inline void zbd_queue_io_u (struct thread_data *td,struct io_u *io_u, -enum fio_q_status status) +enum fio_q_status *status) {if (io_u->zbd_queue_io) { - io_u->zbd_queue_io (td, io_u, status, io_u->error ==0 ); + io_u->zbd_queue_io (td, io_u, (int *)status); io_u->zbd_queue_io =NULL ; } }