Files
mars-nwe/include/nwnss/internal/comnCompress.h

182 lines
6.1 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 _COMN_COMPRESS_H_
#define _COMN_COMPRESS_H_
#define COMP_METADATA_LAYOUT 1
/*
* File/directory datastream's Compression Information
* Stored in the rootBeast's RootVariableData area of uncompressed data streams.
*/
/* Persistent portion */
typedef struct PersistentCompressInfo_s
{
Zid_t compZid; /* ZID of the compressed stream's rootBeast */
LONG chunkSize; /* Compression Chunk size (0 means whole file) */
/*
* An (un)compressed version of a chunk is precious if it contains valid
* user data and should not be discarded, either because it is the only
* valid copy, or because the user told us not to discard it (eg, by
* setting file attributes or through NetWare Set parameters)
*/
LONG UCprecious; /* # precious uncompressed chunks */
LONG Cprecious; /* # precious compressed chunks */
Blknum_t purgeableBlks; /* # purgeable blocks currently contributed
* by this beast to the volume's
* VOLpurgeableBlks count */
BYTE algoID; /* Algorithm ID (Compression Manager-specific) */
BYTE algoVersion;
BYTE status; /* Data stream's compression status */
#define COMP_STATUS_UNCOMPRESSED 0x1 /* Uncompressed data valid */
#define COMP_STATUS_COMPRESSED 0x2 /* Compressed data valid */
#define COMP_STATUS_FAILURE 0x4 /* Comp/decomp attempt
* failed */
#define COMP_STATUS_CLEAN 0x8 /* No extraneous data/metadata */
#define COMP_STATUS_NBITS 4 /* #bits for chunk comp status */
#define CHUNK_COMPRESSED(_status) ((_status) & COMP_STATUS_COMPRESSED)
#define CHUNK_UNCOMPRESSED(_status) ((_status) & COMP_STATUS_UNCOMPRESSED)
#define ISVALID_COMP_CHUNK(_status) CHUNK_COMPRESSED(_status)
#define ISVALID_UNCOMP_CHUNK(_status) CHUNK_UNCOMPRESSED(_status)
#define COMP_FAILED(_status) ((_status) & COMP_STATUS_FAILURE)
#define BEAST_CLEAN(_status) ((_status) & COMP_STATUS_CLEAN)
#define BEAST_COMPRESSED(_compInfo) ((_compInfo)->p.UCprecious == 0)
#define BEAST_UNCOMPRESSED(_compInfo) ((_compInfo)->p.Cprecious == 0)
#define CHUNKY_COMPRESSION(_compInfo) ((_compInfo)->p.chunkSize != 0)
BYTE action; /* misc actions that has been taken */
#define COMP_ACTION_ADD_COMPLOG 0x1 /* PLOG_BEAST_COMP_CLEANUP is added */
#define COMP_ACTION_ENABLE_IO_WRITE 0x2 /* A write is done when ENABLE_IO_XXX */
} NSS_MEDIA_STRUCTURE(PersistentCompressInfo_s,action) PersistentCompressInfo_s;
typedef struct PackedCompInfo_s
{
WORD rvdID;
WORD rvdLayout;
PersistentCompressInfo_s cmInfo;
} NSS_MEDIA_STRUCTURE(PackedCompInfo_s,cmInfo) PackedCompInfo_s;
typedef struct CompressInfo_s
{
PersistentCompressInfo_s p; /* Persistent portion */
/* Non-persistent portion */
DQhead_t CM_activities; /* Head of list of ongoing (de)compression
* activities for this beast */
DQhead_t dataWaiters; /* Head of list of all threads waiting for
* uncompressed data to become available */
} CompressInfo_s;
typedef struct UncompressInfo_s
{
Zid_t uncompBeastZid;
Zid_t uncompParentZid;
BOOL uncompBeastDeleted;
} UncompressInfo_s;
#define MAX_ZIDS_PER_SCOOP 100
STATUS comnCompressInit();
void comnCompressUninit();
STATUS
compSetup(
GeneralMsg_s *genMsg,
RootBeast_s *uncompBeast,
RootBeast_s **compBeast, /* out */
Xaction_s *xaction);
STATUS
compCleanup(
GeneralMsg_s *genMsg,
RootBeast_s *uncompBeast,
RootBeast_s *compBeast,
BOOL recovery,
Xaction_s **xaction);
STATUS
decompSetup(
GeneralMsg_s *genMsg,
RootBeast_s *uncompBeast,
Xaction_s *xaction);
STATUS
decompCleanup(
GeneralMsg_s *genMsg,
RootBeast_s *uncompBeast,
RootBeast_s *compBeast,
BOOL recovery,
Xaction_s *xaction);
Buffer_s *
CM_fetchFileBlk(
GeneralMsg_s *genMsg,
RootBeast_s *beast,
Blknum_t blknum,
NINT mode,
Blknum_t *holeBlks); /* out */
void
updateBeastPurgeableBlksCnt(
GeneralMsg_s *genMsg,
NamedBeast_s *beast,
RootBeast_s *compBeast,
BOOL includeCompBeastInfo, /* Include compBeast's blks also (if any) */
Xaction_s *xaction);
STATUS setBeastCompAttr(
RootBeast_s *uncompBeast,
NINT desiredAttr,
Xaction_s *xaction,
BOOL commitChange);
void setVolCompStats(
RootBeast_s *uncompBeast,
RootBeast_s *compBeast,
Xaction_s *xaction,
BOOL addStats);
RootBeast_s *CM_LookupCompBeast(
GeneralMsg_s *genMsg,
RootBeast_s *beast,
CompressInfo_s *compInfo,
NINT latchType);
#endif /* _COMN_COMPRESS_H_ */