chiark / gitweb /
debugging for thing that crashed
[innduct.git] / storage / cnfs / cnfs-private.h
1 /*  $Id: cnfs-private.h 5975 2002-12-11 04:51:43Z rra $
2 **
3 **  CNFS disk/file mode header file.
4 */
5
6 #ifndef CNFS_PRIVATE_H
7 #define CNFS_PRIVATE_H 1
8
9 #include <sys/types.h>
10 #include <unistd.h>
11
12 #define _PATH_CYCBUFFCONFIG     "cycbuff.conf"
13
14 /* Page boundary on which to mmap() the CNFS article usage header.  Should be
15    a multiple of the pagesize for all the architectures you expect might need
16    access to your CNFS buffer.  If you don't expect to share your buffer
17    across several platforms, you can use 'pagesize' here. */
18 #define CNFS_HDR_PAGESIZE       16384
19
20 #define CNFS_MAGICV1    "Cycbuff"       /* CNFSMASIZ bytes */
21 #define CNFS_MAGICV2    "CBuf1"         /* CNFSMASIZ bytes */
22 #define CNFS_MAGICV3    "CBuf3"         /* CNFSMASIZ bytes */
23 #define CNFS_BLOCKSIZE  512             /* Unit block size we'll work with */
24
25 /* Amount of data stored at beginning of CYCBUFF before the bitfield */
26 #define CNFS_BEFOREBITF (1 * CNFS_BLOCKSIZE)
27
28 struct metacycbuff;             /* Definition comes below */
29
30 #define CNFSMAXCYCBUFFNAME      8
31 #define CNFSMASIZ       8
32 #define CNFSNASIZ       16      /* Effective size is 9, not 16 */
33 #define CNFSPASIZ       64
34 #define CNFSLASIZ       16      /* Match length of ASCII hex off_t
35                                    representation */
36
37 typedef struct _CYCBUFF {
38   char          name[CNFSNASIZ];/* Symbolic name */
39   char          path[CNFSPASIZ];/* Path to file */
40   off_t         len;            /* Length of writable area, in bytes */
41   off_t         free;           /* Offset (relative to byte 0 of file) to first
42                                    freely available byte */
43   time_t        updated;        /* Time of last update to header */
44   int           fd;             /* file descriptor for this cycbuff */
45   uint32_t      cyclenum;       /* Number of current cycle, 0 = invalid */
46   int           magicver;       /* Magic version number */
47   void *        bitfield;       /* Bitfield for article in use */
48   off_t         minartoffset;   /* The minimum offset allowed for article
49                                    storage */
50   bool          needflush;      /* true if CYCBUFFEXTERN is needed to be
51                                    flushed */
52   struct _CYCBUFF       *next;
53   bool          currentbuff;    /* true if this cycbuff is currently used */
54   char          metaname[CNFSNASIZ];/* Symbolic name of meta */
55   int           order;          /* Order in meta, start from 1 not 0 */
56 } CYCBUFF;
57
58 /*
59 ** A structure suitable for thwapping onto disk in a quasi-portable way.
60 ** We assume that sizeof(CYCBUFFEXTERN) < CNFS_BLOCKSIZE.
61 */
62 typedef struct {
63     char        magic[CNFSMASIZ];
64     char        name[CNFSNASIZ];
65     char        path[CNFSPASIZ];
66     char        lena[CNFSLASIZ];        /* ASCII version of len */
67     char        freea[CNFSLASIZ];       /* ASCII version of free */
68     char        updateda[CNFSLASIZ];    /* ASCII version of updated */
69     char        cyclenuma[CNFSLASIZ];   /* ASCII version of cyclenum */
70     char        metaname[CNFSNASIZ];
71     char        orderinmeta[CNFSLASIZ];
72     char        currentbuff[CNFSMASIZ];
73 } CYCBUFFEXTERN;
74
75 #define METACYCBUFF_UPDATE      25
76 #define REFRESH_INTERVAL        30
77
78 typedef enum {INTERLEAVE, SEQUENTIAL} METAMODE;
79
80 typedef struct metacycbuff {
81   char          *name;          /* Symbolic name of the pool */
82   int           count;          /* Number of files/devs in this pool */
83   CYCBUFF       **members;      /* Member cycbuffs */
84   int           memb_next;      /* Index to next member to write onto */
85   unsigned long write_count;    /* Number of writes since last header flush */
86   struct metacycbuff    *next;
87   METAMODE      metamode;
88 } METACYCBUFF;
89
90 typedef struct _CNFSEXPIRERULES {
91   STORAGECLASS          class;
92   METACYCBUFF           *dest;
93   struct _CNFSEXPIRERULES       *next;
94 } CNFSEXPIRERULES;
95
96 typedef struct {
97   long          size;           /* Size of the article */
98   time_t        arrived;        /* This is the time when article arrived */
99   STORAGECLASS  class;          /* storage class */
100 } CNFSARTHEADER;
101
102 /* uncomment below for old cnfs spool */
103 /* #ifdef OLD_CNFS */
104 typedef struct {
105   long      zottf;      /* This should always be 0x01234*/
106   long      size;       /* Size of the article */
107   char      m_id[64];   /* We'll only store up to 63 bytes of the
108                                Message-ID, that should be good enough */
109 } oldCNFSARTHEADER;
110
111 #endif /* !CNFS_PRIVATE_H */