[AF_RXRPC]: Add an interface to the AF_RXRPC module for the AFS filesystem to use
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / fs / afs / server.h
blobe1a006829b5df2e92719e0e8b900e4f0dbe9780a
1 /* 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 AFS_SERVER_H
13 #define AFS_SERVER_H
15 #include "types.h"
16 #include "kafstimod.h"
17 #include <rxrpc/peer.h>
18 #include <linux/rwsem.h>
20 extern spinlock_t afs_server_peer_lock;
23 * AFS server record
25 struct afs_server {
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 */
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 */
46 /* callback promise management */
47 struct list_head cb_promises; /* as yet unbroken promises from this server */
48 spinlock_t cb_lock; /* access lock */
51 extern int afs_server_lookup(struct afs_cell *, const struct in_addr *,
52 struct afs_server **);
54 #define afs_get_server(S) do { atomic_inc(&(S)->usage); } while(0)
56 extern void afs_put_server(struct afs_server *);
57 extern void afs_server_do_timeout(struct afs_server *);
59 extern int afs_server_find_by_peer(const struct rxrpc_peer *,
60 struct afs_server **);
62 extern int afs_server_get_vlconn(struct afs_server *,
63 struct rxrpc_connection **);
65 static inline
66 struct afs_server *afs_server_get_from_peer(struct rxrpc_peer *peer)
68 struct afs_server *server;
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);
76 return server;
80 * AFS server callslot grant record
82 struct afs_server_callslot {
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 */
91 extern int afs_server_request_callslot(struct afs_server *,
92 struct afs_server_callslot *);
94 extern void afs_server_release_callslot(struct afs_server *,
95 struct afs_server_callslot *);
97 #endif /* AFS_SERVER_H */