dm-mpath: Don't probe paths that are getting initialized
Benjamin Marzinski
maintainerPATCH 1/1 dm-mpath: Don't probe paths that are getting initialized
__switch_pg() sets m->current_pg before initializing the pathgroup. If probe_active_paths() is called and pathgroup has not been fully initialized, IO to the paths may fail, even though they will be usable when the pathgroup has finished initializing. Instead, skip sending IO in this situation and just return the number of usable paths. The next request will wait for the pathgroup to be fully initialized.
--- drivers/md/dm-mpath.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
drivers/md/dm-mpath.c +12 -3
@@ -2068,19 +2068,28 @@ static int probe_path(struct pgpath *pgpath)* * Return -ENOTCONN if no valid path is left (even outside of current_pg). We * cannot probe paths in other pgs without switching current_pg, so if valid -* paths are only in different pgs, they may or may not work. Userspace can -* submit a request and we'll switch. If the request fails, it may need to +* paths are only in different pgs, they may or may not work. Additionally +* we should not probe paths in a pathgroup that is in the process of +* Initializing. Userspace can submit a request and we'll switch and wait +* for the pathgroup to be initialized. If the request fails, it may need to * probe again. */ static int probe_active_paths (struct multipath *m) {struct pgpath *pgpath;struct priority_group *pg; +unsigned long flags;int r =0 ;mutex_lock (&m->work_mutex); - pg =READ_ONCE (m->current_pg); +spin_lock_irqsave (&m->lock, flags); +if (test_bit (MPATHF_QUEUE_IO , &m->flags)) + pg =NULL ; +else + pg = m->current_pg; +spin_unlock_irqrestore (&m->lock, flags); +if (pg) {list_for_each_entry (pgpath, &pg->pgpaths, list) {if (!pgpath->is_active)
Signature · 1 line
2.48.1
Quoted 7 lines · Benjamin Marzinski
__switch_pg()setsm->current_pgbefore initializing the pathgroup. Ifprobe_active_paths()is called and pathgroup has not been fully initialized, IO to the paths may fail, even though they will be usable when the pathgroup has finished initializing. Instead, skip sending IO in this situation and just return the number of usable paths. The next request will wait for the pathgroup to be fully initialized.
Quoted 5 lines
Fixes d5d16fabe431 ("dm mpath: Interface for explicit probing of active paths")Signed-off-by Benjamin Marzinski <[email protected]>--- drivers/md/dm-mpath.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
Quoted 36 lines
drivers/md/dm-mpath.c +12
-3@@ -2068,19 +2068,28 @@ static int probe_path(struct pgpath *pgpath)* * Return -ENOTCONN if no valid path is left (even outside of current_pg). We * cannot probe paths in other pgs without switching current_pg, so if valid -* paths are only in different pgs, they may or may not work. Userspace can -* submit a request and we'll switch. If the request fails, it may need to +* paths are only in different pgs, they may or may not work. Additionally +* we should not probe paths in a pathgroup that is in the process of +* Initializing. Userspace can submit a request and we'll switch and wait +* for the pathgroup to be initialized. If the request fails, it may need to * probe again. */ static int probe_active_paths (struct multipath *m) {struct pgpath *pgpath;struct priority_group *pg; +unsigned long flags;int r =0 ;mutex_lock (&m->work_mutex); - pg =READ_ONCE (m->current_pg); +spin_lock_irqsave (&m->lock, flags); +if (test_bit (MPATHF_QUEUE_IO , &m->flags)) + pg =NULL ; +else + pg = m->current_pg; +spin_unlock_irqrestore (&m->lock, flags); +if (pg) {list_for_each_entry (pgpath, &pg->pgpaths, list) {if (!pgpath->is_active)
Mikulas Patocka
maintainerQuoted 6 lines · Benjamin Marzinski
__switch_pg()setsm->current_pgbefore initializing the pathgroup. Ifprobe_active_paths()is called and pathgroup has not been fully initialized, IO to the paths may fail, even though they will be usable when the pathgroup has finished initializing. Instead, skip sending IO in this situation and just return the number of usable paths. The next request will wait for the pathgroup to be fully initialized.
Thanks.
I folded this change into the existing patch.
Mikulas
Quoted 45 lines
Fixes d5d16fabe431 ("dm mpath: Interface for explicit probing of active paths")Signed-off-by Benjamin Marzinski <[email protected]>--- drivers/md/dm-mpath.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)drivers/md/dm-mpath.c +12
-3@@ -2068,19 +2068,28 @@ static int probe_path(struct pgpath *pgpath)* * Return -ENOTCONN if no valid path is left (even outside of current_pg). We * cannot probe paths in other pgs without switching current_pg, so if valid -* paths are only in different pgs, they may or may not work. Userspace can -* submit a request and we'll switch. If the request fails, it may need to +* paths are only in different pgs, they may or may not work. Additionally +* we should not probe paths in a pathgroup that is in the process of +* Initializing. Userspace can submit a request and we'll switch and wait +* for the pathgroup to be initialized. If the request fails, it may need to * probe again. */ static int probe_active_paths (struct multipath *m) {struct pgpath *pgpath;struct priority_group *pg; +unsigned long flags;int r =0 ;mutex_lock (&m->work_mutex); - pg =READ_ONCE (m->current_pg); +spin_lock_irqsave (&m->lock, flags); +if (test_bit (MPATHF_QUEUE_IO , &m->flags)) + pg =NULL ; +else + pg = m->current_pg; +spin_unlock_irqrestore (&m->lock, flags); +if (pg) {list_for_each_entry (pgpath, &pg->pgpaths, list) {if (!pgpath->is_active)Signature · 1 line
2.48.1