12 #include <linux/sched.h>
13 #include <linux/slab.h>
16 static unsigned afs_server_timeout = 10;
32 static int afs_install_server(
struct afs_server *server)
47 _debug(
"- consider %p", p);
49 if (server->
addr.s_addr < xserver->
addr.s_addr)
51 else if (server->
addr.s_addr > xserver->
addr.s_addr)
81 INIT_LIST_HEAD(&server->
link);
82 INIT_LIST_HEAD(&server->
grave);
116 goto found_server_quickly;
120 candidate = afs_alloc_server(cell, addr);
136 if (afs_install_server(server) < 0)
137 goto server_in_two_cells;
147 found_server_quickly:
152 if (!list_empty(&server->
grave)) {
153 spin_lock(&afs_server_graveyard_lock);
154 list_del_init(&server->
grave);
155 spin_unlock(&afs_server_graveyard_lock);
166 goto no_longer_unused;
195 _debug(
"- consider %p", p);
199 }
else if (addr.
s_addr > server->
addr.s_addr) {
237 spin_lock(&afs_server_graveyard_lock);
239 list_move_tail(&server->
grave, &afs_server_graveyard);
242 afs_server_timeout *
HZ);
244 spin_unlock(&afs_server_graveyard_lock);
251 static void afs_destroy_server(
struct afs_server *server)
274 unsigned long delay, expiry;
278 spin_lock(&afs_server_graveyard_lock);
280 while (!list_empty(&afs_server_graveyard)) {
281 server =
list_entry(afs_server_graveyard.next,
287 delay = (expiry - now) *
HZ;
295 list_del_init(&server->
grave);
297 list_move_tail(&server->
grave, &corpses);
298 list_del_init(&server->
link);
305 spin_unlock(&afs_server_graveyard_lock);
308 while (!list_empty(&corpses)) {
311 afs_destroy_server(server);
320 afs_server_timeout = 0;