multipathd: fix mpp->nr_active more than actually active
Benjamin Marzinski
maintainerQuoted 24 lines · Martin Wilck
Quoted 20 lines · Chongyun Wu
Hi Martin, Ben and other viewers
Cloud you help to view below patch, we have reproduce this issue and found a way to fix it, thanks.
From
b3e5d5919668b03185a039fb54962c47d339bb54Mon Sep 17 00:00:00 2001
From: Chongyun Wu <[email protected]>
Date: Wed, 13 Nov 2019 14:52:07 +0800
Subject: [PATCH] multipathd: fixmpp->nr_activemore than actually active
paths countIn
check_pathif path check thread not return in next round check but return before timeout happen, the path state will bePAHT_PENDING, when return upcheck_pathwill try to callreinstate_path, in this situation should not pass add_active=1 intoreinstate_pathfunc as parameter, other wise thempp->nr_activewill bigger than actually active paths count.Quoted 2 lines
We have a environment can reproduce this issue, with this patch issue not found again.
Quoted 6 lines
I wonder how this can happen. In my opinion
pp->statecan never be set toPATH_PENDING, and thus oldstate can never have that value, either.Are you running the latest upstream code? In particular, do you have
e224d57a13cb("libmutipath: continue to use old state onPATH_PENDING")?
Not that it matters to the correctness of this patch, bub that commit does allow pp->state to be set to PATH_PENDING. It's just pretty convoluted. You need two calls to pathinfo, the first needs to set the path state to PATH_WILD or PATH_UNCHECKED, and a later one needs to set the path state to PATH_PENDING. Then the path will be in a PATH_PENDING state during the call to check path. Perhaps pathinfo should never set a path's state to PATH_WILD, PATH_UNCHECKED, or PATH_PENDING, unless it is already one of those values.
But I still don't see how the patch helps. check_path() calls set_no_path_retry(), which will recalculate nr_active, counting any path not in PATH_UP or PATH_GHOST as down. Because of this, it should always be correct to set add_active when a path changes from a state that isn't PATH_UP or PATH_GHOST to one of those states. Do you know why this wouldn't be happening in your scenario?
Quoted 4 lines
Anyway, the ongoing struggle to get
nr_activeright bothers me.@Ben, I'm inclined to remove
nr_activealtogether and calculate it on the fly. What do you think?
I would happily ACK a patch that always calculated the current number of active paths on the fly.
Quoted 3 lines
Regards
Martin