@@ -23,10 +23,16 @@ from bcchelper import BCCHelper # noqa: E402
2323# BPF txg program
2424bpf_text = '#include "' + base_dir + 'lib/bcc_helper.h' + '"\n'
2525bpf_text += """
26+
27+ struct bpf_wq {
28+ __u64 __opaque[2];
29+ } __attribute__((aligned(8)));
30+
2631#include < uapi /linux/ptrace.h>
2732#include < linux /bpf_common.h>
2833#include < uapi /linux/bpf.h>
2934#include < linux /sunrpc/svc.h>
35+ #include < linux /nfs4.h>
3036
3137
3238// nfsd4 definitions from fs/nfsd/xdr4.h
@@ -35,45 +41,43 @@ bpf_text += """
3541#define bool int
3642
3743typedef struct {
38- u32 cl_boot;
39- u32 cl_id;
44+ u32 cl_boot;
45+ u32 cl_id;
4046} clientid_t;
4147
4248typedef struct {
43- clientid_t so_clid;
44- u32 so_id;
49+ clientid_t so_clid;
50+ u32 so_id;
4551} stateid_opaque_t;
4652
4753typedef struct {
48- u32 si_generation;
49- stateid_opaque_t si_opaque;
54+ u32 si_generation;
55+ stateid_opaque_t si_opaque;
5056} stateid_t;
5157
52- typedef struct {
53- stateid_t rd_stateid; /* request */
54- u64 rd_offset; /* request */
55- u32 rd_length; /* request */
56- int rd_vlen;
57- struct file *rd_filp;
58- bool rd_tmp_file;
59- void *rd_rqstp; /* response */
60- void *rd_fhp; /* response */
61- } nfsd4_read;
62-
63- #define NFS4_VERIFIER_SIZE 8
64- typedef struct { char data[NFS4_VERIFIER_SIZE]; } nfs4_verifier;
65-
66- typedef struct {
67- stateid_t wr_stateid; /* request */
68- u64 wr_offset; /* request */
69- u32 wr_stable_how; /* request */
70- u32 wr_buflen; /* request */
71- struct kvec wr_head;
72- struct page ** wr_pagelist; /* request */
73- u32 wr_bytes_written; /* response */
74- u32 wr_how_written; /* response */
75- nfs4_verifier wr_verifier; /* response */
76- } nfsd4_write;
58+ struct nfsd4_read {
59+ stateid_t rd_stateid; /* request */
60+ u64 rd_offset; /* request */
61+ u32 rd_length; /* request */
62+ int rd_vlen;
63+ struct nfsd_file *rd_nf;
64+
65+ struct svc_rqst *rd_rqstp; /* response */
66+ struct svc_fh *rd_fhp; /* response */
67+ u32 rd_eof; /* response */
68+ };
69+
70+ struct nfsd4_write {
71+ stateid_t wr_stateid; /* request */
72+ u64 wr_offset; /* request */
73+ u32 wr_stable_how; /* request */
74+ u32 wr_buflen; /* request */
75+ struct xdr_buf wr_payload; /* request */
76+
77+ u32 wr_bytes_written; /* response */
78+ u32 wr_how_written; /* response */
79+ nfs4_verifier wr_verifier; /* response */
80+ };
7781
7882// Definitions for this script
7983#define READ_STR "read"
@@ -151,7 +155,7 @@ int nfsd3_write_start(struct pt_regs *ctx, struct svc_rqst *rqstp, void *fhp,
151155}
152156
153157int nfsd4_read_start(struct pt_regs *ctx, struct svc_rqst *rqstp, void *cstate,
154- nfsd4_read *nfs_read)
158+ struct nfsd4_read *nfs_read)
155159{
156160 u32 pid = bpf_get_current_pid_tgid();
157161 nfs_data_t data = {};
@@ -166,7 +170,7 @@ int nfsd4_read_start(struct pt_regs *ctx, struct svc_rqst *rqstp, void *cstate,
166170}
167171
168172int nfsd4_write_start(struct pt_regs *ctx, struct svc_rqst *rqstp,
169- void *cstate, nfsd4_write *nfs_write)
173+ void *cstate, struct nfsd4_write *nfs_write)
170174{
171175 u32 pid = bpf_get_current_pid_tgid();
172176 nfs_data_t data = {};
@@ -286,7 +290,7 @@ int nfsd4_write_done(struct pt_regs *ctx)
286290 u64 ts = bpf_ktime_get_ns();
287291 u32 pid = bpf_get_current_pid_tgid();
288292 nfs_data_t *data = nfs_base_data.lookup(&pid);
289- nfsd4_write nfs_write;
293+ struct nfsd4_write nfs_write;
290294
291295 if (data == 0) {
292296 return 0; // missed issue
0 commit comments