verify: add raw pattern verify
authorJens Axboe <axboe@fb.com>
Tue, 9 Jun 2015 02:43:43 +0000 (20:43 -0600)
committerJens Axboe <axboe@fb.com>
Tue, 9 Jun 2015 02:43:43 +0000 (20:43 -0600)
Add specific verify=pattern that doesn't use any headers, it
just writes the specified pattern and verifies it.

Signed-off-by: Jens Axboe <axboe@fb.com>
HOWTO
fio.1
options.c
verify.c
verify.h

diff --git a/HOWTO b/HOWTO
index 291327d52de808248b24212cacc02159e2144f50..61ebe5e9f7de732403dfd85b59837f01f987ddac 100644 (file)
--- a/HOWTO
+++ b/HOWTO
@@ -1281,6 +1281,12 @@ verify=str       If writing to a file, fio can verify the file contents
                                verified for workloads that write data.
                                See also verify_pattern.
 
                                verified for workloads that write data.
                                See also verify_pattern.
 
+                       pattern Verify a strict pattern. Normally fio includes
+                               a header with some basic information and
+                               checksumming, but if this option is set, only
+                               the specific pattern set with 'verify_pattern'
+                               is verified.
+
                        null    Only pretend to verify. Useful for testing
                                internals with ioengine=null, not for much
                                else.
                        null    Only pretend to verify. Useful for testing
                                internals with ioengine=null, not for much
                                else.
diff --git a/fio.1 b/fio.1
index 1657082526d253207037a52d9fecc18fa394b666..5f8e9482cd3e73ed7dec146bd417aaeada1c2fa8 100644 (file)
--- a/fio.1
+++ b/fio.1
@@ -1129,6 +1129,11 @@ not supported by the system.
 Write extra information about each I/O (timestamp, block number, etc.). The
 block number is verified. See \fBverify_pattern\fR as well.
 .TP
 Write extra information about each I/O (timestamp, block number, etc.). The
 block number is verified. See \fBverify_pattern\fR as well.
 .TP
+.B pattern
+Verify a strict pattern. Normally fio includes a header with some basic
+information and checksumming, but if this option is set, only the
+specific pattern set with \fBverify_pattern\fR is verified.
+.TP
 .B null
 Pretend to verify.  Used for testing internals.
 .RE
 .B null
 Pretend to verify.  Used for testing internals.
 .RE
@@ -1162,7 +1167,7 @@ pattern for io verification purposes. Depending on the width of the pattern,
 fio will fill 1/2/3/4 bytes of the 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
 fio will fill 1/2/3/4 bytes of the 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
-\fBverify\fP=meta.
+\fBverify\fP=meta or \fBverify\fP=pattern.
 .TP
 .BI verify_fatal \fR=\fPbool
 If true, exit the job on the first observed verification failure.  Default:
 .TP
 .BI verify_fatal \fR=\fPbool
 If true, exit the job on the first observed verification failure.  Default:
index 96b8b682f1724ce44c7413c7aaa1eabfebe37eca..cd371417d76047efcf84fd9705e9fa7c97a830c7 100644 (file)
--- a/options.c
+++ b/options.c
@@ -983,6 +983,8 @@ static int pattern_cb(char *pattern, unsigned int max_size,
         */
 fill:
        pattern_length = i;
         */
 fill:
        pattern_length = i;
+       if (!i && !off)
+               i = 1;
        while (i > 1 && i * 2 <= max_size) {
                memcpy(&pattern[i], &pattern[0], i);
                i *= 2;
        while (i > 1 && i * 2 <= max_size) {
                memcpy(&pattern[i], &pattern[0], i);
                i *= 2;
@@ -2400,6 +2402,10 @@ struct fio_option fio_options[FIO_MAX_OPTS] = {
                            .oval = VERIFY_META,
                            .help = "Use io information",
                          },
                            .oval = VERIFY_META,
                            .help = "Use io information",
                          },
+                         { .ival = "pattern",
+                           .oval = VERIFY_PATTERN_NO_HDR,
+                           .help = "Verify strict pattern",
+                         },
                          {
                            .ival = "null",
                            .oval = VERIFY_NULL,
                          {
                            .ival = "null",
                            .oval = VERIFY_NULL,
index fcdf748810ea2634d0402588c546ff6d0a08b949..806f41e7c6518072e74fdff6d96d5d9e9ccdc97e 100644 (file)
--- a/verify.c
+++ b/verify.c
@@ -168,6 +168,7 @@ static inline unsigned int __hdr_size(int verify_type)
                len = sizeof(struct vhdr_sha1);
                break;
        case VERIFY_PATTERN:
                len = sizeof(struct vhdr_sha1);
                break;
        case VERIFY_PATTERN:
+       case VERIFY_PATTERN_NO_HDR:
                len = 0;
                break;
        default:
                len = 0;
                break;
        default:
@@ -787,9 +788,11 @@ int verify_io_u(struct thread_data *td, struct io_u **io_u_ptr)
                if (td->o.verifysort || (td->flags & TD_F_VER_BACKLOG))
                        io_u->rand_seed = hdr->rand_seed;
 
                if (td->o.verifysort || (td->flags & TD_F_VER_BACKLOG))
                        io_u->rand_seed = hdr->rand_seed;
 
-               ret = verify_header(io_u, hdr, hdr_num, hdr_inc);
-               if (ret)
-                       return ret;
+               if (td->o.verify != VERIFY_PATTERN_NO_HDR) {
+                       ret = verify_header(io_u, hdr, hdr_num, hdr_inc);
+                       if (ret)
+                               return ret;
+               }
 
                if (td->o.verify != VERIFY_NONE)
                        verify_type = td->o.verify;
 
                if (td->o.verify != VERIFY_NONE)
                        verify_type = td->o.verify;
@@ -832,6 +835,7 @@ int verify_io_u(struct thread_data *td, struct io_u **io_u_ptr)
                        ret = verify_io_u_sha1(hdr, &vc);
                        break;
                case VERIFY_PATTERN:
                        ret = verify_io_u_sha1(hdr, &vc);
                        break;
                case VERIFY_PATTERN:
+               case VERIFY_PATTERN_NO_HDR:
                        ret = verify_io_u_pattern(hdr, &vc);
                        break;
                default:
                        ret = verify_io_u_pattern(hdr, &vc);
                        break;
                default:
@@ -965,6 +969,9 @@ static void populate_hdr(struct thread_data *td, struct io_u *io_u,
        unsigned int data_len;
        void *data, *p;
 
        unsigned int data_len;
        void *data, *p;
 
+       if (td->o.verify == VERIFY_PATTERN_NO_HDR)
+               return;
+
        p = (void *) hdr;
 
        hdr->magic = FIO_HDR_MAGIC;
        p = (void *) hdr;
 
        hdr->magic = FIO_HDR_MAGIC;
index d4d6012b0ec35e6632e4e341881cbd3cd5f87d82..c37b1d56acd10d9dfcc7f310a697c2881ff431d6 100644 (file)
--- a/verify.h
+++ b/verify.h
@@ -20,6 +20,7 @@ enum {
        VERIFY_META,                    /* block_num, timestamp etc. */
        VERIFY_SHA1,                    /* sha1 sum data blocks */
        VERIFY_PATTERN,                 /* verify specific patterns */
        VERIFY_META,                    /* block_num, timestamp etc. */
        VERIFY_SHA1,                    /* sha1 sum data blocks */
        VERIFY_PATTERN,                 /* verify specific patterns */
+       VERIFY_PATTERN_NO_HDR,          /* verify specific patterns, no hdr */
        VERIFY_NULL,                    /* pretend to verify */
 };
 
        VERIFY_NULL,                    /* pretend to verify */
 };