Simplify afs_cell record handling to avoid very occasional races that cause module removal to hang (it waits for all cell records to be removed). There are two things that particularly contribute to the difficulty: firstly, the code tries to pass a ref on the cell to the cell's maintenance work item (which gets awkward if the work item is already queued); and, secondly, there's an overall cell manager that tries to use just one timer for the entire cell collection (to avoid having loads of timers). However, both of these are probably unnecessarily restrictive. To simplify this, the following changes are made: (1) The cell record collection manager is removed. Each cell record manages itself individually. (2) Each afs_cell is given a second work item (cell->destroyer) that is queued when its refcount reaches zero. This is not done in the context of the putting thread as it might be in an inconvenient place to sleep. (3) Each afs_cell is given its own timer. The timer is used to expire the cell record after a period of unuse if not otherwise pinned and can also be used for other maintenance tasks if necessary (of which there are currently none as DNS refresh is triggered by filesystem operations). (4) The afs_cell manager work item (cell->manager) is no longer given a ref on the cell when queued; rather, the manager must be deleted. This does away with the need to deal with the consequences of losing a race to queue cell->manager. Clean up of extra queuing is deferred to the destroyer. (5) The cell destroyer work item makes sure the cell timer is removed and that the normal cell work is cancelled before farming the actual destruction off to RCU. (6) When a network namespace is destroyed or the kafs module is unloaded, it's now a simple matter of marking the namespace as dead then just waking up all the cell work items. They will then remove and destroy themselves once all remaining activity counts and/or a ref counts are dropped. This makes sure that all server records are dropped first. (7) The cell record state set is reduced to just four states: SETTING_UP, ACTIVE, REMOVING and DEAD. The record persists in the active state even when it's not being used until the time comes to remove it rather than downgrading it to an inactive state from whence it can be restored. This means that the cell still appears in /proc and /afs when not in use until it switches to the REMOVING state - at which point it is removed. Note that the REMOVING state is included so that someone wanting to resurrect the cell record is forced to wait whilst the cell is torn down in that state. Once it's in the DEAD state, it has been removed from net->cells tree and is no longer findable and can be replaced.
Showing the changes to include/trace (1 of 7 files). Show all
Unified · Split
| @@ -131,7 +131,6 @@ enum yfs_cm_operation { · 130 unmodified lines | |||
| 131 | EM(afs_server_trace_destroy, "DESTROY ") \ | 131 | EM(afs_server_trace_destroy, "DESTROY ") \ |
| 132 | EM(afs_server_trace_free, "FREE ") \ | 132 | EM(afs_server_trace_free, "FREE ") \ |
| 133 | EM(afs_server_trace_gc, "GC ") \ | 133 | EM(afs_server_trace_gc, "GC ") \ |
| 134 | EM(afs_server_trace_get_install, "GET inst ") \ | ||
| 135 | EM(afs_server_trace_get_probe, "GET probe") \ | 134 | EM(afs_server_trace_get_probe, "GET probe") \ |
| 136 | EM(afs_server_trace_purging, "PURGE ") \ | 135 | EM(afs_server_trace_purging, "PURGE ") \ |
| 137 | EM(afs_server_trace_put_cbi, "PUT cbi ") \ | 136 | EM(afs_server_trace_put_cbi, "PUT cbi ") \ |
| @@ -149,6 +148,7 @@ enum yfs_cm_operation { · 11 unmodified lines | |||
| 149 | EM(afs_server_trace_use_cm_call, "USE cm-cl") \ | 148 | EM(afs_server_trace_use_cm_call, "USE cm-cl") \ |
| 150 | EM(afs_server_trace_use_get_caps, "USE gcaps") \ | 149 | EM(afs_server_trace_use_get_caps, "USE gcaps") \ |
| 151 | EM(afs_server_trace_use_give_up_cb, "USE gvupc") \ | 150 | EM(afs_server_trace_use_give_up_cb, "USE gvupc") \ |
| 151 | EM(afs_server_trace_use_install, "USE inst ") \ | ||
| 152 | E_(afs_server_trace_wait_create, "WAIT crt ") | 152 | E_(afs_server_trace_wait_create, "WAIT crt ") |
| 153 | 153 | ||
| 154 | #define afs_volume_traces \ | 154 | #define afs_volume_traces \ |
| @@ -171,37 +171,36 @@ enum yfs_cm_operation { · 16 unmodified lines | |||
| 171 | 171 | ||
| 172 | #define afs_cell_traces \ | 172 | #define afs_cell_traces \ |
| 173 | EM(afs_cell_trace_alloc, "ALLOC ") \ | 173 | EM(afs_cell_trace_alloc, "ALLOC ") \ |
| 174 | EM(afs_cell_trace_destroy, "DESTROY ") \ | ||
| 174 | EM(afs_cell_trace_free, "FREE ") \ | 175 | EM(afs_cell_trace_free, "FREE ") \ |
| 175 | EM(afs_cell_trace_get_atcell, "GET atcell") \ | 176 | EM(afs_cell_trace_get_atcell, "GET atcell") \ |
| 176 | EM(afs_cell_trace_get_queue_dns, "GET q-dns ") \ | ||
| 177 | EM(afs_cell_trace_get_queue_manage, "GET q-mng ") \ | ||
| 178 | EM(afs_cell_trace_get_queue_new, "GET q-new ") \ | ||
| 179 | EM(afs_cell_trace_get_server, "GET server") \ | 177 | EM(afs_cell_trace_get_server, "GET server") \ |
| 180 | EM(afs_cell_trace_get_vol, "GET vol ") \ | 178 | EM(afs_cell_trace_get_vol, "GET vol ") \ |
| 181 | EM(afs_cell_trace_insert, "INSERT ") \ | 179 | EM(afs_cell_trace_purge, "PURGE ") \ |
| 182 | EM(afs_cell_trace_manage, "MANAGE ") \ | ||
| 183 | EM(afs_cell_trace_put_atcell, "PUT atcell") \ | 180 | EM(afs_cell_trace_put_atcell, "PUT atcell") \ |
| 184 | EM(afs_cell_trace_put_candidate, "PUT candid") \ | 181 | EM(afs_cell_trace_put_candidate, "PUT candid") \ |
| 185 | EM(afs_cell_trace_put_destroy, "PUT destry") \ | 182 | EM(afs_cell_trace_put_final, "PUT final ") \ |
| 186 | EM(afs_cell_trace_put_queue_work, "PUT q-work") \ | ||
| 187 | EM(afs_cell_trace_put_queue_fail, "PUT q-fail") \ | ||
| 188 | EM(afs_cell_trace_put_server, "PUT server") \ | 183 | EM(afs_cell_trace_put_server, "PUT server") \ |
| 189 | EM(afs_cell_trace_put_vol, "PUT vol ") \ | 184 | EM(afs_cell_trace_put_vol, "PUT vol ") \ |
| 185 | EM(afs_cell_trace_queue_again, "QUE again ") \ | ||
| 186 | EM(afs_cell_trace_queue_dns, "QUE dns ") \ | ||
| 187 | EM(afs_cell_trace_queue_new, "QUE new ") \ | ||
| 188 | EM(afs_cell_trace_queue_purge, "QUE purge ") \ | ||
| 189 | EM(afs_cell_trace_manage, "MANAGE ") \ | ||
| 190 | EM(afs_cell_trace_managed, "MANAGED ") \ | ||
| 190 | EM(afs_cell_trace_see_source, "SEE source") \ | 191 | EM(afs_cell_trace_see_source, "SEE source") \ |
| 191 | EM(afs_cell_trace_see_ws, "SEE ws ") \ | 192 | EM(afs_cell_trace_see_mgmt_timer, "SEE mtimer") \ |
| 192 | EM(afs_cell_trace_unuse_alias, "UNU alias ") \ | 193 | EM(afs_cell_trace_unuse_alias, "UNU alias ") \ |
| 193 | EM(afs_cell_trace_unuse_check_alias, "UNU chk-al") \ | 194 | EM(afs_cell_trace_unuse_check_alias, "UNU chk-al") \ |
| 194 | EM(afs_cell_trace_unuse_delete, "UNU delete") \ | 195 | EM(afs_cell_trace_unuse_delete, "UNU delete") \ |
| 195 | EM(afs_cell_trace_unuse_dynroot_mntpt, "UNU dyn-mp") \ | 196 | EM(afs_cell_trace_unuse_dynroot_mntpt, "UNU dyn-mp") \ |
| 196 | EM(afs_cell_trace_unuse_fc, "UNU fc ") \ | 197 | EM(afs_cell_trace_unuse_fc, "UNU fc ") \ |
| 197 | EM(afs_cell_trace_unuse_lookup, "UNU lookup") \ | ||
| 198 | EM(afs_cell_trace_unuse_lookup_dynroot, "UNU lu-dyn") \ | 198 | EM(afs_cell_trace_unuse_lookup_dynroot, "UNU lu-dyn") \ |
| 199 | EM(afs_cell_trace_unuse_lookup_error, "UNU lu-err") \ | 199 | EM(afs_cell_trace_unuse_lookup_error, "UNU lu-err") \ |
| 200 | EM(afs_cell_trace_unuse_mntpt, "UNU mntpt ") \ | 200 | EM(afs_cell_trace_unuse_mntpt, "UNU mntpt ") \ |
| 201 | EM(afs_cell_trace_unuse_no_pin, "UNU no-pin") \ | 201 | EM(afs_cell_trace_unuse_no_pin, "UNU no-pin") \ |
| 202 | EM(afs_cell_trace_unuse_parse, "UNU parse ") \ | 202 | EM(afs_cell_trace_unuse_parse, "UNU parse ") \ |
| 203 | EM(afs_cell_trace_unuse_pin, "UNU pin ") \ | 203 | EM(afs_cell_trace_unuse_pin, "UNU pin ") \ |
| 204 | EM(afs_cell_trace_unuse_probe, "UNU probe ") \ | ||
| 205 | EM(afs_cell_trace_unuse_sbi, "UNU sbi ") \ | 204 | EM(afs_cell_trace_unuse_sbi, "UNU sbi ") \ |
| 206 | EM(afs_cell_trace_unuse_ws, "UNU ws ") \ | 205 | EM(afs_cell_trace_unuse_ws, "UNU ws ") \ |
| 207 | EM(afs_cell_trace_use_alias, "USE alias ") \ | 206 | EM(afs_cell_trace_use_alias, "USE alias ") \ |