fs: dlm: add plock dev tracepoints
authorAlexander Aring <aahringo@redhat.com>
Tue, 1 Aug 2023 18:09:42 +0000 (14:09 -0400)
committerDavid Teigland <teigland@redhat.com>
Thu, 10 Aug 2023 15:33:03 +0000 (10:33 -0500)
I currently debug nfs plock handling and introduce those two tracepoints
for getting more information about what is happening there if the user
space reads plock operations from kernel and writing the result back.

Signed-off-by: Alexander Aring <aahringo@redhat.com>
Signed-off-by: David Teigland <teigland@redhat.com>
fs/dlm/plock.c
include/trace/events/dlm.h

index 5c2cc8d940efc9faa2abd4606e95490f0a31baa9..00e1d802a81cb71c33af93033c66b17e578a94c5 100644 (file)
@@ -11,6 +11,8 @@
 #include <linux/dlm_plock.h>
 #include <linux/slab.h>
 
+#include <trace/events/dlm.h>
+
 #include "dlm_internal.h"
 #include "lockspace.h"
 
@@ -509,6 +511,8 @@ static ssize_t dev_read(struct file *file, char __user *u, size_t count,
        if (!op)
                return -EAGAIN;
 
+       trace_dlm_plock_read(&info);
+
        /* there is no need to get a reply from userspace for unlocks
           that were generated by the vfs cleaning up for a close
           (the process did not make an unlock call). */
@@ -536,6 +540,8 @@ static ssize_t dev_write(struct file *file, const char __user *u, size_t count,
        if (copy_from_user(&info, u, sizeof(info)))
                return -EFAULT;
 
+       trace_dlm_plock_write(&info);
+
        if (check_version(&info))
                return -EINVAL;
 
index 2b09574e12430856e07371a716e883284861a148..c1a146f9fc911b6ec044bb9e5efeb7e2395bbc2f 100644 (file)
@@ -7,6 +7,7 @@
 
 #include <linux/dlm.h>
 #include <linux/dlmconstants.h>
+#include <uapi/linux/dlm_plock.h>
 #include <linux/tracepoint.h>
 
 #include "../../../fs/dlm/dlm_internal.h"
@@ -585,6 +586,56 @@ TRACE_EVENT(dlm_recv_message,
 
 );
 
+DECLARE_EVENT_CLASS(dlm_plock_template,
+
+       TP_PROTO(const struct dlm_plock_info *info),
+
+       TP_ARGS(info),
+
+       TP_STRUCT__entry(
+               __field(uint8_t, optype)
+               __field(uint8_t, ex)
+               __field(uint8_t, wait)
+               __field(uint8_t, flags)
+               __field(uint32_t, pid)
+               __field(int32_t, nodeid)
+               __field(int32_t, rv)
+               __field(uint32_t, fsid)
+               __field(uint64_t, number)
+               __field(uint64_t, start)
+               __field(uint64_t, end)
+               __field(uint64_t, owner)
+       ),
+
+       TP_fast_assign(
+               __entry->optype = info->optype;
+               __entry->ex = info->ex;
+               __entry->wait = info->wait;
+               __entry->flags = info->flags;
+               __entry->pid = info->pid;
+               __entry->nodeid = info->nodeid;
+               __entry->rv = info->rv;
+               __entry->fsid = info->fsid;
+               __entry->number = info->number;
+               __entry->start = info->start;
+               __entry->end = info->end;
+               __entry->owner = info->owner;
+       ),
+
+       TP_printk("fsid=%u number=%llx owner=%llx optype=%d ex=%d wait=%d flags=%x pid=%u nodeid=%d rv=%d start=%llx end=%llx",
+                 __entry->fsid, __entry->number, __entry->owner,
+                 __entry->optype, __entry->ex, __entry->wait,
+                 __entry->flags, __entry->pid, __entry->nodeid,
+                 __entry->rv, __entry->start, __entry->end)
+
+);
+
+DEFINE_EVENT(dlm_plock_template, dlm_plock_read,
+            TP_PROTO(const struct dlm_plock_info *info), TP_ARGS(info));
+
+DEFINE_EVENT(dlm_plock_template, dlm_plock_write,
+            TP_PROTO(const struct dlm_plock_info *info), TP_ARGS(info));
+
 TRACE_EVENT(dlm_send,
 
        TP_PROTO(int nodeid, int ret),