summaryrefslogtreecommitdiff
path: root/btt/devs.c
diff options
context:
space:
mode:
authorAlan D. Brunelle <Alan.Brunelle@hp.com>2007-04-14 08:05:06 +0200
committerJens Axboe <jens.axboe@oracle.com>2007-04-14 08:05:06 +0200
commit6904079488cd3063d171021c8954f955f4236849 (patch)
tree161035c6d78fba22a6acc21cb59d5d019022d5ae /btt/devs.c
parentc8b0b334cc1028ad8aa5407667233747af96a942 (diff)
downloadblktrace-6904079488cd3063d171021c8954f955f4236849.tar.gz
blktrace-6904079488cd3063d171021c8954f955f4236849.tar.bz2
Combine all outstanding patches into one /big patch/
o Added seek absolute option -- allows one to specify whether they want seek distances to be calculated based upon nearness to previous IO or from start to start. o Added block number dumping o Updated btt documentation for above. o Significant clean up of memory used and files opened. All allocated memory and opened files are cleaned up prior to normal program exit. o Fixed problem where Q & M traces were not being freed properly. o Fixed problem where bilink structures were not being freed properly. o Fixed omission -- output combined seeks in addition to read and write seeks. Signed-off-by: Alan D. Brunelle <Alan.Brunelle@hp.com> Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Diffstat (limited to 'btt/devs.c')
-rw-r--r--btt/devs.c46
1 files changed, 45 insertions, 1 deletions
diff --git a/btt/devs.c b/btt/devs.c
index 4aca9dd..9eece81 100644
--- a/btt/devs.c
+++ b/btt/devs.c
@@ -25,6 +25,33 @@
#define DEV_HASH(dev) ((MAJOR(dev) ^ MINOR(dev)) & (N_DEV_HASH - 1))
struct list_head dev_heads[N_DEV_HASH];
+static inline void *dip_rb_mkhds(void)
+{
+ size_t len = N_IOP_TYPES * sizeof(struct rb_root);
+ return memset(malloc(len), 0, len);
+}
+
+static void __destroy(struct rb_node *n)
+{
+ if (n) {
+ struct io *iop = rb_entry(n, struct io, rb_node);
+
+ __destroy(n->rb_left);
+ __destroy(n->rb_right);
+ io_release(iop);
+ }
+}
+
+static void __destroy_heads(struct rb_root *roots)
+{
+ int i;
+
+ for (i = 0; i < N_IOP_TYPES; i++)
+ __destroy(roots[i].rb_node);
+
+ free(roots);
+}
+
#if defined(DEBUG)
void __dump_rb_node(struct rb_node *n)
{
@@ -95,6 +122,22 @@ struct d_info *__dip_find(__u32 device)
return NULL;
}
+void dip_exit(void)
+{
+ struct d_info *dip;
+ struct list_head *p, *q;
+
+ list_for_each_safe(p, q, &all_devs) {
+ dip = list_entry(p, struct d_info, all_head);
+
+ __destroy_heads(dip->heads);
+ region_exit(&dip->regions);
+ seeki_exit(dip->seek_handle);
+ bno_dump_exit(dip->bno_dump_handle);
+ free(dip);
+ }
+}
+
struct d_info *dip_add(__u32 device, struct io *iop)
{
struct d_info *dip = __dip_find(device);
@@ -103,11 +146,12 @@ struct d_info *dip_add(__u32 device, struct io *iop)
dip = malloc(sizeof(struct d_info));
memset(dip, 0, sizeof(*dip));
dip->heads = dip_rb_mkhds();
- init_region(&dip->regions);
+ region_init(&dip->regions);
dip->device = device;
dip->last_q = (__u64)-1;
dip->map = dev_map_find(device);
dip->seek_handle = seeki_init(device);
+ dip->bno_dump_handle = bno_dump_init(device);
latency_init(dip);
list_add_tail(&dip->hash_head, &dev_heads[DEV_HASH(device)]);
list_add_tail(&dip->all_head, &all_devs);