blktrace: backport upstream bugfix patches Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
52 lines
1.8 KiB
Diff
52 lines
1.8 KiB
Diff
From 56f1d9991917ff8313e51fba5d3970042ac072ef Mon Sep 17 00:00:00 2001
|
|
From: Ignat Korchagin <ignat@cloudflare.com>
|
|
Date: Mon, 16 Sep 2019 10:30:23 -0600
|
|
Subject: [PATCH 09/15] btreplay: fix device IO remap functionality
|
|
|
|
Commit dd093eb1c48e ("Fix warnings on newer gcc") moved string buffers holding
|
|
device names during map file parse stage to stack. However, only pointers to
|
|
them are being stored in the allocated "struct map_dev" structure. These
|
|
pointers are invalid outside of scope of this function and in a different
|
|
thread context. Also "release_map_devs" function still tries to "free" them
|
|
later as if they were allocated on the heap.
|
|
|
|
Moving the buffers back to the heap by instructing "fscanf" to allocate them
|
|
while parsing the file.
|
|
|
|
Alternatively, we could redefine the "struct map_dev" to include the whole
|
|
buffers instead of just pointers to them and free them as part of releasing the
|
|
whole "struct map_dev".
|
|
|
|
Fixes: dd093eb1c48e ("Fix warnings on newer gcc")
|
|
Signed-off-by: Ignat Korchagin <ignat@cloudflare.com>
|
|
Signed-off-by: Jens Axboe <axboe@kernel.dk>
|
|
---
|
|
btreplay/btreplay.c | 4 ++--
|
|
1 file changed, 2 insertions(+), 2 deletions(-)
|
|
|
|
diff --git a/btreplay/btreplay.c b/btreplay/btreplay.c
|
|
index edaf81f..23cc2a9 100644
|
|
--- a/btreplay/btreplay.c
|
|
+++ b/btreplay/btreplay.c
|
|
@@ -645,7 +645,7 @@ static void find_input_devs(char *idir)
|
|
static void read_map_devs(char *file_name)
|
|
{
|
|
FILE *fp;
|
|
- char from_dev[256], to_dev[256];
|
|
+ char *from_dev, *to_dev;
|
|
|
|
fp = fopen(file_name, "r");
|
|
if (!fp) {
|
|
@@ -653,7 +653,7 @@ static void read_map_devs(char *file_name)
|
|
/*NOTREACHED*/
|
|
}
|
|
|
|
- while (fscanf(fp, "%s %s", from_dev, to_dev) == 2) {
|
|
+ while (fscanf(fp, "%ms %ms", &from_dev, &to_dev) == 2) {
|
|
struct map_dev *mdp = malloc(sizeof(*mdp));
|
|
|
|
mdp->from_dev = from_dev;
|
|
--
|
|
1.8.3.1
|
|
|