Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 18 additions & 13 deletions mountstats.go
Original file line number Diff line number Diff line change
Expand Up @@ -688,23 +688,28 @@ func parseNFSTransportStats(ss []string, statVersion string) (*NFSTransportStats

// NFS xprt over rdma
// And stat Version 1.1
//
// The order matches the columns printed by xprt_rdma_print_stats()
// in net/sunrpc/xprtrdma/transport.c, which differs from the field
// order of struct rpcrdma_stats. BcallCount is not printed by the
// kernel and is always zero.
ReadChunkCount: ns[13],
WriteChunkCount: ns[14],
ReplyChunkCount: ns[15],
TotalRdmaRequest: ns[16],
PullupCopyCount: ns[17],
HardwayRegisterCount: ns[18],
FailedMarshalCount: ns[19],
BadReplyCount: ns[20],
MrsRecovered: ns[21],
MrsOrphaned: ns[22],
MrsAllocated: ns[23],
EmptySendctxQ: ns[24],
TotalRdmaReply: ns[25],
FixupCopyCount: ns[26],
ReplyWaitsForSend: ns[27],
LocalInvNeeded: ns[28],
NomsgCallCount: ns[29],
TotalRdmaReply: ns[17],
PullupCopyCount: ns[18],
FixupCopyCount: ns[19],
HardwayRegisterCount: ns[20],
FailedMarshalCount: ns[21],
BadReplyCount: ns[22],
NomsgCallCount: ns[23],
MrsRecovered: ns[24],
MrsOrphaned: ns[25],
MrsAllocated: ns[26],
LocalInvNeeded: ns[27],
EmptySendctxQ: ns[28],
ReplyWaitsForSend: ns[29],
BcallCount: ns[30],
}, nil
}
67 changes: 57 additions & 10 deletions mountstats_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -462,19 +462,19 @@ func TestMountStats(t *testing.T) {
WriteChunkCount: 1226637531,
ReplyChunkCount: 2673889,
TotalRdmaRequest: 135120843409861,
PullupCopyCount: 135119397156505,
HardwayRegisterCount: 266368832,
FailedMarshalCount: 75716996,
TotalRdmaReply: 135119397156505,
PullupCopyCount: 266368832,
FixupCopyCount: 75716996,
HardwayRegisterCount: 0,
FailedMarshalCount: 7853,
BadReplyCount: 0,
MrsRecovered: 7853,
NomsgCallCount: 0,
MrsRecovered: 0,
MrsOrphaned: 0,
MrsAllocated: 0,
MrsAllocated: 119328,
LocalInvNeeded: 1336431717,
EmptySendctxQ: 0,
TotalRdmaReply: 0,
FixupCopyCount: 119328,
ReplyWaitsForSend: 1336431717,
LocalInvNeeded: 0,
NomsgCallCount: 96,
ReplyWaitsForSend: 96,
BcallCount: 0,
},
},
Expand Down Expand Up @@ -657,3 +657,50 @@ func TestMountStatsExtendedRDMAStats(t *testing.T) {
t.Errorf("failed to parse mount stats with extended RDMA statistics: %v", err)
}
}

func TestParseNFSTransportStatsRDMAFieldOrder(t *testing.T) {
// Each value is unique so that a field read from the wrong column is
// obvious. The column order follows xprt_rdma_print_stats() in
// net/sunrpc/xprtrdma/transport.c (Linux >= 4.19).
line := "rdma 0 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27"

got, err := parseNFSTransportStats(strings.Fields(line), statVersion11)
if err != nil {
t.Fatalf("failed to parse RDMA transport stats: %v", err)
}

want := &NFSTransportStats{
Protocol: "rdma",
Port: 0,
Bind: 2,
Connect: 3,
ConnectIdleTime: 4,
IdleTimeSeconds: 5,
Sends: 6,
Receives: 7,
BadTransactionIDs: 8,
CumulativeActiveRequests: 9,
CumulativeBacklog: 10,
ReadChunkCount: 11,
WriteChunkCount: 12,
ReplyChunkCount: 13,
TotalRdmaRequest: 14,
TotalRdmaReply: 15,
PullupCopyCount: 16,
FixupCopyCount: 17,
HardwayRegisterCount: 18,
FailedMarshalCount: 19,
BadReplyCount: 20,
NomsgCallCount: 21,
MrsRecovered: 22,
MrsOrphaned: 23,
MrsAllocated: 24,
LocalInvNeeded: 25,
EmptySendctxQ: 26,
ReplyWaitsForSend: 27,
}

if diff := cmp.Diff(want, got); diff != "" {
t.Fatalf("unexpected RDMA transport stats (-want +got):\n%s", diff)
}
}