1 /* server.h: AFS server record
3 * Copyright (C) 2002 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
12 #ifndef _LINUX_AFS_SERVER_H
13 #define _LINUX_AFS_SERVER_H
16 #include "kafstimod.h"
17 #include <rxrpc/peer.h>
18 #include <linux/rwsem.h>
20 extern spinlock_t afs_server_peer_lock;
22 /*****************************************************************************/
29 struct afs_cell *cell; /* cell in which server resides */
30 struct list_head link; /* link in cell's server list */
31 struct rw_semaphore sem; /* access lock */
32 struct afs_timer timeout; /* graveyard timeout */
33 struct in_addr addr; /* server address */
34 struct rxrpc_peer *peer; /* peer record for this server */
35 struct rxrpc_connection *vlserver; /* connection to the volume location service */
37 /* file service access */
38 #define AFS_SERVER_CONN_LIST_SIZE 2
39 struct rxrpc_connection *fs_conn[AFS_SERVER_CONN_LIST_SIZE]; /* FS connections */
40 unsigned fs_conn_cnt[AFS_SERVER_CONN_LIST_SIZE]; /* per conn call count */
41 struct list_head fs_callq; /* queue of processes waiting to make a call */
42 spinlock_t fs_lock; /* access lock */
43 int fs_state; /* 0 or reason FS currently marked dead (-errno) */
44 unsigned fs_rtt; /* FS round trip time */
45 unsigned long fs_act_jif; /* time at which last activity occurred */
46 unsigned long fs_dead_jif; /* time at which no longer to be considered dead */
48 /* callback promise management */
49 struct list_head cb_promises; /* as yet unbroken promises from this server */
50 spinlock_t cb_lock; /* access lock */
53 extern int afs_server_lookup(struct afs_cell *cell,
54 const struct in_addr *addr,
55 struct afs_server **_server);
57 #define afs_get_server(S) do { atomic_inc(&(S)->usage); } while(0)
59 extern void afs_put_server(struct afs_server *server);
60 extern void afs_server_do_timeout(struct afs_server *server);
62 extern int afs_server_find_by_peer(const struct rxrpc_peer *peer,
63 struct afs_server **_server);
65 extern int afs_server_get_vlconn(struct afs_server *server,
66 struct rxrpc_connection **_conn);
69 struct afs_server *afs_server_get_from_peer(struct rxrpc_peer *peer)
71 struct afs_server *server;
73 spin_lock(&afs_server_peer_lock);
76 afs_get_server(server);
77 spin_unlock(&afs_server_peer_lock);
82 /*****************************************************************************/
84 * AFS server callslot grant record
86 struct afs_server_callslot
88 struct list_head link; /* link in server's list */
89 struct task_struct *task; /* process waiting to make call */
90 struct rxrpc_connection *conn; /* connection to use (or NULL on error) */
91 short nconn; /* connection slot number (-1 on error) */
92 char ready; /* T when ready */
93 int errno; /* error number if nconn==-1 */
96 extern int afs_server_request_callslot(struct afs_server *server,
97 struct afs_server_callslot *callslot);
99 extern void afs_server_release_callslot(struct afs_server *server,
100 struct afs_server_callslot *callslot);
102 #endif /* _LINUX_AFS_SERVER_H */