Commit 2eff1924 authored by Mike Snitzer's avatar Mike Snitzer

dm mpath: cleanup 'struct dm_mpath_io' management code

Refactor and rename existing interfaces to be more specific and
self-documenting.
Signed-off-by: default avatarMike Snitzer <snitzer@redhat.com>
parent 8637a6bf
...@@ -228,30 +228,35 @@ static void free_multipath(struct multipath *m) ...@@ -228,30 +228,35 @@ static void free_multipath(struct multipath *m)
kfree(m); kfree(m);
} }
static int set_mapinfo(struct multipath *m, union map_info *info) static struct dm_mpath_io *get_mpio(union map_info *info)
{
return info->ptr;
}
static struct dm_mpath_io *set_mpio(struct multipath *m, union map_info *info)
{ {
struct dm_mpath_io *mpio; struct dm_mpath_io *mpio;
if (!m->mpio_pool) { if (!m->mpio_pool) {
/* Use blk-mq pdu memory requested via per_io_data_size */ /* Use blk-mq pdu memory requested via per_io_data_size */
mpio = info->ptr; mpio = get_mpio(info);
memset(mpio, 0, sizeof(*mpio)); memset(mpio, 0, sizeof(*mpio));
return mpio; return mpio;
} }
mpio = mempool_alloc(m->mpio_pool, GFP_ATOMIC); mpio = mempool_alloc(m->mpio_pool, GFP_ATOMIC);
if (!mpio) if (!mpio)
return -ENOMEM; return NULL;
memset(mpio, 0, sizeof(*mpio)); memset(mpio, 0, sizeof(*mpio));
info->ptr = mpio; info->ptr = mpio;
return 0; return mpio;
} }
static void clear_mapinfo(struct multipath *m, union map_info *info) static void clear_request_fn_mpio(struct multipath *m, union map_info *info)
{ {
/* Only needed for non blk-mq */ /* Only needed for non blk-mq (.request_fn) multipath */
if (m->mpio_pool) { if (m->mpio_pool) {
struct dm_mpath_io *mpio = info->ptr; struct dm_mpath_io *mpio = info->ptr;
...@@ -421,11 +426,11 @@ static int __multipath_map(struct dm_target *ti, struct request *clone, ...@@ -421,11 +426,11 @@ static int __multipath_map(struct dm_target *ti, struct request *clone,
goto out_unlock; goto out_unlock;
} }
if (set_mapinfo(m, map_context) < 0) mpio = set_mpio(m, map_context);
if (!mpio)
/* ENOMEM, requeue */ /* ENOMEM, requeue */
goto out_unlock; goto out_unlock;
mpio = map_context->ptr;
mpio->pgpath = pgpath; mpio->pgpath = pgpath;
mpio->nr_bytes = nr_bytes; mpio->nr_bytes = nr_bytes;
...@@ -451,7 +456,7 @@ static int __multipath_map(struct dm_target *ti, struct request *clone, ...@@ -451,7 +456,7 @@ static int __multipath_map(struct dm_target *ti, struct request *clone,
rq_data_dir(rq), GFP_ATOMIC); rq_data_dir(rq), GFP_ATOMIC);
if (IS_ERR(*__clone)) { if (IS_ERR(*__clone)) {
/* ENOMEM, requeue */ /* ENOMEM, requeue */
clear_mapinfo(m, map_context); clear_request_fn_mpio(m, map_context);
return r; return r;
} }
(*__clone)->bio = (*__clone)->biotail = NULL; (*__clone)->bio = (*__clone)->biotail = NULL;
...@@ -1317,7 +1322,7 @@ static int multipath_end_io(struct dm_target *ti, struct request *clone, ...@@ -1317,7 +1322,7 @@ static int multipath_end_io(struct dm_target *ti, struct request *clone,
int error, union map_info *map_context) int error, union map_info *map_context)
{ {
struct multipath *m = ti->private; struct multipath *m = ti->private;
struct dm_mpath_io *mpio = map_context->ptr; struct dm_mpath_io *mpio = get_mpio(map_context);
struct pgpath *pgpath; struct pgpath *pgpath;
struct path_selector *ps; struct path_selector *ps;
int r; int r;
...@@ -1331,7 +1336,7 @@ static int multipath_end_io(struct dm_target *ti, struct request *clone, ...@@ -1331,7 +1336,7 @@ static int multipath_end_io(struct dm_target *ti, struct request *clone,
if (ps->type->end_io) if (ps->type->end_io)
ps->type->end_io(ps, &pgpath->path, mpio->nr_bytes); ps->type->end_io(ps, &pgpath->path, mpio->nr_bytes);
} }
clear_mapinfo(m, map_context); clear_request_fn_mpio(m, map_context);
return r; return r;
} }
......
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