summaryrefslogtreecommitdiff
path: root/fs/afs/cell.c
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2017-11-02 15:27:46 +0000
committerDavid Howells <dhowells@redhat.com>2017-11-13 15:38:17 +0000
commit9ed900b1160ef306bc74ad0228d7ab199234c758 (patch)
treef2e3ed236dce6980e51e8216e9e06ffbf9c1d989 /fs/afs/cell.c
parent49566f6f06b38d7c1a5c7eacc8a38c6ea2e36549 (diff)
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>
Diffstat (limited to 'fs/afs/cell.c')
-rw-r--r--fs/afs/cell.c14
1 files changed, 7 insertions, 7 deletions
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);