Skip to content

Commit 2085b8f

Browse files
authored
bugfix: Allow multiple xprt fields for NFS stats (#619)
Allow parsing multiple `xprt` fields present in the same NFS transport stats data. Fixes: #450 Signed-off-by: Pranshu Srivastava <[email protected]>
1 parent 68fb3df commit 2085b8f

File tree

2 files changed

+118
-106
lines changed

2 files changed

+118
-106
lines changed

mountstats.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ type MountStatsNFS struct {
8888
// Statistics broken down by filesystem operation.
8989
Operations []NFSOperationStats
9090
// Statistics about the NFS RPC transport.
91-
Transport NFSTransportStats
91+
Transport []NFSTransportStats
9292
}
9393

9494
// mountStats implements MountStats.
@@ -432,7 +432,7 @@ func parseMountStatsNFS(s *bufio.Scanner, statVersion string) (*MountStatsNFS, e
432432
return nil, err
433433
}
434434

435-
stats.Transport = *tstats
435+
stats.Transport = append(stats.Transport, *tstats)
436436
}
437437

438438
// When encountering "per-operation statistics", we must break this

mountstats_test.go

Lines changed: 116 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -116,21 +116,23 @@ func TestMountStats(t *testing.T) {
116116
Type: "nfs",
117117
Stats: &MountStatsNFS{
118118
StatVersion: "1.0",
119-
Transport: NFSTransportStats{
120-
Protocol: "tcp",
121-
Port: 1,
122-
Bind: 2,
123-
Connect: 3,
124-
ConnectIdleTime: 4,
125-
IdleTimeSeconds: 5,
126-
Sends: 6,
127-
Receives: 7,
128-
BadTransactionIDs: 8,
129-
CumulativeActiveRequests: 9,
130-
CumulativeBacklog: 10,
131-
MaximumRPCSlotsUsed: 0, // these three are not
132-
CumulativeSendingQueue: 0, // present in statvers=1.0
133-
CumulativePendingQueue: 0, //
119+
Transport: []NFSTransportStats{
120+
{
121+
Protocol: "tcp",
122+
Port: 1,
123+
Bind: 2,
124+
Connect: 3,
125+
ConnectIdleTime: 4,
126+
IdleTimeSeconds: 5,
127+
Sends: 6,
128+
Receives: 7,
129+
BadTransactionIDs: 8,
130+
CumulativeActiveRequests: 9,
131+
CumulativeBacklog: 10,
132+
MaximumRPCSlotsUsed: 0, // these three are not
133+
CumulativeSendingQueue: 0, // present in statvers=1.0
134+
CumulativePendingQueue: 0, //
135+
},
134136
},
135137
},
136138
}},
@@ -144,21 +146,23 @@ func TestMountStats(t *testing.T) {
144146
Type: "nfs",
145147
Stats: &MountStatsNFS{
146148
StatVersion: "1.0",
147-
Transport: NFSTransportStats{
148-
Protocol: "udp",
149-
Port: 1,
150-
Bind: 2,
151-
Connect: 0,
152-
ConnectIdleTime: 0,
153-
IdleTimeSeconds: 0,
154-
Sends: 3,
155-
Receives: 4,
156-
BadTransactionIDs: 5,
157-
CumulativeActiveRequests: 6,
158-
CumulativeBacklog: 7,
159-
MaximumRPCSlotsUsed: 0, // these three are not
160-
CumulativeSendingQueue: 0, // present in statvers=1.0
161-
CumulativePendingQueue: 0, //
149+
Transport: []NFSTransportStats{
150+
{
151+
Protocol: "udp",
152+
Port: 1,
153+
Bind: 2,
154+
Connect: 0,
155+
ConnectIdleTime: 0,
156+
IdleTimeSeconds: 0,
157+
Sends: 3,
158+
Receives: 4,
159+
BadTransactionIDs: 5,
160+
CumulativeActiveRequests: 6,
161+
CumulativeBacklog: 7,
162+
MaximumRPCSlotsUsed: 0, // these three are not
163+
CumulativeSendingQueue: 0, // present in statvers=1.0
164+
CumulativePendingQueue: 0, //
165+
},
162166
},
163167
},
164168
}},
@@ -172,21 +176,23 @@ func TestMountStats(t *testing.T) {
172176
Type: "nfs",
173177
Stats: &MountStatsNFS{
174178
StatVersion: "1.1",
175-
Transport: NFSTransportStats{
176-
Protocol: "tcp",
177-
Port: 1,
178-
Bind: 2,
179-
Connect: 3,
180-
ConnectIdleTime: 4,
181-
IdleTimeSeconds: 5,
182-
Sends: 6,
183-
Receives: 7,
184-
BadTransactionIDs: 8,
185-
CumulativeActiveRequests: 9,
186-
CumulativeBacklog: 10,
187-
MaximumRPCSlotsUsed: 11,
188-
CumulativeSendingQueue: 12,
189-
CumulativePendingQueue: 13,
179+
Transport: []NFSTransportStats{
180+
{
181+
Protocol: "tcp",
182+
Port: 1,
183+
Bind: 2,
184+
Connect: 3,
185+
ConnectIdleTime: 4,
186+
IdleTimeSeconds: 5,
187+
Sends: 6,
188+
Receives: 7,
189+
BadTransactionIDs: 8,
190+
CumulativeActiveRequests: 9,
191+
CumulativeBacklog: 10,
192+
MaximumRPCSlotsUsed: 11,
193+
CumulativeSendingQueue: 12,
194+
CumulativePendingQueue: 13,
195+
},
190196
},
191197
},
192198
}},
@@ -200,21 +206,23 @@ func TestMountStats(t *testing.T) {
200206
Type: "nfs",
201207
Stats: &MountStatsNFS{
202208
StatVersion: "1.1",
203-
Transport: NFSTransportStats{
204-
Protocol: "udp",
205-
Port: 1,
206-
Bind: 2,
207-
Connect: 0, // these three are not
208-
ConnectIdleTime: 0, // present for UDP
209-
IdleTimeSeconds: 0, //
210-
Sends: 3,
211-
Receives: 4,
212-
BadTransactionIDs: 5,
213-
CumulativeActiveRequests: 6,
214-
CumulativeBacklog: 7,
215-
MaximumRPCSlotsUsed: 8,
216-
CumulativeSendingQueue: 9,
217-
CumulativePendingQueue: 10,
209+
Transport: []NFSTransportStats{
210+
{
211+
Protocol: "udp",
212+
Port: 1,
213+
Bind: 2,
214+
Connect: 0, // these three are not
215+
ConnectIdleTime: 0, // present for UDP
216+
IdleTimeSeconds: 0, //
217+
Sends: 3,
218+
Receives: 4,
219+
BadTransactionIDs: 5,
220+
CumulativeActiveRequests: 6,
221+
CumulativeBacklog: 7,
222+
MaximumRPCSlotsUsed: 8,
223+
CumulativeSendingQueue: 9,
224+
CumulativePendingQueue: 10,
225+
},
218226
},
219227
},
220228
}},
@@ -354,17 +362,19 @@ func TestMountStats(t *testing.T) {
354362
CumulativeTotalRequestMilliseconds: 1953587717,
355363
},
356364
},
357-
Transport: NFSTransportStats{
358-
Protocol: "tcp",
359-
Port: 832,
360-
Connect: 1,
361-
IdleTimeSeconds: 11,
362-
Sends: 6428,
363-
Receives: 6428,
364-
CumulativeActiveRequests: 12154,
365-
MaximumRPCSlotsUsed: 24,
366-
CumulativeSendingQueue: 26,
367-
CumulativePendingQueue: 5726,
365+
Transport: []NFSTransportStats{
366+
{
367+
Protocol: "tcp",
368+
Port: 832,
369+
Connect: 1,
370+
IdleTimeSeconds: 11,
371+
Sends: 6428,
372+
Receives: 6428,
373+
CumulativeActiveRequests: 12154,
374+
MaximumRPCSlotsUsed: 24,
375+
CumulativeSendingQueue: 26,
376+
CumulativePendingQueue: 5726,
377+
},
368378
},
369379
},
370380
},
@@ -428,39 +438,41 @@ func TestMountStats(t *testing.T) {
428438
Errors: 0,
429439
},
430440
},
431-
Transport: NFSTransportStats{
432-
Protocol: "rdma",
433-
Port: 0,
434-
Bind: 0,
435-
Connect: 5808,
436-
ConnectIdleTime: 62,
437-
IdleTimeSeconds: 0,
438-
Sends: 494490723,
439-
Receives: 494490687,
440-
BadTransactionIDs: 36,
441-
CumulativeActiveRequests: 10032963746,
442-
CumulativeBacklog: 1282789,
443-
MaximumRPCSlotsUsed: 0,
444-
CumulativeSendingQueue: 0,
445-
CumulativePendingQueue: 0,
446-
ReadChunkCount: 107150285,
447-
WriteChunkCount: 1226637531,
448-
ReplyChunkCount: 2673889,
449-
TotalRdmaRequest: 135120843409861,
450-
PullupCopyCount: 135119397156505,
451-
HardwayRegisterCount: 266368832,
452-
FailedMarshalCount: 75716996,
453-
BadReplyCount: 0,
454-
MrsRecovered: 7853,
455-
MrsOrphaned: 0,
456-
MrsAllocated: 0,
457-
EmptySendctxQ: 0,
458-
TotalRdmaReply: 0,
459-
FixupCopyCount: 119328,
460-
ReplyWaitsForSend: 1336431717,
461-
LocalInvNeeded: 0,
462-
NomsgCallCount: 96,
463-
BcallCount: 0,
441+
Transport: []NFSTransportStats{
442+
{
443+
Protocol: "rdma",
444+
Port: 0,
445+
Bind: 0,
446+
Connect: 5808,
447+
ConnectIdleTime: 62,
448+
IdleTimeSeconds: 0,
449+
Sends: 494490723,
450+
Receives: 494490687,
451+
BadTransactionIDs: 36,
452+
CumulativeActiveRequests: 10032963746,
453+
CumulativeBacklog: 1282789,
454+
MaximumRPCSlotsUsed: 0,
455+
CumulativeSendingQueue: 0,
456+
CumulativePendingQueue: 0,
457+
ReadChunkCount: 107150285,
458+
WriteChunkCount: 1226637531,
459+
ReplyChunkCount: 2673889,
460+
TotalRdmaRequest: 135120843409861,
461+
PullupCopyCount: 135119397156505,
462+
HardwayRegisterCount: 266368832,
463+
FailedMarshalCount: 75716996,
464+
BadReplyCount: 0,
465+
MrsRecovered: 7853,
466+
MrsOrphaned: 0,
467+
MrsAllocated: 0,
468+
EmptySendctxQ: 0,
469+
TotalRdmaReply: 0,
470+
FixupCopyCount: 119328,
471+
ReplyWaitsForSend: 1336431717,
472+
LocalInvNeeded: 0,
473+
NomsgCallCount: 96,
474+
BcallCount: 0,
475+
},
464476
},
465477
},
466478
}},

0 commit comments

Comments
 (0)