summaryrefslogtreecommitdiff
path: root/btt/devs.c
diff options
context:
space:
mode:
Diffstat (limited to 'btt/devs.c')
-rw-r--r--btt/devs.c63
1 files changed, 28 insertions, 35 deletions
diff --git a/btt/devs.c b/btt/devs.c
index 2f1c6c0..2e3d360 100644
--- a/btt/devs.c
+++ b/btt/devs.c
@@ -104,20 +104,13 @@ void dip_exit(void)
}
}
-static inline char *mkhandle(char *str, __u32 device, char *post)
+static inline FILE *open_pit(struct d_info *dip)
{
- int mjr = device >> MINORBITS;
- int mnr = device & ((1 << MINORBITS) - 1);
+ FILE *fp;
+ char str[256];
- sprintf(str, "%03d,%03d%s", mjr, mnr, post);
- return str;
-}
-
-static inline FILE *open_pit(char *str)
-{
- FILE *fp = my_fopen(str, "w");
-
- if (fp == NULL)
+ sprintf(str, "%s_pit.dat", dip->dip_name);
+ if ((fp = my_fopen(str, "w")) == NULL)
perror(str);
return fp;
@@ -128,38 +121,38 @@ struct d_info *dip_alloc(__u32 device, struct io *iop)
struct d_info *dip = __dip_find(device);
if (dip == NULL) {
- char str[256];
-
dip = malloc(sizeof(struct d_info));
memset(dip, 0, sizeof(*dip));
- dip->heads = dip_rb_mkhds();
- region_init(&dip->regions);
dip->device = device;
- dip->last_q = (__u64)-1;
dip->devmap = dev_map_find(device);
- dip->bno_dump_handle = bno_dump_alloc(device);
- dip->up_hist_handle = unplug_hist_alloc(device);
- dip->seek_handle = seeki_alloc(mkhandle(str, device, "_d2d"));
- dip->q2q_handle = seeki_alloc(mkhandle(str, device, "_q2q"));
- dip->aqd_handle = aqd_alloc(mkhandle(str, device, "_aqd"));
- dip->q2d_plat_handle =
- plat_alloc(mkhandle(str, device, "_q2d_plat"));
- dip->q2c_plat_handle =
- plat_alloc(mkhandle(str, device, "_q2c_plat"));
- dip->d2c_plat_handle =
- plat_alloc(mkhandle(str, device, "_d2c_plat"));
- latency_alloc(dip);
- list_add_tail(&dip->hash_head, &dev_heads[DEV_HASH(device)]);
- list_add_tail(&dip->all_head, &all_devs);
+ dip->last_q = (__u64)-1;
+ dip->heads = dip_rb_mkhds();
+ region_init(&dip->regions);
dip->start_time = BIT_TIME(iop->t.time);
dip->pre_culling = 1;
- dip->rstat_handle = rstat_alloc(mkhandle(str, device, ""));
+
+ mkhandle(dip, dip->dip_name, 256);
+
+ latency_alloc(dip);
+ dip->aqd_handle = aqd_alloc(dip);
+ dip->bno_dump_handle = bno_dump_alloc(dip);
+ dip->up_hist_handle = unplug_hist_alloc(dip);
+ dip->seek_handle = seeki_alloc(dip, "_d2d");
+ dip->q2q_handle = seeki_alloc(dip, "_q2q");
+ dip->q2d_plat_handle = plat_alloc(dip, "_q2d");
+ dip->q2c_plat_handle = plat_alloc(dip, "_q2c");
+ dip->d2c_plat_handle = plat_alloc(dip, "_d2c");
+ dip->rstat_handle = rstat_alloc(dip);
+
+ if (per_io_trees)
+ dip->pit_fp = open_pit(dip);
+
if (output_all_data)
dip->q2d_priv = q2d_alloc();
+
+ list_add_tail(&dip->hash_head, &dev_heads[DEV_HASH(device)]);
+ list_add_tail(&dip->all_head, &all_devs);
n_devs++;
- if (per_io_trees)
- dip->pit_fp = open_pit(mkhandle(per_io_trees,
- device, "_pit.dat"));
}
if (dip->pre_culling) {