Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 922826 Details for
Bug 1090423
Data integrity issue on rebuilding RAID 6 with 100MB resync speed
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
Attachment for comment 21
aiodit.c (text/plain), 13.70 KB, created by
Manibalan
on 2014-07-31 06:18:57 UTC
(
hide
)
Description:
Attachment for comment 21
Filename:
MIME Type:
Creator:
Manibalan
Created:
2014-07-31 06:18:57 UTC
Size:
13.70 KB
patch
obsolete
>#define _GNU_SOURCE /* for O_DIRECT flag */ >#include <stdio.h> >#include <strings.h> >#include <stdlib.h> >#include <sys/types.h> >#include <sys/stat.h> >#include <fcntl.h> >#include <errno.h> >#include <pthread.h> >#include <unistd.h> >#include <libaio.h> > >#define MAX_TEST_AIOS (4 *1024) >#define MIN_TEST_AIOS 128 > >#define MAX_TEST_SIZE_GB 1000 >#define DF_TEST_SIZE (2048*1024*10) >#define DF_TEST_IO_LEN 26 //sectors >#define MAX_TEST_IO_LEN 512 //sectors > >#define SECTOR_SIZE 512 >#define PAGE_SIZE 4096 >#define PAGE_ALIGN(x) ((((x)+(PAGE_SIZE-1))/PAGE_SIZE)*PAGE_SIZE) > >io_context_t g_aio_ctxp; >struct io_event * g_aio_events; >int g_test_running = 1; >int g_test_pass = 0; >int g_io_pending = 0; >unsigned char g_disk[4]; >struct timeval g_start_time, g_lw_time; > >unsigned int g_test_dev_start = 0; >unsigned int g_test_dev_end = DF_TEST_SIZE; >unsigned int g_test_size = DF_TEST_SIZE; >int g_max_io_size = DF_TEST_IO_LEN; >int g_seq_test = 0; >int g_rand_test = 0; >int g_is_seq_mode; >char g_exit_script[256]; > >typedef struct dit_itx_t_ { > > unsigned long dit_sign; // !DIT sign 0xFFFFFFFF21544944 > unsigned long dit_lba; //last written Unix epoch time (No Verify) > unsigned char dit_disk[8]; // disk name > unsigned long dit_passnum; // pass number > struct timeval dit_starttime; // dit start time (Unix epoch time) > struct timeval dit_timestamp; //last written Unix epoch time (No Verify) > unsigned long reserved[56]; > >} dit_itx_t; //512 bytes > >int aio_write( int fd, unsigned long lba, int sectors ) >{ > int r; > struct iocb *iocb; > dit_itx_t * buffer=NULL; > int i; > struct timeval t; > > iocb = calloc(1, sizeof(struct iocb)); > if( !iocb ) { > r = -ENOMEM; > return r; > } > > r = posix_memalign( (void **) &buffer, PAGE_SIZE, PAGE_ALIGN( sectors * SECTOR_SIZE )); > if ( r ) { > r = -ENOMEM; > return r; > } > gettimeofday(&t,NULL); > g_lw_time = t; > > for(i=0; i < sectors; i++) { > buffer[i].dit_sign = 0xFFFFFFFF21544944; > buffer[i].dit_lba = lba + i; > strcpy(buffer[i].dit_disk, g_disk); > buffer[i].dit_passnum = g_test_pass; > buffer[i].dit_starttime = g_start_time; > buffer[i].dit_timestamp = t; > memset(buffer[i].reserved, 0, sizeof(*buffer[i].reserved)); > } > > io_prep_pwrite( iocb, fd, buffer, sectors*SECTOR_SIZE, lba*SECTOR_SIZE ); > iocb->data = (void *)buffer; > r = io_submit( g_aio_ctxp, 1, &iocb ); > if( r == 1 ) { > r = 0; > } else { > r = -EIO; > } > > return r; >} > > >static int aio_read_done(struct iocb *iocb, long r, long r2 ) >{ > int retval = 0; > int i; > dit_itx_t * buffer=NULL; > unsigned long lba = iocb->u.c.offset >> 9; > int sectors = iocb->u.c.nbytes >> 9; > struct timeval t; > > if( r2 != 0 ) > { > printf("Read LBA %ld error r2:%lu r:%ld\n", iocb->u.c.offset >> 9, r2, r ); > retval = -EIO; > g_test_running=0; > goto out; > } > if( r != iocb->u.c.nbytes ) > { > printf("Read LBA %ld missed bytes expected %lu, got %lu\n", > iocb->u.c.offset >> 9, iocb->u.c.nbytes, r ); > retval = -EIO; > g_test_running=0; > goto out; > } > buffer = iocb->data; > > for(i=0; i < sectors; i++) { > > if ( !(buffer[i].dit_sign == 0xFFFFFFFF21544944 > && buffer[i].dit_lba == (lba + i) > && !strcmp(buffer[i].dit_disk, g_disk) > && buffer[i].dit_passnum == g_test_pass > && buffer[i].dit_starttime.tv_sec == g_start_time.tv_sec > && buffer[i].dit_starttime.tv_usec == g_start_time.tv_usec)) > { > gettimeofday(&t,NULL); > > printf("Miscompare: @%lu IO[lba %lu + i %d nsectors %d] TIME[DATA %lu:%lu LASTWRITE %lu:%lu CURRENT %lu:%lu]\n", > lba+i, lba, i, sectors, buffer[i].dit_starttime.tv_sec, buffer[i].dit_starttime.tv_usec, > g_lw_time.tv_sec, g_lw_time.tv_usec, t.tv_sec, t.tv_usec ); > > printf("EXPCTED [SIG:%lx LBA:%lu DISK:%s PASS:%d STS:%lu:%lu] !=", 0xFFFFFFFF21544944, lba+i, g_disk, g_test_pass, > g_start_time.tv_sec, g_start_time.tv_usec ); > printf(" GOT [SIG:%lx LBA:%lu DISK:%s PASS:%d STS:%lu:%lu]\n", buffer[i].dit_sign, buffer[i].dit_lba, buffer[i].dit_disk, > buffer[i].dit_passnum, buffer[i].dit_starttime.tv_sec, buffer[i].dit_starttime.tv_usec ); > retval = -1; > fflush(stdout); > > if (g_test_running) { > g_test_running=0; > if (strlen(g_exit_script)) /* this can be used to terminate any other test scripts like RHS running along with this tool */ > system(g_exit_script); > } > } > } > > //printf("Completing Read IO lba: %llu, size: %lu sectors retval %d\n", > //iocb->u.c.offset >> 9, iocb->u.c.nbytes >> 9 , retval ); > >out: > > free( iocb->data ); > free( iocb ); > g_io_pending--; > return retval; >} > >int aio_read( int fd, unsigned long lba, int sectors ) >{ > int r; > struct iocb *iocb; > dit_itx_t * buffer=NULL; > int i; > > iocb = calloc(1, sizeof(struct iocb)); > if( !iocb ) { > r = -ENOMEM; > return r; > } > > r = posix_memalign( (void **) &buffer, PAGE_SIZE, PAGE_ALIGN( sectors * SECTOR_SIZE )); > if ( r ) { > r = -ENOMEM; > return r; > } > > io_prep_pread( iocb, fd, buffer, sectors*SECTOR_SIZE, lba*SECTOR_SIZE ); > iocb->data = (void *)buffer; > r = io_submit( g_aio_ctxp, 1, &iocb ); > if( r == 1 ) { > r = 0; > } else { > r = -EIO; > } > > return r; >} > > >static int aio_write_done(struct iocb *iocb, long r, long r2 ) >{ > int retval = 0; > if( r2 != 0 ) > { > printf("Write LBA %ld error r2:%lu r:%ld\n", iocb->u.c.offset >> 9, r2, r ); > retval = -EIO; > g_test_running=0; > goto out; > } > if( r != iocb->u.c.nbytes ) > { > printf("Write LBA %ld missed bytes expected %lu, got %lu\n", > iocb->u.c.offset >> 9, iocb->u.c.nbytes, r ); > retval = -EIO; > g_test_running=0; > goto out; > } > > //printf("Completing Write IO lba: %llu, size: %lu sectors \n", > //iocb->u.c.offset >> 9, iocb->u.c.nbytes >> 9 ); > > retval = 0; >out: > > free( iocb->data ); > free( iocb ); > g_io_pending--; > return retval; >} > >int aio_complete( int nr_min, int nr_max, int rw) >{ > int r=0, nr=nr_min; > struct io_event *pevents; > struct iocb *iocb; > > if (nr_min <=0 ) > return 0; > > do { > > int completed = io_getevents( g_aio_ctxp, nr_min, nr_max, g_aio_events, NULL ); > > if( completed == 0 ) > continue; > else if( completed < 0 ) > { > r = -errno; > printf("io_getevents failed with retval:%ld, errno:%s\n", > completed, strerror( r ) ); > break; > } > > nr -= completed; > for( pevents = g_aio_events; completed-- > 0; pevents++ ) > { > iocb = pevents->obj; > if(rw) > r |= aio_write_done( iocb, pevents->res, pevents->res2 ); > else > r |= aio_read_done( iocb, pevents->res, pevents->res2 ); > } > > } while( nr > 1); > > return r; >} > >int perform_aios(int fd, int rw) >{ > int r=0; > int lba_count = 0; > int count=0; > int lba_range = g_test_dev_end - g_test_dev_start; > g_io_pending = 0; > srandom(g_test_pass); > > while( g_test_running && lba_count < g_test_size ) { > > int lba = g_is_seq_mode ? lba_count : random(); > int len = random() % g_max_io_size; > if (!len) > len++; > > lba %= lba_range; > lba+= g_test_dev_start; > > if(!(count++%3000) || (lba_count+len >=g_test_size) ) { > struct timeval t; > gettimeofday(&t,NULL); > printf("Firing %s IO lba: %llu, size: %lu sectors iocount %d lba_count %d g_io_pending %d time<%lu:%lu>\n", > rw? "WRITE":"READ", lba, len, count, lba_count, g_io_pending, t.tv_sec, t.tv_usec ); > fflush(stdout); > } > > if (rw) > r = aio_write(fd, lba, len); > else > r = aio_read(fd, lba, len); > > if (r) { > break; > } else { > g_io_pending++; > lba_count += len; > } > > if ( g_io_pending > (MIN_TEST_AIOS*2) ) { > r = aio_complete( MIN_TEST_AIOS, MIN_TEST_AIOS, rw); > if (r) { > printf("Error in aio_complete %s ret %d\n", rw? "write" : "read", r); > break; > } > } > } > > if(g_io_pending > 0) { > r |= aio_complete(g_io_pending, g_io_pending, rw); > } > > return r; >} > >#define usage() printf("Usage: %s -d </dev/bdev> -b <begin-GB> -e <end-GB> -t <test-size-GB> -i <io-max-size-sectors> -p <passes> ...[-x <exit-script.sh> -s <seq> &|-r <rand> -h <help>]\n", argv[0]) > >int main(int argc, char * argv[]) >{ > char *p, disk[256]={0}; > int r, fd; > int n_pass=2; > int nopts=0, opt; > > int rhs_stat=0; > char buffer [ 32 ]; > FILE *fp = NULL; > > if ( argc < 2 ) { > usage(); > return -EINVAL; > } > > while ((opt = getopt(argc, argv, "d:b:e:t:i:p:x:rsh")) != -1) > { > //printf("opt %c optarg %s nopts %d\n", opt, optarg, nopts); > > switch (opt) > { > case 'd': > strcpy(disk, optarg); > > if (strlen(disk)) > p = strrchr(disk, '/'); > strncpy(g_disk, p+1, 7 ); > nopts++; > break; > case 'x': > if(strlen(optarg)) { // run the exit script, this can be used to kill some scripts/process like RHS > struct stat s; > if (0 == stat(optarg, &s)) { > sprintf(g_exit_script, "sh %s", optarg); > } else { > printf("exit_script %s not found errno %d\n", optarg, -errno); > } > } > break; > case 'b': > if ( atoi(optarg) >= 0 && atoi(optarg) < MAX_TEST_SIZE_GB ) { > g_test_dev_start = atoi(optarg) * 2048 * 1024; > nopts++; > } > break; > case 'e': > if ( atoi(optarg) > 0 && atoi(optarg) < (MAX_TEST_SIZE_GB*2) ) { > g_test_dev_end = (atoi(optarg) * 2048 * 1024) - MAX_TEST_IO_LEN; > nopts++; > } > break; > case 't': > if ( atoi(optarg) > 0 && atoi(optarg) < MAX_TEST_SIZE_GB ) { > g_test_size = atoi(optarg) * 2048 * 1024; > nopts++; > } > break; > case 'i': > if ( atoi(optarg) > 0 && atoi(optarg) <= MAX_TEST_IO_LEN ) { > g_max_io_size = atoi(optarg); > nopts++; > } > break; > case 'p': > n_pass = atoi(optarg); > break; > case 'r': > g_rand_test = 1; > break; > case 's': > g_seq_test = 1; > break; > case 'h': > default: /* '?' */ > usage(); > exit(EXIT_FAILURE); > break; > } > } > > if (!g_rand_test && !g_seq_test) { //default seq test > g_seq_test = 1; > nopts++; > } else { > nopts++; > } > > if (nopts < 6 || g_test_dev_end < g_test_dev_start) { > printf("%s: args <%s> begin<%d> end<%d> test-size<%d> io-size<%d> passes<%d> mode<%s>\n", > argv[0], disk, g_test_dev_start, g_test_dev_end, g_test_size, g_max_io_size, > n_pass, (g_seq_test & g_rand_test) ? "r+s": (g_seq_test ? "s" : "r") ); > printf("%s: insufficient/invalid arguments %d\n", argv[0], nopts); > usage(); > exit(EXIT_FAILURE); > } > > gettimeofday(&g_start_time,NULL); > > printf("%s: args <%s> begin<%d> end<%d> test-size<%d> io-size<%d> num-pass<%d> mode<%s> time-stamp<%lu:%lu> disk<%s>\n", > argv[0], disk, g_test_dev_start, g_test_dev_end, g_test_size, g_max_io_size, > n_pass, (g_seq_test & g_rand_test) ? "r+s": (g_seq_test ? "s" : "r"), > g_start_time.tv_sec, g_start_time.tv_usec, g_disk ); > > fd = open( disk, O_RDWR|O_SYNC|O_DIRECT ); > if( fd == -1 ) { > r = -errno; > printf( "Error in opening disk %s [%d]\n", disk, r ); > return r; > } > > r = io_setup(MAX_TEST_AIOS, &g_aio_ctxp); > if ( r ) { > r = -errno; > printf("Error in io_setup disk %s [%d]\n", disk, r ); > return r; > } > > g_aio_events = calloc( MAX_TEST_AIOS, sizeof(struct io_event) ); > if ( !g_aio_events ) { > r = -errno; > printf("Error in io_setup disk %s [%d]\n", disk, r ); > return r; > } > >//system("touch /tmp/aio.pause"); >//system("touch /tmp/aio.state"); > while( g_test_running ) { > > if (g_seq_test && g_rand_test) { > g_is_seq_mode = g_test_pass &1; //mixed - alternative cycles > } else if (g_seq_test) > g_is_seq_mode = g_seq_test; //sequential only > else > g_is_seq_mode = 0; //random only > > printf("pid %d doing %s write cycle for pass %d on disk %s [%d]\n", getpid(), g_is_seq_mode? "seq" :"random", g_test_pass, disk); > fflush(stdout); > int start_write=1; > int start_verify=1; > //Wait for the write flag set > /*while ( start_write != 1 ){ > sleep(2); > fp = popen( "cat /tmp/aio.stat", "r" ); > if( fp == NULL ){ > printf("Error getting the status of the RHS"); > } > memset( buffer, 0, sizeof(buffer) ); > fgets( buffer, sizeof(buffer)-1, fp ); > if( strstr( buffer, "start_write") != NULL ){ > start_write=1; > } > if( fp ) > pclose( fp ); > }*/ > > start_write=1; > //------------------------------- > > > r = perform_aios(fd, 1); > if (r ) { > printf( "pid %d Error in perform_aios writes disk %s [%d]\n", getpid(), disk, r ); > return r; > } > //Wait for Rebuild to complet... > //Inform the RHS sctipt, that the write cycle is completed, and can start the RHS pass. > // printf("write cycle is completed [write_done]. waiting for [start_verify] flag in /tmp/aio.stat file, to continue read cycle"); > // system("echo \"write_done\" >>/tmp/aio.pause"); > > //Wait for the RHS pass to complete, before starting the verification cycle > /*while ( start_verify != 1 ){ > sleep(2); > fp = popen( "cat /tmp/aio.stat", "r" ); > if( fp == NULL ){ > printf("Error getting the status of the RHS"); > } > memset( buffer, 0, sizeof(buffer) ); > fgets( buffer, sizeof(buffer)-1, fp ); > if( strstr( buffer, "start_verify") != NULL ){ > start_verify=1; > } > if( fp ) > pclose( fp ); > }*/ > > start_verify=1; > //------------------------------- > > > printf("pid %d doing %s read verify cycle for pass %d on disk %s [%d]\n", getpid(), g_is_seq_mode? "seq" :"random", g_test_pass, disk); > fflush(stdout); > r = perform_aios(fd,0); > if (r ) { > printf( "pid %d Error in perform_aios read-verify disk %s [%d]\n", getpid(), disk, r ); > return r; > } > > //printf("verify cycle is completed [write_done]. waiting for [start_write] flag in /tmp/aio.stat file, to continue write cycle"); > // system("echo \"verify_done\" >>/tmp/aio.pause"); > > g_test_pass++; > if (g_test_pass > n_pass) { > printf( "pid %d Test Successfully Completed %d Passes\n", getpid(), n_pass ); > break; > } > fflush(stdout); > } > > free( g_aio_events ); > io_destroy( g_aio_ctxp ); > close(fd); > > return 0; >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 1090423
:
913989
|
921122
|
922175
|
922482
| 922826