Re: [PATCH] Add verify_meta verification type

From: Shawn Lewis <shawnlewis_at_google.com>
Date: Thu, 2 Aug 2007 11:54:55 -0700

On 8/2/07, Jens Axboe <jens.axboe_at_oracle.com> wrote:
>
>
> Looks fine, but one comment - just make the block an uint64_t and store
> the offset in bytes there instead. Ok?

k, patch coming up.

On Wed, Aug 01 2007, Shawn Lewis wrote:
> > diff --git a/HOWTO b/HOWTO
> > index 21ba960..c38266c 100644
> > --- a/HOWTO
> > +++ b/HOWTO
> > @@ -592,6 +592,10 @@ verify=str If writing to a file, fio can
> >
> > sha256 Use sha256 as the checksum function.
> >
> > + meta Write extra information about each io
> > + (timestamp, block number etc.). The block
> > + number is verified.
> > +
> > null Only pretend to verify. Useful for testing
> > internals with ioengine=null, not for much
> > else.
> > diff --git a/fio.h b/fio.h
> > index 5f81300..c16a666 100644
> > --- a/fio.h
> > +++ b/fio.h
> > @@ -197,6 +197,7 @@ enum {
> > VERIFY_CRC7, /* crc7 sum data blocks */
> > VERIFY_SHA256, /* sha256 sum data blocks */
> > VERIFY_SHA512, /* sha512 sum data blocks */
> > + VERIFY_META, /* block_num, timestamp etc. */
> > VERIFY_NULL, /* pretend to verify */
> > };
> >
> > @@ -232,6 +233,13 @@ struct vhdr_crc16 {
> > struct vhdr_crc7 {
> > uint8_t crc7;
> > };
> > +struct vhdr_meta {
> > + unsigned char block[6];
> > + unsigned char thread;
> > + unsigned short numberio;
> > + unsigned long time_sec;
> > + unsigned long time_usec;
> > +};
> >
> > struct group_run_stats {
> > unsigned long long max_run[2], min_run[2];
> > diff --git a/options.c b/options.c
> > index 81ddd23..a50dece 100644
> > --- a/options.c
> > +++ b/options.c
> > @@ -638,6 +638,10 @@ #endif
> > .oval = VERIFY_SHA512,
> > .help = "Use sha512 checksums for
> verification",
> > },
> > + { .ival = "meta",
> > + .oval = VERIFY_META,
> > + .help = "Use io information",
> > + },
> > {
> > .ival = "null",
> > .oval = VERIFY_NULL,
> > diff --git a/verify.c b/verify.c
> > index a0e26c9..f34609c 100644
> > --- a/verify.c
> > +++ b/verify.c
> > @@ -133,6 +133,9 @@ static inline unsigned int __hdr_size(in
> > case VERIFY_SHA512:
> > len = sizeof(struct vhdr_sha512);
> > break;
> > + case VERIFY_META:
> > + len = sizeof(struct vhdr_meta);
> > + break;
> > default:
> > log_err("fio: unknown verify header!\n");
> > assert(0);
> > @@ -163,6 +166,29 @@ static inline void *io_u_verify_off(stru
> > return io_u->buf + header_num * hdr->len + hdr_size(hdr);
> > }
> >
> > +static int verify_io_u_meta(struct verify_header *hdr, struct
> thread_data *td,
> > + struct io_u *io_u, unsigned int header_num)
> > +{
> > + struct vhdr_meta *vh = hdr_priv(hdr);
> > + unsigned long long block;
> > + unsigned int i;
> > +
> > + block = 0;
> > + for (i=0; i < 6; i++) {
> > + block <<= 8;
> > + block |= vh->block[5-i];
> > + }
> > +
> > + if (block != io_u->offset / td->o.verify_interval + header_num) {
> > + log_err("meta: verify failed at %llu/%u\n",
> > + io_u->offset + header_num * hdr->len,
> > + hdr->len);
> > + return 1;
> > + }
> > +
> > + return 0;
> > +}
> > +
> > static int verify_io_u_sha512(struct verify_header *hdr, struct io_u
> *io_u,
> > unsigned int header_num)
> > {
> > @@ -365,6 +391,9 @@ int verify_io_u(struct thread_data *td,
> > case VERIFY_SHA512:
> > ret = verify_io_u_sha512(hdr, io_u, hdr_num);
> > break;
> > + case VERIFY_META:
> > + ret = verify_io_u_meta(hdr, td, io_u, hdr_num);
> > + break;
> > default:
> > log_err("Bad verify type %u\n", hdr->verify_type);
> > ret = 1;
> > @@ -375,6 +404,27 @@ int verify_io_u(struct thread_data *td,
> > return 0;
> > }
> >
> > +static void fill_meta(struct verify_header *hdr, struct thread_data
> *td,
> > + struct io_u *io_u, unsigned int header_num)
> > +{
> > + struct vhdr_meta *vh = hdr_priv(hdr);
> > + unsigned long long block_num;
> > + unsigned int i;
> > +
> > + vh->thread = td->thread_number;
> > +
> > + vh->time_sec = io_u->start_time.tv_sec;
> > + vh->time_usec = io_u->start_time.tv_usec;
> > +
> > + vh->numberio = td->io_issues[DDIR_WRITE];
> > +
> > + block_num = (io_u->offset / td->o.verify_interval) + header_num;
> > + for (i = 0; i < 6; i++) {
> > + vh->block[i] = block_num & 0xff;
> > + block_num >>= 8;
> > + }
> > +}
> > +
> > static void fill_sha512(struct verify_header *hdr, void *p, unsigned
> int len)
> > {
> > struct vhdr_sha512 *vh = hdr_priv(hdr);
> > @@ -444,7 +494,7 @@ void populate_verify_io_u(struct thread_
> > {
> > struct verify_header *hdr;
> > void *p = io_u->buf, *data;
> > - unsigned int hdr_inc, data_len;
> > + unsigned int hdr_inc, data_len, header_num = 0;
> >
> > if (td->o.verify == VERIFY_NULL)
> > return;
> > @@ -486,12 +536,16 @@ void populate_verify_io_u(struct thread_
> > case VERIFY_SHA512:
> > fill_sha512(hdr, data, data_len);
> > break;
> > + case VERIFY_META:
> > + fill_meta(hdr, td, io_u, header_num);
> > + break;
> > default:
> > log_err("fio: bad verify type: %d\n", td->o.verify
> );
> > assert(0);
> > }
> > if (td->o.verify_offset)
> > memswp(p, p + td->o.verify_offset, hdr_size(hdr));
> > + header_num++;
> > }
> > }
> >
> >
>
> --
> Jens Axboe
>
>
Received on Thu Aug 02 2007 - 20:54:55 CEST

This archive was generated by hypermail 2.2.0 : Thu Aug 02 2007 - 21:00:01 CEST