From: VMware, Inc <> Date: Thu, 17 Jun 2010 22:09:09 +0000 (-0700) Subject: Remove FileIO Stats. X-Git-Tag: 2010.06.16-268169~52 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=719c1726b8dfd7add103610f3e2e38ba37f526cf;p=thirdparty%2Fopen-vm-tools.git Remove FileIO Stats. The FileIO stats are not thread-safe (PR 488887), but no one ever looks at them anyway (PR 563363). This change removes stats from FileIO. Signed-off-by: Marcelo Vanzin --- diff --git a/open-vm-tools/lib/file/file.c b/open-vm-tools/lib/file/file.c index bfed3f748..1c5827318 100644 --- a/open-vm-tools/lib/file/file.c +++ b/open-vm-tools/lib/file/file.c @@ -54,7 +54,6 @@ #include "file.h" #include "fileIO.h" #include "fileInt.h" -#include "stats_file.h" #include "dynbuf.h" #include "base64.h" #include "timeutil.h" @@ -65,9 +64,6 @@ #include "unicodeOperations.h" -#define SETUP_DEFINE_VARS -#include "stats_user_setup.h" - #if !defined(O_BINARY) #define O_BINARY 0 #endif diff --git a/open-vm-tools/lib/file/fileIO.c b/open-vm-tools/lib/file/fileIO.c index c5bd3fc3a..76276d8f9 100644 --- a/open-vm-tools/lib/file/fileIO.c +++ b/open-vm-tools/lib/file/fileIO.c @@ -346,113 +346,6 @@ FileIO_Unlock(FileIODescriptor *file) // IN/OUT: } -/* - *---------------------------------------------------------------------- - * - * FileIO_StatsInit -- - * - * Initialize the stat structure in the FileIODescriptor. - * - * Results: - * None. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -void -FileIO_StatsInit(FileIODescriptor *fd) // IN: -{ - /* zero out the stat counters */ - - ASSERT(fd); - -#if defined(VMX86_STATS) - fd->readIn = 0; fd->writeIn = 0; - fd->readvIn = 0; fd->writevIn = 0; - fd->preadvIn = 0; fd->pwritevIn = 0; - fd->readDirect = 0; fd->writeDirect = 0; - fd->readvDirect = 0; fd->writevDirect = 0; - fd->preadDirect = 0; fd->pwriteDirect = 0; - fd->bytesRead = 0; fd->bytesWritten = 0; - fd->numReadCoalesced = 0; fd->numWriteCoalesced = 0; -#endif -} - - -/* - *---------------------------------------------------------------------- - * - * FileIO_StatsLog -- - * - * Dump statistics about file access in the log file. - * - * Results: - * None. - * - * Side effects: - * Logs. - * - *---------------------------------------------------------------------- - */ - -void -FileIO_StatsLog(FileIODescriptor *fd) // IN: -{ - ASSERT(fd); - -#if defined(VMX86_STATS) - if (fd->bytesRead + fd->bytesWritten == 0) { - /* No activity --> no interesting stats */ - return; - } - - if (fd->readIn + fd->writeIn + fd->readvIn + fd->writevIn + - fd->preadvIn + fd->pwritevIn < 100) { - /* - * Less than 100 operations is insufficient to be interesting and this - * way we don't get spew everytime a file (generally a disk) is opened - * temporarily. - */ - return; - } - - Log("FILEIOSTATS | \"%s\" %d %d %d %d %d %d %d %d %d %d %d %d %d %d %"FMT64"d %"FMT64"d\n", - fd->fileName ? UTF8(fd->fileName) : "", - fd->readIn, fd->readDirect, fd->writeIn, fd->writeDirect, - fd->readvIn, fd->readvDirect, fd->writevIn, fd->writevDirect, - fd->preadvIn, fd->preadDirect, fd->pwritevIn, fd->pwriteDirect, - fd->numReadCoalesced, fd->numWriteCoalesced, - fd->bytesRead, fd->bytesWritten); -#endif -} - - -/* - *---------------------------------------------------------------------- - * - * FileIO_StatsExit -- - * - * Release resources allocated for statistics. - * - * Results: - * None. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -void -FileIO_StatsExit(const FileIODescriptor *fd) // IN: -{ - ASSERT(fd); -} - - /* *---------------------------------------------------------------------- * diff --git a/open-vm-tools/lib/file/fileIOPosix.c b/open-vm-tools/lib/file/fileIOPosix.c index 558807062..2fabb407a 100644 --- a/open-vm-tools/lib/file/fileIOPosix.c +++ b/open-vm-tools/lib/file/fileIOPosix.c @@ -87,7 +87,6 @@ #include "config.h" #include "util.h" #include "iovector.h" -#include "stats_file.h" #include "hostType.h" #include "unicodeOperations.h" @@ -337,11 +336,6 @@ FileIO_CreateFDPosix(int posix, // IN: UNIX file descriptor FileIO_Invalidate(&fd); -#if defined(VMX86_STATS) - STATS_USER_INIT_MODULE_ONCE(); - fd.stats = STATS_USER_INIT_INST("Created"); -#endif - if (flags & O_RDWR) { fd.flags |= (FILEIO_OPEN_ACCESS_READ | FILEIO_OPEN_ACCESS_WRITE); } else if (flags & O_WRONLY) { @@ -758,17 +752,6 @@ FileIO_Create(FileIODescriptor *file, // OUT: return FILEIO_ERROR; } -#if defined(VMX86_STATS) - { - Unicode tmp; - - File_SplitName(pathName, NULL, NULL, &tmp); - STATS_USER_INIT_MODULE_ONCE(); - file->stats = STATS_USER_INIT_INST(tmp); - Unicode_Free(tmp); - } -#endif - ASSERT(!FileIO_IsValid(file)); ASSERT(file->lockToken == NULL); ASSERT_ON_COMPILE(FILEIO_ERROR_LAST < 16); /* See comment in fileIO.h */ @@ -917,8 +900,6 @@ FileIO_Create(FileIODescriptor *file, // OUT: file->posix = fd; - FileIO_StatsInit(file); - return FILEIO_SUCCESS; error: @@ -1102,20 +1083,12 @@ FileIO_Write(FileIODescriptor *fd, // IN: ASSERT(fd); - STAT_INST_INC(fd->stats, NumWrites); - STAT_INST_INC_BY(fd->stats, BytesWritten, requested); - STATS_ONLY({ - fd->writeIn++; - fd->bytesWritten += requested; - }) - ASSERT_NOT_IMPLEMENTED(requested < 0x80000000); initial_requested = requested; while (requested > 0) { ssize_t res; - STATS_ONLY(fd->writeDirect++;) res = write(fd->posix, buf, requested); if (res == -1) { @@ -1173,20 +1146,12 @@ FileIO_Read(FileIODescriptor *fd, // IN: ASSERT(fd); - STAT_INST_INC(fd->stats, NumReads); - STAT_INST_INC_BY(fd->stats, BytesRead, requested); - STATS_ONLY({ - fd->readIn++; - fd->bytesRead += requested; - }) - ASSERT_NOT_IMPLEMENTED(requested < 0x80000000); initial_requested = requested; while (requested > 0) { ssize_t res; - STATS_ONLY(fd->readDirect++;) res = read(fd->posix, buf, requested); if (res == -1) { if (errno == EINTR) { @@ -1270,8 +1235,6 @@ FileIO_Close(FileIODescriptor *file) // IN: err = (close(file->posix) == -1) ? errno : 0; - FileIO_StatsExit(file); - /* Unlock the file if it was locked */ FileIO_Unlock(file); FileIO_Cleanup(file); @@ -1479,16 +1442,6 @@ FileIO_Readv(FileIODescriptor *fd, // IN: didCoalesce = FileIOCoalesce(v, numEntries, totalSize, FALSE, FALSE, fd->flags, &coV); - STAT_INST_INC(fd->stats, NumReadvs); - STAT_INST_INC_BY(fd->stats, BytesReadv, totalSize); - STATS_ONLY({ - fd->readvIn++; - fd->bytesRead += totalSize; - if (didCoalesce) { - fd->numReadCoalesced++; - } - }) - ASSERT_NOT_IMPLEMENTED(totalSize < 0x80000000); numVec = didCoalesce ? 1 : numEntries; @@ -1498,7 +1451,6 @@ FileIO_Readv(FileIODescriptor *fd, // IN: ssize_t retval; ASSERT(numVec > 0); - STATS_ONLY(fd->readvDirect++;) retval = readv(fd->posix, vPtr, numVec); if (retval == -1) { @@ -1602,16 +1554,6 @@ FileIO_Writev(FileIODescriptor *fd, // IN: didCoalesce = FileIOCoalesce(v, numEntries, totalSize, TRUE, FALSE, fd->flags, &coV); - STAT_INST_INC(fd->stats, NumWritevs); - STAT_INST_INC_BY(fd->stats, BytesWritev, totalSize); - STATS_ONLY({ - fd->writevIn++; - fd->bytesWritten += totalSize; - if (didCoalesce) { - fd->numWriteCoalesced++; - } - }) - ASSERT_NOT_IMPLEMENTED(totalSize < 0x80000000); numVec = didCoalesce ? 1 : numEntries; @@ -1621,7 +1563,6 @@ FileIO_Writev(FileIODescriptor *fd, // IN: ssize_t retval; ASSERT(numVec > 0); - STATS_ONLY(fd->writevDirect++;) retval = writev(fd->posix, vPtr, numVec); if (retval == -1) { @@ -1710,21 +1651,10 @@ FileIO_Preadv(FileIODescriptor *fd, // IN: File descriptor count = didCoalesce ? 1 : numEntries; vPtr = didCoalesce ? &coV : entries; - STAT_INST_INC(fd->stats, NumPreadvs); - STAT_INST_INC_BY(fd->stats, BytesPreadv, totalSize); - STATS_ONLY({ - fd->preadvIn++; - fd->bytesRead += totalSize; - if (didCoalesce) { - fd->numReadCoalesced++; - } - }) - fileOffset = offset; while (count > 0) { size_t leftToRead = vPtr->iov_len; uint8 *buf = (uint8 *) vPtr->iov_base; - STATS_ONLY(fd->preadDirect++;) while (leftToRead > 0) { ssize_t retval = pread(fd->posix, buf, leftToRead, fileOffset); @@ -1809,21 +1739,10 @@ FileIO_Pwritev(FileIODescriptor *fd, // IN: File descriptor count = didCoalesce ? 1 : numEntries; vPtr = didCoalesce ? &coV : entries; - STAT_INST_INC(fd->stats, NumPwritevs); - STAT_INST_INC_BY(fd->stats, BytesPwritev, totalSize); - STATS_ONLY({ - fd->pwritevIn++; - fd->bytesWritten += totalSize; - if (didCoalesce) { - fd->numWriteCoalesced++; - } - }) - fileOffset = offset; while (count > 0) { size_t leftToWrite = vPtr->iov_len; uint8 *buf = (uint8 *)vPtr->iov_base; - STATS_ONLY(fd->pwriteDirect++;) while (leftToWrite > 0) { ssize_t retval = pwrite(fd->posix, buf, leftToWrite, fileOffset); diff --git a/open-vm-tools/lib/include/fileIO.h b/open-vm-tools/lib/include/fileIO.h index a83135b50..a00b2ad4d 100644 --- a/open-vm-tools/lib/include/fileIO.h +++ b/open-vm-tools/lib/include/fileIO.h @@ -52,24 +52,6 @@ #include "iovector.h" // for struct iovec -#if defined(VMX86_STATS) - -struct StatsUserBlock; - -#define FILEIO_STATS_VARS \ - uint32 readIn, readDirect; \ - uint32 writeIn, writeDirect; \ - uint32 readvIn, readvDirect; \ - uint32 writevIn, writevDirect; \ - uint32 preadvIn, preadDirect; \ - uint32 pwritevIn, pwriteDirect; \ - uint64 bytesRead, bytesWritten; \ - uint32 numReadCoalesced, numWriteCoalesced; \ - struct StatsUserBlock *stats; -#else -#define FILEIO_STATS_VARS -#endif - #if defined(_WIN32) # include @@ -79,7 +61,6 @@ typedef struct FileIODescriptor { uint32 flags; Unicode fileName; void *lockToken; - FILEIO_STATS_VARS } FileIODescriptor; #else @@ -89,7 +70,6 @@ typedef struct FileIODescriptor { int flags; Unicode fileName; void *lockToken; - FILEIO_STATS_VARS } FileIODescriptor; #endif @@ -373,12 +353,6 @@ void FileIO_Init(FileIODescriptor *fd, void FileIO_Cleanup(FileIODescriptor *fd); -void FileIO_StatsInit(FileIODescriptor *fd); - -void FileIO_StatsLog(FileIODescriptor *fd); - -void FileIO_StatsExit(const FileIODescriptor *fd); - const char *FileIO_ErrorEnglish(FileIOResult status); void FileIO_OptionalSafeInitialize(void); diff --git a/open-vm-tools/lib/include/stats_file.h b/open-vm-tools/lib/include/stats_file.h deleted file mode 100644 index f5d9047b0..000000000 --- a/open-vm-tools/lib/include/stats_file.h +++ /dev/null @@ -1,58 +0,0 @@ -/********************************************************* - * Copyright (C) 1998 VMware, Inc. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation version 2.1 and no later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the Lesser GNU General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - *********************************************************/ - -/* - * stats_file.h -- - * - * Implements statistics counters for lib/file/. - * - */ - -#ifndef STATS_FILE_H -#define STATS_FILE_H - -#define INCLUDE_ALLOW_USERLEVEL -#include "includeCheck.h" - -#define STATS_MODULE file -#include "stats_user_defs.h" - -#define SETUP_DECLARE_VARS -#ifdef VMX86_STATS -#define STATS_COUNTERS_INLINE \ - STAT_INST(NumReads, STATS_MODULE, "# Calls to FileIO_Read()") \ - STAT_INST(NumReadvs, STATS_MODULE, "# Calls to FileIO_Readv()") \ - STAT_INST(NumPreadvs, STATS_MODULE, "# Calls to FileIO_Preadv()") \ - STAT_INST(BytesRead, STATS_MODULE, "# Bytes requested of FileIO_Read()") \ - STAT_INST(BytesReadv, STATS_MODULE, "# Bytes requested of FileIO_Readv()") \ - STAT_INST(BytesPreadv, STATS_MODULE, "# Bytes requested of FileIO_Preadv()") \ - \ - STAT_INST(NumWrites, STATS_MODULE, "# Calls to FileIO_Write()") \ - STAT_INST(NumWritevs, STATS_MODULE, "# Calls to FileIO_Writev()") \ - STAT_INST(NumPwritevs, STATS_MODULE, "# Calls to FileIO_Pwritev()") \ - STAT_INST(BytesWritten, STATS_MODULE, "# Bytes requested of FileIO_Write()") \ - STAT_INST(BytesWritev, STATS_MODULE, "# Bytes requested of FileIO_Writev()") \ - STAT_INST(BytesPwritev, STATS_MODULE, "# Bytes requested of FileIO_Pwritev()") - -#else - /* No statcounter in non-STATS builds */ -#define STATS_COUNTERS_NONE -#endif -#include "stats_user_setup.h" - -#endif