|
Packit Service |
310c69 |
/*
|
|
Packit Service |
310c69 |
* Copyright (c) 2020 Red Hat, Inc.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* This program is free software; you can redistribute it and/or
|
|
Packit Service |
310c69 |
* modify it under the terms of the GNU General Public License
|
|
Packit Service |
310c69 |
* as published by the Free Software Foundation; either version 2
|
|
Packit Service |
310c69 |
* of the License, or (at your option) any later version.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* This program is distributed in the hope that it will be useful,
|
|
Packit Service |
310c69 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
310c69 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
Packit Service |
310c69 |
* GNU General Public License for more details.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* You should have received a copy of the GNU General Public License
|
|
Packit Service |
310c69 |
* along with this program; if not, write to the Free Software
|
|
Packit Service |
310c69 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
|
Packit Service |
310c69 |
* 02110-1301, USA.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* $Id: //eng/vdo-releases/aluminum/src/c++/vdo/base/packer.h#3 $
|
|
Packit Service |
310c69 |
*/
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
#ifndef PACKER_H
|
|
Packit Service |
310c69 |
#define PACKER_H
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
#include "completion.h"
|
|
Packit Service |
310c69 |
#include "physicalLayer.h"
|
|
Packit Service |
310c69 |
#include "statistics.h"
|
|
Packit Service |
310c69 |
#include "threadConfig.h"
|
|
Packit Service |
310c69 |
#include "types.h"
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
enum {
|
|
Packit Service |
310c69 |
DEFAULT_PACKER_INPUT_BINS = 16,
|
|
Packit Service |
310c69 |
DEFAULT_PACKER_OUTPUT_BINS = 256,
|
|
Packit Service |
310c69 |
};
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
typedef struct packer Packer;
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Make a new block packer.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param [in] layer The physical layer to which compressed blocks
|
|
Packit Service |
310c69 |
* will be written
|
|
Packit Service |
310c69 |
* @param [in] inputBinCount The number of partial bins to keep in memory
|
|
Packit Service |
310c69 |
* @param [in] outputBinCount The number of compressed blocks that can be
|
|
Packit Service |
310c69 |
* written concurrently
|
|
Packit Service |
310c69 |
* @param [in] threadConfig The thread configuration of the VDO
|
|
Packit Service |
310c69 |
* @param [out] packerPtr A pointer to hold the new packer
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @return VDO_SUCCESS or an error
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
int makePacker(PhysicalLayer *layer,
|
|
Packit Service |
310c69 |
BlockCount inputBinCount,
|
|
Packit Service |
310c69 |
BlockCount outputBinCount,
|
|
Packit Service |
310c69 |
const ThreadConfig *threadConfig,
|
|
Packit Service |
310c69 |
Packer **packerPtr)
|
|
Packit Service |
310c69 |
__attribute__((warn_unused_result));
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Free a block packer and null out the reference to it.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param packerPtr A pointer to the packer to free
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
void freePacker(Packer **packerPtr);
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Check whether the compressed data in a DataVIO will fit in a packer bin.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param dataVIO The DataVIO
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @return true if the DataVIO will fit in a bin
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
bool isSufficientlyCompressible(DataVIO *dataVIO)
|
|
Packit Service |
310c69 |
__attribute__((warn_unused_result));
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Get the thread ID of the packer's zone.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param packer The packer
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @return The packer's thread ID
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
ThreadID getPackerThreadID(Packer *packer);
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Get the current statistics from the packer.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param packer The packer to query
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @return a copy of the current statistics for the packer
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
PackerStatistics getPackerStatistics(const Packer *packer)
|
|
Packit Service |
310c69 |
__attribute__((warn_unused_result));
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Attempt to rewrite the data in this DataVIO as part of a compressed block.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param dataVIO The DataVIO to pack
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
void attemptPacking(DataVIO *dataVIO);
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Request that the packer flush asynchronously. All bins with at least two
|
|
Packit Service |
310c69 |
* compressed data blocks will be written out, and any solitary pending VIOs
|
|
Packit Service |
310c69 |
* will be released from the packer. While flushing is in progress, any VIOs
|
|
Packit Service |
310c69 |
* submitted to attemptPacking() will be continued immediately without
|
|
Packit Service |
310c69 |
* attempting to pack them.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param packer The packer to flush
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
void flushPacker(Packer *packer);
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Remove a lock holder from the packer.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param completion The DataVIO which needs a lock held by a DataVIO in the
|
|
Packit Service |
310c69 |
* packer. The dataVIO's compressedVIO.lockHolder field will
|
|
Packit Service |
310c69 |
* point to the DataVIO to remove.
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
void removeLockHolderFromPacker(VDOCompletion *completion);
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Increment the flush generation in the packer. This will also cause the
|
|
Packit Service |
310c69 |
* packer to flush so that any VIOs from previous generations will exit the
|
|
Packit Service |
310c69 |
* packer.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param packer The packer
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
void incrementPackerFlushGeneration(Packer *packer);
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Drain the packer by preventing any more VIOs from entering the packer and
|
|
Packit Service |
310c69 |
* then flushing.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param packer The packer to drain
|
|
Packit Service |
310c69 |
* @param completion The completion to finish when the packer has drained
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
void drainPacker(Packer *packer, VDOCompletion *completion);
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Resume a packer which has been suspended.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param packer The packer to resume
|
|
Packit Service |
310c69 |
* @param parent The completion to finish when the packer has resumed
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @return VDO_SUCCESS or an error
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
void resumePacker(Packer *packer, VDOCompletion *parent);
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Dump the packer, in a thread-unsafe fashion.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param packer The packer
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
void dumpPacker(const Packer *packer);
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
#endif /* PACKER_H */
|