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 <dhowells@redhat.com>
This commit is contained in:
David Howells
2017-11-02 15:27:46 +00:00
rodzic 49566f6f06
commit 9ed900b116
11 zmienionych plików z 56 dodań i 56 usunięć

Wyświetl plik

@@ -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);