Skip to content
Browse files

These don't belong here. Were added by mistake.

  • Loading branch information...
1 parent e51c2b6 commit 047713f61b039fb7e00a5777ebfc40442f2a3879 Anand Mitra committed Nov 24, 2010
Showing with 0 additions and 15,098 deletions.
  1. +0 −53 wrv/.svn/all-wcprops
  2. +0 −312 wrv/.svn/entries
  3. +0 −1 wrv/.svn/format
  4. +0 −5 wrv/.svn/prop-base/Makefile.svn-base
  5. +0 −5 wrv/.svn/prop-base/iomethods.c.svn-base
  6. +0 −5 wrv/.svn/prop-base/iotest.c.svn-base
  7. +0 −5 wrv/.svn/prop-base/iotest.h.svn-base
  8. +0 −5 wrv/.svn/prop-base/ioutils.c.svn-base
  9. +0 −9 wrv/.svn/prop-base/winwrv.sln.svn-base
  10. +0 −9 wrv/.svn/prop-base/winwrv.vcproj.svn-base
  11. +0 −5 wrv/.svn/prop-base/wrv.manpage.txt.svn-base
  12. +0 −68 wrv/.svn/text-base/Makefile.svn-base
  13. +0 −2,268 wrv/.svn/text-base/iomethods.c.svn-base
  14. +0 −765 wrv/.svn/text-base/iotest.c.svn-base
  15. +0 −261 wrv/.svn/text-base/iotest.h.svn-base
  16. +0 −340 wrv/.svn/text-base/ioutils.c.svn-base
  17. +0 −20 wrv/.svn/text-base/winwrv.sln.svn-base
  18. +0 −414 wrv/.svn/text-base/winwrv.vcproj.svn-base
  19. +0 −156 wrv/.svn/text-base/wrv.manpage.txt.svn-base
  20. +0 −68 wrv/Makefile
  21. +0 −2,268 wrv/iomethods.c
  22. BIN wrv/iomethods.o
  23. +0 −765 wrv/iotest.c
  24. +0 −261 wrv/iotest.h
  25. BIN wrv/iotestlinux.o
  26. +0 −340 wrv/ioutils.c
  27. BIN wrv/ioutils.o
  28. +0 −17 wrv/linux/.svn/all-wcprops
  29. +0 −96 wrv/linux/.svn/entries
  30. +0 −1 wrv/linux/.svn/format
  31. +0 −5 wrv/linux/.svn/prop-base/linuxinclude.h.svn-base
  32. +0 −5 wrv/linux/.svn/prop-base/linuxioutils.c.svn-base
  33. +0 −45 wrv/linux/.svn/text-base/linuxinclude.h.svn-base
  34. +0 −333 wrv/linux/.svn/text-base/linuxioutils.c.svn-base
  35. +0 −45 wrv/linux/linuxinclude.h
  36. +0 −333 wrv/linux/linuxioutils.c
  37. BIN wrv/linux/linuxioutils.o
  38. +0 −5 wrv/logs/.svn/all-wcprops
  39. +0 −28 wrv/logs/.svn/entries
  40. +0 −1 wrv/logs/.svn/format
  41. +0 −17 wrv/macosx/.svn/all-wcprops
  42. +0 −96 wrv/macosx/.svn/entries
  43. +0 −1 wrv/macosx/.svn/format
  44. +0 −5 wrv/macosx/.svn/prop-base/macosxinclude.h.svn-base
  45. +0 −5 wrv/macosx/.svn/prop-base/macosxioutils.c.svn-base
  46. +0 −43 wrv/macosx/.svn/text-base/macosxinclude.h.svn-base
  47. +0 −222 wrv/macosx/.svn/text-base/macosxioutils.c.svn-base
  48. +0 −43 wrv/macosx/macosxinclude.h
  49. +0 −222 wrv/macosx/macosxioutils.c
  50. +0 −1 wrv/pattern
  51. +0 −59 wrv/run_tests.sh
  52. +0 −65 wrv/windows/.svn/all-wcprops
  53. +0 −368 wrv/windows/.svn/entries
  54. +0 −1 wrv/windows/.svn/format
  55. +0 −9 wrv/windows/.svn/prop-base/aclops.c.svn-base
  56. +0 −9 wrv/windows/.svn/prop-base/errormsg.c.svn-base
  57. +0 −9 wrv/windows/.svn/prop-base/fileops.c.svn-base
  58. +0 −9 wrv/windows/.svn/prop-base/getopt.c.svn-base
  59. +0 −9 wrv/windows/.svn/prop-base/getopt.h.svn-base
  60. +0 −9 wrv/windows/.svn/prop-base/gettimeofday.c.svn-base
  61. +0 −9 wrv/windows/.svn/prop-base/signal.c.svn-base
  62. +0 −9 wrv/windows/.svn/prop-base/win32.h.svn-base
  63. +0 −9 wrv/windows/.svn/prop-base/wincompat_utils.c.svn-base
  64. +0 −9 wrv/windows/.svn/prop-base/wininclude.h.svn-base
  65. +0 −216 wrv/windows/.svn/text-base/aclops.c.svn-base
  66. +0 −74 wrv/windows/.svn/text-base/errormsg.c.svn-base
  67. +0 −182 wrv/windows/.svn/text-base/fileops.c.svn-base
  68. +0 −492 wrv/windows/.svn/text-base/getopt.c.svn-base
  69. +0 −144 wrv/windows/.svn/text-base/getopt.h.svn-base
  70. +0 −54 wrv/windows/.svn/text-base/gettimeofday.c.svn-base
  71. +0 −61 wrv/windows/.svn/text-base/signal.c.svn-base
  72. +0 −278 wrv/windows/.svn/text-base/win32.h.svn-base
  73. +0 −441 wrv/windows/.svn/text-base/wincompat_utils.c.svn-base
  74. +0 −32 wrv/windows/.svn/text-base/wininclude.h.svn-base
  75. +0 −216 wrv/windows/aclops.c
  76. +0 −74 wrv/windows/errormsg.c
  77. +0 −182 wrv/windows/fileops.c
  78. +0 −492 wrv/windows/getopt.c
  79. +0 −144 wrv/windows/getopt.h
  80. +0 −54 wrv/windows/gettimeofday.c
  81. +0 −61 wrv/windows/signal.c
  82. +0 −278 wrv/windows/win32.h
  83. +0 −441 wrv/windows/wincompat_utils.c
  84. +0 −32 wrv/windows/wininclude.h
  85. +0 −20 wrv/winwrv.sln
  86. +0 −414 wrv/winwrv.vcproj
  87. BIN wrv/wrv.fs
  88. +0 −156 wrv/wrv.manpage.txt
View
53 wrv/.svn/all-wcprops
@@ -1,53 +0,0 @@
-K 25
-svn:wc:ra_dav:version-url
-V 89
-/svnroot/!svn/ver/158088/branches/releases/USM_trunk/omneon/usm/test/automation/utils/wrv
-END
-wrv.manpage.txt
-K 25
-svn:wc:ra_dav:version-url
-V 105
-/svnroot/!svn/ver/136232/branches/releases/USM_trunk/omneon/usm/test/automation/utils/wrv/wrv.manpage.txt
-END
-winwrv.sln
-K 25
-svn:wc:ra_dav:version-url
-V 100
-/svnroot/!svn/ver/150507/branches/releases/USM_trunk/omneon/usm/test/automation/utils/wrv/winwrv.sln
-END
-iotest.c
-K 25
-svn:wc:ra_dav:version-url
-V 98
-/svnroot/!svn/ver/151098/branches/releases/USM_trunk/omneon/usm/test/automation/utils/wrv/iotest.c
-END
-ioutils.c
-K 25
-svn:wc:ra_dav:version-url
-V 99
-/svnroot/!svn/ver/150507/branches/releases/USM_trunk/omneon/usm/test/automation/utils/wrv/ioutils.c
-END
-iomethods.c
-K 25
-svn:wc:ra_dav:version-url
-V 101
-/svnroot/!svn/ver/158088/branches/releases/USM_trunk/omneon/usm/test/automation/utils/wrv/iomethods.c
-END
-Makefile
-K 25
-svn:wc:ra_dav:version-url
-V 98
-/svnroot/!svn/ver/151410/branches/releases/USM_trunk/omneon/usm/test/automation/utils/wrv/Makefile
-END
-iotest.h
-K 25
-svn:wc:ra_dav:version-url
-V 98
-/svnroot/!svn/ver/150507/branches/releases/USM_trunk/omneon/usm/test/automation/utils/wrv/iotest.h
-END
-winwrv.vcproj
-K 25
-svn:wc:ra_dav:version-url
-V 103
-/svnroot/!svn/ver/150507/branches/releases/USM_trunk/omneon/usm/test/automation/utils/wrv/winwrv.vcproj
-END
View
312 wrv/.svn/entries
@@ -1,312 +0,0 @@
-9
-
-dir
-161550
-http://snow/svnroot/branches/releases/USM_trunk/omneon/usm/test/automation/utils/wrv
-http://snow/svnroot
-
-
-
-2010-06-03T05:44:19.720042Z
-158088
-gjadhav
-
-
-svn:special svn:externals svn:needs-lock
-
-
-
-
-
-
-
-
-
-
-
-d3ff0b4f-3c2c-0410-a809-ba59474314df
-
-linux
-dir
-
-wrv.manpage.txt
-file
-
-
-
-
-2010-07-21T10:52:57.000000Z
-9a217590c377f297849248078d677c61
-2009-07-08T11:02:29.566382Z
-134549
-nkhare
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-6232
-
-logs
-dir
-
-winwrv.sln
-file
-
-
-
-
-2010-07-21T10:52:58.000000Z
-436fadb7571bca87c6c38d6706b702f3
-2010-02-11T13:55:59.819889Z
-150507
-gjadhav
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-860
-
-iotest.c
-file
-
-
-
-
-2010-07-21T10:52:58.000000Z
-6fec09c66ea1ffe69e130596e6dc7fc9
-2010-02-22T12:51:50.105597Z
-151098
-gjadhav
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-28931
-
-ioutils.c
-file
-
-
-
-
-2010-07-21T10:52:58.000000Z
-56e0589992583611ae7ef2af2000c1eb
-2010-02-11T13:55:59.819889Z
-150507
-gjadhav
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-10577
-
-macosx
-dir
-
-windows
-dir
-
-iomethods.c
-file
-
-
-
-
-2010-07-21T10:52:58.000000Z
-1b8de761d6792ecbafcaa3be1ea1b5be
-2010-06-03T05:44:19.720042Z
-158088
-gjadhav
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-79825
-
-Makefile
-file
-
-
-
-
-2010-07-21T10:52:58.000000Z
-bc0e217722037436cee7ec7bd4cb0d0b
-2010-02-25T09:53:47.016854Z
-151410
-ckulkarni
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-1905
-
-iotest.h
-file
-
-
-
-
-2010-07-21T10:52:58.000000Z
-d6974e4fefbcbb35a74dcb17236f7e01
-2010-02-11T13:55:59.819889Z
-150507
-gjadhav
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-9018
-
-winwrv.vcproj
-file
-
-
-
-
-2010-07-21T10:52:58.000000Z
-3be3cc688b1f79396b81073d621bbf8e
-2010-02-11T13:55:59.819889Z
-150507
-gjadhav
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-8240
-
View
1 wrv/.svn/format
@@ -1 +0,0 @@
-9
View
5 wrv/.svn/prop-base/Makefile.svn-base
@@ -1,5 +0,0 @@
-K 13
-svn:eol-style
-V 6
-native
-END
View
5 wrv/.svn/prop-base/iomethods.c.svn-base
@@ -1,5 +0,0 @@
-K 13
-svn:eol-style
-V 6
-native
-END
View
5 wrv/.svn/prop-base/iotest.c.svn-base
@@ -1,5 +0,0 @@
-K 13
-svn:eol-style
-V 6
-native
-END
View
5 wrv/.svn/prop-base/iotest.h.svn-base
@@ -1,5 +0,0 @@
-K 13
-svn:eol-style
-V 6
-native
-END
View
5 wrv/.svn/prop-base/ioutils.c.svn-base
@@ -1,5 +0,0 @@
-K 13
-svn:eol-style
-V 6
-native
-END
View
9 wrv/.svn/prop-base/winwrv.sln.svn-base
@@ -1,9 +0,0 @@
-K 13
-svn:eol-style
-V 6
-native
-K 14
-svn:executable
-V 1
-*
-END
View
9 wrv/.svn/prop-base/winwrv.vcproj.svn-base
@@ -1,9 +0,0 @@
-K 13
-svn:eol-style
-V 6
-native
-K 14
-svn:executable
-V 1
-*
-END
View
5 wrv/.svn/prop-base/wrv.manpage.txt.svn-base
@@ -1,5 +0,0 @@
-K 13
-svn:eol-style
-V 6
-native
-END
View
68 wrv/.svn/text-base/Makefile.svn-base
@@ -1,68 +0,0 @@
-# Version $Revision: 1.0 $
-#
-# The makefile for building all versions for all supported platforms
-#
-# Supports: Linux , Mac
-#
-# CC = cc
-# C89 = c89
-# GCC = gcc
-# CCS = /usr/ccs/bin/cc
-# NACC = /opt/ansic/bin/cc
-#
-#
-
-#CFLAGS = -DDEBUG -g
-
-all:
- @echo ""
- @echo "You must specify the target. "
- @echo " -> linux (32bit) <-"
- @echo " -> macosx (32bit) <-"
- @echo ""
-
-clean:
- rm -f wrv.fs
- rm -f *.o
- rm -f linux/*.o
- rm -f macosx/*.o
-
-#
-# GNU 'C' compiler Linux build with threads, largefiles, async I/O
-#
-
-linux: iotestlinux.o ioutils.o iomethods.o linux/linuxioutils.o
- $(CC) -O3 $(LDFLAGS) iotestlinux.o linux/linuxioutils.o \
- ioutils.o iomethods.o -lrt -o wrv.fs -lpthread
-
-
-macosx: iotestmacosx.o iomethods.o macosx/macosxioutils.o
- $(CC) -O3 $(LDFLAGS) iotestmacosx.o macosx/macosxioutils.o \
- ioutils.o iomethods.o -o wrv.fs -lpthread
-
-iotestlinux.o: iotest.c linux/linuxioutils.c ioutils.c
- @echo ""
- @echo "Building package for Linux"
- @echo ""
- $(CC) -Wall -c -Dlinux -D_LARGEFILE64_SOURCE $(CFLAGS) iotest.c \
- -DNAME='"linux"' -o iotestlinux.o
- $(CC) -Wall -c -Dlinux -D_LARGEFILE64_SOURCE $(CFLAGS) ioutils.c \
- -DNAME='"linux"' -o ioutils.o
- $(CC) -Wall -c -Dlinux -D_LARGEFILE64_SOURCE $(CFLAGS) iomethods.c \
- -DNAME='"linux"' -o iomethods.o
- $(CC) -Wall -c -Dlinux -D_LARGEFILE64_SOURCE $(CFLAGS) linux/linuxioutils.c \
- -DNAME='"linux"' -o linux/linuxioutils.o
-
-
-iotestmacosx.o: iotest.c macosx/macosxioutils.c ioutils.c
- @echo ""
- @echo "Build package for MacOSX"
- @echo ""
- $(CC) -Wall -c -Dmacosx $(CFLAGS) iotest.c \
- -DNAME='"macosx"' -o iotestmacosx.o
- $(CC) -Wall -c -Dmacosx $(CFLAGS) ioutils.c \
- -DNAME='"macosx"' -o ioutils.o
- $(CC) -Wall -c -Dmacosx $(CFLAGS) iomethods.c \
- -DNAME='"macosx"' -o iomethods.o
- $(CC) -Wall -c -Dmacosx $(CFLAGS) macosx/macosxioutils.c \
- -DNAME='"macosx"' -o macosx/macosxioutils.o
View
2,268 wrv/.svn/text-base/iomethods.c.svn-base
@@ -1,2268 +0,0 @@
-/*******************************************************************************
-
-Filename : iomethods.c
-
-Description : This file contains write, read and verify functions for
-mmap/directio/bufferedio.
-
-Copyright (c) 1998-1999 Omneon Video Networks (TM)
-
-OMNEON VIDEO NETWORKS CONFIDENTIAL
-
-*******************************************************************************/
-#include "iotest.h"
-
-#define _FILE_OFFSET_BITS 64
-#define PAGE_SIZE getpagesize()
-#define MAX_ARRAY_SIZE 65356 /* Max size of g_iosizeArray array*/
-
-int g_verifyInitialised = FALSE;
-#if !defined(Windows)
-pthread_mutex_t g_mutex = PTHREAD_MUTEX_INITIALIZER;
-#else
-pthread_mutex_t g_mutex;
-#endif
-uint64 **g_iosizeArray; /* To store the relative offsets and iosize */
-uint64 g_globalArrayIteration;/* No. of times iosizes mentioned in
- * g_iosizeArray will be completely read/written
- */
-uint64 g_sumOfIosizeArray = 0;/* Sum of iosizes mentioned in g_iosizeArray */
-uint64 g_offsetMark; /* Offset mark, incremented by g_sumOfIosizeArray
- * after each iteration of g_iosizeArray
- */
-int32 g_globalArrayCount; /* No. of elements in g_iosizeArray */
-uint64 **g_iosizeSubArray; /* To store the relative offsets and iosize
- which will used after writing
- g_sumOfIosizeArray * g_globalArrayIteration */
-uint64 g_globalSubArrayCount; /* No. of elements in g_iosizeSubArray*/
-uint64 g_sumOfIosizeSubArray; /* Sum of iosizes mentioned in g_iosizeSubArray */
-uint64 g_firstThreadExtraSize = 0;/* Extra size for first thread */
-int g_write = 0;
-int g_status = SUCCESS;
-
-#if defined(Windows)
-struct omFileOperations fops = {
- omMgIoOpenInputFile,
- omMgIoOpenOutputFile,
- omMgIoBufferedDirectSeqRead,
- omMgIoMmapSeqRead,
- omMgIoBufferedDirectSeqRead,
- omMgIoBufferedDirectSeqWrite,
- omMgIoMmapSeqWrite,
- omMgIoBufferedDirectSeqWrite,
- omMgIoBufferedDirectRandomRead,
- omMgIoBufferedDirectRandomRead,
- omMgIoMmapRandomRead,
- omMgIoBufferedDirectRandomWrite,
- omMgIoMmapRandomWrite,
- omMgIoBufferedDirectRandomWrite,
-};
-#else
-struct omFileOperations fops = {
- .openInput = omMgIoOpenInputFile,
- .openOutput = omMgIoOpenOutputFile,
- .readDirectSeq = omMgIoBufferedDirectSeqRead,
- .readDirectRandom = omMgIoBufferedDirectRandomRead,
- .readBufferedSeq = omMgIoBufferedDirectSeqRead,
- .readBufferedRandom = omMgIoBufferedDirectRandomRead,
- .readMmapSeq = omMgIoMmapSeqRead,
- .readMmapRandom = omMgIoMmapRandomRead,
- .writeDirectSeq = omMgIoBufferedDirectSeqWrite,
- .writeDirectRandom = omMgIoBufferedDirectRandomWrite,
- .writeBufferedSeq = omMgIoBufferedDirectSeqWrite,
- .writeBufferedRandom= omMgIoBufferedDirectRandomWrite,
- .writeMmapSeq = omMgIoMmapSeqWrite,
- .writeMmapRandom = omMgIoMmapRandomWrite,
-};
-#endif
-
-
-/*
- * Function : omMgIoCommonAllocateBuffer
- *
- * Description : This function allocates buffer.
- *
- * Parameters :
- * 1. size Size for the the buffer to be allocated.
- *
- * Return Value :
- * Pointer to the filled buffer.
- */
-char* omMgIoCommonAllocateBuffer(int size)
-{
- char *buffer = NULL;
-
- debug("%s\n", __FUNCTION__);
-
- buffer = (char *) malloc(size * sizeof(char));
- if (buffer == NULL) {
- error("Failed to allocate buffer of size %"PRIu32"\n", size);
- exit(ENOMEM);
- }
- debug("Allocated buffer of size %"PRIu32" at address %x \n",
- size, buffer);
- return buffer;
-}
-
-
-/*
- * Function : omMgIoFillBuffer
- *
- * Description : This function fills the buffer with pattern provided.
- *
- * Parameters :
- * 1. buffer Allocated buffer which is to to be filled with the
- * pattern.
- * 2. pattern Pattern.
- * 3. lengthRemaining Size of the buffer.
- *
- */
-void omMgIoFillBuffer(char *buffer, char *pattern, uint64 lengthRemaining)
-{
-
- debug("%s\n", __FUNCTION__);
-
- while (lengthRemaining > 0) {
- if (lengthRemaining > g_patternLen) {
- memcpy(buffer, pattern, g_patternLen);
- } else {
- memcpy(buffer, pattern, (size_t)lengthRemaining);
- break;
- }
- lengthRemaining -= g_patternLen;
- buffer += g_patternLen;
- }
-}
-
-
-/*
- * Function : omMgCollectIoStats
- *
- * Description : This function calculates the io statistics
- *
- */
-void omMgCollectIoStats()
-{
- int32 numThreads = 0;
- int32 i = 0;
- int64 minReadStartTime = 0;
- int64 minWriteStartTime = 0;
- int64 maxReadEndTime = 0;
- int64 maxWriteEndTime = 0;
-
- debug("%s\n", __FUNCTION__);
-
- if (omContext.opcode == OP_READ) {
- numThreads = omContext.numReadThreads;
- } else {
- numThreads = omContext.numWriteThreads;
- }
- for (i = 0; i < numThreads; i++) {
- if ((omMgIoStats[i].readStartTime < minReadStartTime) ||
- (minReadStartTime == 0)) {
- minReadStartTime = omMgIoStats[i].readStartTime;
- }
- if (omMgIoStats[i].readEndTime > maxReadEndTime) {
- maxReadEndTime = omMgIoStats[i].readEndTime;
- }
- if ((omMgIoStats[i].writeStartTime < minWriteStartTime) ||
- (minWriteStartTime == 0)) {
- minWriteStartTime = omMgIoStats[i].writeStartTime;
- }
- if (omMgIoStats[i].writeEndTime > maxWriteEndTime) {
- maxWriteEndTime = omMgIoStats[i].writeEndTime;
- }
- }
- omMgIoPerf.readStartTime = minReadStartTime;
- omMgIoPerf.readEndTime = maxReadEndTime;
- omMgIoPerf.writeStartTime = minWriteStartTime;
- omMgIoPerf.writeEndTime = maxWriteEndTime;
- /* store time in milliseconds */
- omMgIoPerf.readTotalTime = (omMgIoPerf.readEndTime -
- omMgIoPerf.readStartTime) * .001;
- omMgIoPerf.writeTotalTime = (omMgIoPerf.writeEndTime -
- omMgIoPerf.writeStartTime) * .001;
-}
-
-
-/*
- * Function : omMgIoAllocReadBuffer
- *
- * Description : This function chooses the required size
- * for read buffer.
- *
- * Parameters :
- * 1. ioSize iosize
- * 2. patternLen Pattern length
- *
- * Return Value :
- * Pointer to the buffer which is double
- * either iosize or pattern length.
- */
-char* omMgIoAllocReadBuffer(uint64 ioSize, uint32 patternLen)
-{
- char *buffer;
-
- debug("%s\n", __FUNCTION__);
-
- if (ioSize <= patternLen) {
- if ((buffer = omMgIoCommonAllocateBuffer(patternLen *sizeof(char) *
- 2)) == NULL) {
- return NULL;
- }
- } else {
- if ((buffer = omMgIoCommonAllocateBuffer((int)ioSize * sizeof(char) *
- 2)) == NULL) {
- return NULL;
- }
- }
- return buffer;
-}
-
-
-/*
- * Function : omMgIoFillPattern
- *
- * Description : This function chooses the required buffer size
- * and fills it with pattern.
- *
- * Parameters :
- * 1. ioSize iosize
- * 2. patternLen Pattern length
- *
- * Return Value :
- * Pointer to the buffer which is double
- * either iosize or pattern length.
- */
-char* omMgIoFillPattern(uint64 ioSize, uint32 patternLen)
-{
- char *buffer;
-
- debug("%s\n", __FUNCTION__);
-
- if (ioSize <= patternLen) {
- if ((buffer = omMgIoCommonAllocateBuffer(patternLen *sizeof(char) *
- 2)) == NULL) {
- return NULL;
- }
- omMgIoFillBuffer(buffer, g_pattern, patternLen * 2);
- } else {
- if ((buffer = omMgIoCommonAllocateBuffer((int)ioSize * sizeof(char) *
- 2)) == NULL) {
- return NULL;
- }
- omMgIoFillBuffer(buffer, g_pattern, ioSize * 2);
- }
- return buffer;
-}
-
-
-/*
- * Function : getArrayCount
- *
- * Description : This function calculates the number elements for global
- * array which contains offser and iosize.
- *
- * Parameters :
- *
- * Return Value :
- * Returns the number elements for global array .
- */
-uint64 getArrayCount(uint64 size)
-{
- uint64 iosize;
- uint64 count = 0;
-
- debug("%s\n", __FUNCTION__);
-
- srand48(omContext.seed);
- while (size > 0) {
- if (g_randomIosize) {
- if (omContext.opcode == OP_READ) {
- iosize = (lrand48() % (omContext.rarguments.maxBlockSize +
- 1 - omContext.rarguments.minBlockSize) +
- omContext.rarguments.minBlockSize);
- } else {
- iosize = (lrand48() % (omContext.warguments.maxBlockSize +
- 1 - omContext.warguments.minBlockSize) +
- omContext.warguments.minBlockSize);
- }
- } else {
- if (omContext.opcode == OP_READ) {
- iosize = omContext.rarguments.blockSize;
- } else {
- iosize = omContext.warguments.blockSize;
- }
- }
- count++;
- if (size <= iosize) {
- break;
- } else {
- size -= iosize;
- }
- }
- return count;
-}
-
-
-/*
- * Function : createGlobalSubArray
- *
- * Description : This function created the global random array which
- * contains offser and iosize.This fuction is called
- * only when total size is greater than
- * (g_globalArrayIteration * g_sumOfIosizeArray * noOfThreads)
- *
- * Parameters :
- * size Remaining size in bytes.
- * total size - (g_globalArrayIteration * g_sumOfIosizeArray *
- * noOfThreads)
- *
- * Return Value :
- */
-void createGlobalSubArray(uint64 size)
-{
- uint64 i = 0;
- uint64 offset;
- uint64 iosize;
- uint64 sizeRemaining;
- uint64 sizePerThread;
- uint64 bigRand;
- uint64 subArrayCount;
- uint32 noOfThreads;
- uint64 *tmp;
- uint64 directIoOps = 0;
- uint64 directIoOpsPerThread;
-
- debug("%s\n", __FUNCTION__);
-
- offset = g_globalArrayIteration * g_offsetMark;
- if (omContext.opcode == OP_READ) {
- noOfThreads = omContext.numReadThreads;
- directIoOps = size / g_sectorSize;
- directIoOpsPerThread = directIoOps / noOfThreads;
- } else {
- noOfThreads = omContext.numWriteThreads;
- directIoOps = size / g_sectorSize;
- directIoOpsPerThread = directIoOps / noOfThreads;
- }
- if (omContext.warguments.rwflag == IO_DIRECT ||
- omContext.rarguments.rwflag == IO_DIRECT) {
- sizePerThread = directIoOpsPerThread * g_sectorSize;
- } else {
- sizePerThread = (size / noOfThreads);
- }
- subArrayCount = getArrayCount(sizePerThread);
- g_globalSubArrayCount = subArrayCount;
- g_iosizeSubArray = (uint64 **)malloc((size_t)(sizeof(uint64 *) *
- subArrayCount));
- if (g_iosizeSubArray == NULL) {
- error("malloc failed \n");
- exit(ENOMEM);
- }
- for (i = 0; i < subArrayCount; i++) {
- g_iosizeSubArray[i] = malloc(2 * sizeof(uint64));
- if (g_iosizeSubArray[i] == NULL) {
- error("malloc failed \n");
- exit(ENOMEM);
- }
- }
- srand48(omContext.seed);
- sizeRemaining = sizePerThread;
- for (i = 0; i < subArrayCount; i++) {
- if (g_randomIosize) {
- if (omContext.opcode == OP_READ) {
- iosize = (lrand48() % (omContext.rarguments.maxBlockSize +
- 1 - omContext.rarguments.minBlockSize) +
- omContext.rarguments.minBlockSize);
- } else {
- iosize = (lrand48() % (omContext.warguments.maxBlockSize +
- 1 - omContext.warguments.minBlockSize) +
- omContext.warguments.minBlockSize);
- }
- } else {
- if (omContext.opcode == OP_READ) {
- iosize = omContext.rarguments.blockSize;
- } else {
- iosize = omContext.warguments.blockSize;
- }
- }
- if (sizeRemaining < iosize) {
- g_iosizeSubArray[i][1] = sizeRemaining;
- } else {
- g_iosizeSubArray[i][1] = iosize;
- }
- g_iosizeSubArray[i][0] = offset;
- offset += g_iosizeSubArray[i][1] * omContext.sparseFactor;
- g_sumOfIosizeSubArray += g_iosizeSubArray[i][1];
- sizeRemaining -= iosize;
- }
- /* Randomizing g_ig_iosizeSubArray */
- srand48(omContext.seed);
- for (i = 0; i < subArrayCount; i++) {
- bigRand = lrand48();
- bigRand = bigRand % subArrayCount;
- tmp = g_iosizeSubArray[i];
- g_iosizeSubArray[i] = g_iosizeSubArray[bigRand];
- g_iosizeSubArray[bigRand] = tmp;
- }
- /* Calculate the extra size which will be given for first thread.*/
- if (omContext.opcode == OP_READ) {
- g_firstThreadExtraSize = omContext.rarguments.size -
- (omContext.numReadThreads *
- ((g_sumOfIosizeArray *
- g_globalArrayIteration) +
- (g_sumOfIosizeSubArray *
- g_globalSubArrayCount)));
- } else {
- g_firstThreadExtraSize = omContext.warguments.size -
- (omContext.numWriteThreads *
- ((g_sumOfIosizeArray *
- g_globalArrayIteration) +
- (g_sumOfIosizeSubArray)));
- }
-}
-
-
-/*
- * Function : createGlobalArray
- *
- * Description : This function created the global random array which
- * contains offser and iosize.
- *
- * Parameters :
- * size Total read/write size in bytes.
- *
- * Return Value :
- */
-void createGlobalArray(uint64 size)
-{
- uint64 i = 0;
- uint64 offset = 0;
- uint64 iosize;
- uint64 sizeRemaining;
- uint64 sizePerThread;
- uint64 bigRand;
- uint64 arrayCount;
- uint32 noOfThreads;
- uint64 *tmp;
- uint64 subSize;
- uint64 directIoOps = 0;
- uint64 directIoOpsPerThread;
-
- debug("%s\n", __FUNCTION__);
-
- if (omContext.opcode == OP_READ) {
- noOfThreads = omContext.numReadThreads;
- directIoOps = omContext.rarguments.size / g_sectorSize;
- directIoOpsPerThread = directIoOps / noOfThreads;
- } else {
- noOfThreads = omContext.numWriteThreads;
- directIoOps = omContext.warguments.size / g_sectorSize;
- directIoOpsPerThread = directIoOps / noOfThreads;
- }
- if (omContext.warguments.rwflag == IO_DIRECT ||
- omContext.rarguments.rwflag == IO_DIRECT) {
- sizePerThread = directIoOpsPerThread * g_sectorSize;
- } else {
- sizePerThread = (size / noOfThreads);
- }
- arrayCount = getArrayCount(sizePerThread);
- if (MAX_ARRAY_SIZE < arrayCount) {
- arrayCount = MAX_ARRAY_SIZE;
- }
- g_globalArrayCount = (int32)arrayCount;
- g_iosizeArray = (uint64 **)malloc((size_t)(sizeof(uint64 *) * arrayCount));
- if (g_iosizeArray == NULL) {
- error("malloc failed \n");
- exit(ENOMEM);
- }
- for (i = 0; i < arrayCount; i++) {
- g_iosizeArray[i] = malloc(2 * sizeof(uint64));
- if (g_iosizeArray[i] == NULL) {
- error("malloc failed \n");
- exit(ENOMEM);
- }
- }
- srand48(omContext.seed);
- sizeRemaining = sizePerThread;
- for (i = 0; i < arrayCount; i++) {
- if (g_randomIosize) {
- if (omContext.opcode == OP_READ) {
- iosize = (lrand48() % (omContext.rarguments.maxBlockSize +
- 1 - omContext.rarguments.minBlockSize) +
- omContext.rarguments.minBlockSize);
- } else {
- iosize = (lrand48() % (omContext.warguments.maxBlockSize +
- 1 - omContext.warguments.minBlockSize) +
- omContext.warguments.minBlockSize);
- }
- } else {
- if (omContext.opcode == OP_READ) {
- iosize = omContext.rarguments.blockSize;
- } else {
- iosize = omContext.warguments.blockSize;
- }
- }
- if (sizeRemaining < iosize) {
- g_iosizeArray[i][1] = sizeRemaining;
- } else {
- g_iosizeArray[i][1] = iosize;
- }
- g_iosizeArray[i][0] = offset;
- sizeRemaining -= iosize;
- offset += g_iosizeArray[i][1] * omContext.sparseFactor;
- g_sumOfIosizeArray += g_iosizeArray[i][1];
- }
- /* Setting g_offsetMark to the last offset of g_iosizeArray*/
- g_offsetMark = offset;
- /* Calculation for g_globalArrayIteration */
- g_globalArrayIteration = sizePerThread / g_sumOfIosizeArray;
- subSize = size - (g_globalArrayIteration * g_sumOfIosizeArray *
- noOfThreads);
- if (subSize != 0) {
- createGlobalSubArray(subSize);
- }
- /* Randomizing g_iosizeArray */
- srand48(omContext.seed);
- for (i = 0; i < arrayCount; i++) {
- bigRand = lrand48();
- bigRand = bigRand % arrayCount;
- tmp = g_iosizeArray[i];
- g_iosizeArray[i] = g_iosizeArray[bigRand];
- g_iosizeArray[bigRand] = tmp;
- }
-}
-
-
-/*
- * Function : omMgIoBufferedDirectSeqRead
- *
- * Description : This function performs sequential read for buffered and
- * direct I/O.
- *
- * Parameters :
- * 1. fd File descriptor.
- * 2. iostat Pointer to thread specific omMgIoStat structure.
- * Return Value :
- * Returns SUCCESS if read was successful.
- * Returns FAILURE if read failed.
- */
-int omMgIoBufferedDirectSeqRead(int fd, struct omMgIoStat *iostat)
-{
- uint64 sizeRemaining = iostat->size;
- uint64 offset = iostat->start.offset;
- char *buffer = NULL;
- bool finalRead = false;
- uint64 i = 0;
- uint64 iosize;
- uint64 randomSleep;
-
- debug("%s\n", __FUNCTION__);
-
- if (g_randomIosize) {
- if ((buffer = omMgIoAllocReadBuffer(omContext.rarguments.maxBlockSize,
- g_patternLen)) == NULL) {
- return FAILURE;
- }
- } else {
- if ((buffer = omMgIoAllocReadBuffer(omContext.rarguments.blockSize,
- g_patternLen)) == NULL) {
- return FAILURE;
- }
- }
- while (sizeRemaining != 0) {
- if (g_randomIosize) {
- iosize = g_iosizeArray[i][1];
- i++;
- if (i == g_globalArrayCount) {
- i = 0;
- }
- } else {
- iosize = omContext.rarguments.blockSize;
- }
- if ((iosize) <= sizeRemaining) {
- if (omMgIoCommonRead(fd, offset, iosize,
- buffer) == FAILURE) {
- if (buffer != NULL) {
- free(buffer);
- }
- return FAILURE;
- }
- if (omContext.pinterval != NO_PROGRESS) {
- iostat->readDoneCount++;
- }
- } else {
- if (omMgIoCommonRead(fd, offset, sizeRemaining, buffer) ==
- FAILURE) {
- if (buffer != NULL) {
- free(buffer);
- }
- return FAILURE;
- }
- if (omContext.pinterval != NO_PROGRESS) {
- iostat->readDoneCount++;
- }
- finalRead = true;
- }
- if (!g_randomSleep) {
- if (omContext.rarguments.sleep != 0) {
- usleep(omContext.rarguments.sleep);
- }
- } else {
- randomSleep = (rand() % (omContext.rarguments.maxSleep
- + 1 - omContext.rarguments.minSleep)) +
- omContext.rarguments.minSleep;
- usleep(randomSleep);
- }
- if (omContext.verify == TRUE) {
- if (!finalRead) {
- if (omMgIoVerifyBlock(offset, buffer, iosize) == SUCCESS) {
- debug("Verification offset %10"PRIu64" length %10"PRIu64""
- "\n", offset, iosize);
- } else {
- error("Verification offset %10"PRIu64" length %10"PRIu64""
- "\n", offset, iosize);
- }
- } else {
- if (omMgIoVerifyBlock(offset, buffer, sizeRemaining) ==
- SUCCESS) {
- debug("Verification offset %10"PRIu64" length %10"PRIu64""
- "\n", offset, sizeRemaining);
- } else {
- error("Verification offset %10"PRIu64" length %10"PRIu64""
- "\n", offset, sizeRemaining);
- }
- }
- }
- if (omContext.sparseFactor > 1) {
- offset += (omContext.sparseFactor * iosize);
- } else {
- offset += iosize;
- }
- if (!finalRead) {
- sizeRemaining -= (iosize);
- } else {
- sizeRemaining = 0;
- }
- }
- free(buffer);
- return SUCCESS;
-}
-
-
-/*
- * Function : omMgIoBufferedDirectRandomRead
- *
- * Description : This function performs random read for buffered and
- * direct I/O.
- *
- * Parameters :
- * 1. fd File descriptor.
- * 2. iostat Pointer to thread specific omMgIoStat structure.
- * Return Value :
- * Returns SUCCESS if read was successful.
- * Returns FAILURE if read failed.
- */
-int omMgIoBufferedDirectRandomRead(int fd, struct omMgIoStat *iostat)
-{
- uint64 baseOffset = iostat->start.baseOffset;
- uint64 size = iostat->size;
- uint64 i = 0;
- char *buffer = NULL;
- uint64 count = 0;
- uint64 offset;
- uint32 randomSleep;
- uint64 iosize;
- uint64 offsetMark;
- uint64 sizeRemaining;
-
- debug("%s : Baseoffset %"PRIu64" size %"PRIu64"\n", __FUNCTION__,
- baseOffset, size);
-
- if (g_randomIosize) {
- if ((buffer = omMgIoAllocReadBuffer(omContext.rarguments.maxBlockSize,
- g_patternLen)) == NULL) {
- return FAILURE;
- }
- } else {
- if ((buffer = omMgIoAllocReadBuffer(omContext.rarguments.blockSize,
- g_patternLen)) == NULL) {
- return FAILURE;
- }
- }
- /* Do the I/O for (g_globalArrayIteration * g_sumOfIosizeArray) */
- offsetMark = baseOffset;
- for (count = 0; count < g_globalArrayIteration; count++) {
- for (i = 0; i != g_globalArrayCount; i++) {
- offset = g_iosizeArray[i][0] + offsetMark;
- iosize = g_iosizeArray[i][1];
- if (omMgIoCommonRead(fd, offset, iosize,
- buffer) == FAILURE) {
- free(buffer);
- return FAILURE;
- }
- if (omContext.pinterval != NO_PROGRESS) {
- iostat->readDoneCount++;
- }
- if (!g_randomSleep) {
- if (omContext.rarguments.sleep != 0) {
- usleep(omContext.rarguments.sleep);
- }
- } else {
- randomSleep = (uint32)((rand() %
- (omContext.rarguments.maxSleep +
- 1 - omContext.rarguments.minSleep)) +
- (uint32)omContext.rarguments.minSleep);
- usleep(randomSleep);
- }
- if (omContext.verify == TRUE) {
- if (omMgIoVerifyBlock(offset, buffer, iosize) ==
- SUCCESS) {
- debug("Verification offset %10"PRIu64" length %10"PRIu64""
- "\n", offset, iosize);
- } else {
- error("Verification offset %10"PRIu64" length %10"PRIu64""
- "\n", offset, iosize);
- }
- }
- }
- offsetMark += g_offsetMark;
- }
- sizeRemaining = (size - (g_globalArrayIteration * g_sumOfIosizeArray));
- if (sizeRemaining != 0) {
- for (i = 0; i < g_globalSubArrayCount; i++) {
- offset = g_iosizeSubArray[i][0] + baseOffset;
- iosize = g_iosizeSubArray[i][1];
- if (omMgIoCommonRead(fd, offset, iosize,
- buffer) == FAILURE) {
- free(buffer);
- return FAILURE;
- }
- if (omContext.pinterval != NO_PROGRESS) {
- iostat->readDoneCount++;
- }
- if (!g_randomSleep) {
- if (omContext.rarguments.sleep != 0) {
- usleep(omContext.rarguments.sleep);
- }
- } else {
- randomSleep = (uint32)((rand() %
- (omContext.rarguments.maxSleep +
- 1 - omContext.rarguments.minSleep)) +
- omContext.rarguments.minSleep);
- usleep(randomSleep);
- }
- if (omContext.verify == TRUE) {
- if (omMgIoVerifyBlock(offset, buffer, iosize) ==
- SUCCESS) {
- debug("Verification offset %10"PRIu64" length %10"PRIu64""
- "\n", offset, iosize);
- } else {
- error("Verification offset %10"PRIu64" length %10"PRIu64""
- "\n", offset, iosize);
- }
- sizeRemaining -= g_iosizeSubArray[i][1];
- }
- }
- }
- if (g_firstThreadExtraSize != 0) {
- offset = g_sumOfIosizeSubArray + (g_globalArrayIteration *
- g_sumOfIosizeArray);
- if (omMgIoCommonRead(fd, offset, g_firstThreadExtraSize,
- buffer) == FAILURE) {
- free(buffer);
- return FAILURE;
- }
- if (omContext.pinterval != NO_PROGRESS) {
- iostat->readDoneCount++;
- }
- if (!g_randomSleep) {
- if (omContext.rarguments.sleep != 0) {
- usleep(omContext.rarguments.sleep);
- }
- } else {
- randomSleep = (uint32)((rand() % (omContext.rarguments.maxSleep +
- 1 - omContext.rarguments.minSleep)) +
- omContext.rarguments.minSleep);
- usleep(randomSleep);
- }
- if (omContext.verify == TRUE) {
- if (omMgIoVerifyBlock(offset, buffer, g_firstThreadExtraSize) ==
- SUCCESS) {
- debug("Verification offset %10"PRIu64" length %10"PRIu64""
- "\n", offset, g_firstThreadExtraSize);
- } else {
- error("Verification offset %10"PRIu64" length %10"PRIu64""
- "\n", offset, g_firstThreadExtraSize);
- }
- }
- }
- free(buffer);
- return SUCCESS;
-}
-
-
-/*
- * Function : omMgIoMmapSeqRead
- *
- * Description : This function performs mmap sequentitial read.
- *
- * Parameters :
- * 1. fd File descriptor.
- * 2. iostat Pointer to thread specific omMgIoStat structure.
- * Return Value :
- * Returns SUCCESS if read was successful.
- * Returns FAILURE if read failied.
- */
-int omMgIoMmapSeqRead(int fd, struct omMgIoStat *iostat)
-{
- uint64 sizeRemaining = iostat->size;
- uint64 fileOffset = iostat->start.offset;
- void *file_memory = NULL;
- char *buffer = NULL;
- uint64 pageStart = 0;
- uint64 skip = 0;
- bool finalRead = false;
- uint64 i = 0;
- uint64 iosize;
- uint64 pageEnd;
- uint64 inpageOffset;
- uint32 randomSleep;
-
- debug("%s\n", __FUNCTION__);
-
- if (g_randomIosize) {
- if ((buffer = omMgIoAllocReadBuffer(omContext.rarguments.maxBlockSize,
- g_patternLen)) == NULL) {
- return FAILURE;
- }
- } else {
- if ((buffer = omMgIoAllocReadBuffer(omContext.rarguments.blockSize,
- g_patternLen)) == NULL) {
- return FAILURE;
- }
- }
- /* start from the block boundary before the offset */
- while (sizeRemaining != 0) {
- if (g_randomIosize) {
- iosize = g_iosizeArray[i][1];
- i++;
- if (i == g_globalArrayCount) {
- i = 0;
- }
- } else {
- iosize = omContext.rarguments.blockSize;
- }
- pageStart = fileOffset / PAGE_SIZE;
- if(sizeRemaining < PAGE_SIZE) {
- char *tmpBuffer;
- skip = fileOffset % g_patternLen;
- if ((tmpBuffer = omMgIoFillPattern(sizeRemaining,
- g_patternLen)) == NULL) {
- return FAILURE;
- }
- if (omMgIoCommonRead(fd, fileOffset, sizeRemaining,
- tmpBuffer + skip) ==
- FAILURE) {
- if ((buffer != NULL) && (buffer != g_pattern)) {
- free(tmpBuffer);
- free(buffer);
- }
- return FAILURE;
- }
- free(tmpBuffer);
- fileOffset += sizeRemaining;
- sizeRemaining = 0;
- } else {
- if ((iosize) <= sizeRemaining) {
- pageEnd = (fileOffset + iosize + PAGE_SIZE -1) /
- PAGE_SIZE;
- debug("mmap offset %10"PRIu64" page %10"PRIu64"" \
- "size %10" PRIu64"\n", fileOffset, pageStart, iosize);
- } else {
- pageEnd = (fileOffset + sizeRemaining + PAGE_SIZE -1) /
- PAGE_SIZE;
- debug("mmap offset %10"PRIu64" page %10"PRIu64"" \
- "size %10" PRIu64"\n", fileOffset, pageStart,
- sizeRemaining);
- finalRead = true;
- }
- inpageOffset = fileOffset % PAGE_SIZE;
- file_memory = mmap(0, (size_t)((pageEnd - pageStart) * PAGE_SIZE),
- PROT_READ, MAP_SHARED, fd,
- (off_t)(pageStart * PAGE_SIZE));
- if (file_memory == MAP_FAILED) {
- error("mmap failed ! %s\n", strerror(errno));
- if (buffer != NULL) {
- free(buffer);
- }
- return FAILURE;
- }
- if (!finalRead) {
- memcpy(buffer, (char *)(file_memory) + inpageOffset,
- (size_t)iosize);
- munmap(file_memory, (size_t)((pageEnd - pageStart) * PAGE_SIZE));
- } else {
- memcpy(buffer, (char *)(file_memory) + inpageOffset,
- (size_t)sizeRemaining);
- munmap(file_memory, (size_t)((pageEnd - pageStart) * PAGE_SIZE));
- }
- if (omContext.pinterval != NO_PROGRESS) {
- iostat->readDoneCount++;
- }
- if (!g_randomSleep) {
- if (omContext.rarguments.sleep != 0) {
- usleep(omContext.rarguments.sleep);
- }
- } else {
- randomSleep = (uint32)((rand() % (omContext.rarguments.maxSleep +
- 1 - omContext.rarguments.minSleep)) +
- omContext.rarguments.minSleep);
- usleep(randomSleep);
- }
- if (omContext.verify == TRUE) {
- if (!finalRead) {
- if (omMgIoVerifyBlock(fileOffset, buffer, iosize) == SUCCESS) {
- debug("Verification offset %10"PRIu64" length %10"PRIu64""
- "\n", fileOffset, iosize);
- } else {
- error("Verification offset %10"PRIu64" length %10"PRIu64""
- "\n", fileOffset, iosize);
- }
- } else {
- if (omMgIoVerifyBlock(fileOffset, buffer, sizeRemaining) ==
- SUCCESS) {
- debug("Verification offset %10"PRIu64" length %10"PRIu64""
- "\n", fileOffset, sizeRemaining);
- } else {
- error("Verification offset %10"PRIu64" length %10"PRIu64""
- "\n", fileOffset, sizeRemaining);
- }
- }
- }
- if (omContext.sparseFactor > 1) {
- fileOffset += (omContext.sparseFactor * iosize);
- } else {
- fileOffset += iosize;
- }
- sizeRemaining -= iosize;
- if (finalRead) {
- sizeRemaining = 0;
- }
- }
- }
- free(buffer);
- return SUCCESS;
-}
-
-
-/*
- * Function : omMgIoMmapRandomRead
- *
- * Description : This function performs mmap random read.
- *
- * Parameters :
- * 1. fd File descriptor.
- * 2. iostat Pointer to thread specific omMgIoStat structure.
- * Return Value :
- * Returns SUCCESS if read was successful.
- * Returns FAILURE if read failed.
- */
-int omMgIoMmapRandomRead(int fd, struct omMgIoStat *iostat)
-{
- uint64 offset;
- uint64 baseOffset = iostat->start.baseOffset;
- uint64 size = iostat->size;
- void *file_memory = NULL;
- char *buffer = NULL;
- uint64 inpageOffset = 0;
- uint64 pageStart = 0;
- uint64 pageEnd = 0;
- uint64 count = 0;
- uint64 i = 0;
- uint64 randomSleep;
- uint64 offsetMark;
- uint64 iosize;
- uint64 sizeRemaining;
-
- debug("%s : Baseoffset %"PRIu64" size %"PRIu64"\n", __FUNCTION__,
- baseOffset, size);
-
- if (g_randomIosize) {
- if ((buffer = omMgIoAllocReadBuffer(omContext.rarguments.maxBlockSize,
- g_patternLen)) == NULL) {
- return FAILURE;
- }
- } else {
- if ((buffer = omMgIoAllocReadBuffer(omContext.rarguments.blockSize,
- g_patternLen)) == NULL) {
- return FAILURE;
- }
- }
- /* Do the I/O for (g_globalArrayIteration * g_sumOfIosizeArray) */
- offsetMark = baseOffset;
- for (count = 0; count < g_globalArrayIteration; count++) {
- for (i = 0; i != g_globalArrayCount; i++) {
- offset = g_iosizeArray[i][0] + offsetMark;
- iosize = g_iosizeArray[i][1];
- pageStart = offset / PAGE_SIZE;
- pageEnd = (offset + iosize + PAGE_SIZE -1) /
- PAGE_SIZE;
- inpageOffset = offset % PAGE_SIZE;
- file_memory = mmap(0, (size_t)((pageEnd - pageStart) * PAGE_SIZE), PROT_READ,
- MAP_SHARED, fd, (off_t)(pageStart * PAGE_SIZE));
- debug("mmap offset %10"PRIu64" page %10"PRIu64" size %10"
- PRIu64"\n", offset, pageStart, iosize);
- if (file_memory == MAP_FAILED) {
- error("mmap failed ! %s\n", strerror(errno));
- if (buffer != NULL) {
- free(buffer);
- }
- return FAILURE;
- }
- memcpy(buffer, (char *)(file_memory) + inpageOffset,
- (size_t)iosize);
- munmap(file_memory, (size_t)((pageEnd - pageStart) * PAGE_SIZE));
- if (omContext.pinterval != NO_PROGRESS) {
- iostat->readDoneCount++;
- }
- if (!g_randomSleep) {
- if (omContext.rarguments.sleep != 0) {
- usleep(omContext.rarguments.sleep);
- }
- } else {
- randomSleep = (rand() % (omContext.rarguments.maxSleep
- + 1 - omContext.rarguments.minSleep)) +
- omContext.rarguments.minSleep;
- usleep(randomSleep);
- }
- if (omContext.verify == TRUE) {
- if (omMgIoVerifyBlock(offset, buffer, iosize) ==
- SUCCESS) {
- debug("Verification offset %10"PRIu64" length %10"PRIu64""
- "\n", offset, iosize);
- } else {
- error("Verification offset %10"PRIu64" length %10"PRIu64""
- "\n", offset, iosize);
- }
- }
- }
- offsetMark += g_offsetMark;
- }
- sizeRemaining = (size - (g_globalArrayIteration * g_sumOfIosizeArray));
- if (sizeRemaining != 0) {
- for (i = 0; i < g_globalSubArrayCount; i++) {
- offset = g_iosizeSubArray[i][0] + baseOffset;
- iosize = g_iosizeSubArray[i][1];
- pageStart = offset / PAGE_SIZE;
- pageEnd = (offset + iosize + PAGE_SIZE -1) /
- PAGE_SIZE;
- inpageOffset = offset % PAGE_SIZE;
- file_memory = mmap(0, (size_t)((pageEnd - pageStart + 1) * PAGE_SIZE), PROT_READ,
- MAP_SHARED, fd, (off_t)(pageStart * PAGE_SIZE));
- debug("mmap offset %10"PRIu64" page %10"PRIu64" size %10"
- PRIu64"\n", offset, pageStart, iosize);
- if (file_memory == MAP_FAILED) {
- error("mmap failed ! %s\n", strerror(errno));
- if (buffer != NULL) {
- free(buffer);
- }
- return FAILURE;
- }
- memcpy(buffer, (char *)(file_memory) + inpageOffset,
- (size_t)iosize);
- munmap(file_memory, (size_t)((pageEnd - pageStart) * PAGE_SIZE));
- if (omContext.pinterval != NO_PROGRESS) {
- iostat->readDoneCount++;
- }
- if (!g_randomSleep) {
- if (omContext.rarguments.sleep != 0) {
- usleep(omContext.rarguments.sleep);
- }
- } else {
- randomSleep = (rand() % (omContext.rarguments.maxSleep
- + 1 - omContext.rarguments.minSleep)) +
- omContext.rarguments.minSleep;
- usleep(randomSleep);
- }
- if (omContext.verify == TRUE) {
- if (omMgIoVerifyBlock(offset,
- buffer,iosize) == SUCCESS) {
- debug("Verification offset %10"PRIu64" length %10"PRIu64""
- "\n", offset, iosize);
- } else {
- error("Verification offset %10"PRIu64" length %10"PRIu64""
- "\n", offset, iosize);
- }
- }
- sizeRemaining -= iosize;
- }
- }
- if (g_firstThreadExtraSize != 0) {
- offset = g_sumOfIosizeSubArray + (g_globalArrayIteration *
- g_sumOfIosizeArray);
- pageStart = offset / PAGE_SIZE;
- pageEnd = (offset + g_firstThreadExtraSize + PAGE_SIZE -1) /
- PAGE_SIZE;
- inpageOffset = offset % PAGE_SIZE;
- file_memory = mmap(0, (size_t)((pageEnd - pageStart + 1) * PAGE_SIZE), PROT_READ,
- MAP_SHARED, fd, (off_t)(pageStart * PAGE_SIZE));
- debug("mmap offset %10"PRIu64" page %10"PRIu64" size %10"
- PRIu64"\n", offset, pageStart, g_firstThreadExtraSize);
- if (file_memory == MAP_FAILED) {
- error("mmap failed ! %s\n", strerror(errno));
- if (buffer != NULL) {
- free(buffer);
- }
- return FAILURE;
- }
- memcpy(buffer, (char *)(file_memory) + inpageOffset,
- (size_t)g_firstThreadExtraSize);
- munmap(file_memory, (size_t)((pageEnd - pageStart) * PAGE_SIZE));
- if (omContext.pinterval != NO_PROGRESS) {
- iostat->readDoneCount++;
- }
- if (!g_randomSleep) {
- if (omContext.rarguments.sleep != 0) {
- usleep(omContext.rarguments.sleep);
- }
- } else {
- randomSleep = (rand() % (omContext.rarguments.maxSleep
- + 1 - omContext.rarguments.minSleep)) +
- omContext.rarguments.minSleep;
- usleep(randomSleep);
- }
- if (omContext.verify == TRUE) {
- if (omMgIoVerifyBlock(offset,
- buffer,g_firstThreadExtraSize) == SUCCESS) {
- debug("Verification offset %10"PRIu64" length %10"PRIu64""
- "\n", offset, g_firstThreadExtraSize);
- } else {
- error("Verification offset %10"PRIu64" length %10"PRIu64""
- "\n", offset, g_firstThreadExtraSize);
- }
- }
- }
- free(buffer);
- return SUCCESS;
-}
-
-/*
- * Function : omMgIoBufferedDirectSeqWrite
- *
- * Description : This function performs seq write for buffered and
- * direct I/O.
- *
- * Parameters :
- * 1. fd File descriptor.
- * 2. iostat Pointer to thread specific omMgIoStat structure.
- * Return Value :
- * Returns SUCCESS if write was successful.
- * Returns FAILURE if write failed.
- */
-int omMgIoBufferedDirectSeqWrite(int fd, struct omMgIoStat *iostat)
-
-{
- uint64 sizeRemaining = iostat->size;
- uint64 offset = iostat->start.offset;
- char *buffer = NULL;
- uint64 skip = 0;
- bool finalWrite = false;
- uint64 i = 0;
- uint64 iosize;
- uint32 randomSleep;
-
- debug("%s\n", __FUNCTION__);
-
- if (g_randomIosize) {
- if ((buffer = omMgIoFillPattern(omContext.warguments.maxBlockSize,
- g_patternLen)) == NULL) {
- return FAILURE;
- }
- } else {
- if ((buffer = omMgIoFillPattern(omContext.warguments.blockSize,
- g_patternLen)) == NULL) {
- return FAILURE;
- }
- }
- while (sizeRemaining != 0) {
- if (g_randomIosize) {
- iosize = g_iosizeArray[i][1];
- i++;
- if (i == g_globalArrayCount) {
- i = 0;
- }
- } else {
- iosize = omContext.warguments.blockSize;
- }
- skip = (offset % g_patternLen);
- if ((iosize) <= sizeRemaining) {
- if (omMgIoCommonWrite(fd, offset, iosize,
- buffer + skip) == FAILURE) {
- if (buffer != NULL && (buffer != g_pattern)) {
- free(buffer);
- }
- return FAILURE;
- }
- if (omContext.pinterval != NO_PROGRESS) {
- iostat->writeDoneCount++;
- }
- } else {
- if (omMgIoCommonWrite(fd, offset, sizeRemaining, buffer + skip) ==
- FAILURE) {
- if ((buffer != NULL) && (buffer != g_pattern))
- free(buffer);
- return FAILURE;
- }
- if (omContext.pinterval != NO_PROGRESS) {
- iostat->writeDoneCount++;
- }
- finalWrite = true;
- }
- if (!g_randomSleep) {
- if (omContext.warguments.sleep != 0) {
- usleep(omContext.warguments.sleep);
- }
- } else {
- randomSleep = (uint32)((rand() % (omContext.warguments.maxSleep +
- 1 - omContext.warguments.minSleep)) +
- omContext.warguments.minSleep);
- usleep(randomSleep);
- }
- if (omContext.sparseFactor > 1) {
- offset += (omContext.sparseFactor * iosize);
- } else {
- offset += iosize;
- }
- if (!finalWrite) {
- sizeRemaining -= (iosize);
- } else {
- sizeRemaining = 0;
- }
- }
- free(buffer);
- return SUCCESS;
-}
-
-
-/*
- * Function : omMgIoBufferedDirectRandomWrite
- *
- * Description : This function performs random write for buffered and
- * direct I/O.
- *
- * Parameters :
- * 1. fd File descriptor.
- * 2. iostat Pointer to thread specific omMgIoStat structure.
- * Return Value :
- * Returns SUCCESS if write was successful.
- * Returns FAILURE if write failed.
- */
-int omMgIoBufferedDirectRandomWrite(int fd, struct omMgIoStat *iostat)
-{
- uint64 baseOffset = iostat->start.baseOffset;
- uint64 size = iostat->size;
- uint64 i = 0;
- uint64 skip = 0;
- uint64 count = 0;
- uint64 offset;
- char *buffer;
- uint32 randomSleep;
- uint64 iosize;
- uint64 offsetMark;
- uint64 sizeRemaining;
-
- debug("%s : Baseoffset %"PRIu64" size %"PRIu64"\n", __FUNCTION__,
- baseOffset, size);
-
-
- if (g_randomIosize) {
- if ((buffer = omMgIoFillPattern(omContext.warguments.maxBlockSize,
- g_patternLen)) == NULL) {
- return FAILURE;
- }
- } else {
- if ((buffer = omMgIoFillPattern(omContext.warguments.blockSize,
- g_patternLen)) == NULL) {
- return FAILURE;
- }
- }
- /* Do the I/O for (g_globalArrayIteration * g_sumOfIosizeArray) */
- offsetMark = baseOffset;
- for (count = 0; count < g_globalArrayIteration; count++) {
- for (i = 0; i != g_globalArrayCount; i++) {
- offset = g_iosizeArray[i][0] + offsetMark;
- skip = offset % g_patternLen;
- iosize = g_iosizeArray[i][1];
- if (omMgIoCommonWrite(fd, offset, iosize,
- buffer + skip) == FAILURE) {
- if (buffer != NULL)
- free(buffer);
- return FAILURE;
- }
- if (omContext.pinterval != NO_PROGRESS) {
- iostat->writeDoneCount++;
- }
- if (!g_randomSleep) {
- if (omContext.warguments.sleep != 0) {
- usleep(omContext.warguments.sleep);
- }
- } else {
- randomSleep = (uint32)((rand() % (omContext.warguments.maxSleep +
- 1 - omContext.warguments.minSleep)) +
- omContext.warguments.minSleep);
- usleep(randomSleep);
- }
- }
- offsetMark += g_offsetMark;
- }
- sizeRemaining = (size - (g_globalArrayIteration * g_sumOfIosizeArray));
- if (sizeRemaining != 0) {
- for (i = 0; i < g_globalSubArrayCount; i++) {
- offset = g_iosizeSubArray[i][0] + baseOffset;
- skip = offset % g_patternLen;
- iosize = g_iosizeSubArray[i][1];
- if (omMgIoCommonWrite(fd, offset, iosize,
- buffer + skip) == FAILURE) {
- if (buffer != NULL)
- free(buffer);
- return FAILURE;
- }
- if (omContext.pinterval != NO_PROGRESS) {
- iostat->writeDoneCount++;
- }
- if (!g_randomSleep) {
- if (omContext.warguments.sleep != 0) {
- usleep(omContext.warguments.sleep);
- }
- } else {
- randomSleep = (uint32)((rand() % (omContext.warguments.maxSleep +
- 1 - omContext.warguments.minSleep)) +
- omContext.warguments.minSleep);
- usleep(randomSleep);
- }
- sizeRemaining -= g_iosizeSubArray[i][1];
- }
- }
- if (g_firstThreadExtraSize != 0) {
- offset = g_sumOfIosizeSubArray + (g_globalArrayIteration *
- g_sumOfIosizeArray);
- skip = offset % g_patternLen;
- if (omMgIoCommonWrite(fd, offset, g_firstThreadExtraSize,
- buffer + skip) == FAILURE) {
- if (buffer != NULL)
- free(buffer);
- return FAILURE;
- }
- if (!g_randomSleep) {
- if (omContext.warguments.sleep != 0) {
- usleep(omContext.warguments.sleep);
- }
- } else {
- randomSleep = (uint32)((rand() % (omContext.warguments.maxSleep +
- 1 - omContext.warguments.minSleep)) +
- omContext.warguments.minSleep);
- usleep(randomSleep);
- }
- }
- free(buffer);
- return SUCCESS;
-}
-
-
-/*
- * Function : omMgIoMmapSeqWrite
- *
- * Description : This function performs mmap sequential write.
- *
- * Parameters :
- * 1. fd File descriptor.
- * 2. iostat Pointer to thread specific omMgIoStat structure.
- * Return Value :
- * Returns SUCCESS if write was successful.
- * Returns FAILURE if write failed.
- */
-int omMgIoMmapSeqWrite(int fd, struct omMgIoStat *iostat)
-{
- uint64 sizeRemaining = iostat->size;
- uint64 fileOffset = iostat->start.offset;
- void *file_memory = NULL;
- char *buffer = NULL;
- uint64 skip = 0;
- uint64 pageEnd = 0;
- uint64 pageStart = 0;
- bool finalWrite = false;
- uint64 i = 0;
- uint64 iosize;
- uint64 inpageOffset;
- uint32 randomSleep;
-
- debug("%s\n", __FUNCTION__);
-
- if (g_randomIosize) {
- if ((buffer = omMgIoFillPattern(omContext.warguments.maxBlockSize,
- g_patternLen)) == NULL) {
- return FAILURE;
- }
- } else {
- if ((buffer = omMgIoFillPattern(omContext.warguments.blockSize,
- g_patternLen)) == NULL) {
- return FAILURE;
- }
- }
- while (sizeRemaining != 0) {
- if (g_randomIosize) {
- iosize = g_iosizeArray[i][1];
- i++;
- if (i == g_globalArrayCount) {
- i = 0;
- }
- } else {
- iosize = omContext.warguments.blockSize;
- }
-
- pageStart = fileOffset / PAGE_SIZE;
- if(sizeRemaining < PAGE_SIZE) {
- char *tmpBuffer;
- skip = fileOffset % g_patternLen;
- if ((tmpBuffer = omMgIoFillPattern(sizeRemaining,g_patternLen)) == NULL) {
- return FAILURE;
- }
- if (omMgIoCommonWrite(fd, fileOffset, sizeRemaining, tmpBuffer + skip) ==
- FAILURE) {
- if ((buffer != NULL) && (buffer != g_pattern)) {
- free(tmpBuffer);
- free(buffer);
- }
- return FAILURE;
- }
- free(tmpBuffer);
- fileOffset += sizeRemaining;
- sizeRemaining = 0;
- } else {
- if ((iosize) <= sizeRemaining) {
- pageEnd = (fileOffset + iosize + PAGE_SIZE - 1) /
- PAGE_SIZE;
- debug("mmap offset %10"PRIu64" page %10"PRIu64" size %10"
- PRIu64"\n", fileOffset, pageStart, iosize);
- } else {
- pageEnd = (fileOffset + sizeRemaining + PAGE_SIZE - 1) /
- PAGE_SIZE;
- debug("mmap offset %10"PRIu64" page %10"PRIu64" size %10"
- PRIu64"\n", fileOffset, pageStart, sizeRemaining);
- finalWrite = true;
- }
- inpageOffset = fileOffset % PAGE_SIZE;
-
- file_memory = mmap(0, (size_t)((pageEnd - pageStart) * PAGE_SIZE),
- PROT_READ | PROT_WRITE, MAP_SHARED,
- fd, (off_t)(pageStart * PAGE_SIZE));
- if (file_memory == MAP_FAILED) {
- error("mmap failed ! %s\n", strerror(errno));
- if (buffer != NULL) {
- free(buffer);
- }
- return FAILURE;
- }
- skip = fileOffset % g_patternLen;
- if (omContext.sparseFactor > 1) {
- fileOffset += (omContext.sparseFactor * iosize);
- } else {
- fileOffset += iosize;
- }
- if (!finalWrite) {
- memcpy((char *)(file_memory) + inpageOffset, buffer + skip,
- (size_t)iosize);
- munmap(file_memory, (size_t)((pageEnd - pageStart) * PAGE_SIZE));
- sizeRemaining -= iosize;
- } else {
- memcpy((char *)(file_memory) + inpageOffset, buffer + skip,
- (size_t)sizeRemaining);
- munmap(file_memory, (size_t)((pageEnd - pageStart) * PAGE_SIZE));
- fileOffset += sizeRemaining;
- sizeRemaining = 0;
- }
- }
- if (omContext.pinterval != NO_PROGRESS) {
- iostat->writeDoneCount++;
- }
- if (!g_randomSleep) {
- if (omContext.warguments.sleep != 0) {
- usleep(omContext.warguments.sleep);
- }
- } else {
- randomSleep = (uint32)((rand() % (omContext.warguments.maxSleep +
- 1 - omContext.warguments.minSleep)) +
- omContext.warguments.minSleep);
- usleep(randomSleep);
- }
- }
- free(buffer);
- return SUCCESS;
-}
-
-
-/*
- * Function : omMgIoMmapRandomWrite
- *
- * Description : This function performs mmap random write.
- *
- * Parameters :
- * 1. fd File descriptor.
- * 2. iostat Pointer to thread specific omMgIoStat structure.
- * Return Value :
- * Returns SUCCESS if write was successful.
- * Returns FAILURE if write failed.
- */
-int omMgIoMmapRandomWrite(int fd, struct omMgIoStat *iostat)
-{
-
- uint64 offset;
- uint64 baseOffset = iostat->start.baseOffset;
- uint64 size = iostat->size;
- void *file_memory = NULL;
- char *buffer = NULL;
- uint64 skip = 0;
- uint64 inpageOffset = 0;
- uint64 pageStart = 0;
- uint64 pageEnd = 0;
- uint32 randomSleep;
- uint64 count = 0;
- uint64 i = 0;
- uint64 offsetMark;
- uint64 iosize;
- uint64 sizeRemaining;
-
- debug("%s : Baseoffset %"PRIu64" size %"PRIu64"\n", __FUNCTION__,
- baseOffset, size);
-
- if (g_randomIosize) {
- if ((buffer = omMgIoFillPattern(omContext.warguments.maxBlockSize,
- g_patternLen)) == NULL) {
- return FAILURE;
- }
- } else {
- if ((buffer = omMgIoFillPattern(omContext.warguments.blockSize,
- g_patternLen)) == NULL) {
- return FAILURE;
- }
- }
- /* Do the I/O for (g_globalArrayIteration * g_sumOfIosizeArray) */
- offsetMark = baseOffset;
- for (count = 0; count < g_globalArrayIteration; count++) {
- for (i = 0; i != g_globalArrayCount; i++) {
- offset = g_iosizeArray[i][0] + offsetMark;
- skip = offset % g_patternLen;
- iosize = g_iosizeArray[i][1];
- pageStart = offset / PAGE_SIZE;
- pageEnd = (offset + iosize + PAGE_SIZE -1) /
- PAGE_SIZE;
- inpageOffset = offset % PAGE_SIZE;
- file_memory = mmap(0, (size_t)((pageEnd - pageStart) * PAGE_SIZE), PROT_READ |
- PROT_WRITE, MAP_SHARED, fd,
- (off_t)(pageStart * PAGE_SIZE));
- debug("mmap offset %10"PRIu64" page %10"PRIu64" size %10"
- PRIu64"\n", offset, pageStart, iosize);
- if (file_memory == MAP_FAILED) {
- error("mmap failed ! %s\n", strerror(errno));
- if (buffer != NULL) {
- free(buffer);
- }
- return FAILURE;
- }
- memcpy((char *)(file_memory) + inpageOffset, buffer + skip,
- (size_t)iosize);
- munmap(file_memory, (size_t)((pageEnd - pageStart) * PAGE_SIZE));
- if (omContext.pinterval != NO_PROGRESS) {
- iostat->writeDoneCount++;
- }
- if (!g_randomSleep) {
- if (omContext.warguments.sleep != 0) {
- usleep(omContext.warguments.sleep);
- }
- } else {
- randomSleep = (uint32)((rand() % (omContext.warguments.maxSleep +
- 1 - omContext.warguments.minSleep)) +
- omContext.warguments.minSleep);
- usleep(randomSleep);
- }
- }
- offsetMark += g_offsetMark;
- }
- sizeRemaining = (size - (g_globalArrayIteration * g_sumOfIosizeArray));
- if (sizeRemaining != 0) {
- for (i = 0; i < g_globalSubArrayCount; i++) {
- offset = g_iosizeSubArray[i][0] + baseOffset;
- iosize = g_iosizeSubArray[i][1];
- skip = offset % g_patternLen;
- pageStart = offset / PAGE_SIZE;
- pageEnd = (offset + iosize + PAGE_SIZE -1) /
- PAGE_SIZE;
- inpageOffset = offset % PAGE_SIZE;
- file_memory = mmap(0, (size_t)((pageEnd - pageStart) * PAGE_SIZE), PROT_READ |
- PROT_WRITE, MAP_SHARED, fd, (off_t)(pageStart * PAGE_SIZE));
- debug("mmap offset %10"PRIu64" page %10"PRIu64" size %10"
- PRIu64"\n", offset, pageStart, iosize);
- if (file_memory == MAP_FAILED) {
- error("mmap failed ! %s\n", strerror(errno));
- if (buffer != NULL) {
- free(buffer);
- }
- return FAILURE;
- }
- memcpy((char *)(file_memory) + inpageOffset, buffer + skip,
- (size_t)iosize);
- munmap(file_memory, (size_t)((pageEnd - pageStart) * PAGE_SIZE));
- if (omContext.pinterval != NO_PROGRESS) {
- iostat->writeDoneCount++;
- }
- if (!g_randomSleep) {
- if (omContext.warguments.sleep != 0) {
- usleep(omContext.warguments.sleep);
- }
- } else {
- randomSleep = (uint32)((rand() % (omContext.warguments.maxSleep +
- 1 - omContext.warguments.minSleep)) +
- omContext.warguments.minSleep);
- usleep(randomSleep);
- }
- sizeRemaining -= iosize;
- }
- }
- if (g_firstThreadExtraSize != 0) {
- offset = g_sumOfIosizeSubArray + (g_globalArrayIteration *
- g_sumOfIosizeArray);
- skip = offset % g_patternLen;
- pageStart = offset / PAGE_SIZE;
- pageEnd = (offset + g_firstThreadExtraSize + PAGE_SIZE -1) /
- PAGE_SIZE;
- inpageOffset = offset % PAGE_SIZE;
- file_memory = mmap(0, (size_t)((pageEnd - pageStart) * PAGE_SIZE), PROT_READ |
- PROT_WRITE, MAP_SHARED, fd,
- (off_t)(pageStart * PAGE_SIZE));
- debug("mmap offset %10"PRIu64" page %10"PRIu64" size %10"
- PRIu64"\n", offset, pageStart, iosize);
- if (file_memory == MAP_FAILED) {
- error("mmap failed ! %s\n", strerror(errno));
- if (buffer != NULL) {
- free(buffer);
- }
- return FAILURE;
- }
- memcpy((char *)(file_memory) + inpageOffset, buffer + skip,
- (size_t)g_firstThreadExtraSize);
- munmap(file_memory, (size_t)((pageEnd - pageStart) * PAGE_SIZE));
- if (!g_randomSleep) {
- if (omContext.warguments.sleep != 0) {
- usleep(omContext.warguments.sleep);
- }
- } else {
- randomSleep = (uint32)((rand() % (omContext.warguments.maxSleep +
- 1 - omContext.warguments.minSleep)) +
- omContext.warguments.minSleep);
- usleep(randomSleep);
- }
- }
- free(buffer);
- return SUCCESS;
-}
-
-
-/*
- * Function : omMgIoMmapRead
- *
- * Description : This function performs mmap read.
- *
- * Parameters :
- * 1. fd File descriptor.
- * 2. iostat Pointer to thread specific omMgIoStat structure.
- * Return Value :
- * Calls Mmap read function according to the sequence.
- * Returns FAILURE otherwise.
- */
-int omMgIoMmapRead(int fd, struct omMgIoStat *iostat)
-{
-
- debug("%s\n", __FUNCTION__);
-
- if (omContext.sequence == IO_SEQUENCE) {
- return fops.readMmapSeq(fd, iostat);
- } else if (omContext.sequence == IO_RANDOM) {
- return fops.readMmapRandom(fd, iostat);
- }
- return FAILURE;
-}
-
-
-/*
- * Function : omMgIoBufferedRead
- *
- * Description : This function performs buffered read.
- *
- * Parameters :
- * 1. fd File descriptor.
- * 2. iostat Pointer to thread specific omMgIoStat structure.
- * Return Value :
- * Calls Buffered I/O read function according to the sequence.
- * Returns FAILURE otherwise.
- */
-int omMgIoBufferedRead(int fd, struct omMgIoStat *iostat)
-{
-
- debug("%s\n", __FUNCTION__);
-
- if (omContext.sequence == IO_SEQUENCE) {
- return fops.readBufferedSeq(fd, iostat);
- } else if (omContext.sequence == IO_RANDOM) {
- return fops.readBufferedRandom(fd, iostat);
- }
- return FAILURE;
-}
-
-
-/*
- * Function : omMgIoDirectRead
- *
- * Description : This function performs direct read.
- *
- * Parameters :
- * 1. fd File descriptor.
- * 2. iostat Pointer to thread specific omMgIoStat structure.
- * Return Value :
- * Calls Direct I/O read function according to the sequence.
- * Returns FAILURE otherwise.
- */
-int omMgIoDirectRead(int fd, struct omMgIoStat *iostat)
-{
-
- debug("%s\n", __FUNCTION__);
-
- if (omContext.sequence == IO_SEQUENCE) {
- return fops.readDirectSeq(fd, iostat);
- } else if (omContext.sequence == IO_RANDOM) {
- return fops.readDirectRandom(fd, iostat);
- }
- return FAILURE;
-}
-
-
-/*
- * Function : omMgIoMmapWrite
- *
- * Description : This function performs mmap write.
- *
- * Parameters :
- * 1. fd File descriptor.
- * 2. iostat Pointer to thread specific omMgIoStat structure.
- * Return Value :
- * Calls Mmap write function according to the sequence.
- * Returns FAILURE otherwise.
- */
-int omMgIoMmapWrite(int fd, struct omMgIoStat *iostat)
-{
-
- debug("%s\n", __FUNCTION__);
-
- if (omContext.sequence == IO_SEQUENCE) {
- return fops.writeMmapSeq(fd, iostat);
- } else if (omContext.sequence == IO_RANDOM) {
- return fops.writeMmapRandom(fd, iostat);
- }
- return FAILURE;
-}
-
-
-/*
- * Function : omMgIoDirectWrite
- *
- * Description : This function performs direct write.
- *
- * Parameters :
- * 1. fd File descriptor.
- * 2. iostat Pointer to thread specific omMgIoStat structure.
- * Return Value :
- * Calls Direct I/O write function according to the
- * sequence.
- * Returns FAILURE otherwise.
- */
-int omMgIoDirectWrite(int fd, struct omMgIoStat *iostat)
-{
-
- debug("%s\n", __FUNCTION__);
-
- if (omContext.sequence == IO_SEQUENCE) {
- return fops.writeDirectSeq(fd, iostat);
- } else if (omContext.sequence == IO_RANDOM) {
- return fops.writeDirectRandom(fd, iostat);
- }
- return FAILURE;
-}
-
-
-/*
- * Function : omMgIoBufferedWrite
- *
- * Description : This function performs buffered write.
- *
- * Parameters :
- * 1. fd File descriptor.
- * 2. iostat Pointer to thread specific omMgIoStat structure.
- * Return Value :
- * Calls Buffered I/O write function according to the sequence.
- * Returns FAILURE otherwise.
- */
-int omMgIoBufferedWrite(int fd, struct omMgIoStat *iostat)
-{
-
- debug("%s\n", __FUNCTION__);
-
- if (omContext.sequence == IO_SEQUENCE) {
- return fops.writeBufferedSeq(fd, iostat);
- } else if (omContext.sequence == IO_RANDOM) {
- return fops.writeBufferedRandom(fd, iostat);
- }
- return FAILURE;
-}
-
-
-/*
- * Function : omMgIoWrite
- *
- * Description : This function performs write.
- *
- * Parameters :
- * 1. fd File descriptor.
- * 2. iostat Pointer to thread specific omMgIoStat structure.
- * Return Value :
- * Calls write function according to the I/O method .
- * Returns FAILURE otherwise.
- */
-int omMgIoWrite(int fd, struct omMgIoStat *iostat)
-{
-
- debug("%s\n", __FUNCTION__);
-
- if (omContext.warguments.rwflag == IO_MMAP) {
- return omMgIoMmapWrite(fd, iostat);
- } else if (omContext.warguments.rwflag == IO_DIRECT) {
- return omMgIoDirectWrite(fd, iostat);
- } else if (omContext.warguments.rwflag == IO_BUFFERED) {
- return omMgIoBufferedWrite(fd, iostat);
- }
- return FAILURE;
-}
-
-
-/*
- * Function : omMgIoRead
- *
- * Description : This function performs read.
- *
- * Parameters :
- * 1. fd File descriptor.
- * 2. iostat Pointer to thread specific omMgIoStat structure.
- * Return Value :
- * Calls read function according to the I/O method .
- * Returns FAILURE otherwise.
- */
-int omMgIoRead(int fd, struct omMgIoStat *iostat)
-{
-
- debug("%s\n", __FUNCTION__);
-
- if (omContext.rarguments.rwflag == IO_MMAP) {
- return omMgIoMmapRead(fd, iostat);
- } else if (omContext.rarguments.rwflag == IO_DIRECT) {
- return omMgIoDirectRead(fd, iostat);
- } else if (omContext.rarguments.rwflag == IO_BUFFERED) {
- return omMgIoBufferedRead(fd, iostat);
- }
- return FAILURE;
-}
-
-
-/*
- * Function : omMgIoReportCorruption
- *
- * Description : This function reports corruption.
- */
-void omMgIoReportCorruption(uint64 offset, int size, char *buffer,
- char *pattern, uint64 skip)
-{
- FILE *fp;
-
- debug("%s\n", __FUNCTION__);
-
- fp = fopen(omContext.corruptionFile, "a");
- fprintf(fp,"%.8s..%.8s (%.10"PRIu64", %.10"PRIu64")\n",buffer,
- (buffer + size - 8), offset, offset + size);
- fclose(fp);
-}
-
-
-/*
- * Function : omMgIoVerifyBlock
- *
- * Description : This function verifies block read
- *
- * Parameters :
- * 1. offset Offset with file.
- * 2. buffer Read buffer
- * Return Value :
- * Returns SUCCESS if the block is verified.
- * Returns FAILURE if the verification failed.
- *
- */
-int omMgIoVerifyBlock(uint64 offset, char *buffer, uint64 iosize)
-{
- uint64 skip =0;
-
- debug("%s\n", __FUNCTION__);
-
- skip = offset % g_patternLen;
- if (memcmp(buffer, g_patternBuffer + skip, (size_t)iosize)
- == 0) {
- return SUCCESS;
- } else {
- #ifdef Windows
- pthread_mutex_init(&g_mutex);
- #endif
- pthread_mutex_lock(&g_mutex);
- omMgIoPerf.failedVerifyOps++;
- omMgIoReportCorruption(offset, (int)iosize , buffer,
- g_patternBuffer, skip);
- pthread_mutex_unlock(&g_mutex);
- #ifdef Windows
- pthread_mutex_destroy(&g_mutex);
- #endif
- return FAILURE;
- }
-}
-
-
-/*
- * Function : omMgIoVerifyInit
- *
- * Description : This function intializes verification structures.
- *
- * Parameters :
- * Return Value :
- * Returns SUCCESS if the verification structures
- * intilizes successfully.
- * Returns FAILURE if the verification structure
- * intilaization fails.
- */
-int omMgIoVerifyInit()
-{
-
- debug("%s\n", __FUNCTION__);
- if (g_verifyInitialised == TRUE) {
- return SUCCESS;
- }
-
- if (g_randomIosize) {
- if (omContext.rarguments.maxBlockSize <= g_patternLen) {
- if ((g_patternBuffer = omMgIoCommonAllocateBuffer(g_patternLen *
- sizeof(char) * 2))
- == NULL) {
- return FAILURE;
- }
- omMgIoFillBuffer(g_patternBuffer, g_pattern, g_patternLen * 2);
- } else {
- if ((g_patternBuffer = omMgIoCommonAllocateBuffer(
- (int)(omContext.rarguments.maxBlockSize *
- sizeof(char) * 2))) == NULL) {
- return FAILURE;
- }
- omMgIoFillBuffer(g_patternBuffer, g_pattern,
- omContext.rarguments.maxBlockSize * 2);
- }
- } else {
- if (omContext.rarguments.blockSize <= g_patternLen) {
- if ((g_patternBuffer = omMgIoCommonAllocateBuffer(g_patternLen *
- sizeof(char) * 2))
- == NULL) {
- return FAILURE;
- }
- omMgIoFillBuffer(g_patternBuffer, g_pattern, g_patternLen * 2);
- } else {
- if ((g_patternBuffer = omMgIoCommonAllocateBuffer((int)(
- omContext.rarguments.blockSize *
- sizeof(char) * 2))) == NULL) {
- return FAILURE;
- }
- omMgIoFillBuffer(g_patternBuffer, g_pattern,
- omContext.rarguments.blockSize * 2);
- }
- }
- omMgIoPerf.failedVerifyOps = 0;
- snprintf(omContext.corruptionFile,sizeof(omContext.corruptionFile),
- "corruption_log_%d", getpid());
- debug("using corruption log file %s\n", omContext.corruptionFile);
- g_verifyInitialised = TRUE;
- return SUCCESS;
-}
-
-
-/*
- * Function : omMgExecuteTcThread
- *
- * Description : This function executes the thead.
- */
-void *omMgExecuteTcThread(void *argument)
-{
- struct omMgIoStat *omMgIoStat = argument;
- int16 opcode;
- int retRead;
- int retWrite;
-
- debug("%s\n", __FUNCTION__);
-
- opcode = omContext.opcode;
- if (opcode == OP_WRITE) {
- if (fops.openOutput(&(omMgIoStat->outFileDesc)) == FAILURE) {
- exit(-1);
- }
- omMgIoStat->writeStartTime = omMgTimeElapsed();
- retWrite = omMgIoWrite(omMgIoStat->outFileDesc, omMgIoStat);
- if (retWrite == FAILURE) {
- g_status = FAILURE;
- error("Write failed\n");
- exit(FAILURE);
- }
- omMgIoStat->writeEndTime = omMgTimeElapsed();
- close(omMgIoStat->outFileDesc);
- if (omContext.verify == TRUE) {
- omContext.rarguments.offset = omContext.warguments.offset;
- omContext.rarguments.count = omContext.warguments.count;
- omContext.rarguments.size = omContext.warguments.size;
- omContext.rarguments.blockSize = omContext.warguments.blockSize;
- omContext.rarguments.minBlockSize =
- omContext.warguments.minBlockSize;
- omContext.rarguments.maxBlockSize =
- omContext.warguments.maxBlockSize;
- omContext.rarguments.minSleep = omContext.warguments.minSleep;
- omContext.rarguments.maxSleep = omContext.warguments.maxSleep;
- if (g_verifyInitialised == FALSE) {
- debug("Initialising the verification structures\n");
- #ifdef Windows
- pthread_mutex_init(&g_mutex);
- #endif
- pthread_mutex_lock(&g_mutex);
- omMgIoVerifyInit();
- pthread_mutex_unlock(&g_mutex);
- #ifdef Windows
- pthread_mutex_destroy(&g_mutex);
- #endif
- }
- strcpy(omContext.inputFile, omContext.outputFile);
- if (fops.openInput(&(omMgIoStat->inpFileDesc)) == FAILURE) {
- exit(-1);
- }
- omMgIoStat->readStartTime = omMgTimeElapsed();
- retRead = omMgIoRead(omMgIoStat->inpFileDesc, omMgIoStat);
- if (retRead == FAILURE) {
- g_status = FAILURE;
- error("Read failed\n");
- exit(FAILURE);
- }
- omMgIoStat->readEndTime = omMgTimeElapsed();
- close(omMgIoStat->inpFileDesc);
- }
- } else {
- if (fops.openInput(&(omMgIoStat->inpFileDesc)) == FAILURE) {
- exit(-1);
- }
- if (g_verifyInitialised == FALSE) {
- debug("Initialising the verification structures\n");
- #ifdef Windows
- pthread_mutex_init(&g_mutex);
- #endif
- pthread_mutex_lock(&g_mutex);
- omMgIoVerifyInit();
- pthread_mutex_unlock(&g_mutex);
- #ifdef Windows