verify: decouple seed generation from buffer fill
PATCH 1/5 verify: decouple seed generation from buffer fill
It is nicer this way and there will be more code in this area with ZBD verification.
--- backend.c | 6 ------ verify.c | 20 +++++++------------- 2 files changed, 7 insertions(+), 19 deletions(-)
backend.c +0 -6
@@ -1006,12 +1006,6 @@ static void do_io(struct thread_data *td, uint64_t *bytes_done)if (td->o.verify !=VERIFY_NONE && io_u->ddir ==DDIR_READ && ((io_u->flags &IO_U_F_VER_LIST ) || !td_rw (td))) { -if (!td->o.verify_pattern_bytes) { - io_u->rand_seed =__rand (&td->verify_state); -if (sizeof (int ) !=sizeof (long *)) - io_u->rand_seed *=__rand (&td->verify_state); - } -if (verify_state_should_stop (td, io_u)) {put_io_u (td, io_u);break ;
verify.c +7 -13
@@ -46,15 +46,6 @@ static void __fill_buffer(struct thread_options *o, uint64_t seed, void *p,__fill_random_buf_percentage (seed, p, o->compress_percentage, len, len, o->buffer_pattern, o->buffer_pattern_bytes); } -static uint64_t fill_buffer (struct thread_data *td,void *p, -unsigned int len) -{ -struct frand_state *fs = &td->verify_state; -struct thread_options *o = &td->o; - -return fill_random_buf_percentage (fs, p, o->compress_percentage, len, len, o->buffer_pattern, o->buffer_pattern_bytes); -} -void fill_verify_pattern (struct thread_data *td,void *p,unsigned int len,struct io_u *io_u,uint64_t seed,int use_seed) {
@@ -63,10 +54,13 @@ void fill_verify_pattern(struct thread_data *td, void *p, unsigned int len,if (!o->verify_pattern_bytes) {dprint (FD_VERIFY ,"fill random bytes len=%u\n" , len); -if (use_seed) -__fill_buffer (o, seed, p, len); -else - io_u->rand_seed =fill_buffer (td, p, len); +if (!use_seed) { + seed =__rand (&td->verify_state); +if (sizeof (int ) !=sizeof (long *)) + seed *= (unsigned long )__rand (&td->verify_state); + } + io_u->rand_seed = seed; +__fill_buffer (o, seed, p, len);return ; }
Signature · 1 line
2.26.2
PATCH 2/5 zbd: bump ZBD_MAX_OPEN_ZONES
128 opened zones is not enough for us!
4096 opened zones is OK for 64×iodepth=64 stress testing.
--- zbd_types.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
zbd_types.h +1 -1
@@ -8,7 +8,7 @@#include <inttypes.h> -#define ZBD_MAX_OPEN_ZONES 128 +#define ZBD_MAX_OPEN_ZONES 4096/* * Zoned block device models.
Signature · 1 line
2.26.2
PATCH 3/5 zbd: don't lock zones outside working area
In reply to Alexey DobriyanCurrently threads lock each other zones even if their working areas as defined by [f->file_offset, f->file_offset + f->io_size) don't intersect. This leads to unnecessary quiescing.
Patch clamps every zone to [->min_zone, ->max_zone) when doing search for opened zone and more importantly adds an assert so that any unnecessary zone locking becomes very visible.
--- file.h | 3 +++ zbd.c | 46 +++++++++++++++++++++++++++++----------------- 2 files changed, 32 insertions(+), 17 deletions(-)
file.h +3 -0
@@ -104,6 +104,9 @@ struct fio_file {* Zoned block device information. See also zonemode=zbd. */ struct zoned_block_device_info *zbd_info; +/* zonemode=zbd working area */ +uint32_t min_zone;/* inclusive */ +uint32_t max_zone;/* exclusive */ /* * Track last end and last start of IO for a given data direction
zbd.c +29 -17
143 lines not on this page · raw message
Signature · 1 line
2.26.2
PATCH 4/5 zbd: introduce per job maximum open zones limit
In reply to Alexey DobriyanIt is not possible to maintain sustained per-thread iodepth in ZBD mode. The way code is written, "max_open_zones" acts as a global limit, and once one or few threads open all "max_open_zones" zones, other threads can't open anything and _exit_ prematurely.
This config is guaranteed to make equal number of zone resets/IO now:
each thread generates identical pattern and doesn't intersect with other threads:
zonemode=zbd zonesize=... rw=write numjobs=N offset_increment=M*zonesize [j] size=M*zonesize
Patch introduces "job_max_open_zones" which is per-thread/process limit. "max_open_zones" remains per file/device limit. Both limits are checked for each open zone so one thread can't kick out others.
--- fio.1 | 6 +++++- fio.h | 1 + options.c | 16 +++++++++++++--- thread_options.h | 1 + zbd.c | 46 +++++++++++++++++++++++++++++++++++----------- zbd.h | 3 +++ 6 files changed, 58 insertions(+), 15 deletions(-)
fio.1 +5 -1
@@ -804,7 +804,11 @@ so. Default: false. When running a random write test across an entire drive many more zones will be open than in a typical application workload. Hence this command line option that allows to limit the number of open zones. The number of open zones is -defined as the number of zones to which write commands are issued. +defined as the number of zones to which write commands are issued by all +threads/processes. +.TP +.BI job_max_open_zones \fR=\fPint +Limit on the number of simultaneously opened zones per single thread/process. .TP .BI zone_reset_threshold \fR=\fPfloat A number between zero and one that indicates the ratio of logical blocks with
fio.h +1 -0
@@ -260,6 +260,7 @@ struct thread_data {struct frand_state prio_state;struct zone_split_index **zone_state_index; +unsigned int num_open_zones;unsigned int verify_batch;unsigned int trim_batch;
options.c +13 -3
@@ -3360,12 +3360,22 @@ struct fio_option fio_options[FIO_MAX_OPTS] = { }, { .name = "max_open_zones", - .lname = "Maximum number of open zones", + .lname = "Per device/file maximum number of open zones", .type = FIO_OPT_INT, .off1 = offsetof(struct thread_options, max_open_zones), .maxval = ZBD_MAX_OPEN_ZONES, - .help ="Limit random writes to SMR drives to the specified" - " number of sequential zones", + .help = "Limit on the number of simultaneously opened sequential write zones with zonemode=zbd", + .def = "0", + .category = FIO_OPT_C_IO, + .group = FIO_OPT_G_INVALID, + }, + { + .name = "job_max_open_zones", + .lname = "Job maximum number of open zones", + .type = FIO_OPT_INT, + .off1 = offsetof(struct thread_options, job_max_open_zones), + .maxval = ZBD_MAX_OPEN_ZONES, + .help = "Limit on the number of simultaneously opened sequential write zones with zonemode=zbd by one thread/process", .def = "0", .category = FIO_OPT_C_IO, .group = FIO_OPT_G_INVALID,
thread_options.h +1 -0
@@ -343,6 +343,7 @@ struct thread_options {/* Parameters that affect zonemode=zbd */ unsigned int read_beyond_wp;int max_open_zones; +unsigned int job_max_open_zones;fio_fp64_t zrt;fio_fp64_t zrf; };
zbd.c +35 -11
102 lines not on this page · raw message
zbd.h +3 -0
@@ -45,6 +45,8 @@ struct fio_zone_info {/** * zoned_block_device_info - zoned block device characteristics * @model: Device model. +* @max_open_zones: global limit on the number of simultaneously opened +* sequential write zones. * @mutex: Protects the modifiable members in this structure (refcount and * num_open_zones). * @zone_size: size of a single zone in units of 512 bytes
@@ -65,6 +67,7 @@ struct fio_zone_info {*/ struct zoned_block_device_info {enum zbd_zoned_model model; +uint32_t max_open_zones;pthread_mutex_t mutex;uint64_t zone_size;uint64_t sectors_with_data;
Signature · 1 line
2.26.2
PATCH 5/5 zbd: make zbd_info->mutex non-recursive
In reply to Alexey DobriyanThere is no reason for it to be recursive. Resursiveness leaked from struct fio_zone_info::mutex initialisation.
--- zbd.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-)
zbd.c +12 -6
@@ -375,9 +375,9 @@ static int init_zone_info(struct thread_data *td, struct fio_file *f)return -ENOMEM ;pthread_mutexattr_init (&attr); -pthread_mutexattr_settype (&attr,PTHREAD_MUTEX_RECURSIVE );pthread_mutexattr_setpshared (&attr, true);pthread_mutex_init (&zbd_info->mutex, &attr); +pthread_mutexattr_settype (&attr,PTHREAD_MUTEX_RECURSIVE ); zbd_info->refcount =1 ; p = &zbd_info->zone_info[0 ];for (i =0 ; i < nr_zones; i++, p++) {
@@ -419,7 +419,6 @@ static int parse_zone_info(struct thread_data *td, struct fio_file *f)int i, j, ret =0 ;pthread_mutexattr_init (&attr); -pthread_mutexattr_settype (&attr,PTHREAD_MUTEX_RECURSIVE );pthread_mutexattr_setpshared (&attr, true); zones =calloc (ZBD_REPORT_MAX_ZONES ,sizeof (struct zbd_zone ));
@@ -456,6 +455,7 @@ static int parse_zone_info(struct thread_data *td, struct fio_file *f)if (!zbd_info) goto out;pthread_mutex_init (&zbd_info->mutex, &attr); +pthread_mutexattr_settype (&attr,PTHREAD_MUTEX_RECURSIVE ); zbd_info->refcount =1 ; p = &zbd_info->zone_info[0 ];for (offset =0 , j =0 ; j < nr_zones;) {
@@ -794,14 +794,20 @@ static int zbd_reset_zones(struct thread_data *td, struct fio_file *f,* Reset zbd_info.write_cnt, the counter that counts down towards the next * zone reset. */ -static void zbd_reset_write_cnt (const struct thread_data *td, -const struct fio_file *f) +static void _zbd_reset_write_cnt (const struct thread_data *td, +const struct fio_file *f) {assert (0 <= td->o.zrf.u.f && td->o.zrf.u.f <=1 ); -pthread_mutex_lock (&f->zbd_info->mutex); f->zbd_info->write_cnt = td->o.zrf.u.f ?min (1.0 / td->o.zrf.u.f,0.0 +UINT_MAX ) :UINT_MAX ; +} + +static void zbd_reset_write_cnt (const struct thread_data *td, +const struct fio_file *f) +{ +pthread_mutex_lock (&f->zbd_info->mutex); +_zbd_reset_write_cnt (td, f);pthread_mutex_unlock (&f->zbd_info->mutex); }
@@ -815,7 +821,7 @@ static bool zbd_dec_and_reset_write_cnt(const struct thread_data *td,if (f->zbd_info->write_cnt) write_cnt = --f->zbd_info->write_cnt;if (write_cnt ==0 ) -zbd_reset_write_cnt (td, f); +_zbd_reset_write_cnt (td, f);pthread_mutex_unlock (&f->zbd_info->mutex);return write_cnt ==0 ;
Signature · 1 line
2.26.2
Jens Axboe
AppliedQuoted 2 lines · Alexey Dobriyan
It is nicer this way and there will be more code in this area with ZBD verification.
Applied this (and 2-5), thanks.
Signature · 1 line
Jens Axboe