Skip to content

Commit a48f6b8

Browse files
bmarzinsMikulas Patocka
authored andcommitted
dm mpath: don't call dm_get_device in multipath_message
When mutipath_message is called with an action and a device, it needs to find the pgpath that matches that device. dm_get_device() is not the right function for this. dm_get_device() will look for a table_device matching the requested path in use by either the live or inactive table. If it doesn't find the device, dm_get_device() will open it and add it to the table. Means that multipath_message will accept any block device, add it to the table if not present, and then look through the pgpaths to see if it finds a match. Afterwards it will remove the device if it was not previously in the table devices list. This is the only function that can modify the device list of a table besides the constructors and destructors, and it can only do this when it was passed an invalid message. Instead, multipath_message() should call dm_devt_from_path() to get the device dev_t, and match that against its pgpaths. Signed-off-by: Benjamin Marzinski <[email protected]> Signed-off-by: Mikulas Patocka <[email protected]>
1 parent a21f9ed commit a48f6b8

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

drivers/md/dm-mpath.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1419,16 +1419,15 @@ static int reinstate_path(struct pgpath *pgpath)
14191419
/*
14201420
* Fail or reinstate all paths that match the provided struct dm_dev.
14211421
*/
1422-
static int action_dev(struct multipath *m, struct dm_dev *dev,
1423-
action_fn action)
1422+
static int action_dev(struct multipath *m, dev_t dev, action_fn action)
14241423
{
14251424
int r = -EINVAL;
14261425
struct pgpath *pgpath;
14271426
struct priority_group *pg;
14281427

14291428
list_for_each_entry(pg, &m->priority_groups, list) {
14301429
list_for_each_entry(pgpath, &pg->pgpaths, list) {
1431-
if (pgpath->path.dev == dev)
1430+
if (pgpath->path.dev->bdev->bd_dev == dev)
14321431
r = action(pgpath);
14331432
}
14341433
}
@@ -1959,7 +1958,7 @@ static int multipath_message(struct dm_target *ti, unsigned int argc, char **arg
19591958
char *result, unsigned int maxlen)
19601959
{
19611960
int r = -EINVAL;
1962-
struct dm_dev *dev;
1961+
dev_t dev;
19631962
struct multipath *m = ti->private;
19641963
action_fn action;
19651964
unsigned long flags;
@@ -2008,7 +2007,7 @@ static int multipath_message(struct dm_target *ti, unsigned int argc, char **arg
20082007
goto out;
20092008
}
20102009

2011-
r = dm_get_device(ti, argv[1], dm_table_get_mode(ti->table), &dev);
2010+
r = dm_devt_from_path(argv[1], &dev);
20122011
if (r) {
20132012
DMWARN("message: error getting device %s",
20142013
argv[1]);
@@ -2017,8 +2016,6 @@ static int multipath_message(struct dm_target *ti, unsigned int argc, char **arg
20172016

20182017
r = action_dev(m, dev, action);
20192018

2020-
dm_put_device(ti, dev);
2021-
20222019
out:
20232020
mutex_unlock(&m->work_mutex);
20242021
return r;

0 commit comments

Comments
 (0)