Double calling of app_ch_dec_thread
luochen01 opened this issue · comments
In the latest v2.6 version, I saw the channel counter is decremented twice in gl-prov. The first call is at [1] when gl-prov allocates the provision list. The second call is at [2] when the provision list is freed (after writes have been executed). This is clearly a bug and the channel counter should only be decremented once.
The question is when should the counter be decremented? Perhaps it should be decremented at [2] after writes have been executed.
[1]
ox-ctrl/ftl/ox-app/block/oxb-gl-prov.c
Line 233 in 1fd9aea
[2]
ox-ctrl/ftl/ox-app/block/oxb-gl-prov.c
Line 271 in 1fd9aea
Dear Chen,
Thank you for opening the issue. I have analyzed it this is what I found:
We have 2 arrays:
(i) prov_ppa->ch[ch_id] : Stores pointers to channels of provisioned PPAs. If a position is NULL, the related channel (with the same index) is not provisioned.
(ii) dec_ch[ch_id] : Stores pointers to channels that NOT provisioned. If a position is NULL, the related channel is provisioned.
-
It starts by setting ALL active channels to both arrays:
ox-ctrl/ftl/ox-app/block/oxb-gl-prov.c
Line 117 in 1fd9aea
-
Provisioned channels are removed from 'dec_ch':
ox-ctrl/ftl/ox-app/block/oxb-gl-prov.c
Line 195 in 1fd9aea
-
After PPAs are provisioned, we decrease channels that might have been deactivated during the process and channels that were not used (we check for NULL pointers at 'dec_ch'):
ox-ctrl/ftl/ox-app/block/oxb-gl-prov.c
Lines 231 to 233 in 1fd9aea
Note: 'dec_ch' was defined because we need the pointer to the channels to be decreased at line 233.
Note: We start the function by increasing all active channels, and decrease the ones that were not provisioned at the end.
Suggestion: We may change the function to increase only provisioned channels. The increase function replaces the 'dec_ch' array at the line:
ox-ctrl/ftl/ox-app/block/oxb-gl-prov.c
Line 195 in 1fd9aea
Any comments?
Hi Ivan,
To summarize the analysis, the non-provisioned channels can be decremented twice, one after provisioning and one after writing is completed.
To address this problem, after we decrement the non-provisioned channels, shouldn't we unset the corresponding channel from prov_ppa->ch to NULL?