|
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/compressionState.h#2 $
|
|
Packit Service |
310c69 |
*/
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
#ifndef COMPRESSION_STATE_H
|
|
Packit Service |
310c69 |
#define COMPRESSION_STATE_H
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
#include "atomic.h"
|
|
Packit Service |
310c69 |
#include "types.h"
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Where a DataVIO is on the compression path; advanceStatus() depends on the
|
|
Packit Service |
310c69 |
* order of this enum.
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
typedef enum {
|
|
Packit Service |
310c69 |
/* A VIO which has not yet entered the compression path */
|
|
Packit Service |
310c69 |
VIO_PRE_COMPRESSOR = 0,
|
|
Packit Service |
310c69 |
/* A VIO which is in the compressor */
|
|
Packit Service |
310c69 |
VIO_COMPRESSING,
|
|
Packit Service |
310c69 |
/* A VIO which is blocked in the packer */
|
|
Packit Service |
310c69 |
VIO_PACKING,
|
|
Packit Service |
310c69 |
/* A VIO which is no longer on the compression path (and never will be) */
|
|
Packit Service |
310c69 |
VIO_POST_PACKER,
|
|
Packit Service |
310c69 |
} VIOCompressionStatus;
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
typedef struct {
|
|
Packit Service |
310c69 |
VIOCompressionStatus status;
|
|
Packit Service |
310c69 |
bool mayNotCompress;
|
|
Packit Service |
310c69 |
} VIOCompressionState;
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Get the compression state of a DataVIO.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param dataVIO The DataVIO
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @return The compression state
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
__attribute__((warn_unused_result))
|
|
Packit Service |
310c69 |
VIOCompressionState getCompressionState(DataVIO *dataVIO);
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Check whether a DataVIO may go to the compressor.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param dataVIO The DataVIO to check
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @return true if the DataVIO may be compressed at this time
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
bool mayCompressDataVIO(DataVIO *dataVIO)
|
|
Packit Service |
310c69 |
__attribute__((warn_unused_result));
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Check whether a DataVIO may go to the packer.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param dataVIO The DataVIO to check
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @return true if the DataVIO may be packed at this time
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
bool mayPackDataVIO(DataVIO *dataVIO)
|
|
Packit Service |
310c69 |
__attribute__((warn_unused_result));
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Check whether a DataVIO which has gone to the packer may block there. Any
|
|
Packit Service |
310c69 |
* cancelation after this point and before the DataVIO is written out requires
|
|
Packit Service |
310c69 |
* this DataVIO to be picked up by the canceling DataVIO.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param dataVIO The DataVIO to check
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @return true if the DataVIO may block in the packer
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
bool mayBlockInPacker(DataVIO *dataVIO)
|
|
Packit Service |
310c69 |
__attribute__((warn_unused_result));
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Check whether the packer may write out a DataVIO as part of a compressed
|
|
Packit Service |
310c69 |
* block.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param dataVIO The DataVIO to check
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @return true if the DataVIO may be written as part of a
|
|
Packit Service |
310c69 |
* compressed block at this time
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
bool mayWriteCompressedDataVIO(DataVIO *dataVIO)
|
|
Packit Service |
310c69 |
__attribute__((warn_unused_result));
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Indicate that this DataVIO is leaving the compression path.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param dataVIO The DataVIO leaving the compression path
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
void setCompressionDone(DataVIO *dataVIO);
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Prevent this DataVIO from being compressed or packed.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param dataVIO The DataVIO to cancel
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @return true if the DataVIO is in the packer and the caller
|
|
Packit Service |
310c69 |
* was the first caller to cancel it
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
bool cancelCompression(DataVIO *dataVIO);
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
#endif /* COMPRESSION_STATE_H */
|