aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoanne Koong <joannelkoong@gmail.com>2025-02-21 13:24:39 -0800
committerBernd Schubert <bernd@bsbernd.com>2025-04-02 11:03:26 +0200
commit11fde2346885683202eace0302ae4dc39869bfec (patch)
tree18837244e2e53cc16feb933b886afa408b162a44
parenteabe4b62d1ca945eaa65054cee5b0cd0b7583459 (diff)
downloadlibfuse-11fde2346885683202eace0302ae4dc39869bfec.tar.gz
fuse_lowlevel: add tracepoints for request receiving, processing, and replying
Add user statically-defined tracepoints for request lifecycle. Verified by: [machine]$ readelf -n /home/libfuse/build/lib/libfuse3.so | grep -A 1000 '.note.stapsdt' Displaying notes found in: .note.stapsdt Owner Data size Description stapsdt 0x00000035 NT_STAPSDT (SystemTap probe descriptors) Provider: libfuse Name: request_receive Location: 0x0000000000016360, Base: 0x00000000000002fc, Semaphore: 0x0000000000000000 Arguments: -4@%edi stapsdt 0x00000055 NT_STAPSDT (SystemTap probe descriptors) Provider: libfuse Name: request_reply Location: 0x0000000000017c0f, Base: 0x00000000000002fc, Semaphore: 0x0000000000000000 Arguments: 8@8(%r12) 4@(%r12) -4@4(%r12) -4@%r13d stapsdt 0x0000003e NT_STAPSDT (SystemTap probe descriptors) Provider: libfuse Name: request_process Location: 0x000000000001acf7, Base: 0x00000000000002fc, Semaphore: 0x0000000000000000 Arguments: 4@%r8d 4@%edx Signed-off-by: Joanne Koong <joannelkoong@gmail.com>
-rw-r--r--lib/fuse_lowlevel.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/fuse_lowlevel.c b/lib/fuse_lowlevel.c
index 17bc816..a5d9e0c 100644
--- a/lib/fuse_lowlevel.c
+++ b/lib/fuse_lowlevel.c
@@ -17,6 +17,7 @@
#include "fuse_opt.h"
#include "fuse_misc.h"
#include "mount_util.h"
+#include "usdt.h"
#include "util.h"
#include <stdint.h>
@@ -60,6 +61,23 @@ static __attribute__((constructor)) void fuse_ll_init_pagesize(void)
pagesize = getpagesize();
}
+/* tracepoints */
+static void trace_request_receive(int err)
+{
+ USDT(libfuse, request_receive, err);
+}
+
+static void trace_request_process(unsigned int opcode, unsigned int unique)
+{
+ USDT(libfuse, request_process, opcode, unique);
+}
+
+static void trace_request_reply(uint64_t unique, unsigned int len,
+ int error, int reply_err)
+{
+ USDT(libfuse, request_reply, unique, len, error, reply_err);
+}
+
static void convert_stat(const struct stat *stbuf, struct fuse_attr *attr)
{
attr->ino = stbuf->st_ino;
@@ -207,6 +225,7 @@ static int fuse_send_msg(struct fuse_session *se, struct fuse_chan *ch,
res = writev(ch ? ch->fd : se->fd, iov, count);
int err = errno;
+ trace_request_reply(out->unique, out->len, out->error, err);
if (res == -1) {
/* ENOENT means the operation was interrupted */
@@ -2809,6 +2828,8 @@ void fuse_session_process_buf_internal(struct fuse_session *se,
in = buf->mem;
}
+ trace_request_process(in->opcode, in->unique);
+
if (se->debug) {
fuse_log(FUSE_LOG_DEBUG,
"unique: %llu, opcode: %s (%i), nodeid: %llu, insize: %zu, pid: %u\n",
@@ -3067,6 +3088,7 @@ pipe_retry:
bufsize, 0);
}
err = errno;
+ trace_request_receive(err);
if (fuse_session_exited(se))
return 0;
@@ -3171,6 +3193,7 @@ restart:
res = read(ch ? ch->fd : se->fd, buf->mem, bufsize);
}
err = errno;
+ trace_request_receive(err);
if (fuse_session_exited(se))
return 0;