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 +#include #include #include #include #include +#include #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