1 /*             ----> DO NOT REMOVE THE FOLLOWING NOTICE <----
2  *
3  *                 Copyright (c) 2014-2015 Datalight, Inc.
4  *                     All Rights Reserved Worldwide.
5  *
6  *  This program is free software; you can redistribute it and/or modify
7  *  it under the terms of the GNU General Public License as published by
8  *  the Free Software Foundation; use version 2 of the License.
9  *
10  *  This program is distributed in the hope that it will be useful,
11  *  but "AS-IS," WITHOUT ANY WARRANTY; without even the implied warranty
12  *  of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  *  GNU General Public License for more details.
14  *
15  *  You should have received a copy of the GNU General Public License along
16  *  with this program; if not, write to the Free Software Foundation, Inc.,
17  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19 
20 /*  Businesses and individuals that for commercial or other reasons cannot
21  *  comply with the terms of the GPLv2 license may obtain a commercial license
22  *  before incorporating Reliance Edge into proprietary software for
23  *  distribution in any form.  Visit http://www.datalight.com/reliance-edge for
24  *  more information.
25  */
26 
27 /** @file
28  */
29 #ifndef REDCOREVOL_H
30 #define REDCOREVOL_H
31 
32 
33 /** @brief Per-volume run-time data specific to the core.
34  */
35 typedef struct
36 {
37     /** Whether this volume uses the inline imap (true) or external imap
38      *  (false).  Computed at initialization time based on the block count.
39      */
40     bool fImapInline;
41 
42     #if REDCONF_IMAP_EXTERNAL == 1
43 
44         /** First block number of the on-disk imap.  Valid only when fImapInline
45          *  is false.
46          */
47         uint32_t ulImapStartBN;
48 
49         /** The number of double-allocated imap nodes that make up the imap.
50          */
51         uint32_t ulImapNodeCount;
52     #endif
53 
54     /** Block number where the inode table starts.
55      */
56     uint32_t ulInodeTableStartBN;
57 
58     /** First block number that can be allocated.
59      */
60     uint32_t ulFirstAllocableBN;
61 
62     /** The two metaroot structures, committed and working state.
63      */
64     METAROOT aMR[ 2U ];
65 
66     /** The index of the current metaroot; must be 0 or 1.
67      */
68     uint8_t bCurMR;
69 
70     /** Whether the volume has been branched or not.
71      */
72     bool fBranched;
73 
74     /** The number of blocks which will become free after the next transaction.
75      */
76     uint32_t ulAlmostFreeBlocks;
77 
78     #if RESERVED_BLOCKS > 0U
79 
80         /** Whether to use the blocks reserved for operations that create free
81          *  space.
82          */
83         bool fUseReservedBlocks;
84     #endif
85 } COREVOLUME;
86 
87 /*  Pointer to the core volume currently being accessed; populated during
88  *  RedCoreVolSetCurrent().
89  */
90 extern COREVOLUME * CONST_IF_ONE_VOLUME gpRedCoreVol;
91 
92 /*  Pointer to the metaroot currently being accessed; populated during
93  *  RedCoreVolSetCurrent() and RedCoreVolTransact().
94  */
95 extern METAROOT * gpRedMR;
96 
97 
98 #endif /* ifndef REDCOREVOL_H */
99