Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 154260
b: refs/heads/master
c: 02ab823
h: refs/heads/master
v: v3
  • Loading branch information
Kiyoshi Ueda authored and Alasdair G Kergon committed Jun 22, 2009
1 parent 0d1689c commit 63ca79d
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 14 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 2bd023452592e5f5cf90dd426cc39b7632b15b76
refs/heads/master: 02ab823fd1a27d193bda06b74fdad685a20a3e5e
28 changes: 18 additions & 10 deletions trunk/drivers/md/dm-mpath.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ struct multipath {
struct dm_mpath_io {
struct pgpath *pgpath;
struct dm_bio_details details;
size_t nr_bytes;
};

typedef int (*action_fn) (struct pgpath *pgpath);
Expand Down Expand Up @@ -244,11 +245,12 @@ static void __switch_pg(struct multipath *m, struct pgpath *pgpath)
m->pg_init_count = 0;
}

static int __choose_path_in_pg(struct multipath *m, struct priority_group *pg)
static int __choose_path_in_pg(struct multipath *m, struct priority_group *pg,
size_t nr_bytes)
{
struct dm_path *path;

path = pg->ps.type->select_path(&pg->ps, &m->repeat_count);
path = pg->ps.type->select_path(&pg->ps, &m->repeat_count, nr_bytes);
if (!path)
return -ENXIO;

Expand All @@ -260,7 +262,7 @@ static int __choose_path_in_pg(struct multipath *m, struct priority_group *pg)
return 0;
}

static void __choose_pgpath(struct multipath *m)
static void __choose_pgpath(struct multipath *m, size_t nr_bytes)
{
struct priority_group *pg;
unsigned bypassed = 1;
Expand All @@ -272,12 +274,12 @@ static void __choose_pgpath(struct multipath *m)
if (m->next_pg) {
pg = m->next_pg;
m->next_pg = NULL;
if (!__choose_path_in_pg(m, pg))
if (!__choose_path_in_pg(m, pg, nr_bytes))
return;
}

/* Don't change PG until it has no remaining paths */
if (m->current_pg && !__choose_path_in_pg(m, m->current_pg))
if (m->current_pg && !__choose_path_in_pg(m, m->current_pg, nr_bytes))
return;

/*
Expand All @@ -289,7 +291,7 @@ static void __choose_pgpath(struct multipath *m)
list_for_each_entry(pg, &m->priority_groups, list) {
if (pg->bypassed == bypassed)
continue;
if (!__choose_path_in_pg(m, pg))
if (!__choose_path_in_pg(m, pg, nr_bytes))
return;
}
} while (bypassed--);
Expand Down Expand Up @@ -320,6 +322,7 @@ static int map_io(struct multipath *m, struct bio *bio,
struct dm_mpath_io *mpio, unsigned was_queued)
{
int r = DM_MAPIO_REMAPPED;
size_t nr_bytes = bio->bi_size;
unsigned long flags;
struct pgpath *pgpath;

Expand All @@ -328,7 +331,7 @@ static int map_io(struct multipath *m, struct bio *bio,
/* Do we need to select a new pgpath? */
if (!m->current_pgpath ||
(!m->queue_io && (m->repeat_count && --m->repeat_count == 0)))
__choose_pgpath(m);
__choose_pgpath(m, nr_bytes);

pgpath = m->current_pgpath;

Expand All @@ -353,6 +356,11 @@ static int map_io(struct multipath *m, struct bio *bio,
r = -EIO; /* Failed */

mpio->pgpath = pgpath;
mpio->nr_bytes = nr_bytes;

if (r == DM_MAPIO_REMAPPED && pgpath->pg->ps.type->start_io)
pgpath->pg->ps.type->start_io(&pgpath->pg->ps, &pgpath->path,
nr_bytes);

spin_unlock_irqrestore(&m->lock, flags);

Expand Down Expand Up @@ -431,7 +439,7 @@ static void process_queued_ios(struct work_struct *work)
goto out;

if (!m->current_pgpath)
__choose_pgpath(m);
__choose_pgpath(m, 0);

pgpath = m->current_pgpath;

Expand Down Expand Up @@ -1209,7 +1217,7 @@ static int multipath_end_io(struct dm_target *ti, struct bio *bio,
if (pgpath) {
ps = &pgpath->pg->ps;
if (ps->type->end_io)
ps->type->end_io(ps, &pgpath->path);
ps->type->end_io(ps, &pgpath->path, mpio->nr_bytes);
}
if (r != DM_ENDIO_INCOMPLETE)
mempool_free(mpio, m->mpio_pool);
Expand Down Expand Up @@ -1425,7 +1433,7 @@ static int multipath_ioctl(struct dm_target *ti, unsigned int cmd,
spin_lock_irqsave(&m->lock, flags);

if (!m->current_pgpath)
__choose_pgpath(m);
__choose_pgpath(m, 0);

if (m->current_pgpath) {
bdev = m->current_pgpath->path.dev->bdev;
Expand Down
8 changes: 6 additions & 2 deletions trunk/drivers/md/dm-path-selector.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ struct path_selector_type {
* the path fails.
*/
struct dm_path *(*select_path) (struct path_selector *ps,
unsigned *repeat_count);
unsigned *repeat_count,
size_t nr_bytes);

/*
* Notify the selector that a path has failed.
Expand All @@ -75,7 +76,10 @@ struct path_selector_type {
int (*status) (struct path_selector *ps, struct dm_path *path,
status_type_t type, char *result, unsigned int maxlen);

int (*end_io) (struct path_selector *ps, struct dm_path *path);
int (*start_io) (struct path_selector *ps, struct dm_path *path,
size_t nr_bytes);
int (*end_io) (struct path_selector *ps, struct dm_path *path,
size_t nr_bytes);
};

/* Register a path selector */
Expand Down
2 changes: 1 addition & 1 deletion trunk/drivers/md/dm-round-robin.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ static int rr_reinstate_path(struct path_selector *ps, struct dm_path *p)
}

static struct dm_path *rr_select_path(struct path_selector *ps,
unsigned *repeat_count)
unsigned *repeat_count, size_t nr_bytes)
{
struct selector *s = (struct selector *) ps->context;
struct path_info *pi = NULL;
Expand Down

0 comments on commit 63ca79d

Please sign in to comment.