v1 Patchset : Simple Copy Command support
A message that is not in the archive (sent off-list or not yet received): CGME20201201114048epcas5p3e12de26128ce442bbe8406082eaccde9@epcas5p3.samsung.com
cover v1 Patchset : Simple Copy Command support
This patchset adds support for TP4065a ("Simple Copy Command") v2020.05.04 ("Ratified")
The Specification can be found in following link.
https://nvmexpress.org/wp-content/uploads/NVM-Express-1.4-Ratified-TPs-1.zip
Simple copy command is a copy offloading operation and is used to copy multiple contiguous ranges (source_ranges) of LBA's to a single destination LBA within the device, reducing traffic between host and device.
In this implementation we introduce a new copy operation. The copy operation can be enabled by passing rw=copy (Generates sequential source ranges) rw=randcopy (Generates random source ranges)
copy operation requires two new options to be passed num_range - Number of ranges per copy operation. dest_offset - Start of the destination offset.
The existing FIO options will be used as offset - Starting offset of the source range. blocksize - Number of logical blocks per source range.
Introduced a new synchronous ioengine "sctl". This is a basic ioengine which supports only copy command.
Added a basic sequential copy support for Zoned block devices.
This is a RFC and the Linux Kernel interface is under submission and review.
https://lore.kernel.org/linux-nvme/[email protected]/
Feedback / Comments will help in improving this further.
Ankit Kumar (9):
Adding the necessary ddir changes to introduce copy operation. Introducing new offsets for the copy operation.
Added support for printing of stats and estimate time for copy
operation.
Adding a new copy operation.
Added the changes for copy operation support in FIO. New ioctl based synchronous IO engine. Only supports copy command Example configuration for simple copy command
Support copy operation for zoned block devices.
Add a new test case to test the copy operation.
HOWTO | 28 +++++- Makefile | 2 +- backend.c | 25 ++++- cconv.c | 6 ++ engines/sctl.c | 215 +++++++++++++++++++++++++++++++++++++++++ eta.c | 31 ++++-- examples/fio-copy.fio | 32 ++++++ file.h | 7 ++ filesetup.c | 79 +++++++++++++++ fio.1 | 25 ++++- fio.h | 12 +++ init.c | 44 ++++++--- io_ddir.h | 22 +++-- io_u.c | 105 ++++++++++++++++---- io_u.h | 3 + options.c | 64 +++++++++++- os/os-linux.h | 1 + parse.c | 28 ++++++ parse.h | 2 + rate-submit.c | 2 + stat.c | 20 +++- stat.h | 1 - t/zbd/functions | 9 ++ t/zbd/test-zbd-support | 54 +++++++++++ thread_options.h | 9 +- zbd.c | 90 +++++++++++++++-- 26 files changed, 842 insertions(+), 74 deletions(-) create mode 100644 engines/sctl.c create mode 100644 examples/fio-copy.fio
Signature · 1 line
2.17.1
PATCH 1/9 Adding the necessary ddir changes to introduce copy operation.
From: Ankit Kumar <[email protected]>
--- io_ddir.h | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-)
io_ddir.h +15 -7
@@ -5,22 +5,23 @@ enum fio_ddir {DDIR_READ =0 ,DDIR_WRITE =1 ,DDIR_TRIM =2 , -DDIR_SYNC =3 , +DDIR_COPY =3 , +DDIR_SYNC =4 ,DDIR_DATASYNC ,DDIR_SYNC_FILE_RANGE ,DDIR_WAIT ,DDIR_LAST ,DDIR_INVAL =-1 , -DDIR_RWDIR_CNT =3 , - DDIR_RWDIR_SYNC_CNT = 4, +DDIR_RWDIR_CNT =4 , + DDIR_RWDIR_SYNC_CNT = 5, };#define for_each_rw_ddir (ddir) for (enum fio_ddir ddir = 0; ddir < DDIR_RWDIR_CNT; ddir++)static inline const char *io_ddir_name (enum fio_ddir ddir) { -static const char *name[] = {"read" ,"write" ,"trim" ,"sync" , +static const char *name[] = {"read" ,"write" ,"trim" ,"copy" ,"sync" "datasync" ,"sync_file_range" ,"wait" , };
@@ -35,17 +36,20 @@ enum td_ddir {TD_DDIR_WRITE =1 <<1 ,TD_DDIR_RAND =1 <<2 ,TD_DDIR_TRIM =1 <<3 , +TD_DDIR_COPY =1 <<4 ,TD_DDIR_RW =TD_DDIR_READ |TD_DDIR_WRITE ,TD_DDIR_RANDREAD =TD_DDIR_READ |TD_DDIR_RAND ,TD_DDIR_RANDWRITE =TD_DDIR_WRITE |TD_DDIR_RAND ,TD_DDIR_RANDRW =TD_DDIR_RW |TD_DDIR_RAND ,TD_DDIR_RANDTRIM =TD_DDIR_TRIM |TD_DDIR_RAND ,TD_DDIR_TRIMWRITE =TD_DDIR_TRIM |TD_DDIR_WRITE , + TD_DDIR_RANDCOPY = TD_DDIR_COPY | TD_DDIR_RAND, };#define td_read (td) ((td)->o.td_ddir & TD_DDIR_READ)#define td_write (td) ((td)->o.td_ddir & TD_DDIR_WRITE)#define td_trim (td) ((td)->o.td_ddir & TD_DDIR_TRIM) +#define td_copy (td) ((td)->o.td_ddir & TD_DDIR_COPY)#define td_rw (td) (((td)->o.td_ddir & TD_DDIR_RW) == TD_DDIR_RW)#define td_random (td) ((td)->o.td_ddir & TD_DDIR_RAND)#define file_randommap (td, f) (!(td)->o.norandommap && fio_file_axmap((f)))
@@ -60,19 +64,23 @@ static inline int ddir_sync(enum fio_ddir ddir)static inline int ddir_rw (enum fio_ddir ddir) { -return ddir ==DDIR_READ || ddir ==DDIR_WRITE || ddir ==DDIR_TRIM ; +return ddir ==DDIR_READ || ddir ==DDIR_WRITE || ddir ==DDIR_TRIM || + ddir ==DDIR_COPY ; }static inline const char *ddir_str (enum td_ddir ddir) {static const char *__str[] = {NULL ,"read" ,"write" ,"rw" ,"rand" ,"randread" ,"randwrite" ,"randrw" , -"trim" ,NULL ,"trimwrite" ,NULL ,"randtrim" }; +"trim" ,NULL ,"trimwrite" ,NULL ,"randtrim" , +NULL ,NULL ,NULL ,"copy" ,NULL ,NULL , +NULL ,"randcopy" };return __str[ddir]; }#define ddir_rw_sum (arr) \ - ((arr)[DDIR_READ] + (arr)[DDIR_WRITE] + (arr)[DDIR_TRIM]) + ((arr)[DDIR_READ] + (arr)[DDIR_WRITE] + (arr)[DDIR_TRIM] \ + + (arr)[DDIR_COPY])#endif
Signature · 1 line
2.17.1
PATCH 2/9 Introducing new offsets for the copy operation.
In reply to Krishna Kanth ReddyFrom: Ankit Kumar <[email protected]>
--- options.c | 11 ++++++++++- parse.c | 28 ++++++++++++++++++++++++++++ parse.h | 2 ++ 3 files changed, 40 insertions(+), 1 deletion(-)
options.c +10 -1
@@ -2154,6 +2154,7 @@ struct fio_option fio_options[FIO_MAX_OPTS] = { .off1 = offsetof(struct thread_options, bs[DDIR_READ]), .off2 = offsetof(struct thread_options, bs[DDIR_WRITE]), .off3 = offsetof(struct thread_options, bs[DDIR_TRIM]), + .off4 = offsetof(struct thread_options, bs[DDIR_COPY]), .minval = 1, .help = "Block size unit", .def = "4096",
@@ -2171,6 +2172,7 @@ struct fio_option fio_options[FIO_MAX_OPTS] = { .off1 = offsetof(struct thread_options, ba[DDIR_READ]), .off2 = offsetof(struct thread_options, ba[DDIR_WRITE]), .off3 = offsetof(struct thread_options, ba[DDIR_TRIM]), + .off4 = offsetof(struct thread_options, ba[DDIR_COPY]), .minval = 1, .help = "IO block offset alignment", .parent = "rw",
@@ -2190,6 +2192,8 @@ struct fio_option fio_options[FIO_MAX_OPTS] = { .off4 = offsetof(struct thread_options, max_bs[DDIR_WRITE]), .off5 = offsetof(struct thread_options, min_bs[DDIR_TRIM]), .off6 = offsetof(struct thread_options, max_bs[DDIR_TRIM]), + .off7 = offsetof(struct thread_options, min_bs[DDIR_COPY]), + .off8 = offsetof(struct thread_options, max_bs[DDIR_COPY]), .minval = 1, .help = "Set block size range (in more detail than bs)", .parent = "rw",
@@ -2349,9 +2353,10 @@ struct fio_option fio_options[FIO_MAX_OPTS] = { .off1 = offsetof(struct thread_options, perc_rand[DDIR_READ]), .off2 = offsetof(struct thread_options, perc_rand[DDIR_WRITE]), .off3 = offsetof(struct thread_options, perc_rand[DDIR_TRIM]), + .off4 = offsetof(struct thread_options, perc_rand[DDIR_COPY]), .maxval = 100, .help = "Percentage of seq/random mix that should be random", - .def = "100,100,100", + .def = "100,100,100,100", .interval = 5, .inverse = "percentage_sequential", .category = FIO_OPT_C_IO,
@@ -3579,6 +3584,7 @@ struct fio_option fio_options[FIO_MAX_OPTS] = { .off1 = offsetof(struct thread_options, rate[DDIR_READ]), .off2 = offsetof(struct thread_options, rate[DDIR_WRITE]), .off3 = offsetof(struct thread_options, rate[DDIR_TRIM]), + .off4 = offsetof(struct thread_options, rate[DDIR_COPY]), .help = "Set bandwidth rate", .category = FIO_OPT_C_IO, .group = FIO_OPT_G_RATE,
@@ -3591,6 +3597,7 @@ struct fio_option fio_options[FIO_MAX_OPTS] = { .off1 = offsetof(struct thread_options, ratemin[DDIR_READ]), .off2 = offsetof(struct thread_options, ratemin[DDIR_WRITE]), .off3 = offsetof(struct thread_options, ratemin[DDIR_TRIM]), + .off4 = offsetof(struct thread_options, ratemin[DDIR_COPY]), .help = "Job must meet this rate or it will be shutdown", .parent = "rate", .hide = 1,
@@ -3604,6 +3611,7 @@ struct fio_option fio_options[FIO_MAX_OPTS] = { .off1 = offsetof(struct thread_options, rate_iops[DDIR_READ]), .off2 = offsetof(struct thread_options, rate_iops[DDIR_WRITE]), .off3 = offsetof(struct thread_options, rate_iops[DDIR_TRIM]), + .off4 = offsetof(struct thread_options, rate_iops[DDIR_COPY]), .help = "Limit IO used to this number of IO operations/sec", .hide = 1, .category = FIO_OPT_C_IO,
@@ -3616,6 +3624,7 @@ struct fio_option fio_options[FIO_MAX_OPTS] = { .off1 = offsetof(struct thread_options, rate_iops_min[DDIR_READ]), .off2 = offsetof(struct thread_options, rate_iops_min[DDIR_WRITE]), .off3 = offsetof(struct thread_options, rate_iops_min[DDIR_TRIM]), + .off4 = offsetof(struct thread_options, rate_iops_min[DDIR_COPY]), .help = "Job must meet this rate or it will be shut down", .parent = "rate_iops", .hide = 1,
parse.c +28 -0
@@ -669,6 +669,10 @@ static int __handle_option(const struct fio_option *o, const char *ptr,if (o->off3)val_store (ilp, ull, o->off3,0 , data, o); } +if (curr ==3 ) { +if (o->off4) +val_store (ilp, ull, o->off4,0 , data, o); + }if (!more) {if (curr <1 ) {if (o->off2)
@@ -678,6 +682,10 @@ static int __handle_option(const struct fio_option *o, const char *ptr,if (o->off3)val_store (ilp, ull, o->off3,0 , data, o); } +if (curr <3 ) { +if (o->off4) +val_store (ilp, ull, o->off4,0 , data, o); + } } }else if (o->type ==FIO_OPT_ULL ) {if (first)
@@ -690,6 +698,10 @@ static int __handle_option(const struct fio_option *o, const char *ptr,if (o->off3)val_store (ullp, ull, o->off3,0 , data, o); } +if (curr ==3 ) { +if (o->off4) +val_store (ullp, ull, o->off4,0 , data, o); + }if (!more) {if (curr <1 ) {if (o->off2)
@@ -699,6 +711,10 @@ static int __handle_option(const struct fio_option *o, const char *ptr,if (o->off3)val_store (ullp, ull, o->off3,0 , data, o); } +if (curr <3 ) { +if (o->off4) +val_store (ullp, ull, o->off4,0 , data, o); + } } }else {if (first)
@@ -879,6 +895,12 @@ static int __handle_option(const struct fio_option *o, const char *ptr,val_store (ullp, ull2, o->off6,0 , data, o); } } +if (curr ==3 ) { +if (o->off7 && o->off8) { +val_store (ullp, ull1, o->off7,0 , data, o); +val_store (ullp, ull2, o->off8,0 , data, o); + } + }if (!more) {if (curr <1 ) {if (o->off3 && o->off4) {
@@ -892,6 +914,12 @@ static int __handle_option(const struct fio_option *o, const char *ptr,val_store (ullp, ull2, o->off6,0 , data, o); } } +if (curr <3 ) { +if (o->off7 && o->off8) { +val_store (ullp, ull1, o->off7,0 , data, o); +val_store (ullp, ull2, o->off8,0 , data, o); + } + } } }
parse.h +2 -0
@@ -54,6 +54,8 @@ struct fio_option {unsigned int off4;unsigned int off5;unsigned int off6; +unsigned int off7; +unsigned int off8;unsigned long long maxval;/* max and min value */ int minval;double maxfp;/* max and min floating value */
Signature · 1 line
2.17.1
PATCH 3/9 Added support for printing of stats and estimate time for copy operation.
In reply to Krishna Kanth ReddyFrom: Ankit Kumar <[email protected]>
--- backend.c | 3 +++ eta.c | 31 ++++++++++++++++++++++--------- stat.c | 20 +++++++++++++++----- stat.h | 1 - 4 files changed, 40 insertions(+), 15 deletions(-)
backend.c +3 -0
@@ -1828,6 +1828,8 @@ static void *thread_main(void *data)update_runtime (td, elapsed_us,DDIR_WRITE );if (td_trim (td) && td->io_bytes[DDIR_TRIM ])update_runtime (td, elapsed_us,DDIR_TRIM ); +if (td_copy (td) && td->io_bytes[DDIR_COPY ]) +update_runtime (td, elapsed_us,DDIR_COPY );fio_gettime (&td->start,NULL );fio_sem_up (stat_sem);
@@ -2491,6 +2493,7 @@ int fio_backend(struct sk_out *sk_out)setup_log (&agg_io_log[DDIR_READ ], &p,"agg-read_bw.log" );setup_log (&agg_io_log[DDIR_WRITE ], &p,"agg-write_bw.log" );setup_log (&agg_io_log[DDIR_TRIM ], &p,"agg-trim_bw.log" ); +setup_log (&agg_io_log[DDIR_COPY ], &p,"agg-copy_bw.log" ); } startup_sem =fio_sem_init (FIO_SEM_LOCKED );
eta.c +22 -9
@@ -82,6 +82,11 @@ static void check_str_update(struct thread_data *td) c ='w' ; else c ='W' ; + }else if (td_copy (td)) { +if (td_random (td)) + c ='q' ; +else + c ='Q' ; }else {if (td_random (td)) c ='d' ;
@@ -292,6 +297,8 @@ static unsigned long thread_eta(struct thread_data *td) rate_bytes += td->o.rate[DDIR_WRITE ];if (td_trim (td)) rate_bytes += td->o.rate[DDIR_TRIM ]; +if (td_copy (td)) + rate_bytes += td->o.rate[DDIR_COPY ];if (rate_bytes) { r_eta = bytes_total / rate_bytes;
@@ -445,6 +452,12 @@ bool calc_thread_status(struct jobs_eta *je, int force) je->m_rate[2 ] += td->o.ratemin[DDIR_TRIM ]; je->m_iops[2 ] += td->o.rate_iops_min[DDIR_TRIM ]; } +if (td_copy (td)) { + je->t_rate[3 ] += td->o.rate[DDIR_COPY ]; + je->t_iops[3 ] += td->o.rate_iops[DDIR_COPY ]; + je->m_rate[3 ] += td->o.ratemin[DDIR_COPY ]; + je->m_iops[3 ] += td->o.rate_iops_min[DDIR_COPY ]; + } je->files_open += td->nr_open_files; }else if (td->runstate ==TD_RAMP ) {
@@ -534,7 +547,7 @@ bool calc_thread_status(struct jobs_eta *je, int force)static int gen_eta_str (struct jobs_eta *je,char *p,size_t left,char **rate_str,char **iops_str) { -static const char c[DDIR_RWDIR_CNT ] = {'r' ,'w' ,'t' }; +static const char c[DDIR_RWDIR_CNT ] = {'r' ,'w' ,'t' ,'c' };bool has[DDIR_RWDIR_CNT ];bool has_any = false;const char *sep;
@@ -594,23 +607,23 @@ void display_thread_status(struct jobs_eta *je) p +=sprintf (p,"Jobs: %d (f=%d)" , je->nr_running, je->files_open);/* rate limits, if any */ -if (je->m_rate[0 ] || je->m_rate[1 ] || je->m_rate[2 ] || - je->t_rate[0 ] || je->t_rate[1 ] || je->t_rate[2 ]) { +if (je->m_rate[0 ] || je->m_rate[1 ] || je->m_rate[2 ] || je->m_rate[3 ] || + je->t_rate[0 ] || je->t_rate[1 ] || je->t_rate[2 ] || je->t_rate[3 ]) {char *tr, *mr; - mr =num2str (je->m_rate[0 ] + je->m_rate[1 ] + je->m_rate[2 ], + mr =num2str (je->m_rate[0 ] + je->m_rate[1 ] + je->m_rate[2 ] + je->m_rate[3 ], je->sig_figs,0 , je->is_pow2,N2S_BYTEPERSEC ); - tr =num2str (je->t_rate[0 ] + je->t_rate[1 ] + je->t_rate[2 ], + tr =num2str (je->t_rate[0 ] + je->t_rate[1 ] + je->t_rate[2 ] + je->t_rate[3 ], je->sig_figs,0 , je->is_pow2,N2S_BYTEPERSEC ); p +=sprintf (p,", %s-%s" , mr, tr);free (tr);free (mr); - }else if (je->m_iops[0 ] || je->m_iops[1 ] || je->m_iops[2 ] || - je->t_iops[0 ] || je->t_iops[1 ] || je->t_iops[2 ]) { + }else if (je->m_iops[0 ] || je->m_iops[1 ] || je->m_iops[2 ] || je->m_iops[3 ] || + je->t_iops[0 ] || je->t_iops[1 ] || je->t_iops[2 ] || je->t_iops[3 ]) { p +=sprintf (p,", %d-%d IOPS" , - je->m_iops[0 ] + je->m_iops[1 ] + je->m_iops[2 ], - je->t_iops[0 ] + je->t_iops[1 ] + je->t_iops[2 ]); + je->m_iops[0 ] + je->m_iops[1 ] + je->m_iops[2 ] + je->m_iops[3 ], + je->t_iops[0 ] + je->t_iops[1 ] + je->t_iops[2 ] + je->t_iops[3 ]); }/* current run string, % done, bandwidth, iops, eta */
stat.c +15 -5
@@ -286,7 +286,7 @@ void show_group_stats(struct group_run_stats *rs, struct buf_output *out) {char *io, *agg, *min, *max;char *ioalt, *aggalt, *minalt, *maxalt; -const char *str[] = {" READ" ," WRITE" ," TRIM" }; +const char *str[] = {" READ" ," WRITE" ," TRIM" ," COPY" };int i;log_buf (out,"\nRun status group %d (all jobs):\n" , rs->groupid);
@@ -1124,19 +1124,22 @@ static void show_thread_status_normal(struct thread_stat *ts, io_u_dist[1 ], io_u_dist[2 ], io_u_dist[3 ], io_u_dist[4 ], io_u_dist[5], io_u_dist[6]); -log_buf (out," issued rwts: total=%llu,%llu,%llu,%llu" -" short=%llu,%llu,%llu,0" -" dropped=%llu,%llu,%llu,0\n" , +log_buf (out," issued rwts: total=%llu,%llu,%llu,%llu,%llu" +" short=%llu,%llu,%llu,%llu,0" +" dropped=%llu,%llu,%llu,%llu,0\n" , (unsigned long long ) ts->total_io_u[0 ], (unsigned long long ) ts->total_io_u[1 ], (unsigned long long ) ts->total_io_u[2 ], (unsigned long long ) ts->total_io_u[3 ], + (unsigned long long ) ts->total_io_u[4 ], (unsigned long long ) ts->short_io_u[0 ], (unsigned long long ) ts->short_io_u[1 ], (unsigned long long ) ts->short_io_u[2 ], + (unsigned long long ) ts->short_io_u[3 ], (unsigned long long ) ts->drop_io_u[0 ], (unsigned long long ) ts->drop_io_u[1 ], - (unsigned long long ) ts->drop_io_u[2 ]); + (unsigned long long ) ts->drop_io_u[2 ], + (unsigned long long ) ts->drop_io_u[3 ]);if (ts->continue_on_error) { log_buf(out, " errors : total=%llu, first_error=%d/<%s>\n", (unsigned long long)ts->total_err_count,
@@ -1442,6 +1445,8 @@ static void show_thread_status_terse_all(struct thread_stat *ts,/* Log Trim Status */ if (ver ==2 || ver ==4 || ver ==5 )show_ddir_status_terse (ts, rs,DDIR_TRIM , ver, out); +/* Log Copy Status */ +show_ddir_status_terse (ts, rs,DDIR_COPY , ver, out);/* CPU Usage */ if (ts->total_run_time) {
@@ -1545,6 +1550,7 @@ static struct json_object *show_thread_status_json(struct thread_stat *ts,add_ddir_status_json (ts, rs,DDIR_READ , root);add_ddir_status_json (ts, rs,DDIR_WRITE , root);add_ddir_status_json (ts, rs,DDIR_TRIM , root); +add_ddir_status_json (ts, rs,DDIR_COPY , root);add_ddir_status_json (ts, rs,DDIR_SYNC , root);/* CPU Usage */
@@ -2325,6 +2331,8 @@ int __show_running_run_stats(void) td->ts.runtime[DDIR_WRITE ] += rt[i];if (td_trim (td) && td->ts.io_bytes[DDIR_TRIM ]) td->ts.runtime[DDIR_TRIM ] += rt[i]; +if (td_copy (td) && td->ts.io_bytes[DDIR_COPY ]) + td->ts.runtime[DDIR_COPY ] += rt[i]; }for_each_td (td, i) {
@@ -2346,6 +2354,8 @@ int __show_running_run_stats(void) td->ts.runtime[DDIR_WRITE ] -= rt[i];if (td_trim (td) && td->ts.io_bytes[DDIR_TRIM ]) td->ts.runtime[DDIR_TRIM ] -= rt[i]; +if (td_copy (td) && td->ts.io_bytes[DDIR_COPY ]) + td->ts.runtime[DDIR_COPY ] -= rt[i]; }free (rt);
stat.h +0 -1
@@ -281,7 +281,6 @@ struct thread_stat {uint32_t m_iops[DDIR_RWDIR_CNT ]; \uint32_t t_iops[DDIR_RWDIR_CNT ]; \uint32_t iops[DDIR_RWDIR_CNT ]; \ -uint32_t pad; \uint64_t elapsed_sec; \uint64_t eta_sec; \uint32_t is_pow2; \
Signature · 1 line
2.17.1
PATCH 4/9 Adding a new copy operation.
In reply to Krishna Kanth ReddyFrom: Ankit Kumar <[email protected]>
Changes for rw=copy and rw=randcopy
The copy operation requires two new FIO options. dest_offset : The starting destination offset for the copy operation. num_range : The number of source ranges for each copy operation. The existing FIO option offset will be the starting source offset.
Data to be copied from source range can be random or sequential according to rw=copy or randcopy option. The destination location for the copy operation will be sequential.
--- HOWTO | 24 ++++++++++++++++++++++-- cconv.c | 6 ++++++ fio.1 | 21 ++++++++++++++++++++- options.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ thread_options.h | 9 +++++++-- 5 files changed, 103 insertions(+), 5 deletions(-)
HOWTO +22 -2
@@ -177,8 +177,8 @@ Command line options ``--readonly`` option is an extra safety guard to prevent users from accidentally starting a write or trim workload when that is not desired. Fio will only modify the device under test if - `rw=write/randwrite/rw/randrw/trim/randtrim/trimwrite` is given. This - safety net can be used as an extra precaution. + `rw=write/randwrite/rw/randrw/trim/randtrim/trimwrite/copy/randcopy` is given. + This safety net can be used as an extra precaution. .. option:: --eta=when
@@ -1096,6 +1096,9 @@ I/O type **trim** Sequential trims (Linux block devices and SCSI character devices only). + **copy** + Sequential copy (Linux NVMe block device. Source offset + will be sequential). **randread** Random reads. **randwrite**
@@ -1103,6 +1106,9 @@ I/O type **randtrim** Random trims (Linux block devices and SCSI character devices only). + **randcopy** + Random copy (Linux NVMe block device. Source offset + will be random). **rw,readwrite** Sequential mixed reads and writes. **randrw**
@@ -1280,6 +1286,20 @@ I/O type If a percentage is given, the generated offset will be aligned to the minimum ``blocksize`` or to the value of ``offset_align`` if provided. +.. option:: dest_offset=int + + Destination offset in the file for copy command, given as either a fixed size + in bytes or a percentage. The option 'offset' is now used as source offset for + copy command. If a percentage is given, the generated offset will be aligned + to the minimum ``blocksize`` or to the value of ``offset_align`` if provided. + A percentage can be specified by a number between 1 and 100 followed by '%', + for example, ``dest_offset=40%`` to specify 40%. + +.. option:: num_range=int + For copy command this must be the number of source ranges to copy at a time. + The number of logical blocks per source range is determined by the option 'bs' + and it must be a multiple of logical block size. + .. option:: number_ios=int Fio will normally perform I/Os until it has exhausted the size of the region
cconv.c +6 -0
@@ -101,6 +101,7 @@ void convert_thread_options_to_cpu(struct thread_options *o, o->serialize_overlap =le32_to_cpu (top->serialize_overlap); o->size =le64_to_cpu (top->size); o->io_size =le64_to_cpu (top->io_size); + o->num_range =le32_to_cpu (top->num_range); o->size_percent =le32_to_cpu (top->size_percent); o->io_size_percent =le32_to_cpu (top->io_size_percent); o->fill_device =le32_to_cpu (top->fill_device);
@@ -110,6 +111,8 @@ void convert_thread_options_to_cpu(struct thread_options *o, o->start_offset =le64_to_cpu (top->start_offset); o->start_offset_align =le64_to_cpu (top->start_offset_align); o->start_offset_percent =le32_to_cpu (top->start_offset_percent); + o->dest_offset =le64_to_cpu (top->dest_offset); + o->dest_offset_percent =le32_to_cpu (top->dest_offset_percent);for (i =0 ; i <DDIR_RWDIR_CNT ; i++) { o->bs[i] =le64_to_cpu (top->bs[i]);
@@ -553,6 +556,7 @@ void convert_thread_options_to_net(struct thread_options_pack *top, top->size =__cpu_to_le64 (o->size); top->io_size =__cpu_to_le64 (o->io_size); + top->num_range =__cpu_to_le32 (o->num_range); top->verify_backlog =__cpu_to_le64 (o->verify_backlog); top->start_delay =__cpu_to_le64 (o->start_delay); top->start_delay_high =__cpu_to_le64 (o->start_delay_high);
@@ -574,6 +578,8 @@ void convert_thread_options_to_net(struct thread_options_pack *top, top->start_offset =__cpu_to_le64 (o->start_offset); top->start_offset_align =__cpu_to_le64 (o->start_offset_align); top->start_offset_percent =__cpu_to_le32 (o->start_offset_percent); + top->dest_offset =__cpu_to_le64 (o->dest_offset); + top->dest_offset_percent =__cpu_to_le32 (o->dest_offset_percent); top->trim_backlog =__cpu_to_le64 (o->trim_backlog); top->offset_increment_percent =__cpu_to_le32 (o->offset_increment_percent); top->offset_increment =__cpu_to_le64 (o->offset_increment);
fio.1 +20 -1
@@ -74,7 +74,7 @@ Convert \fIjobfile\fR to a set of command\-line options. Turn on safety read\-only checks, preventing writes and trims. The \fB\-\-readonly\fR option is an extra safety guard to prevent users from accidentally starting a write or trim workload when that is not desired. Fio will only modify the -device under test if `rw=write/randwrite/rw/randrw/trim/randtrim/trimwrite' +device under test if `rw=write/randwrite/rw/randrw/trim/randtrim/trimwrite/copy/randcopy' is given. This safety net can be used as an extra precaution. .TP .BI \-\-eta \fR=\fPwhen
@@ -860,6 +860,9 @@ Sequential writes. .B trim Sequential trims (Linux block devices and SCSI character devices only). .TP +.B copy +Sequential copy (Linux NVMe block device. Source offset will be sequential). +.TP .B randread Random reads. .TP
@@ -869,6 +872,9 @@ Random writes. .B randtrim Random trims (Linux block devices and SCSI character devices only). .TP +.B randcopy +Random copy (Linux NVMe block device. Source offset will be random). +.TP .B rw,readwrite Sequential mixed reads and writes. .TP
@@ -1055,6 +1061,19 @@ spacing between the starting points. Percentages can be used for this option. If a percentage is given, the generated offset will be aligned to the minimum \fBblocksize\fR or to the value of \fBoffset_align\fR if provided. .TP +.BI dest_offset \fR=\fPint +Destination offset in the file for copy command, given as either a fixed size in +bytes or a percentage. The \fBoffset\fR is now used as source offset for copy command. +If a percentage is given, the generated destination offset will be aligned to the +minimum \fBblocksize\fR or to the value of \fBoffset_align\fR if provided. +A percentage can be specified by a number between 1 and 100 followed by '%', +for example, `dest_offset=40%' to specify 40%. +.TP +.BI num_range \fR=\fPint +For copy command this must be the number of source ranges to copy at a time. +The number of logical blocks per source range is determined by the option\fBbs\fR +and it must be a multiple of logical block size. +.TP .BI number_ios \fR=\fPint Fio will normally perform I/Os until it has exhausted the size of the region set by \fBsize\fR, or if it exhaust the allocated time (or hits an error
options.c +48 -0
72 lines not on this page · raw message
thread_options.h +7 -2
@@ -77,6 +77,7 @@ struct thread_options {unsigned int iodepth_batch_complete_min;unsigned int iodepth_batch_complete_max;unsigned int serialize_overlap; +unsigned int num_range;unsigned int unique_filename;
@@ -90,6 +91,7 @@ struct thread_options {unsigned long long file_size_high;unsigned long long start_offset;unsigned long long start_offset_align; +unsigned long long dest_offset;unsigned long long bs[DDIR_RWDIR_CNT ];unsigned long long ba[DDIR_RWDIR_CNT ];
@@ -217,6 +219,7 @@ struct thread_options {char *numa_memnodes;unsigned int gpu_dev_id;unsigned int start_offset_percent; +unsigned int dest_offset_percent;unsigned int iolog;unsigned int rwmixcycle;
@@ -379,6 +382,7 @@ struct thread_options_pack {uint32_t serialize_overlap;uint32_t pad; +uint32_t num_range;uint64_t size;uint64_t io_size;uint32_t size_percent;
@@ -390,6 +394,7 @@ struct thread_options_pack {uint64_t file_size_high;uint64_t start_offset;uint64_t start_offset_align; +uint64_t dest_offset;uint64_t bs[DDIR_RWDIR_CNT ];uint64_t ba[DDIR_RWDIR_CNT ];
@@ -462,8 +467,6 @@ struct thread_options_pack {struct zone_split zone_split[DDIR_RWDIR_CNT ][ZONESPLIT_MAX ];uint32_t zone_split_nr[DDIR_RWDIR_CNT ]; -uint8_t pad1[4 ]; -fio_fp64_t zipf_theta;fio_fp64_t pareto_h;fio_fp64_t gauss_dev;
@@ -514,6 +517,7 @@ struct thread_options_pack {#endif uint32_t gpu_dev_id;uint32_t start_offset_percent; +uint32_t dest_offset_percent;uint32_t cpus_allowed_policy;uint32_t iolog;uint32_t rwmixcycle;
@@ -552,6 +556,7 @@ struct thread_options_pack {uint32_t lat_percentiles;uint32_t slat_percentiles;uint32_t percentile_precision; +uint32_t pad3;fio_fp64_t percentile_list[FIO_IO_U_LIST_MAX_LEN ];uint8_t read_iolog_file[FIO_TOP_STR_MAX ];
Signature · 1 line
2.17.1
PATCH 5/9 Added the changes for copy operation support in FIO.
In reply to Krishna Kanth ReddyFrom: Ankit Kumar <[email protected]>
The source ranges for copy operation uses the existing offset generation algorithm. As each copy operation has num_range source ranges the get_next_offset will be called that many times. The data buffer will now contain a range list, with each entry having a start offset and the length in bytes for that source range.
For generating the destination offset added a new function. Each successful copy operation will copy 'num_range' * 'block_size' amount of data.
--- backend.c | 22 +++++++++-- file.h | 3 ++ filesetup.c | 61 ++++++++++++++++++++++++++++++ fio.h | 12 ++++++ init.c | 39 +++++++++++-------- io_u.c | 103 +++++++++++++++++++++++++++++++++++++++++--------- rate-submit.c | 2 + zbd.c | 2 + 8 files changed, 207 insertions(+), 37 deletions(-)
backend.c +18 -4
@@ -521,8 +521,13 @@ sync_done:*/ if (td->io_ops->commit ==NULL )io_u_queued (td, io_u); -if (bytes_issued) - *bytes_issued += io_u->xfer_buflen; +if (bytes_issued) { +if (io_u->ddir ==DDIR_COPY ) { + *bytes_issued += (((io_u->xfer_buflen) * td->o.bs[DDIR_COPY ]) / +sizeof (struct source_range )); + }else + *bytes_issued += io_u->xfer_buflen; + }break ;case FIO_Q_BUSY :if (!from_verify)
@@ -721,6 +726,10 @@ static void do_verify(struct thread_data *td, uint64_t verify_bytes) io_u->ddir =DDIR_READ ;populate_verify_io_u (td, io_u);break ; + }else if (io_u->ddir ==DDIR_COPY ) { + td->io_issues[DDIR_COPY ]++; +put_io_u (td, io_u); +continue ; }else {put_io_u (td, io_u);continue ;
@@ -802,6 +811,8 @@ static bool io_bytes_exceeded(struct thread_data *td, uint64_t *this_bytes) bytes = this_bytes[DDIR_WRITE ]; else if (td_read(td)) bytes = this_bytes[DDIR_READ ]; + else if (td_copy(td)) + bytes = this_bytes[DDIR_COPY ]; else bytes = this_bytes[DDIR_TRIM ];
@@ -1278,7 +1289,8 @@ int init_io_u_buffers(struct thread_data *td) td->orig_buffer_size = (unsigned long long ) max_bs * (unsigned long long ) max_units; -if (td_ioengine_flagged (td,FIO_NOIO ) || !(td_read (td) ||td_write (td))) +if (td_ioengine_flagged (td,FIO_NOIO ) || !(td_read (td) || +td_write (td) ||td_copy (td))) data_xfer =0 ;/*
@@ -1751,13 +1763,15 @@ static void *thread_main(void *data)memcpy (&td->ss.prev_time, &td->epoch,sizeof (td->epoch));if (o->ratemin[DDIR_READ ] || o->ratemin[DDIR_WRITE ] || - o->ratemin[DDIR_TRIM ]) { + o->ratemin[DDIR_TRIM ] || o->ratemin[DDIR_COPY ]) {memcpy (&td->lastrate[DDIR_READ ], &td->bw_sample_time,sizeof (td->bw_sample_time));memcpy (&td->lastrate[DDIR_WRITE ], &td->bw_sample_time,sizeof (td->bw_sample_time));memcpy (&td->lastrate[DDIR_TRIM ], &td->bw_sample_time,sizeof (td->bw_sample_time)); +memcpy (&td->lastrate[DDIR_COPY ], &td->bw_sample_time, +sizeof (td->bw_sample_time)); }memset (bytes_done,0 ,sizeof (bytes_done));
file.h +3 -0
@@ -99,6 +99,7 @@ struct fio_file {*/ uint64_t real_file_size;uint64_t file_offset; +uint64_t file_dest_offset;uint64_t io_size;/*
@@ -113,6 +114,7 @@ struct fio_file {* Track last end and last start of IO for a given data direction */ uint64_t last_pos[DDIR_RWDIR_CNT ]; +uint64_t last_pos_dest[DDIR_RWDIR_CNT ];uint64_t last_start[DDIR_RWDIR_CNT ];uint64_t first_write;
@@ -199,6 +201,7 @@ struct thread_data;extern void close_files (struct thread_data *);extern void close_and_free_files (struct thread_data *);extern uint64_t get_start_offset (struct thread_data *,struct fio_file *); +extern uint64_t get_dest_offset (struct thread_data *,struct fio_file *);extern int __must_check setup_files (struct thread_data *);extern int __must_check file_invalidate_cache (struct thread_data *,struct fio_file *);#ifdef __cplusplus
filesetup.c +61 -0
91 lines not on this page · raw message
fio.h +12 -0
@@ -70,6 +70,14 @@struct fio_sem ; +/* +* Source range data for copy command +*/ +struct source_range { +uint64_t start; +uint64_t len; +}; +/* * offset generator types */
@@ -123,6 +131,7 @@ enum {FIO_RAND_BS_OFF =0 ,FIO_RAND_BS1_OFF ,FIO_RAND_BS2_OFF , +FIO_RAND_BS3_OFF ,FIO_RAND_VER_OFF ,FIO_RAND_MIX_OFF , FIO_RAND_FILE_OFF,
@@ -133,6 +142,7 @@ enum {FIO_RAND_SEQ_RAND_READ_OFF ,FIO_RAND_SEQ_RAND_WRITE_OFF ,FIO_RAND_SEQ_RAND_TRIM_OFF , +FIO_RAND_SEQ_RAND_COPY_OFF ,FIO_RAND_START_DELAY ,FIO_DEDUPE_OFF , FIO_RAND_POISSON_OFF,
@@ -774,6 +784,7 @@ static inline unsigned long long td_max_bs(struct thread_data *td)unsigned long long max_bs; max_bs =max (td->o.max_bs[DDIR_READ ], td->o.max_bs[DDIR_WRITE ]); + max_bs =max (td->o.max_bs[DDIR_COPY ], max_bs);return max (td->o.max_bs[DDIR_TRIM ], max_bs); }
@@ -782,6 +793,7 @@ static inline unsigned long long td_min_bs(struct thread_data *td)unsigned long long min_bs; min_bs =min (td->o.min_bs[DDIR_READ ], td->o.min_bs[DDIR_WRITE ]); + min_bs =min (td->o.min_bs[DDIR_COPY ], min_bs);return min (td->o.min_bs[DDIR_TRIM ], min_bs); }
init.c +24 -15
@@ -592,8 +592,10 @@ static int fixed_block_size(struct thread_options *o)return o->min_bs[DDIR_READ ] == o->max_bs[DDIR_READ ] && o->min_bs[DDIR_WRITE ] == o->max_bs[DDIR_WRITE ] && o->min_bs[DDIR_TRIM ] == o->max_bs[DDIR_TRIM ] && + o->min_bs[DDIR_COPY ] == o->max_bs[DDIR_COPY ] && o->min_bs[DDIR_READ ] == o->min_bs[DDIR_WRITE ] && - o->min_bs[DDIR_READ ] == o->min_bs[DDIR_TRIM ]; + o->min_bs[DDIR_READ ] == o->min_bs[DDIR_TRIM ] && + o->min_bs[DDIR_READ ] == o->min_bs[DDIR_COPY ]; }/*
@@ -616,8 +618,8 @@ static int fixup_options(struct thread_data *td)struct thread_options *o = &td->o;int ret =0 ; -if (read_only && (td_write (td) ||td_trim (td))) { -log_err ("fio: trim and write operations are not allowed" +if (read_only && (td_write (td) ||td_trim (td) ||td_copy (td))) { +log_err ("fio: trim, copy and write operations are not allowed" " with the --readonly parameter.\n" ); ret |=1 ; }
@@ -670,9 +672,9 @@ static int fixup_options(struct thread_data *td) o->zone_range = o->zone_size;/* -* Reads can do overwrites, we always need to pre-create the file +* Reads and copies can do overwrites, we always need to pre-create the file */ -if (td_read (td)) +if (td_read (td) &&td_copy (td)) o->overwrite =1 ;for_each_rw_ddir (ddir) {
@@ -697,7 +699,8 @@ static int fixup_options(struct thread_data *td)if ((o->ba[DDIR_READ ] != o->min_bs[DDIR_READ ] || o->ba[DDIR_WRITE ] != o->min_bs[DDIR_WRITE ] || - o->ba[DDIR_TRIM ] != o->min_bs[DDIR_TRIM ]) && + o->ba[DDIR_TRIM ] != o->min_bs[DDIR_TRIM ] || + o->ba[DDIR_COPY ] != o->min_bs[DDIR_COPY ]) && !o->norandommap) {log_err ("fio: Any use of blockalign= turns off randommap\n" ); o->norandommap =1 ;
@@ -765,10 +768,10 @@ static int fixup_options(struct thread_data *td)if (o->open_files > o->nr_files || !o->open_files) o->open_files = o->nr_files; -if (((o->rate[DDIR_READ ] + o->rate[DDIR_WRITE ] + o->rate[DDIR_TRIM ]) && - (o->rate_iops[DDIR_READ ] + o->rate_iops[DDIR_WRITE ] + o->rate_iops[DDIR_TRIM ])) || - ((o->ratemin[DDIR_READ ] + o->ratemin[DDIR_WRITE ] + o->ratemin[DDIR_TRIM ]) && - (o->rate_iops_min[DDIR_READ ] + o->rate_iops_min[DDIR_WRITE ] + o->rate_iops_min[DDIR_TRIM ]))) { +if (((o->rate[DDIR_READ ] + o->rate[DDIR_WRITE ] + o->rate[DDIR_TRIM ] + o->rate[DDIR_COPY ]) && + (o->rate_iops[DDIR_READ ] + o->rate_iops[DDIR_WRITE ] + o->rate_iops[DDIR_TRIM ] + o->rate_iops[DDIR_COPY ])) || + ((o->ratemin[DDIR_READ ] + o->ratemin[DDIR_WRITE ] + o->ratemin[DDIR_TRIM ] + o->ratemin[DDIR_COPY ]) && + (o->rate_iops_min[DDIR_READ ] + o->rate_iops_min[DDIR_WRITE ] + o->rate_iops_min[DDIR_TRIM ] + o->rate_iops_min[DDIR_COPY ]))) {log_err ("fio: rate and rate_iops are mutually exclusive\n" ); ret |=1 ; }
@@ -1000,6 +1003,7 @@ static void td_fill_rand_seeds_internal(struct thread_data *td, bool use64)uint64_t read_seed = td->rand_seeds[FIO_RAND_BS_OFF ];uint64_t write_seed = td->rand_seeds[FIO_RAND_BS1_OFF ];uint64_t trim_seed = td->rand_seeds[FIO_RAND_BS2_OFF ]; +uint64_t copy_seed = td->rand_seeds[FIO_RAND_BS3_OFF ];int i;/*
@@ -1017,6 +1021,7 @@ static void td_fill_rand_seeds_internal(struct thread_data *td, bool use64)init_rand_seed (&td->bsrange_state[DDIR_READ ], read_seed, use64);init_rand_seed (&td->bsrange_state[DDIR_WRITE ], write_seed, use64);init_rand_seed (&td->bsrange_state[DDIR_TRIM ], trim_seed, use64); +init_rand_seed (&td->bsrange_state[DDIR_COPY ], copy_seed, use64);td_fill_verify_state_seed (td);init_rand_seed (&td->rwmix_state, td->rand_seeds[FIO_RAND_MIX_OFF ], false);
@@ -1675,7 +1680,7 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num,fio_server_send_add_job (td);if (!td_ioengine_flagged (td,FIO_NOIO )) { -char *c1, *c2, *c3, *c4; +char *c1, *c2, *c3, *c4, *c7, *c8;char *c5 =NULL , *c6 =NULL ;int i2p =is_power_of_2 (o->kb_base);struct buf_output out;
@@ -1684,6 +1689,8 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num, c2 =num2str (o->max_bs[DDIR_READ ], o->sig_figs,1 , i2p,N2S_BYTE ); c3 =num2str (o->min_bs[DDIR_WRITE ], o->sig_figs,1 , i2p,N2S_BYTE ); c4 =num2str (o->max_bs[DDIR_WRITE ], o->sig_figs,1 , i2p,N2S_BYTE ); + c7 =num2str (o->min_bs[DDIR_COPY ], o->sig_figs,1 , i2p,N2S_BYTE ); + c8 =num2str (o->max_bs[DDIR_COPY ], o->sig_figs,1 , i2p,N2S_BYTE );if (!o->bs_is_seq_rand) { c5 =num2str (o->min_bs[DDIR_TRIM ], o->sig_figs,1 , i2p,N2S_BYTE );
@@ -1696,11 +1703,11 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num, ddir_str(o->td_ddir));if (o->bs_is_seq_rand) -__log_buf (&out,"bs=(R) %s-%s, (W) %s-%s, bs_is_seq_rand, " , - c1, c2, c3, c4); +__log_buf (&out,"bs=(R) %s-%s, (W) %s-%s, (C) %s-%s, bs_is_seq_rand, " , + c1, c2, c3, c4, c7, c8);else -__log_buf (&out,"bs=(R) %s-%s, (W) %s-%s, (T) %s-%s, " , - c1, c2, c3, c4, c5, c6); +__log_buf (&out,"bs=(R) %s-%s, (W) %s-%s, (T) %s-%s, (C) %s-%s, " , + c1, c2, c3, c4, c5, c6, c7, c8);__log_buf (&out,"ioengine=%s, iodepth=%u\n" , td->io_ops->name, o->iodepth);
@@ -1713,6 +1720,8 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num,free (c4);free (c5);free (c6); +free (c7); +free (c8); } }else if (job_add_num ==1 )log_info ("...\n" );
io_u.c +85 -18
156 lines not on this page · raw message
rate-submit.c +2 -0
@@ -269,6 +269,8 @@ static void io_workqueue_update_acct_fn(struct submit_worker *sw)sum_ddir (dst, src,DDIR_WRITE );if (td_trim (src))sum_ddir (dst, src,DDIR_TRIM ); +if (td_copy (src)) +sum_ddir (dst, src,DDIR_COPY ); }
zbd.c +2 -0
@@ -1682,6 +1682,8 @@ enum io_u_action zbd_adjust_block(struct thread_data *td, struct io_u *io_u)case DDIR_LAST :case DDIR_INVAL : goto accept; +case DDIR_COPY : + goto eof; }assert (false);
Signature · 1 line
2.17.1
PATCH 6/9 New ioctl based synchronous IO engine. Only supports copy command
In reply to Krishna Kanth ReddyFrom: Ankit Kumar <[email protected]>
--- HOWTO | 4 + Makefile | 2 +- engines/sctl.c | 215 +++++++++++++++++++++++++++++++++++++++++++++++++ fio.1 | 4 + io_u.h | 3 + options.c | 5 ++ os/os-linux.h | 1 + 7 files changed, 233 insertions(+), 1 deletion(-) create mode 100644 engines/sctl.c
HOWTO +4 -0
@@ -1913,6 +1913,10 @@ I/O engine character devices. This engine supports trim operations. The sg engine includes engine specific options. + **sctl** + Synchronous ioengine. This engine only supports option ``rw=copy`` and + ``rw=randcopy`` operations. The target should be a block device file. + **null** Doesn't transfer any data, just pretends to. This is mainly used to exercise fio itself and for debugging/testing purposes.
Makefile +1 -1
@@ -189,7 +189,7 @@ endif ifeq ($(CONFIG_TARGET_OS), Linux) SOURCE += diskutil.c fifo.c blktrace.c cgroup.c trim.c engines/sg.c \ - oslib/linux-dev-lookup.c engines/io_uring.c + oslib/linux-dev-lookup.c engines/io_uring.c engines/sctl.c ifdef CONFIG_HAS_BLKZONED SOURCE += oslib/linux-blkzoned.c endif
engines/sctl.c new file +215 -0
215 lines not on this page · raw message
fio.1 +4 -0
@@ -1684,6 +1684,10 @@ I/O. Requires \fBfilename\fR option to specify either block or character devices. This engine supports trim operations. The sg engine includes engine specific options. .TP +.B sctl +Synchronous ioengine. This engine only supports `rw=copy' and +`rw=randcopy' operations. The target should be a block device file. +.TP .B libzbc Synchronous I/O engine for SMR hard-disks using the \fBlibzbc\fR library. The target can be either an sg character device or
io_u.h +3 -0
@@ -127,6 +127,9 @@ struct io_u {#endif #ifdef CONFIG_RDMA struct ibv_mr *mr; +#endif +#ifdef FIO_HAVE_SCTL +struct copy_range cr;#endif void *mmap_data; };
options.c +5 -0
@@ -1886,6 +1886,11 @@ struct fio_option fio_options[FIO_MAX_OPTS] = { { .ival = "sg", .help = "SCSI generic v3 IO", }, +#endif +#ifdef FIO_HAVE_SCTL + { .ival = "sctl", + .help = "Simple copy IO engine", + }, #endif { .ival = "null", .help = "Testing engine (no data transfer)",
os/os-linux.h +1 -0
@@ -36,6 +36,7 @@#define FIO_HAVE_CPU_AFFINITY #define FIO_HAVE_DISK_UTIL #define FIO_HAVE_SGIO +#define FIO_HAVE_SCTL #define FIO_HAVE_IOPRIO #define FIO_HAVE_IOPRIO_CLASS #define FIO_HAVE_IOSCHED_SWITCH
Signature · 1 line
2.17.1
PATCH 7/9 Example configuration for simple copy command
In reply to Krishna Kanth ReddyFrom: Ankit Kumar <[email protected]>
--- examples/fio-copy.fio | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 examples/fio-copy.fio
examples/fio-copy.fio new file +32 -0
@@ -0,0 +1,32 @@ +[global] +threads=1 +filename=fio-copy +size=128m + +[writer] +rw=write +bs=128k +numjobs=1 +offset=0 +buffer_pattern=0xdeadbeef + +[copier] +new_group +wait_for=writer +rw=copy +bs=16k +offset=0 +dest_offset=256m +num_range=8 +numjobs=1 +ioengine=sctl + +[reader] +new_group +wait_for=copier +rw=read +offset=256m +bs=128k +numjobs=1 +verify=pattern +verify_pattern=0xdeadbeef
Signature · 1 line
2.17.1
PATCH 8/9 Support copy operation for zoned block devices.
In reply to Krishna Kanth ReddyFrom: Ankit Kumar <[email protected]>
Added a check so that source and destination zones don't overlap. Source and destination offsets are aligned to zone start. The source range zone data is copied sequentially to the destination zones.
Added a function to reset the destination zones. Source zones won't be reset.
--- file.h | 4 +++ filesetup.c | 18 +++++++++++ init.c | 5 +++ io_u.c | 2 +- zbd.c | 88 ++++++++++++++++++++++++++++++++++++++++++++++++----- 5 files changed, 109 insertions(+), 8 deletions(-)
file.h +4 -0
@@ -110,6 +110,10 @@ struct fio_file {uint32_t min_zone;/* inclusive */ uint32_t max_zone;/* exclusive */ +/* zonemode=zbd copy destination working area */ +uint32_t min_dest_zone;/* inclusive */ +uint32_t max_dest_zone;/* exclusive */ +/* * Track last end and last start of IO for a given data direction */
filesetup.c +18 -0
@@ -1231,6 +1231,24 @@ int setup_files(struct thread_data *td)if (td_copy (td)) f->file_dest_offset =get_dest_offset (td, f); + +if (td_copy (td) && (td->o.zone_mode ==ZONE_MODE_ZBD )) { +if (f->file_offset > f->file_dest_offset) { +if (f->file_offset - f->file_dest_offset < f->io_size) { +log_err ("%s: For copy operation on ZBD device " +"source and destination area shouldn't overlap\n" , + o->name); + goto err_out; + } + }else { +if (f->file_dest_offset - f->file_offset < f->io_size) { +log_err ("%s: For copy operation on ZBD device " +"source and destination area shouldn't overlap\n" , + o->name); + goto err_out; + } + } + } }if (td->o.block_error_hist) {
init.c +5 -0
@@ -671,6 +671,11 @@ static int fixup_options(struct thread_data *td)if (o->zone_mode ==ZONE_MODE_STRIDED && !o->zone_range) o->zone_range = o->zone_size; +if (o->zone_mode ==ZONE_MODE_ZBD &&td_copy (td) &&td_random (td)) { +log_err ("fio: --zonemode=zbd supports copy operation only in sequential mode.\n" ); + ret |=1 ; + } +/* * Reads and copies can do overwrites, we always need to pre-create the file */
io_u.c +1 -1
@@ -1003,7 +1003,7 @@ static int fill_io_u(struct thread_data *td, struct io_u *io_u) offset = io_u->offset; } -if (td->o.zone_mode ==ZONE_MODE_ZBD ) { +if ((td->o.zone_mode ==ZONE_MODE_ZBD ) && !(td_copy (td))) { ret =zbd_adjust_block (td, io_u);if (ret == io_u_eof)return 1 ;
zbd.c +81 -7
165 lines not on this page · raw message
Signature · 1 line
2.17.1
Re: [PATCH 8/9] Support copy operation for zoned block devices.
Quoted 8 lines · Krishna Kanth Reddy
From: Ankit Kumar <[email protected]>
Added a check so that source and destination zones don't overlap. Source and destination offsets are aligned to zone start. The source range zone data is copied sequentially to the destination zones.
Added a function to reset the destination zones. Source zones won't be reset.
I do not see how this can work correctly without relying on the zone locking mechanism. Other jobs may be writing to the same zones too. That will either result in the copy failing or the writes failing due to the zone wp unexpectedly changing.
Quoted 263 lines
Signed-off-by Krishna Kanth Reddy <[email protected]>--- file.h | 4 +++ filesetup.c | 18 +++++++++++ init.c | 5 +++ io_u.c | 2 +- zbd.c | 88 ++++++++++++++++++++++++++++++++++++++++++++++++----- 5 files changed, 109 insertions(+), 8 deletions(-)file.h +4
-0@@ -110,6 +110,10 @@ struct fio_file {uint32_t min_zone;/* inclusive */ uint32_t max_zone;/* exclusive */ +/* zonemode=zbd copy destination working area */ +uint32_t min_dest_zone;/* inclusive */ +uint32_t max_dest_zone;/* exclusive */ +/* * Track last end and last start of IO for a given data direction */ filesetup.c +18
-0@@ -1231,6 +1231,24 @@ int setup_files(struct thread_data *td)if (td_copy (td)) f->file_dest_offset =get_dest_offset (td, f); + +if (td_copy (td) && (td->o.zone_mode ==ZONE_MODE_ZBD )) { +if (f->file_offset > f->file_dest_offset) { +if (f->file_offset - f->file_dest_offset < f->io_size) { +log_err ("%s: For copy operation on ZBD device " +"source and destination area shouldn't overlap\n" , + o->name); + goto err_out; + } + }else { +if (f->file_dest_offset - f->file_offset < f->io_size) { +log_err ("%s: For copy operation on ZBD device " +"source and destination area shouldn't overlap\n" , + o->name); + goto err_out; + } + } + } }if (td->o.block_error_hist) {init.c +5
-0@@ -671,6 +671,11 @@ static int fixup_options(struct thread_data *td)if (o->zone_mode ==ZONE_MODE_STRIDED && !o->zone_range) o->zone_range = o->zone_size; +if (o->zone_mode ==ZONE_MODE_ZBD &&td_copy (td) &&td_random (td)) { +log_err ("fio: --zonemode=zbd supports copy operation only in sequential mode.\n" ); + ret |=1 ; + } +/* * Reads and copies can do overwrites, we always need to pre-create the file */ io_u.c +1
-1@@ -1003,7 +1003,7 @@ static int fill_io_u(struct thread_data *td, struct io_u *io_u) offset = io_u->offset; } -if (td->o.zone_mode ==ZONE_MODE_ZBD ) { +if ((td->o.zone_mode ==ZONE_MODE_ZBD ) && !(td_copy (td))) { ret =zbd_adjust_block (td, io_u);if (ret == io_u_eof)return 1 ;zbd.c +81
-7@@ -246,11 +246,11 @@ static bool zbd_is_seq_job(struct fio_file *f)*/ static bool zbd_verify_sizes (void ) { -const struct fio_zone_info *z; +const struct fio_zone_info *z, *zd;struct thread_data *td;struct fio_file *f;uint64_t new_offset, new_end; -uint32_t zone_idx; +uint32_t zone_idx, zone_didx;int i, j;for_each_td (td, i) {@@ -259,6 +259,9 @@ static bool zbd_verify_sizes(void)continue ;if (f->file_offset >= f->real_file_size)continue ; +if ((td->o.td_ddir ==TD_DDIR_COPY ) && + (f->file_dest_offset >= f->real_file_size)) +continue ;if (!zbd_is_seq_job (f))continue ;@@ -301,6 +304,15 @@ static bool zbd_verify_sizes(void) f->io_size -= (new_offset - f->file_offset); f->file_offset = new_offset; } +if (td->o.td_ddir ==TD_DDIR_COPY ) { + zone_didx =zbd_zone_idx (f, f->file_dest_offset); + zd = &f->zbd_info->zone_info[zone_didx]; +if (f->file_dest_offset != zd->start) { + new_offset =zbd_zone_end (zd); + f->file_dest_offset = new_offset; + } + } + zone_idx =zbd_zone_idx (f, f->file_offset + f->io_size); z = &f->zbd_info->zone_info[zone_idx]; new_end = z->start;@@ -320,6 +332,12 @@ static bool zbd_verify_sizes(void) f->min_zone =zbd_zone_idx (f, f->file_offset); f->max_zone =zbd_zone_idx (f, f->file_offset + f->io_size);assert (f->min_zone < f->max_zone); + +if (td->o.td_ddir ==TD_DDIR_COPY ) { + f->min_dest_zone =zbd_zone_idx (f, f->file_dest_offset); + f->max_dest_zone =zbd_zone_idx (f, f->file_dest_offset + f->io_size); +assert (f->min_dest_zone < f->max_dest_zone); + } } }@@ -823,6 +841,42 @@ static int zbd_reset_zones(struct thread_data *td, struct fio_file *f,return res; } +/* +* Reset a range of zones. +* @td: fio thread data. +* @f: fio file for which to reset zones +*/ +static void zbd_reset_dest_zones (struct thread_data *td,struct fio_file *f) +{ +struct fio_zone_info *z, *zb, *ze; +int ret =0 ; +uint64_t offset, length; + + zb = &f->zbd_info->zone_info[f->min_dest_zone]; + ze = &f->zbd_info->zone_info[f->max_dest_zone]; + +for (z = zb; z < ze; z++) { + offset = z->start; + length = (z+1 )->start - offset; + +dprint (FD_ZBD ,"%s: resetting wp of zone %u.\n" , f->file_name, +zbd_zone_nr (f->zbd_info, z)); +switch (f->zbd_info->model) { +case ZBD_HOST_AWARE : +case ZBD_HOST_MANAGED : + ret =zbd_reset_wp (td, f, offset, length); +break ; +default : +break ; + } + +if (ret <0 ) +continue ; + + td->ts.nr_zone_resets++; + } +} +/* * Reset zbd_info.write_cnt, the counter that counts down towards the next * zone reset. @@ -924,9 +978,14 @@ void zbd_file_reset(struct thread_data *td, struct fio_file *f) {struct fio_zone_info *zb, *ze; -if (!f->zbd_info || !td_write (td)) +if (!f->zbd_info || !(td_write (td) ||td_copy (td)))return ; +if (td_copy (td)) { +zbd_reset_dest_zones (td, f); +return ; + } + zb = &f->zbd_info->zone_info[f->min_zone]; ze = &f->zbd_info->zone_info[f->max_zone];zbd_init_swd (f);@@ -1410,8 +1469,8 @@ void setup_zbd_zone_mode(struct thread_data *td, struct io_u *io_u) {struct fio_file *f = io_u->file;enum fio_ddir ddir = io_u->ddir; -struct fio_zone_info *z; -uint32_t zone_idx; +struct fio_zone_info *z, *zd; +uint32_t zone_idx, zone_didx;assert (td->o.zone_mode ==ZONE_MODE_ZBD );assert (td->o.zone_size);@@ -1419,13 +1478,18 @@ void setup_zbd_zone_mode(struct thread_data *td, struct io_u *io_u) zone_idx =zbd_zone_idx (f, f->last_pos[ddir]); z = &f->zbd_info->zone_info[zone_idx]; +if (ddir ==DDIR_COPY ) { + zone_didx =zbd_zone_idx (f, f->last_pos_dest[ddir]); + zd = &f->zbd_info->zone_info[zone_didx]; + } +/* * When the zone capacity is smaller than the zone size and the I/O is -* sequential write, skip to zone end if the latest position is at the +* sequential write or copy, skip to zone end if the latest position is at the * zone capacity limit. */ if (z->capacity < f->zbd_info->zone_size && !td_random (td) && - ddir ==DDIR_WRITE && + (ddir ==DDIR_WRITE || ddir ==DDIR_COPY ) && f->last_pos[ddir] >=zbd_zone_capacity_end (z)) {dprint (FD_ZBD , "%s: Jump from zone capacity limit to zone end:"@@ -1436,6 +1500,8 @@ void setup_zbd_zone_mode(struct thread_data *td, struct io_u *io_u) (unsigned long long) z->capacity); td->io_skip_bytes +=zbd_zone_end (z) - f->last_pos[ddir]; f->last_pos[ddir] =zbd_zone_end (z); +if (ddir ==DDIR_COPY ) + f->last_pos_dest[ddir] =zbd_zone_end (zd); }/* @@ -1461,13 +1527,21 @@ void setup_zbd_zone_mode(struct thread_data *td, struct io_u *io_u) td->zone_bytes =0 ; f->file_offset += td->o.zone_size + td->o.zone_skip; +if (ddir ==DDIR_COPY ) + f->file_dest_offset += td->o.zone_size + td->o.zone_skip;/* * Wrap from the beginning, if we exceed the file size */ if (f->file_offset >= f->real_file_size) f->file_offset =get_start_offset (td, f); +if ((ddir ==DDIR_COPY ) && f->file_dest_offset >= f->real_file_size) + f->file_dest_offset =get_dest_offset (td, f); + f->last_pos[ddir] = f->file_offset; +if (ddir ==DDIR_COPY ) + f->last_pos_dest[io_u->ddir] = f->file_dest_offset; + td->io_skip_bytes += td->o.zone_skip; } }
Signature · 2 lines
Damien Le Moal Western Digital Research
Re: [PATCH 8/9] Support copy operation for zoned block devices.
Quoted 10 lines · Damien Le Moal
Quoted 8 lines · Krishna Kanth Reddy
From: Ankit Kumar <[email protected]>
Added a check so that source and destination zones don't overlap. Source and destination offsets are aligned to zone start. The source range zone data is copied sequentially to the destination zones.
Added a function to reset the destination zones. Source zones won't be reset.
Quoted 5 lines
I do not see how this can work correctly without relying on the zone locking mechanism. Other jobs may be writing to the same zones too. That will either result in the copy failing or the writes failing due to the zone wp unexpectedly changing.
Sorry for the delay response, as I was hoping for comments for the other patches in this patchset too.
Yes, you are right. There are no locks in the current implementation.
Our initial focus is to introduce a new copy workload and get the infrastructure ready for FIO.
We will modify the existing patch to add the zone locking mechanism, so that it can be used in multi-threaded scenario. Kindly provide your valuable feedback to the other patches in this patchset too.
Quoted 269 lines
Quoted 263 lines
Signed-off-by Krishna Kanth Reddy <[email protected]>--- file.h | 4 +++ filesetup.c | 18 +++++++++++ init.c | 5 +++ io_u.c | 2 +- zbd.c | 88 ++++++++++++++++++++++++++++++++++++++++++++++++----- 5 files changed, 109 insertions(+), 8 deletions(-)file.h +4
-0@@ -110,6 +110,10 @@ struct fio_file {uint32_t min_zone;/* inclusive */ uint32_t max_zone;/* exclusive */ +/* zonemode=zbd copy destination working area */ +uint32_t min_dest_zone;/* inclusive */ +uint32_t max_dest_zone;/* exclusive */ +/* * Track last end and last start of IO for a given data direction */ filesetup.c +18
-0@@ -1231,6 +1231,24 @@ int setup_files(struct thread_data *td)if (td_copy (td)) f->file_dest_offset =get_dest_offset (td, f); + +if (td_copy (td) && (td->o.zone_mode ==ZONE_MODE_ZBD )) { +if (f->file_offset > f->file_dest_offset) { +if (f->file_offset - f->file_dest_offset < f->io_size) { +log_err ("%s: For copy operation on ZBD device " +"source and destination area shouldn't overlap\n" , + o->name); + goto err_out; + } + }else { +if (f->file_dest_offset - f->file_offset < f->io_size) { +log_err ("%s: For copy operation on ZBD device " +"source and destination area shouldn't overlap\n" , + o->name); + goto err_out; + } + } + } }if (td->o.block_error_hist) {init.c +5
-0@@ -671,6 +671,11 @@ static int fixup_options(struct thread_data *td)if (o->zone_mode ==ZONE_MODE_STRIDED && !o->zone_range) o->zone_range = o->zone_size; +if (o->zone_mode ==ZONE_MODE_ZBD &&td_copy (td) &&td_random (td)) { +log_err ("fio: --zonemode=zbd supports copy operation only in sequential mode.\n" ); + ret |=1 ; + } +/* * Reads and copies can do overwrites, we always need to pre-create the file */ io_u.c +1
-1@@ -1003,7 +1003,7 @@ static int fill_io_u(struct thread_data *td, struct io_u *io_u) offset = io_u->offset; } -if (td->o.zone_mode ==ZONE_MODE_ZBD ) { +if ((td->o.zone_mode ==ZONE_MODE_ZBD ) && !(td_copy (td))) { ret =zbd_adjust_block (td, io_u);if (ret == io_u_eof)return 1 ;zbd.c +81
-7@@ -246,11 +246,11 @@ static bool zbd_is_seq_job(struct fio_file *f)*/ static bool zbd_verify_sizes (void ) { -const struct fio_zone_info *z; +const struct fio_zone_info *z, *zd;struct thread_data *td;struct fio_file *f;uint64_t new_offset, new_end; -uint32_t zone_idx; +uint32_t zone_idx, zone_didx;int i, j;for_each_td (td, i) {@@ -259,6 +259,9 @@ static bool zbd_verify_sizes(void)continue ;if (f->file_offset >= f->real_file_size)continue ; +if ((td->o.td_ddir ==TD_DDIR_COPY ) && + (f->file_dest_offset >= f->real_file_size)) +continue ;if (!zbd_is_seq_job (f))continue ;@@ -301,6 +304,15 @@ static bool zbd_verify_sizes(void) f->io_size -= (new_offset - f->file_offset); f->file_offset = new_offset; } +if (td->o.td_ddir ==TD_DDIR_COPY ) { + zone_didx =zbd_zone_idx (f, f->file_dest_offset); + zd = &f->zbd_info->zone_info[zone_didx]; +if (f->file_dest_offset != zd->start) { + new_offset =zbd_zone_end (zd); + f->file_dest_offset = new_offset; + } + } + zone_idx =zbd_zone_idx (f, f->file_offset + f->io_size); z = &f->zbd_info->zone_info[zone_idx]; new_end = z->start;@@ -320,6 +332,12 @@ static bool zbd_verify_sizes(void) f->min_zone =zbd_zone_idx (f, f->file_offset); f->max_zone =zbd_zone_idx (f, f->file_offset + f->io_size);assert (f->min_zone < f->max_zone); + +if (td->o.td_ddir ==TD_DDIR_COPY ) { + f->min_dest_zone =zbd_zone_idx (f, f->file_dest_offset); + f->max_dest_zone =zbd_zone_idx (f, f->file_dest_offset + f->io_size); +assert (f->min_dest_zone < f->max_dest_zone); + } } }@@ -823,6 +841,42 @@ static int zbd_reset_zones(struct thread_data *td, struct fio_file *f,return res; } +/* +* Reset a range of zones. +* @td: fio thread data. +* @f: fio file for which to reset zones +*/ +static void zbd_reset_dest_zones (struct thread_data *td,struct fio_file *f) +{ +struct fio_zone_info *z, *zb, *ze; +int ret =0 ; +uint64_t offset, length; + + zb = &f->zbd_info->zone_info[f->min_dest_zone]; + ze = &f->zbd_info->zone_info[f->max_dest_zone]; + +for (z = zb; z < ze; z++) { + offset = z->start; + length = (z+1 )->start - offset; + +dprint (FD_ZBD ,"%s: resetting wp of zone %u.\n" , f->file_name, +zbd_zone_nr (f->zbd_info, z)); +switch (f->zbd_info->model) { +case ZBD_HOST_AWARE : +case ZBD_HOST_MANAGED : + ret =zbd_reset_wp (td, f, offset, length); +break ; +default : +break ; + } + +if (ret <0 ) +continue ; + + td->ts.nr_zone_resets++; + } +} +/* * Reset zbd_info.write_cnt, the counter that counts down towards the next * zone reset. @@ -924,9 +978,14 @@ void zbd_file_reset(struct thread_data *td, struct fio_file *f) {struct fio_zone_info *zb, *ze; -if (!f->zbd_info || !td_write (td)) +if (!f->zbd_info || !(td_write (td) ||td_copy (td)))return ; +if (td_copy (td)) { +zbd_reset_dest_zones (td, f); +return ; + } + zb = &f->zbd_info->zone_info[f->min_zone]; ze = &f->zbd_info->zone_info[f->max_zone];zbd_init_swd (f);@@ -1410,8 +1469,8 @@ void setup_zbd_zone_mode(struct thread_data *td, struct io_u *io_u) {struct fio_file *f = io_u->file;enum fio_ddir ddir = io_u->ddir; -struct fio_zone_info *z; -uint32_t zone_idx; +struct fio_zone_info *z, *zd; +uint32_t zone_idx, zone_didx;assert (td->o.zone_mode ==ZONE_MODE_ZBD );assert (td->o.zone_size);@@ -1419,13 +1478,18 @@ void setup_zbd_zone_mode(struct thread_data *td, struct io_u *io_u) zone_idx =zbd_zone_idx (f, f->last_pos[ddir]); z = &f->zbd_info->zone_info[zone_idx]; +if (ddir ==DDIR_COPY ) { + zone_didx =zbd_zone_idx (f, f->last_pos_dest[ddir]); + zd = &f->zbd_info->zone_info[zone_didx]; + } +/* * When the zone capacity is smaller than the zone size and the I/O is -* sequential write, skip to zone end if the latest position is at the +* sequential write or copy, skip to zone end if the latest position is at the * zone capacity limit. */ if (z->capacity < f->zbd_info->zone_size && !td_random (td) && - ddir ==DDIR_WRITE && + (ddir ==DDIR_WRITE || ddir ==DDIR_COPY ) && f->last_pos[ddir] >=zbd_zone_capacity_end (z)) {dprint (FD_ZBD , "%s: Jump from zone capacity limit to zone end:"@@ -1436,6 +1500,8 @@ void setup_zbd_zone_mode(struct thread_data *td, struct io_u *io_u) (unsigned long long) z->capacity); td->io_skip_bytes +=zbd_zone_end (z) - f->last_pos[ddir]; f->last_pos[ddir] =zbd_zone_end (z); +if (ddir ==DDIR_COPY ) + f->last_pos_dest[ddir] =zbd_zone_end (zd); }/* @@ -1461,13 +1527,21 @@ void setup_zbd_zone_mode(struct thread_data *td, struct io_u *io_u) td->zone_bytes =0 ; f->file_offset += td->o.zone_size + td->o.zone_skip; +if (ddir ==DDIR_COPY ) + f->file_dest_offset += td->o.zone_size + td->o.zone_skip;/* * Wrap from the beginning, if we exceed the file size */ if (f->file_offset >= f->real_file_size) f->file_offset =get_start_offset (td, f); +if ((ddir ==DDIR_COPY ) && f->file_dest_offset >= f->real_file_size) + f->file_dest_offset =get_dest_offset (td, f); + f->last_pos[ddir] = f->file_offset; +if (ddir ==DDIR_COPY ) + f->last_pos_dest[io_u->ddir] = f->file_dest_offset; + td->io_skip_bytes += td->o.zone_skip; } }Signature · 2 lines
Damien Le Moal Western Digital Research
Re: [PATCH 8/9] Support copy operation for zoned block devices.
Quoted 16 lines · Krishna Kanth Reddy
Quoted 10 lines · Damien Le Moal
Quoted 8 lines · Krishna Kanth Reddy
From: Ankit Kumar <[email protected]>
Added a check so that source and destination zones don't overlap. Source and destination offsets are aligned to zone start. The source range zone data is copied sequentially to the destination zones.
Added a function to reset the destination zones. Source zones won't be reset.Quoted 5 lines
I do not see how this can work correctly without relying on the zone locking mechanism. Other jobs may be writing to the same zones too. That will either result in the copy failing or the writes failing due to the zone wp unexpectedly changing.
Quoted 7 lines
Sorry for the delay response, as I was hoping for comments for the other patches in this patchset too.
Yes, you are right. There are no locks in the current implementation.
Our initial focus is to introduce a new copy workload and get the infrastructure ready for FIO.We will modify the existing patch to add the zone locking mechanism, so that it can be used in multi-threaded scenario. Kindly provide your valuable feedback to the other patches in this patchset too.
I find it very difficult to review something that does not yet have a stable well defined kernel interface. So I prefer to first wait for more progress with the block copy implementation on the kernel side. Reviewing fio patches will then make more sense.
Quoted 270 lines
Quoted 270 lines
Quoted 264 lines
Signed-off-by Krishna Kanth Reddy <[email protected]>--- file.h | 4 +++ filesetup.c | 18 +++++++++++ init.c | 5 +++ io_u.c | 2 +- zbd.c | 88 ++++++++++++++++++++++++++++++++++++++++++++++++----- 5 files changed, 109 insertions(+), 8 deletions(-)file.h +4
-0@@ -110,6 +110,10 @@ struct fio_file {uint32_t min_zone;/* inclusive */ uint32_t max_zone;/* exclusive */ +/* zonemode=zbd copy destination working area */ +uint32_t min_dest_zone;/* inclusive */ +uint32_t max_dest_zone;/* exclusive */ +/* * Track last end and last start of IO for a given data direction */ filesetup.c +18
-0@@ -1231,6 +1231,24 @@ int setup_files(struct thread_data *td)if (td_copy (td)) f->file_dest_offset =get_dest_offset (td, f); + +if (td_copy (td) && (td->o.zone_mode ==ZONE_MODE_ZBD )) { +if (f->file_offset > f->file_dest_offset) { +if (f->file_offset - f->file_dest_offset < f->io_size) { +log_err ("%s: For copy operation on ZBD device " +"source and destination area shouldn't overlap\n" , + o->name); + goto err_out; + } + }else { +if (f->file_dest_offset - f->file_offset < f->io_size) { +log_err ("%s: For copy operation on ZBD device " +"source and destination area shouldn't overlap\n" , + o->name); + goto err_out; + } + } + } }if (td->o.block_error_hist) {init.c +5
-0@@ -671,6 +671,11 @@ static int fixup_options(struct thread_data *td)if (o->zone_mode ==ZONE_MODE_STRIDED && !o->zone_range) o->zone_range = o->zone_size; +if (o->zone_mode ==ZONE_MODE_ZBD &&td_copy (td) &&td_random (td)) { +log_err ("fio: --zonemode=zbd supports copy operation only in sequential mode.\n" ); + ret |=1 ; + } +/* * Reads and copies can do overwrites, we always need to pre-create the file */ io_u.c +1
-1@@ -1003,7 +1003,7 @@ static int fill_io_u(struct thread_data *td, struct io_u *io_u) offset = io_u->offset; } -if (td->o.zone_mode ==ZONE_MODE_ZBD ) { +if ((td->o.zone_mode ==ZONE_MODE_ZBD ) && !(td_copy (td))) { ret =zbd_adjust_block (td, io_u);if (ret == io_u_eof)return 1 ;zbd.c +81
-7@@ -246,11 +246,11 @@ static bool zbd_is_seq_job(struct fio_file *f)*/ static bool zbd_verify_sizes (void ) { -const struct fio_zone_info *z; +const struct fio_zone_info *z, *zd;struct thread_data *td;struct fio_file *f;uint64_t new_offset, new_end; -uint32_t zone_idx; +uint32_t zone_idx, zone_didx;int i, j;for_each_td (td, i) {@@ -259,6 +259,9 @@ static bool zbd_verify_sizes(void)continue ;if (f->file_offset >= f->real_file_size)continue ; +if ((td->o.td_ddir ==TD_DDIR_COPY ) && + (f->file_dest_offset >= f->real_file_size)) +continue ;if (!zbd_is_seq_job (f))continue ;@@ -301,6 +304,15 @@ static bool zbd_verify_sizes(void) f->io_size -= (new_offset - f->file_offset); f->file_offset = new_offset; } +if (td->o.td_ddir ==TD_DDIR_COPY ) { + zone_didx =zbd_zone_idx (f, f->file_dest_offset); + zd = &f->zbd_info->zone_info[zone_didx]; +if (f->file_dest_offset != zd->start) { + new_offset =zbd_zone_end (zd); + f->file_dest_offset = new_offset; + } + } + zone_idx =zbd_zone_idx (f, f->file_offset + f->io_size); z = &f->zbd_info->zone_info[zone_idx]; new_end = z->start;@@ -320,6 +332,12 @@ static bool zbd_verify_sizes(void) f->min_zone =zbd_zone_idx (f, f->file_offset); f->max_zone =zbd_zone_idx (f, f->file_offset + f->io_size);assert (f->min_zone < f->max_zone); + +if (td->o.td_ddir ==TD_DDIR_COPY ) { + f->min_dest_zone =zbd_zone_idx (f, f->file_dest_offset); + f->max_dest_zone =zbd_zone_idx (f, f->file_dest_offset + f->io_size); +assert (f->min_dest_zone < f->max_dest_zone); + } } }@@ -823,6 +841,42 @@ static int zbd_reset_zones(struct thread_data *td, struct fio_file *f,return res; } +/* +* Reset a range of zones. +* @td: fio thread data. +* @f: fio file for which to reset zones +*/ +static void zbd_reset_dest_zones (struct thread_data *td,struct fio_file *f) +{ +struct fio_zone_info *z, *zb, *ze; +int ret =0 ; +uint64_t offset, length; + + zb = &f->zbd_info->zone_info[f->min_dest_zone]; + ze = &f->zbd_info->zone_info[f->max_dest_zone]; + +for (z = zb; z < ze; z++) { + offset = z->start; + length = (z+1 )->start - offset; + +dprint (FD_ZBD ,"%s: resetting wp of zone %u.\n" , f->file_name, +zbd_zone_nr (f->zbd_info, z)); +switch (f->zbd_info->model) { +case ZBD_HOST_AWARE : +case ZBD_HOST_MANAGED : + ret =zbd_reset_wp (td, f, offset, length); +break ; +default : +break ; + } + +if (ret <0 ) +continue ; + + td->ts.nr_zone_resets++; + } +} +/* * Reset zbd_info.write_cnt, the counter that counts down towards the next * zone reset. @@ -924,9 +978,14 @@ void zbd_file_reset(struct thread_data *td, struct fio_file *f) {struct fio_zone_info *zb, *ze; -if (!f->zbd_info || !td_write (td)) +if (!f->zbd_info || !(td_write (td) ||td_copy (td)))return ; +if (td_copy (td)) { +zbd_reset_dest_zones (td, f); +return ; + } + zb = &f->zbd_info->zone_info[f->min_zone]; ze = &f->zbd_info->zone_info[f->max_zone];zbd_init_swd (f);@@ -1410,8 +1469,8 @@ void setup_zbd_zone_mode(struct thread_data *td, struct io_u *io_u) {struct fio_file *f = io_u->file;enum fio_ddir ddir = io_u->ddir; -struct fio_zone_info *z; -uint32_t zone_idx; +struct fio_zone_info *z, *zd; +uint32_t zone_idx, zone_didx;assert (td->o.zone_mode ==ZONE_MODE_ZBD );assert (td->o.zone_size);@@ -1419,13 +1478,18 @@ void setup_zbd_zone_mode(struct thread_data *td, struct io_u *io_u) zone_idx =zbd_zone_idx (f, f->last_pos[ddir]); z = &f->zbd_info->zone_info[zone_idx]; +if (ddir ==DDIR_COPY ) { + zone_didx =zbd_zone_idx (f, f->last_pos_dest[ddir]); + zd = &f->zbd_info->zone_info[zone_didx]; + } +/* * When the zone capacity is smaller than the zone size and the I/O is -* sequential write, skip to zone end if the latest position is at the +* sequential write or copy, skip to zone end if the latest position is at the * zone capacity limit. */ if (z->capacity < f->zbd_info->zone_size && !td_random (td) && - ddir ==DDIR_WRITE && + (ddir ==DDIR_WRITE || ddir ==DDIR_COPY ) && f->last_pos[ddir] >=zbd_zone_capacity_end (z)) {dprint (FD_ZBD , "%s: Jump from zone capacity limit to zone end:"@@ -1436,6 +1500,8 @@ void setup_zbd_zone_mode(struct thread_data *td, struct io_u *io_u) (unsigned long long) z->capacity); td->io_skip_bytes +=zbd_zone_end (z) - f->last_pos[ddir]; f->last_pos[ddir] =zbd_zone_end (z); +if (ddir ==DDIR_COPY ) + f->last_pos_dest[ddir] =zbd_zone_end (zd); }/* @@ -1461,13 +1527,21 @@ void setup_zbd_zone_mode(struct thread_data *td, struct io_u *io_u) td->zone_bytes =0 ; f->file_offset += td->o.zone_size + td->o.zone_skip; +if (ddir ==DDIR_COPY ) + f->file_dest_offset += td->o.zone_size + td->o.zone_skip;/* * Wrap from the beginning, if we exceed the file size */ if (f->file_offset >= f->real_file_size) f->file_offset =get_start_offset (td, f); +if ((ddir ==DDIR_COPY ) && f->file_dest_offset >= f->real_file_size) + f->file_dest_offset =get_dest_offset (td, f); + f->last_pos[ddir] = f->file_offset; +if (ddir ==DDIR_COPY ) + f->last_pos_dest[io_u->ddir] = f->file_dest_offset; + td->io_skip_bytes += td->o.zone_skip; } }Signature · 2 lines
Damien Le Moal Western Digital Research
Signature · 2 lines
Damien Le Moal Western Digital Research
PATCH 9/9 Add a new test case to test the copy operation.
In reply to Krishna Kanth ReddyFrom: Ankit Kumar <[email protected]>
--- t/zbd/functions | 9 +++++++ t/zbd/test-zbd-support | 54 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+)
t/zbd/functions +9 -0
@@ -26,6 +26,15 @@ blkzone_reports_capacity() { "${blkzone}" report -c 1 -o 0 "${dev}" | grep -q 'cap ' } +# Check whether or not $1 (/dev/...) supports copy operation +check_copy_support() { + local copy_support + + copy_support=$(<"/sys/block/$(basename "${1}")/queue/max_copy_sectors") + + [[ "$copy_support" -gt 0 ]] +} + # Whether or not $1 (/dev/...) is a NVME ZNS device. is_nvme_zns() { local s
t/zbd/test-zbd-support +54 -0
60 lines not on this page · raw message
Signature · 1 line
2.17.1