Skip to contentSkip to conversation

fuse: add fuse_request_sent tracepoint

PATCH New Amir Goldstein 1 participant 1 message Jun 5

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 fuse: add fuse_request_sent tracepoint

This new tracepoint complements fuse_request_send (enqueue) and fuse_request_end (completion). It fires after the request has been successfully copied to the daemon's buffer, just before the daemon can start to process it.

fuse_request_sent does not fire if the copy of the request fails. It also does not fire for NOTIFY_REPLY, which fires the _end tracepoint at the end of copy.

This is needed for tools tracking the in-flight state of user initiated fuse requests.

---

Miklos,

Reminder, this is base on Linus master, not on fuse for-next, because it is a candidate for backport to 6.18 and if you apply it at base of for-next, then the new tracepoint needs to be adjusted in commit "fuse: change req->fm to req->chan".

Thanks,
Amir.

Changes from v2 [2]:
- Reword commit message (Joanne)

Changes from v1 [1]:
- Rename tracepoint s/_recv/_sent
- Fire in ioruing
- Fire consistently along with setting FR_SENT, which...
- Avoids firing when request is not sent sue to failure

[1] https://lore.kernel.org/fuse-devel/[email protected]/
[2] https://lore.kernel.org/fuse-devel/[email protected]/

 fs/fuse/dev.c        |  1 +
 fs/fuse/dev_uring.c  |  6 ++++--
 fs/fuse/fuse_trace.h | 22 ++++++++++++++++++++++
 3 files changed, 27 insertions(+), 2 deletions(-)
fs/fuse/dev.c +1 -0
index 5dda7080f4a90..2ad9aedc6237b 100644
@@ -1525,6 +1525,7 @@ static ssize_t fuse_dev_do_read(struct fuse_dev *fud, struct file *file,
 	list_move_tail(&req->list, &fpq->processing[hash]);
 	__fuse_get_request(req);
 	set_bit(FR_SENT, &req->flags);
+	trace_fuse_request_sent(req);
 	spin_unlock(&fpq->lock);
 	/* matches barrier in request_wait_answer() */
 	smp_mb__after_atomic();
fs/fuse/dev_uring.c +4 -2
index 7b9822e8837bc..50f98e9a23a10 100644
@@ -702,10 +702,12 @@ static int fuse_uring_prepare_send(struct fuse_ring_ent *ent,
 	int err;
 
 	err = fuse_uring_copy_to_ring(ent, req);
-	if (!err)
+	if (!err) {
 		set_bit(FR_SENT, &req->flags);
-	else
+		trace_fuse_request_sent(req);
+	} else {
 		fuse_uring_req_end(ent, req, err);
+	}
 
 	return err;
 }
fs/fuse/fuse_trace.h +22 -0
index bbe9ddd8c7169..c912253996b71 100644
@@ -101,6 +101,28 @@ TRACE_EVENT(fuse_request_send,
 		  __print_symbolic(__entry->opcode, OPCODES), __entry->len)
 );
 
+TRACE_EVENT(fuse_request_sent,
+	TP_PROTO(const struct fuse_req *req),
+
+	TP_ARGS(req),
+
+	TP_STRUCT__entry(
+		__field(dev_t,			connection)
+		__field(uint64_t,		unique)
+		__field(enum fuse_opcode,	opcode)
+	),
+
+	TP_fast_assign(
+		__entry->connection	=	req->fm->fc->dev;
+		__entry->unique		=	req->in.h.unique;
+		__entry->opcode		=	req->in.h.opcode;
+	),
+
+	TP_printk("connection %u req %llu opcode %u (%s)",
+		  __entry->connection, __entry->unique, __entry->opcode,
+		  __print_symbolic(__entry->opcode, OPCODES))
+);
+
 TRACE_EVENT(fuse_request_end,
 	TP_PROTO(const struct fuse_req *req),
 
Signature · 1 line
2.54.0