]>
Commit | Line | Data |
---|---|---|
ec26815a | 1 | /* AFS server record |
1da177e4 LT |
2 | * |
3 | * Copyright (C) 2002 Red Hat, Inc. All Rights Reserved. | |
4 | * Written by David Howells ([email protected]) | |
5 | * | |
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. | |
10 | */ | |
11 | ||
ec26815a DH |
12 | #ifndef AFS_SERVER_H |
13 | #define AFS_SERVER_H | |
1da177e4 LT |
14 | |
15 | #include "types.h" | |
16 | #include "kafstimod.h" | |
17 | #include <rxrpc/peer.h> | |
18 | #include <linux/rwsem.h> | |
19 | ||
20 | extern spinlock_t afs_server_peer_lock; | |
21 | ||
1da177e4 LT |
22 | /* |
23 | * AFS server record | |
24 | */ | |
ec26815a | 25 | struct afs_server { |
1da177e4 LT |
26 | atomic_t usage; |
27 | struct afs_cell *cell; /* cell in which server resides */ | |
28 | struct list_head link; /* link in cell's server list */ | |
29 | struct rw_semaphore sem; /* access lock */ | |
30 | struct afs_timer timeout; /* graveyard timeout */ | |
31 | struct in_addr addr; /* server address */ | |
32 | struct rxrpc_peer *peer; /* peer record for this server */ | |
33 | struct rxrpc_connection *vlserver; /* connection to the volume location service */ | |
34 | ||
35 | /* file service access */ | |
36 | #define AFS_SERVER_CONN_LIST_SIZE 2 | |
37 | struct rxrpc_connection *fs_conn[AFS_SERVER_CONN_LIST_SIZE]; /* FS connections */ | |
38 | unsigned fs_conn_cnt[AFS_SERVER_CONN_LIST_SIZE]; /* per conn call count */ | |
39 | struct list_head fs_callq; /* queue of processes waiting to make a call */ | |
40 | spinlock_t fs_lock; /* access lock */ | |
41 | int fs_state; /* 0 or reason FS currently marked dead (-errno) */ | |
42 | unsigned fs_rtt; /* FS round trip time */ | |
43 | unsigned long fs_act_jif; /* time at which last activity occurred */ | |
44 | unsigned long fs_dead_jif; /* time at which no longer to be considered dead */ | |
45 | ||
46 | /* callback promise management */ | |
47 | struct list_head cb_promises; /* as yet unbroken promises from this server */ | |
48 | spinlock_t cb_lock; /* access lock */ | |
49 | }; | |
50 | ||
ec26815a DH |
51 | extern int afs_server_lookup(struct afs_cell *, const struct in_addr *, |
52 | struct afs_server **); | |
1da177e4 LT |
53 | |
54 | #define afs_get_server(S) do { atomic_inc(&(S)->usage); } while(0) | |
55 | ||
ec26815a DH |
56 | extern void afs_put_server(struct afs_server *); |
57 | extern void afs_server_do_timeout(struct afs_server *); | |
1da177e4 | 58 | |
ec26815a DH |
59 | extern int afs_server_find_by_peer(const struct rxrpc_peer *, |
60 | struct afs_server **); | |
1da177e4 | 61 | |
ec26815a DH |
62 | extern int afs_server_get_vlconn(struct afs_server *, |
63 | struct rxrpc_connection **); | |
1da177e4 LT |
64 | |
65 | static inline | |
66 | struct afs_server *afs_server_get_from_peer(struct rxrpc_peer *peer) | |
67 | { | |
68 | struct afs_server *server; | |
69 | ||
70 | spin_lock(&afs_server_peer_lock); | |
71 | server = peer->user; | |
72 | if (server) | |
73 | afs_get_server(server); | |
74 | spin_unlock(&afs_server_peer_lock); | |
75 | ||
76 | return server; | |
77 | } | |
78 | ||
1da177e4 LT |
79 | /* |
80 | * AFS server callslot grant record | |
81 | */ | |
ec26815a | 82 | struct afs_server_callslot { |
1da177e4 LT |
83 | struct list_head link; /* link in server's list */ |
84 | struct task_struct *task; /* process waiting to make call */ | |
85 | struct rxrpc_connection *conn; /* connection to use (or NULL on error) */ | |
86 | short nconn; /* connection slot number (-1 on error) */ | |
87 | char ready; /* T when ready */ | |
88 | int errno; /* error number if nconn==-1 */ | |
89 | }; | |
90 | ||
ec26815a DH |
91 | extern int afs_server_request_callslot(struct afs_server *, |
92 | struct afs_server_callslot *); | |
1da177e4 | 93 | |
ec26815a DH |
94 | extern void afs_server_release_callslot(struct afs_server *, |
95 | struct afs_server_callslot *); | |
1da177e4 | 96 | |
ec26815a | 97 | #endif /* AFS_SERVER_H */ |