More logical naming for .dat files created.
Signed-off-by: Alan D. Brunelle <alan.brunelle@hp.com>
int na; /* # active */
};
-void *aqd_alloc(char *str)
+void *aqd_alloc(struct d_info *dip)
{
char *oname;
struct aqd_info *ap;
ap = malloc(sizeof(*ap));
ap->na = 0;
- oname = malloc(strlen(aqd_name) + strlen(str) + 32);
- sprintf(oname, "%s_%s.dat", aqd_name, str);
+ oname = malloc(strlen(aqd_name) + strlen(dip->dip_name) + 32);
+ sprintf(oname, "%s_%s_aqd.dat", aqd_name, dip->dip_name);
if ((ap->fp = my_fopen(oname, "w")) == NULL) {
perror(oname);
return NULL;
FILE *rfp, *wfp, *cfp;
};
-static FILE *bno_dump_open(__u32 device, char rwc)
+static FILE *bno_dump_open(struct d_info *dip, char rwc)
{
FILE *fp;
char *oname;
- int mjr, mnr;
- mjr = device >> MINORBITS;
- mnr = device & ((1 << MINORBITS) - 1);
-
- oname = malloc(strlen(bno_dump_name) + 32);
- sprintf(oname, "%s_%03d,%03d_%c.dat", bno_dump_name, mjr, mnr, rwc);
+ oname = malloc(strlen(bno_dump_name) + strlen(dip->dip_name) + 32);
+ sprintf(oname, "%s_%s_%c.dat", bno_dump_name, dip->dip_name, rwc);
if ((fp = my_fopen(oname, "w")) == NULL)
perror(oname);
else
(long long)BIT_START(iop), (long long)BIT_END(iop));
}
-void *bno_dump_alloc(__u32 device)
+void *bno_dump_alloc(struct d_info *dip)
{
struct bno_dump *bdp;
if (bno_dump_name == NULL) return NULL;
bdp = malloc(sizeof(*bdp));
- bdp->rfp = bno_dump_open(device, 'r');
- bdp->wfp = bno_dump_open(device, 'w');
- bdp->cfp = bno_dump_open(device, 'c');
+ bdp->rfp = bno_dump_open(dip, 'r');
+ bdp->wfp = bno_dump_open(dip, 'w');
+ bdp->cfp = bno_dump_open(dip, 'c');
return bdp;
}
}
}
-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;
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) {
struct list_head all_head, hash_head;
void *heads;
struct region_info regions;
- char *devmap;
+ char *devmap, dip_name[256];
void *q2q_handle, *seek_handle, *bno_dump_handle, *up_hist_handle;
void *q2d_priv, *aqd_handle, *rstat_handle;
void *q2d_plat_handle, *q2c_plat_handle, *d2c_plat_handle;
void clean_args();
/* aqd.c */
-void *aqd_alloc(char *str);
+void *aqd_alloc(struct d_info *dip);
void aqd_free(void *info);
void aqd_clean(void);
void aqd_issue(void *info, double ts);
void add_file(FILE *fp, char *oname);
void add_buf(void *buf);
char *make_dev_hdr(char *pad, size_t len, struct d_info *dip, int add_parens);
+char *mkhandle(struct d_info *dip, char *str, size_t len);
FILE *my_fopen(const char *path, const char *mode);
int my_open(const char *path, int flags);
void dbg_ping(void);
void pip_exit(void);
/* bno_dump.c */
-void *bno_dump_alloc(__u32 device);
+void *bno_dump_alloc(struct d_info *dip);
void bno_dump_free(void *param);
void bno_dump_add(void *handle, struct io *iop);
void bno_dump_clean(void);
/* plat.c */
-void *plat_alloc(char *str);
+void *plat_alloc(struct d_info *dip, char *post);
void plat_free(void *info);
void plat_clean(void);
void plat_x2c(void *info, __u64 ts, __u64 latency);
void q2d_acc(void *a1, void *a2);
/* rstats.c */
-void *rstat_alloc(char *bn);
+void *rstat_alloc(struct d_info *dip);
void rstat_free(void *ptr);
void rstat_add(void *ptr, double cur, unsigned long long nblks);
int rstat_init(void);
void rstat_exit(void);
/* seek.c */
-void *seeki_alloc(char *str);
+void *seeki_alloc(struct d_info *dip, char *post);
void seeki_free(void *param);
void seek_clean(void);
void seeki_add(void *handle, struct io *iop);
void trace_requeue(struct io *r_iop);
/* unplug_hist.c */
-void *unplug_hist_alloc(__u32 device);
+void *unplug_hist_alloc(struct d_info *dip);
void unplug_hist_free(void *arg);
void unplug_hist_add(struct io *u_iop);
fprintf(ofp, "%lf %lf\n", TO_SEC(tstamp), TO_SEC(latency));
}
-FILE *latency_open(__u32 device, char *name, char *post)
+FILE *latency_open(struct d_info *dip, char *name, char *post)
{
FILE *fp = NULL;
if (name) {
- int mjr, mnr;
- char oname[strlen(name) + 32];
+ size_t tlen = strlen(name) + strlen(dip->dip_name)
+ + strlen(post) + 32;
+ char oname[tlen];
- mjr = device >> MINORBITS;
- mnr = device & ((1 << MINORBITS) - 1);
-
- sprintf(oname, "%s_%03d,%03d_%s.dat", name, mjr, mnr, post);
+ sprintf(oname, "%s_%s_%s.dat", name, dip->dip_name, post);
if ((fp = my_fopen(oname, "w")) == NULL)
perror(oname);
else
void latency_alloc(struct d_info *dip)
{
- dip->q2d_ofp = latency_open(dip->device, q2d_name, "q2d");
- dip->d2c_ofp = latency_open(dip->device, d2c_name, "d2c");
- dip->q2c_ofp = latency_open(dip->device, q2c_name, "q2c");
+ dip->q2d_ofp = latency_open(dip, q2d_name, "q2d");
+ dip->d2c_ofp = latency_open(dip, d2c_name, "d2c");
+ dip->q2c_ofp = latency_open(dip, q2c_name, "q2c");
}
void latency_q2d(struct d_info *dip, __u64 tstamp, __u64 latency)
return pad;
}
+char *mkhandle(struct d_info *dip, char *str, size_t len)
+{
+ return make_dev_hdr(str, len, dip, 0);
+}
+
FILE *my_fopen(const char *path, const char *mode)
{
FILE *fp;
double first_ts, last_ts, tl;
};
-void *plat_alloc(char *str)
+void *plat_alloc(struct d_info *dip, char *post)
{
char *oname;
struct plat_info *pp;
pp->nl = 0;
pp->first_ts = pp->last_ts = pp->tl = -1.0;
- oname = malloc(strlen(str) + 32);
- sprintf(oname, "%s.dat", str);
+ oname = malloc(strlen(dip->dip_name) + strlen(post) + 32);
+ sprintf(oname, "%s%s_plat.dat", dip->dip_name, post);
if ((pp->fp = my_fopen(oname, "w")) == NULL) {
perror(oname);
return NULL;
return -1;
}
-static int init_rsip(struct rstat *rsip, char *bn)
+static int init_rsip(struct rstat *rsip, struct d_info *dip)
{
+ char *nm = dip ? dip->dip_name : "sys";
+
rsip->ios = rsip->nblks = 0;
- if (do_open(&rsip->files[0], bn, "iops_fp") ||
- do_open(&rsip->files[1], bn, "mbps_fp"))
+ if (do_open(&rsip->files[0], nm, "iops_fp") ||
+ do_open(&rsip->files[1], nm, "mbps_fp"))
return -1;
list_add_tail(&rsip->head, &rstats);
rsip->nblks += nblks;
}
-void *rstat_alloc(char *bn)
+void *rstat_alloc(struct d_info *dip)
{
struct rstat *rsip = malloc(sizeof(*rsip));
- if (!init_rsip(rsip, bn))
+ if (!init_rsip(rsip, dip))
return rsip;
free(rsip);
int rstat_init(void)
{
- sys_info = rstat_alloc("sys");
+ sys_info = rstat_alloc(NULL);
return sys_info != NULL;
}
return dist;
}
-void *seeki_alloc(char *str)
+void *seeki_alloc(struct d_info *dip, char *post)
{
+ char str[256];
struct seeki *sip = malloc(sizeof(struct seeki));
+ sprintf(str, "%s%s", dip->dip_name, post);
sip->rfp = seek_open(str, 'r');
sip->wfp = seek_open(str, 'w');
sip->cfp = seek_open(str, 'c');
memset(&sip->sps, 0, sizeof(sip->sps));
- oname = malloc(strlen(sps_name) + strlen(str) + 32);
- sprintf(oname, "%s_%s.dat", sps_name, str);
+ oname = malloc(strlen(sps_name) + strlen(dip->dip_name) + 32);
+ sprintf(oname, "%s_%s.dat", sps_name, dip->dip_name);
if ((sip->sps_fp = my_fopen(oname, "w")) == NULL)
perror(oname);
else
#define NBKTS (EXCESS_BKT + 1)
struct hist_bkt {
- __u32 dev;
+ struct d_info *dip;
int hist[NBKTS * sizeof(int)];
};
-void *unplug_hist_alloc(__u32 device)
+void *unplug_hist_alloc(struct d_info *dip)
{
struct hist_bkt *hbp;
if (unplug_hist_name == NULL) return NULL;
hbp = malloc(sizeof(*hbp));
- hbp->dev = device;
+ hbp->dip = dip;
memset(hbp->hist, 0, NBKTS * sizeof(int));
return hbp;
if (arg) {
FILE *fp;
struct hist_bkt *hbp = arg;
- int mjr = hbp->dev >> MINORBITS;
- int mnr = hbp->dev & ((1 << MINORBITS) - 1);
- char *oname = malloc(strlen(unplug_hist_name) + 32);
+ size_t tlen = strlen(unplug_hist_name)
+ + strlen(hbp->dip->dip_name) + 32;
+ char *oname = malloc(tlen);
- sprintf(oname, "%s_%03d,%03d.dat", unplug_hist_name, mjr, mnr);
+ sprintf(oname, "%s_%s.dat", unplug_hist_name,
+ hbp->dip->dip_name);
if ((fp = my_fopen(oname, "w")) != NULL) {
int i;