Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

lockd: add some client-side tracepoints

Signed-off-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>

authored by

Jeff Layton and committed by
Chuck Lever
2f90e18f e59fb674

+131 -2
+4 -2
fs/lockd/Makefile
··· 3 3 # Makefile for the linux lock manager stuff 4 4 # 5 5 6 + ccflags-y += -I$(src) # needed for trace events 7 + 6 8 obj-$(CONFIG_LOCKD) += lockd.o 7 9 8 - lockd-objs-y := clntlock.o clntproc.o clntxdr.o host.o svc.o svclock.o \ 9 - svcshare.o svcproc.o svcsubs.o mon.o xdr.o 10 + lockd-objs-y += clntlock.o clntproc.o clntxdr.o host.o svc.o svclock.o \ 11 + svcshare.o svcproc.o svcsubs.o mon.o trace.o xdr.o 10 12 lockd-objs-$(CONFIG_LOCKD_V4) += clnt4xdr.o xdr4.o svc4proc.o 11 13 lockd-objs-$(CONFIG_PROC_FS) += procfs.o 12 14 lockd-objs := $(lockd-objs-y)
+4
fs/lockd/clntlock.c
··· 14 14 #include <linux/nfs_fs.h> 15 15 #include <linux/sunrpc/addr.h> 16 16 #include <linux/sunrpc/svc.h> 17 + #include <linux/sunrpc/svc_xprt.h> 17 18 #include <linux/lockd/lockd.h> 18 19 #include <linux/kthread.h> 20 + 21 + #include "trace.h" 19 22 20 23 #define NLMDBG_FACILITY NLMDBG_CLIENT 21 24 ··· 189 186 res = nlm_granted; 190 187 } 191 188 spin_unlock(&nlm_blocked_lock); 189 + trace_nlmclnt_grant(lock, addr, svc_addr_len(addr), res); 192 190 return res; 193 191 } 194 192
+14
fs/lockd/clntproc.c
··· 20 20 #include <linux/sunrpc/svc.h> 21 21 #include <linux/lockd/lockd.h> 22 22 23 + #include "trace.h" 24 + 23 25 #define NLMDBG_FACILITY NLMDBG_CLIENT 24 26 #define NLMCLNT_GRACE_WAIT (5*HZ) 25 27 #define NLMCLNT_POLL_TIMEOUT (30*HZ) ··· 453 451 status = nlm_stat_to_errno(req->a_res.status); 454 452 } 455 453 out: 454 + trace_nlmclnt_test(&req->a_args.lock, 455 + (const struct sockaddr *)&req->a_host->h_addr, 456 + req->a_host->h_addrlen, req->a_res.status); 456 457 nlmclnt_release_call(req); 457 458 return status; 458 459 } ··· 610 605 else 611 606 status = nlm_stat_to_errno(resp->status); 612 607 out: 608 + trace_nlmclnt_lock(&req->a_args.lock, 609 + (const struct sockaddr *)&req->a_host->h_addr, 610 + req->a_host->h_addrlen, req->a_res.status); 613 611 nlmclnt_release_call(req); 614 612 return status; 615 613 out_unlock: 616 614 /* Fatal error: ensure that we remove the lock altogether */ 615 + trace_nlmclnt_lock(&req->a_args.lock, 616 + (const struct sockaddr *)&req->a_host->h_addr, 617 + req->a_host->h_addrlen, req->a_res.status); 617 618 dprintk("lockd: lock attempt ended in fatal error.\n" 618 619 " Attempting to unlock.\n"); 619 620 fl_type = fl->fl_type; ··· 715 704 /* What to do now? I'm out of my depth... */ 716 705 status = -ENOLCK; 717 706 out: 707 + trace_nlmclnt_unlock(&req->a_args.lock, 708 + (const struct sockaddr *)&req->a_host->h_addr, 709 + req->a_host->h_addrlen, req->a_res.status); 718 710 nlmclnt_release_call(req); 719 711 return status; 720 712 }
+3
fs/lockd/trace.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + #define CREATE_TRACE_POINTS 3 + #include "trace.h"
+106
fs/lockd/trace.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + #undef TRACE_SYSTEM 3 + #define TRACE_SYSTEM lockd 4 + 5 + #if !defined(_TRACE_LOCKD_H) || defined(TRACE_HEADER_MULTI_READ) 6 + #define _TRACE_LOCKD_H 7 + 8 + #include <linux/tracepoint.h> 9 + #include <linux/crc32.h> 10 + #include <linux/nfs.h> 11 + #include <linux/lockd/lockd.h> 12 + 13 + #ifdef CONFIG_LOCKD_V4 14 + #define NLM_STATUS_LIST \ 15 + nlm_status_code(LCK_GRANTED) \ 16 + nlm_status_code(LCK_DENIED) \ 17 + nlm_status_code(LCK_DENIED_NOLOCKS) \ 18 + nlm_status_code(LCK_BLOCKED) \ 19 + nlm_status_code(LCK_DENIED_GRACE_PERIOD) \ 20 + nlm_status_code(DEADLCK) \ 21 + nlm_status_code(ROFS) \ 22 + nlm_status_code(STALE_FH) \ 23 + nlm_status_code(FBIG) \ 24 + nlm_status_code_end(FAILED) 25 + #else 26 + #define NLM_STATUS_LIST \ 27 + nlm_status_code(LCK_GRANTED) \ 28 + nlm_status_code(LCK_DENIED) \ 29 + nlm_status_code(LCK_DENIED_NOLOCKS) \ 30 + nlm_status_code(LCK_BLOCKED) \ 31 + nlm_status_code_end(LCK_DENIED_GRACE_PERIOD) 32 + #endif 33 + 34 + #undef nlm_status_code 35 + #undef nlm_status_code_end 36 + #define nlm_status_code(x) TRACE_DEFINE_ENUM(NLM_##x); 37 + #define nlm_status_code_end(x) TRACE_DEFINE_ENUM(NLM_##x); 38 + 39 + NLM_STATUS_LIST 40 + 41 + #undef nlm_status_code 42 + #undef nlm_status_code_end 43 + #define nlm_status_code(x) { NLM_##x, #x }, 44 + #define nlm_status_code_end(x) { NLM_##x, #x } 45 + 46 + #define show_nlm_status(x) __print_symbolic(x, NLM_STATUS_LIST) 47 + 48 + DECLARE_EVENT_CLASS(nlmclnt_lock_event, 49 + TP_PROTO( 50 + const struct nlm_lock *lock, 51 + const struct sockaddr *addr, 52 + unsigned int addrlen, 53 + __be32 status 54 + ), 55 + 56 + TP_ARGS(lock, addr, addrlen, status), 57 + 58 + TP_STRUCT__entry( 59 + __field(u32, oh) 60 + __field(u32, svid) 61 + __field(u32, fh) 62 + __field(unsigned long, status) 63 + __field(u64, start) 64 + __field(u64, len) 65 + __sockaddr(addr, addrlen) 66 + ), 67 + 68 + TP_fast_assign( 69 + __entry->oh = ~crc32_le(0xffffffff, lock->oh.data, lock->oh.len); 70 + __entry->svid = lock->svid; 71 + __entry->fh = nfs_fhandle_hash(&lock->fh); 72 + __entry->start = lock->lock_start; 73 + __entry->len = lock->lock_len; 74 + __entry->status = be32_to_cpu(status); 75 + __assign_sockaddr(addr, addr, addrlen); 76 + ), 77 + 78 + TP_printk( 79 + "addr=%pISpc oh=0x%08x svid=0x%08x fh=0x%08x start=%llu len=%llu status=%s", 80 + __get_sockaddr(addr), __entry->oh, __entry->svid, 81 + __entry->fh, __entry->start, __entry->len, 82 + show_nlm_status(__entry->status) 83 + ) 84 + ); 85 + 86 + #define DEFINE_NLMCLNT_EVENT(name) \ 87 + DEFINE_EVENT(nlmclnt_lock_event, name, \ 88 + TP_PROTO( \ 89 + const struct nlm_lock *lock, \ 90 + const struct sockaddr *addr, \ 91 + unsigned int addrlen, \ 92 + __be32 status \ 93 + ), \ 94 + TP_ARGS(lock, addr, addrlen, status)) 95 + 96 + DEFINE_NLMCLNT_EVENT(nlmclnt_test); 97 + DEFINE_NLMCLNT_EVENT(nlmclnt_lock); 98 + DEFINE_NLMCLNT_EVENT(nlmclnt_unlock); 99 + DEFINE_NLMCLNT_EVENT(nlmclnt_grant); 100 + 101 + #endif /* _TRACE_LOCKD_H */ 102 + 103 + #undef TRACE_INCLUDE_PATH 104 + #define TRACE_INCLUDE_PATH . 105 + #define TRACE_INCLUDE_FILE trace 106 + #include <trace/define_trace.h>