All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ville Herva <vherva@viasys.com>
To: vojtech@suse.cz
Cc: linux-kernel@vger.kernel.org, Mark Cooke <mpc@star.sr.bham.ac.uk>,
	jfr@viasys.com
Subject: Re: Quick question on Software RAID support.
Date: Thu, 14 Feb 2002 00:12:42 +0200	[thread overview]
Message-ID: <20020214001242.A14015@viasys.com> (raw)
In-Reply-To: <20020213225449.B10409@suse.cz>

[-- Attachment #1: Type: text/plain, Size: 806 bytes --]

> I'd like to try that, too, so if you can send me the program ...

I run it on /dev/md0 (which consists of one hd on each HPT370 channel).  
You can also do it for /dev/hd{e,g} in parallel - the effects are pretty
much the same. To make it trigger easier, try "ping -f -s 64000" on
background and stress scsi system if you have one. I think any pci load
affects it, but I found 3c905b network load by far the easiest way to
trigger the bug (I even got OOPSes if 3c905b was in certain slot while
doing that.)

Oh, and please excuse the state of the code - it was meant as a quick hack
only...

--
Ville Herva            vherva@viasys.com             +358-50-5164500
Viasys Oy              Hannuntie 6  FIN-02360 Espoo  +358-9-2313-2160
PGP key available: http://www.iki.fi/v/pgp.html  fax +358-9-2313-2250

[-- Attachment #2: wrchk.c --]
[-- Type: text/plain, Size: 4212 bytes --]

#include <stdlib.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
//#include <fcntl.h>
#include <asm/fcntl.h>
                     
#define KB (1024)
#define MB (1024 * KB)
#define GB (1024 * MB)

int main(int argc, char** argv)
{
    char* dev = "/tmp/jöötti";
    unsigned long long blocksz = 64*MB;
    unsigned long long maxs = 0;
    unsigned iter = 0;
    const unsigned long long qgiga = 1024 * 1024 * 1024 / 4;
    
    char *buffer1, *buffer2;
    int i;
    int devfd;
    int err = 0;
    char ch;
    int round = 0;

    if (argc > 1) dev = argv[1];
    if (argc > 2) maxs = (long long)atoi(argv[2]) * (long long)MB;
    if (argc > 3) blocksz = (long long)atoi(argv[3]) * (long long)MB;
    if (argc > 4) iter = atoi(argv[4]);

    fprintf(stderr, "This test WILL RUIN THE CONTENTS OF %s!\n", dev);
    fprintf(stderr, "Are you 120%% sure you want to do this [Y/N] ? ");
    scanf("%c", &ch);
    fprintf(stderr, "\n");
    if (ch != 'Y') 
    {
       fprintf(stderr, "exiting.\n");
       exit(13);
    }

    fprintf(stderr, "testing %s, max size %llu, block size=%u...\n", 
            dev, maxs, blocksz);

    buffer1 = malloc(blocksz);
    buffer2 = malloc(blocksz);
    if (!buffer1 || !buffer2) 
    {
        perror("malloc failed");
        exit(1);
    }
    for (i = 0; i < blocksz; i++)
        buffer1[i] = (i + rand()) % 256;

    for (round = 0; round < iter || iter == 0; round++)
    {
        unsigned long long nwritten = 0, nread = 0;
        int nr = 0;
        time_t t = time(NULL);

        devfd = open(dev, O_LARGEFILE | O_WRONLY | O_TRUNC | O_CREAT);
        if (devfd < 0)
        {
           perror("open device failed");
           exit(1);
	}

        lseek64(devfd, 0, SEEK_SET);

	while ((nr = write(devfd, buffer1, blocksz)) > 0)
	{
	    nwritten += nr;
	    if (nwritten % qgiga == 0) fprintf(stderr, ".");
	    if (nwritten % (qgiga * 20) == 0) fprintf(stderr, "%lluG", nwritten / (qgiga * 4));
            if (maxs && nwritten > maxs) break;
	}
	fprintf(stderr, "\n");	

        fprintf(stderr, "round %i: Wrote %llu bytes, %2.1f MB/s.\n",
                round, nwritten,
		(float)nwritten / 1024.0 / 1024.0 / (float)(time(NULL) - t));

        close (devfd);

        devfd = open(dev, O_LARGEFILE | O_RDONLY);
        if (devfd < 0)
        {
           perror("open device failed");
           exit(1);
	}
        lseek64(devfd, 0, SEEK_SET);
        t = time(NULL);

	while ((nr = read(devfd, buffer2, blocksz)) > 0)
        {
             if (nr < 0)
             {
                perror("read");
                exit(-2);
             }
             if (memcmp(buffer1, buffer2, nr))
             {
                int l, erbytes = 0, erbytes2 = 0, erbytes3 = 0, l2;
                err++;
                for (l = 0; l < nr; l++)
                    if (buffer1[l] != buffer2[l])
                          erbytes++;
                for (l = 0; l < nr; l++)
                    if (buffer1[l] != buffer2[l])
                          erbytes2++;
                for (l = 0; l < nr; l++)
                    if (buffer1[l] != buffer2[l])
                          erbytes3++;
                fprintf(stderr, "\n%llu byte block at %llu DIFFERS in %i/%i/%i bytes (read %i)!\nFirst 50 bytes:\n",
                        blocksz, nread, erbytes, erbytes2, erbytes3, nr);

                for (l = l2 = 0; l < nr && l2 < 50; l++)
                    if (buffer1[l] != buffer2[l])
                    {
                          fprintf(stderr, "at %8i: %02x vs %02x\n", 
                                  l, (unsigned char)buffer1[l], (unsigned char)buffer2[l]);
                          l2++;
                    }
             }

             nread += nr;

 	     if (nread % qgiga == 0) fprintf(stderr, ".");
 	     if (nread % (qgiga * 20) == 0) fprintf(stderr, "%lluG", nread / (qgiga * 4));
             if (maxs && nread > maxs) break;
        }
	fprintf(stderr, "\n");	

        fprintf(stderr, "round %i: Read %llu bytes, %2.1f MB/s.\n",
                round, nread,
		(float)nread / 1024.0 / 1024.0 / (float)(time(NULL) - t));
		
	close(devfd);
    }

    close(devfd);
    free(buffer1);
    free(buffer2);

    return err;
}

  reply	other threads:[~2002-02-13 22:13 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-02-13  1:34 Quick question on Software RAID support Mukund Ingle
2002-02-13  1:45 ` Alan Cox
2002-02-13  1:47   ` Chris Chabot
2002-02-13  4:10     ` Bill Davidsen
2002-02-13  9:24       ` Francois Romieu
2002-02-13  2:19   ` Rob Landley
2002-02-13 10:33   ` Marco Colombo
2002-02-13 11:15     ` Alan Cox
2002-02-13 14:25       ` Marco Colombo
2002-02-13 18:30       ` Mark Cooke
2002-02-13 21:33         ` Ville Herva
2002-02-13 21:54           ` Vojtech Pavlik
2002-02-13 22:12             ` Ville Herva [this message]
2002-02-15 23:48               ` Mark Cooke
2002-02-16 17:01                 ` VIA KT133 (was: Re: Quick question on Software RAID support.) Ville Herva
2002-02-14 19:05       ` Quick question on Software RAID support Pavel Machek
2002-02-13 18:57 ` Thomas Schenk

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20020214001242.A14015@viasys.com \
    --to=vherva@viasys.com \
    --cc=jfr@viasys.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mpc@star.sr.bham.ac.uk \
    --cc=vojtech@suse.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.