]> git.apps.os.sepia.ceph.com Git - ceph-client.git/commitdiff
debugfs: fixups
authorAlex Markuze <amarkuze@redhat.com>
Tue, 18 Mar 2025 15:57:39 +0000 (15:57 +0000)
committerAlex Markuze <amarkuze@redhat.com>
Tue, 18 Mar 2025 15:57:39 +0000 (15:57 +0000)
fs/ceph/debugfs.c

index 8ae3a7b545599f1a254fd4ca19072ae71d6d4a97..7b576fd382f05e9618b82b17b0241360c51aa3c1 100644 (file)
@@ -9,6 +9,8 @@
 #include <linux/seq_file.h>
 #include <linux/math64.h>
 #include <linux/ktime.h>
+#include <linux/cgroup.h>
+#include <linux/cgroup-defs.h>
 
 #include <linux/ceph/libceph.h>
 #include <linux/ceph/ceph_san_logger.h>
@@ -405,32 +407,43 @@ static int ceph_san_tls_show(struct seq_file *s, void *p)
        return 0;
 }
 
+static int print_task_cgroup(struct task_struct *task, char *cgroup_path, size_t size)
+{
+    struct cgroup_subsys_state *css;
+    if (!task || !task->cgroups)
+        return 0;
+
+    css = task->cgroups->subsys[0];
+    if (css) {
+        cgroup_path_from_kernfs_id(css->cgroup->kn->id, cgroup_path, size);
+    }
+    return 1;
+}
+
 static int ceph_san_contexts_show(struct seq_file *s, void *p)
 {
-       struct ceph_san_tls_ctx *ctx;
-       unsigned long flags;
+    struct ceph_san_tls_ctx *ctx;
+    unsigned long flags;
+    char cgroup_path[256];
 
-       /* Lock the logger to safely traverse the contexts list */
-       spin_lock_irqsave(&g_logger.lock, flags);
+    /* Lock the logger to safely traverse the contexts list */
+    spin_lock_irqsave(&g_logger.lock, flags);
 
-       seq_puts(s, "Active TLS Contexts:\n");
-       seq_puts(s, "PID      Command          Buffer Size\n");
-       seq_puts(s, "----------------------------------------\n");
+    seq_puts(s, "Active TLS Contexts:\n");
+    seq_puts(s, "PID      Command          Buffer Size\n");
+    seq_puts(s, "----------------------------------------\n");
 
-       list_for_each_entry(ctx, &g_logger.contexts, list) {
-               unsigned int buffer_size = ctx->pf.head - ctx->pf.tail;
-               if (ctx->pf.head < ctx->pf.tail) {
-                       buffer_size = CEPHSAN_PAGEFRAG_SIZE - ctx->pf.tail + ctx->pf.head;
-               }
+    list_for_each_entry(ctx, &g_logger.contexts, list) {
+        int rc = print_task_cgroup(ctx->task, cgroup_path, sizeof(cgroup_path));
 
-               seq_printf(s, "%-8d %-15s %u bytes\n",
-                                 ctx->pid,
-                                 ctx->comm,
-                                 buffer_size);
-       }
+        seq_printf(s, "%-8d %-15s : %s\n",
+                  ctx->pid,
+                  ctx->comm,
+                  rc ? cgroup_path : "N/A");
+    }
 
-       spin_unlock_irqrestore(&g_logger.lock, flags);
-       return 0;
+    spin_unlock_irqrestore(&g_logger.lock, flags);
+    return 0;
 }
 
 DEFINE_SHOW_ATTRIBUTE(mdsmap);