Add support of formats for the pattern input
Subsystems (2)
cover Add support of formats for the pattern input
Hello, all.
The intention of this patchset is to support dynamic formats for pattern input which is used for writing and verifying data, e.g. in the latest patch I added '%o' format, which means that current block offset will be written to the buffer and then verified back, i.e. this option can be used as the following:
verify_pattern=%o
and the hexdump of generated file in my case is (few last lines):
...
000f5c00 00 5c 0f 00 00 00 00 00 00 5c 0f 00 00 00 00 00 |.\.......\......| *
000fdc00 00 dc 0f 00 00 00 00 00 00 dc 0f 00 00 00 00 00 |................| *
000ffc00 00 fc 0f 00 00 00 00 00 00 fc 0f 00 00 00 00 00 |................| *
00100000
So, each block is filled in with block offset in little endian order and 8 bytes long.
Unfortunately, 'buffer_pattern' option does not support formats, because it turned out to be a lot of changes which should be made to pass correct io_u->offset through the whole stack of calls. I left this task for future.
Additionally, I moved all 'pattern' parsing/substituting logic to separate library file 'lib/pattern.[ch]'. Also, now 'verify_pattern' and 'buffer_pattern' support combined input which can consist of strings, numbers and formats (as was said formats are supported only by 'verify_pattern' option), e.g. let's consider the following example, where 'in' is a 'verify_pattern' or 'buffer_pattern' and 'out' is an output buffer filled in with bytes regarding specified pattern:
#1 #2 #3 #4
in="abcd" in=-1024 in=66 in=0xFF0X1
out=61 62 63 64 out=00 fc ff ff out=42 out=ff 01
#5 #6
in=%o in="123"0xFFeeCC
out=00 00 00 00 00 00 00 00 out=31 32 33 ff ec cc
#7
in=-100xab"1"%o"2"
out=f6 ff ff ff ab 31 00 00 00 00 00 00 00 00 32#8
in=%o0xdeadbeef%o
out=00 00 00 00 00 00 00 00 de ad be ef 00 00 00 00 00 00 00 00
#9
in=0xfefefefefefefefefefefefefefefefefefefefefe
out=fe fe fe fe fe fe fe fe fe fe fe fe fe fe fe fe fe fe fe fe fe
For %o format 8 bytes reserved in pattern, and when buffer is ready substitution occurs.
The old behaviour is preserved: strings are in quotes, decimals are in the range [INT_MIN, INT_MAX], hexidecimals start from 0[Xx] and can be of any size (the limit is the maximum size of the pattern, which is 512).
New behaviour: now you can combine everything together and additionally use formats (now %o is supported).
--
Roman
Roman Pen (6):
lib/strntol: add 'strntol' function
lib/pattern: add set of functions to parse combined pattern input replace 'fill_pattern' with 'cpy_pattern' from 'lib/pattern.c'
verify: use 'cmp_pattern' from 'lib/pattern.c' to compare pattern and
buffer
add FIELD_SIZE macro to calculate the size of the specified field use 'lib/pattern' to parse patterns and paste formats into buffers
HOWTO | 20 ++- Makefile | 9 +- fio.h | 3 +- lib/pattern.c | 464 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ lib/pattern.h | 47 ++++++ lib/rand.c | 31 +--- lib/rand.h | 1 - lib/strntol.c | 31 ++++ lib/strntol.h | 6 + options.c | 166 ++++---------------- thread_options.h | 3 + verify.c | 62 +++++--- verify.h | 5 + 13 files changed, 656 insertions(+), 192 deletions(-) create mode 100644 lib/pattern.c create mode 100644 lib/pattern.h create mode 100644 lib/strntol.c create mode 100644 lib/strntol.h
Signature · 1 line
2.4.4
RFC 1/6 lib/strntol: add 'strntol' function
In future patches I will need it.
--- Makefile | 2 +- lib/strntol.c | 31 +++++++++++++++++++++++++++++++ lib/strntol.h | 6 ++++++ 3 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 lib/strntol.c create mode 100644 lib/strntol.h
Makefile +1 -1
@@ -39,7 +39,7 @@ endif SOURCE := gettime.c ioengines.c init.c stat.c log.c time.c filesetup.c \ eta.c verify.c memory.c io_u.c parse.c mutex.c options.c \ lib/rbtree.c smalloc.c filehash.c profile.c debug.c lib/rand.c \ - lib/num2str.c lib/ieee754.c engines/cpu.c \ + lib/num2str.c lib/ieee754.c lib/strntol.c engines/cpu.c \ engines/mmap.c engines/sync.c engines/null.c engines/net.c \ memalign.c server.c client.c iolog.c backend.c libfio.c flow.c \ cconv.c lib/prio_tree.c json.c lib/zipf.c lib/axmap.c \
lib/strntol.c new file +31 -0
@@ -0,0 +1,31 @@ +#include <string.h> +#include <stdlib.h> +#include <limits.h> + +long strntol (const char *str,size_t sz,char **end,int base) +{ +/* Expect that digit representation of LONG_MAX/MIN +* not greater than this buffer */ +char buf[24 ]; +long ret; +const char *beg = str; + +/* Catch up leading spaces */ +for (; beg && sz && *beg ==' ' ; beg++, sz--) + ; + +if (!sz || sz >=sizeof (buf)) { +if (end) + *end = (char *)str; +return 0 ; + } + +memcpy (buf, beg, sz); + buf[sz] ='\0' ; + ret =strtol (buf, end, base); +if (ret ==LONG_MIN || ret ==LONG_MAX ) +return ret; +if (end) + *end = (char *)str + (*end - buf); +return ret; +}
lib/strntol.h new file +6 -0
@@ -0,0 +1,6 @@ +#ifndef FIO_STRNTOL_H +#define FIO_STRNTOL_H + +long strntol (const char *str,size_t sz,char **end,int base); + +#endif
Signature · 1 line
2.4.4
RFC 2/6 lib/pattern: add set of functions to parse combined pattern input
In reply to Roman PenThe idea of this patch is to have several helpers to parse combined pattern input, which can consists of strings, numbers and formats.
For example now pattern can be combined and look like this string:
input : 0xdeadbeef"123"0xdeadface
output: de ad be ef 31 32 33 de ad fa ce
or
input : -99"some string"0x66
output: 9d ff ff ff 73 6f 6d 65 20 73 74 72 69 6e 67 66
or with formats
input : 0xdeadface0xffff%o
output: de ad fa ce ff ff 00 00 00 00 00 00 00 00
where %o - offset of the block, reserved 8 bytes
Space for formats is reserved in output buffer.
When buffer will be ready to be written to disk - 'paste' callback should be called for each pattern format. Each callback is responsible for writing data inside the reserved space in the output buffer.
Format array can be extended at any time, all you need is to provide the name of the format and correct 'paste' callback.
--- Makefile | 4 +- lib/pattern.c | 464 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ lib/pattern.h | 47 ++++++ 3 files changed, 513 insertions(+), 2 deletions(-) create mode 100644 lib/pattern.c create mode 100644 lib/pattern.h
Makefile +2 -2
@@ -42,8 +42,8 @@ SOURCE := gettime.c ioengines.c init.c stat.c log.c time.c filesetup.c \ lib/num2str.c lib/ieee754.c lib/strntol.c engines/cpu.c \ engines/mmap.c engines/sync.c engines/null.c engines/net.c \ memalign.c server.c client.c iolog.c backend.c libfio.c flow.c \ - cconv.c lib/prio_tree.c json.c lib/zipf.c lib/axmap.c \ - lib/lfsr.c gettime-thread.c helpers.c lib/flist_sort.c \ + cconv.c lib/prio_tree.c lib/zipf.c lib/axmap.c lib/pattern.c \ + lib/lfsr.c gettime-thread.c helpers.c lib/flist_sort.c json.c \ lib/hweight.c lib/getrusage.c idletime.c td_error.c \ profiles/tiobench.c profiles/act.c io_u_queue.c filelock.c \ lib/tp.c lib/bloom.c lib/gauss.c lib/mountcheck.c workqueue.c \
lib/pattern.c new file +464 -0
464 lines not on this page · raw message
lib/pattern.h new file +47 -0
47 lines not on this page · raw message
Signature · 1 line
2.4.4
RFC 3/6 replace 'fill_pattern' with 'cpy_pattern' from 'lib/pattern.c'
In reply to Roman PenAll pattern helpers are now located inside 'lib/pattern.c', and 'cpy_pattern' should be sligtly faster, since it does copy doubling the size on every iteration.
--- Makefile | 3 ++- lib/rand.c | 31 +++---------------------------- lib/rand.h | 1 - verify.c | 5 +++-- 4 files changed, 8 insertions(+), 32 deletions(-)
Makefile +2 -1
@@ -198,7 +198,8 @@ T_IEEE_OBJS += lib/ieee754.o T_IEEE_PROGS = t/ieee754 T_ZIPF_OBS = t/genzipf.o -T_ZIPF_OBJS += t/log.o lib/ieee754.o lib/rand.o lib/zipf.o lib/gauss.o t/genzipf.o +T_ZIPF_OBJS += t/log.o lib/ieee754.o lib/rand.o lib/pattern.o lib/zipf.o \ + lib/strntol.o lib/gauss.o t/genzipf.o T_ZIPF_PROGS = t/fio-genzipf T_AXMAP_OBJS = t/axmap.o
lib/rand.c +3 -28
@@ -36,6 +36,7 @@#include <string.h> #include <assert.h> #include "rand.h" +#include "lib/pattern.h" #include "../hash.h" int arch_random;
@@ -134,32 +135,6 @@ unsigned long fill_random_buf(struct frand_state *fs, void *buf,return r; } -void fill_pattern (void *p,unsigned int len,char *pattern, -unsigned int pattern_bytes) -{ -switch (pattern_bytes) { -case 0 : -assert (0 ); -break ; -case 1 : -memset (p, pattern[0 ], len); -break ; -default : { -unsigned int i =0 , size =0 ; -unsigned char *b = p; - -while (i < len) { - size = pattern_bytes; -if (size > (len - i)) - size = len - i; -memcpy (b+i, pattern, size); - i += size; - } -break ; - } - } -} - void __fill_random_buf_percentage(unsigned long seed, void *buf, unsigned int percentage, unsigned int segment, unsigned int len,
@@ -169,7 +144,7 @@ void __fill_random_buf_percentage(unsigned long seed, void *buf,if (percentage ==100 ) {if (pbytes) -fill_pattern (buf, len, pattern, pbytes); + (void )cpy_pattern (pattern, pbytes, buf, len);else memset (buf,0 , len);return ;
@@ -199,7 +174,7 @@ void __fill_random_buf_percentage(unsigned long seed, void *buf, this_len = len;if (pbytes) -fill_pattern (buf, this_len, pattern, pbytes); + (void )cpy_pattern (pattern, pbytes, buf, this_len);else memset (buf,0 , this_len);
lib/rand.h +0 -1
@@ -110,6 +110,5 @@ extern void __fill_random_buf(void *buf, unsigned int len, unsigned long seed);extern unsigned long fill_random_buf (struct frand_state *,void *buf,unsigned int len);extern void __fill_random_buf_percentage (unsigned long ,void *,unsigned int ,unsigned int ,unsigned int ,char *,unsigned int );extern unsigned long fill_random_buf_percentage (struct frand_state *,void *,unsigned int ,unsigned int ,unsigned int ,char *,unsigned int ); -extern void fill_pattern (void *p,unsigned int len,char *pattern,unsigned int pattern_bytes);#endif
verify.c +3 -2
@@ -13,6 +13,7 @@#include "trim.h" #include "lib/rand.h" #include "lib/hweight.h" +#include "lib/pattern.h" #include "crc/md5.h" #include "crc/crc64.h"
@@ -35,7 +36,7 @@ static void __fill_hdr(struct verify_header *hdr, int verify_type, uint32_t len,void fill_buffer_pattern (struct thread_data *td,void *p,unsigned int len) { -fill_pattern (p, len, td->o.buffer_pattern, td->o.buffer_pattern_bytes); + (void )cpy_pattern (td->o.buffer_pattern, td->o.buffer_pattern_bytes, p, len); } void __fill_buffer(struct thread_options *o, unsigned long seed, void *p,
@@ -73,7 +74,7 @@ void fill_verify_pattern(struct thread_data *td, void *p, unsigned int len,return ; } -fill_pattern (p, len, o->verify_pattern, o->verify_pattern_bytes); + (void )cpy_pattern (td->o.verify_pattern, td->o.verify_pattern_bytes, p, len); io_u->buf_filled_len = len; }
Signature · 1 line
2.4.4
RFC 4/6 verify: use 'cmp_pattern' from 'lib/pattern.c' to compare pattern and buffer
In reply to Roman Pen'cmp_pattern' function should be faster, since it does not use loops and while doing 'memcmp' the same CPU cache line is used.
Keep in mind, that now single-byte pattern becomes the string of 512 bytes. In that case this optimization will not work as expected, since 'memcmp' will be called twice for the whole pattern, but in next patches this behaviour will be avoided and single-byte pattern will stay single-byte pattern without any attempt to duplicate it.
Also print buffer and pattern bytes as unsigned chars.
--- verify.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-)
verify.c +14 -14
@@ -356,7 +356,8 @@ static int verify_io_u_pattern(struct verify_header *hdr, struct vcont *vc)struct io_u *io_u = vc->io_u;char *buf, *pattern;unsigned int header_size =__hdr_size (td->o.verify); -unsigned int len, mod, i, size, pattern_size; +unsigned int len, mod, i, pattern_size; +int rc; pattern = td->o.verify_pattern; pattern_size = td->o.verify_pattern_bytes;
@@ -366,23 +367,20 @@ static int verify_io_u_pattern(struct verify_header *hdr, struct vcont *vc) len =get_hdr_inc (td, io_u) - header_size; mod = header_size % pattern_size; -for (i =0 ; i < len; i += size) { - size = pattern_size - mod; -if (size > (len - i)) - size = len - i; -if (memcmp (buf + i, pattern + mod, size)) -/* Let the slow compare find the first mismatch byte. */ -break ; - mod =0 ; - } + rc =cmp_pattern (pattern, pattern_size, mod, buf, len); +if (!rc) +return 0 ; -for (; i < len; i++) { +/* Slow path, compare each byte */ +for (i =0 ; i < len; i++) {if (buf[i] != pattern[mod]) {unsigned int bits; bits =hweight8 (buf[i] ^ pattern[mod]); -log_err ("fio: got pattern %x, wanted %x. Bad bits %d\n" , - buf[i], pattern[mod], bits); +log_err ("fio: got pattern '%02x', wanted '%02x'. Bad bits %d\n" , + (unsigned char )buf[i], + (unsigned char )pattern[mod], + bits);log_err ("fio: bad pattern block offset %u\n" , i);dump_verify_buffers (hdr, vc);return EILSEQ ;
@@ -392,7 +390,9 @@ static int verify_io_u_pattern(struct verify_header *hdr, struct vcont *vc) mod =0 ; } -return 0 ; +/* Unreachable line */ +assert (0 ); +return EILSEQ ; }static int verify_io_u_meta (struct verify_header *hdr,struct vcont *vc)
Signature · 1 line
2.4.4
RFC 5/6 add FIELD_SIZE macro to calculate the size of the specified field
In reply to Roman PenWill use this stuff later.
--- fio.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fio.h +2 -1
@@ -667,7 +667,8 @@ extern const char *fio_get_arch_string(int);extern const char *fio_get_os_string (int );#ifdef FIO_INTERNAL -#define ARRAY_SIZE (x) (sizeof((x)) / (sizeof((x)[0]))) +#define ARRAY_SIZE (x) (sizeof((x)) / (sizeof((x)[0]))) +#define FIELD_SIZE (s, f) (sizeof(((typeof(s))0)->f))#endif enum {
Signature · 1 line
2.4.4
RFC 6/6 use 'lib/pattern' to parse patterns and paste formats into buffers
In reply to Roman PenSwitch to new 'lib/pattern' helpers.
Now 'buffer_pattern' and 'verify_pattern' options support combined input and strings like:
buffer_pattern="1234"0xface"5678"
verify_pattern=0xface"1234"-12+14
can be specified.
Also, 'verify_pattern' supports '%o' format, which means that buffer will be patched on each iteration with real 'block offset' number.
So, f.e. 'verify_pattern' such combined input is valid:
verify_pattern=%o
or
verify_pattern=%o"123"%o
--- HOWTO | 20 ++++++- options.c | 166 +++++++++++-------------------------------------------- thread_options.h | 3 + verify.c | 29 ++++++++-- verify.h | 5 ++ 5 files changed, 81 insertions(+), 142 deletions(-)
HOWTO +18 -2
@@ -623,7 +623,16 @@ buffer_pattern=str If set, fio will fill the io buffers with this the other options related to buffer contents. The setting can be any pattern of bytes, and can be prefixed with 0x for hex values. It may also be a string, where the string must then - be wrapped with "". + be wrapped with "", e.g.: + + buffer_pattern="abcd" + or + buffer_pattern=-12 + or + buffer_pattern=0xdeadface + + Also you can combine everything together in any order: + buffer_pattern=0xdeadface"abcd"-12 dedupe_percentage=int If set, fio will generate this percentage of identical buffers when writing. These buffers will be
@@ -1324,7 +1333,14 @@ verify_pattern=str If set, fio will fill the io buffers with this buffer at the time(it can be either a decimal or a hex number). The verify_pattern if larger than a 32-bit quantity has to be a hex number that starts with either "0x" or "0X". Use - with verify=meta. + with verify=meta. Also, verify_pattern supports %o format, + which means that for each block offset will be written and + then verifyied back, e.g.: + + verify_pattern=%o + + Or use combination of everything: + verify_pattern=0xff%o"abcd"-12 verify_fatal=bool Normally fio will keep checking the entire contents before quitting on a block verification failure. If this
options.c +31 -135
209 lines not on this page · raw message
thread_options.h +3 -0
@@ -7,6 +7,7 @@#include "stat.h" #include "gettime.h" #include "lib/ieee754.h" +#include "lib/pattern.h" #include "td_error.h" /*
@@ -97,6 +98,8 @@ struct thread_options {unsigned int verify_offset;char verify_pattern[MAX_PATTERN_SIZE ];unsigned int verify_pattern_bytes; +struct pattern_fmt verify_fmt[8 ]; +unsigned int verify_fmt_sz;unsigned int verify_fatal;unsigned int verify_dump;unsigned int verify_async;
verify.c +24 -5
@@ -68,13 +68,17 @@ void fill_verify_pattern(struct thread_data *td, void *p, unsigned int len,return ; } -if (io_u->buf_filled_len >= len) { +/* Skip if we were here and we do not need to patch pattern +* with format */ +if (!td->o.verify_fmt_sz && io_u->buf_filled_len >= len) {dprint (FD_VERIFY ,"using already filled verify pattern b=%d len=%u\n" , o->verify_pattern_bytes, len);return ; } - (void )cpy_pattern (td->o.verify_pattern, td->o.verify_pattern_bytes, p, len); + (void )paste_format (td->o.verify_pattern, td->o.verify_pattern_bytes, + td->o.verify_fmt, td->o.verify_fmt_sz, + p, len, io_u); io_u->buf_filled_len = len; }
@@ -361,11 +365,14 @@ static int verify_io_u_pattern(struct verify_header *hdr, struct vcont *vc) pattern = td->o.verify_pattern; pattern_size = td->o.verify_pattern_bytes; -if (pattern_size <=1 ) - pattern_size =MAX_PATTERN_SIZE ; +assert (pattern_size !=0 ); + + (void )paste_format_inplace (pattern, pattern_size, + td->o.verify_fmt, td->o.verify_fmt_sz, io_u); + buf = (void *) hdr + header_size; len =get_hdr_inc (td, io_u) - header_size; - mod = header_size % pattern_size; + mod = (get_hdr_inc (td, io_u) * vc->hdr_num + header_size) % pattern_size; rc =cmp_pattern (pattern, pattern_size, mod, buf, len);if (!rc)
@@ -1321,6 +1328,18 @@ void verify_async_exit(struct thread_data *td) td->verify_threads =NULL ; } +int paste_blockoff (char *buf,unsigned int len,void *priv) +{ +struct io_u *io = priv; +unsigned long long off; + +typecheck (typeof (off), io->offset); + off =cpu_to_le64 ((uint64_t )io->offset); + len =min (len, (unsigned int )sizeof (off)); +memcpy (buf, &off, len); +return 0 ; +} +struct all_io_list *get_all_io_list (int save_mask,size_t *sz) {struct all_io_list *rep;
verify.h +5 -0
@@ -89,6 +89,11 @@ extern void fio_verify_init(struct thread_data *td);extern int verify_async_init (struct thread_data *);extern void verify_async_exit (struct thread_data *); +/* +* Callbacks for pasting formats in the pattern buffer +*/ +extern int paste_blockoff (char *buf,unsigned int len,void *priv); +struct thread_rand32_state {uint32_t s[4 ]; };
Signature · 1 line
2.4.4
Quoted 59 lines · Roman Pen
Hello, all.
The intention of this patchset is to support dynamic formats for pattern input which is used for writing and verifying data, e.g. in the latest patch I added '%o' format, which means that current block offset will be written to the buffer and then verified back, i.e. this option can be used as the following:
verify_pattern=%o
and the hexdump of generated file in my case is (few last lines):
... 000f5c00 00 5c 0f 00 00 00 00 00 00 5c 0f 00 00 00 00 00 |.\.......\......| * 000fdc00 00 dc 0f 00 00 00 00 00 00 dc 0f 00 00 00 00 00 |................| * 000ffc00 00 fc 0f 00 00 00 00 00 00 fc 0f 00 00 00 00 00 |................| * 00100000So, each block is filled in with block offset in little endian order and 8 bytes long.
Unfortunately, '
buffer_pattern' option does not support formats, because it turned out to be a lot of changes which should be made to pass correctio_u->offsetthrough the whole stack of calls. I left this task for future.Additionally, I moved all 'pattern' parsing/substituting logic to separate library file 'lib/pattern.[ch]'. Also, now '
verify_pattern' and 'buffer_pattern' support combined input which can consist of strings, numbers and formats (as was said formats are supported only by 'verify_pattern' option), e.g. let's consider the following example, where 'in' is a 'verify_pattern' or 'buffer_pattern' and 'out' is an output buffer filled in with bytes regarding specified pattern:#1 #2 #3 #4 in="abcd" in=-1024 in=66 in=0xFF0X1 out=61 62 63 64 out=00 fc ff ff out=42 out=ff 01 #5 #6 in=%o in="123"0xFFeeCC out=00 00 00 00 00 00 00 00 out=31 32 33 ff ec cc #7 in=-100xab"1"%o"2" out=f6 ff ff ff ab 31 00 00 00 00 00 00 00 00 32 #8 in=%o0xdeadbeef%o out=00 00 00 00 00 00 00 00 de ad be ef 00 00 00 00 00 00 00 00 #9 in=0xfefefefefefefefefefefefefefefefefefefefefe out=fe fe fe fe fe fe fe fe fe fe fe fe fe fe fe fe fe fe fe fe feFor %o format 8 bytes reserved in pattern, and when buffer is ready substitution occurs.
Quoted 6 lines
The old behaviour is preserved: strings are in quotes, decimals are in the range [
INT_MIN,INT_MAX], hexidecimals start from 0[Xx] and can be of any size (the limit is the maximum size of the pattern, which is 512).New behaviour: now you can combine everything together and additionally use formats (now %o is supported).
Sorry for the late response. This looks good, I have applied it. Care to send updates for the HOWTO/man page as well?
Signature · 1 line
Jens Axboe
Quoted 76 lines · Jens Axboe
Quoted 75 lines · Roman Pen
Hello, all.
The intention of this patchset is to support dynamic formats for pattern input which is used for writing and verifying data, e.g. in the latest patch
I added '%o' format, which means that current block offset will be written to
the buffer and then verified back, i.e. this option can be used as the following:verify_pattern=%o
and the hexdump of generated file in my case is (few last lines):
... 000f5c00 00 5c 0f 00 00 00 00 00 00 5c 0f 00 00 00 00 00|.\.......\......|
*
000fdc0000 dc 0f 00 00 00 00 00 00 dc 0f 00 00 00 00 00
|................|
*
000ffc0000 fc 0f 00 00 00 00 00 00 fc 0f 00 00 00 00 00
|................|
*
00100000So, each block is filled in with block offset in little endian order and 8 bytes
long.Unfortunately, '
buffer_pattern' option does not support formats, because it
turned out to be a lot of changes which should be made to pass correctio_u->offsetthrough the whole stack of calls. I left this task for future.Additionally, I moved all 'pattern' parsing/substituting logic to separate library file 'lib/pattern.[ch]'. Also, now '
verify_pattern' and 'buffer_pattern'
support combined input which can consist of strings, numbers and formats (as was said formats are supported only by 'verify_pattern' option), e.g. let's
consider the following example, where 'in' is a 'verify_pattern' or 'buffer_pattern' and 'out' is an output buffer filled in with bytes regarding
specified pattern:#1 #2 #3 #4 in="abcd" in=-1024 in=66 in=0xFF0X1 out=61 62 63 64 out=00 fc ff ff out=42 out=ff 01 #5 #6 in=%o in="123"0xFFeeCC out=00 00 00 00 00 00 00 00 out=31 32 33 ff ec cc #7 in=-100xab"1"%o"2" out=f6 ff ff ff ab 31 00 00 00 00 00 00 00 00 32 #8 in=%o0xdeadbeef%o out=00 00 00 00 00 00 00 00 de ad be ef 00 00 00 00 00 00 00 00 #9 in=0xfefefefefefefefefefefefefefefefefefefefefe out=fe fe fe fe fe fe fe fe fe fe fe fe fe fe fe fe fe fe fe fe feFor %o format 8 bytes reserved in pattern, and when buffer is ready substitution occurs.
The old behaviour is preserved: strings are in quotes, decimals are in the range [
INT_MIN,INT_MAX], hexidecimals start from 0[Xx] and can be of any size (the limit is the maximum size of the pattern, which is 512).
Quoted 6 lines
Quoted 2 lines
New behaviour: now you can combine everything together and additionally use formats (now %o is supported).
Sorry for the late response. This looks good, I have applied it. Care to send updates for the HOWTO/man page as well?
For sure. Frankly, I missed the man, I did update only HOWTO.
Jens, did you forget to review my patch related to moving meta header to generic verify_header? I also will resend it with man updates and rebased on latest changes.
--
Roman
Quoted 4 lines
--
Jens Axboe
Quoted 77 lines · Roman Peniaev
Quoted 76 lines · Jens Axboe
Quoted 75 lines · Roman Pen
Hello, all.
The intention of this patchset is to support dynamic formats for pattern input which is used for writing and verifying data, e.g. in the latest patch
I added '%o' format, which means that current block offset will be written to
the buffer and then verified back, i.e. this option can be used as the following:verify_pattern=%o
and the hexdump of generated file in my case is (few last lines):
... 000f5c00 00 5c 0f 00 00 00 00 00 00 5c 0f 00 00 00 00 00 |.\.......\......| * 000fdc00 00 dc 0f 00 00 00 00 00 00 dc 0f 00 00 00 00 00 |................| * 000ffc00 00 fc 0f 00 00 00 00 00 00 fc 0f 00 00 00 00 00 |................| * 00100000So, each block is filled in with block offset in little endian order and 8 bytes
long.Unfortunately, '
buffer_pattern' option does not support formats, because it
turned out to be a lot of changes which should be made to pass correctio_u->offsetthrough the whole stack of calls. I left this task for future.Additionally, I moved all 'pattern' parsing/substituting logic to separate library file 'lib/pattern.[ch]'. Also, now '
verify_pattern' and 'buffer_pattern'
support combined input which can consist of strings, numbers and formats (as was said formats are supported only by 'verify_pattern' option), e.g. let's
consider the following example, where 'in' is a 'verify_pattern' or 'buffer_pattern' and 'out' is an output buffer filled in with bytes regarding
specified pattern:#1 #2 #3 #4 in="abcd" in=-1024 in=66 in=0xFF0X1 out=61 62 63 64 out=00 fc ff ff out=42 out=ff 01 #5 #6 in=%o in="123"0xFFeeCC out=00 00 00 00 00 00 00 00 out=31 32 33 ff ec cc #7 in=-100xab"1"%o"2" out=f6 ff ff ff ab 31 00 00 00 00 00 00 00 00 32 #8 in=%o0xdeadbeef%o out=00 00 00 00 00 00 00 00 de ad be ef 00 00 00 00 00 00 00 00 #9 in=0xfefefefefefefefefefefefefefefefefefefefefe out=fe fe fe fe fe fe fe fe fe fe fe fe fe fe fe fe fe fe fe fe feFor %o format 8 bytes reserved in pattern, and when buffer is ready substitution occurs.
The old behaviour is preserved: strings are in quotes, decimals are in the range [
INT_MIN,INT_MAX], hexidecimals start from 0[Xx] and can be of any size (the limit is the maximum size of the pattern, which is 512).
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
New behaviour: now you can combine everything together and additionally use formats (now %o is supported).
Sorry for the late response. This looks good, I have applied it. Care to send updates for the HOWTO/man page as well?
For sure. Frankly, I missed the man, I did update only HOWTO.
Ah you did, I missed the HOWTO update. If you could do the man page as well, I'd appreciate it.
Quoted 3 lines
Jens, did you forget to review my patch related to moving meta header to generic
verify_header? I also will resend it with man updates and rebased on latest changes.
I did, I've fallen a bit behind on review of fio patches. If you resend on the new base, I'll take a look at it. Thanks!
Signature · 1 line
Jens Axboe