Skip to content

Commit 97dc339

Browse files
committed
feat(mdstat): recognize reshape status
1 parent 54b2b56 commit 97dc339

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

Diff for: mdstat.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -123,13 +123,16 @@ func parseMDStat(mdStatData []byte) ([]MDStat, error) {
123123
finish := float64(0)
124124
pct := float64(0)
125125
recovering := strings.Contains(lines[syncLineIdx], "recovery")
126+
reshaping := strings.Contains(lines[syncLineIdx], "reshape")
126127
resyncing := strings.Contains(lines[syncLineIdx], "resync")
127128
checking := strings.Contains(lines[syncLineIdx], "check")
128129

129130
// Append recovery and resyncing state info.
130-
if recovering || resyncing || checking {
131+
if recovering || resyncing || checking || reshaping {
131132
if recovering {
132133
state = "recovering"
134+
} else if reshaping {
135+
state = "reshaping"
133136
} else if checking {
134137
state = "checking"
135138
} else {

Diff for: mdstat_test.go

+15
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,21 @@ func TestFS_MDStat(t *testing.T) {
283283
BlocksSyncedFinishTime: 0.2,
284284
BlocksSyncedSpeed: 114176,
285285
Devices: []string{"sda3", "sdb3"}},
286+
"md42": {
287+
Name: "md42",
288+
ActivityState: "reshaping",
289+
DisksActive: 2,
290+
DisksTotal: 3,
291+
DisksFailed: 0,
292+
DisksDown: 1,
293+
DisksSpare: 1,
294+
BlocksTotal: 1953381440,
295+
BlocksSynced: 1096879076,
296+
BlocksToBeSynced: 1953381440,
297+
BlocksSyncedPct: 56.1,
298+
BlocksSyncedFinishTime: 1868.1,
299+
BlocksSyncedSpeed: 7640,
300+
Devices: []string{"sda1", "sdd1", "sde1"}},
286301
}
287302

288303
if want, have := len(refs), len(mdStats); want != have {

Diff for: testdata/fixtures.ttar

+6-1
Original file line numberDiff line numberDiff line change
@@ -2253,7 +2253,7 @@ Lines: 1
22532253
Mode: 444
22542254
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
22552255
Path: fixtures/proc/mdstat
2256-
Lines: 60
2256+
Lines: 65
22572257
Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] [raid10]
22582258

22592259
md3 : active raid6 sda1[8] sdh1[7] sdg1[6] sdf1[5] sde1[11] sdd1[3] sdc1[10] sdb1[9] sdd1[10](S) sdd2[11](S)
@@ -2313,6 +2313,11 @@ md120 : active linear sda1[1] sdb1[0]
23132313
md101 : active (read-only) raid0 sdb[2] sdd[1] sdc[0]
23142314
322560 blocks super 1.2 512k chunks
23152315

2316+
md42 : active raid5 sda1[3](S) sdd1[0] sde1[1]
2317+
1953381440 blocks super 1.2 level 5, 64k chunk, algorithm 2 [3/2] [UU_]
2318+
[===========>.........] reshape = 56.1% (1096879076/1953381440) finish=1868.1min speed=7640K/sec
2319+
bitmap: 4/15 pages [16KB], 65536KB chunk
2320+
23162321
unused devices: <none>
23172322
Mode: 644
23182323
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

0 commit comments

Comments
 (0)