nfs-ganesha 1.4
|
00001 /* 00002 * vim:expandtab:shiftwidth=8:tabstop=8: 00003 * 00004 * Copyright (C) 2012, The Linux Box Corporation 00005 * Contributor : Matt Benjamin <matt@linuxbox.com> 00006 * 00007 * Some portions Copyright CEA/DAM/DIF (2008) 00008 * contributeur : Philippe DENIEL philippe.deniel@cea.fr 00009 * Thomas LEIBOVICI thomas.leibovici@cea.fr 00010 * 00011 * 00012 * This program is free software; you can redistribute it and/or 00013 * modify it under the terms of the GNU Lesser General Public 00014 * License as published by the Free Software Foundation; either 00015 * version 3 of the License, or (at your option) any later version. 00016 * 00017 * This program is distributed in the hope that it will be useful, 00018 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00019 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00020 * Lesser General Public License for more details. 00021 * 00022 * You should have received a copy of the GNU Lesser General Public 00023 * License along with this library; if not, write to the Free Software 00024 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00025 * 00026 * ------------- 00027 */ 00028 00029 #ifndef _NFS_RPC_CALLBACK_H 00030 #define _NFS_RPC_CALLBACK_H 00031 00032 #ifdef HAVE_CONFIG_H 00033 #include "config.h" 00034 #endif /* HAVE_CONFIG_H */ 00035 00036 #ifdef _SOLARIS 00037 #include "solaris_port.h" 00038 #endif /* _SOLARIS */ 00039 00040 #include "log.h" 00041 #include "cache_inode.h" 00042 00056 /* XXX move? */ 00057 typedef struct nfs4_cb_tag 00058 { 00059 int32_t ix; 00060 char *val; 00061 int32_t len; 00062 } nfs4_cb_tag_t; 00063 00064 /* CB compound tags */ 00065 #define NFS4_CB_TAG_DEFAULT 0 00066 00067 void cb_compound_init_v4(nfs4_compound_t *cbt, uint32_t n_ops, uint32_t ident, 00068 char *tag, uint32_t tag_len); 00069 00070 void cb_compound_add_op(nfs4_compound_t *cbt, nfs_cb_argop4 *src); 00071 00072 void cb_compound_free(nfs4_compound_t *cbt); 00073 00074 #define NFS_CB_FLAG_NONE 0x0000 00075 #define NFS_RPC_FLAG_NONE 0x0000 00076 00077 enum nfs_cb_call_states{ 00078 NFS_CB_CALL_NONE, 00079 NFS_CB_CALL_QUEUED, 00080 NFS_CB_CALL_DISPATCH, 00081 NFS_CB_CALL_FINISHED, 00082 NFS_CB_CALL_ABORTED, 00083 NFS_CB_CALL_TIMEDOUT 00084 }; 00085 00086 static inline void init_wait_entry(wait_entry_t *we) 00087 { 00088 pthread_mutex_init(&we->mtx, NULL); 00089 pthread_cond_init(&we->cv, NULL); 00090 } 00091 00092 rpc_call_t *alloc_rpc_call(); 00093 void free_rpc_call(rpc_call_t *call); 00094 00095 static inline nfs_cb_argop4 * alloc_cb_argop(uint32_t cnt) 00096 { 00097 return (gsh_calloc(cnt, sizeof(nfs_cb_argop4))); 00098 } 00099 00100 static inline nfs_cb_resop4 * alloc_cb_resop(uint32_t cnt) 00101 { 00102 return (gsh_calloc(cnt, sizeof(nfs_cb_resop4))); 00103 } 00104 00105 static inline void free_cb_argop(nfs_cb_argop4 *ptr) 00106 { 00107 gsh_free(ptr); 00108 } 00109 00110 static inline void free_cb_resop(nfs_cb_resop4 *ptr) 00111 { 00112 gsh_free(ptr); 00113 } 00114 00115 rpc_call_channel_t *nfs_rpc_get_chan(nfs_client_id_t *pclientid, 00116 uint32_t flags); 00117 00118 enum clnt_stat rpc_cb_null(rpc_call_channel_t *chan, 00119 struct timeval timeout); 00120 00121 static inline void nfs_rpc_init_call(void *ptr, void *parameters) 00122 { 00123 rpc_call_t *call = (rpc_call_t *) ptr; 00124 memset(call, 0, sizeof(rpc_call_t)); 00125 init_wait_entry(&call->we); 00126 } 00127 00128 void nfs_rpc_cb_pkginit(void); 00129 void nfs_rpc_cb_pkgshutdown(void); 00130 00131 /* Create a channel for a new clientid (v4) or session, optionally 00132 * connecting it */ 00133 int nfs_rpc_create_chan_v40(nfs_client_id_t *pclientid, 00134 uint32_t flags); 00135 00136 #if defined (USE_NFS4_1) 00137 /* Create a channel for a new clientid (v4) or session, optionally 00138 * connecting it */ 00139 int nfs_rpc_create_chan_v41(nfs41_session_t *session, 00140 uint32_t flags); 00141 #endif 00142 00143 /* Dispose a channel. */ 00144 void nfs_rpc_destroy_chan(rpc_call_channel_t *chan); 00145 00146 int 00147 nfs_rpc_call_init(rpc_call_t call, uint32_t flags); 00148 00149 #define NFS_RPC_CALL_NONE 0x0000 00150 #define NFS_RPC_CALL_INLINE 0x0001 /* execute in current thread ctxt */ 00151 #define NFS_RPC_CALL_BROADCAST 0x0002 00152 00153 /* Submit rpc to be called on chan, optionally waiting for completion. */ 00154 int32_t nfs_rpc_submit_call(rpc_call_t *call, uint32_t flags); 00155 00156 /* Dispatch method to process a (queued) call */ 00157 int32_t nfs_rpc_dispatch_call(rpc_call_t *call, uint32_t flags); 00158 00159 #endif /* _NFS_RPC_CALLBACK_H */