Blame source/vdo/base/statistics.h

Packit Service 7e342f
/*
Packit Service 7e342f
 * Copyright (c) 2020 Red Hat, Inc.
Packit Service 7e342f
 *
Packit Service 7e342f
 * This program is free software; you can redistribute it and/or
Packit Service 7e342f
 * modify it under the terms of the GNU General Public License
Packit Service 7e342f
 * as published by the Free Software Foundation; either version 2
Packit Service 7e342f
 * of the License, or (at your option) any later version.
Packit Service 7e342f
 * 
Packit Service 7e342f
 * This program is distributed in the hope that it will be useful,
Packit Service 7e342f
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service 7e342f
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit Service 7e342f
 * GNU General Public License for more details.
Packit Service 7e342f
 * 
Packit Service 7e342f
 * You should have received a copy of the GNU General Public License
Packit Service 7e342f
 * along with this program; if not, write to the Free Software
Packit Service 7e342f
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
Packit Service 7e342f
 * 02110-1301, USA. 
Packit Service 7e342f
 */
Packit Service 7e342f
Packit Service 7e342f
#ifndef STATISTICS_H
Packit Service 7e342f
#define STATISTICS_H
Packit Service 7e342f
Packit Service 7e342f
#include "header.h"
Packit Service 7e342f
#include "types.h"
Packit Service 7e342f
Packit Service 7e342f
enum {
Packit Service 7e342f
  STATISTICS_VERSION = 31,
Packit Service 7e342f
};
Packit Service 7e342f
Packit Service 7e342f
typedef struct {
Packit Service 7e342f
  /** The total number of slabs from which blocks may be allocated */
Packit Service 7e342f
  uint64_t slabCount;
Packit Service 7e342f
  /** The total number of slabs from which blocks have ever been allocated */
Packit Service 7e342f
  uint64_t slabsOpened;
Packit Service 7e342f
  /** The number of times since loading that a slab has been re-opened */
Packit Service 7e342f
  uint64_t slabsReopened;
Packit Service 7e342f
} BlockAllocatorStatistics;
Packit Service 7e342f
Packit Service 7e342f
/**
Packit Service 7e342f
 * Counters for tracking the number of items written (blocks, requests, etc.)
Packit Service 7e342f
 * that keep track of totals at steps in the write pipeline. Three counters
Packit Service 7e342f
 * allow the number of buffered, in-memory items and the number of in-flight,
Packit Service 7e342f
 * unacknowledged writes to be derived, while still tracking totals for
Packit Service 7e342f
 * reporting purposes
Packit Service 7e342f
 **/
Packit Service 7e342f
typedef struct {
Packit Service 7e342f
  /** The total number of items on which processing has started */
Packit Service 7e342f
  uint64_t started;
Packit Service 7e342f
  /** The total number of items for which a write operation has been issued */
Packit Service 7e342f
  uint64_t written;
Packit Service 7e342f
  /** The total number of items for which a write operation has completed */
Packit Service 7e342f
  uint64_t committed;
Packit Service 7e342f
} CommitStatistics;
Packit Service 7e342f
Packit Service 7e342f
/** Counters for events in the recovery journal */
Packit Service 7e342f
typedef struct {
Packit Service 7e342f
  /** Number of times the on-disk journal was full */
Packit Service 7e342f
  uint64_t diskFull;
Packit Service 7e342f
  /** Number of times the recovery journal requested slab journal commits. */
Packit Service 7e342f
  uint64_t slabJournalCommitsRequested;
Packit Service 7e342f
  /** Write/Commit totals for individual journal entries */
Packit Service 7e342f
  CommitStatistics entries;
Packit Service 7e342f
  /** Write/Commit totals for journal blocks */
Packit Service 7e342f
  CommitStatistics blocks;
Packit Service 7e342f
} RecoveryJournalStatistics;
Packit Service 7e342f
Packit Service 7e342f
/** The statistics for the compressed block packer. */
Packit Service 7e342f
typedef struct {
Packit Service 7e342f
  /** Number of compressed data items written since startup */
Packit Service 7e342f
  uint64_t compressedFragmentsWritten;
Packit Service 7e342f
  /** Number of blocks containing compressed items written since startup */
Packit Service 7e342f
  uint64_t compressedBlocksWritten;
Packit Service 7e342f
  /** Number of VIOs that are pending in the packer */
Packit Service 7e342f
  uint64_t compressedFragmentsInPacker;
Packit Service 7e342f
} PackerStatistics;
Packit Service 7e342f
Packit Service 7e342f
/** The statistics for the slab journals. */
Packit Service 7e342f
typedef struct {
Packit Service 7e342f
  /** Number of times the on-disk journal was full */
Packit Service 7e342f
  uint64_t diskFullCount;
Packit Service 7e342f
  /** Number of times an entry was added over the flush threshold */
Packit Service 7e342f
  uint64_t flushCount;
Packit Service 7e342f
  /** Number of times an entry was added over the block threshold */
Packit Service 7e342f
  uint64_t blockedCount;
Packit Service 7e342f
  /** Number of times a tail block was written */
Packit Service 7e342f
  uint64_t blocksWritten;
Packit Service 7e342f
  /** Number of times we had to wait for the tail to write */
Packit Service 7e342f
  uint64_t tailBusyCount;
Packit Service 7e342f
} SlabJournalStatistics;
Packit Service 7e342f
Packit Service 7e342f
/** The statistics for the slab summary. */
Packit Service 7e342f
typedef struct {
Packit Service 7e342f
  /** Number of blocks written */
Packit Service 7e342f
  uint64_t blocksWritten;
Packit Service 7e342f
} SlabSummaryStatistics;
Packit Service 7e342f
Packit Service 7e342f
/** The statistics for the reference counts. */
Packit Service 7e342f
typedef struct {
Packit Service 7e342f
  /** Number of reference blocks written */
Packit Service 7e342f
  uint64_t blocksWritten;
Packit Service 7e342f
} RefCountsStatistics;
Packit Service 7e342f
Packit Service 7e342f
/** The statistics for the block map. */
Packit Service 7e342f
typedef struct {
Packit Service 7e342f
  /** number of dirty (resident) pages */
Packit Service 7e342f
  uint32_t dirtyPages;
Packit Service 7e342f
  /** number of clean (resident) pages */
Packit Service 7e342f
  uint32_t cleanPages;
Packit Service 7e342f
  /** number of free pages */
Packit Service 7e342f
  uint32_t freePages;
Packit Service 7e342f
  /** number of pages in failed state */
Packit Service 7e342f
  uint32_t failedPages;
Packit Service 7e342f
  /** number of pages incoming */
Packit Service 7e342f
  uint32_t incomingPages;
Packit Service 7e342f
  /** number of pages outgoing */
Packit Service 7e342f
  uint32_t outgoingPages;
Packit Service 7e342f
  /** how many times free page not avail */
Packit Service 7e342f
  uint32_t cachePressure;
Packit Service 7e342f
  /** number of getVDOPageAsync() for read */
Packit Service 7e342f
  uint64_t readCount;
Packit Service 7e342f
  /** number or getVDOPageAsync() for write */
Packit Service 7e342f
  uint64_t writeCount;
Packit Service 7e342f
  /** number of times pages failed to read */
Packit Service 7e342f
  uint64_t failedReads;
Packit Service 7e342f
  /** number of times pages failed to write */
Packit Service 7e342f
  uint64_t failedWrites;
Packit Service 7e342f
  /** number of gets that are reclaimed */
Packit Service 7e342f
  uint64_t reclaimed;
Packit Service 7e342f
  /** number of gets for outgoing pages */
Packit Service 7e342f
  uint64_t readOutgoing;
Packit Service 7e342f
  /** number of gets that were already there */
Packit Service 7e342f
  uint64_t foundInCache;
Packit Service 7e342f
  /** number of gets requiring discard */
Packit Service 7e342f
  uint64_t discardRequired;
Packit Service 7e342f
  /** number of gets enqueued for their page */
Packit Service 7e342f
  uint64_t waitForPage;
Packit Service 7e342f
  /** number of gets that have to fetch */
Packit Service 7e342f
  uint64_t fetchRequired;
Packit Service 7e342f
  /** number of page fetches */
Packit Service 7e342f
  uint64_t pagesLoaded;
Packit Service 7e342f
  /** number of page saves */
Packit Service 7e342f
  uint64_t pagesSaved;
Packit Service 7e342f
  /** the number of flushes issued */
Packit Service 7e342f
  uint64_t flushCount;
Packit Service 7e342f
} BlockMapStatistics;
Packit Service 7e342f
Packit Service 7e342f
/** The dedupe statistics from hash locks */
Packit Service 7e342f
typedef struct {
Packit Service 7e342f
  /** Number of times the UDS advice proved correct */
Packit Service 7e342f
  uint64_t dedupeAdviceValid;
Packit Service 7e342f
  /** Number of times the UDS advice proved incorrect */
Packit Service 7e342f
  uint64_t dedupeAdviceStale;
Packit Service 7e342f
  /** Number of writes with the same data as another in-flight write */
Packit Service 7e342f
  uint64_t concurrentDataMatches;
Packit Service 7e342f
  /** Number of writes whose hash collided with an in-flight write */
Packit Service 7e342f
  uint64_t concurrentHashCollisions;
Packit Service 7e342f
} HashLockStatistics;
Packit Service 7e342f
Packit Service 7e342f
/** Counts of error conditions in VDO. */
Packit Service 7e342f
typedef struct {
Packit Service 7e342f
  /** number of times VDO got an invalid dedupe advice PBN from UDS */
Packit Service 7e342f
  uint64_t invalidAdvicePBNCount;
Packit Service 7e342f
  /** number of times a VIO completed with a VDO_NO_SPACE error */
Packit Service 7e342f
  uint64_t noSpaceErrorCount;
Packit Service 7e342f
  /** number of times a VIO completed with a VDO_READ_ONLY error */
Packit Service 7e342f
  uint64_t readOnlyErrorCount;
Packit Service 7e342f
} ErrorStatistics;
Packit Service 7e342f
Packit Service 7e342f
/** The statistics of the vdo service. */
Packit Service 7e342f
struct vdoStatistics {
Packit Service 7e342f
  uint32_t version;
Packit Service 7e342f
  uint32_t releaseVersion;
Packit Service 7e342f
  /** Number of blocks used for data */
Packit Service 7e342f
  uint64_t dataBlocksUsed;
Packit Service 7e342f
  /** Number of blocks used for VDO metadata */
Packit Service 7e342f
  uint64_t overheadBlocksUsed;
Packit Service 7e342f
  /** Number of logical blocks that are currently mapped to physical blocks */
Packit Service 7e342f
  uint64_t logicalBlocksUsed;
Packit Service 7e342f
  /** number of physical blocks */
Packit Service 7e342f
  BlockCount physicalBlocks;
Packit Service 7e342f
  /** number of logical blocks */
Packit Service 7e342f
  BlockCount logicalBlocks;
Packit Service 7e342f
  /** Size of the block map page cache, in bytes */
Packit Service 7e342f
  uint64_t blockMapCacheSize;
Packit Service 7e342f
  /** String describing the active write policy of the VDO */
Packit Service 7e342f
  char writePolicy[15];
Packit Service 7e342f
  /** The physical block size */
Packit Service 7e342f
  uint64_t blockSize;
Packit Service 7e342f
  /** Number of times the VDO has successfully recovered */
Packit Service 7e342f
  uint64_t completeRecoveries;
Packit Service 7e342f
  /** Number of times the VDO has recovered from read-only mode */
Packit Service 7e342f
  uint64_t readOnlyRecoveries;
Packit Service 7e342f
  /** String describing the operating mode of the VDO */
Packit Service 7e342f
  char mode[15];
Packit Service 7e342f
  /** Whether the VDO is in recovery mode */
Packit Service 7e342f
  bool inRecoveryMode;
Packit Service 7e342f
  /** What percentage of recovery mode work has been completed */
Packit Service 7e342f
  uint8_t recoveryPercentage;
Packit Service 7e342f
  /** The statistics for the compressed block packer */
Packit Service 7e342f
  PackerStatistics packer;
Packit Service 7e342f
  /** Counters for events in the block allocator */
Packit Service 7e342f
  BlockAllocatorStatistics allocator;
Packit Service 7e342f
  /** Counters for events in the recovery journal */
Packit Service 7e342f
  RecoveryJournalStatistics journal;
Packit Service 7e342f
  /** The statistics for the slab journals */
Packit Service 7e342f
  SlabJournalStatistics slabJournal;
Packit Service 7e342f
  /** The statistics for the slab summary */
Packit Service 7e342f
  SlabSummaryStatistics slabSummary;
Packit Service 7e342f
  /** The statistics for the reference counts */
Packit Service 7e342f
  RefCountsStatistics refCounts;
Packit Service 7e342f
  /** The statistics for the block map */
Packit Service 7e342f
  BlockMapStatistics blockMap;
Packit Service 7e342f
  /** The dedupe statistics from hash locks */
Packit Service 7e342f
  HashLockStatistics hashLock;
Packit Service 7e342f
  /** Counts of error conditions */
Packit Service 7e342f
  ErrorStatistics errors;
Packit Service 7e342f
};
Packit Service 7e342f
Packit Service 7e342f
/**
Packit Service 7e342f
 * Get the proc file path for reading VDOStatistics.
Packit Service 7e342f
 *
Packit Service 7e342f
 * @return The proc file path
Packit Service 7e342f
 **/
Packit Service 7e342f
static inline const char *getVDOStatisticsProcFile(void) {
Packit Service 7e342f
  return "dedupe_stats";
Packit Service 7e342f
}
Packit Service 7e342f
Packit Service 7e342f
#endif /* not STATISTICS_H */