From: Edward Shishkin Date: Tue, 15 Dec 2009 17:47:47 +0000 (+0100) Subject: blktrace: avoid device duplication X-Git-Tag: blktrace-1.0.2~13 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=4b747a4016573e7f2510b6ab767783a2708d1e55;p=blktrace.git blktrace: avoid device duplication Fixup for bz 501457. Problem: If the device list file contains the same device as supplied on the command line, blktrace stops immediately and further I/O tracing is impossible. Bug: device duplication in the devpaths ends with programm termination (BLKTRACESETUP ioctl returns error) while resources (open files in debugfs) are not released. Solution: Make sure devices are not duplicated in devpaths pool. Signed-off-by: Edward Shishkin Signed-off-by: Jens Axboe --- diff --git a/blktrace.c b/blktrace.c index b4c919d..a67e1b8 100644 --- a/blktrace.c +++ b/blktrace.c @@ -1200,7 +1200,16 @@ static int add_devpath(char *path) { int fd; struct devpath *dpp; + struct list_head *p; + /* + * Verify device is not duplicated + */ + __list_for_each(p, &devpaths) { + struct devpath *tmp = list_entry(p, struct devpath, head); + if (!strcmp(tmp->path, path)) + return 0; + } /* * Verify device is valid before going too far */