summaryrefslogtreecommitdiff
path: root/debian/patches/introspection0007-ext2fs-annotate-objects-managed-by-libports.patch
blob: 0ff099deb14c189805bbd9aa887cc7f17385aa5d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
From 5dd8bcc1e5f76499b5b4c5274f88d1989c6de7ce Mon Sep 17 00:00:00 2001
From: Justus Winter <4winter@informatik.uni-hamburg.de>
Date: Wed, 21 May 2014 18:39:38 +0200
Subject: [PATCH hurd 7/9] ext2fs: annotate objects managed by libports

Install a specialized version of libpagers format_debug_info which
prints more detailed information, like the nodes inode number for file
pager objects.  Also label both pager buckets.

* ext2fs/pager-create.c (format_debug_info): New function.
(create_disk_pager): Install our own format_debug_info function.
Label both pager buckets.
---
 ext2fs/pager.c | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)

diff --git a/ext2fs/pager.c b/ext2fs/pager.c
index 3e080f8..b737ba7 100644
--- a/ext2fs/pager.c
+++ b/ext2fs/pager.c
@@ -19,10 +19,12 @@
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
 
 #include <unistd.h>
+#include <stdio.h>
 #include <string.h>
 #include <errno.h>
 #include <error.h>
 #include <hurd/store.h>
+#include <inttypes.h>
 #include "ext2fs.h"
 
 /* XXX */
@@ -1196,6 +1198,38 @@ disk_cache_block_is_ref (block_t block)
   return ref;
 }
 
+/* Provide a human-readable description of the given pager object.  */
+static error_t
+format_debug_info (const void *port, char *buffer, size_t size)
+{
+  const struct pager *pager = port;
+  const struct port_info *pi = port;
+
+  if (pager->upi->type == FILE_DATA)
+    {
+      struct references references;
+      refcounts_references (&pager->upi->node->refcounts, &references);
+      snprintf (buffer, size,
+		"bucket: %s, class: %s, "
+		"node{inode: %"PRIu64", hard: %u, weak: %u}",
+		pi->bucket->label,
+		pi->class->label,
+		pager->upi->node->cache_id,
+		references.hard,
+		references.weak);
+    }
+  else
+    snprintf (buffer, size,
+	      "bucket: %s, class: %s, may_cache: %d",
+	      pi->bucket->label,
+	      pi->class->label,
+	      /* XXX I have no idea what might be interesting to print
+		 here, but it is straight forward to add stuff.	 */
+	      pager->may_cache);
+
+  return 0;
+}
+
 /* Create the disk pager, and the file pager.  */
 void
 create_disk_pager (void)
@@ -1204,12 +1238,15 @@ create_disk_pager (void)
   pthread_attr_t attr;
   error_t err;
 
+  ports_label_class (_pager_class, "_pager_class", format_debug_info);
+
   /* The disk pager.  */
   struct user_pager_info *upi = malloc (sizeof (struct user_pager_info));
   if (!upi)
     ext2_panic ("can't create disk pager: %s", strerror (errno));
   upi->type = DISK;
   disk_pager_bucket = ports_create_bucket ();
+  ports_label_bucket (disk_pager_bucket, "disk_pager_bucket");
   get_hypermetadata ();
   disk_cache_blocks = DISK_CACHE_BLOCKS;
   disk_cache_size = disk_cache_blocks << log2_block_size;
@@ -1219,6 +1256,7 @@ create_disk_pager (void)
 
   /* The file pager.  */
   file_pager_bucket = ports_create_bucket ();
+  ports_label_bucket (file_pager_bucket, "file_pager_bucket");
 
   /* Start libpagers worker threads.  */
   err = pager_start_workers (file_pager_bucket, &file_pager_requests);
-- 
2.1.4