From nobody Thu Oct 2 02:16:52 2025 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0D80A31B10B; Thu, 25 Sep 2025 15:05:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=216.71.153.144 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758812744; cv=none; b=BL1se/h7SSiUK5F7A2Qu0o6wa1+TE8v0h/AcaypBcjWpywwZsb5nD0uef666DHD03VUhuZ1aLPm3NChYq0ImnVnwMkZZOH2OP9eb+rPE+m5oiDMl0NM+WcSLmUaw6JO8d7kpncHCXB546w501jJk0rLYKG16iv59Z/J8M7QS1VQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758812744; c=relaxed/simple; bh=6X+2xPvvoMuMNMDivSf9y9c6nTZvfXkeZsioLX0X17Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dtNFsbysIbsZZQ3c00ySeeAxJwdqQWS3fXk6LZ+AegY9osogxYiUxn/qXTHZH9uW6+G28nDbQaZAUyzC5PNs1HlRgbe/135ngXfR/Kso46DzFclc2/ALLCWI1ojZom/W/OOJLwkZd9Qo4hFGmG5T1o3I0aOghUCMPyJSXEd3JWs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wdc.com; spf=pass smtp.mailfrom=wdc.com; dkim=pass (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b=S7ZbOpnZ; arc=none smtp.client-ip=216.71.153.144 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wdc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=wdc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="S7ZbOpnZ" DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1758812741; x=1790348741; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=6X+2xPvvoMuMNMDivSf9y9c6nTZvfXkeZsioLX0X17Q=; b=S7ZbOpnZFI3CFC4tESbEMQUtWHbhllttw04LZwPt/jd9P6PFB5gE8i+x 8pzJ+TwgqmKYu8HhVdH2hd9R2SpScFqxX7IEA+QdVWtnjFi6k6H9OUTxC KI/TCXg4JK7KkV65h9+bxj37FkPCTkx5RxqJFA2Cwvu282vi5dJduxncp +AArrJAus2swoXvuD9O81cH1uc4KSEmEa2OaxYEPI5YnwU1Mie89B2I/0 M8VRjc8upEFluBN71zIxrt6ckI23eQWrelHvojxvMp9aP4RnR1vzrgvkb BtFQ9iilYI9p5zy5Gl3kRlfYc9jIHjS7GAkZKvaUyLjwF/veDpFWDJyWL g==; X-CSE-ConnectionGUID: iwci3smtSpWGsmYD/IlJRg== X-CSE-MsgGUID: 9tJROEHUTpq5rZUkVdBDAA== X-IronPort-AV: E=Sophos;i="6.18,292,1751212800"; d="scan'208";a="130349405" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 25 Sep 2025 23:05:41 +0800 IronPort-SDR: 68d55a45_s15REnVaqAEwtjij1o1kY/3/qjBzarTujb25Ch73hhkVNgl TkIe49QM2eeiyIzwAsP4NUqYoGUL9jQPTOmDsQw== Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 25 Sep 2025 08:05:42 -0700 WDCIronportException: Internal Received: from c02g55f6ml85.ad.shared (HELO C02G55F6ML85.wdc.com) ([10.224.183.46]) by uls-op-cesaip02.wdc.com with ESMTP; 25 Sep 2025 08:05:38 -0700 From: Johannes Thumshirn To: Jens Axboe Cc: Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-btrace@vger.kernel.org, John Garry , Hannes Reinecke , Damien Le Moal , Christoph Hellwig , Naohiro Aota , Shinichiro Kawasaki , Chaitanya Kulkarni , "Martin K . Petersen" , Johannes Thumshirn Subject: [PATCH blktrace v2 16/22] blkparse: use blk_io_trace2 internally Date: Thu, 25 Sep 2025 17:04:21 +0200 Message-ID: <20250925150427.67394-17-johannes.thumshirn@wdc.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20250925150427.67394-1-johannes.thumshirn@wdc.com> References: <20250925150427.67394-1-johannes.thumshirn@wdc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Use 'struct blk_io_trace2' as internal representation for a captured blktrace. This implies the conversion of 'struct blk_io_trace' into 'struct blk_io_trace2' when reading the trace from the binary file. Signed-off-by: Johannes Thumshirn --- blkparse.c | 131 +++++++++++++++++++++++++++---------------------- blkparse_fmt.c | 16 +++--- blktrace.h | 23 ++++++++- 3 files changed, 103 insertions(+), 67 deletions(-) diff --git a/blkparse.c b/blkparse.c index 6396611..7100009 100644 --- a/blkparse.c +++ b/blkparse.c @@ -243,7 +243,7 @@ static struct option l_opts[] =3D { * for sorting the displayed output */ struct trace { - struct blk_io_trace *bit; + struct blk_io_trace2 *bit; struct rb_node rb_node; struct trace *next; unsigned long read_sequence; @@ -257,7 +257,7 @@ static struct trace *trace_list; /* * allocation cache */ -static struct blk_io_trace *bit_alloc_list; +static struct blk_io_trace2 *bit_alloc_list; static struct trace *t_alloc_list; =20 /* @@ -332,7 +332,7 @@ static int have_drv_data =3D 0; #define CPU_IDX(cpu) ((cpu) / CPUS_PER_LONG) #define CPU_BIT(cpu) ((cpu) & (CPUS_PER_LONG - 1)) =20 -static void io_warn_unless(struct blk_io_trace *t, int condition, +static void io_warn_unless(struct blk_io_trace2 *t, int condition, const char *fmt, ...) { va_list ap; @@ -613,7 +613,7 @@ static struct process_pid_map *add_ppm_hash(pid_t pid, = const char *name) return ppm; } =20 -static void handle_notify(struct blk_io_trace *bit) +static void handle_notify(struct blk_io_trace2 *bit) { void *payload =3D (caddr_t) bit + sizeof(*bit); __u32 two32[2]; @@ -802,25 +802,25 @@ static inline struct trace *t_alloc(void) return malloc(sizeof(*t)); } =20 -static inline void bit_free(struct blk_io_trace *bit) +static inline void bit_free(struct blk_io_trace2 *bit) { if (bit_alloc_cache < 1024 && !bit->pdu_len) { /* * abuse a 64-bit field for a next pointer for the free item */ bit->time =3D (__u64) (unsigned long) bit_alloc_list; - bit_alloc_list =3D (struct blk_io_trace *) bit; + bit_alloc_list =3D (struct blk_io_trace2 *) bit; bit_alloc_cache++; } else free(bit); } =20 -static inline struct blk_io_trace *bit_alloc(void) +static inline struct blk_io_trace2 *bit_alloc(void) { - struct blk_io_trace *bit =3D bit_alloc_list; + struct blk_io_trace2 *bit =3D bit_alloc_list; =20 if (bit) { - bit_alloc_list =3D (struct blk_io_trace *) (unsigned long) \ + bit_alloc_list =3D (struct blk_io_trace2 *) (unsigned long) \ bit->time; bit_alloc_cache--; return bit; @@ -1041,7 +1041,7 @@ static struct io_track *find_track(struct per_dev_inf= o *pdi, pid_t pid, } =20 static void log_track_frontmerge(struct per_dev_info *pdi, - struct blk_io_trace *t) + struct blk_io_trace2 *t) { struct io_track *iot; =20 @@ -1062,7 +1062,7 @@ static void log_track_frontmerge(struct per_dev_info = *pdi, track_rb_insert(pdi, iot); } =20 -static void log_track_getrq(struct per_dev_info *pdi, struct blk_io_trace = *t) +static void log_track_getrq(struct per_dev_info *pdi, struct blk_io_trace2= *t) { struct io_track *iot; struct io_track_req *req; @@ -1081,7 +1081,7 @@ static void log_track_getrq(struct per_dev_info *pdi,= struct blk_io_trace *t) * for md/dm setups, the interesting cycle is Q -> C. So track queueing * time here, as dispatch time */ -static void log_track_queue(struct per_dev_info *pdi, struct blk_io_trace = *t) +static void log_track_queue(struct per_dev_info *pdi, struct blk_io_trace2= *t) { struct io_track *iot; struct io_track_req *req; @@ -1096,7 +1096,7 @@ static void log_track_queue(struct per_dev_info *pdi,= struct blk_io_trace *t) req->dispatch_time =3D t->time; } =20 -static void log_track_split(struct per_dev_info *pdi, struct blk_io_trace = *t) +static void log_track_split(struct per_dev_info *pdi, struct blk_io_trace2= *t) { struct io_track *iot, *split; =20 @@ -1118,7 +1118,7 @@ static void log_track_split(struct per_dev_info *pdi,= struct blk_io_trace *t) * return time between rq allocation and insertion */ static unsigned long long log_track_insert(struct per_dev_info *pdi, - struct blk_io_trace *t) + struct blk_io_trace2 *t) { unsigned long long elapsed; struct io_track *iot; @@ -1153,7 +1153,7 @@ static unsigned long long log_track_insert(struct per= _dev_info *pdi, * return time between queue and issue */ static unsigned long long log_track_issue(struct per_dev_info *pdi, - struct blk_io_trace *t) + struct blk_io_trace2 *t) { unsigned long long elapsed =3D -1ULL; struct io_track *iot; @@ -1191,7 +1191,7 @@ static unsigned long long log_track_issue(struct per_= dev_info *pdi, return elapsed; } =20 -static void fixup_complete(struct per_dev_info *pdi, struct blk_io_trace *= t) +static void fixup_complete(struct per_dev_info *pdi, struct blk_io_trace2 = *t) { struct io_track *iot; __u64 start_sector; @@ -1214,7 +1214,7 @@ static void fixup_complete(struct per_dev_info *pdi, = struct blk_io_trace *t) * return time between dispatch and complete */ static unsigned long long log_track_complete(struct per_dev_info *pdi, - struct blk_io_trace *t) + struct blk_io_trace2 *t) { unsigned long long elapsed =3D -1ULL; struct io_track *iot, *next; @@ -1288,7 +1288,7 @@ static char *get_dev_name(struct per_dev_info *pdi, c= har *buffer, int size) return buffer; } =20 -static void check_time(struct per_dev_info *pdi, struct blk_io_trace *bit) +static void check_time(struct per_dev_info *pdi, struct blk_io_trace2 *bit) { unsigned long long this =3D bit->time; unsigned long long last =3D pdi->last_reported_time; @@ -1297,7 +1297,7 @@ static void check_time(struct per_dev_info *pdi, stru= ct blk_io_trace *bit) pdi->last_reported_time =3D this; } =20 -static inline void __account_m(struct io_stats *ios, struct blk_io_trace *= t, +static inline void __account_m(struct io_stats *ios, struct blk_io_trace2 = *t, int rw) { if (rw) { @@ -1311,7 +1311,7 @@ static inline void __account_m(struct io_stats *ios, = struct blk_io_trace *t, } } =20 -static inline void account_m(struct blk_io_trace *t, struct per_cpu_info *= pci, +static inline void account_m(struct blk_io_trace2 *t, struct per_cpu_info = *pci, int rw) { __account_m(&pci->io_stats, t, rw); @@ -1324,7 +1324,7 @@ static inline void account_m(struct blk_io_trace *t, = struct per_cpu_info *pci, } =20 static inline void __account_pc_queue(struct io_stats *ios, - struct blk_io_trace *t, int rw) + struct blk_io_trace2 *t, int rw) { if (rw) { ios->qwrites_pc++; @@ -1337,7 +1337,7 @@ static inline void __account_pc_queue(struct io_stats= *ios, } } =20 -static inline void account_pc_queue(struct blk_io_trace *t, +static inline void account_pc_queue(struct blk_io_trace2 *t, struct per_cpu_info *pci, int rw) { __account_pc_queue(&pci->io_stats, t, rw); @@ -1363,7 +1363,7 @@ static inline void __account_pc_issue(struct io_stats= *ios, int rw, } } =20 -static inline void account_pc_issue(struct blk_io_trace *t, +static inline void account_pc_issue(struct blk_io_trace2 *t, struct per_cpu_info *pci, int rw) { __account_pc_issue(&pci->io_stats, rw, t->bytes); @@ -1376,7 +1376,7 @@ static inline void account_pc_issue(struct blk_io_tra= ce *t, } =20 static inline void __account_pc_requeue(struct io_stats *ios, - struct blk_io_trace *t, int rw) + struct blk_io_trace2 *t, int rw) { if (rw) { ios->wrqueue_pc++; @@ -1389,7 +1389,7 @@ static inline void __account_pc_requeue(struct io_sta= ts *ios, } } =20 -static inline void account_pc_requeue(struct blk_io_trace *t, +static inline void account_pc_requeue(struct blk_io_trace2 *t, struct per_cpu_info *pci, int rw) { __account_pc_requeue(&pci->io_stats, t, rw); @@ -1409,7 +1409,7 @@ static inline void __account_pc_c(struct io_stats *io= s, int rw) ios->creads_pc++; } =20 -static inline void account_pc_c(struct blk_io_trace *t, +static inline void account_pc_c(struct blk_io_trace2 *t, struct per_cpu_info *pci, int rw) { __account_pc_c(&pci->io_stats, rw); @@ -1421,7 +1421,7 @@ static inline void account_pc_c(struct blk_io_trace *= t, } } =20 -static inline void __account_queue(struct io_stats *ios, struct blk_io_tra= ce *t, +static inline void __account_queue(struct io_stats *ios, struct blk_io_tra= ce2 *t, int rw) { if (rw) { @@ -1435,7 +1435,7 @@ static inline void __account_queue(struct io_stats *i= os, struct blk_io_trace *t, } } =20 -static inline void account_queue(struct blk_io_trace *t, +static inline void account_queue(struct blk_io_trace2 *t, struct per_cpu_info *pci, int rw) { __account_queue(&pci->io_stats, t, rw); @@ -1460,7 +1460,7 @@ static inline void __account_c(struct io_stats *ios, = int rw, int bytes) } } =20 -static inline void account_c(struct blk_io_trace *t, struct per_cpu_info *= pci, +static inline void account_c(struct blk_io_trace2 *t, struct per_cpu_info = *pci, int rw, int bytes) { __account_c(&pci->io_stats, rw, bytes); @@ -1486,7 +1486,7 @@ static inline void __account_issue(struct io_stats *i= os, int rw, } } =20 -static inline void account_issue(struct blk_io_trace *t, +static inline void account_issue(struct blk_io_trace2 *t, struct per_cpu_info *pci, int rw) { __account_issue(&pci->io_stats, rw, t->bytes); @@ -1506,7 +1506,7 @@ static inline void __account_unplug(struct io_stats *= ios, int timer) ios->io_unplugs++; } =20 -static inline void account_unplug(struct blk_io_trace *t, +static inline void account_unplug(struct blk_io_trace2 *t, struct per_cpu_info *pci, int timer) { __account_unplug(&pci->io_stats, timer); @@ -1519,7 +1519,7 @@ static inline void account_unplug(struct blk_io_trace= *t, } =20 static inline void __account_requeue(struct io_stats *ios, - struct blk_io_trace *t, int rw) + struct blk_io_trace2 *t, int rw) { if (rw) { ios->wrqueue++; @@ -1532,7 +1532,7 @@ static inline void __account_requeue(struct io_stats = *ios, } } =20 -static inline void account_requeue(struct blk_io_trace *t, +static inline void account_requeue(struct blk_io_trace2 *t, struct per_cpu_info *pci, int rw) { __account_requeue(&pci->io_stats, t, rw); @@ -1545,31 +1545,31 @@ static inline void account_requeue(struct blk_io_tr= ace *t, } =20 static void log_complete(struct per_dev_info *pdi, struct per_cpu_info *pc= i, - struct blk_io_trace *t, char *act) + struct blk_io_trace2 *t, char *act) { process_fmt(act, pci, t, log_track_complete(pdi, t), 0, NULL); } =20 static void log_insert(struct per_dev_info *pdi, struct per_cpu_info *pci, - struct blk_io_trace *t, char *act) + struct blk_io_trace2 *t, char *act) { process_fmt(act, pci, t, log_track_insert(pdi, t), 0, NULL); } =20 -static void log_queue(struct per_cpu_info *pci, struct blk_io_trace *t, +static void log_queue(struct per_cpu_info *pci, struct blk_io_trace2 *t, char *act) { process_fmt(act, pci, t, -1, 0, NULL); } =20 static void log_issue(struct per_dev_info *pdi, struct per_cpu_info *pci, - struct blk_io_trace *t, char *act) + struct blk_io_trace2 *t, char *act) { process_fmt(act, pci, t, log_track_issue(pdi, t), 0, NULL); } =20 static void log_merge(struct per_dev_info *pdi, struct per_cpu_info *pci, - struct blk_io_trace *t, char *act) + struct blk_io_trace2 *t, char *act) { if (act[0] =3D=3D 'F') log_track_frontmerge(pdi, t); @@ -1577,38 +1577,38 @@ static void log_merge(struct per_dev_info *pdi, str= uct per_cpu_info *pci, process_fmt(act, pci, t, -1ULL, 0, NULL); } =20 -static void log_action(struct per_cpu_info *pci, struct blk_io_trace *t, +static void log_action(struct per_cpu_info *pci, struct blk_io_trace2 *t, char *act) { process_fmt(act, pci, t, -1ULL, 0, NULL); } =20 -static void log_generic(struct per_cpu_info *pci, struct blk_io_trace *t, +static void log_generic(struct per_cpu_info *pci, struct blk_io_trace2 *t, char *act) { process_fmt(act, pci, t, -1ULL, 0, NULL); } =20 -static void log_unplug(struct per_cpu_info *pci, struct blk_io_trace *t, +static void log_unplug(struct per_cpu_info *pci, struct blk_io_trace2 *t, char *act) { process_fmt(act, pci, t, -1ULL, 0, NULL); } =20 -static void log_split(struct per_cpu_info *pci, struct blk_io_trace *t, +static void log_split(struct per_cpu_info *pci, struct blk_io_trace2 *t, char *act) { process_fmt(act, pci, t, -1ULL, 0, NULL); } =20 -static void log_pc(struct per_cpu_info *pci, struct blk_io_trace *t, char = *act) +static void log_pc(struct per_cpu_info *pci, struct blk_io_trace2 *t, char= *act) { unsigned char *buf =3D (unsigned char *) t + sizeof(*t); =20 process_fmt(act, pci, t, -1ULL, t->pdu_len, buf); } =20 -static void dump_trace_pc(struct blk_io_trace *t, struct per_dev_info *pdi, +static void dump_trace_pc(struct blk_io_trace2 *t, struct per_dev_info *pd= i, struct per_cpu_info *pci) { int w =3D (t->action & BLK_TC_ACT(BLK_TC_WRITE)) !=3D 0; @@ -1657,7 +1657,7 @@ static void dump_trace_pc(struct blk_io_trace *t, str= uct per_dev_info *pdi, } } =20 -static void dump_trace_fs(struct blk_io_trace *t, struct per_dev_info *pdi, +static void dump_trace_fs(struct blk_io_trace2 *t, struct per_dev_info *pd= i, struct per_cpu_info *pci) { int w =3D (t->action & BLK_TC_ACT(BLK_TC_WRITE)) !=3D 0; @@ -1737,12 +1737,12 @@ static void dump_trace_fs(struct blk_io_trace *t, s= truct per_dev_info *pdi, /* dump to binary file only */ break; default: - fprintf(stderr, "Bad fs action %x\n", t->action); + fprintf(stderr, "Bad fs action %llx\n", t->action); break; } } =20 -static void dump_trace(struct blk_io_trace *t, struct per_cpu_info *pci, +static void dump_trace(struct blk_io_trace2 *t, struct per_cpu_info *pci, struct per_dev_info *pdi) { if (text_output) { @@ -2162,7 +2162,7 @@ static void find_genesis(void) } } =20 -static inline int check_stopwatch(struct blk_io_trace *bit) +static inline int check_stopwatch(struct blk_io_trace2 *bit) { if (bit->time < stopwatch_end && bit->time >=3D stopwatch_start) @@ -2185,7 +2185,7 @@ static int sort_entries(unsigned long long *youngest) =20 *youngest =3D 0; while ((t =3D trace_list) !=3D NULL) { - struct blk_io_trace *bit =3D t->bit; + struct blk_io_trace2 *bit =3D t->bit; =20 trace_list =3D t->next; =20 @@ -2264,7 +2264,7 @@ static int check_cpu_map(struct per_dev_info *pdi) =20 static int check_sequence(struct per_dev_info *pdi, struct trace *t, int f= orce) { - struct blk_io_trace *bit =3D t->bit; + struct blk_io_trace2 *bit =3D t->bit; unsigned long expected_sequence; struct per_cpu_info *pci; struct trace *__t; @@ -2315,7 +2315,7 @@ static void show_entries_rb(int force) { struct per_dev_info *pdi =3D NULL; struct per_cpu_info *pci =3D NULL; - struct blk_io_trace *bit; + struct blk_io_trace2 *bit; struct rb_node *n; struct trace *t; =20 @@ -2428,12 +2428,22 @@ static inline __u32 get_magic(__u32 magic) return __bswap_32(magic); } =20 -static int read_one_bit(int fd, struct blk_io_trace *bit, int block, +static int read_one_bit(int fd, struct blk_io_trace2 **bit2, int block, int *fdblock) { + struct blk_io_trace2 *new =3D *bit2; + struct blk_io_trace *bit; int ret; int pdu_len; - void *p =3D (void *) ((u8 *)bit + sizeof(__u32)); + void *p; + + bit =3D malloc(sizeof(*bit)); + if (!bit) + return -1; + + bit->magic =3D new->magic; + + p =3D (void *) ((u8 *)bit + sizeof(__u32)); =20 ret =3D read_data(fd, p, sizeof(*bit) - sizeof(__u32), block, fdblock); if (ret) @@ -2449,9 +2459,14 @@ static int read_one_bit(int fd, struct blk_io_trace = *bit, int block, return ret; } bit =3D ptr; + + new =3D realloc(*bit2, sizeof(struct blk_io_trace2) + pdu_len); } =20 bit_trace_to_cpu(bit); + bit_to_bit2(bit, new); + free(bit); + *bit2 =3D new; =20 return 0; } @@ -2491,11 +2506,11 @@ static int read_events(int fd, int always_block, in= t *fdblock) } version =3D magic & 0xff; if (version =3D=3D SUPPORTED_VERSION) { - struct blk_io_trace *bit; + struct blk_io_trace2 *bit; bit =3D bit_alloc(); bit->magic =3D magic; =20 - ret =3D read_one_bit(fd, bit, 1, fdblock); + ret =3D read_one_bit(fd, &bit, 1, fdblock); if (ret) break; =20 @@ -2620,7 +2635,7 @@ static int ms_prime(struct ms_stream *msp) struct trace *t; struct per_dev_info *pdi =3D msp->pdi; struct per_cpu_info *pci =3D get_cpu_info(pdi, msp->cpu); - struct blk_io_trace *bit =3D NULL; + struct blk_io_trace2 *bit =3D NULL; int ret, ndone =3D 0; =20 for (i =3D 0; !is_done() && pci->fd >=3D 0 && i < rb_batch; i++) { @@ -2645,7 +2660,7 @@ static int ms_prime(struct ms_stream *msp) bit =3D bit_alloc(); bit->magic =3D magic; =20 - ret =3D read_one_bit(pci->fd, bit, 1, &pci->fdblock); + ret =3D read_one_bit(pci->fd, &bit, 1, &pci->fdblock); if (ret) goto err; =20 @@ -2767,7 +2782,7 @@ static int handle(struct ms_stream *msp) struct trace *t; struct per_dev_info *pdi; struct per_cpu_info *pci; - struct blk_io_trace *bit; + struct blk_io_trace2 *bit; =20 t =3D ms_peek(msp); =20 diff --git a/blkparse_fmt.c b/blkparse_fmt.c index 02c5a3c..f93addb 100644 --- a/blkparse_fmt.c +++ b/blkparse_fmt.c @@ -51,7 +51,7 @@ int add_format_spec(char *option) return 0; } =20 -static inline void fill_rwbs(char *rwbs, struct blk_io_trace *t) +static inline void fill_rwbs(char *rwbs, struct blk_io_trace2 *t) { bool w =3D !!(t->action & BLK_TC_ACT(BLK_TC_WRITE)); bool a =3D !!(t->action & BLK_TC_ACT(BLK_TC_AHEAD)); @@ -146,16 +146,16 @@ static char *dump_pdu(unsigned char *pdu_buf, int pdu= _len) return p; } =20 -#define pdu_start(t) (((void *) (t) + sizeof(struct blk_io_trace))) +#define pdu_start(t) (((void *) (t) + sizeof(struct blk_io_trace2))) =20 -static unsigned int get_pdu_int(struct blk_io_trace *t) +static unsigned int get_pdu_int(struct blk_io_trace2 *t) { __u64 *val =3D pdu_start(t); =20 return be64_to_cpu(*val); } =20 -static void get_pdu_remap(struct blk_io_trace *t, struct blk_io_trace_rema= p *r) +static void get_pdu_remap(struct blk_io_trace2 *t, struct blk_io_trace_rem= ap *r) { struct blk_io_trace_remap *__r =3D pdu_start(t); __u64 sector_from =3D __r->sector_from; @@ -166,7 +166,7 @@ static void get_pdu_remap(struct blk_io_trace *t, struc= t blk_io_trace_remap *r) } =20 static void print_field(char *act, struct per_cpu_info *pci, - struct blk_io_trace *t, unsigned long long elapsed, + struct blk_io_trace2 *t, unsigned long long elapsed, int pdu_len, unsigned char *pdu_buf, char field, int minus, int has_w, int width) { @@ -275,7 +275,7 @@ static void print_field(char *act, struct per_cpu_info = *pci, } =20 static char *parse_field(char *act, struct per_cpu_info *pci, - struct blk_io_trace *t, unsigned long long elapsed, + struct blk_io_trace2 *t, unsigned long long elapsed, int pdu_len, unsigned char *pdu_buf, char *primary_format) { @@ -302,7 +302,7 @@ static char *parse_field(char *act, struct per_cpu_info= *pci, } =20 static void process_default(char *act, struct per_cpu_info *pci, - struct blk_io_trace *t, unsigned long long elapsed, + struct blk_io_trace2 *t, unsigned long long elapsed, int pdu_len, unsigned char *pdu_buf) { struct blk_io_trace_remap r =3D { .device_from =3D 0, }; @@ -436,7 +436,7 @@ static void process_default(char *act, struct per_cpu_i= nfo *pci, =20 } =20 -void process_fmt(char *act, struct per_cpu_info *pci, struct blk_io_trace = *t, +void process_fmt(char *act, struct per_cpu_info *pci, struct blk_io_trace2= *t, unsigned long long elapsed, int pdu_len, unsigned char *pdu_buf) { diff --git a/blktrace.h b/blktrace.h index 08ac28b..196b3c9 100644 --- a/blktrace.h +++ b/blktrace.h @@ -6,6 +6,7 @@ #include #include #include +#include =20 #include "blktrace_api.h" #include "rbtree.h" @@ -108,6 +109,26 @@ static inline int verify_trace(__u32 magic) return 0; } =20 +static inline void bit_to_bit2(struct blk_io_trace *old, + struct blk_io_trace2 *new) +{ + new->magic =3D old->magic; + new->sequence =3D old->sequence; + new->time =3D old->time; + new->sector =3D old->sector; + new->bytes =3D old->bytes; + new->action =3D 0 | old->action; + new->pid =3D old->pid; + new->device =3D old->device; + new->cpu =3D old->cpu; + new->error =3D old->error; + new->pdu_len =3D old->pdu_len; + + if (new->pdu_len) + memcpy(((u8 *) new + sizeof(*new)), ((u8 *)old + sizeof(*old)), + old->pdu_len); +} + static inline void bit_trace_to_cpu(struct blk_io_trace *t) { if (data_is_native) @@ -147,7 +168,7 @@ static inline int check_data_endianness(u32 magic) =20 extern void set_all_format_specs(char *); extern int add_format_spec(char *); -extern void process_fmt(char *, struct per_cpu_info *, struct blk_io_trace= *, +extern void process_fmt(char *, struct per_cpu_info *, struct blk_io_trace= 2 *, unsigned long long, int, unsigned char *); extern unsigned long long valid_act_opt(unsigned long long); extern int find_mask_map(char *); --=20 2.51.0