Mainly looking at the null selector. --- diff/drivers/md/dm-mpath.c 2003-12-29 10:15:37.000000000 +0000 +++ source/drivers/md/dm-mpath.c 2003-12-29 10:15:43.000000000 +0000 @@ -196,7 +196,7 @@ j = t; ret = 1; } - + if (*timeout > j) *timeout = (long) j; } @@ -433,7 +433,7 @@ * * 0: scrub IO already in progress or error (retry later) * 1: scrub IO queued - * + * */ static inline int _queue_scrub_io(struct path *path) { @@ -863,15 +863,15 @@ dm_kdevname(to_kdev_t(path->dev->dev))); if (_is_failed(path)) { struct timespec fail; - + jiffies_to_timespec(jiffies - path->io_jiffies, &fail); sz += snprintf(result + sz, maxlen - sz, "I(%lu/" ARG_FORMAT ")", (unsigned long) fail.tv_sec, path->reactivation_interval); } else { sz += snprintf(result + sz, maxlen - sz, "O"); - + if (atomic_read(&path->fail_total)) sz += snprintf(result + sz, maxlen - sz, "[" ARG_FORMAT "]", atomic_read(&path->fail_total)); - + sz += snprintf(result + sz, maxlen - sz, " "); } --- diff/drivers/md/dm-null-ps.c 2003-12-29 10:15:37.000000000 +0000 +++ source/drivers/md/dm-null-ps.c 2003-12-29 10:15:43.000000000 +0000 @@ -14,14 +14,15 @@ #include "dm.h" #include "dm-path-selector.h" + #include /* Path selector context */ struct null_c { + spinlock_t lock; + struct list_head paths; /* List of operational paths */ struct list_head failed_paths; /* List of failed paths */ - - spinlock_t lock; }; /* Path info */ @@ -33,7 +34,7 @@ }; /* Allocate null context */ -static struct null_c *_alloc_null_c(void) +static struct null_c *alloc_null_c(void) { struct null_c *nc = kmalloc(sizeof(*nc), GFP_KERNEL); @@ -47,7 +48,7 @@ } /* Allocate path context */ -static struct path_c *_alloc_path_c(void) +static struct path_c *alloc_path_c(void) { struct path_c *pc = kmalloc(sizeof(*pc), GFP_KERNEL); @@ -69,43 +70,36 @@ return -EINVAL; } - nc = _alloc_null_c(); + nc = alloc_null_c(); if (!nc) { *error = "null path selector: Error allocating context"; return -ENOMEM; } ps->context = (void *) nc; - return 0; } -/* Path selector destructor */ -static void null_dtr(struct path_selector *ps) +static void free_paths(struct list_head *paths) { - struct null_c *nc = (struct null_c *) ps->context; - struct list_head *lists[] = { - &nc->paths, - &nc->failed_paths, - }; - int i = ARRAY_SIZE(lists); + struct list_head *elem, *tmp; - spin_lock(&nc->lock); - while (i--) { - struct list_head *elem, *tmp; + list_for_each_safe(elem, tmp, paths) { + struct path_c *path = + list_entry(elem, struct path_c, list); - list_for_each_safe(elem, tmp, lists[i]) { - struct path_c *path = - list_entry(elem, struct path_c, list); - - list_del(elem); - kfree(path); - } + list_del(elem); + kfree(path); } - spin_unlock(&nc->lock); +} +/* Path selector destructor */ +static void null_dtr(struct path_selector *ps) +{ + struct null_c *nc = (struct null_c *) ps->context; + free_paths(&nc->paths); + free_paths(&nc->failed_paths); kfree(nc); - ps->context = NULL; } /* Path add context */ @@ -120,7 +114,7 @@ return NULL; } - pc = _alloc_path_c(); + pc = alloc_path_c(); if (!pc) { *error = "null path selector: Error allocating path context"; return NULL; @@ -128,13 +122,13 @@ pc->path = path; pc->nc = nc; + spin_lock(&nc->lock); list_add_tail(&pc->list, &nc->paths); spin_unlock(&nc->lock); return (void *) pc; } -#undef xx /* Path set state (state = 0 : operational; state != 0 : failed */ static void null_set_path_state(void *ps_private, unsigned long state) @@ -150,7 +144,7 @@ /* Path selector */ static struct path *null_select_path(struct path_selector *ps, - struct buffer_head *bh, int rw, + struct bio *bio, struct path_info *path_context) { unsigned long flags; --- diff/drivers/md/dm-path-selector.h 2003-12-29 10:15:37.000000000 +0000 +++ source/drivers/md/dm-path-selector.h 2003-12-29 10:15:43.000000000 +0000 @@ -36,6 +36,8 @@ * Add an opaque path object, along with some selector specific * path args (eg, path priority). */ +/* + * FIXME: what is this returning ? */ typedef void * (*ps_add_path_fn) (struct path_selector *ps, struct path *path, int argc, char **argv, char **error);