Files
mars-nwe/include/nwnss/include/cmControl.h

238 lines
9.2 KiB
C

/****************************************************************************
|
| (C) Copyright 1985, 1991, 1993, 1996-1999 Novell, Inc.
| All Rights Reserved.
|
| This program is free software; you can redistribute it and/or
| modify it under the terms of version 2 of the GNU General Public
| License as published by the Free Software Foundation.
|
| 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
| GNU General Public License for more details.
|
| You should have received a copy of the GNU General Public License
| along with this program; if not, contact Novell, Inc.
|
| To contact Novell about this file by physical or electronic mail,
| you may find current contact information at www.novell.com
|
|***************************************************************************
|
| NSS Compression Management module
|
|---------------------------------------------------------------------------
|
| $Author: taysom $
| $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $
|
| $RCSfile$
| $Revision: 465 $
|
|---------------------------------------------------------------------------
| Module Description:
|
+-------------------------------------------------------------------------*/
#ifndef _CM_CONTROL_H_
#define _CM_CONTROL_H_
#ifndef _QUE_H_
#include <library/que.h>
#endif /* _QUE_H_ */
/*
* Resource Control Interface
* Netware Set-parameters for compression
*/
typedef struct CMCompControlParams_s
{
/* CPU Utilization Parameters */
LONG dailyCheckStartTime;
LONG dailyCheckStopTime;
LONG maxCompressions;
LONG maxCmActivities; /* Max. # of simultaneous ongoing comp/decomp
* activities allowed
* i.e., max threads allowed for comp/decomp */
QUAD minFileIdleTime; /* for compression */
QUAD minDeletedFileIdleTime; /* for compression */
BOOL compEnabled;
/* Space Utilization parameters */
LONG maxZidsQueuedForCompression; /* Max # of Beast ZIDs queued in memory
for (background) compression */
LONG minPercentGain;
SLONG decompOption;
#define DECOMP_OPTION_LEAVE_DECOMPRESSED 0
#define DECOMP_OPTION_LEAVE_DECOMPRESSED_FOR_N_ACCESSES 1
#define DECOMP_OPTION_CHANGE_TO_DECOMPRESSED 2
SLONG compressDeletedFilesOption;
#define COMP_DELETED_FILES_NEVER 0
#define COMP_DELETED_FILES_NEXT_DAY 1
#define COMP_DELETED_FILES_IMMEDIATELY 2
LONG minFreeSpaceToDecompress;
LONG decompFreeSpaceWarningInterval;
} CMCompControlParams_s;
extern CMCompControlParams_s CM_curCompControlParams;
#define CM_MIN_FILE_SIZE_TO_COMPRESS(_beast) \
((1 << (_beast)->ROOTblkSizeShift) + 1)
#define SET_COMP_DAILY_CHECK_START_TIME(_value, _startup) \
(CM_curCompControlParams.dailyCheckStartTime = (_value)), \
CM_bgCompressRestartStartTimer(_startup)
#define SET_COMP_DAILY_CHECK_STOP_TIME(_value, _startup) \
(CM_curCompControlParams.dailyCheckStopTime = (_value)), \
CM_bgCompressRestartStopTimer(_startup)
#define SET_MIN_PERCENT_GAIN(_value) \
(CM_curCompControlParams.minPercentGain = (_value))
#define SET_DECOMP_OPTION(_value) \
(CM_curCompControlParams.decompOption = (_value))
#define SET_MIN_FREE_SPACE_TO_DECOMPRESS(_value) \
(CM_curCompControlParams.minFreeSpaceToDecompress = (_value))
#define SET_DECOMP_FREE_SPACE_WARN_INTERVAL(_value) \
(CM_curCompControlParams.decompFreeSpaceWarningInterval = (_value))
#define SET_FILE_IDLE_TIME_FOR_COMP(_value) \
(CM_curCompControlParams.minFileIdleTime = (_value))
#define SET_COMPRESS_DELETED_FILES_OPTION(_value) \
(CM_curCompControlParams.compressDeletedFilesOption = (_value))
extern void CM_controlCompression(BOOL enable);
#define SET_COMP_ENABLED_FLAG(_value) \
CM_controlCompression((_value) ? TRUE : FALSE)
extern STATUS CM_controlInit();
#define CM_controlUninit()
extern void CM_controlMaxConcurrentComp(NINT value);
#define SET_MAX_CONCURRENT_COMPRESSIONS(_value) \
CM_controlMaxConcurrentComp((NINT)_value);
extern void CM_bgCompressInit();
extern void CM_bgCompressStartRequest();
extern void CM_bgCompressStopRequest();
extern void CM_bgCompressRestartStartTimer(BOOL startup);
extern void CM_bgCompressRestartStopTimer(BOOL startup);
extern void CM_bgCompressResetTimer();
#define NSS_MAX_COMP_ALGORITHMS 64 /* Currently can't be more than 64 */
/* Compression Management statistics */
typedef struct CMCompStatistics_s
{
Latch_s latch; /* Compression allows multiple threads, use this
* latch when any of the following need to be
* changed. */
QUAD compressedFiles;
QUAD compDelFiles;
QUAD uncompressibleFiles;
// BYTE percentFilesCompressed; /* # of files in compressed state */
LONG percentSpaceSaved; /* % of space saved due to compression */
NINT numCompActivities; /* # of ongoing compression activities */
NINT numDecompActivities; /* # of ongoing decompression activities */
NINT numQueuedCompReqs; /* # of ZIDs queued for normal compression */
NINT numQueuedBGCompReqs; /* # of ZIDs queued for background compression */
// BYTE averageCompRatio[NSS_MAX_COMP_ALGORITHMS];
LONG averageCompRatio; /* Average compression ratio achieved for all
* of the algorithms. */
} CMCompStatistics_s;
extern CMCompStatistics_s CM_curCompStatistics;
extern STATUS getCompStatistics(CMCompStatistics_s *stats /* inout */);
/* Per-volume compression attributes */
typedef struct VolumeCompAttr_s
{
BYTE ImplMajorVersion; /* Identifies which compression implementation
* does this volume use (it's like a version # */
BYTE ImplMinorVersion; /* Version # within that major version */
#define NSS_COMP_IMPL_MAJOR_VERSION 1
#define NSS_COMP_IMPL_MINOR_VERSION 0
BYTE algoID; /* Default compression Algorithm ID */
BYTE algoVersion; /* Default compression Algorithm Version */
LONG compFlags; /* Cumulative */
//#define VOL_COMP_FLAGS_ENABLE_COMPRESS 0x0002 /* Allow compression */
#define VOL_COMP_FLAGS_IMMEDIATE_COMPRESS 0x0001 /* Always Keep files
* compressed */
#define VOL_COMP_FLAGS_UPGRADE_START 0x4000 /* LSS has given permission
* to start upgrading comp beasts
*/
#define VOL_COMP_FLAGS_UPGRADE_FINISHED 0x8000 /* all compressed beasts are
* upgraded from rootbeast_s to
* compbeast_s
*/
QUAD chunkSize; /* Default file compression chunk size */
QUAD algorithms_used; /* Bitmap of algorithms currently used */
} NSS_MEDIA_STRUCTURE(VolumeCompAttr_s,algorithms_used) VolumeCompAttr_s;
/* Interface to set Volume/file/directory Compression Attributes */
extern STATUS volSetCompAttr(Volume_s *volume, VolumeCompAttr_s *newAttr);
/*
* ZIDs of beasts waiting to be compressed are queued up in memory if activity
* structures cannot be allocated for them.
* Each time we need more queuing space, we allocate a CompRequestScoop_s
* structure to hold MAX_COMP_REQS_PER_SCOOP zids. We make sure that
* sizeof(CompRequestScoop_s) == 4Kbytes
*/
typedef struct CompRequest_s
{
Zid_t zid;
} CompRequest_s;
typedef struct CompRequestScoop_s
{
SQlink_t requestQLink;
WORD firstFreeInd;
WORD firstValidReqInd;
WORD removedQueues;
#ifdef COMPILER_NO_INCOMPLETE_OFFSETOF
#define COMP_REQUEST_SCOOP_UNUSED_WORD 3
#else
#define COMP_REQUEST_SCOOP_UNUSED_WORD \
((sizeof(CompRequest_s) - \
((offsetof(struct CompRequestScoop_s, removedQueues) + sizeof(WORD)) \
% sizeof(CompRequest_s))) / sizeof(WORD))
#endif
WORD unused[COMP_REQUEST_SCOOP_UNUSED_WORD];
#ifdef COMPILER_NO_INCOMPLETE_OFFSETOF
#define MAX_COMP_REQS_PER_SCOOP 510
#else
#define MAX_COMP_REQS_PER_SCOOP \
((4096 - (offsetof(struct CompRequestScoop_s, unused) \
+ (sizeof(WORD) * COMP_REQUEST_SCOOP_UNUSED_WORD))) \
/ sizeof(CompRequest_s))
#endif
CompRequest_s req[MAX_COMP_REQS_PER_SCOOP];
} CompRequestScoop_s;
#define MAX_COMP_REQ_SCOOPS 4096
#define MAX_ZIDS_QUEUED_FOR_COMPRESSION \
(MAX_COMP_REQS_PER_SCOOP * MAX_COMP_REQ_SCOOPS)
typedef struct CMVolumeState_s
{
BOOL compActive; /* Compression Management is currently
* active in this volume */
SQhead_t compRequestQHead; /* queue head for requests initiated by
* normal file operations.
*/
Latch_s latch;
SQhead_t compRequestBGQHead; /* queue head for requests initiated by
* background compression
*/
Latch_s BGlatch;
} CMVolumeState_s;
/* the following defines different reasons to initiate compression request.
* Currently, the main purpose is just to clean up all the request initiated
* by background compression when stop timer popps
*/
#define COMP_NORMAL 0x0001 /* by normal file operation */
#define COMP_BACKGROUND 0x0002 /* by background compression thread */
#endif /* _CM_CONTROL_H_ */