diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index bc79293b..e976da99 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -9,9 +9,7 @@ include_directories( ) # copied from configure.ac -# removed __INTEL__ and _FILE_OFFSET_BITS=64 -add_compile_definitions(LINUX) -add_compile_definitions(SG_IO) +# removed __INTEL__, _FILE_OFFSET_BITS=64, LINUX, and SG_IO add_compile_definitions(_GNU_SOURCE) # should probably move this to individual files that need it add_compile_definitions(PACKAGE_STRING="${PACKAGE_STRING}") add_compile_definitions(PACKAGE_VERSION="${PACKAGE_VERSION}") diff --git a/src/base/io_buffers.c b/src/base/io_buffers.c index db3c611a..01eb6e8c 100644 --- a/src/base/io_buffers.c +++ b/src/base/io_buffers.c @@ -15,20 +15,17 @@ * used by the Worker Threads. */ #include "xint.h" -#ifdef DARWIN -#include -#endif /*----------------------------------------------------------------------------*/ /* xdd_init_io_buffers() - set up the I/O buffers * This routine will allocate the memory used as the I/O buffer for a Worker - * Thread. The pointer to the buffer (wd_bufp) and the size of the buffer + * Thread. The pointer to the buffer (wd_bufp) and the size of the buffer * (wd_buf_size) are set in the Worker Data Struct. * * This routine will return the pointer to the buffer upon success. If for - * some reason the buffer cannot be allocated then NULL is returned. + * some reason the buffer cannot be allocated then NULL is returned. * - * For some operating systems, you can use a shared memory segment instead of + * For some operating systems, you can use a shared memory segment instead of * a normal malloc/valloc memory chunk. This is done using the "-sharedmemory" * command line option. * @@ -54,8 +51,8 @@ * | |<-Header->| data buffer | * +-----*----------*-----------------------------------------------------+ * ^ ^ - * ^ +-e2e_datap - * +-e2e_hdrp + * ^ +-e2e_datap + * +-e2e_hdrp */ unsigned char * xdd_init_io_buffers(worker_data_t *wdp) { @@ -66,9 +63,6 @@ xdd_init_io_buffers(worker_data_t *wdp) { int buffer_size; // Size of buffer in bytes int page_size; // Size of a page of memory int pages; // Size of buffer in pages -#ifdef WIN32 - LPVOID lpMsgBuf; /* Used for the error messages */ -#endif tdp = wdp->wd_tdp; wdp->wd_bufp = NULL; @@ -81,7 +75,7 @@ xdd_init_io_buffers(worker_data_t *wdp) { pages++; // Round up to page size if ((tdp->td_target_options & TO_ENDTOEND)) { // Add one page for the e2e header - pages++; + pages++; // If its XNI, add another page for XNI, better would be for XNI to // pack all of the header data (and do the hton, ntoh calls) @@ -91,22 +85,15 @@ xdd_init_io_buffers(worker_data_t *wdp) { } } - + // This is the actual size of the I/O buffer buffer_size = pages * page_size; /* Check to see if we want to use a shared memory segment and allocate it using shmget() and shmat(). - * NOTE: This is not supported by all operating systems. + * NOTE: This is not supported by all operating systems. */ if (tdp->td_target_options & TO_SHARED_MEMORY) { -#if (AIX || LINUX || SOLARIS || DARWIN || FREEBSD) - /* In AIX we need to get memory in a shared memory segment to avoid - * the system continually trying to pin each page on every I/O operation */ -#if (AIX) - buf_shmid = shmget(IPC_PRIVATE, buffer_size, IPC_CREAT | SHM_LGPAGE |SHM_PIN ); -#else buf_shmid = shmget(IPC_PRIVATE, buffer_size, IPC_CREAT ); -#endif if (buf_shmid < 0) { fprintf(xgp->errout,"%s: Cannot create shared memory segment\n", xgp->progname); perror("Reason"); @@ -124,53 +111,23 @@ xdd_init_io_buffers(worker_data_t *wdp) { } if (xgp->global_options & GO_REALLYVERBOSE) fprintf(xgp->output,"Shared Memory ID allocated and attached, shmid=%d\n",buf_shmid); -#elif (IRIX || WIN32 ) - fprintf(xgp->errout,"%s: Shared Memory not supported on this OS - using valloc\n", - xgp->progname); - tdp->td_target_options &= ~TO_SHARED_MEMORY; -#if (IRIX || SOLARIS || LINUX || AIX || DARWIN || FREEBSD) bufp = valloc(buffer_size); -#else - bufp = malloc(buffer_size); -#endif -#endif } else { /* Allocate memory the normal way */ -#if (AIX || LINUX) posix_memalign((void **)&bufp, sysconf(_SC_PAGESIZE), buffer_size); -#elif (IRIX || SOLARIS || LINUX || DARWIN || FREEBSD) - bufp = valloc(buffer_size); -#else - bufp = malloc(buffer_size); -#endif } /* Check to see if we really allocated some memory */ if (bufp == NULL) { fprintf(xgp->errout,"%s: cannot allocate %d bytes of memory for I/O buffer\n", xgp->progname,buffer_size); fflush(xgp->errout); -#ifdef WIN32 - FormatMessage( - FORMAT_MESSAGE_ALLOCATE_BUFFER | - FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, - GetLastError(), - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language - (LPTSTR) &lpMsgBuf, - 0, - NULL); - fprintf(xgp->errout,"Reason:%s",lpMsgBuf); - fflush(xgp->errout); -#else perror("Reason"); -#endif return(NULL); } /* Memory allocation must have succeeded */ /* Lock all pages in memory */ xdd_lock_memory(bufp, buffer_size, "RW BUFFER"); - + wdp->wd_bufp_allocated = TRUE; wdp->wd_bufp = bufp; wdp->wd_buf_size = buffer_size; @@ -178,7 +135,7 @@ xdd_init_io_buffers(worker_data_t *wdp) { return(bufp); } /* end of xdd_init_io_buffers() */ - + /* * Local variables: * indent-tabs-mode: t diff --git a/src/base/target_cleanup.c b/src/base/target_cleanup.c index 586e194d..d9f82e45 100644 --- a/src/base/target_cleanup.c +++ b/src/base/target_cleanup.c @@ -15,10 +15,10 @@ #include "xint.h" /*----------------------------------------------------------------------------*/ -/* xdd_target_thread_cleanup() - Perform termination processing of this +/* xdd_target_thread_cleanup() - Perform termination processing of this * this Target thread. * Return Values: 0 is good, -1 indicates an error but what are ya gonna do? - * + * */ void xdd_target_thread_cleanup(target_data_t *tdp) { @@ -35,7 +35,7 @@ xdd_target_thread_cleanup(target_data_t *tdp) { // get the next Worker in this chain wdp = wdp->wd_next_wdp; } - + /* We need to close all file descriptors opened by worker threads in islocal e2e connection */ if (tdp->td_planp->plan_options & PLAN_ENDTOEND_LOCAL) { wdp = tdp->td_next_wdp; @@ -53,11 +53,7 @@ xdd_target_thread_cleanup(target_data_t *tdp) { if (tdp->td_planp->plan_options & PLAN_ENDTOEND_LOCAL) { xdd_targetpass_e2e_remove_islocal(tdp); } else { -#ifdef WIN32 - DeleteFile(tdp->td_target_full_pathname); -#else unlink(tdp->td_target_full_pathname); -#endif } } @@ -92,6 +88,5 @@ xdd_target_thread_cleanup(target_data_t *tdp) { perror("reason"); } } - -} // End of xdd_target_thread_cleanup() +} // End of xdd_target_thread_cleanup() diff --git a/src/base/target_init.c b/src/base/target_init.c index 2d2112e1..499199c2 100644 --- a/src/base/target_init.c +++ b/src/base/target_init.c @@ -37,14 +37,7 @@ xint_target_init(target_data_t *tdp) { // nclk_t TimeDelta; // Used the init the Global Clock // uint32_t sleepseconds; - -#if (AIX) - tdp->td_thread_id = thread_self(); -#elif (LINUX) tdp->td_thread_id = syscall(SYS_gettid); -#else - tdp->td_thread_id = tdp->td_pid; -#endif // Set the pass number tdp->td_counters.tc_pass_number = 1; diff --git a/src/base/target_open.c b/src/base/target_open.c index ac35f5a5..0accafb8 100644 --- a/src/base/target_open.c +++ b/src/base/target_open.c @@ -11,21 +11,21 @@ * */ /* - * This file contains the subroutines that perform an "open" operation + * This file contains the subroutines that perform an "open" operation * on the target device/file. */ #include "xint.h" #include /*----------------------------------------------------------------------------*/ -/* xdd_target_open() - open the target device and do all necessary +/* xdd_target_open() - open the target device and do all necessary * sanity checks. This routine simply calls the appropriate open routine * for the given operating system it is compiled for. - * Each of the open routines will set the file descriptor in the Target Data - * Struct to an appropriate value. If the open routine succeeds then a - * successful status of 0 (zero) is returned. - * Otherwise, a -1 returned to indicate there was an error. - * The OS-specific open routine will issue the appropriate error messages. + * Each of the open routines will set the file descriptor in the Target Data + * Struct to an appropriate value. If the open routine succeeds then a + * successful status of 0 (zero) is returned. + * Otherwise, a -1 returned to indicate there was an error. + * The OS-specific open routine will issue the appropriate error messages. */ int32_t xdd_target_open(target_data_t *tdp) { @@ -78,9 +78,6 @@ xdd_target_reopen(target_data_t *tdp) { // Close the existing target -#if (WIN32) - CloseHandle(tdp->td_file_desc); -#else status = close(tdp->td_file_desc); if (status != 0) { /* error opening target */ fprintf(xgp->errout, "%s: xdd_target_reopen: ERROR: Aborting I/O for target number %d " @@ -91,15 +88,10 @@ xdd_target_reopen(target_data_t *tdp) { fflush(xgp->errout); xgp->abort = 1; } -#endif - // If we need to "recreate" the file for each pass then we should delete it here before we re-open it - if (tdp->td_target_options & TO_RECREATE) { -#ifdef WIN32 - DeleteFile(tdp->td_target_full_pathname); -#else + // If we need to "recreate" the file for each pass then we should delete it here before we re-open it + if (tdp->td_target_options & TO_RECREATE) { unlink(tdp->td_target_full_pathname); -#endif } /* open the old/new/recreated target file */ status = xdd_target_open(tdp); @@ -120,14 +112,14 @@ xdd_target_reopen(target_data_t *tdp) { * doing the open, simply copy the file descriptor from the target thread. * Only works for Worker Threads spawned from a target thread that has already * opened the file, and OS that support pread/pwrite. - * Otherwise, a -1 returned to indicate there was an error. + * Otherwise, a -1 returned to indicate there was an error. */ int32_t xdd_target_shallow_open(worker_data_t *wdp) { target_data_t *tdp; tdp = wdp->wd_tdp; - + // If this is a NULL target then don't bother opening it if (tdp->td_target_options & TO_NULL_TARGET) return(0); @@ -152,13 +144,13 @@ xdd_target_shallow_open(worker_data_t *wdp) { perror("reason"); return(-1); } - + return(0); } // End of xdd_target_shallow_open() /*----------------------------------------------------------------------------*/ -/* xdd_target_name() - Generate the name of the target +/* xdd_target_name() - Generate the name of the target */ void xdd_target_name(target_data_t *tdp) { @@ -171,7 +163,7 @@ xdd_target_name(target_data_t *tdp) { !(tdp->td_planp->plan_options & PLAN_ENDTOEND_LOCAL)) { // Create a new file name for this target sprintf(tdp->td_target_extension,"%08d",tdp->td_counters.tc_pass_number); } - + /* create the fully qualified target name */ memset(target_full_pathname,0,sizeof(target_full_pathname)); if (strlen(tdp->td_target_directory) > 0) { @@ -181,7 +173,7 @@ xdd_target_name(target_data_t *tdp) { sprintf(target_full_pathname, "%s",tdp->td_target_basename); } - if ((tdp->td_target_options & TO_CREATE_NEW_FILES) && + if ((tdp->td_target_options & TO_CREATE_NEW_FILES) && !(tdp->td_planp->plan_options & PLAN_ENDTOEND_LOCAL)) { // Add the target extension to the name strcat(target_full_pathname, "."); strcat(target_full_pathname, tdp->td_target_extension); @@ -195,7 +187,7 @@ xdd_target_name(target_data_t *tdp) { } // End of xdd_target_name() /*----------------------------------------------------------------------------*/ -/* xdd_target_existence_check() - Check to see if the target exists. +/* xdd_target_existence_check() - Check to see if the target exists. * Return -1 is it does not exist and this is a read or 0 if it does exist. */ int32_t @@ -205,11 +197,7 @@ xdd_target_existence_check(target_data_t *tdp) { /* Stat the file before it is opened */ -#if (AIX || SOLARIS) - status = stat64(tdp->td_target_full_pathname,&tdp->td_statbuf); -#else // All other OSs use stat status = stat(tdp->td_target_full_pathname,&tdp->td_statbuf); -#endif // If stat did not work then it could be that the file does not exist. // For write operations this is ok because the file will just be created. @@ -218,7 +206,7 @@ xdd_target_existence_check(target_data_t *tdp) { // If this is a read or a mixed read/write operation then issue an // error message and return a -1 indicating an error on open. // - if (status < 0) { + if (status < 0) { if ((ENOENT == errno) && (tdp->td_rwratio == 0.0)) { // File does not yet exist tdp->td_target_options |= TO_REGULARFILE; fprintf(xgp->errout, "%s: xdd_target_existence_check: NOTICE: target number %d name %s does not " @@ -264,7 +252,7 @@ xdd_target_existence_check(target_data_t *tdp) { xgp->progname, tdp->td_target_number, tdp->td_target_full_pathname, - (long long)tdp->td_statbuf.st_size, + (long long)tdp->td_statbuf.st_size, (long long)tdp->td_target_bytes_to_xfer_per_pass); fflush(xgp->errout); } @@ -288,11 +276,10 @@ xdd_target_existence_check(target_data_t *tdp) { /* OS-specific Open Routines */ /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ -#if LINUX /*----------------------------------------------------------------------------*/ /* xdd_target_open_for_linux() - Open routine for linux - * This routine currently always returns 0. - * The "td_file_desc" member of the Target Data Struct is the actual return + * This routine currently always returns 0. + * The "td_file_desc" member of the Target Data Struct is the actual return * value from the open() system call and will indicate if there was an error. * The errno should also be valid upon return from this subroutine. */ @@ -300,13 +287,13 @@ int32_t xdd_target_open_for_os(target_data_t *tdp) { // Set the Open Flags to indicate DirectIO if requested - if (tdp->td_target_options & TO_DIO) + if (tdp->td_target_options & TO_DIO) tdp->td_open_flags |= O_DIRECT; else tdp->td_open_flags &= ~O_DIRECT; // Check to see if this is a SCSI Generic (/dev/sg) device - SPECIFIC to LINUX - if (tdp->td_target_options & TO_DEVICEFILE) { - if (strncmp(tdp->td_target_full_pathname, "/dev/sg", 7) == 0 ) // is this an "sg" device? + if (tdp->td_target_options & TO_DEVICEFILE) { + if (strncmp(tdp->td_target_full_pathname, "/dev/sg", 7) == 0 ) // is this an "sg" device? tdp->td_target_options |= TO_SGIO; // Yes - turn on SGIO Mode } @@ -359,7 +346,7 @@ xdd_target_open_for_os(target_data_t *tdp) { if (xgp->global_options & GO_DEBUG_OPEN) { fprintf(stderr, "DEBUG_OPEN: %lld: xdd_target_open_for_os: Target: %d: Worker: %d: " - "READ ONLY: file_desc: %d\n ", + "READ ONLY: file_desc: %d\n ", (long long int)pclk_now(), tdp->td_target_number, tdp->td_queue_depth, @@ -383,223 +370,6 @@ xdd_target_open_for_os(target_data_t *tdp) { return(0); } // End of xdd_target_open_for_linux() -#endif - -#if AIX -/*----------------------------------------------------------------------------*/ -/* xdd_target_open_for_aix() - Open routine for aix - */ -int32_t -xdd_target_open_for_os(target_data_t *tdp) { - // Set the Open Flags to indicate DirectIO if requested - if (tdp->td_target_options & TO_DIO) - tdp->td_open_flags |= O_DIRECT; - else tdp->td_open_flags &= ~O_DIRECT; - - /* open the target */ - if (tdp->td_rwratio == 0.0) { - tdp->td_file_desc = open(tdp->td_target_full_pathname,tdp->td_open_flags|O_WRONLY, 0666); /* write only */ - } else if (tdp->td_rwratio == 1.0) { /* read only */ - tdp->td_open_flags &= ~O_CREAT; - tdp->td_file_desc = open(tdp->td_target_full_pathname,tdp->td_open_flags|O_RDONLY, 0777); /* Read only */ - } else if ((tdp->td_rwratio > 0.0) && (tdp->td_rwratio < 1.0)) { /* read/write mix */ - tdp->td_open_flags &= ~O_CREAT; - tdp->td_file_desc = open(tdp->td_target_full_pathname,tdp->td_open_flags|O_RDWR, 0666); - } - - return(0); -} // End of xdd_target_open_for_aix() -#endif - -#if DARWIN -/*----------------------------------------------------------------------------*/ -/* xdd_target_open_for_darwin() - Open routine for aix - */ -int32_t -xdd_target_open_for_os(target_data_t *tdp) { - /* open the target */ - if (tdp->td_rwratio == 0.0) { - tdp->td_file_desc = open(tdp->td_target_full_pathname,tdp->td_open_flags|O_WRONLY, 0666); /* write only */ - } else if (tdp->td_rwratio == 1.0) { /* read only */ - tdp->td_open_flags &= ~O_CREAT; - tdp->td_file_desc = open(tdp->td_target_full_pathname,tdp->td_open_flags|O_RDONLY, 0777); /* Read only */ - } else if ((tdp->td_rwratio > 0.0) && (tdp->td_rwratio < 1.0)) { /* read/write mix */ - tdp->td_open_flags &= ~O_CREAT; - tdp->td_file_desc = open(tdp->td_target_full_pathname,tdp->td_open_flags|O_RDWR, 0666); - } - - // Modify the file control to allow direct I/O if requested - if (tdp->td_target_options & TO_DIO) - fcntl(tdp->td_file_desc, F_NOCACHE, 1); - - return(0); -} // End of xdd_target_open_for_darwin() -#endif - -#if SOLARIS -/*----------------------------------------------------------------------------*/ -/* xdd_target_open_for_solaris() - Open routine for solaris - */ -int32_t -xdd_target_open_for_os(target_data_t *tdp) { - struct stat64 statbuf; /* buffer for file statistics */ - - flags |= O_LARGEFILE; -//////////////////////////////tbd ////////////////////////////////////////////// - /* setup for DIRECTIO & perform sanity checks */ - if (tdp->td_target_options & TO_DIO) { - /* make sure it is a regular file, otherwise fail */ - if ( (statbuf.st_mode & S_IFMT) != S_IFREG) { - fprintf(xgp->errout, "%s: xdd_open_target: ERROR: Target number %d name %s " - "must be a regular file when used with the -dio flag\n", - xgp->progname, - tdp->td_target_number, - target_full_pathname); - fflush(xgp->errout); - return(-1); - } - i = directio(fd,DIRECTIO_ON); - if (i < 0) { - fprintf(xgp->errout, "%s: xdd_open_target: ERROR: Could not set DIRECTIO flag " - "for target number %d name %s\n", - xgp->progname, - tdp->td_target_number, - target_full_pathname); - fflush(xgp->errout); - perror("reason"); - return(-1); - } - } /* end of IF stmnt that opens with DIO */ - // Generic 64-bit UNIX open stuff - for Solaris, AIX, FREEBSD, and Darwin - if (tdp->td_rwratio == 0.0) { - fd = open64(target_full_pathname,flags|O_WRONLY, 0666); /* write only */ - } else if (tdp->td_rwratio == 1.0) { /* read only */ - flags &= ~O_CREAT; - fd = open64(target_full_pathname,flags|O_RDONLY, 0777); /* Read only */ - } else if ((tdp->td_rwratio > 0.0) && (tdp->td_rwratio < 1.0)) { /* read/write mix */ - flags &= ~O_CREAT; - fd = open64(target_full_pathname,flags|O_RDWR, 0666); - } - /* setup for DIRECTIO & perform sanity checks */ - if (tdp->td_target_options & TO_DIO) { - status = directio(tdp->td_file_desc,DIRECTIO_ON); - if (status < 0) { - fprintf(xgp->errout, "%s: xdd_open_target: ERROR: Could not set DIRECTIO flag " - "for target number %d name %s\n", - xgp->progname, - tdp->td_target_number, - tdp->td_target_full_pathname); - fflush(xgp->errout); - perror("reason"); - return(-1); - } - } - return(0); -} // End of xdd_target_open_for_solaris() -#endif - -#ifdef WIN32 -/*----------------------------------------------------------------------------*/ -/* xdd_target_open_for_windows() - Open routine for Windows - */ -int32_t -xdd_target_open_for_os(target_data_t *tdp) { - HANDLE hfile; /* The file handle */ - LPVOID lpMsgBuf; /* Used for the error messages */ - unsigned long flags; /* Open flags */ - DWORD disp; - - // Check to see if this is a "device" target - must have \\.\ before the name - // Otherwise, it is assumed that this is a regular file - if (strncmp(target_full_pathname,"\\\\.\\",4) == 0) { // This is a device file *not* a regular file - tdp->td_target_options |= TO_DEVICEFILE; - p->target_options &= ~TO_REGULARFILE; - } - else { // This is a regular file *not* a device file - p->target_options &= ~TO_DEVICEFILE; - p->target_options |= TO_REGULARFILE; - } - - // We can only create new files if the target is a regular file (not a device file) - if ((p->target_options & TO_CREATE_NEW_FILES) && (p->target_options & TO_REGULARFILE)) { - // Add the target extension to the name - strcat(target_full_pathname, "."); - strcat(target_full_pathname, p->target_extension); - } - - /* open the target */ - if (p->target_options & TO_DIO) - flags = FILE_FLAG_NO_BUFFERING; - else flags = 0; - /* Device files and files that are being read MUST exist - * in order to be opened. For files that are being written, - * they can be created if they do not exist or use the existing one. - */ - if ((p->target_options & TO_DEVICEFILE) || (p->rwratio == 1.0)) - disp = OPEN_EXISTING; - else if (p->rwratio < 1.0) - disp = OPEN_ALWAYS; - else disp = OPEN_EXISTING; - - nclk_now(&p->open_start_time); // Record the starting time of the open - - if (p->rwratio < 1.0) { /* open for write operations */ - hfile = CreateFile(target_full_pathname, - GENERIC_WRITE | GENERIC_READ, - (FILE_SHARE_WRITE | FILE_SHARE_READ), - (LPSECURITY_ATTRIBUTES)NULL, - disp, - flags, - (HANDLE)NULL); - } else if (p->rwratio == 0.0) { /* write only */ - hfile = CreateFile(target_full_pathname, - GENERIC_WRITE, - (FILE_SHARE_WRITE | FILE_SHARE_READ), - (LPSECURITY_ATTRIBUTES)NULL, - disp, - flags, - (HANDLE)NULL); - } else if ((p->rwratio > 0.0) && p->rwratio < 1.0) { /* read/write mix */ - hfile = CreateFile(target_full_pathname, - GENERIC_WRITE | GENERIC_READ, - (FILE_SHARE_WRITE | FILE_SHARE_READ), - (LPSECURITY_ATTRIBUTES)NULL, - disp, - flags, - (HANDLE)NULL); - } else { /* open for read operations */ - hfile = CreateFile(target_full_pathname, - GENERIC_READ, - (FILE_SHARE_WRITE | FILE_SHARE_READ), - (LPSECURITY_ATTRIBUTES)NULL, - disp, - flags, - (HANDLE)NULL); - } - if (hfile == INVALID_HANDLE_VALUE) { - FormatMessage( - FORMAT_MESSAGE_ALLOCATE_BUFFER | - FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, - GetLastError(), - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language - (LPTSTR) &lpMsgBuf, - 0, - NULL); - fprintf(xgp->errout, "%s: xdd_open_target: Could not open target for %s: %s\n", - xgp->progname, - (p->rwratio < 1.0) ? "write" : "read", - target_full_pathname); - fprintf(xgp->errout, "reason:%s", lpMsgBuf); - fflush(xgp->errout); - return((void *)-1); - } - - nclk_now(&p->open_end_time); // Record the ending time of the open - return(hfile); -} // End of xdd_target_open_for_windows() -#endif /* * Local variables: diff --git a/src/base/target_pass_e2e_specific.c b/src/base/target_pass_e2e_specific.c index 144ea08e..02028f5b 100644 --- a/src/base/target_pass_e2e_specific.c +++ b/src/base/target_pass_e2e_specific.c @@ -11,7 +11,7 @@ * */ /* - * This file contains the subroutines used by target_pass() or targetpass_loop() + * This file contains the subroutines used by target_pass() or targetpass_loop() * that are specific to an End-to-End (E2E) operation. */ #include "xint.h" @@ -19,9 +19,9 @@ /*----------------------------------------------------------------------------*/ /* xdd_targetpass_e2e_loop_dst() - This subroutine will manage assigning tasks to * Worker Threads during an E2E operation but only on the destination side of an - * E2E operation. + * E2E operation. * Called from xdd_targetpass() - * + * */ void xdd_targetpass_e2e_loop_dst(xdd_plan_t* planp, target_data_t *tdp) { @@ -35,12 +35,12 @@ xdd_targetpass_e2e_loop_dst(xdd_plan_t* planp, target_data_t *tdp) { // of bytes it has assigned to be transferred until the number of bytes remaining // becomes zero. // This task assignment loop is based on the availability of Worker Threads to perform - // I/O tasks - namely a recvfrom/write task which is specific to the + // I/O tasks - namely a recvfrom/write task which is specific to the // Destination Side of an E2E operation. Each Worker Thread will continue to perform - // these recvfrom/write tasks until it receives an End-of-File (EOF) packet from - // the Source Side. At this point that Worker Thread remains "unavailable" but also + // these recvfrom/write tasks until it receives an End-of-File (EOF) packet from + // the Source Side. At this point that Worker Thread remains "unavailable" but also // turns on its "EOF" flag to indicate that it has received an EOF. It will also - // enter the targetpass_worker_thread_passcomplete barrier so that by the time this + // enter the targetpass_worker_thread_passcomplete barrier so that by the time this // subroutine returns, all the Worker Threads will be at the targetpass_worker_thread_passcomplete // barrier. // @@ -52,7 +52,7 @@ xdd_targetpass_e2e_loop_dst(xdd_plan_t* planp, target_data_t *tdp) { wdp = xdd_get_any_available_worker_thread(tdp); //////////////////////////// BEGIN I/O LOOP FOR ENTIRE PASS /////////////////////////////////////////// - while (wdp) { + while (wdp) { // Check to see if we've been canceled - if so, we need to leave this loop if ((xgp->canceled) || (xgp->abort) || (tdp->td_abort)) { @@ -63,7 +63,7 @@ xdd_targetpass_e2e_loop_dst(xdd_plan_t* planp, target_data_t *tdp) { break; } - + // Make sure the Worker Thread does not think the pass is complete // Get the most recent File Descriptor in case it changed... wdp->wd_task.task_file_desc = tdp->td_file_desc; @@ -80,7 +80,7 @@ xdd_targetpass_e2e_loop_dst(xdd_plan_t* planp, target_data_t *tdp) { // If time stamping is on then assign a time stamp entry to this Worker Thread if ((tdp->td_ts_table.ts_options & (TS_ON|TS_TRIGGERED))) { - wdp->wd_ts_entry = tdp->td_ts_table.ts_current_entry; + wdp->wd_ts_entry = tdp->td_ts_table.ts_current_entry; ttep = & tdp->td_ts_table.ts_hdrp->tsh_tte[wdp->wd_ts_entry]; tdp->td_ts_table.ts_current_entry++; if (tdp->td_ts_table.ts_options & TS_ONESHOT) { // Check to see if we are at the end of the ts buffer @@ -101,21 +101,21 @@ xdd_targetpass_e2e_loop_dst(xdd_plan_t* planp, target_data_t *tdp) { // Release the Worker Thread to let it start working on this task xdd_barrier(&wdp->wd_thread_targetpass_wait_for_task_barrier,&tdp->td_occupant,0); - // At this point the Worker Thread is running. The first thing it will do is perform all the + // At this point the Worker Thread is running. The first thing it will do is perform all the // Things To Do (ttd) before the I/O operation. This includes receiving data from the Source // which will block until it gets the data. Once the data is received, the Worker Thread will // perform the requested WRITE operation to the Destination file. The byte offset and length - // to WRITE is provided by the Source in the Header of the data received. + // to WRITE is provided by the Source in the Header of the data received. // If the next data blob received is an End Of File (EOF) packet, then things come to a halt. - + tdp->td_counters.tc_current_op_number++; // Get another Worker Thread and lets keepit roling... wdp = xdd_get_any_available_worker_thread(tdp); - + } // End of WHILE loop //////////////////////////// END OF I/O LOOP FOR ENTIRE PASS /////////////////////////////////////////// - - // Check to see if we've been canceled - if so, we need to leave + + // Check to see if we've been canceled - if so, we need to leave if (xgp->canceled) { fprintf(xgp->errout, "\n%s: xdd_targetpass_e2e_loop_src: Target %d: ERROR: Canceled!\n", xgp->progname, @@ -130,7 +130,7 @@ xdd_targetpass_e2e_loop_dst(xdd_plan_t* planp, target_data_t *tdp) { pthread_mutex_lock(&wdp->wd_worker_thread_target_sync_mutex); wdp->wd_worker_thread_target_sync &= ~WTSYNC_BUSY; // Mark this Worker Thread NOT Busy pthread_mutex_unlock(&wdp->wd_worker_thread_target_sync_mutex); - // Check to see if we've been canceled - if so, we need to leave + // Check to see if we've been canceled - if so, we need to leave if (xgp->canceled) { fprintf(xgp->errout, "\n%s: xdd_targetpass_e2e_loop_src: Target %d: ERROR: Canceled!\n", xgp->progname, @@ -139,7 +139,7 @@ xdd_targetpass_e2e_loop_dst(xdd_plan_t* planp, target_data_t *tdp) { } } - if (tdp->td_counters.tc_current_io_status != 0) + if (tdp->td_counters.tc_current_io_status != 0) planp->target_errno[tdp->td_target_number] = XDD_RETURN_VALUE_IOERROR; return; @@ -148,11 +148,11 @@ xdd_targetpass_e2e_loop_dst(xdd_plan_t* planp, target_data_t *tdp) { /*----------------------------------------------------------------------------*/ /* xdd_targetpass_e2e_loop_src() - This subroutine will assign tasks to Worker Threads until - * all bytes have been processed. It will then issue an End-of-Data Task to + * all bytes have been processed. It will then issue an End-of-Data Task to * all Worker Threads one at a time. The End-of-Data Task will send an End-of-Data * packet to the Destination Side so that those Worker Threads know that there * is no more data to receive. - * + * * This subroutine is called by xdd_targetpass(). */ void @@ -180,7 +180,7 @@ xdd_targetpass_e2e_loop_src(xdd_plan_t* planp, target_data_t *tdp) { } // End of WHILE loop that transfers data for a single pass - // Check to see if we've been canceled - if so, we need to leave + // Check to see if we've been canceled - if so, we need to leave if (xgp->canceled) { fprintf(xgp->errout, "\n%s: xdd_targetpass_e2e_loop_src: Target %d: ERROR: Canceled!\n", xgp->progname, @@ -202,7 +202,7 @@ xdd_targetpass_e2e_loop_src(xdd_plan_t* planp, target_data_t *tdp) { pthread_mutex_unlock(&wdp->wd_worker_thread_target_sync_mutex); } - if (tdp->td_counters.tc_current_io_status != 0) + if (tdp->td_counters.tc_current_io_status != 0) planp->target_errno[tdp->td_target_number] = XDD_RETURN_VALUE_IOERROR; return; @@ -230,11 +230,11 @@ xdd_targetpass_e2e_task_setup_src(worker_data_t *wdp) { } else if (tdp->td_seekhdr.seeks[tdp->td_counters.tc_current_op_number].operation == SO_OP_READ) { // READ Operation wdp->wd_task.task_op_type = TASK_OP_TYPE_READ; wdp->wd_task.task_op_string = "READ"; - } else { + } else { wdp->wd_task.task_op_type = TASK_OP_TYPE_NOOP; wdp->wd_task.task_op_string = "NOOP"; } - + // Figure out the transfer size to use for this I/O if (tdp->td_current_bytes_remaining < (uint64_t)tdp->td_xfer_size) wdp->wd_task.task_xfer_size = tdp->td_current_bytes_remaining; @@ -242,7 +242,7 @@ xdd_targetpass_e2e_task_setup_src(worker_data_t *wdp) { wdp->wd_task.task_io_status = 0; wdp->wd_task.task_errno = 0; - // Set the location to seek to + // Set the location to seek to wdp->wd_task.task_byte_offset = tdp->td_counters.tc_current_byte_offset; // Remember the operation number for this target @@ -256,7 +256,7 @@ xdd_targetpass_e2e_task_setup_src(worker_data_t *wdp) { // If time stamping is on then assign a time stamp entry to this Worker Thread if ((tdp->td_ts_table.ts_options & (TS_ON|TS_TRIGGERED))) { - wdp->wd_ts_entry = tdp->td_ts_table.ts_current_entry; + wdp->wd_ts_entry = tdp->td_ts_table.ts_current_entry; ttep = & tdp->td_ts_table.ts_hdrp->tsh_tte[wdp->wd_ts_entry]; tdp->td_ts_table.ts_current_entry++; if (tdp->td_ts_table.ts_options & TS_ONESHOT) { // Check to see if we are at the end of the ts buffer @@ -297,7 +297,7 @@ xdd_targetpass_e2e_task_setup_src(worker_data_t *wdp) { tdp->td_counters.tc_current_op_number++; tdp->td_current_bytes_issued += wdp->wd_task.task_xfer_size; tdp->td_current_bytes_remaining -= wdp->wd_task.task_xfer_size; - + // E2E Source Side needs to be monitored... if (tdp->td_target_options & TO_E2E_SOURCE_MONITOR) xdd_targetpass_e2e_monitor(tdp); @@ -314,8 +314,8 @@ xdd_targetpass_e2e_task_setup_src(worker_data_t *wdp) { * * We need to issue an End-of-File task for this Worker Thread so that it sends an EOF * packet to the corresponding Worker Thread on the Destination Side. We do not have to wait for - * that operation to complete. Just cycle through all the Worker Threads and later wait at the - * targetpass_worker_thread_passcomplete barrier. + * that operation to complete. Just cycle through all the Worker Threads and later wait at the + * targetpass_worker_thread_passcomplete barrier. * */ void @@ -330,7 +330,7 @@ xdd_targetpass_e2e_eof_src(target_data_t *tdp) { // If time stamping is on then assign a time stamp entry to this Worker Thread if ((tdp->td_ts_table.ts_options & (TS_ON|TS_TRIGGERED))) { - wdp->wd_ts_entry = tdp->td_ts_table.ts_current_entry; + wdp->wd_ts_entry = tdp->td_ts_table.ts_current_entry; ttep = & tdp->td_ts_table.ts_hdrp->tsh_tte[wdp->wd_ts_entry]; tdp->td_ts_table.ts_current_entry++; if (tdp->td_ts_table.ts_options & TS_ONESHOT) { // Check to see if we are at the end of the ts buffer @@ -346,10 +346,10 @@ xdd_targetpass_e2e_eof_src(target_data_t *tdp) { ttep->tte_op_number = -1*wdp->wd_worker_number; ttep->tte_byte_offset = -1; } - + // Release the Worker Thread to let it start working on this task xdd_barrier(&wdp->wd_thread_targetpass_wait_for_task_barrier,&tdp->td_occupant,0); - + } } // End of xdd_targetpass_eof_source_side() @@ -357,7 +357,7 @@ xdd_targetpass_e2e_eof_src(target_data_t *tdp) { /* xdd_targetpass_e2e_monitor() - This subroutine will monitor and display * information about the Worker Threads that are running on the Source Side of an * E2E operation. - * + * * This subroutine is called by xdd_targetpass_loop(). */ void @@ -403,9 +403,9 @@ xdd_targetpass_e2e_monitor(target_data_t *tdp) { } // End of xdd_targetpass_e2e_monitor(); /*----------------------------------------------------------------------------*/ -/* xdd_targetpass_e2e_reopen_islocal() - This subroutine will remove the files +/* xdd_targetpass_e2e_reopen_islocal() - This subroutine will remove the files * created and reopen the handles when an E2D islocal operation is performed. - * + * * This subroutine is called by xdd_target_thread_cleanup() and possibly * xdd_target_thread() */ @@ -419,11 +419,7 @@ xdd_targetpass_e2e_reopen_islocal(target_data_t *tdp) { while (wdp && wdp->wd_e2ep) { // Closing all files if (wdp->wd_e2ep->e2e_sd != -1) { -#ifdef WIN32 - CloseHandle(wdp->wd_e2ep->e2e_sd); -#else close(wdp->wd_e2ep->e2e_sd); -#endif } // Get the next worker in the chain wdp = wdp->wd_next_wdp; @@ -458,11 +454,7 @@ xdd_targetpass_e2e_reopen_islocal(target_data_t *tdp) { while (wdp && wdp->wd_e2ep) { // Closing all files if (wdp->wd_e2ep->e2e_sd != -1) { -#ifdef WIN32 - CloseHandle(wdp->wd_e2ep->e2e_sd); -#else close(wdp->wd_e2ep->e2e_sd); -#endif } // Get the next worker in the chain wdp = wdp->wd_next_wdp; @@ -493,9 +485,9 @@ xdd_targetpass_e2e_reopen_islocal(target_data_t *tdp) { } // End of xdd_targetpass_e2e_reopen_islocal /*----------------------------------------------------------------------------*/ -/* xdd_targetpass_e2e_remove_islocal() - This subroutine will remove the files +/* xdd_targetpass_e2e_remove_islocal() - This subroutine will remove the files * created when the islocal E2E operation is performed. - * + * * This subroutine is called by xdd_target_thread_cleanup() and possibly * xdd_target_thread() */ @@ -507,11 +499,7 @@ xdd_targetpass_e2e_remove_islocal(target_data_t *tdp) { wdp = tdp->td_next_wdp; while (wdp && wdp->wd_e2ep) { if (wdp->wd_e2ep->e2e_sd != -1) { -#ifdef WIN32 - CloseHandle(wdp->wd_e2ep->e2e_sd); -#else close(wdp->wd_e2ep->e2e_sd); -#endif } // Get the next worker in the chain wdp = wdp->wd_next_wdp; @@ -519,11 +507,7 @@ xdd_targetpass_e2e_remove_islocal(target_data_t *tdp) { // Only need to delete the files once wdp = tdp->td_next_wdp; -#ifdef WIN32 - DeleteFile(wdp->wd_e2ep->e2e_dest_hostname); -#else unlink(wdp->wd_e2ep->e2e_dest_hostname); -#endif } } // End of xdd_targetpass_e2e_remove_islocal diff --git a/src/base/target_ttd_after_pass.c b/src/base/target_ttd_after_pass.c index 64da0c09..6b7dfb2d 100644 --- a/src/base/target_ttd_after_pass.c +++ b/src/base/target_ttd_after_pass.c @@ -14,11 +14,11 @@ #include //****************************************************************************** -// Things the Target Thread needs to do after a single pass +// Things the Target Thread needs to do after a single pass //****************************************************************************** /*----------------------------------------------------------------------------*/ -/* xdd_target_ttd_after_pass() - This subroutine will do all the stuff needed to +/* xdd_target_ttd_after_pass() - This subroutine will do all the stuff needed to * be done after the inner-most loop has done does all the I/O operations * that constitute a "pass" or some portion of a pass if it terminated early. */ @@ -33,11 +33,7 @@ xdd_target_ttd_after_pass(target_data_t *tdp) { status = 0; // Issue an fdatasync() to flush all the write buffers to disk for this file if the -syncwrite option was specified if (tdp->td_target_options & TO_SYNCWRITE) { -#if (LINUX || AIX) status = fdatasync(tdp->td_file_desc); -#else - status = fsync(tdp->td_file_desc); -#endif } /* Get the ending time stamp */ nclk_now(&tdp->td_counters.tc_pass_end_time); @@ -49,16 +45,16 @@ xdd_target_ttd_after_pass(target_data_t *tdp) { // Loop through all the Worker Threads to put the Earliest Start Time and Latest End Time into this Target Data Struct wdp = tdp->td_next_wdp; while (wdp) { - if (wdp->wd_counters.tc_time_first_op_issued_this_pass <= tdp->td_counters.tc_time_first_op_issued_this_pass) + if (wdp->wd_counters.tc_time_first_op_issued_this_pass <= tdp->td_counters.tc_time_first_op_issued_this_pass) tdp->td_counters.tc_time_first_op_issued_this_pass = wdp->wd_counters.tc_time_first_op_issued_this_pass; - if (wdp->wd_counters.tc_pass_start_time <= tdp->td_counters.tc_pass_start_time) + if (wdp->wd_counters.tc_pass_start_time <= tdp->td_counters.tc_pass_start_time) tdp->td_counters.tc_pass_start_time = wdp->wd_counters.tc_pass_start_time; - if (wdp->wd_counters.tc_pass_end_time >= tdp->td_counters.tc_pass_end_time) + if (wdp->wd_counters.tc_pass_end_time >= tdp->td_counters.tc_pass_end_time) tdp->td_counters.tc_pass_end_time = wdp->wd_counters.tc_pass_end_time; wdp = wdp->wd_next_wdp; } - if (tdp->td_target_options & TO_ENDTOEND) { - // Average the Send/Receive Time + if (tdp->td_target_options & TO_ENDTOEND) { + // Average the Send/Receive Time tdp->td_e2ep->e2e_sr_time /= tdp->td_queue_depth; } diff --git a/src/base/target_ttd_before_pass.c b/src/base/target_ttd_before_pass.c index 24ceb0cd..4088e7e4 100644 --- a/src/base/target_ttd_before_pass.c +++ b/src/base/target_ttd_before_pass.c @@ -16,42 +16,30 @@ // Things the Target Thread has to do before a Pass is started //****************************************************************************** /*----------------------------------------------------------------------------*/ -/* xdd_timer_calibration_before_pass() - This subroutine will check the - * resolution of the timer on the system and display information about it if +/* xdd_timer_calibration_before_pass() - This subroutine will check the + * resolution of the timer on the system and display information about it if * requested. - * + * * This subroutine is called within the context of a Target Thread. * */ void xdd_timer_calibration_before_pass(void) { nclk_t t1,t2,t3; -#ifdef WIN32 - int32_t i; -#else int status; int32_t i; struct timespec req; struct timespec rem; -#endif if (xgp->global_options & GO_TIMER_INFO) { nclk_now(&t1); - for (i=0; i<100; i++) + for (i=0; i<100; i++) nclk_now(&t2); nclk_now(&t2); t3=t2-t1; fprintf(xgp->output,"XDD Timer Calibration Info: Average time to get time stamp=%llu nanoseconds\n",t3/100); -#ifdef WIN32 - for (i=1; i< 1001; i*=10) { - nclk_now(&t1); - Sleep(i); - nclk_now(&t3); - t3 -= t1; - } -#else // Do this for Systems other than Windows for (i=1; i< 1000001; i*=10) { req.tv_sec = 0; req.tv_nsec = i; @@ -63,20 +51,19 @@ xdd_timer_calibration_before_pass(void) { if (status) { // This means that the nanosleep was interrupted early req.tv_sec = rem.tv_sec; req.tv_nsec = rem.tv_nsec; - if (i > 1) + if (i > 1) i=1; continue; } t3 -= t1; } -#endif } } // End of xdd_timer_calibration_before_pass() /*----------------------------------------------------------------------------*/ -/* xdd_start_delay_before_pass() - This subroutine will sleep for the period - * of time specified by the -startdelay option. - * +/* xdd_start_delay_before_pass() - This subroutine will sleep for the period + * of time specified by the -startdelay option. + * * This subroutine is called within the context of a Target Thread. * */ @@ -85,10 +72,6 @@ xdd_start_delay_before_pass(target_data_t *tdp) { int status; struct timespec req; // The requested sleep time struct timespec rem; // The remaining sleep time is awoken early -#if (WIN32 | IRIX) - int32_t sleep_time_dw; -#endif - /* Check to see if this thread has a start delay time. If so, just hang out * until the start delay time has elapsed and then spring into action! @@ -98,13 +81,6 @@ xdd_start_delay_before_pass(target_data_t *tdp) { return; // No start delay // Convert the start delay from nanoseconds to milliseconds -#ifdef WIN32 - sleep_time_dw = (int32_t)(tdp->td_start_delay_psec/BILLION); - Sleep(sleep_time_dw); -#elif (IRIX ) - sleep_time_dw = (int32_t)(tdp->td_start_delay_psec/BILLION); - sginap((sleep_time_dw*CLK_TCK)/1000); -#else req.tv_sec = tdp->td_start_delay; // Whole seconds req.tv_nsec = (tdp->td_start_delay - req.tv_sec) * BILLION; // Fraction of a second fprintf(xgp->output, "\nTarget %d Beginning requested Start Delay for %f seconds before pass %d...\n",tdp->td_target_number, tdp->td_start_delay, tdp->td_counters.tc_pass_number); @@ -118,17 +94,16 @@ xdd_start_delay_before_pass(target_data_t *tdp) { rem.tv_sec = 0; // zero this out just to make sure rem.tv_nsec = 0; // zero this out just to make sure status = nanosleep(&req, &rem); - } + } fprintf(xgp->output, "\nTarget %d Starting pass %d after requested delay of %f seconds\n",tdp->td_target_number,tdp->td_counters.tc_pass_number, tdp->td_start_delay); fflush(xgp->output); -#endif } // End of xdd_start_delay_before_pass() /*----------------------------------------------------------------------------*/ /* xdd_raw_before_pass() - This subroutine initializes the variables that * are used by the read_after_write option - * + * * This subroutine is called within the context of a Target Thread. * */ @@ -156,7 +131,7 @@ xdd_raw_before_pass(target_data_t *tdp) { /*----------------------------------------------------------------------------*/ /* xdd_e2e_before_pass() - This subroutine initializes the variables that * are used by the end-to-end option - * + * * This subroutine is called within the context of a Target Thread. * */ @@ -179,31 +154,31 @@ xdd_e2e_before_pass(target_data_t *tdp) { /*----------------------------------------------------------------------------*/ /* xdd_init_target_data_before_pass() - Reset variables to known state - * + * * This subroutine is called within the context of a Target Thread. * */ -void +void xdd_init_target_data_before_pass(target_data_t *tdp) { - worker_data_t *wdp; // Pointer to Worker Thread Data Struct - + worker_data_t *wdp; // Pointer to Worker Thread Data Struct + // Init all the pass-related variables to 0 tdp->td_counters.tc_pass_elapsed_time = 0; tdp->td_counters.tc_time_first_op_issued_this_pass = 0; - tdp->td_counters.tc_accumulated_op_time = 0; + tdp->td_counters.tc_accumulated_op_time = 0; tdp->td_counters.tc_accumulated_read_op_time = 0; tdp->td_counters.tc_accumulated_write_op_time = 0; tdp->td_counters.tc_accumulated_pattern_fill_time = 0; tdp->td_counters.tc_accumulated_flush_time = 0; tdp->td_counters.tc_accumulated_op_count = 0; // The number of read+write operations that have completed so far - tdp->td_counters.tc_accumulated_read_op_count = 0; // The number of read operations that have completed so far - tdp->td_counters.tc_accumulated_write_op_count = 0; // The number of write operations that have completed so far + tdp->td_counters.tc_accumulated_read_op_count = 0; // The number of read operations that have completed so far + tdp->td_counters.tc_accumulated_write_op_count = 0; // The number of write operations that have completed so far tdp->td_counters.tc_accumulated_bytes_xfered = 0; // Total number of bytes transferred to far (to storage device, not network) tdp->td_counters.tc_accumulated_bytes_read = 0; // Total number of bytes read to far (from storage device, not network) tdp->td_counters.tc_accumulated_bytes_written = 0; // Total number of bytes written to far (to storage device, not network) // tdp->td_counters.tc_current_op_number = 0; // The current operation number init to 0 - tdp->td_counters.tc_current_byte_offset = 0; // Current byte offset for this I/O operation + tdp->td_counters.tc_current_byte_offset = 0; // Current byte offset for this I/O operation tdp->td_counters.tc_current_io_status = 0; // I/O Status of the last I/O operation for this Worker Thread tdp->td_counters.tc_current_io_errno = 0; // The errno associated with the status of this I/O for this thread tdp->td_counters.tc_current_error_count = 0; // The number of I/O errors for this Worker Thread @@ -225,7 +200,7 @@ xdd_init_target_data_before_pass(target_data_t *tdp) { } tdp->td_time_limit_expired = 0; // The time limit expiration indicator - tdp->td_abort = 0; + tdp->td_abort = 0; tdp->td_current_bytes_issued = 0; tdp->td_current_bytes_completed = 0; tdp->td_current_bytes_remaining = tdp->td_target_bytes_to_xfer_per_pass; @@ -238,27 +213,27 @@ xdd_init_target_data_before_pass(target_data_t *tdp) { // Same as above... Pass numbers greater than one will be used when the // multi-file copy support is added tdp->td_counters.tc_pass_start_time = NCLK_MAX; - } + } wdp = tdp->td_next_wdp; - while (wdp) { // Set up the pass_start_times for all the Worker Threads + while (wdp) { // Set up the pass_start_times for all the Worker Threads wdp->wd_counters.tc_pass_start_time = tdp->td_counters.tc_pass_start_time; - if (tdp->td_counters.tc_pass_number == 1) + if (tdp->td_counters.tc_pass_number == 1) times(&wdp->wd_counters.tc_starting_cpu_times_this_run); times(&wdp->wd_counters.tc_starting_cpu_times_this_pass); wdp = wdp->wd_next_wdp; } - + // Initialize the Target Offset Table tot_init(&(tdp->td_totp), tdp->td_queue_depth, tdp->td_target_ops); return; } // End of xdd_init_target_data_before_pass() - + /*----------------------------------------------------------------------------*/ /* xdd_target_ttd_before_pass() - This subroutine is called by targetpass() - * inside the Target Thread and will do all the things to do (ttd) + * inside the Target Thread and will do all the things to do (ttd) * before entering the inner-most loop that does all the I/O operations * that constitute a "pass". * Return values: 0 is good @@ -286,7 +261,7 @@ xdd_target_ttd_before_pass(target_data_t *tdp) { xdd_init_target_data_before_pass(tdp); return(0); - + } // End of xdd_target_ttd_before_pass() /* diff --git a/src/base/worker_thread_init.c b/src/base/worker_thread_init.c index f0db8c84..da2265cd 100644 --- a/src/base/worker_thread_init.c +++ b/src/base/worker_thread_init.c @@ -45,13 +45,7 @@ xdd_worker_thread_init(worker_data_t *wdp) { // Get the Target Data Struct address as well tdp = wdp->wd_tdp; -#if (AIX) - wdp->wd_thread_id = thread_self(); -#elif (LINUX) wdp->wd_thread_id = syscall(SYS_gettid); -#else - wdp->wd_thread_id = wdp->wd_pid; -#endif // The "my_current_state_mutex" is used by the WorkerThreads when checking or updating the state info status = pthread_mutex_init(&tdp->td_current_state_mutex, 0); diff --git a/src/base/worker_thread_io_for_os.c b/src/base/worker_thread_io_for_os.c index f1507f08..0bfaa329 100644 --- a/src/base/worker_thread_io_for_os.c +++ b/src/base/worker_thread_io_for_os.c @@ -16,7 +16,6 @@ #include "xint.h" #include "xint_wd.h" -#if defined(LINUX) /*----------------------------------------------------------------------------*/ /* xdd_io_for_os() - This subroutine is only used on Linux systems * This will initiate the system calls necessary to perform an I/O operation @@ -134,180 +133,6 @@ xdd_io_for_os(worker_data_t *wdp) { } } // End of xdd_io_for_linux() -#endif - -#if defined(AIX) || defined(DARWIN) -/*----------------------------------------------------------------------------*/ -/* xdd_io_for_os() - This subroutine is only used on AIX systems - * This will initiate the system calls necessary to perform an I/O operation - * and any error recovery or post processing necessary. - */ -void -xdd_io_for_os(worker_data_t *wdp) { - target_data_t *tdp; // Pointer to the parent Target Data Structure - xdd_ts_tte_t *ttep; // Pointer to a Timestamp Table Entry - - - tdp = wdp->wd_tdp; // Get pointer to the Target Data - - // Record the starting time for this write op - nclk_now(&wdp->wd_counters.tc_current_op_start_time); - // Time stamp if requested - ttep = &tdp->td_ts_table.ts_hdrp->tsh_tte[wdp->wd_ts_entry]; - if (tdp->td_ts_table.ts_options & (TS_ON | TS_TRIGGERED)) { - ttep->tte_disk_start = wdp->wd_counters.tc_current_op_start_time; - ttep->tte_disk_processor_start = xdd_get_processor(); - } - - /* Do the deed .... */ - wdp->wd_counters.tc_current_op_end_time = 0; - if (wdp->wd_task.task_op_type == TASK_OP_TYPE_WRITE) { // Write Operation - wdp->wd_task.task_op_string = "WRITE"; - // Call xdd_datapattern_fill() to fill the buffer with any required patterns - xdd_datapattern_fill(wdp); - - if (tdp->td_target_options & TO_NULL_TARGET) { // If this is a NULL target then we fake the I/O - wdp->wd_task.task_io_status = wdp->wd_task.task_xfer_size; - } else { // Issue the actual operation - if (!(tdp->td_target_options & TO_NULL_TARGET)) - wdp->wd_task.task_io_status = pwrite(wdp->wd_task.task_file_desc, - wdp->wd_task.task_datap, - wdp->wd_task.task_xfer_size, - (off_t)wdp->wd_task.task_byte_offset); // Issue a positioned write operation - else wdp->wd_task.task_io_status = write(wdp->wd_task.task_file_desc, wdp->wd_task.task_datap, wdp->wd_task.task_xfer_size); // Issue a normal write() op - - } - } else if (wdp->wd_task.task_op_type == TASK_OP_TYPE_READ) { // READ Operation - wdp->wd_task.task_op_string = "READ"; - - if (tdp->td_target_options & TO_NULL_TARGET) { // If this is a NULL target then we fake the I/O - wdp->wd_task.task_io_status = wdp->wd_task.task_xfer_size; - } else { // Issue the actual operation - if (!(tdp->td_target_options & TO_NULL_TARGET)) - wdp->wd_task.task_io_status = pread(wdp->wd_task.task_file_desc, - wdp->wd_task.task_datap, - wdp->wd_task.task_xfer_size, - (off_t)wdp->wd_task.task_byte_offset);// Issue a positioned read operation - else wdp->wd_task.task_io_status = read(wdp->wd_task.task_file_desc, - wdp->wd_task.task_datap, - wdp->wd_task.task_xfer_size);// Issue a normal read() operation - } -/* FIXME - if (tdp->td_target_options & (TO_VERIFY_CONTENTS | TO_VERIFY_LOCATION)) { - wdp->wd_tdp->data_pattern_compare_errors += xdd_verify(wdp, wdp->wdrget_op_number); - } -*/ - } else { // Must be a NOOP - // The NOOP is used to test the overhead usage of XDD when no actual I/O is done - wdp->wd_task.task_op_string = "NOOP"; - - // Make it look like a successful I/O - wdp->wd_task.task_io_status = wdp->wd_task.task_xfer_size; - errno = 0; - } // End of NOOP operation - - // Record the ending time for this op - nclk_now(&wdp->wd_counters.tc_current_op_end_time); - // Time stamp if requested - if (tdp->td_ts_table.ts_options & (TS_ON | TS_TRIGGERED)) { - ttep->tte_disk_end = wdp->wd_counters.tc_current_op_end_time; - ttep->tte_disk_xfer_size = wdp->wd_task.task_io_status; - ttep->tte_disk_processor_end = xdd_get_processor(); - } -} // End of xdd_io_for_os() -#endif - -#ifdef WIN32 -/*----------------------------------------------------------------------------*/ -/* xdd_io_for_os() - This subroutine is only used on Windows - * This will initiate the system calls necessary to perform an I/O operation - * and any error recovery or post processing necessary. - */ -void -xdd_io_for_os(ptds_t *p) { - nclk_t start_time; // Used for calculating elapsed times of ops - nclk_t end_time; // Used for calculating elapsed times of ops - uint64_t current_position; /* seek location read from device */ - uint32_t uj; /* Random unsigned variable */ - LPVOID lpMsgBuf; - uint32_t bytesxferred; /* Bytes transferred */ - unsigned long plow; - unsigned long phi; - - - plow = (unsigned long)p->wd_task.task_byte_offset; - phi = (unsigned long)(p->wd_task.task_byte_offset >> 32); - - /* Position to the correct place on the storage device/file */ - SetFilePointer(p->file_desc, plow, &phi, FILE_BEGIN); - /* Check to see if there is supposed to be a sequenced data pattern in the data buffer */ - /* For write operations, this means that we should update the data pattern in the buffer to - * the expected value which is the relative byte offset of each block in this request. - * For read operations, we need to check the block offset with what we think it should be. - * For read operations, it is assumed that the data read was previously written by xdd - * and is in the expected format. - */ - nclk_now(&p->tgtstp->wd_current_start_time); - if (p->tgtstp->target_op_number == 0) /* record our starting time */ - p->my_start_time = p->tgtstp->wd_current_start_time; - if (p->seekhdr.seeks[p->tgtstp->wd_current_op].operation == SO_OP_WRITE) { - if (p->dpp) { - if (p->dpp->data_pattern_options & DP_SEQUENCED_PATTERN) { - posp = (uint64_t *)p->wd_task.task_datap; - for (uj=0; uj<(p->tgtstp->wd_task.task_xfer_size/sizeof(p->tgtstp->wd_task.task_byte_offset)); uj++) { - *posp = p->tgtstp->wd_task.task_byte_offset + (uj * sizeof(p->tgtstp->wd_task.task_byte_offset)); - *posp |= p->dpp->data_pattern_prefix_binary; - if (p->data_pattern_options & DP_INVERSE_PATTERN) - *posp ^= 0xffffffffffffffffLL; // 1's compliment of the pattern - posp++; - } - } - } - /* Actually write the data to the storage device/file */ - p->my_io_status = WriteFile(p->file_desc, p->wd_task.task_datap, p->tgtstp->wd_task.task_xfer_size, &bytesxferred, NULL); - } else { /* Simply do the normal read operation */ - p->my_io_status = ReadFile(p->file_desc, p->wd_task.task_datap, p->tgtstp->wd_task.task_xfer_size, &bytesxferred, NULL); - if (p->td_target_options & (TO_VERIFY_CONTENTS | TO_VERIFY_LOCATION)) { - posp = (uint64_t *)p->wd_task.task_datap; - current_position = *posp; - } - } - nclk_now(&p->tgtstp->wd_current_end_time); - /* Take a time stamp if necessary */ - if ((p->tsp->ts_options & TS_ON) && (p->tsp->ts_options & TS_TRIGGERED)) { - ttep->tte_sk_end = p->tgtstp->wd_current_end_time; - if (ts_hdrp->tte_indx == ts_hdrp->tt_size) { /* Check to see if we are at the end of the buffer */ - if (p->tsp->ts_options & TS_ONESHOT) - p->tsp->ts_options &= ~TS_ON; /* Turn off Time Stamping now that we are at the end of the time stamp buffer */ - else if (p->tsp->ts_options & TS_WRAP) - ts_hdrp->tte_indx = 0; /* Wrap to the beginning of the time stamp buffer */ - } - } - /* Let's check the status of the last operation to see if things went well. - * If not, tell somebody who cares - like the poor soul running this program. - */ - if ((p->my_io_status == FALSE) || (bytesxferred != (unsigned long)p->tgtstp->wd_task.task_xfer_size)) { - FormatMessage( - FORMAT_MESSAGE_ALLOCATE_BUFFER | - FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, - GetLastError(), - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language - (LPTSTR) &lpMsgBuf, - 0, - NULL); - fprintf(xgp->errout, "%s: I/O error: could not %s target %s\n", - xgp->progname, - (p->seekhdr.seeks[p->tgtstp->wd_current_op].operation == SO_OP_WRITE) ? "write" : "read", - p->target); - fprintf(xgp->errout, "reason:%s", lpMsgBuf); - fflush(xgp->errout); - p->tgtstp->wd_current_error_count++; - } - p->my_io_status = bytesxferred; -} // End of xdd_io_for_os() -#endif /* * Local variables: diff --git a/src/base/worker_thread_ttd_before_io_op.c b/src/base/worker_thread_ttd_before_io_op.c index ee3afbe6..9358de81 100644 --- a/src/base/worker_thread_ttd_before_io_op.c +++ b/src/base/worker_thread_ttd_before_io_op.c @@ -16,10 +16,10 @@ // Things the Worker Thread has to do before each I/O Operation is issued //****************************************************************************** /*----------------------------------------------------------------------------*/ -/* xdd_dio_before_io_op - This subroutine will check several conditions to - * make sure that DIO will work for this particular I/O operation. - * If any of the DIO conditions are not met then DIO is turned off for this - * operation and all subsequent operations by this Worker Thread. +/* xdd_dio_before_io_op - This subroutine will check several conditions to + * make sure that DIO will work for this particular I/O operation. + * If any of the DIO conditions are not met then DIO is turned off for this + * operation and all subsequent operations by this Worker Thread. * * This subroutine is called under the context of a Worker Thread. * @@ -33,7 +33,7 @@ xdd_dio_before_io_op(worker_data_t *wdp) { tdp = wdp->wd_tdp; // Check to see if DIO is enable for this I/O - return if no DIO required - if (!(tdp->td_target_options & TO_DIO)) + if (!(tdp->td_target_options & TO_DIO)) return; // If this is an SG device with DIO turned on for whatever reason then just exit @@ -46,7 +46,7 @@ xdd_dio_before_io_op(worker_data_t *wdp) { // If the current I/O transfer size is an integer multiple of the page size *AND* // if the current byte location (aka offset into the file/device) is an integer multiple // of the page size then this I/O operation is fine - just return. - if ((wdp->wd_task.task_xfer_size % pagesize == 0) && + if ((wdp->wd_task.task_xfer_size % pagesize == 0) && (wdp->wd_task.task_byte_offset % pagesize) == 0) { return; } @@ -74,24 +74,15 @@ xdd_raw_before_io_op(worker_data_t *wdp) { tdp = wdp->wd_tdp; -#if (IRIX || SOLARIS || AIX ) - struct stat64 statbuf; -#elif (LINUX || DARWIN || FREEBSD) struct stat statbuf; -#endif -#if (LINUX || IRIX || SOLARIS || AIX || DARWIN || FREEBSD) - if ((tdp->td_target_options & TO_READAFTERWRITE) && (tdp->td_target_options & TO_RAW_READER)) { + if ((tdp->td_target_options & TO_READAFTERWRITE) && (tdp->td_target_options & TO_RAW_READER)) { // fprintf(stderr,"Reader: RAW check - dataready=%lld, trigger=%x\n",(long long)data_ready,p->rawp->raw_trigger); /* Check to see if we can read more data - if not see where we are at */ if (tdp->td_rawp->raw_trigger & RAW_STAT) { /* This section will continually poll the file status waiting for the size to increase so that it can read more data */ while (tdp->td_rawp->raw_data_ready < wdp->wd_task.task_xfer_size) { /* Stat the file so see if there is data to read */ -#if (LINUX || DARWIN || FREEBSD) status = fstat(wdp->wd_task.task_file_desc,&statbuf); -#else - status = fstat64(wdp->wd_task.task_file_desc,&statbuf); -#endif if (status < 0) { fprintf(xgp->errout, "%s: RAW: Error getting status on file\n", xgp->progname); tdp->td_rawp->raw_data_ready = wdp->wd_task.task_xfer_size; @@ -99,8 +90,8 @@ xdd_raw_before_io_op(worker_data_t *wdp) { tdp->td_rawp->raw_data_ready = statbuf.st_size - tdp->td_counters.tc_current_byte_offset; //if (tdp->td_rawp->raw_data_ready < 0) { // /* The result of this should be positive, otherwise, the target file - // * somehow got smaller and there is a problem. - // * So, fake it and let this loop exit + // * somehow got smaller and there is a problem. + // * So, fake it and let this loop exit // */ // fprintf(xgp->errout,"%s: RAW: Something is terribly wrong with the size of the target file...\n",xgp->progname); // tdp->td_rawp->raw_data_ready = wdp->wd_task.task_xfer_size; @@ -111,63 +102,62 @@ xdd_raw_before_io_op(worker_data_t *wdp) { while (tdp->td_rawp->raw_data_ready < wdp->wd_task.task_xfer_size) { /* xdd_raw_read_wait() will block until there is data to read */ status = xdd_raw_read_wait(wdp); - if (tdp->td_rawp->raw_msg.length != wdp->wd_task.task_xfer_size) + if (tdp->td_rawp->raw_msg.length != wdp->wd_task.task_xfer_size) fprintf(stderr, "error on msg recvd %d loc %lld, length %lld\n", - tdp->td_rawp->raw_msg_recv-1, - (long long)tdp->td_rawp->raw_msg.location, + tdp->td_rawp->raw_msg_recv-1, + (long long)tdp->td_rawp->raw_msg.location, (long long)tdp->td_rawp->raw_msg.length); if (tdp->td_rawp->raw_msg.sequence != tdp->td_rawp->raw_msg_last_sequence) { fprintf(stderr, "sequence error on msg recvd %d loc %lld, length %lld seq num is %lld " "should be %lld\n", - tdp->td_rawp->raw_msg_recv-1, - (long long)tdp->td_rawp->raw_msg.location, - (long long)tdp->td_rawp->raw_msg.length, - (long long)tdp->td_rawp->raw_msg.sequence, + tdp->td_rawp->raw_msg_recv-1, + (long long)tdp->td_rawp->raw_msg.location, + (long long)tdp->td_rawp->raw_msg.length, + (long long)tdp->td_rawp->raw_msg.sequence, (long long)tdp->td_rawp->raw_msg_last_sequence); } if (tdp->td_rawp->raw_msg_last_sequence == 0) { /* this is the first message so prime the prev_loc and length with the current values */ tdp->td_rawp->raw_prev_loc = tdp->td_rawp->raw_msg.location; tdp->td_rawp->raw_prev_len = 0; - } else if (tdp->td_rawp->raw_msg.location <= tdp->td_rawp->raw_prev_loc) + } else if (tdp->td_rawp->raw_msg.location <= tdp->td_rawp->raw_prev_loc) /* this message is old and can be discgarded */ continue; tdp->td_rawp->raw_msg_last_sequence++; /* calculate the amount of data to be read between the end of the last location and the end of the current one */ tdp->td_rawp->raw_data_length = ((tdp->td_rawp->raw_msg.location + tdp->td_rawp->raw_msg.length) - (tdp->td_rawp->raw_prev_loc + tdp->td_rawp->raw_prev_len)); tdp->td_rawp->raw_data_ready += tdp->td_rawp->raw_data_length; - if (tdp->td_rawp->raw_data_length > wdp->wd_task.task_xfer_size) + if (tdp->td_rawp->raw_data_length > wdp->wd_task.task_xfer_size) fprintf(stderr, "msgseq=%lld, loc=%lld, len=%lld, data_length is %lld, data_ready is " "now %lld, iosize=%d\n", - (long long)tdp->td_rawp->raw_msg.sequence, - (long long)tdp->td_rawp->raw_msg.location, - (long long)tdp->td_rawp->raw_msg.length, - (long long)tdp->td_rawp->raw_data_length, - (long long)tdp->td_rawp->raw_data_ready, + (long long)tdp->td_rawp->raw_msg.sequence, + (long long)tdp->td_rawp->raw_msg.location, + (long long)tdp->td_rawp->raw_msg.length, + (long long)tdp->td_rawp->raw_data_length, + (long long)tdp->td_rawp->raw_data_ready, (int)wdp->wd_task.task_xfer_size ); tdp->td_rawp->raw_prev_loc = tdp->td_rawp->raw_msg.location; tdp->td_rawp->raw_prev_len = tdp->td_rawp->raw_data_length; } } } /* End of dealing with a read-after-write */ -#endif } // xdd_raw_before_io_op() /*----------------------------------------------------------------------------*/ /* xdd_e2e_before_io_op() - This subroutine only does something if this * is the Destination side of an End-to-End operation. - * If this is the Destination side of an End-to-End operation then this + * If this is the Destination side of an End-to-End operation then this * subroutine will call xdd_dest_recv_data() to receive data from the Source side * of the End-to-End operation. That call will block until data has been received. * at that point, a number of sanity checks are performed and then control - * is passed back to the caller along with appropriate status. + * is passed back to the caller along with appropriate status. * * This subroutine is called under the context of a Worker Thread. * * Return values: 0 is good * -1 indicates an error */ -int32_t +int32_t xdd_e2e_before_io_op(worker_data_t *wdp) { int32_t status; // Status of subroutine calls target_data_t *tdp; @@ -175,8 +165,8 @@ xdd_e2e_before_io_op(worker_data_t *wdp) { tdp = wdp->wd_tdp; // If there is no end-to-end operation then just skip all this... - if (!(tdp->td_target_options & TO_ENDTOEND)) - return(0); + if (!(tdp->td_target_options & TO_ENDTOEND)) + return(0); // We are the Source side - nothing to do - leave now... if (tdp->td_target_options & TO_E2E_SOURCE) return(0); @@ -195,7 +185,7 @@ xdd_e2e_before_io_op(worker_data_t *wdp) { wdp->wd_e2ep->e2e_data_recvd = 0; // This will record how much data is recvd in this routine // Lets read a packet of data from the Source side - // The call to xdd_e2e_dest_recv() will block until there is data to read + // The call to xdd_e2e_dest_recv() will block until there is data to read wdp->wd_current_state |= WORKER_CURRENT_STATE_DEST_RECEIVE; if (PLAN_ENABLE_XNI & tdp->td_planp->plan_options) { @@ -224,9 +214,9 @@ xdd_e2e_before_io_op(worker_data_t *wdp) { wdp->wd_current_state &= ~WORKER_CURRENT_STATE_DEST_RECEIVE; // If status is "-1" then soemthing happened to the connection - time to leave - if (status == -1) + if (status == -1) return(-1); - + // Check to see of this is the last message in the transmission if (wdp->wd_e2ep->e2e_hdrp->e2eh_magic == XDD_E2E_EOF) { // This must be the End of the File return(0); @@ -237,7 +227,7 @@ xdd_e2e_before_io_op(worker_data_t *wdp) { wdp->wd_task.task_byte_offset = wdp->wd_e2ep->e2e_hdrp->e2eh_byte_offset; wdp->wd_task.task_xfer_size = wdp->wd_e2ep->e2e_hdrp->e2eh_data_length; wdp->wd_task.task_op_number = wdp->wd_e2ep->e2e_hdrp->e2eh_sequence_number; - // Record the amount of data received + // Record the amount of data received wdp->wd_e2ep->e2e_data_recvd = wdp->wd_e2ep->e2e_hdrp->e2eh_data_length; return(0); @@ -250,7 +240,7 @@ xdd_e2e_before_io_op(worker_data_t *wdp) { * that the overall bandwdith or IOP rate meets the throttled value. * This subroutine is called in the context of a Worker Thread */ -void +void xdd_throttle_before_io_op(worker_data_t *wdp) { nclk_t sleep_time; /* This is the number of nano seconds to sleep between I/O ops */ int32_t sleep_time_dw; /* This is the amount of time to sleep in milliseconds */ @@ -269,7 +259,7 @@ xdd_throttle_before_io_op(worker_data_t *wdp) { (tdp->td_throtp != NULL) ? tdp->td_throtp->throttle : -69.69); } - if ((tdp->td_throtp == NULL) || (tdp->td_throtp->throttle <= 0.0)) + if ((tdp->td_throtp == NULL) || (tdp->td_throtp->throttle <= 0.0)) return; /* If this is a 'throttled' operation, check to see what time it is relative to the start @@ -299,18 +289,10 @@ xdd_throttle_before_io_op(worker_data_t *wdp) { if (sleep_time > 0) { sleep_time_dw = sleep_time; -#ifdef WIN32 - Sleep(sleep_time_dw/1000); -#elif (LINUX || IRIX || AIX || DARWIN || FREEBSD) /* Change this line to use usleep */ if ((sleep_time_dw*CLK_TCK) > 1000) /* only sleep if it will be 1 or more ticks */ -#if (IRIX ) - sginap((sleep_time_dw*CLK_TCK)/fixme); -#elif (LINUX || AIX || DARWIN || FREEBSD) /* Change this line to use usleep */ - // The sleep_time_dw is in units of nanoseconds so we + // The sleep_time_dw is in units of nanoseconds so we // divide be 1000 to get the number of microseconds to sleep usleep(sleep_time_dw/1000); -#endif -#endif } } } @@ -318,7 +300,7 @@ xdd_throttle_before_io_op(worker_data_t *wdp) { } // xdd_throttle_before_io_op() /*----------------------------------------------------------------------------*/ -/* xdd_worker_thread_ttd_before_io_op() - This subroutine will do all the stuff +/* xdd_worker_thread_ttd_before_io_op() - This subroutine will do all the stuff * needed to be done before an I/O operation is issued. * * This subroutine is called in the context of a Worker Thread @@ -354,5 +336,3 @@ xdd_worker_thread_ttd_before_io_op(worker_data_t *wdp) { return(0); } // End of xdd_worker_thread_ttd_before_io_op() - - diff --git a/src/base/xint_nclk.c b/src/base/xint_nclk.c index 75eeb92a..fa26c223 100644 --- a/src/base/xint_nclk.c +++ b/src/base/xint_nclk.c @@ -40,16 +40,9 @@ static bool nclk_initialized = false; */ void nclk_initialize(nclk_t *nclkp) { - -#if (LINUX) // Since we use the "nanosecond" clocks in Linux, // the number of nanoseconds per nanosecond "tick" is 1 *nclkp = ONE; -#elif (SOLARIS || AIX || DARWIN || FREEBSD ) - // Since we use the "gettimeofday" clocks in this OS, - // the number of nanoseconds per microsecond "tick" is 1,000 - *nclkp = THOUSAND; -#endif nclk_initialized = true; return; } @@ -78,10 +71,7 @@ nclk_shutdown(void) { * */ /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ void nclk_now(nclk_t *nclkp) { - -#if defined WIN32 - QueryPerformanceCounter((LARGE_INTEGER *)nclkp); -#elif HAVE_CLOCK_GETTIME && _POSIX_TIMERS +#if HAVE_CLOCK_GETTIME && _POSIX_TIMERS struct timespec current_time; clock_gettime(CLOCK_REALTIME, ¤t_time); *nclkp = (nclk_t)(((nclk_t)current_time.tv_sec * BILLION) + diff --git a/src/client/info_display.c b/src/client/info_display.c index 4cfd544c..5bb95e82 100644 --- a/src/client/info_display.c +++ b/src/client/info_display.c @@ -46,16 +46,11 @@ xdd_display_kmgt(FILE *out, long long int n, int block_size) { */ void xdd_system_info(xdd_plan_t* planp, FILE *out) { -#if (SOLARIS || IRIX || LINUX || AIX || FREEBSD) int32_t page_size; int32_t physical_pages; int32_t memory_size; struct rusage xdd_rusage; char *userlogin; -#if ( IRIX ) - inventory_t *inventp; - int64_t mem_size; -#endif // IRIX inventory uname(&planp->hostname); userlogin = getlogin(); if (!userlogin) @@ -63,17 +58,6 @@ xdd_system_info(xdd_plan_t* planp, FILE *out) { fprintf(out, "Computer Name, %s, User Name, %s\n",planp->hostname.nodename, userlogin); fprintf(out, "OS release and version, %s %s %s\n",planp->hostname.sysname, planp->hostname.release, planp->hostname.version); fprintf(out, "Machine hardware type, %s\n",planp->hostname.machine); -#if (SOLARIS) - xgp->number_of_processors = sysconf(_SC_NPROCESSORS_ONLN); - physical_pages = sysconf(_SC_PHYS_PAGES); - page_size = sysconf(_SC_PAGE_SIZE); - xgp->clock_tick = sysconf(_SC_CLK_TCK); -#elif (AIX) - xgp->number_of_processors = sysconf(_SC_NPROCESSORS_ONLN); - physical_pages = sysconf(_SC_PHYS_PAGES); - page_size = sysconf(_SC_PAGE_SIZE); - xgp->clock_tick = sysconf(_SC_CLK_TCK); -#elif (LINUX) getrusage(RUSAGE_SELF, &xdd_rusage); //fprintf(stderr," maxrss %d\n",xdd_rusage.ru_maxrss); /* maximum resident set size */ //fprintf(stderr," ixrss %d\n",xdd_rusage.ru_ixrss); /* integral shared memory size */ @@ -93,74 +77,12 @@ xdd_system_info(xdd_plan_t* planp, FILE *out) { physical_pages = sysconf(_SC_PHYS_PAGES); page_size = sysconf(_SC_PAGE_SIZE); xgp->clock_tick = sysconf(_SC_CLK_TCK); -#elif (IRIX ) - xgp->number_of_processors = sysconf(_SC_NPROC_ONLN); - page_size = sysconf(_SC_PAGE_SIZE); - xgp->clock_tick = sysconf(_SC_CLK_TCK); - physical_pages = 0; - setinvent(); - inventp = getinvent(); - while (inventp) { - if ((inventp->inv_class == INV_MEMORY) && - (inventp->inv_type == INV_MAIN_MB)) { - mem_size = inventp->inv_state; - mem_size *= (1024 * 1024); - physical_pages = mem_size / page_size; - break; - } - inventp = getinvent(); - } -#endif fprintf(out, "Number of processors on this system, %d\n",xgp->number_of_processors); memory_size = (physical_pages * (page_size/1024))/1024; fprintf(out, "Page size in bytes, %d\n",page_size); fprintf(out, "Number of physical pages, %d\n", physical_pages); fprintf(out, "Megabytes of physical memory, %d\n", memory_size); fprintf(out, "Clock Ticks per second, %d\n", xgp->clock_tick); -#elif (WIN32) - SYSTEM_INFO system_info; /* Structure to receive system information */ - OSVERSIONINFOEXA osversion_info; - char computer_name[256]; - DWORD szcomputer_name = sizeof(computer_name); - char user_name[256]; - DWORD szuser_name = sizeof(user_name); - MEMORYSTATUS memorystatus; - BOOL i; - LPVOID lpMsgBuf; - - - GetSystemInfo(&system_info); - osversion_info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); - i = GetVersionEx((LPOSVERSIONINFOA)&osversion_info); - if (i == 0) { - FormatMessage( - FORMAT_MESSAGE_ALLOCATE_BUFFER | - FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, - GetLastError(), - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language - (LPTSTR) &lpMsgBuf, - 0, - NULL); - fprintf(xgp->errout,"%s: Error getting version\n",xgp->progname); - fprintf(xgp->errout,"reason:%s",lpMsgBuf); - } - GetComputerName(computer_name,&szcomputer_name); - GetUserName(user_name,&szuser_name); - GlobalMemoryStatus(&memorystatus); - xgp->clock_tick = sysconf(_SC_CLK_TCK); - fprintf(out, "Computer Name, %s, User Name, %s\n",computer_name, user_name); - fprintf(out, "Operating System Info: %s %d.%d Build %d %s\n", - ((osversion_info.dwPlatformId == VER_PLATFORM_WIN32_NT) ? "NT":"Windows95"), - osversion_info.dwMajorVersion, osversion_info.dwMinorVersion, - osversion_info.dwBuildNumber, - osversion_info.szCSDVersion); - fprintf(out, "Page size in bytes, %d\n",system_info.dwPageSize); - fprintf(out, "Number of processors on this system, %d\n", system_info.dwNumberOfProcessors); - fprintf(out, "Megabytes of physical memory, %d\n", memorystatus.dwTotalPhys/(1024*1024)); -#endif // WIN32 - fprintf(out,"Seconds before starting, %lld\n",(long long)planp->gts_seconds_before_starting); } /* end of xdd_system_info() */ diff --git a/src/client/initialization.c b/src/client/initialization.c index a0185551..202ea058 100644 --- a/src/client/initialization.c +++ b/src/client/initialization.c @@ -11,7 +11,7 @@ * */ /* - * This file contains the subroutines that perform various initialization + * This file contains the subroutines that perform various initialization * functions when xdd is started. */ #include "xint.h" @@ -21,7 +21,7 @@ */ int32_t xdd_initialization(int32_t argc,char *argv[], xdd_plan_t *planp) { - nclk_t tt; + nclk_t tt; // Initialize the Global Data Structure @@ -32,31 +32,24 @@ xdd_initialization(int32_t argc,char *argv[], xdd_plan_t *planp) { // See barrier.c xdd_init_barrier_chain(planp); - // Parse the input arguments + // Parse the input arguments // See parse.c xgp->argc = argc; // remember the original arg count - xgp->argv = argv; // remember the original argv + xgp->argv = argv; // remember the original argv xdd_parse(planp,argc,argv); // Init output format header - if (planp->plan_options & PLAN_ENDTOEND) + if (planp->plan_options & PLAN_ENDTOEND) xdd_results_format_id_add("+E2ESRTIME+E2EIOTIME+E2EPERCENTSRTIME ", planp->format_string); - // Optimize runtime priorities and all that + // Optimize runtime priorities and all that // See schedule.c xdd_schedule_options(); - // initialize the signal handlers + // initialize the signal handlers // See signals.c xdd_signal_init(planp); - -#if WIN32 - /* Init the ts serializer mutex to compensate for a Windows bug */ - xgp->tsp->ts_serializer_mutex_name = "ts_serializer_mutex"; - ts_serializer_init(&xgp->tsp->ts_serializer_mutex, xgp->tsp->ts_serializer_mutex_name); -#endif - /* initialize the clocks */ nclk_initialize(&tt); if (tt == NCLK_BAD) { @@ -67,17 +60,17 @@ xdd_initialization(int32_t argc,char *argv[], xdd_plan_t *planp) { } nclk_now(&planp->base_time); - // Init the Global Clock + // Init the Global Clock // See global_clock.c // xdd_init_global_clock(&xgp->ActualLocalStartTime, planp); - // display configuration information about this run + // display configuration information about this run // See info_display.c xdd_config_info(planp); return(0); } // End of initialization() - + /* * Local variables: * indent-tabs-mode: t diff --git a/src/client/parse.c b/src/client/parse.c index 98bd161d..45c018d5 100644 --- a/src/client/parse.c +++ b/src/client/parse.c @@ -584,7 +584,6 @@ xdd_get_throtp(target_data_t *tdp) { //return(tdp->td_tsp); // //} /* End of xdd_get_tsp() */ -#if (LINUX) /*----------------------------------------------------------------------------*/ /* xdd_linux_cpu_count() - return the number of CPUs on this system */ @@ -610,7 +609,6 @@ xdd_linux_cpu_count(void) { } return(cpus); } /* end of xdd_linux_cpu_count() */ -#endif /*----------------------------------------------------------------------------*/ /* xdd_cpu_count() - return the number of CPUs on this system @@ -618,18 +616,7 @@ xdd_linux_cpu_count(void) { int32_t xdd_cpu_count(void) { int32_t cpus; // Number of CPUs found -#if (DARWIN) - cpus = 1; - fprintf(xgp->errout,"%s: WARNING: Multiple processors not supported in this release\n",xgp->progname); -#elif (SOLARIS || AIX) - /* SOLARIS or AIX */ - cpus = sysconf(_SC_NPROCESSORS_ONLN); -#elif (IRIX || WIN32) - /* IRIX */ - cpus = sysmp(MP_NPROCS,0); -#elif (LINUX) cpus = xdd_linux_cpu_count(); -#endif return(cpus); } /* end of xdd_cpu_count() */ diff --git a/src/client/parse_func.c b/src/client/parse_func.c index 2d2cb158..07d0e16a 100644 --- a/src/client/parse_func.c +++ b/src/client/parse_func.c @@ -352,12 +352,8 @@ xddfunc_datapattern(xdd_plan_t *planp, int32_t argc, char *argv[], uint32_t flag unsigned char *tmpp; int retval; int32_t stat_status; // Return value of stat call -#if (LINUX || DARWIN) struct stat stat_buf; // Stat struct to get size of data file // if DP_FILE_PATTERN/DP_WHOLEFILE_PATTERN is set -#elif (AIX || SOLARIS) - struct stat64 stat_buf; -#endif args = xdd_parse_target_number(planp, argc, &argv[0], flags, &target_number); if (args < 0) return(-1); @@ -563,11 +559,7 @@ xddfunc_datapattern(xdd_plan_t *planp, int32_t argc, char *argv[], uint32_t flag fprintf(xgp->errout, "%s: not enough arguments specified for the option '-datapattern'\n", xgp->progname); return(0); } else { -#if (LINUX || DARWIN) stat_status = stat((char *)argv[args+2], &stat_buf); -#elif (AIX || SOLARIS) - stat_status = stat64((char *)argv[args+2], &stat_buf); -#endif if (stat_status < 0) { fprintf(xgp->errout, "%s: could not open %s to use for the data pattern\n", xgp->progname, diff --git a/src/common/barrier.h b/src/common/barrier.h index 0d09176b..14358f0e 100644 --- a/src/common/barrier.h +++ b/src/common/barrier.h @@ -15,7 +15,7 @@ #include #include "xint_barrier.h" -// Barrier Naming Convention: +// Barrier Naming Convention: // (1) The first part of the name is the barrier "owner" or thread that initializes the barrier // (2) The second part of the name is the other [dependant] thread that will use this barrier // (3) The third part of the name is a descriptive word about the function of this barrier @@ -31,12 +31,12 @@ // About the Barrier Chain // The barrier chain is used to keep track of all barriers that are created so that we can easily scan // through the list during termination to make sure all of them have been removed properly. -// Barriers are added to the chain when they are initialized in xdd_barrier_init(). +// Barriers are added to the chain when they are initialized in xdd_barrier_init(). // Barriers are removed from the chain when they are destrroyed in xdd_barrier_destroy(). // The xdd_global_data structure contains a pointer to the first barrier on the chain, the last barrier // on the chain, and the number of barriers on the chain at any given time. // Each barrier structure contains a pointer to the barrier before it (the *prev* member) and a pointer -// to the barrier after it (the *next* member) in the chain. +// to the barrier after it (the *next* member) in the chain. // At any given time the chain is a circular doubly-linked list that looks like so: // (the last barrier) // ^ @@ -71,11 +71,11 @@ // +-----------|-----+ // V // (the first barrier) -// +// // Barriers are always added to the end of the chain. // Barriers can be removed from the chain in any order. // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -// During normal execution a barrier will have some number of "occupants" or +// During normal execution a barrier will have some number of "occupants" or // threads that are waiting at a particular barrier for other threads to arrive. // The occupants waiting in a barrier are of four different types: // - Target Thread @@ -88,16 +88,16 @@ // Worker_Data if the occupant is a Target Thread or Worker Thread, and previous/next pointers // to the occupants in front or behind any given occupant structure. If the // occupant is the only one on the occupant chain then it simply points to itself. -// Each time a thread enters a barrier, the pointer to the occupant structure passed +// Each time a thread enters a barrier, the pointer to the occupant structure passed // in as an argument to xdd_barrier() is added to the end of the occupant chain. // Similarly, when the barrier is released, the occupant chain is cleared by the -// thread that caused the barrier to open. +// thread that caused the barrier to open. // // The reason for the "occupant" chain is to be able to figure out at any // given time if there are threads of any sort *stuck* in a barrier so that // something might be done about releasing them without necessarily terminating // the XDD run. This is useful for copy (aka end-to-end) operations that might -// have a stalled Worker Thread that needs to be terminated. +// have a stalled Worker Thread that needs to be terminated. // // The "occupant" chain is very similar to the barrier chain in that it is // a circular doubly-linked list of "occupant" structures. Each barrier @@ -105,12 +105,12 @@ // pointers to the first and last occupant structure on the chain. New occupant // structures are always added to the end of the chain. Occupant structures // can be removed from anywhere in the chain but under normal operating conditions -// when the final occupant enters the barrier, the owner of the barrier will +// when the final occupant enters the barrier, the owner of the barrier will // simply remove the first/last pointers to the chain effectively taking all the // occupants off the chain at once (rather than removing them individually). // The "counter" member of the barrier structure indicates the number of occupants -// in the barrier at any given time. -// The "threads" member of the barrier structure indicates the number of occupants +// in the barrier at any given time. +// The "threads" member of the barrier structure indicates the number of occupants // that must enter the barrier before all the occupants are released. // // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -118,10 +118,10 @@ // When the occupant type is either TARGET or Worker THREAD then the occupant_data member // points (or should point) to the Target or Worker Data for that particular thread. // The occupant_name should always point to a character string that indicates -// the name of the occupant. For example, if the occupant_type is SUPPORT then -// the occupant_name will be "results_manager" or "heartbeat" or "restart". +// the name of the occupant. For example, if the occupant_type is SUPPORT then +// the occupant_name will be "results_manager" or "heartbeat" or "restart". // If the occupant_type is a Worker THREAD then the occupant_name will be "TARGET_#_WORKER_#" -// An occupant_type of TARGET will have an occupant_name of "target_#". +// An occupant_type of TARGET will have an occupant_name of "target_#". // Finally, an occupant_type of MAIN will have an occupant_name of "main". // @@ -148,18 +148,16 @@ typedef struct xdd_occupant xdd_occupant_t; #define XDD_BARRIER_MAX_NAME_LENGTH 64 // not to exceed this many characters in length #define XDD_BARRIER_FLAG_INITIALIZED 0x00000001ULL // Indicates that this barrier has been initialized struct xdd_barrier { - struct xdd_barrier *prev_barrier; // Previous barrier in the chain - struct xdd_barrier *next_barrier; // Next barrier in chain + struct xdd_barrier *prev_barrier; // Previous barrier in the chain + struct xdd_barrier *next_barrier; // Next barrier in chain struct xdd_occupant *first_occupant;// First Occupant in the chain struct xdd_occupant *last_occupant; // Last Occupant in the chain uint32_t flags; // State indicators and the like char name[XDD_BARRIER_MAX_NAME_LENGTH]; // This is the ASCII name of the barrier int32_t counter; // Couter used to keep track of how many threads have entered the barrier int32_t threads; /// The number of threads that need to enter this barrier before occupants are released -#ifdef WIN32 - HANDLE sem; // The semaphore Object -#elif (defined HAVE_PTHREAD_BARRIER_T) - pthread_barrier_t pbar; // The PThreads Barrier +#if defined(HAVE_PTHREAD_BARRIER_T) + pthread_barrier_t pbar; // The PThreads Barrier #else xint_barrier_t pbar; #endif @@ -178,5 +176,3 @@ typedef struct xdd_barrier xdd_barrier_t; * * vim: ts=4 sts=4 sw=4 noexpandtab */ - - diff --git a/src/common/memory.c b/src/common/memory.c index a738475f..6c3fb680 100644 --- a/src/common/memory.c +++ b/src/common/memory.c @@ -11,7 +11,7 @@ * */ /* - * This file contains the subroutines that perform various initialization + * This file contains the subroutines that perform various initialization * functions with respect to memory such as locking and unlocking pages. */ #include "xint.h" @@ -21,27 +21,10 @@ void xdd_lock_memory(unsigned char *bp, uint32_t bsize, char *sp) { int32_t status; /* status of a system call */ - // If the nomemlock option is set then do not lock memory + // If the nomemlock option is set then do not lock memory if (xgp->global_options & GO_NOMEMLOCK) return; -#if (AIX) - int32_t liret; - off_t newlim; - /* Get the current memory stack limit - required before locking the the memory */ - liret = -1; - newlim = -1; - liret = ulimit(GET_STACKLIM,0); - if (liret == -1) { - fprintf(xgp->errout,"(PID %d) %s: AIX Could not get memory stack limit\n", - getpid(),xgp->progname); - perror("Reason"); - } - /* Get 8 pages more than the stack limit */ - newlim = liret - (PAGESIZE*8); - return; -#else -#if (LINUX || SOLARIS || DARWIN || AIX || FREEBSD) if (getuid() != 0) { if (xgp->global_options&GO_REALLYVERBOSE) { fprintf(xgp->errout,"(PID %d) %s: You must run as superuser to lock memory for %s\n", @@ -49,14 +32,12 @@ xdd_lock_memory(unsigned char *bp, uint32_t bsize, char *sp) { } return; } -#endif status = mlock((char *)bp, bsize); if (status < 0) { fprintf(xgp->errout,"(PID %d) %s: Could not lock %d bytes of memory for %s\n", getpid(),xgp->progname,bsize,sp); perror("Reason"); } -#endif } /* end of xdd_lock_memory() */ /*----------------------------------------------------------------------------*/ void @@ -66,7 +47,6 @@ xdd_unlock_memory(unsigned char *bp, uint32_t bsize, char *sp) { // If the nomemlock option is set then do not unlock memory because it was never locked if (xgp->global_options & GO_NOMEMLOCK) return; -#if (AIX) #ifdef notdef status = plock(UNLOCK); if (status) { @@ -76,17 +56,13 @@ xdd_unlock_memory(unsigned char *bp, uint32_t bsize, char *sp) { } #endif return; -#else -#if (IRIX || SOLARIS || LINUX || DARWIN || FREEBSD) if (getuid() != 0) { return; } -#endif status = munlock((char *)bp, bsize); if (status < 0) { fprintf(xgp->errout,"(PID %d) %s: Could not unlock memory for %s\n", getpid(),xgp->progname,sp); perror("Reason"); } -#endif } /* end of xdd_unlock_memory() */ diff --git a/src/common/processor.c b/src/common/processor.c index 639c3e28..9c10e992 100644 --- a/src/common/processor.c +++ b/src/common/processor.c @@ -16,8 +16,8 @@ */ #include "xint.h" /*----------------------------------------------------------------------------*/ -/* xdd_processor() - assign this xdd thread to a specific processor - * This works on most operating systems except LINUX at the moment. +/* xdd_processor() - assign this xdd thread to a specific processor + * This works on most operating systems except LINUX at the moment. * The ability to assign a *process* to a specific processor is new to Linux as * of the 2.6.8 Kernel. However, the ability to assign a *thread* to a specific * processor still does not exist in Linux as of 2.6.8. Therefore, all xdd threads @@ -30,37 +30,12 @@ */ void xdd_processor(target_data_t *tdp) { -#if (SOLARIS) - processorid_t i; - int32_t status; - int32_t n,cpus; - n = sysconf(_SC_NPROCESSORS_ONLN); - cpus = 0; - for (i = 0; n > 0; i++) { - status = p_online(i, P_STATUS); - if (status == -1 ) - continue; - /* processor present */ - if (cpus == p->processor) - break; - cpus++; - n--; - } - /* At this point "i" contains the processor number to bind this process to */ - status = processor_bind(P_LWPID, P_MYID, i, NULL); - if (status < 0) { - fprintf(xgp->errout,"%s: Processor assignment failed for target %d\n",xgp->progname,p->my_target_number); - perror("Reason"); - } - return; - -#elif (LINUX) size_t cpumask_size; /* size of the CPU mask in bytes */ cpu_set_t cpumask; /* mask of the CPUs configured on this system */ int status; /* System call status */ int32_t n; /* the number of CPUs configured on this system */ int32_t cpus; /* the number of CPUs configured on this system */ - int32_t i; + int32_t i; cpumask_size = (unsigned int)sizeof(cpumask); status = sched_getaffinity(syscall(SYS_gettid), cpumask_size, &cpumask); @@ -74,7 +49,7 @@ xdd_processor(target_data_t *tdp) { for (i = 0; n > 0; i++) { if (CPU_ISSET(i, &cpumask)) { /* processor present */ - if (cpus == tdp->td_processor) + if (cpus == tdp->td_processor) break; cpus++; n--; @@ -96,32 +71,6 @@ xdd_processor(target_data_t *tdp) { tdp->td_pid, tdp->td_thread_id); return; -#elif (AIX) - int32_t status; - if (xgp->global_options & GO_REALLYVERBOSE) - fprintf(xgp->output, "Binding process/thread %d/%d to processor %d\n",tdp->td_pid, tdp->td_thread_id, tdp->td_processor); - status = bindprocessor( BINDTHREAD, tdp->td_thread_id, tdp->td_processor ); - if (status) { - fprintf(xgp->errout,"%s: Processor assignment failed for target %d to processor %d, thread ID %d, process ID %d\n", - xgp->progname, p->my_target_number, p->processor, p->my_thread_id, p->my_pid); - perror("Reason"); - } - return; -#elif (IRIX || WIN32) - int32_t i; - i = sysmp (MP_MUSTRUN,p->processor); - if (i < 0) { - fprintf(xgp->errout,"%s: **WARNING** Error assigning target %d to processor %d\n", - xgp->progname, p->my_target_number, p->processor); - perror("Reason"); - } - return; -#else - fprintf(xgp->errout,"%s: **WARNING** Error assigning target %d to processor %d\n", - xgp->progname, tdp->td_target_number, tdp->td_processor); - perror("Reason"); - return; -#endif } /* end of xdd_processor() */ /*----------------------------------------------------------------------------*/ /* xdd_get_processor() - Get the processor number that this is current running on. diff --git a/src/common/sg.h b/src/common/sg.h index a43a57c4..5d764ce5 100644 --- a/src/common/sg.h +++ b/src/common/sg.h @@ -11,7 +11,6 @@ * */ -#if LINUX #include #include #include @@ -63,7 +62,7 @@ extern llse_loff_t llse_llseek(unsigned int fd, /* Feel free to copy and modify this GPL-ed code into your applications. */ -/* Version 0.84 (20010115) +/* Version 0.84 (20010115) - all output now sent to stderr rather thatn stdout - remove header files included in this file */ @@ -160,8 +159,8 @@ extern llse_loff_t llse_llseek(unsigned int fd, /* The following "print" functions send ACSII to stdout */ extern void sg_print_command(const unsigned char *command, FILE *outp); extern void sg_print_sense( const char *leadin, - const unsigned char *sense_buffer, - int sb_len, + const unsigned char *sense_buffer, + int sb_len, FILE *outp); extern void sg_print_status(int masked_status, FILE *outp); extern void sg_print_host_status(int host_status, FILE *outp); @@ -169,15 +168,15 @@ extern void sg_print_driver_status(int driver_status, FILE *outp); /* sg_chk_n_print() returns 1 quietly if there are no errors/warnings else it prints to standard output and returns 0. */ -extern int sg_chk_n_print( const char *leadin, +extern int sg_chk_n_print( const char *leadin, int masked_status, - int host_status, + int host_status, int driver_status, - const unsigned char *sense_buffer, - int sb_len, + const unsigned char *sense_buffer, + int sb_len, FILE *outp); -/* The following function declaration is for the sg version 3 driver. +/* The following function declaration is for the sg version 3 driver. Only version 3 sg_err.c defines it. */ struct sg_io_hdr; extern int sg_chk_n_print3(const char *leadin, struct sg_io_hdr *hp, FILE *outp); @@ -192,18 +191,17 @@ extern int sg_chk_n_print3(const char *leadin, struct sg_io_hdr *hp, FILE *outp) #define SG_ERR_CAT_SENSE 98 /* Something else is in the sense buffer */ #define SG_ERR_CAT_OTHER 99 /* Some other error/warning has occurred */ -extern int sg_err_category(int masked_status, +extern int sg_err_category(int masked_status, int host_status, - int driver_status, + int driver_status, const unsigned char *sense_buffer, int sb_len); -/* The following function declaration is for the sg version 3 driver. +/* The following function declaration is for the sg version 3 driver. Only version 3 sg_err.c defines it. */ extern int sg_err_category3(struct sg_io_hdr *hp); #endif -#endif - + //****************************************************************************** /* ASCII values for a number of symbolic constants, printing functions, etc. * @@ -337,7 +335,7 @@ static const char * statuses[] = { // The following tables contain the ASCII strings for the most // common status and sense code combinations. Only a few of // these apply to disk storage devices but they are all here -// just in case. +// just in case. // #define D 0x001 /* DIRECT ACCESS DEVICE (disk) */ #define T 0x002 /* SEQUENTIAL ACCESS DEVICE (tape) */ @@ -586,20 +584,20 @@ static const char *snstext[] = { do not agree */ "Key=15" /* Reserved */ }; - + static const char * hostbyte_table[]={ "DID_OK", "DID_NO_CONNECT", "DID_BUS_BUSY", "DID_TIME_OUT", "DID_BAD_TARGET", "DID_ABORT", "DID_PARITY", "DID_ERROR", "DID_RESET", "DID_BAD_INTR", "DID_PASSTHROUGH", "DID_SOFT_ERROR", NULL}; - + static const char * driverbyte_table[]={ "DRIVER_OK", "DRIVER_BUSY", "DRIVER_SOFT", "DRIVER_MEDIA", "DRIVER_ERROR", "DRIVER_INVALID", "DRIVER_TIMEOUT", "DRIVER_HARD", "DRIVER_SENSE", NULL}; static const char * driversuggest_table[]={"SUGGEST_OK", "SUGGEST_RETRY", "SUGGEST_ABORT", "SUGGEST_REMAP", "SUGGEST_DIE", -unknown,unknown,unknown, "SUGGEST_SENSE",NULL}; - +unknown,unknown,unknown, "SUGGEST_SENSE",NULL}; + /* * Local variables: * indent-tabs-mode: t diff --git a/src/common/timestamp.c b/src/common/timestamp.c index 6dfe8988..2276b414 100644 --- a/src/common/timestamp.c +++ b/src/common/timestamp.c @@ -20,14 +20,14 @@ /* xdd_ts_overhead() - determine time stamp overhead */ void -xdd_ts_overhead(struct xdd_ts_header *ts_hdrp) { +xdd_ts_overhead(struct xdd_ts_header *ts_hdrp) { int32_t i; nclk_t tv[101]; ts_hdrp->tsh_timer_oh = 0; for (i = 0; i < 101; i++) { nclk_now(&tv[i]); } - for (i = 0; i < 100; i++) + for (i = 0; i < 100; i++) ts_hdrp->tsh_timer_oh += (tv[i+1]-tv[i]); ts_hdrp->tsh_timer_oh /= 100; if (xgp->global_options & GO_TIMER_INFO) { /* only display this information if requested */ @@ -38,9 +38,9 @@ xdd_ts_overhead(struct xdd_ts_header *ts_hdrp) { } /* End of xdd_ts_overhead() */ /*----------------------------------------------------------------------------*/ /* xdd_ts_setup() - set up the time stamping - * If time stamping is already turned on for this target then we need to make - * sure that the size of the time stamp table is adequate and enlarge it if - * necessary. + * If time stamping is already turned on for this target then we need to make + * sure that the size of the time stamp table is adequate and enlarge it if + * necessary. */ void xdd_ts_setup(target_data_t *tdp) { @@ -59,7 +59,7 @@ xdd_ts_setup(target_data_t *tdp) { // Calculate the size of the timestamp table needed for this entire run tsp->ts_size = (tdp->td_planp->passes * tdp->td_target_ops) + tdp->td_queue_depth; - if (tsp->ts_options & (TS_TRIGTIME | TS_TRIGOP)) + if (tsp->ts_options & (TS_TRIGTIME | TS_TRIGOP)) tsp->ts_options &= ~TS_ALL; /* turn off the "time stamp all operations" flag if a trigger was requested */ if (tsp->ts_options & TS_TRIGTIME) { /* adjust the trigger time to an actual local time */ tsp->ts_trigtime *= BILLION; @@ -67,7 +67,7 @@ xdd_ts_setup(target_data_t *tdp) { } /* Calculate size of the time stamp table and malloc it */ - tt_entries = tsp->ts_size; + tt_entries = tsp->ts_size; if (tt_entries < ((tdp->td_planp->passes * tdp->td_target_ops) + tdp->td_queue_depth)) { /* Display a NOTICE message if ts_wrap or ts_oneshot have not been specified to compensate for a short time stamp buffer */ if (((tsp->ts_options & TS_WRAP) == 0) && ((tsp->ts_options & TS_ONESHOT) == 0)) { @@ -81,7 +81,6 @@ xdd_ts_setup(target_data_t *tdp) { } /* calculate the total size in bytes of the time stamp table */ tt_bytes = (int)((sizeof(struct xdd_ts_header)) + (tt_entries * sizeof(struct xdd_ts_tte))); -#if (LINUX || SOLARIS || AIX || DARWIN) tdp->td_ts_table.ts_hdrp = (struct xdd_ts_header *)valloc(tt_bytes); if (xgp->global_options & GO_DEBUG_TS) { fprintf(stderr,"DEBUG_TS: %lld: xdd_ts_setup: Target: %d: Worker: -: TS INITIALIZATION " @@ -92,10 +91,7 @@ xdd_ts_setup(target_data_t *tdp) { (int)tt_entries); } - -#else - tdp->td_ts_table.ts_hdrp = (struct xdd_ts_header *)malloc(tt_bytes); -#endif + if (tdp->td_ts_table.ts_hdrp == 0) { fprintf(xgp->errout,"%s: xdd_ts_setup: Target %d: ERROR: Cannot allocate %d bytes of memory for timestamp table\n", xgp->progname, @@ -123,14 +119,14 @@ xdd_ts_setup(target_data_t *tdp) { /* Set the XDD Version into the timestamp header */ tdp->td_ts_table.ts_hdrp->tsh_magic = 0xDEADBEEF; snprintf(tdp->td_ts_table.ts_hdrp->tsh_version, sizeof(tdp->td_ts_table.ts_hdrp->tsh_version), "%s", PACKAGE_STRING); - + /* init entries in the trace table header */ tdp->td_ts_table.ts_hdrp->tsh_target_thread_id = tdp->td_pid; tdp->td_ts_table.ts_hdrp->tsh_res = cycleval; tdp->td_ts_table.ts_hdrp->tsh_reqsize = tdp->td_xfer_size; tdp->td_ts_table.ts_hdrp->tsh_blocksize = tdp->td_block_size; - strcpy(tdp->td_ts_table.ts_hdrp->tsh_id, xgp->id); + strcpy(tdp->td_ts_table.ts_hdrp->tsh_id, xgp->id); tdp->td_ts_table.ts_hdrp->tsh_range = tdp->td_seekhdr.seek_range; tdp->td_ts_table.ts_hdrp->tsh_start_offset = tdp->td_start_offset; tdp->td_ts_table.ts_hdrp->tsh_target_offset = tdp->td_planp->target_offset; @@ -189,14 +185,14 @@ xdd_ts_setup(target_data_t *tdp) { (void *)tdp->td_ts_table.ts_hdrp, (int)tt_entries); } - + if (xgp->global_options & GO_DEBUG_TS) { xdd_show_ts_table(&tdp->td_ts_table, tdp->td_target_number); } return; } /* end of xdd_ts_setup() */ /*----------------------------------------------------------------------------*/ -/* xdd_ts_write() - write the timestamp entried to a file. +/* xdd_ts_write() - write the timestamp entried to a file. */ void xdd_ts_write(target_data_t *tdp) { @@ -245,14 +241,14 @@ xdd_ts_cleanup(struct xdd_ts_header *ts_hdrp) { } /* end of xdd_ts_cleanup() */ /*----------------------------------------------------------------------------*/ -/* xdd_ts_reports() - Generate the time stamp reports. +/* xdd_ts_reports() - Generate the time stamp reports. * In this section disk_io_time is the time from the start of - * I/O to the end of the I/O. The Relative I/O time is + * I/O to the end of the I/O. The Relative I/O time is * the time from time 0 to the end of the current I/O. * The Dead Time is the time from the end of an I/O to * the start of the next I/O - time between I/O. * IMPORTANT NOTE: All times are in nclk units of nanoseconds. - * + * */ void xdd_ts_reports(target_data_t *tdp) { @@ -291,10 +287,6 @@ xdd_ts_reports(target_data_t *tdp) { tsp = &tdp->td_ts_table; tsfp = tsp->ts_tsfp; ts_hdrp = tdp->td_ts_table.ts_hdrp; -#ifdef WIN32 /* This is required to circumvent the problem of mulitple streams to multiple files */ - /* We need to wait for the previous thread to finish writing its ts report and close the output stream before we can continue */ - WaitForSingleObject(tsp->ts_serializer_mutex,INFINITE); -#endif if(tsp->ts_options & TS_SUPPRESS_OUTPUT) return; if (!(tdp->td_current_state & TARGET_CURRENT_STATE_PASS_COMPLETE)) { @@ -338,18 +330,18 @@ xdd_ts_reports(target_data_t *tdp) { } if (tsp->ts_options & TS_DETAILED) { /* Generate the detailed and summary report */ if ((tsp->ts_options & TS_WRAP) || (tsp->ts_options & TS_ONESHOT)) { - if (ts_hdrp->tsh_tte_indx == 0) + if (ts_hdrp->tsh_tte_indx == 0) indx = ts_hdrp->tsh_tt_size - 1; else indx = ts_hdrp->tsh_tte_indx - 1; fprintf(tsfp, "Last time stamp table entry, %lld\n", (long long)indx); } - + fprintf(tsfp,"Start of DETAILED Time Stamp Report, Number of entries, %lld, Picoseconds per clock tick, %lld, delta, %lld\n", (long long)ts_hdrp->tsh_numents, (long long)ts_hdrp->tsh_res, (long long)ts_hdrp->tsh_delta); - + // Print a header line with the Quantities as they appear across the page fprintf(tsfp,"WorkerThread"); fprintf(tsfp,"WorkerThreadID"); @@ -407,7 +399,7 @@ xdd_ts_reports(target_data_t *tdp) { fprintf(tsfp,"\n"); fflush(tsfp); } - + /* Scan the time stamp table and calculate the numbers */ count = 0; hi_dist = 0; @@ -429,12 +421,12 @@ xdd_ts_reports(target_data_t *tdp) { ts_hdrp->tsh_blocksize = tdp->td_block_size; } if (ts_hdrp->tsh_tte[i].tte_byte_offset > ts_hdrp->tsh_tte[i-1].tte_byte_offset) { - distance[i] = (ts_hdrp->tsh_tte[i].tte_byte_offset - - (ts_hdrp->tsh_tte[i-1].tte_byte_offset + + distance[i] = (ts_hdrp->tsh_tte[i].tte_byte_offset - + (ts_hdrp->tsh_tte[i-1].tte_byte_offset + (ts_hdrp->tsh_reqsize))); } else { - distance[i] = (ts_hdrp->tsh_tte[i-1].tte_byte_offset - - (ts_hdrp->tsh_tte[i].tte_byte_offset + + distance[i] = (ts_hdrp->tsh_tte[i-1].tte_byte_offset - + (ts_hdrp->tsh_tte[i].tte_byte_offset + (ts_hdrp->tsh_reqsize))); } loop_time = ts_hdrp->tsh_tte[i].tte_disk_end - ts_hdrp->tsh_tte[i-1].tte_disk_end; @@ -446,7 +438,7 @@ xdd_ts_reports(target_data_t *tdp) { if (ts_hdrp->tsh_tte[i].tte_pass_number > ts_hdrp->tsh_tte[i-1].tte_pass_number) { fprintf(tsfp,"\n"); } - } else { + } else { total_distance += distance[i]; if (hi_dist < distance[i]) hi_dist = distance[i]; if (lo_dist > distance[i]) lo_dist = distance[i]; @@ -458,11 +450,11 @@ xdd_ts_reports(target_data_t *tdp) { disk_fio_time = (double)disk_io_time[i]; frelative_time = (double)relative_time; floop_time = (double)loop_time; - if (disk_fio_time > 0.0) + if (disk_fio_time > 0.0) disk_irate = ((ts_hdrp->tsh_reqsize)/(disk_fio_time / BILLION))/1000000.0; else disk_irate = 0.0; net_fio_time = (double)net_io_time[i]; - if (net_fio_time > 0.0) + if (net_fio_time > 0.0) net_irate = ((ts_hdrp->tsh_reqsize)/(net_fio_time / BILLION))/1000000.0; else net_irate = 0.0; if (tsp->ts_options & TS_DETAILED) { /* Print the detailed report */ @@ -471,55 +463,55 @@ xdd_ts_reports(target_data_t *tdp) { net_start_ts = ts_hdrp->tsh_tte[i].tte_net_start + ts_hdrp->tsh_delta; net_end_ts = ts_hdrp->tsh_tte[i].tte_net_end + ts_hdrp->tsh_delta; switch (ts_hdrp->tsh_tte[i].tte_op_type) { - case SO_OP_READ: - case TASK_OP_TYPE_READ: - opc="r"; + case SO_OP_READ: + case TASK_OP_TYPE_READ: + opc="r"; break; - - case SO_OP_WRITE: - case TASK_OP_TYPE_WRITE: - opc="w"; + + case SO_OP_WRITE: + case TASK_OP_TYPE_WRITE: + opc="w"; break; - case SO_OP_WRITE_VERIFY: - opc="v"; + case SO_OP_WRITE_VERIFY: + opc="v"; break; - case SO_OP_NOOP: - case TASK_OP_TYPE_NOOP: - opc="n"; + case SO_OP_NOOP: + case TASK_OP_TYPE_NOOP: + opc="n"; break; - case SO_OP_EOF: - case TASK_OP_TYPE_EOF: - opc="e"; + case SO_OP_EOF: + case TASK_OP_TYPE_EOF: + opc="e"; break; - default: - sprintf(opc2,"0x%02x",ts_hdrp->tsh_tte[i].tte_op_type); - opc=opc2; + default: + sprintf(opc2,"0x%02x",ts_hdrp->tsh_tte[i].tte_op_type); + opc=opc2; break; } - + fprintf(tsfp,"%d,",ts_hdrp->tsh_tte[i].tte_worker_thread_number); fprintf(tsfp,"%d,",ts_hdrp->tsh_tte[i].tte_thread_id); fprintf(tsfp,"%s,",opc); - fprintf(tsfp,"%d,",ts_hdrp->tsh_tte[i].tte_pass_number); - fprintf(tsfp,"%lld,",(long long)ts_hdrp->tsh_tte[i].tte_op_number); - fprintf(tsfp,"%lld,",(long long)ts_hdrp->tsh_tte[i].tte_byte_offset); - fprintf(tsfp,"%lld,",(long long)distance[i]); - fprintf(tsfp,"%lld,",(long long)ts_hdrp->tsh_tte[i].tte_disk_xfer_size); - fprintf(tsfp,"%d,", ts_hdrp->tsh_tte[i].tte_disk_processor_start); - fprintf(tsfp,"%d,", ts_hdrp->tsh_tte[i].tte_disk_processor_end); - fprintf(tsfp,"%llu,",(unsigned long long)disk_start_ts); - fprintf(tsfp,"%llu,",(unsigned long long)disk_end_ts); - fprintf(tsfp,"%15.5f,",disk_fio_time/1000000000.0); + fprintf(tsfp,"%d,",ts_hdrp->tsh_tte[i].tte_pass_number); + fprintf(tsfp,"%lld,",(long long)ts_hdrp->tsh_tte[i].tte_op_number); + fprintf(tsfp,"%lld,",(long long)ts_hdrp->tsh_tte[i].tte_byte_offset); + fprintf(tsfp,"%lld,",(long long)distance[i]); + fprintf(tsfp,"%lld,",(long long)ts_hdrp->tsh_tte[i].tte_disk_xfer_size); + fprintf(tsfp,"%d,", ts_hdrp->tsh_tte[i].tte_disk_processor_start); + fprintf(tsfp,"%d,", ts_hdrp->tsh_tte[i].tte_disk_processor_end); + fprintf(tsfp,"%llu,",(unsigned long long)disk_start_ts); + fprintf(tsfp,"%llu,",(unsigned long long)disk_end_ts); + fprintf(tsfp,"%15.5f,",disk_fio_time/1000000000.0); fprintf(tsfp,"%15.5f,",disk_irate); - fprintf(tsfp,"%15.5f,",frelative_time/1000000000.0); + fprintf(tsfp,"%15.5f,",frelative_time/1000000000.0); fprintf(tsfp,"%15.5f,",floop_time/1000000000.0); if (tdp->td_target_options & TO_ENDTOEND) { - fprintf(tsfp,"%lld,",(long long)ts_hdrp->tsh_tte[i].tte_net_xfer_size); - fprintf(tsfp,"%d,", ts_hdrp->tsh_tte[i].tte_net_processor_start); - fprintf(tsfp,"%d,", ts_hdrp->tsh_tte[i].tte_net_processor_end); - fprintf(tsfp,"%llu,",(unsigned long long)net_start_ts); - fprintf(tsfp,"%llu,",(unsigned long long)net_end_ts); - fprintf(tsfp,"%15.5f,",net_fio_time/1000000000.0); + fprintf(tsfp,"%lld,",(long long)ts_hdrp->tsh_tte[i].tte_net_xfer_size); + fprintf(tsfp,"%d,", ts_hdrp->tsh_tte[i].tte_net_processor_start); + fprintf(tsfp,"%d,", ts_hdrp->tsh_tte[i].tte_net_processor_end); + fprintf(tsfp,"%llu,",(unsigned long long)net_start_ts); + fprintf(tsfp,"%llu,",(unsigned long long)net_end_ts); + fprintf(tsfp,"%15.5f,",net_fio_time/1000000000.0); fprintf(tsfp,"%15.3f",net_irate); } fprintf(tsfp,"\n"); @@ -531,7 +523,7 @@ xdd_ts_reports(target_data_t *tdp) { free(distance); free(disk_io_time); free(net_io_time); - + if (tsp->ts_options & TS_DETAILED) /* Print the detailed report trailer */ fprintf(tsfp,"End of DETAILED Time Stamp Report\n"); fflush(tsfp); @@ -548,20 +540,20 @@ xdd_ts_reports(target_data_t *tdp) { } fprintf(tsfp, "Start of SUMMARY Time Stamp Report\n"); fflush(tsfp); - + /* display the results */ if (ts_hdrp->tsh_blocksize > 0) { fprintf(tsfp,"Average seek distance in %d byte blocks, %lld, request size in blocks, %d\n", - ts_hdrp->tsh_blocksize, + ts_hdrp->tsh_blocksize, (long long)mean_distance, ts_hdrp->tsh_reqsize/ts_hdrp->tsh_blocksize); fflush(tsfp); } else { fprintf(tsfp,"No average seek distance with 0 byte blocks\n"); } - + fprintf(tsfp,"Range: Longest seek distance in blocks, %lld, shortest seek distance in blocks, %lld\n", - (long long)hi_dist, + (long long)hi_dist, (long long)lo_dist); fflush(tsfp); fmean_iotime = (double)mean_iotime; @@ -577,9 +569,6 @@ xdd_ts_reports(target_data_t *tdp) { fflush(tsfp); if (tsfp != stdout) fclose(tsfp); -#ifdef WIN32 /* Allow the next thread to write its file */ - ReleaseMutex(tsp->ts_serializer_mutex); -#endif } /* end of xdd_ts_reports() */ /* diff --git a/src/common/xint.h b/src/common/xint.h index d2adab65..679fd529 100644 --- a/src/common/xint.h +++ b/src/common/xint.h @@ -15,21 +15,7 @@ #include "config.h" #include "xdd_base_version.h" -#if WIN32 -#include "xint_win32.h" -#elif defined(LINUX) #include "xint_linux.h" -#elif DARWIN -#include "xint_darwin.h" -#elif FREEBSD -#include "xint_freebsd.h" -#elif SOLARIS -#include "xint_solaris.h" -#elif AIX -#include "xint_aix.h" -#elif IRIX -#include "xint_irix.h" -#endif // #include "xint_common.h" #include "xint_plan.h" @@ -47,4 +33,3 @@ * * vim: ts=4 sts=4 sw=4 noexpandtab */ - diff --git a/src/common/xint_misc.h b/src/common/xint_misc.h index 7d87d7b8..54c2232d 100644 --- a/src/common/xint_misc.h +++ b/src/common/xint_misc.h @@ -70,19 +70,6 @@ #define ULONGLONG_MAX ULLONG_MAX #endif -/* - * Windows defines a LONGLONG type to hold long data; problem is - * it's a floating point, rather than an integral type. So this - * kludge is used to convert a LONGLONG to its long long form. - */ -#ifdef WIN32 - -/* Enable Intel on Windows? */ -#define __INTEL__ - -#define LONG_LONG(LLvar) (*(long long *) &(LLvar).QuadPart) -#define pause() /* Not defined in Windows env */ -#endif /* WIN32 long long redefinition */ #endif /* ! MISC_H */ /* diff --git a/src/common/xint_nclk.c b/src/common/xint_nclk.c index 622b2f52..d70dfca1 100644 --- a/src/common/xint_nclk.c +++ b/src/common/xint_nclk.c @@ -41,16 +41,9 @@ static bool nclk_initialized = false; */ void nclk_initialize(nclk_t *nclkp) { - -#if (LINUX) // Since we use the "nanosecond" clocks in Linux, // the number of nanoseconds per nanosecond "tick" is 1 *nclkp = ONE; -#elif (SOLARIS || AIX || DARWIN || FREEBSD ) - // Since we use the "gettimeofday" clocks in this OS, - // the number of nanoseconds per microsecond "tick" is 1,000 - *nclkp = THOUSAND; -#endif nclk_initialized = true; return; } @@ -77,14 +70,6 @@ nclk_shutdown(void) { * * Note that Epoch seconds x 1e9 + nanoseconds will consume 18 decimal digits * * This should fit into unsigned 64-bit integer. * */ -#ifdef WIN32 -void -nclk_now(nclk_t *nclkp) { - - QueryPerformanceCounter((LARGE_INTEGER *)nclkp); -} -/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#elif (LINUX) void nclk_now(nclk_t *nclkp) { @@ -103,18 +88,6 @@ nclk_now(nclk_t *nclkp) { return; } /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#elif (SOLARIS || AIX || DARWIN || FREEBSD ) -void -nclk_now(nclk_t *nclkp) { - struct timeval current_time; - struct timezone tz; - - gettimeofday(¤t_time, &tz); - *nclkp = (nclk_t)(((nclk_t)current_time.tv_sec * BILLION) + - ((nclk_t)current_time.tv_usec * THOUSAND)); - return; -} -#endif int64_t pclk_now(void) { nclk_t now; diff --git a/src/common/xint_plan.h b/src/common/xint_plan.h index f9db1010..ffcab258 100644 --- a/src/common/xint_plan.h +++ b/src/common/xint_plan.h @@ -37,7 +37,7 @@ #include "xint_read_after_write.h" // REMOVE LATER struct ptds; -// Bit field definitions for the xdd_global_options - The "PLAN_XXXX" definitions are specifically for the Global Options +// Bit field definitions for the xdd_global_options - The "PLAN_XXXX" definitions are specifically for the Global Options #define PLAN_SYNCIO 0x0000000000000001ULL /* Sync every nth I/O operation */ #define PLAN_NOBARRIER 0x0000000000000002ULL /* Do not use a barrier */ @@ -110,27 +110,27 @@ struct xint_plan { pthread_t Restart_Thread; // PThread struct for restart monitor pthread_t Interactive_Thread; // PThread struct for Interactive Control processor Thread -// Thread Barriers +// Thread Barriers pthread_mutex_t barrier_chain_mutex; /* Locking mutex for the barrier chain */ xdd_barrier_t *barrier_chain_first; /* First barrier on the chain */ xdd_barrier_t *barrier_chain_last; /* Last barrier on the chain */ int32_t barrier_count; /* Number of barriers on the chain */ - xdd_barrier_t main_general_init_barrier; // Barrier for xdd_main to make sure that the various support threads have initialized + xdd_barrier_t main_general_init_barrier; // Barrier for xdd_main to make sure that the various support threads have initialized xdd_barrier_t main_targets_waitforstart_barrier; // Barrier where all target threads go waiting for main to tell them to start - xdd_barrier_t main_targets_syncio_barrier; // Barrier for syncio + xdd_barrier_t main_targets_syncio_barrier; // Barrier for syncio xdd_barrier_t main_results_final_barrier; // Barrier for the Results Manager to sync with xdd_main after all Target Threads have terminated - xdd_barrier_t results_targets_startpass_barrier; // Barrier for synchronizing target threads - all targets gather here at the beginning of a pass + xdd_barrier_t results_targets_startpass_barrier; // Barrier for synchronizing target threads - all targets gather here at the beginning of a pass - xdd_barrier_t results_targets_endpass_barrier; // Barrier for synchronizing target threads - all targets gather here at the end of a pass + xdd_barrier_t results_targets_endpass_barrier; // Barrier for synchronizing target threads - all targets gather here at the end of a pass - xdd_barrier_t results_targets_display_barrier; // Barrier for all Target Thereads to sync with the Results Manager while it displays information + xdd_barrier_t results_targets_display_barrier; // Barrier for all Target Thereads to sync with the Results Manager while it displays information - xdd_barrier_t results_targets_run_barrier; // Barrier for all Target Thereads to sync with the results manager at the end of the run + xdd_barrier_t results_targets_run_barrier; // Barrier for all Target Thereads to sync with the results manager at the end of the run xdd_barrier_t results_targets_waitforcleanup_barrier; // Barrier for all thereads to sync with the results manager when they have completed cleanup @@ -140,35 +140,27 @@ struct xint_plan { // Variables used by the Results Manager - char *format_string; // Pointer to the format string used by the results_display() to display results + char *format_string; // Pointer to the format string used by the results_display() to display results char results_header_displayed; // 1 means that the header has been displayed, 0 means no uint32_t heartbeat_flags; // Tell the heartbeat thread what to do and when #define HEARTBEAT_ACTIVE 0x00000001 // The HEARTBEAT_ACTIVE is set by the heartbeat thread when it is running -#define HEARTBEAT_HOLDOFF 0x00000002 // The results_manager will set HEARTBEAT_HOLDOFF bit when it wants to display pass results, +#define HEARTBEAT_HOLDOFF 0x00000002 // The results_manager will set HEARTBEAT_HOLDOFF bit when it wants to display pass results, // and unset HEARTBEAT_HOLDOFF after everything is displayed -#define HEARTBEAT_EXIT 0x00000004 // The results_manager will set HEARTBEAT_EXIT to tell heartbeat to exit +#define HEARTBEAT_EXIT 0x00000004 // The results_manager will set HEARTBEAT_EXIT to tell heartbeat to exit // -#ifdef WIN32 - HANDLE ts_serializer_mutex; /* needed to circumvent a Windows bug */ - char *ts_serializer_mutex_name; /* needed to circumvent a Windows bug */ -#endif - /* Target Specific variables */ target_data_t *target_datap[MAX_TARGETS]; /* Pointers to the active Target Data Structs */ results_t *target_average_resultsp[MAX_TARGETS];/* Results area for the "target" which is a composite of all its worker threads */ int64_t target_errno[MAX_TARGETS]; // Is set by each target to indicate its final return code -#ifdef LINUX rlim_t rlimit; -#endif - }; // End of Definition of the xdd_globals data structure typedef struct xint_plan xdd_plan_t; xdd_plan_t* xint_plan_data_initialization(); int xint_plan_start(xdd_plan_t* planp, xdd_occupant_t* occupant); - + int xint_plan_start_targets(xdd_plan_t* planp); void xint_plan_start_results_manager(xdd_plan_t* planp); @@ -178,7 +170,7 @@ void xint_plan_start_heartbeat(xdd_plan_t* planp); void xint_plan_start_restart_monitor(xdd_plan_t* planp); void xint_plan_start_interactive(xdd_plan_t* planp); - + #endif /* * Local variables: diff --git a/src/common/xint_td.h b/src/common/xint_td.h index d0f78730..5e6fd268 100644 --- a/src/common/xint_td.h +++ b/src/common/xint_td.h @@ -54,11 +54,7 @@ struct xint_target_data { int32_t td_pid; // My process ID int32_t td_target_number; // My target number uint64_t td_target_options; // I/O Options specific to each target -#ifdef WIN32 - HANDLE td_file_desc; // File HANDLE for the target device/file -#else int32_t td_file_desc; // File Descriptor for the target device/file -#endif int32_t td_open_flags; // Flags used during open processing of a target int32_t td_xfer_size; // Number of bytes per request int32_t td_filetype; // Type of file: regular, device, socket, ... @@ -165,11 +161,7 @@ struct xint_target_data { struct xint_raw *td_rawp; // RAW Data Structure Pointer struct lockstep *td_lsp; // Pointer to the lockstep structure used by the lockstep option struct xint_restart *td_restartp; // Pointer to the restart structure used by the restart monitor -#if (LINUX || DARWIN) struct stat td_statbuf; // Target File Stat buffer used by xdd_target_open() -#elif (AIX || SOLARIS) - struct stat64 td_statbuf; // Target File Stat buffer used by xdd_target_open() -#endif int32_t td_op_delay; // Number of seconds to delay between operations /* XNI Networking components */ diff --git a/src/compat/CMakeLists.txt b/src/compat/CMakeLists.txt index 6b0d8b08..2dcfc665 100644 --- a/src/compat/CMakeLists.txt +++ b/src/compat/CMakeLists.txt @@ -1,13 +1,5 @@ set(COMPAT_SRC - # nt_unix_compat.c - # nt_unix_compat.h - # xint_aix.h - # xint_barrier.h - # xint_darwin.h - # xint_freebsd.h # xint_linux.h - # xint_solaris.h - # xint_win32.h ) # add_library(compat OBJECT ${COMPAT_SRC} "${CONFIG_H}") diff --git a/src/compat/nt_unix_compat.c b/src/compat/nt_unix_compat.c deleted file mode 100644 index 817cc086..00000000 --- a/src/compat/nt_unix_compat.c +++ /dev/null @@ -1,477 +0,0 @@ -/* - * XDD - a data movement and benchmarking toolkit - * - * Copyright (C) 1992-2013 I/O Performance, Inc. - * Copyright (C) 2009-2013 UT-Battelle, LLC - * - * This is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public - * License version 2, as published by the Free Software - * Foundation. See file COPYING. - * - */ -/* These routines are used to provide the functionality of certain - * UNIX routines that are not in the Windows NT/2000/XP/Vista/Win7 environment. - */ -#include "xdd.h" -/*-----------------------------------------------------------------*/ -/* mlockall() - Lock user buffers and process pages into memory - * Return values: 0 is good, -1 is bad. - * There is no equivalent function in Windows. - */ -int -mlockall(unsigned int flag) { - return(0); -} /* end of mlockall() */ -/*-----------------------------------------------------------------*/ -/* mlock() - Lock user buffers pages into memory - * Return values: 0 is good, -1 is bad. - * There is no equivalent function in Windows. - */ -int -mlock(unsigned char *bp, uint32_t size) { - return(0); -} /* end of mlock() */ -/*-----------------------------------------------------------------*/ -/* munlock() - Free user buffers pages previously locked into memory - * Return values: 0 is good, -1 is bad. - * There is no equivalent function in Windows. - */ -int -munlock(unsigned char *bp, uint32_t size) { - return(0); -} /* end of munlock() */ -/*-----------------------------------------------------------------*/ -/* sched_get_priority_max() - Return the maximum priority class that - * a program can set itself to. This value is later used by - * the sched_setscheduler() routine to maximize the priority of this - * program. - */ -unsigned long -sched_get_priority_max(int flag) { - return(REALTIME_PRIORITY_CLASS); -} /* end of sched_get_priority_max() */ -/*-----------------------------------------------------------------*/ -/* sched_setscheduler() - This routine will set the priority class - * of this program to the requested priority class. - * This routine always returns 0 for successful operation. - */ -int -sched_setscheduler(int arg1, unsigned long arg2, struct sched_param *pp) { - HANDLE thread_handle; - BOOL status; - LPVOID lpMsgBuf; /* Used for the error messages */ - thread_handle = GetCurrentThread(); - /* reset the priority to max max max */ - status = SetThreadPriority(thread_handle,THREAD_PRIORITY_TIME_CRITICAL); - if (status == 0) { - fprintf(stderr,"SetThreadPriority: cannot reset process priority\n"); - FormatMessage( - FORMAT_MESSAGE_ALLOCATE_BUFFER | - FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, - GetLastError(), - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language - (LPTSTR) &lpMsgBuf, - 0, - NULL); - fprintf(stderr,"Reason:%s",lpMsgBuf); - } - return(0); -} /* end of sched_setscheduler() */ -/*-----------------------------------------------------------------*/ -/* lseek64() - This routine will perform a seek operation within a - * 64-bit address space. This routine maps to the SetFilePointer() - * Windows routine. - */ -int64_t -lseek64(unsigned long fd, int64_t offset, int flag) { - LONG phi,plow; - plow = (unsigned long)offset; - phi = (unsigned long)(offset >> 32); - SetFilePointer((void *)fd, plow, &phi, FILE_BEGIN); - return(offset); -} /* end of lseek64() */ -/*-----------------------------------------------------------------*/ -/* fsync() - - * This routine has no Windows equivalent. - */ -int -fsync(int fd) { - return(0); -} /* end of fsync() */ -/*-----------------------------------------------------------------*/ -/* getpagesize() - This function maps to the GetSystemInfo function - * in Windows that returns a structure that contains the page size - * in bytes. - */ -int -getpagesize(void) { - SYSTEM_INFO system_info; - GetSystemInfo(&system_info); - return(system_info.dwPageSize); -} /* end of getpagesize() */ -/*-----------------------------------------------------------------*/ -/* Return the wall clock time in milliseconds. Also, fill in the - * tms time structure with kernel and user times. The GetThreadTimes - * routine returns time values in 100-nanosecond increments. It is - * converted to CLK_TCK increments which is milliseconds. - */ -clock_t -times( struct tms *tp) { - HANDLE thread_handle; - BOOL status; - FILETIME kerneltime; - FILETIME usertime; - FILETIME createtime; - FILETIME exittime; - struct _timeb tstruct; - clock_t wallclock; - thread_handle = GetCurrentThread(); - status = GetThreadTimes( - thread_handle, - &createtime, - &exittime, - &kerneltime, - &usertime); - if (status == 0) { - fprintf(stderr,"times: cannot get thread times\n"); - perror("Reason"); - return(0); - } - tp->tms_utime = (unsigned long)((__int64)((usertime.dwHighDateTime << 32) | usertime.dwLowDateTime)/10000); - tp->tms_stime = (unsigned long)((__int64)((kerneltime.dwHighDateTime << 32) | kerneltime.dwLowDateTime)/10000); - _ftime( &tstruct ); - wallclock = ((tstruct.time*1000)+tstruct.millitm); - return(wallclock); -} /* end of times() */ -/*-----------------------------------------------------------------*/ -/* sleep() - This function maps to the Windows Sleep() function. - */ -void -sleep(int seconds) { - Sleep(seconds*1000); -} /* end of sleep() */ -/*-----------------------------------------------------------------*/ -int -pthread_create(pthread_t *tp, void *thread_attr, void *thread_function, void *thread_arg) -{ - HANDLE thread_handle; - thread_handle = CreateThread(NULL, 0, thread_function, thread_arg, 0,(unsigned long *)tp); - if (thread_handle == FALSE) { - fprintf(stderr,"pthread_create: Could not create target manager\n"); - perror("Reason"); - return(0); - } - tp->pthread = (pthread_t *)thread_handle; - return(0); -} /* end of pthread_create() */ -/*-----------------------------------------------------------------*/ -/* This mutex is needed to circumvent a windows bug that has to - * do with multiple threads creating multiple stream files and - * clobbering each others stuff. - */ -int32_t -ts_serializer_init(HANDLE *mp, char *mutex_name) { - HANDLE mutex_handle; - LPVOID lpMsgBuf; - mutex_handle = CreateMutex(NULL,FALSE, mutex_name); - if (mutex_handle == 0) { - FormatMessage( - FORMAT_MESSAGE_ALLOCATE_BUFFER | - FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, - GetLastError(), - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language - (LPTSTR) &lpMsgBuf, - 0, - NULL); - fprintf(stderr,"ts_serializer_init: Could not create mutex\n"); - fprintf(stderr,"reason:%s",lpMsgBuf); - *mp = 0; - return(-1); - } - *mp = mutex_handle; - WaitForSingleObject(mp,INFINITE); /* make sure we have ownership of this mutex */ - return(0); -} -/*-----------------------------------------------------------------*/ -int32_t -pthread_mutex_init(pthread_mutex_t *mp, int n) { - HANDLE mutex_handle; - LPVOID lpMsgBuf; - SECURITY_ATTRIBUTES sa; - sa.nLength = sizeof(SECURITY_ATTRIBUTES); - sa.lpSecurityDescriptor = NULL; - sa.bInheritHandle = TRUE; - sprintf(mp->name,"xddMutex%llx%",mp); - mutex_handle = CreateMutex(&sa,FALSE,mp->name); - if (mutex_handle == 0) { - FormatMessage( - FORMAT_MESSAGE_ALLOCATE_BUFFER | - FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, - GetLastError(), - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language - (LPTSTR) &lpMsgBuf, - 0, - NULL); - fprintf(stderr,"pthread_mutex_init: Could not create mutex %s\n",mp->name); - fprintf(stderr,"reason:%s",lpMsgBuf); - return(-1); - } - mp->mutex = mutex_handle; - return(0); -} /* end of pthread_mutex_init() */ -/*-----------------------------------------------------------------*/ -void -pthread_mutex_lock(pthread_mutex_t *mp) { - DWORD status; - status = WaitForSingleObject(mp->mutex, INFINITE); - if (status == WAIT_OBJECT_0) - return; - if (status == WAIT_ABANDONED) - fprintf(stderr,"pthread_mutex_lock: wait returned with WAIT_ABANDONED\n"); - if (status == WAIT_TIMEOUT) - fprintf(stderr,"pthread_mutex_lock: wait returned with WAIT_TIMEOUT\n"); - return; -} /* end of pthread_mutex_lock() */ -/*-----------------------------------------------------------------*/ -void -pthread_mutex_unlock(pthread_mutex_t *mp) { - DWORD status; - LPVOID lpMsgBuf; - status = ReleaseMutex(mp->mutex); - if (status == 0) { - FormatMessage( - FORMAT_MESSAGE_ALLOCATE_BUFFER | - FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, - GetLastError(), - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language - (LPTSTR) &lpMsgBuf, - 0, - NULL); - fprintf(stderr,"pthread_mutex_unlock: Could not release mutex\n"); - fprintf(stderr,"reason:%s",lpMsgBuf); - } -} /* end of pthread_mutex_unlock() */ -/*-----------------------------------------------------------------*/ -/* pthread_mutex_destroy() - pthread - * A return value of -1 is bad. Anything else is good. - */ -int -pthread_mutex_destroy(pthread_mutex_t *mp) { - CloseHandle(mp->mutex); - return(0); -} /* end of pthread_mutex_destroy() */ -/*-----------------------------------------------------------------*/ -/* semop() - nonzero return is bad. - * This routine is kind of weird. Semaphores in Unixland work - * quite the opposite - they are non-signaled when less than - * zero and signaled when equal to zero or greater. The NT - * semaphore is non-signaled when equal to zero and signaled - * when greater than zero. - * The way we use semaphores in xdd is as a synchronization barrier - * for all the threads to reach before continuing. - * semop is called with a count "sp->sem_op" of -1 each time a thread is - * supposed to wait at the barrier. If "sp->sem_op" is positive, then - * it is time to set the semaphore to a signaled state thus releasing - * all the waiting threads. It is important to note that if the sem_op is - * a -1, then the WaitForSingleObject() routine is called at which time - * the WaitForSingleObject() routine will first check the state of the - * of the semaphore: if the semaphore is 0 then the calling process is - * suspended until the semaphore is raised to a signaled state (positive - * number greater than 0). The semaphore is raised to a signaled state - * by the calling routine when the sem_op is a positive number greater - * than 0. The semaphore is then released and given this new value. - * The important part is that after the semaphore is set to this positive - * value (signaled), each wait function waiting on that semaphore will - * subtract 1 from the semaphore and then return to this routine which - * subsequently releases the associated thread. - * - */ -int -semop(HANDLE semid, struct sembuf *sp, int n) { - long prevcount; - DWORD status; - LPVOID lpMsgBuf; - if (sp->sem_op == -1) { - status = WaitForSingleObject(semid,INFINITE); - if (status == -1) { - FormatMessage( - FORMAT_MESSAGE_ALLOCATE_BUFFER | - FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, - GetLastError(), - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language - (LPTSTR) &lpMsgBuf, - 0, - NULL); - fprintf(stderr,"semop: Wait failed for semaphore semid 0x%x\n", semid); - fprintf(stderr,"reason:%s",lpMsgBuf); - } - } else { -//fprintf(stderr,"Releasing sp=%x, semop=%d\n",sp,sp->sem_op); - ReleaseSemaphore(semid,sp->sem_op,&prevcount); -//fprintf(stderr,"sp=%x, prevcount=%d\n",sp,prevcount); - } - return(0); -} /* end of semop() */ -/*-----------------------------------------------------------------*/ -/* semget() - Returns a semaphore identifier (semid). - * A retturn value of -1 is bad, anything else is good. - */ -HANDLE -semget(unsigned int semid_base, unsigned int maxsem, unsigned int flags) { - SECURITY_ATTRIBUTES sa; /* used to specify inheritance */ - HANDLE sh; /* Semaphore handle */ - char sname[256]; /* name of semaphore */ - LPVOID lpMsgBuf; - sa.nLength = sizeof(SECURITY_ATTRIBUTES); - sa.lpSecurityDescriptor = NULL; - sa.bInheritHandle = TRUE; - sprintf(sname,"xddseamphore%x",semid_base); - sh = CreateSemaphore(&sa,0,MAX_TARGETS,sname); - if (sh == NULL) { - FormatMessage( - FORMAT_MESSAGE_ALLOCATE_BUFFER | - FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, - GetLastError(), - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language - (LPTSTR) &lpMsgBuf, - 0, - NULL); - fprintf(stderr,"semget: Could not create semaphore %s\n",sname); - fprintf(stderr,"reason:%s",lpMsgBuf); - return((void *)-1); - } - return(sh); -} /* end of semget() */ -/*-----------------------------------------------------------------*/ -/* semctl() - semaphore control - * A return value of -1 is bad. Anything else is good. - */ -int -semctl(HANDLE semid, unsigned int maxsem, unsigned int flags, unsigned short *zp) { - if (flags == IPC_RMID) - CloseHandle(semid); - return(0); -} /* end of semctl() */ -/*-----------------------------------------------------------------*/ -/* sysmp() - assign a thread to a specific processor - * This routine returns a -1 on error. - * Otherwise, it returns the number of processors or the processor - * number that this thread is assigned to depending on the function - * requested. - */ -int -sysmp(int op, int arg) { - DWORD process_affinity; /* CPUs that this process is allowed to run on */ - DWORD system_affinity; /* CPUs on this system */ - DWORD mask; /* A mask used to count the processors on the system */ - BOOL status; /* status of the GetProcessAffinityMask system call */ - HANDLE phandle; /* The handle for this process */ - HANDLE thandle; /* The handle for this thread */ - LPVOID lpMsgBuf; - int i; - int cpus; /* The number of CPUs found on this system */ - phandle = GetCurrentProcess(); - thandle = GetCurrentThread(); - status = GetProcessAffinityMask(phandle, &process_affinity,&system_affinity); - if (status == 0) { - FormatMessage( - FORMAT_MESSAGE_ALLOCATE_BUFFER | - FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, - GetLastError(), - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language - (LPTSTR) &lpMsgBuf, - 0, - NULL); - fprintf(stderr,"sysmp: Could not get process affinity mask\n"); - fprintf(stderr,"reason:%s",lpMsgBuf); - } - switch (op) { - case MP_NPROCS: - mask = 0x01; - cpus = 0; - for (i = 0; i < 31; i++) { - if (mask & system_affinity) cpus++; - mask <<= 1; - } - if (cpus == 0) { - fprintf(stderr,"sysmp: MP_NPROCS: system affinity mask has no processors\n"); - cpus = 1; - } - return(cpus); - case MP_MUSTRUN: - mask = 0x01; - cpus = 0; - /* This loop will scan thru the system affinity mask bit by bit - * When the cpu number (cpus) is equal to the argument passed - * in by the calling routine, then the mask should have the - * correct value to use for the SetThreadAffinityMask() function. - */ - for (i = 0; i < 31; i++) { - if (cpus == arg) break; - if (mask & system_affinity) cpus++; - mask <<= 1; - } - status = SetThreadAffinityMask(thandle,mask); - if (status == 0) { - FormatMessage( - FORMAT_MESSAGE_ALLOCATE_BUFFER | - FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, - GetLastError(), - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language - (LPTSTR) &lpMsgBuf, - 0, - NULL); - fprintf(stderr,"sysmp: Could not set process affinity mask 0x%08x\n",mask); - fprintf(stderr,"reason:%s",lpMsgBuf); - return(-1); - } - return(cpus); /* return the processor number that this thread was assigned to */ - default: - fprintf(stderr,"sysmp: unknown operation: %d\n",op); - return(-1); - } /* end of SWITCH statement */ -} /* end of sysmp() */ -/*-----------------------------------------------------------------*/ -/* getpid() - This function will return the current Windows Thread - * ID which is similar to the Process ID in UNIX. - */ -int -getpid(void) { - return((int)GetCurrentThreadId()); -} /* end of getpid() */ -/*-----------------------------------------------------------------*/ -/* random() - This function maps to the Windows rand function. - */ -int -random(void) { - return(rand()); -} /* end of random() */ -/*-----------------------------------------------------------------*/ -/* initstate() - This function maps to windows srand function. - */ -void -initstate(int seed, char *state, int value) { - srand((unsigned int)seed); -} /* end of random() */ - - - - - diff --git a/src/compat/nt_unix_compat.h b/src/compat/nt_unix_compat.h deleted file mode 100644 index 549d98d0..00000000 --- a/src/compat/nt_unix_compat.h +++ /dev/null @@ -1,271 +0,0 @@ -/* - * XDD - a data movement and benchmarking toolkit - * - * Copyright (C) 1992-2013 I/O Performance, Inc. - * Copyright (C) 2009-2013 UT-Battelle, LLC - * - * This is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public - * License version 2, as published by the Free Software - * Foundation. See file COPYING. - * - */ - -/** Map pthread structures to their windows equivalents */ -struct pthread { - HANDLE pthread; -}; -typedef struct pthread pthread_t; - -/** Map pthread_mutex structures to their windows equivalents */ -struct pthread_mutex { - HANDLE mutex; - char name[MAX_PATH]; -}; -typedef struct pthread_mutex pthread_mutex_t; - -/* Map semaphore structure to the windows equivalent */ -struct sembuf { - int sem_op; /* operation */ - unsigned long sem_flg; /* flags */ - int sem_num; /* number */ -}; - -/* This section contains a variety of definintions that map unix-isms to Windows for compatibility */ -typedef unsigned int uint32_t; -typedef unsigned long ulong_t; -typedef int int32_t; -typedef unsigned __int64 uint64_t; -typedef __int64 int64_t; -typedef unsigned short uint16_t; -typedef short int16_t; -typedef unsigned int in_addr_t; /**< An IP number */ -typedef unsigned short in_port_t; /**< A port number */ -typedef SOCKET sd_t; /**< A socket descriptor */ - -/* The following structures do not exist in the Windows header files so they - * have been recreated here for use with their equivalent functions that live - * in nt_unix_compat.c as part of the xdd distribution - */ - -/** UNIX tmstruct for Win32 */ -struct tms { - unsigned long tms_utime; - unsigned long tms_stime; -}; - -/** UNIX timezone struct for Win32 */ -struct timezone { - unsigned int tz; -}; - -/** UNIX Scheduling parameter for Win32 */ -struct sched_param { - unsigned int sched_priority; -}; - -#define SCHED_RR 1 /**< Round Robin Scheduling */ -#define SCHED_FIFO 2 /**< First In First Out Scheduling */ - -#define MCL_CURRENT 1 /**< Lock Current Memory pages */ -#define MCL_FUTURE 2 /**< Lock Future memory pages */ - -#define MP_MUSTRUN 1 /**< Assign this thread to a specific processor */ -#define MP_NPROCS 2 /**< return the number of processors on the system */ - -#define IPC_RMID -3 /**< remove a semaphore */ -#define EIDRM 43 /**< errno value for Identifer Removed */ -#define SETALL 1 /**< used for Semaphore ops */ -#define IPC_CREAT 01000 /**< Used to create Semaphores */ - -/* These are function calls that do not exist in the Windows CLibrary - * so they have been recreated in the nt_unix_compat.c file and their - * prototypes live here - */ - -/** - * Lock all mapped pages of memory into RAM. - * - * @param flag indicate whether to lock current or future pages - * @return 0 on success, -1 on error with corresponding errno - */ -int mlockall(unsigned int flag); - -/** - * Lock pages starting at bp and ending at bp + size into memory - * - * @param bp beginning address to lock - * @param size number of addresses following bp to lock - * @return 0 on success, -1 on error with corresponding errno - */ -int mlock( unsigned char *bp, uint32_t size); - -/** - * Unlock pages starting at bp and ending at bp + size into memory - * - * @param bp beginning address to unlock - * @param size number of addresses following bp to unlock - * @return 0 on success, -1 on error with corresponding errno - */ -int munlock( unsigned char *bp, uint32_t size); - -/** - * @param flag Scheduling algorithm plicies - * @return The maximum priority value, -1 on error with corresponding errno - */ -unsigned long sched_get_priority_max(int flag); - -/** - * Set the scheduling policy for a process - * - * @param arg1 The process to set the scheduler for. 0 for this process. - * @param arg2 The scheduling policy - * @param pp Scheduling parameter struct - * @return 0 on success, -1 on error with corresponding errno - */ -int sched_setscheduler(int arg1, unsigned long arg2, struct sched_param *pp); - -/** - * Reposition the 64-bit file pointer - * - * @param fd file descriptor - * @param offset to seek to relative to the file begin, current position, or end - * @param whence Relative seek begin position (start, current, or end) - * @return The resulting file pointer location, -1 on error with corresponding - * errno - */ -int64_t lseek64(unsigned long fd, int64_t offset, int flag); - -/** - * Transfers all modified in-memory file data to the disk device - * (incl. metadata) - * @param fd File descriptor - * @return 0 on success, -1 on error with corresponding errno - */ -int fsync(int fd); - -/** @return The system page size */ -int getpagesize(void); - -/** - * Store the current time in struct tms - * - * @param tp struct tms to fill out with time data - * @return Non-zero on success, -1 on error with corresponding errno - */ -clock_t times( struct tms *tp); - -/** - * Set timeval struct to the current time - * - * @param tvp timeval struct to store the current time - * @param tzp Deprecated. Supply as 0 or NULL. - */ -void gettimeofday(struct timeval *tvp, struct timezone *tzp); - -/** - * Sleep until seconds have elapsed - * - * @param seconds Number of seconds until process awakens - */ -void sleep(int seconds); - -/** FIXME - No doc provided */ -int sysmp(int op, int arg); - -/** - * Initialize and start thread - * - * @param tp pointer to allocated pthread_t structure - * @param thread_attr pthread_attr_t thread attributes? - * @param thread_function function to invoke with thread (wrong type) - * @param thread_arg data passed into thread function - * @return 0 on success, -1 on error with corresponding errno - */ -int pthread_create(pthread_t *tp, void *thread_attr, void *thread_function, void *thread_arg); - -/** - * Initialize mutex mp. - * @param mp mutex pointer - * @param n FIXME - huh? - * @return 0 on success, -1 on error with corresponding errno - */ -int32_t pthread_mutex_init(pthread_mutex_t *mp, int n); - -/** - * @param mp mutex pointer - * @return 0 on success, -1 on error with corresponding errno - */ -int32_t pthread_mutex_destroy(pthread_mutex_t *mp); - -/** - * Lock mutex mp. Call blocks until mutex is acquired. - * @param mp mutex pointer - */ -void pthread_mutex_lock(pthread_mutex_t *mp); - -/** - * Unlock mutex mp. - * @param mp mutex pointer - */ -void pthread_mutex_unlock(pthread_mutex_t *mp); - -/** - * Performs operation on semaphore - * @param semid semaphore to modify - * @param sp list of operations to be performed - * @param n number of operations - * @return 0 on success, -1 on error with corresponding errno - */ -int semop(HANDLE semid, struct sembuf *sp, int n); - -/** - * @param semid_base The key for the semaphore set - * @param maxsem number of semaphores to retrive/create - * @param flags Semaphore retrieval flags - * @return Requested semaphore set - */ -HANDLE semget(unsigned int semid_base, unsigned int maxsem, unsigned int flags); - -/** - * @param semid Semaphore set to operate on - * @param maxsem - * @param flags - * @param zp - * @return 0 on success, -1 on error with corresponding errno - */ -int semctl(HANDLE semid, unsigned int maxsem, unsigned int flags, unsigned short *zp); - -/** @return the process id */ -int getpid(void); - -/** - * @param c numeric string to convert to long long - * @return Long long value represented in the string argument - */ -int64_t atoll(char *c); - -/** - * Initialization state array for latter calls to random() - * @param seed random seed - * @param state state array - * @param value the size of the state array - */ -void initstate(int seed, char *state, int value); - -/** - * FIXME - No doc provided. - * @return Probably returns a random number in some range. - */ -int xdd_random_int(void); - -/* - * Local variables: - * indent-tabs-mode: t - * default-tab-width: 4 - * c-indent-level: 4 - * c-basic-offset: 4 - * End: - * - * vim: ts=4 sts=4 sw=4 noexpandtab - */ diff --git a/src/compat/xint_aix.h b/src/compat/xint_aix.h deleted file mode 100644 index 8d2278a2..00000000 --- a/src/compat/xint_aix.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * XDD - a data movement and benchmarking toolkit - * - * Copyright (C) 1992-2013 I/O Performance, Inc. - * Copyright (C) 2009-2013 UT-Battelle, LLC - * - * This is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public - * License version 2, as published by the Free Software - * Foundation. See file COPYING. - * - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include /* UNIX Only */ -#include -#include -#include -#include -#include -#include -#include -#include /* needed for multiple processes */ -#include -#include -#include -#include -#include -#include -#include -/* for the global clock stuff */ -#include -#include -#include -#include -#include -#if (SNFS) -#include -#endif -#include "nclk.h" /* nclk_t, prototype compatibility */ -#include "misc.h" - -#define MP_MUSTRUN 1 /* Assign this thread to a specific processor */ -#define MP_NPROCS 2 /* return the number of processors on the system */ -typedef int sd_t; /* A socket descriptor */ - -#ifndef CLK_TCK -#define CLK_TCK sysconf(_SC_CLK_TCK) -#endif - -#define DFL_FL_ADDR INADDR_ANY /* Any address */ /* server only */ -#define closesocket(sd) close(sd) - -#include "restart.h" - -#include "ptds.h" - -int32_t xdd_target_open_for_aix(ptds_t *p); diff --git a/src/compat/xint_barrier.h b/src/compat/xint_barrier.h deleted file mode 100644 index d5c4a20f..00000000 --- a/src/compat/xint_barrier.h +++ /dev/null @@ -1,93 +0,0 @@ -/* - * XDD - a data movement and benchmarking toolkit - * - * Copyright (C) 1992-2013 I/O Performance, Inc. - * Copyright (C) 1999-2006 Brian Paul - * Copyright (C) 2008 Tungsten Graphics, Inc., Cedar Park, Texas. - * Copyright (C) 2009-2013 UT-Battelle, LLC - * - * This is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public - * License version 2, as published by the Free Software - * Foundation. See file COPYING. - * - */ -/* Pthread-based barrier adapted from Gallium */ -#ifndef XINT_BARRIER_H -#define XINT_BARRIER_H - -#include -#include -#include - -#define HAVE_XINT_BARRIER - -typedef struct xint_barrier { - size_t count; - size_t waiters; - pthread_mutex_t mutex; - pthread_cond_t cond; -} xint_barrier_t; - -inline static int xint_barrier_init(xint_barrier_t *barrier, size_t count) -{ - int rc = 0; - barrier->count = count; - barrier->waiters = 0; - rc = pthread_mutex_init(&barrier->mutex, NULL); - assert(0 == rc); - rc = pthread_cond_init(&barrier->cond, NULL); - assert(0 == rc); - return rc; -} - -inline static int xint_barrier_destroy(xint_barrier_t *barrier) -{ - //int rc = 0; - - // Have to remove the checking because the qthreads are sitting in a mutex - // even during a successful completion - //assert(barrier->waiters == 0); - pthread_cond_destroy(&barrier->cond); - //if (0 != rc) -// fprintf(stderr, -// "Error: Destroying barrier condvar count: %zd reason: %s\n", -// barrier->count, strerror(rc)); - //assert(0 == rc); - pthread_mutex_destroy(&barrier->mutex); -// if (0 != rc) -// fprintf(stderr, -// "Error: Destroying barrier mutex count: %zd reason: %s\n", -// barrier->count, strerror(rc)); - //assert(0 == rc); - return 0; -} - -inline static int xint_barrier_wait(xint_barrier_t *barrier) -{ - assert(barrier->waiters < barrier->count); - pthread_mutex_lock(&barrier->mutex); - barrier->waiters++; - - if (barrier->waiters == barrier->count) { - barrier->waiters = 0; - pthread_cond_broadcast(&barrier->cond); - } else { - pthread_cond_wait(&barrier->cond, &barrier->mutex); - } - - pthread_mutex_unlock(&barrier->mutex); - return 0; -} - -#endif -/* - * Local variables: - * indent-tabs-mode: t - * default-tab-width: 4 - * c-indent-level: 4 - * c-basic-offset: 4 - * End: - * - * vim: ts=4 sts=4 sw=4 noexpandtab - */ diff --git a/src/compat/xint_darwin.h b/src/compat/xint_darwin.h deleted file mode 100644 index 1a883790..00000000 --- a/src/compat/xint_darwin.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - * XDD - a data movement and benchmarking toolkit - * - * Copyright (C) 1992-2013 I/O Performance, Inc. - * Copyright (C) 2009-2013 UT-Battelle, LLC - * - * This is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public - * License version 2, as published by the Free Software - * Foundation. See file COPYING. - * - */ -#ifndef XDD_DARWIN_H -#define XDD_DARWIN_H - -#include "config.h" - -/* Standard C headers */ -#include -#include -#include -#include -#include -#include -#include -#include - -/* POSIX headers */ -#include -#include /* UNIX Only */ -#include -#include -#include -#include -#include -#include -#include /* needed for multiple processes */ -#include -#include -#include -#include -/* for the global clock stuff */ -#include -#include -#include -#include -#include - -/* Platform headers */ -#include -#if (SNFS) -#include -#endif - -/* XDD internal compatibility headers for this platform */ -#include "xint_barrier.h" -#include "xint_nclk.h" /* nclk_t, prototype compatibility */ -#include "xint_misc.h" - -#define MP_MUSTRUN 1 /* ASsign this thread to a specific processor */ -#define MP_NPROCS 2 /* return the number of processors on the system */ -typedef int sd_t; /* A socket descriptor */ -#ifndef CLK_TCK -#define CLK_TCK CLOCKS_PER_SEC -#endif - -/* ------------------------------------------------------------------ - * Constants - * ------------------------------------------------------------------ */ -#define DFL_FL_ADDR INADDR_ANY /* Any address */ /* server only */ -#define closesocket(sd) close(sd) -//static bool sockets_init(void); -#include "xint_plan.h" - -#endif diff --git a/src/compat/xint_freebsd.h b/src/compat/xint_freebsd.h deleted file mode 100644 index ba31cd39..00000000 --- a/src/compat/xint_freebsd.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * XDD - a data movement and benchmarking toolkit - * - * Copyright (C) 1992-2013 I/O Performance, Inc. - * Copyright (C) 2009-2013 UT-Battelle, LLC - * - * This is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public - * License version 2, as published by the Free Software - * Foundation. See file COPYING. - * - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include /* UNIX Only */ -#include -#include -#include -#include -#include -#include -#include /* needed for multiple processes */ -#include -#include -#include -#include -#include -#include -#include -/* for the global clock stuff */ -#include -#include -#include -#include -#include -#if (SNFS) -#include -#endif -#include "nclk.h" /* nclk_t, prototype compatibility */ -#include "misc.h" - -#define MP_MUSTRUN 1 /* ASsign this thread to a specific processor */ -#define MP_NPROCS 2 /* return the number of processors on the system */ -typedef int sd_t; /* A socket descriptor */ -#ifndef CLK_TCK -#define CLK_TCK CLOCKS_PER_SEC -#endif - -/* ------------------------------------------------------------------ - * Constants - * ------------------------------------------------------------------ */ -#define DFL_FL_ADDR INADDR_ANY /* Any address */ /* server only */ -#define closesocket(sd) close(sd) -static bool sockets_init(void); -#include "ptds.h" - diff --git a/src/compat/xint_linux.h b/src/compat/xint_linux.h index 4977f491..0e9265f8 100644 --- a/src/compat/xint_linux.h +++ b/src/compat/xint_linux.h @@ -23,7 +23,7 @@ /* POSIX headers */ #include #include -#include +#include #include #include #include diff --git a/src/compat/xint_solaris.h b/src/compat/xint_solaris.h deleted file mode 100644 index eadb04ff..00000000 --- a/src/compat/xint_solaris.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - * XDD - a data movement and benchmarking toolkit - * - * Copyright (C) 1992-2013 I/O Performance, Inc. - * Copyright (C) 2009-2013 UT-Battelle, LLC - * - * This is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public - * License version 2, as published by the Free Software - * Foundation. See file COPYING. - * - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include /* UNIX Only */ -#include -#include -#include -#include -#include -#include -#include -#include /* needed for multiple processes */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -/* for the global clock stuff */ -#include -#include -#include -#include -#include -#if (SNFS) -#include -#endif -#include "nclk.h" /* nclk_t, prototype compatibility */ -#include "misc.h" - -#define MP_MUSTRUN 1 /* ASsign this thread to a specific processor */ -#define MP_NPROCS 2 /* return the number of processors on the system */ -typedef int sd_t; /* A socket descriptor */ -#ifndef CLK_TCK -#define CLK_TCK CLOCKS_PER_SEC -#endif -#undef RAND_MAX -#define RAND_MAX ((1024*1024*1024*2)-1) - -/* ------------------------------------------------------------------ - * Constants - * ------------------------------------------------------------------ */ -#define DFL_FL_ADDR INADDR_ANY /* Any address */ /* server only */ -#define closesocket(sd) close(sd) -static bool sockets_init(void); -#include "ptds.h" - -int32_t xdd_target_open_for_solaris(ptds_t *p); diff --git a/src/compat/xint_win32.h b/src/compat/xint_win32.h deleted file mode 100644 index 1c77b554..00000000 --- a/src/compat/xint_win32.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * XDD - a data movement and benchmarking toolkit - * - * Copyright (C) 1992-2013 I/O Performance, Inc. - * Copyright (C) 2009-2013 UT-Battelle, LLC - * - * This is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public - * License version 2, as published by the Free Software - * Foundation. See file COPYING. - * - */ -#define _CRT_SECURE_NO_WARNINGS 1 - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "mmsystem.h" -#include -#include - -// XDD include files -#include "nclk.h" -#include "misc.h" -// For Windows, ptds needs to be included here. -#include "ptds.h" - -#define DFL_FL_ADDR 0x0a000001 /* 10.0.0.1 */ - - -// The remainder is OS-specific -/* ------------------------------------------------------------------ - * Macros - * ------------------------------------------------------------------ */ - -/* - * We use this for the first argument to select() to avoid having it - * try to process all possible socket descriptors. Windows ignores - * the first argument to select(), so we could use anything. But we - * use the value elsewhere so we give it its maximal value. - */ -#define getdtablehi() FD_SETSIZE /* Number of sockets in a fd_set */ - -/* ------------------------------------------------------------------ - * Function Prototype Definition specific to Windows - * ------------------------------------------------------------------ */ -int32_t ts_serializer_init(HANDLE *mp, char *mutex_name); - - diff --git a/src/fs/sg.c b/src/fs/sg.c index 49d82546..3f67bba5 100644 --- a/src/fs/sg.c +++ b/src/fs/sg.c @@ -17,7 +17,6 @@ * This file contains the subroutines necessary to support SCSI Generic I/O under LINUX. */ #include "xint.h" -#if LINUX #include "sg.h" // #define SG_DEBUG @@ -29,12 +28,12 @@ // SCSI Generic Support Routines //****************************************************************************** /*----------------------------------------------------------------------------*/ -/* xdd_get_sgiop() - return a pointer to the SCSI Generic I/O (SGIO) Data Structure +/* xdd_get_sgiop() - return a pointer to the SCSI Generic I/O (SGIO) Data Structure * for the specified target */ xdd_sgio_t * xdd_get_sgiop(worker_data_t *wdp) { - + if (wdp->wd_sgiop == 0) { // Since there is no existing SGIO structure, allocate a new one for this target, initialize it, and move on... wdp->wd_sgiop = malloc(sizeof(struct xdd_sgio)); if (wdp->wd_sgiop == NULL) { @@ -48,17 +47,17 @@ xdd_get_sgiop(worker_data_t *wdp) { /*----------------------------------------------------------------------------*/ /* xdd_sg_io() - Perform a "read" or "write" operation on the specified target - * Will return a -1 if the command fails, 0 for EOF, or the number of - * bytes transferred if everything works. + * Will return a -1 if the command fails, 0 for EOF, or the number of + * bytes transferred if everything works. * This ruotine takes two parameters: * - Pointer to the Data Struct of this target - * - A character that is either 'r' or 'w' to indicate a 'read' or 'write' + * - A character that is either 'r' or 'w' to indicate a 'read' or 'write' * operation respectively. */ -int32_t +int32_t xdd_sg_io(worker_data_t *wdp, char rw) { target_data_t *tdp; // Pointer to the Target Data for this worker - unsigned char Cmd[16]; // This is defined as a 16-byte CDB + unsigned char Cmd[16]; // This is defined as a 16-byte CDB sg_io_hdr_t io_hdr; int status; // This is the status from the SG driver int io_status; // This is the status from the device itself @@ -72,9 +71,9 @@ xdd_sg_io(worker_data_t *wdp, char rw) { sgiop->sg_blocksize = 512; // This is because sg uses a sector size block size sgiop->sg_from_block = (wdp->wd_task.task_byte_offset / sgiop->sg_blocksize); sgiop->sg_blocks = wdp->wd_task.task_xfer_size / sgiop->sg_blocksize; - + // Init the CDB - if (rw == 'w') + if (rw == 'w') Cmd[0] = WRITE_16; else Cmd[0] = READ_16; // Assume Read Cmd[1] = 0; @@ -94,7 +93,7 @@ xdd_sg_io(worker_data_t *wdp, char rw) { Cmd[13] = (unsigned char)(sgiop->sg_blocks & 0xff); // MMC-4, and group number - NA Cmd[14] = 0; - // Control + // Control Cmd[15] = 0; // Init the IO Header that is used by the SG driver @@ -102,7 +101,7 @@ xdd_sg_io(worker_data_t *wdp, char rw) { io_hdr.interface_id = 'S'; io_hdr.cmd_len = sizeof(Cmd); io_hdr.cmdp = Cmd; - if (rw == 'w') + if (rw == 'w') io_hdr.dxfer_direction = SG_DXFER_TO_DEV; // Write op else io_hdr.dxfer_direction = SG_DXFER_FROM_DEV; // Read op io_hdr.dxfer_len = sgiop->sg_blocksize * sgiop->sg_blocks; @@ -152,7 +151,7 @@ xdd_sg_io(worker_data_t *wdp, char rw) { tdp->td_target_full_pathname, status, (long long)wdp->wd_task.task_op_number, - (unsigned long long)sgiop->sg_from_block, + (unsigned long long)sgiop->sg_from_block, sgiop->sg_blocks); fflush(xgp->errout); @@ -168,11 +167,11 @@ xdd_sg_io(worker_data_t *wdp, char rw) { tdp->td_target_full_pathname, status, (long long)wdp->wd_task.task_op_number, - (unsigned long long)sgiop->sg_from_block, + (unsigned long long)sgiop->sg_from_block, sgiop->sg_blocks); break; default: - status = xdd_sg_read_capacity(wdp); + status = xdd_sg_read_capacity(wdp); if (status == SUCCESS) { // Check for an out-of-bounds condition last_sector = sgiop->sg_from_block + sgiop->sg_blocks - 1; if ( last_sector > sgiop->sg_num_sectors) { // LBA out of range error most likely @@ -181,7 +180,7 @@ xdd_sg_io(worker_data_t *wdp, char rw) { tdp->td_target_number, wdp->wd_worker_number, (long long)wdp->wd_task.task_op_number, - (unsigned long long)sgiop->sg_from_block, + (unsigned long long)sgiop->sg_from_block, sgiop->sg_blocks); } } // Done checking for out-of-range error @@ -193,10 +192,10 @@ xdd_sg_io(worker_data_t *wdp, char rw) { tdp->td_target_full_pathname, status, (long long)wdp->wd_task.task_op_number, - (unsigned long long)sgiop->sg_from_block, + (unsigned long long)sgiop->sg_from_block, sgiop->sg_blocks); return(0); - + } // End of SWITCH stmnt } // End of looking at SG driver errors @@ -204,14 +203,14 @@ xdd_sg_io(worker_data_t *wdp, char rw) { // No error - return the amount of data that was transferred return(sgiop->sg_blocksize*sgiop->sg_blocks); -} // End of xdd_sg_io() +} // End of xdd_sg_io() /*----------------------------------------------------------------------------*/ /* xdd_sg_read_capacity() - Issue a "Read Capacity" SCSI command to the target * and store the results in the associated Data Struct * Will return SUCCESS or FAILED depending on the outcome of the command. */ -int32_t +int32_t xdd_sg_read_capacity(worker_data_t *wdp) { target_data_t *tdp; // Pointer to the Target Data for this worker int status; @@ -234,7 +233,7 @@ xdd_sg_read_capacity(worker_data_t *wdp) { rcCmd[7] = 0; rcCmd[8] = 0; rcCmd[9] = 0; - + memset(&io_hdr, 0, sizeof(sg_io_hdr_t)); io_hdr.interface_id = 'S'; io_hdr.cmd_len = sizeof(rcCmd); @@ -261,10 +260,10 @@ xdd_sg_read_capacity(worker_data_t *wdp) { } status = sg_err_category3(&io_hdr); if (SG_ERR_CAT_MEDIA_CHANGED == status) - return(FAILED); + return(FAILED); else if (SG_ERR_CAT_CLEAN != status) { fprintf(stderr,"read capacity error"); - return(FAILED); + return(FAILED); } // Retrieve the number of sectors and the sector size from the buffer @@ -273,7 +272,7 @@ xdd_sg_read_capacity(worker_data_t *wdp) { return(SUCCESS); -} // End of xdd_sg_read_capacity() +} // End of xdd_sg_read_capacity() /*----------------------------------------------------------------------------*/ /* xdd_sg_set_reserved_size() - issued after open - called from initialization.c @@ -288,10 +287,10 @@ xdd_sg_set_reserved_size(target_data_t *tdp, int fd) { status = ioctl(fd, SG_SET_RESERVED_SIZE, &reserved_size); if (status < 0) { fprintf(xgp->errout,"%s: xdd_sg_set_reserved_size: SG_SET_RESERVED_SIZE error - request for %d bytes denied", - xgp->progname, + xgp->progname, (tdp->td_block_size*tdp->td_reqsize)); } -} // End of xdd_sg_set_reserved_size() +} // End of xdd_sg_set_reserved_size() /*----------------------------------------------------------------------------*/ /* xdd_sg_get_version() - issued after open - get the current version of SG @@ -311,9 +310,9 @@ xdd_sg_get_version(target_data_t *tdp, int fd) { } // End of xdd_sg_get_version() /*----------------------------------------------------------------------------*/ -/* sg_print_opcode() +/* sg_print_opcode() */ -static void +static void print_opcode(int opcode, FILE *outp) { const char **table = commands[ group(opcode) ]; @@ -334,9 +333,9 @@ print_opcode(int opcode, FILE *outp) { } // End of sg_print_opcode() /*----------------------------------------------------------------------------*/ -/* sg_print_command() +/* sg_print_command() */ -void +void sg_print_command (const unsigned char * command, FILE *outp) { int i,s; print_opcode(command[0], outp); @@ -346,9 +345,9 @@ sg_print_command (const unsigned char * command, FILE *outp) { } // End of sg_print_command() /*----------------------------------------------------------------------------*/ -/* sg_print_status() +/* sg_print_status() */ -void +void sg_print_status (int masked_status, FILE *outp) { /* status = (status >> 1) & 0xf; */ /* already done */ fprintf(outp, "%s ",statuses[masked_status]); @@ -357,10 +356,10 @@ sg_print_status (int masked_status, FILE *outp) { /*----------------------------------------------------------------------------*/ /* sg_print_sense() - Print sense information */ -void -sg_print_sense(const char * leadin, +void +sg_print_sense(const char * leadin, const unsigned char * sense_buffer, - int sb_len, + int sb_len, FILE *outp) { int i, s; @@ -439,12 +438,12 @@ sg_print_sense(const char * leadin, if (leadin) fprintf(outp, "%s: ", leadin); if (sense_buffer[0] < 15) - fprintf(outp, + fprintf(outp, "old sense: key %s\n", snstext[sense_buffer[0] & 0x0f]); else fprintf(outp, "sns = %2x %2x\n", sense_buffer[0], sense_buffer[2]); - fprintf(outp, "Non-extended sense class %d code 0x%0x ", + fprintf(outp, "Non-extended sense class %d code 0x%0x ", sense_class, code); s = 4; } @@ -463,7 +462,7 @@ sg_print_sense(const char * leadin, /*----------------------------------------------------------------------------*/ /* sg_print_host_status() */ -void +void sg_print_host_status(int host_status, FILE *outp) { static int maxcode=0; int i; @@ -478,12 +477,12 @@ sg_print_host_status(int host_status, FILE *outp) return; } fprintf(outp, "(%s) ",hostbyte_table[host_status]); -} // End of sg_print_host_status() +} // End of sg_print_host_status() /*----------------------------------------------------------------------------*/ /* sg_print_driver_status() */ -void +void sg_print_driver_status(int driver_status, FILE *outp) { static int driver_max =0 , suggest_max=0; @@ -501,31 +500,31 @@ sg_print_driver_status(int driver_status, FILE *outp) fprintf(outp, " (%s,%s) ", dr < driver_max ? driverbyte_table[dr]:"invalid", su < suggest_max ? driversuggest_table[su]:"invalid"); -} // End of sg_print_driver_status() +} // End of sg_print_driver_status() /*----------------------------------------------------------------------------*/ -/* sg_chk_n_print3() +/* sg_chk_n_print3() */ -int -sg_chk_n_print3(const char *leadin, - struct sg_io_hdr *hp, - FILE *outp) +int +sg_chk_n_print3(const char *leadin, + struct sg_io_hdr *hp, + FILE *outp) { return sg_chk_n_print(leadin, hp->masked_status, hp->host_status, hp->driver_status, hp->sbp, hp->sb_len_wr, outp); -} // End of sg_chk_n_print3() +} // End of sg_chk_n_print3() /*----------------------------------------------------------------------------*/ -/* sg_chk_n_print() +/* sg_chk_n_print() */ -int -sg_chk_n_print(const char * leadin, +int +sg_chk_n_print(const char * leadin, int masked_status, - int host_status, + int host_status, int driver_status, - const unsigned char * sense_buffer, + const unsigned char * sense_buffer, int sb_len, - FILE *outp) + FILE *outp) { int done_leadin = 0; @@ -570,27 +569,27 @@ sg_chk_n_print(const char * leadin, sg_print_sense(0, sense_buffer, sb_len, outp); } return 0; -} // End of sg_chk_n_print() +} // End of sg_chk_n_print() /*----------------------------------------------------------------------------*/ -/* sg_err_category3() +/* sg_err_category3() */ -int +int sg_err_category3(struct sg_io_hdr * hp) { - return sg_err_category(hp->masked_status, + return sg_err_category(hp->masked_status, hp->host_status, - hp->driver_status, - hp->sbp, + hp->driver_status, + hp->sbp, hp->sb_len_wr); -} // End of sg_err_category3() +} // End of sg_err_category3() /*----------------------------------------------------------------------------*/ -/* sg_err_category() +/* sg_err_category() */ -int +int sg_err_category(int masked_status, int host_status, - int driver_status, + int driver_status, const unsigned char * sense_buffer, int sb_len) { @@ -625,6 +624,4 @@ sg_err_category(int masked_status, return SG_ERR_CAT_TIMEOUT; } return SG_ERR_CAT_OTHER; -} // End of sg_err_category() -#endif - +} // End of sg_err_category() diff --git a/src/net/end_to_end_init.c b/src/net/end_to_end_init.c index dd605841..6f42bd06 100644 --- a/src/net/end_to_end_init.c +++ b/src/net/end_to_end_init.c @@ -35,7 +35,7 @@ xdd_e2e_target_init(target_data_t *tdp) { xint_e2e_xni_init(tdp); } else { - + // Init the sockets - This is actually just for Windows that requires some additional initting status = xdd_sockets_init(); if (status == -1) { @@ -43,7 +43,7 @@ xdd_e2e_target_init(target_data_t *tdp) { return(-1); } } - + // Restart processing if necessary if ((tdp->td_target_options & TO_RESTART_ENABLE) && (tdp->td_restartp)) { // Check to see if restart was requested // Set the last_committed_byte_offset to 0 @@ -92,7 +92,7 @@ xdd_e2e_worker_init(worker_data_t *wdp) { xgp->progname, wdp->wd_e2ep->e2e_dest_hostname); return(-1); } - + // Convert to host byte order wdp->wd_e2ep->e2e_dest_addr = ntohl(addr); } @@ -111,11 +111,11 @@ xdd_e2e_worker_init(worker_data_t *wdp) { } // xdd_e2e_worker_init() /*----------------------------------------------------------------------*/ -/* xdd_e2e_src_init() - init the source side - * This routine is called from the xdd io thread before all the action +/* xdd_e2e_src_init() - init the source side + * This routine is called from the xdd io thread before all the action * starts. When calling this routine, it is because this thread is on the * "source" side of an End-to-End test. Hence, this routine needs - * to set up a socket on the appropriate port + * to set up a socket on the appropriate port * * Return values: 0 is good, -1 is bad * @@ -124,12 +124,12 @@ int32_t xdd_e2e_src_init(worker_data_t *wdp) { target_data_t *tdp; xint_e2e_t *e2ep; // Pointer to the E2E data struct - int status; // status of various function calls + int status; // status of various function calls tdp = wdp->wd_tdp; e2ep = wdp->wd_e2ep; - + // Check to make sure that the source target is actually *reading* the data from a file or device if (tdp->td_rwratio < 1.0) { // Something is wrong - the source file/device is not 100% read fprintf(xgp->errout,"%s: xdd_e2e_src_init: Target %d Worker Thread %d: Error - E2E source file '%s' is not being *read*: rwratio=%5.2f is not valid\n", @@ -154,7 +154,7 @@ xdd_e2e_src_init(worker_data_t *wdp) { wdp->wd_e2ep->e2e_sd = open(wdp->wd_e2ep->e2e_dest_hostname, O_CREAT | O_WRONLY, 00666); } - + status = wdp->wd_e2ep->e2e_sd; if (status == -1) { xdd_e2e_err(wdp,"xdd_e2e_src_init","could not open file for e2e islocal\n"); @@ -168,8 +168,8 @@ xdd_e2e_src_init(worker_data_t *wdp) { } } } - - // Init the relevant variables + + // Init the relevant variables e2ep->e2e_msg_sent = 0; e2ep->e2e_msg_sequence_number = 0; e2ep->e2e_header_size = (int)(sizeof(xdd_e2e_header_t)); @@ -183,8 +183,8 @@ xdd_e2e_src_init(worker_data_t *wdp) { // | |<-Header->| E2E data buffer | // +-----*----------*-----------------------------------------------------+ // ^ ^ - // ^ +-e2e_datap - // +-e2e_hdrp + // ^ +-e2e_datap + // +-e2e_hdrp // e2ep->e2e_hdrp->e2eh_worker_thread_number = 0; e2ep->e2e_hdrp->e2eh_sequence_number = 0; @@ -212,11 +212,11 @@ xdd_e2e_setup_src_socket(worker_data_t *wdp) { int type; static const int connect_try_limit = 4; int i; - - // The socket type is SOCK_STREAM because this is a TCP connection + + // The socket type is SOCK_STREAM because this is a TCP connection type = SOCK_STREAM; - // Create the socket + // Create the socket wdp->wd_e2ep->e2e_sd = socket(AF_INET, type, IPPROTO_TCP); if (wdp->wd_e2ep->e2e_sd < 0) { xdd_e2e_err(wdp,"xdd_e2e_setup_src_socket","ERROR: error openning socket\n"); @@ -246,13 +246,13 @@ xdd_e2e_setup_src_socket(worker_data_t *wdp) { (int)req.tv_sec, status); nanosleep(&req, (struct timespec *)NULL); } - + status = connect(wdp->wd_e2ep->e2e_sd, (struct sockaddr *) &wdp->wd_e2ep->e2e_sname, sizeof(wdp->wd_e2ep->e2e_sname)); i++; } - + if (0 != status) { xdd_e2e_err(wdp,"xdd_e2e_setup_src_socket","error connecting to socket for E2E destination\n"); return(-1); @@ -263,9 +263,9 @@ xdd_e2e_setup_src_socket(worker_data_t *wdp) { } /* end of xdd_e2e_setup_src_socket() */ /*----------------------------------------------------------------------*/ -/* xdd_e2e_dest_init() - init the destination side +/* xdd_e2e_dest_init() - init the destination side * This routine is called by a Worker Thread on the "destination" side of an - * end_to_end operation and is passed a pointer to the Data Struct of the + * end_to_end operation and is passed a pointer to the Data Struct of the * requesting Worker Thread. * * Return values: 0 is good, -1 is bad @@ -274,7 +274,7 @@ xdd_e2e_setup_src_socket(worker_data_t *wdp) { int32_t xdd_e2e_dest_init(worker_data_t *wdp) { target_data_t *tdp; - int status; // status of various function calls + int status; // status of various function calls tdp = wdp->wd_tdp; @@ -288,7 +288,7 @@ xdd_e2e_dest_init(worker_data_t *wdp) { tdp->td_rwratio); return(-1); } - + /* Only setup sockets if not using XNI */ xdd_plan_t *planp = tdp->td_planp; if (!(PLAN_ENABLE_XNI & planp->plan_options)) { @@ -299,7 +299,7 @@ xdd_e2e_dest_init(worker_data_t *wdp) { } // Set up the descriptor table for the select() call - // This section is used when we are using TCP + // This section is used when we are using TCP /* clear out the csd table */ for (wdp->wd_e2ep->e2e_current_csd = 0; wdp->wd_e2ep->e2e_current_csd < FD_SETSIZE; wdp->wd_e2ep->e2e_current_csd++) wdp->wd_e2ep->e2e_csd[wdp->wd_e2ep->e2e_current_csd] = 0; @@ -316,7 +316,7 @@ xdd_e2e_dest_init(worker_data_t *wdp) { /* Find out how many sockets are in each set */ wdp->wd_e2ep->e2e_nd = FD_SETSIZE; } - + // Initialize the message counter and sequencer to 0 wdp->wd_e2ep->e2e_msg_recv = 0; wdp->wd_e2ep->e2e_msg_sequence_number = 0; @@ -340,10 +340,10 @@ xdd_e2e_setup_dest_socket(worker_data_t *wdp) { char msg[256]; - // Set the "type" of socket being requested: for TCP, type=SOCK_STREAM + // Set the "type" of socket being requested: for TCP, type=SOCK_STREAM type = SOCK_STREAM; - // Create the socket + // Create the socket wdp->wd_e2ep->e2e_sd = socket(AF_INET, type, IPPROTO_TCP); if (wdp->wd_e2ep->e2e_sd < 0) { xdd_e2e_err(wdp,"xdd_e2e_setup_dest_socket","ERROR: error openning socket\n"); @@ -360,7 +360,7 @@ xdd_e2e_setup_dest_socket(worker_data_t *wdp) { wdp->wd_e2ep->e2e_snamelen = sizeof(wdp->wd_e2ep->e2e_sname); if (bind(wdp->wd_e2ep->e2e_sd, (struct sockaddr *) &wdp->wd_e2ep->e2e_sname, wdp->wd_e2ep->e2e_snamelen)) { sprintf(msg,"Error binding name to socket - addr=0x%08x, port=0x%08x, specified as %d \n", - wdp->wd_e2ep->e2e_sname.sin_addr.s_addr, + wdp->wd_e2ep->e2e_sname.sin_addr.s_addr, wdp->wd_e2ep->e2e_sname.sin_port, wdp->wd_e2ep->e2e_dest_port); xdd_e2e_err(wdp,"xdd_e2e_setup_dest_socket",msg); @@ -385,18 +385,14 @@ xdd_e2e_setup_dest_socket(worker_data_t *wdp) { * xdd_e2e_set_socket_opts() - set the options for specified socket. * */ -void +void xdd_e2e_set_socket_opts(worker_data_t *wdp, int skt) { target_data_t *tdp; int status; int level = SOL_SOCKET; xdd_plan_t* planp = wdp->wd_tdp->td_planp; - -#if WIN32 - char optionvalue; -#else + int optionvalue; -#endif tdp = wdp->wd_tdp; /* Create the socket and set some options */ @@ -407,40 +403,40 @@ xdd_e2e_set_socket_opts(worker_data_t *wdp, int skt) { } status = setsockopt(skt,level,SO_SNDBUF,(char *)&planp->e2e_TCP_Win,sizeof(planp->e2e_TCP_Win)); if (status < 0) { - fprintf(xgp->errout,"%s: xdd_e2e_set_socket_opts: Target %d Worker Thread %d: WARNING: on setsockopt SO_SNDBUF: status %d: %s\n", - xgp->progname, - tdp->td_target_number, - wdp->wd_worker_number, - status, + fprintf(xgp->errout,"%s: xdd_e2e_set_socket_opts: Target %d Worker Thread %d: WARNING: on setsockopt SO_SNDBUF: status %d: %s\n", + xgp->progname, + tdp->td_target_number, + wdp->wd_worker_number, + status, strerror(errno)); } status = setsockopt(skt,level,SO_RCVBUF,(char *)&planp->e2e_TCP_Win,sizeof(planp->e2e_TCP_Win)); if (status < 0) { - fprintf(xgp->errout,"%s: xdd_e2e_set_socket_opts: Target %d Worker Thread %d: WARNING: on setsockopt SO_RCVBUF: status %d: %s\n", - xgp->progname, - tdp->td_target_number, - wdp->wd_worker_number, - status, + fprintf(xgp->errout,"%s: xdd_e2e_set_socket_opts: Target %d Worker Thread %d: WARNING: on setsockopt SO_RCVBUF: status %d: %s\n", + xgp->progname, + tdp->td_target_number, + wdp->wd_worker_number, + status, strerror(errno)); } status = setsockopt(skt,level,SO_REUSEADDR,(char *)&planp->e2e_TCP_Win,sizeof(planp->e2e_TCP_Win)); if (status < 0) { - fprintf(xgp->errout,"%s: xdd_e2e_set_socket_opts: Target %d Worker Thread %d: WARNING: on setsockopt SO_REUSEPORT: status %d: %s\n", - xgp->progname, - tdp->td_target_number, - wdp->wd_worker_number, - status, + fprintf(xgp->errout,"%s: xdd_e2e_set_socket_opts: Target %d Worker Thread %d: WARNING: on setsockopt SO_REUSEPORT: status %d: %s\n", + xgp->progname, + tdp->td_target_number, + wdp->wd_worker_number, + status, strerror(errno)); } } // End of xdd_e2e_set_socket_opts() /*----------------------------------------------------------------------*/ /* - * xdd_e2e_prt_socket_opts() - print the currnet options for specified + * xdd_e2e_prt_socket_opts() - print the currnet options for specified * socket. * */ -void +void xdd_e2e_prt_socket_opts(int skt) { int level = SOL_SOCKET; int sockbuf_sizs; @@ -468,21 +464,6 @@ xdd_e2e_prt_socket_opts(int skt) { */ void xdd_e2e_err(worker_data_t *wdp, char const *whence, char const *fmt, ...) { -#ifdef WIN32 - LPVOID lpMsgBuf; - fprintf(xgp->errout, "last error was %d\n", WSAGetLastError()); - FormatMessage( - FORMAT_MESSAGE_ALLOCATE_BUFFER | - FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, - WSAGetLastError(), - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language - (LPTSTR) &lpMsgBuf, - 0, - NULL); - fprintf(xgp->errout,"Reason: %s",lpMsgBuf); -#endif /* WIN32 */ fprintf(xgp->errout,"\n%s: %s: Target %d Worker Thread %d: ", xgp->progname, whence, @@ -507,51 +488,17 @@ xdd_e2e_err(worker_data_t *wdp, char const *whence, char const *fmt, ...) { * present, and it worked, so I kept it that way. */ int32_t xdd_sockets_init(void) { -#ifdef WIN32 - WSADATA wsaData; /* Data structure used by WSAStartup */ - int wsastatus; /* status returned by WSAStartup */ - char *reason; - wsastatus = WSAStartup(MAKEWORD(2, 2), &wsaData); - if (wsastatus != 0) { /* Error in starting the network */ - switch (wsastatus) { - case WSASYSNOTREADY: - reason = "Network is down"; - break; - case WSAVERNOTSUPPORTED: - reason = "Request version of sockets <2.2> is not supported"; - break; - case WSAEINPROGRESS: - reason = "Another Windows Sockets operation is in progress"; - break; - case WSAEPROCLIM: - reason = "The limit of the number of sockets tasks has been exceeded"; - break; - case WSAEFAULT: - reason = "Program error: pointer to wsaData is not valid"; - break; - default: - reason = "Unknown error code"; - break; - }; - fprintf(xgp->errout,"%s: Error initializing network connection\nReason: %s\n", - xgp->progname, reason); - fflush(xgp->errout); - WSACleanup(); - return(-1); - } -#endif - return(0); } /* end of xdd_sockets_init() */ /*----------------------------------------------------------------------------*/ -/* xdd_get_e2ep() - return a pointer to the xdd_e2e Data Structure +/* xdd_get_e2ep() - return a pointer to the xdd_e2e Data Structure */ xint_e2e_t * xdd_get_e2ep(void) { xint_e2e_t *e2ep; - + e2ep = malloc(sizeof(xint_e2e_t)); if (e2ep == NULL) { fprintf(xgp->errout,"%s: ERROR: Cannot allocate %d bytes of memory for E2E data structure \n", diff --git a/src/net/read_after_write.c b/src/net/read_after_write.c index 5ab4195d..625d2a8e 100644 --- a/src/net/read_after_write.c +++ b/src/net/read_after_write.c @@ -34,26 +34,9 @@ void xdd_raw_err(char const *fmt, ...) { #ifdef ndef -#ifdef WIN32 - LPVOID lpMsgBuf; -#endif fputs(fmt,xgp->errout); perror("reason"); return; -#ifdef WIN32 /* Windows environment, actually */ - fprintf(xgp->errout, "last error was %d\n", WSAGetLastError()); - FormatMessage( - FORMAT_MESSAGE_ALLOCATE_BUFFER | - FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, - WSAGetLastError(), - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language - (LPTSTR) &lpMsgBuf, - 0, - NULL); - fprintf(xgp->errout,"Reason: %s",lpMsgBuf); -#endif /* WIN32 */ #endif // ndef } /* end of raw_err() */ /*----------------------------------------------------------------------*/ @@ -90,10 +73,10 @@ xdd_raw_setup_reader_socket(target_data_t *tdp) { } rawp->raw_addr = ntohl(rawp->raw_sname.sin_addr.s_addr); rawp->raw_port = ntohs(rawp->raw_sname.sin_port); - fprintf(stderr,"%s: Reader Hostname is %s\n\tSocket address is 0x%x = %s\n\tPort %d <0x%x>\n", + fprintf(stderr,"%s: Reader Hostname is %s\n\tSocket address is 0x%x = %s\n\tPort %d <0x%x>\n", xgp->progname, rawp->raw_myhostname, - rawp->raw_sname.sin_addr.s_addr, + rawp->raw_sname.sin_addr.s_addr, inet_ntoa(rawp->raw_sname.sin_addr), rawp->raw_sname.sin_port,rawp->raw_port); /* All set; prepare to accept connection requests */ @@ -106,10 +89,6 @@ xdd_raw_setup_reader_socket(target_data_t *tdp) { } /* end of xdd_raw_setup_reader_socket() */ /*----------------------------------------------------------------------*/ /* xdd_raw_sockets_init() - for read-after-write operations - * - * Windows requires the WinSock startup routine to be run - * before running a bunch of socket routines. We encapsulate - * that here in case some other environment needs something similar. * * Returns true if startup was successful, false otherwise. * @@ -124,39 +103,6 @@ xdd_raw_sockets_init(target_data_t *tdp) { rawp = p->rawp; -#ifdef WIN32 - WSADATA wsaData; /* Data structure used by WSAStartup */ - int wsastatus; /* status returned by WSAStartup */ - char *reason; - wsastatus = WSAStartup(MAKEWORD(2, 2), &wsaData); - if (wsastatus != 0) { /* Error in starting the network */ - switch (wsastatus) { - case WSASYSNOTREADY: - reason = "Network is down"; - break; - case WSAVERNOTSUPPORTED: - reason = "Request version of sockets <2.2> is not supported"; - break; - case WSAEINPROGRESS: - reason = "Another Windows Sockets operation is in progress"; - break; - case WSAEPROCLIM: - reason = "The limit of the number of sockets tasks has been exceeded"; - break; - case WSAEFAULT: - reason = "Program error: pointer to wsaData is not valid"; - break; - default: - reason = "Unknown error code"; - break; - }; - fprintf(xgp->errout,"%s: Error initializing network connection\nReason: %s\n", - xgp->progname, reason); - fflush(xgp->errout); - WSACleanup(); - return(FALSE); - } -#endif #endif // ndef return(TRUE); } /* end of xdd_raw_sockets_init() */ @@ -210,18 +156,7 @@ xdd_raw_reader_init(target_data_t *tdp) { rawp->raw_active = rawp->raw_readset; rawp->raw_current_csd = rawp->raw_next_csd = 0; /* Find out how many sockets are in each set (berkely only) */ -#if (IRIX || WIN32 ) - rawp->raw_nd = getdtablehi(); -#endif -#if (LINUX || DARWIN) rawp->raw_nd = getdtablesize(); -#endif -#if (AIX) - rawp->raw_nd = FD_SETSIZE; -#endif -#if (SOLARIS ) - rawp->raw_nd = FD_SETSIZE; -#endif rawp->raw_msg_recv = 0; rawp->raw_msg_last_sequence = 0; #endif // ndef @@ -242,12 +177,9 @@ xdd_raw_read_wait(worker_data_t *wdp) { rawp = p->rawp; -#if (IRIX || WIN32 ) - rawp->raw_nd = getdtablehi(); -#endif status = select(rawp->raw_nd, &rawp->raw_readset, NULL, NULL, NULL); /* Handle all the descriptors that are ready */ - /* There are two type of sockets: the one sd socket and multiple + /* There are two type of sockets: the one sd socket and multiple * client sockets. We first check to see if the sd is in the readset. * If so, this means that a client is trying to make a new connection * in which case we need to issue an accept to establish the connection @@ -270,7 +202,7 @@ xdd_raw_read_wait(worker_data_t *wdp) { } /* end of WHILE loop that finds the next csd entry */ } /* End of processing an incoming connection */ /* This section will check to see which of the Client Socket Descriptors - * are in the readset. For those csd's that are ready, a recv is issued to + * are in the readset. For those csd's that are ready, a recv is issued to * receive the incoming data. The clock is then read from nclk() and the * new clock value is sent back to the client. */ @@ -332,7 +264,7 @@ xdd_raw_setup_writer_socket(target_data_t *tdp) { rawp = p->rawp; - /* Create the socket and set some options */ + /* Create the socket and set some options */ rawp->raw_sd = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP); if (rawp->raw_sd < 0) { xdd_raw_err("error opening socket for RAW writer"); @@ -421,8 +353,3 @@ xdd_raw_writer_send_msg(worker_data_t *wdp) { #endif // ndef return(TRUE); } /* end of xdd_raw_writer_send_msg() */ - - - - -