From 9ed900b1160ef306bc74ad0228d7ab199234c758 Mon Sep 17 00:00:00 2001 From: David Howells Date: Thu, 2 Nov 2017 15:27:46 +0000 Subject: afs: Push the net ns pointer to more places Push the network namespace pointer to more places in AFS, including the afs_server structure (which doesn't hold a ref on the netns). In particular, afs_put_cell() now takes requires a net ns parameter so that it can safely alter the netns after decrementing the cell usage count - the cell will be deallocated by a background thread after being cached for a period, which means that it's not safe to access it after reducing its usage count. Signed-off-by: David Howells --- fs/afs/cell.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'fs/afs/cell.c') diff --git a/fs/afs/cell.c b/fs/afs/cell.c index bd570fa539a0..2224e335eed7 100644 --- a/fs/afs/cell.c +++ b/fs/afs/cell.c @@ -251,7 +251,7 @@ int afs_cell_init(struct afs_net *net, char *rootcell) old_root = net->ws_cell; net->ws_cell = new_root; write_unlock(&net->cells_lock); - afs_put_cell(old_root); + afs_put_cell(net, old_root); _leave(" = 0"); return 0; @@ -336,7 +336,7 @@ struct afs_cell *afs_get_cell_maybe(struct afs_cell *cell) /* * destroy a cell record */ -void afs_put_cell(struct afs_cell *cell) +void afs_put_cell(struct afs_net *net, struct afs_cell *cell) { if (!cell) return; @@ -347,10 +347,10 @@ void afs_put_cell(struct afs_cell *cell) /* to prevent a race, the decrement and the dequeue must be effectively * atomic */ - write_lock(&cell->net->cells_lock); + write_lock(&net->cells_lock); if (likely(!atomic_dec_and_test(&cell->usage))) { - write_unlock(&cell->net->cells_lock); + write_unlock(&net->cells_lock); _leave(""); return; } @@ -358,9 +358,9 @@ void afs_put_cell(struct afs_cell *cell) ASSERT(list_empty(&cell->servers)); ASSERT(list_empty(&cell->vl_list)); - wake_up(&cell->net->cells_freeable_wq); + wake_up(&net->cells_freeable_wq); - write_unlock(&cell->net->cells_lock); + write_unlock(&net->cells_lock); _leave(" [unused]"); } @@ -424,7 +424,7 @@ void afs_cell_purge(struct afs_net *net) _enter(""); - afs_put_cell(net->ws_cell); + afs_put_cell(net, net->ws_cell); down_write(&net->cells_sem); -- cgit v1.2.3