Skip to content

Commit

Permalink
dm mpath: remove extra nesting in map function
Browse files Browse the repository at this point in the history
Return early for case when no path exists, and when the
pathgroup isn't ready. This eliminates the need for
extra nesting for the the common case.

Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Hannes Reinecke <hare@suse.de>
  • Loading branch information
Mike Snitzer committed Mar 27, 2014
1 parent 36fcffc commit 9bf59a6
Showing 1 changed file with 24 additions and 22 deletions.
46 changes: 24 additions & 22 deletions drivers/md/dm-mpath.c
Original file line number Diff line number Diff line change
Expand Up @@ -398,29 +398,31 @@ static int multipath_map(struct dm_target *ti, struct request *clone,

pgpath = m->current_pgpath;

if (pgpath) {
if (pg_ready(m)) {
if (set_mapinfo(m, map_context) < 0)
/* ENOMEM, requeue */
goto out_unlock;

bdev = pgpath->path.dev->bdev;
clone->q = bdev_get_queue(bdev);
clone->rq_disk = bdev->bd_disk;
clone->cmd_flags |= REQ_FAILFAST_TRANSPORT;
mpio = map_context->ptr;
mpio->pgpath = pgpath;
mpio->nr_bytes = nr_bytes;
if (pgpath->pg->ps.type->start_io)
pgpath->pg->ps.type->start_io(&pgpath->pg->ps,
&pgpath->path,
nr_bytes);
r = DM_MAPIO_REMAPPED;
goto out_unlock;
}
if (!pgpath) {
if (!__must_push_back(m))
r = -EIO; /* Failed */
goto out_unlock;
}
if (!pg_ready(m)) {
__pg_init_all_paths(m);
} else if (!__must_push_back(m))
r = -EIO; /* Failed */
goto out_unlock;
}
if (set_mapinfo(m, map_context) < 0)
/* ENOMEM, requeue */
goto out_unlock;

bdev = pgpath->path.dev->bdev;
clone->q = bdev_get_queue(bdev);
clone->rq_disk = bdev->bd_disk;
clone->cmd_flags |= REQ_FAILFAST_TRANSPORT;
mpio = map_context->ptr;
mpio->pgpath = pgpath;
mpio->nr_bytes = nr_bytes;
if (pgpath->pg->ps.type->start_io)
pgpath->pg->ps.type->start_io(&pgpath->pg->ps,
&pgpath->path,
nr_bytes);
r = DM_MAPIO_REMAPPED;

out_unlock:
spin_unlock_irqrestore(&m->lock, flags);
Expand Down

0 comments on commit 9bf59a6

Please sign in to comment.