Repository navigation
Conversation
Both the "proc4" and the "proc4ops" line carry one counter per operation,
in the order of the NFSPROC4_CLNT_* enum and of the nfs_opnum4 operation
numbers respectively. Two mistakes had crept into the client mapping:
- LAYOUTGET and GETDEVICEINFO were swapped, so both counters were
reported under the wrong operation. The enum has ordered LAYOUTGET
before GETDEVICEINFO since at least v4.0.
- The ten operations after CLONE were not mapped at all, so the counts
for COPY, OFFLOAD_CANCEL, LOOKUPP, LAYOUTERROR, COPY_NOTIFY and the
RFC 8276 xattr operations were dropped.
On the server side only the NFSv4.0 operations were mapped. Add the
NFSv4.1, NFSv4.2 and RFC 8276 xattr operations, and replace the special
case for the 39 counter line of v2.5.x kernels with the padding the
client parser already uses, so that kernels which emit fewer operations
than are mapped leave the remaining counters at zero.
Fixes prometheus#699
Signed-off-by: neoLsH <43921685+neoLsH@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #699.
How the two lines are laid out
Both lines carry one counter per operation, and the position of a counter is
fixed by the kernel, not by which operations happen to be implemented.
proc4in/proc/net/rpc/nfsis emitted bynet/sunrpc/stats.c: it printsthe operation count, then one counter per index of
vers->counts[]. For NFSv4that array is
nfs4_procedures[]infs/nfs/nfs4xdr.c, which is built withdesignated initializers
[NFSPROC4_CLNT_##proc] = {...}. So the counter atposition n of the line belongs to the operation whose
NFSPROC4_CLNT_*valueis n-1, gaps included.
include/linux/nfs4.hstates the contract:proc4opsin/proc/net/rpc/nfsdworks the same way fromfs/nfsd/stats.c:it prints
LAST_NFS4_OP + 1and then a counter for every operation number from0 to
LAST_NFS4_OP. Those are the stableenum nfs_opnum4numbers from theRFCs, so the server line is indexed by operation number rather than by an
append-only enum.
Two bugs in the client mapping
LAYOUTGET and GETDEVICEINFO were swapped. The parser read
GetDeviceInfo: v[45]andLayoutGet: v[46], but the enum has orderedNFSPROC4_CLNT_LAYOUTGETbeforeNFSPROC4_CLNT_GETDEVICEINFOsince at leastv4.0 — I checked v4.0, v4.9, v5.4, v6.12 and master.
ClientV4Statsinnfs.goalready declared the two fields in the correct order, so this looksunintended rather than a deliberate reading of some older kernel. Both counters
have been reported under the wrong operation on every kernel since v4.0.
The ten operations after CLONE were not mapped at all. COPY,
OFFLOAD_CANCEL, LOOKUPP, LAYOUTERROR, COPY_NOTIFY and the five RFC 8276 xattr
and READ_PLUS operations were parsed off the line and then dropped. The padding
threshold moves from 59 to 69 to match, which is what v6.12 emits.
Server side
Only the NFSv4.0 operations were mapped, plus
RELLOCKOWNERbehind avalues > 39special case. I added the NFSv4.1 operations (40–58), theNFSv4.2 operations (59–71) and the RFC 8276 xattr operations (72–75), and
replaced that special case with the same padding the client parser already
uses. Padding subsumes it: a 39-counter line from an nfs v2.5.x kernel now
leaves
RelLockOwnerand everything after it at zero instead of needing aseparate code path.
What I did not do
Linux master has inserted
NFSPROC4_CLNT_ZERO_RANGEat index 57, which shiftsLAYOUTSTATS, CLONE, COPY and the rest by one, and appended
NFSPROC4_CLNT_OFFLOAD_STATUS. That insertion breaks the append-only rule theenum documents, and no released kernel has it — ZERO_RANGE is absent from
v5.10, v5.15, v6.1, v6.6 and v6.12. I left it alone rather than guess: today's
parser is equally wrong on those slots for such a kernel, so nothing here
regresses, and telling the two layouts apart needs more information than the
counter count on the line. Worth a separate issue if a kernel ships it.
Verification
Two new tests pin the layout down positionally.
TestParseClientV4StatsOpOrderbuilds a 69-counter line where the counter for the operation with enum value
n is n+1, then asserts each field reads its own operation's value;
TestParseV4OpsOpOrderdoes the same for 76 server operations. Before the fixthe first one fails with
LayoutGet: got 46, want 45andGetDeviceInfo: got 45, want 46.I also ran three reverse controls to confirm the tests actually bite: reverting
the swap reproduces exactly those two failures; changing the server padding
threshold from
< 76to< 40panics withindex out of range [73] with length 73on theproc4ops 72fixture; and shiftingSeekfromv[70]tov[69]fails withSeek: got 69, want 70.One existing expectation changed: the
proc4 48case inTestNewNFSClientRPCStatsasserted the swapped values, so it encoded the bug.Whole-repo
go test ./...passes andgolangci-lint run ./nfs/...reports0 issues.