Skip to content

Commit 1f0fc33

Browse files
dhowellskuba-moo
authored andcommitted
afs: Give an afs_server object a ref on the afs_cell object it points to
Give an afs_server object a ref on the afs_cell object it points to so that the cell doesn't get deleted before the server record. Whilst this is circular (cell -> vol -> server_list -> server -> cell), the ref only pins the memory, not the lifetime as that's controlled by the activity counter. When the volume's activity counter reaches 0, it detaches from the cell and discards its server list; when a cell's activity counter reaches 0, it discards its root volume. At that point, the circularity is cut. Fixes: d2ddc77 ("afs: Overhaul volume and server record caching and fileserver rotation") Signed-off-by: David Howells <[email protected]> cc: Marc Dionne <[email protected]> cc: Simon Horman <[email protected]> cc: [email protected] Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent add117e commit 1f0fc33

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

fs/afs/server.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,8 @@ static struct afs_server *afs_install_server(struct afs_cell *cell,
163163
rb_insert_color(&server->uuid_rb, &net->fs_servers);
164164
hlist_add_head_rcu(&server->proc_link, &net->fs_proc);
165165

166+
afs_get_cell(cell, afs_cell_trace_get_server);
167+
166168
added_dup:
167169
write_seqlock(&net->fs_addr_lock);
168170
estate = rcu_dereference_protected(server->endpoint_state,
@@ -442,6 +444,7 @@ static void afs_server_rcu(struct rcu_head *rcu)
442444
atomic_read(&server->active), afs_server_trace_free);
443445
afs_put_endpoint_state(rcu_access_pointer(server->endpoint_state),
444446
afs_estate_trace_put_server);
447+
afs_put_cell(server->cell, afs_cell_trace_put_server);
445448
kfree(server);
446449
}
447450

include/trace/events/afs.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ enum yfs_cm_operation {
174174
EM(afs_cell_trace_get_queue_dns, "GET q-dns ") \
175175
EM(afs_cell_trace_get_queue_manage, "GET q-mng ") \
176176
EM(afs_cell_trace_get_queue_new, "GET q-new ") \
177+
EM(afs_cell_trace_get_server, "GET server") \
177178
EM(afs_cell_trace_get_vol, "GET vol ") \
178179
EM(afs_cell_trace_insert, "INSERT ") \
179180
EM(afs_cell_trace_manage, "MANAGE ") \
@@ -182,6 +183,7 @@ enum yfs_cm_operation {
182183
EM(afs_cell_trace_put_destroy, "PUT destry") \
183184
EM(afs_cell_trace_put_queue_work, "PUT q-work") \
184185
EM(afs_cell_trace_put_queue_fail, "PUT q-fail") \
186+
EM(afs_cell_trace_put_server, "PUT server") \
185187
EM(afs_cell_trace_put_vol, "PUT vol ") \
186188
EM(afs_cell_trace_see_source, "SEE source") \
187189
EM(afs_cell_trace_see_ws, "SEE ws ") \

0 commit comments

Comments
 (0)