mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2026-08-09 06:14:34 +02:00
The NLM GRANTED procedure allows servers to notify clients when a previously blocked lock request has been granted, completing the asynchronous lock request flow. This patch converts the NLMv3 GRANTED procedure to use xdrgen-generated XDR functions. The conversion replaces the legacy decoder with the xdrgen functions nlm_svc_decode_nlm_testargs and nlm_svc_encode_nlm_res generated from the NLM version 3 protocol specification. The procedure handler accesses xdrgen types through a wrapper structure that bridges between generated code and the legacy lockd_lock representation still used by the core lockd logic. A new helper function nlm_lock_to_lockd_lock() converts an xdrgen nlm_lock into the legacy lockd_lock format. The helper complements the existing nlm3svc_lookup_host() and nlm3svc_lookup_file() functions used throughout this series. Setting pc_argzero to zero is safe because the generated decoder fills the argp->xdrgen subfields before the procedure runs, so the zeroing memset performed by the dispatch layer is not needed. The helper populates each field of the wrapper's lock member that any downstream consumer reads: fh, oh, svid, and the file_lock byte range. Because pc_argzero no longer scrubs the rq_argp slot, the shared nlmclnt_lock_event tracepoint class is updated to source its byte-range fields from lock->fl.fl_start and lock->fl.fl_end, which both the client and server populate unconditionally; the old lock_start and lock_len fields are no longer required by the trace. Reviewed-by: Jeff Layton <jlayton@kernel.org> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
108 lines
2.8 KiB
C
108 lines
2.8 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#undef TRACE_SYSTEM
|
|
#define TRACE_SYSTEM lockd
|
|
|
|
#if !defined(_TRACE_LOCKD_H) || defined(TRACE_HEADER_MULTI_READ)
|
|
#define _TRACE_LOCKD_H
|
|
|
|
#include <linux/tracepoint.h>
|
|
#include <linux/crc32.h>
|
|
#include <linux/nfs.h>
|
|
|
|
#include "lockd.h"
|
|
|
|
#ifdef CONFIG_LOCKD_V4
|
|
#define NLM_STATUS_LIST \
|
|
nlm_status_code(LCK_GRANTED) \
|
|
nlm_status_code(LCK_DENIED) \
|
|
nlm_status_code(LCK_DENIED_NOLOCKS) \
|
|
nlm_status_code(LCK_BLOCKED) \
|
|
nlm_status_code(LCK_DENIED_GRACE_PERIOD) \
|
|
nlm_status_code(DEADLCK) \
|
|
nlm_status_code(ROFS) \
|
|
nlm_status_code(STALE_FH) \
|
|
nlm_status_code(FBIG) \
|
|
nlm_status_code_end(FAILED)
|
|
#else
|
|
#define NLM_STATUS_LIST \
|
|
nlm_status_code(LCK_GRANTED) \
|
|
nlm_status_code(LCK_DENIED) \
|
|
nlm_status_code(LCK_DENIED_NOLOCKS) \
|
|
nlm_status_code(LCK_BLOCKED) \
|
|
nlm_status_code_end(LCK_DENIED_GRACE_PERIOD)
|
|
#endif
|
|
|
|
#undef nlm_status_code
|
|
#undef nlm_status_code_end
|
|
#define nlm_status_code(x) TRACE_DEFINE_ENUM(NLM_##x);
|
|
#define nlm_status_code_end(x) TRACE_DEFINE_ENUM(NLM_##x);
|
|
|
|
NLM_STATUS_LIST
|
|
|
|
#undef nlm_status_code
|
|
#undef nlm_status_code_end
|
|
#define nlm_status_code(x) { NLM_##x, #x },
|
|
#define nlm_status_code_end(x) { NLM_##x, #x }
|
|
|
|
#define show_nlm_status(x) __print_symbolic(x, NLM_STATUS_LIST)
|
|
|
|
DECLARE_EVENT_CLASS(nlmclnt_lock_event,
|
|
TP_PROTO(
|
|
const struct lockd_lock *lock,
|
|
const struct sockaddr *addr,
|
|
unsigned int addrlen,
|
|
__be32 status
|
|
),
|
|
|
|
TP_ARGS(lock, addr, addrlen, status),
|
|
|
|
TP_STRUCT__entry(
|
|
__field(u32, oh)
|
|
__field(u32, svid)
|
|
__field(u32, fh)
|
|
__field(unsigned long, status)
|
|
__field(loff_t, start)
|
|
__field(loff_t, end)
|
|
__sockaddr(addr, addrlen)
|
|
),
|
|
|
|
TP_fast_assign(
|
|
__entry->oh = ~crc32_le(0xffffffff, lock->oh.data, lock->oh.len);
|
|
__entry->svid = lock->svid;
|
|
__entry->fh = nfs_fhandle_hash(&lock->fh);
|
|
__entry->start = lock->fl.fl_start;
|
|
__entry->end = lock->fl.fl_end;
|
|
__entry->status = be32_to_cpu(status);
|
|
__assign_sockaddr(addr, addr, addrlen);
|
|
),
|
|
|
|
TP_printk(
|
|
"addr=%pISpc oh=0x%08x svid=0x%08x fh=0x%08x start=%lld end=%lld status=%s",
|
|
__get_sockaddr(addr), __entry->oh, __entry->svid,
|
|
__entry->fh, __entry->start, __entry->end,
|
|
show_nlm_status(__entry->status)
|
|
)
|
|
);
|
|
|
|
#define DEFINE_NLMCLNT_EVENT(name) \
|
|
DEFINE_EVENT(nlmclnt_lock_event, name, \
|
|
TP_PROTO( \
|
|
const struct lockd_lock *lock, \
|
|
const struct sockaddr *addr, \
|
|
unsigned int addrlen, \
|
|
__be32 status \
|
|
), \
|
|
TP_ARGS(lock, addr, addrlen, status))
|
|
|
|
DEFINE_NLMCLNT_EVENT(nlmclnt_test);
|
|
DEFINE_NLMCLNT_EVENT(nlmclnt_lock);
|
|
DEFINE_NLMCLNT_EVENT(nlmclnt_unlock);
|
|
DEFINE_NLMCLNT_EVENT(nlmclnt_grant);
|
|
|
|
#endif /* _TRACE_LOCKD_H */
|
|
|
|
#undef TRACE_INCLUDE_PATH
|
|
#define TRACE_INCLUDE_PATH .
|
|
#define TRACE_INCLUDE_FILE trace
|
|
#include <trace/define_trace.h>
|