Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* server.h: AFS server record |
| 2 | * |
| 3 | * Copyright (C) 2002 Red Hat, Inc. All Rights Reserved. |
| 4 | * Written by David Howells (dhowells@redhat.com) |
| 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 | |
| 12 | #ifndef _LINUX_AFS_SERVER_H |
| 13 | #define _LINUX_AFS_SERVER_H |
| 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 | |
| 22 | /*****************************************************************************/ |
| 23 | /* |
| 24 | * AFS server record |
| 25 | */ |
| 26 | struct afs_server |
| 27 | { |
| 28 | atomic_t usage; |
| 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 */ |
| 36 | |
| 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 */ |
| 47 | |
| 48 | /* callback promise management */ |
| 49 | struct list_head cb_promises; /* as yet unbroken promises from this server */ |
| 50 | spinlock_t cb_lock; /* access lock */ |
| 51 | }; |
| 52 | |
| 53 | extern int afs_server_lookup(struct afs_cell *cell, |
| 54 | const struct in_addr *addr, |
| 55 | struct afs_server **_server); |
| 56 | |
| 57 | #define afs_get_server(S) do { atomic_inc(&(S)->usage); } while(0) |
| 58 | |
| 59 | extern void afs_put_server(struct afs_server *server); |
| 60 | extern void afs_server_do_timeout(struct afs_server *server); |
| 61 | |
| 62 | extern int afs_server_find_by_peer(const struct rxrpc_peer *peer, |
| 63 | struct afs_server **_server); |
| 64 | |
| 65 | extern int afs_server_get_vlconn(struct afs_server *server, |
| 66 | struct rxrpc_connection **_conn); |
| 67 | |
| 68 | static inline |
| 69 | struct afs_server *afs_server_get_from_peer(struct rxrpc_peer *peer) |
| 70 | { |
| 71 | struct afs_server *server; |
| 72 | |
| 73 | spin_lock(&afs_server_peer_lock); |
| 74 | server = peer->user; |
| 75 | if (server) |
| 76 | afs_get_server(server); |
| 77 | spin_unlock(&afs_server_peer_lock); |
| 78 | |
| 79 | return server; |
| 80 | } |
| 81 | |
| 82 | /*****************************************************************************/ |
| 83 | /* |
| 84 | * AFS server callslot grant record |
| 85 | */ |
| 86 | struct afs_server_callslot |
| 87 | { |
| 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 */ |
| 94 | }; |
| 95 | |
| 96 | extern int afs_server_request_callslot(struct afs_server *server, |
| 97 | struct afs_server_callslot *callslot); |
| 98 | |
| 99 | extern void afs_server_release_callslot(struct afs_server *server, |
| 100 | struct afs_server_callslot *callslot); |
| 101 | |
| 102 | #endif /* _LINUX_AFS_SERVER_H */ |