Commit 7250613f authored by Alasdair G. Kergon's avatar Alasdair G. Kergon Committed by Linus Torvalds

[PATCH] device-mapper: Some code/formatting cleanups

Some multipath code/formatting cleanups
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 32ff840b
...@@ -167,11 +167,8 @@ static struct request *emc_trespass_get(struct emc_handler *h, ...@@ -167,11 +167,8 @@ static struct request *emc_trespass_get(struct emc_handler *h,
page22 = (unsigned char *)bio_data(bio); page22 = (unsigned char *)bio_data(bio);
memset(page22, 0, data_size); memset(page22, 0, data_size);
if (h->short_trespass) { memcpy(page22, h->short_trespass ?
memcpy(page22, short_trespass_pg, data_size); short_trespass_pg : long_trespass_pg, data_size);
} else {
memcpy(page22, long_trespass_pg, data_size);
}
/* get request for block layer packet command */ /* get request for block layer packet command */
rq = get_failover_req(h, bio, path); rq = get_failover_req(h, bio, path);
...@@ -226,9 +223,8 @@ static struct emc_handler *alloc_emc_handler(void) ...@@ -226,9 +223,8 @@ static struct emc_handler *alloc_emc_handler(void)
{ {
struct emc_handler *h = kmalloc(sizeof(*h), GFP_KERNEL); struct emc_handler *h = kmalloc(sizeof(*h), GFP_KERNEL);
if (h) { if (h)
h->lock = SPIN_LOCK_UNLOCKED; spin_lock_init(&h->lock);
}
return h; return h;
} }
......
...@@ -22,27 +22,19 @@ struct hw_handler { ...@@ -22,27 +22,19 @@ struct hw_handler {
/* /*
* Constructs a hardware handler object, takes custom arguments * Constructs a hardware handler object, takes custom arguments
*/ */
typedef int (*hwh_ctr_fn) (struct hw_handler *hwh, unsigned arc, char **argv);
typedef void (*hwh_dtr_fn) (struct hw_handler *hwh);
typedef void (*hwh_pg_init_fn) (struct hw_handler *hwh, unsigned bypassed,
struct path *path);
typedef unsigned (*hwh_err_fn) (struct hw_handler *hwh, struct bio *bio);
typedef int (*hwh_status_fn) (struct hw_handler *hwh,
status_type_t type,
char *result, unsigned int maxlen);
/* Information about a hardware handler type */ /* Information about a hardware handler type */
struct hw_handler_type { struct hw_handler_type {
char *name; char *name;
struct module *module; struct module *module;
hwh_ctr_fn ctr; int (*ctr) (struct hw_handler *handler, unsigned int argc, char **argv);
hwh_dtr_fn dtr; void (*dtr) (struct hw_handler *hwh);
hwh_pg_init_fn pg_init; void (*pg_init) (struct hw_handler *hwh, unsigned bypassed,
hwh_err_fn err; struct path *path);
hwh_status_fn status; unsigned (*err) (struct hw_handler *hwh, struct bio *bio);
int (*status) (struct hw_handler *hwh, status_type_t type,
char *result, unsigned int maxlen);
}; };
/* Register a hardware handler */ /* Register a hardware handler */
...@@ -57,10 +49,10 @@ struct hw_handler_type *dm_get_hw_handler(const char *name); ...@@ -57,10 +49,10 @@ struct hw_handler_type *dm_get_hw_handler(const char *name);
/* Releases a hardware handler */ /* Releases a hardware handler */
void dm_put_hw_handler(struct hw_handler_type *hwht); void dm_put_hw_handler(struct hw_handler_type *hwht);
/* Default hwh_err_fn */ /* Default err function */
unsigned dm_scsi_err_handler(struct hw_handler *hwh, struct bio *bio); unsigned dm_scsi_err_handler(struct hw_handler *hwh, struct bio *bio);
/* Error flags for hwh_err_fn and dm_pg_init_complete */ /* Error flags for err and dm_pg_init_complete */
#define MP_FAIL_PATH 1 #define MP_FAIL_PATH 1
#define MP_BYPASS_PG 2 #define MP_BYPASS_PG 2
#define MP_ERROR_IO 4 /* Don't retry this I/O */ #define MP_ERROR_IO 4 /* Don't retry this I/O */
......
...@@ -144,7 +144,7 @@ static void free_pgpaths(struct list_head *pgpaths, struct dm_target *ti) ...@@ -144,7 +144,7 @@ static void free_pgpaths(struct list_head *pgpaths, struct dm_target *ti)
{ {
struct pgpath *pgpath, *tmp; struct pgpath *pgpath, *tmp;
list_for_each_entry_safe (pgpath, tmp, pgpaths, list) { list_for_each_entry_safe(pgpath, tmp, pgpaths, list) {
list_del(&pgpath->list); list_del(&pgpath->list);
dm_put_device(ti, pgpath->path.dev); dm_put_device(ti, pgpath->path.dev);
free_pgpath(pgpath); free_pgpath(pgpath);
...@@ -173,7 +173,7 @@ static struct multipath *alloc_multipath(void) ...@@ -173,7 +173,7 @@ static struct multipath *alloc_multipath(void)
if (m) { if (m) {
memset(m, 0, sizeof(*m)); memset(m, 0, sizeof(*m));
INIT_LIST_HEAD(&m->priority_groups); INIT_LIST_HEAD(&m->priority_groups);
m->lock = SPIN_LOCK_UNLOCKED; spin_lock_init(&m->lock);
m->queue_io = 1; m->queue_io = 1;
INIT_WORK(&m->process_queued_ios, process_queued_ios, m); INIT_WORK(&m->process_queued_ios, process_queued_ios, m);
INIT_WORK(&m->trigger_event, trigger_event, m); INIT_WORK(&m->trigger_event, trigger_event, m);
...@@ -193,7 +193,7 @@ static void free_multipath(struct multipath *m) ...@@ -193,7 +193,7 @@ static void free_multipath(struct multipath *m)
struct priority_group *pg, *tmp; struct priority_group *pg, *tmp;
struct hw_handler *hwh = &m->hw_handler; struct hw_handler *hwh = &m->hw_handler;
list_for_each_entry_safe (pg, tmp, &m->priority_groups, list) { list_for_each_entry_safe(pg, tmp, &m->priority_groups, list) {
list_del(&pg->list); list_del(&pg->list);
free_priority_group(pg, m->ti); free_priority_group(pg, m->ti);
} }
...@@ -270,7 +270,7 @@ static void __choose_pgpath(struct multipath *m) ...@@ -270,7 +270,7 @@ static void __choose_pgpath(struct multipath *m)
* Second time we only try the ones we skipped. * Second time we only try the ones we skipped.
*/ */
do { do {
list_for_each_entry (pg, &m->priority_groups, list) { list_for_each_entry(pg, &m->priority_groups, list) {
if (pg->bypassed == bypassed) if (pg->bypassed == bypassed)
continue; continue;
if (!__choose_path_in_pg(m, pg)) if (!__choose_path_in_pg(m, pg))
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
#ifndef DM_MPATH_H #ifndef DM_MPATH_H
#define DM_MPATH_H #define DM_MPATH_H
#include <linux/device-mapper.h> struct dm_dev;
struct path { struct path {
struct dm_dev *dev; /* Read-only */ struct dm_dev *dev; /* Read-only */
......
...@@ -30,7 +30,7 @@ struct ps_internal *__find_path_selector_type(const char *name) ...@@ -30,7 +30,7 @@ struct ps_internal *__find_path_selector_type(const char *name)
{ {
struct ps_internal *psi; struct ps_internal *psi;
list_for_each_entry (psi, &_path_selectors, list) { list_for_each_entry(psi, &_path_selectors, list) {
if (!strcmp(name, psi->pst.name)) if (!strcmp(name, psi->pst.name))
return psi; return psi;
} }
......
...@@ -26,53 +26,6 @@ struct path_selector { ...@@ -26,53 +26,6 @@ struct path_selector {
void *context; void *context;
}; };
/*
* Constructs a path selector object, takes custom arguments
*/
typedef int (*ps_ctr_fn) (struct path_selector *ps, unsigned argc, char **argv);
typedef void (*ps_dtr_fn) (struct path_selector *ps);
/*
* Add an opaque path object, along with some selector specific
* path args (eg, path priority).
*/
typedef int (*ps_add_path_fn) (struct path_selector *ps, struct path *path,
int argc, char **argv, char **error);
/*
* Chooses a path for this io, if no paths are available then
* NULL will be returned.
*
* repeat_count is the number of times to use the path before
* calling the function again. 0 means don't call it again unless
* the path fails.
*/
typedef struct path *(*ps_select_path_fn) (struct path_selector *ps,
unsigned *repeat_count);
/*
* Notify the selector that a path has failed.
*/
typedef void (*ps_fail_path_fn) (struct path_selector *ps,
struct path *p);
/*
* Ask selector to reinstate a path.
*/
typedef int (*ps_reinstate_path_fn) (struct path_selector *ps,
struct path *p);
/*
* Table content based on parameters added in ps_add_path_fn
* or path selector status
*/
typedef int (*ps_status_fn) (struct path_selector *ps,
struct path *path,
status_type_t type,
char *result, unsigned int maxlen);
typedef int (*ps_end_io_fn) (struct path_selector *ps, struct path *path);
/* Information about a path selector type */ /* Information about a path selector type */
struct path_selector_type { struct path_selector_type {
char *name; char *name;
...@@ -80,15 +33,49 @@ struct path_selector_type { ...@@ -80,15 +33,49 @@ struct path_selector_type {
unsigned int table_args; unsigned int table_args;
unsigned int info_args; unsigned int info_args;
ps_ctr_fn ctr;
ps_dtr_fn dtr; /*
* Constructs a path selector object, takes custom arguments
ps_add_path_fn add_path; */
ps_fail_path_fn fail_path; int (*ctr) (struct path_selector *ps, unsigned argc, char **argv);
ps_reinstate_path_fn reinstate_path; void (*dtr) (struct path_selector *ps);
ps_select_path_fn select_path;
ps_status_fn status; /*
ps_end_io_fn end_io; * Add an opaque path object, along with some selector specific
* path args (eg, path priority).
*/
int (*add_path) (struct path_selector *ps, struct path *path,
int argc, char **argv, char **error);
/*
* Chooses a path for this io, if no paths are available then
* NULL will be returned.
*
* repeat_count is the number of times to use the path before
* calling the function again. 0 means don't call it again unless
* the path fails.
*/
struct path *(*select_path) (struct path_selector *ps,
unsigned *repeat_count);
/*
* Notify the selector that a path has failed.
*/
void (*fail_path) (struct path_selector *ps, struct path *p);
/*
* Ask selector to reinstate a path.
*/
int (*reinstate_path) (struct path_selector *ps, struct path *p);
/*
* Table content based on parameters added in ps_add_path_fn
* or path selector status
*/
int (*status) (struct path_selector *ps, struct path *path,
status_type_t type, char *result, unsigned int maxlen);
int (*end_io) (struct path_selector *ps, struct path *path);
}; };
/* Register a path selector */ /* Register a path selector */
......
...@@ -27,7 +27,7 @@ static void free_paths(struct list_head *paths) ...@@ -27,7 +27,7 @@ static void free_paths(struct list_head *paths)
{ {
struct path_info *pi, *next; struct path_info *pi, *next;
list_for_each_entry_safe (pi, next, paths, list) { list_for_each_entry_safe(pi, next, paths, list) {
list_del(&pi->list); list_del(&pi->list);
kfree(pi); kfree(pi);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment