/* <vms/lib/vcadef.h>
 *
 *	LIB - volume cache block definitions		[not in Starlet]
 */
#ifndef _VCADEF_H
#define _VCADEF_H

/*
   VCA - Volume Cache Block.  This block contains the specialized caches for
   a disk volume; to wit, the file ID cache, the extent cache, and the quota
   file cache.	The file ID cache and extent cache are together in one block;
   the quota cache is located separately in another block.  Both are pointed
   to by the VCB.
 */
#define VCA$V_FIDC_VALID	0
#define VCA$V_EXTC_VALID	1
#define VCA$V_FIDC_FLUSH	2
#define VCA$V_EXTC_FLUSH	3
#define VCA$M_FIDC_VALID	(1<<VCA$V_FIDC_VALID)	/* 0x01 */
#define VCA$M_EXTC_VALID	(1<<VCA$V_EXTC_VALID)	/* 0x02 */
#define VCA$M_FIDC_FLUSH	(1<<VCA$V_FIDC_FLUSH)	/* 0x04 */
#define VCA$M_EXTC_FLUSH	(1<<VCA$V_EXTC_FLUSH)	/* 0x08 */
#ifndef NO_VMS_V6
#define VCA$C_QUEUE	16	/* offset of queue header */
#define VCA$K_LENGTH	24	/* length of block header */
#define VCA$C_LENGTH	24
#define VCA$S_VCADEF	24
#else
#define VCA$K_LENGTH	12	/* length of block header */
#define VCA$C_LENGTH	12
#define VCA$S_VCADEF	12
#endif
struct vcadef {
    unsigned long vca$l_fidcache;	/* pointer to file ID cache */
    unsigned long vca$l_extcache;	/* pointer to extent cache */
    unsigned short vca$w_size;		/* block size */
    unsigned char vca$b_type;		/* block type code */
    union {
	unsigned char vca$b_flags;	/* cache flags */
	struct {
	    unsigned vca$v_fidc_valid : 1; /* FID cache valid */
	    unsigned vca$v_extc_valid : 1; /* extent cache valid */
	    unsigned vca$v_fidc_flush : 1; /* FID cache to be flushed */
	    unsigned vca$v_extc_flush : 1; /* extent cache to be flushed */
	    unsigned		      : 4; /* padding */
	} vca$r_flags_bits;
    } vca$r_flags_overlay;
#ifndef NO_VMS_V6
    unsigned long vca$l_cache_space_used; /* padding to quad align SER_QFL */
    unsigned long vca$l_ser_qfl;	/* extent/FID cache */
    unsigned long vca$l_ser_qbl;	/* serialization queue header */
#endif
};
/*
   The file ID cache consists of the cache header, followed by a longword
   vector of file numbers, densely packed.
 */
#define VCA$S_VCADEF1	40
#define VCA$S_FIDCACB	28
struct vcadef1 {
    unsigned short vca$w_fidsize;	/* number of entries allocated */
    unsigned short vca$w_fidcount;	/* number of entries present */
    unsigned long vca$l_fidclkid;	/* FID cache lock id. */
    unsigned char vca$b_fidcacb[28];	/* FID cache blocking ACB */
    unsigned long vca$l_fidlist;	/* first entry in list */
};
/*
   The extent cache consists of the cache header, followed by a quadword
   vector of extents, densely packed.  Each quadword contains block count
   and starting LBN.
 */
#define VCA$S_VCADEF2	52
#define VCA$S_EXTCACB	28
#define VCA$S_EXTLIST	8
struct vcadef2 {
    unsigned short vca$w_extsize;	/* number of entries allocated */
    unsigned short vca$w_extcount;	/* number of entries present */
    unsigned long vca$l_exttotal;	/* total number of blocks contained in cache */
    unsigned short vca$w_extlimit;	/* limit of volume to be cached, in percent/10 */
    unsigned	: 16;			/* short fill; */
    unsigned long vca$l_extclkid;	/* EXT cache lock id. */
    unsigned char vca$b_extcacb[28];	/* extent cache blocking ACB. */
    unsigned long vca$q_extlist[2];	/* first entry in list */
};
#define VCA$S_VCADEF3	8
struct vcadef3 {
    unsigned long vca$l_extblocks;	/* number of blocks */
    unsigned long vca$l_extlbn;		/* starting LBN */
};
/*
   The quota cache consists of the cache header, followed by the cache
   entries.  Each cache entry is a block as defined below.
 */
#define VCA$V_CACHEVALID	0
#define VCA$V_CACHEFLUSH	1
#define VCA$M_CACHEVALID	(1<<VCA$V_CACHEVALID)	/* 0x01 */
#define VCA$M_CACHEFLUSH	(1<<VCA$V_CACHEFLUSH)	/* 0x02 */
#define VCA$S_VCADEF4	72
#define VCA$S_QUOACB	28
#define VCA$S_QUOFLUSHACB 28
struct vcadef4 {
    unsigned short vca$w_quosize;	/* number of entries allocated */
    unsigned short vca$w_quolru;	/* current LRU counter */
    unsigned long vca$l_quoclkid;	/* whole cache lock ID */
    unsigned	: 24;			/* char fill[3]; */
    union {
	char vca$b_quocflags;		/* cache flags */
	struct {
	    unsigned vca$v_cachevalid : 1; /* cache is valid */
	    unsigned vca$v_cacheflush : 1; /* cache is to be flushed */
	    unsigned		      : 6; /* padding */
	} vca$r_quocflags_bits;
    } vca$r_quocflags_overlay;
    unsigned char vca$b_quoacb[28];	/* ACB to deliver blocking AST */
    unsigned char vca$b_quoflushacb[28]; /* ACB to deliver cache flush AST */
    unsigned long vca$l_quolist;	/* start of entries */
};
#define VCA$V_QUOVALID	0
#define VCA$V_QUODIRTY	1
#define VCA$M_QUOVALID	(1<<VCA$V_QUOVALID)	/* 0x01 */
#define VCA$M_QUODIRTY	(1<<VCA$V_QUODIRTY)	/* 0x02 */
#define VCA$K_QUOLENGTH 28	/* length of quota cache entry */
#define VCA$C_QUOLENGTH 28
#define VCA$S_VCADEF5	28
#define VCA$S_QUOLOCK	24
#define VCA$S_QUORECNUM 3	/* size in bytes */
struct vcadef5 {
    union {
	unsigned char vca$b_quolock[24];	/* lock status block */
	unsigned short vca$w_quostatus;		/* $ENQ status */
	struct {
	    unsigned short vca$w_quoindex;	/* index in cache of this entry */
	    unsigned short vca$w_quolrux;	/* LRU index for entry */
	    unsigned long vca$l_quolkid;	/* lock ID of cache entry */
	    struct {
		unsigned vca$l_quorecnum : 24;	/* record number */
		union {
		    unsigned char vca$b_quoflags;	/* flags byte */
		    struct {
			unsigned vca$v_quovalid : 1;	/* valid entry is present */
			unsigned vca$v_quodirty : 1;	/* dirty flag */
			unsigned		: 6;	/* padding */
		    } vca$r_quoflags_bits;
		} vca$r_quoflags_overlay;
	    } vca$r_quorec_fields;
	    unsigned long vca$l_usage;		/* current usage */
	    unsigned long vca$l_permquota;	/* permanent quota */
	    unsigned long vca$l_overdraft;	/* overdraft limit */
	} vca$r_quolock_fields;
    } vca$r_quolock_overlay;
    unsigned long vca$l_quouic;			/* UIC */
};

#endif	/*_VCADEF_H*/
