Statistics
| Branch: | Tag: | Revision:

root / htools / Ganeti / Block / Drbd / Types.hs @ 3c1915df

History | View | Annotate | Download (8.1 kB)

1
{-| DRBD Data Types
2

    
3
This module holds the definition of the data types describing the status of
4
DRBD.
5

    
6
-}
7
{-
8

    
9
Copyright (C) 2012 Google Inc.
10

    
11
This program is free software; you can redistribute it and/or modify
12
it under the terms of the GNU General Public License as published by
13
the Free Software Foundation; either version 2 of the License, or
14
(at your option) any later version.
15

    
16
This program is distributed in the hope that it will be useful, but
17
WITHOUT ANY WARRANTY; without even the implied warranty of
18
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19
General Public License for more details.
20

    
21
You should have received a copy of the GNU General Public License
22
along with this program; if not, write to the Free Software
23
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
24
02110-1301, USA.
25

    
26
-}
27
module Ganeti.Block.Drbd.Types
28
  ( DRBDStatus(..)
29
  , VersionInfo(..)
30
  , DeviceInfo(..)
31
  , ConnectionState(..)
32
  , LocalRemote(..)
33
  , Role(..)
34
  , DiskState(..)
35
  , PerformanceIndicators(..)
36
  , SyncStatus(..)
37
  , SizeUnit(..)
38
  , Time(..)
39
  , TimeUnit(..)
40
  , AdditionalInfo(..)
41
  ) where
42

    
43
--TODO: consider turning deviceInfos into an IntMap
44
-- | Data type contaning all the data about the status of DRBD.
45
data DRBDStatus =
46
  DRBDStatus
47
  { versionInfo :: VersionInfo  -- ^ Version information about DRBD
48
  , deviceInfos :: [DeviceInfo] -- ^ Per-minor information
49
  } deriving (Eq, Show)
50

    
51
-- | Data type describing the DRBD version.
52
data VersionInfo =
53
  VersionInfo
54
  { version    :: Maybe String -- ^ DRBD driver version
55
  , api        :: Maybe String -- ^ The api version
56
  , proto      :: Maybe String -- ^ The protocol version
57
  , srcversion :: Maybe String -- ^ The version of the source files
58
  , gitHash    :: Maybe String -- ^ Git hash of the source files
59
  , buildBy    :: Maybe String -- ^ Who built the binary (and,
60
                               -- optionally, when)
61
  } deriving (Eq, Show)
62

    
63
-- | Data type describing a device.
64
data DeviceInfo =
65
  UnconfiguredDevice Int -- ^ An DRBD minor marked as unconfigured
66
  | -- | A configured DRBD minor
67
    DeviceInfo
68
      { minorNumber :: Int -- ^ The minor index of the device
69
      , connectionState :: ConnectionState -- ^ State of the connection
70
      , resourceRoles :: LocalRemote Role -- ^ Roles of the resources
71
      , diskStates :: LocalRemote DiskState -- ^ Status of the disks
72
      , replicationProtocol :: Char -- ^ The replication protocol being used
73
      , ioFlags :: String -- ^ The input/output flags
74
      , performanceIndicators :: PerformanceIndicators -- ^ Performance indicators
75
      , syncStatus :: Maybe SyncStatus -- ^ The status of the syncronization of
76
                                     -- the disk (only if it is happening)
77
      , resync :: Maybe AdditionalInfo -- ^ Additional info by DRBD 8.0
78
      , actLog :: Maybe AdditionalInfo -- ^ Additional info by DRBD 8.0
79
      } deriving (Eq, Show)
80

    
81
-- | Data type describing the state of the connection.
82
data ConnectionState
83
  = StandAlone     -- ^  No network configuration available
84
  | Disconnecting  -- ^ Temporary state during disconnection
85
  | Unconnected    -- ^ Prior to a connection attempt
86
  | Timeout        -- ^ Following a timeout in the communication
87
  | BrokenPipe     -- ^ After the connection to the peer was lost
88
  | NetworkFailure -- ^ After the connection to the parner was lost
89
  | ProtocolError  -- ^ After the connection to the parner was lost
90
  | TearDown       -- ^ The peer is closing the connection
91
  | WFConnection   -- ^ Waiting for the peer to become visible
92
  | WFReportParams -- ^ Waiting for first packet from peer
93
  | Connected      -- ^ Connected, data mirroring active
94
  | StartingSyncS  -- ^ Source of a full sync started by admin
95
  | StartingSyncT  -- ^ Target of a full sync started by admin
96
  | WFBitMapS      -- ^ Source of a just starting partial sync
97
  | WFBitMapT      -- ^ Target of a just starting partial sync
98
  | WFSyncUUID     -- ^ Synchronization is about to begin
99
  | SyncSource     -- ^ Source of a running synchronization
100
  | SyncTarget     -- ^ Target of a running synchronization
101
  | PausedSyncS    -- ^ Source of a paused synchronization
102
  | PausedSyncT    -- ^ Target of a paused synchronization
103
  | VerifyS        -- ^ Source of an running verification
104
  | VerifyT        -- ^ Target of an running verification
105
  | Unconfigured   -- ^ The device is not configured
106
    deriving (Show, Eq)
107

    
108
-- | Algebraic data type describing something that has a local and a remote
109
-- value.
110
data LocalRemote a =
111
  LocalRemote
112
  { local  :: a -- ^ The local value
113
  , remote :: a -- ^ The remote value
114
  } deriving (Eq, Show)
115

    
116
-- | Data type describing.
117
data Role = Primary   -- ^ The device role is primary
118
          | Secondary -- ^ The device role is secondary
119
          | Unknown   -- ^ The device role is unknown
120
            deriving (Eq, Show)
121

    
122
-- | Data type describing disk states.
123
data DiskState
124
  = Diskless     -- ^ No local block device assigned to the DRBD driver
125
  | Attaching    -- ^ Reading meta data
126
  | Failed       -- ^ I/O failure
127
  | Negotiating  -- ^ "Attach" on an already-connected device
128
  | Inconsistent -- ^ The data is inconsistent between nodes.
129
  | Outdated     -- ^ Data consistent but outdated
130
  | DUnknown     -- ^ No network connection available
131
  | Consistent   -- ^ Consistent data, but without network connection
132
  | UpToDate     -- ^ Consistent, up-to-date. This is the normal state
133
    deriving (Eq, Show)
134

    
135
-- | Data type containing data about performance indicators.
136
data PerformanceIndicators = PerformanceIndicators
137
  { networkSend :: Int -- ^ KiB of data sent on the network
138
  , networkReceive :: Int -- ^ KiB of data received from the network
139
  , diskWrite :: Int -- ^ KiB of data written on local disk
140
  , diskRead :: Int -- ^ KiB of data read from local disk
141
  , activityLog :: Int -- ^ Number of updates of the activity log
142
  , bitMap :: Int -- ^ Number of updates to the bitmap area of the metadata
143
  , localCount :: Int -- ^ Number of open requests to te local I/O subsystem
144
  , pending :: Int -- ^ Num of requests sent to the partner but not yet answered
145
  , unacknowledged :: Int -- ^ Num of requests received by the partner but still
146
                        -- to be answered
147
  , applicationPending :: Int -- ^ Num of block I/O requests forwarded
148
                              -- to DRBD but that have not yet been
149
                              -- answered
150
  , epochs :: Maybe Int -- ^ Number of epoch objects
151
  , writeOrder :: Maybe Char -- ^ Currently used write ordering method
152
  , outOfSync :: Maybe Int -- ^ KiB of storage currently out of sync
153
  } deriving (Eq, Show)
154

    
155
-- | Data type containing data about the synchronization status of a device.
156
data SyncStatus =
157
  SyncStatus
158
  { percentage      :: Double    -- ^ Percentage of syncronized data
159
  , partialSyncSize :: Int       -- ^ Numerator of the fraction of synced data
160
  , totalSyncSize   :: Int       -- ^ Denominator of the fraction of
161
                                 -- synced data
162
  , syncUnit        :: SizeUnit  -- ^ Measurement unit of the previous
163
                                 -- fraction
164
  , timeToFinish    :: Time      -- ^ Expected time before finishing
165
                                 -- the syncronization
166
  , speed           :: Int       -- ^ Speed of the syncronization
167
  , want            :: Maybe Int -- ^ Want of the syncronization
168
  , speedSizeUnit   :: SizeUnit  -- ^ Size unit of the speed
169
  , speedTimeUnit   :: TimeUnit  -- ^ Time unit of the speed
170
  } deriving (Eq, Show)
171

    
172
-- | Data type describing a size unit for memory.
173
data SizeUnit = KiloByte | MegaByte deriving (Eq, Show)
174

    
175
-- | Data type describing a time (hh:mm:ss).
176
data Time = Time
177
  { hour :: Integer
178
  , min  :: Integer
179
  , sec  :: Integer
180
  } deriving (Eq, Show)
181

    
182
-- | Data type describing a time unit.
183
data TimeUnit = Second deriving (Eq, Show)
184

    
185
-- | Additional device-specific cache-like information produced by
186
-- drbd <= 8.0.
187
--
188
-- Internal debug information exported by old DRBD versions.
189
-- Undocumented both in DRBD and here.
190
data AdditionalInfo = AdditionalInfo
191
  { partialUsed :: Int
192
  , totalUsed   :: Int
193
  , hits        :: Int
194
  , misses      :: Int
195
  , starving    :: Int
196
  , dirty       :: Int
197
  , changed     :: Int
198
  } deriving (Eq, Show)