blktrace: avoid device duplication
authorEdward Shishkin <edward@redhat.com>
Tue, 15 Dec 2009 17:47:47 +0000 (18:47 +0100)
committerJens Axboe <jens.axboe@oracle.com>
Tue, 20 Apr 2010 07:51:52 +0000 (09:51 +0200)
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 <edward@redhat.com>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
blktrace.c

index b4c919df18eec694f7e2e3e11220e0d4155b487a..a67e1b87939d63437348bf42bba19795fc1a21b5 100644 (file)
@@ -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
         */