server.h 3.4 KB

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